You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/03/18 16:19:45 UTC

svn commit: r1667574 - in /subversion/branches/move-tracking-2/subversion: include/private/svn_branch.h libsvn_delta/branch.c svnmover/svnmover.c

Author: julianfoad
Date: Wed Mar 18 15:19:44 2015
New Revision: 1667574

URL: http://svn.apache.org/r1667574
Log:
On the 'move-tracking-2' branch: Simplify branch family nesting. The model
does not need to support multiple branch families at the same nesting level,
so don't.

In fact the usage is more flexible this way. If the branches of separate
projects are in the same family (even if they do not share any elements)
then the repository layout can be rearranged from a /project/branch nesting
to a /branch/project nesting without breaking any branch history. Writing
branch names in upper case:

  {/proj1/TRUNK/...,/proj2/TRUNK/...}
                 ^                ^
                 |                |
                 v                v
  {/TRUNK/proj1/...,/TRUNK/proj2/...}

On the other hand, separating branches into families can be convenient for
organizational purposes. However, for those purposes, support in the model
is unnecessary. A grouping feature can be layered on top of the base model.

* subversion/include/private/svn_branch.h
  (svn_branch_family_t): Replace the nested 'sub_families' with a single
    'subfamily'. Remove an obsolete comment.
  (svn_branch_family_get_children): Delete.

* subversion/libsvn_delta/branch.c
  (svn_branch_family_get_children,
   family_is_child): Delete.
  (assert_branch_family_invariants,
   svn_branch_family_create,
   svn_branch_get_subbranches,
   svn_branch_family_parse,
   svn_branch_family_serialize): Update.
  (get_family): New.
  (branch_branchify): Update.

* subversion/svnmover/svnmover.c
  (family_list_branch_instances): Update.

Modified:
    subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h
    subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h?rev=1667574&r1=1667573&r2=1667574&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_branch.h Wed Mar 18 15:19:44 2015
@@ -128,7 +128,6 @@ svn_branch_revision_root_create(svn_bran
                                 apr_pool_t *result_pool);
 
 /* A branch family.
- * ### Most of this is not per-revision data. Move it out of revision-root?
  */
 typedef struct svn_branch_family_t
 {
@@ -155,8 +154,8 @@ typedef struct svn_branch_family_t
   /* The range of element ids assigned within this family. */
   int first_eid, next_eid;
 
-  /* The immediate sub-families of this family. */
-  apr_array_header_t *sub_families;
+  /* The immediate sub-family of this family, or NULL if none. */
+  struct svn_branch_family_t *subfamily;
 
   /* The pool in which this object lives. */
   apr_pool_t *pool;
@@ -172,14 +171,6 @@ svn_branch_family_create(svn_branch_repo
                          int next_eid,
                          apr_pool_t *result_pool);
 
-/* Return an array of the immediate sub-families of FAMILY.
- *
- * Return an empty array if there are none.
- */
-apr_array_header_t *
-svn_branch_family_get_children(svn_branch_family_t *family,
-                               apr_pool_t *result_pool);
-
 /* Return the branch instances that are members of FAMILY in REV_ROOT.
  *
  * Return an empty array if there are none.

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c?rev=1667574&r1=1667573&r2=1667574&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Wed Mar 18 15:19:44 2015
@@ -119,7 +119,6 @@ static void
 assert_branch_family_invariants(const svn_branch_family_t *family)
 {
   assert(family->branch_siblings);
-  assert(family->sub_families);
   /* ### ... */
 }
 
