=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/import.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/cvs/import.c 2005/05/24 04:21:54 1.16 --- src/usr.bin/cvs/import.c 2005/05/25 09:25:48 1.17 *************** *** 1,4 **** ! /* $OpenBSD: import.c,v 1.16 2005/05/24 04:21:54 jfb Exp $ */ /* * Copyright (c) 2004 Joris Vink * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: import.c,v 1.17 2005/05/25 09:25:48 jfb Exp $ */ /* * Copyright (c) 2004 Joris Vink * All rights reserved. *************** *** 120,131 **** *arg = optind + 3; - cvs_msg = "test\n"; - #if 0 if ((cvs_msg == NULL) && (cvs_msg = cvs_logmsg_get(NULL, NULL, NULL, NULL)) == NULL) return (CVS_EX_DATA); - #endif return (0); } --- 120,128 ---- *************** *** 214,220 **** --- 211,219 ---- int len; struct cvsroot *root; char fpath[MAXPATHLEN], rpath[MAXPATHLEN], repo[MAXPATHLEN]; + const char *comment; RCSFILE *rf; + RCSNUM *rev; root = CVS_DIR_ROOT(cf); len = snprintf(repo, sizeof(repo), "%s/%s", root->cr_dir, module); *************** *** 255,260 **** --- 254,296 ---- rf = rcs_open(rpath, RCS_RDWR|RCS_CREATE); if (rf == NULL) { + cvs_log(LP_ERR, "failed to create RCS file: %s", + strerror(rcs_errno)); + return (CVS_EX_DATA); + } + + comment = rcs_comment_lookup(cf->cf_name); + if ((comment != NULL) && (rcs_comment_set(rf, comment) < 0)) { + cvs_log(LP_ERR, "failed to set RCS comment leader: %s", + rcs_errstr(rcs_errno)); + } + + /* first add the magic 1.1.1.1 revision */ + rev = rcsnum_parse("1.1.1.1"); + if (rcs_rev_add(rf, rev, cvs_msg) < 0) { + cvs_log(LP_ERR, "failed to add revision: %s", + rcs_errstr(rcs_errno)); + rcs_close(rf); + (void)unlink(rpath); + return (CVS_EX_DATA); + } + rcsnum_free(rev); + + rev = rcsnum_parse(RCS_HEAD_INIT); + if (rcs_rev_add(rf, rev, cvs_msg) < 0) { + cvs_log(LP_ERR, "failed to add revision: %s", + rcs_errstr(rcs_errno)); + rcs_close(rf); + (void)unlink(rpath); + return (CVS_EX_DATA); + } + + if (rcs_head_set(rf, rev) < 0) { + cvs_log(LP_ERR, "failed to set RCS head: %s", + rcs_errstr(rcs_errno)); + rcs_close(rf); + (void)unlink(rpath); + return (CVS_EX_DATA); } rcs_close(rf);