/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/git/remote.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-09-12 02:50:00 UTC
  • mfrom: (7103.1.3 parse-git-error)
  • Revision ID: breezy.the.bot@gmail.com-20180912025000-dzxshqqn5dqci1t6
Improve error parsing for git repositories a bit.

Merged from https://code.launchpad.net/~jelmer/brz/parse-git-error/+merge/354724

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    NotBranchError,
46
46
    NotLocalUrl,
47
47
    NoWorkingTree,
 
48
    PermissionDenied,
48
49
    UninitializableFormat,
49
50
    )
50
51
from ..revisiontree import RevisionTree
175
176
    _fmt = "Remote server error: %(msg)s"
176
177
 
177
178
 
 
179
class HeadUpdateFailed(BzrError):
 
180
 
 
181
    _fmt = ("Unable to update remote HEAD branch. To update the master "
 
182
            "branch, specify the URL %(base_url)s,branch=master.")
 
183
 
 
184
    def __init__(self, base_url):
 
185
        super(HeadUpdateFailed, self).__init__()
 
186
        self.base_url = base_url
 
187
 
 
188
 
178
189
def parse_git_error(url, message):
179
190
    """Parse a remote git server error and return a bzr exception.
180
191
 
182
193
    :param message: Message sent by the remote git server
183
194
    """
184
195
    message = str(message).strip()
185
 
    if message.startswith("Could not find Repository "):
 
196
    if (message.startswith("Could not find Repository ") or
 
197
        message == 'Repository not found.'):
186
198
        return NotBranchError(url, message)
187
199
    if message == "HEAD failed to update":
188
200
        base_url, _ = urlutils.split_segment_parameters(url)
189
 
        raise BzrError(
190
 
            ("Unable to update remote HEAD branch. To update the master "
191
 
             "branch, specify the URL %s,branch=master.") % base_url)
 
201
        return HeadUpdateFailed(base_url)
 
202
    if message.startswith('access denied or repository not exported:'):
 
203
        extra, path = message.split(': ', 1)
 
204
        return PermissionDenied(path, extra)
192
205
    # Don't know, just return it to the user as-is
193
206
    return RemoteGitError(message)
194
207