[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Resend importinfo patch
From: |
Wu Yongwei |
Subject: |
Resend importinfo patch |
Date: |
Sun, 28 Sep 2003 11:51:27 +0800 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) |
Why this feature:
http://mail.gnu.org/archive/html/info-cvs/2003-07/msg00144.html
This patch passes `make check', but no checking code for the new code is
added to src/sanity.sh. So it is still an `incomplete' patch. But I
still send it here because:
1) I really want to see this patch incorporated into mainstrean CVS;
2) I have no time to dig into the sanity-check program, nor did I even
find an example of say, commitinfo; :-(
3) Though the author Ralf Engelschall said he would make the patch
himself, it seems he has no time, and I have not been able to contact
him directly because his email system has so heavy an anti-spam system
that none of the SMTP servers I use was able to send email to him.
This patch is against the current CVS of CVS. :-)
Would someone add the test code, or is it not necessary because scripts
like commitinfo has no test code either (or I missed important things)?
I have also patched a v1.11.6 CVS on our company CVS server. It has
been running very well.
Best regards,
Wu Yongwei
Index: src/cvs.h
===================================================================
RCS file: /cvs/ccvs/src/cvs.h,v
retrieving revision 1.270
diff -u -p -r1.270 cvs.h
--- src/cvs.h 29 Aug 2003 19:00:12 -0000 1.270
+++ src/cvs.h 28 Sep 2003 03:32:43 -0000
@@ -166,6 +166,7 @@ char *strerror (int);
#define CVSROOTADM_WRITERS "writers"
#define CVSROOTADM_PASSWD "passwd"
#define CVSROOTADM_CONFIG "config"
+#define CVSROOTADM_IMPORTINFO "importinfo"
#define CVSNULLREPOS "Emptydir" /* an empty directory */
Index: src/import.c
===================================================================
RCS file: /cvs/ccvs/src/import.c,v
retrieving revision 1.139
diff -u -p -r1.139 import.c
--- src/import.c 19 Aug 2003 13:35:15 -0000 1.139
+++ src/import.c 28 Sep 2003 03:32:44 -0000
@@ -56,6 +56,138 @@ static const char *const import_usage[]
NULL
};
+static char *importinfo_vtag;
+
+static int
+importinfo_descend(thisdir)
+ char *thisdir;
+{
+ DIR *dirp;
+ struct dirent *dp;
+ int err = 0;
+ List *dirlist = NULL;
+
+ if ((dirp = CVS_OPENDIR(thisdir)) == NULL) {
+ error(0, errno, "cannot open directory");
+ err++;
+ }
+ else {
+ errno = 0;
+ while ((dp = readdir(dirp)) != NULL) {
+ if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
+ goto one_more_time_boys;
+ if (strcmp(dp->d_name, CVSADM) == 0)
+ goto one_more_time_boys;
+ if (ign_name(dp->d_name))
+ goto one_more_time_boys;
+ if (
+#ifdef DT_DIR
+ (dp->d_type == DT_DIR || (dp->d_type == DT_UNKNOWN && isdir
(dp->d_name)))
+#else
+ isdir (dp->d_name)
+#endif
+ && !wrap_name_has(dp->d_name, WRAP_TOCVS)
+ ) {
+ Node *n;
+ if (dirlist == NULL)
+ dirlist = getlist();
+ n = getnode();
+ n->key = xstrdup(dp->d_name);
+ addnode(dirlist, n);
+ }
+ else if (
+#ifdef DT_DIR
+ dp->d_type == DT_LNK || (dp->d_type == DT_UNKNOWN && islink
(dp->d_name))
+#else
+ islink (dp->d_name)
+#endif
+ ) {
+ err++;
+ }
+ else {
+ if (strcmp(thisdir, ".") == 0) {
+ run_arg(dp->d_name);
+ }
+ else {
+ char *p;
+ p = xmalloc(strlen(thisdir)+1+strlen(dp->d_name)+1);
+ (void)sprintf(p, "%s/%s", thisdir, dp->d_name);
+ run_arg(p);
+ free(p);
+ }
+ }
+ one_more_time_boys:
+ errno = 0;
+ }
+ if (errno != 0) {
+ error(0, errno, "cannot read directory");
+ err++;
+ }
+ (void)closedir(dirp);
+ }
+ if (dirlist != NULL) {
+ Node *head, *p;
+ head = dirlist->list;
+ for (p = head->next; p != head; p = p->next) {
+ if (strcmp(thisdir, ".") == 0) {
+ err += importinfo_descend(p->key);
+ }
+ else {
+ char *nextdir;
+ nextdir = xmalloc(strlen(thisdir)+1+strlen(p->key)+1);
+ (void)sprintf(nextdir, "%s/%s", thisdir, p->key);
+ err += importinfo_descend(nextdir);
+ free(nextdir);
+ }
+ }
+ dellist(&dirlist);
+ }
+ return err;
+}
+
+/* importinfo configuration entry callback */
+static int
+importinfo_runproc(repository, filter, closure)
+ char *repository;
+ char *filter;
+ void *closure;
+{
+ char *s, *cp;
+ int rv;
+
+ /* if possible, do an own check to make sure that filter really exists */
+ if (filter[0] == '/') {
+ s = xstrdup(filter);
+ for (cp = s; *cp; cp++) {
+ if (isspace((unsigned char)*cp)) {
+ *cp = '\0';
+ break;
+ }
+ }
+ if (!isfile(s)) {
+ error (0, errno, "cannot find pre-admin filter '%s'", s);
+ free(s);
+ return (1);
+ }
+ free(s);
+ }
+
+ /* construct the filter command */
+ run_setup(filter);
+ run_arg(importinfo_vtag);
+ run_arg(repository);
+ ign_add_file(CVSDOTIGNORE, 1);
+ wrap_add_file(CVSDOTWRAPPER, 1);
+ rv = importinfo_descend(".");
+ if (rv > 0)
+ return rv;
+
+ /* execute the filter command */
+ rv = run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
+
+ return rv;
+}
+
int
import (int argc, char **argv)
{
@@ -286,6 +418,11 @@ import (int argc, char **argv)
{
error (1, 0, "attempt to import the repository");
}
+
+ importinfo_vtag = argv[1];
+ if (Parse_Info (CVSROOTADM_IMPORTINFO, argv[0], importinfo_runproc,
+ PIOPT_ALL, NULL) > 0)
+ error(1, 0, "Pre-import check failed");
/*
* Make all newly created directories writable. Should really use a more
Index: src/mkmodules.c
===================================================================
RCS file: /cvs/ccvs/src/mkmodules.c,v
retrieving revision 1.75
diff -u -p -r1.75 mkmodules.c
--- src/mkmodules.c 12 Sep 2003 18:54:52 -0000 1.75
+++ src/mkmodules.c 28 Sep 2003 03:32:44 -0000
@@ -163,6 +163,25 @@ static const char *const taginfo_content
NULL
};
+static const char *const importinfo_contents[] = {
+ "# The \"importinfo\" file is used to control pre-import checks.\n",
+ "# The filter on the right is invoked with the repository to check.\n",
+ "# A non-zero exit of the filter program will cause the import\n",
+ "# operation to be aborted.\n",
+ "#\n",
+ "# The first entry on a line is a regular expression which is tested\n",
+ "# against the directory that the change is being committed to,
relative\n",
+ "# to the $CVSROOT. For the first match that is found, then the
remainder\n",
+ "# of the line is the name of the filter to run.\n",
+ "#\n",
+ "# If the repository name does not match any of the regular expressions in
this\n",
+ "# file, the \"DEFAULT\" line is used, if it is specified.\n",
+ "#\n",
+ "# If the name \"ALL\" appears as a regular expression it is always
used\n",
+ "# in addition to the first matching regex or \"DEFAULT\".\n",
+ NULL
+};
+
static const char *const checkoutlist_contents[] = {
"# The \"checkoutlist\" file is used to support additional version
controlled\n",
"# administrative files in $CVSROOT/CVSROOT, such as template files.\n",
@@ -313,6 +332,9 @@ static const struct admin_file filelist[
{CVSROOTADM_TAGINFO,
"a %s file can be used to configure 'cvs tag' checking",
taginfo_contents},
+ {CVSROOTADM_IMPORTINFO,
+ "a %s file can be used to configure 'cvs import' checking",
+ importinfo_contents},
{CVSROOTADM_IGNORE,
"a %s file can be used to specify files to ignore",
NULL},
Index: src/sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.820
diff -u -p -r1.820 sanity.sh
--- src/sanity.sh 12 Sep 2003 18:54:52 -0000 1.820
+++ src/sanity.sh 28 Sep 2003 03:32:54 -0000
@@ -10280,6 +10280,7 @@ fish"
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -10407,6 +10408,7 @@ a change"
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -10430,6 +10432,7 @@ ${SPROG} commit: Rebuilding administrati
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -10456,6 +10459,7 @@ ${SPROG} commit: Rebuilding administrati
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -10523,6 +10527,7 @@ done"
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -11314,6 +11319,7 @@ done"
U CVSROOT/commitinfo
U CVSROOT/config
U CVSROOT/cvswrappers
+U CVSROOT/importinfo
U CVSROOT/loginfo
U CVSROOT/modules
U CVSROOT/notify
@@ -13517,6 +13523,8 @@ ${CPROG} checkout: move away CVSROOT/con
C CVSROOT/config
${CPROG} checkout: move away CVSROOT/cvswrappers; it is in the way
C CVSROOT/cvswrappers
+${CPROG} checkout: move away CVSROOT/importinfo; it is in the way
+C CVSROOT/importinfo
${CPROG} checkout: move away CVSROOT/loginfo; it is in the way
C CVSROOT/loginfo
${CPROG} checkout: move away CVSROOT/modules; it is in the way
- Resend importinfo patch,
Wu Yongwei <=