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 2022/12/02 12:38:03 UTC
svn commit: r1905689 - in /subversion/branches/pristines-on-demand-on-mwf/subversion: include/svn_error_codes.h include/svn_wc.h libsvn_wc/adm_crawler.c libsvn_wc/adm_ops.c libsvn_wc/externals.c libsvn_wc/textbase.c libsvn_wc/textbase.h
Author: kotkov
Date: Fri Dec 2 12:38:02 2022
New Revision: 1905689
URL: http://svn.apache.org/viewvc?rev=1905689&view=rev
Log:
On the 'pristines-on-demand-on-mwf' branch: Rework how we handle a situation
where the caller attempts to access a dehydrated pristine. Ensure that all
newer APIs return a distinguishable error code in this case.
* subversion/include/svn_error_codes.h
(SVN_ERR_WC_PRISTINE_DEHYDRATED): New error code.
* subversion/include/svn_wc.h
(svn_wc_crawl_revisions6,
svn_wc_diff7,
svn_wc_merge6,
svn_wc_get_pristine_contents3,
svn_wc_revert7,
svn_wc_restore2): Adjust documentation for these functions.
Explain the circumstances when the new error will be returned.
* subversion/libsvn_wc/adm_crawler.c
(svn_wc__internal_transmit_text_deltas): Handle the new error code
internally, using it to send a fulltext instead of a delta.
* subversion/libsvn_wc/adm_ops.c
(get_pristine_lazyopen_func): Return the new specific error code.
* subversion/libsvn_wc/externals.c
(close_file): Return the new specific error code.
* subversion/libsvn_wc/textbase.h
(svn_wc__textbase_get_contents): Adjust documentation.
* subversion/libsvn_wc/textbase.c
(open_textbase): Return the new error on an attempt to access the
missing contents of an optional pristine.
Modified:
subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_error_codes.h
subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_wc.h
subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_crawler.c
subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_ops.c
subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/externals.c
subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.c
subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.h
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_error_codes.h?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_error_codes.h (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_error_codes.h Fri Dec 2 12:38:02 2022
@@ -587,6 +587,11 @@ SVN_ERROR_START
"This client uses a deprecated API that does not support "
"working copies without local pristines")
+ /** @since New in 1.15 */
+ SVN_ERRDEF(SVN_ERR_WC_PRISTINE_DEHYDRATED,
+ SVN_ERR_WC_CATEGORY_START + 44,
+ "No local pristine contents for a file")
+
/* fs errors */
SVN_ERRDEF(SVN_ERR_FS_GENERAL,
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_wc.h
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_wc.h?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_wc.h (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/include/svn_wc.h Fri Dec 2 12:38:02 2022
@@ -5549,7 +5549,10 @@ svn_wc_process_committed(const char *pat
* @a notify_baton and the path of the restored file. @a notify_func may
* be @c NULL if this notification is not required. If @a
* use_commit_times is TRUE, then set restored files' timestamps to
- * their last-commit-times.
+ * their last-commit-times. For working copies that do not store local
+ * pristine contents for all files, return @c SVN_ERR_WC_PRISTINE_DEHYDRATED
+ * on an attempt to restore a file whose pristine contents is not present
+ * locally.
*
* @note This is a relatively low-level function operating directly on a
* working copy, so a caller is expected to be able to handle working copies
@@ -5557,9 +5560,6 @@ svn_wc_process_committed(const char *pat
* achieved by synchronizing the text-base state before and optionally
* after the function call. @see svn_wc_textbase_sync().
*
- * Currently, the pristine contents may be required when @a restore_files
- * is TRUE.
- *
* @since New in 1.15.
*/
svn_error_t *
@@ -6815,6 +6815,10 @@ svn_wc_get_diff_editor(svn_wc_adm_access
* points during the operation. If it returns an error (typically
* #SVN_ERR_CANCELLED), return that error immediately.
*
+ * For working copies that do not store local pristine contents for all
+ * files, return @c SVN_ERR_WC_PRISTINE_DEHYDRATED on an attempt to diff
+ * a file whose pristine contents is not present locally.
+ *
* @note For general purposes, please consider using APIs from svn_client.h,
* @see svn_client_diff7().
*
@@ -7111,6 +7115,10 @@ typedef enum svn_wc_merge_outcome_t
*
* Use @a scratch_pool for any temporary allocation.
*
+ * For working copies that do not store local pristine contents for all
+ * files, return @c SVN_ERR_WC_PRISTINE_DEHYDRATED on an attempt to merge
+ * a file whose pristine contents is not present locally.
+ *
* @note This is a relatively low-level function operating directly on a
* working copy, so a caller is expected to be able to handle working copies
* that do not store local copies of all pristine contents. This can be
@@ -7420,6 +7428,12 @@ svn_wc_merge_prop_diffs(svn_wc_notify_st
* @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a wc_ctx to access the working copy.
* @a contents may not be @c NULL (unlike @a *contents).
*
+ * For working copies that do not store local pristine contents for all
+ * files, the function may return a detranslated stream to the contents
+ * of the file itself if the file is not modified. If the file is
+ * modified and its pristine contents is not present locally, return
+ * @c SVN_ERR_WC_PRISTINE_DEHYDRATED.
+ *
* @note This is a relatively low-level function operating directly on a
* working copy, so a caller is expected to be able to handle working copies
* that do not store local copies of all pristine contents. This can be
@@ -7842,6 +7856,10 @@ svn_wc_relocate(const char *path,
* If @a path is not under version control, return the error
* #SVN_ERR_UNVERSIONED_RESOURCE.
*
+ * For working copies that do not store local pristine contents for all
+ * files, return @c SVN_ERR_WC_PRISTINE_DEHYDRATED on an attempt to revert
+ * a file whose pristine contents is not present locally.
+ *
* @note For general purposes, please consider using APIs from svn_client.h,
* @see svn_client_revert4().
*
@@ -8002,6 +8020,10 @@ svn_wc_revert(const char *path,
* SVN_ERROR_WC_PATH_UNEXPECTED_STATUS if LOCAL_ABSPATH is in a status where
* it can't be restored.
*
+ * For working copies that do not store local pristine contents for all
+ * files, return @c SVN_ERR_WC_PRISTINE_DEHYDRATED on an attempt to restore
+ * a file whose pristine contents is not present locally.
+ *
* @note This is a relatively low-level function operating directly on a
* working copy, so a caller is expected to be able to handle working copies
* that do not store local copies of all pristine contents. This can be
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_crawler.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_crawler.c?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_crawler.c Fri Dec 2 12:38:02 2022
@@ -1127,11 +1127,23 @@ svn_wc__internal_transmit_text_deltas(sv
/* We will be computing a delta against the pristine contents */
/* We need the expected checksum to be an MD-5 checksum rather than a
* SHA-1 because we want to pass it to apply_textdelta(). */
- SVN_ERR(read_and_checksum_pristine_text(&base_stream,
- &expected_md5_checksum,
- &verify_checksum,
- db, local_abspath,
- scratch_pool, scratch_pool));
+ err = read_and_checksum_pristine_text(&base_stream,
+ &expected_md5_checksum,
+ &verify_checksum,
+ db, local_abspath,
+ scratch_pool, scratch_pool);
+ if (err && err->apr_err == SVN_ERR_WC_PRISTINE_DEHYDRATED)
+ {
+ /* No local pristine contents to delta against, send a fulltext. */
+ svn_error_clear(err);
+ base_stream = svn_stream_empty(scratch_pool);
+ expected_md5_checksum = NULL;
+ verify_checksum = NULL;
+ }
+ else if (err)
+ {
+ return svn_error_trace(err);
+ }
}
else
{
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_ops.c?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/adm_ops.c Fri Dec 2 12:38:02 2022
@@ -862,7 +862,7 @@ get_pristine_lazyopen_func(svn_stream_t
b->wri_abspath, sha1_checksum,
result_pool, scratch_pool));
if (!stream)
- return svn_error_create(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL, NULL);
+ return svn_error_create(SVN_ERR_WC_PRISTINE_DEHYDRATED, NULL, NULL);
*stream_p = stream;
return SVN_NO_ERROR;
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/externals.c?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/externals.c (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/externals.c Fri Dec 2 12:38:02 2022
@@ -900,7 +900,7 @@ close_file(void *file_baton,
eb->new_sha1_checksum,
pool, pool));
if (!contents)
- return svn_error_create(SVN_ERR_WC_PATH_UNEXPECTED_STATUS,
+ return svn_error_create(SVN_ERR_WC_PRISTINE_DEHYDRATED,
NULL, NULL);
SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath,
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.c
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.c?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.c (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.c Fri Dec 2 12:38:02 2022
@@ -210,6 +210,7 @@ open_textbase(svn_stream_t **contents_p,
svn_boolean_t have_props;
svn_boolean_t props_mod;
const svn_checksum_t *target_checksum;
+ svn_stream_t *contents;
SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, &checksum, NULL, NULL,
@@ -301,9 +302,14 @@ open_textbase(svn_stream_t **contents_p,
}
}
- SVN_ERR(svn_wc__db_pristine_read(contents_p, NULL, db, local_abspath,
+ SVN_ERR(svn_wc__db_pristine_read(&contents, NULL, db, local_abspath,
target_checksum, result_pool, scratch_pool));
+ if (!contents)
+ return svn_error_createf(SVN_ERR_WC_PRISTINE_DEHYDRATED, NULL,
+ _("No local pristine contents for file '%s'"),
+ svn_dirent_local_style(local_abspath, scratch_pool));
+ *contents_p = contents;
return SVN_NO_ERROR;
}
Modified: subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.h
URL: http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.h?rev=1905689&r1=1905688&r2=1905689&view=diff
==============================================================================
--- subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.h (original)
+++ subversion/branches/pristines-on-demand-on-mwf/subversion/libsvn_wc/textbase.h Fri Dec 2 12:38:02 2022
@@ -40,12 +40,15 @@ extern "C" {
* the text-base will correspond to the copy source, even if the file
* replaces a previously existing base node at this path.
*
- * If the file is not modified, the function may return a detranslated
- * stream to the contents of the file itself.
+ * If the file is simply added or replaced and does not have a text-base,
+ * set *CONTENTS_P to NULL if IGNORE_ENOENT is true and return an error
+ * if IGNORE_ENOENT is false.
*
- * If the text-base is not available on disk or if the file does not
- * have a text-base, set *CONTENTS_P to NULL iff IGNORE_ENOENT is true
- * and return an error otherwise.
+ * For working copies that do not store local text-base contents for all
+ * files, the function may return a detranslated stream to the contents
+ * of the file itself if the file is not modified. If the file is
+ * modified and its text-base contents is not present locally, return
+ * an SVN_ERR_WC_PRISTINE_DEHYDRATED error.
*/
svn_error_t *
svn_wc__textbase_get_contents(svn_stream_t **contents_p,