~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_baz_import.py

  • Committer: Aaron Bentley
  • Date: 2006-11-21 23:26:35 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061121232635-z2b0g5rv73im3cdc
Add encoding parameter everywhere

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        self.make_empty_import()
75
75
 
76
76
        self._empty_tag = 'demo@DONOTUSE/c--empty-tag--0'
77
 
        self._empty_tag_bzr = revision_id(self._empty_tag + '--base-0')
 
77
        self._empty_tag_bzr = revision_id(self._empty_tag + '--base-0', None)
78
78
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
79
79
            pybaz.Version(self._empty_tag))
80
80
 
81
81
        self._empty_merged_tag = 'demo@DONOTUSE/c--empty-merged-tag--0'
82
82
        self._empty_merged_tag_bzr_base = revision_id(self._empty_merged_tag 
83
 
                                                 + '--base-0')
 
83
                                                 + '--base-0', None)
84
84
        self._empty_merged_tag_bzr = revision_id(self._empty_merged_tag 
85
 
                                                 + '--patch-1')
 
85
                                                 + '--patch-1', None)
86
86
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
87
87
            pybaz.Version(self._empty_merged_tag))
88
88
        tree = pybaz.Revision(self._empty_merged_tag + '--base-0').get(
97
97
        # tree, two commits, includes merge of other branch
98
98
        self._empty_merged_tag_2 = 'demo@DONOTUSE/c--empty-tag-2--0'
99
99
        self._empty_merged_tag_2_bzr_base = revision_id(
100
 
            self._empty_merged_tag_2 + '--base-0')
 
100
            self._empty_merged_tag_2 + '--base-0', None)
101
101
        self._empty_merged_tag_2_bzr = revision_id(
102
 
            self._empty_merged_tag_2 + '--patch-1')
 
102
            self._empty_merged_tag_2 + '--patch-1', None)
103
103
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
104
104
            pybaz.Version(self._empty_merged_tag_2))
105
105
        tree = pybaz.Revision(self._empty_merged_tag_2 + '--base-0').get (
112
112
        shutil.rmtree(os.path.join(self._tmpdir, 'tree'))
113
113
 
114
114
        self._bad_id_tag = 'demo@DONOTUSE/c--bad-id--0'
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')
 
115
        self._bad_id_tag_bzr_base = revision_id(self._bad_id_tag + '--base-0',
 
116
                                                None)
 
117
        self._bad_id_tag_bzr = revision_id(self._bad_id_tag + '--patch-1',
 
118
                                           None)
117
119
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
118
120
            pybaz.Version(self._bad_id_tag))
119
121
        tree = pybaz.Revision(self._bad_id_tag + '--base-0').get(
133
135
    def make_import_symlink(self):
134
136
        self._import_symlink = 'demo@DONOTUSE/c--import-symlink--0'
135
137
        self._import_symlink_bzr = revision_id(
136
 
            self._import_symlink + '--base-0')
 
138
            self._import_symlink + '--base-0', None)
137
139
        os.mkdir(os.path.join(self._tmpdir, 'tree'))
138
140
        tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'),
139
141
                               self._import_symlink)
171
173
                                     str(self._archivegoneroot))
172
174
        self._missing_import = 'demo-gone@DONOTUSE/c--import--0'
173
175
        self._missing_import_bzr = revision_id(self._missing_import 
174
 
                                                 + '--base-0')
 
176
                                                 + '--base-0', None)
175
177
        self._missing_ancestor = 'demo@DONOTUSE/c--gone--0'
176
178
        self._missing_ancestor_bzr = revision_id(self._missing_ancestor 
177
 
                                                 + '--base-0')
 
179
                                                 + '--base-0', None)
178
180
        os.mkdir(os.path.join(self._tmpdir, 'tree'))
179
181
        tree = pybaz.init_tree(os.path.join(self._tmpdir, 'tree'), 
180
182
                               self._missing_import)
194
196
        os.mkdir(os.path.join(self._tmpdir, 'archivegone-bzr', 'c'))
