Commits

Anonymous committed 831307f

Ported [2978] to 0.9-stable ''(lessen path_history memory usage)''

Comments (0)

Files changed (1)

trac/versioncontrol/svn_fs.py

         return SubversionNode(path, rev, self.authz, self.scope, self.fs_ptr,
                               self.pool)
 
+    def _history(self, path, start, end, limit=None, pool=None):
+        scoped_path = posixpath.join(self.scope[1:], path)
+        return _get_history(scoped_path, self.authz, self.fs_ptr,
+                            pool or self.pool, start, end, limit)
+
+    def _previous_rev(self, rev, path='', pool=None):
+        if rev > 1: # don't use oldest here, as it's too expensive
+            try:
+                for _, prev in self._history(path, 0, rev-1, limit=1,
+                                             pool=pool):
+                    return prev
+            except (SystemError, # "null arg to internal routine" in 1.2.x
+                    core.SubversionException): # in 1.3.x
+                pass
+        return None
+    
+
     def get_oldest_rev(self):
         rev = 0
         if self.scope == '/':
                 for p, r in _get_history(self.scope + path, self.authz,
                                          self.fs_ptr, subpool, 0, rev, limit):
                     older = (_scoped_path(self.scope, p), r, Changeset.ADD)
-                    rev = self.previous_rev(r)
+                    rev = self._previous_rev(r, pool=subpool)
                     if newer:
                         if older[0] == path:
                             # still on the path: 'newer' was an edit
                             yield newer[0], newer[1], Changeset.EDIT
                         else:
                             # the path changed: 'newer' was a copy
-                            rev = self.previous_rev(newer[1])
+                            rev = self._previous_rev(newer[1], pool=subpool)
                             # restart before the copy op
                             yield newer[0], newer[1], Changeset.COPY
                             older = (older[0], older[1], 'unknown')
                     yield older
             else:
                 expect_deletion = True
-                rev = self.previous_rev(rev)
+                rev = self._previous_rev(rev, pool=subpool)
 
 
 class SubversionNode(Node):