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/09/05 13:40:40 UTC

svn commit: r1701374 - in /subversion/branches/move-tracking-2/subversion: libsvn_delta/branch.c tests/cmdline/svntest/wc.py

Author: julianfoad
Date: Sat Sep  5 11:40:40 2015
New Revision: 1701374

URL: http://svn.apache.org/r1701374
Log:
On the 'move-tracking-2' branch: Only serialize EIDs that are in use.

The main goal of this change is to remove an assumption that EIDs are
sequential and close together. In general, they may be very sparse and in
future they may not be scalar.

Decreasing the size of the storage is a side effect, not a goal. (The
storage is designed for simplicity, not efficiency.)

* subversion/libsvn_delta/branch.c
  (sort_compare_items_by_eid): New.
  (svn_branch_get_default_r0_metadata,
   parse_branch_line,
   svn_branch_state_parse,
   svn_branch_state_serialize): Change the serial data format for a
    branch-state to have one line for each existing element instead of one
    line for each possible EID.

* subversion/tests/cmdline/svntest/wc.py
  (_re_parse_eid_branch,
   State.from_eids): Update the regex for matching the serialized metadata.

Modified:
    subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c
    subversion/branches/move-tracking-2/subversion/tests/cmdline/svntest/wc.py

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=1701374&r1=1701373&r2=1701374&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/branch.c Sat Sep  5 11:40:40 2015
@@ -946,7 +946,7 @@ svn_branch_get_default_r0_metadata(apr_p
 {
   static const char *default_repos_info
     = "r0: eids 0 1 branches 1\n"
-      "B0 root-eid 0  # at /\n"
+      "B0 root-eid 0 num-eids 1  # at /\n"
       "e0: normal -1 .\n";
 
   return svn_string_create(default_repos_info, result_pool);
@@ -956,6 +956,7 @@ svn_branch_get_default_r0_metadata(apr_p
 static svn_error_t *
 parse_branch_line(char *bid_p,
                   int *root_eid_p,
+                  int *num_eids_p,
                   svn_stream_t *stream,
                   apr_pool_t *scratch_pool)
 {
@@ -967,9 +968,9 @@ parse_branch_line(char *bid_p,
   SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, scratch_pool));
   SVN_ERR_ASSERT(!eof);
 
-  n = sscanf(line->data, "%s root-eid %d",
-             bid_p, root_eid_p);
-  SVN_ERR_ASSERT(n >= 2);  /* C std is unclear on whether '%n' counts */
+  n = sscanf(line->data, "%s root-eid %d num-eids %d",
+             bid_p, root_eid_p, num_eids_p);
+  SVN_ERR_ASSERT(n >= 3);  /* C std is unclear on whether '%n' counts */
 
   return SVN_NO_ERROR;
 }
@@ -1047,13 +1048,13 @@ svn_branch_state_parse(svn_branch_state_
                        apr_pool_t *scratch_pool)
 {
   char bid[1000];
-  int root_eid;
+  int root_eid, num_eids;
   svn_branch_state_t *branch_state;
   svn_branch_state_t *outer_branch;
   int outer_eid;
-  int eid;
+  int i;
 
-  SVN_ERR(parse_branch_line(bid, &root_eid,
+  SVN_ERR(parse_branch_line(bid, &root_eid, &num_eids,
                             stream, scratch_pool));
 
   /* Find the outer branch and outer EID */
@@ -1076,13 +1077,13 @@ svn_branch_state_parse(svn_branch_state_
 
   /* Read in the structure. Set the payload of each normal element to a
      (branch-relative) reference. */
-  for (eid = rev_root->first_eid; eid < rev_root->next_eid; eid++)
+  for (i = 0; i < num_eids; i++)
     {
-      int this_eid, this_parent_eid;
+      int eid, this_parent_eid;
       const char *this_name;
       svn_boolean_t is_subbranch;
 
-      SVN_ERR(parse_element_line(&this_eid,
+      SVN_ERR(parse_element_line(&eid,
                                  &is_subbranch, &this_parent_eid, &this_name,
                                  stream, scratch_pool));
 
@@ -1158,6 +1159,17 @@ svn_branch_revision_root_parse(svn_branc
   return SVN_NO_ERROR;
 }
 
+/* ### Duplicated in svnmover.c. */
+static int
+sort_compare_items_by_eid(const svn_sort__item_t *a,
+                          const svn_sort__item_t *b)
+{
+  int eid_a = *(const int *)a->key;
+  int eid_b = *(const int *)b->key;
+
+  return eid_a - eid_b;
+}
+
 /* Write to STREAM a parseable representation of BRANCH.
  */
 svn_error_t *
@@ -1165,36 +1177,30 @@ svn_branch_state_serialize(svn_stream_t
                            svn_branch_state_t *branch,
                            apr_pool_t *scratch_pool)
 {
-  svn_branch_revision_root_t *rev_root = branch->rev_root;
   const char *branch_root_rrpath = svn_branch_get_root_rrpath(branch,
                                                               scratch_pool);
-  int eid;
+  SVN_ITER_T(svn_branch_el_rev_content_t) *hi;
 
   SVN_ERR(svn_stream_printf(stream, scratch_pool,
-                            "%s root-eid %d  # at /%s\n",
+                            "%s root-eid %d num-eids %d  # at /%s\n",
                             svn_branch_get_id(branch, scratch_pool),
                             branch->root_eid,
+                            apr_hash_count(branch->e_map),
                             branch_root_rrpath));
 
   map_purge_orphans(branch->e_map, branch->root_eid, scratch_pool);
-  for (eid = rev_root->first_eid; eid < rev_root->next_eid; eid++)
+
+  for (SVN_HASH_ITER_SORTED(hi, branch->e_map, sort_compare_items_by_eid,
+                            scratch_pool))
     {
+      int eid = *(const int *)hi->key;
       svn_branch_el_rev_content_t *element = svn_branch_get_element(branch, eid);
       int parent_eid;
       const char *name;
 
-      if (element)
-        {
-          parent_eid = element->parent_eid;
-          name = element->name[0] ? element->name : ".";
-        }
-      else
-        {
-          /* ### TODO: instead, omit the line completely; but the
-                 parser currently can't handle that. */
-          parent_eid = -1;
-          name = "(null)";
-        }
+      SVN_ERR_ASSERT(element);
+      parent_eid = element->parent_eid;
+      name = element->name[0] ? element->name : ".";
       SVN_ERR(svn_stream_printf(stream, scratch_pool,
                                 "e%d: %s %d %s\n",
                                 eid,

Modified: subversion/branches/move-tracking-2/subversion/tests/cmdline/svntest/wc.py
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/tests/cmdline/svntest/wc.py?rev=1701374&r1=1701373&r2=1701374&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/tests/cmdline/svntest/wc.py (original)
+++ subversion/branches/move-tracking-2/subversion/tests/cmdline/svntest/wc.py Sat Sep  5 11:40:40 2015
@@ -120,7 +120,7 @@ _re_parse_commit = re.compile('^(\w+(  \
 _re_parse_eid_header = re.compile('^r(-1|[0-9]+): eids ([0-9]+) ([0-9]+) '
                                   'branches ([0-9]+)$')
 # B0.2 root-eid 3  # at /X
-_re_parse_eid_branch = re.compile('^B([0-9.]+) root-eid ([0-9]+)  # at /(.*)$')
+_re_parse_eid_branch = re.compile('^B([0-9.]+) root-eid ([0-9]+) num-eids ([0-9]+)  # at /(.*)$')
 # e4: normal 6 C
 _re_parse_eid_ele = re.compile('^e([0-9]+): (none|normal|subbranch) '
                                '(-1|[0-9]+) (.*)$')
@@ -838,7 +838,7 @@ class State:
         if match2:
           parent_branch_eid = branches[match2.group(1)]
         root_eid = match.group(2)
-        path = match.group(3)
+        path = match.group(4)
         branch = [branch_eid, parent_branch_eid, root_eid, path]
 
     branches[branch[0]] = branch