Mercurial > hg
changeset 28105:1fc7b5363871
destutil: document various failure cases
We document what various conditional branch mean and clarify that they are
exclusive (since they all end up in with exception raised).
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 08 Feb 2016 17:34:32 +0100 |
parents | 96f8baddbd6a |
children | cedbe8723d99 |
files | mercurial/destutil.py |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/destutil.py Mon Feb 08 14:56:28 2016 +0100 +++ b/mercurial/destutil.py Mon Feb 08 17:34:32 2016 +0100 @@ -199,18 +199,28 @@ 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. + # + # This is probably a user mistake We bailout pointing at 'hg update' if len(repo.heads()) <= 1: msg, hint = msgdestmerge['nootherheadsbehind'] else: msg, hint = msgdestmerge['notatheads'] raise error.Abort(msg, hint=hint) - - if len(nbhs) > 2: + elif len(nbhs) > 2: + # Case B: There is more than 2 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'] msg %= (branch, len(bheads)) raise error.Abort(msg, hint=hint) - - if len(nbhs) <= 1: + elif len(nbhs) <= 1: + # Case B: There is no other anonymous head that the one we are one + # + # This means that there is no natural candidate to merge with. + # We abort, with various messages for various cases. if len(bheads) > 1: msg, hint = msgdestmerge['bookmarkedheads'] elif len(repo.heads()) > 1: @@ -219,8 +229,7 @@ else: msg, hint = msgdestmerge['nootherheads'] raise error.Abort(msg, hint=hint) - - if parent == nbhs[0]: + elif parent == nbhs[0]: node = nbhs[-1] else: node = nbhs[0]