--- TracGit-0.11.0.2/tracext/git/PyGIT.py	2009-04-14 16:24:01.000000000 +0200
+++ TracGit-0.11.0.2-python2.4/tracext/git/PyGIT.py	2009-04-15 16:44:13.000000000 +0200
@@ -12,11 +12,8 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-from __future__ import with_statement
-
 import os, re, sys, time, weakref
 from collections import deque
-from functools import partial
 from threading import Lock
 from subprocess import Popen, PIPE
 import cStringIO
@@ -64,7 +61,7 @@
         return stdout_data
 
     def __getattr__(self, name):
-        return partial(self.__execute, name.replace('_','-'))
+        return lambda *args: self.__execute(name.replace('_','-'), *args)
 
     __is_sha_pat = re.compile(r'[0-9A-Fa-f]*$')
 
@@ -86,7 +83,8 @@
         self.__lock = Lock()
 
     def __setitem__(self, name, value):
-        with self.__lock:
+        self.__lock.acquire()
+        try:
             assert len(self) == len(self.__key_fifo) # invariant
 
             if not self.__contains__(name):
@@ -98,8 +96,9 @@
                 self.__delitem__(self.__key_fifo.popleft())
 
             assert len(self) == len(self.__key_fifo) # invariant
-
-            return rc
+        finally:
+            self.__lock.release()
+        return rc
 
     def setdefault(k,d=None):
         # TODO
@@ -113,7 +112,8 @@
     def __init__(self, repo, log, weak=True, git_bin='git'):
         self.logger = log
 
-        with StorageFactory.__dict_lock:
+        StorageFactory.__dict_lock.acquire()
+        try:
             try:
                 i = StorageFactory.__dict[repo]
             except KeyError:
@@ -128,6 +128,8 @@
                         pass
                 else:
                     StorageFactory.__dict_nonweak[repo] = i
+        finally:
+            StorageFactory.__dict_lock.release()
 
         self.__inst = i
         self.__repo = repo
@@ -183,12 +185,9 @@
         self.logger = log
 
         # simple sanity checking
-        __git_file_path = partial(os.path.join, git_dir)
-        if not all(map(os.path.exists,
-                       map(__git_file_path,
-                           ['HEAD','objects','refs']))):
+        if not os.path.exists(os.path.join(git_dir, 'HEAD')) or not os.path.exists(os.path.join(git_dir, 'objects')) or not os.path.exists(os.path.join(git_dir, 'refs')):
             self.logger.error("GIT control files missing in '%s'" % git_dir)
-            if os.path.exists(__git_file_path('.git')):
+            if os.path.exists(os.path.join(git_dir, '.git')):
                 self.logger.error("entry '.git' found in '%s'"
                                   " -- maybe use that folder instead..." % git_dir)
             raise GitError("GIT control files not found, maybe wrong directory?")
@@ -219,7 +218,8 @@
     # called by Storage.sync()
     def __rev_cache_sync(self, youngest_rev=None):
         "invalidates revision db cache if necessary"
-        with self.__rev_cache_lock:
+        self.__rev_cache_lock.acquire()
+        try:
             need_update = False
             if self.__rev_cache:
                 last_youngest_rev = self.__rev_cache[0]
@@ -231,11 +231,14 @@
 
             if need_update:
                 self.__rev_cache = None
+        finally:
+            self.__rev_cache_lock.release()
 
-            return need_update
+        return need_update
 
     def get_rev_cache(self):
-        with self.__rev_cache_lock:
+        self.__rev_cache_lock.acquire()
+        try:
             if self.__rev_cache is None: # can be cleared by Storage.__rev_cache_sync()
                 self.logger.debug("triggered rebuild of commit tree db for %d" % id(self))
                 new_db = {}
@@ -312,7 +315,9 @@
                 new_db = tmp
 
                 # convert sdb either to dict or array depending on size
