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.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
118 |
|
119 |
def make_import_symlink(self): |
|
120 |
self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0' |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
121 |
self._import_symlink_bzr = revision_id( |
122 |
self._import_symlink + '--base-0') |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
123 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
124 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
|
125 |
self._import_symlink) |
|
126 |
os.symlink('missing-file-name', |
|
127 |
os.path.join(self._tmpdir, 'tree', 'alink')) |
|
128 |
tree.add_tag('alink') |
|
129 |
id_file = open(os.path.join(tree, '.arch-ids', 'alink.id'), 'w') |
|
130 |
id_file.write('symlink_tag\n') |
|
131 |
id_file.close() |
|
132 |
msg = tree.log_message() |
|
133 |
msg["summary"] = "Import with a symlink" |
|
134 |
tree.import_(msg) |
|
135 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
136 |
||
137 |
def make_empty_import(self): |
|
138 |
self._import = 'demo@DONOTUSE/c--import--0' |
|
139 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
140 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
141 |
self._import) |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
142 |
msg = tree.log_message() |
143 |
msg["summary"] = "I am importing now" |
|
144 |
tree.import_(msg) |
|
145 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
146 |
|
147.1.20
by Robert Collins
handle missing ancestry |
147 |
def make_missing_ancestor(self): |
148 |
self._archivegoneroot = os.path.join(self._tmpdir, 'archivegone') |
|
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
149 |
self._archive = make_archive('demo-gone@DONOTUSE', |
150 |
str(self._archivegoneroot)) |
|
147.1.20
by Robert Collins
handle missing ancestry |
151 |
self._missing_import = 'demo-gone@DONOTUSE/c--import--0' |
152 |
self._missing_import_bzr = revision_id(self._missing_import |
|
153 |
+ '--base-0') |
|
154 |
self._missing_ancestor = 'demo@DONOTUSE/c--gone--0' |
|
155 |
self._missing_ancestor_bzr = revision_id(self._missing_ancestor |
|
156 |
+ '--base-0') |
|
157 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
158 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
|
159 |
self._missing_import) |
|
160 |
msg = tree.log_message() |
|
161 |
msg["summary"] = "I am importing now" |
|
162 |
tree.import_(msg) |
|
163 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
164 |
# tag into the kept archive
|
|
165 |
pybaz.Revision(self._missing_import + '--base-0').make_continuation( |
|
166 |
pybaz.Version(self._missing_ancestor)) |
|
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
167 |
|
168 |
# make an import for testing history-reuse logic.
|
|
169 |
def collect(text): |
|
170 |
pass
|
|
171 |
# note the use of a namespace layout here.
|
|
172 |
self._missing_import_imported = os.path.join(self._tmpdir, |
|
173 |
'archivegone-bzr') |
|
174 |
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr')) |
|
175 |
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c')) |
|
176 |
import_version(os.path.join(self._tmpdir, 'archivegone-bzr', |
|
177 |
'c', 'import'), |
|
178 |
pybaz.Version(self._missing_import), |
|
179 |
collect) |
|
147.1.20
by Robert Collins
handle missing ancestry |
180 |
# and make it inaccessible
|
181 |
pybaz.Archive('demo-gone@DONOTUSE').unregister() |
|
182 |
||
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
183 |
@classmethod
|
184 |
def _makeResource(self): |
|
185 |
return BazTreeResource() |
|
186 |
||
187 |
@classmethod
|
|
188 |
def _cleanResource(self, resource): |
|
189 |
resource.cleanUp() |
|
190 |
||
191 |
||
147.1.12
by Robert Collins
create the output directory |
192 |
class TestImportBranch(TestCaseInTempDir): |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
193 |
|
194 |
_resources = [("_baz", BazTreeResource)] |
|
195 |
||
196 |
def setUp(self): |
|
197 |
TestCaseInTempDir.setUp(self) |
|
198 |
ResourcedTestCase.setUpResources(self) |
|
147.1.36
by Robert Collins
updates for bzr api changes |
199 |
os.environ['HOME'] = self._baz._homedir |
147.1.17
by Robert Collins
make feedback be callback based - really |
200 |
self.output = StringIO() |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
201 |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
202 |
def tearDown(self): |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
203 |
ResourcedTestCase.tearDownResources(self) |
204 |
TestCaseInTempDir.tearDown(self) |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
205 |
|
206 |
def collect(self, text): |
|
207 |
self.output.write(text) |
|
208 |
self.output.write("\n") |
|
209 |
||
147.1.2
by Robert Collins
test empty import and tagged branches |
210 |
def test_import_empty(self): |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
211 |
import_version('output', pybaz.Version(self._baz._import), |
212 |
self.collect) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
213 |
# expected results:
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
214 |
# one commit, no files, revision identifier of
|
215 |
# 'demo@DONOTUSE_c--import--0--base-0'
|
|
147.1.29
by Robert Collins
update to latest bzr api |
216 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
217 |
repo = branch.repository |
147.1.2
by Robert Collins
test empty import and tagged branches |
218 |
self.assertEqual(branch.revision_history(), |
219 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
220 |
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 |
221 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
222 |
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'), |
223 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
224 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
225 |
repo2 = branch2.repository |
147.1.2
by Robert Collins
test empty import and tagged branches |
226 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
227 |
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 |
228 |
# they must be the same
|
229 |
self.assertEqual(rev, rev2) |
|
230 |
||
231 |
# and we should get some expected values:
|
|
232 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
233 |
self.assertEqual(rev.message, "I am importing now") |
|
234 |
self.assertEqual(rev.revision_id, |
|
235 |
"Arch-1:demo@DONOTUSE%c--import--0--base-0") |
|
236 |
||
237 |
def test_empty_tagged(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
238 |
import_version('output', pybaz.Version(self._baz._empty_tag), |
239 |
self.collect) |
|
147.1.2
by Robert Collins
test empty import and tagged branches |
240 |
# expected results:
|
241 |
# two commits, no files, revision identifiers of
|
|
242 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
243 |
# self._baz._empty_tag_bzr
|
147.1.29
by Robert Collins
update to latest bzr api |
244 |
branch = Branch.open('output') |
147.1.2
by Robert Collins
test empty import and tagged branches |
245 |
self.assertEqual(branch.revision_history(), |
246 |
['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 |
247 |
self._baz._empty_tag_bzr]) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
248 |
rev = branch.repository.get_revision(self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
249 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
250 |
import_version('output2', pybaz.Version(self._baz._empty_tag), |
251 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
252 |
branch2 = Branch.open('output2') |
147.1.2
by Robert Collins
test empty import and tagged branches |
253 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
254 |
rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
255 |
# they must be the same
|
256 |
self.assertEqual(rev, rev2) |
|
257 |
||
258 |
# and we should get some expected values:
|
|
259 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
260 |
self.assertEqual(rev.message, |
261 |
"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 |
262 |
self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr) |
147.1.2
by Robert Collins
test empty import and tagged branches |
263 |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
264 |
def test_empty_merged_tagged(self): |
147.1.17
by Robert Collins
make feedback be callback based - really |
265 |
import_version('output', pybaz.Version(self._baz._empty_merged_tag), |
266 |
self.collect) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
267 |
# expected results:
|
268 |
# two commits, no files, revision identifiers of
|
|
269 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
270 |
# self._baz._empty_merged_tag_bzr_base
|
271 |
# 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 |
272 |
# and a merged revision from the latter of
|
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
273 |
# self._baz._empty_tag_bzr
|
147.1.29
by Robert Collins
update to latest bzr api |
274 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
275 |
repo = branch.repository |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
276 |
self.assertEqual(branch.revision_history(), |
277 |
['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 |
278 |
self._baz._empty_merged_tag_bzr_base, |
279 |
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 |
280 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
281 |
import_version('output2', pybaz.Version(self._baz._empty_merged_tag), |
282 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
283 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
284 |
repo2 = branch2.repository |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
285 |
# and import what we should be merged up against for checking with.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
286 |
import_version('output3', pybaz.Version(self._baz._empty_tag), |
287 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
288 |
branch3 = Branch.open('output3') |
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
289 |
|
290 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
291 |
self.assertNotEqual(branch.revision_history(), |
292 |
branch3.revision_history()) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
293 |
# check revisions in the history.
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
294 |
rev = repo.get_revision(self._baz._empty_merged_tag_bzr_base) |
295 |
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 |
296 |
# they must be the same
|
297 |
self.assertEqual(rev, rev2) |
|
298 |
# and we should get some expected values:
|
|
299 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
300 |
self.assertEqual(rev.message, |
301 |
"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 |
302 |
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 |
303 |
self.assertEqual(['Arch-1:demo@DONOTUSE%c--import--0--base-0'], |
304 |
rev.parent_ids) |
|
147.1.3
by Robert Collins
test and deliver basic pending-merges into bzr so that merging is recorded |
305 |
|
306 |
# check next revisions in the history.
|
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
307 |
rev = repo.get_revision(self._baz._empty_merged_tag_bzr) |
308 |
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 |
309 |
# they must be the same
|
310 |
self.assertEqual(rev, rev2) |
|
311 |
# and we should get some expected values:
|
|
312 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
313 |
self.assertEqual(rev.message, "did a merge, yarh") |
|
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) |
147.1.31
by Robert Collins
update to weave api |
315 |
self.assertEqual(rev.parent_ids[0], |
147.1.4
by Robert Collins
start using testresources to coordinate import tests, saves 10 seconds |
316 |
self._baz._empty_merged_tag_bzr_base) |
147.1.31
by Robert Collins
update to weave api |
317 |
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 |
318 |
|
319 |
# this tree should have nothing missing from that tree.
|
|
320 |
# FIXME there is no code for this right now.
|
|
321 |
# self.assertEqual(branch.missing_revisions(branch3), [])
|
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
322 |
|
323 |
def test_merge_branch_with_merges(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
324 |
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2), |
325 |
self.collect) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
326 |
# expected results:
|
327 |
# two commits, no files, revision identifiers of
|
|
328 |
# 'demo@DONOTUSE_c--import--0--base-0' and
|
|
329 |
# self._baz._empty_merged_tag_2_bzr_base
|
|
330 |
# self._baz._empty_merged_tag_2_bzr
|
|
331 |
# and a merged revision from the latter of
|
|
332 |
# self._baz._empty_merged_tag_bzr
|
|
147.1.29
by Robert Collins
update to latest bzr api |
333 |
branch = Branch.open('output') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
334 |
repo = branch.repository |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
335 |
self.assertEqual(branch.revision_history(), |
336 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
337 |
self._baz._empty_merged_tag_2_bzr_base, |
|
338 |
self._baz._empty_merged_tag_2_bzr]) |
|
339 |
# and again.
|
|
147.1.17
by Robert Collins
make feedback be callback based - really |
340 |
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2), |
341 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
342 |
branch2 = Branch.open('output2') |
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
343 |
repo2 = branch2.repository |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
344 |
# and import what we should be merged up against for checking with.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
345 |
import_version('output3', pybaz.Version(self._baz._empty_merged_tag), |
346 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
347 |
branch3 = Branch.open('output3') |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
348 |
|
349 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
350 |
self.assertNotEqual(branch.revision_history(), |
351 |
branch3.revision_history()) |
|
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
352 |
# check revisions in the history.
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
353 |
rev = repo.get_revision(self._baz._empty_merged_tag_2_bzr_base) |
354 |
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 |
355 |
# they must be the same
|
356 |
self.assertEqual(rev, rev2) |
|
357 |
# and we should get some expected values:
|
|
358 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
359 |
self.assertEqual(rev.message, |
360 |
"tag of demo@DONOTUSE/c--import--0--base-0") |
|
361 |
self.assertEqual(rev.revision_id, |
|
362 |
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 |
363 |
|
364 |
# check next 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) |
366 |
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 |
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>") |
|
371 |
self.assertEqual(rev.message, "merge in a merged tree.") |
|
372 |
self.assertEqual(rev.revision_id, self._baz._empty_merged_tag_2_bzr) |
|
147.1.31
by Robert Collins
update to weave api |
373 |
self.assertEqual(rev.parent_ids[0], |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
374 |
self._baz._empty_merged_tag_2_bzr_base) |
147.1.31
by Robert Collins
update to weave api |
375 |
self.assertEqual(rev.parent_ids[1], |
147.1.5
by Robert Collins
test and implement direct merge support of 2-in-a-row patches |
376 |
self._baz._empty_merged_tag_bzr) |
377 |
||
378 |
# this tree should have nothing missing from that tree.
|
|
379 |
# FIXME there is no code for this right now.
|
|
380 |
# self.assertEqual(branch.missing_revisions(branch3), [])
|
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
381 |
|
382 |
def test_import_symlink(self): |
|
147.1.17
by Robert Collins
make feedback be callback based - really |
383 |
import_version('output', pybaz.Version(self._baz._import_symlink), |
384 |
self.collect) |
|
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
385 |
# expected results:
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
386 |
# one commit, no files, revision identifier of
|
387 |
# 'demo@DONOTUSE_c--import--0--base-0'
|
|
147.1.29
by Robert Collins
update to latest bzr api |
388 |
branch = Branch.open('output') |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
389 |
self.assertEqual(branch.revision_history(), |
390 |
[self._baz._import_symlink_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
391 |
rev = branch.repository.get_revision(self._baz._import_symlink_bzr) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
392 |
# and again.
|
147.1.17
by Robert Collins
make feedback be callback based - really |
393 |
import_version('output2', pybaz.Version(self._baz._import_symlink), |
394 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
395 |
branch2 = Branch.open('output2') |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
396 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
397 |
rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
398 |
# they must be the same
|
399 |
self.assertEqual(rev, rev2) |
|
400 |
||
401 |
# and we should get some expected values:
|
|
402 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
403 |
self.assertEqual(rev.message, "Import with a symlink") |
|
404 |
self.assertEqual(rev.revision_id, self._baz._import_symlink_bzr) |
|
405 |
||
406 |
# and we want the symlink alink with target 'missing-file-name'
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
407 |
inv = branch.repository.get_inventory(rev.revision_id) |
147.1.6
by Robert Collins
import symlinks (needs symlink enabled bzr) |
408 |
self.assertEqual(inv.path2id('alink'), 'x_symlink_tag') |
409 |
entry = inv['x_symlink_tag'] |
|
410 |
self.assertEqual(entry.kind, 'symlink') |
|
411 |
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 |
412 |
|
147.1.20
by Robert Collins
handle missing ancestry |
413 |
def test_missing_ancestor(self): |
414 |
import_version('output', pybaz.Version(self._baz._missing_ancestor), |
|
415 |
self.collect) |
|
416 |
# expected results:
|
|
417 |
# one commits, no files, revision identifiers of
|
|
418 |
# 'demo@DONOTUSE_c--gone--0--base-0' and
|
|
419 |
# a merge of demo-gone@DONOTUSE%c--import--0
|
|
147.1.29
by Robert Collins
update to latest bzr api |
420 |
branch = Branch.open('output') |
147.1.20
by Robert Collins
handle missing ancestry |
421 |
self.assertEqual(branch.revision_history(), |
422 |
[self._baz._missing_ancestor_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
423 |
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.1.20
by Robert Collins
handle missing ancestry |
424 |
# and again.
|
425 |
import_version('output2', pybaz.Version(self._baz._missing_ancestor), |
|
426 |
self.collect) |
|
147.1.29
by Robert Collins
update to latest bzr api |
427 |
branch2 = Branch.open('output2') |
147.1.20
by Robert Collins
handle missing ancestry |
428 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
429 |
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr) |
147.1.20
by Robert Collins
handle missing ancestry |
430 |
# they must be the same
|
431 |
self.assertEqual(rev, rev2) |
|
432 |
||
433 |
# and we should get some expected values:
|
|
434 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
435 |
self.assertEqual(rev.message, |
436 |
"tag of demo-gone@DONOTUSE/c--import--0--base-0") |
|
147.1.20
by Robert Collins
handle missing ancestry |
437 |
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr) |
147.1.31
by Robert Collins
update to weave api |
438 |
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr) |
439 |
self.assertEqual(1, len(rev.parent_ids)) |
|
147.1.20
by Robert Collins
handle missing ancestry |
440 |
|
441 |
# must NOT be able to get the merged evision
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
442 |
self.assertRaises(NoSuchRevision, branch.repository.get_revision, |
147.1.20
by Robert Collins
handle missing ancestry |
443 |
self._baz._missing_import_bzr) |
444 |
||
147.4.6
by Robert Collins
Fix continuation direct_merges output, and allow reusing history in a version import |
445 |
def test_missing_ancestor_reusing_history(self): |
446 |
import_version('output', pybaz.Version(self._baz._missing_ancestor), |
|
447 |
self.collect, |
|
448 |
reuse_history_from=[self._baz._missing_import_imported]) |
|
449 |
# expected results:
|
|
450 |
# one commits, no files, revision identifiers of
|
|
451 |
# 'demo-gone@DONOTUSE%c--import--0--base-0' and
|
|
452 |
# 'demo@DONOTUSE%c--gone--0--base-0'
|
|
453 |
branch = Branch.open('output') |
|
454 |
self.assertEqual(branch.revision_history(), |
|
455 |
[self._baz._missing_import_bzr, |
|
456 |
self._baz._missing_ancestor_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
457 |
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 |
458 |
# and again.
|
459 |
import_version('output2', pybaz.Version(self._baz._missing_ancestor), |
|
460 |
self.collect, |
|
461 |
reuse_history_from=[self._baz._missing_import_imported]) |
|
462 |
branch2 = Branch.open('output2') |
|
463 |
self.assertEqual(branch.revision_history(), branch2.revision_history()) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
464 |
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 |
465 |
# they must be the same
|
466 |
self.assertEqual(rev, rev2) |
|
467 |
||
468 |
# must be able to get the missing base revision
|
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
469 |
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 |
470 |
|
471 |
# and we should get some expected values:
|
|
472 |
self.assertEqual(rev.committer, "Test User<test@example.org>") |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
473 |
self.assertEqual(rev.message, |
474 |
"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 |
475 |
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr) |
476 |
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr) |
|
477 |
self.assertEqual(1, len(rev.parent_ids)) |
|
478 |
||
147.4.1
by Robert Collins
test escaping of file ids is working |
479 |
def test_bad_file_id(self): |
480 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
481 |
self.collect) |
|
482 |
# expected results:
|
|
483 |
# three commits, one files, revision identifiers of
|
|
484 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
485 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
486 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
487 |
branch = Branch.open('output') |
|
488 |
self.assertEqual(branch.revision_history(), |
|
489 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
490 |
self._baz._bad_id_tag_bzr_base, |
|
491 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
492 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
493 |
inv = branch.repository.get_inventory(self._baz._bad_id_tag_bzr) |
|
147.4.1
by Robert Collins
test escaping of file ids is working |
494 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
495 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
496 |
||
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 |
497 |
def test_appending_revisions_already_present(self): |
498 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
499 |
self.collect, max_count=2) |
|
500 |
# expected results:
|
|
501 |
# three commits, one files, revision identifiers of
|
|
502 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
503 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
504 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
505 |
branch = Branch.open('output') |
|
506 |
self.assertEqual(branch.revision_history(), |
|
507 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
508 |
self._baz._bad_id_tag_bzr_base]) |
|
509 |
branch.set_revision_history( |
|
510 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
511 |
del branch |
|
512 |
branch = Branch.open('output') |
|
513 |
self.assertEqual(branch.revision_history(), |
|
514 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
515 |
del branch |
|
516 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
517 |
self.collect) |
|
518 |
branch = Branch.open('output') |
|
519 |
self.assertEqual(branch.revision_history(), |
|
520 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
521 |
self._baz._bad_id_tag_bzr_base, |
|
522 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
523 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
524 |
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 |
525 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
526 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
527 |
||
528 |
def test_appending_revisions_all_already_present(self): |
|
529 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
530 |
self.collect) |
|
531 |
# expected results:
|
|
532 |
# three commits, one files, revision identifiers of
|
|
533 |
# 'demo@DONOTUSE_c--import--0--base-0' ,
|
|
534 |
# 'demo@DONOTUSE/c--bad-id--0--base-0' ,
|
|
535 |
# ''demo@DONOTUSE/c--bad-id--0--patch-1'
|
|
536 |
branch = Branch.open('output') |
|
537 |
self.assertEqual(branch.revision_history(), |
|
538 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
539 |
self._baz._bad_id_tag_bzr_base, |
|
540 |
self._baz._bad_id_tag_bzr]) |
|
541 |
branch.set_revision_history( |
|
542 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
543 |
del branch |
|
544 |
branch = Branch.open('output') |
|
545 |
self.assertEqual(branch.revision_history(), |
|
546 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0']) |
|
547 |
del branch |
|
548 |
import_version('output', pybaz.Version(self._baz._bad_id_tag), |
|
549 |
self.collect) |
|
550 |
branch = Branch.open('output') |
|
551 |
self.assertEqual(branch.revision_history(), |
|
552 |
['Arch-1:demo@DONOTUSE%c--import--0--base-0', |
|
553 |
self._baz._bad_id_tag_bzr_base, |
|
554 |
self._baz._bad_id_tag_bzr]) |
|
147.1.55
by Aaron Bentley
Got imports working, via a big hammer |
555 |
rev = branch.repository.get_revision(self._baz._bad_id_tag_bzr) |
556 |
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 |
557 |
self.assertEqual(inv.path2id('path'), 'x_this_id%2fneeds%25escaping') |
558 |
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping')) |
|
559 |
||
147.1.7
by Robert Collins
handle inaccessible sibling archives somewhat - note version-0 is still not handled |
560 |
|
561 |
class TestNamespacePrevious(TestCase): |
|
562 |
||
563 |
def setUp(self): |
|
564 |
TestCase.setUp(self) |
|
565 |
self.version = pybaz.Version('foo@example.com/c--b--0') |
|
566 |
||
567 |
def test_base0_none(self): |
|
568 |
self.assertEqual(namespace_previous(self.version['base-0']), None) |
|
569 |
||
570 |
def test_patch1_base0(self): |
|
571 |
self.assertEqual(namespace_previous(self.version['patch-1']), |
|
572 |
self.version['base-0']) |
|
573 |
||
574 |
def test_patch3000_patch2999(self): |
|
575 |
self.assertEqual(namespace_previous(self.version['patch-3000']), |
|
576 |
self.version['patch-2999']) |
|
577 |
||
578 |
def test_version0_raises(self): |
|
579 |
self.assertRaises(RuntimeError, namespace_previous, |
|
580 |
self.version['version-0']) |
|
581 |
||
582 |
def test_version1_version0(self): |
|
147.1.29
by Robert Collins
update to latest bzr api |
583 |
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 |
584 |
self.version['version-0']) |
147.1.8
by Robert Collins
handle version-xxx and base-0 correctly in namespace_previous |
585 |
|
586 |
def test_version3000_patch2999(self): |
|
147.1.29
by Robert Collins
update to latest bzr api |
587 |
self.assertEqual(namespace_previous(self.version['versionfix-3000']), |
588 |
self.version['versionfix-2999']) |
|
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
589 |
|
147.1.13
by Robert Collins
create the output directory |
590 |
class TestNamespaceMapping(TestCase): |
591 |
||
592 |
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 |
593 |
from bzrlib.plugins.bzrtools.baz_import import map_namespace |
147.1.13
by Robert Collins
create the output directory |
594 |
branch = pybaz.Branch('foo@example.com/c--b') |
147.1.14
by Robert Collins
implement a namespace mapper |
595 |
self.assertRaises(pybaz.errors.NamespaceError, map_namespace, branch) |
147.1.13
by Robert Collins
create the output directory |
596 |
self.assertEqual('c/b', map_namespace(branch['0'])) |
597 |
self.assertEqual('c/0.1/b', map_namespace(branch['0.1'])) |
|
598 |
||
599 |
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 |
600 |
from bzrlib.plugins.bzrtools.baz_import import map_namespace |
147.1.13
by Robert Collins
create the output directory |
601 |
category = pybaz.Category('foo@example.com/c') |
147.1.14
by Robert Collins
implement a namespace mapper |
602 |
self.assertRaises(pybaz.errors.NamespaceError, map_namespace, category) |
603 |
self.assertEqual('c/+trunk', |
|
604 |
map_namespace(pybaz.Version("%s--0" % category))) |
|
605 |
self.assertEqual('c/0.1/+trunk', |
|
606 |
map_namespace(pybaz.Version('%s--0.1' % category))) |
|
147.1.13
by Robert Collins
create the output directory |
607 |
|
147.1.12
by Robert Collins
create the output directory |
608 |
|
147.4.1
by Robert Collins
test escaping of file ids is working |
609 |
class TestFileIdMapping(TestCase): |
610 |
||
611 |
def test_slash(self): |
|
612 |
from bzrlib.plugins.bzrtools.baz_import import map_file_id |
|
613 |
self.assertEqual('c%2fc', map_file_id('c/c')) |
|
614 |
self.assertEqual('c%25c', map_file_id('c%c')) |
|
615 |
||
616 |
||
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
617 |
class TestImport(TestCaseInTempDir): |
618 |
||
147.1.15
by Robert Collins
archive at a time imports |
619 |
def setUp(self): |
620 |
TestCaseInTempDir.setUp(self) |
|
621 |
self._oldhome = os.environ['HOME'] |
|
622 |
self._tmpdir = tempfile.mkdtemp() |
|
623 |
self._homedir = os.path.join(self._tmpdir, 'home') |
|
624 |
os.mkdir(self._homedir) |
|
625 |
os.environ['HOME'] = self._homedir |
|
626 |
self._archiveroot = os.path.join(self._tmpdir, 'archive') |
|
147.1.60
by Aaron Bentley
Stopped using deprecated PyBaz functionality |
627 |
self._archive = make_archive('demo@DONOTUSE', str(self._archiveroot)) |
147.1.15
by Robert Collins
archive at a time imports |
628 |
|
629 |
def tearDown(self): |
|
630 |
os.environ['HOME'] = self._oldhome |
|
631 |
shutil.rmtree(self._tmpdir) |
|
632 |
TestCaseInTempDir.tearDown(self) |
|
633 |
||
634 |
def make_import(self, namespace): |
|
635 |
self._import = 'demo@DONOTUSE/%s' % namespace |
|
636 |
os.mkdir(os.path.join(self._tmpdir, 'tree')) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
637 |
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), |
638 |
self._import) |
|
147.1.15
by Robert Collins
archive at a time imports |
639 |
msg = tree.log_message() |
640 |
msg["summary"] = "I am importing now" |
|
641 |
tree.import_(msg) |
|
642 |
shutil.rmtree(os.path.join(self._tmpdir, 'tree')) |
|
643 |
||
147.1.11
by Robert Collins
move baz-import to baz-import-branch |
644 |
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 |
645 |
from bzrlib.plugins.bzrtools.baz_import import cmd_baz_import |
147.1.12
by Robert Collins
create the output directory |
646 |
|
647 |
def test_empty_archive(self): |
|
147.1.15
by Robert Collins
archive at a time imports |
648 |
command = cmd_baz_import() |
649 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
650 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output'))) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
651 |
walk_len = len(list(os.walk(os.path.join(self._tmpdir,'output')))) |
652 |
self.assertEqual(1, walk_len) |
|
147.1.12
by Robert Collins
create the output directory |
653 |
|
147.1.15
by Robert Collins
archive at a time imports |
654 |
def test_two_branches(self): |
655 |
self.make_import('c--0') |
|
656 |
self.make_import('c1--branch--0.2') |
|
657 |
command = cmd_baz_import() |
|
658 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
659 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output'))) |
|
147.1.57
by Aaron Bentley
Cleaned up baz_import and tests |
660 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', |
661 |
'c','+trunk'))) |
|
662 |
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output', |
|
663 |
'c1', '0.2','branch'))) |
|
664 |
walk_len = len(list(os.walk(os.path.join(self._tmpdir,'output')))) |
|
665 |
self.assertEqual(14, walk_len) |
|
147.1.18
by Robert Collins
baz-import twice should work |
666 |
|
667 |
def test_run_twice(self): |
|
668 |
self.make_import('c--0') |
|
669 |
command = cmd_baz_import() |
|
670 |
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE') |
|
671 |
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 |
672 |
|
673 |
def test_accepts_reuse_history(self): |
|
674 |
self.make_import('c--0') |
|
675 |
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'), |
|
676 |
'demo@DONOTUSE', '.', '.') |
|
147.4.9
by Robert Collins
But do not require a history location. |
677 |
|
678 |
def test_does_not_need_reuse_history(self): |
|
679 |
self.make_import('c--0') |
|
680 |
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'), |
|
681 |
'demo@DONOTUSE') |