/brz/remove-bazaar

To get this branch, use:
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
#
1540.1.7 by John Arbash Meinel
Added copyright statement to test_fileid_involved, and minor pep8 cleanup.
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
#
1540.1.7 by John Arbash Meinel
Added copyright statement to test_fileid_involved, and minor pep8 cleanup.
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
#
1540.1.7 by John Arbash Meinel
Added copyright statement to test_fileid_involved, and minor pep8 cleanup.
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
1711.7.29 by John Arbash Meinel
Switch to using TestSkipped for fileid_involved tests.
18
import sys
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
19
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
20
from bzrlib.errors import IllegalPath, NonAsciiRevisionId
1551.2.55 by abentley
Fix fileid involed tests on win32 (by skipping them for unescaped weave formats)
21
from bzrlib.tests import TestSkipped
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
22
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository
1711.7.4 by John Arbash Meinel
Fix test_fileid_involved so it uses TreeTransform to set the executable bits rather than chmod()
23
from bzrlib.transform import TreeTransform
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
24
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.
25
1534.7.154 by Aaron Bentley
Removed changes from bzr.ab 1529..1536
26
1534.4.54 by Robert Collins
Merge from integration.
27
class FileIdInvolvedBase(TestCaseWithRepository):
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
28
2018.5.96 by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
29
    def touch(self, tree, filename):
2381.1.3 by Robert Collins
Review feedback.
30
        # use the trees transport to not depend on the tree's location or type.
2018.5.96 by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
31
        tree.bzrdir.root_transport.append_bytes(filename, "appended line\n")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
32
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
33
    def compare_tree_fileids(self, branch, old_rev, new_rev):
34
        old_tree = self.branch.repository.revision_tree(old_rev)
35
        new_tree = self.branch.repository.revision_tree(new_rev)
1852.10.3 by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib.
36
        delta = new_tree.changes_from(old_tree)
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
37
38
        l2 = [id for path, id, kind in delta.added] + \
39
             [id for oldpath, newpath, id, kind, text_modified, \
40
                meta_modified in delta.renamed] + \
41
             [id for path, id, kind, text_modified, meta_modified in \
42
                delta.modified]
43
        return set(l2)
44
45
    
46
class TestFileIdInvolved(FileIdInvolvedBase):
47
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
48
    def setUp(self):
1185.64.9 by Goffredo Baroncelli
renamed test_file_involved -> test_fileid_involved
49
        super(TestFileIdInvolved, self).setUp()
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
50
        # create three branches, and merge it
51
        #
52
        #           /-->J ------>K                (branch2)
53
        #          /              \
54
        #  A ---> B --->C ---->D->G               (main)
55
        #  \           /      /
56
        #   \---> E---/----> F                 (branch1)
57
1694.2.6 by Martin Pool
[merge] bzr.dev
58
        # A changes: 
59
        # B changes: 'a-file-id-2006-01-01-abcd'
60
        # C changes:  Nothing (perfect merge)
61
        # D changes: 'b-file-id-2006-01-01-defg'
62
        # E changes: 'file-d'
63
        # F changes: 'file-d'
64
        # G changes: 'b-file-id-2006-01-01-defg'
65
        # J changes: 'b-file-id-2006-01-01-defg'
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
66
        # K changes: 'c-funky<file-id>quiji%bo'
1694.2.6 by Martin Pool
[merge] bzr.dev
67
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
68
        main_wt = self.make_branch_and_tree('main')
69
        main_branch = main_wt.branch
2381.1.3 by Robert Collins
Review feedback.
70
        self.build_tree(["main/a","main/b","main/c"])
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
71
72
        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
73
                                 'b-file-id-2006-01-01-defg',
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
74
                                 'c-funky<file-id>quiji%bo'])
1551.2.55 by abentley
Fix fileid involed tests on win32 (by skipping them for unescaped weave formats)
75
        try:
76
            main_wt.commit("Commit one", rev_id="rev-A")
77
        except IllegalPath:
1711.7.29 by John Arbash Meinel
Switch to using TestSkipped for fileid_involved tests.
78
            # TODO: jam 20060701 Consider raising a different exception
79
            #       newer formats do support this, and nothin can done to 
80
            #       correct this test - its not a bug.
81
            if sys.platform == 'win32':
82
                raise TestSkipped('Old repository formats do not'
83
                                  ' support file ids with <> on win32')
84
            # This is not a known error condition
85
            raise
86
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
87
        #-------- end A -----------
88
2018.14.1 by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures.
89
        bt1 = self.make_branch_and_tree('branch1')
90
        bt1.pull(main_branch)
91
        b1 = bt1.branch
2381.1.3 by Robert Collins
Review feedback.
92
        self.build_tree(["branch1/d"])
