subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r928987 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h
Date Tue, 30 Mar 2010 05:02:27 GMT
Author: gstein
Date: Tue Mar 30 05:02:27 2010
New Revision: 928987

URL: http://svn.apache.org/viewvc?rev=928987&view=rev
Log:
Create a new wc_db entrypoint to record a newly-installed file's
translated_size and last_mod_time.

* subversion/libsvn_wc/wc_db.h:
  (svn_wc__db_global_record_fileinfo): new declaration

* subversion/libsvn_wc/wc_db.c:
  (which_trees_exist): helper function to determine which rows exist in
    BASE_NODE and WORKING_NODE for a given wc_id/local_relpath pair.
  (struct record_baton): baton for the transacted record_fileinfo()
    function's parameters.
  (record_fileinfo): executes within a transaction to record the file
    information in the appropriate table.
  (svn_wc__db_global_record_fileinfo): implement new function, mostly in
    terms of record_fileinfo()

* subversion/libsvn_wc/wc-queries.sql:
  (STMT_UPDATE_BASE_FILEINFO, STMT_UPDATE_WORKING_FILEINFO): new
    statements to record file info in the appropriate table
  (STMT_DETERMINE_TREE_FOR_RECORDING): funky SQL to see what rows exist in
    the BASE_NODE and WORKING_NODE tables

Modified:
    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/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=928987&r1=928986&r2=928987&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Mar 30 05:02:27 2010
@@ -190,6 +190,14 @@ where repos_id = ?1 and
 update base_node set last_mod_time = ?3
 where wc_id = ?1 and local_relpath = ?2;
 
+-- STMT_UPDATE_BASE_FILEINFO
+UPDATE BASE_NODE SET translated_size = ?3, last_mod_time = ?4
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
+-- STMT_UPDATE_WORKING_FILEINFO
+UPDATE WORKING_NODE SET translated_size = ?3, last_mod_time = ?4
+WHERE wc_id = ?1 AND local_relpath = ?2;
+
 -- STMT_UPDATE_ACTUAL_TREE_CONFLICTS
 update actual_node set tree_conflict_data = ?3
 where wc_id = ?1 and local_relpath = ?2;
