Rev 966: Move some common code into a shared file. in file:///data/jelmer/bzr-svn/pyrex/
Jelmer Vernooij
jelmer at samba.org
Thu Mar 13 20:24:57 GMT 2008
At file:///data/jelmer/bzr-svn/pyrex/
------------------------------------------------------------
revno: 966
revision-id:jelmer at samba.org-20080313202456-m0z9rxqncm64mcni
parent: jelmer at samba.org-20080313192229-mx5g79mkrq57fhrx
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: pyrex
timestamp: Thu 2008-03-13 21:24:56 +0100
message:
Move some common code into a shared file.
added:
apr.pxi apr.pxd-20080313192457-r08q1i1681oz4fqp-1
types.pxi types.pxi-20080313202425-vtt1ry64o98kgpg8-1
modified:
ra.pyx ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
wc.pyx wc.pyx-20080313142018-10l8l23vha2j9e6b-1
workingtree.py workingtree.py-20060306120941-b083cb0fdd4a69de
=== added file 'apr.pxi'
--- a/apr.pxi 1970-01-01 00:00:00 +0000
+++ b/apr.pxi 2008-03-13 20:24:56 +0000
@@ -0,0 +1,50 @@
+# Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
+# vim: ft=pyrex
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# APR stuff
+
+cdef extern from "apr_errno.h":
+ ctypedef int apr_status_t
+
+cdef extern from "apr_general.h":
+ apr_status_t apr_initialize()
+
+cdef extern from "apr_file_io.h":
+ ctypedef struct apr_file_t
+
+cdef extern from "apr_pools.h":
+ ctypedef struct apr_pool_t
+ void apr_pool_destroy(apr_pool_t *)
+ apr_status_t apr_pool_create(apr_pool_t **newpool, apr_pool_t *parent)
+
+cdef extern from "apr_tables.h":
+ ctypedef struct apr_array_header_t
+ apr_array_header_t *apr_array_make(apr_pool_t *p, int nelts, int elt_size)
+ void *apr_array_push(apr_array_header_t *arr)
+ void *apr_array_pop(apr_array_header_t *arr)
+
+cdef extern from "apr_hash.h":
+ ctypedef struct apr_hash_t
+ ctypedef struct apr_hash_index_t
+ apr_hash_t *apr_hash_make(apr_pool_t *pool)
+ void apr_hash_set(apr_hash_t *ht, char *key, long klen, char *val)
+ apr_hash_index_t *apr_hash_first(apr_pool_t *p, apr_hash_t *ht)
+ apr_hash_index_t * apr_hash_next(apr_hash_index_t *hi)
+ void apr_hash_this(apr_hash_index_t *hi, void **key,
+ long *klen, void **val)
+
+
=== modified file 'ra.pyx'
--- a/ra.pyx 2008-03-13 19:22:29 +0000
+++ b/ra.pyx 2008-03-13 20:24:56 +0000
@@ -14,24 +14,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# APR stuff
-
-cdef extern from "apr_errno.h":
- ctypedef int apr_status_t
-
-cdef extern from "apr_general.h":
- apr_status_t apr_initialize()
-
-cdef extern from "apr_file_io.h":
- ctypedef struct apr_file_t
+include "apr.pxi"
+include "types.pxi"
apr_initialize()
-cdef extern from "apr_pools.h":
- ctypedef struct apr_pool_t
- void apr_pool_destroy(apr_pool_t *)
- apr_status_t apr_pool_create(apr_pool_t **newpool, apr_pool_t *parent)
-
cdef apr_pool_t *Pool(apr_pool_t *parent):
cdef apr_status_t status
cdef apr_pool_t *ret
@@ -42,34 +29,6 @@
raise Exception("APR Error")
return ret
-cdef extern from "apr_tables.h":
- ctypedef struct apr_array_header_t
- apr_array_header_t *apr_array_make(apr_pool_t *p, int nelts, int elt_size)
- void *apr_array_push(apr_array_header_t *arr)
- void *apr_array_pop(apr_array_header_t *arr)
-
-cdef extern from "apr_hash.h":
- ctypedef struct apr_hash_t
- ctypedef struct apr_hash_index_t
- apr_hash_t *apr_hash_make(apr_pool_t *pool)
- void apr_hash_set(apr_hash_t *ht, char *key, long klen, char *val)
- apr_hash_index_t *apr_hash_first(apr_pool_t *p, apr_hash_t *ht)
- apr_hash_index_t * apr_hash_next(apr_hash_index_t *hi)
- void apr_hash_this(apr_hash_index_t *hi, void **key,
- long *klen, void **val)
-
-
-
-cdef extern from "svn_version.h":
- ctypedef struct svn_version_t:
- int major
- int minor
- int patch
- char *tag
-
-cdef extern from "svn_error.h":
- ctypedef struct svn_error_t
-
cdef extern from "svn_auth.h":
ctypedef struct svn_auth_baton_t
void svn_auth_open(svn_auth_baton_t **auth_baton,
@@ -117,12 +76,6 @@
svn_auth_provider_object_t **provider, svn_auth_simple_prompt_func_t prompt_func, void *prompt_baton, int retry_limit, apr_pool_t *pool)
-cdef extern from "svn_string.h":
- ctypedef struct svn_string_t:
- char *data
- long len
- svn_string_t *svn_string_ncreate(char *bytes, long size, apr_pool_t *pool)
-
cdef extern from "svn_delta.h":
ctypedef struct svn_txdelta_window_t
ctypedef svn_error_t *(*svn_txdelta_window_handler_t) (svn_txdelta_window_t *window, void *baton)
=== added file 'types.pxi'
--- a/types.pxi 1970-01-01 00:00:00 +0000
+++ b/types.pxi 2008-03-13 20:24:56 +0000
@@ -0,0 +1,42 @@
+# Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
+# vim: ft=pyrex
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import apr
+
+cdef extern from "svn_version.h":
+ ctypedef struct svn_version_t:
+ int major
+ int minor
+ int patch
+ char *tag
+
+
+cdef extern from "svn_error.h":
+ ctypedef struct svn_error_t
+
+
+cdef extern from "svn_types.h":
+ ctypedef int svn_boolean_t
+ ctypedef svn_error_t *(*svn_cancel_func_t)(cancel_baton)
+
+cdef extern from "svn_string.h":
+ ctypedef struct svn_string_t:
+ char *data
+ long len
+ svn_string_t *svn_string_ncreate(char *bytes, long size, apr_pool_t *pool)
+
+
=== modified file 'wc.pyx'
--- a/wc.pyx 2008-03-13 19:22:29 +0000
+++ b/wc.pyx 2008-03-13 20:24:56 +0000
@@ -14,17 +14,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-cdef extern from "svn_version.h":
- ctypedef struct svn_version_t:
- int major
- int minor
- int patch
- char *tag
-
-
-cdef extern from "svn_types.h":
- ctypedef int svn_boolean_t
- ctypedef svn_error_t *(*svn_cancel_func_t)(cancel_baton)
+include "apr.pxi"
+include "types.pxi"
+
+apr_initialize()
cdef extern from "svn_wc.h":
ctypedef struct svn_wc_adm_access_t
@@ -32,15 +25,36 @@
svn_error_t *svn_wc_adm_open3(svn_wc_adm_access_t **adm_access,
svn_wc_adm_access_t *associated,
char *path,
- svn_boolean_t write_lock,
+ types.svn_boolean_t write_lock,
int depth,
- svn_cancel_func_t cancel_func,
+ types.svn_cancel_func_t cancel_func,
cancel_baton,
- apr_pool_t *pool)
+ apr.apr_pool_t *pool)
svn_error_t *svn_wc_adm_close(svn_wc_adm_access_t *adm_access)
char *svn_wc_adm_access_path(svn_wc_adm_access_t *adm_access)
svn_boolean_t svn_wc_adm_locked(svn_wc_adm_access_t *adm_access)
-
+ svn_error_t *svn_wc_locked(svn_boolean_t *locked, char *path, apr.apr_pool_t *pool)
+ ctypedef struct svn_wc_revision_status_t:
+ long min_rev
+ long max_rev
+ int switched
+ int modified
+ svn_error_t *svn_wc_revision_status(svn_wc_revision_status_t **result_p,
+ char *wc_path,
+ char *trail_url,
+ types.svn_boolean_t committed,
+ types.svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr.apr_pool_t *pool)
+ svn_error_t *svn_wc_prop_get(svn_string_t **value,
+ char *name,
+ char *path,
+ svn_wc_adm_access_t *adm_access,
+ apr.apr_pool_t *pool)
+ svn_error_t *svn_wc_entries_read(apr_hash_t **entries,
+ svn_wc_adm_access_t *adm_access,
+ svn_boolean_t show_hidden,
+ apr.apr_pool_t *pool)
def version():
"""Get libsvn_wc version information.
@@ -65,5 +79,28 @@
def locked(self):
return svn_wc_adm_locked(self.adm)
+ def prop_get(self, name, path):
+ cdef svn_string_t *value
+ _check_error(svn_wc_prop_get(&value, name, path, self.adm, temp_pool))
+ return PyString_FromStringAndSize(value.data, value.length)
+
+ def entries_read(self, show_hidden):
+ cdef apr_hash_t *entries
+ _check_error(svn_wc_entries_read(&entries, self.adm,
+ show_hidden, temp_pool))
+ # FIXME: Create py_entries
+ py_entries = {}
+ return py_entries
+
def __dealloc__(self):
svn_wc_adm_close(self.adm)
+
+
+def revision_status(wc_path, trail_url, committed, cancel_func=None):
+ cdef svn_wc_revision_status_t *revstatus
+ _check_error(svn_wc_revision_status(&revstatus, wc_path, trail_url,
+ committed, py_cancel_func, cancel_func, temp_pool))
+ return (revstatus.min_rev, revstatus.max_rev,
+ revstatus.switched, revstatus.modified)
+
+
=== modified file 'workingtree.py'
--- a/workingtree.py 2008-03-13 19:22:29 +0000
+++ b/workingtree.py 2008-03-13 20:24:56 +0000
@@ -79,7 +79,7 @@
svn.client.svn_swig_py_get_commit_log_func
self._get_wc()
- status = svn.wc.revision_status(self.basedir, None, True, None, None)
+ status = wc.revision_status(self.basedir, None, True)
if status.min_rev != status.max_rev:
#raise WorkingTreeInconsistent(status.min_rev, status.max_rev)
rev = svn.core.svn_opt_revision_t()
@@ -94,7 +94,7 @@
self.read_working_inventory()
- self.controldir = os.path.join(self.basedir, svn.wc.get_adm_dir(),
+ self.controldir = os.path.join(self.basedir, wc.get_adm_dir(),
'bzr')
try:
os.makedirs(self.controldir)
@@ -102,21 +102,21 @@
except OSError:
pass
control_transport = bzrdir.transport.clone(urlutils.join(
- svn.wc.get_adm_dir(), 'bzr'))
+ wc.get_adm_dir(), 'bzr'))
self._control_files = LockableFiles(control_transport, 'lock', LockDir)
def get_ignore_list(self):
- ignores = set([svn.wc.get_adm_dir()])
- ignores.update(svn.wc.get_default_ignores(svn_config))
+ ignores = set([wc.get_adm_dir()])
+ ignores.update(wc.get_default_ignores(svn_config))
def dir_add(wc, prefix, patprefix):
- ignorestr = svn.wc.prop_get(svn.core.SVN_PROP_IGNORE,
- self.abspath(prefix).rstrip("/"), wc)
+ ignorestr = wc.prop_get(svn.core.SVN_PROP_IGNORE,
+ self.abspath(prefix).rstrip("/"))
if ignorestr is not None:
for pat in ignorestr.splitlines():
ignores.add(urlutils.joinpath(patprefix, pat))
- entries = svn.wc.entries_read(wc, False)
+ entries = wc.entries_read(wc, False)
for entry in entries:
if entry == "":
continue
@@ -126,23 +126,23 @@
subprefix = os.path.join(prefix, entry)
- subwc = svn.wc.adm_open3(wc, self.abspath(subprefix), False,
+ subwc = wc.WorkingCopy(wc, self.abspath(subprefix), False,
0, None)
try:
dir_add(subwc, subprefix, urlutils.joinpath(patprefix, entry))
finally:
- svn.wc.adm_close(subwc)
+ wc.close(subwc)
wc = self._get_wc()
try:
dir_add(wc, "", ".")
finally:
- svn.wc.adm_close(wc)
+ wc.close(wc)
return ignores
def is_control_filename(self, path):
- return svn.wc.is_adm_dir(path)
+ return wc.is_adm_dir(path)
def apply_inventory_delta(self, changes):
raise NotImplementedError(self.apply_inventory_delta)
@@ -159,16 +159,16 @@
wc = self._get_wc(write_lock=True)
try:
for file in files:
- svn.wc.delete2(self.abspath(file), wc, None, None, None)
+ wc.delete(self.abspath(file), wc, None, None, None)
finally:
- svn.wc.adm_close(wc)
+ wc.close(wc)
for file in files:
self._change_fileid_mapping(None, file)
self.read_working_inventory()
def _get_wc(self, relpath="", write_lock=False):
- return svn.wc.adm_open3(None, self.abspath(relpath).rstrip("/"),
+ return wc.WorkingCopy(None, self.abspath(relpath).rstrip("/"),
write_lock, 0, None)
def _get_rel_wc(self, relpath, write_lock=False):
@@ -184,15 +184,15 @@
for entry in from_paths:
try:
to_wc = self._get_wc(to_dir, write_lock=True)
- svn.wc.copy(self.abspath(entry), to_wc,
+ to_wc.copy(self.abspath(entry),
os.path.basename(entry), None, None)
finally:
- svn.wc.adm_close(to_wc)
+ to_wc.close()
try:
from_wc = self._get_wc(write_lock=True)
- svn.wc.delete2(self.abspath(entry), from_wc, None, None, None)
+ from_wc.delete(self.abspath(entry), None, None, None)
finally:
- svn.wc.adm_close(from_wc)
+ from_wc.close()
new_name = urlutils.join(to_dir, os.path.basename(entry))
self._change_fileid_mapping(self.inventory.path2id(entry), new_name)
self._change_fileid_mapping(None, entry)
@@ -212,10 +212,10 @@
(from_wc, _) = self._get_rel_wc(from_rel, write_lock=True)
from_id = self.inventory.path2id(from_rel)
try:
- svn.wc.copy(self.abspath(from_rel), to_wc, to_file, None, None)
- svn.wc.delete2(self.abspath(from_rel), from_wc, None, None, None)
+ to_wc.copy(self.abspath(from_rel), to_file, None, None)
+ from_wc.delete(self.abspath(from_rel), None, None, None)
finally:
- svn.wc.adm_close(to_wc)
+ to_wc.close()
self._change_fileid_mapping(None, from_rel)
self._change_fileid_mapping(from_id, to_rel)
self.read_working_inventory()
@@ -265,7 +265,7 @@
def find_copies(url, relpath=""):
wc = self._get_wc(relpath)
- entries = svn.wc.entries_read(wc, False)
+ entries = wc.entries_read(False)
for entry in entries.values():
subrelpath = os.path.join(relpath, entry.name)
if entry.name == "" or entry.kind != 'directory':
@@ -277,7 +277,7 @@
subrelpath)
else:
find_copies(subrelpath)
- svn.wc.adm_close(wc)
+ wc.close()
def find_ids(entry, rootwc):
relpath = urllib.unquote(entry.url[len(entry.repos):].strip("/"))
@@ -339,7 +339,7 @@
try:
add_dir_to_inv(subrelpath, subwc, id)
finally:
- svn.wc.adm_close(subwc)
+ subwc.close()
else:
(subid, subrevid) = find_ids(entry, rootwc)
if subid:
@@ -351,7 +351,7 @@
try:
add_dir_to_inv(u"", rootwc, None)
finally:
- svn.wc.adm_close(rootwc)
+ rootwc.close()
self._set_inventory(inv, dirty=False)
return inv
@@ -392,18 +392,18 @@
if entry == "":
continue
- subwc = svn.wc.adm_open3(wc, os.path.join(self.basedir, path, entry), False, 0, None)
+ subwc = wc.WorkingCopy(wc, os.path.join(self.basedir, path, entry), False, 0, None)
try:
update_settings(subwc, os.path.join(path, entry))
finally:
- svn.wc.adm_close(subwc)
+ subwc.close()
# Set proper version for all files in the wc
wc = self._get_wc(write_lock=True)
try:
update_settings(wc, "")
finally:
- svn.wc.adm_close(wc)
+ wc.close()
self.base_revid = revid
def commit(self, message=None, message_callback=None, revprops=None,
@@ -441,17 +441,17 @@
extra = ""
wc = self._get_wc(write_lock=True)
try:
- svn.wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
+ wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
self._get_bzr_revids() + extra,
- self.basedir, wc)
- svn.wc.prop_set(SVN_PROP_BZR_REVISION_INFO,
+ self.basedir)
+ wc.prop_set(SVN_PROP_BZR_REVISION_INFO,
generate_revision_metadata(timestamp,
timezone,
committer,
revprops),
- self.basedir, wc)
+ self.basedir)
finally:
- svn.wc.adm_close(wc)
+ wc.close()
try:
try:
@@ -465,15 +465,15 @@
# Reset properties so the next subversion commit won't
# accidently set these properties.
wc = self._get_wc(write_lock=True)
- svn.wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
- self._get_bzr_revids(), self.basedir, wc)
- svn.wc.prop_set(SVN_PROP_BZR_REVISION_INFO,
+ wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
+ self._get_bzr_revids(), self.basedir)
+ wc.prop_set(SVN_PROP_BZR_REVISION_INFO,
self.branch.repository.branchprop_list.get_property(
self.branch.get_branch_path(self.base_revnum),
self.base_revnum,
SVN_PROP_BZR_REVISION_INFO, ""),
- self.basedir, wc)
- svn.wc.adm_close(wc)
+ self.basedir)
+ wc.adm_close()
raise
self.client_ctx.log_msg_baton2 = None
@@ -506,7 +506,7 @@
if not self.inventory.has_filename(f):
if save:
mutter('adding %r' % file_path)
- svn.wc.add2(file_path, wc, None, 0, None, None, None)
+ wc.add(file_path, None, 0, None, None, None)
added.append(file_path)
if recurse and file_kind(file_path) == 'directory':
# Filter out ignored files and update ignored
@@ -519,7 +519,7 @@
ignored.setdefault(ignore_glob, []).append(c_path)
todo.append(c_path)
finally:
- svn.wc.adm_close(wc)
+ wc.close()
if todo != []:
cadded, cignored = self.smart_add(todo, recurse, action, save)
added.extend(cadded)
@@ -539,7 +539,7 @@
wc = self._get_wc(os.path.dirname(f), write_lock=True)
try:
try:
- svn.wc.add2(os.path.join(self.basedir, f), wc, None, 0,
+ wc.add(os.path.join(self.basedir, f), wc, None, 0,
None, None, None)
if ids is not None:
self._change_fileid_mapping(ids.next(), f, wc)
@@ -550,7 +550,7 @@
raise NoSuchFile(path=f)
raise
finally:
- svn.wc.adm_close(wc)
+ wc.close()
self.read_working_inventory()
def basis_tree(self):
@@ -598,15 +598,15 @@
new_entries[path] = id
existing = "".join(map(lambda (path, id): "%s\t%s\n" % (path, id), new_entries.items()))
if existing != "":
- svn.wc.prop_set(SVN_PROP_BZR_FILEIDS, existing.encode("utf-8"), self.basedir, subwc)
+ subwc.prop_set(SVN_PROP_BZR_FILEIDS, existing.encode("utf-8"), self.basedir)
if wc is None:
- svn.wc.adm_close(subwc)
+ subwc.close()
def _get_new_file_ids(self, wc):
committed = self.branch.repository.branchprop_list.get_property(
self.branch.get_branch_path(self.base_revnum), self.base_revnum,
SVN_PROP_BZR_FILEIDS, "")
- existing = svn.wc.prop_get(SVN_PROP_BZR_FILEIDS, self.basedir, wc)
+ existing = wc.prop_get(SVN_PROP_BZR_FILEIDS, self.basedir)
if existing is None or committed == existing:
return {}
return dict(map(lambda x: str(x).split("\t"),
@@ -638,9 +638,9 @@
else:
bzr_merge = ""
- svn.wc.prop_set(SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme),
+ wc.prop_set(SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme),
self._get_bzr_merges() + bzr_merge,
- self.basedir, wc)
+ self.basedir)
svk_merges = parse_svk_features(self._get_svk_merges())
@@ -651,11 +651,11 @@
except InvalidRevisionId:
pass
- svn.wc.prop_set2(SVN_PROP_SVK_MERGE,
+ wc.prop_set(SVN_PROP_SVK_MERGE,
serialize_svk_features(svk_merges), self.basedir,
- wc, False)
+ False)
finally:
- svn.wc.adm_close(wc)
+ wc.close(wc)
def add_pending_merge(self, revid):
merges = self.pending_merges()
@@ -666,14 +666,14 @@
merged = self._get_bzr_merges().splitlines()
wc = self._get_wc()
try:
- merged_data = svn.wc.prop_get(
- SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme), self.basedir, wc)
+ merged_data = wc.prop_get(
+ SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme), self.basedir)
if merged_data is None:
set_merged = []
else:
set_merged = merged_data.splitlines()
finally:
- svn.wc.adm_close(wc)
+ wc.close(wc)
assert (len(merged) == len(set_merged) or
len(merged)+1 == len(set_merged))
@@ -733,11 +733,11 @@
self.local_path = transport.local_abspath(".")
# Open related remote repository + branch
- wc = svn.wc.adm_open3(None, self.local_path, False, 0, None)
+ wc = wc.WorkingCopy(None, self.local_path, False, 0, None)
try:
- svn_url = svn.wc.entry(self.local_path, wc, True).url
+ svn_url = wc.entry(self.local_path, True).url
finally:
- svn.wc.adm_close(wc)
+ wc.close(wc)
remote_transport = SvnRaTransport(svn_url)
self.remote_bzrdir = SvnRemoteAccess(remote_transport)
More information about the bazaar-commits
mailing list