Merge lp:~jelmer/brz/probe-fossil into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/probe-fossil
Merge into: lp:brz
Diff against target: 125 lines (+99/-0)
3 files modified
breezy/plugins/fossil/__init__.py (+94/-0)
breezy/transport/http/__init__.py (+1/-0)
doc/en/release-notes/brz-3.1.txt (+4/-0)
To merge this branch: bzr merge lp:~jelmer/brz/probe-fossil
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+375185@code.launchpad.net

Commit message

Add a fossil plugin that warns users when they attempt to access a Fossil repository.

Description of the change

Add a fossil plugin that warns users when they attempt to access a Fossil repository.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'breezy/plugins/fossil'
2=== added file 'breezy/plugins/fossil/__init__.py'
3--- breezy/plugins/fossil/__init__.py 1970-01-01 00:00:00 +0000
4+++ breezy/plugins/fossil/__init__.py 2019-11-09 17:14:52 +0000
5@@ -0,0 +1,94 @@
6+# Copyright (C) 2019 Jelmer Vernooij <jelmer@samba.org>
7+#
8+# This program is free software; you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License as published by
10+# the Free Software Foundation; version 3 of the License or
11+# (at your option) a later version.
12+#
13+# This program is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with this program; if not, write to the Free Software
20+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
22+"""Fossil foreign branch support.
23+
24+Currently only tells the user that Fossil is not supported.
25+"""
26+
27+from __future__ import absolute_import
28+
29+from ... import version_info # noqa: F401
30+
31+from ... import (
32+ controldir,
33+ errors,
34+ )
35+
36+
37+class FossilUnsupportedError(errors.UnsupportedFormatError):
38+
39+ _fmt = ('Fossil branches are not yet supported. '
40+ 'To convert Fossil branches to Bazaar branches or vice versa, '
41+ 'use fastimport.')
42+
43+
44+class FossilDirFormat(controldir.ControlDirFormat):
45+ """Fossil directory format."""
46+
47+ def get_converter(self):
48+ raise NotImplementedError(self.get_converter)
49+
50+ def get_format_description(self):
51+ return "Fossil control directory"
52+
53+ def initialize_on_transport(self, transport):
54+ raise errors.UninitializableFormat(self)
55+
56+ def is_supported(self):
57+ return False
58+
59+ def supports_transport(self, transport):
60+ return False
61+
62+ def check_support_status(self, allow_unsupported, recommend_upgrade=True,
63+ basedir=None):
64+ raise FossilUnsupportedError()
65+
66+ def open(self, transport):
67+ # Raise NotBranchError if there is nothing there
68+ RemoteFossilProber().probe_transport(transport)
69+ raise NotImplementedError(self.open)
70+
71+
72+class RemoteFossilProber(controldir.Prober):
73+
74+ @classmethod
75+ def priority(klass, transport):
76+ return 95
77+
78+ @classmethod
79+ def probe_transport(klass, transport):
80+ from breezy.transport.http import HttpTransport
81+ if not isinstance(transport, HttpTransport):
82+ raise errors.NotBranchError(path=transport.base)
83+ response = transport.request(
84+ 'POST', transport.base, headers={'Content-Type': 'application/x-fossil'})
85+ if response.status == 501:
86+ raise errors.NotBranchError(path=transport.base)
87+ ct = response.getheader('Content-Type')
88+ if ct is None:
89+ raise errors.NotBranchError(path=transport.base)
90+ if ct.split(';')[0] != 'application/x-fossil':
91+ raise errors.NotBranchError(path=transport.base)
92+ return FossilDirFormat()
93+
94+ @classmethod
95+ def known_formats(cls):
96+ return [FossilDirFormat()]
97+
98+
99+controldir.ControlDirFormat.register_prober(RemoteFossilProber)
100
101=== modified file 'breezy/transport/http/__init__.py'
102--- breezy/transport/http/__init__.py 2019-11-01 00:38:34 +0000
103+++ breezy/transport/http/__init__.py 2019-11-09 17:14:52 +0000
104@@ -1831,6 +1831,7 @@
105 404, # Not found
106 416,
107 422,
108+ 501, # Not implemented
109 ]
110 """The error codes the caller will handle.
111
112
113=== modified file 'doc/en/release-notes/brz-3.1.txt'
114--- doc/en/release-notes/brz-3.1.txt 2019-11-02 23:19:18 +0000
115+++ doc/en/release-notes/brz-3.1.txt 2019-11-09 17:14:52 +0000
116@@ -46,6 +46,10 @@
117 have installed and speeds up import time since psutil brings in
118 various other modules. (Jelmer Vernooij)
119
120+ * A new ``fossil`` plugin has been added that warns users when they
121+ attempt to access Fossil repositories.
122+ (Jelmer Vernooij, #1848821)
123+
124 Improvements
125 ************
126

Subscribers

People subscribed via source and target branches