/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: John Arbash Meinel
  • Date: 2008-10-27 20:18:48 UTC
  • mto: This revision was merged to the branch mainline in revision 3913.
  • Revision ID: john@arbash-meinel.com-20081027201848-m6oepfo8f4jvwf4p
We need the Packer class to cleanup if it is getting a Retry it isn't handling.

This is probably not the cleanest way to do it, but if we need Packer.new_pack.abort() to be
called, or we leave an open file handle around.

Show diffs side-by-side

added added

removed removed

Lines of Context:
595
595
        # XXX: - duplicate code warning with start_write_group; fix before
596
596
        #      considering 'done'.
597
597
        if self._pack_collection._new_pack is not None:
598
 
            raise errors.BzrError('call to create_pack_from_packs while '
599
 
                'another pack is being written.')
 
598
            raise errors.BzrError('call to %s.pack() while another pack is'
 
599
                                  ' being written.'
 
600
                                  % (self.__class__.__name__,))
600
601
        if self.revision_ids is not None:
601
602
            if len(self.revision_ids) == 0:
602
603
                # silly fetch request.
1248
1249
            try:
1249
1250
                return self._do_autopack()
1250
1251
            except errors.RetryAutopack, e:
1251
 
                # If we get a RetryAutopack exception, we should just try again
 
1252
                # If we get a RetryAutopack exception, we should abort the
 
1253
                # current action, and retry.
1252
1254
                pass
1253
1255
 
1254
 
 
1255
1256
    def _do_autopack(self):
1256
1257
        # XXX: Should not be needed when the management of indices is sane.
1257
1258
        total_revisions = self.revision_index.combined_index.key_count()
1299
1300
            # we may have no-ops from the setup logic
1300
1301
            if len(packs) == 0:
1301
1302
                continue
1302
 
            _packer_class(self, packs, '.autopack', reload_func=reload_func).pack()
 
1303
            packer = _packer_class(self, packs, '.autopack',
 
1304
                                   reload_func=reload_func)
 
1305
            try:
 
1306
                packer.pack()
 
1307
            except errors.RetryWithNewPacks:
 
1308
                # An exception is propagating out of this context, make sure
 
1309
                # this packer has cleaned up.
 
1310
                if packer.new_pack is not None:
 
1311
                    packer.new_pack.abort()
 
1312
                raise
1303
1313
            for pack in packs:
1304
1314
                self._remove_pack_from_memory(pack)
1305
1315
        # record the newly available packs and stop advertising the old