Patchwork [2,of,7,hglib] hglib: make str(hglib.context.changectx) work with Python 3 (issue4520)

login
register
mail settings
Submitter Brett Cannon
Date March 26, 2015, 12:39 a.m.
Message ID <6ec4075191ce919dcebd.1427330396@bcannon-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/8279/
State Accepted
Headers show

Comments

Brett Cannon - March 26, 2015, 12:39 a.m.
# HG changeset patch
# User Brett Cannon <brett@python.org>
# Date 1427329041 14400
#      Wed Mar 25 20:17:21 2015 -0400
# Node ID 6ec4075191ce919dcebdbf6b9f4e11948462030c
# Parent  11202c85737eef4677aa68f950ec985a5491c2ee
hglib: make str(hglib.context.changectx) work with Python 3 (issue4520)

Patch

diff -r 11202c85737e -r 6ec4075191ce hglib/context.py
--- a/hglib/context.py	Wed Mar 25 20:15:54 2015 -0400
+++ b/hglib/context.py	Wed Mar 25 20:17:21 2015 -0400
@@ -53,7 +53,7 @@ 
         self._clean = None
 
     def __str__(self):
-        return self._node[:12]
+        return self._node[:12].decode('latin-1')
 
     def __int__(self):
         return self._rev
@@ -91,7 +91,7 @@ 
 
     @util.propertycache
     def _status(self):
-        return self._parsestatus(self._repo.status(change=self))[:4]
+        return self._parsestatus(self._repo.status(change=strtobytes(self)))[:4]
 
     def _parsestatus(self, stat):
         d = dict((c, [])
@@ -107,7 +107,8 @@ 
         Unless this method is used to query the working copy status, the
         _status property will implicitly read the status using its default
         arguments."""
-        stat = self._parsestatus(self._repo.status(change=self, ignored=ignored,
+        stat = self._parsestatus(self._repo.status(change=strtobytes(self),
+                                                   ignored=ignored,
                                                    clean=clean))
         self._unknown = self._ignored = self._clean = None
         if ignored:
@@ -166,7 +167,7 @@ 
     @util.propertycache
     def _manifest(self):
         d = {}
-        for node, p, e, s, path in self._repo.manifest(rev=self):
+        for node, p, e, s, path in self._repo.manifest(rev=strtobytes(self)):
             d[path] = node
         return d
 
@@ -179,7 +180,7 @@ 
     @util.propertycache
     def _parents(self):
         """return contexts for each parent changeset"""
-        par = self._repo.parents(rev=self)
+        par = self._repo.parents(rev=strtobytes(self))
         if not par:
             return [changectx(self._repo, -1)]
         return [changectx(self._repo, int(cset.rev)) for cset in par]