/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_filesystem_cicp.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib import (
 
22
from ... import (
23
23
    osutils,
24
24
    tests,
25
25
    )
26
 
from bzrlib.tests import KnownFailure
27
 
from bzrlib.osutils import canonical_relpath, pathjoin
28
 
from bzrlib.tests.script import run_script
29
 
from bzrlib.tests.features import (
 
26
from .. import KnownFailure
 
27
from ...osutils import canonical_relpath, pathjoin
 
28
from ..script import run_script
 
29
from ..features import (
30
30
    CaseInsCasePresFilenameFeature,
31
31
    )
32
32
 
58
58
        # create a file on disk with the mixed-case name
59
59
        self.build_tree(['CamelCase'])
60
60
        run_script(self, """
61
 
            $ bzr add camelcase
 
61
            $ brz add camelcase
62
62
            adding CamelCase
63
63
            """)
64
64
 
68
68
        # create a file on disk with the mixed-case parent and base name
69
69
        self.build_tree(['CamelCaseParent/', 'CamelCaseParent/CamelCase'])
70
70
        run_script(self, """
71
 
            $ bzr add camelcaseparent/camelcase
 
71
            $ brz add camelcaseparent/camelcase
72
72
            adding CamelCaseParent
73
73
            adding CamelCaseParent/CamelCase
74
74
            """)
79
79
        # create a file on disk with the mixed-case parent and base name
80
80
        self.build_tree(['CamelCaseParent/', 'CamelCaseParent/CamelCase'])
81
81
        run_script(self, """
82
 
            $ bzr add
 
82
            $ brz add
83
83
            adding CamelCaseParent
84
84
            adding CamelCaseParent/CamelCase
85
85
            """)
91
91
        # create a file on disk with the mixed-case name
92
92
        self.build_tree(['MixedCase'])
93
93
        run_script(self, """
94
 
            $ bzr add MixedCase
 
94
            $ brz add MixedCase
95
95
            adding MixedCase
96
96
            """)
97
97
        # 'accidently' rename the file on disk
98
98
        osutils.rename('MixedCase', 'mixedcase')
99
99
        run_script(self, """
100
 
            $ bzr add mixedcase
 
100
            $ brz add mixedcase
101
101
            """)
102
102
 
103
103
    def test_re_add_dir(self):
108
108
        # create a file on disk with the mixed-case name
109
109
        self.build_tree(['MixedCaseParent/', 'MixedCaseParent/MixedCase'])
110
110
        run_script(self, """
111
 
            $ bzr add MixedCaseParent
 
111
            $ brz add MixedCaseParent
112
112
            adding MixedCaseParent
113
113
            adding MixedCaseParent/MixedCase
114
114
            """)
115
115
        # 'accidently' rename the directory on disk
116
116
        osutils.rename('MixedCaseParent', 'mixedcaseparent')
117
117
        run_script(self, """
118
 
            $ bzr add mixedcaseparent
 
118
            $ brz add mixedcaseparent
119
119
            """)
120
120
 
121
121
    def test_add_not_found(self):
125
125
        self.build_tree(['MixedCaseParent/', 'MixedCaseParent/MixedCase'])
126
126
        expected_fname = pathjoin(wt.basedir, "MixedCaseParent", "notfound")
127
127
        run_script(self, """
128
 
            $ bzr add mixedcaseparent/notfound
129
 
            2>bzr: ERROR: No such file: %s
 
128
            $ brz add mixedcaseparent/notfound
 
129
            2>brz: ERROR: No such file: %s
130
130
            """ % (repr(expected_fname),))
131
131
 
132
132
 
135
135
    def test_mv_newname(self):
136
136
        wt = self._make_mixed_case_tree()
137
137
        run_script(self, """
138
 
            $ bzr add -q
139
 
            $ bzr ci -qm message
140
 
            $ bzr mv camelcaseparent/camelcase camelcaseparent/NewCamelCase
 
138
            $ brz add -q
 
139
            $ brz ci -qm message
 
140
            $ brz mv camelcaseparent/camelcase camelcaseparent/NewCamelCase
141
141
            CamelCaseParent/CamelCase => CamelCaseParent/NewCamelCase
142
142
            """)
143
143
 
146
146
        # In this case we can specify the incorrect case for the destination,
147
147
        # as we use --after, so the file-system is sniffed.
148
148
        run_script(self, """
149
 
            $ bzr add -q
150
 
            $ bzr ci -qm message
 
149
            $ brz add -q
 
150
            $ brz ci -qm message
151
151
            $ mv CamelCaseParent/CamelCase CamelCaseParent/NewCamelCase
152
 
            $ bzr mv --after camelcaseparent/camelcase camelcaseparent/newcamelcase
 
152
            $ brz mv --after camelcaseparent/camelcase camelcaseparent/newcamelcase
153
153
            CamelCaseParent/CamelCase => CamelCaseParent/NewCamelCase
154
154
            """)
155
155
 
160
160
        self.run_bzr('add')
161
161
        self.run_bzr('ci -m message')
162
162
        run_script(self, """
163
 
            $ bzr mv camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
164
 
            2>bzr: ERROR: Could not move CamelCase => lowercase: \
 
163
            $ brz mv camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
 
164
            2>brz: ERROR: Could not move CamelCase => lowercase: \
165
165
lowercaseparent/lowercase is already versioned.
166
166
            """)
167
167
 
173
173
        self.run_bzr('add')
174
174
        self.run_bzr('ci -m message')
175
175
        # Remove the source and create a destination file on disk with a different case.
176
 
        # bzr should report that the filename is already versioned.
 
176
        # brz should report that the filename is already versioned.
177
177
        os.unlink('CamelCaseParent/CamelCase')
178
178
        osutils.rename('lowercaseparent/lowercase', 'lowercaseparent/LOWERCASE')
179
179
        run_script(self, """
180
 
            $ bzr mv --after camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
181
 
            2>bzr: ERROR: Could not move CamelCase => lowercase: \
 
180
            $ brz mv --after camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
 
181
            2>brz: ERROR: Could not move CamelCase => lowercase: \
182
182
lowercaseparent/lowercase is already versioned.
183
183
            """)
184
184
 
187
187
        self.run_bzr('add')
188
188
        self.run_bzr('ci -m message')
189
189
        run_script(self, """
190
 
            $ bzr mv camelcaseparent NewCamelCaseParent
 
190
            $ brz mv camelcaseparent NewCamelCaseParent
191
191
            CamelCaseParent => NewCamelCaseParent
192
192
            """)
193
193
 
199
199
        # as we use --after, so the file-system is sniffed.
200
200
        run_script(self, """
201
201
            $ mv CamelCaseParent NewCamelCaseParent
202
 
            $ bzr mv --after camelcaseparent NewCamelCaseParent
 
202
            $ brz mv --after camelcaseparent NewCamelCaseParent
203
203
            CamelCaseParent => NewCamelCaseParent
204
204
            """)
205
205
 
208
208
        self.run_bzr('add')
209
209
        self.run_bzr('ci -m message')
210
210
 
211
 
        # perform a mv to the new case - we expect bzr to accept the new
 
211
        # perform a mv to the new case - we expect brz to accept the new
212
212
        # name, as specified, and rename the file on the file-system too.
213
213
        run_script(self, """
214
 
            $ bzr mv camelcaseparent/camelcase camelcaseparent/camelCase
 
214
            $ brz mv camelcaseparent/camelcase camelcaseparent/camelCase
215
215
            CamelCaseParent/CamelCase => CamelCaseParent/camelCase
216
216
            """)
217
 
        self.failUnlessEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'),
 
217
        self.assertEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'),
218
218
                             'CamelCaseParent/camelCase')
219
219
 
220
220
    def test_mv_newcase_after(self):
226
226
        # new case first.
227
227
        osutils.rename('CamelCaseParent/CamelCase', 'CamelCaseParent/camelCase')
228
228
        run_script(self, """
229
 
            $ bzr mv --after camelcaseparent/camelcase camelcaseparent/camelCase
 
229
            $ brz mv --after camelcaseparent/camelcase camelcaseparent/camelCase
230
230
            CamelCaseParent/CamelCase => CamelCaseParent/camelCase
231
231
            """)
232
 
        # bzr should not have renamed the file to a different case
233
 
        self.failUnlessEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'),
 
232
        # brz should not have renamed the file to a different case
 
233
        self.assertEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'),
234
234
                             'CamelCaseParent/camelCase')
235
235
 
236
236
    def test_mv_multiple(self):
238
238
        self.run_bzr('add')
239
239
        self.run_bzr('ci -m message')
240
240
        run_script(self, """
241
 
            $ bzr mv LOWercaseparent/LOWercase LOWercaseparent/MIXEDCase camelcaseparent
 
241
            $ brz mv LOWercaseparent/LOWercase LOWercaseparent/MIXEDCase camelcaseparent
242
242
            lowercaseparent/lowercase => CamelCaseParent/lowercase
243
243
            lowercaseparent/mixedCase => CamelCaseParent/mixedCase
244
244
            """)
250
250
        wt = self._make_mixed_case_tree()
251
251
        self.run_bzr('add')
252
252
        run_script(self, """
253
 
            $ bzr status camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
 
253
            $ brz status camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
254
254
            added:
255
255
              CamelCaseParent/
256
256
              CamelCaseParent/CamelCase