~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
            parents = self._rev_graph[rev_id]
185
185
            # double check this really is in topological order.
186
186
            unavailable = [p for p in parents if p not in new_inventory_vf]
187
 
            assert len(unavailable) == 0
 
187
            if unavailable:
 
188
                raise AssertionError('unavailable parents: %r'
 
189
                    % unavailable)
188
190
            # this entry has all the non ghost parents in the inventory
189
191
            # file already.
190
192
            self._reweave_step('adding inventories')
203
205
            new_inventory_vf._save()
204
206
        # if this worked, the set of new_inventory_vf.names should equal
205
207
        # self.pending
206
 
        assert set(new_inventory_vf.versions()) == self.pending
 
208
        if not (set(new_inventory_vf.versions()) == self.pending):
 
209
            raise AssertionError()
207
210
        self.pb.update('Writing weave')
208
211
        self.repo.control_weaves.copy(new_inventory_vf, 'inventory', self.repo.get_transaction())
209
212
        self.repo.control_weaves.delete('inventory.new', self.repo.get_transaction())
221
224
        # analyse revision id rev_id and put it in the stack.
222
225
        self._reweave_step('loading revisions')
223
226
        rev = self.repo.get_revision_reconcile(rev_id)
224
 
        assert rev.revision_id == rev_id
225
227
        parents = []
226
228
        for parent in rev.parent_ids:
227
229
            if self._parent_is_available(parent):
340
342
            # double check this really is in topological order, ignoring existing ghosts.
341
343
            unavailable = [p for p in parents if p not in new_inventory_vf and
342
344
                p in self.revisions]
343
 
            assert len(unavailable) == 0
 
345
            if unavailable:
 
346
                raise AssertionError(
 
347
                    'unavailable parents: %r' % (unavailable,))
344
348
            # this entry has all the non ghost parents in the inventory
345
349
            # file already.
346
350
            self._reweave_step('adding inventories')
350
354
 
351
355
        # if this worked, the set of new_inventory_vf.names should equal
352
356
        # self.pending
353
 
        assert set(new_inventory_vf.versions()) == set(self.revisions.versions())
 
357
        if not(set(new_inventory_vf.versions()) == set(self.revisions.versions())):
 
358
            raise AssertionError()
354
359
        self.pb.update('Writing weave')
355
360
        self.repo.control_weaves.copy(new_inventory_vf, 'inventory', self.transaction)
356
361
        self.repo.control_weaves.delete('inventory.new', self.transaction)