Patchwork [2,of,2,hglib] hglib: use strtobytes() (issue4520)

login
register
mail settings
Submitter Brett Cannon
Date March 19, 2015, 9:43 p.m.
Message ID <b91356bf7186845d21a2.1426801428@bcannon-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/8183/
State Accepted
Headers show

Comments

Brett Cannon - March 19, 2015, 9:43 p.m.
# HG changeset patch
# User Brett Cannon <brett@python.org>
# Date 1426801366 14400
#      Thu Mar 19 17:42:46 2015 -0400
# Node ID b91356bf7186845d21a219fa5282f1fa9dade69c
# Parent  b94e1263836c4fdcc4809e2199b97ab24cbd123d
hglib: use strtobytes() (issue4520)
Matt Mackall - March 19, 2015, 9:47 p.m.
On Thu, 2015-03-19 at 17:43 -0400, Brett Cannon wrote:
> # HG changeset patch
> # User Brett Cannon <brett@python.org>
> # Date 1426801366 14400
> #      Thu Mar 19 17:42:46 2015 -0400
> # Node ID b91356bf7186845d21a219fa5282f1fa9dade69c
> # Parent  b94e1263836c4fdcc4809e2199b97ab24cbd123d
> hglib: use strtobytes() (issue4520)

These are queued for hglib, thanks.

Patch

diff -r b94e1263836c -r b91356bf7186 hglib/context.py
--- a/hglib/context.py	Thu Mar 19 17:42:26 2015 -0400
+++ b/hglib/context.py	Thu Mar 19 17:42:46 2015 -0400
@@ -1,7 +1,7 @@ 
 import hglib.client  # Circular dependency.
 from hglib import util, templates
 from hglib.error import CommandError
-from hglib.util import b
+from hglib.util import b, strtobytes
 
 _nullcset = [b('-1'), b('0000000000000000000000000000000000000000'), b(''),
              b(''), b(''), b(''), b('')]
@@ -20,7 +20,7 @@ 
             cset = _nullcset
         else:
             if isinstance(changeid, (long, int)):
-                changeid = b('rev(') + str(changeid).encode('latin-1') + b(')')
+                changeid = b('rev(') + strtobytes(changeid) + b(')')
 
             notfound = False
             try:
diff -r b94e1263836c -r b91356bf7186 tests/test-update.py
--- a/tests/test-update.py	Thu Mar 19 17:42:26 2015 -0400
+++ b/tests/test-update.py	Thu Mar 19 17:42:46 2015 -0400
@@ -1,6 +1,6 @@ 
 from tests import common
 from hglib import error
-from hglib.util import b
+from hglib.util import b, strtobytes
 
 class test_update(common.basetest):
     def setUp(self):
@@ -92,7 +92,7 @@ 
 
         rev2, node2 = self.client.commit(b('third'))
         # Go back to 0
-        self.client.rawcommand([b('update'), str(self.rev0).encode('latin-1')],
+        self.client.rawcommand([b('update'), strtobytes(self.rev0)],
                                 # Keep the 'changed' version
                                prompt=lambda s, d: 'c\n')
         u, m, r, ur = self.client.update(rev2, clean=True)