Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pvec.py @ 38823:e7aa113b14f7
global: use pycompat.xrange()
On Python 3, our module importer automatically rewrites xrange()
to pycompat.xrange().
We want to move away from the custom importer on Python 3.
This commit converts all instances of xrange() to use
pycompat.xrange().
Differential Revision: https://phab.mercurial-scm.org/D4032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 01 Aug 2018 13:00:45 -0700 |
parents | 4462a981e8df |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
38822:7eba8f83129b | 38823:e7aa113b14f7 |
---|---|
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 pycompat, | |
55 util, | 56 util, |
56 ) | 57 ) |
57 | 58 |
58 _size = 448 # 70 chars b85-encoded | 59 _size = 448 # 70 chars b85-encoded |
59 _bytes = _size / 8 | 60 _bytes = _size / 8 |
70 v = v * 256 + ord(b) | 71 v = v * 256 + ord(b) |
71 return v | 72 return v |
72 | 73 |
73 def _str(v, l): | 74 def _str(v, l): |
74 bs = "" | 75 bs = "" |
75 for p in xrange(l): | 76 for p in pycompat.xrange(l): |
76 bs = chr(v & 255) + bs | 77 bs = chr(v & 255) + bs |
77 v >>= 8 | 78 v >>= 8 |
78 return bs | 79 return bs |
79 | 80 |
80 def _split(b): | 81 def _split(b): |
89 while x: | 90 while x: |
90 if x & 1: | 91 if x & 1: |
91 c += 1 | 92 c += 1 |
92 x >>= 1 | 93 x >>= 1 |
93 return c | 94 return c |
94 _htab = [_hweight(x) for x in xrange(256)] | 95 _htab = [_hweight(x) for x in pycompat.xrange(256)] |
95 | 96 |
96 def _hamming(a, b): | 97 def _hamming(a, b): |
97 '''find the hamming distance between two longs''' | 98 '''find the hamming distance between two longs''' |
98 d = a ^ b | 99 d = a ^ b |
99 c = 0 | 100 c = 0 |
150 if not util.safehasattr(r, "_pveccache"): | 151 if not util.safehasattr(r, "_pveccache"): |
151 r._pveccache = {} | 152 r._pveccache = {} |
152 pvc = r._pveccache | 153 pvc = r._pveccache |
153 if ctx.rev() not in pvc: | 154 if ctx.rev() not in pvc: |
154 cl = r.changelog | 155 cl = r.changelog |
155 for n in xrange(ctx.rev() + 1): | 156 for n in pycompat.xrange(ctx.rev() + 1): |
156 if n not in pvc: | 157 if n not in pvc: |
157 node = cl.node(n) | 158 node = cl.node(n) |
158 p1, p2 = cl.parentrevs(n) | 159 p1, p2 = cl.parentrevs(n) |
159 if p1 == nullrev: | 160 if p1 == nullrev: |
160 # start with a 'random' vector at root | 161 # start with a 'random' vector at root |