On Tue, 2010-06-29, Neels J Hofmeyr wrote:
> Hi Julian,
> 
> I heard you were changing things about update editor's add_file() copyfrom
> args. The thing is I have taken the liberty to look at add-vs-add tree
> conflicts and have a pretty nice improvement on that aalmost ready.
> 
> Now I fear that our patches will clash and am curious. Can I see your patch?
> here is mine (there's still some amount of clutter around in it, don't be
> distracted by it -- update_editor.c is the point).
> 
> Because the patch is quite unintelligible I've also attached my current
> update_editor.c.

Hi Neels.  Here is my patch.  It's quite simple.  I'll have a look at
yours and comment if necessary, but right now I'll say please just go
ahead with yours and I'll fit in around it.

- Julian

Fix the three remaining SVN_EXPERIMENTAL_PRISTINE test failures.  When the
update editor adds a file "with history", it was not properly keeping track
of the path to the temporary file holding the copied text.  To solve this,
store the new text into the pristine store at an earlier stage.

### This patch in its current state causes three more failures:
  FAIL: externals_tests.py 1: test checkouts with externals
  FAIL: externals_tests.py 15: should not be able to mv or rm a file external
  FAIL: upgrade_tests.py 7: test upgrading a working copy created with 1.0.0

* subversion/libsvn_wc/update_editor.c
  (window_handler): When completing the text changes, store the resulting
    text in the pristine store.
  (add_file_with_history): Store the resulting text in the pristine store.
  (close_file): Don't install the new text base; assume it's already done.
    Don't delete the temporary text base file.
--This line, and those below, will be ignored--

Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(revision 959212)
+++ subversion/libsvn_wc/update_editor.c	(working copy)
@@ -1103,6 +1103,7 @@ window_handler(svn_txdelta_window_t *win
 {
   struct handler_baton *hb = baton;
   struct file_baton *fb = hb->fb;
+  svn_wc__db_t *db = fb->edit_baton->db;
   svn_error_t *err;
 
   /* Apply this window.  We may be done at that point.  */
@@ -1150,6 +1151,20 @@ window_handler(svn_txdelta_window_t *win
                                   svn_checksum_md5, fb->pool);
       fb->new_text_base_sha1_checksum =
         svn_checksum_dup(hb->new_text_base_sha1_checksum, fb->pool);
+
+#ifdef SVN_EXPERIMENTAL_PRISTINE
+      /* Store the new pristine text in the pristine store now.  Later, in a
+         single transaction we will update the BASE_NODE to include a
+         reference to this pristine text's checksum. */
+      SVN_ERR(svn_wc__db_pristine_install(db, fb->new_text_base_tmp_abspath,
+                                          fb->new_text_base_sha1_checksum,
+                                          fb->new_text_base_md5_checksum,
+                                          hb->pool));
+      SVN_ERR(svn_wc__db_pristine_get_path(&fb->new_text_base_tmp_abspath,
+                                           db, fb->local_abspath,
+                                           fb->new_text_base_sha1_checksum,
+                                           fb->pool, hb->pool));
+#endif
     }
 
   svn_pool_destroy(hb->pool);
@@ -3486,6 +3501,9 @@ copy_regular_props(apr_hash_t *props_in,
 
    After this function returns, subsequent apply_textdelta() commands coming
    from the server may further alter the file before it is installed.
+
+   Ensure the resulting text base is in the pristine store, and set
+   TFB->copied_text_base_* to its readable abspath and checksums.
 */
 static svn_error_t *
 add_file_with_history(struct dir_baton *pb,
@@ -3596,6 +3614,21 @@ add_file_with_history(struct dir_baton *
       working_props = base_props;
     }
 
+#ifdef SVN_EXPERIMENTAL_PRISTINE
+  /* The Pristine Store way: copied_text_base_abspath points to the
+   * installed pristine text. */
+  SVN_ERR(svn_wc__db_pristine_install(db, tfb->copied_text_base_abspath,
+                                      tfb->copied_text_base_sha1_checksum,
+                                      tfb->copied_text_base_md5_checksum,
+                                      subpool));
+  /* Update the reference to the path where we can read the file, now
+   * that it's moved into the pristine store. */
+  SVN_ERR(svn_wc__db_pristine_get_path(&tfb->copied_text_base_abspath,
+                                       db, tfb->local_abspath,
+                                       tfb->copied_text_base_sha1_checksum,
+                                       tfb->pool, subpool));
+#endif
+
   /* Loop over whatever props we have in memory, and add all
      regular props to hashes in the baton. Skip entry and wc
      properties, these are only valid for the original file. */
@@ -4683,28 +4716,6 @@ close_file(void *file_baton,
             expected_md5_digest,
             svn_checksum_to_cstring_display(new_text_base_md5_checksum, pool));
 
-#ifdef SVN_EXPERIMENTAL_PRISTINE
-  /* If we had a text change, drop the pristine into its proper place. */
-  /* ### Caution: there is as yet no code to ever remove these pristine
-     files when they are superseded. */
-  /* The WC-NG way is to install the new pristine text in two steps: move it
-     into the pristine store now, and then later in a single transaction
-     update the BASE_NODE to include a reference to this pristine text's
-     checksum.  In the old WC-1 way, installation of this file happens later
-     (in merge_file()) as a single move into place, being part of the loggy
-     action of updating the WC metadata. */
-  if (new_text_base_abspath)
-    {
-      SVN_ERR(svn_wc__db_pristine_install(eb->db, new_text_base_abspath,
-                                          new_text_base_sha1_checksum,
-                                          new_text_base_md5_checksum, pool));
-      SVN_ERR(svn_wc__db_pristine_get_path(&new_text_base_abspath, eb->db,
-                                           fb->local_abspath,
-                                           new_text_base_sha1_checksum,
-                                           pool, pool));
-    }
-#endif
-
   SVN_ERR(svn_wc_read_kind(&kind, eb->wc_ctx, fb->local_abspath, TRUE, pool));
   if (kind == svn_node_none && ! fb->adding_file)
     return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
@@ -4899,6 +4910,7 @@ close_file(void *file_baton,
       all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
     }
 
+#ifndef SVN_EXPERIMENTAL_PRISTINE
   if (fb->copied_text_base_abspath)
     {
       SVN_ERR(svn_wc__wq_build_file_remove(&work_item, eb->db,
@@ -4906,6 +4918,7 @@ close_file(void *file_baton,
                                            pool, pool));
       all_work_items = svn_wc__wq_merge(all_work_items, work_item, pool);
     }
+#endif
 
   /* ### NOTE: from this point onwards, we make several changes to the
      ### database in a non-transactional way. we also queue additional

Reply via email to