diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-11-22 11:49:03 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-11-22 11:49:03 +0000 |
commit | 5ebfeb516ed416f744a705daa0e24286685ce7f2 (patch) | |
tree | cdf925675db4a35c120534869d45b2f77e677a12 /usr.bin | |
parent | bb76f74956fe60e8ce58011926a3848c10f71890 (diff) |
- ci(1) can intialise RCS files now!
- support for -j added
- support for -i added
ok joris@ xsa@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/rcs.c | 20 | ||||
-rw-r--r-- | usr.bin/rcs/ci.c | 55 |
2 files changed, 60 insertions, 15 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 9d6047740fd..6b717e425f3 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.100 2005/11/16 08:15:21 xsa Exp $ */ +/* $OpenBSD: rcs.c,v 1.101 2005/11/22 11:49:02 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -1390,8 +1390,18 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date, return (-1); if (rev == RCS_HEAD_REV) { - rcsnum_cpy(rf->rf_head, old, 0); - rev = rcsnum_inc(rf->rf_head); + if (rf->rf_flags & RCS_CREATE) { + if ((rev = rcsnum_parse(RCS_HEAD_INIT)) == NULL) + return (-1); + if ((rf->rf_head = rcsnum_alloc()) == NULL) { + rcsnum_free(rev); + return (-1); + } + rcsnum_cpy(rev, rf->rf_head, 0); + } else { + rcsnum_cpy(rf->rf_head, old, 0); + rev = rcsnum_inc(rf->rf_head); + } } else { if ((rdp = rcs_findrev(rf, rev)) != NULL) { rcs_errno = RCS_ERR_DUPENT; @@ -1438,7 +1448,9 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date, return (-1); } - rcsnum_cpy(old, rdp->rd_next, 0); + if (!(rf->rf_flags & RCS_CREATE)) + rcsnum_cpy(old, rdp->rd_next, 0); + rcsnum_free(old); if (username == NULL) diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index f65f38f600c..6136c0077f0 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.65 2005/11/22 09:54:00 xsa Exp $ */ +/* $OpenBSD: ci.c,v 1.66 2005/11/22 11:49:02 niallo Exp $ */ /* * Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -131,10 +131,12 @@ checkin_main(int argc, char **argv) case 'i': rcs_set_rev(rcs_optarg, &pb.newrev); pb.openflags |= RCS_CREATE; + pb.flags |= CI_INIT; break; case 'j': rcs_set_rev(rcs_optarg, &pb.newrev); pb.openflags &= ~RCS_CREATE; + pb.flags &= ~CI_INIT; break; case 'l': rcs_set_rev(rcs_optarg, &pb.newrev); @@ -234,11 +236,22 @@ checkin_main(int argc, char **argv) */ if ((pb.openflags & RCS_CREATE) && (rcs_statfile(pb.filename, pb.fpath, - sizeof(pb.fpath)) < 0)) + sizeof(pb.fpath)) < 0)) { pb.flags |= NEWFILE; - else + } else if (!(pb.openflags & RCS_CREATE) + && (rcs_statfile(pb.filename, pb.fpath, + sizeof(pb.fpath)) < 0)) { + cvs_log(LP_ERR, "No existing RCS file"); + status = 1; + continue; + } else { + if (pb.flags & CI_INIT) { + cvs_log(LP_ERR, "%s already exists", pb.fpath); + status = 1; + continue; + } pb.openflags &= ~RCS_CREATE; - + } /* * If we are to create a new ,v file, we must decide where it * should go. @@ -601,17 +614,14 @@ checkin_init(struct checkin_params *pb) */ rcs_desc = checkin_getdesc(); rcs_desc_set(pb->file, rcs_desc); - printf("set description\n"); /* * Now add our new revision */ - if (rcs_rev_add(pb->file, RCS_HEAD_REV, LOG_INIT, - -1, pb->username) != 0) { + if (rcs_rev_add(pb->file, RCS_HEAD_REV, LOG_INIT, -1, pb->username) != 0) { cvs_log(LP_ERR, "failed to add new revision"); return (-1); } - printf("added rev\n"); /* * If we are checking in to a non-default (ie user-specified) * revision, set head to this revision. @@ -620,17 +630,40 @@ checkin_init(struct checkin_params *pb) rcs_head_set(pb->file, pb->newrev); else pb->newrev = pb->file->rf_head; - printf("set head rev\n"); /* * New head revision has to contain entire file; */ - if (rcs_deltatext_set(pb->file, pb->frev, filec) == -1) { + if (rcs_deltatext_set(pb->file, pb->file->rf_head, filec) == -1) { cvs_log(LP_ERR, "failed to set new head revision"); return (-1); } - printf("set delta text\n"); + /* + * Attach a symbolic name to this revision if specified. + */ + if (pb->symbol != NULL + && (checkin_attach_symbol(pb) < 0)) + return (-1); + /* + * Set the state of this revision if specified. + */ + if (pb->state != NULL) + (void)rcs_state_set(pb->file, pb->newrev, pb->state); + + free(filec); + (void)unlink(pb->filename); + + /* + * Do checkout if -u or -l are specified. + */ + if (((pb->flags & CO_LOCK) || (pb->flags & CO_UNLOCK)) + && !(pb->flags & CI_DEFAULT)) + checkout_rev(pb->file, pb->newrev, pb->filename, pb->flags, + pb->username); + + /* File will NOW be synced */ + rcs_close(pb->file); return (0); } |