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

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun Mar 4 20:19:29 UTC 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG981f328d6d16: py3: use b"%d" instead of str() to convert integers to bytes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

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

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, yuja
Cc: mercurial-devel


More information about the Mercurial-devel mailing list