From patchwork Fri Feb 12 14:29:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6,of,6] destutil: document various failure cases From: Pierre-Yves David X-Patchwork-Id: 13135 Message-Id: <317b33553ba406d35fec.1455287349@marginatus.alto.octopoid.net> To: mercurial-devel@mercurial-scm.org Cc: Pierre-Yves David Date: Fri, 12 Feb 2016 14:29:09 +0000 # HG changeset patch # User Pierre-Yves David # Date 1454949272 -3600 # Mon Feb 08 17:34:32 2016 +0100 # Node ID 317b33553ba406d35fec8d8b1045a14c6ccad7bf # Parent ac9aa93761f3949cb060b94cbbc62925ffc33427 # EXP-Topic destination # Available At http://hg.netv6.net/marmoute-wip/mercurial/ # hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 317b33553ba4 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). diff --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -197,32 +197,41 @@ def _destmergebranch(repo): 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. + # + # 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 candidant. This is + # ambigious we abort asking the user to pick as explicite 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 not 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: msg, hint = msgdestmerge['nootherbranchheads'] msg %= branch 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] assert node is not None return node