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

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun Mar 4 14:47:47 EST 2018


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

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



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


More information about the Mercurial-devel mailing list