2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2005 Canonical Ltd
|
1685.1.80
by Wouter van Heyst
more code cleanup |
2 |
#
|
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
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.
|
|
1685.1.80
by Wouter van Heyst
more code cleanup |
7 |
#
|
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
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.
|
|
1685.1.80
by Wouter van Heyst
more code cleanup |
12 |
#
|
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
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
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
16 |
|
17 |
import os |
|
18 |
||
19 |
||
2490.1.2
by John Arbash Meinel
Cleanup according to PEP8 and some other small whitespace fixes |
20 |
from bzrlib.missing import ( |
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
21 |
find_unmerged, |
2490.1.3
by John Arbash Meinel
Restore the test for iter_log_data as a deprecated function. |
22 |
iter_log_data, |
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
23 |
iter_log_revisions, |
24 |
)
|
|
2490.1.3
by John Arbash Meinel
Restore the test for iter_log_data as a deprecated function. |
25 |
from bzrlib.symbol_versioning import zero_seventeen |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
26 |
from bzrlib.tests import TestCaseWithTransport |
27 |
from bzrlib.workingtree import WorkingTree |
|
28 |
||
1534.4.28
by Robert Collins
first cut at merge from integration. |
29 |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
30 |
class TestMissing(TestCaseWithTransport): |
31 |
||
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
32 |
def test_find_unmerged(self): |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
33 |
original_tree = self.make_branch_and_tree('original') |
34 |
original = original_tree.branch |
|
35 |
puller_tree = self.make_branch_and_tree('puller') |
|
36 |
puller = puller_tree.branch |
|
37 |
merger_tree = self.make_branch_and_tree('merger') |
|
38 |
merger = merger_tree.branch |
|
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
39 |
self.assertEqual(find_unmerged(original, puller), ([], [])) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
40 |
original_tree.commit('a', rev_id='a') |
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
41 |
self.assertEqual(find_unmerged(original, puller), ([(1, u'a')], [])) |
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
42 |
puller_tree.pull(original) |
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
43 |
self.assertEqual(find_unmerged(original, puller), ([], [])) |
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
44 |
merger_tree.pull(original) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
45 |
original_tree.commit('b', rev_id='b') |
46 |
original_tree.commit('c', rev_id='c') |
|
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
47 |
self.assertEqual(find_unmerged(original, puller), ([(2, u'b'), |
48 |
(3, u'c')], [])) |
|
49 |
||
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
50 |
puller_tree.pull(original) |
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
51 |
self.assertEqual(find_unmerged(original, puller), ([], [])) |
52 |
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'), |
|
53 |
(3, u'c')], [])) |
|
1551.15.70
by Aaron Bentley
Avoid using builtins.merge |
54 |
merger_tree.merge_from_branch(original) |
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
55 |
self.assertEqual(find_unmerged(original, merger), ([(2, u'b'), |
56 |
(3, u'c')], [])) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
57 |
merger_tree.commit('d', rev_id='d') |
1185.54.23
by Aaron Bentley
Added unit tests for find_unmerged |
58 |
self.assertEqual(find_unmerged(original, merger), ([], [(2, 'd')])) |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
59 |
|
2490.1.3
by John Arbash Meinel
Restore the test for iter_log_data as a deprecated function. |
60 |
def test_iter_log_data(self): |
61 |
base_tree = self.make_branch_and_tree('base') |
|
62 |
self.build_tree(['base/a']) |
|
63 |
base_tree.add(['a'], ['a-id']) |
|
64 |
base_tree.commit('add a', rev_id='b-1') |
|
65 |
||
66 |
child_tree = base_tree.bzrdir.sprout('child').open_workingtree() |
|
67 |
||
68 |
self.build_tree(['child/b']) |
|
69 |
child_tree.add(['b'], ['b-id']) |
|
70 |
child_tree.commit('adding b', rev_id='c-2') |
|
71 |
||
72 |
child_tree.remove(['a']) |
|
73 |
child_tree.commit('removing a', rev_id='c-3') |
|
74 |
||
75 |
self.build_tree_contents([('child/b', 'new contents for b\n')]) |
|
76 |
child_tree.commit('modifying b', rev_id='c-4') |
|
77 |
||
78 |
child_tree.rename_one('b', 'c') |
|
79 |
child_tree.commit('rename b=>c', rev_id='c-5') |
|
80 |
||
81 |
base_extra, child_extra = find_unmerged(base_tree.branch, |
|
82 |
child_tree.branch) |
|
83 |
results = list(self.applyDeprecated(zero_seventeen, iter_log_data, |
|
84 |
base_extra, |
|
85 |
base_tree.branch.repository, |
|
86 |
verbose=True)) |
|
87 |
self.assertEqual([], results) |
|
88 |
||
89 |
results = list(self.applyDeprecated(zero_seventeen, iter_log_data, |
|
90 |
child_extra, |
|
91 |
child_tree.branch.repository, |
|
92 |
verbose=True)) |
|
93 |
self.assertEqual(4, len(results)) |
|
94 |
||
95 |
r0,r1,r2,r3 = results |
|
96 |
||
97 |
self.assertEqual((2, 'c-2'), (r0[0], r0[1].revision_id)) |
|
98 |
self.assertEqual((3, 'c-3'), (r1[0], r1[1].revision_id)) |
|
99 |
self.assertEqual((4, 'c-4'), (r2[0], r2[1].revision_id)) |
|
100 |
self.assertEqual((5, 'c-5'), (r3[0], r3[1].revision_id)) |
|
101 |
||
102 |
delta0 = r0[2] |
|
103 |
self.assertNotEqual(None, delta0) |
|
104 |
self.assertEqual([('b', 'b-id', 'file')], delta0.added) |
|
105 |
self.assertEqual([], delta0.removed) |
|
106 |
self.assertEqual([], delta0.renamed) |
|
107 |
self.assertEqual([], delta0.modified) |
|
108 |
||
109 |
delta1 = r1[2] |
|
110 |
self.assertNotEqual(None, delta1) |
|
111 |
self.assertEqual([], delta1.added) |
|
112 |
self.assertEqual([('a', 'a-id', 'file')], delta1.removed) |
|
113 |
self.assertEqual([], delta1.renamed) |
|
114 |
self.assertEqual([], delta1.modified) |
|
115 |
||
116 |
delta2 = r2[2] |
|
117 |
self.assertNotEqual(None, delta2) |
|
118 |
self.assertEqual([], delta2.added) |
|
119 |
self.assertEqual([], delta2.removed) |
|
120 |
self.assertEqual([], delta2.renamed) |
|
121 |
self.assertEqual([('b', 'b-id', 'file', True, False)], delta2.modified) |
|
122 |
||
123 |
delta3 = r3[2] |
|
124 |
self.assertNotEqual(None, delta3) |
|
125 |
self.assertEqual([], delta3.added) |
|
126 |
self.assertEqual([], delta3.removed) |
|
127 |
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)], |
|
128 |
delta3.renamed) |
|
129 |
self.assertEqual([], delta3.modified) |
|
130 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
131 |
def test_iter_log_revisions(self): |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
132 |
base_tree = self.make_branch_and_tree('base') |
133 |
self.build_tree(['base/a']) |
|
134 |
base_tree.add(['a'], ['a-id']) |
|
135 |
base_tree.commit('add a', rev_id='b-1') |
|
136 |
||
137 |
child_tree = base_tree.bzrdir.sprout('child').open_workingtree() |
|
138 |
||
139 |
self.build_tree(['child/b']) |
|
140 |
child_tree.add(['b'], ['b-id']) |
|
141 |
child_tree.commit('adding b', rev_id='c-2') |
|
142 |
||
143 |
child_tree.remove(['a']) |
|
144 |
child_tree.commit('removing a', rev_id='c-3') |
|
145 |
||
146 |
self.build_tree_contents([('child/b', 'new contents for b\n')]) |
|
147 |
child_tree.commit('modifying b', rev_id='c-4') |
|
148 |
||
149 |
child_tree.rename_one('b', 'c') |
|
150 |
child_tree.commit('rename b=>c', rev_id='c-5') |
|
151 |
||
152 |
base_extra, child_extra = find_unmerged(base_tree.branch, |
|
153 |
child_tree.branch) |
|
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
154 |
results = list(iter_log_revisions(base_extra, |
155 |
base_tree.branch.repository, |
|
156 |
verbose=True)) |
|
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
157 |
self.assertEqual([], results) |
158 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
159 |
results = list(iter_log_revisions(child_extra, |
160 |
child_tree.branch.repository, |
|
161 |
verbose=True)) |
|
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
162 |
self.assertEqual(4, len(results)) |
163 |
||
164 |
r0,r1,r2,r3 = results |
|
165 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
166 |
self.assertEqual((2, 'c-2'), (r0.revno, r0.rev.revision_id)) |
167 |
self.assertEqual((3, 'c-3'), (r1.revno, r1.rev.revision_id)) |
|
168 |
self.assertEqual((4, 'c-4'), (r2.revno, r2.rev.revision_id)) |
|
169 |
self.assertEqual((5, 'c-5'), (r3.revno, r3.rev.revision_id)) |
|
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
170 |
|
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
171 |
delta0 = r0.delta |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
172 |
self.assertNotEqual(None, delta0) |
173 |
self.assertEqual([('b', 'b-id', 'file')], delta0.added) |
|
174 |
self.assertEqual([], delta0.removed) |
|
175 |
self.assertEqual([], delta0.renamed) |
|
176 |
self.assertEqual([], delta0.modified) |
|
177 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
178 |
delta1 = r1.delta |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
179 |
self.assertNotEqual(None, delta1) |
180 |
self.assertEqual([], delta1.added) |
|
181 |
self.assertEqual([('a', 'a-id', 'file')], delta1.removed) |
|
182 |
self.assertEqual([], delta1.renamed) |
|
183 |
self.assertEqual([], delta1.modified) |
|
184 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
185 |
delta2 = r2.delta |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
186 |
self.assertNotEqual(None, delta2) |
187 |
self.assertEqual([], delta2.added) |
|
188 |
self.assertEqual([], delta2.removed) |
|
189 |
self.assertEqual([], delta2.renamed) |
|
190 |
self.assertEqual([('b', 'b-id', 'file', True, False)], delta2.modified) |
|
191 |
||
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
192 |
delta3 = r3.delta |
2204.1.1
by John Arbash Meinel
'bzr missing -v' was showing adds as deletes. |
193 |
self.assertNotEqual(None, delta3) |
194 |
self.assertEqual([], delta3.added) |
|
195 |
self.assertEqual([], delta3.removed) |
|
196 |
self.assertEqual([('b', 'c', 'b-id', 'file', False, False)], |
|
197 |
delta3.renamed) |
|
198 |
self.assertEqual([], delta3.modified) |