2016-04-27 19:27:56 +03:00
|
|
|
Load extensions
|
|
|
|
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
2018-01-10 19:39:19 +03:00
|
|
|
> arcconfig=$TESTDIR/../hgext/extlib/phabricator/arcconfig.py
|
|
|
|
> arcdiff=
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
Diff with no revision
|
|
|
|
|
|
|
|
$ hg init repo
|
|
|
|
$ cd repo
|
|
|
|
$ touch foo
|
|
|
|
$ hg add foo
|
|
|
|
$ hg ci -qm 'No rev'
|
|
|
|
$ hg diff --since-last-arc-diff
|
2016-09-22 17:44:34 +03:00
|
|
|
abort: local changeset is not associated with a differential revision
|
2016-04-27 19:27:56 +03:00
|
|
|
[255]
|
|
|
|
|
|
|
|
Fake a diff
|
|
|
|
|
|
|
|
$ echo bleet > foo
|
|
|
|
$ hg ci -qm 'Differential Revision: https://phabricator.fb.com/D1'
|
|
|
|
$ hg diff --since-last-arc-diff
|
|
|
|
abort: no .arcconfig found
|
|
|
|
[255]
|
|
|
|
|
|
|
|
Prep configuration
|
|
|
|
|
|
|
|
$ 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
|
|
|
|
|
|
|
Now progressively test the response handling for variations of missing data
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
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 diff --since-last-arc-diff
|
|
|
|
Error calling graphql: Unexpected graphql response format
|
|
|
|
abort: unable to determine previous changeset hash
|
|
|
|
[255]
|
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-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "diff_status_name": "Needs Review",
|
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-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
2016-09-22 17:44:34 +03:00
|
|
|
abort: unable to determine previous changeset hash
|
2016-04-27 19:27:56 +03:00
|
|
|
[255]
|
|
|
|
|
|
|
|
$ 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,
|
2018-03-08 01:32:31 +03:00
|
|
|
> "diff_status_name": "Needs Review",
|
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
2016-09-22 17:44:34 +03:00
|
|
|
abort: unable to determine previous changeset hash
|
2016-04-27 19:27:56 +03:00
|
|
|
[255]
|
|
|
|
|
|
|
|
This is the case when the diff is up to date with the current commit;
|
|
|
|
there is no diff since what was landed.
|
|
|
|
|
|
|
|
$ 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": "Needs Review",
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"2e6531b7dada2a3e5638e136de05f51e94a427f4\"}}"}
|
|
|
|
> ]
|
|
|
|
> }
|
|
|
|
> },
|
2018-03-08 01:32:31 +03:00
|
|
|
> "differential_diffs": {"count": 1},
|
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
|
|
|
|
|
|
|
This is the case when the diff points at our parent commit, we expect to
|
2016-05-12 23:11:08 +03:00
|
|
|
see the bleet text show up. There's a fake hash that I've injected into
|
|
|
|
the commit list returned from our mocked phabricator; it is present to
|
|
|
|
assert that we order the commits consistently based on the time field.
|
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-02-07 12:53:43 +03:00
|
|
|
> "number": 1,
|
|
|
|
> "diff_status_name": "Needs Review",
|
|
|
|
> "latest_active_diff": {
|
|
|
|
> "local_commit_info": {
|
|
|
|
> "nodes": [
|
|
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"88dd5a13bf28b99853a24bddfc93d4c44e07c6bd\"}}"}
|
|
|
|
> ]
|
|
|
|
> }
|
|
|
|
> },
|
2018-03-08 01:32:31 +03:00
|
|
|
> "differential_diffs": {"count": 1},
|
|
|
|
> "created_time": 123,
|
|
|
|
> "updated_time": 222
|
2018-02-07 12:53:45 +03:00
|
|
|
> }]}}]}}]
|
2016-04-27 19:27:56 +03:00
|
|
|
> EOF
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff --nodates
|
2018-02-23 20:36:39 +03:00
|
|
|
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
|
|
|
|
--- a/foo
|
|
|
|
+++ b/foo
|
|
|
|
@@ -0,0 +1,1 @@
|
|
|
|
+bleet
|
|
|
|
|
|
|
|
Make a new commit on top, and then use -r to look at the previous commit
|
|
|
|
$ echo other > foo
|
|
|
|
$ hg commit -m "Other commmit"
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff --nodates -r 2e6531b
|
|
|
|
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
|
2016-04-27 19:27:56 +03:00
|
|
|
--- a/foo
|
|
|
|
+++ b/foo
|
|
|
|
@@ -0,0 +1,1 @@
|
|
|
|
+bleet
|