From 2a268ae38f9219dfddd91f36239f48e36ab7cc80 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 24 Jun 2025 15:59:46 +0200 Subject: [PATCH] Fix inversed parent / child relationship when chaining revisions together --- apis/phabricator.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apis/phabricator.py b/apis/phabricator.py index 384909f..16f39b2 100644 --- a/apis/phabricator.py +++ b/apis/phabricator.py @@ -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) @@ -90,18 +90,18 @@ 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: @@ -109,7 +109,7 @@ def chain_revisions(parent_rev, child_rev): 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:]: