Mercurial > hg > mercurial-crew
changeset 24475:ca4b89683078
bookmarks: reuse @number bookmark, if it refers changeset referred remotely
Before this patch, "@number" suffixed bookmark may be newly created at
each "hg pull" from the remote repository, if the bookmark in remote
repository diverges from one in local one.
This causes unexpected increase of "@number" suffixed bookmarks.
This patch reuses "@number" suffixed bookmark, if it refers the
changeset which is referred by the same bookmark in the remote
repository.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 17 Mar 2015 18:20:24 +0900 |
parents | 194e1e3ebc29 |
children | a38f384f2a57 |
files | mercurial/bookmarks.py tests/test-bookmarks-pushpull.t |
diffstat | 2 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -362,11 +362,14 @@ 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 @@ # 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 @@ 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:
--- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -182,6 +182,24 @@ $ 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"