Author: philip
Date: Mon Mar 21 19:43:54 2011
New Revision: 1083920

URL: http://svn.apache.org/viewvc?rev=1083920&view=rev
Log:
Make the new revert react to updates of actual rows as well as deletes,
make it delete conflict files.

* subversion/libsvn_wc/wc-queries.sql
  (remove_conflict_file): New.
  (revert_restore): Remove conflict files.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_CREATE_REVERT_CACHE): Add notify column and set it, rename delete
   trigger, add update trigger.
  (STMT_DROP_REVERT_CACHE_TRIGGERS): Drop update trigger.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_reverted): Check for notify column.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_reverted): Tweak comments.

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=1083920&r1=1083919&r2=1083920&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Mon Mar 21 19:43:54 2011
@@ -1334,6 +1334,21 @@ verify_revert_depth(svn_wc__db_t *db,
 
 #ifdef SVN_NEW_REVERT
 static svn_error_t *
+remove_conflict_file(const char *name,
+                     const char *local_abspath,
+                     apr_pool_t *scratch_pool)
+{
+  if (name)
+    {
+      const char *conflict_abspath
+        = svn_dirent_join(svn_dirent_dirname(local_abspath, scratch_pool),
+                          name, scratch_pool);
+      SVN_ERR(svn_io_remove_file2(conflict_abspath, TRUE, scratch_pool));
+    }
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 revert_restore(svn_wc__db_t *db,
                const char *revert_root,
                const char *local_abspath,
@@ -1477,7 +1492,10 @@ revert_restore(svn_wc__db_t *db,
       notify_required = TRUE;
     }
 
-  /* ### Tidy up conflict droppings */
+  SVN_ERR(remove_conflict_file(conflict_old, local_abspath, scratch_pool));
+  SVN_ERR(remove_conflict_file(conflict_new, local_abspath, scratch_pool));
+  SVN_ERR(remove_conflict_file(conflict_working, local_abspath, scratch_pool));
+  SVN_ERR(remove_conflict_file(prop_reject, 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=1083920&r1=1083919&r2=1083920&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Mon Mar 21 19:43:54 
2011
@@ -901,6 +901,7 @@ CREATE UNIQUE INDEX temp__node_props_cac
 SELECT local_relpath, kind, properties FROM temp__node_props_cache
 ORDER BY local_relpath
 
+/* Perhaps revert log would be a better term? */
 -- STMT_CREATE_REVERT_CACHE
 DROP TABLE IF EXISTS revert_cache;
 CREATE TEMPORARY TABLE revert_cache (
@@ -908,30 +909,50 @@ CREATE TEMPORARY TABLE revert_cache (
    conflict_old TEXT,
    conflict_new TEXT,
    conflict_working TEXT,
-   prop_reject TEXT
+   prop_reject TEXT,
+   notify INTEGER
    );
 DROP TRIGGER IF EXISTS trigger_revert_cache_nodes;
 CREATE TEMPORARY TRIGGER trigger_revert_cache_nodes
 BEFORE DELETE ON nodes
 BEGIN
-   INSERT OR REPLACE INTO revert_cache(local_relpath) SELECT OLD.local_relpath;
+   INSERT OR REPLACE INTO revert_cache(local_relpath, notify)
+   SELECT OLD.local_relpath, 1;
 END;
 DROP TRIGGER IF EXISTS trigger_revert_cache_actual;
-CREATE TEMPORARY TRIGGER trigger_revert_cache_actual
+CREATE TEMPORARY TRIGGER trigger_revert_cache_actual_delete
 BEFORE DELETE ON actual_node
 BEGIN
-   INSERT OR REPLACE INTO revert_cache
+   INSERT OR REPLACE INTO revert_cache(local_relpath, conflict_old,
+                                       conflict_new, conflict_working,
+                                       prop_reject)
    SELECT OLD.local_relpath,
           OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
           OLD.prop_reject;
+   UPDATE revert_cache SET notify = 1
+   WHERE OLD.properties IS NOT NULL;
+END;
+DROP TRIGGER IF EXISTS trigger_revert_cache_update;
+CREATE TEMPORARY TRIGGER trigger_revert_cache_actual_update
+BEFORE UPDATE ON actual_node
+BEGIN
+   INSERT OR REPLACE INTO revert_cache(local_relpath, conflict_old,
+                                       conflict_new, conflict_working,
+                                       prop_reject)
+   SELECT OLD.local_relpath,
+          OLD.conflict_old, OLD.conflict_new, OLD.conflict_working,
+          OLD.prop_reject;
+   UPDATE revert_cache SET notify = 1
+   WHERE OLD.properties IS NOT NULL;
 END
 
 -- STMT_DROP_REVERT_CACHE_TRIGGERS
 DROP TRIGGER IF EXISTS trigger_revert_cache_nodes;
-DROP TRIGGER IF EXISTS trigger_revert_cache_actual;
+DROP TRIGGER IF EXISTS trigger_revert_cache_actual_delete;
+DROP TRIGGER IF EXISTS trigger_revert_cache_actual_update;
 
 -- STMT_SELECT_REVERT_CACHE
-SELECT conflict_old, conflict_new, conflict_working, prop_reject
+SELECT conflict_old, conflict_new, conflict_working, prop_reject, notify
 FROM revert_cache
 WHERE local_relpath = ?1
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1083920&r1=1083919&r2=1083920&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Mon Mar 21 19:43:54 2011
@@ -3701,7 +3701,7 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
   VERIFY_USABLE_WCROOT(wcroot);
 
   /* We MUST remove the triggers and not leave them to affect subsequent
-     deletes. */
+     operations. */
   err = svn_sqlite__exec_statements(wcroot->sdb, STMT_CREATE_REVERT_CACHE);
   if (err)
     return svn_error_compose_create(err,
@@ -3744,7 +3744,7 @@ svn_wc__db_reverted(svn_boolean_t *rever
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (have_row)
     {
-      *reverted = TRUE;
+      *reverted = !svn_sqlite__column_is_null(stmt, 4);
       *conflict_new = svn_sqlite__column_text(stmt, 0, result_pool);
       *conflict_old = svn_sqlite__column_text(stmt, 1, result_pool);
       *conflict_working = svn_sqlite__column_text(stmt, 2, result_pool);

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1083920&r1=1083919&r2=1083920&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Mon Mar 21 19:43:54 2011
@@ -1260,9 +1260,10 @@ svn_wc__db_op_revert(svn_wc__db_t *db,
                      apr_pool_t *result_pool,
                      apr_pool_t *scratch_pool);
 
-/* Query the revert cache for LOCAL_ABSPATH and set *REVERTED if the path
- * was reverted.  If it was reverted set *CONFLICT_OLD, *CONFLICT_NEW,
- * *CONFLICT_WORKING and *PROP_REJECT to the names of the files.
+/* Query the revert cache 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.
  */
 svn_error_t *
 svn_wc__db_reverted(svn_boolean_t *reverted,


Reply via email to