# HG changeset patch # User Matt Mackall # Date 1323296379 21600 # Node ID 260a6449d83aa788ac154b3a2eab5d1084ed1763 # Parent 2fad18f1540916bfa7be46b7122b3d19e04a09e7 bookmarks: mark divergent bookmarks with book@pathalias when source in [paths] diff -r 2fad18f15409 -r 260a6449d83a mercurial/bookmarks.py --- a/mercurial/bookmarks.py Tue Dec 06 14:17:33 2011 -0600 +++ b/mercurial/bookmarks.py Wed Dec 07 16:19:39 2011 -0600 @@ -177,7 +177,7 @@ finally: w.release() -def updatefromremote(ui, repo, remote): +def updatefromremote(ui, repo, remote, path): ui.debug("checking for updated bookmarks\n") rb = remote.listkeys('bookmarks') changed = False @@ -194,10 +194,17 @@ changed = True ui.status(_("updating bookmark %s\n") % k) else: + # find a unique @ suffix for x in range(1, 100): n = '%s@%d' % (k, 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) + repo._bookmarks[n] = cr.node() changed = True ui.warn(_("divergent bookmark %s stored as %s\n") % (k, n)) diff -r 2fad18f15409 -r 260a6449d83a mercurial/commands.py --- a/mercurial/commands.py Tue Dec 06 14:17:33 2011 -0600 +++ b/mercurial/commands.py Wed Dec 07 16:19:39 2011 -0600 @@ -4273,7 +4273,7 @@ raise util.Abort(err) modheads = repo.pull(other, heads=revs, force=opts.get('force')) - bookmarks.updatefromremote(ui, repo, other) + bookmarks.updatefromremote(ui, repo, other, source) if checkout: checkout = str(repo.changelog.rev(other.lookup(checkout))) repo._subtoppath = source diff -r 2fad18f15409 -r 260a6449d83a mercurial/subrepo.py --- a/mercurial/subrepo.py Tue Dec 06 14:17:33 2011 -0600 +++ b/mercurial/subrepo.py Wed Dec 07 16:19:39 2011 -0600 @@ -484,7 +484,8 @@ self._repo.ui.status(_('pulling subrepo %s from %s\n') % (subrelpath(self), srcurl)) self._repo.pull(other) - bookmarks.updatefromremote(self._repo.ui, self._repo, other) + bookmarks.updatefromremote(self._repo.ui, self._repo, other, + srcurl) def get(self, state, overwrite=False): self._get(state) diff -r 2fad18f15409 -r 260a6449d83a tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t Tue Dec 06 14:17:33 2011 -0600 +++ b/tests/test-bookmarks-pushpull.t Wed Dec 07 16:19:39 2011 -0600 @@ -110,18 +110,18 @@ foo -1:000000000000 foobar -1:000000000000 - $ hg pull ../a - pulling from ../a + $ hg pull --config paths.foo=../a foo + pulling from $TESTTMP/a searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) - divergent bookmark X stored as X@1 + divergent bookmark X stored as X@foo (run 'hg heads' to see heads, 'hg merge' to merge) $ hg book * X 1:9b140be10808 - X@1 2:0d2164f0ce0d + X@foo 2:0d2164f0ce0d Y 0:4e3505fd9583 foo -1:000000000000 foobar -1:000000000000