Rev 1445: Use commit editor API in a couple more places. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Mon Jul 7 17:04:52 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1445
revision-id: jelmer at samba.org-20080707160451-kuwuwzx06dulnq49
parent: jelmer at samba.org-20080707150613-lbw0fzlf5dgb0d1q
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-07-07 18:04:51 +0200
message:
Use commit editor API in a couple more places.
modified:
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'tests/test_push.py'
--- a/tests/test_push.py 2008-07-06 01:07:42 +0000
+++ b/tests/test_push.py 2008-07-07 16:04:51 +0000
@@ -31,7 +31,7 @@
import os
from time import sleep
-from bzrlib.plugins.svn import format, ra
+from bzrlib.plugins.svn import core, format, ra
from bzrlib.plugins.svn.errors import ChangesRootLHSHistory, MissingPrefix
from bzrlib.plugins.svn.commit import push, dpush
from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID
@@ -372,17 +372,17 @@
repos.get_ancestry(wt.branch.last_revision()))
def test_multiple_diverged(self):
- oc_url = self.make_client("o", "oc")
+ oc_url = self.make_repository("o")
self.build_tree({'dc/file': 'data'})
wt = self.bzrdir.open_workingtree()
wt.add('file')
wt.commit(message="Commit from Bzr")
- self.build_tree({'oc/file': 'data2', 'oc/adir': None})
- self.client_add("oc/file")
- self.client_add("oc/adir")
- self.client_commit("oc", "Another commit from Bzr")
+ oc = self.get_commit_editor(oc_url)
+ oc.add_file("file").modify("data2")
+ oc.add_dir("adir")
+ oc.close()
self.assertRaises(DivergedBranches,
lambda: Branch.open(oc_url).pull(self.bzrdir.open_branch()))
@@ -421,7 +421,7 @@
class PushNewBranchTests(TestCaseWithSubversionRepository):
def test_single_revision(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/test': "Tour"})
@@ -438,15 +438,18 @@
self.assertEquals([revid], newbranch.revision_history())
def test_single_revision_single_branching_scheme(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/test': "Tour"})
bzrwt.add("test")
revid = bzrwt.commit("Do a commit")
- self.build_tree({"dc/some/funny/branch": None})
- self.client_add("dc/some")
- self.client_commit("dc", "msg")
+
+ dc = self.get_commit_editor(repos_url)
+ some = dc.add_dir("some")
+ funny = some.add_dir("some/funny")
+ funny.add_dir("some/funny/branch")
+ dc.close()
newdir = BzrDir.open("%s/some/funny/branch/name" % repos_url)
newbranch = newdir.import_branch(bzrwt.branch)
self.assertEquals(revid, newbranch.last_revision())
@@ -548,7 +551,7 @@
wt.branch.push(Branch.open(repos_url+"/trunk"))
def test_missing_prefix_error(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/test': "Tour"})
@@ -559,7 +562,7 @@
lambda: newdir.import_branch(bzrwt.branch))
def test_repeat(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/test': "Tour"})
@@ -576,7 +579,7 @@
bzrwt.branch)
def test_multiple(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/test': "Tour"})
@@ -590,7 +593,7 @@
self.assertEquals([revid1, revid2], newbranch.revision_history())
def test_dato(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/foo.txt': "foo"})
@@ -603,7 +606,7 @@
Repository.open(repos_url).get_revision(revid1).committer)
def test_utf8_commit_msg(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/foo.txt': "foo"})
@@ -615,11 +618,14 @@
Repository.open(repos_url).get_revision(revid1).message)
def test_multiple_part_exists(self):
- repos_url = self.make_client("a", "dc")
- self.build_tree({'dc/trunk/myfile': "data", 'dc/branches': None})
- self.client_add('dc/trunk')
- self.client_add('dc/branches')
- self.client_commit("dc", "Message")
+ repos_url = self.make_repository("a")
+
+ dc = self.get_commit_editor(repos_url)
+ trunk = dc.add_dir('trunk')
+ trunk.add_file("trunk/myfile").modify("data")
+ dc.add_dir("branches")
+ dc.close()
+
svnrepos = Repository.open(repos_url)
os.mkdir("c")
bzrdir = BzrDir.open(repos_url+"/trunk").sprout("c")
@@ -637,10 +643,12 @@
, revid1, revid2], newbranch.revision_history())
def test_push_overwrite(self):
- repos_url = self.make_client("a", "dc")
- self.build_tree({'dc/trunk/bloe': "text"})
- self.client_add("dc/trunk")
- self.client_commit("dc", "initial")
+ repos_url = self.make_repository("a")
+
+ dc = self.get_commit_editor(repos_url)
+ trunk = dc.add_dir("trunk")
+ trunk.add_file("trunk/bloe").modify("text")
+ dc.close()
os.mkdir("d1")
bzrdir = BzrDir.open(repos_url+"/trunk").sprout("d1")
@@ -668,7 +676,7 @@
Branch.open(repos_url+"/trunk").revision_history())
def test_complex_rename(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -698,7 +706,7 @@
BzrDir.open(repos_url+"/trunk").sprout("n")
def test_rename_dir_changing_contents(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -726,7 +734,7 @@
check(copybranch)
def test_rename_dir(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -752,7 +760,7 @@
from bzrlib.debug import debug_flags
debug_flags.add("commit")
debug_flags.add("fetch")
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -767,16 +775,20 @@
newbranch = newdir.import_branch(bzrwt.branch)
# Should create dc/trunk
- self.client_update("dc")
-
- self.build_tree({'dc/branches': None})
- self.client_add("dc/branches")
- self.client_copy("dc/trunk", "dc/branches/foo")
- self.client_commit("dc", "Copy branches")
- self.client_update("dc")
-
- self.build_tree({'dc/branches/foo/registry/generic.c': "France"})
- merge_revno = self.client_commit("dc", "Change copied branch")[0]
+
+ dc = self.get_commit_editor(repos_url)
+ branches = dc.add_dir("branches")
+ branches.add_dir('branches/foo', 'trunk')
+ dc.close()
+
+ dc = self.get_commit_editor(repos_url)
+ branches = dc.open_dir("branches")
+ foo = branches.open_dir("branches/foo")
+ registry = foo.open_dir("branches/foo/registry")
+ registry.open_file("branches/foo/registry/generic.c").modify("France")
+ dc.close()
+
+ merge_revno = ra.RemoteAccess(repos_url).get_latest_revnum()
merge_revid = newdir.find_repository().generate_revision_id(merge_revno, "branches/foo", mapping)
self.build_tree({'c/registry/generic.c': "de"})
@@ -791,13 +803,12 @@
trunk.pull(bzrwt.branch)
self.assertEquals([revid1, revid2, revid3], trunk.revision_history())
- self.client_update("dc")
self.assertEquals(
'1 initialrevid\n2 changerevid\n3 mergerevid\n',
- self.client_get_prop("dc/branches/foo", SVN_PROP_BZR_REVISION_ID+"trunk0"))
+ self.client_get_prop(repos_url+"/branches/foo", SVN_PROP_BZR_REVISION_ID+"trunk0"))
def test_complex_replace_dir(self):
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -823,7 +834,7 @@
from bzrlib.debug import debug_flags
debug_flags.add("commit")
debug_flags.add("fetch")
- repos_url = self.make_client("a", "dc")
+ repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
format=format.get_rich_root_format())
self.build_tree({'c/registry/generic.c': "Tour"})
@@ -836,15 +847,14 @@
newdir = BzrDir.open(repos_url+"/trunk")
newbranch = newdir.import_branch(bzrwt.branch)
- # Should create dc/trunk
- self.client_update("dc")
+ c = ra.RemoteAccess(repos_url)
+ self.assertTrue(c.check_path("trunk/registry/generic.c", c.get_latest_revnum()) == core.NODE_FILE)
- self.assertTrue(os.path.exists("dc/trunk/registry/generic.c"))
- sleep(1) # Subversion relies on timestamps to detect
- # changed files...
- self.build_tree({'dc/trunk/registry/generic.c': "BLA"})
- self.client_commit("dc/trunk", "Change copied branch")
- self.client_update("dc")
+ dc = self.get_commit_editor(repos_url)
+ trunk = dc.open_dir("trunk")
+ registry = trunk.open_dir("trunk/registry")
+ registry.open_file("trunk/registry/generic.c").modify("BLA")
+ dc.close()
mapping = newdir.find_repository().get_mapping()
merge_revid = newdir.find_repository().generate_revision_id(2, "trunk", mapping)
@@ -861,10 +871,9 @@
trunk.repository.get_revision(revid2).parent_ids)
self.assertEquals([revid1, revid2], trunk.revision_history())
- self.client_update("dc")
self.assertEquals(
'1 initialrevid\n2 mergerevid\n',
- self.client_get_prop("dc/trunk", SVN_PROP_BZR_REVISION_ID+"trunk0"))
+ self.client_get_prop(repos_url+"/trunk", SVN_PROP_BZR_REVISION_ID+"trunk0"))
class TestPushTwice(TestCaseWithSubversionRepository):
More information about the bazaar-commits
mailing list