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

Subscribers

People subscribed via source and target branches