Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Mar 2003 18:15:32 +0300 (MSK)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        Tony Finch <dot@dotat.at>
Cc:        hackers@freebsd.org
Subject:   Re: FreeBSD-specific CVS: tagexpand question 
Message-ID:  <20030313180755.Y46614@woozle.rinet.ru>
In-Reply-To: <E18tUEU-0001R8-00@chiark.greenend.org.uk>
References:  <E18tUEU-0001R8-00@chiark.greenend.org.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 13 Mar 2003, Tony Finch wrote:

TF> >Is there any way to tune FreeBSD-specific CVS (with CVSROOT/options support) to
TF> >provide the following functionality:
TF> >- ident keyword should be standard ($ Id $)
TF> >- it should be expanded as ($ CVSHeader $) to repo-relative path
TF>
TF> Why do you want to do that? It seems like a bad idea to me -- you should
TF> keep the semantics of CVS keywords constant, and you should keep per-
TF> project keywords as distinctive as possible to avoid clashes as source
TF> moves around.

Well, AFAIThink the semantics do not change -- just extends a bit, and
thus allow to be extensively checked for example by FreeBSD-styled CVSROOT
scripts like commit_prep.pl

BTW, I've written a little patch to CVS similar to peter's patches: it adds
idexpmode options to CVSROOT/options -- attached just in case anyone
interested.

Sincerely,
D.Marck                                   [DM5020, DM268-RIPE, DM3-RIPN]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
------------------------------------------------------------------------



# $Id: FreeBSD/Patches/cvs-idexpmode.patch,v 1.1 2003/03/13 12:53:15 marck Exp $
#
#-DSC-#	idexpmode option for CVS

This patch adds new option for cvs. You can specify idexpmode=<MODE>
in CVSROOT/options admin file to select $ Id $ RCS keyword expansion mode.

MODE may be on of the following:

	Id		last path component; default
	Header		full path including repository root
	CVSHeader	path relative to repository root

Index: contrib/cvs/src/main.c
===================================================================
RCS file: /home/ncvs/src/contrib/cvs/src/main.c,v
retrieving revision 1.18.2.4
diff -u -r1.18.2.4 main.c
--- contrib/cvs/src/main.c	19 Dec 2002 21:17:56 -0000	1.18.2.4
+++ contrib/cvs/src/main.c	13 Mar 2003 12:26:14 -0000
@@ -1244,6 +1244,12 @@
 		rcs_incexc = buf + 10;
 		RCS_setincexc(rcs_incexc);
 	    }
+	    if (!strncmp(buf, "idexpmode=", 10)) {
+		char *rcs_idexpmode;
+
+		rcs_idexpmode = buf + 10;
+		RCS_setidexpmode(rcs_idexpmode);
+	    }
 	    /*
 	     * OpenBSD has a "umask=" and "dlimit=" command, we silently
 	     * ignore them here since they are not much use to us.  cvsumask
Index: contrib/cvs/src/rcs.c
===================================================================
RCS file: /home/ncvs/src/contrib/cvs/src/rcs.c,v
retrieving revision 1.19.2.5
diff -u -r1.19.2.5 rcs.c
--- contrib/cvs/src/rcs.c	21 Jan 2003 22:26:44 -0000	1.19.2.5
+++ contrib/cvs/src/rcs.c	13 Mar 2003 12:26:14 -0000
@@ -3519,6 +3519,7 @@
     KEYWORD_LOCALID
 };
 enum keyword keyword_local = KEYWORD_ID;
+enum keyword keyword_idexmode = KEYWORD_ID;

 /* Convert an RCS date string into a readable string.  This is like
    the RCS date2str function.  */
@@ -3757,11 +3758,15 @@
 		    old_path = NULL;
 		    if (kw == KEYWORD_HEADER ||
 			    (kw == KEYWORD_LOCALID &&
-			     keyword_local == KEYWORD_HEADER))
+			     keyword_local == KEYWORD_HEADER) ||
+			    (kw == KEYWORD_ID &&
+			     keyword_idexmode == KEYWORD_HEADER))
 			path = rcs->path;
 		    else if (kw == KEYWORD_CVSHEADER ||
 			     (kw == KEYWORD_LOCALID &&
-			      keyword_local == KEYWORD_CVSHEADER))
+			      keyword_local == KEYWORD_CVSHEADER) ||
+			     (kw == KEYWORD_ID &&
+			      keyword_idexmode == KEYWORD_CVSHEADER))
 			path = getfullCVSname(rcs->path, &old_path);
 		    else
 			path = last_component (rcs->path);
@@ -8627,6 +8632,25 @@
 	    error(1, 0, "Unknown LocalId mode: %s", key);
     }
     free(copy);
+}
+
+void
+RCS_setidexpmode (arg)
+    const char *arg;
+{
+    char *key;
+
+    key = xstrdup(arg);
+    if (!strcmp(key, keywords[KEYWORD_ID].string))
+	keyword_idexmode = KEYWORD_ID;
+    else if (!strcmp(key, keywords[KEYWORD_HEADER].string))
+	keyword_idexmode = KEYWORD_HEADER;
+    else if (!strcmp(key, keywords[KEYWORD_CVSHEADER].string))
+	keyword_idexmode = KEYWORD_CVSHEADER;
+    else
+	error(1, 0, "Unknown id expand mode: %s", key);
+
+    free(key);
 }

 void
Index: contrib/cvs/src/rcs.h
===================================================================
RCS file: /home/ncvs/src/contrib/cvs/src/rcs.h,v
retrieving revision 1.7.2.4
diff -u -r1.7.2.4 rcs.h
--- contrib/cvs/src/rcs.h	19 Dec 2002 21:17:56 -0000	1.7.2.4
+++ contrib/cvs/src/rcs.h	13 Mar 2003 12:26:14 -0000
@@ -243,6 +243,7 @@
 			enum rcs_delta_op, char **, size_t *,
 			char **, size_t *));
 void RCS_setincexc PROTO ((const char *arg));
+void RCS_setidexpmode PROTO ((const char *arg));
 void RCS_setlocalid PROTO ((const char *arg));
 char *make_file_label PROTO ((char *, char *, RCSNode *));


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030313180755.Y46614>