[PATCH 3 of 7] py3: use pycompat.bytestr() instead of str()

Pulkit Goyal 7895pulkit at gmail.com
Thu May 4 16:09:51 EDT 2017


On Thu, May 4, 2017 at 7:42 AM, Yuya Nishihara <yuya at tcha.org> wrote:

> On Wed, 03 May 2017 15:29:22 +0530, Pulkit Goyal wrote:
> > # HG changeset patch
> > # User Pulkit Goyal <7895pulkit at gmail.com>
> > # Date 1493266797 -19800
> > #      Thu Apr 27 09:49:57 2017 +0530
> > # Node ID ada413b057f0052a065197295801e24d49799036
> > # Parent  af5154fdc7d485b090ba1bed3bb42addb7836469
> > py3: use pycompat.bytestr() instead of str()
>
> > --- a/hgext/blackbox.py       Thu Apr 20 19:51:37 2017 +0530
> > +++ b/hgext/blackbox.py       Thu Apr 27 09:49:57 2017 +0530
> > @@ -45,6 +45,7 @@
> >
> >  from mercurial import (
> >      cmdutil,
> > +    pycompat,
> >      ui as uimod,
> >      util,
> >  )
> > @@ -173,7 +174,7 @@
> >                  ui._bbinlog = True
> >                  date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
> >                  user = util.getuser()
> > -                pid = str(util.getpid())
> > +                pid = pycompat.bytestr(util.getpid())
>
> pid must be an int, so '%d' can be used instead.
>
> > diff -r af5154fdc7d4 -r ada413b057f0 mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py    Thu Apr 20 19:51:37 2017 +0530
> > +++ b/mercurial/cmdutil.py    Thu Apr 27 09:49:57 2017 +0530
> > @@ -1360,7 +1360,7 @@
> >          if rev is None:
> >              jrev = jnode = 'null'
> >          else:
> > -            jrev = str(rev)
> > +            jrev = pycompat.bytestr(rev)
>
> Same here. '%d'
>
> > @@ -1607,7 +1607,7 @@
> >          if rev in results:
> >              ui.status(_("found revision %s from %s\n") %
> >                        (rev, util.datestr(results[rev])))
>
> Perhaps this message should be updated, too.
>

​I have left this as is in V2 as I am unable to think about an updated
message.​


>
> > -            return str(rev)
> > +            return pycompat.bytestr(rev)
>
> '%d'
>
> > diff -r af5154fdc7d4 -r ada413b057f0 mercurial/templatefilters.py
> > --- a/mercurial/templatefilters.py    Thu Apr 20 19:51:37 2017 +0530
> > +++ b/mercurial/templatefilters.py    Thu Apr 27 09:49:57 2017 +0530
> > @@ -230,7 +230,7 @@
> >      elif obj is True:
> >          return 'true'
> >      elif isinstance(obj, (int, long, float)):
> > -        return str(obj)
> > +        return pycompat.bytestr(obj)
> >      elif isinstance(obj, str):
> >          return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid)
> >      elif util.safehasattr(obj, 'keys'):
> > @@ -359,7 +359,7 @@
> >          return "".join([stringify(t) for t in thing if t is not None])
> >      if thing is None:
> >          return ""
> > -    return str(thing)
> > +    return pycompat.bytestr(thing)
>
> I've taken these templatefilters changes, thanks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170505/a82e100b/attachment.html>


More information about the Mercurial-devel mailing list