Patchwork D11677: bookmarks: add a `ignore` variant of the bookmark mode

login
register
mail settings
Submitter phabricator
Date Oct. 15, 2021, 8:20 a.m.
Message ID <differential-rev-PHID-DREV-bvh4oskzsp33gi2y5qp5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50000/
State Superseded
Headers show

Comments

phabricator - Oct. 15, 2021, 8:20 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This new mode allow to disable bookmark exchange with some path (or all path).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11677

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/helptext/config.txt
  mercurial/utils/urlutil.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -517,6 +517,21 @@ 
      X@foo                     000000000000 removed
      foo                       000000000000 removed
      foobar                    000000000000 removed
+  $ hg incoming --bookmark  -v ../a --config 'paths.*:bookmarks.mode=ignore'
+  comparing with ../a
+  bookmarks exchange disabled with this path
+  $ hg pull ../a --config 'paths.*:bookmarks.mode=ignore'
+  pulling from ../a
+  searching for changes
+  no changes found
+  $ hg book
+     @                         1:9b140be10808
+     @foo                      2:0d2164f0ce0d
+     X@foo                     2:0d2164f0ce0d
+     Y                         0:4e3505fd9583
+     Z                         2:0d2164f0ce0d
+     foo                       -1:000000000000
+   * foobar                    1:9b140be10808
   $ hg pull ../a --config 'paths.*:bookmarks.mode=mirror'
   pulling from ../a
   searching for changes
diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -769,6 +769,7 @@ 
 KNOW_BOOKMARKS_MODE = {
     b'default',
     b'mirror',
+    b'ignore',
 }
 
 
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -1757,6 +1757,9 @@ 
   - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
     is useful to replicate a repository, or as an optimization.
 
+  - ``ignore``: ignore bookmarks during exchange.
+    (This currently only affect pulling)
+
 The following special named paths exist:
 
 ``default``
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -775,6 +775,9 @@ 
 def updatefromremote(
     ui, repo, remotemarks, path, trfunc, explicit=(), mode=None
 ):
+    if mode == b'ignore':
+        # This should move to an higher level to avoid fetching bookmark at all
+        return
     ui.debug(b"checking for updated bookmarks\n")
     if mode == b'mirror':
         changed = mirroring_remote(ui, repo, remotemarks)
@@ -793,6 +796,9 @@ 
 
 def incoming(ui, repo, peer, mode=None):
     """Show bookmarks incoming from other to repo"""
+    if mode == b'ignore':
+        ui.status(_(b"bookmarks exchange disabled with this path\n"))
+        return 0
     ui.status(_(b"searching for changed bookmarks\n"))
 
     with peer.commandexecutor() as e: