Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.py @ 48580: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 | 5105a9975407 |
children | 3b6b43a7ace4 |
comparison
equal
deleted
inserted
replaced
48579:21c0ae0693bc | 48580:91017508a785 |
---|---|
60 limit = opts.get(b'limit') | 60 limit = opts.get(b'limit') |
61 if limit: | 61 if limit: |
62 try: | 62 try: |
63 limit = int(limit) | 63 limit = int(limit) |
64 except ValueError: | 64 except ValueError: |
65 raise error.Abort(_(b'limit must be a positive integer')) | 65 raise error.InputError(_(b'limit must be a positive integer')) |
66 if limit <= 0: | 66 if limit <= 0: |
67 raise error.Abort(_(b'limit must be positive')) | 67 raise error.InputError(_(b'limit must be positive')) |
68 else: | 68 else: |
69 limit = None | 69 limit = None |
70 return limit | 70 return limit |
71 | 71 |
72 | 72 |
1106 linerangebyfname = [] | 1106 linerangebyfname = [] |
1107 for pat in opts.get(b'line_range', []): | 1107 for pat in opts.get(b'line_range', []): |
1108 try: | 1108 try: |
1109 pat, linerange = pat.rsplit(b',', 1) | 1109 pat, linerange = pat.rsplit(b',', 1) |
1110 except ValueError: | 1110 except ValueError: |
1111 raise error.Abort(_(b'malformatted line-range pattern %s') % pat) | 1111 raise error.InputError( |
1112 _(b'malformatted line-range pattern %s') % pat | |
1113 ) | |
1112 try: | 1114 try: |
1113 fromline, toline = map(int, linerange.split(b':')) | 1115 fromline, toline = map(int, linerange.split(b':')) |
1114 except ValueError: | 1116 except ValueError: |
1115 raise error.Abort(_(b"invalid line range for %s") % pat) | 1117 raise error.InputError(_(b"invalid line range for %s") % pat) |
1116 msg = _(b"line range pattern '%s' must match exactly one file") % pat | 1118 msg = _(b"line range pattern '%s' must match exactly one file") % pat |
1117 fname = scmutil.parsefollowlinespattern(repo, None, pat, msg) | 1119 fname = scmutil.parsefollowlinespattern(repo, None, pat, msg) |
1118 linerangebyfname.append( | 1120 linerangebyfname.append( |
1119 (fname, util.processlinerange(fromline, toline)) | 1121 (fname, util.processlinerange(fromline, toline)) |
1120 ) | 1122 ) |
1269 | 1271 |
1270 | 1272 |
1271 def checkunsupportedgraphflags(pats, opts): | 1273 def checkunsupportedgraphflags(pats, opts): |
1272 for op in [b"newest_first"]: | 1274 for op in [b"newest_first"]: |
1273 if op in opts and opts[op]: | 1275 if op in opts and opts[op]: |
1274 raise error.Abort( | 1276 raise error.InputError( |
1275 _(b"-G/--graph option is incompatible with --%s") | 1277 _(b"-G/--graph option is incompatible with --%s") |
1276 % op.replace(b"_", b"-") | 1278 % op.replace(b"_", b"-") |
1277 ) | 1279 ) |
1278 | 1280 |
1279 | 1281 |