Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d20dadf

Browse filesBrowse files
committed
First rename session, db/test_base.py works, but there is much more work to do
1 parent e249941 commit d20dadf
Copy full SHA for d20dadf

15 files changed

+81
-76
lines changed

‎gitdb/db/py/__init__.py

Copy file name to clipboardExpand all lines: gitdb/db/py/__init__.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
from pack import *
1010
from git import *
1111
from ref import *
12-
12+
from resolve import *
13+
from transport import *

‎gitdb/db/py/base.py

Copy file name to clipboardExpand all lines: gitdb/db/py/base.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import os
3636

3737

38-
__all__ = ( 'PureObjectDBR', 'PureObjectDBW', 'PureRootPathDBBase', 'PureCompoundDB',
39-
'NameResolveMixin', 'PureConfigurationMixin', 'PureRepositoryPathsMixin')
38+
__all__ = ( 'PureObjectDBR', 'PureObjectDBW', 'PureRootPathDB', 'PureCompoundDB',
39+
'PureConfigurationMixin', 'PureRepositoryPathsMixin')
4040

4141

4242
class PureObjectDBR(ObjectDBR):
@@ -83,10 +83,10 @@ def store_async(self, reader):
8383
#} END edit interface
8484

8585

86-
class PureRootPathDBBase(RootPathDBBase):
86+
class PureRootPathDB(RootPathDB):
8787

8888
def __init__(self, root_path):
89-
super(PureRootPathDBBase, self).__init__()
89+
super(PureRootPathDB, self).__init__(root_path)
9090
self._root_path = root_path
9191

9292

‎gitdb/db/py/git.py

Copy file name to clipboardExpand all lines: gitdb/db/py/git.py
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
22
#
3-
# This module is part of GitDB and is released under
3+
# This module is part of PureGitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
from base import (
6-
CompoundDB,
7-
ObjectDBW,
8-
RootPathDBBase,
9-
RepositoryPathsMixin,
10-
ConfigurationMixin,
6+
PureCompoundDB,
7+
PureObjectDBW,
8+
PureRootPathDB,
9+
PureRepositoryPathsMixin,
10+
PureConfigurationMixin,
1111
)
1212

13-
from resolve import NameResolvePureMixin
13+
from resolve import PureReferencesMixin
1414

15-
from loose import LooseObjectDB
16-
from pack import PackedDB
17-
from ref import ReferenceDB
15+
from loose import PureLooseObjectODB
16+
from pack import PurePackedODB
17+
from ref import PureReferenceDB
1818

1919
from gitdb.util import (
2020
LazyMixin,
@@ -29,19 +29,19 @@
2929
)
3030
import os
3131

32-
__all__ = ('GitODB', 'GitDB')
32+
__all__ = ('PureGitODB', 'PureGitDB')
3333

3434

35-
class GitODB(RootPathDBBase, ObjectDBW, CompoundDB):
35+
class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB):
3636
"""A git-style object-only database, which contains all objects in the 'objects'
3737
subdirectory.
3838
:note: The type needs to be initialized on the ./objects directory to function,
39-
as it deals solely with object lookup. Use a GitDB type if you need
39+
as it deals solely with object lookup. Use a PureGitDB type if you need
4040
reference and push support."""
4141
# Configuration
42-
PackDBCls = PackedDB
43-
LooseDBCls = LooseObjectDB
44-
ReferenceDBCls = ReferenceDB
42+
PackDBCls = PurePackedODB
43+
LooseDBCls = PureLooseObjectODB
44+
PureReferenceDBCls = PureReferenceDB
4545

4646
# Directories
4747
packs_dir = 'pack'
@@ -50,15 +50,15 @@ class GitODB(RootPathDBBase, ObjectDBW, CompoundDB):
5050

5151
def __init__(self, root_path):
5252
"""Initialize ourselves on a git ./objects directory"""
53-
super(GitODB, self).__init__(root_path)
53+
super(PureGitODB, self).__init__(root_path)
5454

