Blame SOURCES/cvs-1.11.23-Back-port-KeywordExpand-configuration-keyword.patch

814382
From fe7182d15c93f46212781106b4b63503fcec713f Mon Sep 17 00:00:00 2001
814382
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
814382
Date: Tue, 15 Mar 2011 14:44:17 +0100
814382
Subject: [PATCH] Back-port KeywordExpand configuration keyword
814382
814382
This is based on code from developemnt 1.12 branch.
814382
---
814382
 doc/cvs.texinfo |   93 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
814382
 src/mkmodules.c |    5 +++
814382
 src/parseinfo.c |    4 ++
814382
 src/rcs.c       |   51 ++++++++++++++++++++++++++++--
814382
 src/rcs.h       |    1 +
814382
 5 files changed, 146 insertions(+), 8 deletions(-)
814382
814382
diff --git a/doc/cvs.texinfo b/doc/cvs.texinfo
814382
index ad3a414..943af37 100644
814382
--- a/doc/cvs.texinfo
814382
+++ b/doc/cvs.texinfo
814382
@@ -6847,11 +6847,12 @@ with strings of the form
814382
 a new revision of the file.
814382
 
814382
 @menu
814382
-* Keyword list::                Keywords
814382
-* Using keywords::              Using keywords
814382
-* Avoiding substitution::       Avoiding substitution
814382
-* Substitution modes::          Substitution modes
814382
-* Log keyword::                 Problems with the $@splitrcskeyword{Log}$ keyword.
814382
+* Keyword list::                   Keywords
814382
+* Using keywords::                 Using keywords
814382
+* Avoiding substitution::          Avoiding substitution
814382
+* Substitution modes::             Substitution modes
814382
+* Configuring keyword expansion::  Configuring keyword expansion
814382
+* Log keyword::                    Problems with the $@splitrcskeyword{Log}$ keyword.
814382
 @end menu
814382
 
814382
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
814382
@@ -7032,6 +7033,12 @@ contains @samp{$@@asis@{@}Author$} whenever the text
814382
 and @code{troff} you can embed the null-character
814382
 @code{\&} inside the keyword for a similar effect.
814382
 
814382
+It is also possible to specify an explicit list of
814382
+keywords to include or exclude using the
814382
+@code{KeywordExpand} option in the
814382
+@file{CVSROOT/config} file--see @ref{Configuring keyword expansion}
814382
+for more details.
814382
+
814382
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
814382
 @node Substitution modes
814382
 @section Substitution modes
814382
@@ -7124,6 +7131,74 @@ handle an export containing binary files correctly.
814382
 @end table
814382
 
814382
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
814382
+@node Configuring keyword expansion
814382
+@section Configuring Keyword Expansion
814382
+@cindex Configuring keyword expansion
814382
+
814382
+The @code{KeywordExpand} option in the
814382
+@file{CVSROOT/config} file is intended to allow for the
814382
+either the explicit exclusion of a keyword or list of
814382
+keywords, or for the explicit inclusion of a keyword or
814382
+a list of keywords.
814382
+
814382
+The @code{KeywordExpand} option is followed by
814382
+@code{=} and the next character may either be @code{i}
814382
+to start an inclusion list or @code{e} to start an
814382
+exclusion list. If the following lines were added to
814382
+the @file{CVSROOT/config} file:
814382
+
814382
+@example
814382
+        # Restrict keyword expansion to "Log" only
814382
+        KeywordExpand=iLog
814382
+@end example
814382
+
814382
+then only the $@splitrcskeyword{Log}$ keyword would be expanded.
814382
+A list may be used. The this example:
814382
+
814382
+@example
814382
+        # Restrict keyword expansion to the Name and Date keywords.
814382
+        KeywordExpand=iName,Date
814382
+@end example
814382
+
814382
+would allow $@splitrcskeyword{Name}$, and $@splitrcskeyword{Date}$
814382
+to be expanded.
814382
+
814382
+It is also possible to configure an exclusion list
814382
+using the following:
814382
+
814382
+@example
814382
+        # Do not expand the keyword Date
814382
+        KeywordExpand=eDate
814382
+@end example
814382
+
814382
+This allows @sc{cvs} to ignore the 
814382
+$@splitrcskeyword{CVSHeader}$ keyword and retain all of the
814382
+others. This could be confusing
814382
+to users that expect RCS keywords to be expanded, so
814382
+care should be taken to properly set user expectations
814382
+for a repository that is configured in that manner.
814382
+
814382
+If there is a desire to not have any RCS keywords
814382
+expanded and not use the @code{-ko} flags everywhere,
814382
+an administrator may disable all keyword expansion
814382
+using the @file{CVSROOT/config} line:
814382
+
814382
+@example
814382
+    # Do not expand any RCS keywords
814382
+    KeywordExpand=i
814382
+@end example
814382
+
814382
+this could be confusing to users that expect RCS
814382
+keywords like $@splitrcskeyword{Id}$ to be expanded properly,
814382
+so care should be taken to properly set user
814382
+expectations for a repository so configured.
814382
+
814382
+It should be noted that a patch to provide the
814382
+@code{KeywordExpand} feature has been around a long time.
814382
+However, that patch implemented this feature using
814382
+@code{tagexpand=} keyword and this keyword is NOT recognized.
814382
+
814382
+@c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
814382
 @node Log keyword
814382
 @section Problems with the $@splitrcskeyword{Log}$ keyword.
814382
 
814382
@@ -13789,6 +13864,14 @@ each command.  It also provides a place for the
814382
 @file{CVS/Template} file (@pxref{Working directory
814382
 storage}).
814382
 
