~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fileid_involved.py

MergeĀ fromĀ jam-integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
 
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
3
16
 
4
17
from bzrlib.tests import TestCaseInTempDir
5
18
import os
11
24
from bzrlib.workingtree import WorkingTree
12
25
from bzrlib.delta import compare_trees
13
26
 
 
27
 
14
28
class TestFileIdInvolved(TestCaseInTempDir):
15
29
 
16
30
    def touch(self,filename):
18
32
        f.write("appended line\n")
19
33
        f.close( )
20
34
 
21
 
 
22
35
    def merge( self, branch_from, force=False ):
23
36
        from bzrlib.merge_core import ApplyMerge3
24
37
 
41
54
        main_branch = Branch.initialize('.')
42
55
        self.build_tree(["a","b","c"])
43
56
 
44
 
        smart_add('.')
45
 
        commit(Branch.open("."), "Commit one", rev_id="rev-A")
 
57
        b = Branch.open('.')
 
58
        wt = b.working_tree()
 
59
        wt.add(['a', 'b', 'c'], ['a-file-id-2006-01-01-abcd',
 
60
                                 'b-file-id-2006-01-01-defg',
 
61
                                 'c-funky<file-id> quiji%bo'])
 
62
        commit(b, "Commit one", rev_id="rev-A")
 
63
        del b, wt
46
64
        #-------- end A -----------
47
65
 
48
66
        copy_branch(main_branch,"../branch1")
88
106
        os.chdir("../branch2")
89
107
 
90
108
        self.touch("c")
91
 
        smart_add('.')
92
109
        commit(Branch.open("."), "branch2, commit two", rev_id="rev-K")
93
110
 
94
111
        #-------- end K -----------
98
115
        self.touch("b")
99
116
        self.merge("../branch1",force=True)
100
117
 
101
 
        commit(Branch.open("."), "merge branch1, rev-12", rev_id="rev-D")
 
118
        # D gets some funky characters to make sure the unescaping works
 
119
        commit(Branch.open("."), "merge branch1, rev-12", rev_id="rev-<D>")
102
120
 
103
121
        # end D
104
122
 
125
143
        l = self.branch.fileid_involved_between_revs("rev-B","rev-K" )
126
144
        self.assertEquals( sorted(map( lambda x: x[0], l )), ["b","c"])
127
145
 
128
 
        l = self.branch.fileid_involved_between_revs("rev-C","rev-D" )
 
146
        l = self.branch.fileid_involved_between_revs("rev-C","rev-<D>" )
129
147
        self.assertEquals( sorted(map( lambda x: x[0], l )), ["b","d"])
130
148
 
131
149
        l = self.branch.fileid_involved_between_revs("rev-C","rev-G" )
134
152
        l = self.branch.fileid_involved_between_revs("rev-E","rev-G" )
135
153
        self.assertEquals( sorted(map( lambda x: x[0], l )), ["a", "b","c","d"])
136
154
 
137
 
 
138
155
    def test_fileid_involved_sets(self):
139
156
 
140
157
        l = self.branch.fileid_involved_by_set(set(["rev-B"]))
141
158
        self.assertEquals( sorted(map( lambda x: x[0], l )), ["a"])
142
159
 
143
 
        l = self.branch.fileid_involved_by_set(set(["rev-D"]))
 
160
        l = self.branch.fileid_involved_by_set(set(["rev-<D>"]))
144
161
        self.assertEquals( sorted(map( lambda x: x[0], l )), ["b"])
145
162
 
146
163
    def test_fileid_involved_compare(self):
147
164
 
148
 
        l1 = self.branch.fileid_involved_between_revs("rev-E", "rev-D")
149
 
        l2 = self.branch.fileid_involved_by_set(set(["rev-D","rev-F","rev-C","rev-B"]))
 
165
        l1 = self.branch.fileid_involved_between_revs("rev-E", "rev-<D>")
 
166
        l2 = self.branch.fileid_involved_by_set(set(["rev-<D>","rev-F","rev-C","rev-B"]))
150
167
        self.assertEquals( l1, l2 )
151
168
 
152
169
        l1 = self.branch.fileid_involved_between_revs("rev-C", "rev-G")
153
170
        l2 = self.branch.fileid_involved_by_set(
154
 
            set(["rev-G","rev-D","rev-F","rev-K","rev-J"]))
 
171
            set(["rev-G","rev-<D>","rev-F","rev-K","rev-J"]))
155
172
        self.assertEquals( l1, l2 )
156
173
 
157
174
    def test_fileid_involved_full_compare(self):
179
196
 
180
197
                self.assertEquals( l1, set(l2) )
181
198
 
 
199