diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-06-06 05:13:40 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-06-06 05:13:40 +0000 |
commit | 986c1709bd454c556f1d617141a8bc630c0e1d11 (patch) | |
tree | 01530019f3b7c0724ff4e36a5b571fa23a2a419c /usr.bin/cvs/rcs.c | |
parent | e050da0a7ff2a630ed415df93c50c041afa7f810 (diff) |
add support for the -D option of update,
-D allows you to update a file to matching a specified date:
opencvs up -D "1 hour ago" foobar will take the first matching
revision that was commited 1 hour ago.
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r-- | usr.bin/cvs/rcs.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 9940525a562..7bb866b788a 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.182 2006/06/04 13:53:27 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.183 2006/06/06 05:13:39 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -2945,16 +2945,40 @@ RCSNUM * rcs_translate_tag(const char *revstr, RCSFILE *rfp) { size_t i; - int nextroot; + char *sdate; RCSNUM *rev, *brev; struct rcs_branch *brp; - struct rcs_delta *rdp, *brdp; - char revision[16]; + struct rcs_delta *rdp; + time_t givendate, rcsdate; + + rdp = NULL; rev = rcs_sym_getrev(rfp, revstr); if (rev == NULL) { - if ((rev = rcsnum_parse(revstr)) == NULL) - fatal("tag %s does not exist (0)", revstr); + if ((rev = rcsnum_parse(revstr)) == NULL) { + if ((givendate = cvs_date_parse(revstr)) == -1) + fatal("tag %s does not exist (0)", revstr); + + rcs_parse_deltas(rfp, NULL); + + TAILQ_FOREACH(rdp, &(rfp->rf_delta), rd_list) { + sdate = asctime(&rdp->rd_date); + if (sdate == NULL) + fatal("failed to parse rcs date"); + rcsdate = cvs_date_parse(sdate); + if (rcsdate == -1) + fatal("failed to parse %s", sdate); + if (givendate <= rcsdate) + continue; + break; + } + + if (rdp == NULL) + fatal("no revision that matches date %s", + revstr); + + rev = rdp->rd_num; + } } if (RCSNUM_ISBRANCH(rev)) { |