~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil, Patch Queue Manager, Jelmer Vernooij
  • Date: 2017-01-17 16:20:41 UTC
  • mfrom: (6619.1.2 trunk)
  • Revision ID: tarmac-20170117162041-oo62uk1qsmgc9j31
Merge 2.7 into trunk including fixes for bugs #1622039, #1644003, #1579093 and #1645017. [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2011, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Tests for branch implementations - test reconcile() functionality"""
18
18
 
19
19
from bzrlib import errors, reconcile
 
20
from bzrlib.branch import BzrBranch
 
21
from bzrlib.symbol_versioning import deprecated_in
20
22
from bzrlib.tests.per_branch import TestCaseWithBranch
 
23
from bzrlib.tests import TestNotApplicable
21
24
 
22
25
 
23
26
class TestBranchReconcile(TestCaseWithBranch):
24
27
 
25
28
    def test_reconcile_fixes_invalid_revhistory(self):
 
29
        if not isinstance(self.branch_format, BzrBranch):
 
30
            raise TestNotApplicable("test only applies to bzr formats")
26
31
        # Different formats have different ways of handling invalid revision
27
32
        # histories, so the setup portion is customized
28
33
        tree = self.make_branch_and_tree('test')
42
47
        r5 = tree.commit('five')
43
48
        # Now, try to set an invalid history
44
49
        try:
45
 
            tree.branch.set_revision_history([r1, r2b, r5])
 
50
            self.applyDeprecated(deprecated_in((2, 4, 0)),
 
51
                tree.branch.set_revision_history, [r1, r2b, r5])
46
52
            if tree.branch.last_revision_info() != (3, r5):
47
53
                # RemoteBranch silently corrects an impossible revision
48
54
                # history given to set_revision_history.  It can be tricked
73
79
 
74
80
    def test_reconcile_handles_ghosts_in_revhistory(self):
75
81
        tree = self.make_branch_and_tree('test')
 
82
        if not tree.branch.repository._format.supports_ghosts:
 
83
            raise TestNotApplicable("repository format does not support ghosts")
76
84
        tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
77
85
        r1 = tree.commit('one')
78
86
        r2 = tree.commit('two')
79
87
        tree.branch.set_last_revision_info(2, r2)
80
88
 
81
89
        reconciler = tree.branch.reconcile()
82
 
        self.assertEquals([r1, r2], tree.branch.revision_history())
 
90
        self.assertEqual(r2, tree.branch.last_revision())