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 2013/02/04 21:48:13 UTC

svn commit: r1442344 [21/39] - in /subversion/branches/fsfs-format7: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ build/win32/ contrib/client-side/emacs/ contrib/server-side/fsfsfixer/fixer/ contrib/server-side/svncutter/ doc/...

Modified: subversion/branches/fsfs-format7/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_wc/wc-queries.sql?rev=1442344&r1=1442343&r2=1442344&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_wc/wc-queries.sql Mon Feb  4 20:48:05 2013
@@ -96,9 +96,9 @@ FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
 
 -- STMT_SELECT_LOWEST_WORKING_NODE
-SELECT op_depth, presence
+SELECT op_depth, presence, kind, moved_to
 FROM nodes
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3
 ORDER BY op_depth
 LIMIT 1
 
@@ -157,7 +157,7 @@ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, 
 SELECT local_relpath, kind FROM nodes n
 WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0
-  AND presence in ('normal', 'incomplete')
+  AND presence in (MAP_NORMAL, MAP_INCOMPLETE)
   AND NOT EXISTS(SELECT 1 FROM NODES w
                  WHERE w.wc_id = ?1 AND w.local_relpath = n.local_relpath
                    AND op_depth > 0)
@@ -168,7 +168,7 @@ SELECT local_relpath, kind, checksum, tr
 FROM nodes n
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND presence in ('normal', 'incomplete')
+  AND presence in (MAP_NORMAL, MAP_INCOMPLETE)
   AND op_depth = (SELECT MAX(op_depth)
                   FROM NODES w
                   WHERE w.wc_id = ?1
@@ -198,12 +198,12 @@ WHERE wc_id = ?1 AND IS_STRICT_DESCENDAN
                  WHERE w.wc_id = ?1
                    AND w.local_relpath = actual_node.local_relpath
                    AND op_depth > 0
-                   AND presence in ('normal', 'incomplete', 'not-present'))
+                   AND presence in (MAP_NORMAL, MAP_INCOMPLETE, MAP_NOT_PRESENT))
 
 -- STMT_DELETE_WORKING_BASE_DELETE
 DELETE FROM nodes
 WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND presence = 'base-deleted'
+  AND presence = MAP_BASE_DELETED
   AND op_depth > 0
   AND op_depth = (SELECT MIN(op_depth) FROM nodes n
                     WHERE n.wc_id = ?1
@@ -220,15 +220,61 @@ DELETE FROM nodes
 WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0
 
+-- STMT_DELETE_WORKING_OP_DEPTH
+DELETE FROM nodes
+WHERE wc_id = ?1 
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND op_depth = ?3
+
+-- STMT_DELETE_WORKING_OP_DEPTH_ABOVE
+DELETE FROM nodes
+WHERE wc_id = ?1 
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND op_depth > ?3
+
+-- STMT_SELECT_LOCAL_RELPATH_OP_DEPTH
+SELECT local_relpath
+FROM nodes
+WHERE wc_id = ?1
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND op_depth = ?3
+
+-- STMT_SELECT_CHILDREN_OP_DEPTH
+SELECT local_relpath, kind
+FROM nodes
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND op_depth = ?3
+ORDER BY local_relpath DESC
+
+-- STMT_COPY_NODE_MOVE
+INSERT OR REPLACE INTO nodes (
+    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
+    revision, presence, depth, kind, changed_revision, changed_date,
+    changed_author, checksum, properties, translated_size, last_mod_time,
+    symlink_target, moved_here, moved_to )
+SELECT
+    wc_id, ?4 /*local_relpath */, ?5 /*op_depth*/, ?6 /* parent_relpath */,
+    repos_id,
+    repos_path, revision, presence, depth, kind, changed_revision,
+    changed_date, changed_author, checksum, properties, translated_size,
+    last_mod_time, symlink_target, 1,
+    (SELECT dst.moved_to FROM nodes AS dst
+                         WHERE dst.wc_id = ?1
+                         AND dst.local_relpath = ?4
+                         AND dst.op_depth = ?5)
+FROM nodes
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
+
 -- STMT_SELECT_OP_DEPTH_CHILDREN
-SELECT local_relpath FROM nodes
+SELECT local_relpath, kind FROM nodes
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = ?3
   AND (?3 != 0 OR file_external is NULL)
 
 -- 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 != 'base-deleted'))
+  AND (op_depth > ?3 OR (op_depth = ?3 AND presence != MAP_BASE_DELETED))
 UNION ALL
 SELECT 1 FROM ACTUAL_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2
