diff svnwrap/svn_swig_wrapper.py @ 77:ed3dd5bf45da

fetch_command: bypass export3() and checkout manually This method has several advantages: - export3() does not work very well under Windows, while client.list() and ra.get_file() do - File modes are retrieved from get_file() for free, instead of being read from the filesystem, which does not work under Windows, more generally the filesystem is bypassed completely. - It can be made much smarter by checkouting changed files only, like convert extension does.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 Nov 2008 18:08:35 -0600
parents 6c62bd201785
children 85dcea81f22b
line wrap: on
line diff
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -433,6 +433,32 @@ class SubversionRepo(object):
                        rev, True, True, True, 'LF', # should be 'CRLF' on win32
                        self.client_context, self.pool)
 
+    def list_files(self, dirpath, revision):
+        """List the content of a directory at a given revision, recursively.
+
+        Yield tuples (path, kind) where 'path' is the entry path relatively to
+        'dirpath' and 'kind' is 'f' if the entry is a file, 'd' if it is a
+        directory. Raise IOError if the directory cannot be found at given
+        revision.
+        """
+        dirpath = dirpath.strip('/')
+        pool = core.Pool()
+        rpath = '/'.join([self.svn_url, dirpath]).strip('/')
+        rev = optrev(revision)
+        types = {
+            core.svn_node_dir: 'd',
+            core.svn_node_file: 'f',
+            }
+        try:
+            entries = client.ls(rpath, rev, True, self.client_context, pool)
+        except core.SubversionException, e:
+            if e.apr_err == core.SVN_ERR_FS_NOT_FOUND:
+                raise IOError('%s cannot be found at r%d' % (dirpath, revision))
+            raise
+        for path, e in entries.iteritems():
+            kind = types.get(e.kind)
+            yield path, kind
+
 class SubversionRepoCanNotReplay(Exception):
     """Exception raised when the svn server is too old to have replay.
     """