195
197
        import_version(os.path.join(self._tmpdir, 'archivegone-bzr', 
196
198
                                    'c', 'import'),
197
 
                       pybaz.Version(self._missing_import))
 
199
                       pybaz.Version(self._missing_import), None)
198
200
        # and make it inaccessible
199
201
        pybaz.Archive('demo-gone@DONOTUSE').unregister()
200
202
 
201
203
    def make_inbranch_continuation(self):
202
204
        self._inbranch_tag = 'demo@DONOTUSE/c--inbranch-tag--0'
203
205
        self._inbranch_tag_base = self._inbranch_tag + '--base-0'
204
 
        self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base)
 
206
        self._inbranch_tag_base_bzr = revision_id(self._inbranch_tag_base, 
 
207
                                                  None)
205
208
        pybaz.Revision('demo@DONOTUSE/c--import--0--base-0').make_continuation(
206
209
            pybaz.Version(self._inbranch_tag))
207
210
        self._inbranch_tag_head = self._inbranch_tag + '--patch-1'
208
 
        self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head)
 
211
        self._inbranch_tag_head_bzr = revision_id(self._inbranch_tag_head,
 
212
                                                  None)
209
213
        pybaz.Revision(self._inbranch_tag_base).make_continuation(
210
214
            pybaz.Version(self._inbranch_tag))
211
215
 
232
236
        TestCaseInTempDir.tearDown(self)
233
237
 
234
238
    def test_import_empty(self):
235
 
        import_version('output', pybaz.Version(self._baz._import))
 
239
        import_version('output', pybaz.Version(self._baz._import), None)
236
240
        # expected results:
237
241
        # one commit, no files, revision identifier of 
238
242
        # 'demo@DONOTUSE_c--import--0--base-0'
242
246
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
243
247
        rev = repo.get_revision('Arch-1:demo@DONOTUSE%c--import--0--base-0')
244
248
        # and again.
245
 
        import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'))
 
249
        import_version('output2', pybaz.Version('demo@DONOTUSE/c--import--0'),
 
250
                       None)
246
251
        branch2 = Branch.open('output2')
247
252
        repo2 = branch2.repository
248
253
        self.assertEqual(branch.revision_history(), branch2.revision_history())
257
262
                         "Arch-1:demo@DONOTUSE%c--import--0--base-0")
258
263
 
259
264
    def test_empty_tagged(self):
260
 
        import_version('output', pybaz.Version(self._baz._empty_tag))
 
265
        import_version('output', pybaz.Version(self._baz._empty_tag), None)
261
266
        # expected results:
262
267
        # two commits, no files, revision identifiers of 
263
268
        # 'demo@DONOTUSE_c--import--0--base-0' and
268
273
                          self._baz._empty_tag_bzr])
269
274
        rev = branch.repository.get_revision(self._baz._empty_tag_bzr)
270
275
        # and again.
271
 
        import_version('output2', pybaz.Version(self._baz._empty_tag))
 
276
        import_version('output2', pybaz.Version(self._baz._empty_tag), None)
272
277
        branch2 = Branch.open('output2')
273
278
        self.assertEqual(branch.revision_history(), branch2.revision_history())
274
279
        rev2 = branch2.repository.get_revision(self._baz._empty_tag_bzr)
282
287
        self.assertEqual(rev.revision_id, self._baz._empty_tag_bzr)
283
288
 
284
289
    def test_empty_merged_tagged(self):
285
 
        import_version('output', pybaz.Version(self._baz._empty_merged_tag))
 
290
        import_version('output', pybaz.Version(self._baz._empty_merged_tag), 
 
291
                       None)
286
292
        # expected results:
287
293
        # two commits, no files, revision identifiers of 
288
294
        # 'demo@DONOTUSE_c--import--0--base-0' and
297
303
                          self._baz._empty_merged_tag_bzr_base,
298
304
                          self._baz._empty_merged_tag_bzr])
