summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiall O'Higgins <niallo@cvs.openbsd.org>2005-10-29 19:05:52 +0000
committerNiall O'Higgins <niallo@cvs.openbsd.org>2005-10-29 19:05:52 +0000
commit31ef90eb4062a339cbde7db5a621f87aed51245e (patch)
tree98d144010753a9a35fb27a95e8a4fcf95da28c0d /usr.bin
parent0a0e0ff8f3f77f57bef157a71b2ffb2533de15ba (diff)
- add two new functions to RCS api: rcs_state_set() and rcs_state_check()
- use these two new functions to implement -s<state> option in ci ok joris@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/rcs.c45
-rw-r--r--usr.bin/cvs/rcs.h4
-rw-r--r--usr.bin/rcs/ci.c20
3 files changed, 64 insertions, 5 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index b801a316539..a21071d0890 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.94 2005/10/22 17:32:57 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.95 2005/10/29 19:05:50 niallo Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2891,3 +2891,46 @@ rcs_rev_setlog(RCSFILE *rfp, RCSNUM *rev, const char *logtext)
rfp->rf_flags &= ~RCS_SYNCED;
return (0);
}
+
+/*
+ * rcs_state_set()
+ *
+ * Sets the state of revision <rev> to <state>
+ * NOTE: default state is 'Exp'. States may not contain spaces.
+ *
+ * Returns -1 on failure, 0 on success.
+ */
+int
+rcs_state_set(RCSFILE *rfp, RCSNUM *rev, const char *state)
+{
+ struct rcs_delta *rdp;
+
+ if ((rdp = rcs_findrev(rfp, rev)) == NULL)
+ return (-1);
+
+ if (rdp->rd_state != NULL)
+ cvs_strfree(rdp->rd_state);
+
+ if ((rdp->rd_state = cvs_strdup(state)) == NULL)
+ return (-1);
+
+ rfp->rf_flags &= ~RCS_SYNCED;
+
+ return (0);
+}
+
+/*
+ * rcs_state_check()
+ *
+ * Check if string <state> is valid.
+ *
+ * Returns 0 if the string is valid, -1 otherwise.
+ */
+int
+rcs_state_check(const char *state)
+{
+ if (strchr(state, ' ') != NULL)
+ return (-1);
+
+ return (0);
+}
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 326e5bd83b1..0d09dd6e773 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.36 2005/10/22 17:32:57 joris Exp $ */
+/* $OpenBSD: rcs.h,v 1.37 2005/10/29 19:05:50 niallo Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -213,6 +213,8 @@ int rcs_rev_add(RCSFILE *, RCSNUM *, const char *, time_t,
const char *);
int rcs_rev_setlog(RCSFILE *, RCSNUM *, const char *);
int rcs_rev_remove(RCSFILE *, RCSNUM *);
+int rcs_state_set(RCSFILE *, RCSNUM *, const char *);
+int rcs_state_check(const char *);
RCSNUM *rcs_tag_resolve(RCSFILE *, const char *);
const char *rcs_errstr(int);
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 7f1a3c55bd5..784943eb621 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.50 2005/10/27 07:43:56 xsa Exp $ */
+/* $OpenBSD: ci.c,v 1.51 2005/10/29 19:05:51 niallo Exp $ */
/*
* Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -79,19 +79,20 @@ checkin_main(int argc, char **argv)
RCSNUM *frev, *newrev;
char fpath[MAXPATHLEN];
char *rcs_msg, *filec, *deltatext, *username, rbuf[16];
- const char *symbol = NULL;
+ const char *symbol, *state;
struct rcs_lock *lkp;
BUF *bp;
date = DATE_NOW;
file = NULL;
rcs_msg = username = NULL;
+ state = symbol = NULL;
newrev = NULL;
fmode = force = lkmode = rflag = status = symforce = 0;
interactive = 1;
- while ((ch = rcs_getopt(argc, argv, "d::f::j:k:l::m:M:N:n:qr::u::Vw:")) != -1) {
+ while ((ch = rcs_getopt(argc, argv, "d::f::j:k:l::m:M:N:n:qr::s:u::Vw:")) != -1) {
switch (ch) {
case 'd':
if (rcs_optarg == NULL)
@@ -144,6 +145,13 @@ checkin_main(int argc, char **argv)
rcs_set_rev(rcs_optarg, &newrev);
rflag = 1;
break;
+ case 's':
+ state = rcs_optarg;
+ if (rcs_state_check(state) < 0) {
+ cvs_log(LP_ERR, "invalid state `%'", state);
+ exit(1);
+ }
+ break;
case 'u':
rcs_set_rev(rcs_optarg, &newrev);
lkmode = LOCK_UNLOCK;
@@ -358,6 +366,12 @@ checkin_main(int argc, char **argv)
}
}
+ /*
+ * Set the state of this revision if specified.
+ */
+ if (state != NULL)
+ (void)rcs_state_set(file, newrev, state);
+
free(deltatext);
free(filec);
(void)unlink(argv[i]);