From 4177eefd7bdaea96a529b00ba9cf751924ede202 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 19:43:22 +0200 Subject: Added all code from gitdb to gitpython. Next is to make it generally work. Then the tests will need some work --- git/exc.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'git/exc.py') diff --git a/git/exc.py b/git/exc.py index d2cb8d7e..3c69067c 100644 --- a/git/exc.py +++ b/git/exc.py @@ -5,7 +5,40 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all exceptions thrown througout the git package, """ -from gitdb.exc import * +from util import to_hex_sha + +class ODBError(Exception): + """All errors thrown by the object database""" + + +class InvalidDBRoot(ODBError): + """Thrown if an object database cannot be initialized at the given path""" + + +class BadObject(ODBError): + """The object with the given SHA does not exist. Instantiate with the + failed sha""" + + def __str__(self): + return "BadObject: %s" % to_hex_sha(self.args[0]) + + +class ParseError(ODBError): + """Thrown if the parsing of a file failed due to an invalid format""" + + +class AmbiguousObjectName(ODBError): + """Thrown if a possibly shortened name does not uniquely represent a single object + in the database""" + + +class BadObjectType(ODBError): + """The object had an unsupported type""" + + +class UnsupportedOperation(ODBError): + """Thrown if the given operation cannot be supported by the object database""" + class InvalidGitRepositoryError(Exception): """ Thrown if the given repository appears to have an invalid format. """ @@ -53,6 +86,7 @@ class CheckoutError( Exception ): class CacheError(Exception): """Base for all errors related to the git index, which is called cache internally""" + class UnmergedEntriesError(CacheError): """Thrown if an operation cannot proceed as there are still unmerged entries in the cache""" -- cgit v1.2.3 From 024adf37acddd6a5d8293b6b5d15795c59a142c0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 13:06:37 +0200 Subject: Fixed tests far enough to allow basic repository tests to be applied to any of the new database types. This reduces code duplication to the mere minimum, but allows custom tests to be added on top easily and flexibly --- git/exc.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'git/exc.py') diff --git a/git/exc.py b/git/exc.py index 3c69067c..412f82f0 100644 --- a/git/exc.py +++ b/git/exc.py @@ -7,7 +7,10 @@ from util import to_hex_sha -class ODBError(Exception): +class GitPythonError(Exception): + """Base exception for all git-python related errors""" + +class ODBError(GitPythonError): """All errors thrown by the object database""" @@ -40,15 +43,15 @@ class UnsupportedOperation(ODBError): """Thrown if the given operation cannot be supported by the object database""" -class InvalidGitRepositoryError(Exception): +class InvalidGitRepositoryError(GitPythonError): """ Thrown if the given repository appears to have an invalid format. """ -class NoSuchPathError(OSError): +class NoSuchPathError(GitPythonError): """ Thrown if a path could not be access by the system. """ -class GitCommandError(Exception): +class GitCommandError(GitPythonError): """ Thrown if execution of the git command fails with non-zero status code. """ def __init__(self, command, status, stderr=None): self.stderr = stderr @@ -60,7 +63,7 @@ class GitCommandError(Exception): (' '.join(str(i) for i in self.command), self.status, self.stderr)) -class CheckoutError( Exception ): +class CheckoutError(GitPythonError): """Thrown if a file could not be checked out from the index as it contained changes. @@ -83,7 +86,7 @@ class CheckoutError( Exception ): return Exception.__str__(self) + ":%s" % self.failed_files -class CacheError(Exception): +class CacheError(GitPythonError): """Base for all errors related to the git index, which is called cache internally""" -- cgit v1.2.3 From 1f71ed94578799ee1667ba54b66a369e307f415b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 16:32:56 +0200 Subject: git cmd implementation of repository appears to work, at least this is what the test suggests. Pure python implementation still has some trouble, but this should be very fixable --- git/exc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/exc.py') diff --git a/git/exc.py b/git/exc.py index 412f82f0..e14fb7f1 100644 --- a/git/exc.py +++ b/git/exc.py @@ -43,11 +43,11 @@ class UnsupportedOperation(ODBError): """Thrown if the given operation cannot be supported by the object database""" -class InvalidGitRepositoryError(GitPythonError): +class InvalidGitRepositoryError(InvalidDBRoot): """ Thrown if the given repository appears to have an invalid format. """ -class NoSuchPathError(GitPythonError): +class NoSuchPathError(InvalidDBRoot): """ Thrown if a path could not be access by the system. """ -- cgit v1.2.3