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

Diff for /src/usr.bin/rcs/co.c between version 1.17 and 1.18

version 1.17, 2005/10/16 15:46:07 version 1.18, 2005/10/17 15:33:12
Line 43 
Line 43 
 checkout_main(int argc, char **argv)  checkout_main(int argc, char **argv)
 {  {
         int i, ch;          int i, ch;
         int lock;          int fflag, lock;
         RCSNUM *frev, *rev;          RCSNUM *frev, *rev;
         RCSFILE *file;          RCSFILE *file;
         char fpath[MAXPATHLEN], buf[16];          char fpath[MAXPATHLEN], buf[16];
         char *username;          char *username;
   
         lock = 0;          fflag = lock = 0;
         rev = RCS_HEAD_REV;          rev = RCS_HEAD_REV;
         frev = NULL;          frev = NULL;
   
Line 58 
Line 58 
                 exit (1);                  exit (1);
         }          }
   
         while ((ch = rcs_getopt(argc, argv, "l::qr::u::V")) != -1) {          while ((ch = rcs_getopt(argc, argv, "f::l::qr::u::V")) != -1) {
                 switch (ch) {                  switch (ch) {
                   case 'f':
                           if (rev != RCS_HEAD_REV)
                                   cvs_log(LP_WARN,
                                       "redefinition of revision number");
                           if (rcs_optarg != NULL) {
                                   if ((rev = rcsnum_parse(rcs_optarg)) == NULL) {
                                           cvs_log(LP_ERR, "bad revision number");
                                           exit (1);
                                   }
                           }
                           fflag = 1;
                           break;
                 case 'l':                  case 'l':
                         if (rev != RCS_HEAD_REV)                          if (rev != RCS_HEAD_REV)
                                 cvs_log(LP_WARN,                                  cvs_log(LP_WARN,
Line 130 
Line 142 
   
                 rcsnum_tostr(frev, buf, sizeof(buf));                  rcsnum_tostr(frev, buf, sizeof(buf));
   
                 if (checkout_rev(file, frev, argv[i], lock, username) < 0) {                  if (checkout_rev(file, frev, argv[i], lock, username, fflag) < 0) {
                         rcs_close(file);                          rcs_close(file);
                         continue;                          continue;
                 }                  }
Line 162 
Line 174 
  */   */
 int  int
 checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int lkmode,  checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int lkmode,
     const char *username)      const char *username, int force)
 {  {
         char buf[16];          char buf[16], yn;
         mode_t mode = 0444;          mode_t mode = 0444;
         BUF *bp;          BUF *bp;
           struct stat st;
   
         /*          /*
          * Check out the latest revision if <frev> is greater than HEAD           * Check out the latest revision if <frev> is greater than HEAD
Line 176 
Line 189 
   
         rcsnum_tostr(frev, buf, sizeof(buf));          rcsnum_tostr(frev, buf, sizeof(buf));
   
           if (verbose == 1)
                   printf("revision %s", buf);
   
         if ((bp = rcs_getrev(file, frev)) == NULL) {          if ((bp = rcs_getrev(file, frev)) == NULL) {
                 cvs_log(LP_ERR, "cannot find revision `%s'", buf);                  cvs_log(LP_ERR, "cannot find revision `%s'", buf);
                 return (-1);                  return (-1);
Line 189 
Line 205 
                         else                          else
                                 cvs_log(LP_WARN, "you already have a lock");                                  cvs_log(LP_WARN, "you already have a lock");
                 }                  }
   
                 mode = 0644;                  mode = 0644;
                   if (verbose == 1)
                           printf(" (locked)");
         } else if (lkmode == LOCK_UNLOCK) {          } else if (lkmode == LOCK_UNLOCK) {
                 if (rcs_lock_remove(file, frev) < 0) {                  if (rcs_lock_remove(file, frev) < 0) {
                         if (rcs_errno != RCS_ERR_NOENT)                          if (rcs_errno != RCS_ERR_NOENT)
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "failed to remove lock '%s'", buf);                                      "failed to remove lock '%s'", buf);
                 }                  }
   
                 mode = 0444;                  mode = 0444;
                   if (verbose == 1)
                           printf(" (unlocked)");
         }          }
   
           if (verbose == 1)
                   printf("\n");
   
           if ((stat(dst, &st) != -1) && force == 0) {
                   if (st.st_mode & S_IWUSR) {
                           yn = 0;
                           while (yn != 'y' && yn != 'n') {
                                   printf("writeable '%s' exists; ", dst);
                                   printf("remove it? [ny] (n):");
                                   fflush(stdout);
                                   yn = getchar();
                           }
   
                           if (yn == 'n') {
                                   if (verbose == 1)
                                           cvs_log(LP_ERR, "checkout aborted");
                                   return (-1);
                           }
                   }
           }
   
         if (cvs_buf_write(bp, dst, mode) < 0) {          if (cvs_buf_write(bp, dst, mode) < 0) {
                 cvs_log(LP_ERR, "failed to write revision to file");                  cvs_log(LP_ERR, "failed to write revision to file");
                 cvs_buf_free(bp);                  cvs_buf_free(bp);
Line 207 
Line 250 
   
         cvs_buf_free(bp);          cvs_buf_free(bp);
   
         if (verbose == 1) {          if (verbose == 1)
                 cvs_printf("revision %s ", buf);                  printf("done\n");
                 if (lkmode == LOCK_LOCK)  
                         cvs_printf("(locked)");  
                 else if (lkmode == LOCK_UNLOCK)  
                         cvs_printf("(unlocked)");  
                 cvs_printf("\n");  
                 cvs_printf("done\n");  
         }  
   
         return (0);          return (0);
 }  }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18