Merge lp:~jelmer/brz/apply-instead-of 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/apply-instead-of
Merge into: lp:brz
Diff against target: 52 lines (+25/-0)
2 files modified
breezy/git/__init__.py (+18/-0)
breezy/location.py (+7/-0)
To merge this branch: bzr merge lp:~jelmer/brz/apply-instead-of
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+425871@code.launchpad.net

Commit message

Support insteadOf / pushInsteadOf in git config.

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 :
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/__init__.py'
2--- breezy/git/__init__.py 2021-08-19 16:05:04 +0000
3+++ breezy/git/__init__.py 2022-06-30 18:36:20 +0000
4@@ -286,6 +286,24 @@
5 "RioVersionInfoBuilder.hooks", "revision", update_stanza,
6 "git commits")
7
8+
9+def rewrite_instead_of(location, purpose):
10+ try:
11+ from dulwich.config import apply_instead_of, StackedConfig
12+ except ImportError:
13+ # Version of dulwich too old (<< 0.20.44)
14+ return location
15+
16+ config = StackedConfig.default()
17+
18+ return apply_instead_of(config, location, push=(purpose == "push"))
19+
20+
21+from ..location import hooks as location_hooks
22+location_hooks.install_named_hook(
23+ "rewrite_location", rewrite_instead_of,
24+ "apply Git insteadOf / pushInsteadOf")
25+
26 transport_server_registry.register_lazy(
27 'git', __name__ + '.server', 'serve_git',
28 'Git Smart server protocol over TCP. (default port: 9418)')
29
30=== modified file 'breezy/location.py'
31--- breezy/location.py 2022-01-09 13:12:27 +0000
32+++ breezy/location.py 2022-06-30 18:36:20 +0000
33@@ -35,6 +35,10 @@
34 'rewrite_url',
35 "Possibly rewrite a URL. Called with a URL to rewrite and the "
36 "purpose of the URL.", (3, 0))
37+ self.add_hook(
38+ 'rewrite_location',
39+ "Possibly rewrite a location. Called with a location string to "
40+ "rewrite and the purpose of the URL.", (3, 2))
41
42
43 hooks = LocationHooks()
44@@ -129,6 +133,9 @@
45 if not isinstance(location, str):
46 raise AssertionError("location not a byte or unicode string")
47
48+ for hook in hooks['rewrite_location']:
49+ location = hook(location, purpose=purpose)
50+
51 if location.startswith(':pserver:') or location.startswith(':extssh:'):
52 return cvs_to_url(location)
53

Subscribers

People subscribed via source and target branches