~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-07 14:09:48 UTC
  • mfrom: (2948.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20071107140948-l3p8njdhgwstdkri
(robertc) Clean up obsolete_packs directory automatically. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
915
915
                self._remove_pack_from_memory(pack)
916
916
        # record the newly available packs and stop advertising the old
917
917
        # packs
918
 
        self._save_pack_names()
 
918
        self._save_pack_names(clear_obsolete_packs=True)
919
919
        # Move the old packs out of the way now they are no longer referenced.
920
920
        for revision_count, packs in pack_operations:
921
921
            self._obsolete_packs(packs)
1212
1212
        """Release the mutex around the pack-names index."""
1213
1213
        self.repo.control_files.unlock()
1214
1214
 
1215
 
    def _save_pack_names(self):
 
1215
    def _save_pack_names(self, clear_obsolete_packs=False):
1216
1216
        """Save the list of packs.
1217
1217
 
1218
1218
        This will take out the mutex around the pack names list for the
1219
1219
        duration of the method call. If concurrent updates have been made, a
1220
1220
        three-way merge between the current list and the current in memory list
1221
1221
        is performed.
 
1222
 
 
1223
        :param clear_obsolete_packs: If True, clear out the contents of the
 
1224
            obsolete_packs directory.
1222
1225
        """
1223
1226
        self.lock_names()
1224
1227
        try:
1244
1247
            self.transport.put_file('pack-names', builder.finish())
1245
1248
            # move the baseline forward
1246
1249
            self._packs_at_load = disk_nodes
 
1250
            # now clear out the obsolete packs directory
 
1251
            if clear_obsolete_packs:
 
1252
                self.transport.clone('obsolete_packs').delete_multi(
 
1253
                    self.transport.list_dir('obsolete_packs'))
1247
1254
        finally:
1248
1255
            self._unlock_names()
1249
1256
        # synchronise the memory packs list with what we just wrote: