changeset 48244:b56858d85a7b

bookmarks: add a `ignore` variant of the bookmark mode This new mode allow to disable bookmark exchange with some path (or all path). Differential Revision: https://phab.mercurial-scm.org/D11677
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 15 Oct 2021 04:41:24 +0200
parents 76c071bba40d
children 2f7caef017d9
files mercurial/bookmarks.py mercurial/helptext/config.txt mercurial/utils/urlutil.py rust/Cargo.lock tests/test-bookmarks-pushpull.t tests/test-help.t
diffstat 6 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Fri Oct 15 04:25:58 2021 +0200
+++ b/mercurial/bookmarks.py	Fri Oct 15 04:41:24 2021 +0200
@@ -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:
--- a/mercurial/helptext/config.txt	Fri Oct 15 04:25:58 2021 +0200
+++ b/mercurial/helptext/config.txt	Fri Oct 15 04:41:24 2021 +0200
@@ -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``
--- a/mercurial/utils/urlutil.py	Fri Oct 15 04:25:58 2021 +0200
+++ b/mercurial/utils/urlutil.py	Fri Oct 15 04:41:24 2021 +0200
@@ -769,6 +769,7 @@
 SUPPORTED_BOOKMARKS_MODES = {
     b'default',
     b'mirror',
+    b'ignore',
 }
 
 
--- a/rust/Cargo.lock	Fri Oct 15 04:25:58 2021 +0200
+++ b/rust/Cargo.lock	Fri Oct 15 04:41:24 2021 +0200
@@ -1,7 +1,5 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-version = 3
-
 [[package]]
 name = "adler"
 version = "0.2.3"
--- a/tests/test-bookmarks-pushpull.t	Fri Oct 15 04:25:58 2021 +0200
+++ b/tests/test-bookmarks-pushpull.t	Fri Oct 15 04:41:24 2021 +0200
@@ -523,6 +523,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
--- a/tests/test-help.t	Fri Oct 15 04:25:58 2021 +0200
+++ b/tests/test-help.t	Fri Oct 15 04:41:24 2021 +0200
@@ -1908,6 +1908,8 @@
           "merged" on push/pull.
         - "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: