subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1639611 - in /subversion/branches/move-tracking-2/subversion: include/private/svn_editor3.h libsvn_delta/branching.c libsvn_delta/compat3b.c svnmover/svnmover.c
Date Fri, 14 Nov 2014 11:41:17 GMT
Author: julianfoad
Date: Fri Nov 14 11:41:16 2014
New Revision: 1639611

URL: http://svn.apache.org/r1639611
Log:
On the 'move-tracking-2' branch: Calculate branch root path on demand rather
than storing it, as it can change during the edit and was not being updated.

* subversion/include/private/svn_editor3.h,
  subversion/libsvn_delta/branching.c
  (svn_branch_instance_t): Store the outer branch and outer-branch eid
    instead of the branch root path.
  (svn_branch_instance_create): Change the constructor parameters in the
    same way.
  (svn_branch_get_root_rrpath): Calculate the result by recursion. Add a
    result pool parameter.
  Update all callers.

* subversion/libsvn_delta/compat3b.c
  Update all callers.

* subversion/svnmover/svnmover.c
  Update all callers.

Modified:
    subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
    subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c
    subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h?rev=1639611&r1=1639610&r2=1639611&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h Fri Nov 14
11:41:16 2014
@@ -1726,30 +1726,33 @@ struct svn_branch_instance_t
   /* The revision to which this branch-revision-instance belongs */
   svn_branch_revision_root_t *rev_root;
 
-  /* The branch (instance?), within the outer family, that contains the
-     root element of this branch. */
-  /*svn_branch_instance_t *outer_family_branch_instance;*/
+  /* The branch instance within the outer family that contains the
+     root element of this branch. Null if this is the root branch. */
+  struct svn_branch_instance_t *outer_branch;
+
+  /* The element in OUTER_BRANCH of the root of this branch, or -1
+   * if this is the root branch. */
+  int outer_eid;
 
   /* --- Contents of this object --- */
 
   /* EID -> svn_branch_el_rev_content_t mapping. */
   apr_hash_t *e_map;
 
-  /* ### This need not be constant if a parent branch is updated, so should
-   * be calculated on demand not stored here. */
-  const char *branch_root_rrpath;
-
 };
 
-/* Create a new branch instance object */
+/* Create a new branch instance object, with no elements (not even a root
+ * element).
+ */
 svn_branch_instance_t *
 svn_branch_instance_create(svn_branch_sibling_t *branch_sibling,
                            svn_branch_revision_root_t *rev_root,
-                           const char *branch_root_rrpath,
+                           svn_branch_instance_t *outer_branch,
+                           int outer_eid,
                            apr_pool_t *result_pool);
 
