Rev 5613: (vila) Merge 2.2 into 2.3 including bugfix for #701940 (Vincent in file:///home/pqm/archives/thelove/bzr/2.3/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 20 23:42:23 UTC 2011


At file:///home/pqm/archives/thelove/bzr/2.3/

------------------------------------------------------------
revno: 5613 [merge]
revision-id: pqm at pqm.ubuntu.com-20110120234220-hk3rddph3rxjsatd
parent: pqm at pqm.ubuntu.com-20110115180856-50gg6zzuh9idj69q
parent: v.ladeuil+lp at free.fr-20110120211510-9dl4tbl77dad86pl
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.3
timestamp: Thu 2011-01-20 23:42:20 +0000
message:
  (vila) Merge 2.2 into 2.3 including bugfix for #701940 (Vincent
  	Ladeuil)
modified:
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
  doc/en/whats-new/whats-new-in-2.2.txt whatsnewin2.2.txt-20100304041442-cj7jdn23zakcw08l-1
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2010-11-22 03:35:24 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2011-01-20 21:15:10 +0000
@@ -1573,6 +1573,20 @@
         mutter('Packing repository %s, which has %d pack files, '
             'containing %d revisions with hint %r.', self, total_packs,
             total_revisions, hint)
+        while True:
+            try:
+                self._try_pack_operations(hint)
+            except RetryPackOperations:
+                continue
+            break
+
+        if clean_obsolete_packs:
+            self._clear_obsolete_packs()
+
+    def _try_pack_operations(self, hint):
+        """Calculate the pack operations based on the hint (if any), and
+        execute them.
+        """
         # determine which packs need changing
         pack_operations = [[0, []]]
         for pack in self.all_packs():
@@ -1581,10 +1595,8 @@
                 # or this pack was included in the hint.
                 pack_operations[-1][0] += pack.get_revision_count()
                 pack_operations[-1][1].append(pack)
-        self._execute_pack_operations(pack_operations, OptimisingPacker)
-
-        if clean_obsolete_packs:
-            self._clear_obsolete_packs()
+        self._execute_pack_operations(pack_operations, OptimisingPacker,
+            reload_func=self._restart_pack_operations)
 
     def plan_autopack_combinations(self, existing_packs, pack_distribution):
         """Plan a pack operation.
@@ -2044,6 +2056,14 @@
             raise
         raise errors.RetryAutopack(self.repo, False, sys.exc_info())
 
+    def _restart_pack_operations(self):
+        """Reload the pack names list, and restart the autopack code."""
+        if not self.reload_pack_names():
+            # Re-raise the original exception, because something went missing
+            # and a restart didn't find it
+            raise
+        raise RetryPackOperations(self.repo, False, sys.exc_info())
+
     def _clear_obsolete_packs(self, preserve=None):
         """Delete everything from the obsolete-packs directory.
 
@@ -2933,3 +2953,17 @@
         return ("Development repository format, currently the same as "
             "1.6.1-subtree with B+Tree indices.\n")
 
+
+class RetryPackOperations(errors.RetryWithNewPacks):
+    """Raised when we are packing and we find a missing file.
+
+    Meant as a signaling exception, to tell the RepositoryPackCollection.pack
+    code it should try again.
+    """
+
+    internal_error = True
+
+    _fmt = ("Pack files have changed, reload and try pack again."
+            " context: %(context)s %(orig_error)s")
+
+

=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py	2011-01-11 17:54:38 +0000
+++ b/bzrlib/tests/test_knit.py	2011-01-20 21:15:10 +0000
@@ -338,6 +338,33 @@
         writer.end()
         return memos
 
+    def test_pack_collection_pack_retries(self):
+        """An explicit pack of a pack collection succeeds even when a
+        concurrent pack happens.
+        """
+        builder = self.make_branch_builder('.')
+        builder.start_series()
+        builder.build_snapshot('rev-1', None, [
+            ('add', ('', 'root-id', 'directory', None)),
+            ('add', ('file', 'file-id', 'file', 'content\nrev 1\n')),
+            ])
+        builder.build_snapshot('rev-2', ['rev-1'], [
+            ('modify', ('file-id', 'content\nrev 2\n')),
+            ])
+        builder.build_snapshot('rev-3', ['rev-2'], [
+            ('modify', ('file-id', 'content\nrev 3\n')),
+            ])
+        self.addCleanup(builder.finish_series)
+        b = builder.get_branch()
+        self.addCleanup(b.lock_write().unlock)
+        repo = b.repository
+        collection = repo._pack_collection
+        # Concurrently repack the repo.
+        reopened_repo = repo.bzrdir.open_repository()
+        reopened_repo.pack()
+        # Pack the new pack.
+        collection.pack()
+
     def make_vf_for_retrying(self):
         """Create 3 packs and a reload function.
 

=== modified file 'doc/en/whats-new/whats-new-in-2.2.txt'
--- a/doc/en/whats-new/whats-new-in-2.2.txt	2010-11-25 15:56:20 +0000
+++ b/doc/en/whats-new/whats-new-in-2.2.txt	2011-01-20 18:42:20 +0000
@@ -32,6 +32,11 @@
 
 See the :doc:`../release-notes/index` for details.
 
+Bazaar 2.2.3 focused on fixes related to interactions with the launchpad
+server and python-2.7 compatibility.
+
+See the :doc:`../release-notes/index` for details.
+
 Bazaar 2.2 is fully compatible both locally and on the network with 2.0
 and 2.1, and can read and write repositories generated by all previous
 versions.




More information about the bazaar-commits mailing list