summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxsa <xsa@openbsd.org>2006-06-09 14:57:13 +0000
committerxsa <xsa@openbsd.org>2006-06-09 14:57:13 +0000
commita0d919f1cbc95e4811d44a714de1af87b345e0cd (patch)
treeca799b4a1822fef1f174d36d71493a3a251c107f
parentsync the atheros list with what we have in ath(4); (diff)
downloadwireguard-openbsd-a0d919f1cbc95e4811d44a714de1af87b345e0cd.tar.xz
wireguard-openbsd-a0d919f1cbc95e4811d44a714de1af87b345e0cd.zip
handle `cvs tag -F'; input && OK joris@.
-rw-r--r--usr.bin/cvs/rcs.c21
-rw-r--r--usr.bin/cvs/rcs.h5
-rw-r--r--usr.bin/cvs/tag.c37
3 files changed, 56 insertions, 7 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 7bb866b788a..dbe44078d78 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.183 2006/06/06 05:13:39 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.184 2006/06/09 14:57:13 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -791,6 +791,25 @@ rcs_sym_remove(RCSFILE *file, const char *sym)
}
/*
+ * rcs_sym_get()
+ *
+ * Find a specific symbol <sym> entry in the tree of the RCS file <file>.
+ *
+ * Returns a pointer to the symbol on success, or NULL on failure.
+ */
+struct rcs_sym *
+rcs_sym_get(RCSFILE *file, const char *sym)
+{
+ struct rcs_sym *symp;
+
+ TAILQ_FOREACH(symp, &(file->rf_symbols), rs_list)
+ if (strcmp(symp->rs_name, sym) == 0)
+ return (symp);
+
+ return (NULL);
+}
+
+/*
* rcs_sym_getrev()
*
* Retrieve the RCS revision number associated with the symbol <sym> for the
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index c267536a4c1..64aa1875684 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.68 2006/06/01 20:00:52 joris Exp $ */
+/* $OpenBSD: rcs.h,v 1.69 2006/06/09 14:57:13 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -228,10 +228,11 @@ int rcs_access_remove(RCSFILE *, const char *);
int rcs_access_check(RCSFILE *, const char *);
struct rcs_delta *rcs_findrev(RCSFILE *, RCSNUM *);
int rcs_sym_add(RCSFILE *, const char *, RCSNUM *);
+int rcs_sym_check(const char *);
+struct rcs_sym *rcs_sym_get(RCSFILE *, const char *);
int rcs_sym_remove(RCSFILE *, const char *);
RCSNUM *rcs_sym_getrev(RCSFILE *, const char *);
RCSNUM *rcs_translate_tag(const char *, RCSFILE *);
-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 *);
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index 551e35bbe5f..832bffdcf8a 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.45 2006/06/07 18:19:07 xsa Exp $ */
+/* $OpenBSD: tag.c,v 1.46 2006/06/09 14:57:13 xsa Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -28,11 +28,11 @@ static int tag_del(struct cvs_file *);
static int tag_add(struct cvs_file *);
static int tag_delete = 0;
+static int tag_force_move = 0;
static char *tag = NULL;
static char *tag_date = NULL;
static char *tag_name = NULL;
static char *tag_oldname = NULL;
-static RCSNUM *tag_rev = NULL;
struct cvs_cmd cvs_cmd_tag = {
CVS_OP_TAG, CVS_REQ_TAG, "tag",
@@ -60,6 +60,9 @@ cvs_tag(int argc, char **argv)
case 'd':
tag_delete = 1;
break;
+ case 'F':
+ tag_force_move = 1;
+ break;
case 'l':
flags &= ~CR_RECURSE_DIRS;
break;
@@ -186,7 +189,9 @@ tag_del(struct cvs_file *cf)
static int
tag_add(struct cvs_file *cf)
{
- char revbuf[16];
+ char revbuf[16], trevbuf[16];
+ RCSNUM *trev;
+ struct rcs_sym *sym;
if (cf->file_rcs == NULL) {
if (verbosity > 1)
@@ -198,9 +203,33 @@ tag_add(struct cvs_file *cf)
if (cvs_noexec == 1)
return (0);
+ trev = rcs_sym_getrev(cf->file_rcs, tag_name);
+ if (trev != NULL) {
+ if (rcsnum_cmp(cf->file_rcsrev, trev, 0) == 0) {
+ rcsnum_free(trev);
+ return (-1);
+ }
+ (void)rcsnum_tostr(trev, trevbuf, sizeof(trevbuf));
+
+ if (tag_force_move == 0) {
+ cvs_printf("W %s : %s ", cf->file_path, tag_name);
+ cvs_printf("already exists on version %s", trevbuf);
+ cvs_printf(" : NOT MOVING tag to version %s\n", revbuf);
+
+ return (-1);
+ } else if (tag_force_move == 1) {
+ sym = rcs_sym_get(cf->file_rcs, tag_name);
+ rcsnum_cpy(cf->file_rcsrev, sym->rs_num, 0);
+ cf->file_rcs->rf_flags &= ~RCS_SYNCED;
+
+ return (0);
+ }
+ }
+
if (rcs_sym_add(cf->file_rcs, tag_name, cf->file_rcsrev) == -1) {
if (rcs_errno != RCS_ERR_DUPENT) {
- (void)rcsnum_tostr(tag_rev, revbuf, sizeof(revbuf));
+ (void)rcsnum_tostr(cf->file_rcsrev, revbuf,
+ sizeof(revbuf));
cvs_log(LP_NOTICE,
"failed to set tag %s to revision %s in %s",
tag_name, revbuf, cf->file_rcs->rf_path);