You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2014/05/06 13:47:40 UTC

svn commit: r1592723 - in /subversion/trunk: subversion/svnadmin/svnadmin.c subversion/tests/cmdline/svnadmin_tests.py tools/dist/backport_tests.py

Author: danielsh
Date: Tue May  6 11:47:40 2014
New Revision: 1592723

URL: http://svn.apache.org/r1592723
Log:
Add 'svnadmin delrevprop'.

* subversion/svnadmin/svnadmin.c
  (subcommand_delrevprop): New subcommand.
  (cmd_table."delrevprop"): New subcommand.
  (set_revprop): Permit the FILENAME parameter to be NULL.

* subversion/tests/cmdline/svnadmin_tests.py
  (setrevprop): Test delrevprop here.

* tools/dist/backport_tests.py
  (verify_backport): Use delrevprop instead of 'svn propdel'.

Modified:
    subversion/trunk/subversion/svnadmin/svnadmin.c
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
    subversion/trunk/tools/dist/backport_tests.py

Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1592723&r1=1592722&r2=1592723&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Tue May  6 11:47:40 2014
@@ -152,6 +152,7 @@ check_lib_versions(void)
 static svn_opt_subcommand_t
   subcommand_crashtest,
   subcommand_create,
+  subcommand_delrevprop,
   subcommand_deltify,
   subcommand_dump,
   subcommand_freeze,
@@ -339,6 +340,17 @@ static const svn_opt_subcommand_desc2_t 
     svnadmin__pre_1_6_compatible
     } },
 
+  {"delrevprop", subcommand_delrevprop, {0}, N_
+   ("usage: svnadmin delrevprop REPOS_PATH -r REVISION NAME\n\n"
+    "Delete the property NAME on revision REVISION. Use\n"
+    "--use-pre-revprop-change-hook/--use-post-revprop-change-hook to trigger\n"
+    "the revision property-related hooks (for example, if you want an email\n"
+    "notification sent from your post-revprop-change hook).\n\n"
+    "NOTE: Revision properties are not versioned, so this command will\n"
+    "irreversibly destroy the previous value of the property.\n"),
+   {'r', svnadmin__use_pre_revprop_change_hook,
+    svnadmin__use_post_revprop_change_hook} },
+
   {"deltify", subcommand_deltify, {0}, N_
    ("usage: svnadmin deltify [-r LOWER[:UPPER]] REPOS_PATH\n\n"
     "Run over the requested revision range, performing predecessor delti-\n"
@@ -1564,22 +1576,32 @@ subcommand_rmtxns(apr_getopt_t *os, void
 
 /* A helper for the 'setrevprop' and 'setlog' commands.  Expects
    OPT_STATE->use_pre_revprop_change_hook and
-   OPT_STATE->use_post_revprop_change_hook to be set appropriately. */
+   OPT_STATE->use_post_revprop_change_hook to be set appropriately.
+   If FILENAME is NULL, delete property PROP_NAME.  */
 static svn_error_t *
 set_revprop(const char *prop_name, const char *filename,
             struct svnadmin_opt_state *opt_state, apr_pool_t *pool)
 {
   svn_repos_t *repos;
-  svn_string_t *prop_value = svn_string_create_empty(pool);
-  svn_stringbuf_t *file_contents;
+  svn_string_t *prop_value;
 
-  SVN_ERR(svn_stringbuf_from_file2(&file_contents, filename, pool));
+  if (filename)
+    {
+      svn_stringbuf_t *file_contents;
 
-  prop_value->data = file_contents->data;
-  prop_value->len = file_contents->len;
+      SVN_ERR(svn_stringbuf_from_file2(&file_contents, filename, pool));
 
-  SVN_ERR(svn_subst_translate_string2(&prop_value, NULL, NULL, prop_value,
-                                      NULL, FALSE, pool, pool));
+      prop_value = svn_string_create_empty(pool);
+      prop_value->data = file_contents->data;
+      prop_value->len = file_contents->len;
+
+      SVN_ERR(svn_subst_translate_string2(&prop_value, NULL, NULL, prop_value,
+                                          NULL, FALSE, pool, pool));
+    }
+  else
+    {
+      prop_value = NULL;
+    }
 
   /* Open the filesystem  */
   SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
@@ -2273,6 +2295,29 @@ subcommand_upgrade(apr_getopt_t *os, voi
 }
 
 
+/* This implements `svn_opt_subcommand_t'. */
+static svn_error_t *
+subcommand_delrevprop(apr_getopt_t *os, void *baton, apr_pool_t *pool)
+{
+  struct svnadmin_opt_state *opt_state = baton;
+  apr_array_header_t *args;
+  const char *prop_name, *filename;
+
+  /* Expect one more argument: NAME */
+  SVN_ERR(parse_args(&args, os, 1, 1, pool));
+  prop_name = APR_ARRAY_IDX(args, 0, const char *);
+
+  if (opt_state->start_revision.kind != svn_opt_revision_number)
+    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                             _("Missing revision"));
+  else if (opt_state->end_revision.kind != svn_opt_revision_unspecified)
+    return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                             _("Only one revision allowed"));
+
+  return set_revprop(prop_name, NULL, opt_state, pool);
+}
+
+
 
 /** Main. **/
 

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1592723&r1=1592722&r2=1592723&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Tue May  6 11:47:40 2014
@@ -599,7 +599,7 @@ def hotcopy_format(sbox):
 #----------------------------------------------------------------------
 
 def setrevprop(sbox):
-  "'setlog' and 'setrevprop', bypassing hooks'"
+  "setlog, setrevprop, delrevprop; bypass hooks"
   sbox.build()
 
   # Try a simple log property modification.
@@ -638,6 +638,14 @@ def setrevprop(sbox):
                                      "--revprop", "-r0", "svn:author",
                                      sbox.wc_dir)
 
+  # Delete the property.
+  svntest.actions.run_and_verify_svnadmin(None, [], [],
+                                          "delrevprop", "-r0", sbox.repo_dir,
+                                          "svn:author")
+  svntest.actions.run_and_verify_svnlook(None, [], ".*E200017.*svn:author.*",
+                                         "propget", "--revprop", "-r0",
+                                         sbox.repo_dir, "svn:author")
+
 def verify_windows_paths_in_repos(sbox):
   "verify a repository containing paths like 'c:hi'"
 

Modified: subversion/trunk/tools/dist/backport_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/backport_tests.py?rev=1592723&r1=1592722&r2=1592723&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport_tests.py (original)
+++ subversion/trunk/tools/dist/backport_tests.py Tue May  6 11:47:40 2014
@@ -196,9 +196,8 @@ def verify_backport(sbox, expected_dump_
   # mirror repository in preparation for the comparison dump.
   svntest.actions.enable_revprop_changes(sbox.repo_dir)
   for revnum in range(0, 1+int(sbox.youngest())):
-    # TODO: there is no 'svnadmin delrevprop' command.
-    svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [],
-      "propdel", "--revprop", "-r", revnum, "svn:date", sbox.repo_url)
+    svntest.actions.run_and_verify_svnadmin(None, [], [],
+      "delrevprop", "-r", revnum, sbox.repo_dir, "svn:date")
 
   # Create a dump file from the mirror repository.
   dest_dump = open(expected_dump_file).readlines()