Mercurial > hg-stable
changeset 27948:7cb7264cfd52 stable
commands: advance current active bookmark at pull --update correctly
Before this patch, "hg pull --update" doesn't advance current active
bookmark correctly, if pulling itself doesn't advance it, even though
"hg pull" + "hg update" does so.
Existing test for "pull --update works the same as pull && update" in
test-bookmarks.t doesn't examine this case, because pulling itself
advance current active bookmark before actual updating the working
directory in that test case.
To advance current active bookmark at "hg pull --update" correctly,
this patch examines 'movemarkfrom' instead of 'not checkout'.
Even if 'not checkout' at the invocation of postincoming(), 'checkout'
is overwritten by "the revision to update to" value returned by
destutil.destupdate() in such case. Therefore, 'not checkout'
condition means "update destination is revision #0", and isn't
suitable for examining whether active bookmark should be advanced.
Even though examination around "movemarkfrom == repo['.'].node()" may
seem a little redundant just for this issue, this makes it easier to
compare (and unify in the future, maybe) with the same logic to update
bookmark at "hg update" below.
if not ret and movemarkfrom:
if movemarkfrom == repo['.'].node():
pass # no-op update
elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n") % repo._activebookmark)
else:
# this can happen with a non-linear update
ui.status(_("(leaving bookmark %s)\n") %
repo._activebookmark)
bookmarks.deactivate(repo)
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 28 Jan 2016 20:10:06 +0900 |
parents | 571ba161f6be |
children | 7b7e16158c35 |
files | mercurial/commands.py tests/test-bookmarks.t |
diffstat | 2 files changed, 62 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Jan 24 00:10:19 2016 -0500 +++ b/mercurial/commands.py Thu Jan 28 20:10:06 2016 +0900 @@ -5542,8 +5542,10 @@ msg = _("not updating: %s") % str(inst) hint = inst.hint raise error.UpdateAbort(msg, hint=hint) - if not ret and not checkout: - if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): + if not ret and movemarkfrom: + if movemarkfrom == repo['.'].node(): + pass # no-op update + elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()): ui.status(_("updating bookmark %s\n") % repo._activebookmark) return ret if modheads > 1:
--- a/tests/test-bookmarks.t Sun Jan 24 00:10:19 2016 -0500 +++ b/tests/test-bookmarks.t Thu Jan 28 20:10:06 2016 +0900 @@ -781,3 +781,61 @@ foo@2 2:db815d6d32e6 four 3:9ba5f110a0b3 should-end-on-two 2:db815d6d32e6 + +pull --update works the same as pull && update (case #2) + +It is assumed that "hg pull" itself doesn't update current active +bookmark ('Y' in tests below). + + $ hg pull -q ../cloned-bookmarks-update + divergent bookmark Z stored as Z@2 + +(pulling revision on another named branch with --update updates +neither the working directory nor current active bookmark: "no-op" +case) + + $ echo yy >> y + $ hg commit -m yy + + $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' + * Y 3:125c9a1d6df6 + $ hg -R ../cloned-bookmarks-update pull . --update + pulling from . + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + divergent bookmark Z stored as Z@default + adding remote bookmark foo + adding remote bookmark four + adding remote bookmark should-end-on-two + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n" + 3:125c9a1d6df6 + $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' + * Y 3:125c9a1d6df6 + +(pulling revision on current named/topological branch with --update +updates the working directory and current active bookmark) + + $ hg update -C -q 125c9a1d6df6 + $ echo xx >> x + $ hg commit -m xx + + $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' + * Y 3:125c9a1d6df6 + $ hg -R ../cloned-bookmarks-update pull . --update + pulling from . + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + divergent bookmark Z stored as Z@default + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + updating bookmark Y + $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n" + 6:81dcce76aa0b + $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y ' + * Y 6:81dcce76aa0b