You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2017/07/24 11:33:48 UTC

svn commit: r1802787 - in /subversion/trunk/subversion/svn: cl.h cleanup-cmd.c svn.c

Author: stsp
Date: Mon Jul 24 11:33:48 2017
New Revision: 1802787

URL: http://svn.apache.org/viewvc?rev=1802787&view=rev
Log:
Add a new --vacuum-pristines option to 'svn cleanup'.

This option toggles the 'vacuum_pristines' API flag of svn_client_vacuum()
and allows cleaning up the pristine store with a working copy lock held.
It avoids a risk of working copy corruption due to concurrent access by
multiple clients. Because 'svn cleanup' ignores and removes any locks in
its default mode, using that mode to clean up pristines is subtly unsafe.

Adding this feature is cheap since the libsvn_client API already provides it.
The command line client just didn't expose it yet.

* subversion/svn/cl.h
  (svn_cl__opt_state_t): Declare vacuum_pristines flag.

* subversion/svn/cleanup-cmd.c
  (svn_cl__cleanup): Pass the vacuum_pristines flag to svn_client_vacuum().

* subversion/svn/svn.c
  (svn_cl__longopt_t): Add opt_vacuum_pristines.
  (svn_cl__opt_state_t): Document --vacuum-pristines.

Modified:
    subversion/trunk/subversion/svn/cl.h
    subversion/trunk/subversion/svn/cleanup-cmd.c
    subversion/trunk/subversion/svn/svn.c

Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1802787&r1=1802786&r2=1802787&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Mon Jul 24 11:33:48 2017
@@ -250,6 +250,7 @@ typedef struct svn_cl__opt_state_t
   svn_boolean_t pin_externals;     /* pin externals to last-changed revisions */
   const char *show_item;           /* print only the given item */
   svn_boolean_t adds_as_modification; /* update 'add vs add' no tree conflict */
+  svn_boolean_t vacuum_pristines; /* remove unreferenced pristines */
 } svn_cl__opt_state_t;
 
 /* Conflict stats for operations such as update and merge. */

Modified: subversion/trunk/subversion/svn/cleanup-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cleanup-cmd.c?rev=1802787&r1=1802786&r2=1802787&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cleanup-cmd.c (original)
+++ subversion/trunk/subversion/svn/cleanup-cmd.c Mon Jul 24 11:33:48 2017
@@ -72,13 +72,14 @@ svn_cl__cleanup(apr_getopt_t *os,
 
       SVN_ERR(svn_dirent_get_absolute(&target_abspath, target, iterpool));
 
-      if (opt_state->remove_unversioned || opt_state->remove_ignored)
+      if (opt_state->remove_unversioned || opt_state->remove_ignored ||
+          opt_state->vacuum_pristines)
         {
           svn_error_t *err = svn_client_vacuum(target_abspath,
                                                opt_state->remove_unversioned,
                                                opt_state->remove_ignored,
                                                TRUE /* fix_timestamps */,
-                                               FALSE /* vacuum_pristines */,
+                                               opt_state->vacuum_pristines,
                                                opt_state->include_externals,
                                                ctx, iterpool);
 

Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1802787&r1=1802786&r2=1802787&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Mon Jul 24 11:33:48 2017
@@ -143,7 +143,8 @@ typedef enum svn_cl__longopt_t {
   opt_show_passwords,
   opt_pin_externals,
   opt_show_item,
-  opt_adds_as_modification
+  opt_adds_as_modification,
+  opt_vacuum_pristines,
 } svn_cl__longopt_t;
 
 
@@ -459,6 +460,9 @@ const apr_getopt_option_t svn_cl__option
                        "                             "
                        "resolve tree conflicts instead.")},
 
+  {"vacuum-pristines", opt_vacuum_pristines, 0,
+                       N_("remove unreferenced pristines from .svn directory")},
+
   /* Long-opt Aliases
    *
    * These have NULL desriptions, but an option code that matches some
@@ -625,9 +629,16 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "  items can only be removed if the working copy is not already locked\n"
      "  for writing by another Subversion client.\n"
      "  Note that the 'svn status' command shows unversioned items as '?',\n"
-     "  and ignored items as 'I' if the --no-ignore option is given to it.\n"),
+     "  and ignored items as 'I' if the --no-ignore option is given to it.\n"
+     "\n"
+     "  The --vacuum-pristines option provides a safe way to remove pristine\n"
+     "  copies of files which are stored inside the .svn directory and which\n"
+     "  are no longer referenced by any file in the working copy.\n"
+     "  To prevent accidental working copy corruption, this operation will\n"
+     "  only succeed if the working copy is not already locked for writing by\n"
+     "  another Subversion client.\n"),
     {opt_merge_cmd, opt_remove_unversioned, opt_remove_ignored,
-     opt_include_externals, 'q'} },
+     opt_include_externals, 'q', opt_vacuum_pristines} },
 
   { "commit", svn_cl__commit, {"ci"},
     N_("Send changes from your working copy to the repository.\n"