-                tmp = [()]*(max(new_sdb.keys())+1) if len(new_sdb) > 5000 else {}
+                tmp =  {}
+                if len(new_sdb) > 5000:
+                    tmp = [()]*(max(new_sdb.keys())+1)
 
                 try:
                     while True:
@@ -328,9 +333,12 @@
                 self.__rev_cache = youngest, oldest, new_db, new_tags, new_sdb
                 self.logger.debug("rebuilt commit tree db for %d with %d entries" % (id(self),len(new_db)))
 
-            assert all(e is not None for e in self.__rev_cache) or not any(self.__rev_cache)
+            #assert all(e is not None for e in self.__rev_cache) or not any(self.__rev_cache)
+
+        finally:
+            self.__rev_cache_lock.release()
 
-            return self.__rev_cache
+        return self.__rev_cache
         # with self.__rev_cache_lock
 
     # tuple: youngest_rev, oldest_rev, rev_dict, tag_dict, short_rev_dict
@@ -512,7 +520,8 @@
             self.logger.info("read_commit failed for '%s'" % commit_id)
             raise GitErrorSha
 
-        with self.__commit_msg_lock:
+        self.__commit_msg_lock.acquire()
+        try:
             if self.__commit_msg_cache.has_key(commit_id):
                 # cache hit
                 result = self.__commit_msg_cache[commit_id]
@@ -537,7 +546,9 @@
 
             self.__commit_msg_cache[commit_id] = result
 
-            return result[0], dict(result[1])
+        finally:
+            self.__commit_msg_lock.release()
+        return result[0], dict(result[1])
 
     def get_file(self, sha):
         return cStringIO.StringIO(self.repo.cat_file("blob", str(sha)))
@@ -649,7 +660,11 @@
         diff_tree_args = ["-z", "-r"]
         if find_renames:
             diff_tree_args.append("-M")
-        diff_tree_args.extend([str(tree1) if tree1 else "--root",
+        if tree1:
+            arg1 = str(tree1)
+        else:
+            arg1 = "--root"
+        diff_tree_args.extend([arg1,
                                str(tree2),
                                "--", path])
 
@@ -806,7 +821,9 @@
         rev = g.head()
         for mode,type,sha,_size,name in g.ls_tree(rev):
             [last_rev] = g.history(rev, name, limit=1)
-            s = g.get_obj_size(sha) if type == "blob" else 0
+            s = 0
+            if type == "blob":
+                s = g.get_obj_size(sha)
             msg = g.read_commit(last_rev)
 
             print "%s %s %10d [%s]" % (type, last_rev, s, name)
--- TracGit-0.11.0.2/tracext/git/git_fs.py	2009-04-14 16:24:01.000000000 +0200
+++ TracGit-0.11.0.2-python2.4/tracext/git/git_fs.py	2009-04-15 16:33:50.000000000 +0200
@@ -33,8 +33,8 @@
 from datetime import datetime
 import time, sys
 
-if not sys.version_info[:2] >= (2,5):
-        raise TracError("python >= 2.5 dependancy not met")
+if not sys.version_info[:2] >= (2,4):
+        raise TracError("python >= 2.4 dependancy not met")
 
 import PyGIT
 
@@ -65,7 +65,7 @@
                 try:
                         self._version = PyGIT.Storage.git_version(git_bin=self._git_bin)
                 except PyGIT.GitError, e:
-                        self.log.error("GitError: "+e.message)
+                        self.log.error("GitError")
 
                 if self._version:
                         self.log.info("detected GIT version %s" % self._version['v_str'])
@@ -358,7 +358,11 @@
         def get_history(self, limit=None):
                 # TODO: find a way to follow renames/copies
                 for is_last,rev in _last_iterable(self.git.history(self.rev, self.__git_path(), limit)):
-                        yield (self.path, rev, Changeset.EDIT if not is_last else Changeset.ADD)
+                        if not is_last:
+                                op = Changeset.EDIT
+                        else:
+                                op = Changeset.ADD
+                        yield (self.path, rev, op)
 
         def get_last_modified(self):
                 if not self.isfile:
