You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/11/24 19:32:10 UTC

svn commit: r1413231 - in /subversion/trunk/subversion: svn/props.c tests/cmdline/prop_tests.py

Author: brane
Date: Sat Nov 24 18:32:09 2012
New Revision: 1413231

URL: http://svn.apache.org/viewvc?rev=1413231&view=rev
Log:
Improve error message related to unknown svn: properties.

* subversion/svn/props.c (svn_cl__check_svn_prop_name):
   Only suggest alternate spelling if the given property name is
   similar enough to one of the known ones. Will now suggest from none
   up to three alternatives.
  Also remove all debugging code.

* subversion/tests/cmdline/prop_tests.py (almost_known_prop_names):
   Verify that a different enough property name does not trigger
   alternate spelling suggestions.

Modified:
    subversion/trunk/subversion/svn/props.c
    subversion/trunk/subversion/tests/cmdline/prop_tests.py

Modified: subversion/trunk/subversion/svn/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/props.c?rev=1413231&r1=1413230&r2=1413231&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/props.c (original)
+++ subversion/trunk/subversion/svn/props.c Sat Nov 24 18:32:09 2012
@@ -46,10 +46,6 @@
 #include "private/svn_cmdline_private.h"
 
 #include "svn_private_config.h"
-
-#ifdef SVN_DEBUG                /* ### FIXME: remove this bit */
-#include "private/svn_debug.h"
-#endif
 
 
 svn_error_t *
@@ -372,20 +368,48 @@ svn_cl__check_svn_prop_name(const char *
   if (0 == propkeys[0]->diff)
     return SVN_NO_ERROR;        /* We found an exact match. */
 
-  /* ### FIXME: remove this bit
-#ifdef SVN_DEBUG
+  /* See if we can suggest a sane alternative spelling */
   for (i = 0; i < numprops; ++i)
-    SVN_DBG(("score: %.3f diff: %2"APR_SIZE_T_FMT"   %s\n",
-             propkeys[i]->score/1000.0,
-             propkeys[i]->diff,
-             propkeys[i]->propname));
-#endif
-  */
-
-  /* ### suggest a list of the most likely candidates instead? */
-  return svn_error_createf(
-    SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
-    _("'%s' is not a valid %s property name; did you mean '%s'?\n"
-      "(To set the '%s' property, re-run with '--force'.)"),
-      propname, SVN_PROP_PREFIX, propkeys[0]->propname, propname);
+    if (propkeys[i]->score < 666) /* 2/3 similarity required */
+      break;
+
+  switch (i)
+    {
+    case 0:
+      /* The best alternative isn't good enough */
+      return svn_error_createf(
+        SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
+        _("'%s' is not a valid %s property name;"
+          " re-run with '--force' to set it"),
+        propname, SVN_PROP_PREFIX);
+
+    case 1:
+      /* There is only one good candidate */
+      return svn_error_createf(
+        SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
+        _("'%s' is not a valid %s property name; did you mean '%s'?\n"
+          "(To set the '%s' property, re-run with '--force'.)"),
+        propname, SVN_PROP_PREFIX, propkeys[0]->propname, propname);
+
+    case 2:
+      /* Suggest a list of the most likely candidates */
+      return svn_error_createf(
+        SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
+        _("'%s' is not a valid %s property name\n"
+          "Did you mean '%s' or '%s'?\n"
+          "(To set the '%s' property, re-run with '--force'.)"),
+        propname, SVN_PROP_PREFIX,
+        propkeys[0]->propname, propkeys[1]->propname, propname);
+
+    default:
+      /* Never suggest more than three candidates */
+      return svn_error_createf(
+        SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
+        _("'%s' is not a valid %s property name\n"
+          "Did you mean '%s', '%s' or '%s'?\n"
+          "(To set the '%s' property, re-run with '--force'.)"),
+        propname, SVN_PROP_PREFIX,
+        propkeys[0]->propname, propkeys[1]->propname, propkeys[2]->propname,
+        propname);
+    }
 }

Modified: subversion/trunk/subversion/tests/cmdline/prop_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/prop_tests.py?rev=1413231&r1=1413230&r2=1413231&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/prop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/prop_tests.py Sat Nov 24 18:32:09 2012
@@ -2695,6 +2695,12 @@ def almost_known_prop_names(sbox):
   # Different prefix, same prop name
   svntest.actions.set_prop('tsvn:executable', 'x', iota_path)
 
+  # Property name is too different to matter
+  svntest.actions.set_prop('svn:foobar', 'x', iota_path,
+                           "svn: E195011: 'svn:foobar'"
+                           " is not a valid svn: property name;"
+                           " re-run with '--force' to set it")
+
 ########################################################################
 # Run the tests