Merge lp:~jelmer/brz/git-config into lp:brz/3.1

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-config
Merge into: lp:brz/3.1
Diff against target: 163 lines (+39/-23)
4 files modified
breezy/git/branch.py (+20/-18)
breezy/git/dir.py (+11/-4)
breezy/git/repository.py (+7/-0)
breezy/tests/per_branch/test_http.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/git-config
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+400076@code.launchpad.net

Commit message

Set all required fields in git config.

Description of the change

Set all required fields 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 :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/branch.py'
2--- breezy/git/branch.py 2021-01-23 02:54:05 +0000
3+++ breezy/git/branch.py 2021-03-24 03:17:56 +0000
4@@ -156,7 +156,7 @@
5 else:
6 conflicts.append(
7 (tag_name,
8- self.repository.lookup_foreign_revision_id(peeled),
9+ self.source.branch.repository.lookup_foreign_revision_id(peeled),
10 self.target.branch.repository.lookup_foreign_revision_id(
11 old_refs[ref_name])))
12 return ret
13@@ -263,7 +263,7 @@
14 return updates, conflicts
15
16 def _merge_to(self, to_tags, source_tag_refs, overwrite=False,
17- selector=None):
18+ selector=None, ignore_master=False):
19 unpeeled_map = defaultdict(set)
20 conflicts = []
21 updates = {}
22@@ -502,8 +502,9 @@
23 if getattr(self.repository, '_git', None):
24 cs = self.repository._git.get_config_stack()
25 try:
26- return cs.get((b"branch", self.name.encode('utf-8')),
27- b"nick").decode("utf-8")
28+ return cs.get(
29+ (b"branch", self.name.encode('utf-8')),
30+ b"nick").decode("utf-8")
31 except KeyError:
32 pass
33 return self.name or u"HEAD"
34@@ -522,6 +523,9 @@
35 return "<%s(%r, %r)>" % (self.__class__.__name__, self.repository.base,
36 self.name)
37
38+ def set_last_revision(self, revid):
39+ raise NotImplementedError(self.set_last_revision)
40+
41 def generate_revision_history(self, revid, last_rev=None,
42 other_branch=None):
43 if last_rev is not None:
44@@ -597,7 +601,7 @@
45 try:
46 ref = cs.get((b"branch", remote), b"merge")
47 except KeyError:
48- ref = self.ref
49+ ref = b'HEAD'
50
51 return git_url_to_bzr_url(location.decode('utf-8'), ref=ref)
52
53@@ -606,11 +610,6 @@
54 cs = self.repository._git.get_config_stack()
55 return self._get_related_merge_branch(cs)
56
57- def _write_git_config(self, cs):
58- f = BytesIO()
59- cs.write_to_file(f)
60- self.repository._git._put_named_file('config', f.getvalue())
61-
62 def set_parent(self, location):
63 cs = self.repository._git.get_config()
64 remote = self._get_origin(cs)
65@@ -618,14 +617,17 @@
66 target_url, branch, ref = bzr_url_to_git_url(location)
67 location = urlutils.relative_url(this_url, target_url)
68 cs.set((b"remote", remote), b"url", location)
69- if branch:
70- cs.set((b"branch", remote), b"merge", branch_name_to_ref(branch))
71- elif ref:
72- cs.set((b"branch", remote), b"merge", ref)
73- else:
74- # TODO(jelmer): Maybe unset rather than setting to HEAD?
75- cs.set((b"branch", remote), b"merge", b'HEAD')
76- self._write_git_config(cs)
77+ cs.set((b"remote", remote), b'fetch',
78+ b'+refs/heads/*:refs/remotes/%s/*' % remote)
79+ if self.name:
80+ if branch:
81+ cs.set((b"branch", self.name.encode()), b"merge", branch_name_to_ref(branch))
82+ elif ref:
83+ cs.set((b"branch", self.name.encode()), b"merge", ref)
84+ else:
85+ # TODO(jelmer): Maybe unset rather than setting to HEAD?
86+ cs.set((b"branch", self.name.encode()), b"merge", b'HEAD')
87+ self.repository._write_git_config(cs)
88
89 def break_lock(self):
90 raise NotImplementedError(self.break_lock)
91
92=== modified file 'breezy/git/dir.py'
93--- breezy/git/dir.py 2020-07-20 00:29:15 +0000
94+++ breezy/git/dir.py 2021-03-24 03:17:56 +0000
95@@ -238,13 +238,12 @@
96 from ..repository import InterRepository
97 from .mapping import default_mapping
98 from ..transport.local import LocalTransport
99- if stacked_on is not None:
100- raise _mod_branch.UnstackableBranchFormat(
101- self._format, self.user_url)
102 if no_tree:
103 format = BareLocalGitControlDirFormat()
104 else:
105 format = LocalGitControlDirFormat()
106+ if stacked_on is not None:
107+ raise _mod_branch.UnstackableBranchFormat(format, self.user_url)
108 (target_repo, target_controldir, stacking,
109 repo_policy) = format.initialize_on_transport_ex(
110 transport, use_existing_dir=use_existing_dir,
111@@ -264,8 +263,16 @@
112 for name, val in viewitems(refs):
113 target_git_repo.refs[name] = val
114 result_dir = LocalGitDir(transport, target_git_repo, format)
115+ result_branch = result_dir.open_branch()
116+ try:
117+ parent = self.open_branch().get_parent()
118+ except brz_errors.InaccessibleParent:
119+ pass
120+ else:
121+ if parent:
122+ result_branch.set_parent(parent)
123 if revision_id is not None:
124- result_dir.open_branch().set_last_revision(revision_id)
125+ result_branch.set_last_revision(revision_id)
126 if not no_tree and isinstance(result_dir.root_transport, LocalTransport):
127 if result_dir.open_repository().make_working_trees():
128 try:
129
130=== modified file 'breezy/git/repository.py'
131--- breezy/git/repository.py 2020-11-23 19:46:21 +0000
132+++ breezy/git/repository.py 2021-03-24 03:17:56 +0000
133@@ -19,6 +19,8 @@
134
135 from __future__ import absolute_import
136
137+from io import BytesIO
138+
139 from .. import (
140 check,
141 errors,
142@@ -264,6 +266,11 @@
143 self.start_write_group()
144 return builder
145
146+ def _write_git_config(self, cs):
147+ f = BytesIO()
148+ cs.write_to_file(f)
149+ self._git._put_named_file('config', f.getvalue())
150+
151 def get_file_graph(self):
152 return _mod_graph.Graph(GitFileParentProvider(
153 self._file_change_scanner))
154
155=== modified file 'breezy/tests/per_branch/test_http.py'
156--- breezy/tests/per_branch/test_http.py 2018-11-11 04:08:32 +0000
157+++ breezy/tests/per_branch/test_http.py 2021-03-24 03:17:56 +0000
158@@ -76,4 +76,4 @@
159 # from, even if that branch has an invalid parent.
160 branch_b = self.get_branch_with_invalid_parent()
161 branch_c = branch_b.controldir.sprout('c').open_branch()
162- self.assertEqual(branch_b.user_url, branch_c.get_parent())
163+ self.assertEqual(branch_b.base, branch_c.get_parent())

Subscribers

People subscribed via source and target branches