py3: pass a bytestring into querydrev instead of a string that'll TypeError
authorIan Moody <moz-ian@perix.co.uk>
Wed, 18 Sep 2019 00:20:43 +0100
changeset 42950 6fb281f39c25
parent 42949 3355e0c2845f
child 42951 04c6de38734d
py3: pass a bytestring into querydrev instead of a string that'll TypeError This was a regression I introduced in c19d259fd6ad. When the string gets to the memoryview in _tokenize under py3 it'll die. Differential Revision: https://phab.mercurial-scm.org/D6869
hgext/phabricator.py
tests/test-phabricator.t
--- a/hgext/phabricator.py	Wed Sep 18 00:05:52 2019 +0100
+++ b/hgext/phabricator.py	Wed Sep 18 00:20:43 2019 +0100
@@ -612,7 +612,7 @@
         else:
             # Nothing changed. But still set "newrevphid" so the next revision
             # could depend on this one and "newrevid" for the summary line.
-            newrevphid = querydrev(repo, str(revid))[0][b'phid']
+            newrevphid = querydrev(repo, b'%d' % revid)[0][b'phid']
             newrevid = revid
             action = b'skipped'
 
--- a/tests/test-phabricator.t	Wed Sep 18 00:05:52 2019 +0100
+++ b/tests/test-phabricator.t	Wed Sep 18 00:20:43 2019 +0100
@@ -132,60 +132,8 @@
   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