bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1908.5.2
by Robert Collins
Create and test set_parent_trees. |
1 |
# Copyright (C) 2006 by Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
import os |
|
18 |
||
19 |
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree |
|
20 |
from bzrlib.branch import Branch |
|
21 |
from bzrlib.revision import Revision |
|
22 |
from bzrlib.uncommit import uncommit |
|
23 |
import bzrlib.xml5 |
|
24 |
||
25 |
||
26 |
class TestSetParents(TestCaseWithWorkingTree): |
|
27 |
||
28 |
def test_set_no_parents(self): |
|
29 |
t = self.make_branch_and_tree('.') |
|
30 |
t.set_parent_trees([]) |
|
31 |
self.assertEqual([], t.get_parent_ids()) |
|
32 |
# now give it a real parent, and then set it to no parents again.
|
|
33 |
t.commit('first post') |
|
34 |
t.set_parent_trees([]) |
|
35 |
self.assertEqual([], t.get_parent_ids()) |
|
36 |
self.assertEqual(None, t.last_revision()) |
|
37 |
self.assertEqual([], t.pending_merges()) |
|
38 |
||
39 |
def test_set_one_ghost_parent(self): |
|
40 |
t = self.make_branch_and_tree('.') |
|
41 |
t.set_parent_trees([('missing-revision-id', None)]) |
|
42 |
self.assertEqual(['missing-revision-id'], t.get_parent_ids()) |
|
43 |
self.assertEqual('missing-revision-id', t.last_revision()) |
|
44 |
self.assertEqual([], t.pending_merges()) |
|
45 |
||
46 |
def test_set_two_parents_one_ghost(self): |
|
47 |
t = self.make_branch_and_tree('.') |
|
48 |
revision_in_repo = t.commit('first post') |
|
49 |
# remove the tree's history
|
|
50 |
uncommit(t.branch, tree=t) |
|
51 |
rev_tree = t.branch.repository.revision_tree(revision_in_repo) |
|
52 |
t.set_parent_trees([(revision_in_repo, rev_tree), |
|
53 |
('another-missing', None)]) |
|
54 |
self.assertEqual([revision_in_repo, 'another-missing'], |
|
55 |
t.get_parent_ids()) |
|
56 |
self.assertEqual(revision_in_repo, t.last_revision()) |
|
57 |
self.assertEqual(['another-missing'], t.pending_merges()) |
|
58 |
||
59 |
def test_set_three_parents(self): |
|
60 |
t = self.make_branch_and_tree('.') |
|
61 |
first_revision = t.commit('first post') |
|
62 |
uncommit(t.branch, tree=t) |
|
63 |
second_revision = t.commit('second post') |
|
64 |
uncommit(t.branch, tree=t) |
|
65 |
third_revision = t.commit('third post') |
|
66 |
uncommit(t.branch, tree=t) |
|
67 |
rev_tree1 = t.branch.repository.revision_tree(first_revision) |
|
68 |
rev_tree2 = t.branch.repository.revision_tree(second_revision) |
|
69 |
rev_tree3 = t.branch.repository.revision_tree(third_revision) |
|
70 |
t.set_parent_trees([(first_revision, rev_tree1), |
|
71 |
(second_revision, rev_tree2), |
|
72 |
(third_revision, rev_tree3)]) |
|
73 |
self.assertEqual([first_revision, second_revision, third_revision], |
|
74 |
t.get_parent_ids()) |
|
75 |
self.assertEqual(first_revision, t.last_revision()) |
|
76 |
self.assertEqual([second_revision, third_revision], t.pending_merges()) |