1: /*
   2:  *                       rcsmerge operation
   3:  */
   4: #ifndef lint
   5: static char rcsid[]=
   6: "$Header: /arthur/src/local/bin/rcs/src/RCS/rcsmerge.c,v 4.3 87/10/18 10:38:02 narten Exp $ Purdue CS";
   7: #endif
   8: /*****************************************************************************
   9:  *                       join 2 revisions with respect to a third
  10:  *****************************************************************************
  11:  *
  12:  * Copyright (C) 1982 by Walter F. Tichy
  13:  *                       Purdue University
  14:  *                       Computer Science Department
  15:  *                       West Lafayette, IN 47907
  16:  *
  17:  * All rights reserved. No part of this software may be sold or distributed
  18:  * in any form or by any means without the prior written permission of the
  19:  * author.
  20:  * Report problems and direct all inquiries to Tichy@purdue (ARPA net).
  21:  */
  22: 
  23: 
  24: /* $Log:	rcsmerge.c,v $
  25:  * Revision 4.3  87/10/18  10:38:02  narten
  26:  * Updating version numbers. Changes relative to version 1.1
  27:  * actually relative to 4.1
  28:  *
  29:  * Revision 1.3  87/09/24  14:00:31  narten
  30:  * Sources now pass through lint (if you ignore printf/sprintf/fprintf
  31:  * warnings)
  32:  *
  33:  * Revision 1.2  87/03/27  14:22:36  jenkins
  34:  * Port to suns
  35:  *
  36:  * Revision 1.1  84/01/23  14:50:36  kcs
  37:  * Initial revision
  38:  *
  39:  * Revision 4.1  83/03/28  11:14:57  wft
  40:  * Added handling of default branch.
  41:  *
  42:  * Revision 3.3  82/12/24  15:29:00  wft
  43:  * Added call to catchsig().
  44:  *
  45:  * Revision 3.2  82/12/10  21:32:02  wft
  46:  * Replaced getdelta() with gettree(); improved error messages.
  47:  *
  48:  * Revision 3.1  82/11/28  19:27:44  wft
  49:  * Initial revision.
  50:  *
  51:  */
  52: #include "rcsbase.h"
  53: #ifndef lint
  54: static char rcsbaseid[] = RCSBASE;
  55: #endif
  56: 
  57: extern int  cleanup();              /* cleanup after signals                */
  58: extern char * mktempfile();         /*temporary file name generator         */
  59: extern struct hshentry * genrevs(); /*generate delta numbers                */
  60: extern int  nerror;                 /*counter for errors                    */
  61: 
  62: char *RCSfilename;
  63: char *workfilename;
  64: char * temp1file, * temp2file;
  65: 
  66: main (argc, argv)
  67: int argc; char **argv;
  68: {
  69:         char * cmdusage;
  70:         char command[NCPPN+revlength+40];
  71:         int  revnums; /* counter for revision numbers given */
  72:         int tostdout;
  73:         char * rev1, * rev2; /*revision numbers*/
  74:         char numericrev[revlength];   /* holds expanded revision number     */
  75:         struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/
  76:         struct hshentry * target;
  77: 
  78:         catchints();
  79:         cmdid = "rcsmerge";
  80:         cmdusage = "command format:\n    rcsmerge -p -rrev1 -rrev2 file\n    rcsmerge -p -rrev1 file";
  81:         revnums=0;tostdout=false;
  82: 
  83:         while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) {
  84:                 switch ((*argv)[1]) {
  85:                 case 'p':
  86:                         tostdout=true;
  87:                         /* falls into -r */
  88:                 case 'r':
  89:                         if ((*argv)[2]!='\0') {
  90:                             if (revnums==0) {
  91:                                     rev1= *argv+2; revnums=1;
  92:                             } elif (revnums==1) {
  93:                                     rev2= *argv+2; revnums=2;
  94:                             } else {
  95:                                     faterror("too many revision numbers");
  96:                             }
  97:                         } /* do nothing for empty -r or -p */
  98:                         break;
  99: 
 100:                 default:
 101:                         faterror("unknown option: %s\n%s", *argv,cmdusage);
 102:                 };
 103:         } /* end of option processing */
 104: 
 105:         if (argc<1) faterror("No input file\n%s",cmdusage);
 106:         if (revnums<1) faterror("no base revision number given");
 107: 
 108:         /* now handle all filenames */
 109: 
 110:         if (pairfilenames(argc,argv,true,false)==1) {
 111: 
 112:                 if (argc>2 || (argc==2&&argv[1]!=nil))
 113:                         warn("too many arguments");
 114:                 diagnose("RCS file: %s",RCSfilename);
 115:                 if (!(access(workfilename,4)==0))
 116:                         faterror("Can't open %s",workfilename);
 117: 
 118:                 if (!trysema(RCSfilename,false)) goto end; /* give up */
 119: 
 120:                 gettree();  /* reads in the delta tree */
 121: 
 122:                 if (Head==nil) faterror("no revisions present");
 123: 
 124: 
 125:                 if (!expandsym(rev1,numericrev)) goto end;
 126:                 if (!(target=genrevs(numericrev, (char *)nil, (char *)nil, (char *)nil,gendeltas))) goto end;
 127:                 rev1=target->num;
 128:                 if (revnums==1)  /*get default for rev2 */
 129:                         rev2=Dbranch!=nil?Dbranch->num:Head->num;
 130:                 if (!expandsym(rev2,numericrev)) goto end;
 131:                 if (!(target=genrevs(numericrev, (char *)nil, (char *)nil, (char *)nil,gendeltas))) goto end;
 132:                 rev2=target->num;
 133: 
 134:                 temp1file=mktempfile("/tmp/",TMPFILE1);
 135:                 temp2file=mktempfile("/tmp/",TMPFILE2);
 136: 
 137:                 diagnose("retrieving revision %s",rev1);
 138:                 VOID sprintf(command,"%s/co -q -p%s %s > %s\n",
 139:                         TARGETDIR,rev1,RCSfilename,temp1file);
 140:                 if (system(command)){
 141:                         faterror("co failed");
 142:                 }
 143:                 diagnose("retrieving revision %s",rev2);
 144:                 VOID sprintf(command,"%s/co -q -p%s %s > %s\n",
 145:                          TARGETDIR,rev2,RCSfilename,temp2file);
 146:                 if (system(command)){
 147:                         faterror("co failed");
 148:                 }
 149:                 diagnose("Merging differences between %s and %s into %s%s",
 150:                          rev1, rev2, workfilename,
 151:                          tostdout?"; result to stdout":"");
 152: 
 153:                 VOID sprintf(command,"%s %s%s %s %s %s %s\n",MERGE,tostdout?"-p ":"",
 154:                         workfilename,temp1file,temp2file,workfilename,rev2);
 155:                 if (system(command)) {
 156:                         faterror("merge failed");
 157:                 }
 158:         }
 159: 
 160: end:
 161:         VOID cleanup();
 162:         exit(nerror!=0);
 163: 
 164: }

Defined functions

main defined in line 66; never used

Defined variables

RCSfilename defined in line 62; used 4 times
rcsbaseid defined in line 54; never used
rcsid defined in line 5; never used
temp1file defined in line 64; used 3 times
temp2file defined in line 64; used 3 times
workfilename defined in line 63; used 5 times
Last modified: 1988-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2507
Valid CSS Valid XHTML 1.0 Strict