subrepo: introduce getfileset()
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 15 May 2015 23:13:05 -0400
changeset 25121 df63d4843581
parent 25120 a7701001c829
child 25122 755d23a49170
subrepo: introduce getfileset() This will be used in the next patch to help matchers resolve filesets in subrepos. The default implementation returns an empty set (for git and svn).
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Fri May 15 09:46:21 2015 +0200
+++ b/mercurial/subrepo.py	Fri May 15 23:13:05 2015 -0400
@@ -500,6 +500,10 @@
         """return file flags"""
         return ''
 
+    def getfileset(self, expr):
+        """Resolve the fileset expression for this repo"""
+        return set()
+
     def printfiles(self, ui, m, fm, fmt):
         """handle the files command for this subrepo"""
         return 1
@@ -917,6 +921,26 @@
             ctx = self._repo[rev]
         return cmdutil.files(ui, ctx, m, fm, fmt, True)
 
+    @annotatesubrepoerror
+    def getfileset(self, expr):
+        if self._ctx.rev() is None:
+            ctx = self._repo[None]
+        else:
+            rev = self._state[1]
+            ctx = self._repo[rev]
+
+        files = ctx.getfileset(expr)
+
+        for subpath in ctx.substate:
+            sub = ctx.sub(subpath)
+
+            try:
+                files.extend(subpath + '/' + f for f in sub.getfileset(expr))
+            except error.LookupError:
+                self.ui.status(_("skipping missing subrepository: %s\n")
+                               % self.wvfs.reljoin(reporelpath(self), subpath))
+        return files
+
     def walk(self, match):
         ctx = self._repo[None]
         return ctx.walk(match)