destutil: add more precise error classes for destmerge

Having exception classes more precise than 'Abort' will allow us to properly
catch "nothing to rebase" situations when we will be using 'destmerge' in
rebase.
This commit is contained in:
Pierre-Yves David 2016-02-09 23:30:41 +00:00
parent ac286ef82e
commit 4975fa6f10
2 changed files with 15 additions and 6 deletions

View File

@ -209,10 +209,10 @@ def _destmergebook(repo, action='merge', sourceset=None):
node = bmheads[0]
elif len(bmheads) > 2:
msg, hint = msgdestmerge['toomanybookmarks'][action]
raise error.Abort(msg, hint=hint)
raise error.ManyMergeDestAbort(msg, hint=hint)
elif len(bmheads) <= 1:
msg, hint = msgdestmerge['nootherbookmarks'][action]
raise error.Abort(msg, hint=hint)
raise error.NoMergeDestAbort(msg, hint=hint)
assert node is not None
return node
@ -225,13 +225,13 @@ def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True):
branch = repo.dirstate.branch()
elif not sourceset:
msg, hint = msgdestmerge['emptysourceset'][action]
raise error.Abort(msg, hint=hint)
raise error.NoMergeDestAbort(msg, hint=hint)
else:
branch = None
for ctx in repo.set('roots(%ld::%ld)', sourceset, sourceset):
if branch is not None and ctx.branch() != branch:
msg, hint = msgdestmerge['multiplebranchessourceset'][action]
raise error.Abort(msg, hint=hint)
raise error.ManyMergeDestAbort(msg, hint=hint)
branch = ctx.branch()
bheads = repo.branchheads(branch)
@ -256,7 +256,7 @@ def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True):
# instead.
msg, hint = msgdestmerge['toomanyheads'][action]
msg %= (branch, len(bheads) + 1)
raise error.Abort(msg, hint=hint)
raise error.ManyMergeDestAbort(msg, hint=hint)
elif not nbhs:
# Case B: There is no other anonymous heads
#
@ -269,7 +269,7 @@ def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True):
msg %= branch
else:
msg, hint = msgdestmerge['nootherheads'][action]
raise error.Abort(msg, hint=hint)
raise error.NoMergeDestAbort(msg, hint=hint)
else:
node = nbhs[0]
assert node is not None

View File

@ -72,6 +72,15 @@ class ConfigError(Abort):
class UpdateAbort(Abort):
"""Raised when an update is aborted for destination issue"""
class MergeDestAbort(Abort):
"""Raised when an update is aborted for destination issues"""
class NoMergeDestAbort(MergeDestAbort):
"""Raised when an update is aborted because there is nothing to merge"""
class ManyMergeDestAbort(MergeDestAbort):
"""Raised when an update is aborted because destination is ambigious"""
class ResponseExpected(Abort):
"""Raised when an EOF is received for a prompt"""
def __init__(self):