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