bookmarks: when @ bookmark diverges, don't double the @ sign (BC)
This changeset treats the bookmark "@" as a special case for the naming of
divergent bookmarks, as per the tables below. For the <no alias> case, the
actual suffix will vary, depending on what suffixes are already in use.
Before:
Bookmark | Remote | Divergent Bookmark
--------------------------------------
foo | bar | foo@bar
foo | <no alias> | foo@1
@ | bar | @@bar
@ | <no alias> | @@1
After:
Bookmark | Remote | Divergent Bookmark
--------------------------------------
foo | bar | foo@bar
foo | <no alias> | foo@1
@ | bar | @bar
@ | <no alias> | @1
This case is likely to be more common now that
92980a8dfdfe has made the "@"
bookmark have special meaning to clone.
The change in behavior was discussed on the mailing list in the thread below:
http://markmail.org/thread/rwedgxp7le5j2h2f
--- a/mercurial/bookmarks.py Tue Oct 16 16:04:28 2012 +0200
+++ b/mercurial/bookmarks.py Mon Oct 15 23:54:54 2012 -0400
@@ -214,16 +214,20 @@
changed = True
ui.status(_("updating bookmark %s\n") % k)
else:
+ if k == '@':
+ kd = ''
+ else:
+ kd = k
# find a unique @ suffix
for x in range(1, 100):
- n = '%s@%d' % (k, x)
+ n = '%s@%d' % (kd, x)
if n not in repo._bookmarks:
break
# try to use an @pathalias suffix
# if an @pathalias already exists, we overwrite (update) it
for p, u in ui.configitems("paths"):
if path == u:
- n = '%s@%s' % (k, p)
+ n = '%s@%s' % (kd, p)
repo._bookmarks[n] = cr.node()
changed = True
--- a/tests/test-bookmarks-pushpull.t Tue Oct 16 16:04:28 2012 +0200
+++ b/tests/test-bookmarks-pushpull.t Mon Oct 15 23:54:54 2012 -0400
@@ -111,8 +111,10 @@
$ echo c1 > f1
$ hg ci -Am1
adding f1
+ $ hg book -f @
$ hg book -f X
$ hg book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 0:4e3505fd9583
Z 1:0d2164f0ce0d
@@ -124,8 +126,10 @@
$ echo c2 > f2
$ hg ci -Am2
adding f2
+ $ hg book -f @
$ hg book -f X
$ hg book
+ @ 1:9b140be10808
* X 1:9b140be10808
Y 0:4e3505fd9583
Z 0:4e3505fd9583
@@ -141,8 +145,11 @@
added 1 changesets with 1 changes to 1 files (+1 heads)
divergent bookmark X stored as X@foo
updating bookmark Z
+ divergent bookmark @ stored as @foo
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg book
+ @ 1:9b140be10808
+ @foo 2:0d2164f0ce0d
* X 1:9b140be10808
X@foo 2:0d2164f0ce0d
Y 0:4e3505fd9583
@@ -157,6 +164,7 @@
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
$ hg -R ../a book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 0:4e3505fd9583
Z 1:0d2164f0ce0d
@@ -177,6 +185,7 @@
added 1 changesets with 1 changes to 1 files (+1 heads)
updating bookmark Y
$ hg -R ../a book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 3:f6fc62dde3c0
Z 1:0d2164f0ce0d
@@ -206,6 +215,7 @@
(did you forget to merge? use push -f to force)
[255]
$ hg -R ../a book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 3:f6fc62dde3c0
Z 1:0d2164f0ce0d
@@ -221,6 +231,7 @@
(did you forget to merge? use push -f to force)
[255]
$ hg -R ../a book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 3:f6fc62dde3c0
Z 1:0d2164f0ce0d
@@ -241,6 +252,7 @@
remote: added 1 changesets with 1 changes to 1 files (+1 heads)
updating bookmark Y
$ hg -R ../a book
+ @ 1:0d2164f0ce0d
* X 1:0d2164f0ce0d
Y 4:4efff6d98829
Z 1:0d2164f0ce0d
@@ -263,11 +275,12 @@
namespaces
obsolete
$ hg debugpushkey http://localhost:$HGPORT/ bookmarks
+ @ 9b140be1080824d768c5a4691a564088eede71f9
+ foo 0000000000000000000000000000000000000000
+ foobar 9b140be1080824d768c5a4691a564088eede71f9
Y 4efff6d98829d9c824c621afd6e3f01865f5439f
- foobar 9b140be1080824d768c5a4691a564088eede71f9
+ X 9b140be1080824d768c5a4691a564088eede71f9
Z 0d2164f0ce0d8f1d6f94351eba04b794909be66c
- foo 0000000000000000000000000000000000000000
- X 9b140be1080824d768c5a4691a564088eede71f9
$ hg out -B http://localhost:$HGPORT/
comparing with http://localhost:$HGPORT/
searching for changed bookmarks
@@ -289,10 +302,11 @@
$ hg pull -B Z http://localhost:$HGPORT/
pulling from http://localhost:$HGPORT/
no changes found
+ divergent bookmark @ stored as @1
+ adding remote bookmark foo
adding remote bookmark foobar
+ divergent bookmark X stored as X@1
adding remote bookmark Z
- adding remote bookmark foo
- divergent bookmark X stored as X@1
importing bookmark Z
$ hg clone http://localhost:$HGPORT/ cloned-bookmarks
requesting all changes
@@ -303,6 +317,7 @@
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R cloned-bookmarks bookmarks
+ @ 1:9b140be10808
X 1:9b140be10808
Y 3:4efff6d98829
Z 2:0d2164f0ce0d