summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/cvs/Makefile5
-rw-r--r--usr.bin/cvs/rcs.h3
-rw-r--r--usr.bin/cvs/rcsnum.c18
-rw-r--r--usr.bin/cvs/tag.c35
4 files changed, 54 insertions, 7 deletions
diff --git a/regress/usr.bin/cvs/Makefile b/regress/usr.bin/cvs/Makefile
index 6e0fca86bee..024e5c9e623 100644
--- a/regress/usr.bin/cvs/Makefile
+++ b/regress/usr.bin/cvs/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2008/01/06 14:45:50 tobias Exp $
+# $OpenBSD: Makefile,v 1.7 2008/01/10 09:39:32 tobias Exp $
# Regression tests by Niall O'Higgins <niallo@openbsd.org> and
# Tobias Stoeckmann <tobias@openbsd.org>.
@@ -189,10 +189,9 @@ test-cvs-tag:
@grep FIRST_TAG ${.OBJDIR}/regress_cvs_root/seed/seed1.txt,v \
> /dev/null
-# Does not work with OpenCVS, but we need it for further tests _now_.
test-cvs-tag-branch:
@cd ${.OBJDIR}/regress_cvs_wcopy/seed; \
- cvs -Q tag -b FIRST_BRANCH > /dev/null
+ ${CVS} -Q tag -b FIRST_BRANCH > /dev/null
@grep FIRST_BRANCH ${.OBJDIR}/regress_cvs_root/seed/seed1.txt,v \
> /dev/null
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 032ffb4544a..39f8d50ae2d 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.81 2007/11/11 10:01:41 tobias Exp $ */
+/* $OpenBSD: rcs.h,v 1.82 2008/01/10 09:39:32 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -279,6 +279,7 @@ RCSNUM *rcsnum_revtobr(const RCSNUM *);
RCSNUM *rcsnum_inc(RCSNUM *);
RCSNUM *rcsnum_dec(RCSNUM *);
RCSNUM *rcsnum_branch_root(RCSNUM *);
+RCSNUM *rcsnum_new_branch(RCSNUM *);
void rcsnum_free(RCSNUM *);
int rcsnum_aton(const char *, char **, RCSNUM *);
char *rcsnum_tostr(const RCSNUM *, char *, size_t);
diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c
index 59afb640ffb..c757b8c1e35 100644
--- a/usr.bin/cvs/rcsnum.c
+++ b/usr.bin/cvs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.48 2007/12/09 14:02:56 tobias Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.49 2008/01/10 09:39:32 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -390,6 +390,22 @@ rcsnum_brtorev(const RCSNUM *brnum)
}
RCSNUM *
+rcsnum_new_branch(RCSNUM *rev)
+{
+ RCSNUM *branch;
+
+ if (rev->rn_len > RCSNUM_MAXLEN - 1)
+ return NULL;
+
+ branch = rcsnum_alloc();
+ rcsnum_cpy(rev, branch, 0);
+ rcsnum_setsize(branch, rev->rn_len + 1);
+ branch->rn_id[branch->rn_len - 1] = 2;
+
+ return branch;
+}
+
+RCSNUM *
rcsnum_branch_root(RCSNUM *brev)
{
RCSNUM *root;
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index dd30b005b2c..c3e2985f382 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.58 2007/11/17 12:42:39 tobias Exp $ */
+/* $OpenBSD: tag.c,v 1.59 2008/01/10 09:39:32 tobias Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -23,6 +23,7 @@
#define T_CHECK_UPTODATE 0x01
#define T_DELETE 0x02
#define T_FORCE_MOVE 0x04
+#define T_BRANCH 0x08
void cvs_tag_local(struct cvs_file *);
@@ -56,6 +57,9 @@ cvs_tag(int argc, char **argv)
while ((ch = getopt(argc, argv, cvs_cmd_tag.cmd_opts)) != -1) {
switch (ch) {
+ case 'b':
+ runflags |= T_BRANCH;
+ break;
case 'c':
runflags |= T_CHECK_UPTODATE;
break;
@@ -119,6 +123,9 @@ cvs_tag(int argc, char **argv)
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
+ if (runflags & T_BRANCH)
+ cvs_client_send_request("Argument -b");
+
if (runflags & T_CHECK_UPTODATE)
cvs_client_send_request("Argument -c");
@@ -277,14 +284,38 @@ tag_add(struct cvs_file *cf)
}
}
- if (rcs_sym_add(cf->file_rcs, tag_name, cf->file_rcsrev) == -1) {
+ if (runflags & T_BRANCH) {
+ if ((trev = rcsnum_new_branch(cf->file_rcsrev)) == NULL)
+ fatal("Cannot create a new branch");
+
+ for (;;) {
+ TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list)
+ if (!rcsnum_cmp(sym->rs_num, trev, 0))
+ break;
+
+ if (sym != NULL) {
+ if (rcsnum_inc(trev) == NULL)
+ fatal("New revision too high");
+ if (rcsnum_inc(trev) == NULL)
+ fatal("New revision too high");
+ } else
+ break;
+ }
+ } else {
+ trev = rcsnum_alloc();
+ rcsnum_cpy(cf->file_rcsrev, trev, 0);
+ }
+
+ if (rcs_sym_add(cf->file_rcs, tag_name, trev) == -1) {
if (rcs_errno != RCS_ERR_DUPENT) {
cvs_log(LP_NOTICE,
"failed to set tag %s to revision %s in %s",
tag_name, revbuf, cf->file_rcs->rf_path);
}
+ rcsnum_free(trev);
return (-1);
}
+ rcsnum_free(trev);
return (0);
}