299
305
        # and again.
300
 
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag))
 
306
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag), 
 
307
                       None)
301
308
        branch2 = Branch.open('output2')
302
309
        repo2 = branch2.repository
303
310
        # and import what we should be merged up against for checking with.
304
 
        import_version('output3', pybaz.Version(self._baz._empty_tag))
 
311
        import_version('output3', pybaz.Version(self._baz._empty_tag), None)
305
312
        branch3 = Branch.open('output3')
306
313
        
307
314
        self.assertEqual(branch.revision_history(), branch2.revision_history())
338
345
        # self.assertEqual(branch.missing_revisions(branch3), [])
339
346
        
340
347
    def test_merge_branch_with_merges(self):
341
 
        import_version('output', pybaz.Version(self._baz._empty_merged_tag_2))
 
348
        import_version('output', pybaz.Version(self._baz._empty_merged_tag_2), 
 
349
                       None)
342
350
        # expected results:
343
351
        # two commits, no files, revision identifiers of 
344
352
        # 'demo@DONOTUSE_c--import--0--base-0' and
353
361
                          self._baz._empty_merged_tag_2_bzr_base,
354
362
                          self._baz._empty_merged_tag_2_bzr])
355
363
        # and again.
356
 
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2))
 
364
        import_version('output2', pybaz.Version(self._baz._empty_merged_tag_2),
 
365
                       None)
357
366
        branch2 = Branch.open('output2')
358
367
        repo2 = branch2.repository
359
368
        # and import what we should be merged up against for checking with.
360
 
        import_version('output3', pybaz.Version(self._baz._empty_merged_tag))
 
369
        import_version('output3', pybaz.Version(self._baz._empty_merged_tag),
 
370
                       None)
361
371
        branch3 = Branch.open('output3')
362
372
        
363
373
        self.assertEqual(branch.revision_history(), branch2.revision_history())
395
405
        
396
406
    def test_import_symlink(self):
397
407
        import_version('output', pybaz.Version(self._baz._import_symlink), 
398
 
                       max_count=1)
 
408
                       None, max_count=1)
399
409
        # expected results:
400
410
        # two commits, no files, revision identifier of 
401
411
        # 'demo@DONOTUSE_c--import--0--base-0'
405
415
        rev = branch.repository.get_revision(self._baz._import_symlink_bzr)
406
416
        # and again.
407
417
        import_version('output2', pybaz.Version(self._baz._import_symlink),
408
 
                       max_count=1)
 
418
                       None, max_count=1)
409
419
        branch2 = Branch.open('output2')
410
420
        self.assertEqual(branch.revision_history(), branch2.revision_history())
411
421
        rev2 = branch2.repository.get_revision(self._baz._import_symlink_bzr)
426
436
 
427
437
        # current bzr doesn't handle type changes
428
438
        self.assertRaises(AssertionError, import_version, 'output3',
429
 
                          pybaz.Version(self._baz._import_symlink))
 
439
                          pybaz.Version(self._baz._import_symlink), None)
430
440
 
431
441
    def test_missing_ancestor(self):
432
 
        import_version('output', pybaz.Version(self._baz._missing_ancestor))
 
442
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
 
443
                       None)
433
444
        # expected results:
434
445
        # one commits, no files, revision identifiers of 
435
446
        # 'demo@DONOTUSE_c--gone--0--base-0' and
439
450
                         [self._baz._missing_ancestor_bzr])
440
451
        rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
441
452
        # and again.
442
 
        import_version('output2', pybaz.Version(self._baz._missing_ancestor))
 
453
        import_version('output2', pybaz.Version(self._baz._missing_ancestor), 
 
454
                       None)
443
455
        branch2 = Branch.open('output2')
444
456
        self.assertEqual(branch.revision_history(), branch2.revision_history())
445
457
        rev2 = branch2.repository.get_revision(self._baz._missing_ancestor_bzr)
460
472
 
461
473
    def test_missing_ancestor_reusing_history(self):
