Merge lp:~jelmer/brz/git-nested-tree-iterate into lp:brz/3.2

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/brz/git-nested-tree-iterate
Merge into: lp:brz/3.2
Diff against target: 66 lines (+23/-6)
1 file modified
breezy/git/tree.py (+23/-6)
To merge this branch: bzr merge lp:~jelmer/brz/git-nested-tree-iterate
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+415815@code.launchpad.net

This proposal has been superseded by a proposal from 2022-10-27.

Commit message

Raise specific exception when having to access remote git revision trees.

Description of the change

Raise specific exception when having to access remote git revision trees.

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 :
7589. By Jelmer Vernooij

Merge lp:brz/3.3

7590. By Jelmer Vernooij

Fix test.

Unmerged revisions

7590. By Jelmer Vernooij

Fix test.

7589. By Jelmer Vernooij

Merge lp:brz/3.3

7588. By Jelmer Vernooij

Fix extension.

7587. By Jelmer Vernooij

Raise specific exception when having to access remote git revision trees.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tree.py'
2--- breezy/git/tree.py 2022-01-04 18:23:48 +0000
3+++ breezy/git/tree.py 2022-02-19 19:21:16 +0000
4@@ -58,12 +58,15 @@
5 revisiontree,
6 trace,
7 tree as _mod_tree,
8+ urlutils,
9 workingtree,
10 )
11 from ..revision import (
12 CURRENT_REVISION,
13 NULL_REVISION,
14 )
15+from ..transport import get_transport
16+from ..tree import MissingNestedTree
17
18 from .mapping import (
19 encode_git_path,
20@@ -312,6 +315,11 @@
21 return Branch.open(url.decode('utf-8'))
22
23
24+class RemoteNestedTree(MissingNestedTree):
25+
26+ _fmt = "Unable to access remote nested tree at %(path)s"
27+
28+
29 class GitRevisionTree(revisiontree.RevisionTree, GitTree):
30 """Revision tree implementation based on Git objects."""
31
32@@ -341,19 +349,28 @@
33 if not isinstance(relpath, bytes):
34 raise TypeError(relpath)
35 try:
36- info = self._submodule_info()[relpath]
37+ url, section = self._submodule_info()[relpath]
38 except KeyError:
39+ nested_repo_transport = None
40+ else:
41+ nested_repo_transport = self._repository.controldir.control_transport.clone(
42+ posixpath.join('modules', decode_git_path(section)))
43+ if not nested_repo_transport.has('.'):
44+ nested_url = urlutils.join(
45+ self._repository.controldir.user_url, decode_git_path(url))
46+ nested_repo_transport = get_transport(nested_url)
47+ if nested_repo_transport is None:
48 nested_repo_transport = self._repository.controldir.user_transport.clone(
49- decode_git_path(relpath))
50- else:
51- nested_repo_transport = self._repository.controldir.control_transport.clone(
52- posixpath.join('modules', decode_git_path(info[1])))
53+ posixpath.join(decode_git_path(relpath)))
54 nested_controldir = _mod_controldir.ControlDir.open_from_transport(
55 nested_repo_transport)
56 return nested_controldir.find_repository()
57
58 def _get_submodule_store(self, relpath):
59- return self._get_submodule_repository(relpath)._git.object_store
60+ repo = self._get_submodule_repository(relpath)
61+ if not hasattr(repo, '_git'):
62+ raise RemoteNestedTree(relpath)
63+ return repo._git.object_store
64
65 def get_nested_tree(self, path):
66 encoded_path = encode_git_path(path)

Subscribers

People subscribed via source and target branches