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
This commit is contained in:
Jun Wu 2019-12-17 15:37:54 -08:00 committed by Facebook Github Bot
parent ff41e331e0
commit 5d5c575139
3 changed files with 10 additions and 0 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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.)