summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-12-08 18:56:11 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-12-08 18:56:11 +0000
commit9e49e3f8edbdcf3ed41c05c7a022ea027c72b6cc (patch)
tree4c7052462563880fd8dac240d1d7bbf890391a73 /usr.bin/cvs
parent71e9c1668d8823e2153147c31d4d55045ff4112c (diff)
complete and correct rcs locking functionality,
it was only done partially and as a bonus, completely wrong. seriously guys what was up with that?
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/rcs.c31
-rw-r--r--usr.bin/cvs/rcs.h5
2 files changed, 29 insertions, 7 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index a26bca40168..d890e732f21 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.108 2005/12/03 15:31:53 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.109 2005/12/08 18:56:10 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -308,6 +308,8 @@ rcs_open(const char *path, int flags, ...)
RCSFILE *rfp;
struct stat st;
va_list vap;
+ struct rcs_delta *rdp;
+ struct rcs_lock *lkr;
fmode = 0;
flags &= 0xffff; /* ditch any internal flags */
@@ -358,6 +360,20 @@ rcs_open(const char *path, int flags, ...)
return (NULL);
}
+ /* fill in rd_locker */
+ TAILQ_FOREACH(lkr, &(rfp->rf_locks), rl_list) {
+ if ((rdp = rcs_findrev(rfp, lkr->rl_num)) == NULL) {
+ rcs_close(rfp);
+ return (NULL);
+ }
+
+ rdp->rd_locker = strdup(lkr->rl_name);
+ if (rdp->rd_locker == NULL) {
+ rcs_close(rfp);
+ return (NULL);
+ }
+ }
+
return (rfp);
}
@@ -993,7 +1009,8 @@ rcs_lock_add(RCSFILE *file, const char *user, RCSNUM *rev)
/* first look for duplication */
TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) {
- if (strcmp(lkp->rl_name, user) == 0) {
+ if ((strcmp(lkp->rl_name, user) == 0) &&
+ (rcsnum_cmp(rev, lkp->rl_num, 0) == 0)) {
rcs_errno = RCS_ERR_DUPENT;
return (-1);
}
@@ -1036,13 +1053,15 @@ rcs_lock_add(RCSFILE *file, const char *user, RCSNUM *rev)
* Returns 0 on success, or -1 on failure.
*/
int
-rcs_lock_remove(RCSFILE *file, const RCSNUM *rev)
+rcs_lock_remove(RCSFILE *file, const char *user, RCSNUM *rev)
{
struct rcs_lock *lkp;
- TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list)
- if (rcsnum_cmp(lkp->rl_num, rev, 0) == 0)
+ TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) {
+ if ((strcmp(lkp->rl_name, user) == 0) &&
+ (rcsnum_cmp(lkp->rl_num, rev, 0) == 0))
break;
+ }
if (lkp == NULL) {
rcs_errno = RCS_ERR_NOENT;
@@ -2465,6 +2484,8 @@ rcs_freedelta(struct rcs_delta *rdp)
if (rdp->rd_author != NULL)
free(rdp->rd_author);
+ if (rdp->rd_locker != NULL)
+ free(rdp->rd_locker);
if (rdp->rd_state != NULL)
free(rdp->rd_state);
if (rdp->rd_log != NULL)
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 06faa90602e..e4335181fcf 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.41 2005/12/03 15:31:53 joris Exp $ */
+/* $OpenBSD: rcs.h,v 1.42 2005/12/08 18:56:10 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -155,6 +155,7 @@ struct rcs_delta {
char *rd_author;
char *rd_state;
char *rd_log;
+ char *rd_locker;
u_char *rd_text;
size_t rd_tlen;
@@ -206,7 +207,7 @@ int rcs_sym_check(const char *);
int rcs_lock_getmode(RCSFILE *);
int rcs_lock_setmode(RCSFILE *, int);
int rcs_lock_add(RCSFILE *, const char *, RCSNUM *);
-int rcs_lock_remove(RCSFILE *, const RCSNUM *);
+int rcs_lock_remove(RCSFILE *, const char *, RCSNUM *);
BUF *rcs_getrev(RCSFILE *, RCSNUM *);
int rcs_deltatext_set(RCSFILE *, RCSNUM *, const char *);
const char *rcs_desc_get(RCSFILE *);