Author: gstein
Date: Mon Apr 26 23:23:47 2010
New Revision: 938268

URL: http://svn.apache.org/viewvc?rev=938268&view=rev
Log:
Create a new workqueue operation for installing property reject files. The
bulk of the will continue to remain in props.c for now.

* subversion/libsvn_wc/workqueue.h:
  (svn_wc__wq_build_prej_install): new declaration for the new work item

* subversion/libsvn_wc/workqueue.c:
  (OP_PREJ_INSTALL): new workqueue operation
  (run_prej_install): new handler for OP_PREJ_INSTALL. calls back to
    props.c to create the (temporary) prejfile, and to get the target
    prejfile. it then moves it into place.
  (svn_wc__wq_build_prej_install): build and return the new work item.
    there is some temporary hackery here, without a handy svn_skel_dup()
    function.

* subversion/libsvn_wc/props.h:
  (svn_wc__get_prejfile_abspath, svn_wc__create_prejfile): new declarations

* subversion/libsvn_wc/props.c:
  (get_existing_prop_reject_file): renamed to ...
  (svn_wc__get_prejfile_abspath): ... this. the ADM_ABSPATH parameter is
    removed, and we figure out dir/file target based on the prejfile name.
    now takes dual pools, too.
  (create_conflict_file): renamed to ...
  (svn_wc__create_prejfile): ... this.
  (svn_wc__merge_props): no need to create the (temp) prejfile (nor move
    it into place). track rename to get_prejfile_abspath. queue the work
    item after the prejfile property has been set.

Modified:
    subversion/trunk/subversion/libsvn_wc/props.c
    subversion/trunk/subversion/libsvn_wc/props.h
    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=938268&r1=938267&r2=938268&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Mon Apr 26 23:23:47 2010
