Comments
Patch
@@ -363,6 +363,11 @@ def compare(repo, srcmarks, dstmarks,
return results
def _diverge(ui, b, path, localmarks):
+ '''Return appropriate diverged bookmark for specified ``path``
+
+ This returns None, if it is failed to assign any divergent
+ bookmark name.
+ '''
if b == '@':
b = ''
# find a unique @ suffix
@@ -370,6 +375,8 @@ def _diverge(ui, b, path, localmarks):
n = '%s@%d' % (b, x)
if n not in localmarks:
break
+ else:
+ n = None
# try to use an @pathalias suffix
# if an @pathalias already exists, we overwrite (update) it
if path.startswith("file:"):
@@ -411,9 +418,13 @@ def updatefromremote(ui, repo, remotemar
_("importing bookmark %s\n") % (b)))
else:
db = _diverge(ui, b, path, localmarks)
- changed.append((db, bin(scid), warn,
- _("divergent bookmark %s stored as %s\n")
- % (b, db)))
+ if db:
+ changed.append((db, bin(scid), warn,
+ _("divergent bookmark %s stored as %s\n") %
+ (b, db)))
+ else:
+ warn(_("warning: failed to assign numbered name "
+ "to divergent bookmark %s\n") % (b))
for b, scid, dcid in adddst + advdst:
if b in explicit:
explicit.discard(b)
@@ -164,6 +164,27 @@ divergent bookmarks
Z 2:0d2164f0ce0d
foo -1:000000000000
* foobar 1:9b140be10808
+
+(test that too many divergence of bookmark)
+
+ $ cat > $TESTTMP/seq.py <<EOF
+ > import sys
+ > for i in xrange(*[int(a) for a in sys.argv[1:]]):
+ > print i
+ > EOF
+ $ python $TESTTMP/seq.py 1 100 | while read i; do hg bookmarks -r 000000000000 "X@${i}"; done
+ $ 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 '^ X' | grep -v ':000000000000'
+ X 1:9b140be10808
+ X@foo 2:0d2164f0ce0d
+ $ python $TESTTMP/seq.py 1 100 | while read i; do hg bookmarks -d "X@${i}"; done
+ $ hg bookmarks -d "@1"
+
$ hg push -f ../a
pushing to ../a
searching for changes