[BACK]Return to edit.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/edit.c between version 1.22 and 1.23

version 1.22, 2007/01/05 09:41:30 version 1.23, 2007/01/06 17:09:08
Line 26 
Line 26 
 #define E_UNEDIT        0x04  #define E_UNEDIT        0x04
 #define E_ALL           (E_EDIT|E_COMMIT|E_UNEDIT)  #define E_ALL           (E_EDIT|E_COMMIT|E_UNEDIT)
   
   #define BASE_ADD        0x01
   #define BASE_GET        0x02
   #define BASE_REMOVE     0x04
   
 static void     cvs_edit_local(struct cvs_file *);  static void     cvs_edit_local(struct cvs_file *);
 static void     cvs_editors_local(struct cvs_file *);  static void     cvs_editors_local(struct cvs_file *);
 static void     cvs_unedit_local(struct cvs_file *);  static void     cvs_unedit_local(struct cvs_file *);
   
   static RCSNUM   *cvs_base_handle(struct cvs_file *, int);
   
 static int      edit_aflags = 0;  static int      edit_aflags = 0;
   
 struct cvs_cmd cvs_cmd_edit = {  struct cvs_cmd cvs_cmd_edit = {
Line 249 
Line 255 
         if (cvs_noexec == 1)          if (cvs_noexec == 1)
                 return;                  return;
   
           cvs_file_classify(cf, NULL, 0);
   
         if ((fp = fopen(CVS_PATH_NOTIFY, "a")) == NULL)          if ((fp = fopen(CVS_PATH_NOTIFY, "a")) == NULL)
                 fatal("cvs_edit_local: fopen: `%s': %s",                  fatal("cvs_edit_local: fopen: `%s': %s",
                     CVS_PATH_NOTIFY, strerror(errno));                      CVS_PATH_NOTIFY, strerror(errno));
Line 297 
Line 305 
   
         xfree(bfpath);          xfree(bfpath);
   
         /* XXX: Update revision number in CVS/Baserev from CVS/Entries */          (void)cvs_base_handle(cf, BASE_ADD);
 }  }
   
 static void  static void
Line 317 
Line 325 
         if (cvs_noexec == 1)          if (cvs_noexec == 1)
                 return;                  return;
   
           cvs_file_classify(cf, NULL, 0);
   
         bfpath = xmalloc(MAXPATHLEN);          bfpath = xmalloc(MAXPATHLEN);
         if (cvs_path_cat(CVS_PATH_BASEDIR, cf->file_name, bfpath,          if (cvs_path_cat(CVS_PATH_BASEDIR, cf->file_name, bfpath,
             MAXPATHLEN) >= MAXPATHLEN)              MAXPATHLEN) >= MAXPATHLEN)
Line 356 
Line 366 
                 fatal("gethostname failed");                  fatal("gethostname failed");
   
         if (getcwd(wdir, sizeof(wdir)) == NULL)          if (getcwd(wdir, sizeof(wdir)) == NULL)
   
                 fatal("getcwd failed");                  fatal("getcwd failed");
   
         (void)fprintf(fp, "U%s\t%s GMT\t%s\t%s\t\n",          (void)fprintf(fp, "U%s\t%s GMT\t%s\t%s\t\n",
             cf->file_name, timebuf, thishost, wdir);              cf->file_name, timebuf, thishost, wdir);
   
         (void)fclose(fp);          (void)fclose(fp);
   
         /* XXX: Update revision number in CVS/Entries from CVS/Baserev */          /* XXX: Update the revision number in CVS/Entries from CVS/Baserev */
   
         if (fchmod(cf->fd, 0644) == -1)          if (fchmod(cf->fd, 0644) == -1)
                 fatal("cvs_unedit_local: fchmod %s", strerror(errno));                  fatal("cvs_unedit_local: fchmod %s", strerror(errno));
   }
   
   static RCSNUM *
   cvs_base_handle(struct cvs_file *cf, int flags)
   {
           FILE *fp, *tfp;
           RCSNUM *ba_rev;
           size_t len;
           char *filename, *filerev, *p;
           char buf[MAXPATHLEN], rbuf[16];
   
           cvs_log(LP_TRACE, "cvs_base_handle(%s)", cf->file_path);
   
           tfp = NULL;
           ba_rev = NULL;
   
           if ((fp = fopen(CVS_PATH_BASEREV, "r")) == NULL) {
                   cvs_log(LP_ERRNO, "%s", CVS_PATH_BASEREV);
                   goto out;
           }
   
           if (flags & (BASE_ADD|BASE_REMOVE)) {
                   if ((tfp = fopen(CVS_PATH_BASEREVTMP, "w")) == NULL) {
                           cvs_log(LP_ERRNO, "%s", CVS_PATH_BASEREVTMP);
                           goto out;
                   }
           }
   
           while(fgets(buf, sizeof(buf), fp)) {
                   len = strlen(buf);
                   if (len > 0 && buf[len - 1] == '\n')
                           buf[len - 1] = '\0';
   
                   if (buf[0] != 'B')
                           continue;
   
                   filename = buf;
                   if((p = strchr(filename, '/')) == NULL)
                           continue;
   
                   filerev = p;
                   if ((p = strchr(filerev, '/')) == NULL)
                           continue;
   
                   if (cvs_file_cmpname(filename, cf->file_path) == 0) {
                           if (flags & BASE_GET) {
                                   *p = '\0';
                                   if ((ba_rev = rcsnum_parse(filerev)) == NULL)
                                           fatal("cvs_base_handle: rcsnum_parse");
                                   *p = '/';
                                   goto got_rev;
                           }
                   } else {
                           if (flags & (BASE_ADD|BASE_REMOVE))
                                   (void)fprintf(tfp, "%s\n", buf);
                   }
           }
   
   got_rev:
           if (flags & (BASE_ADD)) {
                   (void)rcsnum_tostr(cf->file_ent->ce_rev, rbuf, sizeof(rbuf));
                   (void)fprintf(tfp, "B%s/%s/\n", cf->file_path, rbuf);
           }
   
   out:
           if (fp != NULL)
                   (void)fclose(fp);
   
           if (tfp != NULL) {
                   (void)fclose(tfp);
                   (void)cvs_rename(CVS_PATH_BASEREVTMP, CVS_PATH_BASEREV);
           }
   
           return (ba_rev);
 }  }

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23