From: Dave_Coffin@unicore.com Date: Tue, 23 Mar 1999 15:02:57 -0500 (EST) To: bug-cvs@gnu.org Subject: Patch to allow main-branch import with tags Hello, Here's a patch to allow imports into the main branch of a source tree. It's based on Jim Kingdon's patch, but it doesn't lose the vendor/release tags when creating a new RCS file. Dave Coffin 3/23/99 -- Dave Coffin, BIOS Engineer, Linux & Internet guru Microid Research / Unicore Software 1538 Turnpike Street, North Andover, MA 01845-6221 E-mail: dave_coffin@unicore.com Lat: 42 38'32"N Phone: 978-686-6468x341 Lon: 71 05'00"W Fax: 978-683-1630 Alt: 57 meters ---------- Forwarded message ---------- Date: Tue, 23 Mar 1999 12:37:40 -0500 (EST) From: Dave_Coffin@unicore.com To: Jim Kingdon Subject: Re: A few questions from a CVS user Hi Jim, > > * How can I "import" files into branch 1, instead of 1.1.1? > > Again, can't be done. There is an unofficial patch for this on our > web site but the workaround is just to put them on 1.1.1 - it is > harmless. OK, I downloaded CVS 1.10.5 and the patch. From the patch file: > 1. The vendor-tag and release-tag arguments are handled in a very > inconsistent way. They are ignored for the initial import, and after > that tag things like "1" and revision on the trunk, which probably > isn't very useful. This should be cleaned up. I wouldn't think that > a main branch import would want vendor-tag and release-tag at all. This is not good. I don't care about the vendor tag (all the CD's come from Award), but I've imported 17 CDs so far and I *really* need release tags to keep them all straight! So I fixed the problem. Apply my patch to a clean copy of cvs-1.10.5, and all tags will be handled properly. Dave Coffin 3/23/99 patch follows: --- src/import.c Wed Dec 23 09:58:47 1998 +++ src/import.c Tue Mar 23 14:41:30 1999 @@ -6,7 +6,7 @@ * specified in the README file that comes with the CVS source distribution. * * "import" checks in the vendor release located in the current directory into - * the CVS source repository. The CVS vendor branch support is utilized. + * the CVS source repository. Import to a vendor branch by default. * * At least three arguments are expected to follow the options: * repository Where the source belongs relative to the CVSROOT @@ -37,6 +37,7 @@ static int repos_len; static char *vhead; static char *vbranch; +static int trunk; static FILE *logfp; static char *repository; static int conflicts; @@ -197,11 +198,22 @@ for (cp = vbranch; *cp != '\0'; cp++) if (!isdigit ((unsigned char) *cp) && *cp != '.') error (1, 0, "%s is not a numeric branch", vbranch); - if (numdots (vbranch) != 2) - error (1, 0, "Only branches with two dots are supported: %s", vbranch); - vhead = xstrdup (vbranch); - cp = strrchr (vhead, '.'); - *cp = '\0'; + switch (numdots (vbranch)) + { + case 2: + vhead = xstrdup (vbranch); + cp = strrchr (vhead, '.'); /* truncate level number */ + *cp = '\0'; + break; + case 0: + vhead = xstrdup ("1.1"); + trunk = 1; + break; + default: + error (1, 0, + "Only branches with zero or two dots are supported: %s", + vbranch); + } #ifdef CLIENT_SUPPORT if (client_active) @@ -662,8 +674,9 @@ return (1); } - if (vers->srcfile->branch == NULL || inattic || - strcmp (vers->srcfile->branch, vbranch) != 0) + if (!trunk && + (vers->srcfile->branch == NULL || inattic || + strcmp (vers->srcfile->branch, vbranch) != 0)) { conflicts++; letter = 'C'; @@ -1013,10 +1026,13 @@ char *local_opt = key_opt; char *free_opt = NULL; mode_t file_type; + int side_branch; if (noexec) return (0); + side_branch = add_vbranch && numdots(add_vbranch); + /* Note that as the code stands now, the -k option overrides any settings in wrappers (whether CVSROOT/cvswrappers, -W, or whatever). Some have suggested this should be the other way @@ -1094,7 +1110,7 @@ goto write_error; } - if (add_vbranch != NULL) + if (side_branch) { if (fprintf (fprcs, "branch %s;\012", add_vbranch) < 0) goto write_error; @@ -1161,7 +1177,7 @@ if (fprintf (fprcs, "branches") < 0) goto write_error; - if (add_vbranch != NULL) + if (side_branch) { if (fprintf (fprcs, " %s.1", add_vbranch) < 0) goto write_error; @@ -1215,7 +1231,7 @@ } #endif - if (add_vbranch != NULL) + if (side_branch) { if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 || fprintf (fprcs, "date %s; author %s; state Exp;\012", @@ -1293,7 +1309,7 @@ if (fprintf (fprcs, "\012%s\012", add_vhead) < 0 || fprintf (fprcs, "log\012@") < 0) goto write_error; - if (add_vbranch != NULL) + if (side_branch) { /* We are going to put the log message in the revision on the branch. So putting it here too seems kind of redundant, I @@ -1335,7 +1351,7 @@ } if (fprintf (fprcs, "@\012\012") < 0) goto write_error; - if (add_vbranch != NULL) + if (side_branch) { if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 || fprintf (fprcs, "log\012@") < 0 || --- doc/cvs.texinfo Fri Jan 29 10:18:44 1999 +++ doc/cvs.texinfo Tue Mar 23 12:16:42 1999 @@ -2766,16 +2766,16 @@ @example $ cd @var{wdir} -$ cvs import -m "Imported sources" yoyodyne/@var{rdir} yoyo start +$ cvs import -b 1 -m "Imported sources" yoyodyne/@var{rdir} yoyo start @end example -Unless you supply a log message with the @samp{-m} -flag, @sc{cvs} starts an editor and prompts for a -message. The string @samp{yoyo} is a @dfn{vendor tag}, -and @samp{start} is a @dfn{release tag}. They may fill -no purpose in this context, but since @sc{cvs} requires -them they must be present. @xref{Tracking sources}, for -more information about them. +Unless you supply a log message with the @samp{-m} flag, @sc{cvs} +starts an editor and prompts for a message. By default, new files +are imported into branch 1.1.1, but the @samp{-b 1} option tells +@sc{cvs} to use the main branch, or trunk instead. The @dfn{vendor tag} +@samp{yoyo} is applied to the chosen branch, and the @dfn{release tag} +@samp{start} is applied to the imported revision. @xref{Tracking sources}, +for more information about these tags and vendor branches. You can now verify that it worked, and remove your original source directory. @@ -9146,7 +9146,11 @@ @table @code @item -b @var{branch} -See @ref{Multiple vendor branches}. +Import to a different vendor branch; see +@ref{Multiple vendor branches}. + +If the @var{branch} specified is @samp{1}, then import +to the trunk instead of a vendor branch. @item -k @var{subst} Indicate the keyword expansion mode desired. This