Patchwork D2664: py3: use b"%d" instead of str() to convert integers to bytes

login
register
mail settings
Submitter phabricator
Date March 4, 2018, 7:47 p.m.
Message ID <59eef4d9b2e7358619217a20baff5199@localhost.localdomain>
Download mbox | patch
Permalink /patch/28980/
State Not Applicable
Headers show

Comments

phabricator - March 4, 2018, 7:47 p.m.
pulkit updated this revision to Diff 6601.
Herald added a reviewer: indygreg.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2664?vs=6599&id=6601

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

AFFECTED FILES
  mercurial/context.py
  mercurial/revlog.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1367,7 +1367,7 @@ 
         try:
             # str(rev)
             rev = int(id)
-            if str(rev) != id:
+            if "%d" % rev != id:
                 raise ValueError
             if rev < 0:
                 rev = len(self) + rev
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -433,7 +433,7 @@ 
                 self._rev = changeid
                 return
             if not pycompat.ispy3 and isinstance(changeid, long):
-                changeid = str(changeid)
+                changeid = "%d" % changeid
             if changeid == 'null':
                 self._node = nullid
                 self._rev = nullrev