Patchwork D1556: py3: use pycompat.bytestr() or '%d' in place of str()

login
register
mail settings
Submitter phabricator
Date Dec. 1, 2017, 2:13 p.m.
Message ID <191f0ed6e70e4fe76ab5467c55633589@localhost.localdomain>
Download mbox | patch
Permalink /patch/25861/
State Not Applicable
Headers show

Comments

phabricator - Dec. 1, 2017, 2:13 p.m.
pulkit updated this revision to Diff 4049.
pulkit retitled this revision from "py3: use pycompat.bytestr() in place of str()" to "py3: use pycompat.bytestr() or '%d' in place of str()".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1556?vs=3980&id=4049

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS




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

Patch

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