##// END OF EJS Templates
phabricator: avoid a stacktrace when command arguments are missing...
Matt Harbison -
r44918:09f3e003 default
parent child Browse files
Show More
@@ -257,15 +257,17 b' def vcrcommand(name, flags, spec, helpca'
257 257 return fn(*args, **kwargs)
258 258 return fn(*args, **kwargs)
259 259
260 inner.__name__ = fn.__name__
261 inner.__doc__ = fn.__doc__
260 cmd = util.checksignature(inner, depth=2)
261 cmd.__name__ = fn.__name__
262 cmd.__doc__ = fn.__doc__
263
262 264 return command(
263 265 name,
264 266 fullflags,
265 267 spec,
266 268 helpcategory=helpcategory,
267 269 optionalrepo=optionalrepo,
268 )(inner)
270 )(cmd)
269 271
270 272 return decorate
271 273
@@ -1846,14 +1846,14 b' def pathto(root, n1, n2):'
1846 1846 return pycompat.ossep.join(([b'..'] * len(a)) + b) or b'.'
1847 1847
1848 1848
1849 def checksignature(func):
1849 def checksignature(func, depth=1):
1850 1850 '''wrap a function with code to check for calling errors'''
1851 1851
1852 1852 def check(*args, **kwargs):
1853 1853 try:
1854 1854 return func(*args, **kwargs)
1855 1855 except TypeError:
1856 if len(traceback.extract_tb(sys.exc_info()[2])) == 1:
1856 if len(traceback.extract_tb(sys.exc_info()[2])) == depth:
1857 1857 raise error.SignatureError
1858 1858 raise
1859 1859
@@ -29,6 +29,21 b' this test.'
29 29 > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
30 30 abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
31 31
32 Missing arguments print the command help
33
34 $ hg phabread
35 hg phabread: invalid arguments
36 hg phabread DREVSPEC [OPTIONS]
37
38 print patches from Phabricator suitable for importing
39
40 options:
41
42 --stack read dependencies
43
44 (use 'hg phabread -h' to show more help)
45 [255]
46
32 47 Basic phabread:
33 48 $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head
34 49 # HG changeset patch
General Comments 0
You need to be logged in to leave comments. Login now