From 6f6131c147f71ea44b9fd37a07ed33e84a95b0fc Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Thu, 10 Jan 2008 09:39:33 +0000 Subject: Slap in -b support for tag command. It was missing for a full regress test as of now. --- usr.bin/cvs/rcs.h | 3 ++- usr.bin/cvs/rcsnum.c | 18 +++++++++++++++++- usr.bin/cvs/tag.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) (limited to 'usr.bin') 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 * 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 * All rights reserved. @@ -389,6 +389,22 @@ rcsnum_brtorev(const RCSNUM *brnum) return (num); } +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) { 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 * @@ -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); } -- cgit v1.2.3