5555
def _set_cache_(self, attr):
5656
if attr == '_dbs' or attr == '_loose_db':
5757
self._dbs = list()
5858
loose_db = None
5959
for subpath, dbcls in ((self.packs_dir, self.PackDBCls),
6060
(self.loose_dir, self.LooseDBCls),
61-
(self.alternates_dir, self.ReferenceDBCls)):
61+
(self.alternates_dir, self.PureReferenceDBCls)):
6262
path = self.db_path(subpath)
6363
if os.path.exists(path):
6464
self._dbs.append(dbcls(path))
@@ -79,10 +79,10 @@ def _set_cache_(self, attr):
7979
# finally set the value
8080
self._loose_db = loose_db
8181
else:
82-
super(GitODB, self)._set_cache_(attr)
82+
super(PureGitODB, self)._set_cache_(attr)
8383
# END handle attrs
8484

85-
#{ ObjectDBW interface
85+
#{ PureObjectDBW interface
8686

8787
def store(self, istream):
8888
return self._loose_db.store(istream)
@@ -96,7 +96,7 @@ def set_ostream(self, ostream):
9696
#} END objectdbw interface
9797

9898

99-
class GitDB(GitODB, RepositoryPathsMixin, ConfigurationMixin, NameResolvePureMixin):
99+
class PureGitDB(PureGitODB, PureRepositoryPathsMixin, PureConfigurationMixin, PureReferencesMixin):
100100
"""Git like database with support for object lookup as well as reference resolution.
101101
Our rootpath is set to the actual .git directory (bare on unbare).
102102
@@ -106,8 +106,8 @@ class GitDB(GitODB, RepositoryPathsMixin, ConfigurationMixin, NameResolvePureMix
106106

107107
def __init__(self, root_path):
108108
"""Initialize ourselves on the .git directory, or the .git/objects directory."""
109-
RepositoryPathsMixin._initialize(self, root_path)
110-
super(GitDB, self).__init__(self.objects_path())
109+
PureRepositoryPathsMixin._initialize(self, root_path)
110+
super(PureGitDB, self).__init__(self.objects_path())
111111

112112

113113

‎gitdb/db/py/loose.py

Copy file name to clipboardExpand all lines: gitdb/db/py/loose.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
from base import (
6-
RootPathDBBase,
7-
ObjectDBR,
8-
ObjectDBW
6+
PureRootPathDB,
7+
PureObjectDBR,
8+
PureObjectDBW
99
)
1010

1111

@@ -57,10 +57,10 @@
5757
import os
5858

5959

60-
__all__ = ( 'LooseObjectDB', )
60+
__all__ = ( 'PureLooseObjectODB', )
6161

6262

63-
class LooseObjectDB(RootPathDBBase, ObjectDBR, ObjectDBW):
63+
class PureLooseObjectODB(PureRootPathDB, PureObjectDBR, PureObjectDBW):
6464
"""A database which operates on loose object files"""
6565

6666
# CONFIGURATION
@@ -75,7 +75,7 @@ class LooseObjectDB(RootPathDBBase, ObjectDBR, ObjectDBW):
7575

7676

7777
def __init__(self, root_path):
78-
super(LooseObjectDB, self).__init__(root_path)
78+
super(PureLooseObjectODB, self).__init__(root_path)
7979
self._hexsha_to_file = dict()
8080
# Additional Flags - might be set to 0 after the first failure
8181
# Depending on the root, this might work for some mounts, for others not, which
@@ -156,7 +156,7 @@ def set_ostream(self, stream):
156156
""":raise TypeError: if the stream does not support the Sha1Writer interface"""
157157
if stream is not None and not isinstance(stream, Sha1Writer):
158158
raise TypeError("Output stream musst support the %s interface" % Sha1Writer.__name__)
159-
return super(LooseObjectDB, self).set_ostream(stream)
159+
return super(PureLooseObjectODB, self).set_ostream(stream)
160160

161161
def info(self, sha):
162162
m = self._map_loose_object(sha)

‎gitdb/db/py/mem.py

Copy file name to clipboardExpand all lines: gitdb/db/py/mem.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
"""Contains the MemoryDatabase implementation"""
6-
from loose import LooseObjectDB
6+
from loose import PureLooseObjectODB
77
from base import (
8-
ObjectDBR,
9-
ObjectDBW
8+
PureObjectDBR,
9+
PureObjectDBW
1010
)
1111

1212
from gitdb.base import (
@@ -25,9 +25,9 @@
2525

2626
from cStringIO import StringIO
2727

28-
__all__ = ("MemoryDB", )
28+
__all__ = ("PureMemoryDB", )
2929

30-
class MemoryDB(ObjectDBR, ObjectDBW):
30+
class PureMemoryDB(PureObjectDBR, PureObjectDBW):
3131
"""A memory database stores everything to memory, providing fast IO and object
3232
retrieval. It should be used to buffer results and obtain SHAs before writing
3333
it to the actual physical storage, as it allows to query whether object already
@@ -37,14 +37,14 @@ class MemoryDB(ObjectDBR, ObjectDBW):
3737
for storing"""
3838

3939
def __init__(self):
40-
super(MemoryDB, self).__init__()
41-
self._db = LooseObjectDB("path/doesnt/matter")
40+
super(PureMemoryDB, self).__init__()
41+
self._db = PureLooseObjectODB("path/doesnt/matter")
4242

4343
# maps 20 byte shas to their OStream objects
4444
self._cache = dict()
4545

4646
def set_ostream(self, stream):
47-
raise UnsupportedOperation("MemoryDB's always stream into memory")
47+
raise UnsupportedOperation("PureMemoryDB's always stream into memory")
4848

4949
def store(self, istream):
5050
zstream = ZippedStoreShaWriter()
@@ -62,7 +62,7 @@ def store(self, istream):
6262
return istream
6363

6464
def store_async(self, reader):
65-
raise UnsupportedOperation("MemoryDBs cannot currently be used for async write access")
65+
raise UnsupportedOperation("PureMemoryDBs cannot currently be used for async write access")
6666

6767
def has_object(self, sha):
6868
return sha in self._cache

‎gitdb/db/py/pack.py

Copy file name to clipboardExpand all lines: gitdb/db/py/pack.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
"""Module containing a database to deal with packs"""
6+
from gitdb.db import CachingDB
67
from base import (
7-
RootPathDBBase,
8-
ObjectDBR,
9-
CachingDB
8+
PureRootPathDB,
9+
PureObjectDBR
1010
)
1111

1212
from gitdb.util import LazyMixin
@@ -22,12 +22,12 @@
2222
import os
2323
import glob
2424

25-
__all__ = ('PackedDB', )
25+
__all__ = ('PurePackedODB', )
2626

2727
#{ Utilities
2828

2929

30-
class PackedDB(RootPathDBBase, ObjectDBR, CachingDB, LazyMixin):
30+
class PurePackedODB(PureRootPathDB, PureObjectDBR, CachingDB, LazyMixin):
3131
"""A database operating on a set of object packs"""
3232

3333
# the type to use when instantiating a pack entity
@@ -39,7 +39,7 @@ class PackedDB(RootPathDBBase, ObjectDBR, CachingDB, LazyMixin):
3939
_sort_interval = 500
4040

4141
def __init__(self, root_path):
42-
super(PackedDB, self).__init__(root_path)
42+
super(PurePackedODB, self).__init__(root_path)
4343
# list of lists with three items:
4444
# * hits - number of times the pack was hit with a request
4545
# * entity - Pack entity instance
@@ -127,7 +127,7 @@ def store(self, istream):
127127
raise UnsupportedOperation()
128128

129129
def store_async(self, reader):
130-
# TODO: add ObjectDBRW before implementing this
130+
# TODO: add PureObjectDBRW before implementing this
131131
raise NotImplementedError()
132132

133133
#} END object db write

‎gitdb/db/py/ref.py

Copy file name to clipboardExpand all lines: gitdb/db/py/ref.py
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
#
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5-
from base import (
6-
CompoundDB,
7-
)
5+
from base import PureCompoundDB
86

97
import os
10-
__all__ = ('ReferenceDB', )
8+
__all__ = ('PureReferenceDB', )
119

12-
class ReferenceDB(CompoundDB):
10+
class PureReferenceDB(PureCompoundDB):
1311
"""A database consisting of database referred to in a file"""
1412

1513
# Configuration
@@ -18,15 +16,15 @@ class ReferenceDB(CompoundDB):
1816
ObjectDBCls = None
1917

2018
def __init__(self, ref_file):
21-
super(ReferenceDB, self).__init__()
19+
super(PureReferenceDB, self).__init__()
2220
self._ref_file = ref_file
2321

2422
def _set_cache_(self, attr):
2523
if attr == '_dbs':
2624
self._dbs = list()
2725
self._update_dbs_from_ref_file()
2826
else:
29-
super(ReferenceDB, self)._set_cache_(attr)
27+
super(PureReferenceDB, self)._set_cache_(attr)
3028
# END handle attrs
3129

3230
def _update_dbs_from_ref_file(self):
@@ -64,7 +62,7 @@ def _update_dbs_from_ref_file(self):
6462
try:
6563
db = dbcls(path)
6664
# force an update to verify path
67-
if isinstance(db, CompoundDB):
65+
if isinstance(db, PureCompoundDB):
6866
db.databases()
6967
# END verification
7068
self._dbs.append(db)
@@ -76,4 +74,4 @@ def _update_dbs_from_ref_file(self):
7674
def update_cache(self, force=False):
7775
# re-read alternates and update databases
7876
self._update_dbs_from_ref_file()
79-
return super(ReferenceDB, self).update_cache(force)
77+
return super(PureReferenceDB, self).update_cache(force)

‎gitdb/db/py/resolve.py

Copy file name to clipboardExpand all lines: gitdb/db/py/resolve.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818
import re
1919

20-
__all__ = ["NameResolvePureMixin"]
20+
__all__ = ["PureReferencesMixin"]
2121

2222
#{ Utilities
2323

‎gitdb/test/db/lib.py

Copy file name to clipboardExpand all lines: gitdb/test/db/lib.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
from gitdb.stream import Sha1Writer
1515

16+
# import database types we want to support
17+
# they will be set to None if the respective library could not be loaded
18+
from gitdb.db.py import PureGitDB
19+
1620
from gitdb.base import (
1721
IStream,
1822
OStream,
@@ -36,6 +40,9 @@ class TestDBBase(TestBase):
3640
two_lines = "1234\nhello world"
3741
all_data = (two_lines, )
3842

43+
# all supported database types. Add your own type
44+
ref_db_types = (PureGitDB, )
45+
3946
def _assert_object_writing_simple(self, db):
4047
# write a bunch of objects and query their streams and info
4148
null_objs = db.size()

‎gitdb/test/db/test_loose.py

Copy file name to clipboardExpand all lines: gitdb/test/db/test_loose.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
from lib import *
6-
from gitdb.db import LooseObjectDB
6+
from gitdb.db import PureLooseObjectODB
77
from gitdb.exc import BadObject
88
from gitdb.util import bin_to_hex
99

1010
class TestLooseDB(TestDBBase):
1111

1212
@with_rw_directory
1313
def test_basics(self, path):
14-
ldb = LooseObjectDB(path)
14+
ldb = PureLooseObjectODB(path)
1515

1616
# write data
1717
self._assert_object_writing(ldb)

‎gitdb/test/db/test_mem.py

Copy file name to clipboardExpand all lines: gitdb/test/db/test_mem.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from lib import *
66
from gitdb.db import (
77
MemoryDB,
8-
LooseObjectDB
8+
PureLooseObjectODB
99
)
1010

1111
class TestMemoryDB(TestDBBase):
@@ -18,7 +18,7 @@ def test_writing(self, path):
1818
self._assert_object_writing_simple(mdb)
1919

2020
# test stream copy
21-
ldb = LooseObjectDB(path)
21+
ldb = PureLooseObjectODB(path)
2222
assert ldb.size() == 0
2323
num_streams_copied = mdb.stream_copy(mdb.sha_iter(), ldb)
2424
assert num_streams_copied == mdb.size()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.