/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2006 Canonical Ltd
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
17
18
"""Tests for interface conformance of 'workingtree.get_parent_ids'"""
19
6913.4.3 by Jelmer Vernooij
Skip tests against formats that don't support right hand side parents that are ghosts.
20
from breezy.tests import TestNotApplicable
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
21
from breezy.tests.per_workingtree import TestCaseWithWorkingTree
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
22
23
24
class TestGetParentIds(TestCaseWithWorkingTree):
25
26
    def test_get_parent_ids(self):
27
        t = self.make_branch_and_tree('t1')
28
        self.assertEqual([], t.get_parent_ids())
29
        rev1_id = t.commit('foo', allow_pointless=True)
30
        self.assertEqual([rev1_id], t.get_parent_ids())
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
31
        t2 = t.controldir.sprout('t2').open_workingtree()
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
32
        rev2_id = t2.commit('foo', allow_pointless=True)
33
        self.assertEqual([rev2_id], t2.get_parent_ids())
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
34
        t.merge_from_branch(t2.branch)
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
35
        self.assertEqual([rev1_id, rev2_id], t.get_parent_ids())
2249.5.7 by John Arbash Meinel
Make sure WorkingTree revision_ids are also returned as utf8 strings
36
        for parent_id in t.get_parent_ids():
7045.4.1 by Jelmer Vernooij
Some brz-git fixes.
37
            self.assertIsInstance(parent_id, bytes)
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
38
39
    def test_pending_merges(self):
1908.7.7 by Robert Collins
Deprecated WorkingTree.pending_merges.
40
        """Test the correspondence between set pending merges and get_parent_ids."""
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
41
        wt = self.make_branch_and_tree('.')
42
        self.assertEqual([], wt.get_parent_ids())
6913.4.3 by Jelmer Vernooij
Skip tests against formats that don't support right hand side parents that are ghosts.
43
        if not wt._format. supports_righthand_parent_id_as_ghost:
44
            raise TestNotApplicable(
7143.15.2 by Jelmer Vernooij
Run autopep8.
45
                'format does not support right hand side parents '
46
                'that are ghosts')
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
47
        # the first pending merge replaces the 'last revision' because
48
        # 'last revision' is shorthand for 'left most parent'
7029.4.2 by Jelmer Vernooij
Fix more merge tests.
49
        wt.add_pending_merge(b'foo@azkhazan-123123-abcabc')
50
        self.assertEqual([b'foo@azkhazan-123123-abcabc'], wt.get_parent_ids())
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
51
        # adding a merge which is already in the parents list gets ignored.
7029.4.2 by Jelmer Vernooij
Fix more merge tests.
52
        wt.add_pending_merge(b'foo@azkhazan-123123-abcabc')
53
        self.assertEqual([b'foo@azkhazan-123123-abcabc'], wt.get_parent_ids())
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
54
        # adding a different merge results in it being appended to the list -
55
        # order is preserved.
7029.4.2 by Jelmer Vernooij
Fix more merge tests.
56
        wt.add_pending_merge(b'wibble@fofof--20050401--1928390812')
57
        self.assertEqual([b'foo@azkhazan-123123-abcabc',
7143.15.2 by Jelmer Vernooij
Run autopep8.
58
                          b'wibble@fofof--20050401--1928390812'],
59
                         wt.get_parent_ids())