Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bookmarks.py @ 24355: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 | d0ea2028e8e6 |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Tue Mar 17 18:20:24 2015 +0900 +++ b/mercurial/bookmarks.py Tue Mar 17 18:20:24 2015 +0900 @@ -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: