Date: Mon, 23 Nov 1998 23:49:36 -0800 From: John Cavanaugh To: bug-cvs@gnu.org Subject: PATCH: Fully bounded date queries for "cvs history" Content-Type: multipart/mixed; boundary=sdtB3X0nJg68CQEu --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii This patch allows for history queries to be bounded by both a from & to date similar to the way "cvs diff" functions. The syntax follows exactly from "cvs diff" where the second -D is used as the ending "to" date. Hopefully this will make it in to the official tree. Ive got another patch that passes extended information (reason, tag, oldrev) to commitinfo hooks if anyone wants it. I needed it because it was the only way I could figure to completely lock a specific branch but still allow code changes on other branches. Im intentionally not sending it for submission into the main tree because the whole triggering concept needs a massive overhaul & I dont want to contribute further to its decay. ----------------------------------------------------------------------- John Cavanaugh Hewlett-Packard Company Project Engineer 1400 Fountaingrove Pkwy EESof Division Santa Rosa, CA 95403-1799 Email: cavanaug@sr.hp.com Phone: 707-577-4780 707-577-3948 (Fax) ----------------------------------------------------------------------- Discovery consists of seeing what everybody has seen and thinking what nobody else has thought. -- Albert Szent-Gyorhyi ----------------------------------------------------------------------- --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="history.c_diff" Index: history.c =================================================================== RCS file: /home2/cvsroot/ccvs/src/history.c,v retrieving revision 1.35 diff -c -r1.35 history.c *** history.c 1998/08/15 14:05:54 1.35 --- history.c 1998/11/24 07:26:26 *************** *** 243,248 **** --- 243,249 ---- static char *backto; /* -D option, or 0 if not specified. RCS format. */ static char * since_date; + static char * to_date; static struct hrec *last_since_tag; static struct hrec *last_backto; *************** *** 414,425 **** histfile = optarg; break; case 'D': /* Since specified date */ ! if (*since_rev || *since_tag || *backto) ! { ! error (0, 0, "date overriding rev/tag/backto"); ! *since_rev = *since_tag = *backto = '\0'; ! } ! since_date = Make_Date (optarg); break; case 'b': /* Since specified file/Repos */ if (since_date || *since_rev || *since_tag) --- 415,435 ---- histfile = optarg; break; case 'D': /* Since specified date */ ! if (since_date==NULL) ! { ! if (*since_rev || *since_tag || *backto) ! { ! error (0, 0, "date overriding rev/tag/backto"); ! *since_rev = *since_tag = *backto = '\0'; ! } ! since_date = Make_Date (optarg); ! } ! else ! { ! if (to_date != NULL) ! error (1, 0, "no more than two dates can be specified"); ! to_date = Make_Date (optarg); ! } break; case 'b': /* Since specified file/Repos */ if (since_date || *since_rev || *since_tag) *************** *** 429,434 **** --- 439,445 ---- if (since_date != NULL) free (since_date); since_date = NULL; + to_date = NULL; } free (backto); backto = xstrdup (optarg); *************** *** 453,458 **** --- 464,470 ---- if (since_date != NULL) free (since_date); since_date = NULL; + to_date = NULL; } free (since_rev); since_rev = xstrdup (optarg); *************** *** 465,470 **** --- 477,483 ---- if (since_date != NULL) free (since_date); since_date = NULL; + to_date = NULL; } free (since_tag); since_tag = xstrdup (optarg); *************** *** 558,563 **** --- 571,578 ---- send_arg("-X"); if (since_date) client_senddate (since_date); + if (to_date) + client_senddate (to_date); if (backto[0] != '\0') option_with_arg ("-b", backto); for (f1 = file_list; f1 < &file_list[file_count]; ++f1) *************** *** 1146,1152 **** int count; /* "Since" checking: The argument parser guarantees that only one of the ! * following four choices is set: * * 1. If "since_date" is set, it contains the date specified on the * command line. hr->date fields earlier than "since_date" are ignored. --- 1161,1167 ---- int count; /* "Since" checking: The argument parser guarantees that only one of the ! * following five choices is set: * * 1. If "since_date" is set, it contains the date specified on the * command line. hr->date fields earlier than "since_date" are ignored. *************** *** 1165,1176 **** * repository field with a *prefix* matching "backto" are saved. * The field "last_backto" is set to the last one of these. As in * 3. above, "select_hrec" adjusts to include the last one later on. */ ! if (since_date) { char *ourdate = date_from_time_t (hr->date); if (RCS_datecmp (ourdate, since_date) < 0) return (0); free (ourdate); --- 1180,1196 ---- * repository field with a *prefix* matching "backto" are saved. * The field "last_backto" is set to the last one of these. As in * 3. above, "select_hrec" adjusts to include the last one later on. + * 5. If "since_date" & "to_date" is set, they contain the dates specified + * on the command line. hr->date fields earlier than "since_date" & after + * "to_date" are ignored. */ ! if (since_date || to_date) { char *ourdate = date_from_time_t (hr->date); if (RCS_datecmp (ourdate, since_date) < 0) + return (0); + if (RCS_datecmp (to_date, ourdate) < 0) return (0); free (ourdate); --sdtB3X0nJg68CQEu--