Rev 463: Merge pyrex. in file:///data/jelmer/bzr-svn/native/

Jelmer Vernooij jelmer at samba.org
Wed Mar 19 22:49:20 GMT 2008


At file:///data/jelmer/bzr-svn/native/

------------------------------------------------------------
revno: 463
revision-id: jelmer at samba.org-20080319224919-bu37ta819wi4wj5p
parent: jelmer at samba.org-20080319224907-r1ykcykl72th2yl4
parent: jelmer at samba.org-20080319224647-52s9u285ylc2qnz3
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: native
timestamp: Wed 2008-03-19 23:49:19 +0100
message:
  Merge pyrex.
modified:
  ra.pyx                         ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
  repos.pyx                      repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
    ------------------------------------------------------------
    revno: 457.1.559
    revision-id: jelmer at samba.org-20080319224647-52s9u285ylc2qnz3
    parent: jelmer at samba.org-20080318234801-1wweh8z48k8t4w8k
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: pyrex
    timestamp: Wed 2008-03-19 23:46:47 +0100
    message:
      Wrap some more functions.
    modified:
      ra.pyx                         ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
      repos.pyx                      repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
=== modified file 'ra.pyx'
--- a/ra.pyx	2008-03-18 23:27:43 +0000
+++ b/ra.pyx	2008-03-19 22:46:47 +0000
@@ -579,13 +579,16 @@
 py_editor.close_edit = py_editor_close_edit
 py_editor.abort_edit = py_editor_abort_edit
 
+cdef class Auth
+
 cdef class RemoteAccess:
     """Connection to a remote Subversion repository."""
     cdef svn_ra_session_t *ra
     cdef apr_pool_t *pool
     cdef char *url
     cdef object progress_func