@@ -239,21 +285,21 @@ DELETE FROM nodes
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND (op_depth < ?3
-       OR (op_depth = ?3 AND presence = 'base-deleted'))
+       OR (op_depth = ?3 AND presence = MAP_BASE_DELETED))
 
 /* Get not-present descendants of a copied node. Not valid for the wc-root */
 -- STMT_SELECT_NOT_PRESENT_DESCENDANTS
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1 AND op_depth = ?3
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND presence = 'not-present'
+  AND presence = MAP_NOT_PRESENT
 
 -- STMT_COMMIT_DESCENDANT_TO_BASE
 UPDATE NODES SET op_depth = 0, repos_id = ?4, repos_path = ?5, revision = ?6,
   moved_here = NULL, moved_to = NULL, dav_cache = NULL,
-  presence = CASE presence WHEN 'normal' THEN 'normal'
-                           WHEN 'excluded' THEN 'excluded'
-                           ELSE 'not-present' END
+  presence = CASE presence WHEN MAP_NORMAL THEN MAP_NORMAL
+                           WHEN MAP_EXCLUDED THEN MAP_EXCLUDED
+                           ELSE MAP_NOT_PRESENT END
 WHERE wc_id = ?1 AND local_relpath = ?2 and op_depth = ?3
 
 -- STMT_SELECT_NODE_CHILDREN
@@ -274,11 +320,7 @@ WHERE wc_id = ?1 AND parent_relpath = ?2
        OR
        (op_depth = (SELECT MAX(op_depth) FROM nodes
                     WHERE wc_id = ?1 AND local_relpath = ?2)
-        AND presence != 'base-deleted'))
-
--- STMT_SELECT_BASE_PROPS
-SELECT properties FROM nodes
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
+        AND presence != MAP_BASE_DELETED))
 
 -- STMT_SELECT_NODE_PROPS
 SELECT properties, presence FROM nodes
@@ -289,17 +331,6 @@ ORDER BY op_depth DESC
 SELECT properties FROM actual_node
 WHERE wc_id = ?1 AND local_relpath = ?2
 
--- STMT_UPDATE_NODE_BASE_PROPS
-UPDATE nodes SET properties = ?3
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
-
--- STMT_UPDATE_NODE_WORKING_PROPS
-UPDATE nodes SET properties = ?3
-WHERE wc_id = ?1 AND local_relpath = ?2
-  AND op_depth =
-   (SELECT MAX(op_depth) FROM nodes
-    WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0)
-
 -- STMT_UPDATE_ACTUAL_PROPS
 UPDATE actual_node SET properties = ?3
 WHERE wc_id = ?1 AND local_relpath = ?2
@@ -344,7 +375,7 @@ WHERE work.wc_id = ?1 AND work.local_rel
 LIMIT 1
 
 -- STMT_SELECT_DELETION_INFO_SCAN
-/* ### FIXME.  modes_move.moved_to IS NOT NULL works when there is
+/* ### FIXME.  moved.moved_to IS NOT NULL works when there is
  only one move but we need something else when there are several. */
 SELECT (SELECT b.presence FROM nodes AS b
          WHERE b.wc_id = ?1 AND b.local_relpath = ?2 AND b.op_depth = 0),
@@ -408,10 +439,6 @@ WHERE wc_id = ?1 AND local_relpath = ?2
   AND op_depth = (SELECT MAX(op_depth) FROM nodes
                   WHERE wc_id = ?1 AND local_relpath = ?2)
 
--- STMT_UPDATE_NODE_FILEINFO_OPDEPTH
-UPDATE nodes SET translated_size = ?3, last_mod_time = ?4
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?5
-
 -- STMT_INSERT_ACTUAL_CONFLICT
 INSERT INTO actual_node (wc_id, local_relpath, conflict_data, parent_relpath)
 VALUES (?1, ?2, ?3, ?4)
@@ -427,7 +454,7 @@ WHERE wc_id = ?1
   AND local_relpath = (SELECT local_relpath FROM targets_list AS t
                        WHERE wc_id = ?1
                          AND t.local_relpath = actual_node.local_relpath
-                         AND kind = 'file')
+                         AND kind = MAP_FILE)
 
 -- STMT_UPDATE_ACTUAL_CLEAR_CHANGELIST
 UPDATE actual_node SET changelist = NULL
@@ -440,7 +467,7 @@ SELECT wc_id, local_relpath, 7, ?3
 FROM targets_list
 WHERE wc_id = ?1
   AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
