@@ -362,11 +362,14 @@ def compare(repo, srcmarks, dstmarks,
return results
-def _diverge(ui, b, path, localmarks):
+def _diverge(ui, b, path, localmarks, remotenode):
'''Return appropriate diverged bookmark for specified ``path``
This returns None, if it is failed to assign any divergent
bookmark name.
+
+ This reuses already existing one with "@number" suffix, if it
+ refers ``remotenode``.
'''
if b == '@':
b = ''
@@ -383,7 +386,7 @@ def _diverge(ui, b, path, localmarks):
# assign a unique "@number" suffix newly
for x in range(1, 100):
n = '%s@%d' % (b, x)
- if n not in localmarks:
+ if n not in localmarks or localmarks[n] == remotenode:
return n
return None
@@ -417,9 +420,10 @@ def updatefromremote(ui, repo, remotemar
changed.append((b, bin(scid), status,
_("importing bookmark %s\n") % (b)))
else:
- db = _diverge(ui, b, path, localmarks)
+ snode = bin(scid)
+ db = _diverge(ui, b, path, localmarks, snode)
if db:
- changed.append((db, bin(scid), warn,
+ changed.append((db, snode, warn,
_("divergent bookmark %s stored as %s\n") %
(b, db)))
else:
@@ -182,6 +182,24 @@ divergent bookmarks
$ hg bookmarks | grep '^ X' | grep -v ':000000000000'
X 1:9b140be10808
X@foo 2:0d2164f0ce0d
+
+(test that remotely diverged bookmarks are reused if they aren't changed)
+
+ $ hg bookmarks | grep '^ @'
+ @ 1:9b140be10808
+ @1 2:0d2164f0ce0d
+ @foo 2:0d2164f0ce0d
+ $ hg pull ../a
+ pulling from ../a
+ searching for changes
+ no changes found
+ warning: failed to assign numbered name to divergent bookmark X
+ divergent bookmark @ stored as @1
+ $ hg bookmarks | grep '^ @'
+ @ 1:9b140be10808
+ @1 2:0d2164f0ce0d
+ @foo 2:0d2164f0ce0d
+
$ python $TESTTMP/seq.py 1 100 | while read i; do hg bookmarks -d "X@${i}"; done
$ hg bookmarks -d "@1"