subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1159093 - in /subversion/trunk: build/transform_sql.py subversion/libsvn_wc/wc-queries.sql
Date Thu, 18 Aug 2011 08:53:05 GMT
Author: danielsh
Date: Thu Aug 18 08:53:04 2011
New Revision: 1159093

URL: http://svn.apache.org/viewvc?rev=1159093&view=rev
Log:
Factor out a repeated code fraction, for maintainability and readability.

* build/transform_sql.py
  (Processor.process_file):
    Grow support for a IS_STRICT_DESCENDANT_OF() macro.  At this time the
    macro must be contained within one input line.

* subversion/libsvn_wc/wc-queries.sql
  (*): Replace the "Is a descendant" check with the macro.
    No functional change --- this only adds/removes some parentheses from the
    generated file.

Modified:
    subversion/trunk/build/transform_sql.py
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql

Modified: subversion/trunk/build/transform_sql.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/transform_sql.py?rev=1159093&r1=1159092&r2=1159093&view=diff
==============================================================================
--- subversion/trunk/build/transform_sql.py (original)
+++ subversion/trunk/build/transform_sql.py Thu Aug 18 08:53:04 2011
@@ -102,6 +102,9 @@ class Processor(object):
 
     for line in input.split('\n'):
       line = line.replace('"', '\\"')
+      line = re.sub(r'IS_STRICT_DESCENDANT_OF[(]([A-Za-z_.]+), ([?][0-9]+)[)]',
+                    r"((\1 > \2 || '/') AND (\1 < \2 || '0')) ",
+                    line)
 
       if line.strip():
         handled = False

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1159093&r1=1159092&r2=1159093&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu Aug 18 08:53:04 2011
@@ -178,7 +178,7 @@ WHERE wc_id = ?1 AND parent_relpath = ?2
 DELETE FROM nodes
 WHERE wc_id = ?1
   AND (local_relpath = ?2
-       OR ((local_relpath > ?2 || '/') AND (local_relpath < ?2 || '0')))
+       OR ((IS_STRICT_DESCENDANT_OF(local_relpath, ?2))))
   AND (op_depth < ?3
        OR (op_depth = ?3 AND presence = 'base-deleted'))
 
@@ -186,7 +186,7 @@ WHERE wc_id = ?1
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1 AND op_depth = ?3
   AND (parent_relpath = ?2
-       OR ((parent_relpath > ?2 || '/') AND (parent_relpath < ?2 || '0')))
+       OR ((IS_STRICT_DESCENDANT_OF(parent_relpath, ?2))))
   AND presence == 'not-present'
 
 -- STMT_COMMIT_DESCENDANT_TO_BASE
@@ -263,7 +263,7 @@ LEFT JOIN lock ON nodes.repos_id = lock.
 WHERE wc_id = ?1 AND op_depth = 0
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_INSERT_WCROOT
 INSERT INTO wcroot (local_abspath)
@@ -298,7 +298,7 @@ UPDATE nodes SET dav_cache = NULL
 WHERE dav_cache IS NOT NULL AND wc_id = ?1 AND op_depth = 0
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_RECURSIVE_UPDATE_NODE_REPO
 UPDATE nodes SET repos_id = ?4, dav_cache = NULL
@@ -306,7 +306,7 @@ WHERE wc_id = ?1
   AND repos_id = ?3
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_UPDATE_LOCK_REPOS_ID
 UPDATE lock SET repos_id = ?2
@@ -476,7 +476,7 @@ FROM nodes_current
 WHERE wc_id = ?1
        AND (?2 = ''
             OR local_relpath = ?2 
-            OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+            OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_INSERT_TARGET_WITH_CHANGELIST
 INSERT INTO targets_list(wc_id, local_relpath, parent_relpath, kind)
@@ -509,7 +509,7 @@ SELECT N.wc_id, N.local_relpath, N.paren
  WHERE N.wc_id = ?1
        AND (?2 = ''
             OR N.local_relpath = ?2 
-            OR (N.local_relpath > ?2 || '/' AND N.local_relpath < ?2 || '0'))
+            OR (IS_STRICT_DESCENDANT_OF(N.local_relpath, ?2)))
        AND A.changelist = ?3
 
 -- STMT_SELECT_TARGETS
@@ -578,7 +578,7 @@ DELETE FROM nodes
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth >= ?3
 
 -- STMT_DELETE_ACTUAL_NODE
@@ -590,7 +590,7 @@ DELETE FROM actual_node
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_DELETE_ACTUAL_NODE_WITHOUT_CONFLICT
 DELETE FROM actual_node
@@ -611,7 +611,7 @@ DELETE FROM actual_node
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND (changelist IS NULL
        OR NOT EXISTS (SELECT 1 FROM nodes_current c
                       WHERE c.wc_id = ?1 
@@ -647,7 +647,7 @@ SET properties = NULL,
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
 
 -- STMT_UPDATE_NODE_BASE_DEPTH
 UPDATE nodes SET depth = ?3
@@ -779,7 +779,7 @@ DELETE FROM wc_lock
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_dir_relpath = ?2
-       OR (local_dir_relpath > ?2 || '/' AND local_dir_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_dir_relpath, ?2)))
   AND NOT EXISTS (SELECT 1 FROM nodes
                    WHERE nodes.wc_id = ?1
                      AND nodes.local_relpath = wc_lock.local_dir_relpath)
