D6869: py3: pass a bytestring into querydrev instead of a string that'll TypeError

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D6869: py3: pass a bytestring into querydrev instead of a string that'll TypeError

indygreg (Gregory Szorc)
Kwan created this revision.
Kwan added a comment.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.


  For stable

REVISION SUMMARY
  This was a regression I introduced in c19d259fd6ad <https://phab.mercurial-scm.org/rHGc19d259fd6adc567ba59744678828f47ec81b887>.  When the string gets to
  the memoryview in _tokenize under py3 it'll die.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/phabricator.py
  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
@@ -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
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -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'
 



To: Kwan, #hg-reviewers
Cc: mjpieters, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6869: py3: pass a bytestring into querydrev instead of a string that'll TypeError

indygreg (Gregory Szorc)
Closed by commit rHG6fb281f39c25: py3: pass a bytestring into querydrev instead of a string that&#039;ll TypeError (authored by Kwan).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6869?vs=16580&id=16582

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6869/new/

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

AFFECTED FILES
  hgext/phabricator.py
  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
@@ -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
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -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'
 



To: Kwan, #hg-reviewers
Cc: mjpieters, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel