summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-06-03 19:07:14 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-06-03 19:07:14 +0000
commit0e24eba0851053f1aea820e367757645fd458f96 (patch)
tree6ab057040ffb7ead3606bb59639ffe615707df0a
parent6eca9d9639e8747a35781ce95c9a4a86e64980b6 (diff)
add support for update -A and update -r<rev>.
hacking on the plane from toronto to barbados. i will probably hack some more since im stuck in barbados for 12 lovely hours over night cause the carribean airlines dont understand the meaning over 'more than one flight a day'.
-rw-r--r--usr.bin/cvs/checkout.c16
-rw-r--r--usr.bin/cvs/cvs.h3
-rw-r--r--usr.bin/cvs/file.c4
-rw-r--r--usr.bin/cvs/update.c22
4 files changed, 35 insertions, 10 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index b7cbae9188f..0e89943af68 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.59 2006/05/31 22:25:59 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.60 2006/06/03 19:07:13 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -128,7 +128,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, BUF *bp, int flags)
time_t rcstime;
CVSENTRIES *ent;
struct timeval tv[2];
- char *entry, rev[16], timebuf[64], tbuf[32];
+ char *entry, rev[16], timebuf[64], tbuf[32], stickytag[32];
rcsnum_tostr(rnum, rev, sizeof(rev));
@@ -188,9 +188,17 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, BUF *bp, int flags)
strlcpy(timebuf, tbuf, sizeof(timebuf));
}
+ if (flags & CO_SETSTICKY) {
+ l = snprintf(stickytag, sizeof(stickytag), "T%s", rev);
+ if (l == -1 || l >= (int)sizeof(stickytag))
+ fatal("cvs_checkout_file: overflow");
+ } else {
+ stickytag[0] = '\0';
+ }
+
entry = xmalloc(CVS_ENT_MAXLINELEN);
- l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", cf->file_name,
- rev, timebuf);
+ l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//%s", cf->file_name,
+ rev, timebuf, stickytag);
ent = cvs_ent_open(cf->file_wd);
cvs_ent_add(ent, entry);
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 8e9a07dff68..a3491a60a66 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.110 2006/05/30 06:34:39 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.111 2006/06/03 19:07:13 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -352,5 +352,6 @@ void cvs_checkout_file(struct cvs_file *, RCSNUM *, BUF *, int);
int update_has_conflict_markers(struct cvs_file *);
#define CO_MERGE 0x01
+#define CO_SETSTICKY 0x02
#endif
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index bf1535466d5..b679e3466b0 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.157 2006/06/02 19:10:23 david Exp $ */
+/* $OpenBSD: file.c,v 1.158 2006/06/03 19:07:13 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -642,6 +642,8 @@ cvs_file_classify(struct cvs_file *cf, const char *tag, int loud)
if (tag != NULL && cf->file_rcs != NULL)
cf->file_rcsrev = rcs_translate_tag(tag, cf->file_rcs);
+ else if (cf->file_ent != NULL && cf->file_ent->ce_tag != NULL)
+ cf->file_rcsrev = cf->file_ent->ce_rev;
else if (cf->file_rcs != NULL)
cf->file_rcsrev = rcs_head_get(cf->file_rcs);
else
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 73222b2d65f..1d0b2f59dac 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.69 2006/05/31 22:25:59 joris Exp $ */
+/* $OpenBSD: update.c,v 1.70 2006/06/03 19:07:13 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -25,6 +25,8 @@
int cvs_update(int, char **);
int prune_dirs = 0;
int build_dirs = 0;
+int reset_stickies = 0;
+static char *tag = NULL;
static void update_clear_conflict(struct cvs_file *);
@@ -52,6 +54,7 @@ cvs_update(int argc, char **argv)
while ((ch = getopt(argc, argv, cvs_cmd_update.cmd_opts)) != -1) {
switch (ch) {
case 'A':
+ reset_stickies = 1;
break;
case 'C':
case 'D':
@@ -81,6 +84,7 @@ cvs_update(int argc, char **argv)
case 'R':
break;
case 'r':
+ tag = optarg;
break;
default:
fatal("%s", cvs_cmd_update.cmd_synopsis);
@@ -238,8 +242,8 @@ cvs_update_leavedir(struct cvs_file *cf)
void
cvs_update_local(struct cvs_file *cf)
{
- int ret;
BUF *bp;
+ int ret, flags;
CVSENTRIES *entlist;
cvs_log(LP_TRACE, "cvs_update_local(%s)", cf->file_path);
@@ -258,8 +262,15 @@ cvs_update_local(struct cvs_file *cf)
* the bp buffer will be released inside rcs_kwexp_buf,
* which is called from cvs_checkout_file().
*/
+ flags = 0;
bp = NULL;
- cvs_file_classify(cf, NULL, 1);
+ cvs_file_classify(cf, tag, 1);
+
+ if (cf->file_status == FILE_UPTODATE && cf->file_ent != NULL &&
+ cf->file_ent->ce_tag != NULL && reset_stickies == 1) {
+ cf->file_status = FILE_CHECKOUT;
+ cf->file_rcsrev = rcs_head_get(cf->file_rcs);
+ }
switch (cf->file_status) {
case FILE_UNKNOWN:
@@ -291,7 +302,10 @@ cvs_update_local(struct cvs_file *cf)
if (bp == NULL)
fatal("cvs_update_local: failed to get HEAD");
- cvs_checkout_file(cf, cf->file_rcsrev, bp, 0);
+ if (tag != NULL)
+ flags = CO_SETSTICKY;
+
+ cvs_checkout_file(cf, cf->file_rcsrev, bp, flags);
cvs_printf("U %s\n", cf->file_path);
break;
case FILE_MERGE: