2016-08-05 21:33:36 +03:00
|
|
|
Setup
|
|
|
|
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
2018-01-10 19:39:19 +03:00
|
|
|
> arcconfig=$TESTDIR/../hgext/extlib/phabricator/arcconfig.py
|
|
|
|
> phabstatus=
|
|
|
|
> smartlog=
|
2016-08-05 21:33:36 +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 '{syncstatus}\n' -r .
|
|
|
|
arcconfig configuration problem. No diff information can be provided.
|
2017-03-31 13:26:04 +03:00
|
|
|
Error info: no .arcconfig found
|
|
|
|
Error
|
2016-08-05 21:33:36 +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-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
And now with bad responses:
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:43 +03:00
|
|
|
> [{}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
|
|
|
Error info: Unexpected graphql response format
|
|
|
|
Error
|
2016-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"errors": [{"message": "failed, yo"}]}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
2017-03-31 13:26:04 +03:00
|
|
|
Error info: failed, yo
|
|
|
|
Error
|
2016-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
Missing status field is treated as an error
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [{
|
2018-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
|
|
|
> ]
|
|
|
|
> }
|
|
|
|
> },
|
2018-03-08 01:32:31 +03:00
|
|
|
> "differential_diffs": {"count": 3},
|
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
|
|
|
Error info: Unexpected graphql response format
|
|
|
|
Error
|
2016-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
Missing count field is treated as an error
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [{
|
2018-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "diff_status_name": "Approved",
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
|
|
|
> ]
|
2018-02-07 12:53:38 +03:00
|
|
|
> }
|
2018-03-08 01:32:31 +03:00
|
|
|
> },
|
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
2018-02-07 12:53:52 +03:00
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
|
|
|
Error talking to phabricator. No diff information can be provided.
|
|
|
|
Error info: Unexpected graphql response format
|
|
|
|
Error
|
2016-08-05 21:33:36 +03:00
|
|
|
|
2018-02-07 12:53:38 +03:00
|
|
|
Missing hash field is treated as unsync
|
2016-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [{
|
2018-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "diff_status_name": "Approved",
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0}}"}
|
|
|
|
> ]
|
|
|
|
> }
|
|
|
|
> },
|
2018-03-08 01:32:31 +03:00
|
|
|
> "differential_diffs": {"count": 3},
|
2018-05-22 12:46:35 +03:00
|
|
|
> "is_landing": false,
|
2018-03-08 01:32:31 +03:00
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
2018-02-07 12:53:38 +03:00
|
|
|
unsync
|
2016-08-05 21:33:36 +03:00
|
|
|
|
|
|
|
And finally, the success case
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
2018-02-07 12:53:45 +03:00
|
|
|
> [{"data": {"query": [{"results": {"nodes": [{
|
2018-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "diff_status_name": "Committed",
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
|
|
|
> ]
|
|
|
|
> }
|
|
|
|
> },
|
2018-03-08 01:32:31 +03:00
|
|
|
> "differential_diffs": {"count": 3},
|
2018-05-22 12:46:35 +03:00
|
|
|
> "is_landing": false,
|
2018-03-08 01:32:31 +03:00
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-08-05 21:33:36 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
|
|
|
committed
|