summaryrefslogtreecommitdiff
path: root/git/db/py/complex.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-05-29 21:59:12 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-05-29 21:59:12 +0200
commit0996049122842a343e0ea7fbbecafddb2b4ba9d3 (patch)
treecaf5682e79d1317cd29d9bbab965cf932a1b67ff /git/db/py/complex.py
parentcd26aaebbda94dc3740e41bbd3f91ba6b1a25c10 (diff)
downloadgitpython-0996049122842a343e0ea7fbbecafddb2b4ba9d3.tar.gz
Intermediate commit with quite some progress in order to put all extra methods on the default Repo implementation into interfaces or something that can be abstracted. It shows that it would indeed be good to keep the differentiation between Repositories which contain an object database as it is clearly easier to setup any combination of repositories that use git and those that do not, with just the addition of one more level of indirection. Lets see how it will end up
Diffstat (limited to 'git/db/py/complex.py')
-rw-r--r--git/db/py/complex.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/git/db/py/complex.py b/git/db/py/complex.py
index de68d4fd..6504b3ed 100644
--- a/git/db/py/complex.py
+++ b/git/db/py/complex.py
@@ -8,6 +8,7 @@ from base import (
PureRootPathDB,
PureRepositoryPathsMixin,
PureConfigurationMixin,
+ PureAlternatesFileMixin,
)
from resolve import PureReferencesMixin
@@ -17,6 +18,8 @@ from pack import PurePackedODB
from ref import PureReferenceDB
from submodule import PureSubmoduleDB
+from git.db.compat import RepoCompatInterface
+
from git.util import (
LazyMixin,
normpath,
@@ -30,10 +33,11 @@ from git.exc import (
)
import os
-__all__ = ('PureGitODB', 'PureGitDB')
+__all__ = ('PureGitODB', 'PureGitDB', 'PureCompatibilityGitDB')
-class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureSubmoduleDB):
+class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB,
+ PureSubmoduleDB, PureAlternatesFileMixin):
"""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,
@@ -47,7 +51,7 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureSubmoduleDB)
# Directories
packs_dir = 'pack'
loose_dir = ''
- alternates_dir = os.path.join('info', 'alternates')
+
def __init__(self, root_path):
"""Initialize ourselves on a git ./objects directory"""
@@ -59,7 +63,7 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureSubmoduleDB)
loose_db = None
for subpath, dbcls in ((self.packs_dir, self.PackDBCls),
(self.loose_dir, self.LooseDBCls),
- (self.alternates_dir, self.PureReferenceDBCls)):
+ (self.alternates_filepath, self.PureReferenceDBCls)):
path = self.db_path(subpath)
if os.path.exists(path):
self._dbs.append(dbcls(path))
@@ -75,7 +79,7 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureSubmoduleDB)
# END handle error
# we the first one should have the store method
- assert loose_db is not None and hasattr(loose_db, 'store'), "First database needs store functionality"
+ assert loose_db is not None and hasattr(loose_db, 'store'), "One database needs store functionality"
# finally set the value
self._loose_db = loose_db
@@ -97,6 +101,7 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureSubmoduleDB)
#} END objectdbw interface
+
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).
@@ -112,3 +117,6 @@ class PureGitDB(PureGitODB, PureRepositoryPathsMixin, PureConfigurationMixin, Pu
+class PureCompatibilityGitDB(PureGitDB, RepoCompatInterface):
+ """Pure git database with a compatability layer required by 0.3x code"""
+