bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1185.50.5
by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer) |
1 |
# Copyright (C) 2005 by Canonical Ltd
|
2 |
# -*- coding: utf-8 -*-
|
|
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 |
||
|
1185.50.8
by John Arbash Meinel
Cleanup of test_pull.py headers |
19 |
"""Black-box tests for bzr pull.
|
|
1185.50.5
by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer) |
20 |
"""
|
21 |
||
22 |
import os |
|
23 |
||
24 |
from bzrlib.branch import Branch |
|
25 |
from bzrlib.tests.blackbox import ExternalBase |
|
26 |
||
|
1185.50.7
by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull |
27 |
class TestPull(ExternalBase): |
28 |
||
29 |
def example_branch(test): |
|
30 |
test.runbzr('init') |
|
31 |
file('hello', 'wt').write('foo') |
|
32 |
test.runbzr('add hello') |
|
33 |
test.runbzr('commit -m setup hello') |
|
34 |
file('goodbye', 'wt').write('baz') |
|
35 |
test.runbzr('add goodbye') |
|
36 |
test.runbzr('commit -m setup goodbye') |
|
|
1185.50.5
by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer) |
37 |
|
38 |
def test_pull(self): |
|
39 |
"""Pull changes from one branch to another.""" |
|
40 |
os.mkdir('a') |
|
41 |
os.chdir('a') |
|
42 |
||
43 |
self.example_branch() |
|
44 |
self.runbzr('pull', retcode=3) |
|
45 |
self.runbzr('missing', retcode=3) |
|
46 |
self.runbzr('missing .') |
|
47 |
self.runbzr('missing') |
|
48 |
self.runbzr('pull') |
|
49 |
self.runbzr('pull /', retcode=3) |
|
50 |
self.runbzr('pull') |
|
51 |
||
52 |
os.chdir('..') |
|
53 |
self.runbzr('branch a b') |
|
54 |
os.chdir('b') |
|
55 |
self.runbzr('pull') |
|
56 |
os.mkdir('subdir') |
|
57 |
self.runbzr('add subdir') |
|
58 |
self.runbzr('commit -m blah --unchanged') |
|
59 |
os.chdir('../a') |
|
60 |
a = Branch.open('.') |
|
61 |
b = Branch.open('../b') |
|
62 |
self.assertEquals(a.revision_history(), b.revision_history()[:-1]) |
|
63 |
self.runbzr('pull ../b') |
|
64 |
self.assertEquals(a.revision_history(), b.revision_history()) |
|
65 |
self.runbzr('commit -m blah2 --unchanged') |
|
66 |
os.chdir('../b') |
|
67 |
self.runbzr('commit -m blah3 --unchanged') |
|
68 |
# no overwrite
|
|
69 |
self.runbzr('pull ../a', retcode=3) |
|
70 |
os.chdir('..') |
|
71 |
self.runbzr('branch b overwriteme') |
|
72 |
os.chdir('overwriteme') |
|
73 |
self.runbzr('pull --overwrite ../a') |
|
74 |
overwritten = Branch.open('.') |
|
75 |
self.assertEqual(overwritten.revision_history(), |
|
76 |
a.revision_history()) |
|
77 |
os.chdir('../a') |
|
78 |
self.runbzr('merge ../b') |
|
79 |
self.runbzr('commit -m blah4 --unchanged') |
|
80 |
os.chdir('../b/subdir') |
|
81 |
self.runbzr('pull ../../a') |
|
82 |
self.assertEquals(a.revision_history()[-1], b.revision_history()[-1]) |
|
83 |
self.runbzr('commit -m blah5 --unchanged') |
|
84 |
self.runbzr('commit -m blah6 --unchanged') |
|
85 |
os.chdir('..') |
|
86 |
self.runbzr('pull ../a') |
|
87 |
os.chdir('../a') |
|
88 |
self.runbzr('commit -m blah7 --unchanged') |
|
89 |
self.runbzr('merge ../b') |
|
90 |
self.runbzr('commit -m blah8 --unchanged') |
|
91 |
self.runbzr('pull ../b') |
|
92 |
self.runbzr('pull ../b') |
|
93 |
||
|
1185.50.7
by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull |
94 |
def test_overwrite_uptodate(self): |
|
1185.50.5
by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer) |
95 |
# Make sure pull --overwrite overwrites
|
96 |
# even if the target branch has merged
|
|
97 |
# everything already.
|
|
98 |
bzr = self.run_bzr |
|
99 |
||
100 |
def get_rh(expected_len): |
|
101 |
rh = self.capture('revision-history') |
|
102 |
# Make sure we don't have trailing empty revisions
|
|
103 |
rh = rh.strip().split('\n') |
|
104 |
self.assertEqual(len(rh), expected_len) |
|
105 |
return rh |
|
106 |
||
107 |
os.mkdir('a') |
|
108 |
os.chdir('a') |
|
109 |
bzr('init') |
|
110 |
open('foo', 'wb').write('original\n') |
|
111 |
bzr('add', 'foo') |
|
112 |
bzr('commit', '-m', 'initial commit') |
|
113 |
||
114 |
os.chdir('..') |
|
115 |
bzr('branch', 'a', 'b') |
|
116 |
||
117 |
os.chdir('a') |
|
118 |
open('foo', 'wb').write('changed\n') |
|
119 |
bzr('commit', '-m', 'later change') |
|
120 |
||
121 |
open('foo', 'wb').write('another\n') |
|
122 |
bzr('commit', '-m', 'a third change') |
|
123 |
||
124 |
rev_history_a = get_rh(3) |
|
125 |
||
126 |
os.chdir('../b') |
|
127 |
bzr('merge', '../a') |
|
128 |
bzr('commit', '-m', 'merge') |
|
129 |
||
130 |
rev_history_b = get_rh(2) |
|
131 |
||
132 |
bzr('pull', '--overwrite', '../a') |
|
133 |
rev_history_b = get_rh(3) |
|
134 |
||
135 |
self.assertEqual(rev_history_b, rev_history_a) |
|
136 |
||
|
1185.50.7
by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull |
137 |
def test_overwrite_children(self): |
|
1185.50.5
by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer) |
138 |
# Make sure pull --overwrite sets the revision-history
|
139 |
# to be identical to the pull source, even if we have convergence
|
|
140 |
bzr = self.run_bzr |
|
141 |
||
142 |
def get_rh(expected_len): |
|
143 |
rh = self.capture('revision-history') |
|
144 |
# Make sure we don't have trailing empty revisions
|
|
145 |
rh = rh.strip().split('\n') |
|
146 |
self.assertEqual(len(rh), expected_len) |
|
147 |
return rh |
|
148 |
||
149 |
os.mkdir('a') |
|
150 |
os.chdir('a') |
|
151 |
bzr('init') |
|
152 |
open('foo', 'wb').write('original\n') |
|
153 |
bzr('add', 'foo') |
|
154 |
bzr('commit', '-m', 'initial commit') |
|
155 |
||
156 |
os.chdir('..') |
|
157 |
bzr('branch', 'a', 'b') |
|
158 |
||
159 |
os.chdir('a') |
|
160 |
open('foo', 'wb').write('changed\n') |
|
161 |
bzr('commit', '-m', 'later change') |
|
162 |
||
163 |
open('foo', 'wb').write('another\n') |
|
164 |
bzr('commit', '-m', 'a third change') |
|
165 |
||
166 |
rev_history_a = get_rh(3) |
|
167 |
||
168 |
os.chdir('../b') |
|
169 |
bzr('merge', '../a') |
|
170 |
bzr('commit', '-m', 'merge') |
|
171 |
||
172 |
rev_history_b = get_rh(2) |
|
173 |
||
174 |
os.chdir('../a') |
|
175 |
open('foo', 'wb').write('a fourth change\n') |
|
176 |
bzr('commit', '-m', 'a fourth change') |
|
177 |
||
178 |
rev_history_a = get_rh(4) |
|
179 |
||
180 |
# With convergence, we could just pull over the
|
|
181 |
# new change, but with --overwrite, we want to switch our history
|
|
182 |
os.chdir('../b') |
|
183 |
bzr('pull', '--overwrite', '../a') |
|
184 |
rev_history_b = get_rh(4) |
|
185 |
||
186 |
self.assertEqual(rev_history_b, rev_history_a) |
|
187 |
||
188 |