Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 20280:95b9c6149e17
merge: consider successor changesets for a bare update
Previously, a bare update would ignore any successor changesets thus
potentially leaving you on an obsolete head. This happens commonly when there
is an old bookmark that hasn't been moved forward which is the motivating
reason for this patch series.
Now, we will check for successor changesets if two conditions hold: 1) we are
doing a bare update 2) *and* we are currently on an obsolete head.
If we are in this situation, then we calculate the branchtip of the successor
set and update to that changeset.
Tests coverage has been added.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Wed, 15 Jan 2014 16:41:18 -0600 |
parents | 5b4f963d21cc |
children | e4d7cbc94219 |
comparison
equal
deleted
inserted
replaced
20279:5b4f963d21cc | 20280:95b9c6149e17 |
---|---|
694 except error.RepoLookupError: | 694 except error.RepoLookupError: |
695 if wc.branch() == "default": # no default branch! | 695 if wc.branch() == "default": # no default branch! |
696 node = repo.lookup("tip") # update to tip | 696 node = repo.lookup("tip") # update to tip |
697 else: | 697 else: |
698 raise util.Abort(_("branch %s not found") % wc.branch()) | 698 raise util.Abort(_("branch %s not found") % wc.branch()) |
699 | |
700 if p1.obsolete() and not p1.children(): | |
701 # allow updating to successors | |
702 successors = obsolete.successorssets(repo, p1.node()) | |
703 | |
704 # behavior of certain cases is as follows, | |
705 # | |
706 # divergent changesets: update to highest rev, similar to what | |
707 # is currently done when there are more than one head | |
708 # (i.e. 'tip') | |
709 # | |
710 # replaced changesets: same as divergent except we know there | |
711 # is no conflict | |
712 # | |
713 # pruned changeset: no update is done; though, we could | |
714 # consider updating to the first non-obsolete parent, | |
715 # similar to what is current done for 'hg prune' | |
716 | |
717 if successors: | |
718 # flatten the list here handles both divergent (len > 1) | |
719 # and the usual case (len = 1) | |
720 successors = [n for sub in successors for n in sub] | |
721 | |
722 # get the max revision for the given successors set, | |
723 # i.e. the 'tip' of a set | |
724 node = repo.revs("max(%ln)", successors)[0] | |
725 pa = p1 | |
726 | |
699 overwrite = force and not branchmerge | 727 overwrite = force and not branchmerge |
700 | 728 |
701 p2 = repo[node] | 729 p2 = repo[node] |
702 if pa is None: | 730 if pa is None: |
703 pa = p1.ancestor(p2) | 731 pa = p1.ancestor(p2) |