comparison mercurial/pvec.py @ 32201:4462a981e8df

base85: proxy through util module I'm going to replace hgimporter with a simpler import function, so we can access to pure/cext modules by name: # util.py base85 = policy.importmod('base85') # select pure.base85 or cext.base85 # cffi/base85.py from ..pure.base85 import * # may re-export pure.base85 functions This means we'll have to use policy.importmod() function in place of the standard import statement, but we wouldn't want to write it every place where C extension modules are used. So this patch makes util host base85 functions.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 26 Apr 2017 21:56:47 +0900
parents 983e93d88193
children e7aa113b14f7
comparison
equal deleted inserted replaced
32200:2d84947cd85d 32201:4462a981e8df
50 50
51 from __future__ import absolute_import 51 from __future__ import absolute_import
52 52
53 from .node import nullrev 53 from .node import nullrev
54 from . import ( 54 from . import (
55 base85,
56 util, 55 util,
57 ) 56 )
58 57
59 _size = 448 # 70 chars b85-encoded 58 _size = 448 # 70 chars b85-encoded
60 _bytes = _size / 8 59 _bytes = _size / 8
164 d, v = pvc[p1] 163 d, v = pvc[p1]
165 pvc[n] = (d + 1, _flipbit(v, node)) 164 pvc[n] = (d + 1, _flipbit(v, node))
166 else: 165 else:
167 pvc[n] = _mergevec(pvc[p1], pvc[p2], node) 166 pvc[n] = _mergevec(pvc[p1], pvc[p2], node)
168 bs = _join(*pvc[ctx.rev()]) 167 bs = _join(*pvc[ctx.rev()])
169 return pvec(base85.b85encode(bs)) 168 return pvec(util.b85encode(bs))
170 169
171 class pvec(object): 170 class pvec(object):
172 def __init__(self, hashorctx): 171 def __init__(self, hashorctx):
173 if isinstance(hashorctx, str): 172 if isinstance(hashorctx, str):
174 self._bs = hashorctx 173 self._bs = hashorctx
175 self._depth, self._vec = _split(base85.b85decode(hashorctx)) 174 self._depth, self._vec = _split(util.b85decode(hashorctx))
176 else: 175 else:
177 self._vec = ctxpvec(hashorctx) 176 self._vec = ctxpvec(hashorctx)
178 177
179 def __str__(self): 178 def __str__(self):
180 return self._bs 179 return self._bs