[Request] [+-- ] D11509: histedit: use more specific exceptions for more detailed exit codes
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Sep 29 04:53:03 UTC 2021
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11509
AFFECTED FILES
hgext/histedit.py
tests/test-histedit-arguments.t
tests/test-histedit-edit.t
tests/test-histedit-non-commute-abort.t
tests/test-histedit-obsolete.t
tests/test-histedit-outgoing.t
CHANGE DETAILS
diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
--- a/tests/test-histedit-outgoing.t
+++ b/tests/test-histedit-outgoing.t
@@ -134,7 +134,7 @@
$ HGEDITOR=cat hg -q histedit --outgoing '../r'
abort: there are ambiguous outgoing revisions
(see 'hg help histedit' for more detail)
- [255]
+ [20]
$ hg -q update -C 2
$ echo aa >> a
@@ -151,6 +151,6 @@
$ HGEDITOR=cat hg -q histedit --outgoing '../r#default'
abort: there are ambiguous outgoing revisions
(see 'hg help histedit' for more detail)
- [255]
+ [20]
$ cd ..
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -508,7 +508,7 @@
$ hg ci -m 'modify wat'
$ hg histedit 050280826e04
abort: cannot edit history that contains merges
- [255]
+ [20]
$ cd ..
Check abort behavior
diff --git a/tests/test-histedit-non-commute-abort.t b/tests/test-histedit-non-commute-abort.t
--- a/tests/test-histedit-non-commute-abort.t
+++ b/tests/test-histedit-non-commute-abort.t
@@ -160,7 +160,7 @@
$ hg histedit e860deea161a
c: untracked file differs
abort: untracked files in working directory conflict with files in 055a42cdd887
- [255]
+ [20]
We should have detected the collision early enough we're not in a
histedit state, and p1 is unchanged.
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -552,5 +552,5 @@
do you want to continue (yN)? n
abort: histedit cancelled
- [255]
+ [250]
$ cd ..
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -93,7 +93,7 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg histedit -r 4
abort: 08d98a8350f3 is not an ancestor of working directory
- [255]
+ [10]
$ hg up --quiet
@@ -290,7 +290,7 @@
created new head
$ hg histedit -r 'heads(all())'
abort: The specified revisions must have exactly one common root
- [255]
+ [10]
Test that trimming description using multi-byte characters
--------------------------------------------------------------------
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -749,7 +749,7 @@
def abortdirty():
- raise error.Abort(
+ raise error.StateError(
_(b'working copy has pending changes'),
hint=_(
b'amend, commit, or revert them and run histedit '
@@ -1052,12 +1052,12 @@
outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
if not outgoing.missing:
- raise error.Abort(_(b'no outgoing ancestors'))
+ raise error.StateError(_(b'no outgoing ancestors'))
roots = list(repo.revs(b"roots(%ln)", outgoing.missing))
if len(roots) > 1:
msg = _(b'there are ambiguous outgoing revisions')
hint = _(b"see 'hg help histedit' for more detail")
- raise error.Abort(msg, hint=hint)
+ raise error.StateError(msg, hint=hint)
return repo[roots[0]].node()
@@ -1703,13 +1703,13 @@
if defaultrev is not None:
revs.append(defaultrev)
if len(revs) != 1:
- raise error.Abort(
+ raise error.InputError(
_(b'histedit requires exactly one ancestor revision')
)
rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
if len(rr) != 1:
- raise error.Abort(
+ raise error.InputError(
_(
b'The specified revisions must have '
b'exactly one common root'
@@ -1720,7 +1720,7 @@
topmost = repo.dirstate.p1()
revs = between(repo, root, topmost, keep)
if not revs:
- raise error.Abort(
+ raise error.InputError(
_(b'%s is not an ancestor of working directory') % short(root)
)
@@ -1926,7 +1926,7 @@
# blanket if mq patches are applied somewhere
mq = getattr(repo, 'mq', None)
if mq and mq.applied:
- raise error.Abort(_(b'source has mq patches applied'))
+ raise error.StateError(_(b'source has mq patches applied'))
# basic argument incompatibility processing
outg = opts.get(b'outgoing')
@@ -1934,24 +1934,26 @@
abort = opts.get(b'abort')
force = opts.get(b'force')
if force and not outg:
- raise error.Abort(_(b'--force only allowed with --outgoing'))
+ raise error.InputError(_(b'--force only allowed with --outgoing'))
if goal == b'continue':
if any((outg, abort, revs, freeargs, rules, editplan)):
- raise error.Abort(_(b'no arguments allowed with --continue'))
+ raise error.InputError(_(b'no arguments allowed with --continue'))
elif goal == b'abort':
if any((outg, revs, freeargs, rules, editplan)):
- raise error.Abort(_(b'no arguments allowed with --abort'))
+ raise error.InputError(_(b'no arguments allowed with --abort'))
elif goal == b'edit-plan':
if any((outg, revs, freeargs)):
- raise error.Abort(
+ raise error.InputError(
_(b'only --commands argument allowed with --edit-plan')
)
else:
if outg:
if revs:
- raise error.Abort(_(b'no revisions allowed with --outgoing'))
+ raise error.InputError(
+ _(b'no revisions allowed with --outgoing')
+ )
if len(freeargs) > 1:
- raise error.Abort(
+ raise error.InputError(
_(b'only one repo argument allowed with --outgoing')
)
else:
@@ -1962,7 +1964,7 @@
revs.append(defaultrev)
if len(revs) != 1:
- raise error.Abort(
+ raise error.InputError(
_(b'histedit requires exactly one ancestor revision')
)
@@ -1995,7 +1997,7 @@
),
default=1,
):
- raise error.Abort(_(b'histedit cancelled\n'))
+ raise error.CanceledError(_(b'histedit cancelled\n'))
# rebuild state
if goal == goalcontinue:
state.read()
@@ -2205,7 +2207,7 @@
else:
rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
if len(rr) != 1:
- raise error.Abort(
+ raise error.InputError(
_(
b'The specified revisions must have '
b'exactly one common root'
@@ -2215,7 +2217,7 @@
revs = between(repo, root, topmost, state.keep)
if not revs:
- raise error.Abort(
+ raise error.InputError(
_(b'%s is not an ancestor of working directory') % short(root)
)
@@ -2245,7 +2247,7 @@
followcopies=False,
)
except error.Abort:
- raise error.Abort(
+ raise error.StateError(
_(
b"untracked files in working directory conflict with files in %s"
)
@@ -2323,7 +2325,9 @@
if revs and not keep:
rewriteutil.precheck(repo, revs, b'edit')
if repo.revs(b'(%ld) and merge()', revs):
- raise error.Abort(_(b'cannot edit history that contains merges'))
+ raise error.StateError(
+ _(b'cannot edit history that contains merges')
+ )
return pycompat.maplist(repo.changelog.node, revs)
To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210929/f06b4202/attachment-0001.html>
More information about the Mercurial-patches
mailing list