/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/propose/gitlabs.py

  • Committer: Jelmer Vernooij
  • Date: 2019-01-02 21:59:47 UTC
  • mfrom: (0.431.64 trunk)
  • mto: This revision was merged to the branch mainline in revision 7239.
  • Revision ID: jelmer@jelmer.uk-20190102215947-bv6tjqf5rg71id76
Merge lp:brz-propose.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    def set_description(self, description):
143
143
        self._mr.description = description
144
144
 
 
145
    def _branch_url_from_project(self, project_id, branch_name):
 
146
        project = self._mr.manager.gitlab.projects.get(project_id)
 
147
        return gitlab_url_to_bzr_url(project.http_url_to_repo, branch_name)
 
148
 
 
149
    def get_source_branch_url(self):
 
150
        return self._branch_url_from_project(
 
151
            self._mr.source_project_id, self._mr.source_branch)
 
152
 
 
153
    def get_target_branch_url(self):
 
154
        return self._branch_url_from_project(
 
155
            self._mr.target_project_id, self._mr.target_branch)
 
156
 
145
157
    def is_merged(self):
146
 
        return (self._mr.attributes['state'] == 'merged')
 
158
        return (self._mr.state == 'merged')
147
159
 
148
160
 
149
161
def gitlab_url_to_bzr_url(url, name):
168
180
        (host, project_name, branch_name) = parse_gitlab_url(branch)
169
181
        project = self.gl.projects.get(project_name)
170
182
        return gitlab_url_to_bzr_url(
171
 
            project.attributes['ssh_url_to_repo'], branch_name)
 
183
            project.ssh_url_to_repo, branch_name)
172
184
 
173
185
    def publish_derived(self, local_branch, base_branch, name, project=None,
174
186
                        owner=None, revision_id=None, overwrite=False,
194
206
                target_project = base_project.forks.create({})
195
207
            else:
196
208
                raise
197
 
        remote_repo_url = git_url_to_bzr_url(target_project.attributes['ssh_url_to_repo'])
 
209
        remote_repo_url = git_url_to_bzr_url(target_project.ssh_url_to_repo)
198
210
        remote_dir = controldir.ControlDir.open(remote_repo_url)
199
211
        try:
200
212
            push_result = remote_dir.push_branch(
207
219
                local_branch, revision_id=revision_id, overwrite=overwrite,
208
220
                name=name, lossy=True)
209
221
        public_url = gitlab_url_to_bzr_url(
210
 
            target_project.attributes['http_url_to_repo'], name)
 
222
            target_project.http_url_to_repo, name)
211
223
        return push_result.target_branch, public_url
212
224
 
213
225
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
232
244
                raise errors.NotBranchError('%s/%s/%s' % (self.gl.url, owner, project))
233
245
            raise
234
246
        return _mod_branch.Branch.open(gitlab_url_to_bzr_url(
235
 
            target_project.attributes['ssh_url_to_repo'], name))
 
247
            target_project.ssh_url_to_repo, name))
236
248
 
237
249
    def get_proposer(self, source_branch, target_branch):
238
250
        return GitlabMergeProposalBuilder(self.gl, source_branch, target_branch)
250
262
        target_project = self.gl.projects.get(target_project_name)
251
263
        try:
252
264
            for mr in target_project.mergerequests.list(state='all'):
253
 
                attrs = mr.attributes
254
 
                if (attrs['source_project_id'] != source_project.id or
255
 
                        attrs['source_branch'] != source_branch_name or
256
 
                        attrs['target_project_id'] != target_project.id or
257
 
                        attrs['target_branch'] != target_branch_name):
 
265
                if (mr.source_project_id != source_project.id or
 
266
                        mr.source_branch != source_branch_name or
 
267
                        mr.target_project_id != target_project.id or
 
268
                        mr.target_branch != target_branch_name):
258
269
                    continue
259
270
                return GitLabMergeProposal(mr)
260
271
        except gitlab.GitlabListError as e: