147.1.1
by Robert Collins
start adding baz_import unit test cases |
1 |
# Copyright (C) 2005 Canonical Limited
|
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
147.4.23
by Robert Collins
Update for integration changes. |
18 |
from bzrlib.tests import TestCaseInTempDir, TestCase |
19 |
from bzrlib.osutils import has_symlinks |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
20 |
try: |
21 |
import pybaz |
|
22 |
except ImportError: |
|
23 |
pybaz = None |
|
24 |
import os |
|
147.1.34
by Robert Collins
wrap > 80 chars line |
25 |
from bzrlib.plugins.bzrtools.baz_import import (import_version, revision_id, |
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
26 |
cmd_baz_import, make_archive) |
147.1.20
by Robert Collins
handle missing ancestry |
27 |
from bzrlib.errors import NoSuchRevision |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
28 |
import shutil |
147.1.17
by Robert Collins
make feedback be callback based - really |
29 |
from StringIO import StringIO |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
30 |
import tempfile |
31 |
from testresources import (TestResource, TestLoader, OptimisingTestSuite, |
|
147.1.54
by Aaron Bentley
Got bzrtools almost working, except baz-import |
32 |
ResourcedTestCase) |
33 |
||
147.1.33
by Robert Collins
merge from aaron, and update test imports to import successfully. |
34 |
from bzrlib.plugins.bzrtools.fai import namespace_previous |
147.1.29
by Robert Collins
update to latest bzr api |
35 |
from bzrlib.branch import Branch |
147.1.1
by Robert Collins
start adding baz_import unit test cases |
36 |
|
37 |
def test_suite(): |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
38 |
if pybaz is None: |
147.1.54
by Aaron Bentley
Got bzrtools almost working, except baz-import |
39 |
from unittest import TestSuite |
40 |
return TestSuite() |
|
147.1.1
by Robert Collins
start adding baz_import unit test cases |
41 |
return TestLoader().loadTestsFromName(__name__) |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
42 |
|
43 |
||
44 |
class BazTreeResource(TestResource): |
|
45 |
||
46 |
def cleanUp(self): |
|
47 |
os.environ['HOME'] = self._oldhome |
|
48 |
shutil.rmtree(self._tmpdir) |
|
49 |
||
50 |
def __init__(self): |
|
51 |
self._tmpdir = tempfile.mkdtemp() |
|
52 |
self._homedir = os.path.join(self._tmpdir, 'home') |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
53 |
self._oldhome = os.environ['HOME'] |
54 |
os.mkdir(self._homedir) |
|
55 |
os.environ['HOME'] = self._homedir |
|
147.1.20
by Robert Collins
handle missing ancestry |
56 |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
57 |
self._archiveroot = os.path.join(self._tmpdir, 'archive') |
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
58 |
self._archive = make_archive('demo@DONOTUSE', str(self._archiveroot)) |
147.1.2
by Robert Collins
test empty import and tagged branches |
59 |
pybaz.set_my_id("Test User<test@example.org>") |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
60 |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
61 |
self.make_empty_import() |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
62 |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
63 |
self._empty_tag = 'demo@DONOTUSE/c--empty-tag--0' |
64 |
self._empty_tag_bzr = revision_id(self._empty_tag + '--base-0') |
|
65 |
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation( |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
66 |
pybaz.Version(self._empty_tag)) |
67 |
||
68 |
self._empty_merged_tag = 'demo@DONOTUSE/c--empty-merged-tag--0' |
|
69 |
self._empty_merged_tag_bzr_base = revision_id(self._empty_merged_tag |
|
70 |
+ '--base-0') |
|
71 |
self._empty_merged_tag_bzr = revision_id(self._empty_merged_tag |
|
72 |
+ '--patch-1') |
|
73 |
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation( |
|
74 |
pybaz.Version(self._empty_merged_tag)) |
|
75 |
tree = pybaz.Revision(self._empty_merged_tag + '--base-0').get( |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
76 |
os.path.join(self._tmpdir, 'tree')) |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
77 |
tree.star_merge(self._empty_tag, |
78 |
pybaz.Version('demo@DONOTUSE/c--import--0')) |
|
79 |
msg = tree.log_message() |
|
80 |
msg["summary"]="did a merge, yarh" |
|
81 |
tree.commit(msg) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
82 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
83 |
||
84 |
# tree, two commits, includes merge of other branch
|
|
85 |
self._empty_merged_tag_2 = 'demo@DONOTUSE/c--empty-tag-2--0' |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
86 |
self._empty_merged_tag_2_bzr_base = revision_id( |
87 |
self._empty_merged_tag_2 + '--base-0') |
|
88 |
self._empty_merged_tag_2_bzr = revision_id( |
|
89 |
self._empty_merged_tag_2 + '--patch-1') |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
90 |
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation( |
91 |
pybaz.Version(self._empty_merged_tag_2)) |
|
92 |
tree = pybaz.Revision(self._empty_merged_tag_2 + '--base-0').get ( |
|
93 |
os.path.join(self._tmpdir, 'tree')) |
|
94 |
tree.star_merge(self._empty_merged_tag, |
|
95 |
pybaz.Version('demo@DONOTUSE/c--import--0')) |
|
96 |
msg = tree.log_message() |
|
97 |
msg["summary"] = "merge in a merged tree." |
|
98 |
tree.commit(msg) |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
99 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
100 |
||
147.4.1
by Robert Collins
test escaping of file ids is working |
101 |
self._bad_id_tag = 'demo@DONOTUSE/c--bad-id--0' |
102 |
self._bad_id_tag_bzr_base = revision_id(self._bad_id_tag + '--base-0') |
|
103 |
self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1') |
|
104 |
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation( |
|
105 |
pybaz.Version(self._bad_id_tag)) |
|
106 |
tree = pybaz.Revision(self._bad_id_tag + '--base-0').get( |
|
107 |
os.path.join(self._tmpdir, 'tree')) |
|
108 |
from bzrlib.plugins.bzrtools.baz_import import add_file |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
109 |
add_file(os.path.join(self._tmpdir,'tree/path'), 'text', |
110 |
'this_id/needs%escaping') |
|
147.4.1
by Robert Collins
test escaping of file ids is working |
111 |
msg = tree.log_message() |
112 |
msg["summary"] = "commit something which needs escaping." |
|
113 |
tree.commit(msg) |
|
114 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
115 |
||
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
116 |
self.make_import_symlink() |
147.1.20
by Robert Collins
handle missing ancestry |
117 |
self.make_missing_ancestor() |
147.4.26
by Robert Collins
Test in-branch continuations. |
118 |
self.make_inbranch_continuation() |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
119 |
|
120 |
def make_import_symlink(self): |
|
121 |
self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0' |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
122 |
self._import_symlink_bzr = revision_id( |
123 |
self._import_symlink + '--base-0') |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
124 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
125 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
|
126 |
self._import_symlink) |
|
127 |
os.symlink('missing-file-name', |
|
128 |
os.path.join(self._tmpdir, 'tree', 'alink')) |
|
129 |
tree.add_tag('alink') |
|
130 |
id_file = open(os.path.join(tree, '.arch-ids', 'alink.id'), 'w') |
|
131 |
id_file.write('symlink_tag\n') |
|
132 |
id_file.close() |
|
133 |
msg = tree.log_message() |
|
134 |
msg["summary"] = "Import with a symlink" |
|
135 |
tree.import_(msg) |
|
136 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
137 |
||
138 |
def make_empty_import(self): |
|
139 |
self._import = 'demo@DONOTUSE/c--import--0' |
|
140 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
141 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
142 |
self._import) |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
143 |
msg = tree.log_message() |
144 |
msg["summary"] = "I am importing now" |
|
145 |
tree.import_(msg) |
|
146 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
147 |
|
147.1.20
by Robert Collins
handle missing ancestry |
148 |
def make_missing_ancestor(self): |
149 |
self._archivegoneroot = os.path.join(self._tmpdir, 'archivegone') |
|
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
150 |
self._archive = make_archive('demo-gone@DONOTUSE', |
151 |
str(self._archivegoneroot)) |
|
147.1.20
by Robert Collins
handle missing ancestry |
152 |
self._missing_import = 'demo-gone@DONOTUSE/c--import--0' |
153 |
self._missing_import_bzr = revision_id(self._missing_import |
|
154 |
+ '--base-0') |
|
155 |
self._missing_ancestor = 'demo@DONOTUSE/c--gone--0' |
|
156 |
self._missing_ancestor_bzr = revision_id(self._missing_ancestor |
|
157 |
+ '--base-0') |
|
158 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
159 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
|
160 |
self._missing_import) |
|
161 |
msg = tree.log_message() |
|
162 |
msg["summary"] = "I am importing now" |
|
163 |
tree.import_(msg) |
|
164 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
165 |
# tag into the kept archive
|
|
166 |
pybaz.Revision(self._missing_import + '--base-0').make_continuation( |
|
167 |
pybaz.Version(self._missing_ancestor)) |
|
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
168 |
|
169 |
# make an import for testing history-reuse logic.
|
|
170 |
def collect(text): |
|
171 |
pass
|
|
172 |
# note the use of a namespace layout here.
|
|
173 |
self._missing_import_imported = os.path.join(self._tmpdir, |
|
174 |
'archivegone-bzr') |
|
175 |
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr')) |
|
176 |
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c')) |
|
177 |
import_version(os.path.join(self._tmpdir, 'archivegone-bzr', |
|
178 |
'c', 'import'), |
|
179 |
pybaz.Version(self._missing_import), |
|
180 |
collect) |
|
147.1.20
by Robert Collins
handle missing ancestry |
181 |
# and make it inaccessible
|
182 |
pybaz.Archive('demo-gone@DONOTUSE').unregister() |
|
183 |
||
147.4.26
by Robert Collins
Test in-branch continuations. |
184 |
def make_inbranch_continuation(self): |
185 |
self._inbranch_tag = 'demo@DONOTUSE/c--inbranch-tag--0' |
|
186 |
self._inbranch_tag_base = self._inbranch_tag + '--base-0' |
|
187 |
self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base) |
|
188 |
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation( |
|
189 |
pybaz.Version(self._inbranch_tag)) |
|
190 |
self._inbranch_tag_head = self._inbranch_tag + '--patch-1' |
|
191 |
self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head) |
|
192 |
pybaz.Revision(self._inbranch_tag_base).make_continuation( |
|
193 |
pybaz.Version(self._inbranch_tag)) |
|
194 |
||
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
195 |
@classmethod
|
196 |
def _makeResource(self): |
|
197 |
return BazTreeResource() |
|
198 |
||
199 |
@classmethod
|
|
200 |
def _cleanResource(self, resource): |
|
201 |
resource.cleanUp() |
|
202 |
||
203 |
||
147.1.12
by Robert Collins
create the output directory |
204 |
class TestImportBranch(TestCaseInTempDir): |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
205 |
|
206 |
_resources = [("_baz", BazTreeResource)] |
|
207 |
||
208 |
def setUp(self): |
|
209 |
TestCaseInTempDir.setUp(self) |
|
210 |
ResourcedTestCase.setUpResources(self) |
|
147.1.36
by Robert Collins
updates for bzr api changes |
211 |
os.environ['HOME'] = self._baz._homedir |
147.1.17
by Robert Collins
make feedback be callback based - really |
212 |
self.output = StringIO() |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
213 |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
214 |
def tearDown(self): |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
215 |
ResourcedTestCase.tearDownResources(self) |
216 |
TestCaseInTempDir.tearDown(self) |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
217 |
|
218 |
def collect(self, text): |
|
219 |
self.output.write(text) |
|
220 |
self.output.write("\n") |
|
221 |
||
147.1.2
by Robert Collins
test empty import and tagged branches |
222 |
def test_import_empty(self): |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
223 |
import_version('output', pybaz.Version(self._baz._import), |
224 |
self.collect) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
225 |
# expected results:
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
226 |
# one commit, no files, revision identifier of
|
227 |
# 'demo@DONOTUSE_c--import--0--base-0'
|
|
147.1.29
by Robert Collins
update to latest bzr api |
228 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
229 |
repo = branch.repository |
147.1.2
by Robert Collins
test empty import and tagged branches |
230 |
self.assertEqual(branch.revision_history(), |
231 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
232 |
rev = repo.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0') |
147.1.2
by Robert Collins
test empty import and tagged branches |
233 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
234 |
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'), |
235 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
236 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
237 |
repo2 = branch2.repository |
147.1.2
by Robert Collins
test empty import and tagged branches |
238 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
239 |
rev2 = repo2.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0') |
147.1.2
by Robert Collins
test empty import and tagged branches |
240 |
# they must be the same
|
241 |
self.assertEqual(rev, rev2) |
|
242 |
||
243 |
# and we should get some expected values:
|
|
244 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
245 |
self.assertEqual(rev.message, "I am importing now") |
|
246 |
self.assertEqual(rev.revision_id, |
|
247 |
"Arch-1:demo@DONOTUSE%c--import--0--base-0") |
|
248 |
||
249 |
def test_empty_tagged(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
250 |
import_version('output', pybaz.Version(self._baz._empty_tag), |
251 |
self.collect) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
252 |
# expected results:
|
253 |
# two commits, no files, revision identifiers of
|
|
254 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
255 |
# self._baz._empty_tag_bzr
|
147.1.29
by Robert Collins
update to latest bzr api |
256 |
branch = Branch.open('output') |
147.1.2
by Robert Collins
test empty import and tagged branches |
257 |
self.assertEqual(branch.revision_history(), |
258 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
259 |
self._baz._empty_tag_bzr]) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
260 |
rev = branch.repository.get_revision(self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
261 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
262 |
import_version('output2', pybaz.Version(self._baz._empty_tag), |
263 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
264 |
branch2 = Branch.open('output2') |
147.1.2
by Robert Collins
test empty import and tagged branches |
265 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
266 |
rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
267 |
# they must be the same
|
268 |
self.assertEqual(rev, rev2) |
|
269 |
||
270 |
# and we should get some expected values:
|
|
271 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
272 |
self.assertEqual(rev.message, |
273 |
"tag of demo@DONOTUSE/c--import--0--base-0") |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
274 |
self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
275 |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
276 |
def test_empty_merged_tagged(self): |
147.1.17
by Robert Collins
make feedback be callback based - really |
277 |
import_version('output', pybaz.Version(self._baz._empty_merged_tag), |
278 |
self.collect) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
279 |
# expected results:
|
280 |
# two commits, no files, revision identifiers of
|
|
281 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
282 |
# self._baz._empty_merged_tag_bzr_base
|
283 |
# self._baz._empty_merged_tag_bzr
|
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
284 |
# and a merged revision from the latter of
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
285 |
# self._baz._empty_tag_bzr
|
147.1.29
by Robert Collins
update to latest bzr api |
286 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
287 |
repo = branch.repository |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
288 |
self.assertEqual(branch.revision_history(), |
289 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
290 |
self._baz._empty_merged_tag_bzr_base, |
291 |
self._baz._empty_merged_tag_bzr]) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
292 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
293 |
import_version('output2', pybaz.Version(self._baz._empty_merged_tag), |
294 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
295 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
296 |
repo2 = branch2.repository |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
297 |
# and import what we should be merged up against for checking with.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
298 |
import_version('output3', pybaz.Version(self._baz._empty_tag), |
299 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
300 |
branch3 = Branch.open('output3') |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
301 |
|
302 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
303 |
self.assertNotEqual(branch.revision_history(), |
304 |
branch3.revision_history()) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
305 |
# check revisions in the history.
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
306 |
rev = repo.get_revision(self._baz._empty_merged_tag_bzr_base) |
307 |
rev2 = repo2.get_revision(self._baz._empty_merged_tag_bzr_base) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
308 |
# they must be the same
|
309 |
self.assertEqual(rev, rev2) |
|
310 |
# and we should get some expected values:
|
|
311 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
312 |
self.assertEqual(rev.message, |
313 |
"tag of demo@DONOTUSE/c--import--0--base-0") |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
314 |
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_bzr_base) |
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
315 |
self.assertEqual(['Arch-1:demo@DONOTUSE%c--import--0--base-0'], |
316 |
rev.parent_ids) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
317 |
|
318 |
# check next revisions in the history.
|
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
319 |
rev = repo.get_revision(self._baz._empty_merged_tag_bzr) |
320 |
rev2 = repo2.get_revision(self._baz._empty_merged_tag_bzr) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
321 |
# they must be the same
|
322 |
self.assertEqual(rev, rev2) |
|
323 |
# and we should get some expected values:
|
|
324 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
325 |
self.assertEqual(rev.message, "did a merge, yarh") |
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
326 |
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_bzr) |
147.1.31
by Robert Collins
update to weave api |
327 |
self.assertEqual(rev.parent_ids[0], |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
328 |
self._baz._empty_merged_tag_bzr_base) |
147.1.31
by Robert Collins
update to weave api |
329 |
self.assertEqual(rev.parent_ids[1], self._baz._empty_tag_bzr) |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
330 |
|
331 |
# this tree should have nothing missing from that tree.
|
|
332 |
# FIXME there is no code for this right now.
|
|
333 |
# self.assertEqual(branch.missing_revisions(branch3), [])
|
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
334 |
|
335 |
def test_merge_branch_with_merges(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
336 |
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2), |
337 |
self.collect) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
338 |
# expected results:
|
339 |
# two commits, no files, revision identifiers of
|
|
340 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
341 |
# self._baz._empty_merged_tag_2_bzr_base
|
|
342 |
# self._baz._empty_merged_tag_2_bzr
|
|
343 |
# and a merged revision from the latter of
|
|
344 |
# self._baz._empty_merged_tag_bzr
|
|
147.1.29
by Robert Collins
update to latest bzr api |
345 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
346 |
repo = branch.repository |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
347 |
self.assertEqual(branch.revision_history(), |
348 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
349 |
self._baz._empty_merged_tag_2_bzr_base, |
|
350 |
self._baz._empty_merged_tag_2_bzr]) |
|
351 |
# and again.
|
|
147.1.17
by Robert Collins
make feedback be callback based - really |
352 |
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2), |
353 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
354 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
355 |
repo2 = branch2.repository |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
356 |
# and import what we should be merged up against for checking with.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
357 |
import_version('output3', pybaz.Version(self._baz._empty_merged_tag), |
358 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
359 |
branch3 = Branch.open('output3') |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
360 |
|
361 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
362 |
self.assertNotEqual(branch.revision_history(), |
363 |
branch3.revision_history()) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
364 |
# check revisions in the history.
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
365 |
rev = repo.get_revision(self._baz._empty_merged_tag_2_bzr_base) |
366 |
rev2 = repo2.get_revision(self._baz._empty_merged_tag_2_bzr_base) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
367 |
# they must be the same
|
368 |
self.assertEqual(rev, rev2) |
|
369 |
# and we should get some expected values:
|
|
370 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
371 |
self.assertEqual(rev.message, |
372 |
"tag of demo@DONOTUSE/c--import--0--base-0") |
|
373 |
self.assertEqual(rev.revision_id, |
|
374 |
self._baz._empty_merged_tag_2_bzr_base) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
375 |
|
376 |
# check next revisions in the history.
|
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
377 |
rev = repo.get_revision(self._baz._empty_merged_tag_2_bzr) |
378 |
rev2 = repo2.get_revision(self._baz._empty_merged_tag_2_bzr) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
379 |
# they must be the same
|
380 |
self.assertEqual(rev, rev2) |
|
381 |
# and we should get some expected values:
|
|
382 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
383 |
self.assertEqual(rev.message, "merge in a merged tree.") |
|
384 |
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_2_bzr) |
|
147.1.31
by Robert Collins
update to weave api |
385 |
self.assertEqual(rev.parent_ids[0], |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
386 |
self._baz._empty_merged_tag_2_bzr_base) |
147.1.31
by Robert Collins
update to weave api |
387 |
self.assertEqual(rev.parent_ids[1], |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
388 |
self._baz._empty_merged_tag_bzr) |
389 |
||
390 |
# this tree should have nothing missing from that tree.
|
|
391 |
# FIXME there is no code for this right now.
|
|
392 |
# self.assertEqual(branch.missing_revisions(branch3), [])
|
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
393 |
|
394 |
def test_import_symlink(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
395 |
import_version('output', pybaz.Version(self._baz._import_symlink), |
396 |
self.collect) |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
397 |
# expected results:
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
398 |
# one commit, no files, revision identifier of
|
399 |
# 'demo@DONOTUSE_c--import--0--base-0'
|
|
147.1.29
by Robert Collins
update to latest bzr api |
400 |
branch = Branch.open('output') |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
401 |
self.assertEqual(branch.revision_history(), |
402 |
[self._baz._import_symlink_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
403 |
rev = branch.repository.get_revision(self._baz._import_symlink_bzr) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
404 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
405 |
import_version('output2', pybaz.Version(self._baz._import_symlink), |
406 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
407 |
branch2 = Branch.open('output2') |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
408 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
409 |
rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
410 |
# they must be the same
|
411 |
self.assertEqual(rev, rev2) |
|
412 |
||
413 |
# and we should get some expected values:
|
|
414 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
415 |
self.assertEqual(rev.message, "Import with a symlink") |
|
416 |
self.assertEqual(rev.revision_id, self._baz._import_symlink_bzr) |
|
417 |
||
418 |
# and we want the symlink alink with target 'missing-file-name'
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
419 |
inv = branch.repository.get_inventory(rev.revision_id) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
420 |
self.assertEqual(inv.path2id('alink'), 'x_symlink_tag') |
421 |
entry = inv['x_symlink_tag'] |
|
422 |
self.assertEqual(entry.kind, 'symlink') |
|
423 |
self.assertEqual(entry.symlink_target, 'missing-file-name') |
|
147.1.7
by Robert Collins
handle inaccessible sibling archives somewhat - note version-0 is still not handled |
424 |
|
147.1.20
by Robert Collins
handle missing ancestry |
425 |
def test_missing_ancestor(self): |
426 |
import_version('output', pybaz.Version(self._baz._missing_ancestor), |
|
427 |
self.collect) |
|
428 |
# expected results:
|
|
429 |
# one commits, no files, revision identifiers of
|
|
430 |
# 'demo@DONOTUSE_c--gone--0--base-0' and
|
|
431 |
# a merge of demo-gone@DONOTUSE%c--import--0
|
|
147.1.29
by Robert Collins
update to latest bzr api |
432 |
branch = Branch.open('output') |
147.1.20
by Robert Collins
handle missing ancestry |
433 |
self.assertEqual(branch.revision_history(), |
434 |
[self._baz._missing_ancestor_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
435 |
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.1.20
by Robert Collins
handle missing ancestry |
436 |
# and again.
|
437 |
import_version('output2', pybaz.Version(self._baz._missing_ancestor), |
|
438 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
439 |
branch2 = Branch.open('output2') |
147.1.20
by Robert Collins
handle missing ancestry |
440 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
441 |
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.1.20
by Robert Collins
handle missing ancestry |
442 |
# they must be the same
|
443 |
self.assertEqual(rev, rev2) |
|
444 |
||
445 |
# and we should get some expected values:
|
|
446 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
447 |
self.assertEqual(rev.message, |
448 |
"tag of demo-gone@DONOTUSE/c--import--0--base-0") |
|
147.1.20
by Robert Collins
handle missing ancestry |
449 |
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr) |
147.1.31
by Robert Collins
update to weave api |
450 |
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr) |
451 |
self.assertEqual(1, len(rev.parent_ids)) |
|
147.1.20
by Robert Collins
handle missing ancestry |
452 |
|
453 |
# must NOT be able to get the merged evision
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
454 |
self.assertRaises(NoSuchRevision, branch.repository.get_revision, |
147.1.20
by Robert Collins
handle missing ancestry |
455 |
self._baz._missing_import_bzr) |
456 |
||
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
457 |
def test_missing_ancestor_reusing_history(self): |
458 |
import_version('output', pybaz.Version(self._baz._missing_ancestor), |
|
459 |
self.collect, |
|
460 |
reuse_history_from=[self._baz._missing_import_imported]) |
|
461 |
# expected results:
|
|
462 |
# one commits, no files, revision identifiers of
|
|
463 |
# 'demo-gone@DONOTUSE%c--import--0--base-0' and
|
|
464 |
# 'demo@DONOTUSE%c--gone--0--base-0'
|
|
465 |
branch = Branch.open('output') |
|
466 |
self.assertEqual(branch.revision_history(), |
|
467 |
[self._baz._missing_import_bzr, |
|
468 |
self._baz._missing_ancestor_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
469 |
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
470 |
# and again.
|
471 |
import_version('output2', pybaz.Version(self._baz._missing_ancestor), |
|
472 |
self.collect, |
|
473 |
reuse_history_from=[self._baz._missing_import_imported]) |
|
474 |
branch2 = Branch.open('output2') |
|
475 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
476 |
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
477 |
# they must be the same
|
478 |
self.assertEqual(rev, rev2) |
|
479 |
||
480 |
# must be able to get the missing base revision
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
481 |
branch.repository.get_revision(self._baz._missing_import_bzr) |
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
482 |
|
483 |
# and we should get some expected values:
|
|
484 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
485 |
self.assertEqual(rev.message, |
486 |
"tag of demo-gone@DONOTUSE/c--import--0--base-0") |
|
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
487 |
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr) |
488 |
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr) |
|
489 |
self.assertEqual(1, len(rev.parent_ids)) |
|
490 |
||
147.4.1
by Robert Collins
test escaping of file ids is working |
491 |
def test_bad_file_id(self): |
492 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
493 |
self.collect) |
|
494 |
# expected results:
|
|
495 |
# three commits, one files, revision identifiers of
|
|
496 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
497 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
498 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
499 |
branch = Branch.open('output') |
|
500 |
self.assertEqual(branch.revision_history(), |
|
501 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
502 |
self._baz._bad_id_tag_bzr_base, |
|
503 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
504 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
505 |
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr) |
|
147.4.1
by Robert Collins
test escaping of file ids is working |
506 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
507 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
508 |
||
147.4.5
by Robert Collins
When an import finds a revision it needs already in the branch, just append it to the revision history |
509 |
def test_appending_revisions_already_present(self): |
510 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
511 |
self.collect, max_count=2) |
|
512 |
# expected results:
|
|
513 |
# three commits, one files, revision identifiers of
|
|
514 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
515 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
516 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
517 |
branch = Branch.open('output') |
|
518 |
self.assertEqual(branch.revision_history(), |
|
519 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
520 |
self._baz._bad_id_tag_bzr_base]) |
|
521 |
branch.set_revision_history( |
|
522 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
523 |
del branch |
|
524 |
branch = Branch.open('output') |
|
525 |
self.assertEqual(branch.revision_history(), |
|
526 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
527 |
del branch |
|
528 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
529 |
self.collect) |
|
530 |
branch = Branch.open('output') |
|
531 |
self.assertEqual(branch.revision_history(), |
|
532 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
533 |
self._baz._bad_id_tag_bzr_base, |
|
534 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
535 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
536 |
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr) |
|
147.4.5
by Robert Collins
When an import finds a revision it needs already in the branch, just append it to the revision history |
537 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
538 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
539 |
||
540 |
def test_appending_revisions_all_already_present(self): |
|
541 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
542 |
self.collect) |
|
543 |
# expected results:
|
|
544 |
# three commits, one files, revision identifiers of
|
|
545 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
546 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
547 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
548 |
branch = Branch.open('output') |
|
549 |
self.assertEqual(branch.revision_history(), |
|
550 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
551 |
self._baz._bad_id_tag_bzr_base, |
|
552 |
self._baz._bad_id_tag_bzr]) |
|
553 |
branch.set_revision_history( |
|
554 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
555 |
del branch |
|
556 |
branch = Branch.open('output') |
|
557 |
self.assertEqual(branch.revision_history(), |
|
558 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
559 |
del branch |
|
560 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
561 |
self.collect) |
|
562 |
branch = Branch.open('output') |
|
563 |
self.assertEqual(branch.revision_history(), |
|
564 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
565 |
self._baz._bad_id_tag_bzr_base, |
|
566 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
567 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
568 |
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr) |
|
147.4.5
by Robert Collins
When an import finds a revision it needs already in the branch, just append it to the revision history |
569 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
570 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
571 |
||
147.4.26
by Robert Collins
Test in-branch continuations. |
572 |
def test_inbranch_conversion(self): |
573 |
import_version('output', pybaz.Version(self._baz._inbranch_tag), |
|
574 |
self.collect) |
|
575 |
# expected results:
|
|
576 |
# three commits, no files, revision identifiers of
|
|
577 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
578 |
# self._baz._inbranch_tag_base_bzr
|
|
579 |
# self._baz._inbranch_tag_head_bzr
|
|
580 |
# with no merges.
|
|
581 |
branch = Branch.open('output') |
|
582 |
self.assertEqual(branch.revision_history(), |
|
583 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
584 |
self._baz._inbranch_tag_base_bzr, |
|
585 |
self._baz._inbranch_tag_head_bzr]) |
|
586 |
# and again.
|
|
587 |
import_version('output2', pybaz.Version(self._baz._inbranch_tag), |
|
588 |
self.collect) |
|
589 |
branch2 = Branch.open('output2') |
|
590 |
||
591 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
592 |
# check revisions in the history.
|
|
147.4.28
by Robert Collins
merge in storage api support. |
593 |
rev = branch.repository.get_revision(self._baz._inbranch_tag_base_bzr) |
594 |
rev2 = branch2.repository.get_revision(self._baz._inbranch_tag_base_bzr) |
|
147.4.26
by Robert Collins
Test in-branch continuations. |
595 |
# they must be the same
|
596 |
self.assertEqual(rev, rev2) |
|
597 |
# and we should get some expected values:
|
|
598 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
599 |
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--import--0--base-0") |
|
600 |
self.assertEqual(rev.revision_id, self._baz._inbranch_tag_base_bzr) |
|
601 |
||
602 |
# check next revisions in the history.
|
|
147.4.28
by Robert Collins
merge in storage api support. |
603 |
rev = branch.repository.get_revision(self._baz._inbranch_tag_head_bzr) |
604 |
rev2 = branch2.repository.get_revision(self._baz._inbranch_tag_head_bzr) |
|
147.4.26
by Robert Collins
Test in-branch continuations. |
605 |
# they must be the same
|
606 |
self.assertEqual(rev, rev2) |
|
607 |
# and we should get some expected values:
|
|
608 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
609 |
self.assertEqual(rev.message, "tag of demo@DONOTUSE/c--inbranch-tag--0--base-0") |
|
610 |
self.assertEqual(rev.revision_id, self._baz._inbranch_tag_head_bzr) |
|
611 |
self.assertEqual(rev.parent_ids, |
|
612 |
[self._baz._inbranch_tag_base_bzr]) |
|
613 |
||
147.1.7
by Robert Collins
handle inaccessible sibling archives somewhat - note version-0 is still not handled |
614 |
|
615 |
class TestNamespacePrevious(TestCase): |
|
616 |
||
617 |
def setUp(self): |
|
618 |
TestCase.setUp(self) |
|
619 |
self.version = pybaz.Version('foo@example.com/c--b--0') |
|
620 |
||
621 |
def test_base0_none(self): |
|
622 |
self.assertEqual(namespace_previous(self.version['base-0']), None) |
|
623 |
||
624 |
def test_patch1_base0(self): |
|
625 |
self.assertEqual(namespace_previous(self.version['patch-1']), |
|
626 |
self.version['base-0']) |
|
627 |
||
628 |
def test_patch3000_patch2999(self): |
|
629 |
self.assertEqual(namespace_previous(self.version['patch-3000']), |
|
630 |
self.version['patch-2999']) |
|
631 |
||
632 |
def test_version0_raises(self): |
|
633 |
self.assertRaises(RuntimeError, namespace_previous, |
|
634 |
self.version['version-0']) |
|
635 |
||
636 |
def test_version1_version0(self): |
|
147.1.29
by Robert Collins
update to latest bzr api |
637 |
self.assertEqual(namespace_previous(self.version['versionfix-1']), |
147.1.7
by Robert Collins
handle inaccessible sibling archives somewhat - note version-0 is still not handled |
638 |
self.version['version-0']) |
147.1.8
by Robert Collins
handle version-xxx and base-0 correctly in namespace_previous |
639 |
|
640 |
def test_version3000_patch2999(self): |
|
147.1.29
by Robert Collins
update to latest bzr api |
641 |
self.assertEqual(namespace_previous(self.version['versionfix-3000']), |
642 |
self.version['versionfix-2999']) |
|
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
643 |
|
147.1.13
by Robert Collins
create the output directory |
644 |
class TestNamespaceMapping(TestCase): |
645 |
||
646 |
def test_namespace_mapping_branch(self): |
|
147.1.37
by Robert Collins
get all tests passing again, and disable importing the body of continuation log messages |
647 |
from bzrlib.plugins.bzrtools.baz_import import map_namespace |
147.1.13
by Robert Collins
create the output directory |
648 |
branch = pybaz.Branch('foo@example.com/c--b') |
147.1.14
by Robert Collins
implement a namespace mapper |
649 |
self.assertRaises(pybaz.errors.NamespaceError, map_namespace, branch) |
147.1.13
by Robert Collins
create the output directory |
650 |
self.assertEqual('c/b', map_namespace(branch['0'])) |
651 |
self.assertEqual('c/0.1/b', map_namespace(branch['0.1'])) |
|
652 |
||
653 |
def test_namespace_mapping_no_branch(self): |
|
147.1.37
by Robert Collins
get all tests passing again, and disable importing the body of continuation log messages |
654 |
from bzrlib.plugins.bzrtools.baz_import import map_namespace |
147.1.13
by Robert Collins
create the output directory |
655 |
category = pybaz.Category('foo@example.com/c') |
147.1.14
by Robert Collins
implement a namespace mapper |
656 |
self.assertRaises(pybaz.errors.NamespaceError, map_namespace, category) |
657 |
self.assertEqual('c/+trunk', |
|
658 |
map_namespace(pybaz.Version("%s--0" % category))) |
|
659 |
self.assertEqual('c/0.1/+trunk', |
|
660 |
map_namespace(pybaz.Version('%s--0.1' % category))) |
|
147.1.13
by Robert Collins
create the output directory |
661 |
|
147.1.12
by Robert Collins
create the output directory |
662 |
|
147.4.1
by Robert Collins
test escaping of file ids is working |
663 |
class TestFileIdMapping(TestCase): |
664 |
||
665 |
def test_slash(self): |
|
666 |
from bzrlib.plugins.bzrtools.baz_import import map_file_id |
|
667 |
self.assertEqual('c%2fc', map_file_id('c/c')) |
|
668 |
self.assertEqual('c%25c', map_file_id('c%c')) |
|
669 |
||
670 |
||
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
671 |
class TestImport(TestCaseInTempDir): |
672 |
||
147.1.15
by Robert Collins
archive at a time imports |
673 |
def setUp(self): |
674 |
TestCaseInTempDir.setUp(self) |
|
675 |
self._oldhome = os.environ['HOME'] |
|
676 |
self._tmpdir = tempfile.mkdtemp() |
|
677 |
self._homedir = os.path.join(self._tmpdir, 'home') |
|
678 |
os.mkdir(self._homedir) |
|
679 |
os.environ['HOME'] = self._homedir |
|
680 |
self._archiveroot = os.path.join(self._tmpdir, 'archive') |
|
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
681 |
self._archive = make_archive('demo@DONOTUSE', str(self._archiveroot)) |
147.1.15
by Robert Collins
archive at a time imports |
682 |
|
683 |
def tearDown(self): |
|
684 |
os.environ['HOME'] = self._oldhome |
|
685 |
shutil.rmtree(self._tmpdir) |
|
686 |
TestCaseInTempDir.tearDown(self) |
|
687 |
||
688 |
def make_import(self, namespace): |
|
689 |
self._import = 'demo@DONOTUSE/%s' % namespace |
|
690 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
691 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
692 |
self._import) |
|
147.1.15
by Robert Collins
archive at a time imports |
693 |
msg = tree.log_message() |
694 |
msg["summary"] = "I am importing now" |
|
695 |
tree.import_(msg) |
|
696 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
697 |
||
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
698 |
def test_cmd_exists(self): |
147.1.37
by Robert Collins
get all tests passing again, and disable importing the body of continuation log messages |
699 |
from bzrlib.plugins.bzrtools.baz_import import cmd_baz_import |
147.1.12
by Robert Collins
create the output directory |
700 |
|
701 |
def test_empty_archive(self): |
|
147.1.15
by Robert Collins
archive at a time imports |
702 |
command = cmd_baz_import() |
703 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
704 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output'))) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
705 |
walk_len = len(list(os.walk(os.path.join(self._tmpdir,'output')))) |
328
by Aaron Bentley
Adjust number in bzr selftest |
706 |
self.assertEqual(7, walk_len) |
147.1.12
by Robert Collins
create the output directory |
707 |
|
147.1.15
by Robert Collins
archive at a time imports |
708 |
def test_two_branches(self): |
709 |
self.make_import('c--0') |
|
710 |
self.make_import('c1--branch--0.2') |
|
711 |
command = cmd_baz_import() |
|
712 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
713 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output'))) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
714 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', |
715 |
'c','+trunk'))) |
|
716 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', |
|
717 |
'c1', '0.2','branch'))) |
|
718 |
walk_len = len(list(os.walk(os.path.join(self._tmpdir,'output')))) |
|
147.1.73
by Aaron Bentley
Updated number of files expected by test_two_branches |
719 |
self.assertEqual(22, walk_len) |
147.1.18
by Robert Collins
baz-import twice should work |
720 |
|
721 |
def test_run_twice(self): |
|
722 |
self.make_import('c--0') |
|
723 |
command = cmd_baz_import() |
|
724 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
725 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
147.4.8
by Robert Collins
Enable reuse of history on archive imports, just append the history locations to the command line |
726 |
|
727 |
def test_accepts_reuse_history(self): |
|
728 |
self.make_import('c--0') |
|
729 |
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'), |
|
730 |
'demo@DONOTUSE', '.', '.') |
|
147.4.9
by Robert Collins
But do not require a history location. |
731 |
|
732 |
def test_does_not_need_reuse_history(self): |
|
733 |
self.make_import('c--0') |
|
734 |
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'), |
|
735 |
'demo@DONOTUSE') |