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