bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.64.281
by Jelmer Vernooij
Add tests for _get_source_stream. |
1 |
# Copyright (C) 2010 Canonical Ltd
|
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
|
|
|
0.64.334
by Jelmer Vernooij
Remove old FSF address. Thanks Dan Callaghan. |
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
0.64.281
by Jelmer Vernooij
Add tests for _get_source_stream. |
15 |
|
16 |
"""Test the command implementations."""
|
|
17 |
||
18 |
import os |
|
|
0.135.2
by Andy Grimm
fix --baseline bugs, and add a couple of tests |
19 |
import re |
|
0.64.281
by Jelmer Vernooij
Add tests for _get_source_stream. |
20 |
import tempfile |
21 |
import gzip |
|
22 |
||
23 |
from bzrlib import tests |
|
|
0.64.309
by Jelmer Vernooij
Add some blackbox tests for 'bzr fast-export'. |
24 |
from bzrlib.tests.blackbox import ExternalBase |
|
0.64.281
by Jelmer Vernooij
Add tests for _get_source_stream. |
25 |
|
|
0.64.286
by Jelmer Vernooij
Move command implementations into a separate cmds module. |
26 |
from bzrlib.plugins.fastimport.cmds import ( |
|
0.64.281
by Jelmer Vernooij
Add tests for _get_source_stream. |
27 |
_get_source_stream, |
28 |
)
|
|
29 |
||
30 |
from bzrlib.plugins.fastimport.tests import ( |
|
31 |
FastimportFeature, |
|
32 |
)
|
|
33 |
||
34 |
||
35 |
class TestSourceStream(tests.TestCase): |
|
36 |
||
37 |
_test_needs_features = [FastimportFeature] |
|
38 |
||
39 |
def test_get_source_stream_stdin(self): |
|
40 |
# - returns standard in
|
|
41 |
self.assertIsNot(None, _get_source_stream("-")) |
|
42 |
||
43 |
def test_get_source_gz(self): |
|
44 |
# files ending in .gz are automatically decompressed.
|
|
45 |
fd, filename = tempfile.mkstemp(suffix=".gz") |
|
46 |
f = gzip.GzipFile(fileobj=os.fdopen(fd, "w"), mode='w') |
|
47 |
f.write("bla") |
|
48 |
f.close() |
|
49 |
stream = _get_source_stream(filename) |
|
50 |
self.assertIsNot("bla", stream.read()) |
|
51 |
||
52 |
def test_get_source_file(self): |
|
53 |
# other files are opened as regular files.
|
|
54 |
fd, filename = tempfile.mkstemp() |
|
55 |
f = os.fdopen(fd, 'w') |
|
56 |
f.write("bla") |
|
57 |
f.close() |
|
58 |
stream = _get_source_stream(filename) |
|
59 |
self.assertIsNot("bla", stream.read()) |
|
|
0.64.309
by Jelmer Vernooij
Add some blackbox tests for 'bzr fast-export'. |
60 |
|
61 |
||
|
0.135.2
by Andy Grimm
fix --baseline bugs, and add a couple of tests |
62 |
fast_export_baseline_data = """commit refs/heads/master |
63 |
mark :1
|
|
64 |
committer
|
|
65 |
data 15
|
|
66 |
add c, remove b
|
|
67 |
M 644 inline a
|
|
68 |
data 13
|
|
69 |
test 1
|
|
70 |
test 3
|
|
71 |
M 644 inline c
|
|
72 |
data 6
|
|
73 |
test 4
|
|
74 |
commit refs/heads/master
|
|
75 |
mark :2
|
|
76 |
committer
|
|
77 |
data 14
|
|
78 |
modify a again
|
|
79 |
from :1
|
|
80 |
M 644 inline a
|
|
81 |
data 20
|
|
82 |
test 1
|
|
83 |
test 3
|
|
84 |
test 5
|
|
85 |
commit refs/heads/master
|
|
86 |
mark :3
|
|
87 |
committer
|
|
88 |
data 5
|
|
89 |
add d
|
|
90 |
from :2
|
|
91 |
M 644 inline d
|
|
92 |
data 6
|
|
93 |
test 6
|
|
94 |
"""
|
|
95 |
||
|
0.64.309
by Jelmer Vernooij
Add some blackbox tests for 'bzr fast-export'. |
96 |
class TestFastExport(ExternalBase): |
97 |
||
98 |
def test_empty(self): |
|
99 |
self.make_branch_and_tree("br") |
|
100 |
self.assertEquals("", self.run_bzr("fast-export br")[0]) |
|
101 |
||
102 |
def test_pointless(self): |
|
103 |
tree = self.make_branch_and_tree("br") |
|
104 |
tree.commit("pointless") |
|
105 |
data = self.run_bzr("fast-export br")[0] |
|
106 |
self.assertTrue(data.startswith('commit refs/heads/master\nmark :1\ncommitter')) |
|
107 |
||
108 |
def test_file(self): |
|
109 |
tree = self.make_branch_and_tree("br") |
|
110 |
tree.commit("pointless") |
|
111 |
data = self.run_bzr("fast-export br br.fi")[0] |
|
112 |
self.assertEquals("", data) |
|
|
0.64.314
by Jelmer Vernooij
Use TestCase.assertPathExists if available (fix deprecation warning with bzr 2.4) |
113 |
try: |
114 |
self.assertPathExists("br.fi") |
|
115 |
except AttributeError: # bzr < 2.4 |
|
116 |
self.failUnlessExists("br.fi") |
|
|
0.64.310
by Jelmer Vernooij
Fix fast-import-info. |
117 |
|
|
0.133.3
by Oleksandr Usov
Implement comments from patch review: |
118 |
def test_tag_rewriting(self): |
119 |
tree = self.make_branch_and_tree("br") |
|
120 |
tree.commit("pointless") |
|
121 |
self.assertTrue(tree.branch.supports_tags()) |
|
122 |
rev_id = tree.branch.dotted_revno_to_revision_id((1,)) |
|
123 |
tree.branch.tags.set_tag("goodTag", rev_id) |
|
124 |
tree.branch.tags.set_tag("bad Tag", rev_id) |
|
125 |
||
126 |
# first check --no-rewrite-tag-names
|
|
127 |
data = self.run_bzr("fast-export --plain --no-rewrite-tag-names br")[0] |
|
128 |
self.assertNotEqual(-1, data.find("reset refs/tags/goodTag")) |
|
129 |
self.assertEqual(data.find("reset refs/tags/"), data.rfind("reset refs/tags/")) |
|
130 |
||
131 |
# and now with --rewrite-tag-names
|
|
132 |
data = self.run_bzr("fast-export --plain --rewrite-tag-names br")[0] |
|
133 |
self.assertNotEqual(-1, data.find("reset refs/tags/goodTag")) |
|
134 |
# "bad Tag" should be exported as bad_Tag
|
|
135 |
self.assertNotEqual(-1, data.find("reset refs/tags/bad_Tag")) |
|
136 |
||
|
0.135.2
by Andy Grimm
fix --baseline bugs, and add a couple of tests |
137 |
def test_baseline_option(self): |
138 |
tree = self.make_branch_and_tree("bl") |
|
139 |
||
140 |
# Revision 1
|
|
141 |
file('bl/a', 'w').write('test 1') |
|
142 |
tree.add('a') |
|
143 |
tree.commit(message='add a') |
|
144 |
||
145 |
# Revision 2
|
|
146 |
file('bl/b', 'w').write('test 2') |
|
147 |
file('bl/a', 'a').write('\ntest 3') |
|
148 |
tree.add('b') |
|
149 |
tree.commit(message='add b, modify a') |
|
150 |
||
151 |
# Revision 3
|
|
152 |
file('bl/c', 'w').write('test 4') |
|
153 |
tree.add('c') |
|
154 |
tree.remove('b') |
|
155 |
tree.commit(message='add c, remove b') |
|
156 |
||
157 |
# Revision 4
|
|
158 |
file('bl/a', 'a').write('\ntest 5') |
|
159 |
tree.commit(message='modify a again') |
|
160 |
||
161 |
# Revision 5
|
|
162 |
file('bl/d', 'w').write('test 6') |
|
163 |
tree.add('d') |
|
164 |
tree.commit(message='add d') |
|
165 |
||
166 |
# This exports the baseline state at Revision 3,
|
|
167 |
# followed by the deltas for 4 and 5
|
|
168 |
data = self.run_bzr("fast-export --baseline -r 3.. bl")[0] |
|
169 |
data = re.sub('committer.*', 'committer', data) |
|
170 |
self.assertEquals(fast_export_baseline_data, data) |
|
171 |
||
172 |
# Also confirm that --baseline with no args is identical to full export
|
|
173 |
data1 = self.run_bzr("fast-export --baseline bl")[0] |
|
174 |
data2 = self.run_bzr("fast-export bl")[0] |
|
175 |
self.assertEquals(data1, data2) |
|
|
0.64.310
by Jelmer Vernooij
Fix fast-import-info. |
176 |
|
177 |
simple_fast_import_stream = """commit refs/heads/master |
|
178 |
mark :1
|
|
179 |
committer Jelmer Vernooij <jelmer@samba.org> 1299718135 +0100
|
|
180 |
data 7
|
|
181 |
initial
|
|
182 |
||
183 |
"""
|
|
184 |
||
185 |
class TestFastImportInfo(ExternalBase): |
|
186 |
||
187 |
def test_simple(self): |
|
188 |
self.build_tree_contents([('simple.fi', simple_fast_import_stream)]) |
|
189 |
output = self.run_bzr("fast-import-info simple.fi")[0] |
|
190 |
self.assertEquals(output, """Command counts: |
|
191 |
\t0\tblob |
|
192 |
\t0\tcheckpoint |
|
193 |
\t1\tcommit |
|
194 |
\t0\tfeature |
|
195 |
\t0\tprogress |
|
196 |
\t0\treset |
|
197 |
\t0\ttag |
|
198 |
File command counts:
|
|
199 |
\t0\tfilemodify |
|
200 |
\t0\tfiledelete |
|
201 |
\t0\tfilecopy |
|
202 |
\t0\tfilerename |
|
203 |
\t0\tfiledeleteall |
|
204 |
Parent counts:
|
|
205 |
\t1\tparents-0 |
|
206 |
\t0\ttotal revisions merged |
|
207 |
Commit analysis:
|
|
208 |
\tno\texecutables |
|
209 |
\tno\tseparate authors found |
|
210 |
\tno\tsymlinks |
|
211 |
\tno\tblobs referenced by SHA |
|
212 |
Head analysis:
|
|
213 |
\t[':1']\trefs/heads/master |
|
214 |
Merges:
|
|
215 |
""") |
|
|
0.131.1
by Jelmer Vernooij
Add blackbox tests for 'bzr fast-import'. |
216 |
|
217 |
||
218 |
class TestFastImport(ExternalBase): |
|
219 |
||
220 |
def test_empty(self): |
|
221 |
self.build_tree_contents([('empty.fi', "")]) |
|
222 |
self.make_branch_and_tree("br") |
|
223 |
self.assertEquals("", self.run_bzr("fast-import empty.fi br")[0]) |
|
224 |
||
225 |
def test_file(self): |
|
226 |
tree = self.make_branch_and_tree("br") |
|
227 |
self.build_tree_contents([('file.fi', simple_fast_import_stream)]) |
|
228 |
data = self.run_bzr("fast-import file.fi br")[0] |
|
|
0.131.2
by Jelmer Vernooij
Fix 'bzr fast-import' bzrdir argument and add a blackbox test. |
229 |
self.assertEquals(1, tree.branch.revno()) |
|
0.64.321
by Jelmer Vernooij
Allow fast-import-filter to be used without first argument. |
230 |
|
231 |
||
232 |
class TestFastImportFilter(ExternalBase): |
|
233 |
||
234 |
def test_empty(self): |
|
235 |
self.build_tree_contents([('empty.fi', "")]) |
|
236 |
self.make_branch_and_tree("br") |
|
237 |
self.assertEquals("", self.run_bzr("fast-import-filter -")[0]) |
|
238 |
||
239 |
def test_default_stdin(self): |
|
240 |
self.build_tree_contents([('empty.fi', "")]) |
|
241 |
self.make_branch_and_tree("br") |
|
242 |
self.assertEquals("", self.run_bzr("fast-import-filter")[0]) |