1694.2.6 by Martin Pool
[merge] bzr.dev
93
        bt1.add(['d'], ['file-d'])
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
94
        bt1.commit("branch1, Commit one", rev_id="rev-E")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
95
96
        #-------- end E -----------
97
2018.5.96 by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
98
        self.touch(main_wt, "a")
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
99
        main_wt.commit("Commit two", rev_id="rev-B")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
100
101
        #-------- end B -----------
102
2018.14.1 by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures.
103
        bt2 = self.make_branch_and_tree('branch2')
104
        bt2.pull(main_branch)
105
        branch2_branch = bt2.branch
1711.7.4 by John Arbash Meinel
Fix test_fileid_involved so it uses TreeTransform to set the executable bits rather than chmod()
106
        set_executability(bt2, 'b', True)
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
107
        bt2.commit("branch2, Commit one", rev_id="rev-J")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
108
109
        #-------- end J -----------
110
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
111
        main_wt.merge_from_branch(b1)
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
112
        main_wt.commit("merge branch1, rev-11", rev_id="rev-C")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
113
114
        #-------- end C -----------
115
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
116
        bt1.rename_one("d","e")
117
        bt1.commit("branch1, commit two", rev_id="rev-F")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
118
119
        #-------- end F -----------
120
2018.5.96 by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
121
        self.touch(bt2, "c")
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
122
        bt2.commit("branch2, commit two", rev_id="rev-K")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
123
124
        #-------- end K -----------
125
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
126
        main_wt.merge_from_branch(b1)
2018.5.96 by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
127
        self.touch(main_wt, "b")
1540.1.6 by John Arbash Meinel
fileid_involved needs to unescape the file id and revision id
128
        # 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.
129
        main_wt.commit("merge branch1, rev-12", rev_id="rev-<D>")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
130
131
        # end D
132
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
133
        main_wt.merge_from_branch(branch2_branch)
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
134
        main_wt.commit("merge branch1, rev-22",  rev_id="rev-G")
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
135
136
        # end G
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
137
        self.branch = main_branch
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
138
1694.2.6 by Martin Pool
[merge] bzr.dev
139
    def test_fileids_altered_between_two_revs(self):
140
        def foo(old, new):
141
            print set(self.branch.repository.get_ancestry(new)).difference(set(self.branch.repository.get_ancestry(old)))
2592.3.214 by Robert Collins
Merge bzr.dev.
142
        self.branch.lock_read()
143
        self.addCleanup(self.branch.unlock)
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
144
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
145
            {'b-file-id-2006-01-01-defg':set(['rev-J']),
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
146
             'c-funky<file-id>quiji%bo':set(['rev-K'])
1694.2.6 by Martin Pool
[merge] bzr.dev
147
             },
148
            self.branch.repository.fileids_altered_by_revision_ids(["rev-J","rev-K"]))
149
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
150
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
151
            {'b-file-id-2006-01-01-defg': set(['rev-<D>']),
152
             'file-d': set(['rev-F']),
153
             },
154
            self.branch.repository.fileids_altered_by_revision_ids(['rev-<D>', 'rev-F']))
155
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
156
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
157
            {
158
             'b-file-id-2006-01-01-defg': set(['rev-<D>', 'rev-G', 'rev-J']), 
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
159
             'c-funky<file-id>quiji%bo': set(['rev-K']),
1694.2.6 by Martin Pool
[merge] bzr.dev
160
             'file-d': set(['rev-F']), 
161
             },
162
            self.branch.repository.fileids_altered_by_revision_ids(
163
                ['rev-<D>', 'rev-G', 'rev-F', 'rev-K', 'rev-J']))
164
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
165
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
166
            {'a-file-id-2006-01-01-abcd': set(['rev-B']),
167
             'b-file-id-2006-01-01-defg': set(['rev-<D>', 'rev-G', 'rev-J']),
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
168
             'c-funky<file-id>quiji%bo': set(['rev-K']),
1694.2.6 by Martin Pool
[merge] bzr.dev
169
             'file-d': set(['rev-F']),
170
             },
171
            self.branch.repository.fileids_altered_by_revision_ids(
172
                ['rev-G', 'rev-F', 'rev-C', 'rev-B', 'rev-<D>', 'rev-K', 'rev-J']))
173
1910.2.24 by Aaron Bentley
Got intra-repository fetch working between model1 and 2 for all types
174
    def fileids_altered_by_revision_ids(self, revision_ids):
175
        """This is a wrapper to strip TREE_ROOT if it occurs"""
176
        repo = self.branch.repository
2946.3.3 by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('')
177
        root_id = self.branch.basis_tree().get_root_id()
1910.2.24 by Aaron Bentley
Got intra-repository fetch working between model1 and 2 for all types
178
        result = repo.fileids_altered_by_revision_ids(revision_ids)
1731.1.49 by Aaron Bentley
Merge bzr.dev
179
        if root_id in result:
180
            del result[root_id]
1910.2.24 by Aaron Bentley
Got intra-repository fetch working between model1 and 2 for all types
181
        return result
182
1694.2.6 by Martin Pool
[merge] bzr.dev
183
    def test_fileids_altered_by_revision_ids(self):
2592.3.214 by Robert Collins
Merge bzr.dev.
184
        self.branch.lock_read()
185
        self.addCleanup(self.branch.unlock)
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
186
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
187
            {'a-file-id-2006-01-01-abcd':set(['rev-A']),
188
             'b-file-id-2006-01-01-defg': set(['rev-A']),
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
189
             'c-funky<file-id>quiji%bo': set(['rev-A']),
2592.3.214 by Robert Collins
Merge bzr.dev.
190
             },
1910.2.24 by Aaron Bentley
Got intra-repository fetch working between model1 and 2 for all types
191
            self.fileids_altered_by_revision_ids(["rev-A"]))
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
192
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
193
            {'a-file-id-2006-01-01-abcd':set(['rev-B'])
194
             }, 
195
            self.branch.repository.fileids_altered_by_revision_ids(["rev-B"]))
1711.7.16 by John Arbash Meinel
remove assertDictsEqual
196
        self.assertEqual(
1694.2.6 by Martin Pool
[merge] bzr.dev
197
            {'b-file-id-2006-01-01-defg':set(['rev-<D>'])
198
             },
199
            self.branch.repository.fileids_altered_by_revision_ids(["rev-<D>"]))
200
201
    def test_fileids_involved_full_compare(self):
202
        # this tests that the result of each fileid_involved calculation 
203
        # along a revision history selects only the fileids selected by
204
        # comparing the trees - no less, and no more. This is correct 
205
        # because in our sample data we do not revert any file ids along
206
        # the revision history.
2592.3.214 by Robert Collins
Merge bzr.dev.
207
        self.branch.lock_read()
208
        self.addCleanup(self.branch.unlock)
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
209
        pp=[]
210
        history = self.branch.revision_history( )
211
212
        if len(history) < 2: return
213
214
        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]
215
            start_id = history[start]
1185.64.7 by Goffredo Baroncelli
added test for function fileid_involved
216
            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]
217
                end_id = history[end]
1694.2.6 by Martin Pool
[merge] bzr.dev
218
                old_revs = set(self.branch.repository.get_ancestry(start_id))
219
                new_revs = set(self.branch.repository.get_ancestry(end_id))
220
                l1 = self.branch.repository.fileids_altered_by_revision_ids(
221
                    new_revs.difference(old_revs))
222
                l1 = set(l1.keys())
223
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
224
                l2 = self.compare_tree_fileids(self.branch, start_id, end_id)
225
                self.assertEquals(l1, l2)
226
227
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
228
class TestFileIdInvolvedNonAscii(FileIdInvolvedBase):
229
230
    def test_utf8_file_ids_and_revision_ids(self):
231
        main_wt = self.make_branch_and_tree('main')
232
        main_branch = main_wt.branch
2381.1.3 by Robert Collins
Review feedback.
233
        self.build_tree(["main/a"])
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
234
2294.1.10 by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass
235
        file_id = u'a-f\xedle-id'.encode('utf8')
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
236
        main_wt.add(['a'], [file_id])
237
        revision_id = u'r\xe9v-a'.encode('utf8')
238
        try:
239
            main_wt.commit('a', rev_id=revision_id)
240
        except NonAsciiRevisionId:
241
            raise TestSkipped('non-ascii revision ids not supported by %s'
242
                              % self.repository_format)
243
244
        repo = main_wt.branch.repository
2592.3.214 by Robert Collins
Merge bzr.dev.
245
        repo.lock_read()
246
        self.addCleanup(repo.unlock)
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
247
        file_ids = repo.fileids_altered_by_revision_ids([revision_id])
2946.3.3 by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('')
248
        root_id = main_wt.basis_tree().get_root_id()
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
249
        if root_id in file_ids:
250
            self.assertEqual({file_id:set([revision_id]),
251
                              root_id:set([revision_id])
252
                             }, file_ids)
253
        else:
254
            self.assertEqual({file_id:set([revision_id])}, file_ids)
255
256
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
257
class TestFileIdInvolvedSuperset(FileIdInvolvedBase):
258
259
    def setUp(self):
260
        super(TestFileIdInvolvedSuperset, self).setUp()
261
1711.7.4 by John Arbash Meinel
Fix test_fileid_involved so it uses TreeTransform to set the executable bits rather than chmod()
262
        self.branch = None
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
263
        main_wt = self.make_branch_and_tree('main')
264
        main_branch = main_wt.branch
2381.1.3 by Robert Collins
Review feedback.
265
        self.build_tree(["main/a","main/b","main/c"])
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
266
267
        main_wt.add(['a', 'b', 'c'], ['a-file-id-2006-01-01-abcd',
268
                                 'b-file-id-2006-01-01-defg',
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
269
                                 'c-funky<file-id>quiji\'"%bo'])
1551.2.55 by abentley
Fix fileid involed tests on win32 (by skipping them for unescaped weave formats)
270
        try:
271
            main_wt.commit("Commit one", rev_id="rev-A")
2670.1.1 by Robert Collins
Remove the use of file_ids with spaces in the fileid_involved tests.
272
        except IllegalPath:
1711.7.29 by John Arbash Meinel
Switch to using TestSkipped for fileid_involved tests.
273
            # TODO: jam 20060701 Consider raising a different exception
274
            #       newer formats do support this, and nothin can done to 
275
            #       correct this test - its not a bug.
276
            if sys.platform == 'win32':
277
                raise TestSkipped('Old repository formats do not'
278
                                  ' support file ids with <> on win32')
279
            # This is not a known error condition
280
            raise
1910.2.29 by Aaron Bentley
Fix up sprout, nuke workaround
281
2018.14.1 by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures.
282
        branch2_wt = self.make_branch_and_tree('branch2')
283
        branch2_wt.pull(main_branch)
284
        branch2_bzrdir = branch2_wt.bzrdir
1534.5.3 by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository.
285
        branch2_branch = branch2_bzrdir.open_branch()
1711.7.4 by John Arbash Meinel
Fix test_fileid_involved so it uses TreeTransform to set the executable bits rather than chmod()
286
        set_executability(branch2_wt, 'b', True)
1534.5.3 by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository.
287
        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]
288
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
289
        main_wt.merge_from_branch(branch2_branch)
1711.7.15 by John Arbash Meinel
Properly handle the case when you want to turn off executability.
290
        set_executability(main_wt, 'b', False)
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
291
        main_wt.commit("merge branch1, rev-22",  rev_id="rev-G")
292
293
        # end G
294
        self.branch = main_branch
295
296
    def test_fileid_involved_full_compare2(self):
1694.2.6 by Martin Pool
[merge] bzr.dev
297
        # this tests that fileids_alteted_by_revision_ids returns 
298
        # more information than compare_tree can, because it 
299
        # sees each change rather than the aggregate delta.
2592.3.214 by Robert Collins
Merge bzr.dev.
300
        self.branch.lock_read()
301
        self.addCleanup(self.branch.unlock)
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
302
        history = self.branch.revision_history()
303
        old_rev = history[0]
304
        new_rev = history[1]
1694.2.6 by Martin Pool
[merge] bzr.dev
305
        old_revs = set(self.branch.repository.get_ancestry(old_rev))
306
        new_revs = set(self.branch.repository.get_ancestry(new_rev))
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
307
1694.2.6 by Martin Pool
[merge] bzr.dev
308
        l1 = self.branch.repository.fileids_altered_by_revision_ids(
309
            new_revs.difference(old_revs))
310
        l1 = set(l1.keys())
1551.2.7 by Aaron Bentley
Test case for discrepancy between fileid_involved and compare_tree [recommit]
311
312
        l2 = self.compare_tree_fileids(self.branch, old_rev, new_rev)
313
        self.assertNotEqual(l2, l1)
1553.5.28 by Martin Pool
[merge] from bzr.dev before integration
314
        self.assertSubset(l2, l1)
1711.7.4 by John Arbash Meinel
Fix test_fileid_involved so it uses TreeTransform to set the executable bits rather than chmod()
315
316
317
def set_executability(wt, path, executable=True):
318
    """Set the executable bit for the file at path in the working tree
319
320
    os.chmod() doesn't work on windows. But TreeTransform can mark or
321
    unmark a file as executable.
322
    """
323
    file_id = wt.path2id(path)
324
    tt = TreeTransform(wt)
1711.7.5 by John Arbash Meinel
Call finalize() though it doesn't help to release resources to allow cleanup.
325
    try:
1711.7.15 by John Arbash Meinel
Properly handle the case when you want to turn off executability.
326
        tt.set_executability(executable, tt.trans_id_tree_file_id(file_id))
1711.7.5 by John Arbash Meinel
Call finalize() though it doesn't help to release resources to allow cleanup.
327
        tt.apply()
328
    finally:
329
        tt.finalize()