Author: julianfoad
Date: Fri May 20 16:38:24 2011
New Revision: 1125455

URL: http://svn.apache.org/viewvc?rev=1125455&view=rev
Log:
Prepare to give pristine text files a filename extension of ".svn-base"
after the string of 40 hex digits.  This will help users who search the disk
using a tool that can easily exclude matches to a given filename extension
but cannot easily exclude pristine files any other way.

This change will not be active until SVN_WC__VERSION is bumped to 29, at
which time svntest/wc.py:text_base_path() will need to be adjusted as
indicated in its comment.

See email "WC format bump imminent - renaming pristines [...]" from Julian
Foad on 2011-05-20, <http://svn.haxx.se/dev/archive-2011-05/0734.shtml>.

* subversion/libsvn_wc/upgrade.c
  (rename_pristine_file): New function.
  (bump_to_29): Rename all pristine files using rename_pristine_file().

* subversion/libsvn_wc/wc_db_pristine.c
  (PRISTINE_STORAGE_EXT): New #define.
  (get_pristine_fname): Append PRISTINE_STORAGE_EXT to the file name.

* subversion/libsvn_wc/wc.h
  Add this rename to the documentation of format 29.

* subversion/tests/cmdline/svntest/wc.py
  (text_base_path): Add a comment that we will need to append ".svn-base"
    to the file name here when we bump the format.

Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc.h
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
    subversion/trunk/subversion/tests/cmdline/svntest/wc.py

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1125455&r1=1125454&r2=1125455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Fri May 20 16:38:24 2011
@@ -1213,13 +1213,47 @@ bump_to_28(void *baton, svn_sqlite__db_t
   return SVN_NO_ERROR;
 }
 
+/* If FINFO indicates that PATH names a file, rename it to '<PATH>.svn-base'.
+ * Ignore any file whose name is not the expected length, in order to make
+ * life easier for any developer who runs this code twice or has some
+ * non-standard files in the pristine directory.
+ *
+ * A callback for bump_to_29(), implementing #svn_io_walk_func_t. */
+static svn_error_t *
+rename_pristine_file(void *baton,
+                     const char *path,
+                     const apr_finfo_t *finfo,
+                     apr_pool_t *pool)
+{
+  const char *new_path;
+
+  /* The old pristine file name was 40 hex digits. */
+  if (finfo->filetype == APR_REG && strlen(path) == 40)
+    {
+      new_path = apr_pstrcat(pool, path, ".svn-base", (char *)NULL);
+      SVN_ERR(svn_io_file_rename(path, new_path, pool));
+    }
+  return SVN_NO_ERROR;
+}
+
 static svn_error_t *
 bump_to_29(void *baton, svn_sqlite__db_t *sdb, apr_pool_t *scratch_pool)
 {
+  const char *wcroot_abspath = ((struct bump_baton *)baton)->wcroot_abspath;
+  const char *pristine_dir;
+
   /* ### Before enabling this code we should be able to upgrade existing
      ### file externals to their new location */
   SVN_ERR_MALFUNCTION();
 
+  /* Rename all pristine files, adding a ".svn-base" suffix. */
+  pristine_dir = svn_dirent_join_many(scratch_pool, wcroot_abspath,
+                                      svn_wc_get_adm_dir(scratch_pool),
+                                      PRISTINE_STORAGE_RELPATH, NULL);
+  SVN_ERR(svn_io_dir_walk2(pristine_dir, APR_FINFO_MIN,
+                           rename_pristine_file, NULL, scratch_pool));
+
+  /* Externals */
   SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_CREATE_EXTERNALS));
   SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_29));
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_wc/wc.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc.h?rev=1125455&r1=1125454&r2=1125455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc.h Fri May 20 16:38:24 2011
@@ -146,7 +146,9 @@ extern "C" {
  * The bump to 28 converted any remaining references to MD5 checksums
  *   to SHA1 checksums. Bumped in r1095214.
  *
- * The bump to 29 will probably introduce the EXTERNALS store. Not bumped yet
+ * The bump to 29 renamed the pristine files from '<SHA1>' to
+ * '<SHA1>.svn-base' and introduced the EXTERNALS store.
+ * ### Not bumped yet
  *
  * == 1.7.x shipped with format ???
  *

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c?rev=1125455&r1=1125454&r2=1125455&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Fri May 20 16:38:24 
2011
@@ -32,6 +32,7 @@
 #include "wc-queries.h"
 #include "wc_db_private.h"
 
+#define PRISTINE_STORAGE_EXT ".svn-base"
 #define PRISTINE_STORAGE_RELPATH "pristine"
 #define PRISTINE_TEMPDIR_RELPATH ""
 
@@ -75,7 +76,12 @@ get_pristine_fname(const char **pristine
   subdir[1] = hexdigest[1];
   subdir[2] = '\0';
 
-  /* The file is located at DIR/.svn/pristine/XX/XXYYZZ... */
+#if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
+  hexdigest = apr_pstrcat(scratch_pool, hexdigest, PRISTINE_STORAGE_EXT,
+                          (char *)NULL);
+#endif
+
+  /* The file is located at DIR/.svn/pristine/XX/XXYYZZ...svn-base */
   *pristine_abspath = svn_dirent_join_many(result_pool,
                                            base_dir_abspath,
                                            subdir,

Modified: subversion/trunk/subversion/tests/cmdline/svntest/wc.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/wc.py?rev=1125455&r1=1125454&r2=1125455&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/wc.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/wc.py Fri May 20 16:38:24 
2011
@@ -857,6 +857,7 @@ def text_base_path(file_path):
   # Calculate single DB location
   dot_svn = svntest.main.get_admin_name()
   fn = os.path.join(root_path, dot_svn, 'pristine', checksum[0:2], checksum)
+  ### When SVN_WC__VERSION is bumped to 29, then use: checksum + ".svn-base"
 
   if os.path.isfile(fn):
     return fn


Reply via email to