Merge lp:~jelmer/brz/fix-submodule-import into lp:brz

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/fix-submodule-import
Merge into: lp:brz
Diff against target: 162 lines (+49/-9)
7 files modified
breezy/git/branch.py (+2/-2)
breezy/git/fetch.py (+3/-2)
breezy/git/tests/__init__.py (+6/-0)
breezy/git/tests/test_branch.py (+29/-0)
breezy/git/tests/test_fetch.py (+1/-1)
breezy/tree.py (+4/-4)
doc/en/release-notes/brz-3.1.txt (+4/-0)
To merge this branch: bzr merge lp:~jelmer/brz/fix-submodule-import
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+378021@code.launchpad.net

Commit message

Support importing Git submodules as tree references.

Description of the change

Support importing Git submodules as tree references.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/git/branch.py'
--- breezy/git/branch.py 2020-01-20 00:51:05 +0000
+++ breezy/git/branch.py 2020-01-24 02:05:30 +0000
@@ -987,8 +987,8 @@
987 for path, url, section in parse_submodules(987 for path, url, section in parse_submodules(
988 GitConfigFile.from_file(f)):988 GitConfigFile.from_file(f)):
989 self.target.set_reference_info(989 self.target.set_reference_info(
990 path.decode('utf-8'), url.decode('utf-8'),990 tree.path2id(path.decode('utf-8')), url.decode('utf-8'),
991 tree.path2id(path.decode('utf-8')))991 path.decode('utf-8'))
992 except errors.NoSuchFile:992 except errors.NoSuchFile:
993 pass993 pass
994994
995995
=== modified file 'breezy/git/fetch.py'
--- breezy/git/fetch.py 2020-01-18 00:08:16 +0000
+++ breezy/git/fetch.py 2020-01-24 02:05:30 +0000
@@ -126,7 +126,7 @@
126 # Check what revision we should store126 # Check what revision we should store
127 parent_keys = []127 parent_keys = []
128 for ptree in parent_bzr_trees:128 for ptree in parent_bzr_trees:
129 ppath = find_previous_path(base_bzr_tree, ptree, decoded_path, file_id)129 ppath = find_previous_path(base_bzr_tree, ptree, decoded_path, file_id, recurse='none')
130 if ppath is None:130 if ppath is None:
131 continue131 continue
132 pkind = ptree.kind(ppath)132 pkind = ptree.kind(ppath)
@@ -182,12 +182,13 @@
182 (base_mode, mode) = modes182 (base_mode, mode) = modes
183 if base_hexsha == hexsha and base_mode == mode:183 if base_hexsha == hexsha and base_mode == mode:
184 return [], {}184 return [], {}
185 path = path.decode('utf-8')
185 file_id = lookup_file_id(path)186 file_id = lookup_file_id(path)
186 invdelta = []187 invdelta = []
187 ie = TreeReference(file_id, name.decode("utf-8"), parent_id)188 ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
188 ie.revision = revision_id189 ie.revision = revision_id
189 if base_hexsha is not None:190 if base_hexsha is not None:
190 old_path = path.decode("utf-8") # Renames are not supported yet191 old_path = path # Renames are not supported yet
191 if stat.S_ISDIR(base_mode):192 if stat.S_ISDIR(base_mode):
192 invdelta.extend(remove_disappeared_children(193 invdelta.extend(remove_disappeared_children(
193 base_bzr_tree, old_path, lookup_object(base_hexsha), [],194 base_bzr_tree, old_path, lookup_object(base_hexsha), [],
194195
=== modified file 'breezy/git/tests/__init__.py'
--- breezy/git/tests/__init__.py 2018-11-11 04:08:32 +0000
+++ breezy/git/tests/__init__.py 2020-01-24 02:05:30 +0000
@@ -96,6 +96,12 @@
96 self.commit_info.append(b'M %s :%d %s\n'96 self.commit_info.append(b'M %s :%d %s\n'
97 % (mode, mark, self._encode_path(path)))97 % (mode, mark, self._encode_path(path)))
9898
99 def set_submodule(self, path, commit_sha):
100 """Create or update submodule at a given path."""
101 mode = b'160000'
102 self.commit_info.append(
103 b'M %s %s %s\n' % (mode, commit_sha, self._encode_path(path)))
104
99 def set_file(self, path, content, executable):105 def set_file(self, path, content, executable):
100 """Create or update content at a given path."""106 """Create or update content at a given path."""
101 mark = self._create_blob(content)107 mark = self._create_blob(content)
102108
=== modified file 'breezy/git/tests/test_branch.py'
--- breezy/git/tests/test_branch.py 2019-02-15 18:31:22 +0000
+++ breezy/git/tests/test_branch.py 2020-01-24 02:05:30 +0000
@@ -245,6 +245,35 @@
245 # Dulwich raises a UserWarning for tags with invalid target245 # Dulwich raises a UserWarning for tags with invalid target
246 self.assertIn(('ref refs/tags/lala points at non-present sha ' + ("aa" * 20), ), [w.args for w in warnings])246 self.assertIn(('ref refs/tags/lala points at non-present sha ' + ("aa" * 20), ), [w.args for w in warnings])
247247
248 def test_interbranch_pull_submodule(self):
249 path = "d"
250 os.mkdir(path)
251 os.chdir(path)
252 GitRepo.init('.')
253 bb = tests.GitBranchBuilder()
254 bb.set_file("foobar", b"foo\nbar\n", False)
255 mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg")
256 bb.set_submodule("core", b'102ee7206ebc4227bec8ac02450972e6738f4a33')
257 bb.set_file('.gitmodules', b"""\
258[submodule "core"]
259 path = core
260 url = https://github.com/phhusson/QuasselC.git
261""", False)
262 mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg")
263 marks = bb.finish()
264 os.chdir("..")
265 gitsha1 = marks[mark1]
266 gitsha2 = marks[mark2]
267 oldrepo = Repository.open(path)
268 revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
269 newbranch = self.make_branch('g')
270 inter_branch = InterBranch.get(Branch.open(path), newbranch)
271 inter_branch.pull()
272 self.assertEqual(revid2, newbranch.last_revision())
273 self.assertEqual(
274 ('https://github.com/phhusson/QuasselC.git', 'core'),
275 newbranch.get_reference_info(newbranch.basis_tree().path2id('core')))
276
248 def test_interbranch_pull(self):277 def test_interbranch_pull(self):
249 path, (gitsha1, gitsha2) = self.make_tworev_branch()278 path, (gitsha1, gitsha2) = self.make_tworev_branch()
250 oldrepo = Repository.open(path)279 oldrepo = Repository.open(path)
251280
=== modified file 'breezy/git/tests/test_fetch.py'
--- breezy/git/tests/test_fetch.py 2018-11-11 04:08:32 +0000
+++ breezy/git/tests/test_fetch.py 2020-01-24 02:05:30 +0000
@@ -502,7 +502,7 @@
502 self.assertEqual(2, len(ret))502 self.assertEqual(2, len(ret))
503 self.assertEqual(503 self.assertEqual(
504 ret[0], ("foo/bar", None, base_inv.path2id("foo/bar"), None))504 ret[0], ("foo/bar", None, base_inv.path2id("foo/bar"), None))
505 self.assertEqual(ret[1][:3], ("foo", b"foo",505 self.assertEqual(ret[1][:3], ("foo", "foo",
506 self._mapping.generate_file_id("foo")))506 self._mapping.generate_file_id("foo")))
507 ie = ret[1][3]507 ie = ret[1][3]
508 self.assertEqual(ie.kind, "tree-reference")508 self.assertEqual(ie.kind, "tree-reference")
509509
=== modified file 'breezy/tree.py'
--- breezy/tree.py 2020-01-19 14:53:22 +0000
+++ breezy/tree.py 2020-01-24 02:05:30 +0000
@@ -1207,7 +1207,7 @@
1207InterTree.register_optimiser(InterTree)1207InterTree.register_optimiser(InterTree)
12081208
12091209
1210def find_previous_paths(from_tree, to_tree, paths):1210def find_previous_paths(from_tree, to_tree, paths, recurse='none'):
1211 """Find previous tree paths.1211 """Find previous tree paths.
12121212
1213 :param from_tree: From tree1213 :param from_tree: From tree
@@ -1218,11 +1218,11 @@
1218 """1218 """
1219 ret = {}1219 ret = {}
1220 for path in paths:1220 for path in paths:
1221 ret[path] = find_previous_path(from_tree, to_tree, path)1221 ret[path] = find_previous_path(from_tree, to_tree, path, recurse=recurse)
1222 return ret1222 return ret
12231223
12241224
1225def find_previous_path(from_tree, to_tree, path, file_id=None):1225def find_previous_path(from_tree, to_tree, path, file_id=None, recurse='none'):
1226 """Find previous tree path.1226 """Find previous tree path.
12271227
1228 :param from_tree: From tree1228 :param from_tree: From tree
@@ -1236,7 +1236,7 @@
1236 if file_id is None:1236 if file_id is None:
1237 raise errors.NoSuchFile(path)1237 raise errors.NoSuchFile(path)
1238 try:1238 try:
1239 return to_tree.id2path(file_id)1239 return to_tree.id2path(file_id, recurse=recurse)
1240 except errors.NoSuchId:1240 except errors.NoSuchId:
1241 return None1241 return None
12421242
12431243
=== modified file 'doc/en/release-notes/brz-3.1.txt'
--- doc/en/release-notes/brz-3.1.txt 2020-01-19 15:58:34 +0000
+++ doc/en/release-notes/brz-3.1.txt 2020-01-24 02:05:30 +0000
@@ -99,6 +99,10 @@
99* CVS pserver URLs now indicate that the pserver protocol is not99* CVS pserver URLs now indicate that the pserver protocol is not
100 supported. (Jelmer Vernooij)100 supported. (Jelmer Vernooij)
101101
102 * Git repositories with submodules can now be imported into 2a
103 branches; submodules are converted to nested trees.
104 (Jelmer Vernooij, #402814)
105
102Bug Fixes106Bug Fixes
103*********107*********
104108

Subscribers

People subscribed via source and target branches