/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

Raise proper exception when forking isn't available for a project.

Merged from https://code.launchpad.net/~jelmer/brz/fork-disabled/+merge/386359

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
        self.error = error
101
101
 
102
102
 
 
103
class ForkingDisabled(errors.BzrError):
 
104
 
 
105
    _fmt = ("Forking on project %(project)s is disabled.")
 
106
 
 
107
    def __init__(self, project):
 
108
        self.project = project
 
109
 
 
110
 
103
111
class MergeRequestExists(Exception):
104
112
    """Raised when a merge requests already exists."""
105
113
 
356
364
    def _fork_project(self, project_name, timeout=50, interval=5):
357
365
        path = 'projects/%s/fork' % urlutils.quote(str(project_name), '')
358
366
        response = self._api_request('POST', path)
 
367
        if response.status == 404:
 
368
            raise ForkingDisabled(project_name)
359
369
        if response.status not in (200, 201):
360
370
            raise errors.InvalidHttpResponse(path, response.text)
361
371
        # The response should be valid JSON, but let's ignore it