175
175
self._archive = make_archive('demo-gone@DONOTUSE',
176
176
str(self._archivegoneroot))
177
177
self._missing_import = 'demo-gone@DONOTUSE/c--import--0'
178
self._missing_import_bzr = revision_id(self._missing_import
178
self._missing_import_bzr = revision_id(self._missing_import
179
179
+ '--base-0', None)
180
180
self._missing_ancestor = 'demo@DONOTUSE/c--gone--0'
181
self._missing_ancestor_bzr = revision_id(self._missing_ancestor
181
self._missing_ancestor_bzr = revision_id(self._missing_ancestor
182
182
+ '--base-0', None)
183
183
os.mkdir(os.path.join(self._tmpdir, 'tree'))
184
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
184
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
185
185
self._missing_import)
186
186
msg = tree.log_message()
187
187
msg["summary"] = "I am importing now"
194
194
# make an import for testing history-reuse logic.
195
195
# note the use of a namespace layout here.
196
self._missing_import_imported = os.path.join(self._tmpdir,
196
self._missing_import_imported = os.path.join(self._tmpdir,
197
197
'archivegone-bzr')
198
198
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr'))
199
199
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c'))
200
import_version(os.path.join(self._tmpdir, 'archivegone-bzr',
200
import_version(os.path.join(self._tmpdir, 'archivegone-bzr',
202
202
pybaz.Version(self._missing_import), None)
203
203
# and make it inaccessible
300
300
# and we should get some expected values:
301
301
self.assertEqual(rev.committer, "Test User<test@example.org>")
302
self.assertEqual(rev.message,
302
self.assertEqual(rev.message,
303
303
"tag of demo@DONOTUSE/c--import--0--base-0")
304
304
self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr)
306
306
def test_empty_merged_tagged(self):
307
import_version('output', pybaz.Version(self._baz._empty_merged_tag),
307
import_version('output', pybaz.Version(self._baz._empty_merged_tag),
309
309
# expected results:
310
# two commits, no files, revision identifiers of
310
# two commits, no files, revision identifiers of
311
311
# 'demo@DONOTUSE_c--import--0--base-0' and
312
312
# self._baz._empty_merged_tag_bzr_base
313
313
# self._baz._empty_merged_tag_bzr
320
320
self._baz._empty_merged_tag_bzr_base,
321
321
self._baz._empty_merged_tag_bzr])
323
import_version('output2', pybaz.Version(self._baz._empty_merged_tag),
323
import_version('output2', pybaz.Version(self._baz._empty_merged_tag),
325
325
branch2 = Branch.open('output2')
326
326
repo2 = branch2.repository
327
327
# and import what we should be merged up against for checking with.
328
328
import_version('output3', pybaz.Version(self._baz._empty_tag), None)
329
329
branch3 = Branch.open('output3')
331
331
self.assertEqual(branch.revision_history(), branch2.revision_history())
332
self.assertNotEqual(branch.revision_history(),
332
self.assertNotEqual(branch.revision_history(),
333
333
branch3.revision_history())
334
334
# check revisions in the history.
335
335
rev = repo.get_revision(self._baz._empty_merged_tag_bzr_base)
357
357
self._baz._empty_merged_tag_bzr_base)
358
358
self.assertEqual(rev.parent_ids[1], self._baz._empty_tag_bzr)
360
# this tree should have nothing missing from that tree.
360
# this tree should have nothing missing from that tree.
361
361
# FIXME there is no code for this right now.
362
362
# self.assertEqual(branch.missing_revisions(branch3), [])
364
364
def test_merge_branch_with_merges(self):
365
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2),
365
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2),
367
367
# expected results:
368
# two commits, no files, revision identifiers of
368
# two commits, no files, revision identifiers of
369
369
# 'demo@DONOTUSE_c--import--0--base-0' and
370
370
# self._baz._empty_merged_tag_2_bzr_base
371
371
# self._baz._empty_merged_tag_2_bzr
416
416
self.assertEqual(rev.parent_ids[1],
417
417
self._baz._empty_merged_tag_bzr)
419
# this tree should have nothing missing from that tree.
419
# this tree should have nothing missing from that tree.
420
420
# FIXME there is no code for this right now.
421
421
# self.assertEqual(branch.missing_revisions(branch3), [])
423
423
def test_import_symlink(self):
424
import_version('output', pybaz.Version(self._baz._import_symlink),
424
import_version('output', pybaz.Version(self._baz._import_symlink),
425
425
None, max_count=1)
426
426
# expected results:
427
# two commits, no files, revision identifier of
427
# two commits, no files, revision identifier of
428
428
# 'demo@DONOTUSE_c--import--0--base-0'
429
429
branch = Branch.open('output')
430
430
self.assertEqual(branch.revision_history(),
478
478
# and we should get some expected values:
479
479
self.assertEqual(rev.committer, "Test User<test@example.org>")
480
self.assertEqual(rev.message,
480
self.assertEqual(rev.message,
481
481
"tag of demo-gone@DONOTUSE/c--import--0--base-0")
482
482
self.assertEqual(rev.revision_id, self._baz._missing_ancestor_bzr)
483
483
self.assertEqual(rev.parent_ids[0], self._baz._missing_import_bzr)
484
484
self.assertEqual(1, len(rev.parent_ids))
486
486
# must NOT be able to get the merged evision
487
self.assertRaises(NoSuchRevision, branch.repository.get_revision,
487
self.assertRaises(NoSuchRevision, branch.repository.get_revision,
488
488
self._baz._missing_import_bzr)
490
490
def test_missing_ancestor_reusing_history(self):
749
749
command = cmd_baz_import()
750
750
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
751
751
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output')))
752
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
752
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
754
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
754
self.failUnless(os.path.exists(os.path.join(self._tmpdir,'output',
755
755
'c1', '0.2','branch')))
756
756
default_format = repository.RepositoryFormat.get_default_format()
757
757
if getattr(default_format, 'rich_root_data', False):
766
766
command = cmd_baz_import()
767
767
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
768
768
command.run(os.path.join(self._tmpdir, 'output'), 'demo@DONOTUSE')
770
770
def test_accepts_reuse_history(self):
771
771
self.make_import('c--0')
772
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
773
'demo@DONOTUSE', '.', '.')
775
def test_does_not_need_reuse_history(self):
776
self.make_import('c--0')
777
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
780
def test_does_not_need_reuse_history(self):
781
self.make_import('c--0')
782
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
772
self.run_bzr(['baz-import', os.path.join(self._tmpdir, 'output'),
773
'demo@DONOTUSE', '.', '.'])
775
def test_does_not_need_reuse_history(self):
776
self.make_import('c--0')
777
self.run_bzr(['baz-import', os.path.join(self._tmpdir, 'output'),
780
def test_does_not_need_reuse_history(self):
781
self.make_import('c--0')
782
self.run_bzr(['baz-import', os.path.join(self._tmpdir, 'output'),
785
785
def test_encoding_flag(self):
786
786
self.make_import('c--0')
787
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
789
self.assertEqual(['Arch-1:demo@DONOTUSE%c--0--base-0'],
790
Branch.open(os.path.join(self._tmpdir,
787
self.run_bzr(['baz-import', os.path.join(self._tmpdir, 'output'),
789
self.assertEqual(['Arch-1:demo@DONOTUSE%c--0--base-0'],
790
Branch.open(os.path.join(self._tmpdir,
791
791
'output/c/+trunk')).revision_history())
792
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output2'),
793
'demo@DONOTUSE', '--encoding', 'utf-8')
794
self.assertEqual(['Arch-1-utf-8:demo@DONOTUSE%c--0--base-0'],
795
Branch.open(os.path.join(self._tmpdir,
792
self.run_bzr(['baz-import', os.path.join(self._tmpdir, 'output2'),
793
'demo@DONOTUSE', '--encoding', 'utf-8'])
794
self.assertEqual(['Arch-1-utf-8:demo@DONOTUSE%c--0--base-0'],
795
Branch.open(os.path.join(self._tmpdir,
796
796
'output2/c/+trunk')).revision_history())
797
self.run_bzr('baz-import-branch', os.path.join(self._tmpdir, 'output3'),
798
'demo@DONOTUSE/c--0')
799
self.assertEqual(['Arch-1:demo@DONOTUSE%c--0--base-0'],
800
Branch.open(os.path.join(self._tmpdir,
797
self.run_bzr(['baz-import-branch', os.path.join(self._tmpdir,
798
'output3'), 'demo@DONOTUSE/c--0'])
799
self.assertEqual(['Arch-1:demo@DONOTUSE%c--0--base-0'],
800
Branch.open(os.path.join(self._tmpdir,
801
801
'output3')).revision_history())
802
self.run_bzr('baz-import-branch', os.path.join(self._tmpdir,
803
'output4'), 'demo@DONOTUSE/c--0', '--encoding', 'utf-8')
804
self.assertEqual(['Arch-1-utf-8:demo@DONOTUSE%c--0--base-0'],
805
Branch.open(os.path.join(self._tmpdir,
802
self.run_bzr(['baz-import-branch', os.path.join(self._tmpdir,
803
'output4'), 'demo@DONOTUSE/c--0', '--encoding', 'utf-8'])
804
self.assertEqual(['Arch-1-utf-8:demo@DONOTUSE%c--0--base-0'],
805
Branch.open(os.path.join(self._tmpdir,
806
806
'output4')).revision_history())