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/04/10 13:48:21 UTC

svn commit: r932700 - in /subversion/trunk/subversion/libsvn_wc: merge.c update_editor.c wc.h

Author: gstein
Date: Sat Apr 10 11:48:20 2010
New Revision: 932700

URL: http://svn.apache.org/viewvc?rev=932700&view=rev
Log:
Remove a bunch of log accumulator management that was being performed
around close_file, in order to ensure that we didn't have a partial state
change when somebody aborted an interactive conflict resolve during the
update process. This is no longer needed, since we're making the state
changes (more) atomically now.

* subversion/libsvn_wc/update_editor.c:
  (merge_file): remove the LOG_ACCUM param, since we no longer have
    delayed/incoming changes to queue up (nor any to return). all queuing
    can happen internally. remove verious assertions/flush calls around
    the obsolete accumulator. and we no longer need to pass this into
    svn_wc__internal_merge since it is empty, and the merge was defined to
    never return operations (thus, it can do everything internally).
    create a tightly-scoped accumulator for some of the file timestamp and
    size tweaking bits, and directly queue the operations.
  (close_file): remove DELAYED_LOG_ACCUM since we no longer put anything
    into it beyond what was happening in merge_file, and that function can
    just do its own queuing.

* subversion/libsvn_wc/merge.c:
  (svn_wc__internal_merge): remove the LOG_ACCUM parameter. it no longer
    arrives with operations, and we defined it to never return any. thus,
    all ops are queued internally. simiarly, remove LOG_ACCUM from the
    merge_binary_file and merge_text_file calls, and let them queue any
    operations internally.
  (merge_text_file): remove LOG_ACCUM param in favor of internal queuing.
    the only use was maybe_resolve_conflicts, so we remove its LOG_ACCUM
    param and let it internally-queue. remove the assert/flush around the
    now-obsolete LOG_ACCUM param.
  (maybe_resolve_conflicts): remove the LOG_ACCUM parameter and all of the
    flushing calls. operations are no longer held pending the result of
    the CONFLICT_FUNC invocation.
  (merge_binary_file): remove the LOG_ACCUM param in favor of internal
    queueing. there are no incoming ops (no param!), so remove the flush
    calls. for one accum operation, use a tightly-scoped accumulator to
    record the work item and immediately queue it up.

* subversion/libsvn_wc/wc.h:
  (svn_wc__internal_merge): adjust params

Modified:
    subversion/trunk/subversion/libsvn_wc/merge.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/libsvn_wc/wc.h

