Patchwork D5300: py3: replace str() with pycompat.bytestr() or ('%d' % int)

login
register
mail settings
Submitter phabricator
Date Nov. 26, 2018, 11:06 p.m.
Message ID <1af610539ff466a5780b37f56214344f@localhost.localdomain>
Download mbox | patch
Permalink /patch/36801/
State Not Applicable
Headers show

Comments

phabricator - Nov. 26, 2018, 11:06 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG001f27970b60: py3: replace str() with pycompat.bytestr() or (&#039;%d&#039; % int) (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5300?vs=12594&id=12601

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

AFFECTED FILES
  hgext/fastannotate/formatter.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/fastannotate/formatter.py b/hgext/fastannotate/formatter.py
--- a/hgext/fastannotate/formatter.py
+++ b/hgext/fastannotate/formatter.py
@@ -39,23 +39,26 @@ 
             orig = hexfunc
             hexfunc = lambda x: None if x is None else orig(x)
             wnode = hexfunc(repo[None].p1().node()) + '+'
-            wrev = str(repo[None].p1().rev())
+            wrev = '%d' % repo[None].p1().rev()
             wrevpad = ''
             if not opts.get('changeset'): # only show + if changeset is hidden
                 wrev += '+'
                 wrevpad = ' '
-            revenc = lambda x: wrev if x is None else str(x) + wrevpad
-            csetenc = lambda x: wnode if x is None else str(x) + ' '
+            revenc = lambda x: wrev if x is None else ('%d' % x) + wrevpad
+            def csetenc(x):
+                if x is None:
+                    return wnode
+                return pycompat.bytestr(x) + ' '
         else:
-            revenc = csetenc = str
+            revenc = csetenc = pycompat.bytestr
 
         # opt name, separator, raw value (for json/plain), encoder (for plain)
         opmap = [('user', ' ', lambda x: getctx(x).user(), ui.shortuser),
                  ('number', ' ', lambda x: getctx(x).rev(), revenc),
                  ('changeset', ' ', lambda x: hexfunc(x[0]), csetenc),
                  ('date', ' ', lambda x: getctx(x).date(), datefunc),
-                 ('file', ' ', lambda x: x[2], str),
-                 ('line_number', ':', lambda x: x[1] + 1, str)]
+                 ('file', ' ', lambda x: x[2], pycompat.bytestr),
+                 ('line_number', ':', lambda x: x[1] + 1, pycompat.bytestr)]
         fieldnamemap = {'number': 'rev', 'changeset': 'node'}
         funcmap = [(get, sep, fieldnamemap.get(op, op), enc)
                    for op, sep, get, enc in opmap