bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
3920.2.30
by Jelmer Vernooij
Review from John. |
1 |
# Copyright (C) 2005, 2007, 2008, 2009 Canonical Ltd
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
|
3920.2.28
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
16 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
17 |
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
18 |
"""Black-box tests for bzr dpush."""
|
19 |
||
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
20 |
|
|
3920.2.30
by Jelmer Vernooij
Review from John. |
21 |
import os |
22 |
||
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
23 |
from bzrlib.branch import ( |
24 |
Branch, |
|
25 |
)
|
|
26 |
from bzrlib.bzrdir import ( |
|
27 |
BzrDirFormat, |
|
28 |
)
|
|
29 |
from bzrlib.foreign import ( |
|
30 |
ForeignBranch, |
|
31 |
ForeignRepository, |
|
32 |
)
|
|
33 |
from bzrlib.repository import ( |
|
34 |
Repository, |
|
35 |
)
|
|
36 |
from bzrlib.tests.blackbox import ( |
|
37 |
ExternalBase, |
|
38 |
)
|
|
39 |
from bzrlib.tests.test_foreign import ( |
|
40 |
DummyForeignVcsDirFormat, |
|
41 |
)
|
|
|
3920.2.15
by Jelmer Vernooij
Add a DummyForeignVcsDir class. |
42 |
|
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
43 |
|
44 |
class TestDpush(ExternalBase): |
|
45 |
||
46 |
def setUp(self): |
|
|
3920.2.15
by Jelmer Vernooij
Add a DummyForeignVcsDir class. |
47 |
BzrDirFormat.register_control_format(DummyForeignVcsDirFormat) |
|
3920.2.30
by Jelmer Vernooij
Review from John. |
48 |
self.addCleanup(self.unregister_format) |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
49 |
super(TestDpush, self).setUp() |
50 |
||
|
3920.2.30
by Jelmer Vernooij
Review from John. |
51 |
def unregister_format(self): |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
52 |
try: |
|
3920.2.15
by Jelmer Vernooij
Add a DummyForeignVcsDir class. |
53 |
BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat) |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
54 |
except ValueError: |
55 |
pass
|
|
56 |
||
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
57 |
def make_dummy_builder(self, relpath): |
58 |
builder = self.make_branch_builder(relpath, |
|
59 |
format=DummyForeignVcsDirFormat()) |
|
60 |
builder.build_snapshot('revid', None, |
|
61 |
[('add', ('', 'TREE_ROOT', 'directory', None)), |
|
62 |
('add', ('foo', 'fooid', 'file', 'bar'))]) |
|
63 |
return builder |
|
64 |
||
|
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
65 |
def test_dpush_native(self): |
|
3920.2.30
by Jelmer Vernooij
Review from John. |
66 |
target_tree = self.make_branch_and_tree("dp") |
67 |
source_tree = self.make_branch_and_tree("dc") |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
68 |
output, error = self.run_bzr("dpush -d dc dp", retcode=3) |
69 |
self.assertEquals("", output) |
|
|
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
70 |
self.assertContainsRe(error, 'not a foreign branch, use regular push') |
71 |
||
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
72 |
def test_dpush(self): |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
73 |
branch = self.make_dummy_builder('d').get_branch() |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
74 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
75 |
dc = branch.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
76 |
self.build_tree(("dc/foo", "blaaaa")) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
77 |
dc.open_workingtree().commit('msg') |
78 |
||
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
79 |
self.check_output("", "dpush -d dc d") |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
80 |
self.check_output("", "status dc") |
81 |
||
82 |
def test_dpush_new(self): |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
83 |
branch = self.make_dummy_builder('d').get_branch() |
84 |
||
85 |
dc = branch.bzrdir.sprout('dc', force_new_repo=True) |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
86 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
87 |
dc_tree = dc.open_workingtree() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
88 |
dc_tree.add("foofile") |
89 |
dc_tree.commit("msg") |
|
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
90 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
91 |
self.check_output("", "dpush -d dc d") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
92 |
self.check_output("2\n", "revno dc") |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
93 |
self.check_output("", "status dc") |
94 |
||
95 |
def test_dpush_wt_diff(self): |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
96 |
branch = self.make_dummy_builder('d').get_branch() |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
97 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
98 |
dc = branch.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
99 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
100 |
dc_tree = dc.open_workingtree() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
101 |
dc_tree.add("foofile") |
102 |
newrevid = dc_tree.commit('msg') |
|
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
103 |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
104 |
self.build_tree_contents([("dc/foofile", "blaaaal")]) |
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
105 |
self.check_output("", "dpush -d dc d") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
106 |
self.assertFileEqual("blaaaal", "dc/foofile") |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
107 |
self.check_output('modified:\n foofile\n', "status dc") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
108 |
|
109 |
def test_diverged(self): |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
110 |
builder = self.make_dummy_builder('d') |
111 |
||
112 |
branch = builder.get_branch() |
|
113 |
||
114 |
dc = branch.bzrdir.sprout('dc', force_new_repo=True) |
|
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
115 |
dc_tree = dc.open_workingtree() |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
116 |
|
117 |
self.build_tree_contents([("dc/foo", "bar")]) |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
118 |
dc_tree.commit('msg1') |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
119 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
120 |
builder.build_snapshot('revid2', None, |
121 |
[('modify', ('fooid', 'blie'))]) |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
122 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
123 |
output, error = self.run_bzr("dpush -d dc d", retcode=3) |
124 |
self.assertEquals(output, "") |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
125 |
self.assertContainsRe(error, "have diverged") |