diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-05-11 11:01:45 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-05-12 15:56:50 +0200 |
commit | 600fcbc1a2d723f8d51e5f5ab6d9e4c389010e1c (patch) | |
tree | 2be1a6f54390e18bc7b6c2318eae23e700c96df6 /lib/git | |
parent | 8caeec1b15645fa53ec5ddc6e990e7030ffb7c5a (diff) | |
download | gitpython-600fcbc1a2d723f8d51e5f5ab6d9e4c389010e1c.tar.gz |
Repo: Added comparison operators and hash operator including test
Cmd: AutoInterrupt handles boundary cases more gracefully as it can be that the os module suddenly becomes None if the interpreter is going down
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/cmd.py | 8 | ||||
-rw-r--r-- | lib/git/repo.py | 16 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py index 60912142..254b7dd3 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -63,8 +63,12 @@ class Git(object): def __del__(self): # did the process finish already so we have a return code ? if self.proc.poll() is not None: - return - + return + + # can be that nothing really exists anymore ... + if os is None: + return + # try to kill it try: os.kill(self.proc.pid, 2) # interrupt signal diff --git a/lib/git/repo.py b/lib/git/repo.py index 396dd129..f4caa3fb 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -131,6 +131,20 @@ class Repo(object): self.working_dir = self._working_tree_dir or self.git_dir self.git = Git(self.working_dir) + def __eq__(self, rhs): + if isinstance(rhs, Repo): + return self.git_dir == rhs.git_dir + return False + + def __ne__(self, rhs): + return not self.__eq__(rhs) + + def __hash__(self): + return hash(self.git_dir) + + def __repr__(self): + return "%s(%r)" % (type(self).__name__, self.git_dir) + # Description property def _get_description(self): filename = os.path.join(self.git_dir, 'description') @@ -145,6 +159,8 @@ class Repo(object): del _get_description del _set_description + + @property def working_tree_dir(self): """ |