changeset 48552:91017508a785

logcmdutil: raise `InputError` on bad CLI arguments Apparently there were no tests for any of these errors. Differential Revision: https://phab.mercurial-scm.org/D11968
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 06 Jan 2022 22:03:21 -0800
parents 21c0ae0693bc
children 3b6b43a7ace4
files mercurial/logcmdutil.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/logcmdutil.py	Sun Jan 09 13:35:30 2022 +0100
+++ b/mercurial/logcmdutil.py	Thu Jan 06 22:03:21 2022 -0800
@@ -62,9 +62,9 @@
         try:
             limit = int(limit)
         except ValueError:
-            raise error.Abort(_(b'limit must be a positive integer'))
+            raise error.InputError(_(b'limit must be a positive integer'))
         if limit <= 0:
-            raise error.Abort(_(b'limit must be positive'))
+            raise error.InputError(_(b'limit must be positive'))
     else:
         limit = None
     return limit
@@ -1108,11 +1108,13 @@
         try:
             pat, linerange = pat.rsplit(b',', 1)
         except ValueError:
-            raise error.Abort(_(b'malformatted line-range pattern %s') % pat)
+            raise error.InputError(
+                _(b'malformatted line-range pattern %s') % pat
+            )
         try:
             fromline, toline = map(int, linerange.split(b':'))
         except ValueError:
-            raise error.Abort(_(b"invalid line range for %s") % pat)
+            raise error.InputError(_(b"invalid line range for %s") % pat)
         msg = _(b"line range pattern '%s' must match exactly one file") % pat
         fname = scmutil.parsefollowlinespattern(repo, None, pat, msg)
         linerangebyfname.append(
@@ -1271,7 +1273,7 @@
 def checkunsupportedgraphflags(pats, opts):
     for op in [b"newest_first"]:
         if op in opts and opts[op]:
-            raise error.Abort(
+            raise error.InputError(
                 _(b"-G/--graph option is incompatible with --%s")
                 % op.replace(b"_", b"-")
             )