localrepo: add set method to iterate over a given revset
This should allow replacing a number of hand-rolled graph algorithms.
--- a/mercurial/localrepo.py Thu Jul 21 14:05:45 2011 -0500
+++ b/mercurial/localrepo.py Thu Jul 21 14:06:55 2011 -0500
@@ -10,7 +10,7 @@
import repo, changegroup, subrepo, discovery, pushkey
import changelog, dirstate, filelog, manifest, context, bookmarks
import lock, transaction, store, encoding
-import scmutil, util, extensions, hook, error
+import scmutil, util, extensions, hook, error, revset
import match as matchmod
import merge as mergemod
import tags as tagsmod
@@ -217,6 +217,17 @@
for i in xrange(len(self)):
yield i
+ def set(self, expr, *args):
+ '''
+ Yield a context for each matching revision, after doing arg
+ replacement via formatrevspec
+ '''
+
+ expr = revset.formatspec(expr, *args)
+ m = revset.match(None, expr)
+ for r in m(self, range(len(self))):
+ yield self[r]
+
def url(self):
return 'file:' + self.root