bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
1 |
# Copyright (C) 2005-2011 Canonical Ltd
|
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
|
6379.6.7
by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear. |
18 |
"""Tests for weave-era working tree formats."""
|
19 |
||
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
20 |
import os |
21 |
||
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
22 |
from ... import ( |
|
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
23 |
conflicts, |
24 |
)
|
|
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
25 |
from ...bzr.conflicts import TextConflict, ContentsConflict |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from ... import ( |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
27 |
errors, |
28 |
)
|
|
29 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
30 |
from ...tests import ( |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
31 |
TestCaseWithTransport, |
32 |
)
|
|
33 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
34 |
from .bzrdir import BzrDirFormat6 |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
35 |
|
36 |
||
37 |
class TestFormat2WorkingTree(TestCaseWithTransport): |
|
38 |
"""Tests that are specific to format 2 trees.""" |
|
39 |
||
40 |
def create_format2_tree(self, url): |
|
41 |
return self.make_branch_and_tree( |
|
42 |
url, format=BzrDirFormat6()) |
|
43 |
||
44 |
def test_conflicts(self): |
|
|
6745.1.2
by Jelmer Vernooij
s/compatability/compatibility/ |
45 |
# test backwards compatibility
|
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
46 |
tree = self.create_format2_tree('.') |
47 |
self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts, |
|
48 |
None) |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
49 |
with open('lala.BASE', 'wb') as f: |
50 |
f.write(b'labase') |
|
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
51 |
expected = ContentsConflict('lala') |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
52 |
self.assertEqual(list(tree.conflicts()), [expected]) |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
53 |
with open('lala', 'wb') as f: |
54 |
f.write(b'la') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
55 |
tree.add('lala', b'lala-id') |
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
56 |
expected = ContentsConflict('lala', file_id='lala-id') |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
57 |
self.assertEqual(list(tree.conflicts()), [expected]) |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
58 |
with open('lala.THIS', 'wb') as f: |
59 |
f.write(b'lathis') |
|
60 |
with open('lala.OTHER', 'wb') as f: |
|
61 |
f.write(b'laother') |
|
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
62 |
# When "text conflict"s happen, stem, THIS and OTHER are text
|
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
63 |
expected = TextConflict('lala', file_id='lala-id') |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
64 |
self.assertEqual(list(tree.conflicts()), [expected]) |
65 |
os.unlink('lala.OTHER') |
|
66 |
os.mkdir('lala.OTHER') |
|
|
7490.129.8
by Jelmer Vernooij
Fix imports. |
67 |
expected = ContentsConflict('lala', file_id='lala-id') |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
68 |
self.assertEqual(list(tree.conflicts()), [expected]) |
69 |
||
70 |
def test_detect_conflicts(self): |
|
71 |
"""Conflicts are detected properly""" |
|
72 |
tree = self.create_format2_tree('.') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
73 |
self.build_tree_contents([('hello', b'hello world4'), |
74 |
('hello.THIS', b'hello world2'), |
|
75 |
('hello.BASE', b'hello world1'), |
|
76 |
('hello.OTHER', b'hello world3'), |
|
77 |
('hello.sploo.BASE', b'yellowworld'), |
|
78 |
('hello.sploo.OTHER', b'yellowworld2'), |
|
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
79 |
])
|
80 |
tree.lock_read() |
|
81 |
self.assertLength(6, list(tree.list_files())) |
|
82 |
tree.unlock() |
|
83 |
tree_conflicts = tree.conflicts() |
|
84 |
self.assertLength(2, tree_conflicts) |
|
85 |
self.assertTrue('hello' in tree_conflicts[0].path) |
|
86 |
self.assertTrue('hello.sploo' in tree_conflicts[1].path) |
|
87 |
conflicts.restore('hello') |
|
88 |
conflicts.restore('hello.sploo') |
|
89 |
self.assertLength(0, tree.conflicts()) |
|
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
90 |
self.assertFileEqual(b'hello world2', 'hello') |
|
5697.1.1
by Jelmer Vernooij
Move WorkingTreeFormat2 to a separate file. |
91 |
self.assertFalse(os.path.lexists('hello.sploo')) |
92 |
self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello') |
|
93 |
self.assertRaises(errors.NotConflicted, |
|
94 |
conflicts.restore, 'hello.sploo') |