# HG changeset patch # User FUJIWARA Katsunori # Date 2016-01-28 11:10:06 # Node ID 7cb7264cfd52d2672644db4bc16a0bd50aa093ca # Parent 571ba161f6be9ad696efcdbcf8bdf0a8a6ba0766 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) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5542,8 +5542,10 @@ def postincoming(ui, repo, modheads, opt 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: diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -781,3 +781,61 @@ test clearing only a single divergent bo 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