From patchwork Sat Oct 12 13:46:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7055: phabricator: update hgmatcher to cope with the new data format From: phabricator X-Patchwork-Id: 42265 Message-Id: <7064d8895abfe04d2d55bdb63462c444@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 12 Oct 2019 13:46:11 +0000 Kwan added a comment. Kwan updated this revision to Diff 17105. I'd missed out the attrs key conversion needed on py3. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7055?vs=17085&id=17105 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7055/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7055 AFFECTED FILES hgext/phabricator.py CHANGE DETAILS To: Kwan, #hg-reviewers Cc: mercurial-devel diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -144,9 +144,21 @@ def hgmatcher(r1, r2): if r1.uri != r2.uri or r1.method != r2.method: return False - r1params = r1.body.split(b'&') - r2params = r2.body.split(b'&') - return set(r1params) == set(r2params) + r1params = util.urlreq.parseqs(r1.body) + r2params = util.urlreq.parseqs(r2.body) + for key in r1params: + if key not in r2params: + return False + value = r1params[key][0] + # we want to compare json payloads without worrying about ordering + if value.startswith(b'{') and value.endswith(b'}'): + r1json = json.loads(value) + r2json = json.loads(r2params[key][0]) + if r1json != r2json: + return False + elif r2params[key][0] != value: + return False + return True def sanitiserequest(request): request.body = re.sub(