Show More
@@ -117,14 +117,6 b' def runcatch(ui, args):' | |||||
117 | ui.warn("\n%r\n" % util.ellipsis(inst[1])) |
|
117 | ui.warn("\n%r\n" % util.ellipsis(inst[1])) | |
118 | except util.Abort, inst: |
|
118 | except util.Abort, inst: | |
119 | ui.warn(_("abort: %s\n") % inst) |
|
119 | ui.warn(_("abort: %s\n") % inst) | |
120 | except TypeError, inst: |
|
|||
121 | # was this an argument error? |
|
|||
122 | tb = traceback.extract_tb(sys.exc_info()[2]) |
|
|||
123 | if len(tb) > 2: # no |
|
|||
124 | raise |
|
|||
125 | ui.debug(inst, "\n") |
|
|||
126 | ui.warn(_("%s: invalid arguments\n") % cmd) |
|
|||
127 | commands.help_(ui, cmd) |
|
|||
128 | except SystemExit, inst: |
|
120 | except SystemExit, inst: | |
129 | # Commands shouldn't sys.exit directly, but give a return code. |
|
121 | # Commands shouldn't sys.exit directly, but give a return code. | |
130 | # Just in case catch this and and pass exit code to caller. |
|
122 | # Just in case catch this and and pass exit code to caller. | |
@@ -324,15 +316,25 b' def dispatch(ui, args):' | |||||
324 | else: |
|
316 | else: | |
325 | d = lambda: func(ui, *args, **cmdoptions) |
|
317 | d = lambda: func(ui, *args, **cmdoptions) | |
326 |
|
318 | |||
327 | return runcommand(ui, options, d) |
|
319 | return runcommand(ui, options, cmd, d) | |
328 |
|
320 | |||
329 | def runcommand(ui, options, cmdfunc): |
|
321 | def runcommand(ui, options, cmd, cmdfunc): | |
|
322 | def checkargs(): | |||
|
323 | try: | |||
|
324 | return cmdfunc() | |||
|
325 | except TypeError, inst: | |||
|
326 | # was this an argument error? | |||
|
327 | tb = traceback.extract_tb(sys.exc_info()[2]) | |||
|
328 | if len(tb) != 2: # no | |||
|
329 | raise | |||
|
330 | raise ParseError(cmd, _("invalid arguments")) | |||
|
331 | ||||
330 | if options['profile']: |
|
332 | if options['profile']: | |
331 | import hotshot, hotshot.stats |
|
333 | import hotshot, hotshot.stats | |
332 | prof = hotshot.Profile("hg.prof") |
|
334 | prof = hotshot.Profile("hg.prof") | |
333 | try: |
|
335 | try: | |
334 | try: |
|
336 | try: | |
335 |
return prof.runcall(c |
|
337 | return prof.runcall(checkargs) | |
336 | except: |
|
338 | except: | |
337 | try: |
|
339 | try: | |
338 | ui.warn(_('exception raised - generating ' |
|
340 | ui.warn(_('exception raised - generating ' | |
@@ -356,14 +358,14 b' def runcommand(ui, options, cmdfunc):' | |||||
356 | p = lsprof.Profiler() |
|
358 | p = lsprof.Profiler() | |
357 | p.enable(subcalls=True) |
|
359 | p.enable(subcalls=True) | |
358 | try: |
|
360 | try: | |
359 |
return c |
|
361 | return checkargs() | |
360 | finally: |
|
362 | finally: | |
361 | p.disable() |
|
363 | p.disable() | |
362 | stats = lsprof.Stats(p.getstats()) |
|
364 | stats = lsprof.Stats(p.getstats()) | |
363 | stats.sort() |
|
365 | stats.sort() | |
364 | stats.pprint(top=10, file=sys.stderr, climit=5) |
|
366 | stats.pprint(top=10, file=sys.stderr, climit=5) | |
365 | else: |
|
367 | else: | |
366 |
return c |
|
368 | return checkargs() | |
367 |
|
369 | |||
368 | def bail_if_changed(repo): |
|
370 | def bail_if_changed(repo): | |
369 | modified, added, removed, deleted = repo.status()[:4] |
|
371 | modified, added, removed, deleted = repo.status()[:4] |
@@ -6,6 +6,9 b' cd a' | |||||
6 | echo a > a |
|
6 | echo a > a | |
7 | hg ci -Ama -d '0 0' |
|
7 | hg ci -Ama -d '0 0' | |
8 |
|
8 | |||
|
9 | echo "# missing arg" | |||
|
10 | hg cat | |||
|
11 | ||||
9 | echo '% [defaults]' |
|
12 | echo '% [defaults]' | |
10 | hg cat a |
|
13 | hg cat a | |
11 | cat > $HGRCPATH <<EOF |
|
14 | cat > $HGRCPATH <<EOF | |
@@ -13,3 +16,4 b' cat > $HGRCPATH <<EOF' | |||||
13 | cat = -v |
|
16 | cat = -v | |
14 | EOF |
|
17 | EOF | |
15 | hg cat a |
|
18 | hg cat a | |
|
19 |
@@ -1,4 +1,30 b'' | |||||
1 | adding a |
|
1 | adding a | |
|
2 | # missing arg | |||
|
3 | hg cat: invalid arguments | |||
|
4 | hg cat [OPTION]... FILE... | |||
|
5 | ||||
|
6 | output the current or given revision of files | |||
|
7 | ||||
|
8 | Print the specified files as they were at the given revision. | |||
|
9 | If no revision is given, the parent of the working directory is used, | |||
|
10 | or tip if no revision is checked out. | |||
|
11 | ||||
|
12 | Output may be to a file, in which case the name of the file is | |||
|
13 | given using a format string. The formatting rules are the same as | |||
|
14 | for the export command, with the following additions: | |||
|
15 | ||||
|
16 | %s basename of file being printed | |||
|
17 | %d dirname of file being printed, or '.' if in repo root | |||
|
18 | %p root-relative path name of file being printed | |||
|
19 | ||||
|
20 | options: | |||
|
21 | ||||
|
22 | -o --output print output to file with formatted name | |||
|
23 | -r --rev print the given revision | |||
|
24 | -I --include include names matching the given patterns | |||
|
25 | -X --exclude exclude names matching the given patterns | |||
|
26 | ||||
|
27 | use "hg -v help cat" to show global options | |||
2 | % [defaults] |
|
28 | % [defaults] | |
3 | a |
|
29 | a | |
4 | a |
|
30 | a |
General Comments 0
You need to be logged in to leave comments.
Login now