Merge lp:~jelmer/brz/git-symlink-push into lp:brz/3.0

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-symlink-push
Merge into: lp:brz/3.0
Diff against target: 89 lines (+32/-4)
2 files modified
breezy/git/object_store.py (+2/-2)
breezy/git/tests/test_object_store.py (+30/-2)
To merge this branch: bzr merge lp:~jelmer/brz/git-symlink-push
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+363697@code.launchpad.net

Commit message

Fix pushing of revisions from bzr to git that convert directories to symlinks.

Description of the change

Fix pushing of revisions from bzr to git that convert directories to symlinks.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/object_store.py'
2--- breezy/git/object_store.py 2019-01-01 21:23:40 +0000
3+++ breezy/git/object_store.py 2019-02-27 01:44:43 +0000
4@@ -359,7 +359,7 @@
5 continue
6
7 if tree.kind(path) != 'directory':
8- raise AssertionError
9+ continue
10
11 obj = Tree()
12 for value in tree.iter_child_entries(path):
13@@ -589,7 +589,7 @@
14 for (file_id, revision, expected_sha), chunks in stream:
15 blob = Blob()
16 blob.chunked = chunks
17- if blob.id != expected_sha and blob.data == "":
18+ if blob.id != expected_sha and blob.data == b"":
19 # Perhaps it's a symlink ?
20 tree = self.tree_cache.revision_tree(revision)
21 path = tree.id2path(file_id)
22
23=== modified file 'breezy/git/tests/test_object_store.py'
24--- breezy/git/tests/test_object_store.py 2018-11-11 04:08:32 +0000
25+++ breezy/git/tests/test_object_store.py 2019-02-27 01:44:43 +0000
26@@ -18,6 +18,9 @@
27
28 from __future__ import absolute_import
29
30+import os
31+import shutil
32+
33 from dulwich.objects import (
34 Blob,
35 Tree,
36@@ -144,11 +147,11 @@
37 def setUp(self):
38 super(BazaarObjectStoreTests, self).setUp()
39 self.branch = self.make_branch(".")
40- self.branch.lock_write()
41- self.addCleanup(self.branch.unlock)
42 self.store = BazaarObjectStore(self.branch.repository)
43
44 def test_get_blob(self):
45+ self.branch.lock_write()
46+ self.addCleanup(self.branch.unlock)
47 b = Blob()
48 b.data = b'a\nb\nc\nd\ne\n'
49 self.store.lock_read()
50@@ -167,7 +170,30 @@
51 self.store.lock_read()
52 self.assertEqual(b, self.store[b.id])
53
54+ def test_directory_converted_to_symlink(self):
55+ b = Blob()
56+ b.data = b'trgt'
57+ self.store.lock_read()
58+ self.addCleanup(self.store.unlock)
59+ self.assertRaises(KeyError, self.store.__getitem__, b.id)
60+ tree = self.branch.controldir.create_workingtree()
61+ self.build_tree_contents([
62+ ('foo/', ),
63+ ('foo/bar', b'a\nb\nc\nd\ne\n')])
64+ tree.add(['foo', 'foo/bar'])
65+ revid1 = tree.commit('commit 1')
66+ shutil.rmtree('foo')
67+ os.symlink('trgt', 'foo')
68+ revid2 = tree.commit('commit 2')
69+ # read locks cache
70+ self.assertRaises(KeyError, self.store.__getitem__, b.id)
71+ self.store.unlock()
72+ self.store.lock_read()
73+ self.assertEqual(b, self.store[b.id])
74+
75 def test_get_raw(self):
76+ self.branch.lock_write()
77+ self.addCleanup(self.branch.unlock)
78 b = Blob()
79 b.data = b'a\nb\nc\nd\ne\n'
80 self.store.lock_read()
81@@ -187,6 +213,8 @@
82 self.assertEqual(b.as_raw_string(), self.store.get_raw(b.id)[1])
83
84 def test_contains(self):
85+ self.branch.lock_write()
86+ self.addCleanup(self.branch.unlock)
87 b = Blob()
88 b.data = b'a\nb\nc\nd\ne\n'
89 self.store.lock_read()

Subscribers

People subscribed via source and target branches