Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Nov 2008 14:53:21 +0000 (UTC)
From:      Ulf Lilleengen <lulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r185203 - projects/csup_cvsmode/contrib/csup
Message-ID:  <200811231453.mANErL5Q054760@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lulf
Date: Sun Nov 23 14:53:21 2008
New Revision: 185203
URL: http://svn.freebsd.org/changeset/base/185203

Log:
  - Add support for reading RCS info from status file to avoid having to detail a
    file if it is up to date.

Modified:
  projects/csup_cvsmode/contrib/csup/lister.c

Modified: projects/csup_cvsmode/contrib/csup/lister.c
==============================================================================
--- projects/csup_cvsmode/contrib/csup/lister.c	Sun Nov 23 14:32:40 2008	(r185202)
+++ projects/csup_cvsmode/contrib/csup/lister.c	Sun Nov 23 14:53:21 2008	(r185203)
@@ -64,10 +64,10 @@ static int	lister_dofile(struct lister *
 		    struct statusrec *);
 static int	lister_dodead(struct lister *, struct coll *,
 		    struct statusrec *);
-#if 0
 static int	lister_dorcsfile(struct lister *, struct coll *,
-		    struct statusrec *, int);
-#endif
+		    struct statusrec *);
+static int	lister_dorcsdead(struct lister *, struct coll *,
+		    struct statusrec *);
 
 void *
 lister(void *arg)
@@ -150,14 +150,13 @@ lister_coll(struct lister *l, struct col
 	struct statusrec *sr;
 	struct fattr *fa;
 	size_t i;
-	int depth, error, ret, prunedepth, attic;
+	int depth, error, ret, prunedepth;
 
 	wr = l->wr;
 	depth = 0;
 	prunedepth = INT_MAX;
 	as = attrstack_new();
 	while ((ret = status_get(st, NULL, 0, 0, &sr)) == 1) {
-		attic = 0;
 		switch (sr->sr_type) {
 		case SR_DIRDOWN:
 			depth++;
@@ -194,20 +193,24 @@ lister_coll(struct lister *l, struct col
 					goto bad;
 			}
 			break;
-#if 0
 		case SR_FILEDEAD:
-			attic = 1;
+			if (depth < prunedepth) {
+				if (!(coll->co_options & CO_CHECKOUTMODE)) {
+					error = lister_dorcsdead(l, coll, sr);
+					if (error)
+						goto bad;
+				}
+			}
+			break;
 		case SR_FILELIVE:
 			if (depth < prunedepth) {
 				if (!(coll->co_options & CO_CHECKOUTMODE)) {
-					error = lister_dorcsfile(l, coll, sr,
-					    attic);
+					error = lister_dorcsfile(l, coll, sr);
 					if (error)
 						goto bad;
 				}
 			}
 			break;
-#endif
 		}
 	}
 	if (ret == -1) {
@@ -402,18 +405,15 @@ send:
 	return (0);
 }
 
-#if 0
-/* Handle a file live or file dead entry found in the status file. */
+/* Handle a rcs file live entry found in the status file. */
 static int
-lister_dorcsfile(struct lister *l, struct coll *coll, struct statusrec *sr,
-    int attic)
+lister_dorcsfile(struct lister *l, struct coll *coll, struct statusrec *sr)
 {
 	struct config *config;
 	struct stream *wr;
 	const struct fattr *sendattr;
 	struct fattr *fa;
 	char *path, *spath;
-	char cmd;
 	size_t len;
 	int error;
 
@@ -422,7 +422,7 @@ lister_dorcsfile(struct lister *l, struc
 	config = l->config;
 	wr = l->wr;
 	if (!coll->co_options & CO_TRUSTSTATUSFILE) {
-		path = cvspath(coll->co_prefix, sr->sr_file, attic);
+		path = cvspath(coll->co_prefix, sr->sr_file, 0);
 		if (path == NULL) {
 			spath = coll_statuspath(coll);
 			xasprintf(&l->errmsg, "Error in \"%s\": "
@@ -434,9 +434,11 @@ lister_dorcsfile(struct lister *l, struc
 		free(path);
 	} else 
 		fa = sr->sr_clientattr;
-	/* XXX: Perhaps check attic path name here. */
-	cmd = attic ? 'F' : 'f';
 	if (fattr_equal(fa, sr->sr_clientattr)) {
+		/*
+		 * If the file is an RCS file, we use "loose" equality, so sizes
+		 * may disagress because of differences in whitespace.
+		 */
 		if (isrcs(sr->sr_file, &len) &&
 		    !(coll->co_options & CO_NORCS) &&
 		    !(coll->co_options & CO_STRICTCHECKRCS)) {
@@ -444,15 +446,18 @@ lister_dorcsfile(struct lister *l, struc
 		}
 		sendattr = fa;
 	} else {
+		/*
+		 * If different, the user may have changed it, so we report
+		 * bogus attributes to force a full comparison.
+		 */
 		sendattr = fattr_bogus;
 	}
-	error = proto_printf(wr, "%c %s %F\n", cmd, pathlast(sr->sr_file), fa,
+	error = proto_printf(wr, "F %s %F\n", pathlast(sr->sr_file), sendattr,
 	    config->fasupport, coll->co_attrignore);
 	if (error)
 		return (LISTER_ERR_WRITE);
 	return (0);
 }
-#endif
 
 /* Handle a checkout dead entry found in the status file. */
 static int
@@ -508,3 +513,57 @@ lister_dodead(struct lister *l, struct c
 		return (LISTER_ERR_WRITE);
 	return (0);
 }
+
+/* Handle a rcs file dead entry found in the status file. */
+static int
+lister_dorcsdead(struct lister *l, struct coll *coll, struct statusrec *sr)
+{
+	struct config *config;
+	struct stream *wr;
+	const struct fattr *sendattr;
+	struct fattr *fa;
+	char *path, *spath;
+	size_t len;
+	int error;
+
+	if (!globtree_test(coll->co_filefilter, sr->sr_file))
+		return (0);
+	config = l->config;
+	wr = l->wr;
+	if (!coll->co_options & CO_TRUSTSTATUSFILE) {
+		path = cvspath(coll->co_prefix, sr->sr_file, 1);
+		if (path == NULL) {
+			spath = coll_statuspath(coll);
+			xasprintf(&l->errmsg, "Error in \"%s\": "
+			    "Invalid filename \"%s\"", spath, sr->sr_file);
+			free(spath);
+			return (LISTER_ERR_STATUS);
+		}
+		fa = fattr_frompath(path, FATTR_NOFOLLOW);
+		free(path);
+	} else 
+		fa = sr->sr_clientattr;
+	if (fattr_equal(fa, sr->sr_clientattr)) {
+		/*
+		 * If the file is an RCS file, we use "loose" equality, so sizes
+		 * may disagress because of differences in whitespace.
+		 */
+		if (isrcs(sr->sr_file, &len) &&
+		    !(coll->co_options & CO_NORCS) &&
+		    !(coll->co_options & CO_STRICTCHECKRCS)) {
+			fattr_maskout(fa, FA_SIZE);
+		}
+		sendattr = fa;
+	} else {
+		/*
+		 * If different, the user may have changed it, so we report
+		 * bogus attributes to force a full comparison.
+		 */
+		sendattr = fattr_bogus;
+	}
+	error = proto_printf(wr, "f %s %F\n", pathlast(sr->sr_file), sendattr,
+	    config->fasupport, coll->co_attrignore);
+	if (error)
+		return (LISTER_ERR_WRITE);
+	return (0);
+}



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