On the 1.9.x-update-tc-detection branch: revert r1662089
git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/1.9.x-update-tc-detection@1662090 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_wc/wc-queries.sql b/subversion/libsvn_wc/wc-queries.sql
index a0e912b..257decc 100644
--- a/subversion/libsvn_wc/wc-queries.sql
+++ b/subversion/libsvn_wc/wc-queries.sql
@@ -344,8 +344,7 @@
-- STMT_SELECT_GE_OP_DEPTH_CHILDREN
SELECT 1 FROM nodes
WHERE wc_id = ?1 AND parent_relpath = ?2
- AND (op_depth > ?3 OR (op_depth = ?3
- AND presence IN (MAP_NORMAL, MAP_DELETED)))
+ AND (op_depth > ?3 OR (op_depth = ?3 AND presence != MAP_BASE_DELETED))
UNION ALL
SELECT 1 FROM ACTUAL_NODE a
WHERE wc_id = ?1 AND parent_relpath = ?2
@@ -1128,6 +1127,11 @@
UPDATE nodes SET repos_id = ?3, repos_path = ?4
WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
+-- STMT_ACTUAL_HAS_CHILDREN
+SELECT 1 FROM actual_node
+WHERE wc_id = ?1 AND parent_relpath = ?2
+LIMIT 1
+
-- STMT_INSERT_EXTERNAL
INSERT OR REPLACE INTO externals (
wc_id, local_relpath, parent_relpath, presence, kind, def_local_relpath,
diff --git a/subversion/libsvn_wc/wc_db.c b/subversion/libsvn_wc/wc_db.c
index d2d5445..118eefd 100644
--- a/subversion/libsvn_wc/wc_db.c
+++ b/subversion/libsvn_wc/wc_db.c
@@ -6821,7 +6821,20 @@
SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
if (affected_rows)
{
- /* An actual only node can't have descendants so we're done */
+ /* Can't do non-recursive actual-only revert if actual-only
+ children exist. Raise an error to cancel the transaction. */
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+ STMT_ACTUAL_HAS_CHILDREN));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR(svn_sqlite__reset(stmt));
+ if (have_row)
+ return svn_error_createf(SVN_ERR_WC_INVALID_OPERATION_DEPTH, NULL,
+ _("Can't revert '%s' without"
+ " reverting children"),
+ path_for_error_message(wcroot,
+ local_relpath,
+ scratch_pool));
return SVN_NO_ERROR;
}