[PATCH RFC] update: default update should move as far forward as possible (issue3883)
Augie Fackler
raf at durin42.com
Wed Apr 10 15:22:58 CDT 2013
On Wed, Apr 10, 2013 at 12:55:39PM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1365614989 25200
> # Wed Apr 10 10:29:49 2013 -0700
> # Node ID 4f8c54c2540d1a28773f0dd48e6e2b92163259e4
> # Parent dfd94b32f8731515a0e6e90642609343dc1d6d4d
> update: default update should move as far forward as possible (issue3883)
>
> DO NOT QUEUE THIS CHANGE! It's an rfc.
>
> Previously the default behavior for 'hg up' was to move to the tip of the
> current named branch. This meant if you were on a different fork of the
> DAG from the tip you got an "abort: crosses branches" error.
>
> This changes 'hg up' to update to the farthest descendant of your current
> working copy parent within your current named branch. Ex:
>
> o 3
> |
> | o 2
> | |
> | @ 1
> |/
> |
> o 0
>
> 'hg update' will now put you on commit 2. If you were already on commit 2,
> it would be a no-op. If you were on commit 0, it would put you on 3.
Where would it put you before this change?
>
> This only affects hg updates that would have previously failed. hg updates
> that would have succeeded before will continue to succeed and land on tip.
>
> I considered making this only happen if they have an active bookmark, but
> it seemed weird to have different behavior based on if your bookmark was
> active or not, and it seems like the new behavior is desirable even in non
> bookmark scenarios.
>
> If people agree with this change, I'll update the tests and help documentation
> and resubmit.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -652,14 +652,17 @@
> try:
> wc = repo[None]
> if node is None:
> - # tip of current branch
> - try:
> - node = repo.branchtip(wc.branch())
> - except error.RepoLookupError:
> - if wc.branch() == "default": # no default branch!
> - node = repo.lookup("tip") # update to tip
> - else:
> - raise util.Abort(_("branch %s not found") % wc.branch())
> + # move as far forward as possible
> + wcbranch = wc.branch()
> + nodectx = wc.parents()[0]
> + descendants = nodectx.descendants()
> + for descendant in descendants:
> + if (descendant.branch() == wcbranch and
> + descendant.rev() > nodectx.rev()):
> + nodectx = descendant
> +
> + node = nodectx.node()
> +
> overwrite = force and not branchmerge
> pl = wc.parents()
> p1, p2 = pl[0], repo[node]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list