diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -257,15 +257,17 @@ return fn(*args, **kwargs) return fn(*args, **kwargs) - inner.__name__ = fn.__name__ - inner.__doc__ = fn.__doc__ + cmd = util.checksignature(inner, depth=2) + cmd.__name__ = fn.__name__ + cmd.__doc__ = fn.__doc__ + return command( name, fullflags, spec, helpcategory=helpcategory, optionalrepo=optionalrepo, - )(inner) + )(cmd) return decorate diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1846,14 +1846,14 @@ return pycompat.ossep.join(([b'..'] * len(a)) + b) or b'.' -def checksignature(func): +def checksignature(func, depth=1): '''wrap a function with code to check for calling errors''' def check(*args, **kwargs): try: return func(*args, **kwargs) except TypeError: - if len(traceback.extract_tb(sys.exc_info()[2])) == 1: + if len(traceback.extract_tb(sys.exc_info()[2])) == depth: raise error.SignatureError raise diff --git a/tests/test-phabricator.t b/tests/test-phabricator.t --- a/tests/test-phabricator.t +++ b/tests/test-phabricator.t @@ -29,6 +29,21 @@ > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long. +Missing arguments print the command help + + $ hg phabread + hg phabread: invalid arguments + hg phabread DREVSPEC [OPTIONS] + + print patches from Phabricator suitable for importing + + options: + + --stack read dependencies + + (use 'hg phabread -h' to show more help) + [255] + Basic phabread: $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head # HG changeset patch