/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-04 00:40:55 UTC
  • mfrom: (0.431.68 trunk)
  • mto: This revision was merged to the branch mainline in revision 7239.
  • Revision ID: jelmer@jelmer.uk-20190104004055-tzqez2pxep3poo8s
Merge lp:brz-propose.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    UnsupportedHoster,
39
39
    )
40
40
 
 
41
def mp_status_to_status(status):
 
42
    return {
 
43
        'all': 'all',
 
44
        'open': 'opened',
 
45
        'merged': 'merged',
 
46
        'closed': 'closed'}[status]
 
47
 
41
48
 
42
49
class NotGitLabUrl(errors.BzrError):
43
50
 
248
255
    def get_proposer(self, source_branch, target_branch):
249
256
        return GitlabMergeProposalBuilder(self.gl, source_branch, target_branch)
250
257
 
251
 
    def iter_proposals(self, source_branch, target_branch):
 
258
    def iter_proposals(self, source_branch, target_branch, status):
252
259
        import gitlab
253
260
        (source_host, source_project_name, source_branch_name) = (
254
261
            parse_gitlab_url(source_branch))
259
266
        self.gl.auth()
260
267
        source_project = self.gl.projects.get(source_project_name)
261
268
        target_project = self.gl.projects.get(target_project_name)
 
269
        state = mp_status_to_status(status)
262
270
        try:
263
 
            for mr in target_project.mergerequests.list(state='all'):
 
271
            for mr in target_project.mergerequests.list(state=state):
264
272
                if (mr.source_project_id != source_project.id or
265
273
                        mr.source_branch != source_branch_name or
266
274
                        mr.target_project_id != target_project.id or
311
319
            yield cls(gl)
312
320
 
313
321
    def iter_my_proposals(self, status='open'):
314
 
        state = {
315
 
            'all': 'all',
316
 
            'open': 'opened',
317
 
            'merged': 'merged',
318
 
            'closed': 'closed'}[status]
 
322
        state = mp_status_to_status(status)
319
323
        self.gl.auth()
320
324
        for mp in self.gl.mergerequests.list(
321
325
                owner=self.gl.user.username, state=state):