You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2010/07/23 14:08:19 UTC

svn commit: r967061 - in /subversion/trunk/subversion/libsvn_wc: log.c log.h merge.c workqueue.c workqueue.h

Author: rhuijben
Date: Fri Jul 23 12:08:19 2010
New Revision: 967061

URL: http://svn.apache.org/viewvc?rev=967061&view=rev
Log:
Replace svn_wc__loggy_translated_file() with a new wq operation. Move the
ordering of the arguments to be more like the new wc-db apis.

* subversion/libsvn_wc/log.c
  (SVN_WC__LOG_CP_AND_TRANSLATE, SVN_WC__LOG_ATTR_DEST,
   SVN_WC__LOG_ATTR_ARG_2): Remove defines.
  (log_do_file_cp_and_translate): Remove function.
  (start_handler): Remove LOG_CP_AND_TRANSLATE support.
  (svn_wc__loggy_translated_file): Remove function.

* subversion/libsvn_wc/log.h
  (svn_wc__loggy_translated_file): Remove function.

* subversion/libsvn_wc/merge.c
  (save_merge_result): Build a wq item.
  (preserve_pre_merge_files): Build three wq items.

* subversion/libsvn_wc/workqueue.c
  (OP_FILE_COPY_TRANSLATED): New define.
  (run_file_copy_translated): New function.
  (svn_wc__wq_build_file_copy_translated): New function.
  (dispatch_table): Add OP_FILE_COPY_TRANSLATED.

* subversion/libsvn_wc/workqueue.h
  (svn_wc__wq_build_file_copy_translated): New function.

Modified:
    subversion/trunk/subversion/libsvn_wc/log.c
    subversion/trunk/subversion/libsvn_wc/log.h
    subversion/trunk/subversion/libsvn_wc/merge.c
    subversion/trunk/subversion/libsvn_wc/workqueue.c
    subversion/trunk/subversion/libsvn_wc/workqueue.h

Modified: subversion/trunk/subversion/libsvn_wc/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/log.c?rev=967061&r1=967060&r2=967061&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/log.c (original)
+++ subversion/trunk/subversion/libsvn_wc/log.c Fri Jul 23 12:08:19 2010
@@ -74,11 +74,6 @@
 #define SVN_WC__LOG_ATTR_REVISION       "revision"
 #define SVN_WC__LOG_ATTR_KIND           "kind"
 
-/* Copy file SVN_WC__LOG_ATTR_NAME to SVN_WC__LOG_ATTR_DEST, but
-   expand any keywords and use any eol-style defined by properties of
-   the DEST. */
-#define SVN_WC__LOG_CP_AND_TRANSLATE    "cp-and-translate"
-
 /* Set SVN_WC__LOG_ATTR_NAME to have timestamp SVN_WC__LOG_ATTR_TIMESTAMP. */
 #define SVN_WC__LOG_SET_TIMESTAMP       "set-timestamp"
 
@@ -92,15 +87,10 @@
     how these are used. **/
 
 #define SVN_WC__LOG_ATTR_NAME           "name"
-#define SVN_WC__LOG_ATTR_DEST           "dest"
 #define SVN_WC__LOG_ATTR_TIMESTAMP      "timestamp"
 #define SVN_WC__LOG_ATTR_DATA           "data"
 
-/* This one is for SVN_WC__LOG_CP_AND_TRANSLATE to indicate a versioned
-   path to take its translation properties from */
-#define SVN_WC__LOG_ATTR_ARG_2          "arg2"
 
-
 /*** Userdata for the callbacks. ***/
 struct log_runner
 {
@@ -135,44 +125,6 @@ struct log_runner
                          loggy->parser)
 
 
