bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1540.1.7
by John Arbash Meinel
Added copyright statement to test_fileid_involved, and minor pep8 cleanup. |
1 |
# Copyright (C) 2005 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
|
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
16 |
|
17 |
import os |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
18 |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
19 |
from bzrlib.add import smart_add |
|
1545.2.9
by Aaron Bentley
Moved merge.merge to builtins |
20 |
from bzrlib.builtins import merge |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
21 |
from bzrlib.delta import compare_trees |
22 |
from bzrlib.merge import merge_inner |
|
23 |
from bzrlib.revision import common_ancestor |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
24 |
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
25 |
from bzrlib.workingtree import WorkingTree |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
26 |
|
|
1534.7.154
by Aaron Bentley
Removed changes from bzr.ab 1529..1536 |
27 |
|
|
1534.4.54
by Robert Collins
Merge from integration. |
28 |
class FileIdInvolvedBase(TestCaseWithRepository): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
29 |
|
30 |
def touch(self,filename): |
|
31 |
f = file(filename,"a") |
|
32 |
f.write("appended line\n") |
|
33 |
f.close( ) |
|
34 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
35 |
def merge(self, branch_from, wt_to): |
36 |
# minimal ui-less merge.
|
|
|
1534.1.31
by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo. |
37 |
wt_to.branch.fetch(branch_from) |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
38 |
base_rev = common_ancestor(branch_from.last_revision(), |
39 |
wt_to.branch.last_revision(), |
|
|
1534.4.28
by Robert Collins
first cut at merge from integration. |
40 |
wt_to.branch.repository) |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
41 |
merge_inner(wt_to.branch, branch_from.basis_tree(), |
|
1534.4.28
by Robert Collins
first cut at merge from integration. |
42 |
wt_to.branch.repository.revision_tree(base_rev), |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
43 |
this_tree=wt_to) |
44 |
wt_to.add_pending_merge(branch_from.last_revision()) |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
45 |
|
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
46 |
def compare_tree_fileids(self, branch, old_rev, new_rev): |
47 |
old_tree = self.branch.repository.revision_tree(old_rev) |
|
48 |
new_tree = self.branch.repository.revision_tree(new_rev) |
|
49 |
delta = compare_trees(old_tree, new_tree) |
|
50 |
||
51 |
l2 = [id for path, id, kind in delta.added] + \ |
|
52 |
[id for oldpath, newpath, id, kind, text_modified, \ |
|
53 |
meta_modified in delta.renamed] + \ |
|
54 |
[id for path, id, kind, text_modified, meta_modified in \ |
|
55 |
delta.modified] |
|
56 |
return set(l2) |
|
57 |
||
58 |
||
59 |
class TestFileIdInvolved(FileIdInvolvedBase): |
|
60 |
||
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
61 |
def setUp(self): |
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
62 |
super(TestFileIdInvolved, self).setUp() |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
63 |
# create three branches, and merge it
|
64 |
#
|
|
65 |
# /-->J ------>K (branch2)
|
|
66 |
# / \
|
|
67 |
# A ---> B --->C ---->D->G (main)
|
|
68 |
# \ / /
|
|
69 |
# \---> E---/----> F (branch1)
|
|
70 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
71 |
main_wt = self.make_branch_and_tree('main') |
72 |
main_branch = main_wt.branch |
|
73 |
self.build_tree(["main/a","main/b","main/c"]) |
|
74 |
||
75 |
main_wt.add(['a', 'b', 'c'], ['a-file-id-2006-01-01-abcd', |
|
|
1540.1.6
by John Arbash Meinel
fileid_involved needs to unescape the file id and revision id |
76 |
'b-file-id-2006-01-01-defg', |
77 |
'c-funky<file-id> quiji%bo']) |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
78 |
main_wt.commit("Commit one", rev_id="rev-A") |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
79 |
#-------- end A -----------
|
80 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
81 |
d1 = main_branch.bzrdir.clone('branch1') |
82 |
b1 = d1.open_branch() |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
83 |
self.build_tree(["branch1/d"]) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
84 |
bt1 = d1.open_workingtree() |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
85 |
bt1.add('d') |
86 |
bt1.commit("branch1, Commit one", rev_id="rev-E") |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
87 |
|
88 |
#-------- end E -----------
|
|
89 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
90 |
self.touch("main/a") |
91 |
main_wt.commit("Commit two", rev_id="rev-B") |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
92 |
|
93 |
#-------- end B -----------
|
|
94 |
||
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
95 |
d2 = main_branch.bzrdir.clone('branch2') |
96 |
branch2_branch = d2.open_branch() |
|
97 |
bt2 = d2.open_workingtree() |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
98 |
os.chmod("branch2/b",0770) |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
99 |
bt2.commit("branch2, Commit one", rev_id="rev-J") |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
100 |
|
101 |
#-------- end J -----------
|
|
102 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
103 |
self.merge(b1, main_wt) |
104 |
main_wt.commit("merge branch1, rev-11", rev_id="rev-C") |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
105 |
|
106 |
#-------- end C -----------
|
|
107 |
||
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
108 |
bt1.rename_one("d","e") |
109 |
bt1.commit("branch1, commit two", rev_id="rev-F") |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
110 |
|
111 |
#-------- end F -----------
|
|
112 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
113 |
self.touch("branch2/c") |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
114 |
bt2.commit("branch2, commit two", rev_id="rev-K") |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
115 |
|
116 |
#-------- end K -----------
|
|
117 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
118 |
self.touch("main/b") |
119 |
self.merge(b1, main_wt) |
|
|
1540.1.6
by John Arbash Meinel
fileid_involved needs to unescape the file id and revision id |
120 |
# D gets some funky characters to make sure the unescaping works
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
121 |
main_wt.commit("merge branch1, rev-12", rev_id="rev-<D>") |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
122 |
|
123 |
# end D
|
|
124 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
125 |
self.merge(branch2_branch, main_wt) |
126 |
main_wt.commit("merge branch1, rev-22", rev_id="rev-G") |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
127 |
|
128 |
# end G
|
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
129 |
self.branch = main_branch |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
130 |
|
131 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
132 |
def test_fileid_involved_all_revs(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
133 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
134 |
l = self.branch.repository.fileid_involved( ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
135 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["a","b","c","d"]) |
136 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
137 |
def test_fileid_involved_one_rev(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
138 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
139 |
l = self.branch.repository.fileid_involved("rev-B" ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
140 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["a","b","c"]) |
141 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
142 |
def test_fileid_involved_two_revs(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
143 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
144 |
l = self.branch.repository.fileid_involved_between_revs("rev-B","rev-K" ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
145 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["b","c"]) |
146 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
147 |
l = self.branch.repository.fileid_involved_between_revs("rev-C","rev-<D>" ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
148 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["b","d"]) |
149 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
150 |
l = self.branch.repository.fileid_involved_between_revs("rev-C","rev-G" ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
151 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["b","c","d"]) |
152 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
153 |
l = self.branch.repository.fileid_involved_between_revs("rev-E","rev-G" ) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
154 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["a", "b","c","d"]) |
155 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
156 |
def test_fileid_involved_sets(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
157 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
158 |
l = self.branch.repository.fileid_involved_by_set(set(["rev-B"])) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
159 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["a"]) |
160 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
161 |
l = self.branch.repository.fileid_involved_by_set(set(["rev-<D>"])) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
162 |
self.assertEquals( sorted(map( lambda x: x[0], l )), ["b"]) |
163 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
164 |
def test_fileid_involved_compare(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
165 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
166 |
l1 = self.branch.repository.fileid_involved_between_revs("rev-E", "rev-<D>") |
167 |
l2 = self.branch.repository.fileid_involved_by_set(set(["rev-<D>","rev-F","rev-C","rev-B"])) |
|
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
168 |
self.assertEquals( l1, l2 ) |
169 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
170 |
l1 = self.branch.repository.fileid_involved_between_revs("rev-C", "rev-G") |
171 |
l2 = self.branch.repository.fileid_involved_by_set( |
|
|
1540.1.6
by John Arbash Meinel
fileid_involved needs to unescape the file id and revision id |
172 |
set(["rev-G","rev-<D>","rev-F","rev-K","rev-J"])) |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
173 |
self.assertEquals( l1, l2 ) |
174 |
||
|
1185.64.9
by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved |
175 |
def test_fileid_involved_full_compare(self): |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
176 |
pp=[] |
177 |
history = self.branch.revision_history( ) |
|
178 |
||
179 |
if len(history) < 2: return |
|
180 |
||
181 |
for start in range(0,len(history)-1): |
|
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
182 |
start_id = history[start] |
|
1185.64.7
by Goffredo Baroncelli
added test for function fileid_involved |
183 |
for end in range(start+1,len(history)): |
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
184 |
end_id = history[end] |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
185 |
l1 = self.branch.repository.fileid_involved_between_revs( |
|
1534.4.54
by Robert Collins
Merge from integration. |
186 |
start_id, end_id) |
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
187 |
l2 = self.compare_tree_fileids(self.branch, start_id, end_id) |
188 |
self.assertEquals(l1, l2) |
|
189 |
||
190 |
||
191 |
class TestFileIdInvolvedSuperset(FileIdInvolvedBase): |
|
192 |
||
193 |
def setUp(self): |
|
194 |
super(TestFileIdInvolvedSuperset, self).setUp() |
|
195 |
||
196 |
main_wt = self.make_branch_and_tree('main') |
|
197 |
main_branch = main_wt.branch |
|
198 |
self.build_tree(["main/a","main/b","main/c"]) |
|
199 |
||
200 |
main_wt.add(['a', 'b', 'c'], ['a-file-id-2006-01-01-abcd', |
|
201 |
'b-file-id-2006-01-01-defg', |
|
202 |
'c-funky<file-id> quiji%bo']) |
|
203 |
main_wt.commit("Commit one", rev_id="rev-A") |
|
204 |
||
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
205 |
branch2_bzrdir = main_branch.bzrdir.sprout("branch2") |
206 |
branch2_branch = branch2_bzrdir.open_branch() |
|
207 |
branch2_wt = branch2_bzrdir.open_workingtree() |
|
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
208 |
os.chmod("branch2/b",0770) |
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
209 |
branch2_wt.commit("branch2, Commit one", rev_id="rev-J") |
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
210 |
|
211 |
self.merge(branch2_branch, main_wt) |
|
212 |
os.chmod("main/b",0660) |
|
213 |
main_wt.commit("merge branch1, rev-22", rev_id="rev-G") |
|
214 |
||
215 |
# end G
|
|
216 |
self.branch = main_branch |
|
217 |
||
218 |
def test_fileid_involved_full_compare2(self): |
|
219 |
history = self.branch.revision_history() |
|
220 |
old_rev = history[0] |
|
221 |
new_rev = history[1] |
|
222 |
||
|
1534.4.54
by Robert Collins
Merge from integration. |
223 |
l1 = self.branch.repository.fileid_involved_between_revs(old_rev, new_rev) |
|
1551.2.7
by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit] |
224 |
|
225 |
l2 = self.compare_tree_fileids(self.branch, old_rev, new_rev) |
|
226 |
self.assertNotEqual(l2, l1) |
|
|
1553.5.28
by Martin Pool
[merge] from bzr.dev before integration |
227 |
self.assertSubset(l2, l1) |