~bzr-pqm/bzr/bzr.dev

1649.1.1 by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two
1
# Copyright (C) 2004, 2005 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
"""Tests for branch.pull behaviour."""
18
19
import os
20
21
from bzrlib.branch import Branch
22
from bzrlib.osutils import abspath, realpath
23
from bzrlib.tests import TestCaseWithTransport
24
25
26
class TestPull(TestCaseWithTransport):
27
28
    def test_pull_convergence_simple(self):
29
        # when revisions are pulled, the left-most accessible parents must 
30
        # become the revision-history.
31
        parent = self.make_branch_and_tree('parent')
32
        parent.commit('1st post', rev_id='P1', allow_pointless=True)
33
        mine = parent.bzrdir.sprout('mine').open_workingtree()
34
        mine.commit('my change', rev_id='M1', allow_pointless=True)
35
        self.merge(mine.branch, parent)
36
        parent.commit('merge my change', rev_id='P2')
37
        mine.pull(parent.branch)
38
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
39
40
    def test_pull_merged_indirect(self):
41
        # it should be possible to do a pull from one branch into another
42
        # when the tip of the target was merged into the source branch
43
        # via a third branch - so its buried in the ancestry and is not
44
        # directly accessible.
45
        parent = self.make_branch_and_tree('parent')
46
        parent.commit('1st post', rev_id='P1', allow_pointless=True)
47
        mine = parent.bzrdir.sprout('mine').open_workingtree()
48
        mine.commit('my change', rev_id='M1', allow_pointless=True)
49
        other = parent.bzrdir.sprout('other').open_workingtree()
50
        self.merge(mine.branch, other)
51
        other.commit('merge my change', rev_id='O2')
52
        self.merge(other.branch, parent)
53
        parent.commit('merge other', rev_id='P2')
54
        mine.pull(parent.branch)
55
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())