Mercurial > hg-stable
changeset 15614:260a6449d83a
bookmarks: mark divergent bookmarks with book@pathalias when source in [paths]
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 07 Dec 2011 16:19:39 -0600 |
parents | 2fad18f15409 |
children | 74e691b141c4 |
files | mercurial/bookmarks.py mercurial/commands.py mercurial/subrepo.py tests/test-bookmarks-pushpull.t |
diffstat | 4 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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
--- 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)
--- 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