~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_reconcile.py

  • Committer: Andrew Bennetts
  • Date: 2007-11-10 15:09:09 UTC
  • mfrom: (2916.2.17 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071110150909-ik5254kgn930th10
Merge streamable-containers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        repo.commit_write_group()
70
70
        repo.unlock()
71
71
 
 
72
        def add_commit(repo, revision_id, parent_ids):
 
73
            repo.lock_write()
 
74
            repo.start_write_group()
 
75
            inv = Inventory(revision_id=revision_id)
 
76
            inv.root.revision = revision_id
 
77
            root_id = inv.root.file_id
 
78
            sha1 = repo.add_inventory(revision_id, inv, parent_ids)
 
79
            vf = repo.weave_store.get_weave_or_empty(root_id,
 
80
                repo.get_transaction())
 
81
            vf.add_lines(revision_id, [], [])
 
82
            rev = bzrlib.revision.Revision(timestamp=0,
 
83
                                           timezone=None,
 
84
                                           committer="Foo Bar <foo@example.com>",
 
85
                                           message="Message",
 
86
                                           inventory_sha1=sha1,
 
87
                                           revision_id=revision_id)
 
88
            rev.parent_ids = parent_ids
 
89
            repo.add_revision(revision_id, rev)
 
90
            repo.commit_write_group()
 
91
            repo.unlock()
72
92
        # an empty inventory with no revision for testing with.
73
93
        # this is referenced by 'references_missing' to let us test
74
94
        # that all the cached data is correctly converted into ghost links
77
97
        repo.lock_write()
78
98
        repo.start_write_group()
79
99
        repo.add_inventory('missing', inv, [])
80
 
        inv = Inventory(revision_id='references_missing')
81
 
        inv.root.revision = 'references_missing'
82
 
        sha1 = repo.add_inventory('references_missing', inv, ['missing'])
83
 
        rev = Revision(timestamp=0,
84
 
                       timezone=None,
85
 
                       committer="Foo Bar <foo@example.com>",
86
 
                       message="Message",
87
 
                       inventory_sha1=sha1,
88
 
                       revision_id='references_missing')
89
 
        rev.parent_ids = ['missing']
90
 
        repo.add_revision('references_missing', rev)
91
100
        repo.commit_write_group()
92
101
        repo.unlock()
 
102
        add_commit(repo, 'references_missing', ['missing'])
93
103
 
94
104
        # a inventory with no parents and the revision has parents..
95
105
        # i.e. a ghost.
96
106
        repo = self.make_repository('inventory_one_ghost')
97
 
        repo.lock_write()
98
 
        repo.start_write_group()
99
 
        inv = Inventory(revision_id='ghost')
100
 
        inv.root.revision = 'ghost'
101
 
        sha1 = repo.add_inventory('ghost', inv, [])
102
 
        rev = Revision(timestamp=0,
103
 
                       timezone=None,
104
 
                       committer="Foo Bar <foo@example.com>",
105
 
                       message="Message",
106
 
                       inventory_sha1=sha1,
107
 
                       revision_id='ghost')
108
 
        rev.parent_ids = ['the_ghost']
109
 
        repo.add_revision('ghost', rev)
110
 
        repo.commit_write_group()
111
 
        repo.unlock()
 
107
        add_commit(repo, 'ghost', ['the_ghost'])
112
108
         
113
109
        # a inventory with a ghost that can be corrected now.
114
110
        t.copy_tree('inventory_one_ghost', 'inventory_ghost_present')
115
111
        bzrdir_url = self.get_url('inventory_ghost_present')
116
112
        bzrdir = bzrlib.bzrdir.BzrDir.open(bzrdir_url)
117
113
        repo = bzrdir.open_repository()
118
 
        repo.lock_write()
119
 
        repo.start_write_group()
120
 
        inv = Inventory(revision_id='the_ghost')
121
 
        inv.root.revision = 'the_ghost'
122
 
        sha1 = repo.add_inventory('the_ghost', inv, [])
123
 
        rev = Revision(timestamp=0,
124
 
                       timezone=None,
125
 
                       committer="Foo Bar <foo@example.com>",
126
 
                       message="Message",
127
 
                       inventory_sha1=sha1,
128
 
                       revision_id='the_ghost')
129
 
        rev.parent_ids = []
130
 
        repo.add_revision('the_ghost', rev)
131
 
        repo.commit_write_group()
132
 
        repo.unlock()
 
114
        add_commit(repo, 'the_ghost', [])
133
115
 
134
116
    def checkEmptyReconcile(self, **kwargs):
135
117
        """Check a reconcile on an empty repository."""
212
194
                         repo.get_ancestry('references_missing'))
213
195
 
214
196
    def check_missing_was_removed(self, repo):
215
 
        backup = repo.control_weaves.get_weave('inventory.backup',
216
 
                                               repo.get_transaction())
217
 
        self.assertTrue('missing' in backup.versions())
 
197
        if repo._reconcile_backsup_inventory:
 
198
            backup = repo.control_weaves.get_weave('inventory.backup',
 
199
                                                   repo.get_transaction())
 
200
            self.assertTrue('missing' in backup.versions())
218
201
        self.assertRaises(errors.RevisionNotPresent,
219
202
                          repo.get_inventory, 'missing')
220
203
 
340
323
        repo.start_write_group()
341
324
        inv = Inventory(revision_id='wrong-secondary-parent')
342
325
        inv.root.revision = 'wrong-secondary-parent'
 
326
        if repo.supports_rich_root():
 
327
            root_id = inv.root.file_id
 
328
            vf = repo.weave_store.get_weave_or_empty(root_id,
 
329
                repo.get_transaction())
 
330
            vf.add_lines('wrong-secondary-parent', [], [])
343
331
        sha1 = repo.add_inventory('wrong-secondary-parent', inv, ['1', '3', '2'])
344
332
        rev = Revision(timestamp=0,
345
333
                       timezone=None,