( )⚙ D1608 phabricator: switch hgext from conduit to graphql

This is an archive of the discontinued Mercurial Phabricator instance.

phabricator: switch hgext from conduit to graphql
ClosedPublic

Authored by medson on Dec 6 2017, 3:42 PM.
Tags
None
Subscribers

Details

Reviewers
quark
Group Reviewers
Restricted Project
Commits
rFBHGXe898a50bf5cd: phabricator: switch hgext from conduit to graphql
Summary

There are two usages that I found and switched over

  1. hg ssl
  2. hg diff --since-last-arc-diff

The new phabricator_graphql_client.py file came mostly from
fbsource/fbcode/phabricator, but I had to modify it so it could use the lightweight url client instead of the (unavailable) thirdparty "requests" library

This requires the config changes in D6495153, and replaces D5339248

Test Plan

ran "hg ssl" on www and fbsource on my sandbox, and verified that it looked the same before & after my changes.
ran "hg diff --since-last-arc-diff" on a modified workspace, and an unmodified workspace (unmodified results differ, so i'll tidy those up and edit this comment away from the test plan once they match)

I tested both of these steps using an .arcrc containing only username/cert, and one containing username/oauth. I don't think there are any other combinations of .arcrc's around.

To help with review, here's an example. When I do "hg ssl" in a directory with lots of open & closed revisions:

it calls graphql.getrevisioninfo() with

('1608', '1602')

That results in the graphql call like this:

Query:

query RevisionQuery(
  $params:[DifferentialRevisionQueryParams!]!
) {
  differential_revision_query(query_params: $params) {
    results {
      nodes {
        number
        diff_status_name
        latest_active_diff {
        	local_commit_info: diff_properties (
            property_names: ["local:commits"]
          ) {
            nodes {
              property_value
            }
          }
        }
        differential_diffs {
          count
        }
      }
    }
  }
}

Data:

{
  "params": {
    "numbers": [
      "1608",
      "1602"
    ]
  }
}

Response:

{
  "data": {
    "differential_revision_query": [
      {
        "results": {
          "nodes": [
            {
              "number": 1602,
              "diff_status_name": "Closed",
              "latest_active_diff": {
                "local_commit_info": {
                  "nodes": []
                }
              },
              "differential_diffs": {
                "count": 2
              }
            },
            {
              "number": 1608,
              "diff_status_name": "Closed",
              "latest_active_diff": {
                "local_commit_info": {
                  "nodes": []
                }
              },
              "differential_diffs": {
                "count": 1
              }
            }
          ]
        }
      }
    ]
  }
}

which is then post-processed by the getrevisioninfo() function and returned as:

{'1608': {'status': 'Committed', 'count': 1}, '1602': {'status': 'Committed', 'count': 2}}

If you do "hg ssl" in a repo that can respond to the "--since-last-arc-diff" extension, you'll get a graphql response like this:

{
  "data": {
    "differential_revision_query": [
      {
        "results": {
          "nodes": [
            {
              "number": 5197950,
              "diff_status_name": "Needs Revision",
              "latest_active_diff": {
                "local_commit_info": {
                  "nodes": [
                    {
                      "property_value": "{\"baaf3583b9d99b4bafbabc74b629dde07f3130fe\":{\"author\":\"Mark Edson\",\"time\":1496799878,\"branch\":\"default\",\"tag\":\"\",\"commit\":\"baaf3583b9d99b4bafbabc74b629dde07f3130fe\",\"rev\":\"baaf3583b9d99b4bafbabc74b629dde07f3130fe\",\"local\":\"1767197\",\"parents\":[\"2609278551467eda7fa8f9a708606ff66e4bc6de\"],\"summary\":\"Add a script to detect race-condition deletes of accepting reviewers\",\"message\":\"Add a script to detect race-condition deletes of accepting reviewers\\n\\nSummary:\\nWe know this happens, but we don't really know how often it happens, or how\\nmuch time it takes for acceptors to re-accept.  This script will figure out how\\noften it happens, and track time between removal & reaccepting.  It's not 100\\u0025\\naccurate (I found a couple where someone intentionally deleted an accepting\\nreviewer, but almost all of these revisions have some \\\"hey, wtf.  my reviewer\\ngot deleted!\\\" comments in them).\\n\\nTest Plan:\\nTo check all of the created revisions between Jan 1st and today, use this\\ncmdline:\\n\\n.\\/scripts\\/intern\\/phabricator\\/check_racy_badness.php -f 4376105 -t 5196923 -c 50\\n\\nReviewers: #phabricator\\n\\nDifferential Revision: https:\\/\\/phabricator.intern.facebook.com\\/D5197950\",\"authorEmail\":\"medson\\u0040fb.com\"}}"
                    }
                  ]
                }
              },
              "differential_diffs": {
                "count": 1
              }
            }
          ]
        }
      }
    ]
  }
}

And the getrevisioninfo() function will return something like this:

{'5197950': {'status': u'Needs Revision', 'count': 1, 'hash': u'baaf3583b9d99b4bafbabc74b629dde07f3130fe'}}

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

medson created this revision.Dec 6 2017, 3:42 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptDec 6 2017, 3:42 PM
medson edited the test plan for this revision. (Show Details)Dec 6 2017, 3:43 PM
medson planned changes to this revision.Dec 6 2017, 3:48 PM

Bummer. I knew I forgot something.
I need to add the OAuth stuff so the connections will prefer the oauth key if it's in the .arcrc

medson edited the test plan for this revision. (Show Details)Dec 7 2017, 1:51 PM
medson updated this revision to Diff 4167.
medson edited the test plan for this revision. (Show Details)Dec 7 2017, 2:07 PM
medson edited the test plan for this revision. (Show Details)Dec 12 2017, 5:41 PM
quark accepted this revision.Dec 13 2017, 9:39 PM
quark added a subscriber: quark.

Thanks for doing this!

phabricator/graphql.py
91

Maybe use docstring '''?

tests/test-check-py3-compat-hg.t
78–80

These could be solved by adding at the top:

from __future__ import absolute_import
This revision is now accepted and ready to land.Dec 13 2017, 9:39 PM
medson added inline comments.Dec 14 2017, 1:29 PM
tests/test-check-py3-compat-hg.t
78–80

I tried that, but it made a bunch of tests fail with "abort: no module named arcconfig!", so I left it as-is.

quark added inline comments.Dec 14 2017, 1:32 PM
tests/test-check-py3-compat-hg.t
78–80

Ok. I can follow-up cleaning up them.

from phabricator import needs to be changed to relative import. That could be done by moving phabricator directory to hgext3rd and use from .phabricator in files under hgext3rd.

medson edited the test plan for this revision. (Show Details)Dec 14 2017, 1:38 PM
medson updated this revision to Diff 4431.
medson added inline comments.Dec 14 2017, 1:40 PM
tests/test-check-py3-compat-hg.t
78–80

Great, thanks. I've pushed this commit out, but public phabricator hasn't caught it yet, so it doesn't show committed. I'm assuming if I'm just patient, it'll figure it out.
Thanks for the review & suggestions.

medson edited the test plan for this revision. (Show Details)Dec 14 2017, 2:04 PM
medson closed this revision.Dec 15 2017, 10:45 AM

Not sure why this didn't auto-close. It landed as:

changeset: e898a50bf5cd346fbf8aac3efcaa2d2ccf206a6f D1608
user: Mark Edson <medson@fb.com>
date: Thu, 14 Dec 2017 10:28:30 -0800
summary: phabricator: switch hgext from conduit to graphql

phabricator/arcconfig.py