changeset 155:6ec4075191ce

hglib: make str(hglib.context.changectx) work with Python 3 (issue4520)
author Brett Cannon <brett@python.org>
date Wed, 25 Mar 2015 20:17:21 -0400
parents 11202c85737e
children 6d273d0a51aa
files hglib/context.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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]