Rev 2975: (robertc) Clean up obsolete_packs directory automatically. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Nov 7 14:09:51 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2975
revision-id: pqm at pqm.ubuntu.com-20071107140948-l3p8njdhgwstdkri
parent: pqm at pqm.ubuntu.com-20071106124804-ehlreba0lfp3kab9
parent: robertc at robertcollins.net-20071107131409-v6icfi9sg0m6209b
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-11-07 14:09:48 +0000
message:
  (robertc) Clean up obsolete_packs directory automatically. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
    ------------------------------------------------------------
    revno: 2948.1.3
    merged: robertc at robertcollins.net-20071107131409-v6icfi9sg0m6209b
    parent: robertc at robertcollins.net-20071107131037-1sl8cq53pxb9qzhv
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: integration
    timestamp: Thu 2007-11-08 00:14:09 +1100
    message:
      Move NEWS entry for dev inclusion.
    ------------------------------------------------------------
    revno: 2948.1.2
    merged: robertc at robertcollins.net-20071107131037-1sl8cq53pxb9qzhv
    parent: robertc at robertcollins.net-20071029204506-19todg20tf48abis
    parent: pqm at pqm.ubuntu.com-20071106124804-ehlreba0lfp3kab9
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: integration
    timestamp: Thu 2007-11-08 00:10:37 +1100
    message:
      Merge bzr.dev.
    ------------------------------------------------------------
    revno: 2948.1.1
    merged: robertc at robertcollins.net-20071029204506-19todg20tf48abis
    parent: pqm at pqm.ubuntu.com-20071029050400-j2jmz8smj2yecfrr
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: pack-unlink-old-packs
    timestamp: Tue 2007-10-30 07:45:06 +1100
    message:
      * Obsolete packs are now cleaned up by pack and autopack operations.
        (Robert Collins, #153789)
=== modified file 'NEWS'
--- a/NEWS	2007-11-06 11:11:18 +0000
+++ b/NEWS	2007-11-07 13:14:09 +0000
@@ -55,6 +55,9 @@
    * Don't use timeout in HttpServer anymore.
      (Vincent Ladeuil, #158972).
 
+   * Obsolete packs are now cleaned up by pack and autopack operations.
+     (Robert Collins, #153789)
+
    * Reconcile now shows progress bars. (Robert Collins, #159351)
 
    * Unicode-safe output from ``bzr info``. The output will be encoded

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-11-04 21:58:30 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-11-07 13:10:37 +0000
@@ -915,7 +915,7 @@
                 self._remove_pack_from_memory(pack)
         # record the newly available packs and stop advertising the old
         # packs
-        self._save_pack_names()
+        self._save_pack_names(clear_obsolete_packs=True)
         # Move the old packs out of the way now they are no longer referenced.
         for revision_count, packs in pack_operations:
             self._obsolete_packs(packs)
@@ -1212,13 +1212,16 @@
         """Release the mutex around the pack-names index."""
         self.repo.control_files.unlock()
 
-    def _save_pack_names(self):
+    def _save_pack_names(self, clear_obsolete_packs=False):
         """Save the list of packs.
 
         This will take out the mutex around the pack names list for the
         duration of the method call. If concurrent updates have been made, a
         three-way merge between the current list and the current in memory list
         is performed.
+
+        :param clear_obsolete_packs: If True, clear out the contents of the
+            obsolete_packs directory.
         """
         self.lock_names()
         try:
@@ -1244,6 +1247,10 @@
             self.transport.put_file('pack-names', builder.finish())
             # move the baseline forward
             self._packs_at_load = disk_nodes
+            # now clear out the obsolete packs directory
+            if clear_obsolete_packs:
+                self.transport.clone('obsolete_packs').delete_multi(
+                    self.transport.list_dir('obsolete_packs'))
         finally:
             self._unlock_names()
         # synchronise the memory packs list with what we just wrote:

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2007-11-04 20:35:32 +0000
+++ b/bzrlib/tests/test_repository.py	2007-11-07 13:10:37 +0000
@@ -888,6 +888,9 @@
         # there should be 9 packs:
         index = GraphIndex(trans, 'pack-names', None)
         self.assertEqual(9, len(list(index.iter_all_entries())))
+        # insert some files in obsolete_packs which should be removed by pack.
+        trans.put_bytes('obsolete_packs/foo', '123')
+        trans.put_bytes('obsolete_packs/bar', '321')
         # committing one more should coalesce to 1 of 10.
         tree.commit('commit triggering pack')
         index = GraphIndex(trans, 'pack-names', None)
@@ -896,6 +899,11 @@
         tree = tree.bzrdir.open_workingtree()
         check_result = tree.branch.repository.check(
             [tree.branch.last_revision()])
+        # We should have 50 (10x5) files in the obsolete_packs directory.
+        obsolete_files = list(trans.list_dir('obsolete_packs'))
+        self.assertFalse('foo' in obsolete_files)
+        self.assertFalse('bar' in obsolete_files)
+        self.assertEqual(50, len(obsolete_files))
         # XXX: Todo check packs obsoleted correctly - old packs and indices
         # in the obsolete_packs directory.
         large_pack_name = list(index.iter_all_entries())[0][1][0]




More information about the bazaar-commits mailing list