diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2011-07-07 14:53:37 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2011-07-07 17:30:47 +0200 |
commit | 4bb5107cff6f205f5c6e73a6f8bd22fc56f48cf4 (patch) | |
tree | 4164a8f9d4d3434d67dcaeb6e7ef60ae4bff81cd /git/db/py | |
parent | d5038ebadc190753c67c02c9f5930a14ca2dc1e7 (diff) | |
download | gitpython-4bb5107cff6f205f5c6e73a6f8bd22fc56f48cf4.tar.gz |
Initial version of the DulwichType inheritance. For now, it inherits everything from the existing implementation, but one by one things can be reimplmented to use dulwich.
It also shows that py 2.6 is quite plagued from its new feature, which is actually a bug, as objects inability to accept any args makes mixins hard to use ...
Diffstat (limited to 'git/db/py')
-rw-r--r-- | git/db/py/base.py | 19 | ||||
-rw-r--r-- | git/db/py/complex.py | 16 | ||||
-rw-r--r-- | git/db/py/resolve.py | 4 |
3 files changed, 17 insertions, 22 deletions
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 |