diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-26 23:24:56 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-26 23:24:56 +0100 |
commit | 2792e534dd55fe03bca302f87a3ea638a7278bf1 (patch) | |
tree | 28d8f1cc81d8d121a9976204ee10be22996f6e2d /lib/git/cmd.py | |
parent | 1b89f39432cdb395f5fbb9553b56595d29e2b773 (diff) | |
parent | 0ef1f89abe5b2334705ee8f1a6da231b0b6c9a50 (diff) | |
download | gitpython-2792e534dd55fe03bca302f87a3ea638a7278bf1.tar.gz |
Merge branch 'index' into improvements
* index:
index.add: Finished implemenation including through tests
When parsing trees, we now store the originan type bits as well, previously we dropped it
cmd.wait: AutoKill wrapped process will automatically raise on errors to unify error handling amongst clients using the process directly. It might be needed to add a flag allowing to easily override that
added head kwarg to reset and commit method, allowing to automatically change the head to the given commit, which makes the methods more versatile
refs.SymoblicRef: implemented direcft setting of the symbolic references commit, which possibly dereferences to the respective head
index.commit: implemented initial version, but in fact some more changes are required to have a nice API. Tests are not yet fully done either
actor: added __eq__, __ne__ and __hash__ methods including simple test
index.remove implemented including throrough test
Implemented index.reset method including test
IndexEntry is now based on a 'minimal' version that is suitable to be fed into UpdateIndex. The Inode and device information is only needed to quickly compare the index against the working tree for changes, hence it should not be that dominant in the API either. More changes to come
Added notes about git-update-ref
Refs can now set the reference they are pointing to in a controlled fashion by writing their ref file directly
Added TagRefernce creation and deletion including tests
Implemented head methods: create, delete, rename, including tests
refs: added create, delete and rename methods where appropriate. Tests are marked, implementation is needed for most of them
Added frame for IndexFile add/remove/commit methods and respective test markers
Added repo.index property including simple test, and additional ideas in the TODO list
Renamed Index to IndexFile, adjusted tests, it will only operate on physical files, not on streams, as Indices are not streamed by any git command ( at least not in raw format )
Diffstat (limited to 'lib/git/cmd.py')
-rw-r--r-- | lib/git/cmd.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py index d674224c..4b4b84af 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -42,12 +42,16 @@ class Git(object): """ Kill/Interrupt the stored process instance once this instance goes out of scope. It is used to prevent processes piling up in case iterators stop reading. - Besides all attributes are wired through to the contained process object + Besides all attributes are wired through to the contained process object. + + The wait method was overridden to perform automatic status code checking + and possibly raise. """ - __slots__= "proc" + __slots__= ("proc", "args") - def __init__(self, proc ): + def __init__(self, proc, args ): self.proc = proc + self.args = args def __del__(self): # did the process finish already so we have a return code ? @@ -64,6 +68,20 @@ class Git(object): def __getattr__(self, attr): return getattr(self.proc, attr) + + def wait(self): + """ + Wait for the process and return its status code. + + Raise + GitCommandError if the return status is not 0 + """ + status = self.proc.wait() + if status != 0: + raise GitCommandError(self.args, status, self.proc.stderr.read()) + # END status handling + return status + def __init__(self, git_dir=None): @@ -184,7 +202,7 @@ class Git(object): **extra ) if as_process: - return self.AutoInterrupt(proc) + return self.AutoInterrupt(proc, command) # Wait for the process to return status = 0 |