Author: julianfoad
Date: Wed Jun 15 14:53:05 2011
New Revision: 1136075

URL: http://svn.apache.org/viewvc?rev=1136075&view=rev
Log:
Simplify both the FSFS and BDB versions of 'get_mergeinfo_for_path', in the
same way, by factoring out the mergeinfo parsing to a single place in each
one.

* subversion/libsvn_fs_base/tree.c
  (txn_body_get_mergeinfo_for_path): Simplify.

* subversion/libsvn_fs_fs/tree.c
  (get_mergeinfo_for_path): Simplify. Correct a parameter name in doc string.

Modified:
    subversion/trunk/subversion/libsvn_fs_base/tree.c
    subversion/trunk/subversion/libsvn_fs_fs/tree.c

Modified: subversion/trunk/subversion/libsvn_fs_base/tree.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/tree.c?rev=1136075&r1=1136074&r2=1136075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/tree.c Wed Jun 15 14:53:05 2011
@@ -5363,67 +5363,46 @@ txn_body_get_mergeinfo_for_path(void *ba
                                  "mergeinfo but doesn't"), id_str->data);
     }
 
+  /* Parse the mergeinfo; store the result in ARGS->MERGEINFO. */
+  {
+    /* Issue #3896: If a node has syntactically invalid mergeinfo, then
+       treat it as if no mergeinfo is present rather than raising a parse
+       error. */
+    svn_error_t *err = svn_mergeinfo_parse(args->mergeinfo,
+                                           mergeinfo_string->data,
+                                           args->pool);
+    if (err)
+      {
+        if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
+          {
+            svn_error_clear(err);
+            err = NULL;
+            args->mergeinfo = NULL;
+          }
+        return svn_error_return(err);
+      }
+  }
+
   /* If our nearest ancestor is the very path we inquired about, we
      can return the mergeinfo results directly.  Otherwise, we're
      inheriting the mergeinfo, so we need to a) remove non-inheritable
-     ranges and b) telescope the merged-from paths.
-
-     Issue #3896: If a node has syntactically invalid mergeinfo, then
-     treat it as if no mergeinfo is present rather than raising a parse
-     error. */
-  if (nearest_ancestor == parent_path)
-    {
-      svn_error_t *err = svn_mergeinfo_parse(args->mergeinfo,
-                                             mergeinfo_string->data,
-                                             args->pool);
-      if (err)
-        {
-          if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
-            {
-              svn_error_clear(err);
-              err = NULL;
-              args->mergeinfo = NULL;
-            }
-        }
-      return svn_error_return(err);
-    }
-  else
+     ranges and b) telescope the merged-from paths. */
+  if (nearest_ancestor != parent_path)
     {
       svn_mergeinfo_t tmp_mergeinfo;
-      svn_error_t *err = svn_mergeinfo_parse(&tmp_mergeinfo,
-                                             mergeinfo_string->data,
-                                             trail->pool);
-
-      /* Issue #3896: If a node inherits syntactically invalid mergeinfo,
-         then treat it as if no mergeinfo is inherited rather than raising
-         a parse error. */
-      if (err)
-        {
-          if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
-            {
-              svn_error_clear(err);
-              args->mergeinfo = NULL;
-            }
-          else
-            {
-              return svn_error_return(err);
-            }
-        }
-      else
-        {
-          SVN_ERR(svn_mergeinfo_inheritable2(&tmp_mergeinfo, tmp_mergeinfo,
-                                             NULL, SVN_INVALID_REVNUM,
-                                             SVN_INVALID_REVNUM, TRUE,
-                                             trail->pool, trail->pool));
-          SVN_ERR(append_to_merged_froms(args->mergeinfo,
-                                         tmp_mergeinfo,
-                                         parent_path_relpath(parent_path,
-                                                             nearest_ancestor,
-                                                             trail->pool),
-                                         args->pool));
-          *(args->inherited) = TRUE;
-        }
+
+      SVN_ERR(svn_mergeinfo_inheritable2(&tmp_mergeinfo, *args->mergeinfo,
+                                         NULL, SVN_INVALID_REVNUM,
+                                         SVN_INVALID_REVNUM, TRUE,
+                                         trail->pool, trail->pool));
+      SVN_ERR(append_to_merged_froms(args->mergeinfo, tmp_mergeinfo,
+                                     parent_path_relpath(
+                                       parent_path, nearest_ancestor,
+                                       trail->pool),
+                                     args->pool));
+      *(args->inherited) = TRUE;
     }
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_fs_fs/tree.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/tree.c?rev=1136075&r1=1136074&r2=1136075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/tree.c Wed Jun 15 14:53:05 2011
@@ -3603,8 +3603,8 @@ append_to_merged_froms(svn_mergeinfo_t *
    type INHERIT.  Returns it in *MERGEINFO, or NULL if there is none.
    If *MERGEINFO is inherited and VALIDATE_INHERITED_MERGEINFO is true,
    then *MERGEINFO will only contain path-revs that actually exist in
-   repository.  The result is allocated in RESULT_POOL; POOL is used for
-   temporary allocations.
+   repository.  The result is allocated in RESULT_POOL; SCRATCH_POOL is
+   used for temporary allocations.
  */
 static svn_error_t *
 get_mergeinfo_for_path(svn_mergeinfo_t *mergeinfo,
@@ -3672,80 +3672,53 @@ get_mergeinfo_for_path(svn_mergeinfo_t *
        _("Node-revision '%s@%ld' claims to have mergeinfo but doesn't"),
        parent_path_path(nearest_ancestor, scratch_pool), rev_root->rev);
 
-  if (nearest_ancestor == parent_path)
+  /* Parse the mergeinfo; store the result in *MERGEINFO. */
+  {
+    /* Issue #3896: If a node has syntactically invalid mergeinfo, then
+       treat it as if no mergeinfo is present rather than raising a parse
+       error. */
+    svn_error_t *err = svn_mergeinfo_parse(mergeinfo,
+                                           mergeinfo_string->data,
+                                           result_pool);
+    if (err)
+      {
+        if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
+          {
+            svn_error_clear(err);
+            err = NULL;
+            *mergeinfo = NULL;
+          }
+        svn_pool_destroy(iterpool);
+        return svn_error_return(err);
+      }
+  }
+
+  /* If our nearest ancestor is the very path we inquired about, we
+     can return the mergeinfo results directly.  Otherwise, we're
+     inheriting the mergeinfo, so we need to a) remove non-inheritable
+     ranges and b) telescope the merged-from paths. */
+  if (nearest_ancestor != parent_path)
     {
-      svn_error_t *err;
-
-      /* We can return this directly. */
-      svn_pool_destroy(iterpool);
+      svn_mergeinfo_t tmp_mergeinfo;
 
-      /* Issue #3896: If a node has syntactically invalid mergeinfo, then
-         treat it as if no mergeinfo is present rather than raising a parse
-         error. */
-      err = svn_mergeinfo_parse(mergeinfo,
-                                mergeinfo_string->data,
-                                result_pool);
-      if (err)
-        {
-          if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
-            {
-              svn_error_clear(err);
-              err = NULL;
-              *mergeinfo = NULL;
-            }
-        }
-      return svn_error_return(err);
+      SVN_ERR(svn_mergeinfo_inheritable2(&tmp_mergeinfo, *mergeinfo,
+                                         NULL, SVN_INVALID_REVNUM,
+                                         SVN_INVALID_REVNUM, TRUE,
+                                         scratch_pool, scratch_pool));
+      SVN_ERR(append_to_merged_froms(mergeinfo, tmp_mergeinfo,
+                                     parent_path_relpath(
+                                       parent_path, nearest_ancestor,
+                                       scratch_pool),
+                                     result_pool));
+
+      if (validate_inherited_mergeinfo)
+        SVN_ERR(svn_fs_fs__validate_mergeinfo(mergeinfo, rev_root->fs,
+                                              *mergeinfo, result_pool,
+                                              iterpool));
     }
-  else
-    {
-      svn_mergeinfo_t temp_mergeinfo;
-      svn_error_t *err;
 
-      /* We're inheriting this, so we need to (a) remove
-         non-inheritable ranges and (b) add the rest of the path to
-         the merged-from paths.
-       */
-
-      /* Issue #3896: If a node inherits syntactically invalid mergeinfo,
-         then treat it as if no mergeinfo is inherited rather than raising
-         a parse error. */
-      err = svn_mergeinfo_parse(&temp_mergeinfo,
-                                mergeinfo_string->data,
-                                scratch_pool);
-      if (err)
-        {
-          if (err->apr_err == SVN_ERR_MERGEINFO_PARSE_ERROR)
-            {
-              svn_error_clear(err);
-              *mergeinfo = NULL;
-            }
-          else
-            {
-              return svn_error_return(err);
-            }
-        }
-      else
-        {
-          SVN_ERR(svn_mergeinfo_inheritable2(&temp_mergeinfo, temp_mergeinfo,
-                                             NULL, SVN_INVALID_REVNUM,
-                                             SVN_INVALID_REVNUM, TRUE,
-                                             scratch_pool, scratch_pool));
-
-          SVN_ERR(append_to_merged_froms(mergeinfo,
-                                         temp_mergeinfo,
-                                         parent_path_relpath(parent_path,
-                                                             nearest_ancestor,
-                                                             scratch_pool),
-                                         result_pool));
-
-          if (validate_inherited_mergeinfo)
-            SVN_ERR(svn_fs_fs__validate_mergeinfo(mergeinfo, rev_root->fs,
-                                                  *mergeinfo, result_pool,
-                                                  iterpool));
-        }
-      svn_pool_destroy(iterpool);
-      return SVN_NO_ERROR;
-    }
+  svn_pool_destroy(iterpool);
+  return SVN_NO_ERROR;
 }
 
 /* Adds mergeinfo for each descendant of PATH (but not PATH itself)


Reply via email to