~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.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:
198
198
            signature_index)
199
199
        self.name = name
200
200
        self.pack_transport = pack_transport
201
 
        assert None not in (revision_index, inventory_index, text_index,
202
 
            signature_index, name, pack_transport)
 
201
        if None in (revision_index, inventory_index, text_index,
 
202
                signature_index, name, pack_transport):
 
203
            raise AssertionError()
203
204
 
204
205
    def __eq__(self, other):
205
206
        return self.__dict__ == other.__dict__
322
323
 
323
324
    def access_tuple(self):
324
325
        """Return a tuple (transport, name) for the pack content."""
325
 
        assert self._state in ('open', 'finished')
326
326
        if self._state == 'finished':
327
327
            return Pack.access_tuple(self)
328
 
        else:
 
328
        elif self._state == 'open':
329
329
            return self.upload_transport, self.random_name
 
330
        else:
 
331
            raise AssertionError(self._state)
330
332
 
331
333
    def data_inserted(self):
332
334
        """True if data has been added to this pack."""
495
497
        :param index: An index from the pack parameter.
496
498
        :param pack: A Pack instance.
497
499
        """
498
 
        assert self.add_callback is None, \
499
 
            "%s already has a writable index through %s" % \
500
 
            (self, self.add_callback)
 
500
        if self.add_callback is not None:
 
501
            raise AssertionError(
 
502
                "%s already has a writable index through %s" % \
 
503
                (self, self.add_callback))
501
504
        # allow writing: queue writes to a new index
502
505
        self.add_index(index, pack)
503
506
        # Updates the index to packs mapping as a side effect,
1149
1152
        
1150
1153
        :param pack: A Pack object.
1151
1154
        """
1152
 
        assert pack.name not in self._packs_by_name
 
1155
        if pack.name in self._packs_by_name:
 
1156
            raise AssertionError()
1153
1157
        self.packs.append(pack)
1154
1158
        self._packs_by_name[pack.name] = pack
1155
1159
        self.revision_index.add_index(pack.revision_index, pack)
2169
2173
        """
2170
2174
        if not _found:
2171
2175
            format = RepositoryFormat.find_format(a_bzrdir)
2172
 
            assert format.__class__ ==  self.__class__
2173
2176
        if _override_transport is not None:
2174
2177
            repo_transport = _override_transport
2175
2178
        else: