summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/db/compat.py24
-rw-r--r--git/db/dulwich/base.py6
-rw-r--r--git/db/dulwich/complex.py59
-rw-r--r--git/db/interface.py12
-rw-r--r--git/db/py/base.py19
-rw-r--r--git/db/py/complex.py16
-rw-r--r--git/db/py/resolve.py4
-rw-r--r--git/test/db/base.py6
-rw-r--r--git/test/db/dulwich/lib.py7
-rw-r--r--git/test/db/dulwich/test_base.py22
-rw-r--r--git/test/test_remote.py8
11 files changed, 133 insertions, 50 deletions
diff --git a/git/db/compat.py b/git/db/compat.py
index 767ab5e0..771a1e77 100644
--- a/git/db/compat.py
+++ b/git/db/compat.py
@@ -4,14 +4,10 @@
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Module providing adaptors to maintain backwards compatability"""
-class RepoCompatibilityInterface(object):
+class RepoCompatibilityInterfaceNoBare(object):
"""Interface to install backwards compatability of the new complex repository
types with the previous, all in one, repository."""
- @property
- def bare(self):
- return self.is_bare
-
def rev_parse(self, *args, **kwargs):
return self.resolve_object(*args, **kwargs)
@@ -28,4 +24,22 @@ class RepoCompatibilityInterface(object):
return self.head.reference
def __repr__(self):
+ """Return the representation of the repository, the way it used to be"""
return '<git.Repo "%s">' % self.git_dir
+
+ @property
+ def branches(self):
+ return self.heads
+
+
+class RepoCompatibilityInterface(RepoCompatibilityInterfaceNoBare):
+ """Interface to install backwards compatability of the new complex repository
+ types with the previous, all in one, repository."""
+
+ @property
+ def bare(self):
+ return self.is_bare
+
+ @property
+ def refs(self):
+ return self.references
diff --git a/git/db/dulwich/base.py b/git/db/dulwich/base.py
deleted file mode 100644
index cd1d71c8..00000000
--- a/git/db/dulwich/base.py
+++ /dev/null
@@ -1,6 +0,0 @@
-"""Module with some basic database implementations"""
-
-
-__all__ = []
-
-
diff --git a/git/db/dulwich/complex.py b/git/db/dulwich/complex.py
new file mode 100644
index 00000000..6c3645a4
--- /dev/null
+++ b/git/db/dulwich/complex.py
@@ -0,0 +1,59 @@
+
+__all__ = ['DulwichGitODB', 'DulwichGitDB', 'DulwichCompatibilityGitDB']
+
+from git.db.py.complex import PureGitODB
+from git.db.py.base import (
+ PureRepositoryPathsMixin,
+ PureConfigurationMixin,
+ PureIndexDB,
+ )
+from git.db.py.resolve import PureReferencesMixin
+from git.db.py.transport import PureTransportDB
+from git.db.py.submodule import PureSubmoduleDB
+
+from git.db.cmd.complex import CmdHighLevelRepository, GitCommandMixin
+from git.db.compat import RepoCompatibilityInterfaceNoBare
+
+#from git.db.interface import ObjectDBW, ObjectDBR
+from dulwich.repo import Repo as DulwichRepo
+
+import os
+
+
+class DulwichGitODB(PureGitODB):
+ """A full fledged database to read and write object files from all kinds of sources."""
+
+ def __init__(self, objects_root):
+ """Initalize this instance"""
+ PureGitODB.__init__(self, objects_root)
+ self._dw_repo = DulwichRepo(self.working_dir)
+
+ def __getattr__(self, attr):
+ try:
+ # supply LazyMixin with this call first
+ return super(DulwichGitODB, self).__getattr__(attr)
+ except AttributeError:
+ # now assume its on the dulwich repository ... for now
+ return getattr(self._dw_repo, attr)
+ #END handle attr
+
+
+class DulwichGitDB( PureRepositoryPathsMixin, PureConfigurationMixin,
+ PureReferencesMixin, PureSubmoduleDB,
+ PureIndexDB,
+ PureTransportDB, # not fully implemented
+ GitCommandMixin,
+ CmdHighLevelRepository,
+ DulwichGitODB): # must come last, as it doesn't pass on __init__ with super
+
+
+ def __init__(self, root_path):
+ """Initialize ourselves on the .git directory, or the .git/objects directory."""
+ PureRepositoryPathsMixin._initialize(self, root_path)
+ super(DulwichGitDB, self).__init__(self.objects_dir)
+
+
+class DulwichCompatibilityGitDB(RepoCompatibilityInterfaceNoBare, DulwichGitDB):
+ """Basic dulwich compatibility database"""
+ pass
+
diff --git a/git/db/interface.py b/git/db/interface.py
index 803f7769..9ad74cc1 100644
--- a/git/db/interface.py
+++ b/git/db/interface.py
@@ -561,16 +561,8 @@ class ReferencesMixin(object):
raise NotImplementedError()
#}END edit methods
-
- #{ Backward Compatability
- # These aliases need to be provided by the implementing interface as well
- refs = references
- branches = heads
- #} END backward compatability
-
-
-
-
+
+
class RepositoryPathsMixin(object):
"""Represents basic functionality of a full git repository. This involves an
optional working tree, a git directory with references and an object directory.
diff --git a/git/db/py/base.py b/git/db/py/base.py
index 2c21c136..fb6e2f4a 100644
--- a/git/db/py/base.py
+++ b/git/db/py/base.py
@@ -104,7 +104,6 @@ class PureRootPathDB(RootPathDB):
super(PureRootPathDB, self).__init__(root_path)
-
#{ Interface
def root_path(self):
return self._root_path
@@ -233,7 +232,7 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB):
class PureRepositoryPathsMixin(RepositoryPathsMixin):
# slots has no effect here, its just to keep track of used attrs
- __slots__ = ("_git_path", '_bare')
+ __slots__ = ("_git_path", '_bare', '_working_tree_dir')
#{ Configuration
repo_dir = '.git'
@@ -272,14 +271,16 @@ class PureRepositoryPathsMixin(RepositoryPathsMixin):
raise InvalidGitRepositoryError(epath)
# END path not found
- self._bare = self._git_path.endswith(self.repo_dir)
+ self._bare = self._working_tree_dir is None
if hasattr(self, 'config_reader'):
try:
self._bare = self.config_reader("repository").getboolean('core','bare')
except Exception:
# lets not assume the option exists, although it should
pass
+ #END handle exception
#END check bare flag
+ self._working_tree_dir = self._bare and None or self._working_tree_dir
#} end subclass interface
@@ -313,7 +314,7 @@ class PureRepositoryPathsMixin(RepositoryPathsMixin):
@property
def working_tree_dir(self):
- if self.is_bare:
+ if self._working_tree_dir is None:
raise AssertionError("Repository at %s is bare and does not have a working tree directory" % self.git_dir)
#END assertion
return dirname(self.git_dir)
@@ -354,6 +355,10 @@ class PureConfigurationMixin(ConfigurationMixin):
repo_config_file_name = "config"
#} END
+ def __new__(cls, *args, **kwargs):
+ """This is just a stupid workaround for the evil py2.6 change which makes mixins quite impossible"""
+ return super(PureConfigurationMixin, cls).__new__(cls, *args, **kwargs)
+
def __init__(self, *args, **kwargs):
"""Verify prereqs"""
try:
@@ -421,7 +426,11 @@ class PureAlternatesFileMixin(object):
#} END configuration
def __init__(self, *args, **kwargs):
- super(PureAlternatesFileMixin, self).__init__(*args, **kwargs)
+ try:
+ super(PureAlternatesFileMixin, self).__init__(*args, **kwargs)
+ except TypeError:
+ pass
+ #END handle py2.6 code breaking changes
self._alternates_path() # throws on incompatible type
#{ Interface
diff --git a/git/db/py/complex.py b/git/db/py/complex.py
index d5c185f3..5f4e81e0 100644
--- a/git/db/py/complex.py
+++ b/git/db/py/complex.py
@@ -22,17 +22,7 @@ from submodule import PureSubmoduleDB
from git.db.compat import RepoCompatibilityInterface
-from git.util import (
- LazyMixin,
- normpath,
- join,
- dirname
- )
-from git.exc import (
- InvalidDBRoot,
- BadObject,
- AmbiguousObjectName
- )
+from git.exc import InvalidDBRoot
import os
__all__ = ('PureGitODB', 'PurePartialGitDB', 'PureCompatibilityGitDB')
@@ -106,7 +96,8 @@ class PureGitODB(PureRootPathDB, PureObjectDBW, PureCompoundDB, PureAlternatesFi
class PurePartialGitDB(PureGitODB,
PureRepositoryPathsMixin, PureConfigurationMixin,
PureReferencesMixin, PureSubmoduleDB,
- PureIndexDB, PureTransportDB
+ PureIndexDB,
+ PureTransportDB # not fully implemented
# HighLevelRepository Currently not implemented !
):
"""Git like database with support for object lookup as well as reference resolution.
@@ -122,7 +113,6 @@ class PurePartialGitDB(PureGitODB,
super(PurePartialGitDB, self).__init__(self.objects_dir)
-
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 7bea779e..9a31fbd8 100644
--- a/git/db/py/resolve.py
+++ b/git/db/py/resolve.py
@@ -361,7 +361,3 @@ class PureReferencesMixin(ReferencesMixin):
def delete_tag(self, *tags):
return self.TagReferenceCls.delete(self, *tags)
-
- # compat
- branches = heads
- refs = references
diff --git a/git/test/db/base.py b/git/test/db/base.py
index 5291ba03..7016afb7 100644
--- a/git/test/db/base.py
+++ b/git/test/db/base.py
@@ -613,8 +613,14 @@ class RepoBase(TestDBBase):
def test_submodule_update(self, rwrepo):
# fails in bare mode
rwrepo._bare = True
+ # special handling: there are repo implementations which have a bare attribute. IN that case, set it directly
+ if not rwrepo.bare:
+ rwrepo.bare = True
self.failUnlessRaises(InvalidGitRepositoryError, rwrepo.submodule_update)
rwrepo._bare = False
+ if rwrepo.bare:
+ rwrepo.bare = False
+ #END special repo handling
# test create submodule
sm = rwrepo.submodules[0]
diff --git a/git/test/db/dulwich/lib.py b/git/test/db/dulwich/lib.py
index a1110ffa..56734064 100644
--- a/git/test/db/dulwich/lib.py
+++ b/git/test/db/dulwich/lib.py
@@ -1,6 +1,11 @@
"""dulwich specific utilities, as well as all the default ones"""
-from git.test.lib import *
+from git.test.lib import (
+ InheritedTestMethodsOverrideWrapperMetaClsAutoMixin,
+ needs_module_or_skip
+ )
+
+__all__ = ['needs_dulwich_or_skip', 'DulwichRequiredMetaMixin']
#{ Decoorators
diff --git a/git/test/db/dulwich/test_base.py b/git/test/db/dulwich/test_base.py
index 9bc9c394..50e64131 100644
--- a/git/test/db/dulwich/test_base.py
+++ b/git/test/db/dulwich/test_base.py
@@ -3,21 +3,31 @@
# This module is part of GitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
from lib import *
+from git.test.lib import TestBase, with_rw_repo
from git.test.db.base import RepoBase
-from git.db.complex import PureCompatibilityGitDB
+
+
try:
import dulwich
except ImportError:
# om this case, all other dulwich tests will be skipped
- pass
+ # Need to properly initialize the class though, otherwise it would fail
+ from git.db.complex import PureCompatibilityGitDB as DulwichDB
+else:
+ # now we know dulwich is available, to do futher imports
+ from git.db.dulwich.complex import DulwichCompatibilityGitDB as DulwichDB
+
+#END handle imports
class TestPyDBBase(RepoBase):
__metaclass__ = DulwichRequiredMetaMixin
- RepoCls = PureCompatibilityGitDB
+ RepoCls = DulwichDB
@needs_dulwich_or_skip
- def test_basics(self):
- import dulwich
- pass
+ @with_rw_repo('HEAD', bare=False)
+ def test_basics(self, rw_repo):
+ db = DulwichDB(rw_repo.working_tree_dir)
+ print db.git_dir
+
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index cef8687b..30bd1232 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -21,6 +21,8 @@ from git.refs import (
SymbolicReference
)
+from nose import SkipTest
+
import tempfile
import shutil
import os
@@ -352,7 +354,13 @@ class TestRemote(TestBase):
# the same repository
TagReference.delete(rw_repo, new_tag, other_tag)
remote.push(":%s" % other_tag.path)
+
+ def test_todo(self):
+ # If you see this, plesase remind yourself, that all this needs to be run
+ # per repository type !
+ raise SkipTest("todo")
+
@with_rw_and_rw_remote_repo('0.1.6')
def test_base(self, rw_repo, remote_repo):
num_remotes = 0