[PATCH STABLE] commands: advance current active bookmark at pull --update correctly

Yuya Nishihara yuya at tcha.org
Thu Jan 28 08:20:37 CST 2016


On Thu, 28 Jan 2016 20:16:23 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1453979406 -32400
> #      Thu Jan 28 20:10:06 2016 +0900
> # Branch stable
> # Node ID 3678de8c5edb6f62f9722be5a028b4ec49a7fadc
> # Parent  4511e8dac4c798e5fed91e629aa9802b01c2b6c3
> 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)

This looks like a follow-up for 70ac5f724fbd, and looks good to me.

https://selenic.com/repo/hg/rev/70ac5f724fbd

Pushed to the clowncopter, thanks.


More information about the Mercurial-devel mailing list