Re: [viewvc-dev] [PATCH] vclib change to limit results in subversion log retrieval

Michael Brailsford <[email protected]>
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Message-ID <[email protected]>
I did some additional testing and the previous patch was actually pretty crummy.  I added error handling and now correctly truncate the set *after* it is sorted, since history_set is apparently really a set and so I can't just grab the last X number of entries and expect sane results.  In addition, I added exception handling to handle boundary conditions.

--- viewvc_1_0_4/lib/vclib/svn/__init__.py    2007-11-29 16:46:29.000000000 -0600
+++ viewvc/lib/vclib/svn/__init__.py    2007-12-03 11:27:43.000000000 -0600
@@ -363,10 +363,20 @@
     if rev:
       revs.append(rev)
   else:
-    history_set = _get_history(svnrepos, full_name, which_rev, options)
-    history_revs = history_set.keys()
-    history_revs.sort()
-    history_revs.reverse()
+    # try to get the history
+    try:
+        history_set = _get_history(svnrepos, full_name, which_rev, options)
+    except (core.SubversionException, e):
+        return []
+
+    nrevs = int(options.get('num_revs'))
+    if nrevs <= 0:
+        history_revs = []
+    else:
+        history_revs = history_set.keys()
+        history_revs.sort()
+        history_revs = history_revs[-nrevs:len(history_revs)]
+        history_revs.reverse()
     subpool = core.svn_pool_create(pool)
     for history_rev in history_revs:
       core.svn_pool_clear(subpool)
@@ -649,7 +659,10 @@
         entry
     """
     path = self._getpath(path_parts)
-    rev = self._getrev(rev)
+    try:
+        rev = self._getrev(rev)
+    except (vclib.InvalidRevision):
+        return []
 
     revs = _fetch_log(self, path, rev, options, self.scratch_pool)
     self._scratch_clear()

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.