-    def __init__(self, char *url, progress_cb=None, config={}):
+    cdef Auth auth
+    def __init__(self, char *url, progress_cb=None, Auth auth=None, config={}):
         """Connect to a remote Subversion repository. 
 
         :param url: URL of the repository
@@ -595,11 +598,16 @@
         cdef svn_error_t *error
         cdef svn_ra_callbacks2_t *callbacks2
         cdef apr_hash_t *config_hash
+        if auth is None:
+            auth = Auth()
+        self.auth = auth
         self.url = url
         self.pool = Pool(NULL)
         assert self.pool != NULL
         check_error(svn_ra_create_callbacks(&callbacks2, self.pool))
         callbacks2.progress_func = py_progress_func
+        Py_INCREF(self.auth)
+        callbacks2.auth_baton = self.auth.auth_baton
         self.progress_func = progress_cb
         callbacks2.progress_baton = <void *>self.progress_func
         config_hash = apr_hash_make(self.pool)
@@ -836,6 +844,7 @@
     def __dealloc__(self):
         if self.pool != NULL:
             apr_pool_destroy(self.pool)
+        Py_DECREF(self.auth)
 
     def __repr__(self):
         return "%s(%r)" % (self.__class__.__name__, self.url)
@@ -850,7 +859,7 @@
 cdef class Auth:
     cdef svn_auth_baton_t *auth_baton
     cdef apr_pool_t *pool
-    def __init__(self, providers):
+    def __init__(self, providers=[]):
         cdef apr_array_header_t *c_providers    
         cdef AuthProvider provider
         cdef svn_auth_provider_object_t **el
@@ -869,7 +878,8 @@
         return <char *>svn_auth_get_parameter(self.auth_baton, name)
 
     def __dealloc__(self):
-        apr_pool_destroy(self.pool)
+        if self.pool != NULL:
+            apr_pool_destroy(self.pool)
 
 cdef svn_error_t *py_username_prompt(svn_auth_cred_username_t **cred, void *baton, char *realm, int may_save, apr_pool_t *pool):
     fn = <object>baton

=== modified file 'repos.pyx'
--- a/repos.pyx	2008-03-16 14:17:23 +0000
+++ b/repos.pyx	2008-03-19 22:46:47 +0000
@@ -15,13 +15,27 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from apr cimport apr_pool_t, apr_hash_t, apr_pool_destroy
-from types cimport svn_error_t, svn_boolean_t, svn_cancel_func_t, svn_stream_t
+from types cimport svn_error_t, svn_boolean_t, svn_cancel_func_t, svn_stream_t, svn_node_kind_t, svn_revnum_t, svn_filesize_t
 
 from core cimport Pool, check_error, new_py_stream, py_cancel_func
 
 cdef extern from "svn_fs.h":
     ctypedef struct svn_fs_t
+    ctypedef struct svn_fs_root_t
     svn_error_t *svn_fs_get_uuid(svn_fs_t *fs, char **uuid, apr_pool_t *pool)
+    svn_error_t *svn_fs_check_path(svn_node_kind_t *kind_p, svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    svn_boolean_t svn_fs_is_txn_root(svn_fs_root_t *root)
+    svn_boolean_t svn_fs_is_revision_root(svn_fs_root_t *root)
+    svn_error_t *svn_fs_youngest_rev(svn_revnum_t *youngest_p, svn_fs_t *fs, apr_pool_t *pool)
+    svn_error_t *svn_fs_revision_root(svn_fs_root_t **root_p, svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
+    svn_error_t *svn_fs_make_dir(svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    svn_error_t *svn_fs_delete(svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    svn_error_t *svn_fs_copy(svn_fs_root_t *from_root, char *from_path, svn_fs_root_t *to_root, char *to_path, apr_pool_t *pool)
+    svn_error_t *svn_fs_file_length(svn_filesize_t *length_p, svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    svn_error_t *svn_fs_file_md5_checksum(unsigned char digest[], svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    svn_error_t *svn_fs_file_contents(svn_stream_t **contents, svn_fs_root_t *root, char *path, apr_pool_t *pool)
+    void svn_fs_close_root(svn_fs_root_t *root)
+
 
 cdef extern from "svn_repos.h":
     ctypedef struct svn_repos_t
@@ -90,6 +104,75 @@
     def fs(self):
         return FileSystem(self)
 
+cdef class FileSystemRoot:
+    cdef svn_fs_root_t *root
+    cdef apr_pool_t *pool
+
+    def __dealloc__(self):
+        if self.pool != NULL:
+            apr_pool_destroy(self.pool)
+
+    def check_path(self, char *path):
+        cdef svn_node_kind_t kind
+        cdef apr_pool_t *pool
+        pool = Pool(NULL)
+        check_error(svn_fs_check_path(&kind, self.root, path, pool))
+        apr_pool_destroy(pool)
+        return kind
+
+    def make_dir(self, char *path):
+        cdef apr_pool_t *pool
+        pool = Pool(self.pool)
+        check_error(svn_fs_make_dir(self.root, path, pool))
+        apr_pool_destroy(pool)
+
+    def delete(self, char *path):
+        cdef apr_pool_t *pool
+        pool = Pool(self.pool)
+        check_error(svn_fs_delete(self.root, path, pool))
+        apr_pool_destroy(pool)
+
+    def copy(self, char *from_path, FileSystemRoot to_root, char *to_path):
+        cdef apr_pool_t *pool
+        pool = Pool(self.pool)
+        check_error(svn_fs_copy(self.root, from_path, to_root.root, to_path, pool))
+        apr_pool_destroy(pool)
+
+    def file_length(self, char *path):
+        cdef apr_pool_t *pool
+        cdef svn_filesize_t length
+        pool = Pool(self.pool)
+        check_error(svn_fs_file_length(&length, self.root, path, pool))
+        apr_pool_destroy(pool)
+        return length
+
+    def file_md5_checksum(self, char *path):
+        cdef char digest[64]
+        cdef apr_pool_t *pool
+        pool = Pool(NULL)
+        check_error(svn_fs_file_md5_checksum(<unsigned char*>digest, self.root, path, pool))
+        ret = digest
+        apr_pool_destroy(pool)
+        return ret
+
+    def file_contents(self, char *path):
+        cdef apr_pool_t *pool
+        cdef svn_stream_t *stream
+        pool = Pool(self.pool)
+        check_error(svn_fs_file_contents(&stream, self.root, path, pool))
+        apr_pool_destroy(pool)
+        return None # FIXME
+
+    def is_txn_root(self):
+        return svn_fs_is_txn_root(self.root)
+
+    def is_revision_root(self):
+        return svn_fs_is_revision_root(self.root)
+
+    def close(self):
+        svn_fs_close_root(self.root)
+
+
 cdef class FileSystem:
     cdef svn_fs_t *fs
     cdef apr_pool_t *pool
@@ -105,6 +188,22 @@
         check_error(svn_fs_get_uuid(self.fs, &uuid, self.pool))
         return uuid
 
+    def youngest_revision(self):
+        cdef apr_pool_t *pool
+        cdef svn_revnum_t youngest
+        pool = Pool(NULL)
+        check_error(svn_fs_youngest_rev(&youngest, self.fs, pool))
+        apr_pool_destroy(pool)
+        return youngest
+
+    def revision_root(self, svn_revnum_t rev):
+        cdef FileSystemRoot ret
+        ret = FileSystemRoot()
+        ret.pool = Pool(NULL)
+        check_error(svn_fs_revision_root(&ret.root, self.fs, rev, ret.pool))
+        return ret
+
+
 LOAD_UUID_DEFAULT = 0
 LOAD_UUID_IGNORE = 1
 LOAD_UUID_FORCE = 2




More information about the bazaar-commits mailing list