Mercurial > hg-stable
changeset 28138:5ad2017454ee
destutil: remove current head from list of candidates early
While 'hg merge' will refuse to pick a default destination if the working copy
is not on a head, this will be a common and valid case for rebase. In this
case, we will need to exclude from the candidate destination all descendants
from the rebased set.
We make a step forward in that direction by removing parents of the working
copy from the candidate destinations instead of manually filtering the working
copy parent at the end of the process. This will make the extra step of
filtering descendant much simpler in a future changeset.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 08 Feb 2016 18:12:06 +0100 |
parents | b54c0246295b |
children | 5476a7a039c0 |
files | mercurial/destutil.py |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/destutil.py Mon Feb 08 17:53:44 2016 +0100 +++ b/mercurial/destutil.py Mon Feb 08 18:12:06 2016 +0100 @@ -212,7 +212,6 @@ parent = repo.dirstate.p1() branch = repo.dirstate.branch() bheads = repo.branchheads(branch) - nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] if parent not in bheads: # Case A: working copy if not on a head. @@ -223,21 +222,25 @@ else: msg, hint = msgdestmerge['notatheads'][action] raise error.Abort(msg, hint=hint) - elif len(nbhs) > 2: - # Case B: There is more than 2 anonymous heads + # remove current head from the set + bheads = [bh for bh in bheads if bh != parent] + # filters out bookmarked heads + nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] + if len(nbhs) > 1: + # Case B: There is more than 1 other anonymous heads # # This means that there will be more than 1 candidate. This is # ambiguous. We abort asking the user to pick as explicit destination # instead. msg, hint = msgdestmerge['toomanyheads'][action] - msg %= (branch, len(bheads)) + msg %= (branch, len(bheads) + 1) raise error.Abort(msg, hint=hint) - elif len(nbhs) <= 1: - # Case B: There is no other anonymous head that the one we are one + elif not nbhs: + # Case B: There is no other anonymous heads # # This means that there is no natural candidate to merge with. # We abort, with various messages for various cases. - if len(bheads) > 1: + if bheads: msg, hint = msgdestmerge['bookmarkedheads'][action] elif len(repo.heads()) > 1: msg, hint = msgdestmerge['nootherbranchheads'][action] @@ -245,8 +248,6 @@ else: msg, hint = msgdestmerge['nootherheads'][action] raise error.Abort(msg, hint=hint) - elif parent == nbhs[0]: - node = nbhs[-1] else: node = nbhs[0] assert node is not None