@@ -267,20 +267,18 @@ append_prop_conflict(svn_stream_t *strea
 
 /* Get the reject file for LOCAL_ABSPATH in DB.  Set *REJECT_FILE to the
    name of that file, or to NULL if no such file exists. */
-static svn_error_t *
-get_existing_prop_reject_file(const char **reject_file,
-                              svn_wc__db_t *db,
-                              const char *adm_abspath,
-                              const char *local_abspath,
-                              apr_pool_t *pool)
+svn_error_t *
+svn_wc__get_prejfile_abspath(const char **prejfile_abspath,
+                             svn_wc__db_t *db,
+                             const char *local_abspath,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool)
 {
   const apr_array_header_t *conflicts;
   int i;
 
-  *reject_file = NULL;
-
   SVN_ERR(svn_wc__db_read_conflicts(&conflicts, db, local_abspath,
-                                    pool, pool));
+                                    scratch_pool, scratch_pool));
 
   for (i = 0; i < conflicts->nelts; i++)
     {
@@ -288,9 +286,22 @@ get_existing_prop_reject_file(const char
       cd = APR_ARRAY_IDX(conflicts, i, const svn_wc_conflict_description2_t *);
 
       if (cd->kind == svn_wc_conflict_kind_property)
-        *reject_file = svn_dirent_join(adm_abspath, cd->their_file, pool);
+        {
+          if (strcmp(cd->their_file, SVN_WC__THIS_DIR_PREJ) == 0)
+            *prejfile_abspath = svn_dirent_join(local_abspath,
+                                                SVN_WC__THIS_DIR_PREJ,
+                                                result_pool);
+          else
+            *prejfile_abspath = svn_dirent_join(
+                                  svn_dirent_dirname(local_abspath,
+                                                     scratch_pool),
+                                  cd->their_file,
+                                  result_pool);
+          return SVN_NO_ERROR;
+        }
     }
 
+  *prejfile_abspath = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -891,13 +902,13 @@ message_from_skel(const svn_skel_t *skel
 
 /* Create a property conflict file at PREJFILE based on the property
    conflicts in CONFLICT_SKEL.  */
-static svn_error_t *
-create_conflict_file(const char **tmp_prejfile_abspath,
-                     svn_wc__db_t *db,
-                     const char *local_abspath,
-                     const svn_skel_t *conflict_skel,
-                     apr_pool_t *result_pool,
-                     apr_pool_t *scratch_pool)
+svn_error_t *
+svn_wc__create_prejfile(const char **tmp_prejfile_abspath,
+                        svn_wc__db_t *db,
+                        const char *local_abspath,
+                        const svn_skel_t *conflict_skel,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool)
 {
   const char *tempdir_abspath;
   svn_stream_t *stream;
@@ -1812,19 +1823,12 @@ svn_wc__merge_props(svn_wc_notify_state_
 
   if (conflict_skel != NULL)
     {
-      const char *tmp_prejfile_abspath;
       const char *reject_path;
 
-      /* Construct a property reject file in the temporary area.  */
-      SVN_ERR(create_conflict_file(&tmp_prejfile_abspath,
-                                   db, local_abspath,
-                                   conflict_skel,
-                                   scratch_pool, scratch_pool));
-
       /* Now try to get the name of a pre-existing .prej file from the
          entries file */
-      SVN_ERR(get_existing_prop_reject_file(&reject_path, db, adm_abspath,
-                                            local_abspath, scratch_pool));
+      SVN_ERR(svn_wc__get_prejfile_abspath(&reject_path, db, local_abspath,
+                                           scratch_pool, scratch_pool));
 
       if (! reject_path)
         {
@@ -1854,12 +1858,6 @@ svn_wc__merge_props(svn_wc_notify_state_
              disk. */
         }
 
-      /* Move the temporary file to THE property reject file in the working
-         copy area.  */
-      SVN_ERR(svn_wc__loggy_move(db, adm_abspath,
-                                 tmp_prejfile_abspath, reject_path,
-                                 scratch_pool));
-
       /* Mark entry as "conflicted" with a particular .prej file. */
       {
         svn_wc_entry_t entry;
@@ -1870,6 +1868,21 @@ svn_wc__merge_props(svn_wc_notify_state_
                                            SVN_WC__ENTRY_MODIFY_PREJFILE,
                                            scratch_pool));
       }
+
+      /* Once the prejfile is recorded, then install the file.  */
+      {
+        const svn_skel_t *work_item;
+
+        /* ### careful. CONFLICT_SKEL is NOT dup'd into the provided
+           ### result_pool at the moment. we'll get that fixed soon-ish.
+           ### this is okay for now since we immediately serialize it and
+           ### shove it into the database.  */
+        SVN_ERR(svn_wc__wq_build_prej_install(&work_item,
+                                              db, local_abspath,
+                                              conflict_skel,
+                                              scratch_pool, scratch_pool));
+        SVN_ERR(svn_wc__db_wq_add(db, local_abspath, work_item, scratch_pool));
+      }
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_wc/props.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.h?rev=938268&r1=938267&r2=938268&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.h (original)
+++ subversion/trunk/subversion/libsvn_wc/props.h Mon Apr 26 23:23:47 2010
@@ -225,6 +225,21 @@ svn_wc__marked_as_binary(svn_boolean_t *
                          apr_pool_t *scratch_pool);
 
 
+svn_error_t *
+svn_wc__get_prejfile_abspath(const char **prejfile_abspath,
+                             svn_wc__db_t *db,
+                             const char *local_abspath,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool);
+
+svn_error_t *
+svn_wc__create_prejfile(const char **tmp_prejfile_abspath,
+                        svn_wc__db_t *db,
+                        const char *local_abspath,
+                        const svn_skel_t *conflict_skel,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=938268&r1=938267&r2=938268&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Mon Apr 26 23:23:47 2010
@@ -63,6 +63,7 @@
 #define OP_FILE_INSTALL "file-install"
 #define OP_FILE_REMOVE "file-remove"
 #define OP_SYNC_FILE_FLAGS "sync-file-flags"
+#define OP_PREJ_INSTALL "prej-install"
 
 
 /* For work queue debugging. Generates output about its operation.  */
@@ -2234,6 +2235,76 @@ svn_wc__wq_build_sync_file_flags(const s
 
 /* ------------------------------------------------------------------------ */
 
+/* OP_PREJ_INSTALL  */
+
+static svn_error_t *
+run_prej_install(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;
+  const svn_skel_t *conflict_skel;
+  const char *tmp_prejfile_abspath;
+  const char *prejfile_abspath;
+
+  local_abspath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
+  if (arg1->next != NULL)
+    conflict_skel = arg1->next;
+  else
+    SVN_ERR_MALFUNCTION();  /* ### wc_db can't provide it ... yet.  */
+
+  /* Construct a property reject file in the temporary area.  */
+  SVN_ERR(svn_wc__create_prejfile(&tmp_prejfile_abspath,
+                                  db, local_abspath,
+                                  conflict_skel,
+                                  scratch_pool, scratch_pool));
+
+  /* Get the (stored) name of where it should go.  */
+  SVN_ERR(svn_wc__get_prejfile_abspath(&prejfile_abspath, db, local_abspath,
+                                       scratch_pool, scratch_pool));
+  SVN_ERR_ASSERT(prejfile_abspath != NULL);
+
+  /* ... and atomically move it into place.  */
+  SVN_ERR(svn_io_file_rename(tmp_prejfile_abspath,
+                             prejfile_abspath,
+                             scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__wq_build_prej_install(const svn_skel_t **work_item,
+                              svn_wc__db_t *db,
+                              const char *local_abspath,
+                              const svn_skel_t *conflict_skel,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool)
+{
+  svn_skel_t *build_item = svn_skel__make_empty_list(result_pool);
+
+  /* ### gotta have this, today  */
+  SVN_ERR_ASSERT(conflict_skel != NULL);
+
+  if (conflict_skel != NULL)
+    /* ### woah! this needs to dup the skel into RESULT_POOL  */
+    svn_skel__prepend((svn_skel_t *)conflict_skel, build_item);
+  svn_skel__prepend_str(apr_pstrdup(result_pool, local_abspath),
+                        build_item, result_pool);
+  svn_skel__prepend_str(OP_PREJ_INSTALL, 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 },
@@ -2247,6 +2318,7 @@ static const struct work_item_dispatch d
   { OP_FILE_INSTALL, run_file_install },
   { OP_FILE_REMOVE, run_file_remove },
   { OP_SYNC_FILE_FLAGS, run_sync_file_flags },
+  { OP_PREJ_INSTALL, run_prej_install },
 
   /* Sentinel.  */
   { NULL }

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=938268&r1=938267&r2=938268&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.h (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.h Mon Apr 26 23:23:47 2010
@@ -106,6 +106,19 @@ svn_wc__wq_build_sync_file_flags(const s
                                  apr_pool_t *scratch_pool);
 
 
+/* Build a work item that will install a property reject file for
+   LOCAL_ABSPATH into the working copy. The propety conflicts will
+   be taken from CONFLICT_SKEL, or if NULL, then from wc_db for the
+   given DB/LOCAL_ABSPATH.  */
+svn_error_t *
+svn_wc__wq_build_prej_install(const svn_skel_t **work_item,
+                              svn_wc__db_t *db,
+                              const char *local_abspath,
+                              const svn_skel_t *conflict_skel,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool);
+
+
 /* Record a work item to revert LOCAL_ABSPATH.  */
 svn_error_t *
 svn_wc__wq_add_revert(svn_boolean_t *will_revert,


Reply via email to