/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/bzr/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-28 00:32:38 UTC
  • mfrom: (7490.40.77 work)
  • mto: (7490.40.79 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200728003238-vx5u412hn72f18lr
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    )
26
26
 
27
27
 
 
28
class LineEndingError(errors.BzrError):
 
29
 
 
30
    _fmt = ("Line ending corrupted for file: %(file)s; "
 
31
            "Maybe your files got corrupted in transport?")
 
32
 
 
33
    def __init__(self, file):
 
34
        self.file = file
 
35
 
 
36
 
28
37
class BzrProber(controldir.Prober):
29
38
    """Prober for formats that use a .bzr/ control directory."""
30
39
 
42
51
            format_string = transport.get_bytes(".bzr/branch-format")
43
52
        except errors.NoSuchFile:
44
53
            raise errors.NotBranchError(path=transport.base)
 
54
        except errors.BadHttpRequest as e:
 
55
            if e.reason == 'no such method: .bzr':
 
56
                # hgweb 
 
57
                raise errors.NotBranchError(path=transport.base)
 
58
            raise
 
59
 
45
60
        try:
46
61
            first_line = format_string[:format_string.index(b"\n") + 1]
47
62
        except ValueError:
48
63
            first_line = format_string
 
64
        if (first_line.startswith(b'<!DOCTYPE') or
 
65
                first_line.startswith(b'<html')):
 
66
            raise errors.NotBranchError(
 
67
                path=transport.base, detail="format file looks like HTML")
49
68
        try:
50
69
            cls = klass.formats.get(first_line)
51
70
        except KeyError:
52
71
            if first_line.endswith(b"\r\n"):
53
 
                raise errors.LineEndingError(file=".bzr/branch-format")
 
72
                raise LineEndingError(file=".bzr/branch-format")
54
73
            else:
55
74
                raise errors.UnknownFormatError(
56
75
                    format=first_line, kind='bzrdir')