mercurial/pvec.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43115 4aa72cdf616f
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)