[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: [PATCH] add limit argument to svn_repos_history

From: Jens Peters <jpeters7677_at_gmx.de>
Date: 2007-07-14 07:39:34 CEST

>Seems useful in general, though! Even if you do go with Mike's
>suggestion to make the callback say whether or not it should continue,
>a "limit" argument is often helpful (I think SVK would use it), and so
>if you go down Mike's path adding a function which takes a log
>callback and a limit integer and returns a new log callback which does
>the limit logic for you would be nice.
>
>--dave

Thank you for your quick review, I took your suggestions and attached a new
version. Implementing the ability to cancel through the callbacks reads
indeed quite elegant, I will give it a try.. (and sorry for the spelling
issues..)

Jens

[[[
Add a limit argument to svn_repos_history, equivalent to svn_repos_get_logs.

* subversion/include/svn_repos.h
  Add svn_repos_history3 and deprecate svn_repos_history2.

* subversion/libsvn_repos/rev_hunt.c
  (svn_repos_history3): New function, implement limit functionality over
svn_repos_history2.
  (svn_repos_history2): Redirect to svn_repos_history3, limit is always 0.

* subversion/svnlook/main.c
  (do_history): Let svnlook use svn_repos_history3. However, limit is always
0,
  so actually no output changes.
]]]

Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 25731)
+++ subversion/include/svn_repos.h (working copy)
@@ -1026,9 +1026,31 @@
  * them; instead, immediately stop traversing history and return
  * SVN_NO_ERROR.
  *
- * @since New in 1.1.
+ * If @a limit is non-zero then only invoke @a history_func on the first
+ * @a limit locations.
+ *
+ * @since New in 1.5.
  */
 svn_error_t *
+svn_repos_history3(svn_fs_t *fs,
+ const char *path,
+ svn_repos_history_func_t history_func,
+ void *history_baton,
+ svn_repos_authz_func_t authz_read_func,
+ void *authz_read_baton,
+ svn_revnum_t start,
+ svn_revnum_t end,
+ int limit,
+ svn_boolean_t cross_copies,
+ apr_pool_t *pool);
+
+
+/**
+ * Same as svn_repos_history3(), but with @a limit always set to 0.
+ *
+ * @deprecated Provided for backward compatibility with the 1.1 API.
+ */
+svn_error_t *
 svn_repos_history2(svn_fs_t *fs,
                    const char *path,
                    svn_repos_history_func_t history_func,
Index: subversion/libsvn_repos/rev_hunt.c
===================================================================
--- subversion/libsvn_repos/rev_hunt.c (revision 25731)
+++ subversion/libsvn_repos/rev_hunt.c (working copy)
@@ -193,6 +193,7 @@
 
 
 
+/* Deprecated. */
 svn_error_t *
 svn_repos_history2(svn_fs_t *fs,
                    const char *path,
@@ -205,12 +206,33 @@
                    svn_boolean_t cross_copies,
                    apr_pool_t *pool)
 {
+ return svn_repos_history3(fs, path, history_func, history_baton,
+ authz_read_func, authz_read_baton,
+ start, end, 0, cross_copies, pool);
+}
+
+
+
+svn_error_t *
+svn_repos_history3(svn_fs_t *fs,
+ const char *path,
+ svn_repos_history_func_t history_func,
+ void *history_baton,
+ svn_repos_authz_func_t authz_read_func,
+ void *authz_read_baton,
+ svn_revnum_t start,
+ svn_revnum_t end,
+ int limit,
+ svn_boolean_t cross_copies,
+ apr_pool_t *pool)
+{
   svn_fs_history_t *history;
   apr_pool_t *oldpool = svn_pool_create(pool);
   apr_pool_t *newpool = svn_pool_create(pool);
   const char *history_path;
   svn_revnum_t history_rev;
   svn_fs_root_t *root;
+ int count = 0;
 
   /* Validate the revisions. */
   if (! SVN_IS_VALID_REVNUM(start))
@@ -290,6 +312,12 @@
       tmppool = oldpool;
       oldpool = newpool;
       newpool = tmppool;
+
+ count++;
+ /* If limit is set and we reach limit, quit
+ here. */
+ if (limit && count >= limit)
+ break;
     }
   while (history); /* shouldn't hit this */
 
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 25731)
+++ subversion/svnlook/main.c (working copy)
@@ -1390,8 +1390,8 @@
      copies. */
   args.fs = c->fs;
   args.show_ids = show_ids;
- SVN_ERR(svn_repos_history2(c->fs, path, print_history, &args,
- NULL, NULL, 0, c->rev_id, 1, pool));
+ SVN_ERR(svn_repos_history3(c->fs, path, print_history, &args,
+ NULL, NULL, 0, c->rev_id, 0, 1, pool));
   return SVN_NO_ERROR;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jul 14 07:39:00 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.