From owner-svn-src-projects@FreeBSD.ORG Thu Nov 20 13:39:16 2008 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50C6E1065670; Thu, 20 Nov 2008 13:39:15 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B4E18FC0A; Thu, 20 Nov 2008 13:39:15 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAKDdFdT053082; Thu, 20 Nov 2008 13:39:15 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAKDdFLh053081; Thu, 20 Nov 2008 13:39:15 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200811201339.mAKDdFLh053081@svn.freebsd.org> From: Ulf Lilleengen Date: Thu, 20 Nov 2008 13:39:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185131 - projects/csup_cvsmode/contrib/csup X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2008 13:39:16 -0000 Author: lulf Date: Thu Nov 20 13:39:14 2008 New Revision: 185131 URL: http://svn.freebsd.org/changeset/base/185131 Log: - Add support for 'X' and 'x' commands in CVSup protocol. These commands are not often used, but were quite simple to implement anyway. Modified: projects/csup_cvsmode/contrib/csup/updater.c Modified: projects/csup_cvsmode/contrib/csup/updater.c ============================================================================== --- projects/csup_cvsmode/contrib/csup/updater.c Thu Nov 20 12:52:07 2008 (r185130) +++ projects/csup_cvsmode/contrib/csup/updater.c Thu Nov 20 13:39:14 2008 (r185131) @@ -97,7 +97,7 @@ static int updater_delete(struct update static void updater_deletefile(const char *); static int updater_checkout(struct updater *, struct file_update *, int); static int updater_addfile(struct updater *, struct file_update *, - char *); + char *, int); int updater_addelta(struct rcsfile *, struct stream *, char *); static int updater_setattrs(struct updater *, struct file_update *, char *, char *, char *, char *, char *, struct fattr *); @@ -576,7 +576,7 @@ updater_docoll(struct updater *up, struc if (sr->sr_serverattr == NULL) return (UPDATER_ERR_PROTO); lprintf(1, " Create %s -> Attic\n", name); - error = updater_addfile(up, fup, attr); + error = updater_addfile(up, fup, attr, 0); if (error) return (error); break; @@ -599,7 +599,7 @@ updater_docoll(struct updater *up, struc if (sr->sr_serverattr == NULL) return (UPDATER_ERR_PROTO); lprintf(1, " Create %s\n", name); - error = updater_addfile(up, fup, attr); + error = updater_addfile(up, fup, attr, 0); if (error) return (error); break; @@ -864,32 +864,48 @@ updater_docoll(struct updater *up, struc if (error) return (error); break; -/* - X - Receive the live RCS file in its entirety, as a fixup. - Set its attributes to . The data follows, in the same - format as for the "A" command. CVS mode only. - - x - Like "X", but put the file into the Attic. CVS mode only. -*/ -#if 0 case 'X': + name = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (name == NULL || attr == NULL || line != NULL) + return (UPDATER_ERR_PROTO); + error = fup_prepare(fup, name, 0); + if (error) + return (UPDATER_ERR_PROTO); + + fup->temppath = tempname(fup->destpath); + sr = &fup->srbuf; + sr->sr_type = SR_FILELIVE; + sr->sr_file = xstrdup(name); + sr->sr_serverattr = fattr_decode(attr); + if (sr->sr_serverattr == NULL) + return (UPDATER_ERR_PROTO); + lprintf(1, " Fixup %s\n", name); + error = updater_addfile(up, fup, attr, 1); + if (error) + return (error); + break; case 'x': - lprintf(1, "Got X\n"); + name = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (name == NULL || attr == NULL || line != NULL) + return (UPDATER_ERR_PROTO); + error = fup_prepare(fup, name, 1); + if (error) + return (UPDATER_ERR_PROTO); + + fup->temppath = tempname(fup->destpath); + sr = &fup->srbuf; + sr->sr_type = SR_FILEDEAD; + sr->sr_file = xstrdup(name); + sr->sr_serverattr = fattr_decode(attr); + if (sr->sr_serverattr == NULL) + return (UPDATER_ERR_PROTO); + lprintf(1, " Fixup %s -> Attic\n", name); + error = updater_addfile(up, fup, attr, 1); + if (error) + return (error); break; -#endif -/* - Z - Append some new data to the end of the existing file , - and set its attributes to . The data should be written - to the file starting at file offset , which should be - exactly at the end of the file. Exactly n bytes of data follow, - where n is the size attribute minus . After the data - comes a terminating line, as in the "A" command. The number - of bytes n can be 0, in which case the file's attributes are - simply updated. -*/ case 'Z': name = proto_get_ascii(&line); attr = proto_get_ascii(&line); @@ -1443,7 +1459,8 @@ updater_updatenode(struct updater *up, s * Fetches a new file in CVS mode. */ static int -updater_addfile(struct updater *up, struct file_update *fup, char *attr) +updater_addfile(struct updater *up, struct file_update *fup, char *attr, + int isfixup) { char md5[MD5_DIGEST_SIZE]; struct coll *coll; @@ -1504,7 +1521,7 @@ updater_addfile(struct updater *up, stru return (UPDATER_ERR_PROTO); fattr_override(sr->sr_clientattr, sr->sr_serverattr, FA_MODTIME | FA_MASK); - error = updater_updatefile(up, fup, md5, 0); + error = updater_updatefile(up, fup, md5, isfixup); fup->wantmd5 = NULL; /* So that it doesn't get freed. */ /* UPDATE IT. */ if (error)