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/09 06:43:07 UTC

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

Author: gstein
Date: Fri Apr  9 04:43:07 2010
New Revision: 932240

URL: http://svn.apache.org/viewvc?rev=932240&view=rev
Log:
Create a new work item for synchronizing a working file's readonly and
executable flags with its property/lock state. This can be used to
modify the working file in situations where it is not re-installed
(for example, a props-only update).

This obsoletes two loggy operations, and we can consolidate many calls
to svn_wc__maybe_set_* into one location in the workqueue.

* subversion/libsvn_wc/workqueue.h:
  (svn_wc__wq_build_sync_file_flags): new declaration

* subversion/libsvn_wc/workqueue.c:
  (OP_SYNC_FILE_FLAGS): new operation code
  (sync_file_flags): internal helper to synchronize a working file
    against its property/lock state.
  (copy_and_translate, run_file_install): use sync_file_flags rather
    than manual calls to the svn_wc_maybe_set_* functions.
  (run_sync_file_flags): work item handler that wraps sync_file_flags
  (svn_wc__wq_build_sync_file_flags): new function to build the
    OP_SYNC_FILE_FLAGS work item.
  (dispatch_table): add the OP_SYNC_FILE_FLAGS handler

* subversion/libsvn_wc/log.h:
  (svn_wc__loggy_maybe_set_executable,
      svn_wc__loggy_maybe_set_readonly): removed. no longer used.

* subversion/libsvn_wc/log.c:
  (SVN_WC__LOG_MAYBE_READONLY, SVN_WC__LOG_MAYBE_EXECUTABLE): removed
  (log_do_file_maybe_executable, log_do_file_maybe_readonly): removed
  (start_handler): removed processing of the MAYBE operations
  (svn_wc__loggy_maybe_set_executable,
      svn_wc__loggy_maybe_set_readonly): removed. no longer used.

* subversion/libsvn_wc/merge.c:
  (svn_wc__internal_merge): queue an OP_SYNC_FILE_FLAGS rather than
    the old loggy operations

* subversion/libsvn_wc/update_editor.c:
  (close_file): queue an OP_SYNC_FILE_FLAGS work item rather than the
    old set_readonly loggy operation. the new OP will also sync the
    executable flag while there, but no biggy.

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/update_editor.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=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/log.c (original)
+++ subversion/trunk/subversion/libsvn_wc/log.c Fri Apr  9 04:43:07 2010
@@ -94,14 +94,6 @@
 /* Make file SVN_WC__LOG_ATTR_NAME readonly */
 #define SVN_WC__LOG_READONLY            "readonly"
 
-/* Make file SVN_WC__LOG_ATTR_NAME readonly if needs-lock property is set
-   and there is no lock token for the file in the working copy. */
-#define SVN_WC__LOG_MAYBE_READONLY "maybe-readonly"
-
-/* Make file SVN_WC__LOG_ATTR_NAME executable if the
-   executable property is set. */
-#define SVN_WC__LOG_MAYBE_EXECUTABLE "maybe-executable"
-
 /* Set SVN_WC__LOG_ATTR_NAME to have timestamp SVN_WC__LOG_ATTR_TIMESTAMP. */
 #define SVN_WC__LOG_SET_TIMESTAMP       "set-timestamp"
 
@@ -232,6 +224,8 @@ file_xfer_under_path(svn_wc__db_t *db,
             svn_error_clear(err);
           }
 
+        /* ### switch to OP_SYNC_FILE_FLAGS  */
+
         SVN_ERR(svn_wc__maybe_set_read_only(NULL, db, dest_abspath,
                                             scratch_pool));
 
@@ -322,29 +316,6 @@ log_do_file_readonly(struct log_runner *
   return SVN_NO_ERROR;
 }
 
