72
72
pybaz.set_my_id("Test User<test@example.org>")
74
74
self.make_empty_import()
77
76
self._empty_tag = 'demo@DONOTUSE/c--empty-tag--0'
78
self._empty_tag_bzr = revision_id(self._empty_tag + '--base-0', None)
77
self._empty_tag_bzr = revision_id(self._empty_tag + '--base-0')
79
78
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
80
79
pybaz.Version(self._empty_tag))
82
81
self._empty_merged_tag = 'demo@DONOTUSE/c--empty-merged-tag--0'
83
82
self._empty_merged_tag_bzr_base = revision_id(self._empty_merged_tag
85
84
self._empty_merged_tag_bzr = revision_id(self._empty_merged_tag
87
86
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
88
87
pybaz.Version(self._empty_merged_tag))
89
88
tree = pybaz.Revision(self._empty_merged_tag + '--base-0').get(
98
97
# tree, two commits, includes merge of other branch
99
98
self._empty_merged_tag_2 = 'demo@DONOTUSE/c--empty-tag-2--0'
100
99
self._empty_merged_tag_2_bzr_base = revision_id(
101
self._empty_merged_tag_2 + '--base-0', None)
100
self._empty_merged_tag_2 + '--base-0')
102
101
self._empty_merged_tag_2_bzr = revision_id(
103
self._empty_merged_tag_2 + '--patch-1', None)
102
self._empty_merged_tag_2 + '--patch-1')
104
103
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
105
104
pybaz.Version(self._empty_merged_tag_2))
106
105
tree = pybaz.Revision(self._empty_merged_tag_2 + '--base-0').get (
113
112
shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
115
114
self._bad_id_tag = 'demo@DONOTUSE/c--bad-id--0'
116
self._bad_id_tag_bzr_base = revision_id(self._bad_id_tag + '--base-0',
118
self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1',
115
self._bad_id_tag_bzr_base = revision_id(self._bad_id_tag + '--base-0')
116
self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1')
120
117
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
121
118
pybaz.Version(self._bad_id_tag))
122
119
tree = pybaz.Revision(self._bad_id_tag + '--base-0').get(
136
133
def make_import_symlink(self):
137
134
self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0'
138
135
self._import_symlink_bzr = revision_id(
139
self._import_symlink + '--base-0', None)
136
self._import_symlink + '--base-0')
140
137
os.mkdir(os.path.join(self._tmpdir, 'tree'))
141
138
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
142
139
self._import_symlink)
168
165
tree.import_(msg)
169
166
shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
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'),
176
msg = tree.log_message()
177
msg["summary"] = u"I am importing now\u1234".encode('utf-8')
179
shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
181
168
def make_missing_ancestor(self):
182
169
self._archivegoneroot = os.path.join(self._tmpdir, 'archivegone')
183
170
self._archive = make_archive('demo-gone@DONOTUSE',
184
171
str(self._archivegoneroot))
185
172
self._missing_import = 'demo-gone@DONOTUSE/c--import--0'
186
173
self._missing_import_bzr = revision_id(self._missing_import
188
175
self._missing_ancestor = 'demo@DONOTUSE/c--gone--0'
189
176
self._missing_ancestor_bzr = revision_id(self._missing_ancestor
191
178
os.mkdir(os.path.join(self._tmpdir, 'tree'))
192
179
tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
193
180
self._missing_import)
207
194
os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c'))
208
195
import_version(os.path.join(self._tmpdir, 'archivegone-bzr',
210
pybaz.Version(self._missing_import), None)
197
pybaz.Version(self._missing_import))
211
198
# and make it inaccessible
212
199
pybaz.Archive('demo-gone@DONOTUSE').unregister()
214
201
def make_inbranch_continuation(self):
215
202
self._inbranch_tag = 'demo@DONOTUSE/c--inbranch-tag--0'
216
203
self._inbranch_tag_base = self._inbranch_tag + '--base-0'
217
self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base,
204
self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base)
219
205
pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
220
206
pybaz.Version(self._inbranch_tag))
221
207
self._inbranch_tag_head = self._inbranch_tag + '--patch-1'
222
self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head,
208
self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head)
224
209
pybaz.Revision(self._inbranch_tag_base).make_continuation(
225
210
pybaz.Version(self._inbranch_tag))
245
230
def tearDown(self):
246
231
ResourcedTestCase.tearDownResources(self)
247
232
TestCaseInTempDir.tearDown(self)
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)
263
234
def test_import_empty(self):
264
import_version('output', pybaz.Version(self._baz._import), None)
235
import_version('output', pybaz.Version(self._baz._import))
265
236
# expected results:
266
237
# one commit, no files, revision identifier of
267
238
# 'demo@DONOTUSE_c--import--0--base-0'
271
242
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
272
243
rev = repo.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
274
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'),
245
import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'))
276
246
branch2 = Branch.open('output2')
277
247
repo2 = branch2.repository
278
248
self.assertEqual(branch.revision_history(), branch2.revision_history())
287
257
"Arch-1:demo@DONOTUSE%c--import--0--base-0")
289
259
def test_empty_tagged(self):
290
import_version('output', pybaz.Version(self._baz._empty_tag), None)
260
import_version('output', pybaz.Version(self._baz._empty_tag))
291
261
# expected results:
292
262
# two commits, no files, revision identifiers of
293
263
# 'demo@DONOTUSE_c--import--0--base-0' and
298
268
self._baz._empty_tag_bzr])
299
269
rev = branch.repository.get_revision(self._baz._empty_tag_bzr)
301
import_version('output2', pybaz.Version(self._baz._empty_tag), None)
271
import_version('output2', pybaz.Version(self._baz._empty_tag))
302
272
branch2 = Branch.open('output2')
303
273
self.assertEqual(branch.revision_history(), branch2.revision_history())
304
274
rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr)
312
282
self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr)
314
284
def test_empty_merged_tagged(self):
315
import_version('output', pybaz.Version(self._baz._empty_merged_tag),
285
import_version('output', pybaz.Version(self._baz._empty_merged_tag))
317
286
# expected results:
318
287
# two commits, no files, revision identifiers of
319
288
# 'demo@DONOTUSE_c--import--0--base-0' and
328
297
self._baz._empty_merged_tag_bzr_base,
329
298
self._baz._empty_merged_tag_bzr])
331
import_version('output2', pybaz.Version(self._baz._empty_merged_tag),
300
import_version('output2', pybaz.Version(self._baz._empty_merged_tag))
333
301
branch2 = Branch.open('output2')
334
302
repo2 = branch2.repository
335
303
# and import what we should be merged up against for checking with.
336
import_version('output3', pybaz.Version(self._baz._empty_tag), None)
304
import_version('output3', pybaz.Version(self._baz._empty_tag))
337
305
branch3 = Branch.open('output3')
339
307
self.assertEqual(branch.revision_history(), branch2.revision_history())
370
338
# self.assertEqual(branch.missing_revisions(branch3), [])
372
340
def test_merge_branch_with_merges(self):
373
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2),
341
import_version('output', pybaz.Version(self._baz._empty_merged_tag_2))
375
342
# expected results:
376
343
# two commits, no files, revision identifiers of
377
344
# 'demo@DONOTUSE_c--import--0--base-0' and
386
353
self._baz._empty_merged_tag_2_bzr_base,
387
354
self._baz._empty_merged_tag_2_bzr])
389
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2),
356
import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2))
391
357
branch2 = Branch.open('output2')
392
358
repo2 = branch2.repository
393
359
# and import what we should be merged up against for checking with.
394
import_version('output3', pybaz.Version(self._baz._empty_merged_tag),
360
import_version('output3', pybaz.Version(self._baz._empty_merged_tag))
396
361
branch3 = Branch.open('output3')
398
363
self.assertEqual(branch.revision_history(), branch2.revision_history())
431
396
def test_import_symlink(self):
432
397
import_version('output', pybaz.Version(self._baz._import_symlink),
434
399
# expected results:
435
400
# two commits, no files, revision identifier of
436
401
# 'demo@DONOTUSE_c--import--0--base-0'
440
405
rev = branch.repository.get_revision(self._baz._import_symlink_bzr)
442
407
import_version('output2', pybaz.Version(self._baz._import_symlink),
444
409
branch2 = Branch.open('output2')
445
410
self.assertEqual(branch.revision_history(), branch2.revision_history())
446
411
rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr)
462
427
# current bzr doesn't handle type changes
463
428
self.assertRaises(AssertionError, import_version, 'output3',
464
pybaz.Version(self._baz._import_symlink), None)
429
pybaz.Version(self._baz._import_symlink))
466
431
def test_missing_ancestor(self):
467
import_version('output', pybaz.Version(self._baz._missing_ancestor),
432
import_version('output', pybaz.Version(self._baz._missing_ancestor))
469
433
# expected results:
470
434
# one commits, no files, revision identifiers of
471
435
# 'demo@DONOTUSE_c--gone--0--base-0' and
475
439
[self._baz._missing_ancestor_bzr])
476
440
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
478
import_version('output2', pybaz.Version(self._baz._missing_ancestor),
442
import_version('output2', pybaz.Version(self._baz._missing_ancestor))
480
443
branch2 = Branch.open('output2')
481
444
self.assertEqual(branch.revision_history(), branch2.revision_history())
482
445
rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
498
461
def test_missing_ancestor_reusing_history(self):
499
462
import_version('output', pybaz.Version(self._baz._missing_ancestor),
501
463
reuse_history_from=[self._baz._missing_import_imported])
502
464
# expected results:
503
465
# one commits, no files, revision identifiers of
510
472
rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
512
474
import_version('output2', pybaz.Version(self._baz._missing_ancestor),
514
475
reuse_history_from=[self._baz._missing_import_imported])
515
476
branch2 = Branch.open('output2')
516
477
self.assertEqual(branch.revision_history(), branch2.revision_history())
530
491
self.assertEqual(1, len(rev.parent_ids))
532
493
def test_bad_file_id(self):
533
import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
494
import_version('output', pybaz.Version(self._baz._bad_id_tag))
534
495
# expected results:
535
496
# three commits, one files, revision identifiers of
536
497
# 'demo@DONOTUSE_c--import--0--base-0' ,
547
508
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
549
510
def test_appending_revisions_already_present(self):
550
import_version('output', pybaz.Version(self._baz._bad_id_tag), None,
511
import_version('output', pybaz.Version(self._baz._bad_id_tag),
552
513
# expected results:
553
514
# three commits, one files, revision identifiers of
565
526
self.assertEqual(branch.revision_history(),
566
527
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
568
import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
529
import_version('output', pybaz.Version(self._baz._bad_id_tag))
569
530
branch = Branch.open('output')
570
531
self.assertEqual(branch.revision_history(),
571
532
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
577
538
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
579
540
def test_appending_revisions_all_already_present(self):
580
import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
541
import_version('output', pybaz.Version(self._baz._bad_id_tag))
581
542
# expected results:
582
543
# three commits, one files, revision identifiers of
583
544
# 'demo@DONOTUSE_c--import--0--base-0' ,
595
556
self.assertEqual(branch.revision_history(),
596
557
['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
598
import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
559
import_version('output', pybaz.Version(self._baz._bad_id_tag))
599
560
branch = Branch.open('output')
600
561
self.assertEqual(branch.revision_history(),
601
562
['Arch-1:demo@DONOTUSE%c--import--0--base-0',
607
568
self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
609
570
def test_inbranch_conversion(self):
610
import_version('output', pybaz.Version(self._baz._inbranch_tag), None)
571
import_version('output', pybaz.Version(self._baz._inbranch_tag))
611
572
# expected results:
612
573
# three commits, no files, revision identifiers of
613
574
# 'demo@DONOTUSE_c--import--0--base-0' and
620
581
self._baz._inbranch_tag_base_bzr,
621
582
self._baz._inbranch_tag_head_bzr])
623
import_version('output2', pybaz.Version(self._baz._inbranch_tag), None)
584
import_version('output2', pybaz.Version(self._baz._inbranch_tag))
624
585
branch2 = Branch.open('output2')
626
587
self.assertEqual(branch.revision_history(), branch2.revision_history())
652
613
branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(path)
653
import_version(path, pybaz.Version(self._baz._import), None)
614
import_version(path, pybaz.Version(self._baz._import))
654
615
# expected results:
655
616
# one commit, revision identifier of
656
617
# 'demo@DONOTUSE_c--import--0--base-0'
785
746
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
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'),
793
def test_encoding_flag(self):
794
self.make_import('c--0')
795
self.run_bzr('baz-import', os.path.join(self._tmpdir, 'output'),
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())