# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1394811832 25200
#      Fri Mar 14 08:43:52 2014 -0700
# Node ID cfd03c069e082fec71bf403462daf612cf522c63
# Parent  f15ff553b762fb76bb250038ee0b7ab7fdbe2b96
cmdutil: changed code in getgraphlogrevs not to use getitem

__getitem__ is a method that is not implemented lazily on many of the new
classes and it can be easily replaced with a structure that takes advantage of
the new lazy implementations instead.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1661,7 +1661,12 @@
         revs = matcher(repo, revs)
         revs.sort(reverse=True)
     if limit is not None:
-        revs = revs[:limit]
+        limitedrevs = revset.baseset()
+        for idx, rev in enumerate(revs):
+            if idx >= limit:
+                break
+            limitedrevs.append(rev)
+        revs = limitedrevs
 
     return revs, expr, filematcher