You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/11/26 13:34:08 UTC

svn commit: r1771481 - /subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c

Author: stsp
Date: Sat Nov 26 13:34:08 2016
New Revision: 1771481

URL: http://svn.apache.org/viewvc?rev=1771481&view=rev
Log:
Merge a duplicated bit of code in the resolver into a helper function.

* subversion/libsvn_wc/wc_db_update_move.c
  (copy_working_node): New helper function.
  (tc_editor_incoming_add_directory, tc_editor_incoming_add_file): Use it.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c?rev=1771481&r1=1771480&r2=1771481&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_update_move.c Sat Nov 26 13:34:08 2016
@@ -765,6 +765,53 @@ tc_editor_add_directory(node_move_baton_
 }
 
 static svn_error_t *
+copy_working_node(const char *src_relpath,
+                  const char *dst_relpath,
+                  svn_wc__db_wcroot_t *wcroot,
+                  apr_pool_t *scratch_pool)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+  const char *dst_parent_relpath = svn_relpath_dirname(dst_relpath,
+                                                       scratch_pool);
+
+  /* Add a WORKING row for the new node, based on the source. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt,wcroot->sdb,
+                                    STMT_INSERT_WORKING_NODE_COPY_FROM));
+  SVN_ERR(svn_sqlite__bindf(stmt, "issdst", wcroot->wc_id, src_relpath,
+                            dst_relpath, relpath_depth(dst_relpath),
+                            dst_parent_relpath, presence_map,
+                            svn_wc__db_status_normal));
+  SVN_ERR(svn_sqlite__step_done(stmt));
+
+  /* Copy properties over.  ### This loses changelist association. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_ACTUAL_NODE));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, src_relpath));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (have_row)
+    {
+      apr_size_t props_size;
+      const char *properties;
+
+      properties = svn_sqlite__column_blob(stmt, 1, &props_size,
+                                           scratch_pool);
+      SVN_ERR(svn_sqlite__reset(stmt));
+      SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                        STMT_INSERT_ACTUAL_NODE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "issbs",
+                                wcroot->wc_id, dst_relpath,
+                                svn_relpath_dirname(dst_relpath,
+                                                    scratch_pool),
+                                properties, props_size, NULL));
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 tc_editor_incoming_add_directory(node_move_baton_t *nmb,
                                  const char *dst_relpath,
                                  svn_node_kind_t old_kind,
@@ -805,45 +852,8 @@ tc_editor_incoming_add_directory(node_mo
     }
   else
     {
-      svn_sqlite__stmt_t *stmt;
-      svn_boolean_t have_row;
-      const char *dst_parent_relpath = svn_relpath_dirname(dst_relpath,
-                                                           scratch_pool);
-
-      /* Add a WORKING row for the new dir, based on the source. */
-      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                        STMT_INSERT_WORKING_NODE_COPY_FROM));
-      SVN_ERR(svn_sqlite__bindf(stmt, "issdst",
-                    b->wcroot->wc_id, src_relpath,
-                    dst_relpath, relpath_depth(dst_relpath),
-                    dst_parent_relpath,
-                    presence_map, svn_wc__db_status_normal));
-      SVN_ERR(svn_sqlite__step_done(stmt));
-
-      /* Copy properties over.  ### This loses changelist association. */
-      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                        STMT_SELECT_ACTUAL_NODE));
-      SVN_ERR(svn_sqlite__bindf(stmt, "is", b->wcroot->wc_id, src_relpath));
-      SVN_ERR(svn_sqlite__step(&have_row, stmt));
-      if (have_row)
-        {
-          apr_size_t props_size;
-          const char *properties;
-
-          properties = svn_sqlite__column_blob(stmt, 1, &props_size,
-                                               scratch_pool);
-          SVN_ERR(svn_sqlite__reset(stmt));
-          SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                            STMT_INSERT_ACTUAL_NODE));
-          SVN_ERR(svn_sqlite__bindf(stmt, "issbs",
-                                    b->wcroot->wc_id, dst_relpath,
-                                    svn_relpath_dirname(dst_relpath,
-                                                        scratch_pool),
-                                    properties, props_size, NULL));
-          SVN_ERR(svn_sqlite__step(&have_row, stmt));
-        }
-      SVN_ERR(svn_sqlite__reset(stmt));
-
+      SVN_ERR(copy_working_node(src_relpath, dst_relpath, b->wcroot,
+                                scratch_pool));
       SVN_ERR(svn_wc__wq_build_dir_install(&work_item, b->db, dst_abspath,
                                            scratch_pool, scratch_pool));
     }
@@ -989,47 +999,14 @@ tc_editor_incoming_add_file(node_move_ba
     }
   else
     {
-      svn_sqlite__stmt_t *stmt;
-      svn_boolean_t have_row;
-      const char *dst_parent_relpath = svn_relpath_dirname(dst_relpath,
-                                                           scratch_pool);
-      const char *src_abspath = svn_dirent_join(b->wcroot->abspath,
-                                                src_relpath, scratch_pool);
-
-      /* Add a WORKING row for the new file, based on the source. */
-      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                        STMT_INSERT_WORKING_NODE_COPY_FROM));
-      SVN_ERR(svn_sqlite__bindf(stmt, "issdst",
-                    b->wcroot->wc_id, src_relpath,
-                    dst_relpath, relpath_depth(dst_relpath),
-                    dst_parent_relpath,
-                    presence_map, svn_wc__db_status_normal));
-      SVN_ERR(svn_sqlite__step_done(stmt));
-
-      /* Copy properties over.  ### This loses changelist association. */
-      SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                        STMT_SELECT_ACTUAL_NODE));
-      SVN_ERR(svn_sqlite__bindf(stmt, "is", b->wcroot->wc_id, src_relpath));
-      SVN_ERR(svn_sqlite__step(&have_row, stmt));
-      if (have_row)
-        {
-          apr_size_t props_size;
-          const char *properties;
-
-          properties = svn_sqlite__column_blob(stmt, 1, &props_size,
-                                               scratch_pool);
-          SVN_ERR(svn_sqlite__reset(stmt));
-          SVN_ERR(svn_sqlite__get_statement(&stmt, b->wcroot->sdb,
-                                            STMT_INSERT_ACTUAL_NODE));
-          SVN_ERR(svn_sqlite__bindf(stmt, "issbs",
-                                    b->wcroot->wc_id, dst_relpath,
-                                    svn_relpath_dirname(dst_relpath,
-                                                        scratch_pool),
-                                    properties, props_size, NULL));
-          SVN_ERR(svn_sqlite__step(&have_row, stmt));
-        }
+      const char *src_abspath;
+
+      SVN_ERR(copy_working_node(src_relpath, dst_relpath, b->wcroot,
+                                scratch_pool));
 
       /* Update working file. */
+      src_abspath = svn_dirent_join(b->wcroot->abspath, src_relpath,
+                                    scratch_pool);
       SVN_ERR(svn_wc__wq_build_file_install(&work_item, b->db, dst_abspath,
                                             src_abspath,
                                             FALSE /* FIXME: use_commit_times?*/,