/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_tree/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
        :param empty_tree: A working tree with no content and no parents to
136
136
            modify.
137
137
        """
138
 
        empty_tree.set_root_id('empty-root-id')
 
138
        if empty_tree.supports_setting_file_ids():
 
139
            empty_tree.set_root_id(b'empty-root-id')
139
140
        return self._convert_tree(empty_tree, converter)
140
141
 
141
142
    def _make_abc_tree(self, tree):
143
144
        files = ['a', 'b/', 'b/c']
144
145
        self.build_tree(files, line_endings='binary',
145
146
                        transport=tree.controldir.root_transport)
146
 
        tree.set_root_id('root-id')
147
 
        tree.add(files, ['a-id', 'b-id', 'c-id'])
 
147
        tree.add(files)
148
148
 
149
149
    def get_tree_no_parents_abc_content(self, tree, converter=None):
150
150
        """return a test tree with a, b/, b/c contents."""
220
220
        """
221
221
        self._make_abc_tree(tree)
222
222
        self.build_tree(['d/'], transport=tree.controldir.root_transport)
223
 
        tree.add(['d'], ['d-id'])
 
223
        tree.add(['d'])
224
224
        tt = transform.TreeTransform(tree)
225
225
        trans_id = tt.trans_id_tree_path('b')
226
226
        parent_trans_id = tt.trans_id_tree_path('d')
246
246
                            by breezy.osutils.has_symlinks() function.
247
247
 
248
248
        The returned tree has the following inventory:
249
 
            [('', inventory.ROOT_ID),
250
 
             ('0file', '2file'),
251
 
             ('1top-dir', '1top-dir'),
252
 
             (u'2utf\u1234file', u'0utf\u1234file'),
253
 
             ('symlink', 'symlink'),            # only if symlinks arg is True
254
 
             ('1top-dir/0file-in-1topdir', '1file-in-1topdir'),
255
 
             ('1top-dir/1dir-in-1topdir', '0dir-in-1topdir')]
 
249
            ['',
 
250
             '0file',
 
251
             '1top-dir',
 
252
             u'2utf\u1234file',
 
253
             'symlink',            # only if symlinks arg is True
 
254
             '1top-dir/0file-in-1topdir',
 
255
             '1top-dir/1dir-in-1topdir']
256
256
        where each component has the type of its name -
257
257
        i.e. '1file..' is afile.
258
258
 
267
267
            '1top-dir/0file-in-1topdir',
268
268
            '1top-dir/1dir-in-1topdir/'
269
269
            ]
270
 
        ids = [
271
 
            '2file',
272
 
            '1top-dir',
273
 
            u'0utf\u1234file'.encode('utf8'),
274
 
            '1file-in-1topdir',
275
 
            '0dir-in-1topdir'
276
 
            ]
277
270
        self.build_tree(paths)
278
 
        tree.add(paths, ids)
 
271
        tree.add(paths)
279
272
        tt = transform.TreeTransform(tree)
280
273
        if symlinks:
281
274
            root_transaction_id = tt.trans_id_tree_path('')
284
277
        tt.apply()
285
278
        return self.workingtree_to_test_tree(tree)
286
279
 
287
 
    def get_tree_with_utf8(self, tree):
288
 
        """Generate a tree with a utf8 revision and unicode paths."""
289
 
        self._create_tree_with_utf8(tree)
290
 
        return self.workingtree_to_test_tree(tree)
291
 
 
292
 
    def _create_tree_with_utf8(self, tree):
293
 
        """Generate a tree with a utf8 revision and unicode paths."""
294
 
        self.requireFeature(features.UnicodeFilenameFeature)
295
 
        # We avoid combining characters in file names here, normalization
296
 
        # checks (as performed by some file systems (OSX) are outside the scope
297
 
        # of these tests).  We use the euro sign \N{Euro Sign} or \u20ac in
298
 
        # unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
299
 
        paths = [u'',
300
 
                 u'fo\N{Euro Sign}o',
301
 
                 u'ba\N{Euro Sign}r/',
302
 
                 u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
303
 
                ]
304
 
        # bzr itself does not create unicode file ids, but we want them for
305
 
        # testing.
306
 
        file_ids = ['TREE_ROOT',
307
 
                    'fo\xe2\x82\xaco-id',
308
 
                    'ba\xe2\x82\xacr-id',
309
 
                    'ba\xe2\x82\xacz-id',
310
 
                   ]
311
 
        self.build_tree(paths[1:])
312
 
        if tree.get_root_id() is None:
313
 
            # Some trees do not have a root yet.
314
 
            tree.add(paths, file_ids)
315
 
        else:
316
 
            # Some trees will already have a root
317
 
            tree.set_root_id(file_ids[0])
318
 
            tree.add(paths[1:], file_ids[1:])
319
 
        try:
320
 
            tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
321
 
        except errors.NonAsciiRevisionId:
322
 
            raise tests.TestSkipped('non-ascii revision ids not supported')
323
 
 
324
 
    def get_tree_with_merged_utf8(self, tree):
325
 
        """Generate a tree with utf8 ancestors."""
326
 
        self._create_tree_with_utf8(tree)
327
 
        tree2 = tree.controldir.sprout('tree2').open_workingtree()
328
 
        self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x'])
329
 
        tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'],
330
 
                  [u'qu\N{Euro Sign}x-id'.encode('utf-8')])
331
 
        tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
332
 
 
333
 
        tree.merge_from_branch(tree2.branch)
334
 
        tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
335
 
        return self.workingtree_to_test_tree(tree)
336
 
 
337
280
 
338
281
def make_scenarios(transport_server, transport_readonly_server, formats):
339
282
    """Generate test suites for each Tree implementation in breezy.