Author: gstein Date: Mon May 10 21:18:06 2010 New Revision: 942906 URL: http://svn.apache.org/viewvc?rev=942906&view=rev Log: Introduce OP_RECORD_FILEINFO, which allows us to strip out two loggy operations and a bunch of hacky sorta-loggy_modify_entry code. The fallout also moves a few more things into old-and-busted, which also gets simplified because it doesn't have to track the special attr values.
* subversion/libsvn_wc/workqueue.h: (svn_wc__wq_build_record_fileinfo): new operation * subversion/libsvn_wc/workqueue.c: (OP_RECORD_FILEINFO): new operation (get_and_record_fileinfo): new helper, with guts from run_file_install. added ability to ignore missing files. (run_file_install): shift code to get_and_record_fileinfo and call it (run_record_fileinfo): simple operation to call get_and_record_fileinfo (svn_wc__wq_build_record_fileinfo): new function to build OP_RECORD_FILEINFO work items (dispatch_table): add OP_RECORD_FILEINFO and its handler * subversion/libsvn_wc/update_editor.c: (merge_file): remove calls to two loggy functions and queue an OP_RECORD_FILEINFO instead. leave some comments here. the exact conditions around this code are quite sketchy/unclear. * subversion/libsvn_wc/log.h: (svn_wc__loggy_set_entry_timestamp_from_wc): removed (svn_wc__loggy_set_entry_working_size_from_wc): removed * subversion/libsvn_wc/log.c: (svn_wc__loggy_set_entry_timestamp_from_wc): removed (svn_wc__loggy_set_entry_working_size_from_wc): removed (log_do_modify_entry): without the special attribute values, this function can be dramatically simplified. * subversion/libsvn_wc/entries.h: (SVN_WC__ENTRY_ATTR_TEXT_TIME, SVN_WC__ENTRY_ATTR_WORKING_SIZE): no longer used after the log.c changes. moved to old-and-busted.c * subversion/libsvn_wc/old-and-busted.c: (ENTRIES_ATTR_WORKING_SIZE, ENTRIES_ATTR_TEXT_TIME): moved here from entries.h, and renamed (svn_wc__atts_to_entry): remove special values from the text time and working size attributes. and these no longer need to set MODIFY_FLAGS. * subversion/libsvn_wc/wc.h: (SVN_WC__TIMESTAMP_WC, SVN_WC__WORKING_SIZE_WC): these special values are no longer used. Modified: subversion/trunk/subversion/libsvn_wc/entries.h subversion/trunk/subversion/libsvn_wc/log.c subversion/trunk/subversion/libsvn_wc/log.h subversion/trunk/subversion/libsvn_wc/old-and-busted.c subversion/trunk/subversion/libsvn_wc/update_editor.c subversion/trunk/subversion/libsvn_wc/wc.h subversion/trunk/subversion/libsvn_wc/workqueue.c subversion/trunk/subversion/libsvn_wc/workqueue.h Modified: subversion/trunk/subversion/libsvn_wc/entries.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/entries.h?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/entries.h (original) +++ subversion/trunk/subversion/libsvn_wc/entries.h Mon May 10 21:18:06 2010 @@ -44,12 +44,10 @@ extern "C" { and for error reporting when reading a non-XML entries file. ### If you add or remove items here, you probably want to make sure to do the same for the SVN_WC__ENTRY_MODIFY_* #defines as well. */ -#define SVN_WC__ENTRY_ATTR_TEXT_TIME "text-time" #define SVN_WC__ENTRY_ATTR_CONFLICT_OLD "conflict-old" /* saved old file */ #define SVN_WC__ENTRY_ATTR_CONFLICT_NEW "conflict-new" /* saved new file */ #define SVN_WC__ENTRY_ATTR_CONFLICT_WRK "conflict-wrk" /* saved wrk file */ #define SVN_WC__ENTRY_ATTR_PREJFILE "prop-reject-file" -#define SVN_WC__ENTRY_ATTR_WORKING_SIZE "working-size" /* Set *NEW_ENTRY to a new entry, taking attributes from ATTS, whose Modified: subversion/trunk/subversion/libsvn_wc/log.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/log.c?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/log.c (original) +++ subversion/trunk/subversion/libsvn_wc/log.c Mon May 10 21:18:06 2010 @@ -253,80 +253,22 @@ log_do_modify_entry(struct log_runner *l const char *name, const char **atts) { - svn_error_t *err; apr_hash_t *ah = svn_xml_make_att_hash(atts, loggy->pool); const char *local_abspath; svn_wc_entry_t *entry; int modify_flags; - const char *valuestr; local_abspath = svn_dirent_join(loggy->adm_abspath, name, loggy->pool); /* Convert the attributes into an entry structure. */ SVN_ERR(svn_wc__atts_to_entry(&entry, &modify_flags, ah, loggy->pool)); - /* svn_wc__atts_to_entry will no-op if the TEXT_TIME timestamp is - SVN_WC__TIMESTAMP_WC, so look for that case and fill in the proper - value. */ - valuestr = apr_hash_get(ah, SVN_WC__ENTRY_ATTR_TEXT_TIME, - APR_HASH_KEY_STRING); - if ((modify_flags & SVN_WC__ENTRY_MODIFY_TEXT_TIME) - && (! strcmp(valuestr, SVN_WC__TIMESTAMP_WC))) - { - apr_time_t text_time; - - err = svn_io_file_affected_time(&text_time, local_abspath, loggy->pool); - if (err) - return svn_error_createf - (SVN_ERR_WC_BAD_ADM_LOG, err, - _("Error getting 'affected time' on '%s'"), - svn_dirent_local_style(local_abspath, loggy->pool)); - - entry->text_time = text_time; - } - - valuestr = apr_hash_get(ah, SVN_WC__ENTRY_ATTR_WORKING_SIZE, - APR_HASH_KEY_STRING); - if ((modify_flags & SVN_WC__ENTRY_MODIFY_WORKING_SIZE) - && (! strcmp(valuestr, SVN_WC__WORKING_SIZE_WC))) - { - apr_finfo_t finfo; - const svn_wc_entry_t *tfile_entry; - - err = svn_wc__get_entry(&tfile_entry, loggy->db, local_abspath, TRUE, - svn_node_file, FALSE, - loggy->pool, loggy->pool); - if (err) - SIGNAL_ERROR(loggy, err); - - if (! tfile_entry) - return SVN_NO_ERROR; - - err = svn_io_stat(&finfo, local_abspath, APR_FINFO_MIN | APR_FINFO_LINK, - loggy->pool); - if (err && APR_STATUS_IS_ENOENT(err->apr_err)) - { - svn_error_clear(err); - finfo.size = 0; - } - else if (err) - return svn_error_createf - (SVN_ERR_WC_BAD_ADM_LOG, NULL, - _("Error getting file size on '%s'"), - svn_dirent_local_style(local_abspath, loggy->pool)); - - entry->working_size = finfo.size; - } - /* ### this function never needs to modify a parent stub. ### NOTE: this call to entry_modify MAY create a new node. */ - err = svn_wc__entry_modify(loggy->db, local_abspath, svn_node_unknown, - entry, modify_flags, loggy->pool); - if (err) - return svn_error_createf(SVN_ERR_WC_BAD_ADM_LOG, err, - _("Error modifying entry for '%s'"), name); - - return SVN_NO_ERROR; + return svn_error_return(svn_wc__entry_modify(loggy->db, local_abspath, + svn_node_unknown, + entry, modify_flags, + loggy->pool)); } /* */ @@ -866,63 +808,6 @@ svn_wc__loggy_move(svn_skel_t **work_ite svn_error_t * -svn_wc__loggy_set_entry_timestamp_from_wc(svn_skel_t **work_item, - svn_wc__db_t *db, - const char *adm_abspath, - const char *local_abspath, - apr_pool_t *result_pool) -{ - svn_stringbuf_t *log_accum = NULL; - const char *loggy_path1; - - SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); - - SVN_ERR(loggy_path(&loggy_path1, local_abspath, adm_abspath, result_pool)); - svn_xml_make_open_tag(&log_accum, - result_pool, - svn_xml_self_closing, - SVN_WC__LOG_MODIFY_ENTRY, - SVN_WC__LOG_ATTR_NAME, - loggy_path1, - SVN_WC__ENTRY_ATTR_TEXT_TIME, - SVN_WC__TIMESTAMP_WC, - NULL); - - return svn_error_return(svn_wc__wq_build_loggy(work_item, - db, adm_abspath, log_accum, - result_pool)); -} - -svn_error_t * -svn_wc__loggy_set_entry_working_size_from_wc(svn_skel_t **work_item, - svn_wc__db_t *db, - const char *adm_abspath, - const char *local_abspath, - apr_pool_t *result_pool) -{ - svn_stringbuf_t *log_accum = NULL; - const char *loggy_path1; - - SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); - - SVN_ERR(loggy_path(&loggy_path1, local_abspath, adm_abspath, result_pool)); - svn_xml_make_open_tag(&log_accum, - result_pool, - svn_xml_self_closing, - SVN_WC__LOG_MODIFY_ENTRY, - SVN_WC__LOG_ATTR_NAME, - loggy_path1, - SVN_WC__ENTRY_ATTR_WORKING_SIZE, - SVN_WC__WORKING_SIZE_WC, - NULL); - - return svn_error_return(svn_wc__wq_build_loggy(work_item, - db, adm_abspath, log_accum, - result_pool)); -} - - -svn_error_t * svn_wc__loggy_set_timestamp(svn_skel_t **work_item, svn_wc__db_t *db, const char *adm_abspath, Modified: subversion/trunk/subversion/libsvn_wc/log.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/log.h?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/log.h (original) +++ subversion/trunk/subversion/libsvn_wc/log.h Mon May 10 21:18:06 2010 @@ -130,27 +130,6 @@ svn_wc__loggy_move(svn_skel_t **work_ite apr_pool_t *result_pool); -svn_error_t * -svn_wc__loggy_set_entry_timestamp_from_wc(svn_skel_t **work_item, - svn_wc__db_t *db, - const char *adm_abspath, - const char *local_abspath, - apr_pool_t *result_pool); - - -/* Queue log instructions to set the file size of PATH - in the entries' WORKING_SIZE field. - - ADM_ABSPATH is the absolute path for the admin directory for PATH. -*/ -svn_error_t * -svn_wc__loggy_set_entry_working_size_from_wc(svn_skel_t **work_item, - svn_wc__db_t *db, - const char *adm_abspath, - const char *local_abspath, - apr_pool_t *result_pool); - - /* Queue instructions to set the timestamp of PATH to the time TIMESTR. Modified: subversion/trunk/subversion/libsvn_wc/old-and-busted.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/old-and-busted.c?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/old-and-busted.c (original) +++ subversion/trunk/subversion/libsvn_wc/old-and-busted.c Mon May 10 21:18:06 2010 @@ -73,6 +73,8 @@ #define ENTRIES_ATTR_COPYFROM_URL "copyfrom-url" #define ENTRIES_ATTR_COPYFROM_REV "copyfrom-rev" #define ENTRIES_ATTR_CHECKSUM "checksum" +#define ENTRIES_ATTR_WORKING_SIZE "working-size" +#define ENTRIES_ATTR_TEXT_TIME "text-time" /* Attribute values used in our old XML entries file. */ #define ENTRIES_VALUE_FILE "file" @@ -924,26 +926,14 @@ svn_wc__atts_to_entry(svn_wc_entry_t **n name)); /* Attempt to set up timestamps. */ + /* ### not used by loggy; no need to set MODIFY_FLAGS */ { const char *text_timestr; - text_timestr = apr_hash_get(atts, SVN_WC__ENTRY_ATTR_TEXT_TIME, + text_timestr = apr_hash_get(atts, ENTRIES_ATTR_TEXT_TIME, APR_HASH_KEY_STRING); if (text_timestr) - { - if (strcmp(text_timestr, SVN_WC__TIMESTAMP_WC) == 0) - { - /* Special case: a magic string that means 'get this value - from the working copy' -- we ignore it here, trusting - that the caller of this function know what to do about - it. */ - } - else - SVN_ERR(svn_time_from_cstring(&entry->text_time, text_timestr, - pool)); - - *modify_flags |= SVN_WC__ENTRY_MODIFY_TEXT_TIME; - } + SVN_ERR(svn_time_from_cstring(&entry->text_time, text_timestr, pool)); /* Note: we do not persist prop_time, so there is no need to attempt to parse a new prop_time value from the log. Certainly, on any @@ -1004,23 +994,14 @@ svn_wc__atts_to_entry(svn_wc_entry_t **n going to ignore them. */ /* Translated size */ + /* ### not used by loggy; no need to set MODIFY_FLAGS */ { - const char *val - = apr_hash_get(atts, - SVN_WC__ENTRY_ATTR_WORKING_SIZE, - APR_HASH_KEY_STRING); + const char *val = apr_hash_get(atts, ENTRIES_ATTR_WORKING_SIZE, + APR_HASH_KEY_STRING); if (val) { - if (strcmp(val, SVN_WC__WORKING_SIZE_WC) == 0) - { - /* Special case (same as the timestamps); ignore here - these will be handled elsewhere */ - } - else - /* Cast to off_t; it's safe: we put in an off_t to start with... */ - entry->working_size = (apr_off_t)apr_strtoi64(val, NULL, 0); - - *modify_flags |= SVN_WC__ENTRY_MODIFY_WORKING_SIZE; + /* Cast to off_t; it's safe: we put in an off_t to start with... */ + entry->working_size = (apr_off_t)apr_strtoi64(val, NULL, 0); } } Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original) +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon May 10 21:18:06 2010 @@ -4683,8 +4683,9 @@ merge_file(svn_skel_t **work_items, } #endif - /* Log commands to handle text-timestamp and working-size, - if the file is - or will be - unmodified and schedule-normal */ + /* Installing from a pristine will handle timestamps and recording. + However, if we are NOT creating a new working copy file, then create + work items to handle text-timestamp and working-size. */ if (!*install_pristine && !is_locally_modified && (fb->adding_file || entry->schedule == svn_wc_schedule_normal)) @@ -4700,19 +4701,11 @@ merge_file(svn_skel_t **work_items, *work_items = svn_wc__wq_merge(*work_items, work_item, pool); } - if ((new_text_base_tmp_abspath || magic_props_changed) - && !fb->deleted) - { - /* Adjust entries file to match working file */ - SVN_ERR(svn_wc__loggy_set_entry_timestamp_from_wc( - &work_item, eb->db, pb->local_abspath, - fb->local_abspath, pool)); - *work_items = svn_wc__wq_merge(*work_items, work_item, pool); - } - - SVN_ERR(svn_wc__loggy_set_entry_working_size_from_wc( - &work_item, eb->db, pb->local_abspath, - fb->local_abspath, pool)); + /* ### what if the file is locally-deleted? or if there is an + ### obstruction. OP_RECORD_FILEINFO will deal with a missing + ### file, but what if this is NOT our file? (ie. obstruction) */ + SVN_ERR(svn_wc__wq_build_record_fileinfo(eb->db, fb->local_abspath, + pool)); *work_items = svn_wc__wq_merge(*work_items, work_item, pool); } Modified: subversion/trunk/subversion/libsvn_wc/wc.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc.h?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/wc.h (original) +++ subversion/trunk/subversion/libsvn_wc/wc.h Mon May 10 21:18:06 2010 @@ -61,7 +61,7 @@ extern "C" { * For example, ".svn/props/foo" became ".svn/props/foo.svn-work". * * The change from 2 to 3 was the introduction of the entry attribute - * SVN_WC__ENTRY_ATTR_ABSENT. + * old-and-busted.c::ENTRIES_ATTR_ABSENT. * * The change from 3 to 4 was the renaming of the magic "svn:this_dir" * entry name to "". @@ -266,29 +266,6 @@ struct svn_wc_traversal_info_t }; - -/*** Timestamps. ***/ - -/* A special timestamp value which means "use the timestamp from the - working copy". This is sometimes used in a log entry like: - - <modify-entry name="foo.c" revision="5" timestamp="working"/> - */ -#define SVN_WC__TIMESTAMP_WC "working" - - - -/*** Filesizes. ***/ - -/* A special filesize value which means "use the filesize from the - working copy". This is sometimes used in a log entry like: - - <modify-entry name="foo.c" revision="5" working-size="working"/> - */ -#define SVN_WC__WORKING_SIZE_WC "working" - - - /*** Names and file/dir operations in the administrative area. ***/ /** The files within the administrative subdir. **/ Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/workqueue.c (original) +++ subversion/trunk/subversion/libsvn_wc/workqueue.c Mon May 10 21:18:06 2010 @@ -64,6 +64,7 @@ #define OP_SYNC_FILE_FLAGS "sync-file-flags" #define OP_PREJ_INSTALL "prej-install" #define OP_WRITE_OLD_PROPS "write-old-props" +#define OP_RECORD_FILEINFO "record-fileinfo" /* For work queue debugging. Generates output about its operation. */ @@ -111,6 +112,39 @@ sync_file_flags(svn_wc__db_t *db, } +static svn_error_t * +get_and_record_fileinfo(svn_wc__db_t *db, + const char *local_abspath, + svn_boolean_t ignore_enoent, + apr_pool_t *scratch_pool) +{ + apr_time_t last_mod_time; + apr_finfo_t finfo; + svn_error_t *err; + + err = svn_io_file_affected_time(&last_mod_time, local_abspath, + scratch_pool); + if (err) + { + if (!ignore_enoent || !APR_STATUS_IS_ENOENT(err->apr_err)) + return svn_error_return(err); + + /* No biggy. Just skip all this. */ + svn_error_clear(err); + return SVN_NO_ERROR; + } + + SVN_ERR(svn_io_stat(&finfo, local_abspath, + APR_FINFO_MIN | APR_FINFO_LINK, + scratch_pool)); + + return svn_error_return(svn_wc__db_global_record_fileinfo( + db, local_abspath, + finfo.size, last_mod_time, + scratch_pool)); +} + + /* If SOURCE_ABSPATH is present, then move it to DEST_ABSPATH. Ignore any ENOENT message for a missing source, which may indicate the move has already been performed. */ @@ -1910,22 +1944,9 @@ run_file_install(svn_wc__db_t *db, /* ### this should happen before we rename the file into place. */ if (record_fileinfo) { - apr_time_t last_mod_time; - apr_finfo_t finfo; - - /* loggy_set_entry_timestamp_from_wc() */ - SVN_ERR(svn_io_file_affected_time(&last_mod_time, - local_abspath, - scratch_pool)); - - /* loggy_set_entry_working_size_from_wc() */ - SVN_ERR(svn_io_stat(&finfo, local_abspath, - APR_FINFO_MIN | APR_FINFO_LINK, - scratch_pool)); - - SVN_ERR(svn_wc__db_global_record_fileinfo(db, local_abspath, - finfo.size, last_mod_time, - scratch_pool)); + SVN_ERR(get_and_record_fileinfo(db, local_abspath, + FALSE /* ignore_enoent */, + scratch_pool)); /* ### there used to be a call to entry_modify() above, to set the ### TRANSLATED_SIZE and LAST_MOD_TIME values. that function elided @@ -2120,6 +2141,7 @@ svn_wc__wq_build_prej_install(svn_skel_t /* OP_WRITE_OLD_PROPS */ + static svn_error_t * run_write_old_props(svn_wc__db_t *db, const svn_skel_t *work_item, @@ -2191,6 +2213,46 @@ svn_wc__wq_build_write_old_props(svn_ske /* ------------------------------------------------------------------------ */ +/* OP_RECORD_FILEINFO */ + + +static svn_error_t * +run_record_fileinfo(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 *local_abspath; + + local_abspath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len); + + return svn_error_return(get_and_record_fileinfo(db, local_abspath, + TRUE /* ignore_enoent */, + scratch_pool)); +} + + +svn_error_t * +svn_wc__wq_build_record_fileinfo(svn_skel_t **work_item, + const char *local_abspath, + apr_pool_t *result_pool) +{ + *work_item = svn_skel__make_empty_list(result_pool); + + SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); + + svn_skel__prepend_str(apr_pstrdup(result_pool, local_abspath), + *work_item, result_pool); + svn_skel__prepend_str(OP_RECORD_FILEINFO, *work_item, result_pool); + + return SVN_NO_ERROR; +} + + +/* ------------------------------------------------------------------------ */ + static const struct work_item_dispatch dispatch_table[] = { { OP_REVERT, run_revert }, { OP_PREPARE_REVERT_FILES, run_prepare_revert_files }, @@ -2205,6 +2267,7 @@ static const struct work_item_dispatch d { OP_SYNC_FILE_FLAGS, run_sync_file_flags }, { OP_PREJ_INSTALL, run_prej_install }, { OP_WRITE_OLD_PROPS, run_write_old_props }, + { OP_RECORD_FILEINFO, run_record_fileinfo }, /* Sentinel. */ { NULL } Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=942906&r1=942905&r2=942906&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/workqueue.h (original) +++ subversion/trunk/subversion/libsvn_wc/workqueue.h Mon May 10 21:18:06 2010 @@ -158,6 +158,17 @@ svn_wc__wq_build_write_old_props(svn_ske apr_pool_t *result_pool); +/* Build a work item that will record file information of LOCAL_ABSPATH + into the TRANSLATED_SIZE and LAST_MOD_TIME of the node via the + svn_wc__db_global_record_fileinfo() function. + + ### it is unclear whether this should survive. */ +svn_error_t * +svn_wc__wq_build_record_fileinfo(svn_skel_t **work_item, + const char *local_abspath, + 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,