Streamlined libbe.command.serve, adding --auth option, #/bea/c1b#, and testing.
[be.git] / libbe / storage / __init__.py
1 # Copyright (C) 2009-2010 W. Trevor King <wking@drexel.edu>
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; either version 2 of the License, or
6 # (at your option) any 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 along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
17 import base
18
19 ConnectionError = base.ConnectionError
20 InvalidStorageVersion = base.InvalidStorageVersion
21 InvalidID = base.InvalidID
22 InvalidRevision = base.InvalidRevision
23 InvalidDirectory = base.InvalidDirectory
24 NotWriteable = base.NotWriteable
25 NotReadable = base.NotReadable
26 EmptyCommit = base.EmptyCommit
27
28 # a list of all past versions
29 STORAGE_VERSIONS = ['Bugs Everywhere Tree 1 0',
30                     'Bugs Everywhere Directory v1.1',
31                     'Bugs Everywhere Directory v1.2',
32                     'Bugs Everywhere Directory v1.3',
33                     'Bugs Everywhere Directory v1.4',
34                     ]
35
36 # the current version
37 STORAGE_VERSION = STORAGE_VERSIONS[-1]
38
39 def get_http_storage(location):
40     import http
41     return http.HTTP(location)
42
43 def get_vcs_storage(location):
44     import vcs
45     s = vcs.detect_vcs(location)
46     s.repo = location
47     return s
48
49 def get_storage(location):
50     """
51     Return a Storage instance from a repo location string.
52     """
53     if location.startswith('http://') or location.startswith('https://'):
54         return get_http_storage(location)
55     return get_vcs_storage(location)
56
57 __all__ = [ConnectionError, InvalidStorageVersion, InvalidID,
58            InvalidRevision, InvalidDirectory, NotWriteable, NotReadable,
59            EmptyCommit, STORAGE_VERSIONS, STORAGE_VERSION,
60            get_storage]