Rev 1301: Use new commit editor. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Mon Jun 23 01:49:30 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1301
revision-id: jelmer at samba.org-20080623004929-gf4qz26pv0k18n1q
parent: jelmer at samba.org-20080623002734-oxgti3m9yova9j7a
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-06-23 02:49:29 +0200
message:
Use new commit editor.
modified:
tests/__init__.py __init__.py-20060508151940-e9f4d914801a2535
tests/test_logwalker.py test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2008-06-23 00:27:34 +0000
+++ b/tests/__init__.py 2008-06-23 00:49:29 +0000
@@ -36,6 +36,7 @@
class TestFileEditor(object):
def __init__(self, file):
self.file = file
+ self.is_closed = False
def change_prop(self, name, value):
self.file.change_prop(name, value)
@@ -43,10 +44,11 @@
def modify(self, contents=None):
if contents is None:
contents = osutils.rand_chars(100)
- txdelta = self.apply_textdelta()
+ txdelta = self.file.apply_textdelta()
txdelta_send_stream(StringIO(contents), txdelta)
def close(self):
+ self.is_closed = True
self.file.close()
@@ -55,31 +57,45 @@
self.dir = dir
self.baseurl = baseurl
self.revnum = revnum
+ self.is_closed = False
+ self.children = []
def close(self):
+ self.is_closed = True
+ for c in reversed(self.children):
+ if not c.is_closed:
+ c.close()
self.dir.close()
def change_prop(self, name, value):
self.dir.change_prop(name, value)
def open_dir(self, path):
- return TestDirEditor(self.dir.open_directory(path, -1), self.baseurl, self.revnum)
+ child = TestDirEditor(self.dir.open_directory(path, -1), self.baseurl, self.revnum)
+ self.children.append(child)
+ return child
def open_file(self, path):
- return TestFileEditor(self.dir.open_file(path, -1))
+ child = TestFileEditor(self.dir.open_file(path, -1))
+ self.children.append(child)
+ return child
def add_dir(self, path, copyfrom_path=None, copyfrom_rev=-1):
if copyfrom_path is not None:
copyfrom_path = urlutils.join(self.baseurl, copyfrom_path)
if copyfrom_path is not None and copyfrom_rev == -1:
copyfrom_rev = self.revnum
- return TestDirEditor(self.dir.add_directory(path, copyfrom_path, copyfrom_rev), self.baseurl, self.revnum)
+ child = TestDirEditor(self.dir.add_directory(path, copyfrom_path, copyfrom_rev), self.baseurl, self.revnum)
+ self.children.append(child)
+ return child
def add_file(self, path, copyfrom_path=None, copyfrom_rev=-1):
- return TestFileEditor(self.dir.add_file(path, copyfrom_path, copyfrom_rev))
+ child = TestFileEditor(self.dir.add_file(path, copyfrom_path, copyfrom_rev))
+ self.children.append(child)
+ return child
def delete(self, path):
- self.dir.delete_path(path)
+ self.dir.delete_entry(path)
class TestCommitEditor(TestDirEditor):
=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py 2008-06-23 00:27:34 +0000
+++ b/tests/test_logwalker.py 2008-06-23 00:49:29 +0000
@@ -40,7 +40,7 @@
def test_get_branch_log(self):
repos_url = self.make_repository("a")
cb = self.get_commit_editor(repos_url)
- cb.add_file("foo").close()
+ cb.add_file("foo").modify()
cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -69,7 +69,7 @@
repos_url = self.make_repository("a")
cb = self.get_commit_editor(repos_url)
d = cb.add_dir("trunk")
- d.add_file("trunk/foo").close()
+ d.add_file("trunk/foo").modify()
d.close()
cb.close()
@@ -91,9 +91,9 @@
def test_get_revision_paths(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_file("foo")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ cb.add_file("foo").modify()
+ cb.close()
walker = self.get_log_walker(SvnRaTransport(repos_url))
self.assertEqual({"foo": ('A', None, -1)}, walker.get_revision_paths(1))
self.assertEqual({"": ('A', None, -1)}, walker.get_revision_paths(0))
@@ -116,12 +116,12 @@
def test_branch_log_all(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_dir("trunk")
- cb.add_file("trunk/file")
- cb.add_dir("foo")
- cb.add_file("foo/file")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ d = cb.add_dir("trunk")
+ d.add_file("trunk/file").modify()
+ d = cb.add_dir("foo")
+ d.add_file("foo/file").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -129,14 +129,14 @@
def test_branch_log_specific(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_dir("branches")
- cb.add_dir("branches/brancha")
- cb.add_dir("branches/branchb")
- cb.add_dir("branches/branchab")
- cb.add_file("branches/brancha/data")
- cb.add_file("branches/branchab/data")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ d = cb.add_dir("branches")
+ ba = d.add_dir("branches/brancha")
+ ba.add_file("branches/brancha/data").modify()
+ d.add_dir("branches/branchb")
+ bab = d.add_dir("branches/branchab")
+ bab.add_file("branches/branchab/data").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -145,16 +145,18 @@
def test_iter_changes_ignore_unchanged(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_dir("branches")
- cb.add_dir("branches/brancha")
- cb.add_dir("branches/branchab")
- cb.add_file("branches/brancha/data")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ b = cb.add_dir("branches")
+ ba = b.add_dir("branches/brancha")
+ ba.add_file("branches/brancha/data").modify()
+ b.add_dir("branches/branchab")
+ cb.close()
- cb = self.commit_editor(repos_url)
- cb.add_file("branches/branchab/data")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ bs = cb.open_dir("branches")
+ bab = bs.open_dir("branches/branchab")
+ bab.add_file("branches/branchab/data").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -173,9 +175,9 @@
def test_find_latest_children_root(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_file("branches")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ cb.add_file("branches").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -184,15 +186,15 @@
def test_find_latest_case(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_dir("branches")
- cb.add_file("branches/child")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ b = cb.add_dir("branches")
+ b.add_file("branches/child").modify()
+ cb.close()
- cb = self.commit_editor(repos_url)
- cb.add_dir("BRANCHES")
- cb.add_file("BRANCHES/child")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ b = cb.add_dir("BRANCHES")
+ b.add_file("BRANCHES/child").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -284,13 +286,14 @@
def test_find_latest_change_children(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
+ cb = self.get_commit_editor(repos_url)
cb.add_dir("branches")
- cb.done()
+ cb.close()
- cb = self.commit_editor(repos_url)
- cb.add_file("branches/foo")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.add_file("branches/foo")
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -299,17 +302,18 @@
def test_find_latest_change_prop(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
+ cb = self.get_commit_editor(repos_url)
cb.add_dir("branches")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.change_dir_prop("branches", "myprop", "mydata")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.add_file("branches/foo")
- cb.done()
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ cb.open_dir("branches").change_prop("myprop", "mydata")
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.add_file("branches/foo")
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -318,17 +322,19 @@
def test_find_latest_change_file(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
+ cb = self.get_commit_editor(repos_url)
cb.add_dir("branches")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.add_file("branches/foo")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.change_file("branches/foo")
- cb.done()
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.add_file("branches/foo").modify()
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.open_file("branches/foo").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -337,17 +343,19 @@
def test_find_latest_change_newer(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
+ cb = self.get_commit_editor(repos_url)
cb.add_dir("branches")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.add_file("branches/foo")
- cb.done()
-
- cb = self.commit_editor(repos_url)
- cb.change_file("branches/foo")
- cb.done()
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.add_file("branches/foo")
+ cb.close()
+
+ cb = self.get_commit_editor(repos_url)
+ b = cb.open_dir("branches")
+ b.open_file("branches/foo").modify()
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
@@ -356,19 +364,19 @@
def test_follow_history_branch_replace(self):
repos_url = self.make_repository("a")
- cb = self.commit_editor(repos_url)
- cb.add_dir("trunk")
- cb.add_file("trunk/data")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ t = cb.add_dir("trunk")
+ t.add_file("trunk/data").modify()
+ cb.close()
- cb = self.commit_editor(repos_url)
+ cb = self.get_commit_editor(repos_url)
cb.delete("trunk")
- cb.done()
+ cb.close()
- cb = self.commit_editor(repos_url)
- cb.add_dir("trunk")
- cb.add_file("trunk/data")
- cb.done()
+ cb = self.get_commit_editor(repos_url)
+ t = cb.add_dir("trunk")
+ t.add_file("trunk/data")
+ cb.close()
walker = self.get_log_walker(transport=SvnRaTransport(repos_url))
self.assertEqual([({"trunk/data": ('A', None, -1),
More information about the bazaar-commits
mailing list