D6868: py3: add test demonstrating TypeError when phabsending skips unchanged commits

Kwan (Ian Moody) phabricator at mercurial-scm.org
Tue Sep 17 23:23:43 UTC 2019


Kwan created this revision.
Kwan added a comment.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.


  For stable

REVISION SUMMARY
  Skipping can currently only happen with `--no-amend`, so this isn't a usual
  configuration.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6868

AFFECTED FILES
  tests/phabricator/phabsend-skipped.json
  tests/test-phabricator.t

CHANGE DETAILS

diff --git a/tests/test-phabricator.t b/tests/test-phabricator.t
--- a/tests/test-phabricator.t
+++ b/tests/test-phabricator.t
@@ -131,6 +131,62 @@
   $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
   D1253 - updated - 1acd4b60af38: create comment for phabricator test
 
+Phabsending a skipped commit:
+#if no-py3
+  $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
+  D1253 - skipped - 1acd4b60af38: create comment for phabricator test
+#endif
+BROKEN: shouldn't error under py3
+#if py3
+  $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
+  ** unknown exception encountered, please report by visiting
+  ** https://mercurial-scm.org/wiki/BugTracker
+  ** Python 3* (glob)
+  ** Mercurial Distributed SCM (version *) (glob)
+  ** Extensions loaded: phabricator
+  Traceback (most recent call last):
+    File "*/install/bin/hg", line *, in <module> (glob)
+      dispatch.run()
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in run (glob)
+      status = dispatch(req)
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in dispatch (glob)
+      ret = _runcatch(req) or 0
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcatch (glob)
+      return _callcatch(ui, _runcatchfunc)
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in _callcatch (glob)
+      return scmutil.callcatch(ui, func)
+    File "*/install/lib/python/mercurial/scmutil.py", line *, in callcatch (glob)
+      return func()
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcatchfunc (glob)
+      return _dispatch(req)
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in _dispatch (glob)
+      cmdpats, cmdoptions)
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in runcommand (glob)
+      ret = _runcommand(ui, options, cmd, d)
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcommand (glob)
+      return cmdfunc()
+    File "*/install/lib/python/mercurial/dispatch.py", line *, in <lambda> (glob)
+      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
+    File "*/install/lib/python/mercurial/util.py", line *, in check (glob)
+      return func(*args, **kwargs)
+    File "*/install/lib/python/hgext/phabricator.py", line *, in inner (glob)
+      return fn(*args, **kwargs)
+    File "*/install/lib/python/hgext/phabricator.py", line *, in phabsend (glob)
+      newrevphid = querydrev(repo, str(revid))[0][b'phid']
+    File "*/install/lib/python/hgext/phabricator.py", line *, in querydrev (glob)
+      tree = _parse(spec)
+    File "*/install/lib/python/hgext/phabricator.py", line *, in _parse (glob)
+      tree, pos = parser.parser(_elements).parse(_tokenize(text))
+    File "*/install/lib/python/mercurial/parser.py", line *, in parse (glob)
+      self._advance()
+    File "*/install/lib/python/mercurial/parser.py", line *, in _advance (glob)
+      self.current = next(self._iter, None)
+    File "*/install/lib/python/hgext/phabricator.py", line *, in _tokenize (glob)
+      view = memoryview(text) # zero-copy slice
+  TypeError: memoryview: a bytes-like object is required, not 'str'
+  [1]
+#endif
+
 Phabreading a DREV with a local:commits time as a string:
   $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
   # HG changeset patch