814382
+@cindex KeywordExpand, in @file{CVSROOT/config}
814382
+@item KeywordExpand=@var{value}
814382
+Specify @samp{i} followed by a list of keywords to be expanded
814382
+(for example, @samp{KeywordExpand=iName,Date}),
814382
+or @samp{e} followed by a list of keywords not to be expanded
814382
+(for example, @samp{KeywordExpand=eName}).
814382
+For more on keyword expansion, see @ref{Configuring keyword expansion}.
814382
+
814382
 @cindex LockDir, in CVSROOT/config
814382
 @item LockDir=@var{directory}
814382
 Put @sc{cvs} lock files in @var{directory} rather than
814382
diff --git a/src/mkmodules.c b/src/mkmodules.c
814382
index 4bb9d74..3be9509 100644
814382
--- a/src/mkmodules.c
814382
+++ b/src/mkmodules.c
814382
@@ -300,6 +300,11 @@ static const char *const config_contents[] = {
814382
     "# primary CVS repository.\n",
814382
     "#IgnoreUnknownConfigKeys=no\n",
814382
     "\n",
814382
+    "# Set `KeywordExpand' to `i' followed by a list of keywords to expand or\n",
814382
+    "# `e' followed by a list of keywords to not expand.\n"
814382
+    "#KeywordExpand=iName,Date\n",
814382
+    "#KeywordExpand=eName\n",
814382
+    "\n",
814382
     "# Put CVS lock files in this directory rather than directly in the repository.\n",
814382
     "#LockDir=/var/lock/cvs\n",
814382
     "\n",
814382
diff --git a/src/parseinfo.c b/src/parseinfo.c
814382
index 86fc6d6..477740a 100644
814382
--- a/src/parseinfo.c
814382
+++ b/src/parseinfo.c
814382
@@ -360,6 +360,10 @@ parse_config (cvsroot)
814382
 		goto error_return;
814382
 	    }
814382
 	}
814382
+	else if (strcmp (line, "KeywordExpand") == 0)
814382
+	{
814382
+	    RCS_setincexc (p);
814382
+	}
814382
 	else if (strcmp (line, "PreservePermissions") == 0)
814382
 	{
814382
 	    if (strcmp (p, "no") == 0)
814382
diff --git a/src/rcs.c b/src/rcs.c
814382
index 20c3162..ba255ce 100644
814382
--- a/src/rcs.c
814382
+++ b/src/rcs.c
814382
@@ -15,6 +15,7 @@
814382
  */
814382
 
814382
 #include <assert.h>
814382
+#include <stdbool.h>
814382
 #include "cvs.h"
814382
 #include "edit.h"
814382
 #include "hardlink.h"
814382
@@ -3509,9 +3510,10 @@ struct rcs_keyword
814382
 {
814382
     const char *string;
814382
     size_t len;
814382
+    bool expandit;
814382
 };
814382
-#define KEYWORD_INIT(s) (s), sizeof (s) - 1
814382
-static const struct rcs_keyword keywords[] =
814382
+#define KEYWORD_INIT(s) (s), sizeof (s) - 1, true
814382
+static struct rcs_keyword keywords[] =
814382
 {
814382
     { KEYWORD_INIT ("Author") },
814382
     { KEYWORD_INIT ("Date") },
814382
@@ -3717,7 +3719,8 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen)
814382
 	slen = s - srch;
814382
 	for (keyword = keywords; keyword->string != NULL; keyword++)
814382
 	{
814382
-	    if (keyword->len == slen
814382
+	    if (keyword->expandit
814382
+		&& keyword->len == slen
814382
 		&& strncmp (keyword->string, srch, slen) == 0)
814382
 	    {
814382
 		break;
814382
@@ -8958,3 +8961,45 @@ make_file_label (path, rev, rcs)
814382
     }
814382
     return label;
814382
 }
814382
+
814382
+
814382
+
814382
+void
814382
+RCS_setincexc (const char *arg)
814382
+{
814382
+    char *key;
814382
+    char *copy, *next;
814382
+    bool include = false;
814382
+    struct rcs_keyword *keyword;
814382
+
814382
+    copy = xstrdup(arg);
814382
+    next = copy;
814382
+    switch (*next++) {
814382
+	case 'e':
814382
+	    include = false;
814382
+	    break;
814382
+	case 'i':
814382
+	    include = true;
814382
+	    break;
814382
+	default:
814382
+	    free(copy);
814382
+	    return;
814382
+    }
814382
+
814382
+    if (include)
814382
+	for (keyword = keywords; keyword->string != NULL; keyword++)
814382
+	{
814382
+	    keyword->expandit = false;
814382
+	}
814382
+
814382
+    key = strtok(next, ",");
814382
+    while (key) {
814382
+	for (keyword = keywords; keyword->string != NULL; keyword++) {
814382
+	    if (strcmp (keyword->string, key) == 0)
814382
+		keyword->expandit = include;
814382
+	}
814382
+	key = strtok(NULL, ",");
814382
+    }
814382
+    free(copy);
814382
+    return;
814382
+}
814382
diff --git a/src/rcs.h b/src/rcs.h
814382
index 3a66640..2126029 100644
814382
--- a/src/rcs.h
814382
+++ b/src/rcs.h
814382
@@ -250,6 +250,7 @@ int rcs_change_text PROTO ((const char *, char *, size_t, const char *,
814382
 void RCS_deltas PROTO ((RCSNode *, FILE *, struct rcsbuffer *, const char *,
814382
 			enum rcs_delta_op, char **, size_t *,
814382
 			char **, size_t *));
814382
+void RCS_setincexc (const char *arg);
814382
 char *make_file_label PROTO ((const char *, const char *, RCSNode *));
814382
 
814382
 extern int preserve_perms;
814382
-- 
814382
1.7.4
814382