[PATCH] Make update with no node jump to the tip of the current branch

Alexis S. L. Carvalho alexis at cecm.usp.br
Sat Mar 10 07:42:40 CST 2007


Thus spake Brendan Cully:
> # HG changeset patch
> # User Brendan Cully <brendan at kublai.com>
> # Date 1173488439 28800
> # Node ID bf86ac3281f074078ad42056723d451867bd3985
> # Parent  ac9e891f2c0f6a43639f9708e4e17cf7cfa19e4b
> Make update with no node jump to the tip of the current branch
> 
> diff -r ac9e891f2c0f -r bf86ac3281f0 mercurial/merge.py
> --- a/mercurial/merge.py	Fri Mar 09 20:08:13 2007 +0100
> +++ b/mercurial/merge.py	Fri Mar 09 17:00:39 2007 -0800
> @@ -444,15 +444,17 @@ def update(repo, node, branchmerge, forc
>      wlock = working dir lock, if already held
>      """
>  
> +    wc = repo.workingctx()
> +

Keep the creation of the workingctx after the call to repo.wlock().  It
doesn't really make a difference right now, but that's just because of
an implementation detail.

>      if node is None:
> -        node = "tip"
> +        # tip of current branch
> +        node = repo.branchtags()[wc.branch()]

I guess you're using branchtags() directly to ensure the branch name
won't get hidden by a tag name...  Hm...

>  
>      if not wlock:
>          wlock = repo.wlock()
>  
>      overwrite = force and not branchmerge
>      forcemerge = force and branchmerge
> -    wc = repo.workingctx()
>      pl = wc.parents()
>      p1, p2 = pl[0], repo.changectx(node)
>      pa = p1.ancestor(p2)

Alexis


More information about the Mercurial-devel mailing list