Show More
@@ -117,14 +117,6 b' def runcatch(ui, args):' | |||
|
117 | 117 | ui.warn("\n%r\n" % util.ellipsis(inst[1])) |
|
118 | 118 | except util.Abort, inst: |
|
119 | 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 | 120 | except SystemExit, inst: |
|
129 | 121 | # Commands shouldn't sys.exit directly, but give a return code. |
|
130 | 122 | # Just in case catch this and and pass exit code to caller. |
@@ -324,15 +316,25 b' def dispatch(ui, args):' | |||
|
324 | 316 | else: |
|
325 | 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 | 332 | if options['profile']: |
|
331 | 333 | import hotshot, hotshot.stats |
|
332 | 334 | prof = hotshot.Profile("hg.prof") |
|
333 | 335 | try: |
|
334 | 336 | try: |
|
335 |
return prof.runcall(c |
|
|
337 | return prof.runcall(checkargs) | |
|
336 | 338 | except: |
|
337 | 339 | try: |
|
338 | 340 | ui.warn(_('exception raised - generating ' |
@@ -356,14 +358,14 b' def runcommand(ui, options, cmdfunc):' | |||
|
356 | 358 | p = lsprof.Profiler() |
|
357 | 359 | p.enable(subcalls=True) |
|
358 | 360 | try: |
|
359 |
return c |
|
|
361 | return checkargs() | |
|
360 | 362 | finally: |
|
361 | 363 | p.disable() |
|
362 | 364 | stats = lsprof.Stats(p.getstats()) |
|
363 | 365 | stats.sort() |
|
364 | 366 | stats.pprint(top=10, file=sys.stderr, climit=5) |
|
365 | 367 | else: |
|
366 |
return c |
|
|
368 | return checkargs() | |
|
367 | 369 | |
|
368 | 370 | def bail_if_changed(repo): |
|
369 | 371 | modified, added, removed, deleted = repo.status()[:4] |
@@ -6,6 +6,9 b' cd a' | |||
|
6 | 6 | echo a > a |
|
7 | 7 | hg ci -Ama -d '0 0' |
|
8 | 8 | |
|
9 | echo "# missing arg" | |
|
10 | hg cat | |
|
11 | ||
|
9 | 12 | echo '% [defaults]' |
|
10 | 13 | hg cat a |
|
11 | 14 | cat > $HGRCPATH <<EOF |
@@ -13,3 +16,4 b' cat > $HGRCPATH <<EOF' | |||
|
13 | 16 | cat = -v |
|
14 | 17 | EOF |
|
15 | 18 | hg cat a |
|
19 |
@@ -1,4 +1,30 b'' | |||
|
1 | 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 | 28 | % [defaults] |
|
3 | 29 | a |
|
4 | 30 | a |
General Comments 0
You need to be logged in to leave comments.
Login now