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

[PATCH] add limit argument to svn_repos_history

From: Jens Peters <jpeters7677_at_gmx.de>
Date: 2007-07-13 15:24:51 CEST

Hello there,

Attached is a patch that teaches svn_repos_history to use a limit argument, equivalent to svn_repos_get_logs3. The reason why I would like to have
that functionality can be read here: http://viewvc.tigris.org/servlets/ReadMsg?list=dev&msgNo=2793. Any chance that this patch can made it into svn 1.5?

Any reviews, remarks are welcome of course.

Regards,
Jens

-----------------------------------------

[[[
Teach svn_repos_history to use a limit argument, equivalent to svn_repos_get_logs.

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

* subversion/libsvn_repos/rev_hunt.c (svn_repos_history3)
   New function, implement limit functionality over svn_repos_history2

* subversion/libsvn_repos/rev_hunt.c (svn_repos_history2)
   redirect to svn_repos_history3, limit is always 0

* subversion/svnlook/main.c
   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,
@@ -1041,8 +1063,8 @@
                     apr_pool_t *pool);

  /**
- * Similar to svn_repos_history2(), but with @a authz_read_func
- * and @a authz_read_baton always set to NULL.
+ * Same as svn_repos_history3(), but with @a limit always set to 0 and
+ * with @a authz_read_func and @a authz_read_baton always set to NULL.
   *
   * @deprecated Provided for backward compatibility with the 1.0 API.
   */
Index: subversion/libsvn_repos/rev_hunt.c
===================================================================
--- subversion/libsvn_repos/rev_hunt.c (revision 25731)
+++ subversion/libsvn_repos/rev_hunt.c (working copy)
@@ -192,7 +192,7 @@
  }

-
+/* Deprecated. */
  svn_error_t *
  svn_repos_history2(svn_fs_t *fs,
                     const char *path,
@@ -205,12 +205,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))
@@ -267,6 +288,11 @@
        if (history_rev < start)
          break;

+ /* If limit is set and we reaches limt, quit
+ here. */
+ if (limit && count >= limit)
+ break;
+
        /* Is the history item readable? If not, quit. */
        if (authz_read_func)
          {
@@ -290,6 +316,8 @@
        tmppool = oldpool;
        oldpool = newpool;
        newpool = tmppool;
+
+ count++;
      }
    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 Fri Jul 13 15:24:39 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.