diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2011-05-04 19:33:36 +0200 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2011-05-04 19:33:36 +0200 |
| commit | d20dadfde5824dcabda351f75a6784d616b2fd23 (patch) | |
| tree | 8b75a3bab4a76d57cacb53b5cb54f20e23951a3a /gitdb/db | |
| parent | e24994109f01bd315fd6a2aaecbbfcdd05bd0586 (diff) | |
| download | gitdb-d20dadfde5824dcabda351f75a6784d616b2fd23.tar.gz | |
First rename session, db/test_base.py works, but there is much more work to do
Diffstat (limited to 'gitdb/db')
| -rw-r--r-- | gitdb/db/py/__init__.py | 3 | ||||
| -rw-r--r-- | gitdb/db/py/base.py | 8 | ||||
| -rw-r--r-- | gitdb/db/py/git.py | 46 | ||||
| -rw-r--r-- | gitdb/db/py/loose.py | 14 | ||||
| -rw-r--r-- | gitdb/db/py/mem.py | 18 | ||||
| -rw-r--r-- | gitdb/db/py/pack.py | 14 | ||||
| -rw-r--r-- | gitdb/db/py/ref.py | 16 | ||||
| -rw-r--r-- | gitdb/db/py/resolve.py | 2 |
8 files changed, 60 insertions, 61 deletions
diff --git a/gitdb/db/py/__init__.py b/gitdb/db/py/__init__.py index e5935b7..046c699 100644 --- a/gitdb/db/py/__init__.py +++ b/gitdb/db/py/__init__.py @@ -9,4 +9,5 @@ from mem import * from pack import * from git import * from ref import * - +from resolve import * +from transport import * diff --git a/gitdb/db/py/base.py b/gitdb/db/py/base.py index a9296f0..a369552 100644 --- a/gitdb/db/py/base.py +++ b/gitdb/db/py/base.py @@ -35,8 +35,8 @@ import sys import os -__all__ = ( 'PureObjectDBR', 'PureObjectDBW', 'PureRootPathDBBase', 'PureCompoundDB', - 'NameResolveMixin', 'PureConfigurationMixin', 'PureRepositoryPathsMixin') +__all__ = ( 'PureObjectDBR', 'PureObjectDBW', 'PureRootPathDB', 'PureCompoundDB', + 'PureConfigurationMixin', 'PureRepositoryPathsMixin') class PureObjectDBR(ObjectDBR): @@ -83,10 +83,10 @@ class PureObjectDBW(ObjectDBW): #} END edit interface -class PureRootPathDBBase(RootPathDBBase): +class PureRootPathDB(RootPathDB): def __init__(self, root_path): - super(PureRootPathDBBase, self).__init__() + super(PureRootPathDB, self).__init__(root_path) self._root_path = root_path diff --git a/gitdb/db/py/git.py b/gitdb/db/py/git.py index d8eced5..bc148c6 100644 --- a/gitdb/db/py/git.py +++ b/gitdb/db/py/git.py @@ -1,20 +1,20 @@ # Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors # -# This module is part of GitDB and is released under +# This module is part of PureGitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php from base import ( - CompoundDB, - ObjectDBW, - RootPathDBBase, - RepositoryPathsMixin, - ConfigurationMixin, + PureCompoundDB, + PureObjectDBW, + PureRootPathDB, + PureRepositoryPathsMixin, + PureConfigurationMixin, ) -from resolve import NameResolvePureMixin +from resolve import PureReferencesMixin -from loose import LooseObjectDB -from pack import PackedDB -from ref import ReferenceDB +from loose import PureLooseObjectODB +from pack import PurePackedODB +from ref import PureReferenceDB from gitdb.util import ( LazyMixin, @@ -29,19 +29,19 @@ from gitdb.exc import ( ) import os -__all__ = ('GitODB', 'GitDB') +__all__ = ('PureGitODB', 'PureGitDB') -class GitODB(RootPathDBBase, ObjectDBW, CompoundDB): +class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB): """A git-style object-only database, which contains all objects in the 'objects' subdirectory. :note: The type needs to be initialized on the ./objects directory to function, - as it deals solely with object lookup. Use a GitDB type if you need + as it deals solely with object lookup. Use a PureGitDB type if you need reference and push support.""" # Configuration - PackDBCls = PackedDB - LooseDBCls = LooseObjectDB - ReferenceDBCls = ReferenceDB + PackDBCls = PurePackedODB + LooseDBCls = PureLooseObjectODB + PureReferenceDBCls = PureReferenceDB # Directories packs_dir = 'pack' @@ -50,7 +50,7 @@ class GitODB(RootPathDBBase, ObjectDBW, CompoundDB): def __init__(self, root_path): """Initialize ourselves on a git ./objects directory""" - super(GitODB, self).__init__(root_path) + super(PureGitODB, self).__init__(root_path) def _set_cache_(self, attr): if attr == '_dbs' or attr == '_loose_db': @@ -58,7 +58,7 @@ class GitODB(RootPathDBBase, ObjectDBW, CompoundDB): loose_db = None for subpath, dbcls in ((self.packs_dir, self.PackDBCls), (self.loose_dir, self.LooseDBCls), - (self.alternates_dir, self.ReferenceDBCls)): + (self.alternates_dir, self.PureReferenceDBCls)): path = self.db_path(subpath) if os.path.exists(path): self._dbs.append(dbcls(path)) @@ -79,10 +79,10 @@ class GitODB(RootPathDBBase, ObjectDBW, CompoundDB): # finally set the value self._loose_db = loose_db else: - super(GitODB, self)._set_cache_(attr) + super(PureGitODB, self)._set_cache_(attr) # END handle attrs - #{ ObjectDBW interface + #{ PureObjectDBW interface def store(self, istream): return self._loose_db.store(istream) @@ -96,7 +96,7 @@ class GitODB(RootPathDBBase, ObjectDBW, CompoundDB): #} END objectdbw interface -class GitDB(GitODB, RepositoryPathsMixin, ConfigurationMixin, NameResolvePureMixin): +class PureGitDB(PureGitODB, PureRepositoryPathsMixin, PureConfigurationMixin, PureReferencesMixin): """Git like database with support for object lookup as well as reference resolution. Our rootpath is set to the actual .git directory (bare on unbare). @@ -106,8 +106,8 @@ class GitDB(GitODB, RepositoryPathsMixin, ConfigurationMixin, NameResolvePureMix def __init__(self, root_path): """Initialize ourselves on the .git directory, or the .git/objects directory.""" - RepositoryPathsMixin._initialize(self, root_path) - super(GitDB, self).__init__(self.objects_path()) + PureRepositoryPathsMixin._initialize(self, root_path) + super(PureGitDB, self).__init__(self.objects_path()) diff --git a/gitdb/db/py/loose.py b/gitdb/db/py/loose.py index 16a3c4e..34e31da 100644 --- a/gitdb/db/py/loose.py +++ b/gitdb/db/py/loose.py @@ -3,9 +3,9 @@ # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php from base import ( - RootPathDBBase, - ObjectDBR, - ObjectDBW + PureRootPathDB, + PureObjectDBR, + PureObjectDBW ) @@ -57,10 +57,10 @@ import sys import os -__all__ = ( 'LooseObjectDB', ) +__all__ = ( 'PureLooseObjectODB', ) -class LooseObjectDB(RootPathDBBase, ObjectDBR, ObjectDBW): +class PureLooseObjectODB(PureRootPathDB, PureObjectDBR, PureObjectDBW): """A database which operates on loose object files""" # CONFIGURATION @@ -75,7 +75,7 @@ class LooseObjectDB(RootPathDBBase, ObjectDBR, ObjectDBW): def __init__(self, root_path): - super(LooseObjectDB, self).__init__(root_path) + super(PureLooseObjectODB, self).__init__(root_path) self._hexsha_to_file = dict() # Additional Flags - might be set to 0 after the first failure # Depending on the root, this might work for some mounts, for others not, which @@ -156,7 +156,7 @@ class LooseObjectDB(RootPathDBBase, ObjectDBR, ObjectDBW): """:raise TypeError: if the stream does not support the Sha1Writer interface""" if stream is not None and not isinstance(stream, Sha1Writer): raise TypeError("Output stream musst support the %s interface" % Sha1Writer.__name__) - return super(LooseObjectDB, self).set_ostream(stream) + return super(PureLooseObjectODB, self).set_ostream(stream) def info(self, sha): m = self._map_loose_object(sha) diff --git a/gitdb/db/py/mem.py b/gitdb/db/py/mem.py index 8012ad1..ba922e9 100644 --- a/gitdb/db/py/mem.py +++ b/gitdb/db/py/mem.py @@ -3,10 +3,10 @@ # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php """Contains the MemoryDatabase implementation""" -from loose import LooseObjectDB +from loose import PureLooseObjectODB from base import ( - ObjectDBR, - ObjectDBW + PureObjectDBR, + PureObjectDBW ) from gitdb.base import ( @@ -25,9 +25,9 @@ from gitdb.stream import ( from cStringIO import StringIO -__all__ = ("MemoryDB", ) +__all__ = ("PureMemoryDB", ) -class MemoryDB(ObjectDBR, ObjectDBW): +class PureMemoryDB(PureObjectDBR, PureObjectDBW): """A memory database stores everything to memory, providing fast IO and object retrieval. It should be used to buffer results and obtain SHAs before writing it to the actual physical storage, as it allows to query whether object already @@ -37,14 +37,14 @@ class MemoryDB(ObjectDBR, ObjectDBW): for storing""" def __init__(self): - super(MemoryDB, self).__init__() - self._db = LooseObjectDB("path/doesnt/matter") + super(PureMemoryDB, self).__init__() + self._db = PureLooseObjectODB("path/doesnt/matter") # maps 20 byte shas to their OStream objects self._cache = dict() def set_ostream(self, stream): - raise UnsupportedOperation("MemoryDB's always stream into memory") + raise UnsupportedOperation("PureMemoryDB's always stream into memory") def store(self, istream): zstream = ZippedStoreShaWriter() @@ -62,7 +62,7 @@ class MemoryDB(ObjectDBR, ObjectDBW): return istream def store_async(self, reader): - raise UnsupportedOperation("MemoryDBs cannot currently be used for async write access") + raise UnsupportedOperation("PureMemoryDBs cannot currently be used for async write access") def has_object(self, sha): return sha in self._cache diff --git a/gitdb/db/py/pack.py b/gitdb/db/py/pack.py index 53c912e..1d0e9bf 100644 --- a/gitdb/db/py/pack.py +++ b/gitdb/db/py/pack.py @@ -3,10 +3,10 @@ # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php """Module containing a database to deal with packs""" +from gitdb.db import CachingDB from base import ( - RootPathDBBase, - ObjectDBR, - CachingDB + PureRootPathDB, + PureObjectDBR ) from gitdb.util import LazyMixin @@ -22,12 +22,12 @@ from gitdb.pack import PackEntity import os import glob -__all__ = ('PackedDB', ) +__all__ = ('PurePackedODB', ) #{ Utilities -class PackedDB(RootPathDBBase, ObjectDBR, CachingDB, LazyMixin): +class PurePackedODB(PureRootPathDB, PureObjectDBR, CachingDB, LazyMixin): """A database operating on a set of object packs""" # the type to use when instantiating a pack entity @@ -39,7 +39,7 @@ class PackedDB(RootPathDBBase, ObjectDBR, CachingDB, LazyMixin): _sort_interval = 500 def __init__(self, root_path): - super(PackedDB, self).__init__(root_path) + super(PurePackedODB, self).__init__(root_path) # list of lists with three items: # * hits - number of times the pack was hit with a request # * entity - Pack entity instance @@ -127,7 +127,7 @@ class PackedDB(RootPathDBBase, ObjectDBR, CachingDB, LazyMixin): raise UnsupportedOperation() def store_async(self, reader): - # TODO: add ObjectDBRW before implementing this + # TODO: add PureObjectDBRW before implementing this raise NotImplementedError() #} END object db write diff --git a/gitdb/db/py/ref.py b/gitdb/db/py/ref.py index feb7fdc..5825d9e 100644 --- a/gitdb/db/py/ref.py +++ b/gitdb/db/py/ref.py @@ -2,14 +2,12 @@ # # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php -from base import ( - CompoundDB, - ) +from base import PureCompoundDB import os -__all__ = ('ReferenceDB', ) +__all__ = ('PureReferenceDB', ) -class ReferenceDB(CompoundDB): +class PureReferenceDB(PureCompoundDB): """A database consisting of database referred to in a file""" # Configuration @@ -18,7 +16,7 @@ class ReferenceDB(CompoundDB): ObjectDBCls = None def __init__(self, ref_file): - super(ReferenceDB, self).__init__() + super(PureReferenceDB, self).__init__() self._ref_file = ref_file def _set_cache_(self, attr): @@ -26,7 +24,7 @@ class ReferenceDB(CompoundDB): self._dbs = list() self._update_dbs_from_ref_file() else: - super(ReferenceDB, self)._set_cache_(attr) + super(PureReferenceDB, self)._set_cache_(attr) # END handle attrs def _update_dbs_from_ref_file(self): @@ -64,7 +62,7 @@ class ReferenceDB(CompoundDB): try: db = dbcls(path) # force an update to verify path - if isinstance(db, CompoundDB): + if isinstance(db, PureCompoundDB): db.databases() # END verification self._dbs.append(db) @@ -76,4 +74,4 @@ class ReferenceDB(CompoundDB): def update_cache(self, force=False): # re-read alternates and update databases self._update_dbs_from_ref_file() - return super(ReferenceDB, self).update_cache(force) + return super(PureReferenceDB, self).update_cache(force) diff --git a/gitdb/db/py/resolve.py b/gitdb/db/py/resolve.py index b3d6e4b..1e7aece 100644 --- a/gitdb/db/py/resolve.py +++ b/gitdb/db/py/resolve.py @@ -17,7 +17,7 @@ from string import digits import os import re -__all__ = ["NameResolvePureMixin"] +__all__ = ["PureReferencesMixin"] #{ Utilities |
