diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-04-01 06:19:30 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-04-01 06:19:30 +0000 |
commit | 6691dd4dd24b9bf6edd8d48e2dcb4ed07be01435 (patch) | |
tree | a75ef385e9f69429511ae4be581dbf6ac6bb3591 /usr.bin | |
parent | 143730248bf47be98ceed1603bed218d2e51e045 (diff) |
Add rcs -l, rcs -u, and regression tests.
``put it all in'' joris@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/rcs.1 | 18 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 70 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.h | 16 |
3 files changed, 90 insertions, 14 deletions
diff --git a/usr.bin/rcs/rcs.1 b/usr.bin/rcs/rcs.1 index 79bb6d04b34..ffe46286a02 100644 --- a/usr.bin/rcs/rcs.1 +++ b/usr.bin/rcs/rcs.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rcs.1,v 1.23 2006/03/08 11:25:58 xsa Exp $ +.\" $OpenBSD: rcs.1,v 1.24 2006/04/01 06:19:29 ray Exp $ .\" .\" Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> .\" Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org> @@ -39,6 +39,7 @@ .Op Fl c Ns Ar string .Op Fl e Ns Op Ar users .Op Fl k Ns Ar mode +.Op Fl l Ns Op Ar rev .Oo Fl m Ns Ar rev Ns : .Ar msg Oc .Op Fl o Ns Ar rev @@ -46,6 +47,7 @@ .Op : Ns Ar rev Oc .Oo Fl t Ns Ar file Ns \*(Ba .Ar str Oc +.Op Fl u Ns Op Ar rev .Op Fl x Ns Ar suffixes .Ar file ... .Sh DESCRIPTION @@ -110,6 +112,13 @@ Files created this way contain no revision. Specify the keyword substitution mode. .It Fl L Enable strict locking on the RCS files. +.It Fl l Ns Op Ar rev +Lock revision +.Ar rev +on the RCS files. +If +.Ar rev +is not given, the head revision is locked. .It Fl M Disable mail warnings when breaking a user's lock. Normally, @@ -185,6 +194,13 @@ terminated by end-of-file or by a line containing the character by itself. .It Fl U Disable strict locking on the RCS files. +.It Fl u Ns Op Ar rev +Unlock revision +.Ar rev +on the RCS files. +If +.Ar rev +is not given, the head revision is unlocked. .It Fl V Print the program's version string and exit. .It Fl x Ns Ar suffixes diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 9dbcd9b44f5..99c43786ca8 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.91 2006/04/01 05:58:17 ray Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.92 2006/04/01 06:19:29 ray Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -29,7 +29,7 @@ #include "rcsprog.h" #define RCS_CMD_MAXARG 128 -#define RCSPROG_OPTSTRING "A:a:b::c:e::hik:Lm:Mn:N:qt::TUVx::z:" +#define RCSPROG_OPTSTRING "A:a:b::c:e::hik:Ll::m:Mn:N:qt::TUu::Vx::z:" #define DESC_PROMPT "enter description, terminated with single '.' " \ "or end of file:\nNOTE: This is NOT the log message!" \ @@ -421,8 +421,8 @@ rcs_usage(void) { fprintf(stderr, "usage: rcs [-ehIiLMqTUV] [-Aoldfile] [-ausers] [-b[rev]]\n" - " [-cstring] [-e[users]] [-kmode] [-mrev:msg]\n" - " [-orev] [-sstate[:rev]] [-tfile|str]\n" + " [-cstring] [-e[users]] [-kmode] [-l[rev]] [-mrev:msg]\n" + " [-orev] [-sstate[:rev]] [-tfile|str] [-u[rev]]\n" " [-xsuffixes] file ...\n"); } @@ -438,7 +438,7 @@ rcs_main(int argc, char **argv) int i, j, ch, kflag, lkmode; char fpath[MAXPATHLEN], ofpath[MAXPATHLEN]; char *logstr, *logmsg, *nflag, *descfile; - char *alist, *comment, *elist; + char *alist, *comment, *elist, *lrev, *urev; mode_t fmode; RCSFILE *file, *oldfile; RCSNUM *logrev; @@ -448,7 +448,7 @@ rcs_main(int argc, char **argv) kflag = lkmode = -1; fmode = S_IRUSR|S_IRGRP|S_IROTH; flags = RCS_RDWR|RCS_PARSE_FULLY; - descfile = nflag = NULL; + lrev = urev = descfile = nflag = NULL; logstr = alist = comment = elist = NULL; while ((ch = rcs_getopt(argc, argv, RCSPROG_OPTSTRING)) != -1) { @@ -489,6 +489,11 @@ rcs_main(int argc, char **argv) cvs_log(LP_WARN, "-U overriden by -L"); lkmode = RCS_LOCK_STRICT; break; + case 'l': + /* XXX - Check with -u flag. */ + lrev = rcs_optarg; + rcsflags |= RCSPROG_LFLAG; + break; case 'm': logstr = xstrdup(rcs_optarg); break; @@ -517,6 +522,11 @@ rcs_main(int argc, char **argv) cvs_log(LP_WARN, "-L overriden by -U"); lkmode = RCS_LOCK_LOOSE; break; + case 'u': + /* XXX - Check with -l flag. */ + urev = rcs_optarg; + rcsflags |= RCSPROG_UFLAG; + break; case 'V': printf("%s\n", rcs_version); exit(0); @@ -647,6 +657,54 @@ rcs_main(int argc, char **argv) if (lkmode != -1) (void)rcs_lock_setmode(file, lkmode); + if (rcsflags & RCSPROG_LFLAG) { + RCSNUM *rev; + const char *username; + + if ((username = getlogin()) == NULL) + fatal("could not get username"); + if (lrev == NULL) { + rev = rcsnum_alloc(); + rcsnum_cpy(file->rf_head, rev, 0); + } else if ((rev = rcsnum_parse(lrev)) == NULL) { + cvs_log(LP_ERR, "unable to unlock file"); + rcs_close(file); + continue; + } + /* Make sure revision exists. */ + if (rcs_findrev(file, rev) == NULL) + fatal("revision does not exist"); + if (rcs_lock_add(file, username, rev) == -1) { + rcs_close(file); + fatal("unable to lock file"); + } + rcsnum_free(rev); + } + + if (rcsflags & RCSPROG_UFLAG) { + RCSNUM *rev; + const char *username; + + if ((username = getlogin()) == NULL) + fatal("could not get username"); + if (urev == NULL) { + rev = rcsnum_alloc(); + rcsnum_cpy(file->rf_head, rev, 0); + } else if ((rev = rcsnum_parse(urev)) == NULL) { + cvs_log(LP_ERR, "unable to unlock file"); + rcs_close(file); + continue; + } + /* Make sure revision exists. */ + if (rcs_findrev(file, rev) == NULL) + fatal("revision does not exist"); + if (rcs_lock_remove(file, username, rev) == -1) { + rcs_close(file); + fatal("unable to unlock file"); + } + rcsnum_free(rev); + } + rcs_close(file); if (rcsflags & PRESERVETIME) diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h index 276ef4d0d43..e08bcdf964c 100644 --- a/usr.bin/rcs/rcsprog.h +++ b/usr.bin/rcs/rcsprog.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.h,v 1.40 2006/04/01 05:58:17 ray Exp $ */ +/* $OpenBSD: rcsprog.h,v 1.41 2006/04/01 06:19:29 ray Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -52,14 +52,16 @@ /* flags specific to rcsprog.c */ #define RCSPROG_EFLAG (1<<10) -#define RCSPROG_NFLAG (1<<11) -#define RCSPROG_TFLAG (1<<12) +#define RCSPROG_LFLAG (1<<11) +#define RCSPROG_NFLAG (1<<12) +#define RCSPROG_TFLAG (1<<13) +#define RCSPROG_UFLAG (1<<14) /* shared flags */ -#define FORCE (1<<13) -#define INTERACTIVE (1<<14) -#define NEWFILE (1<<15) -#define PRESERVETIME (1<<16) +#define FORCE (1<<15) +#define INTERACTIVE (1<<16) +#define NEWFILE (1<<17) +#define PRESERVETIME (1<<18) extern char *__progname; extern const char rcs_version[]; |