From 5d5c575139b96f42c6dd40e89bd48752de98ace0 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Tue, 17 Dec 2019 15:37:54 -0800 Subject: [PATCH] exchange: add a config to stop writing local bookmarks Summary: This is part of the logic of remotenames. Unfortunately our production setup has some really annoying legacy code in multiple places that disables remotenames and do `rm .hg/bookmarks` manually. They should really enable remotenames and get rid of `rm .hg/bookmarks`. However that has complications. With recent changes, `.hg/bookmarks` is moved to `.hg/store/bookmarks` and later moved to `metalog`. That caused 10k+ bookmarks left in local bookmarks after clone (or pull). Writing remote bookmarks as local bookmarks makes no sense in modern setup. Therefore this diff adds a config option to disable such feature. The ideal state is the bookmark logic in exchange writes remotenames directly, instead of silently ignoring it. But that's a risky and larger change. My expectation is, the remotenames extension will be enabled and take care of the rest. The idea of not writing local bookmarks come from markbt. Reviewed By: DurhamG Differential Revision: D19148278 fbshipit-source-id: a03eac68378908586d6e6848ed43532c0aab06c3 --- eden/scm/edenscm/mercurial/configitems.py | 1 + eden/scm/edenscm/mercurial/exchange.py | 5 +++++ eden/scm/edenscm/mercurial/helptext.py | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/eden/scm/edenscm/mercurial/configitems.py b/eden/scm/edenscm/mercurial/configitems.py index 85cadaa030..df1e27041c 100644 --- a/eden/scm/edenscm/mercurial/configitems.py +++ b/eden/scm/edenscm/mercurial/configitems.py @@ -503,6 +503,7 @@ coreconfigitem("ui", "quietbookmarkmove", default=False) coreconfigitem("ui", "remotecmd", default="hg") coreconfigitem("ui", "report_untrusted", default=True) coreconfigitem("ui", "rollback", default=True) +coreconfigitem("ui", "skip-local-bookmarks-on-pull", default=False) coreconfigitem("ui", "slash", default=False) coreconfigitem("ui", "ssh", default="ssh") coreconfigitem("ui", "ssherrorhint", default=None) diff --git a/eden/scm/edenscm/mercurial/exchange.py b/eden/scm/edenscm/mercurial/exchange.py index 5c75322301..17f0bcbfe6 100644 --- a/eden/scm/edenscm/mercurial/exchange.py +++ b/eden/scm/edenscm/mercurial/exchange.py @@ -1704,6 +1704,11 @@ def _pullbookmarks(pullop): return pullop.stepsdone.add("bookmarks") repo = pullop.repo + ui = repo.ui + # XXX: Ideally we update remotenames right here to avoid race + # conditions. See racy-pull-on-push in remotenames.py. + if ui.configbool("ui", "skip-local-bookmarks-on-pull"): + return remotebookmarks = pullop.remotebookmarks bookmod.updatefromremote( repo.ui, diff --git a/eden/scm/edenscm/mercurial/helptext.py b/eden/scm/edenscm/mercurial/helptext.py index a393a2f194..162890566c 100644 --- a/eden/scm/edenscm/mercurial/helptext.py +++ b/eden/scm/edenscm/mercurial/helptext.py @@ -2519,6 +2519,10 @@ User interface controls. Remote command to use for clone/push/pull operations. (default: ``hg``) +``skip-local-bookmarks-on-pull`` + Do not write local bookmarks on pull or clone. + Turn on the ``remotenames`` extension to get remote bookmarks. + ``slash`` (Deprecated. Use ``slashpath`` template filter instead.)