aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/__init__.py
blob: 01885e93a202315c776376c658bca7515f6c6d2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (C) 2009-2012 Chris Ball <cjb@laptop.org>
#                         W. Trevor King <wking@tremily.us>
#
# This file is part of Bugs Everywhere.
#
# Bugs Everywhere is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2 of the License, or (at your option) any
# later version.
#
# Bugs Everywhere is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# Bugs Everywhere.  If not, see <http://www.gnu.org/licenses/>.

"""Define the :py:class:`~libbe.storage.base.Storage` and
:py:class:`~libbe.storage.base.VersionedStorage` classes for storing BE
data.

Also define assorted implementations for the Storage classes:

* :py:mod:`libbe.storage.vcs`

Also define an assortment of storage-related tools and utilities:

* :py:mod:`libbe.storage.util`
"""

from . import base as _base

ConnectionError = _base.ConnectionError
InvalidStorageVersion = _base.InvalidStorageVersion
InvalidID = _base.InvalidID
InvalidRevision = _base.InvalidRevision
InvalidDirectory = _base.InvalidDirectory
NotWriteable = _base.NotWriteable
NotReadable = _base.NotReadable
EmptyCommit = _base.EmptyCommit

# a list of all past versions
STORAGE_VERSIONS = ['Bugs Everywhere Tree 1 0',
                    'Bugs Everywhere Directory v1.1',
                    'Bugs Everywhere Directory v1.2',
                    'Bugs Everywhere Directory v1.3',
                    'Bugs Everywhere Directory v1.4',
                    'Bugs Everywhere Directory v1.5',
                    ]

# the current version
STORAGE_VERSION = STORAGE_VERSIONS[-1]

def get_vcs_storage(location):
    import vcs
    s = vcs.detect_vcs(location)
    s.repo = location
    return s

def get_storage(location):
    """
    Return a Storage instance from a repo location string.
    """
    if location.startswith('http://') or location.startswith('https://'):
        raise ConnectionError('HTTP URLs are no longer supported')
    return get_vcs_storage(location)

__all__ = [ConnectionError, InvalidStorageVersion, InvalidID,
           InvalidRevision, InvalidDirectory, NotWriteable, NotReadable,
           EmptyCommit, STORAGE_VERSIONS, STORAGE_VERSION,
           get_storage]