summaryrefslogtreecommitdiff
path: root/git/db
diff options
context:
space:
mode:
Diffstat (limited to 'git/db')
-rw-r--r--git/db/cmd/base.py30
-rw-r--r--git/db/cmd/complex.py13
-rw-r--r--git/db/complex.py19
-rw-r--r--git/db/py/base.py9
-rw-r--r--git/db/py/complex.py16
-rw-r--r--git/db/py/resolve.py3
6 files changed, 50 insertions, 40 deletions
diff --git a/git/db/cmd/base.py b/git/db/cmd/base.py
index 6a2473a3..b3354b0a 100644
--- a/git/db/cmd/base.py
+++ b/git/db/cmd/base.py
@@ -13,16 +13,16 @@ from git.base import (
from git.util import (
bin_to_hex,
- hex_to_bin
- )
-from git.db.compat import RepoCompatibilityInterface
-from git.util import RemoteProgress
+ hex_to_bin,
+ RemoteProgress,
+ isfile,
+ join_path,
+ join,
+ Actor
+ )
from git.db.interface import FetchInfo as GitdbFetchInfo
from git.db.interface import PushInfo as GitdbPushInfo
from git.db.interface import HighLevelRepository
-
-from git.util import join_path
-from git.util import join
from git.cmd import Git
from git.refs import (
Reference,
@@ -30,8 +30,9 @@ from git.refs import (
SymbolicReference,
TagReference
)
-
+from git.objects.commit import Commit
import re
+import os
import sys
@@ -472,6 +473,11 @@ class CmdHighLevelRepository(HighLevelRepository):
re_author_committer_start = re.compile(r'^(author|committer)')
re_tab_full_line = re.compile(r'^\t(.*)$')
+ #{ Configuration
+ CommitCls = Commit
+ GitCls = Git
+ #} END configuration
+
def daemon_export():
def _get_daemon_export(self):
filename = join(self.git_dir, self.DAEMON_EXPORT_FILE)
@@ -588,7 +594,7 @@ class CmdHighLevelRepository(HighLevelRepository):
sha = info['id']
c = commits.get(sha)
if c is None:
- c = Commit( self, hex_to_bin(sha),
+ c = self.CommitCls( self, hex_to_bin(sha),
author=Actor._from_string(info['author'] + ' ' + info['author_email']),
authored_date=info['author_date'],
committer=Actor._from_string(info['committer'] + ' ' + info['committer_email']),
@@ -619,9 +625,9 @@ class CmdHighLevelRepository(HighLevelRepository):
os.makedirs(path, 0755)
# git command automatically chdir into the directory
- git = Git(path)
+ git = cls.GitCls(path)
output = git.init(**kwargs)
- return Repo(path)
+ return cls(path)
@classmethod
def _clone(cls, git, url, path, **kwargs):
@@ -686,7 +692,7 @@ class CmdHighLevelRepository(HighLevelRepository):
"""
:param kwargs: see the ``clone`` method
For more information, see the respective method in the HighLevelRepository"""
- return cls._clone(type(self.git)(os.getcwd()), url, to_path, **kwargs)
+ return cls._clone(cls.GitCls(os.getcwd()), url, to_path, **kwargs)
def archive(self, ostream, treeish=None, prefix=None, **kwargs):
"""For all args see HighLevelRepository interface
diff --git a/git/db/cmd/complex.py b/git/db/cmd/complex.py
index 3e6804f5..49e8c590 100644
--- a/git/db/cmd/complex.py
+++ b/git/db/cmd/complex.py
@@ -1,12 +1,10 @@
"""Module with our own git implementation - it uses the git command"""
from git.db.compat import RepoCompatibilityInterface
-from git.db.py.complex import PureGitDB
-
from base import *
-__all__ = ['GitCmdDB', 'CmdCompatibilityGitDB', 'CmdPartialGitDB']
+__all__ = ['CmdPartialGitDB']
class CmdPartialGitDB( GitCommandMixin, CmdObjectDBRMixin, CmdTransportMixin,
@@ -16,12 +14,3 @@ class CmdPartialGitDB( GitCommandMixin, CmdObjectDBRMixin, CmdTransportMixin,
implementations"""
pass
-
-class CmdGitDB(CmdPartialGitDB, PureGitDB):
- """A database which fills in its missing implementation using the pure python
- implementation"""
- pass
-
-
-class CmdCompatibilityGitDB(CmdGitDB, RepoCompatibilityInterface):
- """Command git database with the compatabilty interface added for 0.3x code"""
diff --git a/git/db/complex.py b/git/db/complex.py
index ef2013e3..71a39c45 100644
--- a/git/db/complex.py
+++ b/git/db/complex.py
@@ -1,12 +1,25 @@
"""Module with many useful complex databases with different useful combinations of primary implementations"""
-from py.complex import PureGitDB
+from py.complex import PurePartialGitDB
from cmd.complex import CmdPartialGitDB
from compat import RepoCompatibilityInterface
-__all__ = ['CmdPartialGitDB', 'PureGitDB', 'PureCmdGitDB']
+__all__ = ['CmdGitDB', 'PureGitDB', 'CmdCompatibilityGitDB', 'PureCompatibilityGitDB']
-class PureCmdGitDB(PureGitDB, CmdPartialGitDB, RepoCompatibilityInterface):
+class CmdGitDB(CmdPartialGitDB, PurePartialGitDB):
+ """A database which uses primarily the git command implementation, but falls back
+ to pure python where it is more feasible"""
+
+class CmdCompatibilityGitDB(RepoCompatibilityInterface, CmdGitDB):
+ """A database which fills in its missing implementation using the pure python
+ implementation"""
+ pass
+
+class PureGitDB(PurePartialGitDB, CmdPartialGitDB):
+ """A repository which uses the pure implementation primarily, but falls back
+ on using the git command for high-level functionality"""
+
+class PureCompatibilityGitDB(RepoCompatibilityInterface, PureGitDB):
"""Repository which uses the pure implementation primarily, but falls back
to the git command implementation. Please note that the CmdGitDB does it
the opposite way around."""
diff --git a/git/db/py/base.py b/git/db/py/base.py
index 74b8beb9..4d9b6e14 100644
--- a/git/db/py/base.py
+++ b/git/db/py/base.py
@@ -8,6 +8,7 @@ from git.db.interface import *
from git.util import (
pool,
join,
+ isfile,
normpath,
abspath,
dirname,
@@ -25,7 +26,8 @@ from git.config import GitConfigParser
from git.exc import (
BadObject,
AmbiguousObjectName,
- InvalidDBRoot
+ InvalidGitRepositoryError,
+ NoSuchPathError
)
from async import ChannelThreadTask
@@ -240,7 +242,7 @@ class PureRepositoryPathsMixin(RepositoryPathsMixin):
epath = abspath(expandvars(expanduser(path or os.getcwd())))
if not exists(epath):
- raise InvalidDBRoot(epath)
+ raise NoSuchPathError(epath)
#END check file
self._working_tree_dir = None
@@ -264,7 +266,7 @@ class PureRepositoryPathsMixin(RepositoryPathsMixin):
# END while curpath
if self._git_path is None:
- raise InvalidDBRoot(epath)
+ raise InvalidGitRepositoryError(epath)
# END path not found
self._bare = self._git_path.endswith(self.repo_dir)
@@ -351,6 +353,7 @@ class PureConfigurationMixin(ConfigurationMixin):
def __init__(self, *args, **kwargs):
"""Verify prereqs"""
+ super(PureConfigurationMixin, self).__init__(*args, **kwargs)
assert hasattr(self, 'git_dir')
def _path_at_level(self, level ):
diff --git a/git/db/py/complex.py b/git/db/py/complex.py
index 9d891537..a51118b3 100644
--- a/git/db/py/complex.py
+++ b/git/db/py/complex.py
@@ -1,6 +1,6 @@
# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
#
-# This module is part of PureGitDB and is released under
+# This module is part of PurePartialGitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
from git.db.interface import HighLevelRepository
from base import (
@@ -12,7 +12,7 @@ from base import (
PureAlternatesFileMixin,
PureIndexDB,
)
-
+from transport import PureTransportDB
from resolve import PureReferencesMixin
from loose import PureLooseObjectODB
@@ -35,14 +35,14 @@ from git.exc import (
)
import os
-__all__ = ('PureGitODB', 'PureGitDB', 'PureCompatibilityGitDB')
+__all__ = ('PureGitODB', 'PurePartialGitDB', 'PureCompatibilityGitDB')
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 PureGitDB type if you need
+ as it deals solely with object lookup. Use a PurePartialGitDB type if you need
reference and push support."""
# Configuration
PackDBCls = PurePackedODB
@@ -103,10 +103,10 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB):
-class PureGitDB(PureGitODB,
+class PurePartialGitDB(PureGitODB,
PureRepositoryPathsMixin, PureConfigurationMixin,
PureReferencesMixin, PureSubmoduleDB, PureAlternatesFileMixin,
- PureIndexDB,
+ PureIndexDB, PureTransportDB
# HighLevelRepository Currently not implemented !
):
"""Git like database with support for object lookup as well as reference resolution.
@@ -119,10 +119,10 @@ class PureGitDB(PureGitODB,
def __init__(self, root_path):
"""Initialize ourselves on the .git directory, or the .git/objects directory."""
PureRepositoryPathsMixin._initialize(self, root_path)
- super(PureGitDB, self).__init__(self.objects_dir)
+ super(PurePartialGitDB, self).__init__(self.objects_dir)
-class PureCompatibilityGitDB(PureGitDB, RepoCompatibilityInterface):
+class PureCompatibilityGitDB(PurePartialGitDB, RepoCompatibilityInterface):
"""Pure git database with a compatability layer required by 0.3x code"""
diff --git a/git/db/py/resolve.py b/git/db/py/resolve.py
index 7194149c..7bea779e 100644
--- a/git/db/py/resolve.py
+++ b/git/db/py/resolve.py
@@ -320,8 +320,7 @@ class PureReferencesMixin(ReferencesMixin):
return self.TagReferenceCls.list_items(self)
def tag(self, name):
- return self.tags[name]
-
+ return self.TagReferenceCls(self, self.TagReferenceCls.to_full_path(name))
def commit(self, rev=None):
if rev is None: