1
# Copyright (C) 2004, 2005 Canonical Ltd
1
# Copyright (C) 2004, 2005, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
80
80
self.assertRaises(errors.BoundBranchConnectionFailure,
81
81
checkout.branch.pull, other.branch)
83
def test_pull_overwrite(self):
84
tree_a = self.make_branch_and_tree('tree_a')
85
tree_a.commit('message 1')
86
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
87
tree_a.commit('message 2', rev_id='rev2a')
88
tree_b.commit('message 2', rev_id='rev2b')
89
self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
90
tree_a.branch.pull(tree_a.branch, overwrite=True,
91
stop_revision='rev2b')
92
self.assertEqual('rev2b', tree_a.branch.last_revision())
93
self.assertEqual(tree_b.branch.revision_history(),
94
tree_a.branch.revision_history())
84
97
class TestPullHook(TestCaseWithBranch):
87
100
self.hook_calls = []
88
101
TestCaseWithBranch.setUp(self)
90
def capture_post_pull_hook(self, source, local, master, old_revno,
91
old_revid, new_revno, new_revid):
103
def capture_post_pull_hook(self, result):
92
104
"""Capture post pull hook calls to self.hook_calls.
94
106
The call is logged, as is some state of the two branches.
97
local_locked = local.is_locked()
98
local_base = local.base
108
if result.local_branch:
109
local_locked = result.local_branch.is_locked()
110
local_base = result.local_branch.base
100
112
local_locked = None
101
113
local_base = None
102
114
self.hook_calls.append(
103
('post_pull', source, local_base, master.base, old_revno, old_revid,
104
new_revno, new_revid, source.is_locked(), local_locked,
115
('post_pull', result.source_branch, local_base,
116
result.master_branch.base, result.old_revno,
118
result.new_revno, result.new_revid,
119
result.source_branch.is_locked(), local_locked,
120
result.master_branch.is_locked()))
107
122
def test_post_pull_empty_history(self):
108
123
target = self.make_branch('target')