[Why --branch and not either (a) -r -D, or (b) -r branchname:date (or whatever that syntax is that is supported by update -j or whatever it is)? There should be a consistent syntax for this feature which works across all commands which support -D/-r/etc. Needs a test case and documentation. -kingdon] Date: Mon, 13 Apr 1998 11:46:08 +0900 (JST) To: bug-cvs@gnu.org Subject: support to specify diff point by date on branch From: enami@but-b.or.jp >Submitter-Id: net >Originator: enami tsugutomo >Organization: net >Confidential: no >Synopsis: support to specify diff point by date on branch >Severity: non-critical >Priority: medium >Category: cvs >Class: change-request >Release: cvs-1.9.26.1 >Environment: System: NetBSD parity-error.sm.sony.co.jp 1.3E NetBSD 1.3E (PARITY_ERROR) #228: Fri Apr 10 12:01:51 JST 1998 enami@parity-error.sm.sony.co.jp:/a/compile/PARITY_ERROR i386 >Description: It is unable to specify the diff point by date on branch. In other words, can't take diff by using -D option on branch. >How-To-Repeat: Checkout branch. Do cvs diff -D yesterday on it. >Fix: Since RCS_getversion can pick up rcs version by date if branch tag is specified, pass it. Following patch does: - introduce new diff option --branch, which can be used after -D option, specifies branch tag. - if branch tag is not set by user, try to use sticky tag if it is branch. - pass branch tag as revision for Version_TS. 1998-04-13 enami tsugutomo * diff.c (diff_branch1, diff_branch2): New variable to hold branch tag set by user. (diff_curdir_branch1, diff_curdir_branch2): New variable to hold branch tag used for this current directory. (longopts): Add entry for new option --branch. (diff): Handle --branch option. Pass them to server. Call diff_branch_setup to set diff_curdir_branch[12] for starting directory. (diff_fileproc): Pass diff_curdir_branch1 if diff_date1 is specified. (diff_set_diff_branch): New helper function to find values for diff_curdir_branch[12]. If user specified it, use it. Otherwise, try to find sticky branch tag. (diff_branch_setup): New function to initialize diff_curdir_branch[12]. (diff_dirproc): Call diff_branch_setup. (diff_file_nodiff): Pass diff_curdir_branch[12] if diff_date[12] is specified. Index: src/diff.c =================================================================== RCS file: /cvsroot/cvs/src/diff.c,v retrieving revision 1.1.1.11 diff -u -r1.1.1.11 diff.c --- diff.c 1998/02/28 05:53:25 1.1.1.11 +++ diff.c 1998/04/09 08:36:10 @@ -39,11 +39,14 @@ enum diff_file)); static int diff_fileproc PROTO ((void *callerdat, struct file_info *finfo)); static void diff_mark_errors PROTO((int err)); +static void diff_branch_setup PROTO ((void)); static char *diff_rev1, *diff_rev2; static char *diff_date1, *diff_date2; static char *use_rev1, *use_rev2; static int have_rev1_label, have_rev2_label; +static char *diff_branch1, *diff_branch2; +static char *diff_curdir_branch1, *diff_curdir_branch2; /* Revision of the user file, if it is unchanged from something in the repository and we want to use that fact. */ @@ -146,6 +149,7 @@ {"changed-group-format", 1, 0, 139}, {"horizon-lines", 1, 0, 140}, {"binary", 0, 0, 142}, + {"branch", 1, 0, 149}, {0, 0, 0, 0} }; @@ -285,6 +289,15 @@ strcat_and_allocate (&opts, &opts_allocated, optarg); } break; + case 149: + /* --branch. */ + if (diff_date2 != NULL) + diff_branch2 = optarg; + else if (diff_date1 != NULL) + diff_branch1 = optarg; + else + error(1, 0, "no date is specified for branch"); + break; case 'R': local = 0; break; @@ -348,10 +361,14 @@ option_with_arg ("-r", diff_rev1); if (diff_date1) client_senddate (diff_date1); + if (diff_branch1) + option_with_arg ("--branch", diff_branch1); if (diff_rev2) option_with_arg ("-r", diff_rev2); if (diff_date2) client_senddate (diff_date2); + if (diff_branch2) + option_with_arg ("--branch", diff_branch2); send_file_names (argc, argv, SEND_EXPAND_WILD); @@ -379,6 +396,8 @@ wrap_setup (); + diff_branch_setup(); + /* start the recursion processor */ err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc, diff_dirleaveproc, NULL, argc, argv, local, @@ -439,7 +458,10 @@ { Vers_TS *xvers; - xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1, + xvers = Version_TS (finfo, NULL, + (diff_date1 ? diff_curdir_branch1 + : diff_rev1), + diff_date1, 1, 0); exists = xvers->vn_rcs != NULL; freevers_ts (&xvers); @@ -736,6 +758,47 @@ diff_errors = err; } +static void +diff_set_diff_branch(curbranch, defbranch) + char **curbranch; + char *defbranch; +{ + char *curdir_branch = *curbranch; + char *diff_branch; + int nonbranch; + + if (curdir_branch != NULL) + free(curdir_branch); + + if (defbranch != NULL) + curdir_branch = xstrdup (defbranch); + else + { + ParseTag(&diff_branch, NULL, &nonbranch); + if (nonbranch) + curdir_branch = NULL; + else + curdir_branch = xstrdup (diff_branch); + if (diff_branch) + free(diff_branch); + } + *curbranch = curdir_branch; +} + +static void +diff_branch_setup() +{ + diff_set_diff_branch(&diff_curdir_branch1, diff_branch1); + diff_set_diff_branch(&diff_curdir_branch2, diff_branch2); + if (!quiet) + { + if (diff_curdir_branch1 != NULL) + error (0, 0, "Tag1: %s", diff_curdir_branch1); + if (diff_curdir_branch2 != NULL) + error (0, 0, "Tag2: %s", diff_curdir_branch2); + } +} + /* * Print a warm fuzzy message when we enter a dir * @@ -758,6 +821,8 @@ if (!quiet) error (0, 0, "Diffing %s", update_dir); + + diff_branch_setup(); return (R_PROCESS); } @@ -817,7 +882,9 @@ use_rev1 = xstrdup (vers->vn_rcs); else { - xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1, 1, 0); + xvers = Version_TS (finfo, NULL, + diff_date1 ? diff_curdir_branch1 : diff_rev1, + diff_date1, 1, 0); if (xvers->vn_rcs != NULL) use_rev1 = xstrdup (xvers->vn_rcs); freevers_ts (&xvers); @@ -830,7 +897,9 @@ use_rev2 = xstrdup (vers->vn_rcs); else { - xvers = Version_TS (finfo, NULL, diff_rev2, diff_date2, 1, 0); + xvers = Version_TS (finfo, NULL, + diff_date2 ? diff_curdir_branch2 : diff_rev2, + diff_date2, 1, 0); if (xvers->vn_rcs != NULL) use_rev2 = xstrdup (xvers->vn_rcs); freevers_ts (&xvers);