-/* Maybe make file NAME in log's CWD executable */
-static svn_error_t *
-log_do_file_maybe_executable(struct log_runner *loggy,
-                             const char *name)
-{
-  const char *local_abspath
-    = svn_dirent_join(loggy->adm_abspath, name, loggy->pool);
-
-  return svn_error_return(svn_wc__maybe_set_executable(
-                                NULL, loggy->db, local_abspath, loggy->pool));
-}
-
-/* Maybe make file NAME in log's CWD readonly */
-static svn_error_t *
-log_do_file_maybe_readonly(struct log_runner *loggy,
-                           const char *name)
-{
-  const char *local_abspath
-    = svn_dirent_join(loggy->adm_abspath, name, loggy->pool);
-
-  return svn_wc__maybe_set_read_only(NULL, loggy->db, local_abspath,
-                                     loggy->pool);
-}
 
 /* Set file NAME in log's CWD to timestamp value in ATTS. */
 static svn_error_t *
@@ -670,12 +641,6 @@ start_handler(void *userData, const char
   else if (strcmp(eltname, SVN_WC__LOG_READONLY) == 0) {
     err = log_do_file_readonly(loggy, name);
   }
-  else if (strcmp(eltname, SVN_WC__LOG_MAYBE_READONLY) == 0) {
-    err = log_do_file_maybe_readonly(loggy, name);
-  }
-  else if (strcmp(eltname, SVN_WC__LOG_MAYBE_EXECUTABLE) == 0) {
-    err = log_do_file_maybe_executable(loggy, name);
-  }
   else if (strcmp(eltname, SVN_WC__LOG_SET_TIMESTAMP) == 0) {
     err = log_do_file_timestamp(loggy, name, atts);
   }
@@ -1068,48 +1033,6 @@ svn_wc__loggy_move(svn_stringbuf_t **log
                                   result_pool, scratch_pool);
 }
 
