You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2010/06/30 13:30:50 UTC

svn commit: r959272 - in /subversion/trunk/subversion/libsvn_wc: upgrade.c wc_db.c wc_db.h

Author: philip
Date: Wed Jun 30 11:30:50 2010
New Revision: 959272

URL: http://svn.apache.org/viewvc?rev=959272&view=rev
Log:
Get the pristine path using a standard function.

* subversion/libsvn_wc/wc_db.h
  (svn_wc__db_pristine_get_future_path): New.

* subversion/libsvn_wc/wc_db.c
  (get_pristine_fname): Change parameter from pdh to abspath.
  (svn_wc__db_pristine_get_path, svn_wc__db_pristine_read,
   svn_wc__db_pristine_install, svn_wc__db_pristine_remove,
   svn_wc__db_pristine_check): Adjust callers.
  (svn_wc__db_pristine_get_future_path): New.

* subversion/libsvn_wc/upgrade.c
  (migrate_text_bases): Use svn_wc__db_pristine_get_future_path.

Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=959272&r1=959271&r2=959272&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Wed Jun 30 11:30:50 2010
@@ -1167,7 +1167,6 @@ migrate_text_bases(const char *wcroot_ab
       svn_checksum_t *sha1_checksum;
       svn_sqlite__stmt_t *stmt;
       apr_finfo_t finfo;
-      const char *hex_digest;
 
       svn_pool_clear(iterpool);
       text_base_path = svn_dirent_join(text_base_dir, text_base_basename,
@@ -1199,21 +1198,19 @@ migrate_text_bases(const char *wcroot_ab
       SVN_ERR(svn_sqlite__bind_int64(stmt, 3, finfo.size));
       SVN_ERR(svn_sqlite__insert(NULL, stmt));
 
-      /* ### Compute the path of the pristine. We should use some
-             standard function to do this, to handle sharding etc.
-             Will we need an svn_wc__db_t?
-
-         ### Should we be doing all this IO inside the transaction?
-             Why not use the workqueue? */
-      hex_digest = svn_checksum_to_cstring(sha1_checksum, iterpool);
-      pristine_path = svn_dirent_join_many(iterpool,
-                                           wcroot_abspath,
-                                           svn_wc_get_adm_dir(iterpool),
-                                           PRISTINE_STORAGE_RELPATH,
-                                           hex_digest,
-                                           NULL);
-
-      /* Finally, copy the file over. ### Why not move? */
+      SVN_ERR(svn_wc__db_pristine_get_future_path(&pristine_path,
+                                                  wcroot_abspath,
+                                                  sha1_checksum,
+                                                  iterpool, iterpool));
+
+      /* Ensure any sharding directories exist. */
+      SVN_ERR(svn_wc__ensure_directory(svn_dirent_dirname(pristine_path,
+                                                          iterpool),
+                                       iterpool));
+
+      /* Copy, rather than move, so that the upgrade can be restarted.
+         It could be moved if upgrades scanned for files in the
+         pristine directory as well as the text-base directory. */
       SVN_ERR(svn_io_copy_file(text_base_path, pristine_path, TRUE,
                                iterpool));
     }

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=959272&r1=959271&r2=959272&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jun 30 11:30:50 2010
@@ -289,7 +289,7 @@ escape_sqlite_like(const char * const st
    Any other allocations are made in SCRATCH_POOL. */
 static svn_error_t *
 get_pristine_fname(const char **pristine_abspath,
-                   svn_wc__db_pdh_t *pdh,
+                   const char *wcroot_abspath,
                    const svn_checksum_t *sha1_checksum,
                    svn_boolean_t create_subdir,
                    apr_pool_t *result_pool,
@@ -303,7 +303,7 @@ get_pristine_fname(const char **pristine
 
   /* ### code is in transition. make sure we have the proper data.  */
   SVN_ERR_ASSERT(pristine_abspath != NULL);
-  SVN_ERR_ASSERT(pdh->wcroot != NULL);
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(wcroot_abspath));
   SVN_ERR_ASSERT(sha1_checksum != NULL);
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
@@ -311,7 +311,7 @@ get_pristine_fname(const char **pristine
      ### to use join_many since we know "/" is the separator for
      ### internal canonical paths */
   base_dir_abspath = svn_dirent_join_many(scratch_pool,
-                                          pdh->wcroot->abspath,
+                                          wcroot_abspath,
                                           svn_wc_get_adm_dir(scratch_pool),
                                           PRISTINE_STORAGE_RELPATH,
                                           NULL);
@@ -2226,13 +2226,27 @@ svn_wc__db_pristine_get_path(const char 
 
   /* ### should we look in the PRISTINE table for anything?  */
 
-  SVN_ERR(get_pristine_fname(pristine_abspath, pdh, sha1_checksum,
+  SVN_ERR(get_pristine_fname(pristine_abspath, pdh->wcroot->abspath,
+                             sha1_checksum,
                              FALSE /* create_subdir */,
                              result_pool, scratch_pool));
 
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc__db_pristine_get_future_path(const char **pristine_abspath,
+                                    const char *wcroot_abspath,
+                                    svn_checksum_t *sha1_checksum,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool)
+{
+  SVN_ERR(get_pristine_fname(pristine_abspath, wcroot_abspath,
+                             sha1_checksum,
+                             FALSE /* create_subdir */,
+                             result_pool, scratch_pool));
+  return SVN_NO_ERROR;
+}
 
 svn_error_t *
 svn_wc__db_pristine_read(svn_stream_t **contents,
@@ -2264,7 +2278,8 @@ svn_wc__db_pristine_read(svn_stream_t **
 
   /* ### should we look in the PRISTINE table for anything?  */
 
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh, sha1_checksum,
+  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+                             sha1_checksum,
                              FALSE /* create_subdir */,
                              scratch_pool, scratch_pool));
   return svn_error_return(svn_stream_open_readonly(
@@ -2333,7 +2348,8 @@ svn_wc__db_pristine_install(svn_wc__db_t
                               scratch_pool, scratch_pool));
   VERIFY_USABLE_PDH(pdh);
 
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh, sha1_checksum,
+  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+                             sha1_checksum,
                              TRUE /* create_subdir */,
                              scratch_pool, scratch_pool));
 
@@ -2492,7 +2508,8 @@ svn_wc__db_pristine_remove(svn_wc__db_t 
       SVN_ERR(svn_sqlite__update(NULL, stmt));
 
       /* Remove the file */
-      SVN_ERR(get_pristine_fname(&pristine_abspath, pdh, sha1_checksum,
+      SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+                                 sha1_checksum,
                                  TRUE /* create_subdir */,
                                  scratch_pool, scratch_pool));
       SVN_ERR(svn_io_remove_file2(pristine_abspath, TRUE, scratch_pool));
@@ -2541,7 +2558,8 @@ svn_wc__db_pristine_check(svn_boolean_t 
   SVN_ERR(svn_sqlite__reset(stmt));
 
   /* Check that the pristine text file exists. */
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh, sha1_checksum,
+  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+                             sha1_checksum,
                              FALSE /* create_subdir */,
                              scratch_pool, scratch_pool));
   SVN_ERR(svn_io_check_path(pristine_abspath, &kind_on_disk, scratch_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=959272&r1=959271&r2=959272&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Wed Jun 30 11:30:50 2010
@@ -898,6 +898,17 @@ svn_wc__db_pristine_get_path(const char 
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);
 
+/* Set *PRISTINE_ABSPATH to the path under WCROOT_ABSPATH that will be
+   used by the pristine text identified by SHA1_CHECKSUM.  The file
+   need not exist.
+ */
+svn_error_t *
+svn_wc__db_pristine_get_future_path(const char **pristine_abspath,
+                                    const char *wcroot_abspath,
+                                    svn_checksum_t *sha1_checksum,
+                                    apr_pool_t *result_pool,
+                                    apr_pool_t *scratch_pool);
+
 
 /* Set *CONTENTS to a readable stream that will yield the pristine text
    identified by CHECKSUM (### which should/must be its SHA-1 checksum?).