mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
phabstatus: fix interaction with the smartlog extension
Summary: Previously phabstatus.extsetup() would throw an exception if the smartlog extension was not in use and already loaded. This fixes the code to use extensions.afterloaded() to ensure that we try to wrap smartlog functions only after smartlog is loaded. It also handles the lookup error if smartlog is not in use at all. Test Plan: Included a new unit test. Reviewers: #mercurial, phillco Reviewed By: phillco Subscribers: medson, mjpieters, net-systems-diffs@fb.com Differential Revision: https://phabricator.intern.facebook.com/D5375301 Tasks: 16939242 Signature: t1:5375301:1499323251:4bc00c9cba79d60cbbb6738e8f1d648e75055cdb
This commit is contained in:
parent
de95312716
commit
4a7be070d7
@ -193,5 +193,13 @@ def _getdag(orig, *args):
|
||||
return orig(*args)
|
||||
|
||||
def extsetup(ui):
|
||||
smartlog = extensions.find("smartlog")
|
||||
extensions.wrapfunction(smartlog, 'getdag', _getdag)
|
||||
def _smartlogloaded(loaded):
|
||||
smartlog = None
|
||||
try:
|
||||
smartlog = extensions.find('smartlog')
|
||||
except KeyError:
|
||||
pass
|
||||
if smartlog:
|
||||
extensions.wrapfunction(smartlog, 'getdag', _getdag)
|
||||
|
||||
extensions.afterloaded('smartlog', _smartlogloaded)
|
||||
|
@ -59,6 +59,15 @@ And finally, the success case
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
||||
Needs Review
|
||||
|
||||
Make sure the code works without the smartlog extensions
|
||||
|
||||
$ 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 --config 'extensions.smartlog=!' log -T '{phabstatus}\n' -r .
|
||||
Needs Review
|
||||
|
||||
Make sure the template keywords are documented correctly
|
||||
|
||||
$ hg help templates | egrep 'phabstatus|syncstatus'
|
||||
|
Loading…
Reference in New Issue
Block a user