Mercurial > python-hglib
comparison hglib/context.py @ 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 | ef8eb78fc88d |
children | 6d273d0a51aa |
comparison
equal
deleted
inserted
replaced
154:11202c85737e | 155:6ec4075191ce |
---|---|
51 | 51 |
52 self._ignored = None | 52 self._ignored = None |
53 self._clean = None | 53 self._clean = None |
54 | 54 |
55 def __str__(self): | 55 def __str__(self): |
56 return self._node[:12] | 56 return self._node[:12].decode('latin-1') |
57 | 57 |
58 def __int__(self): | 58 def __int__(self): |
59 return self._rev | 59 return self._rev |
60 | 60 |
61 def __repr__(self): | 61 def __repr__(self): |
89 for f in sorted(self._manifest): | 89 for f in sorted(self._manifest): |
90 yield f | 90 yield f |
91 | 91 |
92 @util.propertycache | 92 @util.propertycache |
93 def _status(self): | 93 def _status(self): |
94 return self._parsestatus(self._repo.status(change=self))[:4] | 94 return self._parsestatus(self._repo.status(change=strtobytes(self)))[:4] |
95 | 95 |
96 def _parsestatus(self, stat): | 96 def _parsestatus(self, stat): |
97 d = dict((c, []) | 97 d = dict((c, []) |
98 for c in (b('M'), b('A'), b('R'), b('!'), b('?'), b('I'), | 98 for c in (b('M'), b('A'), b('R'), b('!'), b('?'), b('I'), |
99 b('C'), b(' '))) | 99 b('C'), b(' '))) |
105 def status(self, ignored=False, clean=False): | 105 def status(self, ignored=False, clean=False): |
106 """Explicit status query | 106 """Explicit status query |
107 Unless this method is used to query the working copy status, the | 107 Unless this method is used to query the working copy status, the |
108 _status property will implicitly read the status using its default | 108 _status property will implicitly read the status using its default |
109 arguments.""" | 109 arguments.""" |
110 stat = self._parsestatus(self._repo.status(change=self, ignored=ignored, | 110 stat = self._parsestatus(self._repo.status(change=strtobytes(self), |
111 ignored=ignored, | |
111 clean=clean)) | 112 clean=clean)) |
112 self._unknown = self._ignored = self._clean = None | 113 self._unknown = self._ignored = self._clean = None |
113 if ignored: | 114 if ignored: |
114 self._ignored = stat[5] | 115 self._ignored = stat[5] |
115 if clean: | 116 if clean: |
164 return self._clean | 165 return self._clean |
165 | 166 |
166 @util.propertycache | 167 @util.propertycache |
167 def _manifest(self): | 168 def _manifest(self): |
168 d = {} | 169 d = {} |
169 for node, p, e, s, path in self._repo.manifest(rev=self): | 170 for node, p, e, s, path in self._repo.manifest(rev=strtobytes(self)): |
170 d[path] = node | 171 d[path] = node |
171 return d | 172 return d |
172 | 173 |
173 def manifest(self): | 174 def manifest(self): |
174 return self._manifest | 175 return self._manifest |
177 return hex(self._node) | 178 return hex(self._node) |
178 | 179 |
179 @util.propertycache | 180 @util.propertycache |
180 def _parents(self): | 181 def _parents(self): |
181 """return contexts for each parent changeset""" | 182 """return contexts for each parent changeset""" |
182 par = self._repo.parents(rev=self) | 183 par = self._repo.parents(rev=strtobytes(self)) |
183 if not par: | 184 if not par: |
184 return [changectx(self._repo, -1)] | 185 return [changectx(self._repo, -1)] |
185 return [changectx(self._repo, int(cset.rev)) for cset in par] | 186 return [changectx(self._repo, int(cset.rev)) for cset in par] |
186 | 187 |
187 def parents(self): | 188 def parents(self): |