/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_reconcile.py

  • Committer: Andrew Bennetts
  • Date: 2007-09-24 03:45:21 UTC
  • mto: (2745.6.48 reconcile-check-heads)
  • mto: This revision was merged to the branch mainline in revision 2905.
  • Revision ID: andrew.bennetts@canonical.com-20070924034521-hbp0u7drdwzgx8b0
Make reconcile abort gracefully if the revision index has bad parents.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""Tests for reconiliation of repositories."""
 
17
"""Tests for reconciliation of repositories."""
18
18
 
19
19
 
20
20
import bzrlib
21
21
import bzrlib.errors as errors
22
22
from bzrlib.inventory import Inventory
23
23
from bzrlib.reconcile import reconcile, Reconciler
 
24
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
24
25
from bzrlib.revision import Revision
25
 
from bzrlib.tests import TestSkipped
 
26
from bzrlib.tests import TestSkipped, TestNotApplicable
26
27
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository
 
28
from bzrlib.tests.repository_implementations.helpers import (
 
29
    TestCaseWithBrokenRevisionIndex,
 
30
    )
27
31
from bzrlib.transport import get_transport
28
32
from bzrlib.uncommit import uncommit
29
 
from bzrlib.workingtree import WorkingTree
30
33
 
31
34
 
32
35
class TestReconcile(TestCaseWithRepository):
374
377
        repo = d.open_repository()
375
378
        self.checkUnreconciled(d, repo.reconcile())
376
379
        self.checkUnreconciled(d, repo.reconcile(thorough=True))
 
380
 
 
381
 
 
382
class TestBadRevisionParents(TestCaseWithBrokenRevisionIndex):
 
383
 
 
384
    def test_aborts_if_bad_parents_in_index(self):
 
385
        """Reconcile refuses to proceed if the revision index is wrong when
 
386
        checked against the revision texts, so that it does not generate broken
 
387
        data.
 
388
 
 
389
        Ideally reconcile would fix this, but until we implement that we just
 
390
        make sure we safely detect this problem.
 
391
        """
 
392
        repo = self.make_repo_with_extra_ghost_index()
 
393
        reconciler = repo.reconcile(thorough=True)
 
394
        self.assertTrue(reconciler.aborted,
 
395
            "reconcile should have aborted due to bad parents.")
 
396
 
 
397
    def test_does_not_abort_on_clean_repo(self):
 
398
        repo = self.make_repository('.')
 
399
        reconciler = repo.reconcile(thorough=True)
 
400
        self.assertFalse(reconciler.aborted,
 
401
            "reconcile should not have aborted on an unbroken repository.")
 
402
 
 
403