mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
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:
parent
ac286ef82e
commit
4975fa6f10
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user