@@ -351,10 +359,16 @@ SELECT wc_id, local_relpath, parent_relp
     repos_relpath, revnum FROM BASE_NODE
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
--- STMT_UPDATE_COPYFROM (
+-- STMT_UPDATE_COPYFROM
 UPDATE WORKING_NODE set copyfrom_repos_id = ?3, copyfrom_repos_path = ?4
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
+-- STMT_DETERMINE_TREE_FOR_RECORDING
+SELECT 0 FROM BASE_NODE WHERE wc_id = ?1 AND local_relpath = ?2
+UNION
+SELECT 1 FROM WORKING_NODE WHERE wc_id = ?1 AND local_relpath = ?2;
+
+
 /* ------------------------------------------------------------------------- */
 
 /* these are used in entries.c  */

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=928987&r1=928986&r2=928987&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Mar 30 05:02:27 2010
@@ -1530,6 +1530,48 @@ add_work_items(svn_sqlite__db_t *sdb,
 }
 
 
+/* Determine which trees' nodes exist for a given WC_ID and LOCAL_RELPATH
+   in the specified SDB.  */
+static svn_error_t *
+which_trees_exist(svn_boolean_t *base_exists,
+                  svn_boolean_t *working_exists,
+                  svn_sqlite__db_t *sdb,
+                  apr_int64_t wc_id,
+                  const char *local_relpath)
+{
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  *base_exists = FALSE;
+  *working_exists = FALSE;
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                    STMT_DETERMINE_TREE_FOR_RECORDING));
+  SVN_ERR(svn_sqlite__bindf(stmt, "is", wc_id, local_relpath));
+
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (have_row)
+    {
+      int value = svn_sqlite__column_int(stmt, 0);
+
+      if (value)
+        *working_exists = TRUE;  /* value == 1  */
+      else
+        *base_exists = TRUE;  /* value == 0  */
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+      if (have_row)
+        {
+          /* If both rows, then both tables.  */
+          *base_exists = TRUE;
+          *working_exists = TRUE;
+        }
+    }
+
+  return svn_error_return(svn_sqlite__reset(stmt));
+}
+
+
 /* */
 static svn_error_t *
 create_db(svn_sqlite__db_t **sdb,
@@ -4753,6 +4795,90 @@ svn_wc__db_global_update(svn_wc__db_t *d
 }
 
 
+struct record_baton {
+  apr_int64_t wc_id;
+  const char *local_relpath;
+
+  svn_filesize_t translated_size;
+  apr_time_t last_mod_time;
+
+  /* For error reporting.  */
+  const char *local_abspath;
+};
+
+
+/* Record TRANSLATED_SIZE and LAST_MOD_TIME into the WORKING tree if a
+   node is present; otherwise, record it into the BASE tree. One of them
+   must exist.  */
+static svn_error_t *
+record_fileinfo(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
+{
+  struct record_baton *rb = baton;
+  svn_boolean_t base_exists;
+  svn_boolean_t working_exists;
+  svn_sqlite__stmt_t *stmt;
+  int affected_rows;
+
+  SVN_ERR(which_trees_exist(&base_exists, &working_exists,
+                            sdb, rb->wc_id, rb->local_relpath));
+  if (!base_exists && !working_exists)
+    return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                             _("Could not find node '%s' for recording file "
+                               "information."),
+                             svn_dirent_local_style(rb->local_abspath,
+                                                    scratch_pool));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                    working_exists
+                                      ? STMT_UPDATE_WORKING_FILEINFO
+                                      : STMT_UPDATE_BASE_FILEINFO));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isii",
+                            rb->wc_id, rb->local_relpath,
+                            rb->translated_size, rb->last_mod_time));
+  SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
+
+  SVN_ERR_ASSERT(affected_rows == 1);
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
+                                  const char *local_abspath,
+                                  svn_filesize_t translated_size,
+                                  apr_time_t last_mod_time,
+                                  apr_pool_t *scratch_pool)
+{
+  svn_wc__db_pdh_t *pdh;
+  const char *local_relpath;
+  struct record_baton rb;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+
+  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
+                              svn_sqlite__mode_readwrite,
+                              scratch_pool, scratch_pool));
+  VERIFY_USABLE_PDH(pdh);
+
+  rb.wc_id = pdh->wcroot->wc_id;
+  rb.local_relpath = local_relpath;
+
+  rb.translated_size = translated_size;
+  rb.last_mod_time = last_mod_time;
+
+  rb.local_abspath = local_abspath;
+
+  SVN_ERR(svn_sqlite__with_transaction(pdh->wcroot->sdb, record_fileinfo, &rb,
+                                       scratch_pool));
+
+  /* We *totally* monkeyed the entries. Toss 'em.  */
+  flush_entries(pdh);
+
+  return SVN_NO_ERROR;
+}
+
+
 svn_error_t *
 svn_wc__db_lock_add(svn_wc__db_t *db,
                     const char *local_abspath,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=928987&r1=928986&r2=928987&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue Mar 30 05:02:27 2010
@@ -1517,6 +1517,26 @@ svn_wc__db_global_update(svn_wc__db_t *d
                          apr_pool_t *scratch_pool);
 
 
+/* Record the TRANSLATED_SIZE and LAST_MOD_TIME for a versioned node.
+
+   This function will record the information within the WORKING node,
+   if present, or within the BASE tree. If neither node is present, then
+   SVN_ERR_WC_PATH_NOT_FOUND will be returned.
+
+   TRANSLATED_SIZE may be SVN_INVALID_FILESIZE, which will be recorded
+   as such, implying "unknown size".
+
+   LAST_MOD_TIME may be 0, which will be recorded as such, implying
+   "unknown last mod time".
+*/
+svn_error_t *
+svn_wc__db_global_record_fileinfo(svn_wc__db_t *db,
+                                  const char *local_abspath,
+                                  svn_filesize_t translated_size,
+                                  apr_time_t last_mod_time,
+                                  apr_pool_t *scratch_pool);
+
+
 /* ### post-commit handling.
    ### maybe multiple phases?
    ### 1) mark a changelist as being-committed



Mime
View raw message