Modified: subversion/trunk/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/merge.c?rev=932700&r1=932699&r2=932700&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Sat Apr 10 11:48:20 2010
@@ -392,7 +392,7 @@ do_text_merge_external(svn_boolean_t *co
  * resolution to the file RESULT_TARGET. The merge result is expected
  * in the same directory as TARGET_ABSPATH the same basename as
  * TARGET_ABSPATH, but followed by ".edited".
- * Use LOG_ACCUM as log accumulator.  DB contains an access baton with
+ * DB contains an access baton with
  * a write lock for the directory containing RESULT_TARGET.
  * Do all allocations in POOL.
  */
@@ -739,8 +739,7 @@ setup_text_conflict_desc(const char *lef
 
 /* XXX Insane amount of parameters... */
 static svn_error_t*
-maybe_resolve_conflicts(svn_stringbuf_t **log_accum,
-                        svn_wc__db_t *db,
+maybe_resolve_conflicts(svn_wc__db_t *db,
                         const char *left_abspath,
                         const char *right_abspath,
                         const char *target_abspath,
@@ -770,11 +769,6 @@ maybe_resolve_conflicts(svn_stringbuf_t 
      up the conflicts before we mark the file 'conflicted' */
   if (!conflict_func)
     {
-      /* Since we're not calling the interactive conflict resolve,
-         (and thus subject to exit within an interim/bogus database
-         state), let's flush out all the work items passed to us.  */
-      SVN_WC__FLUSH_LOG_ACCUM(db, dir_abspath, *log_accum, pool);
-
       /* If there is no interactive conflict resolution then we are effectively
          postponing conflict resolution. */
       result = svn_wc_create_conflict_result(svn_wc_conflict_choose_postpone,
@@ -801,11 +795,6 @@ maybe_resolve_conflicts(svn_stringbuf_t 
                                 NULL, _("Conflict callback violated API:"
                                         " returned no results"));
 
-      /* Now that we're back from the interactive resolver function,
-         we should flush all the work that has been accumulated so far.
-         All work from here, onwards, will be flushed immediately.  */
-      SVN_WC__FLUSH_LOG_ACCUM(db, dir_abspath, *log_accum, pool);
-
       if (result->save_merged)
         SVN_ERR(save_merge_result(db,
                                   target_abspath,
@@ -817,10 +806,6 @@ maybe_resolve_conflicts(svn_stringbuf_t 
                                   pool));
     }
 
-  /* The above logic should have flushed everything: what was given
-     to us, and anything that we may need to accomplish.  */
-  SVN_ERR_ASSERT(*log_accum == NULL || svn_stringbuf_isempty(*log_accum));
-
   SVN_ERR(eval_conflict_func_result(merge_outcome,
                                     result,
                                     db,
@@ -856,8 +841,7 @@ maybe_resolve_conflicts(svn_stringbuf_t 
 
 /* XXX Insane amount of parameters... */
 static svn_error_t*
-merge_text_file(svn_stringbuf_t **log_accum,
-                enum svn_wc_merge_outcome_t *merge_outcome,
+merge_text_file(enum svn_wc_merge_outcome_t *merge_outcome,
                 svn_wc__db_t *db,
                 const char *left_abspath,
                 const char *right_abspath,
@@ -933,8 +917,7 @@ merge_text_file(svn_stringbuf_t **log_ac
 
   if (contains_conflicts && ! dry_run)
     {
-      SVN_ERR(maybe_resolve_conflicts(log_accum,
-                                      db,
+      SVN_ERR(maybe_resolve_conflicts(db,
                                       left_abspath,
                                       right_abspath,
                                       target_abspath,
@@ -953,10 +936,6 @@ merge_text_file(svn_stringbuf_t **log_ac
                                       cancel_func, cancel_baton,
                                       pool));
 
-      /* The above function should have flushed everything: what was given
-         to us, and anything that we may need to accomplish.  */
-      SVN_ERR_ASSERT(*log_accum == NULL || svn_stringbuf_isempty(*log_accum));
-
       if (*merge_outcome == svn_wc_merge_merged)
         return SVN_NO_ERROR;
     }
@@ -982,11 +961,6 @@ merge_text_file(svn_stringbuf_t **log_ac
       *merge_outcome = same ? svn_wc_merge_unchanged : svn_wc_merge_merged;
     }
 
-  /* If we don't call maybe_resolve_conflicts(), there MAY be work items
-     in the accumulator, provided by our caller, to flush out to the queue.
-     Do that now.  */
-  SVN_WC__FLUSH_LOG_ACCUM(db, dir_abspath, *log_accum, pool);
-
   if (*merge_outcome != svn_wc_merge_unchanged && ! dry_run)
     {
       const svn_skel_t *work_item;
@@ -1007,8 +981,7 @@ merge_text_file(svn_stringbuf_t **log_ac
 
 /* XXX Insane amount of parameters... */
 static svn_error_t *
-merge_binary_file(svn_stringbuf_t **log_accum,
-                  enum svn_wc_merge_outcome_t *merge_outcome,
+merge_binary_file(enum svn_wc_merge_outcome_t *merge_outcome,
                   svn_wc__db_t *db,
                   const char *left_abspath,
                   const char *right_abspath,
@@ -1058,11 +1031,6 @@ merge_binary_file(svn_stringbuf_t **log_
                                 NULL, _("Conflict callback violated API:"
                                         " returned no results"));
 
-      /* Now that we're back from the interactive resolver function,
-         we should flush all the work that has been accumulated so far.
-         All work from here, onwards, will be flushed immediately.  */
-      SVN_WC__FLUSH_LOG_ACCUM(db, merge_dirpath, *log_accum, pool);
-
       switch (result->choice)
         {
           /* For a binary file, there's no merged file to look at,
@@ -1130,11 +1098,6 @@ merge_binary_file(svn_stringbuf_t **log_
         }
     }
 
-  /* If we don't call the conflict resolver, there MAY be work items
-     in the accumulator, provided by our caller, to flush out to the queue.
-     Do that now.  */
-  SVN_WC__FLUSH_LOG_ACCUM(db, merge_dirpath, *log_accum, pool);
-
   /* reserve names for backups of left and right fulltexts */
   SVN_ERR(svn_io_open_uniquely_named(NULL,
                                      &left_copy,
@@ -1161,6 +1124,7 @@ merge_binary_file(svn_stringbuf_t **log_
     {
       /* Create a .mine file too */
       const char *mine_copy;
+      svn_stringbuf_t *log_accum = NULL;
 
       SVN_ERR(svn_io_open_uniquely_named(NULL,
                                          &mine_copy,
@@ -1169,12 +1133,13 @@ merge_binary_file(svn_stringbuf_t **log_
                                          target_label,
                                          svn_io_file_del_none,
                                          pool, pool));
-      SVN_ERR(svn_wc__loggy_move(log_accum,
+      SVN_ERR(svn_wc__loggy_move(&log_accum,
                                  merge_dirpath,
                                  detranslated_target_abspath,
                                  mine_copy,
                                  pool, pool));
-      SVN_WC__FLUSH_LOG_ACCUM(db, merge_dirpath, *log_accum, pool);
+      SVN_ERR(svn_wc__wq_add_loggy(db, merge_dirpath, log_accum, pool));
+
       mine_copy = svn_dirent_is_child(merge_dirpath,
                                       mine_copy, pool);
       tmp_entry.conflict_wrk = mine_copy;
@@ -1205,8 +1170,7 @@ merge_binary_file(svn_stringbuf_t **log_
 
 /* XXX Insane amount of parameters... */
 svn_error_t *
-svn_wc__internal_merge(svn_stringbuf_t **log_accum,
-                       enum svn_wc_merge_outcome_t *merge_outcome,
+svn_wc__internal_merge(enum svn_wc_merge_outcome_t *merge_outcome,
                        svn_wc__db_t *db,
                        const char *left_abspath,
                        const svn_wc_conflict_version_t *left_version,
@@ -1289,8 +1253,7 @@ svn_wc__internal_merge(svn_stringbuf_t *
         /* in dry-run mode, binary files always conflict */
         *merge_outcome = svn_wc_merge_conflict;
       else
-        SVN_ERR(merge_binary_file(log_accum,
-                                  merge_outcome,
+        SVN_ERR(merge_binary_file(merge_outcome,
                                   db,
                                   left_abspath,
                                   right_abspath,
@@ -1309,8 +1272,7 @@ svn_wc__internal_merge(svn_stringbuf_t *
                                   pool));
     }
   else
-    SVN_ERR(merge_text_file(log_accum,
-                            merge_outcome,
+    SVN_ERR(merge_text_file(merge_outcome,
                             db,
                             left_abspath,
                             right_abspath,
@@ -1332,11 +1294,6 @@ svn_wc__internal_merge(svn_stringbuf_t *
                             cancel_baton,
                             pool));
 
-  /* The above code should have flushed all work to the queue. This will
-     include prior work given to us, and anything else that we may need
-     to queue ourselves.  */
-  SVN_ERR_ASSERT(*log_accum == NULL || svn_stringbuf_isempty(*log_accum));
-
   /* Merging is complete.  Regardless of text or binariness, we might
      need to tweak the executable bit on the new working file, and
      possibly make it read-only. */
@@ -1375,7 +1332,6 @@ svn_wc_merge4(enum svn_wc_merge_outcome_
               void *cancel_baton,
               apr_pool_t *scratch_pool)
 {
-  svn_stringbuf_t *log_accum = NULL;
   const char *dir_abspath = svn_dirent_dirname(target_abspath, scratch_pool);
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(left_abspath));
@@ -1387,7 +1343,7 @@ svn_wc_merge4(enum svn_wc_merge_outcome_
     SVN_ERR(svn_wc__write_check(wc_ctx->db, dir_abspath, scratch_pool));
 
   /* Queue all the work.  */
-  SVN_ERR(svn_wc__internal_merge(&log_accum, merge_outcome,
+  SVN_ERR(svn_wc__internal_merge(merge_outcome,
                                  wc_ctx->db,
                                  left_abspath, left_version,
                                  right_abspath, right_version,
@@ -1402,9 +1358,6 @@ svn_wc_merge4(enum svn_wc_merge_outcome_
                                  cancel_func, cancel_baton,
                                  scratch_pool));
 
-  /* svn_wc__internal_merge() should have queued all of its work.  */
-  SVN_ERR_ASSERT(log_accum == NULL || svn_stringbuf_isempty(log_accum));
-
   /* If this isn't a dry run, then run the work!  */
   if (!dry_run)
     SVN_ERR(svn_wc__wq_run(wc_ctx->db, target_abspath,

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=932700&r1=932699&r2=932700&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Sat Apr 10 11:48:20 2010
@@ -4192,8 +4192,7 @@ install_text_base(svn_wc__db_t *db,
  * POOL is used for all bookkeeping work during the installation.
  */
 static svn_error_t *
-merge_file(svn_stringbuf_t **log_accum,
-           svn_boolean_t *install_pristine,
+merge_file(svn_boolean_t *install_pristine,
            const char **install_from,
            svn_wc_notify_state_t *content_state,
            const svn_wc_entry_t *entry,
@@ -4228,11 +4227,6 @@ merge_file(svn_stringbuf_t **log_accum,
      modifications.
   */
 
-#if 0
-  /* ### this will break update_tests 43. see comment in close_file()  */
-  SVN_WC__FLUSH_LOG_ACCUM(eb->db, pb->local_abspath, *log_accum, pool);
-#endif
-
   *install_pristine = FALSE;
   *install_from = NULL;
 
@@ -4451,7 +4445,7 @@ merge_file(svn_stringbuf_t **log_accum,
                  ###   in the future, all the state changes should be
                  ###   made atomically.  */
               SVN_ERR(svn_wc__internal_merge(
-                        log_accum, &merge_outcome,
+                        &merge_outcome,
                         eb->db,
                         merge_left, NULL,
                         new_text_base_tmp_abspath, NULL,
@@ -4464,12 +4458,6 @@ merge_file(svn_stringbuf_t **log_accum,
                         eb->cancel_func, eb->cancel_baton,
                         pool));
 
-              /* svn_wc__internal_merge() should have queued all of
-                 its work (including a bunch of stuff that we pre-loaded
-                 into the log accumulator).  */
-              SVN_ERR_ASSERT(*log_accum == NULL
-                             || svn_stringbuf_isempty(*log_accum));
-
               /* If we created a temporary left merge file, get rid of it. */
               if (delete_left)
                 {
@@ -4531,9 +4519,6 @@ merge_file(svn_stringbuf_t **log_accum,
         }
     }
 
-  /* Flush anything that may be residing here.  */
-  SVN_WC__FLUSH_LOG_ACCUM(eb->db, pb->local_abspath, *log_accum, pool);
-
   /* Deal with installation of the new textbase, if appropriate. */
   if (new_text_base_tmp_abspath)
     {
@@ -4565,11 +4550,13 @@ merge_file(svn_stringbuf_t **log_accum,
       && !is_locally_modified
       && (fb->adding_file || entry->schedule == svn_wc_schedule_normal))
     {
+      svn_stringbuf_t *log_accum = NULL;
+
       /* Adjust working copy file unless this file is an allowed
          obstruction. */
       if (fb->last_changed_date && !fb->obstruction_found)
         SVN_ERR(svn_wc__loggy_set_timestamp(
-                  log_accum, pb->local_abspath,
+                  &log_accum, pb->local_abspath,
                   fb->local_abspath, fb->last_changed_date,
                   pool, pool));
 
@@ -4578,14 +4565,15 @@ merge_file(svn_stringbuf_t **log_accum,
         {
           /* Adjust entries file to match working file */
           SVN_ERR(svn_wc__loggy_set_entry_timestamp_from_wc(
-                    log_accum, pb->local_abspath,
+                    &log_accum, pb->local_abspath,
                     fb->local_abspath, pool, pool));
         }
       SVN_ERR(svn_wc__loggy_set_entry_working_size_from_wc(
-                log_accum, pb->local_abspath,
+                &log_accum, pb->local_abspath,
                 fb->local_abspath, pool, pool));
 
-      SVN_WC__FLUSH_LOG_ACCUM(eb->db, pb->local_abspath, *log_accum, pool);
+      SVN_ERR(svn_wc__wq_add_loggy(eb->db, pb->local_abspath, log_accum,
+                                   pool));
     }
 
   /* Set the returned content state. */
@@ -4631,7 +4619,6 @@ close_file(void *file_baton,
   const char *new_text_base_abspath;
   apr_hash_t *new_base_props = NULL;
   apr_hash_t *new_actual_props = NULL;
-  svn_stringbuf_t *delayed_log_accum = svn_stringbuf_create("", pool);
   apr_array_header_t *entry_props;
   apr_array_header_t *wc_props;
   apr_array_header_t *regular_props;
@@ -4767,17 +4754,6 @@ close_file(void *file_baton,
                                   TRUE /* force_base_install */,
                                   pool));
 
-#if 0
-  /* ### this breaks update_tests 43. it does a *partial* edit of the
-     ### state. if the user cancels a merge resolution (e.g EOF), then
-     ### the working copy ends up horked.  */
-
-  /* Now that the installation of the props has been queued, flush out
-     anything from the delayed accumulator.  */
-  SVN_WC__FLUSH_LOG_ACCUM(eb->db, fb->dir_baton->local_abspath,
-                          delayed_log_accum, pool);
-#endif
-
   /* This writes a whole bunch of log commands to install wcprops.  */
   /* ### no it doesn't. this immediately modifies them. should probably
      ### occur later, when we know the (new) BASE node exists.  */
@@ -4786,15 +4762,11 @@ close_file(void *file_baton,
                                         pool));
 
   /* Do the hard work. This will queue some additional work.  */
-  SVN_ERR(merge_file(&delayed_log_accum, &install_pristine, &install_from,
+  SVN_ERR(merge_file(&install_pristine, &install_from,
                      &content_state, entry,
                      fb, new_text_base_abspath, new_text_base_md5_checksum,
                      new_text_base_sha1_checksum, pool));
 
-  /* Queue all operations.  */
-  SVN_WC__FLUSH_LOG_ACCUM(eb->db, fb->dir_baton->local_abspath,
-                          delayed_log_accum, pool);
-
   /* Insert/replace the BASE node with all of the new metadata.  */
   {
     const svn_checksum_t *new_checksum = new_text_base_md5_checksum;

Modified: subversion/trunk/subversion/libsvn_wc/wc.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc.h?rev=932700&r1=932699&r2=932700&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc.h Sat Apr 10 11:48:20 2010
@@ -421,8 +421,7 @@ svn_wc__internal_text_modified_p(svn_boo
    the (loggy) implementation.
 */
 svn_error_t *
-svn_wc__internal_merge(svn_stringbuf_t **log_accum,
-                       enum svn_wc_merge_outcome_t *merge_outcome,
+svn_wc__internal_merge(enum svn_wc_merge_outcome_t *merge_outcome,
                        svn_wc__db_t *db,
                        const char *left_abspath,
                        const svn_wc_conflict_version_t *left_version,