|
|
Choosing A Webhost: |
cvs rdiff -B feature for binary files: msg#00129version-control.cvs.bugs
Enclosed is a patch that implements a new option -B to rdiff. This tells it not to output the contents of binary files, only the headers. This is useful because diffs of arbitrary binary files cannot be parsed by other tools. In particular, I wrote a tool to show the history of changes made on a branch since a given date, which uses rdiff. (I'm happy to share the tool if anyone wants it.) It needs -B to get the right output. It's also necessary to always get the time of the second file in the diff, so the right time can be shown for removed files. I posted this before, for 1.11 and 1.11.1, but apparently it never made it into the sources. Hope you'll accept it this time. Thanks, karl *** ./ORIG/patch.c Tue Aug 7 11:35:32 2001 --- ./patch.c Sat Apr 20 19:46:08 2002 *************** static int force_tag_match = 1; *** 29,32 **** --- 29,33 ---- static int patch_short = 0; static int toptwo_diffs = 0; + static int binary_file_info = 0; static char *options = NULL; static char *rev1 = NULL; *************** static const char *const patch_usage[] = *** 53,56 **** --- 54,58 ---- "\t-t\tTop two diffs - last change made to the file.\n", "\t-D date\tDate.\n", + "\t-B\tShow headers for binary files.\n", "\t-r rev\tRevision - symbolic or numeric.\n", "\t-V vers\tUse RCS Version \"vers\" for keyword expansion.\n", *************** patch (argc, argv) *** 74,78 **** optind = 0; ! while ((c = getopt (argc, argv, "+V:k:cuftsQqlRD:r:")) != -1) { switch (c) --- 76,80 ---- optind = 0; ! while ((c = getopt (argc, argv, "+V:k:cuftsQqlRBD:r:")) != -1) { switch (c) *************** patch (argc, argv) *** 104,107 **** --- 106,112 ---- patch_short = 1; break; + case 'B': + binary_file_info = 1; + break; case 'D': if (rev2 != NULL || date2 != NULL) *************** patch (argc, argv) *** 208,211 **** --- 213,218 ---- if (unidiff) send_arg("-u"); + if (binary_file_info) + send_arg("-B"); if (rev1) *************** patch_fileproc (callerdat, finfo) *** 390,393 **** --- 397,402 ---- FILE *fp; int line_length; + time_t file2_time = -1; + char *diff_options; line1 = NULL; *************** patch_fileproc (callerdat, finfo) *** 417,420 **** --- 426,430 ---- if (vers_head != NULL && RCS_isdead (rcsfile, vers_head)) { + file2_time = RCS_getrevtime (rcsfile, vers_head, date2, 1); free (vers_head); vers_head = NULL; *************** patch_fileproc (callerdat, finfo) *** 576,587 **** goto out; } ! if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_head, ! (char *) 0, 0)) != -1) ! /* I believe this timestamp only affects the dates in our diffs, ! and therefore should be on the server, not the client. */ ! (void) utime (tmpfile2, &t); } ! switch (diff_exec (tmpfile1, tmpfile2, NULL, NULL, unidiff ? "-u" : "-c", tmpfile3)) { case -1: /* fork/wait failure */ --- 586,609 ---- goto out; } ! /* Always get file2_time so we can put the right timestamp in ! the header even if the file was removed. */ ! file2_time = RCS_getrevtime (rcsfile, vers_head, (char *) 0, 0); } ! /* Set mod time on file2 */ ! if (file2_time != -1) ! { ! t.actime = t.modtime = file2_time; ! /* I believe this timestamp only affects the dates in our diffs, ! and therefore should be on the server, not the client. */ ! (void) utime (tmpfile2, &t); ! } ! ! if (unidiff) ! diff_options = binary_file_info ? "-u --text" : "-u"; ! else ! diff_options = binary_file_info ? "-c --text" : "-c"; ! ! switch (diff_exec (tmpfile1, tmpfile2, NULL, NULL, diff_options, tmpfile3)) { case -1: /* fork/wait failure */ *************** failed to read diff file header %s for % *** 708,714 **** /* spew the rest of the diff out */ ! while ((line_length ! = getline (&line1, &line1_chars_allocated, fp)) ! >= 0) cvs_output (line1, 0); if (line_length < 0 && !feof (fp)) --- 730,738 ---- /* spew the rest of the diff out */ ! line_length = 0; ! if (!binary_file_info) ! while ((line_length ! = getline (&line1, &line1_chars_allocated, fp)) ! >= 0) cvs_output (line1, 0); if (line_length < 0 && !feof (fp))
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | 喜泉电磁阀又出新品了, =?gb2312?q?=C0=D6=C7=E5=CA=D0=B6=AB=B4=EF=B5=E7=D7=D3=D3=D0=CF=DE=B9=AB=CB=BE_ |
|---|---|
| Next by Date: | A IE 6.0 patch, dgg |
| Previous by Thread: | 喜泉电磁阀又出新品了, =?gb2312?q?=C0=D6=C7=E5=CA=D0=B6=AB=B4=EF=B5=E7=D7=D3=D3=D0=CF=DE=B9=AB=CB=BE_ |
| Next by Thread: | A IE 6.0 patch, dgg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |