comparison hgext/phabricator.py @ 44436:09f3e003fc2a

phabricator: avoid a stacktrace when command arguments are missing Previously, the TypeError wasn't properly converted to a SignatureError when improper arguments were supplied to the inner function, because the stack depth is 2 inside the vcrcommand decorator. The `__name__` and `__doc__` attributes need to be reassigned to the new wrapper so that the help summary is available. Differential Revision: https://phab.mercurial-scm.org/D8209
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 04 Mar 2020 00:45:54 -0500
parents 4ce2330f2d0b
children 9d2b2df2c2ba
comparison
equal deleted inserted replaced
44435:4152183acedd 44436:09f3e003fc2a
255 vcr.register_matcher('hgmatcher', hgmatcher) 255 vcr.register_matcher('hgmatcher', hgmatcher)
256 with vcr.use_cassette(cassette, match_on=['hgmatcher']): 256 with vcr.use_cassette(cassette, match_on=['hgmatcher']):
257 return fn(*args, **kwargs) 257 return fn(*args, **kwargs)
258 return fn(*args, **kwargs) 258 return fn(*args, **kwargs)
259 259
260 inner.__name__ = fn.__name__ 260 cmd = util.checksignature(inner, depth=2)
261 inner.__doc__ = fn.__doc__ 261 cmd.__name__ = fn.__name__
262 cmd.__doc__ = fn.__doc__
263
262 return command( 264 return command(
263 name, 265 name,
264 fullflags, 266 fullflags,
265 spec, 267 spec,
266 helpcategory=helpcategory, 268 helpcategory=helpcategory,
267 optionalrepo=optionalrepo, 269 optionalrepo=optionalrepo,
268 )(inner) 270 )(cmd)
269 271
270 return decorate 272 return decorate
271 273
272 274
273 def urlencodenested(params): 275 def urlencodenested(params):