##// END OF EJS Templates
global: use pycompat.xrange()...
Gregory Szorc -
r38806:e7aa113b default
parent child Browse files
Show More
@@ -220,6 +220,7 b' from mercurial import ('
220 220 error,
221 221 extensions,
222 222 match,
223 pycompat,
223 224 registrar,
224 225 util,
225 226 )
@@ -403,7 +404,7 b' def _txnhook(ui, repo, hooktype, node, s'
403 404 allow = buildmatch(ui, repo, user, 'acl.allow')
404 405 deny = buildmatch(ui, repo, user, 'acl.deny')
405 406
406 for rev in xrange(repo[node].rev(), len(repo)):
407 for rev in pycompat.xrange(repo[node].rev(), len(repo)):
407 408 ctx = repo[rev]
408 409 branch = ctx.branch()
409 410 if denybranches and denybranches(branch):
@@ -18,6 +18,7 b' from mercurial import ('
18 18 encoding,
19 19 extensions,
20 20 graphmod,
21 pycompat,
21 22 templatekw,
22 23 )
23 24
@@ -53,7 +54,7 b' def prettyedge(before, edge, after):'
53 54 def convertedges(line):
54 55 line = ' %s ' % line
55 56 pretty = []
56 for idx in xrange(len(line) - 2):
57 for idx in pycompat.xrange(len(line) - 2):
57 58 pretty.append(prettyedge(line[idx], line[idx + 1], line[idx + 2]))
58 59 return ''.join(pretty)
59 60
@@ -45,6 +45,7 b' from mercurial.node import hex'
45 45
46 46 from mercurial import (
47 47 encoding,
48 pycompat,
48 49 registrar,
49 50 ui as uimod,
50 51 util,
@@ -111,7 +112,7 b' def _openlogfile(ui, vfs):'
111 112 if st.st_size >= maxsize:
112 113 path = vfs.join(name)
113 114 maxfiles = ui.configint('blackbox', 'maxfiles')
114 for i in xrange(maxfiles - 1, 1, -1):
115 for i in pycompat.xrange(maxfiles - 1, 1, -1):
115 116 rotate(oldpath='%s.%d' % (path, i - 1),
116 117 newpath='%s.%d' % (path, i))
117 118 rotate(oldpath=path,
@@ -32,6 +32,7 b' from mercurial.node import short'
32 32
33 33 from mercurial import (
34 34 error,
35 pycompat,
35 36 registrar,
36 37 revlog,
37 38 scmutil,
@@ -160,7 +161,7 b" def _docensor(ui, repo, path, rev='', to"
160 161 offset += rewrite(crev, offset, tombstone + pad, revlog.REVIDX_ISCENSORED)
161 162
162 163 # Rewrite all following filelog revisions fixing up offsets and deltas.
163 for srev in xrange(crev + 1, len(flog)):
164 for srev in pycompat.xrange(crev + 1, len(flog)):
164 165 if crev in flog.parentrevs(srev):
165 166 # Immediate children of censored node must be re-added as fulltext.
166 167 try:
@@ -763,7 +763,7 b' def createchangeset(ui, log, fuzz=60, me'
763 763 # branchpoints such that it is the latest possible
764 764 # commit without any intervening, unrelated commits.
765 765
766 for candidate in xrange(i):
766 for candidate in pycompat.xrange(i):
767 767 if c.branch not in changesets[candidate].branchpoints:
768 768 if p is not None:
769 769 break
@@ -266,7 +266,7 b' def _checkhook(ui, repo, node, headsonly'
266 266 ensureenabled(ui)
267 267 files = set()
268 268 revs = set()
269 for rev in xrange(repo[node].rev(), len(repo)):
269 for rev in pycompat.xrange(repo[node].rev(), len(repo)):
270 270 revs.add(rev)
271 271 if headsonly:
272 272 ctx = repo[rev]
@@ -227,7 +227,7 b' def revtree(ui, args, repo, full="tree",'
227 227 else:
228 228 i -= chunk
229 229
230 for x in xrange(chunk):
230 for x in pycompat.xrange(chunk):
231 231 if i + x >= count:
232 232 l[chunk - x:] = [0] * (chunk - x)
233 233 break
@@ -238,7 +238,7 b' def revtree(ui, args, repo, full="tree",'
238 238 else:
239 239 if (i + x) in repo:
240 240 l[x] = 1
241 for x in xrange(chunk - 1, -1, -1):
241 for x in pycompat.xrange(chunk - 1, -1, -1):
242 242 if l[x] != 0:
243 243 yield (i + x, full is not None and l[x] or None)
244 244 if i == 0:
@@ -249,7 +249,7 b' def revtree(ui, args, repo, full="tree",'
249 249 if len(ar) == 0:
250 250 return 1
251 251 mask = 0
252 for i in xrange(len(ar)):
252 for i in pycompat.xrange(len(ar)):
253 253 if sha in reachable[i]:
254 254 mask |= 1 << i
255 255
@@ -386,7 +386,7 b' class histeditstate(object):'
386 386 rules = []
387 387 rulelen = int(lines[index])
388 388 index += 1
389 for i in xrange(rulelen):
389 for i in pycompat.xrange(rulelen):
390 390 ruleaction = lines[index]
391 391 index += 1
392 392 rule = lines[index]
@@ -397,7 +397,7 b' class histeditstate(object):'
397 397 replacements = []
398 398 replacementlen = int(lines[index])
399 399 index += 1
400 for i in xrange(replacementlen):
400 for i in pycompat.xrange(replacementlen):
401 401 replacement = lines[index]
402 402 original = node.bin(replacement[:40])
403 403 succ = [node.bin(replacement[i:i + 40]) for i in
@@ -414,7 +414,7 b' class patchheader(object):'
414 414 the field and a blank line.'''
415 415 if self.message:
416 416 subj = 'subject: ' + self.message[0].lower()
417 for i in xrange(len(self.comments)):
417 for i in pycompat.xrange(len(self.comments)):
418 418 if subj == self.comments[i].lower():
419 419 del self.comments[i]
420 420 self.message = self.message[2:]
@@ -1800,7 +1800,7 b' class queue(object):'
1800 1800 # if the patch excludes a modified file, mark that
1801 1801 # file with mtime=0 so status can see it.
1802 1802 mm = []
1803 for i in xrange(len(m) - 1, -1, -1):
1803 for i in pycompat.xrange(len(m) - 1, -1, -1):
1804 1804 if not match1(m[i]):
1805 1805 mm.append(m[i])
1806 1806 del m[i]
@@ -1908,7 +1908,7 b' class queue(object):'
1908 1908 else:
1909 1909 start = self.series.index(patch) + 1
1910 1910 unapplied = []
1911 for i in xrange(start, len(self.series)):
1911 for i in pycompat.xrange(start, len(self.series)):
1912 1912 pushable, reason = self.pushable(i)
1913 1913 if pushable:
1914 1914 unapplied.append((i, self.series[i]))
@@ -1946,7 +1946,7 b' class queue(object):'
1946 1946 if not missing:
1947 1947 if self.ui.verbose:
1948 1948 idxwidth = len("%d" % (start + length - 1))
1949 for i in xrange(start, start + length):
1949 for i in pycompat.xrange(start, start + length):
1950 1950 patch = self.series[i]
1951 1951 if patch in applied:
1952 1952 char, state = 'A', 'applied'
@@ -2091,7 +2091,7 b' class queue(object):'
2091 2091 def nextpatch(start):
2092 2092 if all_patches or start >= len(self.series):
2093 2093 return start
2094 for i in xrange(start, len(self.series)):
2094 for i in pycompat.xrange(start, len(self.series)):
2095 2095 p, reason = self.pushable(i)
2096 2096 if p:
2097 2097 return i
@@ -2876,7 +2876,7 b' def guard(ui, repo, *args, **opts):'
2876 2876 if args or opts.get(r'none'):
2877 2877 raise error.Abort(_('cannot mix -l/--list with options or '
2878 2878 'arguments'))
2879 for i in xrange(len(q.series)):
2879 for i in pycompat.xrange(len(q.series)):
2880 2880 status(i)
2881 2881 return
2882 2882 if not args or args[0][0:1] in '-+':
@@ -3179,14 +3179,16 b' def select(ui, repo, *args, **opts):'
3179 3179 pushable = lambda i: q.pushable(q.applied[i].name)[0]
3180 3180 if args or opts.get('none'):
3181 3181 old_unapplied = q.unapplied(repo)
3182 old_guarded = [i for i in xrange(len(q.applied)) if not pushable(i)]
3182 old_guarded = [i for i in pycompat.xrange(len(q.applied))
3183 if not pushable(i)]
3183 3184 q.setactive(args)
3184 3185 q.savedirty()
3185 3186 if not args:
3186 3187 ui.status(_('guards deactivated\n'))
3187 3188 if not opts.get('pop') and not opts.get('reapply'):
3188 3189 unapplied = q.unapplied(repo)
3189 guarded = [i for i in xrange(len(q.applied)) if not pushable(i)]
3190 guarded = [i for i in pycompat.xrange(len(q.applied))
3191 if not pushable(i)]
3190 3192 if len(unapplied) != len(old_unapplied):
3191 3193 ui.status(_('number of unguarded, unapplied patches has '
3192 3194 'changed from %d to %d\n') %
@@ -3225,7 +3227,7 b' def select(ui, repo, *args, **opts):'
3225 3227 reapply = opts.get('reapply') and q.applied and q.applied[-1].name
3226 3228 popped = False
3227 3229 if opts.get('pop') or opts.get('reapply'):
3228 for i in xrange(len(q.applied)):
3230 for i in pycompat.xrange(len(q.applied)):
3229 3231 if not pushable(i):
3230 3232 ui.status(_('popping guarded patches\n'))
3231 3233 popped = True
@@ -16,6 +16,7 b' from mercurial import ('
16 16 match as matchmod,
17 17 mdiff,
18 18 node,
19 pycompat,
19 20 revlog,
20 21 util,
21 22 )
@@ -332,7 +333,7 b' def setup():'
332 333 # somewhat unsurprised to find a case in the wild
333 334 # where this breaks down a bit. That said, I don't
334 335 # know if it would hurt anything.
335 for i in xrange(rev, 0, -1):
336 for i in pycompat.xrange(rev, 0, -1):
336 337 if revlog.linkrev(i) == clrev:
337 338 return i
338 339 # We failed to resolve a parent for this node, so
@@ -783,7 +783,7 b' def _rebaserestoredcommit(ui, repo, opts'
783 783 tr.close()
784 784
785 785 nodestoremove = [repo.changelog.node(rev)
786 for rev in xrange(oldtiprev, len(repo))]
786 for rev in pycompat.xrange(oldtiprev, len(repo))]
787 787 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
788 788 branchtorestore, opts.get('keep'), activebookmark)
789 789 raise error.InterventionRequired(
@@ -49,6 +49,7 b' from mercurial.node import ('
49 49 short,
50 50 )
51 51 from mercurial import (
52 pycompat,
52 53 registrar,
53 54 )
54 55 from mercurial.utils import (
@@ -141,7 +142,8 b' def forbidnewline(ui, repo, hooktype, no'
141 142 # changegroup that contains an unacceptable commit followed later
142 143 # by a commit that fixes the problem.
143 144 tip = repo['tip']
144 for rev in xrange(repo.changelog.tiprev(), repo[node].rev() - 1, -1):
145 for rev in pycompat.xrange(repo.changelog.tiprev(),
146 repo[node].rev() - 1, -1):
145 147 c = repo[rev]
146 148 for f in c.files():
147 149 if f in seen or f not in tip or f not in c:
@@ -11,6 +11,9 b' import collections'
11 11 import heapq
12 12
13 13 from .node import nullrev
14 from . import (
15 pycompat,
16 )
14 17
15 18 def commonancestorsheads(pfunc, *nodes):
16 19 """Returns a set with the heads of all common ancestors of all nodes,
@@ -174,7 +177,7 b' class incrementalmissingancestors(object'
174 177 # no revs to consider
175 178 return
176 179
177 for curr in xrange(start, min(revs) - 1, -1):
180 for curr in pycompat.xrange(start, min(revs) - 1, -1):
178 181 if curr not in bases:
179 182 continue
180 183 revs.discard(curr)
@@ -215,7 +218,7 b' class incrementalmissingancestors(object'
215 218 # exit.
216 219
217 220 missing = []
218 for curr in xrange(start, nullrev, -1):
221 for curr in pycompat.xrange(start, nullrev, -1):
219 222 if not revsvisit:
220 223 break
221 224
@@ -2223,11 +2223,11 b' def handlerbc(op, inpart):'
2223 2223 total += header[1] + header[2]
2224 2224 utf8branch = inpart.read(header[0])
2225 2225 branch = encoding.tolocal(utf8branch)
2226 for x in xrange(header[1]):
2226 for x in pycompat.xrange(header[1]):
2227 2227 node = inpart.read(20)
2228 2228 rev = cl.rev(node)
2229 2229 cache.setdata(branch, rev, node, False)
2230 for x in xrange(header[2]):
2230 for x in pycompat.xrange(header[2]):
2231 2231 node = inpart.read(20)
2232 2232 rev = cl.rev(node)
2233 2233 cache.setdata(branch, rev, node, True)
@@ -325,7 +325,7 b' class cg1unpacker(object):'
325 325 cl = repo.changelog
326 326 ml = repo.manifestlog
327 327 # validate incoming csets have their manifests
328 for cset in xrange(clstart, clend):
328 for cset in pycompat.xrange(clstart, clend):
329 329 mfnode = cl.changelogrevision(cset).manifest
330 330 mfest = ml[mfnode].readdelta()
331 331 # store file cgnodes we must see
@@ -367,7 +367,7 b' class cg1unpacker(object):'
367 367 repo.hook('pretxnchangegroup',
368 368 throw=True, **pycompat.strkwargs(hookargs))
369 369
370 added = [cl.node(r) for r in xrange(clstart, clend)]
370 added = [cl.node(r) for r in pycompat.xrange(clstart, clend)]
371 371 phaseall = None
372 372 if srctype in ('push', 'serve'):
373 373 # Old servers can not push the boundary themselves.
@@ -568,7 +568,7 b' class cg1packer(object):'
568 568 if units is not None:
569 569 progress = self._repo.ui.makeprogress(_('bundling'), unit=units,
570 570 total=(len(revs) - 1))
571 for r in xrange(len(revs) - 1):
571 for r in pycompat.xrange(len(revs) - 1):
572 572 if progress:
573 573 progress.update(r + 1)
574 574 prev, curr = revs[r], revs[r + 1]
@@ -989,7 +989,7 b' def _addchangegroupfiles(repo, source, r'
989 989 revisions += len(fl) - o
990 990 if f in needfiles:
991 991 needs = needfiles[f]
992 for new in xrange(o, len(fl)):
992 for new in pycompat.xrange(o, len(fl)):
993 993 n = fl.node(new)
994 994 if n in needs:
995 995 needs.remove(n)
@@ -313,7 +313,7 b' class changelog(revlog.revlog):'
313 313 self.filteredrevs = frozenset()
314 314
315 315 def tiprev(self):
316 for i in xrange(len(self) -1, -2, -1):
316 for i in pycompat.xrange(len(self) -1, -2, -1):
317 317 if i not in self.filteredrevs:
318 318 return i
319 319
@@ -332,7 +332,7 b' class changelog(revlog.revlog):'
332 332 return revlog.revlog.__iter__(self)
333 333
334 334 def filterediter():
335 for i in xrange(len(self)):
335 for i in pycompat.xrange(len(self)):
336 336 if i not in self.filteredrevs:
337 337 yield i
338 338
@@ -563,8 +563,8 b' class changelog(revlog.revlog):'
563 563 if revs is not None:
564 564 if revs:
565 565 assert revs[-1] + 1 == rev
566 revs = xrange(revs[0], rev + 1)
566 revs = pycompat.xrange(revs[0], rev + 1)
567 567 else:
568 revs = xrange(rev, rev + 1)
568 revs = pycompat.xrange(rev, rev + 1)
569 569 transaction.changes['revs'] = revs
570 570 return node
@@ -1755,7 +1755,7 b' def walkfilerevs(repo, match, follow, re'
1755 1755 """
1756 1756 cl_count = len(repo)
1757 1757 revs = []
1758 for j in xrange(0, last + 1):
1758 for j in pycompat.xrange(0, last + 1):
1759 1759 linkrev = filelog.linkrev(j)
1760 1760 if linkrev < minrev:
1761 1761 continue
@@ -1966,7 +1966,7 b' def walkchangerevs(repo, match, opts, pr'
1966 1966 rev = repo[rev].rev()
1967 1967 ff = _followfilter(repo)
1968 1968 stop = min(revs[0], revs[-1])
1969 for x in xrange(rev, stop - 1, -1):
1969 for x in pycompat.xrange(rev, stop - 1, -1):
1970 1970 if ff.match(x):
1971 1971 wanted = wanted - [x]
1972 1972
@@ -1985,7 +1985,7 b' def walkchangerevs(repo, match, opts, pr'
1985 1985 stopiteration = False
1986 1986 for windowsize in increasingwindows():
1987 1987 nrevs = []
1988 for i in xrange(windowsize):
1988 for i in pycompat.xrange(windowsize):
1989 1989 rev = next(it, None)
1990 1990 if rev is None:
1991 1991 stopiteration = True
@@ -2607,15 +2607,15 b' def grep(ui, repo, pattern, *pats, **opt'
2607 2607 sm = difflib.SequenceMatcher(None, a, b)
2608 2608 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2609 2609 if tag == 'insert':
2610 for i in xrange(blo, bhi):
2610 for i in pycompat.xrange(blo, bhi):
2611 2611 yield ('+', b[i])
2612 2612 elif tag == 'delete':
2613 for i in xrange(alo, ahi):
2613 for i in pycompat.xrange(alo, ahi):
2614 2614 yield ('-', a[i])
2615 2615 elif tag == 'replace':
2616 for i in xrange(alo, ahi):
2616 for i in pycompat.xrange(alo, ahi):
2617 2617 yield ('-', a[i])
2618 for i in xrange(blo, bhi):
2618 for i in pycompat.xrange(blo, bhi):
2619 2619 yield ('+', b[i])
2620 2620
2621 2621 def display(fm, fn, ctx, pstates, states):
@@ -1896,7 +1896,7 b' class overlayworkingctx(committablectx):'
1896 1896 # Test that each new directory to be created to write this path from p2
1897 1897 # is not a file in p1.
1898 1898 components = path.split('/')
1899 for i in xrange(len(components)):
1899 for i in pycompat.xrange(len(components)):
1900 1900 component = "/".join(components[0:i])
1901 1901 if component in self.p1():
1902 1902 fail(path, component)
@@ -195,7 +195,7 b' def _builddescendantsmap(repo, startrev,'
195 195 """Build map of 'rev -> child revs', offset from startrev"""
196 196 cl = repo.changelog
197 197 nullrev = node.nullrev
198 descmap = [[] for _rev in xrange(startrev, len(cl))]
198 descmap = [[] for _rev in pycompat.xrange(startrev, len(cl))]
199 199 for currev in cl.revs(startrev + 1):
200 200 p1rev, p2rev = cl.parentrevs(currev)
201 201 if p1rev >= startrev:
@@ -435,7 +435,7 b' def _annotatepair(parents, childfctx, ch'
435 435 for idx, (parent, blocks) in enumerate(pblocks):
436 436 for (a1, a2, b1, b2), _t in blocks:
437 437 if a2 - a1 >= b2 - b1:
438 for bk in xrange(b1, b2):
438 for bk in pycompat.xrange(b1, b2):
439 439 if child.fctxs[bk] == childfctx:
440 440 ak = min(a1 + (bk - b1), a2 - 1)
441 441 child.fctxs[bk] = parent.fctxs[ak]
@@ -448,7 +448,7 b' def _annotatepair(parents, childfctx, ch'
448 448 # line.
449 449 for parent, blocks in remaining:
450 450 for a1, a2, b1, b2 in blocks:
451 for bk in xrange(b1, b2):
451 for bk in pycompat.xrange(b1, b2):
452 452 if child.fctxs[bk] == childfctx:
453 453 ak = min(a1 + (bk - b1), a2 - 1)
454 454 child.fctxs[bk] = parent.fctxs[ak]
@@ -222,7 +222,7 b' def parsedag(desc):'
222 222 elif c == '+':
223 223 c, digs = nextrun(nextch(), pycompat.bytestr(string.digits))
224 224 n = int(digs)
225 for i in xrange(0, n):
225 for i in pycompat.xrange(0, n):
226 226 yield 'n', (r, [p1])
227 227 p1 = r
228 228 r += 1
@@ -177,7 +177,8 b' def debugbuilddag(ui, repo, text=None,'
177 177 if mergeable_file:
178 178 linesperrev = 2
179 179 # make a file with k lines per rev
180 initialmergedlines = ['%d' % i for i in xrange(0, total * linesperrev)]
180 initialmergedlines = ['%d' % i
181 for i in pycompat.xrange(0, total * linesperrev)]
181 182 initialmergedlines.append("")
182 183
183 184 tags = []
@@ -2018,7 +2019,7 b' def debugrevlog(ui, repo, file_=None, **'
2018 2019 ts = 0
2019 2020 heads = set()
2020 2021
2021 for rev in xrange(numrevs):
2022 for rev in pycompat.xrange(numrevs):
2022 2023 dbase = r.deltaparent(rev)
2023 2024 if dbase == -1:
2024 2025 dbase = rev
@@ -2079,7 +2080,7 b' def debugrevlog(ui, repo, file_=None, **'
2079 2080 l[2] += size
2080 2081
2081 2082 numrevs = len(r)
2082 for rev in xrange(numrevs):
2083 for rev in pycompat.xrange(numrevs):
2083 2084 p1, p2 = r.parentrevs(rev)
2084 2085 delta = r.deltaparent(rev)
2085 2086 if format > 0:
@@ -11,6 +11,7 b' from .i18n import _'
11 11
12 12 from . import (
13 13 error,
14 pycompat,
14 15 )
15 16
16 17 def addlines(fp, hunk, lena, lenb, a, b):
@@ -26,7 +27,7 b' def addlines(fp, hunk, lena, lenb, a, b)'
26 27 num = max(todoa, todob)
27 28 if num == 0:
28 29 break
29 for i in xrange(num):
30 for i in pycompat.xrange(num):
30 31 s = fp.readline()
31 32 if not s:
32 33 raise error.ParseError(_('incomplete hunk'))
@@ -71,7 +72,7 b' def testhunk(a, b, bstart):'
71 72 blen = len(b)
72 73 if alen > blen - bstart or bstart < 0:
73 74 return False
74 for i in xrange(alen):
75 for i in pycompat.xrange(alen):
75 76 if a[i][1:] != b[i + bstart]:
76 77 return False
77 78 return True
@@ -251,7 +251,7 b' def ucolwidth(d):'
251 251 def getcols(s, start, c):
252 252 '''Use colwidth to find a c-column substring of s starting at byte
253 253 index start'''
254 for x in xrange(start + c, len(s)):
254 for x in pycompat.xrange(start + c, len(s)):
255 255 t = s[start:x]
256 256 if colwidth(t) == c:
257 257 return t
@@ -346,7 +346,7 b" def trim(s, width, ellipsis='', leftside"
346 346 else:
347 347 uslice = lambda i: u[:-i]
348 348 concat = lambda s: s + ellipsis
349 for i in xrange(1, len(u)):
349 for i in pycompat.xrange(1, len(u)):
350 350 usub = uslice(i)
351 351 if ucolwidth(usub) <= width:
352 352 return concat(usub.encode(_sysstr(encoding)))
@@ -22,6 +22,7 b' from __future__ import absolute_import'
22 22 from .node import nullrev
23 23 from . import (
24 24 dagop,
25 pycompat,
25 26 smartset,
26 27 util,
27 28 )
@@ -426,16 +427,16 b' def ascii(ui, state, type, char, text, c'
426 427 # shift_interline is the line containing the non-vertical
427 428 # edges between this entry and the next
428 429 shift_interline = echars[:idx * 2]
429 for i in xrange(2 + coldiff):
430 for i in pycompat.xrange(2 + coldiff):
430 431 shift_interline.append(' ')
431 432 count = ncols - idx - 1
432 433 if coldiff == -1:
433 for i in xrange(count):
434 for i in pycompat.xrange(count):
434 435 shift_interline.extend(['/', ' '])
435 436 elif coldiff == 0:
436 437 shift_interline.extend(echars[(idx + 1) * 2:ncols * 2])
437 438 else:
438 for i in xrange(count):
439 for i in pycompat.xrange(count):
439 440 shift_interline.extend(['\\', ' '])
440 441
441 442 # draw edges from the current node to its parents
@@ -215,7 +215,7 b' def _search(web):'
215 215
216 216 def revgen():
217 217 cl = web.repo.changelog
218 for i in xrange(len(web.repo) - 1, 0, -100):
218 for i in pycompat.xrange(len(web.repo) - 1, 0, -100):
219 219 l = []
220 220 for j in cl.revs(max(0, i - 99), i):
221 221 ctx = web.repo[j]
@@ -613,21 +613,21 b' def _getcompblockgen(context, leftlines,'
613 613 len1 = lhi - llo
614 614 len2 = rhi - rlo
615 615 count = min(len1, len2)
616 for i in xrange(count):
616 for i in pycompat.xrange(count):
617 617 yield _compline(type=type,
618 618 leftlineno=llo + i + 1,
619 619 leftline=leftlines[llo + i],
620 620 rightlineno=rlo + i + 1,
621 621 rightline=rightlines[rlo + i])
622 622 if len1 > len2:
623 for i in xrange(llo + count, lhi):
623 for i in pycompat.xrange(llo + count, lhi):
624 624 yield _compline(type=type,
625 625 leftlineno=i + 1,
626 626 leftline=leftlines[i],
627 627 rightlineno=None,
628 628 rightline=None)
629 629 elif len2 > len1:
630 for i in xrange(rlo + count, rhi):
630 for i in pycompat.xrange(rlo + count, rhi):
631 631 yield _compline(type=type,
632 632 leftlineno=None,
633 633 leftline=None,
@@ -64,7 +64,7 b' def encodevalueinheaders(value, header, '
64 64 result = []
65 65
66 66 n = 0
67 for i in xrange(0, len(value), valuelen):
67 for i in pycompat.xrange(0, len(value), valuelen):
68 68 n += 1
69 69 result.append((fmt % str(n), pycompat.strurl(value[i:i + valuelen])))
70 70
@@ -850,7 +850,7 b' class localrepository(object):'
850 850 if isinstance(changeid, slice):
851 851 # wdirrev isn't contiguous so the slice shouldn't include it
852 852 return [context.changectx(self, i)
853 for i in xrange(*changeid.indices(len(self)))
853 for i in pycompat.xrange(*changeid.indices(len(self)))
854 854 if i not in self.changelog.filteredrevs]
855 855 try:
856 856 return context.changectx(self, changeid)
@@ -1385,7 +1385,7 b' class localrepository(object):'
1385 1385 releasefn=releasefn,
1386 1386 checkambigfiles=_cachedfiles,
1387 1387 name=desc)
1388 tr.changes['revs'] = xrange(0, 0)
1388 tr.changes['revs'] = pycompat.xrange(0, 0)
1389 1389 tr.changes['obsmarkers'] = set()
1390 1390 tr.changes['phases'] = {}
1391 1391 tr.changes['bookmarks'] = {}
@@ -357,7 +357,7 b' def _unidiff(t1, t2, opts=defaultopts):'
357 357 # walk backwards from the start of the context up to the start of
358 358 # the previous hunk context until we find a line starting with an
359 359 # alphanumeric char.
360 for i in xrange(astart - 1, lastpos - 1, -1):
360 for i in pycompat.xrange(astart - 1, lastpos - 1, -1):
361 361 if l1[i][0:1].isalnum():
362 362 func = b' ' + l1[i].rstrip()
363 363 # split long function name if ASCII. otherwise we have no
@@ -381,7 +381,7 b' def _unidiff(t1, t2, opts=defaultopts):'
381 381 hunklines = (
382 382 ["@@ -%d,%d +%d,%d @@%s\n" % (hunkrange + (func,))]
383 383 + delta
384 + [' ' + l1[x] for x in xrange(a2, aend)]
384 + [' ' + l1[x] for x in pycompat.xrange(a2, aend)]
385 385 )
386 386 # If either file ends without a newline and the last line of
387 387 # that file is part of a hunk, a marker is printed. If the
@@ -390,7 +390,7 b' def _unidiff(t1, t2, opts=defaultopts):'
390 390 # which the hunk can end in a shared line without a newline.
391 391 skip = False
392 392 if not t1.endswith('\n') and astart + alen == len(l1) + 1:
393 for i in xrange(len(hunklines) - 1, -1, -1):
393 for i in pycompat.xrange(len(hunklines) - 1, -1, -1):
394 394 if hunklines[i].startswith(('-', ' ')):
395 395 if hunklines[i].startswith(' '):
396 396 skip = True
@@ -398,7 +398,7 b' def _unidiff(t1, t2, opts=defaultopts):'
398 398 hunklines.insert(i + 1, _missing_newline_marker)
399 399 break
400 400 if not skip and not t2.endswith('\n') and bstart + blen == len(l2) + 1:
401 for i in xrange(len(hunklines) - 1, -1, -1):
401 for i in pycompat.xrange(len(hunklines) - 1, -1, -1):
402 402 if hunklines[i].startswith('+'):
403 403 hunklines[i] += '\n'
404 404 hunklines.insert(i + 1, _missing_newline_marker)
@@ -316,7 +316,7 b' def findtables(blocks):'
316 316
317 317 # column markers are ASCII so we can calculate column
318 318 # position in bytes
319 columns = [x for x in xrange(len(div))
319 columns = [x for x in pycompat.xrange(len(div))
320 320 if div[x:x + 1] == '=' and (x == 0 or
321 321 div[x - 1:x] == ' ')]
322 322 rows = []
@@ -685,7 +685,7 b' def format(text, width=80, indent=0, kee'
685 685 if llen and llen != plen:
686 686 collapse = False
687 687 s = []
688 for j in xrange(3, plen - 1):
688 for j in pycompat.xrange(3, plen - 1):
689 689 parent = parents[j]
690 690 if (j >= llen or
691 691 lastparents[j] != parent):
@@ -394,7 +394,7 b' def _fm1purereadmarkers(data, off, stop)'
394 394 off = o3 + metasize * nummeta
395 395 metapairsize = unpack('>' + (metafmt * nummeta), data[o3:off])
396 396 metadata = []
397 for idx in xrange(0, len(metapairsize), 2):
397 for idx in pycompat.xrange(0, len(metapairsize), 2):
398 398 o1 = off + metapairsize[idx]
399 399 o2 = o1 + metapairsize[idx + 1]
400 400 metadata.append((data[off:o1], data[o1:o2]))
@@ -815,7 +815,7 b' class patchfile(object):'
815 815 for x, s in enumerate(self.lines):
816 816 self.hash.setdefault(s, []).append(x)
817 817
818 for fuzzlen in xrange(self.ui.configint("patch", "fuzz") + 1):
818 for fuzzlen in pycompat.xrange(self.ui.configint("patch", "fuzz") + 1):
819 819 for toponly in [True, False]:
820 820 old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly)
821 821 oldstart = oldstart + self.offset + self.skew
@@ -1286,7 +1286,7 b' class hunk(object):'
1286 1286 self.lena = int(aend) - self.starta
1287 1287 if self.starta:
1288 1288 self.lena += 1
1289 for x in xrange(self.lena):
1289 for x in pycompat.xrange(self.lena):
1290 1290 l = lr.readline()
1291 1291 if l.startswith('---'):
1292 1292 # lines addition, old block is empty
@@ -1320,7 +1320,7 b' class hunk(object):'
1320 1320 if self.startb:
1321 1321 self.lenb += 1
1322 1322 hunki = 1
1323 for x in xrange(self.lenb):
1323 for x in pycompat.xrange(self.lenb):
1324 1324 l = lr.readline()
1325 1325 if l.startswith('\ '):
1326 1326 # XXX: the only way to hit this is with an invalid line range.
@@ -1396,14 +1396,14 b' class hunk(object):'
1396 1396 top = 0
1397 1397 bot = 0
1398 1398 hlen = len(self.hunk)
1399 for x in xrange(hlen - 1):
1399 for x in pycompat.xrange(hlen - 1):
1400 1400 # the hunk starts with the @@ line, so use x+1
1401 1401 if self.hunk[x + 1].startswith(' '):
1402 1402 top += 1
1403 1403 else:
1404 1404 break
1405 1405 if not toponly:
1406 for x in xrange(hlen - 1):
1406 for x in pycompat.xrange(hlen - 1):
1407 1407 if self.hunk[hlen - bot - 1].startswith(' '):
1408 1408 bot += 1
1409 1409 else:
@@ -374,7 +374,7 b' class phasecache(object):'
374 374
375 375 changes = set() # set of revisions to be changed
376 376 delroots = [] # set of root deleted by this path
377 for phase in xrange(targetphase + 1, len(allphases)):
377 for phase in pycompat.xrange(targetphase + 1, len(allphases)):
378 378 # filter nodes that are not in a compatible phase already
379 379 nodes = [n for n in nodes
380 380 if self.phase(repo, repo[n].rev()) >= phase]
@@ -420,7 +420,7 b' class phasecache(object):'
420 420 affected = set(repo.revs('(%ln::) - (%ln::)', new, old))
421 421
422 422 # find the phase of the affected revision
423 for phase in xrange(targetphase, -1, -1):
423 for phase in pycompat.xrange(targetphase, -1, -1):
424 424 if phase:
425 425 roots = oldroots[phase]
426 426 revs = set(repo.revs('%ln::%ld', roots, affected))
@@ -150,7 +150,7 b' if not pycompat.iswindows:'
150 150 rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int))
151 151 rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) /
152 152 ctypes.sizeof(ctypes.c_int))
153 return [rfds[i] for i in xrange(rfdscount)]
153 return [rfds[i] for i in pycompat.xrange(rfdscount)]
154 154
155 155 else:
156 156 import msvcrt
@@ -52,6 +52,7 b' from __future__ import absolute_import'
52 52
53 53 from .node import nullrev
54 54 from . import (
55 pycompat,
55 56 util,
56 57 )
57 58
@@ -72,7 +73,7 b' def _bin(bs):'
72 73
73 74 def _str(v, l):
74 75 bs = ""
75 for p in xrange(l):
76 for p in pycompat.xrange(l):
76 77 bs = chr(v & 255) + bs
77 78 v >>= 8
78 79 return bs
@@ -91,7 +92,7 b' def _hweight(x):'
91 92 c += 1
92 93 x >>= 1
93 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 97 def _hamming(a, b):
97 98 '''find the hamming distance between two longs'''
@@ -152,7 +153,7 b' def ctxpvec(ctx):'
152 153 pvc = r._pveccache
153 154 if ctx.rev() not in pvc:
154 155 cl = r.changelog
155 for n in xrange(ctx.rev() + 1):
156 for n in pycompat.xrange(ctx.rev() + 1):
156 157 if n not in pvc:
157 158 node = cl.node(n)
158 159 p1, p2 = cl.parentrevs(n)
@@ -24,6 +24,7 b' from . import ('
24 24 exchange,
25 25 obsolete,
26 26 obsutil,
27 pycompat,
27 28 util,
28 29 )
29 30 from .utils import (
@@ -70,7 +71,7 b' def _collectfiles(repo, striprev):'
70 71 """find out the filelogs affected by the strip"""
71 72 files = set()
72 73
73 for x in xrange(striprev, len(repo)):
74 for x in pycompat.xrange(striprev, len(repo)):
74 75 files.update(repo[x].files())
75 76
76 77 return sorted(files)
@@ -199,7 +200,7 b' def strip(ui, repo, nodelist, backup=Tru'
199 200 repo.file(fn).strip(striprev, tr)
200 201 tr.endgroup()
201 202
202 for i in xrange(offset, len(tr.entries)):
203 for i in pycompat.xrange(offset, len(tr.entries)):
203 204 file, troffset, ignore = tr.entries[i]
204 205 with repo.svfs(file, 'a', checkambig=True) as fp:
205 206 fp.truncate(troffset)
@@ -128,7 +128,7 b' def computeimpactable(repo, visibilityex'
128 128 firstmutable = min(firstmutable, min(cl.rev(r) for r in roots))
129 129 # protect from nullrev root
130 130 firstmutable = max(0, firstmutable)
131 return frozenset(xrange(firstmutable, len(cl)))
131 return frozenset(pycompat.xrange(firstmutable, len(cl)))
132 132
133 133 # function to compute filtered set
134 134 #
@@ -1066,7 +1066,7 b' class revlog(object):'
1066 1066 def __len__(self):
1067 1067 return len(self.index) - 1
1068 1068 def __iter__(self):
1069 return iter(xrange(len(self)))
1069 return iter(pycompat.xrange(len(self)))
1070 1070 def revs(self, start=0, stop=None):
1071 1071 """iterate over all rev in this revlog (from start to stop)"""
1072 1072 step = 1
@@ -1079,7 +1079,7 b' class revlog(object):'
1079 1079 stop = length
1080 1080 else:
1081 1081 stop = length
1082 return xrange(start, stop, step)
1082 return pycompat.xrange(start, stop, step)
1083 1083
1084 1084 @util.propertycache
1085 1085 def nodemap(self):
@@ -1136,7 +1136,7 b' class revlog(object):'
1136 1136 p = len(i) - 2
1137 1137 else:
1138 1138 assert p < len(i)
1139 for r in xrange(p, -1, -1):
1139 for r in pycompat.xrange(p, -1, -1):
1140 1140 v = i[r][7]
1141 1141 n[v] = r
1142 1142 if v == node:
@@ -2789,7 +2789,7 b' class revlog(object):'
2789 2789 self._cache = None
2790 2790 self._chaininfocache = {}
2791 2791 self._chunkclear()
2792 for x in xrange(rev, len(self)):
2792 for x in pycompat.xrange(rev, len(self)):
2793 2793 del self.nodemap[self.node(x)]
2794 2794
2795 2795 del self.index[rev:-1]
@@ -63,7 +63,7 b' symbols = {}'
63 63 _syminitletters = set(pycompat.iterbytestr(
64 64 string.ascii_letters.encode('ascii') +
65 65 string.digits.encode('ascii') +
66 '._@')) | set(map(pycompat.bytechr, xrange(128, 256)))
66 '._@')) | set(map(pycompat.bytechr, pycompat.xrange(128, 256)))
67 67
68 68 # default set of valid characters for non-initial letters of symbols
69 69 _symletters = _syminitletters | set(pycompat.iterbytestr('-/'))
@@ -1542,7 +1542,7 b' def registersummarycallback(repo, otr, t'
1542 1542 @reportsummary
1543 1543 def reportnewcs(repo, tr):
1544 1544 """Report the range of new revisions pulled/unbundled."""
1545 newrevs = tr.changes.get('revs', xrange(0, 0))
1545 newrevs = tr.changes.get('revs', pycompat.xrange(0, 0))
1546 1546 if not newrevs:
1547 1547 return
1548 1548
@@ -1565,7 +1565,7 b' def registersummarycallback(repo, otr, t'
1565 1565 """Report statistics of phase changes for changesets pre-existing
1566 1566 pull/unbundle.
1567 1567 """
1568 newrevs = tr.changes.get('revs', xrange(0, 0))
1568 newrevs = tr.changes.get('revs', pycompat.xrange(0, 0))
1569 1569 phasetracking = tr.changes.get('phases', {})
1570 1570 if not phasetracking:
1571 1571 return
@@ -79,7 +79,7 b' def runservice(opts, parentfn=None, init'
79 79 runargs.append('--daemon-postexec=unlink:%s' % lockpath)
80 80 # Don't pass --cwd to the child process, because we've already
81 81 # changed directory.
82 for i in xrange(1, len(runargs)):
82 for i in pycompat.xrange(1, len(runargs)):
83 83 if runargs[i].startswith('--cwd='):
84 84 del runargs[i]
85 85 break
@@ -58,7 +58,8 b' def compare_range(a, astart, aend, b, bs'
58 58 """
59 59 if (aend - astart) != (bend - bstart):
60 60 return False
61 for ia, ib in zip(xrange(astart, aend), xrange(bstart, bend)):
61 for ia, ib in zip(pycompat.xrange(astart, aend),
62 pycompat.xrange(bstart, bend)):
62 63 if a[ia] != b[ib]:
63 64 return False
64 65 else:
@@ -152,11 +152,11 b' class abstractsmartset(object):'
152 152 # but start > stop is allowed, which should be an empty set.
153 153 ys = []
154 154 it = iter(self)
155 for x in xrange(start):
155 for x in pycompat.xrange(start):
156 156 y = next(it, None)
157 157 if y is None:
158 158 break
159 for x in xrange(stop - start):
159 for x in pycompat.xrange(stop - start):
160 160 y = next(it, None)
161 161 if y is None:
162 162 break
@@ -1005,13 +1005,13 b' class _spanset(abstractsmartset):'
1005 1005 return self.fastdesc()
1006 1006
1007 1007 def fastasc(self):
1008 iterrange = xrange(self._start, self._end)
1008 iterrange = pycompat.xrange(self._start, self._end)
1009 1009 if self._hiddenrevs:
1010 1010 return self._iterfilter(iterrange)
1011 1011 return iter(iterrange)
1012 1012
1013 1013 def fastdesc(self):
1014 iterrange = xrange(self._end - 1, self._start - 1, -1)
1014 iterrange = pycompat.xrange(self._end - 1, self._start - 1, -1)
1015 1015 if self._hiddenrevs:
1016 1016 return self._iterfilter(iterrange)
1017 1017 return iter(iterrange)
@@ -118,7 +118,7 b' def _buildencodefun():'
118 118 def decode(s):
119 119 i = 0
120 120 while i < len(s):
121 for l in xrange(1, 4):
121 for l in pycompat.xrange(1, 4):
122 122 try:
123 123 yield dmap[s[i:i + l]]
124 124 i += l
@@ -127,7 +127,8 b' def _buildencodefun():'
127 127 pass
128 128 else:
129 129 raise KeyError
130 return (lambda s: ''.join([cmap[s[c:c + 1]] for c in xrange(len(s))]),
130 return (lambda s: ''.join([cmap[s[c:c + 1]]
131 for c in pycompat.xrange(len(s))]),
131 132 lambda s: ''.join(list(decode(s))))
132 133
133 134 _encodefname, _decodefname = _buildencodefun()
@@ -159,7 +160,7 b' def _buildlowerencodefun():'
159 160 'the~07quick~adshot'
160 161 '''
161 162 xchr = pycompat.bytechr
162 cmap = dict([(xchr(x), xchr(x)) for x in xrange(127)])
163 cmap = dict([(xchr(x), xchr(x)) for x in pycompat.xrange(127)])
163 164 for x in _reserved():
164 165 cmap[xchr(x)] = "~%02x" % x
165 166 for x in range(ord("A"), ord("Z") + 1):
@@ -358,7 +358,7 b' def consumev1(repo, fp, filecount, bytec'
358 358
359 359 with repo.transaction('clone'):
360 360 with repo.svfs.backgroundclosing(repo.ui, expectedcount=filecount):
361 for i in xrange(filecount):
361 for i in pycompat.xrange(filecount):
362 362 # XXX doesn't support '\n' or '\r' in filenames
363 363 l = fp.readline()
364 364 try:
@@ -119,7 +119,7 b' def commondir(filelist):'
119 119 b = b[:len(a)]
120 120 if a == b:
121 121 return a
122 for i in xrange(len(a)):
122 for i in pycompat.xrange(len(a)):
123 123 if a[i] != b[i]:
124 124 return a[:i]
125 125 return a
@@ -266,7 +266,7 b' def indent(text, prefix):'
266 266 num_lines = len(lines)
267 267 endswithnewline = text[-1:] == '\n'
268 268 def indenter():
269 for i in xrange(num_lines):
269 for i in pycompat.xrange(num_lines):
270 270 l = lines[i]
271 271 if i and l.strip():
272 272 yield prefix
@@ -16,6 +16,7 b' from .node import ('
16 16 )
17 17 from . import (
18 18 error,
19 pycompat,
19 20 )
20 21
21 22 def findcommonincoming(repo, remote, heads=None, force=False):
@@ -111,7 +112,7 b' def findcommonincoming(repo, remote, hea'
111 112 progress.increment()
112 113 repo.ui.debug("request %d: %s\n" %
113 114 (reqcnt, " ".join(map(short, r))))
114 for p in xrange(0, len(r), 10):
115 for p in pycompat.xrange(0, len(r), 10):
115 116 with remote.commandexecutor() as e:
116 117 branches = e.callcommand('branches', {
117 118 'nodes': r[p:p + 10],
@@ -464,7 +464,7 b' def _MBTextWrapper(**kwargs):'
464 464 def _cutdown(self, ucstr, space_left):
465 465 l = 0
466 466 colwidth = encoding.ucolwidth
467 for i in xrange(len(ucstr)):
467 for i in pycompat.xrange(len(ucstr)):
468 468 l += colwidth(ucstr[i])
469 469 if space_left < l:
470 470 return (ucstr[:i], ucstr[i:])
@@ -615,7 +615,7 b' def unlink(f):'
615 615 # callers to recreate f immediately while having other readers do their
616 616 # implicit zombie filename blocking on a temporary name.
617 617
618 for tries in xrange(10):
618 for tries in pycompat.xrange(10):
619 619 temp = '%s-%08x' % (f, random.randint(0, 0xffffffff))
620 620 try:
621 621 os.rename(f, temp) # raises OSError EEXIST if temp exists
@@ -502,14 +502,14 b' class sshv1protocolhandler(object):'
502 502 def getargs(self, args):
503 503 data = {}
504 504 keys = args.split()
505 for n in xrange(len(keys)):
505 for n in pycompat.xrange(len(keys)):
506 506 argline = self._fin.readline()[:-1]
507 507 arg, l = argline.split()
508 508 if arg not in keys:
509 509 raise error.Abort(_("unexpected parameter %r") % arg)
510 510 if arg == '*':
511 511 star = {}
512 for k in xrange(int(l)):
512 for k in pycompat.xrange(int(l)):
513 513 argline = self._fin.readline()[:-1]
514 514 arg, l = argline.split()
515 515 val = self._fin.read(int(l))
@@ -497,7 +497,7 b' class wirepeer(repository.peer):'
497 497 def between(self, pairs):
498 498 batch = 8 # avoid giant requests
499 499 r = []
500 for i in xrange(0, len(pairs), batch):
500 for i in pycompat.xrange(0, len(pairs), batch):
501 501 n = " ".join([wireprototypes.encodelist(p, '-')
502 502 for p in pairs[i:i + batch]])
503 503 d = self._call("between", pairs=n)
General Comments 0
You need to be logged in to leave comments. Login now