/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/gitlab/hoster.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-15 21:51:27 UTC
  • mto: (7490.40.58 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200715215127-3hn9ktbg3f1xikjj
More fixes for hg probing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
            raise KeyError('no such user %s' % username)
339
339
        if response.status == 200:
340
340
            return json.loads(response.data)
341
 
        raise errors.InvalidHttpResponse(path, response.text)
 
341
        raise errors.UnexpectedHttpStatus(path, response.status)
342
342
 
343
343
    def _get_user_by_email(self, email):
344
344
        path = 'users?search=%s' % urlutils.quote(str(email), '')
350
350
            if len(ret) != 1:
351
351
                raise ValueError('unexpected number of results; %r' % ret)
352
352
            return ret[0]
353
 
        raise errors.InvalidHttpResponse(path, response.text)
 
353
        raise errors.UnexpectedHttpStatus(path, response.status)
354
354
 
355
355
    def _get_project(self, project_name):
356
356
        path = 'projects/%s' % urlutils.quote(str(project_name), '')
359
359
            raise NoSuchProject(project_name)
360
360
        if response.status == 200:
361
361
            return json.loads(response.data)
362
 
        raise errors.InvalidHttpResponse(path, response.text)
 
362
        raise errors.UnexpectedHttpStatus(path, response.status)
363
363
 
364
364
    def _fork_project(self, project_name, timeout=50, interval=5):
365
365
        path = 'projects/%s/fork' % urlutils.quote(str(project_name), '')
367
367
        if response.status == 404:
368
368
            raise ForkingDisabled(project_name)
369
369
        if response.status not in (200, 201):
370
 
            raise errors.InvalidHttpResponse(path, response.text)
 
370
            raise errors.UnexpectedHttpStatus(path, response.status)
371
371
        # The response should be valid JSON, but let's ignore it
372
372
        project = json.loads(response.data)
373
373
        # Spin and wait until import_status for new project
400
400
            if response.status == 403:
401
401
                raise errors.PermissionDenied(response.text)
402
402
            if response.status != 200:
403
 
                raise errors.InvalidHttpResponse(path, response.text)
 
403
                raise errors.UnexpectedHttpStatus(path, response.status)
404
404
            page = response.getheader("X-Next-Page")
405
405
            for entry in json.loads(response.data):
406
406
                yield entry
423
423
        if response.status == 403:
424
424
            raise errors.PermissionDenied(response.text)
425
425
        if response.status != 200:
426
 
            raise errors.InvalidHttpResponse(path, response.text)
 
426
            raise errors.UnexpectedHttpStatus(path, response.status
427
427
        return json.loads(response.data)
428
428
 
429
429
    def _list_projects(self, owner):
437
437
        response = self._api_request('PUT', path, fields=mr)
438
438
        if response.status == 200:
439
439
            return json.loads(response.data)
440
 
        raise errors.InvalidHttpResponse(path, response.text)
 
440
        raise errors.UnexpectedHttpStatus(path, response.status)
441
441
 
442
442
    def _post_merge_request_note(self, project_id, iid, kwargs):
443
443
        path = 'projects/%s/merge_requests/%s/notes' % (
446
446
        if response.status == 201:
447
447
            json.loads(response.data)
448
448
            return
449
 
        raise errors.InvalidHttpResponse(path, response.text)
 
449
        raise errors.UnexpectedHttpStatus(path, response.status)
450
450
 
451
451
    def _create_mergerequest(
452
452
            self, title, source_project_id, target_project_id,
469
469
        if response.status == 409:
470
470
            raise MergeRequestExists()
471
471
        if response.status != 201:
472
 
            raise errors.InvalidHttpResponse(path, response.text)
 
472
            raise errors.UnexpectedHttpStatus(path, response.status)
473
473
        return json.loads(response.data)
474
474
 
475
475
    def get_push_url(self, branch):
617
617
        if response.status == 404:
618
618
            raise NoSuchProject(project)
619
619
        if response.status != 202:
620
 
            raise errors.InvalidHttpResponse(path, response.text)
 
620
            raise errors.UnexpectedHttpStatus(path, response.status)
621
621
 
622
622
 
623
623
class GitlabMergeProposalBuilder(MergeProposalBuilder):