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

Diff for /src/usr.bin/cvs/checkout.c between version 1.86 and 1.87

version 1.86, 2007/01/26 21:59:11 version 1.87, 2007/01/28 02:04:45
Line 203 
Line 203 
         time_t rcstime;          time_t rcstime;
         CVSENTRIES *ent;          CVSENTRIES *ent;
         struct timeval tv[2];          struct timeval tv[2];
           char *tosend;
         char template[MAXPATHLEN], *p, entry[CVS_ENT_MAXLINELEN], rev[16];          char template[MAXPATHLEN], *p, entry[CVS_ENT_MAXLINELEN], rev[16];
         char timebuf[64], kbuf[8], tbuf[32], stickytag[32];          char timebuf[64], kbuf[8], tbuf[32], stickytag[32];
   
           exists = 0;
           tosend = NULL;
         rcsnum_tostr(rnum, rev, sizeof(rev));          rcsnum_tostr(rnum, rev, sizeof(rev));
   
         cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d) -> %s",          cvs_log(LP_TRACE, "cvs_checkout_file(%s, %s, %d) -> %s",
Line 223 
Line 226 
                 return;                  return;
         }          }
   
           if (co_flags & CO_MERGE)
                   printf("merge on %s\n", cf->file_path);
   
         if (cvs_server_active == 0) {          if (cvs_server_active == 0) {
                 oflags = O_WRONLY | O_TRUNC;                  if (!(co_flags & CO_MERGE)) {
                 if (cf->fd != -1) {                          oflags = O_WRONLY | O_TRUNC;
                         exists = 1;                          if (cf->fd != -1) {
                         (void)close(cf->fd);                                  exists = 1;
                 } else  {                                  (void)close(cf->fd);
                         exists = 0;                          } else  {
                         oflags |= O_CREAT;                                  oflags |= O_CREAT;
                 }                          }
   
                 cf->fd = open(cf->file_path, oflags);                          cf->fd = open(cf->file_path, oflags);
                 if (cf->fd == -1)                          if (cf->fd == -1)
                         fatal("cvs_checkout_file: open: %s", strerror(errno));                                  fatal("cvs_checkout_file: open: %s",
                                       strerror(errno));
   
                 rcs_rev_write_fd(cf->file_rcs, rnum, cf->fd, 1);                          rcs_rev_write_fd(cf->file_rcs, rnum, cf->fd, 1);
                   } else {
                           cvs_merge_file(cf, 1);
                   }
   
                 if (fchmod(cf->fd, 0644) == -1)                  if (fchmod(cf->fd, 0644) == -1)
                         fatal("cvs_checkout_file: fchmod: %s", strerror(errno));                          fatal("cvs_checkout_file: fchmod: %s", strerror(errno));
   
                 if (exists == 0 && cf->file_ent == NULL)                  if ((exists == 0) && (cf->file_ent == NULL) &&
                       !(co_flags & CO_MERGE))
                         rcstime = rcs_rev_getdate(cf->file_rcs, rnum);                          rcstime = rcs_rev_getdate(cf->file_rcs, rnum);
                 else                  else
                         time(&rcstime);                          time(&rcstime);
Line 300 
Line 311 
                 if ((p = strrchr(cf->file_rpath, ',')) != NULL)                  if ((p = strrchr(cf->file_rpath, ',')) != NULL)
                         *p = '\0';                          *p = '\0';
   
                   if (co_flags & CO_MERGE) {
                           cvs_merge_file(cf, 1);
                           tosend = cf->file_path;
                   }
   
                 if (co_flags & CO_COMMIT)                  if (co_flags & CO_COMMIT)
                         cvs_server_update_entry("Checked-in", cf);                          cvs_server_update_entry("Checked-in", cf);
                   else if (co_flags & CO_MERGE)
                           cvs_server_update_entry("Merged", cf);
                 else                  else
                         cvs_server_update_entry("Updated", cf);                          cvs_server_update_entry("Updated", cf);
   
                 cvs_remote_output(entry);                  cvs_remote_output(entry);
   
                 if (!(co_flags & CO_COMMIT)) {                  if (!(co_flags & CO_COMMIT)) {
                         l = snprintf(template, MAXPATHLEN,                          if (!(co_flags & CO_MERGE)) {
                             "%s/checkout.XXXXXXXXXX", cvs_tmpdir);                                  l = snprintf(template, MAXPATHLEN,
                         if (l == -1 || l >= (int)sizeof(template))                                      "%s/checkout.XXXXXXXXXX", cvs_tmpdir);
                                 fatal("cvs_checkout_file: overflow");                                  if (l == -1 || l >= MAXPATHLEN)
                                           fatal("cvs_Checkout_file: overflow");
                                   rcs_rev_write_stmp(cf->file_rcs, rnum,
                                       template, 0);
                                   tosend = template;
                           }
   
                         /* XXX - fd race below */                          cvs_remote_send_file(tosend);
                         rcs_rev_write_stmp(cf->file_rcs, rnum, template, 0);  
                         cvs_remote_send_file(template);                          if (!(co_flags & CO_MERGE)) {
                         cvs_worklist_run(&temp_files, cvs_worklist_unlink);                                  (void)unlink(template);
                                   cvs_worklist_run(&temp_files,
                                       cvs_worklist_unlink);
                                   xfree(template);
                           }
                 }                  }
   
                 if (p != NULL)                  if (p != NULL)

Legend:
Removed from v.1.86  
changed lines
  Added in v.1.87