Rev 1081: Fix several bugs. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Thu Jun 5 12:17:14 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1081
revision-id: jelmer at samba.org-20080605111713-6f2d16i82vyn15zu
parent: jelmer at samba.org-20080605103724-l1w6ju7lagqmp4e9
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Thu 2008-06-05 13:17:13 +0200
message:
Fix several bugs.
modified:
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
tests/test_branch.py test_branch.py-20060508162215-74ffeb5d608f8e20
tree.py tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'mapping.py'
--- a/mapping.py 2008-06-04 18:56:53 +0000
+++ b/mapping.py 2008-06-05 11:17:13 +0000
@@ -22,6 +22,7 @@
from bzrlib.plugins.svn import core, constants, version_info, constants, errors
import calendar
import sha
+import time
import urllib
MAPPING_VERSION = 3
=== modified file 'ra.c'
--- a/ra.c 2008-06-05 10:37:24 +0000
+++ b/ra.c 2008-06-05 11:17:13 +0000
@@ -46,6 +46,9 @@
{
PyObject *fn = (PyObject *)baton, *ret;
+ if (fn == Py_None)
+ return NULL;
+
ret = PyObject_CallFunction(fn, "izz",
commit_info->revision, commit_info->date,
commit_info->author);
@@ -720,7 +723,7 @@
ReporterObject *ret;
RemoteAccessObject *ra = (RemoteAccessObject *)self;
- if (!PyArg_ParseTuple(args, "lsbO", &revision_to_update_to, &update_target, &recurse, &update_editor))
+ if (!PyArg_ParseTuple(args, "lsbO:do_update", &revision_to_update_to, &update_target, &recurse, &update_editor))
return NULL;
if (ra_check_busy(ra))
@@ -765,7 +768,7 @@
apr_pool_t *temp_pool;
ReporterObject *ret;
- if (!PyArg_ParseTuple(args, "lsbsO", &revision_to_update_to, &update_target,
+ if (!PyArg_ParseTuple(args, "lsbsO:do_switch", &revision_to_update_to, &update_target,
&recurse, &switch_url, &update_editor))
return NULL;
if (ra_check_busy(ra))
@@ -849,7 +852,7 @@
{
char *kwnames[] = { "revprops", "callback", "lock_tokens", "keep_locks",
NULL };
- PyObject *revprops, *commit_callback, *lock_tokens = Py_None;
+ PyObject *revprops, *commit_callback = Py_None, *lock_tokens = Py_None;
bool keep_locks = false;
apr_pool_t *temp_pool, *pool;
const svn_delta_editor_t *editor;
@@ -857,7 +860,7 @@
RemoteAccessObject *ra = (RemoteAccessObject *)self;
apr_hash_t *hash_lock_tokens;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Ob", kwnames, &revprops, &commit_callback, &lock_tokens, &keep_locks))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOb", kwnames, &revprops, &commit_callback, &lock_tokens, &keep_locks))
return NULL;
temp_pool = Pool();
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-06-05 10:23:08 +0000
+++ b/tests/__init__.py 2008-06-05 11:17:13 +0000
@@ -24,6 +24,7 @@
from bzrlib import osutils, urlutils
from bzrlib.bzrdir import BzrDir
+from bzrlib.plugins.svn.ra import RemoteAccess, txdelta_send_stream
from bzrlib.tests import TestCaseInTempDir, TestSkipped
from bzrlib.trace import mutter
from bzrlib.workingtree import WorkingTree
@@ -173,32 +174,6 @@
def client_update(self, path):
self.client_ctx.update([path], None, True)
- def commit_tree(self, repos_url, changes, revprops={"svn:log": "test commit"}):
- ret_revnum = None
- def callback(revmeta):
- ret_revnum = revmeta.revision
- x = ra.RemoteAccess(repos_url)
- editor = x.get_commit_editor(revprops, callback)
- root = editor.open_root()
- def process(changes, dir_editor, path):
- for f, v in changes.items():
- p = urlutils.join(path, f)
- if v is None:
- dir_editor.delete_entry(p)
- elif isinstance(v, dict):
- child_editor = dir_editor.add_directory(p)
- process(v, child_editor)
- child_editor.close()
- elif isinstance(f, str):
- file_editor = dir_editor.add_file(p)
- # FIXME: send delta
- file_editor.close()
- else:
- raise TypeError("Invalid type for %s" % f)
- process(changes, root)
- root.close()
- return ret_revnum
-
def build_tree(self, files):
"""Create a directory tree.
@@ -253,14 +228,12 @@
return svn.repos.fs(repos)
def commit_editor(self, url, message="Test commit"):
- ra = svn.client.open_ra_session(url.encode('utf8'),
- self.client_ctx)
+ ra = RemoteAccess(url.encode('utf8'))
class CommitEditor:
- def __init__(self, ra, editor, edit_baton, base_revnum, base_url):
+ def __init__(self, ra, edit_baton, base_revnum, base_url):
self._used = False
self.ra = ra
self.base_revnum = base_revnum
- self.editor = editor
self.edit_baton = edit_baton
self.data = {}
self.create = set()
@@ -322,49 +295,48 @@
for name, contents in dir_dict.items():
subpath = urlutils.join(path, name).strip("/")
if contents is None:
- svn.delta.editor_invoke_delete_entry(self.editor, subpath, -1, dir_baton)
+ dir_baton.delete_entry(subpath, -1)
elif isinstance(contents, dict):
if subpath in self.create:
- child_baton = svn.delta.editor_invoke_add_directory(self.editor, subpath, dir_baton, self.copyfrom[subpath][0], self.copyfrom[subpath][1])
+ child_baton = dir_baton.add_directory(subpath, self.copyfrom[subpath][0], self.copyfrom[subpath][1])
else:
- child_baton = svn.delta.editor_invoke_open_directory(self.editor, subpath, dir_baton, -1)
+ child_baton = dir_baton.open_directory(subpath, -1)
if subpath in self.props:
for k, v in self.props[subpath].items():
- svn.delta.editor_invoke_change_dir_prop(self.editor, child_baton, k, v)
+ child_baton.change_prop(k, v)
self._process_dir(child_baton, dir_dict[name], subpath)
- svn.delta.editor_invoke_close_directory(self.editor, child_baton)
+ child_baton.close()
else:
if subpath in self.create:
- child_baton = svn.delta.editor_invoke_add_file(self.editor, subpath, dir_baton, None, -1)
+ child_baton = dir_baton.add_file(subpath, None, -1)
else:
- child_baton = svn.delta.editor_invoke_open_file(self.editor, subpath, dir_baton, -1)
+ child_baton = dir_baton.open_file(subpath, -1)
if isinstance(contents, str):
- (txdelta, txbaton) = svn.delta.editor_invoke_apply_textdelta(self.editor, child_baton, None)
- svn.delta.svn_txdelta_send_stream(StringIO(contents), txdelta, txbaton)
+ txdelta = child_baton.apply_textdelta(None)
+ txdelta_send_stream(StringIO(contents), txdelta)
if subpath in self.props:
for k, v in self.props[subpath].items():
- svn.delta.editor_invoke_change_file_prop(self.editor, child_baton, k, v)
- svn.delta.editor_invoke_close_file(self.editor, child_baton, None)
+ child_baton.change_prop(k, v)
+ child_baton.close(None)
def done(self):
assert self._used == False
self._used = True
- root_baton = svn.delta.editor_invoke_open_root(self.editor, self.edit_baton,
- self.base_revnum)
+ root_baton = self.edit_baton.open_root(self.base_revnum)
self._process_dir(root_baton, self.data, "")
- svn.delta.editor_invoke_close_directory(self.editor, root_baton)
- svn.delta.editor_invoke_close_edit(self.editor, self.edit_baton)
+ root_baton.close()
+ self.edit_baton.close()
- my_revnum = svn.ra.get_latest_revnum(ra)
+ my_revnum = self.ra.get_latest_revnum()
assert my_revnum > self.base_revnum
return my_revnum
- base_revnum = svn.ra.get_latest_revnum(ra)
- editor, edit_baton = svn.ra.get_commit_editor(ra, message, None, None, True)
- return CommitEditor(ra, editor, edit_baton, base_revnum, url)
+ base_revnum = ra.get_latest_revnum()
+ edit_baton = ra.get_commit_editor({"svn:log": message})
+ return CommitEditor(ra, edit_baton, base_revnum, url)
def test_suite():
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py 2008-06-05 03:29:15 +0000
+++ b/tests/test_branch.py 2008-06-05 11:17:13 +0000
@@ -596,7 +596,6 @@
repos_url = self.make_repository('d')
dc = self.commit_editor(repos_url)
-
dc.add_dir("trunk")
dc.add_file("trunk/hosts")
dc.done()
=== modified file 'tree.py'
--- a/tree.py 2008-06-04 23:03:52 +0000
+++ b/tree.py 2008-06-05 11:17:13 +0000
@@ -109,7 +109,7 @@
root_repos = repository.transport.get_svn_repos_root()
conn = repository.transport.get_connection()
reporter = conn.do_switch(
- self.revnum, True,
+ self.revnum, "", True,
urlutils.join(root_repos, self.branch_path), editor)
try:
reporter.set_path("", 0, True)
More information about the bazaar-commits
mailing list