You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2010/05/07 22:49:26 UTC
svn commit: r942214 - in /subversion/trunk/subversion/libsvn_wc: props.c
workqueue.c workqueue.h
Author: gstein
Date: Fri May 7 20:49:26 2010
New Revision: 942214
URL: http://svn.apache.org/viewvc?rev=942214&view=rev
Log:
Introduce a work item to write an old-style properties file, then use it
wherever we actually attempt to write such a file.
* subversion/libsvn_wc/workqueue.h:
(svn_wc__wq_build_write_old_props): new declaration
* subversion/libsvn_wc/workqueue.c:
(OP_WRITE_OLD_PROPS): new operation code
(run_install_properties): don't immediately write out the files.
instead, queue up more items to do the writing.
(run_write_old_props): new handler to write old-style props files
(svn_wc__wq_build_write_old_props): new function
(dispatch_table): add the new opcode and handler
* subversion/libsvn_wc/props.c:
(immediate_install_props): rather than writing the file manually,
construct a work item, queue it, then run the queue. this is the long
way around but we actually want that work item for the next iteration
Modified:
subversion/trunk/subversion/libsvn_wc/props.c
subversion/trunk/subversion/libsvn_wc/workqueue.c
subversion/trunk/subversion/libsvn_wc/workqueue.h
Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=942214&r1=942213&r2=942214&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Fri May 7 20:49:26 2010
@@ -403,6 +403,7 @@ immediate_install_props(svn_wc__db_t *db
apr_hash_t *base_props;
const char *propfile_abspath;
apr_array_header_t *prop_diffs;
+ const svn_skel_t *work_item;
/* ### no pristines should be okay. */
SVN_ERR_W(load_pristine_props(&base_props, db, local_abspath,
@@ -416,28 +417,20 @@ immediate_install_props(svn_wc__db_t *db
SVN_ERR(svn_prop_diffs(&prop_diffs, working_props, base_props,
scratch_pool));
- /* Save the working properties file if it differs from base. */
- if (prop_diffs->nelts > 0)
- {
- /* Write out the properties (synchronously). */
- svn_stream_t *stream;
-
- SVN_ERR(svn_io_remove_file2(propfile_abspath, TRUE, scratch_pool));
- SVN_ERR(svn_stream_open_writable(&stream, propfile_abspath, scratch_pool,
- scratch_pool));
- if (apr_hash_count(working_props) != 0)
- SVN_ERR(svn_hash_write2(working_props, stream, SVN_HASH_TERMINATOR,
- scratch_pool));
- SVN_ERR(svn_stream_close(stream));
+ /* Save (if there are differences from "base") or remove the
+ ACTUAL (aka "props_working") properties file. */
- SVN_ERR(svn_io_set_file_read_only(propfile_abspath, FALSE,
- scratch_pool));
- }
- else
- {
- /* No property modifications, remove the file instead. */
- SVN_ERR(svn_io_remove_file2(propfile_abspath, TRUE, scratch_pool));
- }
+ /* ### for now, we play some hacky with work items and the queue */
+ SVN_ERR(svn_wc__wq_build_write_old_props(&work_item,
+ propfile_abspath,
+ prop_diffs->nelts > 0
+ ? working_props
+ : NULL,
+ scratch_pool));
+ SVN_ERR(svn_wc__db_wq_add(db, local_abspath, work_item, scratch_pool));
+ SVN_ERR(svn_wc__wq_run(db, local_abspath,
+ NULL, NULL, /* cancel_func/baton */
+ scratch_pool));
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath,
(prop_diffs->nelts > 0) ? working_props
Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=942214&r1=942213&r2=942214&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Fri May 7 20:49:26 2010
@@ -63,6 +63,7 @@
#define OP_FILE_REMOVE "file-remove"
#define OP_SYNC_FILE_FLAGS "sync-file-flags"
#define OP_PREJ_INSTALL "prej-install"
+#define OP_WRITE_OLD_PROPS "write-old-props"
/* For work queue debugging. Generates output about its operation. */
@@ -1608,23 +1609,17 @@ run_install_properties(svn_wc__db_t *db,
{
SVN_ERR(svn_wc__prop_path(&prop_abspath, local_abspath, kind,
svn_wc__props_base, scratch_pool));
+ /* ### oh hack! */
+ {
+ const svn_skel_t *write_item;
- SVN_ERR(svn_io_remove_file2(prop_abspath, TRUE, scratch_pool));
-
- if (apr_hash_count(base_props) > 0)
- {
- svn_stream_t *propfile;
-
- SVN_ERR(svn_stream_open_writable(&propfile, prop_abspath,
- scratch_pool, scratch_pool));
-
- SVN_ERR(svn_hash_write2(base_props, propfile, SVN_HASH_TERMINATOR,
+ SVN_ERR(svn_wc__wq_build_write_old_props(&write_item,
+ prop_abspath,
+ base_props,
+ scratch_pool));
+ SVN_ERR(svn_wc__db_wq_add(db, local_abspath, write_item,
scratch_pool));
-
- SVN_ERR(svn_stream_close(propfile));
-
- SVN_ERR(svn_io_set_file_read_only(prop_abspath, FALSE, scratch_pool));
- }
+ }
{
svn_boolean_t written = FALSE;
@@ -1660,22 +1655,17 @@ run_install_properties(svn_wc__db_t *db,
SVN_ERR(svn_wc__prop_path(&prop_abspath, local_abspath, kind,
svn_wc__props_working, scratch_pool));
+ /* ### oh hack! */
+ {
+ const svn_skel_t *write_item;
- SVN_ERR(svn_io_remove_file2(prop_abspath, TRUE, scratch_pool));
-
- if (actual_props != NULL)
- {
- svn_stream_t *propfile;
-
- SVN_ERR(svn_stream_open_writable(&propfile, prop_abspath,
- scratch_pool, scratch_pool));
-
- SVN_ERR(svn_hash_write2(actual_props, propfile, SVN_HASH_TERMINATOR,
+ SVN_ERR(svn_wc__wq_build_write_old_props(&write_item,
+ prop_abspath,
+ actual_props,
+ scratch_pool));
+ SVN_ERR(svn_wc__db_wq_add(db, local_abspath, write_item,
scratch_pool));
-
- SVN_ERR(svn_stream_close(propfile));
- SVN_ERR(svn_io_set_file_read_only(prop_abspath, FALSE, scratch_pool));
- }
+ }
SVN_ERR(svn_wc__db_op_set_props(db, local_abspath, actual_props,
scratch_pool));
@@ -2167,6 +2157,82 @@ svn_wc__wq_build_prej_install(const svn_
/* ------------------------------------------------------------------------ */
+/* OP_WRITE_OLD_PROPS */
+
+static svn_error_t *
+run_write_old_props(svn_wc__db_t *db,
+ const svn_skel_t *work_item,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
+{
+ const svn_skel_t *arg1 = work_item->children->next;
+ const char *props_abspath;
+ svn_stream_t *stream;
+ apr_hash_t *props;
+
+ props_abspath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
+
+ /* Torch whatever may be there. */
+ SVN_ERR(svn_io_remove_file2(props_abspath, TRUE, scratch_pool));
+
+ if (arg1->next == NULL)
+ {
+ /* PROPS == NULL means the file should be removed. Note that an
+ empty set of properties has an entirely different meaning.
+
+ The file has already been removed. Simply exit. */
+ return SVN_NO_ERROR;
+ }
+ SVN_ERR(svn_skel__parse_proplist(&props, arg1->next, scratch_pool));
+
+ SVN_ERR(svn_stream_open_writable(&stream, props_abspath,
+ scratch_pool, scratch_pool));
+
+ /* An empty file is shorthand for an empty set of properties. */
+ if (apr_hash_count(props) != 0)
+ SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, scratch_pool));
+
+ SVN_ERR(svn_stream_close(stream));
+
+ SVN_ERR(svn_io_set_file_read_only(props_abspath,
+ FALSE /* ignore_enoent */,
+ scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__wq_build_write_old_props(const svn_skel_t **work_item,
+ const char *props_abspath,
+ apr_hash_t *props,
+ apr_pool_t *result_pool)
+{
+ svn_skel_t *build_item = svn_skel__make_empty_list(result_pool);
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(props_abspath));
+
+ if (props != NULL)
+ {
+ svn_skel_t *props_skel;
+
+ SVN_ERR(svn_skel__unparse_proplist(&props_skel, props, result_pool));
+ svn_skel__prepend(props_skel, build_item);
+ }
+ svn_skel__prepend_str(apr_pstrdup(result_pool, props_abspath),
+ build_item, result_pool);
+ svn_skel__prepend_str(OP_WRITE_OLD_PROPS, build_item, result_pool);
+
+ /* Done. Assign to the const-ful WORK_ITEM. */
+ *work_item = build_item;
+
+ return SVN_NO_ERROR;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
static const struct work_item_dispatch dispatch_table[] = {
{ OP_REVERT, run_revert },
{ OP_PREPARE_REVERT_FILES, run_prepare_revert_files },
@@ -2180,6 +2246,7 @@ static const struct work_item_dispatch d
{ OP_FILE_REMOVE, run_file_remove },
{ OP_SYNC_FILE_FLAGS, run_sync_file_flags },
{ OP_PREJ_INSTALL, run_prej_install },
+ { OP_WRITE_OLD_PROPS, run_write_old_props },
/* Sentinel. */
{ NULL }
Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=942214&r1=942213&r2=942214&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.h (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.h Fri May 7 20:49:26 2010
@@ -119,6 +119,17 @@ svn_wc__wq_build_prej_install(const svn_
apr_pool_t *scratch_pool);
+/* Build a work item that will install PROPS at PROPS_ABSPATH. If PROPS
+ is NULL, then the target props file will will be removed.
+
+ ### this will go away when we fully move to in-db properties. */
+svn_error_t *
+svn_wc__wq_build_write_old_props(const svn_skel_t **work_item,
+ const char *props_abspath,
+ apr_hash_t *props,
+ apr_pool_t *result_pool);
+
+
/* Record a work item to revert LOCAL_ABSPATH. */
svn_error_t *
svn_wc__wq_add_revert(svn_boolean_t *will_revert,