##// END OF EJS Templates
clfilter: remove usage of `range` in favor of iteration over changelog...
Pierre-Yves David -
r17675:8575f4a2 default
parent child Browse files
Show More
@@ -1394,7 +1394,8 b' def getgraphlogrevs(repo, pats, opts):'
1394 if follow and len(repo) > 0:
1394 if follow and len(repo) > 0:
1395 revs = scmutil.revrange(repo, ['.:0'])
1395 revs = scmutil.revrange(repo, ['.:0'])
1396 else:
1396 else:
1397 revs = range(len(repo) - 1, -1, -1)
1397 revs = list(repo.changelog)
1398 revs.reverse()
1398 if not revs:
1399 if not revs:
1399 return iter([]), None, None
1400 return iter([]), None, None
1400 expr, filematcher = _makegraphlogrevset(repo, pats, opts, revs)
1401 expr, filematcher = _makegraphlogrevset(repo, pats, opts, revs)
@@ -363,14 +363,13 b' class localrepository(object):'
363 return len(self.changelog)
363 return len(self.changelog)
364
364
365 def __iter__(self):
365 def __iter__(self):
366 for i in xrange(len(self)):
366 return iter(self.changelog)
367 yield i
368
367
369 def revs(self, expr, *args):
368 def revs(self, expr, *args):
370 '''Return a list of revisions matching the given revset'''
369 '''Return a list of revisions matching the given revset'''
371 expr = revset.formatspec(expr, *args)
370 expr = revset.formatspec(expr, *args)
372 m = revset.match(None, expr)
371 m = revset.match(None, expr)
373 return [r for r in m(self, range(len(self)))]
372 return [r for r in m(self, list(self))]
374
373
375 def set(self, expr, *args):
374 def set(self, expr, *args):
376 '''
375 '''
@@ -603,7 +602,7 b' class localrepository(object):'
603 # TODO: rename this function?
602 # TODO: rename this function?
604 tiprev = len(self) - 1
603 tiprev = len(self) - 1
605 if lrev != tiprev:
604 if lrev != tiprev:
606 ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1))
605 ctxgen = (self[r] for r in self.changelog.revs(lrev + 1, tiprev))
607 self._updatebranchcache(partial, ctxgen)
606 self._updatebranchcache(partial, ctxgen)
608 self._writebranchcache(partial, self.changelog.tip(), tiprev)
607 self._writebranchcache(partial, self.changelog.tip(), tiprev)
609
608
@@ -215,11 +215,11 b' def symbolset(repo, subset, x):'
215 def rangeset(repo, subset, x, y):
215 def rangeset(repo, subset, x, y):
216 m = getset(repo, subset, x)
216 m = getset(repo, subset, x)
217 if not m:
217 if not m:
218 m = getset(repo, range(len(repo)), x)
218 m = getset(repo, list(repo), x)
219
219
220 n = getset(repo, subset, y)
220 n = getset(repo, subset, y)
221 if not n:
221 if not n:
222 n = getset(repo, range(len(repo)), y)
222 n = getset(repo, list(repo), y)
223
223
224 if not m or not n:
224 if not m or not n:
225 return []
225 return []
@@ -234,7 +234,7 b' def rangeset(repo, subset, x, y):'
234
234
235 def dagrange(repo, subset, x, y):
235 def dagrange(repo, subset, x, y):
236 if subset:
236 if subset:
237 r = range(len(repo))
237 r = list(repo)
238 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
238 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
239 s = set(subset)
239 s = set(subset)
240 return [r for r in xs if r in s]
240 return [r for r in xs if r in s]
@@ -277,7 +277,7 b' def ancestor(repo, subset, x):'
277 """
277 """
278 # i18n: "ancestor" is a keyword
278 # i18n: "ancestor" is a keyword
279 l = getargs(x, 2, 2, _("ancestor requires two arguments"))
279 l = getargs(x, 2, 2, _("ancestor requires two arguments"))
280 r = range(len(repo))
280 r = list(repo)
281 a = getset(repo, r, l[0])
281 a = getset(repo, r, l[0])
282 b = getset(repo, r, l[1])
282 b = getset(repo, r, l[1])
283 if len(a) != 1 or len(b) != 1:
283 if len(a) != 1 or len(b) != 1:
@@ -288,7 +288,7 b' def ancestor(repo, subset, x):'
288 return [r for r in an if r in subset]
288 return [r for r in an if r in subset]
289
289
290 def _ancestors(repo, subset, x, followfirst=False):
290 def _ancestors(repo, subset, x, followfirst=False):
291 args = getset(repo, range(len(repo)), x)
291 args = getset(repo, list(repo), x)
292 if not args:
292 if not args:
293 return []
293 return []
294 s = set(_revancestors(repo, args, followfirst)) | set(args)
294 s = set(_revancestors(repo, args, followfirst)) | set(args)
@@ -415,7 +415,7 b' def branch(repo, subset, x):'
415 else:
415 else:
416 return [r for r in subset if matcher(repo[r].branch())]
416 return [r for r in subset if matcher(repo[r].branch())]
417
417
418 s = getset(repo, range(len(repo)), x)
418 s = getset(repo, list(repo), x)
419 b = set()
419 b = set()
420 for r in s:
420 for r in s:
421 b.add(repo[r].branch())
421 b.add(repo[r].branch())
@@ -466,7 +466,7 b' def children(repo, subset, x):'
466 """``children(set)``
466 """``children(set)``
467 Child changesets of changesets in set.
467 Child changesets of changesets in set.
468 """
468 """
469 s = set(getset(repo, range(len(repo)), x))
469 s = set(getset(repo, list(repo), x))
470 cs = _children(repo, subset, s)
470 cs = _children(repo, subset, s)
471 return [r for r in subset if r in cs]
471 return [r for r in subset if r in cs]
472
472
@@ -547,7 +547,7 b' def desc(repo, subset, x):'
547 return l
547 return l
548
548
549 def _descendants(repo, subset, x, followfirst=False):
549 def _descendants(repo, subset, x, followfirst=False):
550 args = getset(repo, range(len(repo)), x)
550 args = getset(repo, list(repo), x)
551 if not args:
551 if not args:
552 return []
552 return []
553 s = set(_revdescendants(repo, args, followfirst)) | set(args)
553 s = set(_revdescendants(repo, args, followfirst)) | set(args)
@@ -571,9 +571,9 b' def destination(repo, subset, x):'
571 is the same as passing all().
571 is the same as passing all().
572 """
572 """
573 if x is not None:
573 if x is not None:
574 args = set(getset(repo, range(len(repo)), x))
574 args = set(getset(repo, list(repo), x))
575 else:
575 else:
576 args = set(getall(repo, range(len(repo)), x))
576 args = set(getall(repo, list(repo), x))
577
577
578 dests = set()
578 dests = set()
579
579
@@ -877,7 +877,7 b' def limit(repo, subset, x):'
877 # i18n: "limit" is a keyword
877 # i18n: "limit" is a keyword
878 raise error.ParseError(_("limit expects a number"))
878 raise error.ParseError(_("limit expects a number"))
879 ss = set(subset)
879 ss = set(subset)
880 os = getset(repo, range(len(repo)), l[0])[:lim]
880 os = getset(repo, list(repo), l[0])[:lim]
881 return [r for r in os if r in ss]
881 return [r for r in os if r in ss]
882
882
883 def last(repo, subset, x):
883 def last(repo, subset, x):
@@ -895,14 +895,14 b' def last(repo, subset, x):'
895 # i18n: "last" is a keyword
895 # i18n: "last" is a keyword
896 raise error.ParseError(_("last expects a number"))
896 raise error.ParseError(_("last expects a number"))
897 ss = set(subset)
897 ss = set(subset)
898 os = getset(repo, range(len(repo)), l[0])[-lim:]
898 os = getset(repo, list(repo), l[0])[-lim:]
899 return [r for r in os if r in ss]
899 return [r for r in os if r in ss]
900
900
901 def maxrev(repo, subset, x):
901 def maxrev(repo, subset, x):
902 """``max(set)``
902 """``max(set)``
903 Changeset with highest revision number in set.
903 Changeset with highest revision number in set.
904 """
904 """
905 os = getset(repo, range(len(repo)), x)
905 os = getset(repo, list(repo), x)
906 if os:
906 if os:
907 m = max(os)
907 m = max(os)
908 if m in subset:
908 if m in subset:
@@ -922,7 +922,7 b' def minrev(repo, subset, x):'
922 """``min(set)``
922 """``min(set)``
923 Changeset with lowest revision number in set.
923 Changeset with lowest revision number in set.
924 """
924 """
925 os = getset(repo, range(len(repo)), x)
925 os = getset(repo, list(repo), x)
926 if os:
926 if os:
927 m = min(os)
927 m = min(os)
928 if m in subset:
928 if m in subset:
@@ -972,9 +972,9 b' def origin(repo, subset, x):'
972 for the first operation is selected.
972 for the first operation is selected.
973 """
973 """
974 if x is not None:
974 if x is not None:
975 args = set(getset(repo, range(len(repo)), x))
975 args = set(getset(repo, list(repo), x))
976 else:
976 else:
977 args = set(getall(repo, range(len(repo)), x))
977 args = set(getall(repo, list(repo), x))
978
978
979 def _firstsrc(rev):
979 def _firstsrc(rev):
980 src = _getrevsource(repo, rev)
980 src = _getrevsource(repo, rev)
@@ -1024,7 +1024,7 b' def p1(repo, subset, x):'
1024
1024
1025 ps = set()
1025 ps = set()
1026 cl = repo.changelog
1026 cl = repo.changelog
1027 for r in getset(repo, range(len(repo)), x):
1027 for r in getset(repo, list(repo), x):
1028 ps.add(cl.parentrevs(r)[0])
1028 ps.add(cl.parentrevs(r)[0])
1029 return [r for r in subset if r in ps]
1029 return [r for r in subset if r in ps]
1030
1030
@@ -1042,7 +1042,7 b' def p2(repo, subset, x):'
1042
1042
1043 ps = set()
1043 ps = set()
1044 cl = repo.changelog
1044 cl = repo.changelog
1045 for r in getset(repo, range(len(repo)), x):
1045 for r in getset(repo, list(repo), x):
1046 ps.add(cl.parentrevs(r)[1])
1046 ps.add(cl.parentrevs(r)[1])
1047 return [r for r in subset if r in ps]
1047 return [r for r in subset if r in ps]
1048
1048
@@ -1056,7 +1056,7 b' def parents(repo, subset, x):'
1056
1056
1057 ps = set()
1057 ps = set()
1058 cl = repo.changelog
1058 cl = repo.changelog
1059 for r in getset(repo, range(len(repo)), x):
1059 for r in getset(repo, list(repo), x):
1060 ps.update(cl.parentrevs(r))
1060 ps.update(cl.parentrevs(r))
1061 return [r for r in subset if r in ps]
1061 return [r for r in subset if r in ps]
1062
1062
@@ -631,7 +631,7 b' def revrange(repo, revs):'
631
631
632 # fall through to new-style queries if old-style fails
632 # fall through to new-style queries if old-style fails
633 m = revset.match(repo.ui, spec)
633 m = revset.match(repo.ui, spec)
634 dl = [r for r in m(repo, xrange(len(repo))) if r not in seen]
634 dl = [r for r in m(repo, list(repo)) if r not in seen]
635 l.extend(dl)
635 l.extend(dl)
636 seen.update(dl)
636 seen.update(dl)
637
637
General Comments 0
You need to be logged in to leave comments. Login now