bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1563.2.12
by Robert Collins
Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile. |
1 |
# Copyright (C) 2006 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 join between versioned files."""
|
|
18 |
||
19 |
||
20 |
from bzrlib.tests import TestCaseWithTransport |
|
21 |
from bzrlib.transport import get_transport |
|
22 |
||
23 |
||
24 |
class TestJoin(TestCaseWithTransport): |
|
25 |
#Tests have self.versionedfile_factory and self.versionedfile_factory_to
|
|
26 |
#available to create source and target versioned files respectively.
|
|
27 |
||
28 |
def get_source(self, name='source'): |
|
29 |
"""Get a versioned file we will be joining from.""" |
|
30 |
return self.versionedfile_factory(name, |
|
31 |
get_transport(self.get_url())) |
|
32 |
||
33 |
def get_target(self, name='source'): |
|
34 |
""""Get an empty versioned file to join into.""" |
|
35 |
return self.versionedfile_factory_to(name, |
|
36 |
get_transport(self.get_url())) |
|
37 |
||
38 |
def test_join(self): |
|
39 |
f1 = self.get_source() |
|
40 |
f1.add_lines('r0', [], ['a\n', 'b\n']) |
|
41 |
f1.add_lines('r1', ['r0'], ['c\n', 'b\n']) |
|
42 |
f2 = self.get_target() |
|
43 |
f2.join(f1, None) |
|
44 |
def verify_file(f): |
|
45 |
self.assertTrue(f.has_version('r0')) |
|
46 |
self.assertTrue(f.has_version('r1')) |
|
47 |
verify_file(f2) |
|
48 |
verify_file(self.get_target()) |
|
49 |
||
50 |
self.assertRaises(RevisionNotPresent, |
|
51 |
f2.join, f1, version_ids=['r3']) |
|
52 |
||
53 |
#f3 = self.get_file('1')
|
|
54 |
#f3.add_lines('r0', ['a\n', 'b\n'], [])
|
|
55 |
#f3.add_lines('r1', ['c\n', 'b\n'], ['r0'])
|
|
56 |
#f4 = self.get_file('2')
|
|
57 |
#f4.join(f3, ['r0'])
|
|
58 |
#self.assertTrue(f4.has_version('r0'))
|
|
59 |
#self.assertFalse(f4.has_version('r1'))
|
|
60 |