-svn_error_t *
-svn_wc__loggy_maybe_set_executable(svn_wc__db_t *db,
-                                   const char *adm_abspath,
-                                   const char *path,
-                                   apr_pool_t *scratch_pool)
-{
-  svn_stringbuf_t *log_accum = NULL;
-  const char *loggy_path1;
-
-  SVN_ERR(loggy_path(&loggy_path1, path, adm_abspath, scratch_pool));
-  svn_xml_make_open_tag(&log_accum,
-                        scratch_pool,
-                        svn_xml_self_closing,
-                        SVN_WC__LOG_MAYBE_EXECUTABLE,
-                        SVN_WC__LOG_ATTR_NAME, loggy_path1,
-                        NULL);
-
-  return svn_error_return(svn_wc__wq_add_loggy(db, adm_abspath, log_accum,
-                                               scratch_pool));
-}
-
-svn_error_t *
-svn_wc__loggy_maybe_set_readonly(svn_wc__db_t *db,
-                                 const char *adm_abspath,
-                                 const char *path,
-                                 apr_pool_t *scratch_pool)
-{
-  svn_stringbuf_t *log_accum = NULL;
-  const char *loggy_path1;
-
-  SVN_ERR(loggy_path(&loggy_path1, path, adm_abspath, scratch_pool));
-  svn_xml_make_open_tag(&log_accum,
-                        scratch_pool,
-                        svn_xml_self_closing,
-                        SVN_WC__LOG_MAYBE_READONLY,
-                        SVN_WC__LOG_ATTR_NAME,
-                        loggy_path1,
-                        NULL);
-
-  return svn_error_return(svn_wc__wq_add_loggy(db, adm_abspath, log_accum,
-                                               scratch_pool));
-}
 
 svn_error_t *
 svn_wc__loggy_set_entry_timestamp_from_wc(svn_stringbuf_t **log_accum,

Modified: subversion/trunk/subversion/libsvn_wc/log.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/log.h?rev=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/log.h (original)
+++ subversion/trunk/subversion/libsvn_wc/log.h Fri Apr  9 04:43:07 2010
@@ -191,39 +191,6 @@ svn_wc__loggy_move(svn_stringbuf_t **log
                    apr_pool_t *scratch_pool);
 
 
-
-/* Queue instructions to set permissions of PATH to 'executable' if it has
-   the 'executable' property set.
-
-   ADM_ABSPATH is the absolute path for the admin directory for PATH.
-
-   The property is tested at log run time, within this log instruction.
-
-   Use SCRATCH_POOL for temporary allocations.
-*/
-svn_error_t *
-svn_wc__loggy_maybe_set_executable(svn_wc__db_t *db,
-                                   const char *adm_abspath,
-                                   const char *path,
-                                   apr_pool_t *scratch_pool);
-
-/* Queue instructions to set permissions of PATH to 'readonly' if it has
-   the 'needs-lock' property set and there is no lock for the file in the
-   working copy.
-
-   ADM_ABSPATH is the absolute path for the admin directory for PATH.
-
-   The tests are made at log run time, within this log instruction.
-
-   Use SCRATCH_POOL for temporary allocations.
-*/
-svn_error_t *
-svn_wc__loggy_maybe_set_readonly(svn_wc__db_t *db,
-                                 const char *adm_abspath,
-                                 const char *path,
-                                 apr_pool_t *scratch_pool);
-
-
 /* Extend **LOG_ACCUM with log instructions to set the timestamp of PATH
    in the entry field with name TIME_PROP.
    TODO ### Huh? There is no 'TIME_PROP' argument.

Modified: subversion/trunk/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/merge.c?rev=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Fri Apr  9 04:43:07 2010
@@ -1269,12 +1269,12 @@ svn_wc__internal_merge(svn_stringbuf_t *
      possibly make it read-only. */
   if (! dry_run)
     {
-      SVN_ERR(svn_wc__loggy_maybe_set_executable(db, dir_abspath,
-                                                 target_abspath,
-                                                 pool));
-      SVN_ERR(svn_wc__loggy_maybe_set_readonly(db, dir_abspath,
+      const svn_skel_t *work_item;
+
+      SVN_ERR(svn_wc__wq_build_sync_file_flags(&work_item, db,
                                                target_abspath,
-                                               pool));
+                                               pool, pool));
+      SVN_ERR(svn_wc__db_wq_add(db, dir_abspath, work_item, pool));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Fri Apr  9 04:43:07 2010
@@ -4979,11 +4979,17 @@ close_file(void *file_baton,
   if (new_text_base_abspath == NULL
       && lock_state == svn_wc_notify_lock_state_unlocked)
     {
+      const svn_skel_t *work_item;
+
       /* If a lock was removed and we didn't update the text contents, we
-         might need to set the file read-only. */
-      SVN_ERR(svn_wc__loggy_maybe_set_readonly(eb->db,
-                                               fb->dir_baton->local_abspath,
-                                               fb->local_abspath, pool));
+         might need to set the file read-only.
+
+         Note: this will also update the executable flag, but ... meh.  */
+      SVN_ERR(svn_wc__wq_build_sync_file_flags(&work_item, eb->db,
+                                               fb->local_abspath,
+                                               pool, pool));
+      SVN_ERR(svn_wc__db_wq_add(eb->db, fb->dir_baton->local_abspath,
+                                work_item, pool));
     }
 
   /* Clean up any temporary files.  */

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Fri Apr  9 04:43:07 2010
@@ -28,6 +28,7 @@
 #include "svn_dirent_uri.h"
 #include "svn_subst.h"
 #include "svn_hash.h"
+#include "svn_io.h"
 
 #include "wc.h"
 #include "wc_db.h"
@@ -61,6 +62,7 @@
 #define OP_DELETE "delete"
 #define OP_FILE_INSTALL "file-install"
 #define OP_FILE_REMOVE "file-remove"
+#define OP_SYNC_FILE_FLAGS "sync-file-flags"
 
 
 /* For work queue debugging. Generates output about its operation.  */
@@ -77,6 +79,24 @@ struct work_item_dispatch {
 };
 
 
+static svn_error_t *
+sync_file_flags(svn_wc__db_t *db,
+                const char *local_abspath,
+                apr_pool_t *scratch_pool)
+{
+  /* ### right now, the maybe_set_* functions will only positively set those
+     ### values. we need to clear them first.  */
+  SVN_ERR(svn_io_set_file_read_write(local_abspath, FALSE, scratch_pool));
+  SVN_ERR(svn_io_set_file_executable(local_abspath, FALSE, FALSE,
+                                     scratch_pool));
+
+  SVN_ERR(svn_wc__maybe_set_read_only(NULL, db, local_abspath, scratch_pool));
+  SVN_ERR(svn_wc__maybe_set_executable(NULL, db, local_abspath, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+
 /* Ripped from the old loggy cp_and_translate operation.
 
    SOURCE_ABSPATH specifies the source which is translated for
@@ -116,10 +136,8 @@ copy_and_translate(svn_wc__db_t *db,
             scratch_pool));
 
   /* ### this is a problem. DEST_ABSPATH is not necessarily versioned.  */
-  SVN_ERR(svn_wc__maybe_set_read_only(NULL, db, dest_abspath,
-                                      scratch_pool));
-  SVN_ERR(svn_wc__maybe_set_executable(NULL, db, dest_abspath,
-                                       scratch_pool));
+  /* ### actually, for the single caller: it *is* versioned.  */
+  SVN_ERR(sync_file_flags(db, dest_abspath, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1198,6 +1216,9 @@ install_committed_file(svn_boolean_t *ov
       *overwrote_working = TRUE;
     }
 
+  /* ### should be using OP_SYNC_FILE_FLAGS, or an internal version of
+     ### that here. do we need to set *OVERWROTE_WORKING?  */
+
   if (remove_executable)
     {
       /* No need to chmod -x on a new file: new files don't have it. */
@@ -2025,8 +2046,7 @@ run_file_install(svn_wc__db_t *db,
   SVN_ERR(svn_io_file_rename(dst_abspath, local_abspath, scratch_pool));
 
   /* Tweak the on-disk file according to its properties.  */
-  SVN_ERR(svn_wc__maybe_set_read_only(NULL, db, local_abspath, scratch_pool));
-  SVN_ERR(svn_wc__maybe_set_executable(NULL, db, local_abspath, scratch_pool));
+  SVN_ERR(sync_file_flags(db, local_abspath, scratch_pool));
 
   if (use_commit_times)
     {
@@ -2156,6 +2176,49 @@ svn_wc__wq_build_file_remove(const svn_s
 
 /* ------------------------------------------------------------------------ */
 
+/* OP_SYNC_FILE_FLAGS  */
+
+/* Process the OP_SYNC_FILE_FLAGS work item WORK_ITEM.
+ * See svn_wc__wq_build_file_remove() which generates this work item.
+ * Implements (struct work_item_dispatch).func. */
+static svn_error_t *
+run_sync_file_flags(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(sync_file_flags(db, local_abspath, scratch_pool));
+}
+
+
+svn_error_t *
+svn_wc__wq_build_sync_file_flags(const svn_skel_t **work_item,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 apr_pool_t *result_pool,
+                                 apr_pool_t *scratch_pool)
+{
+  svn_skel_t *build_item = svn_skel__make_empty_list(result_pool);
+
+  svn_skel__prepend_str(apr_pstrdup(result_pool, local_abspath),
+                        build_item, result_pool);
+  svn_skel__prepend_str(OP_SYNC_FILE_FLAGS, 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 },
@@ -2168,6 +2231,7 @@ static const struct work_item_dispatch d
   { OP_DELETE, run_delete },
   { OP_FILE_INSTALL, run_file_install },
   { OP_FILE_REMOVE, run_file_remove },
+  { OP_SYNC_FILE_FLAGS, run_sync_file_flags },
 
   /* Sentinel.  */
   { NULL }

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.h?rev=932240&r1=932239&r2=932240&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.h (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.h Fri Apr  9 04:43:07 2010
@@ -95,6 +95,17 @@ svn_wc__wq_build_file_remove(const svn_s
                              apr_pool_t *scratch_pool);
 
 
+/* Build a work item (returned in *WORK_ITEM) that will synchronize the
+   target node's readonly and executable flags with the values defined
+   by its properties and lock status.  */
+svn_error_t *
+svn_wc__wq_build_sync_file_flags(const svn_skel_t **work_item,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 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,