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 |
||
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
20 |
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree |
1773.2.1
by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids. |
21 |
|
22 |
||
23 |
class TestGetParentIds(TestCaseWithWorkingTree): |
|
24 |
||
25 |
def test_get_parent_ids(self): |
|
26 |
t = self.make_branch_and_tree('t1') |
|
27 |
self.assertEqual([], t.get_parent_ids()) |
|
28 |
rev1_id = t.commit('foo', allow_pointless=True) |
|
29 |
self.assertEqual([rev1_id], t.get_parent_ids()) |
|
30 |
t2 = t.bzrdir.sprout('t2').open_workingtree() |
|
31 |
rev2_id = t2.commit('foo', allow_pointless=True) |
|
32 |
self.assertEqual([rev2_id], t2.get_parent_ids()) |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
33 |
t.merge_from_branch(t2.branch) |
1773.2.1
by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids. |
34 |
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 |
35 |
for parent_id in t.get_parent_ids(): |
36 |
self.assertIsInstance(parent_id, str) |
|
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. |
37 |
|
38 |
def test_pending_merges(self): |
|
1908.7.7
by Robert Collins
Deprecated WorkingTree.pending_merges. |
39 |
"""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. |
40 |
wt = self.make_branch_and_tree('.') |
41 |
self.assertEqual([], wt.get_parent_ids()) |
|
42 |
# the first pending merge replaces the 'last revision' because
|
|
43 |
# 'last revision' is shorthand for 'left most parent'
|
|
44 |
wt.add_pending_merge('foo@azkhazan-123123-abcabc') |
|
45 |
self.assertEqual(['foo@azkhazan-123123-abcabc'], wt.get_parent_ids()) |
|
46 |
# adding a merge which is already in the parents list gets ignored.
|
|
47 |
wt.add_pending_merge('foo@azkhazan-123123-abcabc') |
|
48 |
self.assertEqual(['foo@azkhazan-123123-abcabc'], wt.get_parent_ids()) |
|
49 |
# adding a different merge results in it being appended to the list -
|
|
50 |
# order is preserved.
|
|
51 |
wt.add_pending_merge('wibble@fofof--20050401--1928390812') |
|
52 |
self.assertEqual(['foo@azkhazan-123123-abcabc', |
|
53 |
'wibble@fofof--20050401--1928390812'], |
|
54 |
wt.get_parent_ids()) |