Mercurial > public > mercurial-scm > hg
comparison mercurial/pvec.py @ 43077:687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:48:39 -0400 |
parents | 2372284d9457 |
children | 4aa72cdf616f |
comparison
equal
deleted
inserted
replaced
43076:2372284d9457 | 43077:687b865b95ad |
---|---|
72 v = v * 256 + ord(b) | 72 v = v * 256 + ord(b) |
73 return v | 73 return v |
74 | 74 |
75 | 75 |
76 def _str(v, l): | 76 def _str(v, l): |
77 bs = "" | 77 bs = b"" |
78 for p in pycompat.xrange(l): | 78 for p in pycompat.xrange(l): |
79 bs = chr(v & 255) + bs | 79 bs = chr(v & 255) + bs |
80 v >>= 8 | 80 v >>= 8 |
81 return bs | 81 return bs |
82 | 82 |
157 | 157 |
158 | 158 |
159 def ctxpvec(ctx): | 159 def ctxpvec(ctx): |
160 '''construct a pvec for ctx while filling in the cache''' | 160 '''construct a pvec for ctx while filling in the cache''' |
161 r = ctx.repo() | 161 r = ctx.repo() |
162 if not util.safehasattr(r, "_pveccache"): | 162 if not util.safehasattr(r, b"_pveccache"): |
163 r._pveccache = {} | 163 r._pveccache = {} |
164 pvc = r._pveccache | 164 pvc = r._pveccache |
165 if ctx.rev() not in pvc: | 165 if ctx.rev() not in pvc: |
166 cl = r.changelog | 166 cl = r.changelog |
167 for n in pycompat.xrange(ctx.rev() + 1): | 167 for n in pycompat.xrange(ctx.rev() + 1): |
211 return False | 211 return False |
212 return True | 212 return True |
213 | 213 |
214 def __sub__(self, b): | 214 def __sub__(self, b): |
215 if self | b: | 215 if self | b: |
216 raise ValueError("concurrent pvecs") | 216 raise ValueError(b"concurrent pvecs") |
217 return self._depth - b._depth | 217 return self._depth - b._depth |
218 | 218 |
219 def distance(self, b): | 219 def distance(self, b): |
220 d = abs(b._depth - self._depth) | 220 d = abs(b._depth - self._depth) |
221 h = _hamming(self._vec, b._vec) | 221 h = _hamming(self._vec, b._vec) |