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 12:52:36 UTC

svn commit: r1413178 - /subversion/trunk/subversion/svn/props.c

Author: brane
Date: Sat Nov 24 11:52:35 2012
New Revision: 1413178

URL: http://svn.apache.org/viewvc?rev=1413178&view=rev
Log:
Increase the resolution of the similarity scores when checking
property names by not looking at the prefix which we've already
checked.

* subversion/svn/props.c: Add some debugging code, to be removed.
  (simprop_context_t): Update comments.
  (simprop_t): New member propname; update comments.
  (svn_cl__check_svn_prop_name): When initializing the property
   buffers for similarity checking, skip the svn: prefix.
   Add some temporary debugging code.

Modified:
    subversion/trunk/subversion/svn/props.c

Modified: subversion/trunk/subversion/svn/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/props.c?rev=1413178&r1=1413177&r2=1413178&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/props.c (original)
+++ subversion/trunk/subversion/svn/props.c Sat Nov 24 11:52:35 2012
@@ -47,6 +47,9 @@
 
 #include "svn_private_config.h"
 
+#ifdef SVN_DEBUG                /* ### FIXME: remove this bit */
+#include "private/svn_debug.h"
+#endif
 
 
 svn_error_t *
@@ -230,16 +233,17 @@ svn_cl__check_boolean_prop_val(const cha
 /* Context for sorting property names */
 struct simprop_context_t
 {
-  svn_string_t name;      /* The name of the property we're checking against */
-  svn_membuf_t buffer;    /* Buffer for similariry testing */
+  svn_string_t name;    /* The name of the property we're comparing with */
+  svn_membuf_t buffer;  /* Buffer for similariry testing */
 };
 
 struct simprop_t
 {
-  svn_string_t name;      /* svn: property name */
-  unsigned int score;     /* the similarity score */
-  apr_size_t diff;        /* number of chars different from context.name */
-  struct simprop_context_t *context; /* sorting context for qsort() */
+  const char *propname; /* The original svn: property name */
+  svn_string_t name;    /* The property name without the svn: prefx */
+  unsigned int score;   /* The similarity score */
+  apr_size_t diff;      /* Number of chars different from context.name */
+  struct simprop_context_t *context; /* Sorting context for qsort() */
 };
 
 /* Similarity test between two property names */
@@ -344,16 +348,21 @@ svn_cl__check_svn_prop_name(const char *
     }
 
   /* Now find the closest match from amongst a the set of reserved
-     node or revision property names. */
+     node or revision property names. Skip the prefix while matching,
+     we already know that it's the same and looking at it would only
+     skew the results. */
   propkeys = apr_palloc(scratch_pool,
                         numprops * sizeof(struct simprop_t*));
   propbuf = apr_palloc(scratch_pool,
                        numprops * sizeof(struct simprop_t));
+  context.name.data += prefix.len;
+  context.name.len -= prefix.len;
   for (i = 0; i < numprops; ++i)
     {
       propkeys[i] = &propbuf[i];
-      propbuf[i].name.data = proplist[i];
-      propbuf[i].name.len = strlen(proplist[i]);
+      propbuf[i].propname = proplist[i];
+      propbuf[i].name.data = proplist[i] + prefix.len;
+      propbuf[i].name.len = strlen(propbuf[i].name.data);
       propbuf[i].score = (unsigned int)-1;
       propbuf[i].context = &context;
     }
@@ -363,10 +372,20 @@ 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
+  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]->name.data, propname);
+      propname, SVN_PROP_PREFIX, propkeys[0]->propname, propname);
 }