~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: INADA Naoki
  • Date: 2011-05-05 09:15:34 UTC
  • mto: (5830.3.3 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110505091534-7sv835xpofwrmpt4
Add update-pot command to Makefile and tools/bzrgettext script that
extracts help text from bzr commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
        finally:
122
122
            wt1.unlock()
123
123
 
124
 
    def test_merge_into_null_tree(self):
125
 
        wt = self.make_branch_and_tree('tree')
126
 
        null_tree = wt.basis_tree()
127
 
        self.build_tree(['tree/file'])
128
 
        wt.add('file')
129
 
        wt.commit('tree with root')
130
 
        merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
131
 
                                         this_branch=wt.branch,
132
 
                                         do_merge=False)
133
 
        with merger.make_preview_transform() as tt:
134
 
            self.assertEqual([], tt.find_conflicts())
135
 
            preview = tt.get_preview_tree()
136
 
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
137
 
 
138
 
    def test_merge_unrelated_retains_root(self):
139
 
        wt = self.make_branch_and_tree('tree')
140
 
        root_id_before_merge = wt.get_root_id()
141
 
        other_tree = self.make_branch_and_tree('other')
142
 
        # Do a commit so there is something to merge
143
 
        other_tree.commit('commit other')
144
 
        self.assertNotEquals(root_id_before_merge, other_tree.get_root_id())
145
 
        wt.merge_from_branch(other_tree.branch,
146
 
                             from_revision=_mod_revision.NULL_REVISION)
147
 
        self.assertEqual(root_id_before_merge, wt.get_root_id())
148
 
 
149
 
    def test_merge_preview_unrelated_retains_root(self):
150
 
        wt = self.make_branch_and_tree('tree')
151
 
        other_tree = self.make_branch_and_tree('other')
152
 
        # Do a commit so there is something to merge
153
 
        other_tree.commit('commit other')
154
 
        merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
155
 
                                         this_branch=wt.branch,
156
 
                                         do_merge=False)
157
 
        with merger.make_preview_transform() as tt:
158
 
            preview = tt.get_preview_tree()
159
 
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
160
 
 
161
124
    def test_create_rename(self):
162
125
        """Rename an inventory entry while creating the file"""
163
126
        tree =self.make_branch_and_tree('.')
424
387
                             '>>>>>>> MERGE-SOURCE\n',
425
388
                             'this/file')
426
389
 
427
 
    def test_merge_reverse_revision_range(self):
428
 
        tree = self.make_branch_and_tree(".")
429
 
        tree.lock_write()
430
 
        self.addCleanup(tree.unlock)
431
 
        self.build_tree(['a'])
432
 
        tree.add('a')
433
 
        tree.commit("added a")
434
 
        first_rev = tree.branch.revision_history()[0]
435
 
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
436
 
                                          _mod_revision.NULL_REVISION,
437
 
                                          first_rev)
438
 
        merger.merge_type = _mod_merge.Merge3Merger
439
 
        merger.interesting_files = 'a'
440
 
        conflict_count = merger.do_merge()
441
 
        self.assertEqual(0, conflict_count)
442
 
 
443
 
        self.assertPathDoesNotExist("a")
444
 
        tree.revert()
445
 
        self.assertPathExists("a")
446
 
 
447
390
    def test_make_merger(self):
448
391
        this_tree = self.make_branch_and_tree('this')
449
392
        this_tree.commit('rev1', rev_id='rev1')
513
456
        finally:
514
457
            tree_file.close()
515
458
 
516
 
    def test_merge_require_tree_root(self):
517
 
        tree = self.make_branch_and_tree(".")
518
 
        tree.lock_write()
519
 
        self.addCleanup(tree.unlock)
520
 
        self.build_tree(['a'])
521
 
        tree.add('a')
522
 
        tree.commit("added a")
523
 
        old_root_id = tree.get_root_id()
524
 
        first_rev = tree.branch.revision_history()[0]
525
 
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
526
 
                                          _mod_revision.NULL_REVISION,
527
 
                                          first_rev)
528
 
        merger.merge_type = _mod_merge.Merge3Merger
529
 
        conflict_count = merger.do_merge()
530
 
        self.assertEqual(0, conflict_count)
531
 
        self.assertEquals(set([old_root_id]), tree.all_file_ids())
532
 
        tree.set_parent_ids([])
533
 
 
534
459
    def test_merge_add_into_deleted_root(self):
535
460
        # Yes, people actually do this.  And report bugs if it breaks.
536
461
        source = self.make_branch_and_tree('source', format='rich-root-pack')
1902
1827
        builder.build_snapshot('C-id', ['A-id'], [])
1903
1828
        builder.build_snapshot('E-id', ['C-id', 'B-id'],
1904
1829
            [('unversion', 'a-id'),
1905
 
             ('flush', None),
1906
1830
             ('add', (u'a', 'a-id', 'directory', None))])
1907
1831
        builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1908
1832
        merge_obj = self.make_merge_obj(builder, 'E-id')
1926
1850
        builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1927
1851
        builder.build_snapshot('D-id', ['B-id', 'C-id'],
1928
1852
            [('unversion', 'a-id'),
1929
 
             ('flush', None),
1930
1853
             ('add', (u'a', 'a-id', 'directory', None))])
1931
1854
        merge_obj = self.make_merge_obj(builder, 'E-id')
1932
1855
        entries = list(merge_obj._entries_lca())
2940
2863
 
2941
2864
    def get_merger_factory(self):
2942
2865
        # Allows  the inner methods to access the test attributes
2943
 
        calls = self.calls
 
2866
        test = self
2944
2867
 
2945
2868
        class FooMerger(_mod_merge.ConfigurableFileMerger):
2946
2869
            name_prefix = "foo"
2947
2870
            default_files = ['bar']
2948
2871
 
2949
2872
            def merge_text(self, params):
2950
 
                calls.append('merge_text')
 
2873
                test.calls.append('merge_text')
2951
2874
                return ('not_applicable', None)
2952
2875
 
2953
2876
        def factory(merger):