-  AND kind = 'dir'
+  AND kind = MAP_DIR
 
 -- STMT_RESET_ACTUAL_WITH_CHANGELIST
 REPLACE INTO actual_node (
@@ -479,10 +506,6 @@ BEGIN
    WHERE new.changelist IS NOT NULL;
 END
 
--- STMT_INSERT_CHANGELIST_LIST
-INSERT INTO changelist_list(wc_id, local_relpath, notify, changelist)
-VALUES (?1, ?2, ?3, ?4)
-
 -- STMT_FINALIZE_CHANGELIST
 DROP TRIGGER trigger_changelist_list_change;
 DROP TABLE changelist_list;
@@ -520,7 +543,7 @@ SELECT wc_id, local_relpath, parent_relp
 FROM nodes_current
 WHERE wc_id = ?1
   AND parent_relpath = ?2
-  AND kind = 'file'
+  AND kind = MAP_FILE
 
 -- STMT_INSERT_TARGET_DEPTH_IMMEDIATES
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
@@ -552,7 +575,7 @@ SELECT N.wc_id, N.local_relpath, N.paren
     ON A.wc_id = N.wc_id AND A.local_relpath = N.local_relpath
  WHERE N.wc_id = ?1
    AND N.parent_relpath = ?2
-   AND kind = 'file'
+   AND kind = MAP_FILE
    AND A.changelist = ?3
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST_DEPTH_IMMEDIATES
@@ -620,8 +643,8 @@ WHERE wc_id = ?1 AND local_relpath = ?2
 DELETE FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2
   AND op_depth = (SELECT MIN(op_depth) FROM nodes
-                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > 0)
-  AND presence = 'base-deleted'
+                  WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3)
+  AND presence = MAP_BASE_DELETED
 
 -- STMT_DELETE_ALL_LAYERS
 DELETE FROM nodes
@@ -652,7 +675,7 @@ WHERE wc_id = ?1
   AND (changelist IS NULL
        OR NOT EXISTS (SELECT 1 FROM nodes_current c
                       WHERE c.wc_id = ?1 AND c.local_relpath = ?2
-                        AND c.kind = 'file'))
+                        AND c.kind = MAP_FILE))
 
 -- STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE
 DELETE FROM actual_node
@@ -663,7 +686,7 @@ WHERE wc_id = ?1
        OR NOT EXISTS (SELECT 1 FROM nodes_current c
                       WHERE c.wc_id = ?1 
                         AND c.local_relpath = actual_node.local_relpath
-                        AND c.kind = 'file'))
+                        AND c.kind = MAP_FILE))
 
 -- STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST
 UPDATE actual_node
@@ -692,7 +715,7 @@ WHERE wc_id = ?1
 -- STMT_UPDATE_NODE_BASE_DEPTH
 UPDATE nodes SET depth = ?3
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
-  AND kind='dir'
+  AND kind=MAP_DIR
 
 -- STMT_UPDATE_NODE_BASE_PRESENCE
 UPDATE nodes SET presence = ?3
@@ -746,6 +769,28 @@ WHERE refcount = 0
 DELETE FROM pristine
 WHERE checksum = ?1 AND refcount = 0
 
+-- STMT_SELECT_COPY_PRISTINES
+/* For the root itself */
+SELECT n.checksum, md5_checksum, size
+FROM nodes_current n
+LEFT JOIN pristine p ON n.checksum = p.checksum
+WHERE wc_id = ?1
+  AND n.local_relpath = ?2
+  AND n.checksum IS NOT NULL
+UNION ALL
+/* And all descendants */
+SELECT n.checksum, md5_checksum, size
+FROM nodes n
+LEFT JOIN pristine p ON n.checksum = p.checksum
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(n.local_relpath, ?2)
+  AND op_depth >=
+      (SELECT MAX(op_depth) FROM nodes WHERE wc_id = ?1 AND local_relpath = ?2)
+  AND n.checksum IS NOT NULL
+
+-- STMT_VACUUM
+VACUUM
+
 -- STMT_SELECT_CONFLICT_VICTIMS
 SELECT local_relpath, conflict_data
 FROM actual_node
