/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/git/tests/test_object_store.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import os
22
22
import shutil
 
23
import stat
23
24
 
24
25
from dulwich.objects import (
25
26
    Blob,
44
45
    TestCase,
45
46
    TestCaseWithTransport,
46
47
    )
 
48
from ...tests.features import SymlinkFeature
47
49
 
48
50
from ..cache import (
49
51
    DictGitShaMap,
171
173
        self.assertEqual(b, self.store[b.id])
172
174
 
173
175
    def test_directory_converted_to_symlink(self):
 
176
        self.requireFeature(SymlinkFeature)
174
177
        b = Blob()
175
178
        b.data = b'trgt'
176
179
        self.store.lock_read()
256
259
        entries = list(_tree_to_objects(revtree, [], self.idmap, {}))
257
260
        self.assertEqual(['foo', ''], [p[0] for p in entries])
258
261
 
 
262
    def test_merge(self):
 
263
        basis_tree = self.make_branch_and_tree('base')
 
264
        self.build_tree(['base/foo/'])
 
265
        basis_tree.add(['foo'])
 
266
        basis_rev = basis_tree.commit('foo')
 
267
        basis_revtree = basis_tree.branch.repository.revision_tree(basis_rev)
 
268
 
 
269
        tree_a = self.make_branch_and_tree('a')
 
270
        tree_a.pull(basis_tree.branch)
 
271
 
 
272
        self.build_tree(['a/foo/file1'])
 
273
        self.build_tree(['a/foo/subdir-a/'])
 
274
        os.symlink('.', 'a/foo/subdir-a/symlink')
 
275
        tree_a.add(['foo/subdir-a', 'foo/subdir-a/symlink'])
 
276
 
 
277
        tree_a.add(['foo/file1'])
 
278
        rev_a = tree_a.commit('commit a')
 
279
        revtree_a = tree_a.branch.repository.revision_tree(rev_a)
 
280
 
 
281
        with revtree_a.lock_read():
 
282
            entries = list(_tree_to_objects(revtree_a, [basis_revtree],
 
283
                           self.idmap, {}))
 
284
            objects = {path: obj for (path, obj, key) in entries}
 
285
            subdir_a = objects['foo/subdir-a']
 
286
 
 
287
        tree_b = self.make_branch_and_tree('b')
 
288
        tree_b.pull(basis_tree.branch)
 
289
        self.build_tree(['b/foo/subdir/'])
 
290
        os.symlink('.', 'b/foo/subdir/symlink')
 
291
        tree_b.add(['foo/subdir', 'foo/subdir/symlink'])
 
292
        rev_b = tree_b.commit('commit b')
 
293
        revtree_b = tree_b.branch.repository.revision_tree(rev_b)
 
294
        self.addCleanup(revtree_b.lock_read().unlock)
 
295
 
 
296
        with revtree_b.lock_read():
 
297
            list(_tree_to_objects(revtree_b, [basis_revtree], self.idmap, {}))
 
298
 
 
299
        with tree_a.lock_write():
 
300
            tree_a.merge_from_branch(tree_b.branch)
 
301
        rev_merge = tree_a.commit('merge')
 
302
 
 
303
        revtree_merge = tree_a.branch.basis_tree()
 
304
        self.addCleanup(revtree_merge.lock_read().unlock)
 
305
 
 
306
        entries = list(_tree_to_objects(
 
307
            revtree_merge,
 
308
            [tree_a.branch.repository.revision_tree(r)
 
309
             for r in revtree_merge.get_parent_ids()],
 
310
            self.idmap, {}))
 
311
        objects = {path: obj for (path, obj, key) in entries}
 
312
        self.assertEqual(set(['', 'foo', 'foo/subdir']), set(objects))
 
313
        self.assertEqual(
 
314
            (stat.S_IFDIR, subdir_a.id), objects['foo'][b'subdir-a'])
 
315
 
259
316
 
260
317
class DirectoryToTreeTests(TestCase):
261
318