bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2004, 2005 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
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 |
|
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
22 |
from bzrlib import errors |
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
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) |
|
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
35 |
parent.merge_from_branch(mine.branch) |
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
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() |
|
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
50 |
other.merge_from_branch(mine.branch) |
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
51 |
other.commit('merge my change', rev_id='O2') |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
52 |
parent.merge_from_branch(other.branch) |
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
53 |
parent.commit('merge other', rev_id='P2') |
54 |
mine.pull(parent.branch) |
|
55 |
self.assertEqual(['P1', 'P2'], mine.branch.revision_history()) |
|
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
56 |
|
57 |
def test_pull_updates_checkout_and_master(self): |
|
58 |
"""Pulling into a checkout updates the checkout and the master branch""" |
|
59 |
master_tree = self.make_branch_and_tree('master') |
|
60 |
rev1 = master_tree.commit('master') |
|
61 |
checkout = master_tree.branch.create_checkout('checkout') |
|
62 |
||
63 |
other = master_tree.branch.bzrdir.sprout('other').open_workingtree() |
|
64 |
rev2 = other.commit('other commit') |
|
65 |
# now pull, which should update both checkout and master.
|
|
66 |
checkout.branch.pull(other.branch) |
|
67 |
self.assertEqual([rev1, rev2], checkout.branch.revision_history()) |
|
68 |
self.assertEqual([rev1, rev2], master_tree.branch.revision_history()) |
|
69 |
||
70 |
def test_pull_raises_specific_error_on_master_connection_error(self): |
|
71 |
master_tree = self.make_branch_and_tree('master') |
|
72 |
checkout = master_tree.branch.create_checkout('checkout') |
|
73 |
other = master_tree.branch.bzrdir.sprout('other').open_workingtree() |
|
74 |
# move the branch out of the way on disk to cause a connection
|
|
75 |
# error.
|
|
76 |
os.rename('master', 'master_gone') |
|
77 |
# try to pull, which should raise a BoundBranchConnectionFailure.
|
|
78 |
self.assertRaises(errors.BoundBranchConnectionFailure, |
|
79 |
checkout.branch.pull, other.branch) |