bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
1 |
# Copyright (C) 2006-2007 by Jelmer Vernooij
|
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
|
|
|
0.436.16
by Jelmer Vernooij
Some more work on maptree. |
16 |
"""Tests for the rebase code."""
|
|
0.436.2
by Jelmer Vernooij
Add stubs for testsuite, rebase-continue and rebase-abort commands. |
17 |
|
|
0.436.37
by Jelmer Vernooij
Store parents correctly. |
18 |
from bzrlib.errors import UnknownFormatError, NoSuchFile, ConflictsInTree |
|
0.436.6
by Jelmer Vernooij
Add somewhat more complex plan generation function, rebase implementation. |
19 |
from bzrlib.revision import NULL_REVISION |
|
0.436.5
by Jelmer Vernooij
Import change_revision_parent from bzr-svn. |
20 |
from bzrlib.tests import TestCase, TestCaseWithTransport |
21 |
||
22 |
from rebase import (marshall_rebase_plan, unmarshall_rebase_plan, |
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
23 |
replay_snapshot, generate_simple_plan, |
24 |
generate_transpose_plan, rebase_plan_exists, |
|
|
0.436.18
by Jelmer Vernooij
More tests, extend MapTree a bit. |
25 |
rebase_todo, REBASE_PLAN_FILENAME, |
26 |
REBASE_CURRENT_REVID_FILENAME, read_rebase_plan, |
|
27 |
remove_rebase_plan, read_active_rebase_revid, |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
28 |
write_active_rebase_revid, write_rebase_plan, MapTree, |
|
0.436.37
by Jelmer Vernooij
Store parents correctly. |
29 |
ReplaySnapshotError, ReplayParentsInconsistent, |
30 |
replay_delta_workingtree) |
|
|
0.436.5
by Jelmer Vernooij
Import change_revision_parent from bzr-svn. |
31 |
|
|
0.436.4
by Jelmer Vernooij
Add some tests. |
32 |
|
|
0.436.3
by Jelmer Vernooij
Fill in commands. |
33 |
class RebasePlanReadWriterTests(TestCase): |
|
0.436.4
by Jelmer Vernooij
Add some tests. |
34 |
def test_simple_marshall_rebase_plan(self): |
35 |
self.assertEqualDiff( |
|
36 |
"""# Bazaar rebase plan 1
|
|
37 |
1 bla
|
|
38 |
oldrev newrev newparent1 newparent2
|
|
39 |
""", marshall_rebase_plan((1, "bla"), |
|
40 |
{"oldrev": ("newrev", ["newparent1", "newparent2"])})) |
|
41 |
||
42 |
def test_simple_unmarshall_rebase_plan(self): |
|
43 |
self.assertEquals(((1, "bla"), |
|
44 |
{"oldrev": ("newrev", ["newparent1", "newparent2"])}), |
|
45 |
unmarshall_rebase_plan("""# Bazaar rebase plan 1 |
|
46 |
1 bla
|
|
47 |
oldrev newrev newparent1 newparent2
|
|
48 |
""")) |
|
49 |
||
50 |
def test_unmarshall_rebase_plan_formatunknown(self): |
|
51 |
self.assertRaises(UnknownFormatError, |
|
52 |
unmarshall_rebase_plan, """# Bazaar rebase plan x |
|
53 |
1 bla
|
|
54 |
oldrev newrev newparent1 newparent2
|
|
55 |
""") |
|
|
0.436.5
by Jelmer Vernooij
Import change_revision_parent from bzr-svn. |
56 |
|
57 |
||
58 |
class ConversionTests(TestCaseWithTransport): |
|
59 |
def test_simple(self): |
|
60 |
wt = self.make_branch_and_tree('.') |
|
61 |
b = wt.branch |
|
62 |
file('hello', 'w').write('hello world') |
|
63 |
wt.add('hello') |
|
64 |
wt.commit(message='add hello', rev_id="bla") |
|
65 |
file('hello', 'w').write('world') |
|
66 |
wt.commit(message='change hello', rev_id="bloe") |
|
67 |
wt.set_last_revision("bla") |
|
68 |
b.set_revision_history(["bla"]) |
|
69 |
file('hello', 'w').write('world') |
|
70 |
wt.commit(message='change hello', rev_id="bla2") |
|
71 |
||
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
72 |
newrev = replay_snapshot(wt.branch.repository, "bla2", "bla4", |
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
73 |
["bloe"], {"bla": "bloe"}) |
|
0.436.5
by Jelmer Vernooij
Import change_revision_parent from bzr-svn. |
74 |
self.assertEqual("bla4", newrev) |
75 |
self.assertTrue(wt.branch.repository.has_revision(newrev)) |
|
|
0.436.20
by Jelmer Vernooij
Some more blackbox tests. |
76 |
self.assertEqual(["bloe"], |
77 |
wt.branch.repository.revision_parents(newrev)) |
|
78 |
self.assertEqual("bla2", |
|
79 |
wt.branch.repository.get_revision(newrev).properties["rebase-of"]) |
|
|
0.436.6
by Jelmer Vernooij
Add somewhat more complex plan generation function, rebase implementation. |
80 |
|
81 |
||
82 |
class PlanCreatorTests(TestCaseWithTransport): |
|
83 |
def test_simple_plan_creator(self): |
|
84 |
wt = self.make_branch_and_tree('.') |
|
85 |
b = wt.branch |
|
86 |
file('hello', 'w').write('hello world') |
|
87 |
wt.add('hello') |
|
88 |
wt.commit(message='add hello', rev_id="bla") |
|
89 |
file('hello', 'w').write('world') |
|
90 |
wt.commit(message='change hello', rev_id="bloe") |
|
91 |
wt.set_last_revision("bla") |
|
92 |
b.set_revision_history(["bla"]) |
|
93 |
file('hello', 'w').write('world') |
|
94 |
wt.commit(message='change hello', rev_id="bla2") |
|
95 |
||
96 |
self.assertEquals({'bla2': ('newbla2', ["bloe"])}, |
|
97 |
generate_simple_plan(b.repository, b.revision_history(), "bla2", "bloe", |
|
98 |
lambda y: "new"+y.revision_id)) |
|
99 |
||
100 |
def test_simple_plan_creator_extra_history(self): |
|
101 |
wt = self.make_branch_and_tree('.') |
|
102 |
b = wt.branch |
|
103 |
file('hello', 'w').write('hello world') |
|
104 |
wt.add('hello') |
|
105 |
wt.commit(message='add hello', rev_id="bla") |
|
106 |
file('hello', 'w').write('world') |
|
107 |
wt.commit(message='change hello', rev_id="bloe") |
|
108 |
wt.set_last_revision("bla") |
|
109 |
b.set_revision_history(["bla"]) |
|
110 |
file('hello', 'w').write('world') |
|
111 |
wt.commit(message='change hello', rev_id="bla2") |
|
112 |
file('hello', 'w').write('universe') |
|
113 |
wt.commit(message='change hello again', rev_id="bla3") |
|
114 |
||
115 |
self.assertEquals({'bla2': ('newbla2', ["bloe"]), 'bla3': ('newbla3', ['newbla2'])}, |
|
116 |
generate_simple_plan(b.repository, b.revision_history(), "bla2", "bloe", |
|
117 |
lambda y: "new"+y.revision_id)) |
|
118 |
||
119 |
||
120 |
def test_generate_transpose_plan(self): |
|
121 |
wt = self.make_branch_and_tree('.') |
|
122 |
b = wt.branch |
|
123 |
file('hello', 'w').write('hello world') |
|
124 |
wt.add('hello') |
|
125 |
wt.commit(message='add hello', rev_id="bla") |
|
126 |
file('hello', 'w').write('world') |
|
127 |
wt.commit(message='change hello', rev_id="bloe") |
|
128 |
wt.set_last_revision("bla") |
|
129 |
b.set_revision_history(["bla"]) |
|
130 |
file('hello', 'w').write('world') |
|
131 |
wt.commit(message='change hello', rev_id="bla2") |
|
132 |
file('hello', 'w').write('universe') |
|
133 |
wt.commit(message='change hello again', rev_id="bla3") |
|
134 |
wt.set_last_revision("bla") |
|
135 |
b.set_revision_history(["bla"]) |
|
136 |
file('hello', 'w').write('somebar') |
|
137 |
wt.commit(message='change hello yet again', rev_id="blie") |
|
138 |
wt.set_last_revision(NULL_REVISION) |
|
139 |
b.set_revision_history([]) |
|
140 |
wt.add('hello') |
|
141 |
wt.commit(message='add hello', rev_id="lala") |
|
142 |
||
143 |
self.assertEquals({ |
|
|
0.436.36
by Jelmer Vernooij
Fix compatibility with bzr 0.19. |
144 |
'blie': ('newblie', ['lala'])}, |
145 |
generate_transpose_plan(b.repository.get_revision_graph("blie"), |
|
146 |
{"bla": "lala"}, b.repository.revision_parents, lambda y: "new"+y)) |
|
|
0.436.6
by Jelmer Vernooij
Add somewhat more complex plan generation function, rebase implementation. |
147 |
self.assertEquals({ |
|
0.436.36
by Jelmer Vernooij
Fix compatibility with bzr 0.19. |
148 |
'bla2': ('newbla2', ['lala']), |
149 |
'bla3': ('newbla3', ['newbla2']), |
|
150 |
'blie': ('newblie', ['lala']), |
|
151 |
'bloe': ('newbloe', ['lala'])}, |
|
152 |
generate_transpose_plan(b.repository.get_revision_graph(), |
|
153 |
{"bla": "lala"}, |
|
154 |
b.repository.revision_parents, lambda y: "new"+y)) |
|
|
0.436.6
by Jelmer Vernooij
Add somewhat more complex plan generation function, rebase implementation. |
155 |
|
|
0.436.31
by Jelmer Vernooij
Refactor generate_transpose_plan() to not take a repository object but |
156 |
def test_generate_transpose_plan_one(self): |
157 |
self.assertEquals({"bla": ("newbla", ["lala"])}, |
|
158 |
generate_transpose_plan({"bla": ["bloe"], "bloe": []}, |
|
159 |
{"bloe": "lala"}, {}.get, lambda y: "new"+y)) |
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
160 |
|
161 |
class PlanFileTests(TestCaseWithTransport): |
|
162 |
def test_rebase_plan_exists_false(self): |
|
163 |
wt = self.make_branch_and_tree('.') |
|
164 |
self.assertFalse(rebase_plan_exists(wt)) |
|
165 |
||
166 |
def test_rebase_plan_exists_empty(self): |
|
167 |
wt = self.make_branch_and_tree('.') |
|
168 |
wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "") |
|
169 |
self.assertFalse(rebase_plan_exists(wt)) |
|
170 |
||
171 |
def test_rebase_plan_exists(self): |
|
172 |
wt = self.make_branch_and_tree('.') |
|
173 |
wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "foo") |
|
174 |
self.assertTrue(rebase_plan_exists(wt)) |
|
175 |
||
176 |
def test_remove_rebase_plan(self): |
|
177 |
wt = self.make_branch_and_tree('.') |
|
178 |
wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "foo") |
|
179 |
remove_rebase_plan(wt) |
|
180 |
self.assertFalse(rebase_plan_exists(wt)) |
|
181 |
||
182 |
def test_remove_rebase_plan_twice(self): |
|
183 |
wt = self.make_branch_and_tree('.') |
|
184 |
remove_rebase_plan(wt) |
|
185 |
self.assertFalse(rebase_plan_exists(wt)) |
|
186 |
||
187 |
def test_write_rebase_plan(self): |
|
188 |
wt = self.make_branch_and_tree('.') |
|
189 |
file('hello', 'w').write('hello world') |
|
190 |
wt.add('hello') |
|
191 |
wt.commit(message='add hello', rev_id="bla") |
|
192 |
write_rebase_plan(wt, |
|
193 |
{"oldrev": ("newrev", ["newparent1", "newparent2"])}) |
|
194 |
self.assertEqualDiff("""# Bazaar rebase plan 1 |
|
195 |
1 bla
|
|
196 |
oldrev newrev newparent1 newparent2
|
|
197 |
""", wt._control_files.get(REBASE_PLAN_FILENAME).read()) |
|
198 |
||
199 |
def test_read_rebase_plan_nonexistant(self): |
|
200 |
wt = self.make_branch_and_tree('.') |
|
201 |
self.assertRaises(NoSuchFile, read_rebase_plan, wt) |
|
202 |
||
203 |
def test_read_rebase_plan_empty(self): |
|
204 |
wt = self.make_branch_and_tree('.') |
|
205 |
wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "") |
|
206 |
self.assertRaises(NoSuchFile, read_rebase_plan, wt) |
|
207 |
||
208 |
def test_read_rebase_plan(self): |
|
209 |
wt = self.make_branch_and_tree('.') |
|
210 |
wt._control_files.put_utf8(REBASE_PLAN_FILENAME, """# Bazaar rebase plan 1 |
|
211 |
1 bla
|
|
212 |
oldrev newrev newparent1 newparent2
|
|
213 |
""") |
|
|
0.436.36
by Jelmer Vernooij
Fix compatibility with bzr 0.19. |
214 |
self.assertEquals(((1, "bla"), |
215 |
{"oldrev": ("newrev", ["newparent1", "newparent2"])}), |
|
216 |
read_rebase_plan(wt)) |
|
|
0.436.7
by Jelmer Vernooij
Add more test, make basic rebase work. |
217 |
|
|
0.436.20
by Jelmer Vernooij
Some more blackbox tests. |
218 |
|
|
0.436.9
by Jelmer Vernooij
Add rebase-todo command, fix rebase-continue. |
219 |
class CurrentRevidFileTests(TestCaseWithTransport): |
220 |
def test_read_nonexistant(self): |
|
221 |
wt = self.make_branch_and_tree('.') |
|
222 |
self.assertIs(None, read_active_rebase_revid(wt)) |
|
223 |
||
224 |
def test_read_null(self): |
|
225 |
wt = self.make_branch_and_tree('.') |
|
226 |
wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, NULL_REVISION) |
|
227 |
self.assertIs(None, read_active_rebase_revid(wt)) |
|
228 |
||
229 |
def test_read(self): |
|
230 |
wt = self.make_branch_and_tree('.') |
|
231 |
wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, "bla") |
|
232 |
self.assertEquals("bla", read_active_rebase_revid(wt)) |
|
233 |
||
234 |
def test_write(self): |
|
235 |
wt = self.make_branch_and_tree('.') |
|
236 |
write_active_rebase_revid(wt, "bloe") |
|
237 |
self.assertEquals("bloe", read_active_rebase_revid(wt)) |
|
238 |
||
239 |
def test_write_null(self): |
|
240 |
wt = self.make_branch_and_tree('.') |
|
241 |
write_active_rebase_revid(wt, None) |
|
242 |
self.assertIs(None, read_active_rebase_revid(wt)) |
|
|
0.436.18
by Jelmer Vernooij
More tests, extend MapTree a bit. |
243 |
|
|
0.436.20
by Jelmer Vernooij
Some more blackbox tests. |
244 |
|
|
0.436.18
by Jelmer Vernooij
More tests, extend MapTree a bit. |
245 |
class RebaseTodoTests(TestCase): |
246 |
def test_done(self): |
|
247 |
class Repository: |
|
248 |
def has_revision(self, revid): |
|
249 |
return revid == "bloe" |
|
250 |
self.assertEquals([], |
|
251 |
list(rebase_todo(Repository(), { "bla": ("bloe", [])}))) |
|
252 |
||
253 |
def test_notstarted(self): |
|
254 |
class Repository: |
|
255 |
def has_revision(self, revid): |
|
256 |
return False |
|
257 |
self.assertEquals(["bla"], |
|
258 |
list(rebase_todo(Repository(), { "bla": ("bloe", [])}))) |
|
259 |
||
260 |
def test_halfway(self): |
|
261 |
class Repository: |
|
262 |
def has_revision(self, revid): |
|
263 |
return revid == "bloe" |
|
264 |
self.assertEquals(["ha"], |
|
265 |
list(rebase_todo(Repository(), { "bla": ("bloe", []), |
|
266 |
"ha": ("hee", [])}))) |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
267 |
|
268 |
class ReplaySnapshotTests(TestCaseWithTransport): |
|
269 |
def test_single_revision(self): |
|
270 |
wt = self.make_branch_and_tree(".") |
|
271 |
self.build_tree(['afile']) |
|
272 |
wt.add(["afile"]) |
|
273 |
wt.commit("bla", rev_id="oldcommit") |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
274 |
replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", [], |
275 |
{})
|
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
276 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
277 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
278 |
self.assertEquals([], newrev.parent_ids) |
|
279 |
self.assertEquals("newcommit", newrev.revision_id) |
|
280 |
self.assertEquals(oldrev.committer, newrev.committer) |
|
281 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
282 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
283 |
inv = wt.branch.repository.get_inventory("newcommit") |
|
284 |
self.assertEquals("newcommit", inv[inv.path2id("afile")].revision) |
|
285 |
||
286 |
def test_parents_different(self): |
|
287 |
"""replay_snapshot() relies on the fact that the contents of |
|
288 |
the old and new parents is equal (at least concerning tree shape). If
|
|
289 |
it turns out it isn't, an exception should be raised."""
|
|
290 |
wt = self.make_branch_and_tree(".") |
|
291 |
wt.commit("bloe", rev_id="base") |
|
292 |
self.build_tree(['afile', 'notherfile']) |
|
293 |
wt.add(["afile"]) |
|
294 |
wt.commit("bla", rev_id="oldparent") |
|
295 |
wt.add(["notherfile"]) |
|
296 |
wt.commit("bla", rev_id="oldcommit") |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
297 |
# this should raise an exception since oldcommit is being rewritten
|
298 |
# but 'afile' is present in the old parents but not in the new ones.
|
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
299 |
self.assertRaises( |
|
0.436.34
by Jelmer Vernooij
Some more tests. |
300 |
ReplayParentsInconsistent, replay_snapshot, |
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
301 |
wt.branch.repository, "oldcommit", "newcommit", |
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
302 |
["base"], {"oldparent": "base"}) |
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
303 |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
304 |
def test_two_revisions(self): |
305 |
wt = self.make_branch_and_tree("old") |
|
306 |
self.build_tree(['old/afile', 'old/notherfile']) |
|
307 |
wt.add(["afile"], ["somefileid"]) |
|
308 |
wt.commit("bla", rev_id="oldparent") |
|
309 |
wt.add(["notherfile"]) |
|
310 |
wt.commit("bla", rev_id="oldcommit") |
|
311 |
oldrepos = wt.branch.repository |
|
312 |
wt = self.make_branch_and_tree("new") |
|
313 |
self.build_tree(['new/afile', 'new/notherfile']) |
|
314 |
wt.add(["afile"], ["afileid"]) |
|
315 |
wt.commit("bla", rev_id="newparent") |
|
316 |
wt.branch.repository.fetch(oldrepos) |
|
317 |
replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
318 |
["newparent"], {"oldparent": "newparent"}) |
|
0.436.34
by Jelmer Vernooij
Some more tests. |
319 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
320 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
321 |
self.assertEquals(["newparent"], newrev.parent_ids) |
|
322 |
self.assertEquals("newcommit", newrev.revision_id) |
|
323 |
self.assertEquals(oldrev.committer, newrev.committer) |
|
324 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
325 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
326 |
inv = wt.branch.repository.get_inventory("newcommit") |
|
327 |
self.assertEquals("afileid", inv.path2id("afile")) |
|
328 |
self.assertEquals("newcommit", inv[inv.path2id("notherfile")].revision) |
|
329 |
||
330 |
def test_two_revisions_no_renames(self): |
|
331 |
wt = self.make_branch_and_tree("old") |
|
332 |
self.build_tree(['old/afile', 'old/notherfile']) |
|
333 |
wt.add(["afile"], ["somefileid"]) |
|
334 |
wt.commit("bla", rev_id="oldparent") |
|
335 |
wt.add(["notherfile"]) |
|
336 |
wt.commit("bla", rev_id="oldcommit") |
|
337 |
oldrepos = wt.branch.repository |
|
338 |
wt = self.make_branch_and_tree("new") |
|
339 |
self.build_tree(['new/afile', 'new/notherfile']) |
|
340 |
wt.add(["afile"], ["afileid"]) |
|
341 |
wt.commit("bla", rev_id="newparent") |
|
342 |
wt.branch.repository.fetch(oldrepos) |
|
343 |
self.assertRaises(ReplayParentsInconsistent, |
|
344 |
replay_snapshot, wt.branch.repository, |
|
345 |
"oldcommit", "newcommit", |
|
346 |
["newparent"], revid_renames={}) |
|
347 |
||
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
348 |
def test_multi_revisions(self): |
349 |
wt = self.make_branch_and_tree("old") |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
350 |
self.build_tree(['old/afile', 'old/sfile', 'old/notherfile']) |
351 |
wt.add(['sfile']) |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
352 |
wt.add(["afile"], ["somefileid"]) |
353 |
wt.commit("bla", rev_id="oldgrandparent") |
|
354 |
open("old/afile", "w").write("data") |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
355 |
wt.commit("bla", rev_id="oldparent") |
356 |
wt.add(["notherfile"]) |
|
357 |
wt.commit("bla", rev_id="oldcommit") |
|
358 |
oldrepos = wt.branch.repository |
|
359 |
wt = self.make_branch_and_tree("new") |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
360 |
self.build_tree(['new/afile', 'new/sfile', 'new/notherfile']) |
361 |
wt.add(['sfile']) |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
362 |
wt.add(["afile"], ["afileid"]) |
363 |
wt.commit("bla", rev_id="newgrandparent") |
|
364 |
open("new/afile", "w").write("data") |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
365 |
wt.commit("bla", rev_id="newparent") |
366 |
wt.branch.repository.fetch(oldrepos) |
|
367 |
replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
368 |
["newparent"], {"oldgrandparent": "newgrandparent", |
369 |
"oldparent": "newparent"}) |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
370 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
371 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
372 |
self.assertEquals(["newparent"], newrev.parent_ids) |
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
373 |
self.assertEquals("newcommit", newrev.revision_id) |
374 |
self.assertEquals(oldrev.committer, newrev.committer) |
|
375 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
376 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
377 |
inv = wt.branch.repository.get_inventory("newcommit") |
|
|
0.436.34
by Jelmer Vernooij
Some more tests. |
378 |
self.assertEquals("afileid", inv.path2id("afile")) |
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
379 |
self.assertEquals("newcommit", inv[inv.path2id("notherfile")].revision) |
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
380 |
self.assertEquals("newgrandparent", inv[inv.path2id("sfile")].revision) |
|
0.436.34
by Jelmer Vernooij
Some more tests. |
381 |
|
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
382 |
def test_maps_ids(self): |
383 |
wt = self.make_branch_and_tree("old") |
|
384 |
wt.commit("base", rev_id="base") |
|
385 |
self.build_tree(['old/afile']) |
|
386 |
wt.add(["afile"], ids=["originalid"]) |
|
387 |
wt.commit("bla", rev_id="oldparent") |
|
388 |
file("old/afile", "w").write("bloe") |
|
389 |
wt.commit("bla", rev_id="oldcommit") |
|
390 |
oldrepos = wt.branch.repository |
|
391 |
wt = self.make_branch_and_tree("new") |
|
392 |
self.build_tree(['new/afile']) |
|
393 |
wt.add(["afile"], ids=["newid"]) |
|
394 |
wt.commit("bla", rev_id="newparent") |
|
395 |
wt.branch.repository.fetch(oldrepos) |
|
396 |
replay_snapshot(wt.branch.repository, "oldcommit", "newcommit", |
|
|
0.436.35
by Jelmer Vernooij
Make revid_renames argument mandatory. |
397 |
["newparent"], {"oldparent": "newparent"}) |
|
0.436.32
by Jelmer Vernooij
Properly detect invalid snapshot replays. |
398 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
399 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
400 |
self.assertEquals(["newparent"], newrev.parent_ids) |
|
401 |
self.assertEquals("newcommit", newrev.revision_id) |
|
402 |
self.assertEquals(oldrev.committer, newrev.committer) |
|
403 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
404 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
405 |
inv = wt.branch.repository.get_inventory("newcommit") |
|
406 |
self.assertEquals("newid", inv.path2id("afile")) |
|
407 |
self.assertEquals("newcommit", inv[inv.path2id("afile")].revision) |
|
408 |
||
|
0.436.37
by Jelmer Vernooij
Store parents correctly. |
409 |
|
410 |
class TestReplayWorkingtree(TestCaseWithTransport): |
|
411 |
def test_conflicts(self): |
|
412 |
wt = self.make_branch_and_tree("old") |
|
413 |
wt.commit("base", rev_id="base") |
|
414 |
self.build_tree(['old/afile']) |
|
415 |
wt.add(["afile"], ids=["originalid"]) |
|
416 |
wt.commit("bla", rev_id="oldparent") |
|
417 |
file("old/afile", "w").write("bloe") |
|
418 |
wt.commit("bla", rev_id="oldcommit") |
|
419 |
oldrepos = wt.branch.repository |
|
420 |
wt = self.make_branch_and_tree("new") |
|
421 |
self.build_tree(['new/afile']) |
|
422 |
wt.add(["afile"], ids=["newid"]) |
|
423 |
wt.commit("bla", rev_id="newparent") |
|
424 |
wt.branch.repository.fetch(oldrepos) |
|
425 |
self.assertRaises(ConflictsInTree, |
|
426 |
replay_delta_workingtree, wt, "oldcommit", "newcommit", |
|
427 |
["newparent"]) |
|
428 |
||
429 |
def test_simple(self): |
|
430 |
wt = self.make_branch_and_tree("old") |
|
431 |
wt.commit("base", rev_id="base") |
|
432 |
self.build_tree(['old/afile']) |
|
433 |
wt.add(["afile"], ids=["originalid"]) |
|
434 |
wt.commit("bla", rev_id="oldparent") |
|
435 |
file("old/afile", "w").write("bloe") |
|
436 |
wt.commit("bla", rev_id="oldcommit") |
|
437 |
wt = wt.bzrdir.sprout("new").open_workingtree() |
|
438 |
self.build_tree(['new/bfile']) |
|
439 |
wt.add(["bfile"], ids=["newid"]) |
|
440 |
wt.commit("bla", rev_id="newparent") |
|
441 |
replay_delta_workingtree(wt, "oldcommit", "newcommit", |
|
442 |
["newparent"]) |
|
443 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
|
444 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
445 |
self.assertEquals(["newparent"], newrev.parent_ids) |
|
446 |
self.assertEquals("newcommit", newrev.revision_id) |
|
447 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
448 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
449 |
||
450 |
def test_multiple(self): |
|
451 |
wt = self.make_branch_and_tree("old") |
|
452 |
wt.commit("base", rev_id="base") |
|
453 |
self.build_tree(['old/afile']) |
|
454 |
wt.add(["afile"], ids=["originalid"]) |
|
455 |
wt.commit("bla", rev_id="oldparent") |
|
456 |
file("old/afile", "w").write("bloe") |
|
457 |
wt.add_pending_merge("ghost") |
|
458 |
wt.commit("bla", rev_id="oldcommit") |
|
459 |
wt = wt.bzrdir.sprout("new").open_workingtree() |
|
460 |
self.build_tree(['new/bfile']) |
|
461 |
wt.add(["bfile"], ids=["newid"]) |
|
462 |
wt.commit("bla", rev_id="newparent") |
|
463 |
replay_delta_workingtree(wt, "oldcommit", "newcommit", |
|
464 |
["newparent", "ghost"]) |
|
465 |
oldrev = wt.branch.repository.get_revision("oldcommit") |
|
466 |
newrev = wt.branch.repository.get_revision("newcommit") |
|
467 |
self.assertEquals(["newparent", "ghost"], newrev.parent_ids) |
|
468 |
self.assertEquals("newcommit", newrev.revision_id) |
|
469 |
self.assertEquals(oldrev.timestamp, newrev.timestamp) |
|
470 |
self.assertEquals(oldrev.timezone, newrev.timezone) |
|
471 |
||
472 |
||
|
0.436.34
by Jelmer Vernooij
Some more tests. |
473 |
class TestReplaySnapshotError(TestCase): |
474 |
def test_create(self): |
|
475 |
ReplaySnapshotError("message") |
|
476 |
||
477 |
||
478 |
class TestReplayParentsInconsistent(TestCase): |
|
479 |
def test_create(self): |
|
480 |
ReplayParentsInconsistent("afileid", "arevid") |