changeset 12322:510afb31cf99

subrepo: introduce files and filedata methods for subrepo classes
author Martin Geisler <mg@aragost.com>
date Mon, 20 Sep 2010 15:44:30 +0200
parents 11db6fa2961e
children f00953d9533c
files mercurial/subrepo.py
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Sep 20 15:42:58 2010 +0200
+++ b/mercurial/subrepo.py	Mon Sep 20 15:44:30 2010 +0200
@@ -270,6 +270,18 @@
     def incoming(self, ui, source, opts):
         return 1
 
+    def files(self):
+        """return filename iterator"""
+        raise NotImplementedError
+
+    def filedata(self, name):
+        """return file data"""
+        raise NotImplementedError
+
+    def fileflags(self, name):
+        """return file flags"""
+        return ''
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -406,6 +418,21 @@
     def incoming(self, ui, source, opts):
         return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts)
 
+    def files(self):
+        rev = self._state[1]
+        ctx = self._repo[rev]
+        return ctx.manifest()
+
+    def filedata(self, name):
+        rev = self._state[1]
+        return self._repo[rev][name].data()
+
+    def fileflags(self, name):
+        rev = self._state[1]
+        ctx = self._repo[rev]
+        return ctx.flags(name)
+
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -508,6 +535,15 @@
         # push is a no-op for SVN
         return True
 
+    def files(self):
+        output = self._svncommand(['list'])
+        # This works because svn forbids \n in filenames.
+        return output.splitlines()
+
+    def filedata(self, name):
+        return self._svncommand(['cat'], name)
+
+
 types = {
     'hg': hgsubrepo,
     'svn': svnsubrepo,