Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apis/phabricator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def submit_to_phabricator(rev_id):
# Chain revisions together if needed
@retry
def chain_revisions(parent_rev, child_rev):
# First get the PHID of the revision
cmd = "echo " + quote_echo_string("""{"constraints": {"ids":[%s]}}""" % child_rev)
# First get the PHID of the parent revision
cmd = "echo " + quote_echo_string("""{"constraints": {"ids":[%s]}}""" % parent_rev)
cmd += " | %s call-conduit --conduit-uri=%s differential.revision.search --""" % (_arc(), self.url)

ret = self.run(cmd, shell=True)
Expand All @@ -90,26 +90,26 @@ def chain_revisions(parent_rev, child_rev):
raise Exception("Could not decode response as JSON: %s" % ret.stdout.decode())

if result['error']:
raise Exception("Got an error from phabricator when trying to search for %s" % (child_rev))
raise Exception("Got an error from phabricator when trying to search for %s" % (parent_rev))

assert 'response' in result
assert 'data' in result['response']
if len(result['response']['data']) != 1:
raise Exception("When querying conduit for diff %s, we got back %i results"
% (child_rev, len(result['response']['data'])))
% (parent_rev, len(result['response']['data'])))

child_phid = result['response']['data'][0]['phid']
parent_phid = result['response']['data'][0]['phid']

# Now connect them
cmd = "echo " + quote_echo_string("""{"transactions": [{"type":"parents.add", "value":["%s"]}], "objectIdentifier": "%s"}""" % (child_phid, parent_rev))
# Now connect them - add parent as parent of child
cmd = "echo " + quote_echo_string("""{"transactions": [{"type":"parents.add", "value":["%s"]}], "objectIdentifier": "%s"}""" % (parent_phid, child_rev))
cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --""" % (_arc(), self.url)
ret = self.run(cmd, shell=True)
try:
result = json.loads(ret.stdout.decode())
except Exception:
raise Exception("Could not decode response as JSON: %s" % ret.stdout.decode())
if result['error']:
raise Exception("Got an error from phabricator when trying chain revisions, parent: %s, child %s %s" % (parent_rev, child_rev, child_phid))
raise Exception("Got an error from phabricator when trying chain revisions, parent: %s, child %s %s" % (parent_rev, child_rev, parent_phid))

parent_rev = phab_revisions[0]
for child_rev in phab_revisions[1:]:
Expand Down