Mercurial > hg
comparison hgext/mq.py @ 48116:5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Most callers of `scmutil.revrange()` pass in a revset provided by the
user. If there are problems resolving that, it should result in an
`InputError` and exit code 10 (when using detailed exit
codes). However, there are also some callers that pass in revsets not
provided by the user. `InputError` is not appropriate in those
cases. This patch therefore introduces a wrapper around
`scmutil.revrange()` that simply converts the exception type. I put it
in `logcmdutil.py` since that seems to be the lowest-level module in
the (poorly defined) UI layer.
Differential Revision: https://phab.mercurial-scm.org/D11560
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 28 Sep 2021 08:47:11 -0700 |
parents | 0dc9ced02a3b |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48115:b067d22dc6ad | 48116:5ced12cfa41b |
---|---|
1239 | 1239 |
1240 numrevs = 0 | 1240 numrevs = 0 |
1241 if opts.get(b'rev'): | 1241 if opts.get(b'rev'): |
1242 if not self.applied: | 1242 if not self.applied: |
1243 raise error.Abort(_(b'no patches applied')) | 1243 raise error.Abort(_(b'no patches applied')) |
1244 revs = scmutil.revrange(repo, opts.get(b'rev')) | 1244 revs = logcmdutil.revrange(repo, opts.get(b'rev')) |
1245 revs.sort() | 1245 revs.sort() |
1246 revpatches = self._revpatches(repo, revs) | 1246 revpatches = self._revpatches(repo, revs) |
1247 realpatches += revpatches | 1247 realpatches += revpatches |
1248 numrevs = len(revpatches) | 1248 numrevs = len(revpatches) |
1249 | 1249 |
2415 if rev: | 2415 if rev: |
2416 if files: | 2416 if files: |
2417 raise error.Abort( | 2417 raise error.Abort( |
2418 _(b'option "-r" not valid when importing files') | 2418 _(b'option "-r" not valid when importing files') |
2419 ) | 2419 ) |
2420 rev = scmutil.revrange(repo, rev) | 2420 rev = logcmdutil.revrange(repo, rev) |
2421 rev.sort(reverse=True) | 2421 rev.sort(reverse=True) |
2422 elif not files: | 2422 elif not files: |
2423 raise error.Abort(_(b'no files or revisions specified')) | 2423 raise error.Abort(_(b'no files or revisions specified')) |
2424 if (len(files) > 1 or len(rev) > 1) and patchname: | 2424 if (len(files) > 1 or len(rev) > 1) and patchname: |
2425 raise error.Abort( | 2425 raise error.Abort( |
3876 q = repo.mq | 3876 q = repo.mq |
3877 if not q.applied: | 3877 if not q.applied: |
3878 ui.status(_(b'no patches applied\n')) | 3878 ui.status(_(b'no patches applied\n')) |
3879 return 0 | 3879 return 0 |
3880 | 3880 |
3881 revs = scmutil.revrange(repo, revrange) | 3881 revs = logcmdutil.revrange(repo, revrange) |
3882 if repo[b'.'].rev() in revs and repo[None].files(): | 3882 if repo[b'.'].rev() in revs and repo[None].files(): |
3883 ui.warn(_(b'warning: uncommitted changes in the working directory\n')) | 3883 ui.warn(_(b'warning: uncommitted changes in the working directory\n')) |
3884 # queue.finish may changes phases but leave the responsibility to lock the | 3884 # queue.finish may changes phases but leave the responsibility to lock the |
3885 # repo to the caller to avoid deadlock with wlock. This command code is | 3885 # repo to the caller to avoid deadlock with wlock. This command code is |
3886 # responsibility for this locking. | 3886 # responsibility for this locking. |