diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -177,7 +177,7 @@ def pushbookmark(repo, key, old, new): 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 @@ def updatefromremote(ui, repo, remote): 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4273,7 +4273,7 @@ def pull(ui, repo, source="default", **o 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 --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -484,7 +484,8 @@ class hgsubrepo(abstractsubrepo): 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 --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -110,18 +110,18 @@ divergent bookmarks 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