Patchwork D1557: py3: use pycompat.bytestr() to convert string to bytes

login
register
mail settings
Submitter phabricator
Date Nov. 29, 2017, 11:10 p.m.
Message ID <differential-rev-PHID-DREV-5t3ntze6uahzsorh75v7-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25816/
State Superseded
Headers show

Comments

phabricator - Nov. 29, 2017, 11:10 p.m.
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/D1557

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 30, 2017, 12:28 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  The result of `strftime()` has to be converted back to local string
  by `.encode('ascii')` or `encoding.strtolocal()`.
  
  See util.parsedate() for details.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Dec. 2, 2017, 2:59 a.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> debugcommands.py:729
> +        ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2],
> +                 encoding.strtolocal(timestr), file_))
>      for f in repo.dirstate.copies():

`timestr` may be either bytes or str. `strtolocal()` should be
applied only to the return value of `strftime()`.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -725,7 +725,8 @@ 
             mode = 'lnk'
         else:
             mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
-        ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
+        ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2],
+                 pycompat.bytestr(timestr), file_))
     for f in repo.dirstate.copies():
         ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))