##// END OF EJS Templates
errors: raise InputError from revsingle() iff revset provided by the user...
Martin von Zweigbergk -
r48930:5105a997 default
parent child Browse files
Show More
@@ -35,6 +35,7 b' from mercurial.node import short'
35 35
36 36 from mercurial import (
37 37 error,
38 logcmdutil,
38 39 registrar,
39 40 scmutil,
40 41 )
@@ -84,7 +85,7 b" def _docensor(ui, repo, path, rev=b'', t"
84 85 if not len(flog):
85 86 raise error.Abort(_(b'cannot censor file with no history'))
86 87
87 rev = scmutil.revsingle(repo, rev, rev).rev()
88 rev = logcmdutil.revsingle(repo, rev, rev).rev()
88 89 try:
89 90 ctx = repo[rev]
90 91 except KeyError:
@@ -22,7 +22,6 b' from mercurial import ('
22 22 logcmdutil,
23 23 pycompat,
24 24 registrar,
25 scmutil,
26 25 )
27 26
28 27 templateopts = cmdutil.templateopts
@@ -71,7 +70,7 b' def children(ui, repo, file_=None, **opt'
71 70 """
72 71 opts = pycompat.byteskwargs(opts)
73 72 rev = opts.get(b'rev')
74 ctx = scmutil.revsingle(repo, rev)
73 ctx = logcmdutil.revsingle(repo, rev)
75 74 if file_:
76 75 fctx = repo.filectx(file_, changeid=ctx.rev())
77 76 childctxs = [fcctx.changectx() for fcctx in fctx.children()]
@@ -13,9 +13,9 b' from mercurial import ('
13 13 cmdutil,
14 14 context,
15 15 error,
16 logcmdutil,
16 17 pycompat,
17 18 registrar,
18 logcmdutil,
19 19 )
20 20
21 21 cmdtable = {}
@@ -559,15 +559,15 b' def dodiff(ui, repo, cmdline, pats, opts'
559 559 do3way = b'$parent2' in cmdline
560 560
561 561 if change:
562 ctx2 = scmutil.revsingle(repo, change, None)
562 ctx2 = logcmdutil.revsingle(repo, change, None)
563 563 ctx1a, ctx1b = ctx2.p1(), ctx2.p2()
564 564 elif from_rev or to_rev:
565 565 repo = scmutil.unhidehashlikerevs(
566 566 repo, [from_rev] + [to_rev], b'nowarn'
567 567 )
568 ctx1a = scmutil.revsingle(repo, from_rev, None)
568 ctx1a = logcmdutil.revsingle(repo, from_rev, None)
569 569 ctx1b = repo[nullrev]
570 ctx2 = scmutil.revsingle(repo, to_rev, None)
570 ctx2 = logcmdutil.revsingle(repo, to_rev, None)
571 571 else:
572 572 ctx1a, ctx2 = logcmdutil.revpair(repo, revs)
573 573 if not revs:
@@ -15,6 +15,7 b' from mercurial import ('
15 15 encoding,
16 16 error,
17 17 extensions,
18 logcmdutil,
18 19 patch,
19 20 pycompat,
20 21 registrar,
@@ -75,7 +76,7 b' def _matchpaths(repo, rev, pats, opts, a'
75 76 def bad(x, y):
76 77 raise error.Abort(b"%s: %s" % (x, y))
77 78
78 ctx = scmutil.revsingle(repo, rev)
79 ctx = logcmdutil.revsingle(repo, rev)
79 80 m = scmutil.match(ctx, pats, opts, badfn=bad)
80 81 for p in ctx.walk(m):
81 82 yield p
@@ -317,7 +318,7 b' def debugbuildannotatecache(ui, repo, *p'
317 318 )
318 319 if ui.configbool(b'fastannotate', b'unfilteredrepo'):
319 320 repo = repo.unfiltered()
320 ctx = scmutil.revsingle(repo, rev)
321 ctx = logcmdutil.revsingle(repo, rev)
321 322 m = scmutil.match(ctx, pats, opts)
322 323 paths = list(ctx.walk(m))
323 324 if util.safehasattr(repo, 'prefetchfastannotate'):
@@ -1667,7 +1667,7 b' def overridetransplant(orig, ui, repo, *'
1667 1667 @eh.wrapcommand(b'cat')
1668 1668 def overridecat(orig, ui, repo, file1, *pats, **opts):
1669 1669 opts = pycompat.byteskwargs(opts)
1670 ctx = scmutil.revsingle(repo, opts.get(b'rev'))
1670 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'))
1671 1671 err = 1
1672 1672 notbad = set()
1673 1673 m = scmutil.match(ctx, (file1,) + pats, opts)
@@ -1323,7 +1323,7 b' def _definedestmap(ui, repo, inmemory, d'
1323 1323 return None
1324 1324 if destf:
1325 1325 # --base does not support multiple destinations
1326 dest = scmutil.revsingle(repo, destf)
1326 dest = logcmdutil.revsingle(repo, destf)
1327 1327 else:
1328 1328 dest = repo[_destrebase(repo, base, destspace=destspace)]
1329 1329 destf = bytes(dest)
@@ -1480,7 +1480,7 b' def copy(ui, repo, pats, opts, rename=Fa'
1480 1480 # TODO: Remove this restriction and make it also create the copy
1481 1481 # targets (and remove the rename source if rename==True).
1482 1482 raise error.InputError(_(b'--at-rev requires --after'))
1483 ctx = scmutil.revsingle(repo, rev)
1483 ctx = logcmdutil.revsingle(repo, rev)
1484 1484 if len(ctx.parents()) > 1:
1485 1485 raise error.InputError(
1486 1486 _(b'cannot mark/unmark copy in merge commit')
@@ -445,7 +445,7 b' def annotate(ui, repo, *pats, **opts):'
445 445 rev = opts.get(b'rev')
446 446 if rev:
447 447 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
448 ctx = scmutil.revsingle(repo, rev)
448 ctx = logcmdutil.revsingle(repo, rev)
449 449
450 450 ui.pager(b'annotate')
451 451 rootfm = ui.formatter(b'annotate', opts)
@@ -649,7 +649,7 b' def archive(ui, repo, dest, **opts):'
649 649 rev = opts.get(b'rev')
650 650 if rev:
651 651 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
652 ctx = scmutil.revsingle(repo, rev)
652 ctx = logcmdutil.revsingle(repo, rev)
653 653 if not ctx:
654 654 raise error.InputError(
655 655 _(b'no working directory: please specify a revision')
@@ -791,7 +791,7 b' def _dobackout(ui, repo, node=None, rev='
791 791
792 792 cmdutil.checkunfinished(repo)
793 793 cmdutil.bailifchanged(repo)
794 ctx = scmutil.revsingle(repo, rev)
794 ctx = logcmdutil.revsingle(repo, rev)
795 795 node = ctx.node()
796 796
797 797 op1, op2 = repo.dirstate.parents()
@@ -1761,7 +1761,7 b' def cat(ui, repo, file1, *pats, **opts):'
1761 1761 rev = opts.get(b'rev')
1762 1762 if rev:
1763 1763 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
1764 ctx = scmutil.revsingle(repo, rev)
1764 ctx = logcmdutil.revsingle(repo, rev)
1765 1765 m = scmutil.match(ctx, (file1,) + pats, opts)
1766 1766 fntemplate = opts.pop(b'output', b'')
1767 1767 if cmdutil.isstdiofilename(fntemplate):
@@ -2600,14 +2600,14 b' def diff(ui, repo, *pats, **opts):'
2600 2600 cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
2601 2601 if change:
2602 2602 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
2603 ctx2 = scmutil.revsingle(repo, change, None)
2603 ctx2 = logcmdutil.revsingle(repo, change, None)
2604 2604 ctx1 = logcmdutil.diff_parent(ctx2)
2605 2605 elif from_rev or to_rev:
2606 2606 repo = scmutil.unhidehashlikerevs(
2607 2607 repo, [from_rev] + [to_rev], b'nowarn'
2608 2608 )
2609 ctx1 = scmutil.revsingle(repo, from_rev, None)
2610 ctx2 = scmutil.revsingle(repo, to_rev, None)
2609 ctx1 = logcmdutil.revsingle(repo, from_rev, None)
2610 ctx2 = logcmdutil.revsingle(repo, to_rev, None)
2611 2611 else:
2612 2612 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
2613 2613 ctx1, ctx2 = logcmdutil.revpair(repo, revs)
@@ -2864,7 +2864,7 b' def files(ui, repo, *pats, **opts):'
2864 2864 rev = opts.get(b'rev')
2865 2865 if rev:
2866 2866 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
2867 ctx = scmutil.revsingle(repo, rev, None)
2867 ctx = logcmdutil.revsingle(repo, rev, None)
2868 2868
2869 2869 end = b'\n'
2870 2870 if opts.get(b'print0'):
@@ -3175,7 +3175,7 b' def _dograft(ui, repo, *revs, **opts):'
3175 3175 skipped = set()
3176 3176 basectx = None
3177 3177 if opts.get('base'):
3178 basectx = scmutil.revsingle(repo, opts['base'], None)
3178 basectx = logcmdutil.revsingle(repo, opts['base'], None)
3179 3179 if basectx is None:
3180 3180 # check for merges
3181 3181 for rev in repo.revs(b'%ld and merge()', revs):
@@ -3696,7 +3696,7 b' def heads(ui, repo, *branchrevs, **opts)'
3696 3696 rev = opts.get(b'rev')
3697 3697 if rev:
3698 3698 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3699 start = scmutil.revsingle(repo, rev, None).node()
3699 start = logcmdutil.revsingle(repo, rev, None).node()
3700 3700
3701 3701 if opts.get(b'topo'):
3702 3702 heads = [repo[h] for h in repo.heads(start)]
@@ -3932,7 +3932,7 b' def identify('
3932 3932 else:
3933 3933 if rev:
3934 3934 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
3935 ctx = scmutil.revsingle(repo, rev, None)
3935 ctx = logcmdutil.revsingle(repo, rev, None)
3936 3936
3937 3937 if ctx.rev() is None:
3938 3938 ctx = repo[None]
@@ -4445,7 +4445,7 b' def locate(ui, repo, *pats, **opts):'
4445 4445 end = b'\0'
4446 4446 else:
4447 4447 end = b'\n'
4448 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
4448 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'), None)
4449 4449
4450 4450 ret = 1
4451 4451 m = scmutil.match(
@@ -4790,7 +4790,7 b' def manifest(ui, repo, node=None, rev=No'
4790 4790 mode = {b'l': b'644', b'x': b'755', b'': b'644', b't': b'755'}
4791 4791 if node:
4792 4792 repo = scmutil.unhidehashlikerevs(repo, [node], b'nowarn')
4793 ctx = scmutil.revsingle(repo, node)
4793 ctx = logcmdutil.revsingle(repo, node)
4794 4794 mf = ctx.manifest()
4795 4795 ui.pager(b'manifest')
4796 4796 for f in ctx:
@@ -4877,7 +4877,7 b' def merge(ui, repo, node=None, **opts):'
4877 4877 node = opts.get(b'rev')
4878 4878
4879 4879 if node:
4880 ctx = scmutil.revsingle(repo, node)
4880 ctx = logcmdutil.revsingle(repo, node)
4881 4881 else:
4882 4882 if ui.configbool(b'commands', b'merge.require-rev'):
4883 4883 raise error.InputError(
@@ -5056,7 +5056,7 b' def parents(ui, repo, file_=None, **opts'
5056 5056 rev = opts.get(b'rev')
5057 5057 if rev:
5058 5058 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
5059 ctx = scmutil.revsingle(repo, rev, None)
5059 ctx = logcmdutil.revsingle(repo, rev, None)
5060 5060
5061 5061 if file_:
5062 5062 m = scmutil.match(ctx, (file_,), opts)
@@ -6347,7 +6347,7 b' def revert(ui, repo, *pats, **opts):'
6347 6347 rev = opts.get(b'rev')
6348 6348 if rev:
6349 6349 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
6350 ctx = scmutil.revsingle(repo, rev)
6350 ctx = logcmdutil.revsingle(repo, rev)
6351 6351
6352 6352 if not (
6353 6353 pats
@@ -6905,7 +6905,7 b' def status(ui, repo, *pats, **opts):'
6905 6905 raise error.InputError(msg)
6906 6906 elif change:
6907 6907 repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
6908 ctx2 = scmutil.revsingle(repo, change, None)
6908 ctx2 = logcmdutil.revsingle(repo, change, None)
6909 6909 ctx1 = ctx2.p1()
6910 6910 else:
6911 6911 repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
@@ -7453,7 +7453,7 b' def tag(ui, repo, name1, *names, **opts)'
7453 7453 b'(use -f to force)'
7454 7454 )
7455 7455 )
7456 node = scmutil.revsingle(repo, rev_).node()
7456 node = logcmdutil.revsingle(repo, rev_).node()
7457 7457
7458 7458 if not message:
7459 7459 # we don't translate commit messages
@@ -7477,7 +7477,7 b' def tag(ui, repo, name1, *names, **opts)'
7477 7477 # don't allow tagging the null rev
7478 7478 if (
7479 7479 not opts.get(b'remove')
7480 and scmutil.revsingle(repo, rev_).rev() == nullrev
7480 and logcmdutil.revsingle(repo, rev_).rev() == nullrev
7481 7481 ):
7482 7482 raise error.InputError(_(b"cannot tag null revision"))
7483 7483
@@ -7840,7 +7840,7 b' def update(ui, repo, node=None, **opts):'
7840 7840 brev = rev
7841 7841 if rev:
7842 7842 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
7843 ctx = scmutil.revsingle(repo, rev, default=None)
7843 ctx = logcmdutil.revsingle(repo, rev, default=None)
7844 7844 rev = ctx.rev()
7845 7845 hidden = ctx.hidden()
7846 7846 overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')}
@@ -506,7 +506,7 b' def debugcapabilities(ui, path, **opts):'
506 506 )
507 507 def debugchangedfiles(ui, repo, rev, **opts):
508 508 """list the stored files changes for a revision"""
509 ctx = scmutil.revsingle(repo, rev, None)
509 ctx = logcmdutil.revsingle(repo, rev, None)
510 510 files = None
511 511
512 512 if opts['compute']:
@@ -1373,7 +1373,7 b' def debugfileset(ui, repo, expr, **opts)'
1373 1373
1374 1374 fileset.symbols # force import of fileset so we have predicates to optimize
1375 1375 opts = pycompat.byteskwargs(opts)
1376 ctx = scmutil.revsingle(repo, opts.get(b'rev'), None)
1376 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'), None)
1377 1377
1378 1378 stages = [
1379 1379 (b'parsed', pycompat.identity),
@@ -912,6 +912,18 b' def _makenofollowfilematcher(repo, pats,'
912 912 return None
913 913
914 914
915 def revsingle(repo, revspec, default=b'.', localalias=None):
916 """Resolves user-provided revset(s) into a single revision.
917
918 This just wraps the lower-level scmutil.revsingle() in order to raise an
919 exception indicating user error.
920 """
921 try:
922 return scmutil.revsingle(repo, revspec, default, localalias)
923 except error.RepoLookupError as e:
924 raise error.InputError(e.args[0], hint=e.hint)
925
926
915 927 def revpair(repo, revs):
916 928 """Resolves user-provided revset(s) into two revisions.
917 929
@@ -101,7 +101,7 b' typical client does not want echo-back m'
101 101 000000000000 tip
102 102 *** runcommand id -runknown
103 103 abort: unknown revision 'unknown'
104 [255]
104 [10]
105 105
106 106 >>> from hgclient import bprint, check, readchannel
107 107 >>> @check
@@ -75,7 +75,7 b' Testing with rev number'
75 75 $ hg status --change 2 --config experimental.directaccess.revnums=False
76 76 abort: hidden revision '2' was rewritten as: 2443a0e66469
77 77 (use --hidden to access hidden revisions)
78 [255]
78 [10]
79 79
80 80 $ hg diff -c 2
81 81 diff -r 29becc82797a -r 28ad74487de9 c
@@ -88,7 +88,7 b' The next two calls are expected to abort'
88 88
89 89 $ hg manifest -r 2
90 90 abort: unknown revision '2'
91 [255]
91 [10]
92 92
93 93 $ hg manifest -r tip tip
94 94 abort: please specify just one revision
@@ -54,7 +54,7 b' Actual test'
54 54 $ hg update 471f378eab4c
55 55 abort: hidden revision '471f378eab4c' was rewritten as: 4ae3a4151de9
56 56 (use --hidden to access hidden revisions)
57 [255]
57 [10]
58 58 $ hg update --hidden "desc(A0)"
59 59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 60 updated to hidden changeset 471f378eab4c
@@ -118,7 +118,7 b' Actual test'
118 118 $ hg up 0dec01379d3b
119 119 abort: hidden revision '0dec01379d3b' is pruned
120 120 (use --hidden to access hidden revisions)
121 [255]
121 [10]
122 122 $ hg up --hidden -r 'desc(B0)'
123 123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
124 124 updated to hidden changeset 0dec01379d3b
@@ -196,7 +196,7 b' Actual test'
196 196 $ hg update 471597cad322
197 197 abort: hidden revision '471597cad322' was split as: 337fec4d2edc, f257fde29c7a
198 198 (use --hidden to access hidden revisions)
199 [255]
199 [10]
200 200 $ hg update --hidden 'min(desc(A0))'
201 201 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 202 updated to hidden changeset 471597cad322
@@ -296,7 +296,7 b' Actual test'
296 296 $ hg update de7290d8b885
297 297 abort: hidden revision 'de7290d8b885' was split as: 337fec4d2edc, f257fde29c7a and 2 more
298 298 (use --hidden to access hidden revisions)
299 [255]
299 [10]
300 300 $ hg update --hidden 'min(desc(A0))'
301 301 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
302 302 updated to hidden changeset de7290d8b885
@@ -377,7 +377,7 b' Test setup'
377 377 $ hg update 471f378eab4c
378 378 abort: hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192
379 379 (use --hidden to access hidden revisions)
380 [255]
380 [10]
381 381 $ hg update --hidden 'desc(A0)'
382 382 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
383 383 updated to hidden changeset 471f378eab4c
@@ -385,7 +385,7 b' Test setup'
385 385 $ hg update 0dec01379d3b
386 386 abort: hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192
387 387 (use --hidden to access hidden revisions)
388 [255]
388 [10]
389 389 $ hg update --hidden 'desc(B0)'
390 390 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
391 391 updated to hidden changeset 0dec01379d3b
@@ -460,7 +460,7 b' Actual test'
460 460 $ hg update 471f378eab4c
461 461 abort: hidden revision '471f378eab4c' has diverged
462 462 (use --hidden to access hidden revisions)
463 [255]
463 [10]
464 464 $ hg update --hidden 'desc(A0)'
465 465 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
466 466 updated to hidden changeset 471f378eab4c
@@ -557,7 +557,7 b' Test setup'
557 557 $ hg update 471f378eab4c
558 558 abort: hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192
559 559 (use --hidden to access hidden revisions)
560 [255]
560 [10]
561 561 $ hg update --hidden 'desc(A0)'
562 562 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
563 563 updated to hidden changeset 471f378eab4c
@@ -162,7 +162,7 b' Multiple destinations cannot be used wit'
162 162 > A D
163 163 > EOS
164 164 abort: unknown revision 'SRC'
165 [255]
165 [10]
166 166
167 167 Rebase to null should work:
168 168
@@ -709,7 +709,7 b' test hg strip -B bookmark'
709 709 bookmark 'todelete' deleted
710 710 $ hg id -ir dcbb326fdec2
711 711 abort: unknown revision 'dcbb326fdec2'
712 [255]
712 [10]
713 713 $ hg id -ir d62d843c9a01
714 714 d62d843c9a01
715 715 $ hg bookmarks
@@ -725,17 +725,17 b' test hg strip -B bookmark'
725 725 bookmark 'multipledelete2' deleted
726 726 $ hg id -ir e46a4836065c
727 727 abort: unknown revision 'e46a4836065c'
728 [255]
728 [10]
729 729 $ hg id -ir b4594d867745
730 730 abort: unknown revision 'b4594d867745'
731 [255]
731 [10]
732 732 $ hg strip -B singlenode1 -B singlenode2
733 733 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg
734 734 bookmark 'singlenode1' deleted
735 735 bookmark 'singlenode2' deleted
736 736 $ hg id -ir 43227190fef8
737 737 abort: unknown revision '43227190fef8'
738 [255]
738 [10]
739 739 $ hg strip -B unknownbookmark
740 740 abort: bookmark 'unknownbookmark' not found
741 741 [255]
@@ -750,7 +750,7 b' test hg strip -B bookmark'
750 750 bookmark 'delete' deleted
751 751 $ hg id -ir 6:2702dd0c91e7
752 752 abort: unknown revision '2702dd0c91e7'
753 [255]
753 [10]
754 754 $ hg update B
755 755 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
756 756 (activating bookmark B)
General Comments 0
You need to be logged in to leave comments. Login now