Merge lp:~jelmer/brz/merge-3.1 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/merge-3.1
Merge into: lp:brz
Diff against target: 275 lines (+130/-23)
8 files modified
README.rst (+2/-2)
breezy/git/config.py (+46/-3)
breezy/git/tests/test_blackbox.py (+31/-0)
breezy/library_state.py (+5/-3)
breezy/plugins/propose/gitlabs.py (+9/-2)
breezy/tests/test_library_state.py (+12/-0)
doc/en/release-notes/brz-3.1.txt (+6/-0)
doc/en/tutorials/using_breezy_with_github.txt (+19/-13)
To merge this branch: bzr merge lp:~jelmer/brz/merge-3.1
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+381004@code.launchpad.net

Commit message

Merge lp:brz/3.1.

Description of the change

Merge lp:brz/3.1.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
lp:~jelmer/brz/merge-3.1 updated
7499. By Jelmer Vernooij

Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/381004

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.rst'
2--- README.rst 2019-02-11 20:37:27 +0000
3+++ README.rst 2020-03-22 01:38:36 +0000
4@@ -18,8 +18,8 @@
5 Breezy is a friendly fork of the Bazaar (``bzr``) project, hosted on
6 http://bazaar.canonical.com/. It is backwards compatibility with
7 Bazaar's disk format and protocols. One of the key differences with
8-Bazaar is that Breezy also runs on Python 3.3 and later, in addition to
9-Python 2.7.
10+Bazaar is that Breezy runs on Python 3.3 and later, rather than on
11+Python 2.
12
13 Breezy highlights
14 =================
15
16=== modified file 'breezy/git/config.py'
17--- breezy/git/config.py 2020-02-18 01:57:45 +0000
18+++ breezy/git/config.py 2020-03-22 01:38:36 +0000
19@@ -44,19 +44,62 @@
20 return self._get_best_value('_get_user_id')
21
22
23+class GitConfigSectionDefault(config.Section):
24+ """The "default" config section in git config file"""
25+
26+ def __init__(self, config):
27+ self._config = config
28+
29+ def get(self, name, default=None, expand=True):
30+ if name == 'email':
31+ try:
32+ email = self._config.get((b'user', ), b'email')
33+ except KeyError:
34+ return None
35+ try:
36+ name = self._config.get((b'user', ), b'name')
37+ except KeyError:
38+ return email.decode()
39+ return '%s <%s>' % (name.decode(), email.decode())
40+ if name == 'gpg_signing_key':
41+ try:
42+ key = self._config.get((b'user', ), b'signingkey')
43+ except KeyError:
44+ return None
45+ return key.decode()
46+ return None
47+
48+
49+class GitConfigStore(config.Store):
50+ """Store that uses gitconfig."""
51+
52+ def __init__(self, config):
53+ self._config = config
54+
55+ def get_sections(self):
56+ return [
57+ (self, GitConfigSectionDefault(self._config)),
58+ ]
59+
60+
61 class GitBranchStack(config._CompatibleStack):
62 """GitBranch stack."""
63
64 def __init__(self, branch):
65+ section_getters = [self._get_overrides]
66 lstore = config.LocationStore()
67 loc_matcher = config.LocationMatcher(lstore, branch.base)
68+ section_getters.append(loc_matcher.get_sections)
69 # FIXME: This should also be looking in .git/config for
70 # local git branches.
71+ git = getattr(branch.repository, '_git', None)
72+ if git:
73+ cstore = GitConfigStore(git.get_config())
74+ section_getters.append(cstore.get_sections)
75 gstore = config.GlobalStore()
76+ section_getters.append(gstore.get_sections)
77 super(GitBranchStack, self).__init__(
78- [self._get_overrides,
79- loc_matcher.get_sections,
80- gstore.get_sections],
81+ section_getters,
82 # All modifications go to the corresponding section in
83 # locations.conf
84 lstore, branch.base)
85
86=== modified file 'breezy/git/tests/test_blackbox.py'
87--- breezy/git/tests/test_blackbox.py 2020-02-18 01:57:45 +0000
88+++ breezy/git/tests/test_blackbox.py 2020-03-22 01:38:36 +0000
89@@ -424,6 +424,37 @@
90 self.assertEqual(out, '')
91 self.assertTrue(err.endswith, '3 objects\n')
92
93+ def test_local_whoami(self):
94+ r = GitRepo.init("gitr", mkdir=True)
95+ self.build_tree_contents([('gitr/.git/config', """\
96+[user]
97+ email = some@example.com
98+ name = Test User
99+""")])
100+ out, err = self.run_bzr(["whoami", "-d", "gitr"])
101+ self.assertEqual(out, "Test User <some@example.com>\n")
102+ self.assertEqual(err, "")
103+
104+ self.build_tree_contents([('gitr/.git/config', """\
105+[user]
106+ email = some@example.com
107+""")])
108+ out, err = self.run_bzr(["whoami", "-d", "gitr"])
109+ self.assertEqual(out, "some@example.com\n")
110+ self.assertEqual(err, "")
111+
112+ def test_local_signing_key(self):
113+ r = GitRepo.init("gitr", mkdir=True)
114+ self.build_tree_contents([('gitr/.git/config', """\
115+[user]
116+ email = some@example.com
117+ name = Test User
118+ signingkey = D729A457
119+""")])
120+ out, err = self.run_bzr(["config", "-d", "gitr", "gpg_signing_key"])
121+ self.assertEqual(out, "D729A457\n")
122+ self.assertEqual(err, "")
123+
124
125 class ShallowTests(ExternalBase):
126
127
128=== modified file 'breezy/library_state.py'
129--- breezy/library_state.py 2020-02-18 01:57:45 +0000
130+++ breezy/library_state.py 2020-03-22 01:38:36 +0000
131@@ -98,8 +98,9 @@
132 self._trace.__enter__()
133
134 self._orig_ui = breezy.ui.ui_factory
135- breezy.ui.ui_factory = self._ui
136- self._ui.__enter__()
137+ if self._ui is not None:
138+ breezy.ui.ui_factory = self._ui
139+ self._ui.__enter__()
140
141 if breezy._global_state is not None:
142 raise RuntimeError("Breezy already initialized")
143@@ -115,7 +116,8 @@
144 trace._flush_stdout_stderr()
145 trace._flush_trace()
146 osutils.report_extension_load_failures()
147- self._ui.__exit__(None, None, None)
148+ if self._ui is not None:
149+ self._ui.__exit__(None, None, None)
150 self._trace.__exit__(None, None, None)
151 ui.ui_factory = self._orig_ui
152 breezy._global_state = None
153
154=== modified file 'breezy/plugins/propose/gitlabs.py'
155--- breezy/plugins/propose/gitlabs.py 2020-03-07 15:47:50 +0000
156+++ breezy/plugins/propose/gitlabs.py 2020-03-22 01:38:36 +0000
157@@ -97,6 +97,10 @@
158 self.error = error
159
160
161+class MergeRequestExists(Exception):
162+ """Raised when a merge requests already exists."""
163+
164+
165 def default_config_path():
166 return os.path.join(bedding.config_dir(), 'gitlab.conf')
167
168@@ -401,7 +405,7 @@
169 if response.status == 403:
170 raise errors.PermissionDenied(response.text)
171 if response.status == 409:
172- raise MergeProposalExists(self.source_branch.user_url)
173+ raise MergeRequestExists()
174 if response.status != 201:
175 raise errors.InvalidHttpResponse(path, response.text)
176 return json.loads(response.data)
177@@ -616,7 +620,10 @@
178 else:
179 user = self.gl._get_user(reviewer)
180 kwargs['assignee_ids'].append(user['id'])
181- merge_request = self.gl._create_mergerequest(**kwargs)
182+ try:
183+ merge_request = self.gl._create_mergerequest(**kwargs)
184+ except MergeRequestExists:
185+ raise ProposalExists(self.source_branch.user_url)
186 return GitLabMergeProposal(self.gl, merge_request)
187
188
189
190=== modified file 'breezy/tests/test_library_state.py'
191--- breezy/tests/test_library_state.py 2017-08-27 13:57:26 +0000
192+++ breezy/tests/test_library_state.py 2020-03-22 01:38:36 +0000
193@@ -52,3 +52,15 @@
194 finally:
195 state.__exit__(None, None, None)
196 self.assertEqual(['__enter__', '__exit__'], tracer._calls)
197+
198+ def test_ui_not_specified(self):
199+ self.overrideAttr(breezy, '_global_state', None)
200+ state = library_state.BzrLibraryState(
201+ ui=None, trace=fixtures.RecordingContextManager())
202+ orig_ui = _mod_ui.ui_factory
203+ state.__enter__()
204+ try:
205+ self.assertEqual(orig_ui, _mod_ui.ui_factory)
206+ finally:
207+ state.__exit__(None, None, None)
208+ self.assertEqual(orig_ui, _mod_ui.ui_factory)
209
210=== modified file 'doc/en/release-notes/brz-3.1.txt'
211--- doc/en/release-notes/brz-3.1.txt 2020-02-08 17:00:10 +0000
212+++ doc/en/release-notes/brz-3.1.txt 2020-03-22 01:38:36 +0000
213@@ -114,6 +114,9 @@
214 * Python 3 is now used by default to run scripts, etc. from the makefile.
215 (Jelmer Vernooij)
216
217+ * ``.git/config`` is now consulted to determine the users' identity
218+ for commits, and the gpg_signing_key. (Jelmer Vernooij)
219+
220 Bug Fixes
221 *********
222
223@@ -148,6 +151,9 @@
224 * Ignore ghost tags when interacting with remote Git repositories.
225 (Jelmer Vernooij)
226
227+* Fix ``setup_ui=False`` when initializing Breezy.
228+ (Jelmer Vernooij, #1852647)
229+
230 Documentation
231 *************
232
233
234=== modified file 'doc/en/tutorials/using_breezy_with_github.txt'
235--- doc/en/tutorials/using_breezy_with_github.txt 2018-11-22 03:04:59 +0000
236+++ doc/en/tutorials/using_breezy_with_github.txt 2020-03-22 01:38:36 +0000
237@@ -39,19 +39,25 @@
238 GitHub is a code hosting service so you can push your
239 branch to it and others can access your code from there.
240
241-In the GitHub web UI, you can create a "fork" of an upstream repository. For
242-example, if user "jelmer" forked the inkscape repository at
243-https://github.com/inkscape/inkscape then the fork would be at
244-https://github.com/jelmer/inkscape.
245-
246-You can then push your changes to a branch like this::
247-
248- brz push git+ssh://github.com/jelmer/inkscape,branch=my-branch
249-
250-Others can then download your code like this::
251-
252- brz branch git://github.com/jelmer/inkscape,branch=my-branch
253-
254+The first time you use GitHub, you will need to log into to your GitHub account
255+with Breezy. This can be done by running ``brz github-login``. This will prompt
256+you for your password, and store the authentication token in ~/.config/breezy.
257+
258+You can now use either ``brz publish`` to upload the changes back to
259+GitHub, or ``brz propose`` to upload to the changes to GitHub and
260+create merge proposal.
261+
262+Both ``brz publish`` and ``brz propose`` will create a fork of the upstream
263+repository and then push your local changes to the active branch
264+(or another branch specify with the --name argument).
265+
266+For example, running ``brz publish --name=my-branch`` in your local inkscape
267+clone will create https://github.com/jelmer/inkscape if your GitHub username is
268+"jelmer", and it will open your editor to allow you to enter the merge proposal
269+description.
270+
271+Subsequent use of ``brz publish`` in the local branch (e.g. to push more
272+commits) will update the previously created branch.
273
274 Associating branches with GitHub issues
275 ---------------------------------------

Subscribers

People subscribed via source and target branches