diff --git a/tests/phabricator/phabsend-skipped.json b/tests/phabricator/phabsend-skipped.json
new file mode 100644
--- /dev/null
+++ b/tests/phabricator/phabsend-skipped.json
@@ -0,0 +1,149 @@
+{
+    "version": 1,
+    "interactions": [
+        {
+            "response": {
+                "headers": {
+                    "x-xss-protection": [
+                        "1; mode=block"
+                    ],
+                    "content-length": [
+                        "6067"
+                    ],
+                    "content-type": [
+                        "application/json"
+                    ],
+                    "expires": [
+                        "Sat, 01 Jan 2000 00:00:00 GMT"
+                    ],
+                    "vary": [
+                        "Accept-Encoding"
+                    ],
+                    "connection": [
+                        "keep-alive"
+                    ],
+                    "strict-transport-security": [
+                        "max-age=31536000; includeSubdomains; preload"
+                    ],
+                    "cache-control": [
+                        "no-store"
+                    ],
+                    "referrer-policy": [
+                        "no-referrer",
+                        "strict-origin-when-cross-origin"
+                    ],
+                    "x-frame-options": [
+                        "Deny"
+                    ],
+                    "date": [
+                        "Tue, 17 Sep 2019 21:22:31 GMT"
+                    ],
+                    "x-content-type-options": [
+                        "nosniff"
+                    ]
+                },
+                "body": {
+                    "string": "{\"result\":{\"2175\":{\"id\":\"2175\",\"revisionID\":\"1253\",\"dateCreated\":\"1568754923\",\"dateModified\":\"1568754927\",\"sourceControlBaseRevision\":null,\"sourceControlPath\":null,\"sourceControlSystem\":null,\"branch\":null,\"bookmark\":null,\"creationMethod\":\"web\",\"description\":null,\"unitStatus\":\"4\",\"lintStatus\":\"4\",\"changes\":[{\"id\":\"5562\",\"metadata\":{\"line:first\":1,\"hash.effect\":\"sOtQ9WtAYaL5\"},\"oldPath\":null,\"currentPath\":\"comment\",\"awayPaths\":[],\"oldProperties\":[],\"newProperties\":{\"unix:filemode\":\"100644\"},\"type\":\"1\",\"fileType\":\"1\",\"commitHash\":null,\"addLines\":\"2\",\"delLines\":\"0\",\"hunks\":[{\"oldOffset\":\"0\",\"newOffset\":\"1\",\"oldLength\":\"0\",\"newLength\":\"2\",\"addLines\":null,\"delLines\":null,\"isMissingOldNewline\":null,\"isMissingNewNewline\":null,\"corpus\":\"+comment\\n+comment2\\n\"}]}],\"properties\":{\"hg:meta\":{\"branch\":\"default\",\"date\":\"0 0\",\"node\":\"1acd4b60af38c934182468719a8a431248f49bef\",\"parent\":\"a19f1434f9a578325eb9799c9961b5465d4e6e40\",\"user\":\"test\"},\"local:commits\":{\"1acd4b60af38c934182468719a8a431248f49bef\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"1acd4b60af38c934182468719a8a431248f49bef\",\"parents\":[\"a19f1434f9a578325eb9799c9961b5465d4e6e40\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"},\"2172\":{\"id\":\"2172\",\"revisionID\":\"1253\",\"dateCreated\":\"1568752955\",\"dateModified\":\"1568752959\",\"sourceControlBaseRevision\":null,\"sourceControlPath\":null,\"sourceControlSystem\":null,\"branch\":null,\"bookmark\":null,\"creationMethod\":\"web\",\"description\":null,\"unitStatus\":\"4\",\"lintStatus\":\"4\",\"changes\":[{\"id\":\"5559\",\"metadata\":{\"line:first\":1,\"hash.effect\":\"sOtQ9WtAYaL5\"},\"oldPath\":null,\"currentPath\":\"comment\",\"awayPaths\":[],\"oldProperties\":[],\"newProperties\":{\"unix:filemode\":\"100644\"},\"type\":\"1\",\"fileType\":\"1\",\"commitHash\":null,\"addLines\":\"2\",\"delLines\":\"0\",\"hunks\":[{\"oldOffset\":\"0\",\"newOffset\":\"1\",\"oldLength\":\"0\",\"newLength\":\"2\",\"addLines\":null,\"delLines\":null,\"isMissingOldNewline\":null,\"isMissingNewNewline\":null,\"corpus\":\"+comment\\n+comment2\\n\"}]}],\"properties\":{\"hg:meta\":{\"branch\":\"default\",\"date\":\"0 0\",\"node\":\"a2ee35bb90599d36732e25eaa3522e813807c436\",\"parent\":\"a19f1434f9a578325eb9799c9961b5465d4e6e40\",\"user\":\"test\"},\"local:commits\":{\"a2ee35bb90599d36732e25eaa3522e813807c436\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"a2ee35bb90599d36732e25eaa3522e813807c436\",\"parents\":[\"a19f1434f9a578325eb9799c9961b5465d4e6e40\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"},\"2171\":{\"id\":\"2171\",\"revisionID\":\"1253\",\"dateCreated\":\"1568752852\",\"dateModified\":\"1568752856\",\"sourceControlBaseRevision\":null,\"sourceControlPath\":null,\"sourceControlSystem\":null,\"branch\":null,\"bookmark\":null,\"creationMethod\":\"web\",\"description\":null,\"unitStatus\":\"4\",\"lintStatus\":\"4\",\"changes\":[{\"id\":\"5558\",\"metadata\":{\"line:first\":1,\"hash.effect\":\"sOtQ9WtAYaL5\"},\"oldPath\":null,\"currentPath\":\"comment\",\"awayPaths\":[],\"oldProperties\":[],\"newProperties\":{\"unix:filemode\":\"100644\"},\"type\":\"1\",\"fileType\":\"1\",\"commitHash\":null,\"addLines\":\"2\",\"delLines\":\"0\",\"hunks\":[{\"oldOffset\":\"0\",\"newOffset\":\"1\",\"oldLength\":\"0\",\"newLength\":\"2\",\"addLines\":null,\"delLines\":null,\"isMissingOldNewline\":null,\"isMissingNewNewline\":null,\"corpus\":\"+comment\\n+comment2\\n\"}]}],\"properties\":{\"hg:meta\":{\"branch\":\"default\",\"date\":\"0 0\",\"node\":\"a2ee35bb90599d36732e25eaa3522e813807c436\",\"parent\":\"a19f1434f9a578325eb9799c9961b5465d4e6e40\",\"user\":\"test\"},\"local:commits\":{\"a2ee35bb90599d36732e25eaa3522e813807c436\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"a2ee35bb90599d36732e25eaa3522e813807c436\",\"parents\":[\"a19f1434f9a578325eb9799c9961b5465d4e6e40\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"},\"1990\":{\"id\":\"1990\",\"revisionID\":\"1253\",\"dateCreated\":\"1559939219\",\"dateModified\":\"1559939221\",\"sourceControlBaseRevision\":null,\"sourceControlPath\":null,\"sourceControlSystem\":null,\"branch\":null,\"bookmark\":null,\"creationMethod\":\"web\",\"description\":null,\"unitStatus\":\"4\",\"lintStatus\":\"4\",\"changes\":[{\"id\":\"5274\",\"metadata\":{\"line:first\":1,\"hash.effect\":\"sOtQ9WtAYaL5\"},\"oldPath\":null,\"currentPath\":\"comment\",\"awayPaths\":[],\"oldProperties\":[],\"newProperties\":{\"unix:filemode\":\"100644\"},\"type\":\"1\",\"fileType\":\"1\",\"commitHash\":null,\"addLines\":\"2\",\"delLines\":\"0\",\"hunks\":[{\"oldOffset\":\"0\",\"newOffset\":\"1\",\"oldLength\":\"0\",\"newLength\":\"2\",\"addLines\":null,\"delLines\":null,\"isMissingOldNewline\":null,\"isMissingNewNewline\":null,\"corpus\":\"+comment\\n+comment2\\n\"}]}],\"properties\":{\"hg:meta\":{\"branch\":\"default\",\"date\":\"0 0\",\"node\":\"26e841a56a257327455a2d61b4cdce5a23603e0f\",\"parent\":\"bbe10799509c2879ee316782805e70541cd5fd67\",\"user\":\"test\"},\"local:commits\":{\"26e841a56a257327455a2d61b4cdce5a23603e0f\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"26e841a56a257327455a2d61b4cdce5a23603e0f\",\"parents\":[\"bbe10799509c2879ee316782805e70541cd5fd67\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"},\"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\":\"bbe10799509c2879ee316782805e70541cd5fd67\",\"user\":\"test\"},\"local:commits\":{\"0025df7d064f9c916862d19e207429a0f799fa7d\":{\"author\":\"test\",\"authorEmail\":\"test\",\"branch\":\"default\",\"commit\":\"0025df7d064f9c916862d19e207429a0f799fa7d\",\"parents\":[\"bbe10799509c2879ee316782805e70541cd5fd67\"],\"time\":0}}},\"authorName\":\"test\",\"authorEmail\":\"test\"}},\"error_code\":null,\"error_info\":null}"
+                },
+                "status": {
+                    "code": 200,
+                    "message": "OK"
+                }
+            },
+            "request": {
+                "headers": {
+                    "content-length": [
+                        "66"
+                    ],
+                    "content-type": [
+                        "application/x-www-form-urlencoded"
+                    ],
+                    "user-agent": [
+                        "mercurial/proto-1.0 (Mercurial 5.1.1+7-32677ec7df40+20190917)"
+                    ],
+                    "accept": [
+                        "application/mercurial-0.1"
+                    ],
+                    "host": [
+                        "phab.mercurial-scm.org"
+                    ]
+                },
+                "body": "revisionIDs%5B0%5D=1253&api.token=cli-hahayouwish",
+                "uri": "https://phab.mercurial-scm.org//api/differential.querydiffs",
+                "method": "POST"
+            }
+        },
+        {
+            "response": {
+                "headers": {
+                    "x-xss-protection": [
+                        "1; mode=block"
+                    ],
+                    "content-length": [
+                        "1055"
+                    ],
+                    "content-type": [
+                        "application/json"
+                    ],
+                    "expires": [
+                        "Sat, 01 Jan 2000 00:00:00 GMT"
+                    ],
+                    "vary": [
+                        "Accept-Encoding"
+                    ],
+                    "connection": [
+                        "keep-alive"
+                    ],
+                    "strict-transport-security": [
+                        "max-age=31536000; includeSubdomains; preload"
+                    ],
+                    "cache-control": [
+                        "no-store"
+                    ],
+                    "referrer-policy": [
+                        "no-referrer",
+                        "strict-origin-when-cross-origin"
+                    ],
+                    "x-frame-options": [
+                        "Deny"
+                    ],
+                    "date": [
+                        "Tue, 17 Sep 2019 21:22:32 GMT"
+                    ],
+                    "x-content-type-options": [
+                        "nosniff"
+                    ]
+                },
+                "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\":\"1568754928\",\"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\"},\"PHID-HMBB-fwvmqztsgs3r3tpz3q5x\":{\"status\":\"passed\"},\"PHID-HMBB-hkx7mvm7pfacmg2pwwo2\":{\"status\":\"passed\"},\"PHID-HMBB-qfk7ksky77lpzlmzojtz\":{\"status\":\"passed\"},\"PHID-HMBB-p5eo6q67kttzuhdtg2d3\":{\"status\":\"passed\"}}},\"branch\":null,\"summary\":\"\",\"testPlan\":\"\",\"lineCount\":\"2\",\"activeDiffPHID\":\"PHID-DIFF-pigorrruetzslmwaard3\",\"diffs\":[\"2175\",\"2172\",\"2171\",\"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}"
+                },
+                "status": {
+                    "code": 200,
+                    "message": "OK"
+                }
+            },
+            "request": {
+                "headers": {
+                    "content-length": [
+                        "58"
+                    ],
+                    "content-type": [
+                        "application/x-www-form-urlencoded"
+                    ],
+                    "user-agent": [
+                        "mercurial/proto-1.0 (Mercurial 5.1.1+7-32677ec7df40+20190917)"
+                    ],
+                    "accept": [
+                        "application/mercurial-0.1"
+                    ],
+                    "host": [
+                        "phab.mercurial-scm.org"
+                    ]
+                },
+                "body": "ids%5B0%5D=1253&api.token=cli-hahayouwish",
+                "uri": "https://phab.mercurial-scm.org//api/differential.query",
+                "method": "POST"
+            }
+        }
+    ]
+}
\ No newline at end of file



To: Kwan, #hg-reviewers
Cc: mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list