2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2016-04-27 19:27:56 +03:00
|
|
|
Setup
|
|
|
|
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
2019-01-29 05:29:48 +03:00
|
|
|
> arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
|
2018-01-10 19:39:19 +03:00
|
|
|
> phabstatus=
|
|
|
|
> smartlog=
|
2016-04-27 19:27:56 +03:00
|
|
|
> 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.
|
phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.
The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.
This also fixes the phabstatus warning messages to end with a newline.
Test Plan: Added a unit test.
Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy
Reviewed By: wez, rmcelroy
Subscribers: rmcelroy, net-systems-diffs@fb.com, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4800977
Tasks: 17002914
Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 21:55:39 +03:00
|
|
|
Error info: no .arcconfig found
|
|
|
|
Error
|
2016-04-27 19:27:56 +03:00
|
|
|
|
|
|
|
Configure arc...
|
|
|
|
|
|
|
|
$ echo '{}' > .arcrc
|
2017-12-14 21:28:30 +03:00
|
|
|
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "cert" : "garbage_cert"}}}' > .arcconfig
|
2016-04-27 19:27:56 +03:00
|
|
|
|
|
|
|
And now with bad responses:
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:43 +03:00
|
|
|
> [{}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
|
|
|
Error info: Unexpected graphql response format
|
|
|
|
Error
|
2016-04-27 19:27:56 +03:00
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"errors": [{"message": "failed, yo"}]}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.
The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.
This also fixes the phabstatus warning messages to end with a newline.
Test Plan: Added a unit test.
Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy
Reviewed By: wez, rmcelroy
Subscribers: rmcelroy, net-systems-diffs@fb.com, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4800977
Tasks: 17002914
Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 21:55:39 +03:00
|
|
|
Error info: failed, yo
|
|
|
|
Error
|
2016-04-27 19:27:56 +03:00
|
|
|
|
2018-02-07 12:53:48 +03:00
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
|
|
> [{"data": {"query": [{"results": {"nodes": null}}]}}]
|
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
2018-02-07 12:53:50 +03:00
|
|
|
Error talking to phabricator. No diff information can be provided.
|
2018-02-07 12:53:52 +03:00
|
|
|
Error info: Unexpected graphql response format
|
2018-02-07 12:53:50 +03:00
|
|
|
Error
|
2018-02-07 12:53:48 +03:00
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
|
|
> [{"data": {"query": [{"results": null}]}}]
|
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
2018-02-07 12:53:48 +03:00
|
|
|
Error talking to phabricator. No diff information can be provided.
|
2018-02-07 12:53:52 +03:00
|
|
|
Error info: Unexpected graphql response format
|
2018-02-07 12:53:48 +03:00
|
|
|
Error
|
|
|
|
|
2016-08-05 21:33:36 +03:00
|
|
|
Missing status field is treated as an error
|
2016-04-27 19:27:56 +03:00
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [
|
2018-03-08 01:32:31 +03:00
|
|
|
> {"number": 1, "created_time": 0, "updated_time": 2}
|
2018-02-07 12:53:45 +03:00
|
|
|
> ]}}]}}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
|
|
|
Error info: Unexpected graphql response format
|
|
|
|
Error
|
2016-04-27 19:27:56 +03:00
|
|
|
|
2018-05-22 12:46:35 +03:00
|
|
|
If the diff is landing, show "Landing" in place of the status name
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
|
|
> [{"data": {"query": [{"results": {"nodes": [
|
|
|
|
> {"number": 1, "diff_status_name": "Accepted",
|
|
|
|
> "created_time": 0, "updated_time": 2, "is_landing": true}
|
|
|
|
> ]}}]}}]
|
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
|
|
Landing
|
|
|
|
|
2016-04-27 19:27:56 +03:00
|
|
|
And finally, the success case
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [
|
2018-03-08 01:32:31 +03:00
|
|
|
> {"number": 1, "diff_status_name": "Needs Review",
|
2018-05-22 12:46:35 +03:00
|
|
|
> "created_time": 0, "updated_time": 2, "is_landing": false}
|
2018-02-07 12:53:45 +03:00
|
|
|
> ]}}]}}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
|
|
|
Needs Review
|
|
|
|
|
2017-07-06 19:38:14 +03:00
|
|
|
Make sure the code works without the smartlog extensions
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [
|
2018-03-08 01:32:31 +03:00
|
|
|
> {"number": 1, "diff_status_name": "Needs Review",
|
2018-05-22 12:46:35 +03:00
|
|
|
> "created_time": 0, "updated_time": 2, "is_landing": false}
|
2018-02-07 12:53:45 +03:00
|
|
|
> ]}}]}}]
|
2017-07-06 19:38:14 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg --config 'extensions.smartlog=!' log -T '{phabstatus}\n' -r .
|
|
|
|
Needs Review
|
|
|
|
|
templates: fix help messages for template keywords
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
2017-01-19 23:52:54 +03:00
|
|
|
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
|
phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.
The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.
This also fixes the phabstatus warning messages to end with a newline.
Test Plan: Added a unit test.
Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy
Reviewed By: wez, rmcelroy
Subscribers: rmcelroy, net-systems-diffs@fb.com, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4800977
Tasks: 17002914
Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 21:55:39 +03:00
|
|
|
|
|
|
|
Make sure we get decent error messages when .arcrc is missing credential
|
|
|
|
information. We intentionally do not use HG_ARC_CONDUIT_MOCK for this test,
|
|
|
|
so it tries to parse the (empty) arc config files.
|
|
|
|
|
2017-12-14 21:28:30 +03:00
|
|
|
$ echo '{}' > .arcrc
|
|
|
|
$ echo '{}' > .arcconfig
|
phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.
The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.
This also fixes the phabstatus warning messages to end with a newline.
Test Plan: Added a unit test.
Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy
Reviewed By: wez, rmcelroy
Subscribers: rmcelroy, net-systems-diffs@fb.com, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4800977
Tasks: 17002914
Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 21:55:39 +03:00
|
|
|
$ hg log -T '{phabstatus}\n' -r .
|
|
|
|
arcconfig configuration problem. No diff information can be provided.
|
2018-12-19 21:25:11 +03:00
|
|
|
Error info: arcrc is missing user credentials. use "jf authenticate" to fix, or ensure you are prepping your arcrc properly.
|
phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.
The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.
This also fixes the phabstatus warning messages to end with a newline.
Test Plan: Added a unit test.
Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy
Reviewed By: wez, rmcelroy
Subscribers: rmcelroy, net-systems-diffs@fb.com, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4800977
Tasks: 17002914
Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 21:55:39 +03:00
|
|
|
Error
|
2018-01-12 13:46:25 +03:00
|
|
|
|
|
|
|
Make sure we get an error message if .arcrc is not proper JSON (for example
|
|
|
|
due to trailing commas). We do not use HG_ARC_CONDUIT_MOCK for this test,
|
|
|
|
in order for it to parse the badly formatted arc config file.
|
|
|
|
|
|
|
|
$ echo '{,}' > ../.arcrc
|
|
|
|
$ hg log -T '{phabstatus}\n' -r .
|
|
|
|
arcconfig configuration problem. No diff information can be provided.
|
|
|
|
Error info: Configuration file $TESTTMP/.arcrc is not a proper JSON file.
|
|
|
|
Error
|