Merge lp:~jelmer/brz/set-target-branch 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/set-target-branch
Merge into: lp:brz
Diff against target: 118 lines (+24/-8)
5 files modified
breezy/forge.py (+4/-0)
breezy/plugins/github/forge.py (+9/-7)
breezy/plugins/gitlab/forge.py (+6/-0)
breezy/plugins/launchpad/forge.py (+4/-0)
breezy/transport/http/urllib.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/set-target-branch
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+426999@code.launchpad.net

Commit message

Add MergeProposal.set_target_branch().

Description of the change

Add MergeProposal.set_target_branch().

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 :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/forge.py'
2--- breezy/forge.py 2022-07-12 09:23:34 +0000
3+++ breezy/forge.py 2022-07-17 01:53:37 +0000
4@@ -149,6 +149,10 @@
5 """Return the target branch."""
6 raise NotImplementedError(self.get_target_branch_url)
7
8+ def set_target_branch_name(self):
9+ """Set the target branch name."""
10+ raise NotImplementedError(self.set_target_branch_name)
11+
12 def get_source_project(self):
13 raise NotImplementedError(self.get_source_project)
14
15
16=== modified file 'breezy/plugins/github/forge.py'
17--- breezy/plugins/github/forge.py 2022-07-12 10:20:12 +0000
18+++ breezy/plugins/github/forge.py 2022-07-17 01:53:37 +0000
19@@ -147,6 +147,9 @@
20 def get_target_branch_url(self):
21 return self._branch_from_part(self._pr['base'])
22
23+ def set_target_branch_name(self, name):
24+ self._patch(base=name)
25+
26 def get_source_project(self):
27 return self._pr['head']['repo']['full_name']
28
29@@ -162,7 +165,7 @@
30 def set_commit_message(self, message):
31 raise errors.UnsupportedOperation(self.set_commit_message, self)
32
33- def _patch(self, data):
34+ def _patch(self, **data):
35 response = self._gh._api_request(
36 'PATCH', self._pr['url'], body=json.dumps(data).encode('utf-8'))
37 if response.status == 422:
38@@ -173,10 +176,9 @@
39 self._pr = json.loads(response.text)
40
41 def set_description(self, description):
42- self._patch({
43- 'body': description,
44- 'title': determine_title(description),
45- })
46+ self._patch(
47+ body=description,
48+ title=determine_title(description))
49
50 def is_merged(self):
51 return bool(self._pr.get('merged_at'))
52@@ -186,12 +188,12 @@
53
54 def reopen(self):
55 try:
56- self._patch({'state': 'open'})
57+ self._patch(state='open')
58 except ValidationFailed as e:
59 raise ReopenFailed(e.error['errors'][0]['message'])
60
61 def close(self):
62- self._patch({'state': 'closed'})
63+ self._patch(state='closed')
64
65 def can_be_merged(self):
66 return self._pr['mergeable']
67
68=== modified file 'breezy/plugins/gitlab/forge.py'
69--- breezy/plugins/gitlab/forge.py 2022-07-12 10:20:12 +0000
70+++ breezy/plugins/gitlab/forge.py 2022-07-17 01:53:37 +0000
71@@ -291,6 +291,9 @@
72 return self._branch_url_from_project(
73 self._mr['target_project_id'], self._mr['target_branch'])
74
75+ def set_target_branch_name(self, name):
76+ self._update(branch=name)
77+
78 def _get_project_name(self, project_id):
79 source_project = self.gl._get_project(project_id)
80 return source_project['path_with_namespace']
81@@ -728,6 +731,9 @@
82 'GET', 'https://%s/api/v4/projects/%s' % (host, urlutils.quote(str(project), '')))
83 except errors.UnexpectedHttpStatus as e:
84 raise UnsupportedForge(url)
85+ except errors.RedirectRequested:
86+ # GitLab doesn't send redirects for these URLs
87+ raise UnsupportedForge(url)
88 else:
89 if not resp.getheader('X-Gitlab-Feature-Category'):
90 raise UnsupportedForge(url)
91
92=== modified file 'breezy/plugins/launchpad/forge.py'
93--- breezy/plugins/launchpad/forge.py 2022-07-12 10:20:12 +0000
94+++ breezy/plugins/launchpad/forge.py 2022-07-17 01:53:37 +0000
95@@ -142,6 +142,10 @@
96 self._mp.target_git_repository.git_identity,
97 ref=self._mp.target_git_path.encode('utf-8'))
98
99+ def set_target_branch_name(self, name):
100+ # The launchpad API doesn't support changing branch names today.
101+ raise NotImplementedError(self.set_target_branch_name)
102+
103 @property
104 def url(self):
105 return lp_api.canonical_url(self._mp)
106
107=== modified file 'breezy/transport/http/urllib.py'
108--- breezy/transport/http/urllib.py 2022-07-16 13:44:07 +0000
109+++ breezy/transport/http/urllib.py 2022-07-17 01:53:37 +0000
110@@ -167,7 +167,7 @@
111 """
112
113 # Some responses have bodies in which we have no interest
114- _body_ignored_responses = [301, 302, 303, 307, 308, 403, 404, 501]
115+ _body_ignored_responses = [301, 302, 303, 307, 308, 404, 501]
116
117 # in finish() below, we may have to discard several MB in the worst
118 # case. To avoid buffering that much, we read and discard by chunks

Subscribers

People subscribed via source and target branches