bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
2052.3.2
by John Arbash Meinel
 Change Copyright .. by Canonical to Copyright ... Canonical  | 
1  | 
# Copyright (C) 2005 Canonical Ltd
 | 
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
2  | 
#
 | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
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.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
7  | 
#
 | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
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.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
12  | 
#
 | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
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  | 
||
18  | 
import os  | 
|
19  | 
||
| 
2120.7.2
by Aaron Bentley
 Move autoresolve functionality to workingtree  | 
20  | 
from bzrlib import bzrdir  | 
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
21  | 
from bzrlib.tests import TestCaseWithTransport, TestCase  | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
22  | 
from bzrlib.branch import Branch  | 
| 
3017.2.1
by Aaron Bentley
 Revert now resolves conflicts recursively (#102739)  | 
23  | 
from bzrlib.conflicts import (  | 
24  | 
ConflictList,  | 
|
25  | 
ContentsConflict,  | 
|
26  | 
DuplicateID,  | 
|
27  | 
DuplicateEntry,  | 
|
28  | 
MissingParent,  | 
|
29  | 
ParentLoop,  | 
|
30  | 
PathConflict,  | 
|
31  | 
TextConflict,  | 
|
32  | 
UnversionedParent,  | 
|
33  | 
resolve,  | 
|
34  | 
restore,  | 
|
35  | 
    )
 | 
|
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
36  | 
from bzrlib.errors import NotConflicted  | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
37  | 
|
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
38  | 
|
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
39  | 
# TODO: Test commit with some added, and added-but-missing files
 | 
| 
1534.4.26
by Robert Collins
 Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.  | 
40  | 
# RBC 20060124 is that not tested in test_commit.py ?
 | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
41  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
42  | 
# The order of 'path' here is important - do not let it
 | 
43  | 
# be a sorted list.
 | 
|
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
44  | 
# u'\xe5' == a with circle
 | 
45  | 
# '\xc3\xae' == u'\xee' == i with hat
 | 
|
46  | 
# So these are u'pathg' and 'idg' only with a circle and a hat. (shappo?)
 | 
|
| 
1534.10.22
by Aaron Bentley
 Got ConflictList implemented  | 
47  | 
example_conflicts = ConflictList([  | 
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
48  | 
MissingParent('Not deleting', u'p\xe5thg', '\xc3\xaedg'),  | 
49  | 
ContentsConflict(u'p\xe5tha', None, '\xc3\xaeda'),  | 
|
50  | 
TextConflict(u'p\xe5tha'),  | 
|
51  | 
PathConflict(u'p\xe5thb', u'p\xe5thc', '\xc3\xaedb'),  | 
|
52  | 
DuplicateID('Unversioned existing file', u'p\xe5thc', u'p\xe5thc2',  | 
|
53  | 
'\xc3\xaedc', '\xc3\xaedc'),  | 
|
54  | 
DuplicateEntry('Moved existing file to', u'p\xe5thdd.moved', u'p\xe5thd',  | 
|
55  | 
'\xc3\xaedd', None),  | 
|
56  | 
ParentLoop('Cancelled move', u'p\xe5the', u'p\xe5th2e',  | 
|
57  | 
None, '\xc3\xaed2e'),  | 
|
58  | 
UnversionedParent('Versioned directory', u'p\xe5thf', '\xc3\xaedf'),  | 
|
| 
1534.10.22
by Aaron Bentley
 Got ConflictList implemented  | 
59  | 
])
 | 
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
60  | 
|
61  | 
||
| 
1534.4.26
by Robert Collins
 Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.  | 
62  | 
class TestConflicts(TestCaseWithTransport):  | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
63  | 
|
64  | 
def test_conflicts(self):  | 
|
65  | 
"""Conflicts are detected properly"""  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
66  | 
tree = self.make_branch_and_tree('.',  | 
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
67  | 
format=bzrdir.BzrDirFormat6())  | 
| 
1534.4.26
by Robert Collins
 Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.  | 
68  | 
b = tree.branch  | 
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
69  | 
file('hello', 'w').write('hello world4')  | 
70  | 
file('hello.THIS', 'w').write('hello world2')  | 
|
71  | 
file('hello.BASE', 'w').write('hello world1')  | 
|
72  | 
file('hello.OTHER', 'w').write('hello world3')  | 
|
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
73  | 
file('hello.sploo.BASE', 'w').write('yellow world')  | 
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
74  | 
file('hello.sploo.OTHER', 'w').write('yellow world2')  | 
| 
2255.2.61
by John Arbash Meinel
 Find callers of list_files() and make sure the tree is always locked.  | 
75  | 
tree.lock_read()  | 
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
76  | 
self.assertEqual(len(list(tree.list_files())), 6)  | 
| 
2255.2.61
by John Arbash Meinel
 Find callers of list_files() and make sure the tree is always locked.  | 
77  | 
tree.unlock()  | 
| 
1534.10.22
by Aaron Bentley
 Got ConflictList implemented  | 
78  | 
conflicts = tree.conflicts()  | 
| 
1185.14.8
by Aaron Bentley
 Added test_commit.py  | 
79  | 
self.assertEqual(len(conflicts), 2)  | 
| 
1534.10.20
by Aaron Bentley
 Got all tests passing  | 
80  | 
self.assert_('hello' in conflicts[0].path)  | 
81  | 
self.assert_('hello.sploo' in conflicts[1].path)  | 
|
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
82  | 
restore('hello')  | 
83  | 
restore('hello.sploo')  | 
|
| 
1534.10.22
by Aaron Bentley
 Got ConflictList implemented  | 
84  | 
self.assertEqual(len(tree.conflicts()), 0)  | 
| 
1185.35.1
by Aaron Bentley
 Implemented conflicts.restore  | 
85  | 
self.assertFileEqual('hello world2', 'hello')  | 
86  | 
assert not os.path.lexists('hello.sploo')  | 
|
87  | 
self.assertRaises(NotConflicted, restore, 'hello')  | 
|
88  | 
self.assertRaises(NotConflicted, restore, 'hello.sploo')  | 
|
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
89  | 
|
| 
1558.12.9
by Aaron Bentley
 Handle resolving conflicts with directories properly  | 
90  | 
def test_resolve_conflict_dir(self):  | 
91  | 
tree = self.make_branch_and_tree('.')  | 
|
92  | 
b = tree.branch  | 
|
93  | 
file('hello', 'w').write('hello world4')  | 
|
94  | 
tree.add('hello', 'q')  | 
|
95  | 
file('hello.THIS', 'w').write('hello world2')  | 
|
96  | 
file('hello.BASE', 'w').write('hello world1')  | 
|
97  | 
os.mkdir('hello.OTHER')  | 
|
98  | 
l = ConflictList([TextConflict('hello')])  | 
|
99  | 
l.remove_files(tree)  | 
|
100  | 
||
| 
1551.15.58
by Aaron Bentley
 Status honours selected paths for conflicts (#127606)  | 
101  | 
def test_select_conflicts(self):  | 
102  | 
tree = self.make_branch_and_tree('.')  | 
|
103  | 
tree_conflicts = ConflictList([ContentsConflict('foo'),  | 
|
104  | 
ContentsConflict('bar')])  | 
|
105  | 
self.assertEqual((ConflictList([ContentsConflict('bar')]),  | 
|
106  | 
ConflictList([ContentsConflict('foo')])),  | 
|
107  | 
tree_conflicts.select_conflicts(tree, ['foo']))  | 
|
108  | 
self.assertEqual((ConflictList(), tree_conflicts),  | 
|
109  | 
tree_conflicts.select_conflicts(tree, [''],  | 
|
110  | 
ignore_misses=True, recurse=True))  | 
|
111  | 
tree_conflicts = ConflictList([ContentsConflict('foo/baz'),  | 
|
112  | 
ContentsConflict('bar')])  | 
|
113  | 
self.assertEqual((ConflictList([ContentsConflict('bar')]),  | 
|
114  | 
ConflictList([ContentsConflict('foo/baz')])),  | 
|
115  | 
tree_conflicts.select_conflicts(tree, ['foo'],  | 
|
116  | 
recurse=True,  | 
|
117  | 
ignore_misses=True))  | 
|
118  | 
tree_conflicts = ConflictList([PathConflict('qux', 'foo/baz')])  | 
|
119  | 
self.assertEqual((ConflictList(), tree_conflicts),  | 
|
120  | 
tree_conflicts.select_conflicts(tree, ['foo'],  | 
|
121  | 
recurse=True,  | 
|
122  | 
ignore_misses=True))  | 
|
| 
1551.15.59
by Aaron Bentley
 Test that default behavior is as before  | 
123  | 
self.assertEqual((tree_conflicts, ConflictList()),  | 
124  | 
tree_conflicts.select_conflicts(tree, ['foo'],  | 
|
125  | 
ignore_misses=True))  | 
|
| 
1551.15.58
by Aaron Bentley
 Status honours selected paths for conflicts (#127606)  | 
126  | 
|
| 
3017.2.1
by Aaron Bentley
 Revert now resolves conflicts recursively (#102739)  | 
127  | 
def test_resolve_conflicts_recursive(self):  | 
128  | 
tree = self.make_branch_and_tree('.')  | 
|
129  | 
self.build_tree(['dir/', 'dir/hello'])  | 
|
130  | 
tree.add(['dir', 'dir/hello'])  | 
|
131  | 
tree.set_conflicts(ConflictList([TextConflict('dir/hello')]))  | 
|
132  | 
resolve(tree, ['dir'], recursive=False, ignore_misses=True)  | 
|
133  | 
self.assertEqual(ConflictList([TextConflict('dir/hello')]),  | 
|
134  | 
tree.conflicts())  | 
|
135  | 
resolve(tree, ['dir'], recursive=True, ignore_misses=True)  | 
|
136  | 
self.assertEqual(ConflictList([]),  | 
|
137  | 
tree.conflicts())  | 
|
138  | 
||
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
139  | 
|
140  | 
class TestConflictStanzas(TestCase):  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
141  | 
|
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
142  | 
def test_stanza_roundtrip(self):  | 
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
143  | 
        # write and read our example stanza.
 | 
| 
1534.10.23
by Aaron Bentley
 Removed conflicts_to_stanzas and stanzas_to_conflicts  | 
144  | 
stanza_iter = example_conflicts.to_stanzas()  | 
145  | 
processed = ConflictList.from_stanzas(stanza_iter)  | 
|
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
146  | 
for o, p in zip(processed, example_conflicts):  | 
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
147  | 
self.assertEqual(o, p)  | 
148  | 
||
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
149  | 
self.assertIsInstance(o.path, unicode)  | 
150  | 
||
151  | 
if o.file_id is not None:  | 
|
152  | 
self.assertIsInstance(o.file_id, str)  | 
|
153  | 
||
| 
2309.4.14
by John Arbash Meinel
 The parameter is 'conflict_path' not 'conflict_file_path'  | 
154  | 
conflict_path = getattr(o, 'conflict_path', None)  | 
155  | 
if conflict_path is not None:  | 
|
156  | 
self.assertIsInstance(conflict_path, unicode)  | 
|
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
157  | 
|
158  | 
conflict_file_id = getattr(o, 'conflict_file_id', None)  | 
|
159  | 
if conflict_file_id is not None:  | 
|
160  | 
self.assertIsInstance(conflict_file_id, str)  | 
|
161  | 
||
| 
1534.10.4
by Aaron Bentley
 Implemented conflict serialization  | 
162  | 
def test_stanzification(self):  | 
| 
1534.10.23
by Aaron Bentley
 Removed conflicts_to_stanzas and stanzas_to_conflicts  | 
163  | 
for stanza in example_conflicts.to_stanzas():  | 
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
164  | 
if 'file_id' in stanza:  | 
165  | 
                # In Stanza form, the file_id has to be unicode.
 | 
|
166  | 
self.assertStartsWith(stanza['file_id'], u'\xeed')  | 
|
167  | 
self.assertStartsWith(stanza['path'], u'p\xe5th')  | 
|
| 
2309.4.14
by John Arbash Meinel
 The parameter is 'conflict_path' not 'conflict_file_path'  | 
168  | 
if 'conflict_path' in stanza:  | 
169  | 
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')  | 
|
| 
2309.4.13
by John Arbash Meinel
 Conflicts go through Stanza so the need to be aware of utf8 versus unicode file ids.  | 
170  | 
if 'conflict_file_id' in stanza:  | 
171  | 
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')  |