D1556: py3: use pycompat.bytestr() in place of str()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Nov 29 23:10:20 UTC 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -825,9 +825,9 @@
                   total=None, seqno=None, revwidth=None, pathname=None):
     node_expander = {
         'H': lambda: hex(node),
-        'R': lambda: str(repo.changelog.rev(node)),
+        'R': lambda: pycompat.bytestr(repo.changelog.rev(node)),
         'h': lambda: short(node),
-        'm': lambda: re.sub('[^\w]', '_', str(desc))
+        'm': lambda: re.sub('[^\w]', '_', pycompat.bytestr(desc))
         }
     expander = {
         '%': lambda: '%',
@@ -838,14 +838,15 @@
         if node:
             expander.update(node_expander)
         if node:
-            expander['r'] = (lambda:
-                    str(repo.changelog.rev(node)).zfill(revwidth or 0))
+            expander['r'] = (lambda: pycompat.bytestr(
+                             repo.changelog.rev(node)).zfill(revwidth or 0))
         if total is not None:
-            expander['N'] = lambda: str(total)
+            expander['N'] = lambda: pycompat.bytestr(total)
         if seqno is not None:
-            expander['n'] = lambda: str(seqno)
+            expander['n'] = lambda: pycompat.bytestr(seqno)
         if total is not None and seqno is not None:
-            expander['n'] = lambda: str(seqno).zfill(len(str(total)))
+            expander['n'] = (lambda: pycompat.bytestr(seqno).zfill(
+                                                len(pycompat.bytestr(total))))
         if pathname is not None:
             expander['s'] = lambda: os.path.basename(pathname)
             expander['d'] = lambda: os.path.dirname(pathname) or '.'



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


More information about the Mercurial-devel mailing list