subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1570294 - in /subversion/trunk/subversion: include/private/svn_fs_private.h libsvn_fs/fs-loader.c libsvn_repos/log.c libsvn_repos/rev_hunt.c
Date Thu, 20 Feb 2014 18:21:20 GMT
Author: julianfoad
Date: Thu Feb 20 18:21:20 2014
New Revision: 1570294

URL: http://svn.apache.org/r1570294
Log:
Factor out some repeated code.

* subversion/include/private/svn_fs_private.h,
  subversion/libsvn_fs/fs-loader.c
  (svn_fs__get_mergeinfo_for_path): New, semi-public and modified version of
    a function that was in rev_hunt.c.

* subversion/libsvn_repos/log.c
  (fs_mergeinfo_changed,
   get_combined_mergeinfo_changes): Use it to simplify code.

* subversion/libsvn_repos/rev_hunt.c
  (get_path_mergeinfo): Delete this version of the repeated code.
  (get_merged_mergeinfo): Adjust to use the new version.

Modified:
    subversion/trunk/subversion/include/private/svn_fs_private.h
    subversion/trunk/subversion/libsvn_fs/fs-loader.c
    subversion/trunk/subversion/libsvn_repos/log.c
    subversion/trunk/subversion/libsvn_repos/rev_hunt.c

Modified: subversion/trunk/subversion/include/private/svn_fs_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_fs_private.h?rev=1570294&r1=1570293&r2=1570294&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_fs_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_fs_private.h Thu Feb 20 18:21:20 2014
@@ -179,6 +179,23 @@ svn_fs__editor_commit(svn_revnum_t *revi
                       apr_pool_t *scratch_pool);
 
 
+/** Set @a *mergeinfo to the mergeinfo for @a path in @a root.
+ *
+ * If there is no mergeinfo, set @a *mergeinfo to NULL.
+ *
+ * See svn_fs_get_mergeinfo2() but for the meanings of @a inherit and
+ * @a adjust_inheritable_mergeinfo and other details.
+ */
+svn_error_t *
+svn_fs__get_mergeinfo_for_path(svn_mergeinfo_t *mergeinfo,
+                               svn_fs_root_t *root,
+                               const char *path,
+                               svn_mergeinfo_inheritance_t inherit,
+                               svn_boolean_t adjust_inherited_mergeinfo,
+                               apr_pool_t *result_pool,
+                               apr_pool_t *scratch_pool);
+
+
 /** @} */
 
 

Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1570294&r1=1570293&r2=1570294&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Thu Feb 20 18:21:20 2014
@@ -1223,6 +1223,30 @@ svn_fs_get_mergeinfo(svn_mergeinfo_catal
 }
 
 svn_error_t *
