mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
63b7bb19c5
Summary: Many of the template keywords in our extensions were being registered incorrectly, causing their help output to be rendered incorrectly in the "hg help templates" output. The ones in smartlog.py were particularly bad, as most of them showed only their description, without displaying the name of the template. In smartlog.py only singlepublicsuccessor was being displayed correctly, because it's docstring explicitly included it's own name at the start. This fixes all of our extensions to consistently use the registrar.templatekeyword() decorator to register the keywords. This decorator automatically prefixes the help message with the keyword name. The mercurial/extensions.py code will explicitly check to see if an extension contains an "templatekeyword" attribute, and if so it will register any keywords contained in this registry after calling extsetup(). Test Plan: Added new unit tests to check the output of "hg help templates" for the affected keywords. Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4427729 Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
65 lines
2.0 KiB
Perl
65 lines
2.0 KiB
Perl
Setup
|
|
|
|
$ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
|
|
$ export PYTHONPATH
|
|
$ cat >> $HGRCPATH << EOF
|
|
> [extensions]
|
|
> arcconfig=$TESTDIR/../phabricator/arcconfig.py
|
|
> phabstatus=$TESTDIR/../hgext3rd/phabstatus.py
|
|
> smartlog=$TESTDIR/../hgext3rd/smartlog.py
|
|
> EOF
|
|
$ hg init repo
|
|
$ cd repo
|
|
$ touch foo
|
|
$ hg ci -qAm 'Differential Revision: https://phabricator.fb.com/D1'
|
|
|
|
With an invalid arc configuration
|
|
|
|
$ hg log -T '{phabstatus}\n' -r .
|
|
arcconfig configuration problem. No diff information can be provided.
|
|
Error info: no .arcconfig foundError
|
|
|
|
Configure arc...
|
|
|
|
$ echo '{}' > .arcconfig
|
|
$ echo '{}' > .arcrc
|
|
|
|
And now with bad responses:
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "result": {}}]
|
|
> EOF
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
Error
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "error_info": "failed, yo"}]
|
|
> EOF
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
Error talking to phabricator. No diff information can be provided.
|
|
Error info: failed, yoError
|
|
|
|
Missing status field is treated as an error
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
|
> "result": {"1" : {"hash": "this is the best hash ewa"}}}]
|
|
> EOF
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
Error
|
|
|
|
And finally, the success case
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
|
> "result": {"1" : {"count": 1, "status": "Needs Review", "hash": "lolwut"}}}]
|
|
> EOF
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
Needs Review
|
|
|
|
Make sure the template keywords are documented correctly
|
|
|
|
$ hg help templates | egrep 'phabstatus|syncstatus'
|
|
phabstatus String. Return the diff approval status for a given hg rev
|
|
syncstatus String. Return whether the local revision is in sync with
|