@@ -812,7 +812,7 @@ SELECT wc_id, local_relpath, ?4 /*op_dep
        kind
 FROM nodes
 WHERE wc_id = ?1
-  AND (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0')
+  AND (IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND op_depth = ?3
   AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent')
 
@@ -852,7 +852,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 UPDATE nodes SET op_depth = ?3 + 1
 WHERE wc_id = ?1
   AND (?2 = ''
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
  AND op_depth = ?3
 
 -- STMT_DOES_NODE_EXIST
@@ -864,7 +864,7 @@ SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth = 0 AND presence = 'absent'
 LIMIT 1
 
@@ -874,7 +874,7 @@ SELECT local_relpath FROM nodes
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth = 0
   AND presence = 'absent'
 
@@ -965,7 +965,7 @@ FROM externals
 WHERE wc_id = ?1 
   AND (?2 = ''
        OR def_local_relpath = ?2
-       OR (def_local_relpath > ?2 || '/' AND def_local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(def_local_relpath, ?2)))
 
 -- STMT_UPDATE_EXTERNAL_FILEINFO
 UPDATE externals SET recorded_size = ?3, recorded_mod_time = ?4
@@ -984,7 +984,7 @@ FROM nodes n
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND kind = 'dir' AND presence='normal'
   AND op_depth=(SELECT MAX(op_depth) FROM nodes o
                 WHERE o.wc_id = ?1 AND o.local_relpath = n.local_relpath)
@@ -1205,7 +1205,7 @@ INSERT INTO delete_list(local_relpath)
 SELECT local_relpath FROM nodes n
 WHERE wc_id = ?1
   AND (local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth >= ?3
   AND presence NOT IN ('base-deleted', 'not-present', 'excluded', 'absent')
   AND op_depth = (SELECT MAX(op_depth) FROM nodes s
@@ -1230,7 +1230,7 @@ SELECT MIN(revision), MAX(revision),
   WHERE wc_id = ?1
     AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
     AND presence IN ('normal', 'incomplete')
     AND file_external IS NULL
     AND op_depth = 0
@@ -1240,7 +1240,7 @@ SELECT 1 FROM nodes
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth = 0
   AND (presence IN ('absent', 'excluded')
         OR depth NOT IN ('infinity', 'unknown'))
@@ -1252,7 +1252,7 @@ SELECT 1 FROM nodes
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth > 0
 LIMIT 1
 
@@ -1261,7 +1261,7 @@ SELECT 1 FROM actual_node
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND properties IS NOT NULL
 LIMIT 1
 
@@ -1284,7 +1284,7 @@ SELECT o.repos_path || '/' || SUBSTR(s.l
 FROM nodes AS o
 LEFT JOIN nodes AS s
 ON o.wc_id = s.wc_id
-   AND s.local_relpath > ?2 || '/' AND s.local_relpath < ?2 || '0'
+   AND IS_STRICT_DESCENDANT_OF(s.local_relpath, ?2)
    AND s.op_depth = 0
    AND s.repos_id = o.repos_id
    AND s.file_external IS NULL
@@ -1298,7 +1298,7 @@ SELECT SUBSTR(s.local_relpath, LENGTH(?2
 FROM nodes AS o
 LEFT JOIN nodes AS s
 ON o.wc_id = s.wc_id
-   AND s.local_relpath > ?2 || '/' AND s.local_relpath < ?2 || '0'
+   AND IS_STRICT_DESCENDANT_OF(s.local_relpath, ?2)
    AND s.op_depth = 0
    AND s.repos_id = o.repos_id
    AND s.file_external IS NULL
@@ -1339,7 +1339,7 @@ SELECT local_relpath, translated_size, l
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth = 0
   AND kind='file'
   AND presence='normal'
@@ -1362,7 +1362,7 @@ UPDATE nodes SET moved_to = NULL
 WHERE wc_id = ?1
   AND (?2 = ''
        OR local_relpath = ?2
-       OR (local_relpath > ?2 || '/' AND local_relpath < ?2 || '0'))
+       OR (IS_STRICT_DESCENDANT_OF(local_relpath, ?2)))
   AND op_depth = 0
 
 /* This statement returns pairs of move-roots below the path ?2 in WC_ID ?1.
@@ -1371,7 +1371,7 @@ WHERE wc_id = ?1
 -- STMT_SELECT_MOVED_HERE_CHILDREN
 SELECT moved_to, local_relpath FROM nodes
 WHERE wc_id = ?1 AND op_depth = 0
-  AND (moved_to > ?2 || '/' AND moved_to < ?2 || '0')
+  AND (IS_STRICT_DESCENDANT_OF(moved_to, ?2))
 
 /* ------------------------------------------------------------------------- */
 



Mime
View raw message