+svn_fs__get_mergeinfo_for_path(svn_mergeinfo_t *mergeinfo,
+                               svn_fs_root_t *root,
+                               const char *path,
+                               svn_mergeinfo_inheritance_t inherit,
+                               svn_boolean_t adjust_inherited_mergeinfo,
+                               apr_pool_t *result_pool,
+                               apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *paths
+    = apr_array_make(scratch_pool, 1, sizeof(const char *));
+  svn_mergeinfo_catalog_t catalog;
+
+  APR_ARRAY_PUSH(paths, const char *) = path;
+
+  SVN_ERR(svn_fs_get_mergeinfo2(&catalog, root, paths,
+                                inherit, FALSE /*include_descendants*/,
+                                adjust_inherited_mergeinfo,
+                                result_pool, scratch_pool));
+  *mergeinfo = svn_hash_gets(catalog, path);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_fs_merge(const char **conflict_p, svn_fs_root_t *source_root,
              const char *source_path, svn_fs_root_t *target_root,
              const char *target_path, svn_fs_root_t *ancestor_root,

Modified: subversion/trunk/subversion/libsvn_repos/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/log.c?rev=1570294&r1=1570293&r2=1570294&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/log.c (original)
+++ subversion/trunk/subversion/libsvn_repos/log.c Thu Feb 20 18:21:20 2014
@@ -39,6 +39,7 @@
 #include "svn_mergeinfo.h"
 #include "repos.h"
 #include "private/svn_fspath.h"
+#include "private/svn_fs_private.h"
 #include "private/svn_mergeinfo_private.h"
 #include "private/svn_subr_private.h"
 
@@ -741,7 +742,6 @@ fs_mergeinfo_changed(svn_mergeinfo_catal
                      svn_revnum_t rev,
                      apr_pool_t *result_pool,
                      apr_pool_t *scratch_pool)
-
 {
   svn_fs_root_t *root;
   apr_pool_t *iterpool;
@@ -882,16 +882,12 @@ fs_mergeinfo_changed(svn_mergeinfo_catal
          inherited mergeinfo for that path/revision.  */
       if (prev_mergeinfo_value && (! mergeinfo_value))
         {
-          apr_array_header_t *query_paths =
-            apr_array_make(iterpool, 1, sizeof(const char *));
           svn_mergeinfo_t tmp_mergeinfo;
-          svn_mergeinfo_catalog_t tmp_catalog;
 
-          APR_ARRAY_PUSH(query_paths, const char *) = changed_path;
-          SVN_ERR(svn_fs_get_mergeinfo2(&tmp_catalog, root,
-                                        query_paths, svn_mergeinfo_inherited,
-                                        FALSE, TRUE, iterpool, iterpool));
-          tmp_mergeinfo = svn_hash_gets(tmp_catalog, changed_path);
+          SVN_ERR(svn_fs__get_mergeinfo_for_path(&tmp_mergeinfo,
+                                                 root, changed_path,
+                                                 svn_mergeinfo_inherited, TRUE,
+                                                 iterpool, iterpool));
           if (tmp_mergeinfo)
             SVN_ERR(svn_mergeinfo_to_string(&mergeinfo_value,
                                             tmp_mergeinfo,
@@ -900,16 +896,12 @@ fs_mergeinfo_changed(svn_mergeinfo_catal
       else if (mergeinfo_value && (! prev_mergeinfo_value)
                && base_path && SVN_IS_VALID_REVNUM(base_rev))
         {
-          apr_array_header_t *query_paths =
-            apr_array_make(iterpool, 1, sizeof(const char *));
           svn_mergeinfo_t tmp_mergeinfo;
-          svn_mergeinfo_catalog_t tmp_catalog;
 
-          APR_ARRAY_PUSH(query_paths, const char *) = base_path;
-          SVN_ERR(svn_fs_get_mergeinfo2(&tmp_catalog, base_root,
-                                        query_paths, svn_mergeinfo_inherited,
-                                        FALSE, TRUE, iterpool, iterpool));
-          tmp_mergeinfo = svn_hash_gets(tmp_catalog, base_path);
+          SVN_ERR(svn_fs__get_mergeinfo_for_path(&tmp_mergeinfo,
+                                                 base_root, base_path,
+                                                 svn_mergeinfo_inherited, TRUE,
+                                                 iterpool, iterpool));
           if (tmp_mergeinfo)
             SVN_ERR(svn_mergeinfo_to_string(&prev_mergeinfo_value,
                                             tmp_mergeinfo,
@@ -1023,13 +1015,10 @@ get_combined_mergeinfo_changes(svn_merge
     {
       const char *path = APR_ARRAY_IDX(paths, i, const char *);
       const char *prev_path;
-      apr_ssize_t klen;
       svn_revnum_t appeared_rev, prev_rev;
       svn_fs_root_t *prev_root;
-      svn_mergeinfo_catalog_t catalog, inherited_catalog;
       svn_mergeinfo_t prev_mergeinfo, mergeinfo, deleted, added,
         prev_inherited_mergeinfo, inherited_mergeinfo;
-      apr_array_header_t *query_paths;
 
       svn_pool_clear(iterpool);
 
@@ -1065,11 +1054,10 @@ get_combined_mergeinfo_changes(svn_merge
          this path.  Ignore not-found errors returned by the
          filesystem or invalid mergeinfo (Issue #3896).*/
       SVN_ERR(svn_fs_revision_root(&prev_root, fs, prev_rev, iterpool));
-      query_paths = apr_array_make(iterpool, 1, sizeof(const char *));
-      APR_ARRAY_PUSH(query_paths, const char *) = prev_path;
-      err = svn_fs_get_mergeinfo2(&catalog, prev_root, query_paths,
-                                  svn_mergeinfo_inherited, FALSE, TRUE,
-                                  iterpool, iterpool);
+      err = svn_fs__get_mergeinfo_for_path(&prev_mergeinfo,
+                                           prev_root, prev_path,
+                                           svn_mergeinfo_inherited, TRUE,
+                                           iterpool, iterpool);
       if (err && (err->apr_err == SVN_ERR_FS_NOT_FOUND ||
                   err->apr_err == SVN_ERR_FS_NOT_DIRECTORY ||
                   err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR))
@@ -1089,31 +1077,25 @@ get_combined_mergeinfo_changes(svn_merge
 
          To check for this we must fetch the "raw" previous inherited
          mergeinfo and the "raw" mergeinfo @REV then compare these. */
-      SVN_ERR(svn_fs_get_mergeinfo2(&inherited_catalog, prev_root, query_paths,
-                                    svn_mergeinfo_nearest_ancestor, FALSE,
-                                    FALSE, /* adjust_inherited_mergeinfo */
-                                    iterpool, iterpool));
-
-      klen = strlen(prev_path);
-      prev_mergeinfo = apr_hash_get(catalog, prev_path, klen);
-      prev_inherited_mergeinfo = apr_hash_get(inherited_catalog, prev_path, klen);
+      SVN_ERR(svn_fs__get_mergeinfo_for_path(&prev_inherited_mergeinfo,
+                                             prev_root, prev_path,
+                                             svn_mergeinfo_nearest_ancestor,
+                                             FALSE, /* adjust_inherited_mergeinfo */
+                                             iterpool, iterpool));
 
       /* Fetch the current mergeinfo (as of REV, and including
          inherited stuff) for this path. */
-      APR_ARRAY_IDX(query_paths, 0, const char *) = path;
-      SVN_ERR(svn_fs_get_mergeinfo2(&catalog, root, query_paths,
-                                    svn_mergeinfo_inherited, FALSE, TRUE,
-                                    iterpool, iterpool));
+      SVN_ERR(svn_fs__get_mergeinfo_for_path(&mergeinfo,
+                                             root, path,
+                                             svn_mergeinfo_inherited, TRUE,
+                                             iterpool, iterpool));
 
       /* Issue #4022 again, fetch the raw inherited mergeinfo. */
-      SVN_ERR(svn_fs_get_mergeinfo2(&inherited_catalog, root, query_paths,
-                                    svn_mergeinfo_nearest_ancestor, FALSE,
-                                    FALSE, /* adjust_inherited_mergeinfo */
-                                    iterpool, iterpool));
-
-      klen = strlen(path);
-      mergeinfo = apr_hash_get(catalog, path, klen);
-      inherited_mergeinfo = apr_hash_get(inherited_catalog, path, klen);
+      SVN_ERR(svn_fs__get_mergeinfo_for_path(&inherited_mergeinfo,
+                                             root, path,
+                                             svn_mergeinfo_nearest_ancestor,
+                                             FALSE, /* adjust_inherited_mergeinfo */
+                                             iterpool, iterpool));
 
       if (!prev_mergeinfo && !mergeinfo)
         continue;

Modified: subversion/trunk/subversion/libsvn_repos/rev_hunt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/rev_hunt.c?rev=1570294&r1=1570293&r2=1570294&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/rev_hunt.c (original)
+++ subversion/trunk/subversion/libsvn_repos/rev_hunt.c Thu Feb 20 18:21:20 2014
@@ -39,6 +39,7 @@
 #include "svn_mergeinfo.h"
 #include "repos.h"
 #include "private/svn_fspath.h"
+#include "private/svn_fs_private.h"
 
 
 /* Note:  this binary search assumes that the datestamp properties on
@@ -963,37 +964,6 @@ svn_repos_node_location_segments(svn_rep
   return SVN_NO_ERROR;
 }
 
-/* Get the mergeinfo for PATH in REPOS at REVNUM and store it in MERGEINFO. */
-static svn_error_t *
-get_path_mergeinfo(apr_hash_t **mergeinfo,
-                   svn_fs_t *fs,
-                   const char *path,
-                   svn_revnum_t revnum,
-                   apr_pool_t *result_pool,
-                   apr_pool_t *scratch_pool)
-{
-  svn_mergeinfo_catalog_t tmp_catalog;
-  svn_fs_root_t *root;
-  apr_array_header_t *paths = apr_array_make(scratch_pool, 1,
-                                             sizeof(const char *));
-
-  APR_ARRAY_PUSH(paths, const char *) = path;
-
-  SVN_ERR(svn_fs_revision_root(&root, fs, revnum, scratch_pool));
-  /* We do not need to call svn_repos_fs_get_mergeinfo() (which performs authz)
-     because we will filter out unreadable revisions in
-     find_interesting_revision(), above */
-  SVN_ERR(svn_fs_get_mergeinfo2(&tmp_catalog, root, paths,
-                                svn_mergeinfo_inherited, FALSE, TRUE,
-                                result_pool, scratch_pool));
-
-  *mergeinfo = svn_hash_gets(tmp_catalog, path);
-  if (!*mergeinfo)
-    *mergeinfo = apr_hash_make(result_pool);
-
-  return SVN_NO_ERROR;
-}
-
 static APR_INLINE svn_boolean_t
 is_path_in_hash(apr_hash_t *duplicate_path_revs,
                 const char *path,
@@ -1031,7 +1001,7 @@ get_merged_mergeinfo(apr_hash_t **merged
 {
   apr_hash_t *curr_mergeinfo, *prev_mergeinfo, *deleted, *changed;
   svn_error_t *err;
-  svn_fs_root_t *root;
+  svn_fs_root_t *root, *prev_root;
   apr_hash_t *changed_paths;
   const char *path = old_path_rev->path;
 
@@ -1056,9 +1026,13 @@ get_merged_mergeinfo(apr_hash_t **merged
 
   /* First, find the mergeinfo difference for old_path_rev->revnum, and
      old_path_rev->revnum - 1. */
-  err = get_path_mergeinfo(&curr_mergeinfo, repos->fs, old_path_rev->path,
-                           old_path_rev->revnum, scratch_pool,
-                           scratch_pool);
+  /* We do not need to call svn_repos_fs_get_mergeinfo() (which performs authz)
+     because we will filter out unreadable revisions in
+     find_interesting_revision() */
+  err = svn_fs__get_mergeinfo_for_path(&curr_mergeinfo,
+                                       root, old_path_rev->path,
+                                       svn_mergeinfo_inherited, TRUE,
+                                       scratch_pool, scratch_pool);
   if (err)
     {
       if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
@@ -1076,9 +1050,12 @@ get_merged_mergeinfo(apr_hash_t **merged
         }
     }
 
-  err = get_path_mergeinfo(&prev_mergeinfo, repos->fs, old_path_rev->path,
-                           old_path_rev->revnum - 1, scratch_pool,
-                           scratch_pool);
+  SVN_ERR(svn_fs_revision_root(&prev_root, repos->fs, old_path_rev->revnum - 1,
+                               scratch_pool));
+  err = svn_fs__get_mergeinfo_for_path(&prev_mergeinfo,
+                                       prev_root, old_path_rev->path,
+                                       svn_mergeinfo_inherited, TRUE,
+                                       scratch_pool, scratch_pool);
   if (err && (err->apr_err == SVN_ERR_FS_NOT_FOUND
               || err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR))
     {



Mime
View raw message