bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
1 |
# Copyright (C) 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
"""Tests for interface conformance of 'WorkingTree.annotate_iter'"""
|
|
18 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy.tests.per_workingtree import TestCaseWithWorkingTree |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
20 |
|
21 |
||
22 |
class TestAnnotateIter(TestCaseWithWorkingTree): |
|
23 |
||
24 |
def make_single_rev_tree(self): |
|
25 |
builder = self.make_branch_builder('branch') |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
26 |
revid = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
27 |
('add', ('', None, 'directory', None)), |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
28 |
('add', ('file', None, 'file', b'initial content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
29 |
])
|
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
30 |
b = builder.get_branch() |
31 |
tree = b.create_checkout('tree', lightweight=True) |
|
32 |
tree.lock_read() |
|
33 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
34 |
return tree, revid |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
35 |
|
36 |
def test_annotate_same_as_parent(self): |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
37 |
tree, revid = self.make_single_rev_tree() |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
38 |
annotations = tree.annotate_iter('file') |
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
39 |
self.assertEqual([(revid, b'initial content\n')], |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
40 |
annotations) |
41 |
||
42 |
def test_annotate_mod_from_parent(self): |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
43 |
tree, revid = self.make_single_rev_tree() |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
44 |
self.build_tree_contents([('tree/file', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
45 |
b'initial content\nnew content\n')]) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
46 |
annotations = tree.annotate_iter('file') |
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
47 |
self.assertEqual([(revid, b'initial content\n'), |
48 |
(b'current:', b'new content\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
49 |
], annotations) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
50 |
|
51 |
def test_annotate_merge_parents(self): |
|
52 |
builder = self.make_branch_builder('branch') |
|
53 |
builder.start_series() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
54 |
revid1 = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
55 |
('add', ('', None, 'directory', None)), |
56 |
('add', ('file', None, 'file', b'initial content\n')), |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
57 |
])
|
58 |
revid2 = builder.build_snapshot([revid1], [ |
|
|
6883.22.11
by Jelmer Vernooij
merge trunk |
59 |
('modify', ('file', b'initial content\ncontent in 2\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
60 |
])
|
61 |
revid3 = builder.build_snapshot([revid1], [ |
|
|
6883.22.11
by Jelmer Vernooij
merge trunk |
62 |
('modify', ('file', b'initial content\ncontent in 3\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
63 |
])
|
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
64 |
builder.finish_series() |
65 |
b = builder.get_branch() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
66 |
tree = b.create_checkout('tree', revision_id=revid2, lightweight=True) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
67 |
tree.lock_write() |
68 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
69 |
tree.set_parent_ids([revid2, revid3]) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
70 |
self.build_tree_contents([('tree/file', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
71 |
b'initial content\ncontent in 2\n' |
72 |
b'content in 3\nnew content\n')]) |
|
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
73 |
annotations = tree.annotate_iter('file') |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
74 |
self.assertEqual([(revid1, b'initial content\n'), |
75 |
(revid2, b'content in 2\n'), |
|
76 |
(revid3, b'content in 3\n'), |
|
77 |
(b'current:', b'new content\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
78 |
], annotations) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
79 |
|
80 |
def test_annotate_merge_parent_no_file(self): |
|
81 |
builder = self.make_branch_builder('branch') |
|
82 |
builder.start_series() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
83 |
revid1 = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
84 |
('add', ('', None, 'directory', None)), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
85 |
])
|
86 |
revid2 = builder.build_snapshot([revid1], [ |
|
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
87 |
('add', ('file', None, 'file', b'initial content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
88 |
])
|
89 |
revid3 = builder.build_snapshot([revid1], []) |
|
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
90 |
builder.finish_series() |
91 |
b = builder.get_branch() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
92 |
tree = b.create_checkout('tree', revision_id=revid2, lightweight=True) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
93 |
tree.lock_write() |
94 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
95 |
tree.set_parent_ids([revid2, revid3]) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
96 |
self.build_tree_contents([('tree/file', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
97 |
b'initial content\nnew content\n')]) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
98 |
annotations = tree.annotate_iter('file') |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
99 |
self.assertEqual([(revid2, b'initial content\n'), |
100 |
(b'current:', b'new content\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
101 |
], annotations) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
102 |
|
103 |
def test_annotate_merge_parent_was_directory(self): |
|
104 |
builder = self.make_branch_builder('branch') |
|
105 |
builder.start_series() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
106 |
revid1 = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
107 |
('add', ('', None, 'directory', None)), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
108 |
])
|
109 |
revid2 = builder.build_snapshot([revid1], [ |
|
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
110 |
('add', ('file', None, 'file', b'initial content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
111 |
])
|
112 |
revid3 = builder.build_snapshot([revid1], [ |
|
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
113 |
('add', ('a_dir', None, 'directory', None)), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
114 |
])
|
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
115 |
builder.finish_series() |
116 |
b = builder.get_branch() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
117 |
tree = b.create_checkout('tree', revision_id=revid2, lightweight=True) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
118 |
tree.lock_write() |
119 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
120 |
tree.set_parent_ids([revid2, revid3]) |
|
4454.3.68
by John Arbash Meinel
Add some tests that we can handle doing annotations even when |
121 |
self.build_tree_contents([('tree/file', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
122 |
b'initial content\nnew content\n')]) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
123 |
annotations = tree.annotate_iter('file') |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
124 |
self.assertEqual([(revid2, b'initial content\n'), |
125 |
(b'current:', b'new content\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
126 |
], annotations) |
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
127 |
|
128 |
def test_annotate_same_as_merge_parent(self): |
|
129 |
builder = self.make_branch_builder('branch') |
|
130 |
builder.start_series() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
131 |
revid1 = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
132 |
('add', ('', None, 'directory', None)), |
133 |
('add', ('file', None, 'file', b'initial content\n')), |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
134 |
])
|
135 |
revid2 = builder.build_snapshot([revid1], [ |
|
136 |
])
|
|
137 |
revid3 = builder.build_snapshot([revid1], [ |
|
|
6883.22.11
by Jelmer Vernooij
merge trunk |
138 |
('modify', ('file', b'initial content\ncontent in 3\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
139 |
])
|
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
140 |
builder.finish_series() |
141 |
b = builder.get_branch() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
142 |
tree = b.create_checkout('tree', revision_id=revid2, lightweight=True) |
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
143 |
tree.lock_write() |
144 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
145 |
tree.set_parent_ids([revid2, revid3]) |
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
146 |
self.build_tree_contents([('tree/file', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
147 |
b'initial content\ncontent in 3\n')]) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
148 |
annotations = tree.annotate_iter('file') |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
149 |
self.assertEqual([(revid1, b'initial content\n'), |
150 |
(revid3, b'content in 3\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
151 |
], annotations) |
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
152 |
|
153 |
def test_annotate_same_as_merge_parent_supersedes(self): |
|
154 |
builder = self.make_branch_builder('branch') |
|
155 |
builder.start_series() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
156 |
revid1 = builder.build_snapshot(None, [ |
|
6883.22.13
by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder. |
157 |
('add', ('', None, 'directory', None)), |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
158 |
('add', ('file', None, 'file', b'initial content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
159 |
])
|
160 |
revid2 = builder.build_snapshot([revid1], [ |
|
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
161 |
('modify', ('file', b'initial content\nnew content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
162 |
])
|
163 |
revid3 = builder.build_snapshot([revid2], [ |
|
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
164 |
('modify', ('file', b'initial content\ncontent in 3\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
165 |
])
|
166 |
revid4 = builder.build_snapshot([revid3], [ |
|
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
167 |
('modify', ('file', b'initial content\nnew content\n')), |
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
168 |
])
|
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
169 |
# In this case, the content locally is the same as content in basis
|
170 |
# tree, but the merge revision states that *it* should win
|
|
171 |
builder.finish_series() |
|
172 |
b = builder.get_branch() |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
173 |
tree = b.create_checkout('tree', revision_id=revid2, lightweight=True) |
|
4454.3.69
by John Arbash Meinel
Add a couple more annotate-after-merge tests for WT. |
174 |
tree.lock_write() |
175 |
self.addCleanup(tree.unlock) |
|
|
6829.2.1
by Jelmer Vernooij
Avoid passing in file_ids/revision_ids in a few more places. |
176 |
tree.set_parent_ids([revid2, revid4]) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
177 |
annotations = tree.annotate_iter('file') |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
178 |
self.assertEqual([(revid1, b'initial content\n'), |
179 |
(revid4, b'new content\n'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
180 |
], annotations) |