[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] issue 2640 - $Author:$ is not considered an expanded form

From: Lieven Govaerts <lgo_at_mobsol.be>
Date: 2006-10-25 00:08:36 CEST

Hi,

attached is a patch for issue 2640. The issue is about keywords like
$Author:$ that don't have a space between ':' and '$'. Subversion
currently considers $Author:$ to be unexpanded, which can give some
weird diff results (as shown in the issue).

This behavior is apparently intended, as it was added explicitly in
r4271. Looking at the log message, the reasoning appears to be:
a. it has to be either expanded or unexpanded, not something undefined.
b. RCS considers $Author:$ an unexpanded form, so let's do the same thing.

I had a discussion with Erik on IRC about this, and to both of us it
seemed more correct to change current behavior. What do other people
think about this?

Lieven.

[[[
Fix for issue 2640. The patch basically reverts r4271, and adds the
'$Keyword:$ is considered an expanded form' behavior.

* subversion/libsvn_subr/subst.c
  (translate_keyword_subst): consider $keyword:$ expanded instead of
   unexpanded.

* subversion/tests/libsvn_subr/translate-test.c
  (lines): change the testcase in line 46 to this new behavior.
  (substitute_and_verify): add the new expected behavior for $keyword:$
   and remove the old one.
]]]

Index: subversion/libsvn_subr/subst.c
===================================================================
--- subversion/libsvn_subr/subst.c (revision 22106)
+++ subversion/libsvn_subr/subst.c (working copy)
@@ -529,9 +529,7 @@
     }
 
   /* Check for unexpanded keyword. */
- else if ((buf_ptr[0] == '$') /* "$keyword$" */
- || ((buf_ptr[0] == ':')
- && (buf_ptr[1] == '$'))) /* "$keyword:$" */
+ else if (buf_ptr[0] == '$') /* "$keyword$" */
     {
       /* unexpanded... */
       if (value)
@@ -566,10 +564,13 @@
     }
 
   /* Check for expanded keyword. */
- else if ((*len >= 4 + keyword_len ) /* holds at least "$keyword: $" */
- && (buf_ptr[0] == ':') /* first char after keyword is ':' */
- && (buf_ptr[1] == ' ') /* second char after keyword is ' ' */
- && (buf[*len - 2] == ' ')) /* has ' ' for next to last character */
+ else if (((*len >= 4 + keyword_len ) /* holds at least "$keyword: $" */
+ && (buf_ptr[0] == ':') /* first char after keyword is ':' */
+ && (buf_ptr[1] == ' ') /* second char after keyword is ' ' */
+ && (buf[*len - 2] == ' '))
+ || ((*len >= 3 + keyword_len ) /* holds at least "$keyword:$" */
+ && (buf_ptr[0] == ':') /* first char after keyword is ':' */
+ && (buf_ptr[1] == '$'))) /* second char after keyword is '$' */
     {
       /* expanded... */
       if (! value)
Index: subversion/tests/libsvn_subr/translate-test.c
===================================================================
--- subversion/tests/libsvn_subr/translate-test.c (revision 22106)
+++ subversion/tests/libsvn_subr/translate-test.c (working copy)
@@ -92,7 +92,7 @@
     "Line 43: fairly boring subst test data... blah blah.",
     "Line 44: fairly boring subst test data... blah blah.",
     "Line 45: Invalid $LastChangedRevisionWithSuffix$, started unexpanded.",
- "Line 46: Valid $Rev:$ is missing a space.",
+ "Line 46: Empty $Author:$, started expanded.",
     "Line 47: fairly boring subst test data... blah blah.",
     "Line 48: Two keywords back to back: $Author$$Rev$.",
     "Line 49: One keyword, one not, back to back: $Author$Rev$.",
@@ -516,6 +516,10 @@
             apr_pstrcat(pool, "Line 38: ",
                         "Valid $Author: ", author, " $, started expanded.",
                         NULL);
+ expect[46 - 1] =
+ apr_pstrcat(pool, "Line 46: ",
+ "Empty $Author: ", author, " $, started expanded.",
+ NULL);
           expect[71 - 1] =
             apr_pstrcat(pool, ".$veR$Author: ", author, " $", NULL);
 
@@ -547,6 +551,8 @@
             "Line 37: Valid $LastChangedBy$, started expanded.";
           expect[38 - 1] =
             "Line 38: Valid $Author$, started expanded.";
+ expect[46 - 1] =
+ "Line 46: Empty $Author$, started expanded.";
           expect[74 - 1] =
             "Line 74: Valid $Author$, started expanded.";
           expect[79 - 1] =
@@ -597,17 +603,6 @@
         }
     }
 
- if (rev)
- {
- if (expand)
- {
- expect[46 - 1] =
- apr_pstrcat(pool, "Line 46: ", "Valid $Rev: ", rev,
- " $ is missing a space.", NULL);
- }
- /* Else Line 46 remains unchanged. */
- }
-
   /* Handle lines 48, 49, and 70 specially, as they contains two valid
      keywords. */
   if (rev && author)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Oct 25 00:08:55 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.