462
474
        import_version('output', pybaz.Version(self._baz._missing_ancestor),
 
475
                       None,
463
476
                       reuse_history_from=[self._baz._missing_import_imported])
464
477
        # expected results:
465
478
        # one commits, no files, revision identifiers of 
472
485
        rev = branch.repository.get_revision(self._baz._missing_ancestor_bzr)
473
486
        # and again.
474
487
        import_version('output2', pybaz.Version(self._baz._missing_ancestor),
 
488
                       None,
475
489
                       reuse_history_from=[self._baz._missing_import_imported])
476
490
        branch2 = Branch.open('output2')
477
491
        self.assertEqual(branch.revision_history(), branch2.revision_history())
491
505
        self.assertEqual(1, len(rev.parent_ids))
492
506
 
493
507
    def test_bad_file_id(self):
494
 
        import_version('output', pybaz.Version(self._baz._bad_id_tag))
 
508
        import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
495
509
        # expected results:
496
510
        # three commits, one files, revision identifiers of 
497
511
        # 'demo@DONOTUSE_c--import--0--base-0' ,
508
522
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
509
523
 
510
524
    def test_appending_revisions_already_present(self):
511
 
        import_version('output', pybaz.Version(self._baz._bad_id_tag),
 
525
        import_version('output', pybaz.Version(self._baz._bad_id_tag), None,
512
526
                       max_count=2)
513
527
        # expected results:
514
528
        # three commits, one files, revision identifiers of 
526
540
        self.assertEqual(branch.revision_history(),
527
541
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
528
542
        del branch
529
 
        import_version('output', pybaz.Version(self._baz._bad_id_tag))
 
543
        import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
530
544
        branch = Branch.open('output')
531
545
        self.assertEqual(branch.revision_history(),
532
546
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
538
552
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
539
553
 
540
554
    def test_appending_revisions_all_already_present(self):
541
 
        import_version('output', pybaz.Version(self._baz._bad_id_tag))
 
555
        import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
542
556
        # expected results:
543
557
        # three commits, one files, revision identifiers of 
544
558
        # 'demo@DONOTUSE_c--import--0--base-0' ,
556
570
        self.assertEqual(branch.revision_history(),
557
571
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0'])
558
572
        del branch
559
 
        import_version('output', pybaz.Version(self._baz._bad_id_tag))
 
573
        import_version('output', pybaz.Version(self._baz._bad_id_tag), None)
560
574
        branch = Branch.open('output')
561
575
        self.assertEqual(branch.revision_history(),
562
576
                         ['Arch-1:demo@DONOTUSE%c--import--0--base-0',
568
582
        self.assertEqual('path', inv.id2path('x_this_id%2fneeds%25escaping'))
569
583
 
570
584
    def test_inbranch_conversion(self):
571
 
        import_version('output', pybaz.Version(self._baz._inbranch_tag))
 
585
        import_version('output', pybaz.Version(self._baz._inbranch_tag), None)
572
586
        # expected results:
573
587
        # three commits, no files, revision identifiers of 
574
588
        # 'demo@DONOTUSE_c--import--0--base-0' and
581
595
                          self._baz._inbranch_tag_base_bzr,
582
596
                          self._baz._inbranch_tag_head_bzr])
583
597
        # and again.
584
 
        import_version('output2', pybaz.Version(self._baz._inbranch_tag))
 
598
        import_version('output2', pybaz.Version(self._baz._inbranch_tag), None)
585
599
        branch2 = Branch.open('output2')
586
600
        
587
601
        self.assertEqual(branch.revision_history(), branch2.revision_history())
611
625
        path = 'output'
612
626
        os.mkdir(path)
613
627
        branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(path)
614
 
        import_version(path, pybaz.Version(self._baz._import))
 
628
        import_version(path, pybaz.Version(self._baz._import), None)
615
629
        # expected results:
616
630
        # one commit, revision identifier of 
617
631
        # 'demo@DONOTUSE_c--import--0--base-0'