@@ -137,7 +136,7 @@ svn_branch_family_create(svn_branch_repo
   f->fid = fid;
   f->repos = repos;
   f->branch_siblings = svn_array_make(result_pool);
-  f->sub_families = svn_array_make(result_pool);
+  f->subfamily = NULL;
   f->first_bsid = first_bsid;
   f->next_bsid = next_bsid;
   f->first_eid = first_eid;
@@ -182,7 +181,7 @@ svn_branch_family_add_new_subfamily(svn_
 
   /* Register the family */
   repos_register_family(repos, family);
-  SVN_ARRAY_PUSH(outer_family->sub_families) = family;
+  outer_family->subfamily = family;
 
   assert_branch_family_invariants(outer_family);
   assert_branch_family_invariants(family);
@@ -260,13 +259,6 @@ svn_branch_family_add_new_branch_sibling
 }
 
 apr_array_header_t *
-svn_branch_family_get_children(svn_branch_family_t *family,
-                               apr_pool_t *result_pool)
-{
-  return family->sub_families;
-}
-
-apr_array_header_t *
 svn_branch_family_get_branch_instances(
                                 svn_branch_revision_root_t *rev_root,
                                 svn_branch_family_t *family,
@@ -834,19 +826,6 @@ svn_branch_map_branch_children(svn_branc
   return SVN_NO_ERROR;
 }
 
-/* Return true iff CHILD_FAMILY is an immediate child of PARENT_FAMILY. */
-static svn_boolean_t
-family_is_child(svn_branch_family_t *parent_family,
-                svn_branch_family_t *child_family)
-{
-  SVN_ITER_T(svn_branch_family_t) *fi;
-
-  for (SVN_ARRAY_ITER_NO_POOL(fi, parent_family->sub_families))
-    if (fi->val == child_family)
-      return TRUE;
-  return FALSE;
-}
-
 apr_array_header_t *
 svn_branch_get_subbranches(const svn_branch_instance_t *branch,
                            int eid,
@@ -866,7 +845,7 @@ svn_branch_get_subbranches(const svn_bra
         = svn_branch_get_root_rrpath(bi->val, bi->iterpool);
 
       /* Is it an immediate child at or below EID? */
-      if (family_is_child(family, sub_branch_family)
+      if (sub_branch_family == family->subfamily
           && svn_relpath_skip_ancestor(top_rrpath, sub_branch_root_rrpath))
         SVN_ARRAY_PUSH(subbranches) = bi->val;
     }
@@ -1126,7 +1105,7 @@ svn_branch_family_parse(svn_branch_famil
             = repos_get_family_by_id(repos, *parent_fid);
 
           SVN_ERR_ASSERT(parent_family);
-          SVN_ARRAY_PUSH(parent_family->sub_families) = family;
+          parent_family->subfamily = family;
         }
     }
 
@@ -1251,7 +1230,6 @@ svn_branch_family_serialize(svn_stream_t
 {
   svn_array_t *branch_instances = svn_array_make(scratch_pool);
   SVN_ITER_T(svn_branch_instance_t) *bi;
-  SVN_ITER_T(svn_branch_family_t) *fi;
 
   for (SVN_ARRAY_ITER(bi, rev_root->branch_instances, scratch_pool))
     if (bi->val->sibling_defn->family == family)
@@ -1269,9 +1247,10 @@ svn_branch_family_serialize(svn_stream_t
   for (SVN_ARRAY_ITER(bi, branch_instances, scratch_pool))
     SVN_ERR(svn_branch_instance_serialize(stream, bi->val, bi->iterpool));
 
-  for (SVN_ARRAY_ITER(fi, family->sub_families, scratch_pool))
-    SVN_ERR(svn_branch_family_serialize(stream, rev_root, fi->val, family->fid,
-                                        fi->iterpool));
+  if (family->subfamily)
+    SVN_ERR(svn_branch_family_serialize(stream, rev_root,
+                                        family->subfamily, family->fid,
+                                        scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1531,6 +1510,19 @@ svn_branch_branch(svn_branch_instance_t
   return SVN_NO_ERROR;
 }
 
+/* Return the subfamily of OUTER_FAMILY, creating it if it did not yet exist.
+ */
+static svn_branch_family_t *
+get_family(svn_branch_family_t *outer_family)
+{
+  svn_branch_family_t *family = outer_family->subfamily;
+
+  if (! family)
+    family = svn_branch_family_add_new_subfamily(outer_family);
+
+  return family;
+}
+
 /* The body of svn_branch_branchify(), which see */
 static svn_error_t *
 branch_branchify(svn_branch_instance_t **new_branch_p,
@@ -1539,7 +1531,7 @@ branch_branchify(svn_branch_instance_t *
                  apr_pool_t *scratch_pool)
 {
   svn_branch_family_t *new_family
-    = svn_branch_family_add_new_subfamily(outer_branch->sibling_defn->family);
+    = get_family(outer_branch->sibling_defn->family);
   int new_root_eid = svn_branch_family_add_new_element(new_family);
   svn_branch_sibling_t *
     new_branch_def = svn_branch_family_add_new_branch_sibling(new_family,

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=1667574&r1=1667573&r2=1667574&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Wed Mar 18 15:19:44 2015
@@ -456,13 +456,11 @@ family_list_branch_instances(svn_branch_
 
   if (recursive)
     {
-      SVN_ITER_T(svn_branch_family_t) *fi;
-
-      for (SVN_ARRAY_ITER(fi, svn_branch_family_get_children(
-                                family, scratch_pool), scratch_pool))
+      if (family->subfamily)
         {
-          SVN_ERR(family_list_branch_instances(rev_root, fi->val, recursive,
-                                               verbose, fi->iterpool));
+          SVN_ERR(family_list_branch_instances(rev_root, family->subfamily,
+                                               recursive,
+                                               verbose, scratch_pool));
         }
     }