Mercurial > hg-stable
changeset 42447:29528c4235a1
phabricator: add commenting to phabsend for new/updated Diffs
Especially useful when sending updates to existing Revisions so one can specify
the sort of changes e.g. "Address review comments" or "Rebase to tip"
If the diff content hasn't changed then it only needs a metadata update which
doesn't show in the Phabricator updates UI, so don't add a comment that will.
Differential Revision: https://phab.mercurial-scm.org/D6496
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Fri, 07 Jun 2019 20:19:55 +0100 |
parents | 5b217451a2c2 |
children | bc7b07bb36cc |
files | hgext/phabricator.py tests/phabricator/phabsend-comment-created.json tests/phabricator/phabsend-comment-updated.json tests/test-phabricator.t |
diffstat | 4 files changed, 1254 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/phabricator.py Wed Jun 05 22:09:26 2019 +0300 +++ b/hgext/phabricator.py Fri Jun 07 20:19:55 2019 +0100 @@ -416,7 +416,7 @@ callconduit(ctx.repo(), b'differential.setdiffproperty', params) def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, - olddiff=None, actions=None): + olddiff=None, actions=None, comment=None): """create or update a Differential Revision If revid is None, create a new Differential Revision, otherwise update @@ -439,6 +439,8 @@ if neednewdiff: diff = creatediff(ctx) transactions.append({b'type': b'update', b'value': diff[b'phid']}) + if comment: + transactions.append({b'type': b'comment', b'value': comment}) else: # Even if we don't need to upload a new diff because the patch content # does not change. We might still need to update its metadata so @@ -497,6 +499,8 @@ [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')), (b'', b'amend', True, _(b'update commit messages')), (b'', b'reviewer', [], _(b'specify reviewers')), + (b'm', b'comment', b'', + _(b'add a comment to Revisions with new/updated Diffs')), (b'', b'confirm', None, _(b'ask for confirmation before sending'))], _(b'REV [OPTIONS]'), helpcategory=command.CATEGORY_IMPORT_EXPORT) @@ -567,7 +571,8 @@ if oldnode != ctx.node() or opts.get(b'amend'): # Create or update Differential Revision revision, diff = createdifferentialrevision( - ctx, revid, lastrevid, oldnode, olddiff, actions) + ctx, revid, lastrevid, oldnode, olddiff, actions, + opts.get(b'comment')) diffmap[ctx.node()] = diff newrevid = int(revision[b'object'][b'id']) if revid:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/phabricator/phabsend-comment-created.json Fri Jun 07 20:19:55 2019 +0100 @@ -0,0 +1,653 @@ +{ + "version": 1, + "interactions": [ + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":{\"data\":[{\"id\":12,\"type\":\"REPO\",\"phid\":\"PHID-REPO-bvunnehri4u2isyr7bc3\",\"fields\":{\"name\":\"Mercurial\",\"vcs\":\"hg\",\"callsign\":\"HG\",\"shortName\":\"Mercurial\",\"status\":\"active\",\"isImporting\":false,\"almanacServicePHID\":null,\"refRules\":{\"fetchRules\":[],\"trackRules\":[],\"permanentRefRules\":[]},\"spacePHID\":null,\"dateCreated\":1523292927,\"dateModified\":1523297359,\"policy\":{\"view\":\"public\",\"edit\":\"admin\",\"diffusion.push\":\"users\"}},\"attachments\":{}}],\"maps\":{},\"query\":{\"queryKey\":null},\"cursor\":{\"limit\":100,\"after\":null,\"before\":null,\"order\":null}},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:04 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "587" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/diffusion.repository.search", + "body": "constraints%5Bcallsigns%5D%5B0%5D=HG&api.token=cli-hahayouwish", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "81" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":{\"id\":1989,\"phid\":\"PHID-DIFF-3mtjdk4tjjkaw4arccah\",\"uri\":\"https:\\/\\/phab.mercurial-scm.org\\/differential\\/diff\\/1989\\/\"},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:05 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "172" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.createrawdiff", + "body": "repositoryPHID=PHID-REPO-bvunnehri4u2isyr7bc3&diff=diff+--git+a%2Fcomment+b%2Fcomment%0Anew+file+mode+100644%0A---+%2Fdev%2Fnull%0A%2B%2B%2B+b%2Fcomment%0A%40%40+-0%2C0+%2B1%2C1+%40%40%0A%2Bcomment%0A&api.token=cli-hahayouwish", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "243" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:06 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "51" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "body": "api.token=cli-hahayouwish&data=%7B%22branch%22%3A+%22default%22%2C+%22date%22%3A+%220+0%22%2C+%22node%22%3A+%22a7ee4bac036ae424bfc9e1a4228c4fa06d637f53%22%2C+%22parent%22%3A+%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%2C+%22user%22%3A+%22test%22%7D&name=hg%3Ameta&diff_id=1989", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "296" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:07 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "51" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "body": "api.token=cli-hahayouwish&data=%7B%22a7ee4bac036ae424bfc9e1a4228c4fa06d637f53%22%3A+%7B%22author%22%3A+%22test%22%2C+%22authorEmail%22%3A+%22test%22%2C+%22branch%22%3A+%22default%22%2C+%22commit%22%3A+%22a7ee4bac036ae424bfc9e1a4228c4fa06d637f53%22%2C+%22parents%22%3A+%5B%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%5D%2C+%22time%22%3A+0%7D%7D&name=local%3Acommits&diff_id=1989", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "396" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":{\"errors\":[],\"fields\":{\"title\":\"create comment for phabricator test\"},\"revisionIDFieldInfo\":{\"value\":null,\"validDomain\":\"https:\\/\\/phab.mercurial-scm.org\"},\"transactions\":[{\"type\":\"title\",\"value\":\"create comment for phabricator test\"}]},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:07 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "288" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.parsecommitmessage", + "body": "corpus=create+comment+for+phabricator+test&api.token=cli-hahayouwish", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "85" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":{\"object\":{\"id\":1253,\"phid\":\"PHID-DREV-4rhqd6v3yxbtodc7wbv7\"},\"transactions\":[{\"phid\":\"PHID-XACT-DREV-g73sutb5nezcyh6\"},{\"phid\":\"PHID-XACT-DREV-yg6ysul7pcxtqce\"},{\"phid\":\"PHID-XACT-DREV-vxhpgk64u3kax45\"},{\"phid\":\"PHID-XACT-DREV-mkt5rq3racrpzhe\"},{\"phid\":\"PHID-XACT-DREV-s7la723tgqhwovt\"}]},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:08 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "336" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.revision.edit", + "body": "transactions%5B0%5D%5Bvalue%5D=PHID-DIFF-3mtjdk4tjjkaw4arccah&transactions%5B0%5D%5Btype%5D=update&transactions%5B1%5D%5Bvalue%5D=For+default+branch&transactions%5B1%5D%5Btype%5D=comment&transactions%5B2%5D%5Bvalue%5D=create+comment+for+phabricator+test&transactions%5B2%5D%5Btype%5D=title&api.token=cli-hahayouwish", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "332" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":[{\"id\":\"1253\",\"phid\":\"PHID-DREV-4rhqd6v3yxbtodc7wbv7\",\"title\":\"create comment for phabricator test\",\"uri\":\"https:\\/\\/phab.mercurial-scm.org\\/D1253\",\"dateCreated\":\"1559938988\",\"dateModified\":\"1559938988\",\"authorPHID\":\"PHID-USER-qmzis76vb2yh3ogldu6r\",\"status\":\"0\",\"statusName\":\"Draft\",\"properties\":{\"draft.broadcast\":false,\"lines.added\":1,\"lines.removed\":0},\"branch\":null,\"summary\":\"\",\"testPlan\":\"\",\"lineCount\":\"1\",\"activeDiffPHID\":\"PHID-DIFF-3mtjdk4tjjkaw4arccah\",\"diffs\":[\"1989\"],\"commits\":[],\"reviewers\":[],\"ccs\":[],\"hashes\":[],\"auxiliary\":{\"bugzilla.bug-id\":null,\"phabricator:projects\":[\"PHID-PROJ-f2a3wl5wxtqdtfgdjqzk\"],\"phabricator:depends-on\":[]},\"repositoryPHID\":\"PHID-REPO-bvunnehri4u2isyr7bc3\",\"sourcePath\":null}],\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:09 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "773" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.query", + "body": "api.token=cli-hahayouwish&ids%5B0%5D=1253", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "58" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:10 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "51" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "body": "api.token=cli-hahayouwish&data=%7B%22branch%22%3A+%22default%22%2C+%22date%22%3A+%220+0%22%2C+%22node%22%3A+%2281fce7de1b7d8ea6b8309a58058d3b5793506c34%22%2C+%22parent%22%3A+%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%2C+%22user%22%3A+%22test%22%7D&name=hg%3Ameta&diff_id=1989", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "296" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + }, + { + "response": { + "status": { + "message": "OK", + "code": 200 + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "date": [ + "Fri, 07 Jun 2019 20:23:10 GMT" + ], + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "x-content-type-options": [ + "nosniff" + ], + "vary": [ + "Accept-Encoding" + ], + "cache-control": [ + "no-store" + ], + "content-length": [ + "51" + ], + "connection": [ + "keep-alive" + ], + "content-type": [ + "application/json" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-frame-options": [ + "Deny" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ] + } + }, + "request": { + "method": "POST", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "body": "api.token=cli-hahayouwish&data=%7B%2281fce7de1b7d8ea6b8309a58058d3b5793506c34%22%3A+%7B%22author%22%3A+%22test%22%2C+%22authorEmail%22%3A+%22test%22%2C+%22branch%22%3A+%22default%22%2C+%22commit%22%3A+%2281fce7de1b7d8ea6b8309a58058d3b5793506c34%22%2C+%22parents%22%3A+%5B%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%5D%2C+%22time%22%3A+0%7D%7D&name=local%3Acommits&diff_id=1989", + "headers": { + "accept": [ + "application/mercurial-0.1" + ], + "content-type": [ + "application/x-www-form-urlencoded" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "396" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ] + } + } + } + ] +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/phabricator/phabsend-comment-updated.json Fri Jun 07 20:19:55 2019 +0100 @@ -0,0 +1,581 @@ +{ + "interactions": [ + { + "request": { + "method": "POST", + "body": "api.token=cli-hahayouwish&revisionIDs%5B0%5D=1253", + "uri": "https://phab.mercurial-scm.org//api/differential.querydiffs", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "66" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":{\"1989\":{\"id\":\"1989\",\"revisionID\":\"1253\",\"dateCreated\":\"1559938985\",\"dateModified\":\"1559938988\",\"sourceControlBaseRevision\":null,\"sourceControlPath\":null,\"sourceControlSystem\":null,\"branch\":null,\"bookmark\":null,\"creationMethod\":\"web\",\"description\":null,\"unitStatus\":\"4\",\"lintStatus\":\"4\",\"changes\":[{\"id\":\"5273\",\"metadata\":{\"line:first\":1,\"hash.effect\":\"mzg_LBhhVYqb\"},\"oldPath\":null,\"currentPath\":\"comment\",\"awayPaths\":[],\"oldProperties\":[],\"newProperties\":{\"unix:filemode\":\"100644\"},\"type\":\"1\",\"fileType\":\"1\",\"commitHash\":null,\"addLines\":\"1\",\"delLines\":\"0\",\"hunks\":[{\"oldOffset\":\"0\",\"newOffset\":\"1\",\"oldLength\":\"0\",\"newLength\":\"1\",\"addLines\":null,\"delLines\":null,\"isMissingOldNewline\":null,\"isMissingNewNewline\":null,\"corpus\":\"+comment\\n\"}]}],\"properties\":{\"hg:meta\":{\"branch\":\"default\",\"date\":\"0 0\",\"node\":\"0025df7d064f9c916862d19e207429a0f799fa7d\",\"parent\":\"a19f1434f9a578325eb9799c9961b5465d4e6e40\",\"user\":\"test\"},\"local:commits\":{\"0025df7d064f9c916862d19e207429a0f799fa7d\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"0025df7d064f9c916862d19e207429a0f799fa7d\",\"parents\":[\"a19f1434f9a578325eb9799c9961b5465d4e6e40\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"}},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:26:57 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "1243" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "constraints%5Bcallsigns%5D%5B0%5D=HG&api.token=cli-hahayouwish", + "uri": "https://phab.mercurial-scm.org//api/diffusion.repository.search", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "81" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":{\"data\":[{\"id\":12,\"type\":\"REPO\",\"phid\":\"PHID-REPO-bvunnehri4u2isyr7bc3\",\"fields\":{\"name\":\"Mercurial\",\"vcs\":\"hg\",\"callsign\":\"HG\",\"shortName\":\"Mercurial\",\"status\":\"active\",\"isImporting\":false,\"almanacServicePHID\":null,\"refRules\":{\"fetchRules\":[],\"trackRules\":[],\"permanentRefRules\":[]},\"spacePHID\":null,\"dateCreated\":1523292927,\"dateModified\":1523297359,\"policy\":{\"view\":\"public\",\"edit\":\"admin\",\"diffusion.push\":\"users\"}},\"attachments\":{}}],\"maps\":{},\"query\":{\"queryKey\":null},\"cursor\":{\"limit\":100,\"after\":null,\"before\":null,\"order\":null}},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:26:58 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "587" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "repositoryPHID=PHID-REPO-bvunnehri4u2isyr7bc3&api.token=cli-hahayouwish&diff=diff+--git+a%2Fcomment+b%2Fcomment%0Anew+file+mode+100644%0A---+%2Fdev%2Fnull%0A%2B%2B%2B+b%2Fcomment%0A%40%40+-0%2C0+%2B1%2C2+%40%40%0A%2Bcomment%0A%2Bcomment2%0A", + "uri": "https://phab.mercurial-scm.org//api/differential.createrawdiff", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "257" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":{\"id\":1990,\"phid\":\"PHID-DIFF-xfa4yzc5h2cvjfhpx4dv\",\"uri\":\"https:\\/\\/phab.mercurial-scm.org\\/differential\\/diff\\/1990\\/\"},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:26:59 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "172" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "diff_id=1990&data=%7B%22branch%22%3A+%22default%22%2C+%22date%22%3A+%220+0%22%2C+%22node%22%3A+%221acd4b60af38c934182468719a8a431248f49bef%22%2C+%22parent%22%3A+%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%2C+%22user%22%3A+%22test%22%7D&api.token=cli-hahayouwish&name=hg%3Ameta", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "296" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:26:59 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "51" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "diff_id=1990&data=%7B%221acd4b60af38c934182468719a8a431248f49bef%22%3A+%7B%22author%22%3A+%22test%22%2C+%22authorEmail%22%3A+%22test%22%2C+%22branch%22%3A+%22default%22%2C+%22commit%22%3A+%221acd4b60af38c934182468719a8a431248f49bef%22%2C+%22parents%22%3A+%5B%22a19f1434f9a578325eb9799c9961b5465d4e6e40%22%5D%2C+%22time%22%3A+0%7D%7D&api.token=cli-hahayouwish&name=local%3Acommits", + "uri": "https://phab.mercurial-scm.org//api/differential.setdiffproperty", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "396" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":null,\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:27:00 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "51" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "api.token=cli-hahayouwish&corpus=create+comment+for+phabricator+test%0A%0ADifferential+Revision%3A+https%3A%2F%2Fphab.mercurial-scm.org%2FD1253", + "uri": "https://phab.mercurial-scm.org//api/differential.parsecommitmessage", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "165" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":{\"errors\":[],\"fields\":{\"title\":\"create comment for phabricator test\",\"revisionID\":1253},\"revisionIDFieldInfo\":{\"value\":1253,\"validDomain\":\"https:\\/\\/phab.mercurial-scm.org\"},\"transactions\":[{\"type\":\"title\",\"value\":\"create comment for phabricator test\"}]},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:27:01 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "306" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "api.token=cli-hahayouwish&transactions%5B0%5D%5Btype%5D=update&transactions%5B0%5D%5Bvalue%5D=PHID-DIFF-xfa4yzc5h2cvjfhpx4dv&transactions%5B1%5D%5Btype%5D=comment&transactions%5B1%5D%5Bvalue%5D=Address+review+comments&transactions%5B2%5D%5Btype%5D=title&transactions%5B2%5D%5Bvalue%5D=create+comment+for+phabricator+test&objectIdentifier=1253", + "uri": "https://phab.mercurial-scm.org//api/differential.revision.edit", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "359" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":{\"object\":{\"id\":1253,\"phid\":\"PHID-DREV-4rhqd6v3yxbtodc7wbv7\"},\"transactions\":[{\"phid\":\"PHID-XACT-DREV-punz3dredrxghth\"},{\"phid\":\"PHID-XACT-DREV-ykwxppmzdgrtgye\"}]},\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:27:02 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "210" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + }, + { + "request": { + "method": "POST", + "body": "api.token=cli-hahayouwish&ids%5B0%5D=1253", + "uri": "https://phab.mercurial-scm.org//api/differential.query", + "headers": { + "content-type": [ + "application/x-www-form-urlencoded" + ], + "accept": [ + "application/mercurial-0.1" + ], + "user-agent": [ + "mercurial/proto-1.0 (Mercurial 5.0.1+253-f2ebe61e9a8e+20190607)" + ], + "host": [ + "phab.mercurial-scm.org" + ], + "content-length": [ + "58" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "body": { + "string": "{\"result\":[{\"id\":\"1253\",\"phid\":\"PHID-DREV-4rhqd6v3yxbtodc7wbv7\",\"title\":\"create comment for phabricator test\",\"uri\":\"https:\\/\\/phab.mercurial-scm.org\\/D1253\",\"dateCreated\":\"1559938988\",\"dateModified\":\"1559939221\",\"authorPHID\":\"PHID-USER-qmzis76vb2yh3ogldu6r\",\"status\":\"0\",\"statusName\":\"Needs Review\",\"properties\":{\"draft.broadcast\":true,\"lines.added\":2,\"lines.removed\":0,\"buildables\":{\"PHID-HMBB-hsvjwe4uccbkgjpvffhz\":{\"status\":\"passed\"}}},\"branch\":null,\"summary\":\"\",\"testPlan\":\"\",\"lineCount\":\"2\",\"activeDiffPHID\":\"PHID-DIFF-xfa4yzc5h2cvjfhpx4dv\",\"diffs\":[\"1990\",\"1989\"],\"commits\":[],\"reviewers\":[],\"ccs\":[],\"hashes\":[],\"auxiliary\":{\"bugzilla.bug-id\":null,\"phabricator:projects\":[],\"phabricator:depends-on\":[]},\"repositoryPHID\":\"PHID-REPO-bvunnehri4u2isyr7bc3\",\"sourcePath\":null}],\"error_code\":null,\"error_info\":null}" + }, + "headers": { + "expires": [ + "Sat, 01 Jan 2000 00:00:00 GMT" + ], + "content-type": [ + "application/json" + ], + "connection": [ + "keep-alive" + ], + "vary": [ + "Accept-Encoding" + ], + "x-frame-options": [ + "Deny" + ], + "strict-transport-security": [ + "max-age=31536000; includeSubdomains; preload" + ], + "date": [ + "Fri, 07 Jun 2019 20:27:02 GMT" + ], + "cache-control": [ + "no-store" + ], + "referrer-policy": [ + "no-referrer", + "strict-origin-when-cross-origin" + ], + "x-content-type-options": [ + "nosniff" + ], + "content-length": [ + "822" + ], + "x-xss-protection": [ + "1; mode=block" + ] + } + } + } + ], + "version": 1 +} \ No newline at end of file
--- a/tests/test-phabricator.t Wed Jun 05 22:09:26 2019 +0300 +++ b/tests/test-phabricator.t Fri Jun 07 20:19:55 2019 +0100 @@ -118,4 +118,17 @@ 1 https://phab.mercurial-scm.org/D1191 D1191 0 https://phab.mercurial-scm.org/D1190 D1190 +Commenting when phabsending: + $ echo comment > comment + $ hg ci --addremove -m "create comment for phabricator test" + adding comment + $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json" + D1253 - created - a7ee4bac036a: create comment for phabricator test + saved backup bundle to $TESTTMP/repo/.hg/strip-backup/a7ee4bac036a-8009b5a0-phabsend.hg + $ echo comment2 >> comment + $ hg ci --amend + saved backup bundle to $TESTTMP/repo/.hg/strip-backup/81fce7de1b7d-05339e5b-amend.hg + $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json" + D1253 - updated - 1acd4b60af38: create comment for phabricator test + $ cd ..