Patchwork D2261: py3: use pycompat.bytestr to convert str to bytes

login
register
mail settings
Submitter phabricator
Date Feb. 14, 2018, 11:25 a.m.
Message ID <differential-rev-PHID-DREV-hbdivxynfvo3vdxcdbgi-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27895/
State Superseded
Headers show

Comments

phabricator - Feb. 14, 2018, 11:25 a.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/D2261

AFFECTED FILES
  mercurial/changelog.py
  mercurial/ui.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 14, 2018, 1:17 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Here `'%r' % pycompat.bytestr(user)` is preferred since repr(user) would
  leave `b''` prefix in error message.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -809,7 +809,7 @@ 
                                     'to set your username'))
         if "\n" in user:
             raise error.Abort(_("username %s contains a newline\n")
-                              % repr(user))
+                              % pycompat.bytestr(repr(user)))
         return user
 
     def shortuser(self, user):
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -20,6 +20,7 @@ 
 from . import (
     encoding,
     error,
+    pycompat,
     revlog,
     util,
 )
@@ -518,7 +519,7 @@ 
             raise error.RevlogError(_("empty username"))
         if "\n" in user:
             raise error.RevlogError(_("username %s contains a newline")
-                                    % repr(user))
+                                    % pycompat.bytestr(repr(user)))
 
         desc = stripdesc(desc)