~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Aaron Bentley
  • Date: 2006-10-25 13:35:12 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061025133512-09660b1b3104b054
Update version number to 0.13.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        pybaz.set_my_id("Test User<test@example.org>")
73
73
 
74
74
        self.make_empty_import()
75
 
        self.make_utf8_log()
76
75
 
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))
81
80
 
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 
84
 
                                                 + '--base-0', None)
 
83
                                                 + '--base-0')
85
84
        self._empty_merged_tag_bzr = revision_id(self._empty_merged_tag 
86
 
                                                 + '--patch-1', None)
 
85
                                                 + '--patch-1')
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'))
114
113
 
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',
117
 
                                                None)
118
 
        self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1',
119
 
                                           None)
 
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'))
170
167
 
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
 
 
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 
187
 
                                                 + '--base-0', None)
 
174
                                                 + '--base-0')
188
175
        self._missing_ancestor = 'demo@DONOTUSE/c--gone--0'
189
176
        self._missing_ancestor_bzr = revision_id(self._missing_ancestor 
190
 
                                                 + '--base-0', None)
 
177
                                                 + '--base-0')
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', 
209
196
                                    'c', 'import'),
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()
213
200
 
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, 
218
 
                                                  None)
 
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,
223
 
                                                  None)
 
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))
226
211
 
245
230
    def tearDown(self):
246
231
        ResourcedTestCase.tearDownResources(self)
247
232
        TestCaseInTempDir.tearDown(self)
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
 
 
 
233
 
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')
273
244
        # and again.
274
 
        import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'),
275
 
                       None)
 
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")
288
258
 
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)
300
270
        # and again.
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)
313
283
 
314
284
    def test_empty_merged_tagged(self):
315
 
        import_version('output', pybaz.Version(self._baz._empty_merged_tag), 
316
 
                       None)
 
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])
330
299
        # and again.
331
 
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag), 
332
 
                       None)
 
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')
338
306
        
339
307
        self.assertEqual(branch.revision_history(), branch2.revision_history())
370
338
        # self.assertEqual(branch.missing_revisions(branch3), [])
371
339
        
372
340
    def test_merge_branch_with_merges(self):
373
 
        import_version('output', pybaz.Version(self._baz._empty_merged_tag_2), 
374
 
                       None)
 
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])
388
355
        # and again.
389
 
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2),
390
 
                       None)
 
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),
395
 
                       None)
 
360
        import_version('output3', pybaz.Version(self._baz._empty_merged_tag))
396
361
        branch3 = Branch.open('output3')
397
362
        
398
363
        self.assertEqual(branch.revision_history(), branch2.revision_history())
430
395
        
431
396
    def test_import_symlink(self):
432
397
        import_version('output', pybaz.Version(self._baz._import_symlink), 
433
 
                       None, max_count=1)
 
398
                       max_count=1)
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)
441
406
        # and again.
442
407
        import_version('output2', pybaz.Version(self._baz._import_symlink),
443
 
                       None, max_count=1)
 
408
                       max_count=1)
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)
461
426
 
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))
465
430
 
466
431
    def test_missing_ancestor(self):
467
 
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
468
 
                       None)
 
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)
477
441
        # and again.
478
 
        import_version('output2', pybaz.Version(self._baz._missing_ancestor), 
479
 
                       None)
 
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)
497
460
 
498
461
    def test_missing_ancestor_reusing_history(self):
499
462
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
500
 
                       None,
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)
511
473
        # and again.
512
474
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
513
 
                       None,
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))
531
492
 
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'))
548
509
 
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),
551
512
                       max_count=2)
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'])
567
528
        del branch
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'))
578
539
 
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'])
597
558
        del branch
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'))
608
569
 
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])
622
583
        # and again.
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')
625
586
        
626
587
        self.assertEqual(branch.revision_history(), branch2.revision_history())
650
611
        path = 'output'
651
612
        os.mkdir(path)
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'),
786
747
                     'demo@DONOTUSE')
787
748
 
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())