[PATCH STABLE] bookmarks: clone non-divergent bookmarks with @ in them

Kevin Bullock kbullock+mercurial at ringworld.org
Thu Mar 22 13:57:17 CDT 2012


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1332365978 18000
# Node ID 227f1026222ed94d52c6bbcde9009f6a162a906e
# Parent  63a1bed65fa32262a45136a583fb6af117215241
bookmarks: clone non-divergent bookmarks with @ in them

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -169,7 +169,7 @@ def listbookmarks(repo):
     d = {}
     for k, v in marks.iteritems():
         # don't expose local divergent bookmarks
-        if '@' not in k and not k.endswith('@'):
+        if '@' not in k or k.endswith('@'):
             d[k] = hex(v)
     return d
 
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -356,7 +356,7 @@ def clone(ui, peeropts, source, dest=Non
         if dircleanup:
             dircleanup.close()
 
-        # clone all bookmarks
+        # clone all bookmarks except divergent ones
         if destrepo.local() and srcrepo.capable("pushkey"):
             rb = srcrepo.listkeys('bookmarks')
             for k, n in rb.iteritems():
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -269,18 +269,24 @@ test rollback
 
 test clone
 
+  $ hg bookmark -r 2 -i @
+  $ hg bookmark -r 2 -i a@
   $ hg bookmarks
+     @                         2:db815d6d32e6
      X2                        1:925d80f479bb
      Y                         2:db815d6d32e6
    * Z                         2:db815d6d32e6
+     a@                        2:db815d6d32e6
      x  y                      2:db815d6d32e6
   $ hg clone . cloned-bookmarks
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg -R cloned-bookmarks bookmarks
+     @                         2:db815d6d32e6
      X2                        1:925d80f479bb
      Y                         2:db815d6d32e6
      Z                         2:db815d6d32e6
+     a@                        2:db815d6d32e6
      x  y                      2:db815d6d32e6
 
 test clone with pull protocol
@@ -294,11 +300,16 @@ test clone with pull protocol
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg -R cloned-bookmarks-pull bookmarks
+     @                         2:db815d6d32e6
      X2                        1:925d80f479bb
      Y                         2:db815d6d32e6
      Z                         2:db815d6d32e6
+     a@                        2:db815d6d32e6
      x  y                      2:db815d6d32e6
 
+  $ hg bookmark -d @
+  $ hg bookmark -d a@
+
 test clone with a specific revision
 
   $ hg clone -r 925d80 . cloned-bookmarks-rev


More information about the Mercurial-devel mailing list