Rev 4754: In discussing with Robert, RepoReconciler should not be run on a repo in http://bazaar.launchpad.net/~jameinel/bzr/2.0.6-reconcile-stacked-441125

John Arbash Meinel john at arbash-meinel.com
Thu Jun 24 22:13:16 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.0.6-reconcile-stacked-441125

------------------------------------------------------------
revno: 4754
revision-id: john at arbash-meinel.com-20100624211309-8elavv5wlkddeu2e
parent: john at arbash-meinel.com-20100623205641-0spyysovkb8573kv
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.6-reconcile-stacked-441125
timestamp: Thu 2010-06-24 16:13:09 -0500
message:
  In discussing with Robert, RepoReconciler should not be run on a repo
  that has fallbacks set. (it will end up trying to reconcile the revs that are in the
  fallbacks, which isn't accurate).
  So add a simple assertion that we refuse to do such a thing.
-------------- next part --------------
=== modified file 'bzrlib/reconcile.py'
--- a/bzrlib/reconcile.py	2009-07-31 22:48:55 +0000
+++ b/bzrlib/reconcile.py	2010-06-24 21:13:09 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2006-2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -183,6 +183,9 @@
         self.aborted = False
         self.repo = repo
         self.thorough = thorough
+        if self.repo._fallback_repositories:
+            raise errors.BzrError('A repository should not be reconciled'
+                                  ' with fallbacks set.')
 
     def reconcile(self):
         """Perform reconciliation.

=== modified file 'bzrlib/tests/per_repository_reference/test_reconcile.py'
--- a/bzrlib/tests/per_repository_reference/test_reconcile.py	2010-06-23 20:56:41 +0000
+++ b/bzrlib/tests/per_repository_reference/test_reconcile.py	2010-06-24 21:13:09 +0000
@@ -23,14 +23,26 @@
 class TestReconcile(TestCaseWithExternalReferenceRepository):
     # Tests that reconcile works on stacked branches
 
+    def test_reconcile_refuses_stacked_repo(self):
+        # RepoReconciler is designed to be used directly a repository, without
+        # any fallbacks set. It should assert this.
+        base = self.make_repository('base')
+        repo = self.make_referring('referring', 'base')
+        # repo currently has a fallback repository set, and that is illegal for
+        # the purposes of reconcile
+        self.assertRaises(errors.BzrError, repo.reconcile)
+        # But if we open the repo directly, it should work
+        repo2 = repo.bzrdir.open_repository()
+        repo2.reconcile()
+
     def test_simple_reconcile(self):
         tree = self.make_branch_and_tree('sample')
         self.build_tree(['sample/a'])
-        tree.add(['a'], ['a-id'])
-        rev_id_base = tree.commit('a')
+        tree.add(['a'], ['z-id'])
+        rev_id_base = tree.commit('a', rev_id='revid-base')
         self.build_tree(['sample/b'])
         tree.add(['b'], ['b-id'])
-        rev_id_feature = tree.commit('add b')
+        rev_id_feature = tree.commit('add b', rev_id='revid-feature')
         tree.lock_read()
         self.addCleanup(tree.unlock)
         base = self.make_repository('base')
@@ -44,6 +56,8 @@
             repo.revisions._index.get_parent_map([rev_id_base]))
         # And neither should the base text
         self.assertEqual({('b-id', rev_id_feature): ()},
-            repo.texts._index.get_parent_map([('a-id', rev_id_base),
+            repo.texts._index.get_parent_map([('z-id', rev_id_base),
                                               ('b-id', rev_id_feature)]))
+        # Re-open the repository to get rid of the fallback repos
+        repo = repo.bzrdir.open_repository()
         reconciler = repo.reconcile(thorough=True)



More information about the bazaar-commits mailing list