Rev 3802: Merge in the debug_hacks. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/merge_dev

John Arbash Meinel john at arbash-meinel.com
Sun Dec 7 17:43:53 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/merge_dev

------------------------------------------------------------
revno: 3802
revision-id: john at arbash-meinel.com-20081207174338-vx3sm4yzedmk338j
parent: john at arbash-meinel.com-20081207174043-xjxckelplsqdey73
parent: john at arbash-meinel.com-20081203043230-f0riipwg6wkjr6ae
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge_dev
timestamp: Sun 2008-12-07 11:43:38 -0600
message:
  Merge in the debug_hacks.
modified:
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
    ------------------------------------------------------------
    revno: 3791.1.16
    revision-id: john at arbash-meinel.com-20081203043230-f0riipwg6wkjr6ae
    parent: john at arbash-meinel.com-20081203041138-ecssp5m0mqxjgzhu
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: chk_map
    timestamp: Tue 2008-12-02 22:32:30 -0600
    message:
      Hack in some other code, so we can determine how much compression we get.
      
      This just tracks the 'old size' of all the packs that are getting combined versus the
      'new size' of the newly created pack file.
    modified:
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
    ------------------------------------------------------------
    revno: 3791.1.15
    revision-id: john at arbash-meinel.com-20081203041138-ecssp5m0mqxjgzhu
    parent: john at arbash-meinel.com-20081203035643-0x4npc4s8mh8nqlh
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: chk_map
    timestamp: Tue 2008-12-02 22:11:38 -0600
    message:
      Add size information to the mutter when -Dpack is used.
      
      Also fix a bug in -Dpack when the repository doesn't support chk_bytes.
    modified:
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
-------------- next part --------------
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-12-07 16:46:56 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-12-07 17:43:38 +0000
@@ -418,9 +418,15 @@
                 '../packs/' + self.name + '.pack')
         self._state = 'finished'
         if 'pack' in debug.debug_flags:
+            try:
+                size = self.pack_transport.stat(self.name + '.pack').st_size
+                size /= 1024.*1024
+            except errors.TransportNotPossible:
+                size = -1
             # XXX: size might be interesting?
-            mutter('%s: create_pack: pack renamed into place: %s%s->%s%s t+%6.3fs',
-                time.ctime(), self.upload_transport.base, self.random_name,
+            mutter('%s: create_pack: pack renamed into place (%.3fMB): %s%s->%s%s'
+                   ' t+%6.3fs',
+                time.ctime(), size, self.upload_transport.base, self.random_name,
                 self.pack_transport, self.name,
                 time.time() - self.start_time)
 
@@ -815,10 +821,17 @@
                 rev_count = len(self.revision_ids)
             else:
                 rev_count = 'all'
-            mutter('%s: create_pack: creating pack from source packs: '
+            size = 0
+            for a_pack in self.packs:
+                try:
+                    size += a_pack.pack_transport.stat(a_pack.name + '.pack').st_size
+                except errors.TransportNotPossible:
+                    pass
+            size /= 1024.*1024
+            mutter('%s: create_pack: creating pack from source packs (%.3fMB): '
                 '%s%s %s revisions wanted %s t=0',
-                time.ctime(), self._pack_collection._upload_transport.base, new_pack.random_name,
-                plain_pack_list, rev_count)
+                time.ctime(), size, self._pack_collection._upload_transport.base,
+                new_pack.random_name, plain_pack_list, rev_count)
         self._copy_revision_texts()
         self._copy_inventory_texts()
         self._copy_text_texts()
@@ -1349,12 +1362,6 @@
         total_packs = len(self._names)
         if self._max_pack_count(total_revisions) >= total_packs:
             return False
-        # XXX: the following may want to be a class, to pack with a given
-        # policy.
-        mutter('Auto-packing repository %s, which has %d pack files, '
-            'containing %d revisions into no more than %d packs.', self,
-            total_packs, total_revisions,
-            self._max_pack_count(total_revisions))
         # determine which packs need changing
         pack_distribution = self.pack_distribution(total_revisions)
         existing_packs = []
@@ -1383,7 +1390,17 @@
             ' revisions', self, total_packs, total_revisions, num_old_packs,
             num_new_packs, num_revs_affected)
         self._execute_pack_operations(pack_operations)
-        mutter('Auto-packing repository %s completed', self)
+        old_size, new_size = self._execute_pack_operations(pack_operations)
+        if old_size is None:
+            old_size = -1
+        else:
+            old_size /= (1024.0*1024)
+        if new_size is None:
+            new_size = -1
+        else:
+            new_size /= (1024.0*1024)
+        mutter('Auto-packing repository %s completed %.3fMB => %.3fMB',
+               self.transport.base, old_size, new_size)
         return True
 
     def _execute_pack_operations(self, pack_operations, _packer_class=Packer):
@@ -1393,19 +1410,32 @@
         :param _packer_class: The class of packer to use (default: Packer).
         :return: None.
         """
+        new_size = 0
         for revision_count, packs in pack_operations:
             # we may have no-ops from the setup logic
             if len(packs) == 0:
                 continue
-            _packer_class(self, packs, '.autopack').pack()
+            new_pack = _packer_class(self, packs, '.autopack').pack()
+            try:
+                new_size += new_pack.pack_transport.stat(new_pack.name + '.pack').st_size
+            except errors.TransportNotPossible:
+                new_size = None
             for pack in packs:
                 self._remove_pack_from_memory(pack)
         # record the newly available packs and stop advertising the old
         # packs
+        if new_size is None:
+            old_size = None
+        else:
+            old_size = 0
+            for revision_count, packs in pack_operations:
+                for a_pack in packs:
+                    old_size += a_pack.pack_transport.stat(a_pack.name + '.pack').st_size
         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)
+        return old_size, new_size
 
     def lock_names(self):
         """Acquire the mutex around the pack-names index.



More information about the bazaar-commits mailing list