1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
1 |
# Copyright (C) 2006 Canonical Ltd
|
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
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
"""Tests for the WorkingTree.merge_from_branch api."""
|
|
19 |
||
20 |
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree |
|
21 |
||
22 |
||
23 |
class TestMergeFromBranch(TestCaseWithWorkingTree): |
|
24 |
||
25 |
def create_two_trees_for_merging(self): |
|
26 |
"""Create two trees that can be merged from.
|
|
27 |
||
28 |
This sets self.tree_from, self.first_rev, self.tree_to, self.second_rev
|
|
29 |
and self.to_second_rev.
|
|
30 |
"""
|
|
31 |
self.tree_from = self.make_branch_and_tree('from') |
|
32 |
self.first_rev = self.tree_from.commit('first post') |
|
33 |
self.tree_to = self.tree_from.bzrdir.sprout('to').open_workingtree() |
|
34 |
self.second_rev = self.tree_from.commit('second rev', allow_pointless=True) |
|
35 |
self.to_second_rev = self.tree_to.commit('second rev', allow_pointless=True) |
|
36 |
||
37 |
def test_smoking_merge(self): |
|
38 |
"""Smoke test of merge_from_branch."""
|
|
39 |
self.create_two_trees_for_merging() |
|
40 |
self.tree_to.merge_from_branch(self.tree_from.branch) |
|
41 |
self.assertEqual([self.to_second_rev, self.second_rev], |
|
42 |
self.tree_to.get_parent_ids()) |
|
43 |
||
44 |
def test_merge_to_revision(self): |
|
45 |
"""Merge from a branch to a revision that is not the tip."""
|
|
46 |
self.create_two_trees_for_merging() |
|
47 |
self.third_rev = self.tree_from.commit('real_tip') |
|
48 |
self.tree_to.merge_from_branch(self.tree_from.branch, |
|
49 |
to_revision=self.second_rev) |
|
50 |
self.assertEqual([self.to_second_rev, self.second_rev], |
|
51 |
self.tree_to.get_parent_ids()) |