diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-02-10 10:10:16 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-02-10 10:10:16 +0000 |
commit | 8b60bdfd121637f6e89639e4fe4264cb8f430756 (patch) | |
tree | d92037466e46fa24a2aaa81f0974a1b440fb49e9 /usr.bin/cvs | |
parent | 21433647af7b591d4d24cf16cd3aaacd1eed041c (diff) |
parse any date tags set in CVS/Tag or CVS/Entries properly, and use
them for commands;
with tobias@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/cvs.h | 5 | ||||
-rw-r--r-- | usr.bin/cvs/entries.c | 38 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 12 |
3 files changed, 45 insertions, 10 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index cc601ecad4c..e3daafc512b 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.158 2008/02/09 20:04:00 xsa Exp $ */ +/* $OpenBSD: cvs.h,v 1.159 2008/02/10 10:10:15 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -264,10 +264,11 @@ struct cvsroot { struct cvs_ent { char *ce_buf; + char *ce_conflict; char *ce_name; char *ce_opts; char *ce_tag; - char *ce_conflict; + time_t *ce_date; time_t ce_mtime; u_int16_t ce_type; u_int16_t ce_status; diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c index 27f6af771cc..03cbe878b9f 100644 --- a/usr.bin/cvs/entries.c +++ b/usr.bin/cvs/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.90 2008/02/09 20:04:00 xsa Exp $ */ +/* $OpenBSD: entries.c,v 1.91 2008/02/10 10:10:15 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -107,7 +107,7 @@ struct cvs_ent * cvs_ent_parse(const char *entry) { int i; - struct tm t; + struct tm t, dt; struct cvs_ent *ent; char *fields[CVS_ENTRIES_NFIELDS], *buf, *sp, *dp; @@ -184,9 +184,25 @@ cvs_ent_parse(const char *entry) else ent->ce_opts = NULL; - if (strcmp(fields[5], "")) - ent->ce_tag = fields[5] + 1; - else + if (strcmp(fields[5], "")) { + switch(*fields[5]) { + case 'D': + if (sscanf(fields[5] + 1, "%d.%d.%d.%d.%d.%d", + &dt.tm_year, &dt.tm_mon, &dt.tm_mday, + &dt.tm_hour, &dt.tm_min, &dt.tm_sec) != 6) + fatal("wrong date specification"); + dt.tm_year -= 1900; + dt.tm_mon -= 1; + ent->ce_date = timegm(&dt); + ent->ce_tag = NULL; + break; + case 'T': + ent->ce_tag = fields[5] + 1; + break; + default: + fatal("invalid sticky entry"); + } + } else ent->ce_tag = NULL; return (ent); @@ -379,6 +395,7 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp) FILE *fp; int i, linenum; size_t len; + struct tm datetm; char linebuf[128], tagpath[MAXPATHLEN]; if (tagp != NULL) @@ -420,6 +437,17 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp) *tagp = xstrdup(linebuf + 1); break; case 'D': + if (sscanf(linebuf + 1, "%d.%d.%d.%d.%d.%d", + &datetm.tm_year, &datetm.tm_mon, &datetm.tm_mday, + &datetm.tm_hour, &datetm.tm_min, &datetm.tm_sec) != + 6) + fatal("wrong date specification"); + datetm.tm_year -= 1900; + datetm.tm_mon -= 1; + + if (cvs_specified_date == 0) + cvs_specified_date = timegm(&datetm); + if (datep != NULL) *datep = xstrdup(linebuf + 1); break; diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index d24bac354af..cad31560a8a 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.129 2008/02/09 20:04:00 xsa Exp $ */ +/* $OpenBSD: update.c,v 1.130 2008/02/10 10:10:15 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -441,8 +441,14 @@ cvs_update_local(struct cvs_file *cf) if (cvs_cmdop != CVS_OP_UPDATE) break; - if ((tag != NULL && cf->file_rcs->rf_dead != 1 && - (cf->file_flags & FILE_HAS_TAG)) || cvs_specified_date != 0) + if (cf->file_rcsrev == NULL) + break; + + if (tag == NULL && cvs_specified_date == 0) + break; + + if (cf->file_rcs->rf_dead != 1 && + (cf->file_flags & FILE_HAS_TAG)) cvs_checkout_file(cf, cf->file_rcsrev, tag, CO_SETSTICKY); break; |