You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2021/02/13 14:27:49 UTC

svn commit: r1886489 - in /subversion/trunk/subversion: include/private/svn_io_private.h libsvn_subr/stream.c libsvn_wc/wc_db_pristine.c

Author: kotkov
Date: Sat Feb 13 14:27:49 2021
New Revision: 1886489

URL: http://svn.apache.org/viewvc?rev=1886489&view=rev
Log:
Lay a bit of necessary groundwork for streamy checkouts.

Make the get_info function for an install stream return only the parts
of the file information that we require right now (mtime and size), instead
of supporting arbitrary APR finfo requests.  This should make it easier to
introduce an ability to set custom mtime and attributes for the install
stream.

* subversion/include/private/svn_io_private.h
  (svn_stream__install_get_info): Return the mtime and size as two optional
   arguments.

* subversion/libsvn_subr/stream.c
  (svn_stream__install_get_info): Rework to make the apr_file_info_get()
   call with predefined flags, depending on which parts of the information
   the caller has asked for.

* subversion/libsvn_wc/wc_db_pristine.c
  (pristine_install_txn): Update calls to svn_stream__install_get_info().

Modified:
    subversion/trunk/subversion/include/private/svn_io_private.h
    subversion/trunk/subversion/libsvn_subr/stream.c
    subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c

Modified: subversion/trunk/subversion/include/private/svn_io_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_io_private.h?rev=1886489&r1=1886488&r2=1886489&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_io_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_io_private.h Sat Feb 13 14:27:49 2021
@@ -119,12 +119,12 @@ svn_error_t *
 svn_stream__install_delete(svn_stream_t *install_stream,
                            apr_pool_t *scratch_pool);
 
-/* Optimized apr_file_stat / apr_file_info_get operating on a closed
-   install stream */
+/* Retrieves file information for the specified install stream.
+   MTIME_P and SIZE_P both may be NULL to allow for partial queries. */
 svn_error_t *
-svn_stream__install_get_info(apr_finfo_t *finfo,
+svn_stream__install_get_info(apr_time_t *mtime_p,
+                             apr_off_t *size_p,
                              svn_stream_t *install_stream,
-                             apr_int32_t wanted,
                              apr_pool_t *scratch_pool);
 
 /* Internal version of svn_stream_from_aprfile2() supporting the

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1886489&r1=1886488&r2=1886489&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Sat Feb 13 14:27:49 2021
@@ -2399,18 +2399,34 @@ svn_stream__install_stream(svn_stream_t
 }
 
 svn_error_t *
-svn_stream__install_get_info(apr_finfo_t *finfo,
+svn_stream__install_get_info(apr_time_t *mtime_p,
+                             apr_off_t *size_p,
                              svn_stream_t *install_stream,
-                             apr_int32_t wanted,
                              apr_pool_t *scratch_pool)
 {
   struct install_baton_t *ib = install_stream->baton;
   apr_status_t status;
+  apr_int32_t wanted;
+  apr_finfo_t finfo;
 
-  status = apr_file_info_get(finfo, wanted, ib->baton_apr.file);
+  wanted = 0;
+  if (mtime_p)
+    wanted |= APR_FINFO_MTIME;
+  if (size_p)
+    wanted |= APR_FINFO_SIZE;
 
-  if (status)
-    return svn_error_wrap_apr(status, NULL);
+  if (wanted)
+    {
+      status = apr_file_info_get(&finfo, wanted, ib->baton_apr.file);
+      if (status)
+        return svn_error_wrap_apr(status, NULL);
+    }
+
+  if (mtime_p)
+    *mtime_p = finfo.mtime;
+
+  if (size_p)
+    *size_p = finfo.size;
 
   return SVN_NO_ERROR;
 }

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=1886489&r1=1886488&r2=1886489&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Sat Feb 13 14:27:49 2021
@@ -305,21 +305,22 @@ pristine_install_txn(svn_sqlite__db_t *s
       /* Consistency checks.  Verify both files exist and match.
        * ### We could check much more. */
       {
-        apr_finfo_t finfo1, finfo2;
+        apr_finfo_t finfo;
+        apr_off_t size;
 
-        SVN_ERR(svn_stream__install_get_info(&finfo1, install_stream, APR_FINFO_SIZE,
+        SVN_ERR(svn_stream__install_get_info(NULL, &size, install_stream,
                                              scratch_pool));
 
-        SVN_ERR(svn_io_stat(&finfo2, pristine_abspath, APR_FINFO_SIZE,
+        SVN_ERR(svn_io_stat(&finfo, pristine_abspath, APR_FINFO_SIZE,
                             scratch_pool));
-        if (finfo1.size != finfo2.size)
+        if (size != finfo.size)
           {
             return svn_error_createf(
               SVN_ERR_WC_CORRUPT_TEXT_BASE, NULL,
               _("New pristine text '%s' has different size: %s versus %s"),
               svn_checksum_to_cstring_display(sha1_checksum, scratch_pool),
-              apr_off_t_toa(scratch_pool, finfo1.size),
-              apr_off_t_toa(scratch_pool, finfo2.size));
+              apr_off_t_toa(scratch_pool, size),
+              apr_off_t_toa(scratch_pool, finfo.size));
           }
       }
 #endif
@@ -332,16 +333,17 @@ pristine_install_txn(svn_sqlite__db_t *s
   /* Move the file to its target location.  (If it is already there, it is
    * an orphan file and it doesn't matter if we overwrite it.) */
   {
-    apr_finfo_t finfo;
-    SVN_ERR(svn_stream__install_get_info(&finfo, install_stream,
-                                         APR_FINFO_SIZE, scratch_pool));
+    apr_off_t size;
+
+    SVN_ERR(svn_stream__install_get_info(NULL, &size, install_stream,
+                                         scratch_pool));
     SVN_ERR(svn_stream__install_stream(install_stream, pristine_abspath,
                                        TRUE, scratch_pool));
 
     SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_PRISTINE));
     SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
     SVN_ERR(svn_sqlite__bind_checksum(stmt, 2, md5_checksum, scratch_pool));
-    SVN_ERR(svn_sqlite__bind_int64(stmt, 3, finfo.size));
+    SVN_ERR(svn_sqlite__bind_int64(stmt, 3, size));
     SVN_ERR(svn_sqlite__insert(NULL, stmt));
 
     SVN_ERR(svn_io_set_file_read_only(pristine_abspath, FALSE, scratch_pool));