You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2012/07/04 19:47:45 UTC

svn commit: r1357348 - in /subversion/trunk/subversion/libsvn_wc: adm_ops.c wc-queries.sql wc_db.c wc_db.h

Author: rhuijben
Date: Wed Jul  4 17:47:44 2012
New Revision: 1357348

URL: http://svn.apache.org/viewvc?rev=1357348&view=rev
Log:
Make the conflict handling in the revert code ready for conflict skels
by using an array of marker paths instead of specific markers.
(This also allows a simple loop in the callers)

* subversion/libsvn_wc/adm_ops.c
  (revert_restore): Update caller. Loop over the conflict markers.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_CREATE_REVERT_LIST):
        Add conflict_data blob and fill it in the triggers.
  (STMT_SELECT_REVERT_LIST): Reorder columns to move the conflicts at the
        end.

* subversion/libsvn_wc/wc_db.c
  (revert_list_read_baton): Store marker list.
  (revert_list_read): Collect a list of markers and add conflict skel code.
  (svn_wc__db_revert_list_read): Use marker list.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_revert_list_read): Update prototype and documentation.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1357348&r1=1357347&r2=1357348&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Wed Jul  4 17:47:44 2012
@@ -1609,10 +1609,7 @@ revert_restore(svn_wc__db_t *db,
   svn_kind_t kind;
   svn_node_kind_t on_disk;
   svn_boolean_t notify_required;
-  const char *conflict_old;
-  const char *conflict_new;
-  const char *conflict_working;
-  const char *prop_reject;
+  const apr_array_header_t *conflict_files;
   svn_filesize_t recorded_size;
   apr_time_t recorded_mod_time;
   apr_finfo_t finfo;
@@ -1626,8 +1623,7 @@ revert_restore(svn_wc__db_t *db,
     SVN_ERR(cancel_func(cancel_baton));
 
   SVN_ERR(svn_wc__db_revert_list_read(&notify_required,
-                                      &conflict_old, &conflict_new,
-                                      &conflict_working, &prop_reject,
+                                      &conflict_files,
                                       &copied_here, &reverted_kind,
                                       db, local_abspath,
                                       scratch_pool, scratch_pool));
@@ -1894,14 +1890,17 @@ revert_restore(svn_wc__db_t *db,
       notify_required = TRUE;
     }
 
-  SVN_ERR(remove_conflict_file(&notify_required, conflict_old,
-                               local_abspath, scratch_pool));
-  SVN_ERR(remove_conflict_file(&notify_required, conflict_new,
-                               local_abspath, scratch_pool));
-  SVN_ERR(remove_conflict_file(&notify_required, conflict_working,
-                               local_abspath, scratch_pool));
-  SVN_ERR(remove_conflict_file(&notify_required, prop_reject,
-                               local_abspath, scratch_pool));
+  if (conflict_files)
+    {
+      int i;
+      for (i = 0; i < conflict_files->nelts; i++)
+        {
+          SVN_ERR(remove_conflict_file(&notify_required,
+                                       APR_ARRAY_IDX(conflict_files, i,
+                                                     const char *),
+                                       local_abspath, scratch_pool));
+        }
+    }
 
   if (notify_func && notify_required)
     notify_func(notify_baton,

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1357348&r1=1357347&r2=1357348&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Jul  4 17:47:44 2012
@@ -1123,6 +1123,7 @@ CREATE TEMPORARY TABLE revert_list (
    /* need wc_id if/when revert spans multiple working copies */
    local_relpath TEXT NOT NULL,
    actual INTEGER NOT NULL,         /* 1 if an actual row, 0 if a nodes row */
+   conflict_data BLOB,
    conflict_old TEXT,
    conflict_new TEXT,
    conflict_working TEXT,
@@ -1145,28 +1146,30 @@ DROP TRIGGER IF EXISTS   trigger_revert_
 CREATE TEMPORARY TRIGGER trigger_revert_list_actual_delete
 BEFORE DELETE ON actual_node
 BEGIN
-   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old,
-                                       conflict_new, conflict_working,
-                                       prop_reject, notify)
-   SELECT OLD.local_relpath, 1,
+   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_data,
+                                      conflict_old, conflict_new,
+                                      conflict_working, prop_reject, notify)
+   SELECT OLD.local_relpath, 1, OLD.conflict_data,
           OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
           OLD.prop_reject,
           CASE
-          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL
+          WHEN OLD.properties IS NOT NULL
+            OR OLD.tree_conflict_data IS NOT NULL
           THEN 1 ELSE NULL END;
 END;
 DROP TRIGGER IF EXISTS   trigger_revert_list_actual_update;
 CREATE TEMPORARY TRIGGER trigger_revert_list_actual_update
 BEFORE UPDATE ON actual_node
 BEGIN
-   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_old,
-                                       conflict_new, conflict_working,
-                                       prop_reject, notify)
-   SELECT OLD.local_relpath, 1,
+   INSERT OR REPLACE INTO revert_list(local_relpath, actual, conflict_data,
+                                      conflict_old, conflict_new,
+                                      conflict_working, prop_reject, notify)
+   SELECT OLD.local_relpath, 1, OLD.conflict_data,
           OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
           OLD.prop_reject,
           CASE
-          WHEN OLD.properties IS NOT NULL OR OLD.tree_conflict_data IS NOT NULL
+          WHEN OLD.properties IS NOT NULL
+            OR OLD.tree_conflict_data IS NOT NULL
           THEN 1 ELSE NULL END;
 END
 
@@ -1176,8 +1179,8 @@ DROP TRIGGER IF EXISTS trigger_revert_li
 DROP TRIGGER IF EXISTS trigger_revert_list_actual_update
 
 -- STMT_SELECT_REVERT_LIST
-SELECT conflict_old, conflict_new, conflict_working, prop_reject, notify,
-       actual, op_depth, repos_id, kind
+SELECT actual, notify, kind, op_depth, repos_id, conflict_data,
+       conflict_old, conflict_new, conflict_working, prop_reject
 FROM revert_list
 WHERE local_relpath = ?1
 ORDER BY actual DESC

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1357348&r1=1357347&r2=1357348&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jul  4 17:47:44 2012
@@ -5951,10 +5951,7 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
 
 struct revert_list_read_baton {
   svn_boolean_t *reverted;
-  const char **conflict_old;
-  const char **conflict_new;
-  const char **conflict_working;
-  const char **prop_reject;
+  apr_array_header_t *marker_paths;
   svn_boolean_t *copied_here;
   svn_kind_t *kind;
   apr_pool_t *result_pool;
@@ -5971,8 +5968,7 @@ revert_list_read(void *baton,
   svn_boolean_t have_row;
 
   *(b->reverted) = FALSE;
-  *(b->conflict_new) = *(b->conflict_old) = *(b->conflict_working) = NULL;
-  *(b->prop_reject) = NULL;
+  b->marker_paths = NULL;
   *(b->copied_here) = FALSE;
   *(b->kind) = svn_kind_unknown;
 
@@ -5982,37 +5978,59 @@ revert_list_read(void *baton,
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (have_row)
     {
-      svn_boolean_t is_actual = svn_sqlite__column_boolean(stmt, 5);
+      svn_boolean_t is_actual = svn_sqlite__column_boolean(stmt, 0);
       svn_boolean_t another_row = FALSE;
 
       if (is_actual)
         {
-          if (!svn_sqlite__column_is_null(stmt, 4))
-            *(b->reverted) = TRUE;
+#if SVN_WC__VERSION < SVN_WC__USES_CONFLICT_SKELS
+          int i;
+
+          for (i = 6; i <= 9; i++)
+            {
+              const char *relpath = svn_sqlite__column_text(stmt, i, NULL);
+
+              if (! relpath)
+                continue;
 
-          if (!svn_sqlite__column_is_null(stmt, 0))
-            *(b->conflict_new)
-              = svn_dirent_join(wcroot->abspath,
-                                svn_sqlite__column_text(stmt, 0, NULL),
-                                b->result_pool);
-
-          if (!svn_sqlite__column_is_null(stmt, 1))
-            *(b->conflict_old)
-              = svn_dirent_join(wcroot->abspath,
-                                svn_sqlite__column_text(stmt, 1, NULL),
-                                b->result_pool);
-
-          if (!svn_sqlite__column_is_null(stmt, 2))
-            *(b->conflict_working)
-              = svn_dirent_join(wcroot->abspath,
-                                svn_sqlite__column_text(stmt, 2, NULL),
-                                b->result_pool);
-
-          if (!svn_sqlite__column_is_null(stmt, 3))
-            *(b->prop_reject)
-              = svn_dirent_join(wcroot->abspath,
-                                svn_sqlite__column_text(stmt, 3, NULL),
-                                b->result_pool);
+              if (!b->marker_paths)
+                b->marker_paths = apr_array_make(b->result_pool, 4,
+                                                 sizeof(const char*));
+
+              APR_ARRAY_PUSH(b->marker_paths, const char *)
+                  = svn_dirent_join(wcroot->abspath, relpath, b->result_pool);
+            }
+#else
+          apr_size_t conflict_len;
+          const void *conflict_data;
+
+          conflict_data = svn_sqlite__column_blob(stmt, 5, &conflict_len);
+          if (conflict_data)
+            {
+              svn_boolean_t tree_conflicted;
+              svn_skel_t *conflicts = svn_skel__parse(conflict_data,
+                                                      conflict_len,
+                                                      scratch_pool);
+
+              SVN_ERR(svn_wc__conflict_read_markers(&b->marker_paths,
+                                                    b->db, wcroot->abspath,
+                                                    conflicts,
+                                                    result_pool,
+                                                    scratch_pool));
+
+              SVN_ERR(svn_wc__conflict_read_info(NULL, NULL,
+                                                 NULL, NULL, &tree_conflicted,
+                                                 b->db, wcroot->abspath,
+                                                 conflicts,
+                                                 result_pool, scratch_pool));
+
+              if (tree_conflicted)
+                *(b->reverted) = TRUE;
+            }
+#endif
+
+          if (!svn_sqlite__column_is_null(stmt, 1)) /* notify */
+            *(b->reverted) = TRUE;
 
           SVN_ERR(svn_sqlite__step(&another_row, stmt));
         }
@@ -6020,12 +6038,12 @@ revert_list_read(void *baton,
       if (!is_actual || another_row)
         {
           *(b->reverted) = TRUE;
-          if (!svn_sqlite__column_is_null(stmt, 7))
+          if (!svn_sqlite__column_is_null(stmt, 4)) /* repos_id */
             {
-              int op_depth = svn_sqlite__column_int(stmt, 6);
+              int op_depth = svn_sqlite__column_int(stmt, 3);
               *(b->copied_here) = (op_depth == relpath_depth(local_relpath));
             }
-          *(b->kind) = svn_sqlite__column_token(stmt, 8, kind_map);
+          *(b->kind) = svn_sqlite__column_token(stmt, 2, kind_map);
         }
 
     }
@@ -6044,10 +6062,7 @@ revert_list_read(void *baton,
 
 svn_error_t *
 svn_wc__db_revert_list_read(svn_boolean_t *reverted,
-                            const char **conflict_old,
-                            const char **conflict_new,
-                            const char **conflict_working,
-                            const char **prop_reject,
+                            const apr_array_header_t **marker_files,
                             svn_boolean_t *copied_here,
                             svn_kind_t *kind,
                             svn_wc__db_t *db,
@@ -6060,10 +6075,6 @@ svn_wc__db_revert_list_read(svn_boolean_
   struct revert_list_read_baton b;
 
   b.reverted = reverted;
-  b.conflict_old = conflict_old;
-  b.conflict_new = conflict_new;
-  b.conflict_working = conflict_working;
-  b.prop_reject = prop_reject;
   b.copied_here = copied_here;
   b.kind = kind;
   b.result_pool = result_pool;
@@ -6074,6 +6085,7 @@ svn_wc__db_revert_list_read(svn_boolean_
 
   SVN_ERR(svn_wc__db_with_txn(wcroot, local_relpath, revert_list_read, &b,
                               scratch_pool));
+  *marker_files = b.marker_paths;
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1357348&r1=1357347&r2=1357348&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Jul  4 17:47:44 2012
@@ -1553,9 +1553,8 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
                      apr_pool_t *scratch_pool);
 
 /* Query the revert list for LOCAL_ABSPATH and set *REVERTED if the
- * path was reverted.  Set *CONFLICT_OLD, *CONFLICT_NEW,
- * *CONFLICT_WORKING and *PROP_REJECT to the names of the conflict
- * files, or NULL if the names are not stored.
+ * path was reverted.  Set *MARKER_FILES to a const char *list of
+ * marker files if any were recorded on LOCAL_ABSPATH.
  *
  * Set *COPIED_HERE if the reverted node was copied here and is the
  * operation root of the copy.
@@ -1565,10 +1564,7 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
  */
 svn_error_t *
 svn_wc__db_revert_list_read(svn_boolean_t *reverted,
-                            const char **conflict_old,
-                            const char **conflict_new,
-                            const char **conflict_working,
-                            const char **prop_reject,
+                            const apr_array_header_t **marker_files,
                             svn_boolean_t *copied_here,
                             svn_kind_t *kind,
                             svn_wc__db_t *db,