@@ -811,23 +856,20 @@ VALUES (?1, ?2, 0,
 INSERT OR REPLACE INTO nodes (
     wc_id, local_relpath, op_depth,
     parent_relpath, presence, kind)
-SELECT wc_id, local_relpath, ?3 /*op_depth*/,
-       parent_relpath, ?4 /*presence*/, kind
-FROM nodes
-WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
+VALUES(?1, ?2, ?3, ?4, MAP_BASE_DELETED, ?5)
 
 /* If this query is updated, STMT_INSERT_DELETE_LIST should too. */
 -- STMT_INSERT_DELETE_FROM_NODE_RECURSIVE
 INSERT INTO nodes (
     wc_id, local_relpath, op_depth, parent_relpath, presence, kind)
-SELECT wc_id, local_relpath, ?4 /*op_depth*/, parent_relpath, 'base-deleted',
+SELECT wc_id, local_relpath, ?4 /*op_depth*/, parent_relpath, MAP_BASE_DELETED,
        kind
 FROM nodes
 WHERE wc_id = ?1
   AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = ?3
-  AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'server-excluded')
+  AND presence NOT IN (MAP_BASE_DELETED, MAP_NOT_PRESENT, MAP_EXCLUDED, MAP_SERVER_EXCLUDED)
 
 -- STMT_INSERT_WORKING_NODE_FROM_BASE_COPY
 INSERT INTO nodes (
@@ -846,7 +888,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 INSERT INTO nodes (
     wc_id, local_relpath, op_depth, parent_relpath, presence, kind)
 SELECT wc_id, local_relpath, ?3 /*op_depth*/, parent_relpath,
-    'base-deleted', kind
+    MAP_BASE_DELETED, kind
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
@@ -857,6 +899,12 @@ WHERE wc_id = ?1
  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
  AND op_depth = ?3
 
+-- STMT_UPDATE_OP_DEPTH_RECURSIVE
+UPDATE nodes SET op_depth = ?4, moved_here = NULL
+WHERE wc_id = ?1
+ AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+ AND op_depth = ?3
+
 -- STMT_DOES_NODE_EXIST
 SELECT 1 FROM nodes WHERE wc_id = ?1 AND local_relpath = ?2
 LIMIT 1
@@ -865,7 +913,7 @@ LIMIT 1
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND op_depth = 0 AND presence = 'server-excluded'
+  AND op_depth = 0 AND presence = MAP_SERVER_EXCLUDED
 LIMIT 1
 
 /* Select all excluded nodes. Not valid on the WC-root */
@@ -874,7 +922,7 @@ SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
   AND op_depth = 0
-  AND (presence = 'server-excluded' OR presence = 'excluded')
+  AND (presence = MAP_SERVER_EXCLUDED OR presence = MAP_EXCLUDED)
 
 /* Creates a copy from one top level NODE to a different location */
 -- STMT_INSERT_WORKING_NODE_COPY_FROM
@@ -949,7 +997,7 @@ WHERE wc_id = ?1
 DELETE FROM externals
 WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND kind != 'dir'
+  AND kind != MAP_DIR
 
 -- STMT_DELETE_EXTERNAL_REGISTATIONS
 DELETE FROM externals
@@ -964,29 +1012,44 @@ WHERE wc_id = ?1
  * Arguments:
  *  ?1: wc_id.
  *  ?2: the target path, local relpath inside ?1.
- *  ?3: boolean, if 1 return immediate children of ?2 only.
  *
  * ### NOTE: This statement deliberately removes file externals that live
  * inside an unversioned dir, because commit still breaks on those.
  * Once that's been fixed, the conditions below "--->8---" become obsolete. */
 -- STMT_SELECT_COMMITTABLE_EXTERNALS_BELOW
 SELECT local_relpath, kind, def_repos_relpath,
-       (SELECT root FROM repository AS r
-         WHERE r.id = e.repos_id)
-FROM externals AS e
-WHERE e.wc_id = ?1
+  (SELECT root FROM repository AS r WHERE r.id = e.repos_id)
+FROM externals e
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
+  AND def_revision IS NULL
+  AND repos_id = (SELECT repos_id
+                  FROM nodes AS n
+                  WHERE n.wc_id = ?1
+                    AND n.local_relpath = ''
+                    AND n.op_depth = 0)
+  AND ((kind='dir')
+       OR EXISTS (SELECT 1 FROM nodes
+                  WHERE nodes.wc_id = e.wc_id
+                  AND nodes.local_relpath = e.parent_relpath))
+
+-- STMT_SELECT_COMMITTABLE_EXTERNALS_IMMEDIATELY_BELOW
+SELECT local_relpath, kind, def_repos_relpath,
+  (SELECT root FROM repository AS r WHERE r.id = e.repos_id)
+FROM externals e
+WHERE wc_id = ?1
   AND IS_STRICT_DESCENDANT_OF(e.local_relpath, ?2)
-  AND e.def_revision IS NULL
-  AND e.repos_id = (SELECT repos_id
+  AND parent_relpath = ?2
+  AND def_revision IS NULL
+  AND repos_id = (SELECT repos_id
                     FROM nodes AS n
                     WHERE n.wc_id = ?1
                       AND n.local_relpath = ''
                       AND n.op_depth = 0)
-  AND ( (NOT ?3) OR (parent_relpath = ?2) )
-  /* ------>8----- */
-  AND (EXISTS (SELECT 1 FROM nodes
-               WHERE nodes.wc_id = e.wc_id
-               AND nodes.local_relpath = e.parent_relpath))
+  AND ((kind='dir')
+       OR EXISTS (SELECT 1 FROM nodes
+                  WHERE nodes.wc_id = e.wc_id
+                  AND nodes.local_relpath = e.parent_relpath))
 
 -- STMT_SELECT_EXTERNALS_DEFINED
 SELECT local_relpath, def_local_relpath
@@ -1012,7 +1075,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2
  * WHERE wc_id = ?1
  *   AND (local_relpath = ?2
  *        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
- *   AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+ *   AND kind = MAP_DIR AND presence IN (MAP_NORMAL, MAP_INCOMPLETE)
  * ### But it would take a double table scan execution plan for it.
  * ### Maybe there is something else going on? */
 SELECT IFNULL((SELECT properties FROM actual_node a
@@ -1021,7 +1084,7 @@ SELECT IFNULL((SELECT properties FROM ac
        local_relpath, depth
 FROM nodes_current n
 WHERE wc_id = ?1 AND local_relpath = ?2
-  AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+  AND kind = MAP_DIR AND presence IN (MAP_NORMAL, MAP_INCOMPLETE)
 UNION ALL
 SELECT IFNULL((SELECT properties FROM actual_node a
                WHERE a.wc_id = ?1 AND A.local_relpath = n.local_relpath),
@@ -1029,7 +1092,7 @@ SELECT IFNULL((SELECT properties FROM ac
        local_relpath, depth
 FROM nodes_current n
 WHERE wc_id = ?1 AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
-  AND kind = 'dir' AND presence IN ('normal', 'incomplete')
+  AND kind = MAP_DIR AND presence IN (MAP_NORMAL, MAP_INCOMPLETE)
 
 -- STMT_SELECT_CURRENT_PROPS_RECURSIVE
 /* ### Ugly OR to make sqlite use the proper optimizations */
@@ -1067,16 +1130,12 @@ VALUES (?1, ?2, ?3, ?4)
 
 -- STMT_SELECT_ALL_FILES
 SELECT local_relpath FROM nodes_current
-WHERE wc_id = ?1 AND parent_relpath = ?2 AND kind = 'file'
+WHERE wc_id = ?1 AND parent_relpath = ?2 AND kind = MAP_FILE
 
 -- STMT_UPDATE_NODE_PROPS
 UPDATE nodes SET properties = ?4
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
 
--- STMT_HAS_WORKING_NODES
-SELECT 1 FROM nodes WHERE op_depth > 0
-LIMIT 1
-
 /* --------------------------------------------------------------------------
  * Complex queries for callback walks, caching results in a temporary table.
  *
@@ -1105,13 +1164,13 @@ INSERT INTO target_prop_cache(local_relp
    JOIN nodes_current AS n ON t.wc_id= n.wc_id
                           AND t.local_relpath = n.local_relpath
   WHERE t.wc_id = ?1
-    AND (presence='normal' OR presence='incomplete')
+    AND (presence=MAP_NORMAL OR presence=MAP_INCOMPLETE)
 
 -- STMT_CACHE_TARGET_PRISTINE_PROPS
 INSERT INTO target_prop_cache(local_relpath, kind, properties)
  SELECT n.local_relpath, n.kind,
         CASE n.presence
-          WHEN 'base-deleted'
+          WHEN MAP_BASE_DELETED
           THEN (SELECT properties FROM nodes AS p
                  WHERE p.wc_id = n.wc_id
                    AND p.local_relpath = n.local_relpath
@@ -1122,9 +1181,9 @@ INSERT INTO target_prop_cache(local_relp
   JOIN nodes_current AS n ON t.wc_id= n.wc_id
                           AND t.local_relpath = n.local_relpath
   WHERE t.wc_id = ?1
-    AND (presence = 'normal'
-         OR presence = 'incomplete'
-         OR presence = 'base-deleted')
+    AND (presence = MAP_NORMAL
+         OR presence = MAP_INCOMPLETE
+         OR presence = MAP_BASE_DELETED)
 
 -- STMT_SELECT_ALL_TARGET_PROP_CACHE
 SELECT local_relpath, properties FROM target_prop_cache
@@ -1247,15 +1306,39 @@ WHERE wc_id = ?1
   AND op_depth = (SELECT MAX(s.op_depth) FROM nodes AS s
                   WHERE s.wc_id = ?1
                     AND s.local_relpath = n.local_relpath)
-  AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'server-excluded')
+  AND presence NOT IN (MAP_BASE_DELETED, MAP_NOT_PRESENT, MAP_EXCLUDED, MAP_SERVER_EXCLUDED)
 
 -- STMT_SELECT_DELETE_LIST
 SELECT local_relpath FROM delete_list
 ORDER BY local_relpath
 
 -- STMT_FINALIZE_DELETE
-DROP TABLE delete_list
+DROP TABLE IF EXISTS delete_list
+
+-- STMT_CREATE_UPDATE_MOVE_LIST
+DROP TABLE IF EXISTS update_move_list;
+CREATE TEMPORARY TABLE update_move_list (
+/* ### we should put the wc_id in here in case a move update spans multiple
+   ### working copies. queries, etc will need to be adjusted.  */
+  local_relpath TEXT PRIMARY KEY NOT NULL UNIQUE,
+  action INTEGER NOT NULL,
+  kind  INTEGER NOT NULL,
+  content_state INTEGER NOT NULL,
+  prop_state  INTEGER NOT NULL
+  )
+
+-- STMT_INSERT_UPDATE_MOVE_LIST
+INSERT INTO update_move_list(local_relpath, action, kind, content_state,
+  prop_state)
+VALUES (?1, ?2, ?3, ?4, ?5)
+
+-- STMT_SELECT_UPDATE_MOVE_LIST
+SELECT local_relpath, action, kind, content_state, prop_state
+FROM update_move_list
+ORDER BY local_relpath
 
+-- STMT_FINALIZE_UPDATE_MOVE
+DROP TABLE IF EXISTS update_move_list
 
 /* ------------------------------------------------------------------------- */
 
@@ -1267,7 +1350,7 @@ SELECT MIN(revision), MAX(revision),
   WHERE wc_id = ?1
     AND (local_relpath = ?2
          OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
-    AND presence IN ('normal', 'incomplete')
+    AND presence IN (MAP_NORMAL, MAP_INCOMPLETE)
     AND file_external IS NULL
     AND op_depth = 0
 
@@ -1277,8 +1360,8 @@ WHERE wc_id = ?1
   AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = 0
-  AND (presence IN ('server-excluded', 'excluded')
-        OR depth NOT IN ('infinity', 'unknown'))
+  AND (presence IN (MAP_SERVER_EXCLUDED, MAP_EXCLUDED)
+        OR depth NOT IN (MAP_DEPTH_INFINITY, MAP_DEPTH_UNKNOWN))
   AND file_external IS NULL
 LIMIT 1
 
@@ -1373,8 +1456,8 @@ WHERE wc_id = ?1
   AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = 0
-  AND kind='file'
-  AND presence='normal'
+  AND kind=MAP_FILE
+  AND presence=MAP_NORMAL
   AND file_external IS NULL
 
 /* ### FIXME: op-depth?  What about multiple moves? */
@@ -1386,10 +1469,9 @@ WHERE wc_id = ?1 AND moved_to = ?2 AND o
 UPDATE nodes SET moved_to = ?4
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
 
-/* ### FIXME: op-depth?  What about multiple moves? */
 -- STMT_CLEAR_MOVED_TO_RELPATH
 UPDATE nodes SET moved_to = NULL
-WHERE wc_id = ?1 AND local_relpath = ?2
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
 
 /* This statement returns pairs of move-roots below the path ?2 in WC_ID ?1.
  * Each row returns a moved-here path (always a child of ?2) in the first
@@ -1400,8 +1482,8 @@ WHERE wc_id = ?1 AND op_depth > 0
   AND IS_STRICT_DESCENDANT_OF(moved_to, ?2)
 
 /* This statement returns pairs of paths that define a move where the
-   destination of the move is within the subtree rooted at path ?2 in
-   WC_ID ?1. */
+   destination of the move is within the subtree rooted at path ?2 or
+   the source of the move is within the subtree rooted at path ?2 */
 -- STMT_SELECT_MOVED_PAIR
 SELECT local_relpath, moved_to, op_depth FROM nodes_current
 WHERE wc_id = ?1
@@ -1419,6 +1501,29 @@ WHERE wc_id = ?1
   AND moved_to IS NOT NULL
   AND NOT IS_STRICT_DESCENDANT_OF(moved_to, ?2)
 
+-- STMT_SELECT_MOVED_PAIR3
+SELECT local_relpath, moved_to, op_depth FROM nodes
+WHERE wc_id = ?1
+  AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
+  AND op_depth > ?3
+  AND moved_to IS NOT NULL
+
+-- STMT_SELECT_OP_DEPTH_MOVED_PAIR
+SELECT n.local_relpath, n.moved_to,
+       (SELECT o.repos_path FROM nodes AS o
+        WHERE o.wc_id = n.wc_id
+          AND o.local_relpath = n.local_relpath
+          AND o.op_depth < ?3 ORDER BY o.op_depth DESC LIMIT 1)
+FROM nodes AS n
+WHERE n.wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(n.local_relpath, ?2)
+  AND n.op_depth = ?3
+  AND n.moved_to IS NOT NULL
+
+-- STMT_HAS_LAYER_BETWEEN
+SELECT 1 FROM NODES
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3 AND op_depth < ?4
+
 /* ------------------------------------------------------------------------- */
 
 /* Queries for verification. */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_wc/wc.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_wc/wc.h?rev=1442344&r1=1442343&r2=1442344&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_wc/wc.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_wc/wc.h Mon Feb  4 20:48:05 2013
@@ -188,6 +188,16 @@ extern "C" {
 /* A version < this has no work queue (see workqueue.h).  */
 #define SVN_WC__HAS_WORK_QUEUE 13
 
+/* Return a string indicating the released version (or versions) of
+ * Subversion that used WC format number WC_FORMAT, or some other
+ * suitable string if no released version used WC_FORMAT.
+ *
+ * ### It's not ideal to encode this sort of knowledge in this low-level
+ * library.  On the other hand, it doesn't need to be updated often and
+ * should be easily found when it does need to be updated.  */
+const char *
+svn_wc__version_string_from_format(int wc_format);
+
 /* Return true iff error E indicates an "is not a working copy" type
    of error, either because something wasn't a working copy at all, or
    because it's a working copy from a previous version (in need of
@@ -378,17 +388,24 @@ svn_wc__internal_file_modified_p(svn_boo
                                  apr_pool_t *scratch_pool);
 
 
-/* Merge the difference between LEFT_ABSPATH and RIGHT_ABSPATH into
-   TARGET_ABSPATH, return the appropriate work queue operations in
-   *WORK_ITEMS.
-
-   Note that, in the case of updating, the update can have sent new
-   properties, which could affect the way the wc target is
-   detranslated and compared with LEFT and RIGHT for merging.
-
-   The merge result is stored in *MERGE_OUTCOME and merge conflicts
-   are marked in MERGE_RESULT using LEFT_LABEL, RIGHT_LABEL and
-   TARGET_LABEL.
+/* Prepare to merge a file content change into the working copy.  This
+   does not merge properties; see svn_wc__merge_props() for that.  This
+   does not change the working file on disk; it returns work items that
+   will replace the working file on disk when they are run.
+
+   Merge the difference between LEFT_ABSPATH and RIGHT_ABSPATH into
+   TARGET_ABSPATH.
+
+   Set *WORK_ITEMS to the appropriate work queue operations.
+
+   If there are any conflicts, append a conflict description to
+   *CONFLICT_SKEL.  (First allocate *CONFLICT_SKEL from RESULT_POOL if
+   it is initially NULL.  CONFLICT_SKEL itself must not be NULL.)
+   Also, unless it is considered to be a 'binary' file, mark any
+   conflicts in the text of the file TARGET_ABSPATH using LEFT_LABEL,
+   RIGHT_LABEL and TARGET_LABEL.
+
+   Set *MERGE_OUTCOME to indicate the result.
 
    When DRY_RUN is true, no actual changes are made to the working copy.
 
@@ -401,12 +418,18 @@ svn_wc__internal_file_modified_p(svn_boo
    WRI_ABSPATH describes in which working copy information should be
    retrieved. (Interesting for merging file externals).
 
-   ACTUAL_PROPS is the set of actual properties before merging; used for
-   detranslating the file before merging.
+   OLD_ACTUAL_PROPS is the set of actual properties before merging; used for
+   detranslating the file before merging.  This is necessary because, in
+   the case of updating, the update can have sent new properties, so we
+   cannot simply fetch and use the current actual properties.
+
+     ### Is OLD_ACTUAL_PROPS still necessary, now that we first prepare the
+         content change and property change and then apply them both to
+         the WC together?
 
    Property changes sent by the update are provided in PROP_DIFF.
 
-   For a complete description, see svn_wc_merge3() for which this is
+   For a complete description, see svn_wc_merge5() for which this is
    the (loggy) implementation.
 
    *WORK_ITEMS will be allocated in RESULT_POOL. All temporary allocations
@@ -424,7 +447,7 @@ svn_wc__internal_merge(svn_skel_t **work
                        const char *left_label,
                        const char *right_label,
                        const char *target_label,
-                       apr_hash_t *actual_props,
+                       apr_hash_t *old_actual_props,
                        svn_boolean_t dry_run,
                        const char *diff3_cmd,
                        const apr_array_header_t *merge_options,
@@ -641,27 +664,6 @@ svn_wc__wipe_postupgrade(const char *dir
                          void *cancel_baton,
                          apr_pool_t *scratch_pool);
 
-/* Check whether a node is a working copy root or switched.
- *
- * If LOCAL_ABSPATH is the root of a working copy, set *WC_ROOT to TRUE,
- * otherwise to FALSE.
- *
- * If KIND is not null, set *KIND to the node type of LOCAL_ABSPATH.
- *
- * If LOCAL_ABSPATH is switched against its parent in the same working copy
- * set *SWITCHED to TRUE, otherwise to FALSE.  SWITCHED can be NULL
- * if the result is not important.
- *
- * Use SCRATCH_POOL for temporary allocations.
- */
-svn_error_t *
-svn_wc__check_wc_root(svn_boolean_t *wc_root,
-                      svn_kind_t *kind,
-                      svn_boolean_t *switched,
-                      svn_wc__db_t *db,
-                      const char *local_abspath,
-                      apr_pool_t *scratch_pool);
-
 /* Ensure LOCAL_ABSPATH is still locked in DB.  Returns the error
  * SVN_ERR_WC_NOT_LOCKED if this is not the case.
  */
@@ -697,18 +699,21 @@ svn_wc__read_conflicts(const apr_array_h
    identified by WRI_ABSPATH. Use OLD_REVISION and TARGET_REVISION for naming
    the intermediate files.
 
+   Set *FOUND_TEXT_CONFLICT to TRUE when the merge encountered a conflict,
+   otherwise to FALSE.
+
    The rest of the arguments are passed to svn_wc__internal_merge.
  */
 svn_error_t *
 svn_wc__perform_file_merge(svn_skel_t **work_items,
                            svn_skel_t **conflict_skel,
-                           enum svn_wc_merge_outcome_t *merge_outcome,
+                           svn_boolean_t *found_conflict,
                            svn_wc__db_t *db,
                            const char *local_abspath,
                            const char *wri_abspath,
                            const svn_checksum_t *new_checksum,
                            const svn_checksum_t *original_checksum,
-                           apr_hash_t *actual_props,
+                           apr_hash_t *old_actual_props,
                            const apr_array_header_t *ext_patterns,
                            svn_revnum_t old_revision,
                            svn_revnum_t target_revision,
@@ -765,6 +770,28 @@ svn_wc__externals_find_target_dups(apr_a
                                    apr_pool_t *pool,
                                    apr_pool_t *scratch_pool);
 
+/* Revert tree LOCAL_ABSPATH to depth DEPTH and notify for all
+   reverts. */
+svn_error_t *
+svn_wc__revert_internal(svn_wc__db_t *db,
+                        const char *local_abspath,
+                        svn_depth_t depth,
+                        svn_boolean_t use_commit_times,
+                        svn_cancel_func_t cancel_func,
+                        void *cancel_baton,
+                        svn_wc_notify_func2_t notify_func,
+                        void *notify_baton,
+                        apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_wc__node_has_local_mods(svn_boolean_t *modified,
+                            svn_boolean_t *all_edits_are_deletes,
+                            svn_wc__db_t *db,
+                            const char *local_abspath,
+                            svn_cancel_func_t cancel_func,
+                            void *cancel_baton,
+                            apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */