~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fileid_involved.py

Removed changes from bzr.ab 1529..1536

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.tests import TestCaseWithTransport
27
27
from bzrlib.workingtree import WorkingTree
28
28
 
29
 
class FileIdInvolvedBase(TestCaseWithTransport):
 
29
 
 
30
class TestFileIdInvolved(TestCaseWithTransport):
30
31
 
31
32
    def touch(self,filename):
32
33
        f = file(filename,"a")
45
46
                    this_tree=wt_to)
46
47
        wt_to.add_pending_merge(branch_from.last_revision())
47
48
 
48
 
    def compare_tree_fileids(self, branch, old_rev, new_rev):
49
 
        old_tree = self.branch.repository.revision_tree(old_rev)
50
 
        new_tree = self.branch.repository.revision_tree(new_rev)
51
 
        delta = compare_trees(old_tree, new_tree)
52
 
 
53
 
        l2 = [id for path, id, kind in delta.added] + \
54
 
             [id for oldpath, newpath, id, kind, text_modified, \
55
 
                meta_modified in delta.renamed] + \
56
 
             [id for path, id, kind, text_modified, meta_modified in \
57
 
                delta.modified]
58
 
        return set(l2)
59
 
 
60
 
    
61
 
class TestFileIdInvolved(FileIdInvolvedBase):
62
 
 
63
49
    def setUp(self):
64
50
        super(TestFileIdInvolved, self).setUp()
65
51
        # create three branches, and merge it
180
166
        if len(history) < 2: return
181
167
 
182
168
        for start in range(0,len(history)-1):
183
 
            start_id = history[start]
184
169
            for end in range(start+1,len(history)):
185
 
                end_id = history[end]
186
 
                l1 = self.branch.fileid_involved_between_revs(start_id, end_id)
187
 
 
188
 
                l2 = self.compare_tree_fileids(self.branch, start_id, end_id)
189
 
                self.assertEquals(l1, l2)
190
 
 
191
 
 
192
 
class TestFileIdInvolvedSuperset(FileIdInvolvedBase):
193
 
 
194
 
    def setUp(self):
195
 
        super(TestFileIdInvolvedSuperset, self).setUp()
196
 
 
197
 
        main_wt = self.make_branch_and_tree('main')
198
 
        main_branch = main_wt.branch
199
 
        self.build_tree(["main/a","main/b","main/c"])
200
 
 
201
 
        main_wt.add(['a', 'b', 'c'], ['a-file-id-2006-01-01-abcd',
202
 
                                 'b-file-id-2006-01-01-defg',
203
 
                                 'c-funky<file-id> quiji%bo'])
204
 
        main_wt.commit("Commit one", rev_id="rev-A")
205
 
 
206
 
        branch2_branch = main_branch.clone("branch2")
207
 
        os.chmod("branch2/b",0770)
208
 
        branch2_branch.working_tree().commit("branch2, Commit one", 
209
 
                                             rev_id="rev-J")
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
 
 
223
 
        l1 = self.branch.fileid_involved_between_revs(old_rev, new_rev)
224
 
 
225
 
        l2 = self.compare_tree_fileids(self.branch, old_rev, new_rev)
226
 
        self.assertNotEqual(l2, l1)
227
 
        self.AssertSubset(l2, l1)
 
170
 
 
171
                l1 = self.branch.fileid_involved_between_revs(
 
172
                    history[start], history[end])
 
173
 
 
174
                old_tree = self.branch.repository.revision_tree(history[start])
 
175
                new_tree = self.branch.repository.revision_tree(history[end])
 
176
                delta = compare_trees(old_tree, new_tree )
 
177
 
 
178
                l2 = [id for path, id, kind in delta.added] + \
 
179
                     [id for oldpath, newpath, id, kind, text_modified, \
 
180
                        meta_modified in delta.renamed] + \
 
181
                     [id for path, id, kind, text_modified, meta_modified in \
 
182
                        delta.modified]
 
183
 
 
184
                self.assertEquals(l1, set(l2))
 
185
 
 
186