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