subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1638784 - in /subversion/branches/move-tracking-2/subversion: include/private/svn_editor3.h libsvn_delta/compat3.c svnmover/svnmover.c
Date Wed, 12 Nov 2014 13:18:04 GMT
Author: julianfoad
Date: Wed Nov 12 13:18:03 2014
New Revision: 1638784

URL: http://svn.apache.org/r1638784
Log:
On the 'move-tracking-2' branch: Sort the output of 'svnmover diff'.

* subversion/include/private/svn_editor3.h,
  subversion/libsvn_delta/compat3.c
  (svn_branch_get_path_by_eid): Make public; renamed from
    'branch_map_get_path_by_eid'. Update all callers.

* subversion/svnmover/svnmover.c
  (diff_item_t, diff_ordering): New.
  (svn_branch_diff): Sort the output before displaying.

Modified:
    subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
    subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.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=1638784&r1=1638783&r2=1638784&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 Wed Nov 12
13:18:03 2014
@@ -1751,8 +1751,23 @@ svn_branch_el_rev_content_equal(const sv
 const char *
 svn_branch_get_root_rrpath(const svn_branch_instance_t *branch);
 
+/* Return the branch-relative path of element EID in BRANCH.
+ *
+ * If the EID mapping does not currently have a complete path to EID,
+ * return NULL.
+ *
+ * ### A branch element's rrpath can change during the edit.
+ */
+const char *
+svn_branch_get_path_by_eid(const svn_branch_instance_t *branch,
+                           int eid,
+                           apr_pool_t *result_pool);
+
 /* Return the repos-relpath of element EID in BRANCH.
  *
+ * If the EID mapping does not currently have a complete path to EID,
+ * return NULL.
+ *
  * ### A branch element's rrpath can change during the edit.
  */
 const char *

Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c?rev=1638784&r1=1638783&r2=1638784&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c Wed Nov 12 13:18:03
2014
@@ -2138,14 +2138,8 @@ branch_map_purge_orphans(svn_branch_inst
   while (changed);
 }
 
-/* If the mapping has a complete path from the root to element EID,
- * return this path, relative to the branch root.
- *
- * If the EID mapping does not currently have a complete path to EID,
- * return NULL.
- */
-static const char *
-branch_map_get_path_by_eid(const svn_branch_instance_t *branch,
+const char *
+svn_branch_get_path_by_eid(const svn_branch_instance_t *branch,
                            int eid,
                            apr_pool_t *result_pool)
 {
@@ -2171,7 +2165,7 @@ svn_branch_get_rrpath_by_eid(const svn_b
                              int eid,
                              apr_pool_t *result_pool)
 {
-  const char *path = branch_map_get_path_by_eid(branch, eid, result_pool);
+  const char *path = svn_branch_get_path_by_eid(branch, eid, result_pool);
   const char *rrpath = NULL;
 
   if (path)
@@ -2197,7 +2191,7 @@ branch_map_get_eid_by_path(const svn_bra
        hi; hi = apr_hash_next(hi))
     {
       int eid = *(const int *)apr_hash_this_key(hi);
-      const char *this_path = branch_map_get_path_by_eid(branch, eid,
+      const char *this_path = svn_branch_get_path_by_eid(branch, eid,
                                                          scratch_pool);
 
       if (! this_path)
@@ -2521,7 +2515,7 @@ branch_add_new_branch_instance(svn_branc
   /* 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
-    = branch_map_get_path_by_eid(outer_branch, outer_eid, scratch_pool);
+    = 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);
 
@@ -2735,7 +2729,7 @@ svn_branch_instance_serialize(svn_stream
 
       if (node)
         {
-          path = branch_map_get_path_by_eid(branch, eid, scratch_pool);
+          path = svn_branch_get_path_by_eid(branch, eid, scratch_pool);
           SVN_ERR_ASSERT(path);
           parent_eid = node->parent_eid;
           name = node->name[0] ? node->name : ".";
@@ -3109,9 +3103,9 @@ element_relpath_in_subtree(const svn_bra
     eid >= subtree->branch->sibling_defn->family->first_eid
     && eid < subtree->branch->sibling_defn->family->next_eid);
 
-  subtree_path = branch_map_get_path_by_eid(subtree->branch, subtree->eid,
+  subtree_path = svn_branch_get_path_by_eid(subtree->branch, subtree->eid,
                                             scratch_pool);
-  element_path = branch_map_get_path_by_eid(subtree->branch, eid,
+  element_path = svn_branch_get_path_by_eid(subtree->branch, eid,
                                             scratch_pool);
 
   SVN_ERR_ASSERT_NO_RETURN(subtree_path);
@@ -4055,7 +4049,7 @@ svn_branch_branch(svn_editor3_t *editor,
                   const char *new_name,
                   apr_pool_t *scratch_pool)
 {
-  if (! branch_map_get_path_by_eid(from_branch, from_eid, scratch_pool))
+  if (! svn_branch_get_path_by_eid(from_branch, from_eid, scratch_pool))
     {
       return svn_error_createf(SVN_ERR_BRANCHING, NULL,
                                _("cannot branch from b%d e%d: "
@@ -4272,7 +4266,7 @@ convert_branch_to_paths(apr_hash_t *path
        hi; hi = apr_hash_next(hi))
     {
       int eid = *(const int *)apr_hash_this_key(hi);
-      const char *relpath = branch_map_get_path_by_eid(branch, eid, result_pool);
+      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);
       svn_branch_el_rev_id_t *ba = svn_hash_gets(paths, rrpath);

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=1638784&r1=1638783&r2=1638784&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Wed Nov 12 13:18:03
2014
@@ -772,6 +772,28 @@ svn_branch_diff_e(svn_editor3_t *editor,
   return SVN_NO_ERROR;
 }
 
+/*  */
+typedef struct diff_item_t
+{
+  char status_mod, status_reparent, status_rename;
+  const char *major_path;
+  const char *from;
+} diff_item_t;
+
+/*  */
+static int
+diff_ordering(const void *a, const void *b)
+{
+  const diff_item_t *item1 = *(void *const *)a, *item2 = *(void *const *)b;
+
+  /* Sort items with status 'D' before all others */
+  if ((item1->status_mod == 'D') != (item2->status_mod == 'D'))
+    return (item2->status_mod == 'D') - (item1->status_mod == 'D');
+
+  /* Sort by path */
+  return svn_path_compare_paths(item1->major_path, item2->major_path);
+}
+
 /* Display differences, referring to paths */
 static svn_error_t *
 svn_branch_diff(svn_editor3_t *editor,
@@ -781,6 +803,9 @@ svn_branch_diff(svn_editor3_t *editor,
 {
   apr_hash_t *diff_yca_tgt;
   int first_eid, next_eid, eid;
+  apr_array_header_t *diff_changes
+    = apr_array_make(scratch_pool, 0, sizeof(void *));
+  int i;
 
   if (left->branch->sibling_defn->family->fid
       != right->branch->sibling_defn->family->fid)
@@ -816,45 +841,65 @@ svn_branch_diff(svn_editor3_t *editor,
 
       if (e0 || e1)
         {
-          char status_mod = ' ', status_reparent = ' ', status_rename = ' ';
+          diff_item_t *item = apr_palloc(scratch_pool, sizeof(*item));
           const char *path0 = NULL, *path1 = NULL;
           const char *from = "";
 
+          item->status_mod = ' ';
+          item->status_reparent = ' ';
+          item->status_rename = ' ';
+
           if (e0 && e1)
             {
-              status_mod = 'M';
-              status_reparent = (e0->parent_eid != e1->parent_eid) ? 'v' : ' ';
-              status_rename  = (strcmp(e0->name, e1->name) != 0) ? 'r' : ' ';
+              item->status_mod = 'M';
+              item->status_reparent = (e0->parent_eid != e1->parent_eid) ? 'v' :
' ';
+              item->status_rename  = (strcmp(e0->name, e1->name) != 0) ? 'r' : '
';
             }
           else
             {
-              status_mod = e0 ? 'D' : 'A';
+              item->status_mod = e0 ? 'D' : 'A';
             }
           if (e0)
-            path0 = svn_branch_get_rrpath_by_eid(left->branch, eid, scratch_pool);
+            path0 = svn_branch_get_path_by_eid(left->branch, eid, scratch_pool);
           if (e1)
-            path1 = svn_branch_get_rrpath_by_eid(right->branch, eid, scratch_pool);
+            path1 = svn_branch_get_path_by_eid(right->branch, eid, scratch_pool);
           if (e0 && e1
               && (e0->parent_eid != e1->parent_eid
                   || strcmp(e0->name, e1->name) != 0))
             {
               if (e0->parent_eid == e1->parent_eid)
-                from = apr_psprintf(scratch_pool, " (renamed from .../%s)", e0->name);
+                from = apr_psprintf(scratch_pool,
+                                    " (renamed from .../%s)",
+                                    e0->name);
               else if (strcmp(e0->name, e1->name) == 0)
-                from = apr_psprintf(scratch_pool, " (moved from %s/...)",
-                                    svn_branch_get_rrpath_by_eid(left->branch,
-                                                                 e0->parent_eid,
-                                                                 scratch_pool));
+                from = apr_psprintf(scratch_pool,
+                                    " (moved from %s/...)",
+                                    svn_branch_get_path_by_eid(left->branch,
+                                                               e0->parent_eid,
+                                                               scratch_pool));
               else
-                from = apr_psprintf(scratch_pool, " (moved+renamed from %s)", path0);
+                from = apr_psprintf(scratch_pool,
+                                    " (moved+renamed from %s)",
+                                    path0);
             }
-          printf("%c%c%c %s%s\n",
-                 status_mod, status_reparent, status_rename,
-                 e1 ? path1 : path0,
-                 from);
+          item->major_path = (e1 ? path1 : path0);
+          item->from = from;
+          APR_ARRAY_PUSH(diff_changes, void *) = item;
         }
     }
 
+  svn_sort__array(diff_changes, diff_ordering);
+
+  for (i = 0; i < diff_changes->nelts; i++)
+    {
+      diff_item_t *item = APR_ARRAY_IDX(diff_changes, i, void *);
+
+      printf("%c%c%c %s%s\n",
+             item->status_mod, item->status_reparent, item->status_rename,
+             item->major_path,
+             item->from);
+    }
+
   return SVN_NO_ERROR;
 }
 



Mime
View raw message