localrepo: add revs helper method
authorMatt Mackall <mpm@selenic.com>
Wed, 02 Nov 2011 13:37:34 -0500
changeset 15403 e27561eb4a76
parent 15402 f437967f9f80
child 15404 c1eb8398fe82
localrepo: add revs helper method
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Nov 01 16:49:30 2011 -0500
+++ b/mercurial/localrepo.py	Wed Nov 02 13:37:34 2011 -0500
@@ -220,15 +220,18 @@
         for i in xrange(len(self)):
             yield i
 
+    def revs(self, expr, *args):
+        '''Return a list of revisions matching the given revset'''
+        expr = revset.formatspec(expr, *args)
+        m = revset.match(None, expr)
+        return [r for r in m(self, range(len(self)))]
+
     def set(self, expr, *args):
         '''
         Yield a context for each matching revision, after doing arg
         replacement via revset.formatspec
         '''
-
-        expr = revset.formatspec(expr, *args)
-        m = revset.match(None, expr)
-        for r in m(self, range(len(self))):
+        for r in self.revs(expr, *args):
             yield self[r]
 
     def url(self):