-/* Create a new branch instance at OUTER_BRANCH:EID, of the branch class
- * BRANCH_SIBLING, with no elements.
+/* Create a new branch instance at OUTER_BRANCH:OUTER_EID, of the branch class
+ * BRANCH_SIBLING, with no elements (not even a root element).
  */
 svn_branch_instance_t *
 svn_branch_add_new_branch_instance(svn_branch_instance_t *outer_branch,
@@ -1988,7 +1991,8 @@ svn_branch_copy_subtree_r(const svn_bran
  * ### TODO: Clarify sequencing requirements.
  */
 const char *
-svn_branch_get_root_rrpath(const svn_branch_instance_t *branch);
+svn_branch_get_root_rrpath(const svn_branch_instance_t *branch,
+                           apr_pool_t *result_pool);
 
 /* Return the branch-relative path of element EID in BRANCH.
  *

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c?rev=1639611&r1=1639610&r2=1639611&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branching.c Fri Nov 14 11:41:16
2014
@@ -261,7 +261,8 @@ svn_branch_sibling_create(svn_branch_fam
 svn_branch_instance_t *
 svn_branch_instance_create(svn_branch_sibling_t *branch_sibling,
                            svn_branch_revision_root_t *rev_root,
-                           const char *branch_root_rrpath,
+                           svn_branch_instance_t *outer_branch,
+                           int outer_eid,
                            apr_pool_t *result_pool)
 {
   svn_branch_instance_t *b = apr_pcalloc(result_pool, sizeof(*b));
@@ -269,7 +270,8 @@ svn_branch_instance_create(svn_branch_si
   b->sibling_defn = branch_sibling;
   b->rev_root = rev_root;
   b->e_map = apr_hash_make(result_pool);
-  b->branch_root_rrpath = apr_pstrdup(result_pool, branch_root_rrpath);
+  b->outer_branch = outer_branch;
+  b->outer_eid = outer_eid;
   return b;
 }
 
@@ -353,15 +355,6 @@ svn_branch_el_rev_content_equal(const sv
  * ========================================================================
  */
 
-const char *
-svn_branch_get_root_rrpath(const svn_branch_instance_t *branch)
-{
-  const char *root_rrpath = branch->branch_root_rrpath;
-
-  SVN_ERR_ASSERT_NO_RETURN(root_rrpath);
-  return root_rrpath;
-}
-
 /* Validate that NODE is suitable for a mapping of BRANCH:EID.
  * NODE->content may be null.
  */
@@ -526,6 +519,27 @@ svn_branch_map_purge_orphans(svn_branch_
 }
 
 const char *
+svn_branch_get_root_rrpath(const svn_branch_instance_t *branch,
+                           apr_pool_t *result_pool)
+{
+  const char *root_rrpath;
+
+  if (branch->outer_branch)
+    {
+      root_rrpath
+        = svn_branch_get_rrpath_by_eid(branch->outer_branch, branch->outer_eid,
+                                       result_pool);
+    }
+  else
+    {
+      root_rrpath = "";
+    }
+
+  SVN_ERR_ASSERT_NO_RETURN(root_rrpath);
+  return root_rrpath;
+}
+
+const char *
 svn_branch_get_path_by_eid(const svn_branch_instance_t *branch,
                            int eid,
                            apr_pool_t *result_pool)
@@ -557,7 +571,7 @@ svn_branch_get_rrpath_by_eid(const svn_b
 
   if (path)
     {
-      rrpath = svn_relpath_join(svn_branch_get_root_rrpath(branch),
+      rrpath = svn_relpath_join(svn_branch_get_root_rrpath(branch, result_pool),
                                 path, result_pool);
     }
   return rrpath;
@@ -597,7 +611,8 @@ svn_branch_get_eid_by_rrpath(svn_branch_
                              const char *rrpath,
                              apr_pool_t *scratch_pool)
 {
-  const char *path = svn_relpath_skip_ancestor(svn_branch_get_root_rrpath(branch),
+  const char *path = svn_relpath_skip_ancestor(svn_branch_get_root_rrpath(
+                                                 branch, scratch_pool),
                                                rrpath);
   int eid = -1;
 
@@ -790,7 +805,7 @@ branch_get_sub_branches(const svn_branch
         = APR_ARRAY_IDX(branch->rev_root->branch_instances, i, void *);
       svn_branch_family_t *sub_branch_family = sub_branch->sibling_defn->family;
       const char *sub_branch_root_rrpath
-        = svn_branch_get_root_rrpath(sub_branch);
+        = svn_branch_get_root_rrpath(sub_branch, scratch_pool);
 
       /* Is it an immediate child at or below EID? */
       if (family_is_child(family, sub_branch_family)
@@ -869,16 +884,9 @@ svn_branch_add_new_branch_instance(svn_b
 {
   svn_branch_family_t *family = branch_sibling->family;
 
-  /* ### All this next bit is to get an RRPATH. Should ultimately go away. */
-  const char *outer_root_rrpath = svn_branch_get_root_rrpath(outer_branch);
-  const char *outer_eid_relpath
-    = svn_branch_get_path_by_eid(outer_branch, outer_eid, scratch_pool);
-  const char *new_root_rrpath
-    = svn_relpath_join(outer_root_rrpath, outer_eid_relpath, scratch_pool);
-
   svn_branch_instance_t *branch_instance
     = svn_branch_instance_create(branch_sibling, outer_branch->rev_root,
-                                 new_root_rrpath, family->pool);
+                                 outer_branch, outer_eid, family->pool);
 
   APR_ARRAY_PUSH(branch_instance->rev_root->branch_instances, void *)
     = branch_instance;
@@ -912,6 +920,8 @@ svn_branch_instance_parse(svn_branch_ins
   svn_branch_instance_t *branch_instance;
   char branch_root_path[100];
   const char *branch_root_rrpath;
+  svn_branch_instance_t *outer_branch;
+  int outer_eid;
   int eid;
 
   SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, scratch_pool));
@@ -924,8 +934,21 @@ svn_branch_instance_parse(svn_branch_ins
   branch_root_rrpath
     = strcmp(branch_root_path, ".") == 0 ? "" : branch_root_path;
   branch_sibling = family_find_or_create_branch_sibling(family, bid, root_eid);
+  if (branch_root_rrpath[0])
+    {
+      svn_branch_find_nested_branch_element_by_rrpath(&outer_branch, &outer_eid,
+                                                      rev_root->root_branch,
+                                                      branch_root_rrpath,
+                                                      scratch_pool);
+    }
+  else
+    {
+      outer_branch = NULL;
+      outer_eid = -1;
+    }
   branch_instance = svn_branch_instance_create(branch_sibling, rev_root,
-                                               branch_root_rrpath, result_pool);
+                                               outer_branch, outer_eid,
+                                               result_pool);
 
   for (eid = family->first_eid; eid < family->next_eid; eid++)
     {
@@ -1056,6 +1079,7 @@ svn_branch_revision_root_parse(svn_branc
                                       scratch_pool));
 
       /* parse the branches */
+      /* ### Need to iterate over N(instances) not over N(sibling-defs) */
       for (bid = family->first_bid; bid < family->next_bid; ++bid)
         {
           svn_branch_instance_t *branch;
@@ -1082,7 +1106,8 @@ svn_branch_instance_serialize(svn_stream
                               apr_pool_t *scratch_pool)
 {
   svn_branch_family_t *family = branch->sibling_defn->family;
-  const char *branch_root_rrpath = svn_branch_get_root_rrpath(branch);
+  const char *branch_root_rrpath = svn_branch_get_root_rrpath(branch,
+                                                              scratch_pool);
   int eid;
 
   SVN_ERR(svn_stream_printf(stream, scratch_pool,
@@ -1195,7 +1220,8 @@ svn_branch_find_nested_branch_element_by
                                 const char *rrpath,
                                 apr_pool_t *scratch_pool)
 {
-  const char *branch_root_path = svn_branch_get_root_rrpath(root_branch);
+  const char *branch_root_path = svn_branch_get_root_rrpath(root_branch,
+                                                            scratch_pool);
   apr_array_header_t *branch_instances;
   int i;
 

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c?rev=1639611&r1=1639610&r2=1639611&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3b.c Fri Nov 14 11:41:16
2014
@@ -911,7 +911,7 @@ svn_branch_branchify(svn_editor3_t *edit
 
   SVN_DBG(("branchify(b%d e%d at ^/%s): new f%d b%d e%d",
            outer_branch->sibling_defn->bid, outer_eid,
-           svn_branch_get_root_rrpath(new_branch),
+           svn_branch_get_root_rrpath(new_branch, scratch_pool),
            new_family->fid, new_branch_def->bid, new_branch_def->root_eid));
 
   /* Initialize the root element */
@@ -1084,8 +1084,9 @@ convert_branch_to_paths(apr_hash_t *path
       int eid = *(const int *)apr_hash_this_key(hi);
       const char *relpath = svn_branch_get_path_by_eid(branch, eid,
                                                        result_pool);
-      const char *rrpath = svn_relpath_join(svn_branch_get_root_rrpath(branch),
-                                            relpath, result_pool);
+      const char *rrpath
+        = svn_relpath_join(svn_branch_get_root_rrpath(branch, scratch_pool),
+                           relpath, result_pool);
       svn_branch_el_rev_id_t *ba = svn_hash_gets(paths, rrpath);
 
       /* Fill in the details. If it's already been filled in, then let a

Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1639611&r1=1639610&r2=1639611&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Fri Nov 14 11:41:16
2014
@@ -297,7 +297,7 @@ family_list_branch_instances(svn_branch_
 
       printf("  branch %d (root element %d -> '/%s')\n",
              branch->sibling_defn->bid, branch->sibling_defn->root_eid,
-             svn_branch_get_root_rrpath(branch));
+             svn_branch_get_root_rrpath(branch, scratch_pool));
       for (eid = family->first_eid; eid < family->next_eid; eid++)
         {
           const char *rrpath = svn_branch_get_rrpath_by_eid(branch, eid,
@@ -306,8 +306,8 @@ family_list_branch_instances(svn_branch_
           if (rrpath)
             {
               const char *relpath
-                = svn_relpath_skip_ancestor(svn_branch_get_root_rrpath(branch),
-                                            rrpath);
+                = svn_relpath_skip_ancestor(
+                    svn_branch_get_root_rrpath(branch, scratch_pool), rrpath);
 
               printf("    e%d -> %s\n",
                      eid, relpath[0] ? relpath : ".");



Mime
View raw message