-static svn_error_t *
-log_do_file_cp_and_translate(svn_wc__db_t *db,
-                             const char *from_abspath,
-                             const char *dest_abspath,
-                             const char *versioned_abspath,
-                             apr_pool_t *scratch_pool)
-{
-  svn_error_t *err;
-  svn_subst_eol_style_t style;
-  const char *eol;
-  apr_hash_t *keywords;
-  svn_boolean_t special;
-
-  err = svn_wc__get_translate_info(&style, &eol,
-                                   &keywords,
-                                   &special,
-                                   db, versioned_abspath,
-                                   scratch_pool, scratch_pool);
-
-  if (! err)
-    err = svn_subst_copy_and_translate4(from_abspath, dest_abspath,
-                                        eol, TRUE /* repair */,
-                                        keywords, TRUE /* expand */,
-                                        special,
-                                        NULL, NULL, /* ### cancel */
-                                        scratch_pool);
-
-  if (err)
-    {
-      if (!APR_STATUS_IS_ENOENT(err->apr_err))
-        return svn_error_return(err);
-      svn_error_clear(err);
-    }
-
-  return SVN_NO_ERROR;
-}
-
-
 /* Set file NAME in log's CWD to timestamp value in ATTS. */
 static svn_error_t *
 log_do_file_timestamp(struct log_runner *loggy,
@@ -399,23 +351,6 @@ start_handler(void *userData, const char
       kind = svn_node_file;
     err = log_do_delete_entry(loggy, name, revision, kind);
   }
-  else if (strcmp(eltname, SVN_WC__LOG_CP_AND_TRANSLATE) == 0) {
-    const char *dest = svn_xml_get_attr_value(SVN_WC__LOG_ATTR_DEST, atts);
-    const char *versioned = svn_xml_get_attr_value(SVN_WC__LOG_ATTR_ARG_2,
-                                                   atts);
-    const char *from_abspath;
-    const char *dest_abspath;
-    const char *versioned_abspath;
-
-    SVN_ERR_ASSERT_NO_RETURN(dest != NULL);
-    SVN_ERR_ASSERT_NO_RETURN(versioned != NULL);
-    from_abspath = svn_dirent_join(loggy->adm_abspath, name, loggy->pool);
-    dest_abspath = svn_dirent_join(loggy->adm_abspath, dest, loggy->pool);
-    versioned_abspath = svn_dirent_join(loggy->adm_abspath, versioned,
-                                        loggy->pool);
-    err = log_do_file_cp_and_translate(loggy->db, from_abspath, dest_abspath,
-                                       versioned_abspath, loggy->pool);
-  }
   else if (strcmp(eltname, SVN_WC__LOG_SET_TIMESTAMP) == 0) {
     err = log_do_file_timestamp(loggy, name, atts);
   }
@@ -508,42 +443,6 @@ loggy_path(const char **relpath,
 
 
 svn_error_t *
-svn_wc__loggy_translated_file(svn_skel_t **work_item,
-                              svn_wc__db_t *db,
-                              const char *adm_abspath,
-                              const char *dst_abspath,
-                              const char *src_abspath,
-                              const char *versioned_abspath,
-                              apr_pool_t *result_pool)
-{
-  const char *loggy_path1;
-  const char *loggy_path2;
-  const char *loggy_path3;
-  svn_stringbuf_t *log_accum = NULL;
-
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(adm_abspath));
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(dst_abspath));
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(src_abspath));
-  SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_abspath));
-
-  SVN_ERR(loggy_path(&loggy_path1, src_abspath, adm_abspath, result_pool));
-  SVN_ERR(loggy_path(&loggy_path2, dst_abspath, adm_abspath, result_pool));
-  SVN_ERR(loggy_path(&loggy_path3, versioned_abspath, adm_abspath,
-                     result_pool));
-
-  svn_xml_make_open_tag(&log_accum, result_pool, svn_xml_self_closing,
-                        SVN_WC__LOG_CP_AND_TRANSLATE,
-                        SVN_WC__LOG_ATTR_NAME, loggy_path1,
-                        SVN_WC__LOG_ATTR_DEST, loggy_path2,
-                        SVN_WC__LOG_ATTR_ARG_2, loggy_path3,
-                        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_delete_entry(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=967061&r1=967060&r2=967061&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/log.h (original)
+++ subversion/trunk/subversion/libsvn_wc/log.h Fri Jul 23 12:08:19 2010
@@ -47,22 +47,6 @@ extern "C" {
    ADM_ABSPATH (or equal to it, where that makes sense).
 */
 
-
-/* Set *WORK_ITEM to a work queue instruction to generate a translated
-   file from SRC_ABSPATH to DST_ABSPATH with translation settings from
-   VERSIONED_ABSPATH.
-
-   ADM_ABSPATH is described above.
-*/
-svn_error_t *
-svn_wc__loggy_translated_file(svn_skel_t **work_item,
-                              svn_wc__db_t *db,
-                              const char *adm_abspath,
-                              const char *dst_abspath,
-                              const char *src_abspath,
-                              const char *versioned_abspath,
-                              apr_pool_t *result_pool);
-
 /* Set *WORK_ITEM to a work queue instruction to delete the entry
    associated with LOCAL_ABSPATH from the entries file.
 

Modified: subversion/trunk/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/merge.c?rev=967061&r1=967060&r2=967061&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Fri Jul 23 12:08:19 2010
@@ -463,12 +463,10 @@ save_merge_result(svn_skel_t **work_item
                                      ".edited",
                                      svn_io_file_del_none,
                                      scratch_pool, scratch_pool));
-  SVN_ERR(svn_wc__loggy_translated_file(work_item,
-                                        db, dir_abspath,
-                                        edited_copy_abspath,
-                                        source,
-                                        versioned_abspath,
-                                        result_pool));
+  SVN_ERR(svn_wc__wq_build_file_copy_translated(work_item,
+                                                db, versioned_abspath,
+                                                source, edited_copy_abspath,
+                                                result_pool, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -645,6 +643,9 @@ eval_conflict_func_result(svn_skel_t **w
    The translation to working-copy form will be done according to the
    versioned properties of TARGET_ABSPATH that are current when the work
    queue items are executed.
+
+   If target_abspath is not versioned use detranslated_target_abspath
+   as the target file.
 */
 static svn_error_t *
 preserve_pre_merge_files(svn_skel_t **work_items,
@@ -658,6 +659,7 @@ preserve_pre_merge_files(svn_skel_t **wo
                          const char *left_label,
                          const char *right_label,
                          const char *target_label,
+                         const char *detranslated_target_abspath,
                          svn_cancel_func_t cancel_func,
                          void *cancel_baton,
                          apr_pool_t *result_pool,
@@ -730,14 +732,16 @@ preserve_pre_merge_files(svn_skel_t **wo
   /* Create LEFT and RIGHT backup files, in expanded form.
      We use TARGET_ABSPATH's current properties to do the translation. */
   /* Derive the basenames of the 3 backup files. */
-  SVN_ERR(svn_wc__loggy_translated_file(&work_item, db, dir_abspath,
-                                        *left_copy, tmp_left,
-                                        target_abspath, result_pool));
+  SVN_ERR(svn_wc__wq_build_file_copy_translated(&work_item,
+                                                db, target_abspath,
+                                                tmp_left, *left_copy,
+                                                result_pool, scratch_pool));
   *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
 
-  SVN_ERR(svn_wc__loggy_translated_file(&work_item, db, dir_abspath,
-                                        *right_copy, tmp_right,
-                                        target_abspath, result_pool));
+  SVN_ERR(svn_wc__wq_build_file_copy_translated(&work_item,
+                                                 db, target_abspath,
+                                                 tmp_right, *right_copy,
+                                                 result_pool, scratch_pool));
   *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
 
   /* Back up TARGET_ABSPATH through detranslation/retranslation:
@@ -754,14 +758,16 @@ preserve_pre_merge_files(svn_skel_t **wo
 
       /* We are merging to a not versioned file, so we have handle
          this without translation */
-      detranslated_target_copy = target_abspath;
+      detranslated_target_copy = detranslated_target_abspath;
     }
   else
     SVN_ERR(err);
 
-  SVN_ERR(svn_wc__loggy_translated_file(&work_item, db, dir_abspath,
-                                        *target_copy, detranslated_target_copy,
-                                        target_abspath, result_pool));
+  SVN_ERR(svn_wc__wq_build_file_copy_translated(&work_item,
+                                                db, target_abspath,
+                                                detranslated_target_copy,
+                                                *target_copy,
+                                                result_pool, scratch_pool));
   *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);
 
   return SVN_NO_ERROR;
@@ -1017,6 +1023,7 @@ merge_text_file(svn_skel_t **work_items,
                     db,
                     left_abspath, right_abspath, target_abspath,
                     left_label, right_label, target_label,
+                    detranslated_target_abspath,
                     cancel_func, cancel_baton,
                     result_pool, scratch_pool));
           *work_items = svn_wc__wq_merge(*work_items, work_item, result_pool);

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=967061&r1=967060&r2=967061&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Fri Jul 23 12:08:19 2010
@@ -60,6 +60,7 @@
 #define OP_FILE_INSTALL "file-install"
 #define OP_FILE_REMOVE "file-remove"
 #define OP_FILE_MOVE "file-move"
+#define OP_FILE_COPY_TRANSLATED "file-translate"
 #define OP_SYNC_FILE_FLAGS "sync-file-flags"
 #define OP_PREJ_INSTALL "prej-install"
 #define OP_WRITE_OLD_PROPS "write-old-props"
@@ -2051,6 +2052,93 @@ svn_wc__wq_build_file_move(svn_skel_t **
   return SVN_NO_ERROR;
 }
 
+/* ------------------------------------------------------------------------ */
+
+/* OP_FILE_COPY_TRANSLATED */
+
+/* Process the OP_FILE_COPY_TRANSLATED work item WORK_ITEM.
+ * See run_file_copy_translated() which generates this work item.
+ * Implements (struct work_item_dispatch).func. */
+static svn_error_t *
+run_file_copy_translated(svn_wc__db_t *db,
+                         const svn_skel_t *work_item,
+                         const char *wri_abspath,
+                         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, *src_abspath, *dst_abspath;
+  svn_subst_eol_style_t style;
+  const char *eol;
+  apr_hash_t *keywords;
+  svn_boolean_t special;
+
+  svn_error_t *err;
+
+  local_abspath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
+  src_abspath = apr_pstrmemdup(scratch_pool, arg1->next->data,
+                               arg1->next->len);
+  dst_abspath = apr_pstrmemdup(scratch_pool, arg1->next->next->data,
+                                arg1->next->next->len);
+
+  SVN_ERR(svn_wc__get_translate_info(&style, &eol,
+                                     &keywords,
+                                     &special,
+                                     db, local_abspath,
+                                     scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_subst_copy_and_translate4(src_abspath, dst_abspath,
+                                        eol, TRUE /* repair */,
+                                        keywords, TRUE /* expand */,
+                                        special,
+                                        NULL, NULL, /* ### cancel */
+                                        scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
+svn_wc__wq_build_file_copy_translated(svn_skel_t **work_item,
+                                      svn_wc__db_t *db,
+                                      const char *local_abspath,
+                                      const char *src_abspath,
+                                      const char *dst_abspath,
+                                      apr_pool_t *result_pool,
+                                      apr_pool_t *scratch_pool)
+{
+  svn_node_kind_t kind;
+  *work_item = svn_skel__make_empty_list(result_pool);
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(src_abspath));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(dst_abspath));
+
+  /* File must exist */
+  SVN_ERR(svn_io_check_path(src_abspath, &kind, result_pool));
+
+  if (kind == svn_node_none)
+    return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                             _("'%s' not found"),
+                             svn_dirent_local_style(src_abspath,
+                                                    scratch_pool));
+
+  /* ### Once we move to a central DB we should try making
+     ### src_abspath, dst_abspath and info_abspath relative from
+     ### the WCROOT of info_abspath. */
+
+  svn_skel__prepend_str(apr_pstrdup(result_pool, dst_abspath),
+                        *work_item, result_pool);
+  svn_skel__prepend_str(apr_pstrdup(result_pool, src_abspath),
+                        *work_item, result_pool);
+  svn_skel__prepend_str(apr_pstrdup(result_pool, local_abspath),
+                        *work_item, result_pool);
+  svn_skel__prepend_str(OP_FILE_COPY_TRANSLATED, *work_item, result_pool);
+
+  return SVN_NO_ERROR;
+}
+
 
 /* ------------------------------------------------------------------------ */
 
@@ -2505,6 +2593,7 @@ static const struct work_item_dispatch d
   { OP_FILE_INSTALL, run_file_install },
   { OP_FILE_REMOVE, run_file_remove },
   { OP_FILE_MOVE, run_file_move },
+  { OP_FILE_COPY_TRANSLATED, run_file_copy_translated },
   { OP_SYNC_FILE_FLAGS, run_sync_file_flags },
   { OP_PREJ_INSTALL, run_prej_install },
   { OP_WRITE_OLD_PROPS, run_write_old_props },

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=967061&r1=967060&r2=967061&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.h (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.h Fri Jul 23 12:08:19 2010
@@ -137,6 +137,18 @@ svn_wc__wq_build_file_move(svn_skel_t **
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool);
 
+/* Set *WORK_ITEM to a new work item that describes a copy from
+   SRC_ABSPATH to DST_ABSPATH, while translating the stream using
+   the information from LOCAL_ABSPATH. */
+svn_error_t *
+svn_wc__wq_build_file_copy_translated(svn_skel_t **work_item,
+                                      svn_wc__db_t *db,
+                                      const char *local_abspath,
+                                      const char *src_abspath,
+                                      const char *dst_abspath,
+                                      apr_pool_t *result_pool,
+                                      apr_pool_t *scratch_pool);
+
 
 /* Set *WORK_ITEM to a new work item that will synchronize the
    target node's readonly and executable flags with the values defined