Rev 1183: Merge 0.4. in file:///data/jelmer/bzr-svn/dpush/
Jelmer Vernooij
jelmer at samba.org
Sat Jun 28 17:01:52 BST 2008
At file:///data/jelmer/bzr-svn/dpush/
------------------------------------------------------------
revno: 1183
revision-id: jelmer at samba.org-20080628160151-9f1e1vb6h0v9uc1w
parent: jelmer at samba.org-20080627182306-m9y3ybcg2d3n6mye
parent: jelmer at samba.org-20080628123728-0lqgtvhe8424ha8j
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: dpush
timestamp: Sat 2008-06-28 18:01:51 +0200
message:
Merge 0.4.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
tests/test_tree.py test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
transport.py transport.py-20060406231150-b3472d06b3a0818d
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.10.2
revision-id: jelmer at samba.org-20080628123728-0lqgtvhe8424ha8j
parent: jelmer at samba.org-20080628031146-cnlgw6iqhrnblyc8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-06-28 14:37:28 +0200
message:
Properly raise error when bindings haven't been built.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
------------------------------------------------------------
revno: 1177.10.1
revision-id: jelmer at samba.org-20080628031146-cnlgw6iqhrnblyc8
parent: jelmer at samba.org-20080627000850-f1l89dkqlxuuye5b
parent: jelmer at samba.org-20080628030340-mzqzpokfwod0as18
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-06-28 05:11:46 +0200
message:
Merge partial support for stacked branches.
modified:
Makefile makefile.other-20080311181537-5svhje3v1flh1n4f-1
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
delta.py delta.py-20080316001917-xyng7m3jlxvdc4c9-1
editor.c editor.c-20080602191336-frj7az1sdk13o1tw-1
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
tests/test_fetch.py test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
tests/test_fileids.py test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
tests/test_repository.py test_repos.py-20060508151940-ddc49a59257ca712
tests/test_transport.py test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
tests/test_tree.py test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
transport.py transport.py-20060406231150-b3472d06b3a0818d
util.c util.c-20080531154025-s8ef6ej9tytsnkkw-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.216
revision-id: jelmer at samba.org-20080628030340-mzqzpokfwod0as18
parent: jelmer at samba.org-20080628030324-xuw01kyj3in23yrv
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 05:03:40 +0200
message:
Deal with the fact inventory_sha1 can't be None.
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
------------------------------------------------------------
revno: 1177.1.215
revision-id: jelmer at samba.org-20080628030324-xuw01kyj3in23yrv
parent: jelmer at samba.org-20080628021542-7gdny8vrapok9v7u
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 05:03:24 +0200
message:
Deal with absent content.
modified:
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.214
revision-id: jelmer at samba.org-20080628021542-7gdny8vrapok9v7u
parent: jelmer at samba.org-20080628021421-79f5nmgcq388xuc1
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 04:15:42 +0200
message:
Fix construction of fake texts.
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
------------------------------------------------------------
revno: 1177.1.213
revision-id: jelmer at samba.org-20080628021421-79f5nmgcq388xuc1
parent: jelmer at samba.org-20080628015301-6gd76dge9h4406fc
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 04:14:21 +0200
message:
Add wrapper for get-file.
modified:
transport.py transport.py-20060406231150-b3472d06b3a0818d
------------------------------------------------------------
revno: 1177.1.212
revision-id: jelmer at samba.org-20080628015301-6gd76dge9h4406fc
parent: jelmer at samba.org-20080627225252-el1byuv3mn5jkrfr
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 03:53:01 +0200
message:
Implement get_record_stream() for files.
modified:
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.211
revision-id: jelmer at samba.org-20080627225252-el1byuv3mn5jkrfr
parent: jelmer at samba.org-20080627222333-jv28jra07no8txoy
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 00:52:52 +0200
message:
implement content for FakeRevisionTexts.
modified:
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.210
revision-id: jelmer at samba.org-20080627222333-jv28jra07no8txoy
parent: jelmer at samba.org-20080627222030-coqhvjkrucsbzox2
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 00:23:33 +0200
message:
Switch to using serializer format 7
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
------------------------------------------------------------
revno: 1177.1.209
revision-id: jelmer at samba.org-20080627222030-coqhvjkrucsbzox2
parent: jelmer at samba.org-20080627215452-m3wc33d8hrytynab
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Sat 2008-06-28 00:20:30 +0200
message:
Fix versionedfiles tests.
modified:
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.208
revision-id: jelmer at samba.org-20080627215452-m3wc33d8hrytynab
parent: jelmer at samba.org-20080627211327-60tdygznt0nz17cz
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Fri 2008-06-27 23:54:52 +0200
message:
Implement get_record_stream in FakeVersionedFiles.
modified:
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.207
revision-id: jelmer at samba.org-20080627211327-60tdygznt0nz17cz
parent: jelmer at samba.org-20080627191110-j0t5mtvnlbokmzo0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: stackable
timestamp: Fri 2008-06-27 23:13:27 +0200
message:
Implement FakeVersionedFiles.get_parent_map.
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
------------------------------------------------------------
revno: 1177.1.206
revision-id: jelmer at samba.org-20080627191110-j0t5mtvnlbokmzo0
parent: jelmer at samba.org-20080627185607-554l1oh62x0g3spq
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-06-27 21:11:10 +0200
message:
Couple more.
modified:
tests/test_tree.py test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
------------------------------------------------------------
revno: 1177.1.205
revision-id: jelmer at samba.org-20080627185607-554l1oh62x0g3spq
parent: jelmer at samba.org-20080627184340-9f9p6ml8qgv4shb3
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-06-27 20:56:07 +0200
message:
use commit editor in some places in tree tests.
modified:
tests/test_tree.py test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
------------------------------------------------------------
revno: 1177.1.204
revision-id: jelmer at samba.org-20080627184340-9f9p6ml8qgv4shb3
parent: jelmer at samba.org-20080627162804-xxfjk30jfb53ilvb
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-06-27 20:43:40 +0200
message:
Convert some push tests to use the new commit builder API.
modified:
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file '__init__.py'
--- a/__init__.py 2008-06-27 18:23:06 +0000
+++ b/__init__.py 2008-06-28 16:01:51 +0000
@@ -72,6 +72,7 @@
from bzrlib.plugins.svn.ra import version
except:
warning("Unable to load bzr-svn extensions - did you build it?")
+ raise BzrError('missing dependency')
ra_version = version()
if (ra_version[0] >= 5 and getattr(ra, 'SVN_REVISION', None) and 27729 <= ra.SVN_REVISION < 31470):
warning('Installed Subversion has buggy svn.ra.get_log() implementation, please install newer.')
=== modified file 'fileids.py'
--- a/fileids.py 2008-06-26 15:38:43 +0000
+++ b/fileids.py 2008-06-28 01:53:01 +0000
@@ -61,15 +61,20 @@
FILEIDMAP_VERSION = 1
def simple_apply_changes(new_file_id, changes, find_children=None):
- """Simple function that can apply file id changes.
+ """Simple function that generates a dictionary with file id changes.
Does not track renames. """
map = {}
for p in sorted(changes.keys()):
data = changes[p]
+ inv_p = p.decode("utf-8")
+ if data[0] in ('D', 'R'):
+ map[inv_p] = None
+ for p in map:
+ if p.startswith("%s/" % inv_p):
+ map[p] = None
if data[0] in ('A', 'R'):
- inv_p = p.decode("utf-8")
map[inv_p] = new_file_id(inv_p)
if data[1] is not None:
@@ -174,7 +179,14 @@
if changes[p][0] == 'M' and not idmap.has_key(p):
idmap[p] = map[p][0]
- map.update(dict([(x, (str(idmap[x]), revid)) for x in idmap]))
+ for x in sorted(idmap.keys()):
+ if idmap[x] is None:
+ del map[x]
+ for p in map.keys():
+ if p.startswith("%s/" % x):
+ del map[p]
+ else:
+ map[x] = (str(idmap[x]), revid)
# Mark all parent paths as changed
for p in idmap:
=== modified file 'ra.c'
--- a/ra.c 2008-06-27 16:28:04 +0000
+++ b/ra.c 2008-06-28 01:53:01 +0000
@@ -1212,10 +1212,52 @@
}
py_props = prop_hash_to_dict(props);
+ if (py_props == NULL) {
+ apr_pool_destroy(temp_pool);
+ return NULL;
+ }
apr_pool_destroy(temp_pool);
return Py_BuildValue("(NlN)", py_dirents, fetch_rev, py_props);
}
+static PyObject *ra_get_file(PyObject *self, PyObject *args)
+{
+ char *path;
+ svn_revnum_t revision = -1;
+ RemoteAccessObject *ra = (RemoteAccessObject *)self;
+ apr_hash_t *props;
+ svn_revnum_t fetch_rev;
+ PyObject *py_stream, *py_props;
+ apr_pool_t *temp_pool;
+
+ if (!PyArg_ParseTuple(args, "sO|l", &path, &py_stream, &revision))
+ return NULL;
+
+ if (ra_check_busy(ra))
+ return NULL;
+
+ temp_pool = Pool(NULL);
+ if (temp_pool == NULL)
+ return NULL;
+
+ if (revision != SVN_INVALID_REVNUM)
+ fetch_rev = revision;
+
+ RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_file(ra->ra, path, revision,
+ new_py_stream(temp_pool, py_stream),
+ &fetch_rev, &props, temp_pool));
+
+ py_props = prop_hash_to_dict(props);
+ if (py_props == NULL) {
+ apr_pool_destroy(temp_pool);
+ return NULL;
+ }
+
+ apr_pool_destroy(temp_pool);
+
+ return Py_BuildValue("(lN)", fetch_rev, py_props);
+}
+
static PyObject *ra_get_lock(PyObject *self, PyObject *args)
{
char *path;
@@ -1495,6 +1537,7 @@
{ "check_path", ra_check_path, METH_VARARGS, NULL },
{ "get_lock", ra_get_lock, METH_VARARGS, NULL },
{ "get_dir", ra_get_dir, METH_VARARGS, NULL },
+ { "get_file", ra_get_file, METH_VARARGS, NULL },
{ "change_rev_prop", ra_change_rev_prop, METH_VARARGS, NULL },
{ "get_commit_editor", (PyCFunction)get_commit_editor, METH_VARARGS|METH_KEYWORDS, NULL },
{ "rev_proplist", ra_rev_proplist, METH_VARARGS, NULL },
=== modified file 'repository.py'
--- a/repository.py 2008-06-26 22:58:21 +0000
+++ b/repository.py 2008-06-28 03:03:40 +0000
@@ -16,7 +16,7 @@
"""Subversion repository access."""
import bzrlib
-from bzrlib import osutils, ui, urlutils, xml5
+from bzrlib import osutils, ui, urlutils, xml7
from bzrlib.branch import Branch, BranchCheckResult
from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, NotBranchError,
UninitializableFormat, UnrelatedBranches)
@@ -49,7 +49,7 @@
parse_svk_feature)
from bzrlib.plugins.svn.tree import SvnRevisionTree
from bzrlib.plugins.svn.versionedfiles import (SvnTexts, FakeRevisionTexts,
- FakeInventoryTexts)
+ FakeInventoryTexts, FakeSignatureTexts)
import urllib
def full_paths(find_children, paths, bp, from_bp, from_rev):
@@ -161,9 +161,10 @@
control_files = LockableFiles(transport, '', TransportLock)
Repository.__init__(self, SvnRepositoryFormat(), bzrdir, control_files)
- self.texts = SvnTexts()
- self.revisions = FakeRevisionTexts()
- self.inventories = FakeInventoryTexts()
+ self.texts = SvnTexts(self)
+ self.revisions = FakeRevisionTexts(self)
+ self.inventories = FakeInventoryTexts(self)
+ self.signatures = FakeSignatureTexts(self)
self._cached_revnum = None
self._lock_mode = None
self._lock_count = 0
@@ -173,7 +174,7 @@
assert self.uuid is not None
self.base = transport.base
assert self.base is not None
- self._serializer = xml5.serializer_v5
+ self._serializer = xml7.serializer_v7
self.get_config().add_location(self.base)
self._log = logwalker.LogWalker(transport=transport)
self.fileid_map = FileIdMap(simple_apply_changes, self)
@@ -346,10 +347,6 @@
for revmeta in self.iter_all_changes(layout):
yield revmeta.get_revision_id(mapping)
- def get_inventory_weave(self):
- """See Repository.get_inventory_weave()."""
- raise NotImplementedError(self.get_inventory_weave)
-
def set_make_working_trees(self, new_value):
"""See Repository.set_make_working_trees()."""
pass # FIXME: ignored, nowhere to store it...
@@ -500,7 +497,7 @@
revmeta = RevisionMetadata(self, path, None, revnum, svn_revprops, svn_fileprops)
rev = Revision(revision_id=revision_id, parent_ids=revmeta.get_parent_ids(mapping),
- inventory_sha1=None)
+ inventory_sha1="")
mapping.import_revision(svn_revprops, svn_fileprops, rev)
=== modified file 'tests/test_push.py'
--- a/tests/test_push.py 2008-06-22 04:51:45 +0000
+++ b/tests/test_push.py 2008-06-27 18:43:40 +0000
@@ -31,7 +31,7 @@
import os
from time import sleep
-from bzrlib.plugins.svn import format
+from bzrlib.plugins.svn import format, ra
from bzrlib.plugins.svn.errors import ChangesRootLHSHistory, MissingPrefix
from bzrlib.plugins.svn.commit import push
from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID
@@ -40,16 +40,20 @@
class TestPush(TestCaseWithSubversionRepository):
def setUp(self):
super(TestPush, self).setUp()
- self.repos_url = self.make_client('d', 'sc')
-
- self.build_tree({'sc/foo/bla': "data"})
- self.client_add("sc/foo")
- self.client_commit("sc", "foo")
-
- self.svndir = BzrDir.open("sc")
+ self.repos_url = self.make_repository('d')
+
+ dc = self.commit_editor()
+ foo = dc.add_dir("foo")
+ foo.add_file("foo/bla").modify("data")
+ dc.close()
+
+ self.svndir = BzrDir.open(self.repos_url)
os.mkdir("dc")
self.bzrdir = self.svndir.sprout("dc")
+ def commit_editor(self):
+ return self.get_commit_editor(self.repos_url)
+
def test_empty(self):
svnbranch = self.svndir.open_branch()
bzrbranch = self.bzrdir.open_branch()
@@ -59,9 +63,10 @@
bzrbranch.revision_history())
def test_child(self):
- self.build_tree({'sc/foo/bar': "data"})
- self.client_add("sc/foo/bar")
- self.client_commit("sc", "second message")
+ dc = self.commit_editor()
+ foo = dc.open_dir("foo")
+ foo.add_file("foo/bar").modify("data")
+ dc.close()
svnbranch = self.svndir.open_branch()
bzrbranch = self.bzrdir.open_branch()
@@ -69,11 +74,12 @@
self.assertEqual(0, result.new_revno - result.old_revno)
def test_diverged(self):
- self.build_tree({'sc/foo/bar': "data"})
- self.client_add("sc/foo/bar")
- self.client_commit("sc", "second message")
+ dc = self.commit_editor()
+ foo = dc.open_dir("foo")
+ foo.add_file("foo/bar").modify("data")
+ dc.close()
- svndir = BzrDir.open("sc")
+ svndir = BzrDir.open(self.repos_url)
self.build_tree({'dc/file': 'data'})
wt = self.bzrdir.open_workingtree()
@@ -92,7 +98,7 @@
svnbranch = self.svndir.open_branch()
svnbranch.pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
self.assertEquals(newid, svnbranch.last_revision())
inv = repos.get_inventory(repos.generate_revision_id(2, "", mapping))
@@ -113,7 +119,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
inv = repos.get_inventory(repos.generate_revision_id(2, "", mapping))
self.assertTrue(inv.has_filename('file'))
@@ -123,7 +129,7 @@
self.svndir.open_branch().last_revision())
def test_override_revprops(self):
- self.svndir._find_repository().get_config().set_user_option("override-svn-revprops", "True")
+ self.svndir.find_repository().get_config().set_user_option("override-svn-revprops", "True")
self.build_tree({'dc/file': 'data'})
wt = self.bzrdir.open_workingtree()
wt.add('file')
@@ -142,7 +148,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
inv = repos.get_inventory(repos.generate_revision_id(2, "", mapping))
self.assertTrue(inv.has_filename('file'))
@@ -162,7 +168,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
inv = repos.get_inventory(repos.generate_revision_id(2, "", mapping))
self.assertTrue(inv.has_filename('south'))
@@ -177,7 +183,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
inv = repos.get_inventory(repos.generate_revision_id(2, "", mapping))
self.assertTrue(inv.has_filename('file'))
@@ -213,7 +219,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
self.assertEqual("Commit from Bzr",
repos.get_revision(repos.generate_revision_id(2, "", mapping)).message)
@@ -226,9 +232,9 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- self.client_update("sc")
+ c = ra.RemoteAccess(self.repos_url)
self.assertEqual("3 some-rid\n",
- self.client_get_prop("sc", SVN_PROP_BZR_REVISION_ID+"none"))
+ c.get_dir("", c.get_latest_revnum())[2][SVN_PROP_BZR_REVISION_ID+"none"])
def test_commit_check_rev_equal(self):
self.build_tree({'dc/file': 'data'})
@@ -238,7 +244,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- rev1 = self.svndir._find_repository().get_revision(wt.branch.last_revision())
+ rev1 = self.svndir.find_repository().get_revision(wt.branch.last_revision())
rev2 = self.bzrdir.find_repository().get_revision(wt.branch.last_revision())
self.assertEqual(rev1.committer, rev2.committer)
@@ -260,7 +266,7 @@
self.svndir.open_branch().pull(self.bzrdir.open_branch())
- repos = self.svndir._find_repository()
+ repos = self.svndir.find_repository()
mapping = repos.get_mapping()
@@ -303,31 +309,34 @@
def test_different_branch_path(self):
# A ,> C
# \ -> B /
- self.build_tree({'sc/trunk/foo': "data", 'sc/branches': None})
- self.client_add("sc/trunk")
- self.client_add("sc/branches")
- self.client_commit("sc", "foo")
-
- self.client_copy('sc/trunk', 'sc/branches/mybranch')
- self.build_tree({'sc/branches/mybranch/foo': "data2"})
- self.client_commit("sc", "add branch")
-
- self.svndir = BzrDir.open("sc/branches/mybranch")
+ dc = self.commit_editor()
+ trunk = dc.add_dir("trunk")
+ trunk.add_file('trunk/foo').modify("data")
+ dc.add_dir("branches")
+ dc.close()
+
+ dc = self.commit_editor()
+ branches = dc.open_dir('branches')
+ mybranch = branches.add_dir('branches/mybranch', 'trunk')
+ mybranch.open_file("branches/mybranch/foo").modify('data2')
+ dc.close()
+
+ self.svndir = BzrDir.open("%s/branches/mybranch" % self.repos_url)
os.mkdir("mybranch")
self.bzrdir = self.svndir.sprout("mybranch")
self.build_tree({'mybranch/foo': 'bladata'})
wt = self.bzrdir.open_workingtree()
revid = wt.commit(message="Commit from Bzr")
- push(Branch.open("sc/trunk"), wt.branch,
+ push(Branch.open("%s/trunk" % self.repos_url), wt.branch,
wt.branch.revision_history()[-2])
- mutter('log %r' % self.client_log("sc/trunk")[4][0])
+ mutter('log %r' % self.client_log("%s/trunk" % self.repos_url)[4][0])
self.assertEquals('M',
- self.client_log("sc/trunk")[4][0]['/trunk'][0])
- push(Branch.open("sc/trunk"), wt.branch, wt.branch.last_revision())
- mutter('log %r' % self.client_log("sc/trunk")[5][0])
+ self.client_log("%s/trunk" % self.repos_url)[4][0]['/trunk'][0])
+ push(Branch.open("%s/trunk" % self.repos_url), wt.branch, wt.branch.last_revision())
+ mutter('log %r' % self.client_log("%s/trunk" % self.repos_url)[5][0])
self.assertEquals("/branches/mybranch",
- self.client_log("sc/trunk")[5][0]['/trunk'][1])
+ self.client_log("%s/trunk" % self.repos_url)[5][0]['/trunk'][1])
class PushNewBranchTests(TestCaseWithSubversionRepository):
def test_single_revision(self):
=== modified file 'tests/test_tree.py'
--- a/tests/test_tree.py 2008-06-23 02:56:49 +0000
+++ b/tests/test_tree.py 2008-06-27 19:11:10 +0000
@@ -46,23 +46,26 @@
self.assertTrue(tree.inventory[tree.inventory.path2id("file")].executable)
def test_executable_changed(self):
- self.make_client("d", "dc")
- self.build_tree({"dc/file": "x"})
- self.client_add("dc/file")
- self.client_commit("dc", "executable")
+ repos_url = self.make_client("d", "dc")
+
+ dc = self.get_commit_editor(repos_url)
+ dc.add_file("file").modify("x")
+ dc.close()
+
self.client_update("dc")
self.client_set_prop("dc/file", "svn:executable", "*")
tree = SvnBasisTree(self.open_checkout("dc"))
self.assertFalse(tree.inventory[tree.inventory.path2id("file")].executable)
def test_symlink(self):
- if not has_symlinks():
- return
- self.make_client("d", "dc")
- os.symlink("target", "dc/file")
- self.build_tree({"dc/file": "x"})
- self.client_add("dc/file")
- self.client_commit("dc", "symlink")
+ repos_url = self.make_client("d", "dc")
+
+ dc = self.get_commit_editor(repos_url)
+ file = dc.add_file("file")
+ file.modify("link target")
+ file.change_prop("svn:special", "*")
+ dc.close()
+
self.client_update("dc")
tree = SvnBasisTree(self.open_checkout("dc"))
self.assertEqual('symlink',
@@ -71,17 +74,21 @@
tree.inventory[tree.inventory.path2id("file")].symlink_target)
def test_symlink_next(self):
- if not has_symlinks():
- return
- self.make_client("d", "dc")
- os.symlink("target", "dc/file")
- self.build_tree({"dc/file": "x", "dc/bla": "p"})
- self.client_add("dc/file")
- self.client_add("dc/bla")
- self.client_commit("dc", "symlink")
- self.build_tree({"dc/bla": "pa"})
- self.client_commit("dc", "change")
+ repos_url = self.make_client("d", "dc")
+
+ dc = self.get_commit_editor(repos_url)
+ dc.add_file("bla").modify("p")
+ file = dc.add_file("file")
+ file.modify("link target")
+ file.change_prop("svn:special", "*")
+ dc.close()
+
+ dc = self.get_commit_editor(repos_url)
+ dc.open_file("bla").modify("pa")
+ dc.close()
+
self.client_update("dc")
+
tree = SvnBasisTree(self.open_checkout("dc"))
self.assertEqual('symlink',
tree.inventory[tree.inventory.path2id("file")].kind)
@@ -89,25 +96,34 @@
tree.inventory[tree.inventory.path2id("file")].symlink_target)
def test_annotate_iter(self):
- self.make_client("d", "dc")
- self.build_tree({"dc/file": "x\n"})
- self.client_add("dc/file")
- self.client_commit("dc", "change")
- self.client_update("dc")
- self.build_tree({"dc/file": "x\n\y\n"})
- self.client_commit("dc", "change")
+ repos_url = self.make_client("d", "dc")
+
+ dc = self.get_commit_editor(repos_url)
+ dc.add_file("file").modify("x\n")
+ dc.close()
+
+ dc = self.get_commit_editor(repos_url)
+ dc.open_file("file").modify("x\ny\n")
+ dc.close()
+
+ self.client_update('dc')
tree = SvnBasisTree(self.open_checkout("dc"))
self.assertRaises(NotImplementedError, tree.annotate_iter, tree.path2id("file"))
def test_executable_link(self):
if not has_symlinks():
return
- self.make_client("d", "dc")
- os.symlink("target", "dc/file")
- self.build_tree({"dc/file": "x"})
- self.client_add("dc/file")
- self.client_set_prop("dc/file", "svn:executable", "*")
- self.client_commit("dc", "exe1")
+ repos_url = self.make_client("d", "dc")
+
+ dc = self.get_commit_editor(repos_url)
+ file = dc.add_file("file")
+ file.modify("link target")
+ file.change_prop("svn:special", "*")
+ file.change_prop("svn:executable", "*")
+ dc.close()
+
+ self.client_update("dc")
+
wt = self.open_checkout("dc")
tree = SvnBasisTree(wt)
self.assertFalse(tree.inventory[tree.inventory.path2id("file")].executable)
=== modified file 'tests/test_versionedfiles.py'
--- a/tests/test_versionedfiles.py 2008-06-26 16:37:27 +0000
+++ b/tests/test_versionedfiles.py 2008-06-27 22:20:30 +0000
@@ -13,10 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from bzrlib import osutils
+from bzrlib.graph import DictParentsProvider
from bzrlib.tests import TestCase
from bzrlib.plugins.svn.versionedfiles import (SvnTexts, FakeRevisionTexts,
- FakeInventoryTexts)
+ FakeInventoryTexts, FakeSignatureTexts,
+ FakeVersionedFiles)
class BasicSvnTextsTests:
@@ -41,12 +44,61 @@
self.texts = SvnTexts()
+class FakeTextsTests(TestCase,BasicSvnTextsTests):
+ def get_parent_map(self, keys):
+ return DictParentsProvider(self.parent_map).get_parent_map(keys)
+
+ def get_lines(self, key):
+ (k,) = key
+ if not k in self.lines:
+ return None
+ return self.lines[k]
+
+ def test_get_parent_map(self):
+ self.parent_map = {"G": ("A", "B")}
+ self.assertEquals({("G",): (("A",),("B",))}, self.texts.get_parent_map([("G",)]))
+
+ def test_get_sha1s(self):
+ self.lines = {"A": ["FOO"]}
+ self.assertEquals({("A",): osutils.sha_strings(["FOO"])},
+ self.texts.get_sha1s([("A",), ("B",)]))
+
+ def test_get_record_stream(self):
+ self.lines = {"A": ["FOO"]}
+ it = self.texts.get_record_stream([("A",)], "unordered", True)
+ record = it.next()
+ self.assertEquals("FOO", record.get_bytes_as("fulltext"))
+
+ def setUp(self):
+ self.texts = FakeVersionedFiles(self.get_parent_map, self.get_lines)
+
+
class FakeRevisionTextsTests(TestCase,BasicSvnTextsTests):
def setUp(self):
- self.texts = FakeRevisionTexts()
+ self.texts = FakeRevisionTexts(self)
+
+ def get_parent_map(self, keys):
+ raise NotImplementedError
class FakeInventoryTextsTests(TestCase,BasicSvnTextsTests):
- def setUp(self):
- self.texts = FakeInventoryTexts()
+ def get_inventory_xml(self, key):
+ return "FOO"
+
+ def get_parent_map(self, keys):
+ return {("A",): (("B",))}
+
+ def setUp(self):
+ self.texts = FakeInventoryTexts(self)
+
+ def test_get_sha1s(self):
+ self.assertEquals({("A",): osutils.sha_strings(["FOO"])}, self.texts.get_sha1s([("A",)]))
+
+
+class FakeSignatureTextsTests(TestCase,BasicSvnTextsTests):
+ def setUp(self):
+ self.texts = FakeSignatureTexts(self)
+
+ def get_parent_map(self, keys):
+ raise NotImplementedError
=== modified file 'transport.py'
--- a/transport.py 2008-06-26 22:23:21 +0000
+++ b/transport.py 2008-06-28 02:14:21 +0000
@@ -318,6 +318,15 @@
finally:
self.add_connection(conn)
+ def get_file(self, path, stream, revnum):
+ path = self._request_path(path)
+ conn = self.get_connection()
+ self.mutter('svn get-file -r%d %s' % (revnum, path))
+ try:
+ return conn.get_file(path, stream, revnum)
+ finally:
+ self.add_connection(conn)
+
def mutter(self, text, *args):
if 'transport' in debug.debug_flags:
mutter(text, *args)
=== modified file 'versionedfiles.py'
--- a/versionedfiles.py 2008-06-26 16:37:27 +0000
+++ b/versionedfiles.py 2008-06-28 03:03:24 +0000
@@ -13,34 +13,134 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from bzrlib.versionedfile import VersionedFiles
+from bzrlib import debug, osutils, urlutils
+from bzrlib.trace import mutter
+from bzrlib.versionedfile import FulltextContentFactory, VersionedFiles, AbsentContentFactory
+
+from cStringIO import StringIO
class SvnTexts(VersionedFiles):
"""Subversion texts backend."""
+ def __init__(self, repository):
+ self.repository = repository
+
def check(self, progressbar=None):
return True
- # TODO: annotate, get_parent_map, get_record_stream, get_sha1s,
+ def add_mpdiffs(self, records):
+ raise NotImplementedError(self.add_mpdiffs)
+
+ def get_record_stream(self, keys, ordering, include_delta_closure):
+ for (fileid, revid) in list(keys):
+ (branch, revnum, mapping) = self.repository.lookup_revision_id(revid)
+ map = self.repository.get_fileid_map(revnum, branch, mapping)
+ # Unfortunately, the map is the other way around
+ lines = None
+ mutter('map %r', map)
+ for k,(v,ck) in map.items():
+ if v == fileid:
+ stream = StringIO()
+ self.repository.transport.get_file(urlutils.join(branch, k), stream, revnum)
+ lines = stream.readlines()
+ break
+ if lines is None:
+ raise Exception("Inconsistent key specified: (%r,%r)" % (fileid, revid))
+ yield FulltextContentFactory((fileid,revid), None,
+ sha1=osutils.sha_strings(lines),
+ text=''.join(lines))
+
+ def get_parent_map(self, keys):
+ mutter("get_parent_map(%r)" % keys)
+
+ invs = {}
+
+ # First, figure out the revision number/path
+ ret = {}
+ for (fileid, revid) in keys:
+ # FIXME: Evil hack
+ ret[(fileid, revid)] = None
+ return ret
+
+ # TODO: annotate, , get_sha1s,
# iter_lines_added_or_present_in_keys, keys
-class FakeRevisionTexts(VersionedFiles):
+class FakeVersionedFiles(VersionedFiles):
+ def mutter(self, text, *args):
+ if "fakevf" in debug.debug_flags:
+ mutter(text, *args)
+
+ def __init__(self, get_parent_map, get_lines):
+ self._get_parent_map = get_parent_map
+ self._get_lines = get_lines
+
+ def check(self, progressbar=None):
+ return True
+
+ def add_mpdiffs(self, records):
+ raise NotImplementedError(self.add_mpdiffs)
+
+ def get_parent_map(self, keys):
+ self.mutter("get_parent_map(%r)" % keys)
+ return dict([((k,), tuple([(p,) for p in v])) for k,v in self._get_parent_map([k for (k,) in keys]).iteritems()])
+
+ def get_sha1s(self, keys):
+ self.mutter("get_sha1s(%r)" % keys)
+ ret = {}
+ for (k,) in keys:
+ lines = self._get_lines(k)
+ if lines is not None:
+ assert isinstance(lines, list)
+ ret[(k,)] = osutils.sha_strings(lines)
+ return ret
+
+ def get_record_stream(self, keys, ordering, include_delta_closure):
+ self.mutter("get_record_stream(%r)" % keys)
+ for (k,) in list(keys):
+ lines = self._get_lines(k)
+ if lines is not None:
+ assert isinstance(lines, list)
+ yield FulltextContentFactory((k,), None,
+ sha1=osutils.sha_strings(lines),
+ text=''.join(lines))
+ else:
+ yield AbsentContentFactory((k,))
+
+
+class FakeRevisionTexts(FakeVersionedFiles):
"""Fake revisions backend."""
-
- def check(self, progressbar=None):
- return True
-
- # TODO: annotate, get_parent_map, get_record_stream, get_sha1s,
- # iter_lines_added_or_present_in_keys, keys
-
-
-class FakeInventoryTexts(VersionedFiles):
+ def __init__(self, repository):
+ self.repository = repository
+ super(FakeRevisionTexts, self).__init__(self.repository.get_parent_map, self.get_lines)
+
+ def get_lines(self, key):
+ self.mutter("get revision text(%r)", key)
+ return osutils.split_lines(self.repository.get_revision_xml(key))
+
+ # TODO: annotate, iter_lines_added_or_present_in_keys, keys
+
+
+class FakeInventoryTexts(FakeVersionedFiles):
"""Fake inventories backend."""
-
- def check(self, progressbar=None):
- return True
-
- # TODO: annotate, get_parent_map, get_record_stream, get_sha1s,
- # iter_lines_added_or_present_in_keys, keys
+ def __init__(self, repository):
+ self.repository = repository
+ super(FakeInventoryTexts, self).__init__(self.repository.get_parent_map, self.get_lines)
+
+ def get_lines(self, key):
+ return osutils.split_lines(self.repository.get_inventory_xml(key))
+
+ # TODO: annotate, iter_lines_added_or_present_in_keys, keys
+
+
+class FakeSignatureTexts(FakeVersionedFiles):
+ """Fake signatures backend."""
+ def __init__(self, repository):
+ self.repository = repository
+ super(FakeSignatureTexts, self).__init__(self.repository.get_parent_map, self.get_lines)
+
+ def get_lines(self, key):
+ return osutils.split_lines(self.repository.get_signature_text(key))
+
+ # TODO: annotate, iter_lines_added_or_present_in_keys, keys
More information about the bazaar-commits
mailing list