1 # Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 from bzrlib.branch import Branch
18 from bzrlib.bzrdir import BzrDir, BzrDirTestProviderAdapter, BzrDirFormat
19 from bzrlib.repository import Repository
23 import svn.core, svn.client
26 from tests import TestCaseWithSubversionRepository
28 class WorkingSubversionBranch(TestCaseWithSubversionRepository):
29 def test_num_revnums(self):
30 repos_url = self.make_client('a', 'dc')
31 bzrdir = BzrDir.open("svn+"+repos_url)
32 branch = bzrdir.open_branch()
33 self.assertEqual(None, branch.last_revision())
35 self.build_tree({'dc/foo': "data"})
36 self.client_add("dc/foo")
37 self.client_commit("dc", "My Message")
39 bzrdir = BzrDir.open("svn+"+repos_url)
40 branch = bzrdir.open_branch()
41 repos = bzrdir.open_repository()
43 self.assertEqual("svn-v1:1@%s-" % repos.uuid, branch.last_revision())
45 self.build_tree({'dc/foo': "data2"})
46 self.client_commit("dc", "My Message")
48 branch = Branch.open("svn+"+repos_url)
49 repos = Repository.open("svn+"+repos_url)
51 self.assertEqual("svn-v1:2@%s-" % repos.uuid, branch.last_revision())
53 def test_revision_history(self):
54 repos_url = self.make_client('a', 'dc')
56 branch = Branch.open("svn+"+repos_url)
57 self.assertEqual([], branch.revision_history())
59 self.build_tree({'dc/foo': "data"})
60 self.client_add("dc/foo")
61 self.client_commit("dc", "My Message")
63 branch = Branch.open("svn+"+repos_url)
64 repos = Repository.open("svn+"+repos_url)
66 self.assertEqual(["svn-v1:1@%s-" % repos.uuid], branch.revision_history())
68 self.build_tree({'dc/foo': "data34"})
69 self.client_commit("dc", "My Message")
71 branch = Branch.open("svn+"+repos_url)
72 repos = Repository.open("svn+"+repos_url)
75 "svn-v1:1@%s-" % repos.uuid,
76 "svn-v1:2@%s-" % repos.uuid],
77 branch.revision_history())
79 def test_get_nick(self):
80 repos_url = self.make_client('a', 'dc')
82 self.build_tree({'dc/foo': "data"})
83 self.client_add("dc/foo")
84 self.client_commit("dc", "My Message")
86 branch = Branch.open("svn+"+repos_url)
88 self.assertIs(None, branch.nick)
90 def test_fetch_branch(self):
91 repos_url = self.make_client('d', 'sc')
93 self.build_tree({'sc/foo/bla': "data"})
94 self.client_add("sc/foo")
95 self.client_commit("sc", "foo")
97 olddir = BzrDir.open("sc")
101 newdir = olddir.sprout('dc')
104 olddir.open_branch().last_revision(),
105 newdir.open_branch().last_revision())
107 def test_ghost_workingtree(self):
108 # Looks like bazaar has trouble creating a working tree of a
109 # revision that has ghost parents
110 repos_url = self.make_client('d', 'sc')
112 self.build_tree({'sc/foo/bla': "data"})
113 self.client_add("sc/foo")
114 self.client_set_prop("sc", "bzr:merge", "some-ghost\n")
115 self.client_commit("sc", "foo")
117 olddir = BzrDir.open("sc")
121 newdir = olddir.sprout('dc')
122 newdir.open_repository().get_revision(
123 newdir.open_branch().last_revision())
124 newdir.open_repository().get_revision_inventory(
125 newdir.open_branch().last_revision())