You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/03/23 17:01:06 UTC
svn commit: r926637 - in /subversion/trunk/subversion/libsvn_wc: adm_files.c
adm_files.h update_editor.c
Author: julianfoad
Date: Tue Mar 23 16:01:06 2010
New Revision: 926637
URL: http://svn.apache.org/viewvc?rev=926637&view=rev
Log:
Unify the writing of new WC-1 text-base files in three different places in
update_editor.c.
This is a re-application of the patch I first committed in r919413 (and
Philip tweaked in r919436) and which I then reverted in r919478. I have
since charted the usage of temp text bases (see
'notes/wc-ng/use-of-tmp-text-base-path') and found that the usage here is
independent of the special path given by svn_wc__text_base_path(), and is
safe to change.
* subversion/libsvn_wc/adm_files.h,
subversion/libsvn_wc/adm_files.c
(svn_wc__open_writable_base): Change from creating the temporary file at
a special path (that depended on whether it was a revert-base) to
creating it with an arbitrary and unique name in the admin temp dir.
(open_adm_file): Remove.
* subversion/libsvn_wc/update_editor.c
(add_file_with_history, svn_wc_add_repos_file4): Use
svn_wc__open_writable_base() instead of the equivalent long-hand code.
(apply_textdelta): Adjust by passing the 'db' instead of a 'revert' flag
to svn_wc__open_writable_base().
Modified:
subversion/trunk/subversion/libsvn_wc/adm_files.c
subversion/trunk/subversion/libsvn_wc/adm_files.h
subversion/trunk/subversion/libsvn_wc/update_editor.c
Modified: subversion/trunk/subversion/libsvn_wc/adm_files.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.c?rev=926637&r1=926636&r2=926637&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.c Tue Mar 23 16:01:06 2010
@@ -375,60 +375,6 @@ svn_wc__prop_path(const char **prop_path
/*** Opening and closing files in the adm area. ***/
-/* Create and open a writable file in the admin temporary area of the WC
- directory DIR_ABSPATH, in a subdirectory named SUBDIR (such as "text-base"),
- with the name FNAME and extra EXTENSION (such as ".svn-base"). If the
- file already exists, first delete it. Set *STREAM to a writable stream
- to this file, and (if SELECTED_ABSPATH is not NULL) set *SELECTED_PATH to
- the path to this file, both allocated in RESULT_POOL.
-
- Closing the stream will close (but not delete) the file. */
-static svn_error_t *
-open_adm_file(svn_stream_t **stream,
- const char **selected_abspath,
- const char *dir_abspath,
- const char *subdir,
- const char *fname,
- const char *extension,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- svn_error_t *err;
-
- SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
-
- /* Extend with tmp name. */
- dir_abspath = extend_with_adm_name(dir_abspath, extension, TRUE, result_pool,
- subdir, fname, NULL);
- if (selected_abspath)
- *selected_abspath = dir_abspath; /* note: built in result_pool */
-
- err = svn_stream_open_writable(stream, dir_abspath, result_pool, scratch_pool);
- if (err && APR_STATUS_IS_EEXIST(err->apr_err))
- {
- /* Exclusive open failed, delete and retry */
- svn_error_clear(err);
- SVN_ERR(svn_io_remove_file2(dir_abspath, FALSE, scratch_pool));
- err = svn_stream_open_writable(stream, dir_abspath, result_pool, scratch_pool);
- }
-
- /* Examine the error from the first and/or second attempt at opening. */
- if (err && APR_STATUS_IS_ENOENT(err->apr_err))
- {
- /* If we receive a failure to open a file in our temporary directory,
- * it may be because our temporary directories aren't created.
- * Older SVN clients did not create these directories.
- * 'svn cleanup' will fix this problem.
- */
- err = svn_error_quick_wrap(err,
- _("Your .svn/tmp directory may be missing or "
- "corrupt; run 'svn cleanup' and try again"));
- }
-
- return svn_error_return(err);
-}
-
-
svn_error_t *
svn_wc__open_adm_stream(svn_stream_t **stream,
const char *dir_abspath,
@@ -449,26 +395,24 @@ svn_wc__open_adm_stream(svn_stream_t **s
svn_error_t *
svn_wc__open_writable_base(svn_stream_t **stream,
const char **temp_base_abspath,
+ svn_wc__db_t *db,
const char *local_abspath,
- svn_boolean_t need_revert_base,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- const char *parent_abspath;
- const char *base_name;
-
+ const char *temp_dir_abspath;
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
- svn_dirent_split(local_abspath, &parent_abspath, &base_name, scratch_pool);
-
- return open_adm_file(stream, temp_base_abspath,
- parent_abspath,
- SVN_WC__ADM_TEXT_BASE,
- base_name,
- need_revert_base
- ? SVN_WC__REVERT_EXT
- : SVN_WC__BASE_EXT,
- result_pool, scratch_pool);
+ /* Select a directory in which to put a WC-1-style temp text-base file. */
+ /* See update_editor.c:get_pristine_tee_stream() for the WC-NG way. */
+ SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&temp_dir_abspath, db, local_abspath,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_stream_open_unique(stream,
+ temp_base_abspath,
+ temp_dir_abspath,
+ svn_io_file_del_none,
+ result_pool, scratch_pool));
+ return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_wc/adm_files.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_files.h?rev=926637&r1=926636&r2=926637&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_files.h (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_files.h Tue Mar 23 16:01:06 2010
@@ -118,17 +118,17 @@ svn_error_t *svn_wc__open_adm_stream(svn
apr_pool_t *scratch_pool);
-/* Open the normal or revert text base, associated with LOCAL_ABSPATH, for
- writing.
- The selection is based on NEED_REVERT_BASE. The opened stream will be
- returned in STREAM and the selected path will be returned in,
- TEMP_BASE_ABSPATH, and both will be allocated in RESULT_POOL. Any temporary
- allocations will be performed in SCRATCH_POOL. */
+/* Open a writable stream to a temporary (normal or revert) text base,
+ associated with the versioned file LOCAL_ABSPATH in DB. Set *STREAM to
+ the opened stream and *TEMP_BASE_ABSPATH to the path to the temporary
+ file, both allocated in RESULT_POOL. The temporary file will have an
+ arbitrary unique name, in contrast to the deterministic name that
+ svn_wc__text_base_path(tmp=TRUE) returns. */
svn_error_t *
svn_wc__open_writable_base(svn_stream_t **stream,
const char **temp_base_abspath,
+ svn_wc__db_t *db,
const char *local_abspath,
- svn_boolean_t need_revert_base,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=926637&r1=926636&r2=926637&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Mar 23 16:01:06 2010
@@ -3518,7 +3518,6 @@ add_file_with_history(const char *path,
apr_hash_t *base_props, *working_props;
svn_error_t *err;
svn_stream_t *copied_stream;
- const char *temp_dir_abspath;
const char *src_local_abspath;
svn_wc__db_t *db = eb->db;
const char *dir_repos_relpath, *dir_repos_root, *dir_repos_uuid;
@@ -3544,13 +3543,10 @@ add_file_with_history(const char *path,
else
SVN_ERR(err);
- SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&temp_dir_abspath, db, pb->local_abspath,
- subpool, subpool));
- SVN_ERR(svn_stream_open_unique(&copied_stream,
- &tfb->copied_text_base,
- temp_dir_abspath,
- svn_io_file_del_none,
- pool, pool));
+ /* Open the text base for writing (this will get us a temporary file). */
+ SVN_ERR(svn_wc__open_writable_base(&copied_stream, &tfb->copied_text_base,
+ db, pb->local_abspath,
+ pool, pool));
#ifdef SVN_EXPERIMENTAL
/* Copy the 'copied_stream' into a WC-NG pristine temp file as well. */
SVN_ERR(get_pristine_tee_stream(&copied_stream, &tfb->temp_pristine_abspath,
@@ -4228,8 +4224,7 @@ apply_textdelta(void *file_baton,
/* Open the text base for writing (this will get us a temporary file). */
err = svn_wc__open_writable_base(&target, &hb->work_abspath,
- fb->local_abspath,
- replaced /* need_revert_base */,
+ fb->edit_baton->db, fb->local_abspath,
handler_pool, pool);
if (err)
{
@@ -6017,9 +6012,9 @@ svn_wc_add_repos_file4(svn_wc_context_t
/* Copy the text base contents into a temporary file so our log
can refer to it. Compute its checksum as we copy. */
- SVN_ERR(svn_stream_open_unique(&tmp_base_contents, &tmp_text_base_path,
- temp_dir_abspath, svn_io_file_del_none, pool,
- pool));
+ SVN_ERR(svn_wc__open_writable_base(&tmp_base_contents, &tmp_text_base_path,
+ wc_ctx->db, local_abspath,
+ pool, pool));
new_base_contents = svn_stream_checksummed2(new_base_contents,
&base_checksum, NULL,
svn_checksum_md5, TRUE, pool);