Merge lp:~jelmer/brz/submodule-missing into lp:brz/3.2

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/submodule-missing
Merge into: lp:brz/3.2
Diff against target: 73 lines (+37/-3)
3 files modified
breezy/git/dir.py (+8/-2)
breezy/git/repository.py (+2/-1)
breezy/git/tests/test_remote.py (+27/-0)
To merge this branch: bzr merge lp:~jelmer/brz/submodule-missing
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+414558@code.launchpad.net

Commit message

Cope with invalid submodules.

Description of the change

Cope with invalid submodules.

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 :
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
1=== modified file 'breezy/git/dir.py'
2--- breezy/git/dir.py 2022-01-08 01:23:14 +0000
3+++ breezy/git/dir.py 2022-01-25 14:16:15 +0000
4@@ -210,9 +210,15 @@
5 sublocation = wt.get_reference_info(path)
6 if sublocation is None:
7 trace.warning("Unable to find submodule info for %s", path)
8- return None
9+ continue
10 remote_url = urlutils.join(self.user_url, sublocation)
11- subbranch = _mod_branch.Branch.open(remote_url, possible_transports=possible_transports)
12+ try:
13+ subbranch = _mod_branch.Branch.open(remote_url, possible_transports=possible_transports)
14+ except brz_errors.NotBranchError as e:
15+ trace.warning(
16+ 'Unable to clone submodule %s from %s: %s',
17+ path, remote_url, e)
18+ continue
19 subbranch.controldir.sprout(
20 target, basis.get_reference_revision(path),
21 force_new_repo=force_new_repo, recurse=recurse,
22
23=== modified file 'breezy/git/repository.py'
24--- breezy/git/repository.py 2022-01-16 17:24:02 +0000
25+++ breezy/git/repository.py 2022-01-25 14:16:15 +0000
26@@ -186,7 +186,8 @@
27 transaction = self._transaction
28 self._transaction = None
29 transaction.finish()
30- self._git.close()
31+ if hasattr(self, '_git'):
32+ self._git.close()
33
34 def is_write_locked(self):
35 return (self._lock_mode == 'w')
36
37=== modified file 'breezy/git/tests/test_remote.py'
38--- breezy/git/tests/test_remote.py 2022-01-08 01:23:14 +0000
39+++ breezy/git/tests/test_remote.py 2022-01-25 14:16:15 +0000
40@@ -293,6 +293,33 @@
41 self.remote_real.head()),
42 local.open_branch().last_revision())
43
44+ def test_sprout_submodule_invalid(self):
45+ self.sub_real = GitRepo.init('sub', mkdir=True)
46+ self.sub_real.do_commit(
47+ message=b'message in sub',
48+ committer=b'committer <committer@example.com>',
49+ author=b'author <author@example.com>')
50+
51+ self.sub_real.clone('remote/nested')
52+ self.remote_real.stage('nested')
53+ self.permit_url(urljoin(self.remote_url, '../sub'))
54+ self.assertIn(b'nested', self.remote_real.open_index())
55+ self.remote_real.do_commit(
56+ message=b'message',
57+ committer=b'committer <committer@example.com>',
58+ author=b'author <author@example.com>')
59+
60+ remote = ControlDir.open(self.remote_url)
61+ self.make_controldir('local', format=self._to_format)
62+ local = remote.sprout('local')
63+ self.assertEqual(
64+ default_mapping.revision_id_foreign_to_bzr(
65+ self.remote_real.head()),
66+ local.open_branch().last_revision())
67+ self.assertRaises(
68+ NotBranchError,
69+ local.open_workingtree().get_nested_tree, 'nested')
70+
71 def test_sprout_submodule_relative(self):
72 self.sub_real = GitRepo.init('sub', mkdir=True)
73 self.sub_real.do_commit(

Subscribers

People subscribed via source and target branches