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 2013/04/10 20:00:21 UTC

svn commit: r1466598 - in /subversion/trunk/subversion: include/svn_subst.h libsvn_subr/subst.c svn/svn.c tests/libsvn_subr/subst_translate-test.c

Author: stsp
Date: Wed Apr 10 18:00:21 2013
New Revision: 1466598

URL: http://svn.apache.org/r1466598
Log:
Add two additional custom keyword format codes which are used by FreeBSD.

   %H   - Equivalent to %P%_%r%_%d%_%a.
   %I   - Equivalent to %b%_%r%_%d%_%a.

With this, keyword expansion works as expected with svn.freebsd.org using
a stock Subversion client, rather than requiring a patched client.

These two codes are already in use at svn.freebsd.org and were part of the
originally submitted patch. I'd rather add support for these format codes
to Subversion than require FreeBSD to change its svn:keywords properties
throughout their repository history.

But I'm not sure whether adding additional alias format codes is a good
idea in general, so please don't regard this as a carte blanche for
everyone else to get their favorite format code aliases into the
Subversion code base.

* subversion/include/svn_subst.h
  (svn_subst_build_keywords3): Document support for %H and %I format codes.

* subversion/libsvn_subr/subst.c
  (keyword_printf): Implement support for %H and %I format codes.

* subversion/svn/svn.c
  (svn_cl__cmd_table): Document support for %H and %I in 'svn help propset'.

* subversion/tests/libsvn_subr/subst_translate-test.c
  (test_svn_subst_build_keywords3): Expand test to cover %H and %I.

Modified:
    subversion/trunk/subversion/include/svn_subst.h
    subversion/trunk/subversion/libsvn_subr/subst.c
    subversion/trunk/subversion/svn/svn.c
    subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c

Modified: subversion/trunk/subversion/include/svn_subst.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_subst.h?rev=1466598&r1=1466597&r2=1466598&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_subst.h (original)
+++ subversion/trunk/subversion/include/svn_subst.h Wed Apr 10 18:00:21 2013
@@ -143,6 +143,9 @@ typedef struct svn_subst_keywords_t
  *   %u   - The URL of the file.
  *   %_   - A space (keyword definitions cannot contain a literal space).
  *   %%   - A literal '%'.
+ *   %H   - Equivalent to %P%_%r%_%d%_%a.
+ *   %I   - Equivalent to %b%_%r%_%d%_%a.
+ *
  * Custom keywords are defined by appending '=' to the keyword name, followed
  * by a string containing any combination of the format substitutions.
  *

Modified: subversion/trunk/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/subst.c?rev=1466598&r1=1466597&r2=1466598&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/subst.c (original)
+++ subversion/trunk/subversion/libsvn_subr/subst.c Wed Apr 10 18:00:21 2013
@@ -143,6 +143,10 @@ svn_subst_translation_required(svn_subst
  * %_ a space
  * %% a literal %
  *
+ * The following special format codes are also recognized:
+ *   %H is equivalent to %P%_%r%_%d%_%a
+ *   %I is equivalent to %b%_%r%_%d%_%a
+ *
  * All memory is allocated out of @a pool.
  */
 static svn_string_t *
@@ -244,6 +248,22 @@ keyword_printf(const char *fmt,
            * formatting random memory contents. */
           cur--;
           break;
+        case 'H':
+          {
+            svn_string_t *s = keyword_printf("%P%_%r%_%d%_%a", rev, url,
+                                             repos_root_url, date, author,
+                                             pool);
+            svn_stringbuf_appendcstr(value, s->data);
+          }
+          break;
+        case 'I':
+          {
+            svn_string_t *s = keyword_printf("%b%_%r%_%d%_%a", rev, url,
+                                             repos_root_url, date, author,
+                                             pool);
+            svn_stringbuf_appendcstr(value, s->data);
+          }
+          break;
         default: /* Unrecognized code, just print it literally. */
           svn_stringbuf_appendbytes(value, cur, 2);
           break;

Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1466598&r1=1466597&r2=1466598&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Wed Apr 10 18:00:21 2013
@@ -1294,6 +1294,8 @@ const svn_opt_subcommand_desc2_t svn_cl_
      "        %u   - The URL of the file.\n"
      "        %_   - A space (keyword definitions cannot contain a literal space).\n"
      "        %%   - A literal '%'.\n"
+     "        %H   - Equivalent to %P%_%r%_%d%_%a.\n"
+     "        %I   - Equivalent to %b%_%r%_%d%_%a.\n"
      "      Example custom keyword definition: MyKeyword=%r%_%a%_%P\n"
      "      Once a custom keyword has been defined for a file, it can be used\n"
      "      within the file like any other keyword: $MyKeyword$\n"

Modified: subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c?rev=1466598&r1=1466597&r2=1466598&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c Wed Apr 10 18:00:21 2013
@@ -273,6 +273,14 @@ test_svn_subst_build_keywords3(apr_pool_
        "4567 http://svn.example.com/svn/branches/myfile  jrandom",
        "4567", "http://svn.example.com/svn/branches/myfile",
        "http://svn.example.com/svn", "jrandom"},
+      {"FreeBSD", "FreeBSD=%H",
+       "head/README 222812  joel", /* date is not expanded in this test */
+       "222812", "http://svn.freebsd.org/base/head/README",
+       "http://svn.freebsd.org/base", "joel"},
+      {"FreeBSD", "FreeBSD=%I",
+       "README 222812  joel", /* date is not expanded in this test */
+       "222812", "http://svn.freebsd.org/base/head/README",
+       "http://svn.freebsd.org/base", "joel"},
       { NULL, NULL, NULL, NULL, NULL, NULL, NULL}
   };