home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / cvs-1.8.7-src.tgz / tar.out / fsf / cvs / src / no_diff.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  124 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.4 kit.
  7.  * 
  8.  * No Difference
  9.  * 
  10.  * The user file looks modified judging from its time stamp; however it needn't
  11.  * be.  No_difference() finds out whether it is or not. If it is not, it
  12.  * updates the administration.
  13.  * 
  14.  * returns 0 if no differences are found and non-zero otherwise
  15.  */
  16.  
  17. #include "cvs.h"
  18.  
  19. int
  20. No_Difference (finfo, vers)
  21.     struct file_info *finfo;
  22.     Vers_TS *vers;
  23. {
  24.     Node *p;
  25.     char *tmp;
  26.     int ret;
  27.     char *ts, *options;
  28.     int retcode = 0;
  29.     char *tocvsPath;
  30.  
  31.     if (!vers->srcfile || !vers->srcfile->path)
  32.     return (-1);            /* different since we couldn't tell */
  33.  
  34.     if (vers->entdata && vers->entdata->options)
  35.     options = xstrdup (vers->entdata->options);
  36.     else
  37.     options = xstrdup ("");
  38.  
  39.     tmp = cvs_temp_name ();
  40.     retcode = RCS_fast_checkout (vers->srcfile, NULL, vers->vn_user, options,
  41.                  tmp, 0);
  42.     if (retcode == 0)
  43.     {
  44. #if 0
  45.     /* Why would we want to munge the modes?  And only if the timestamps
  46.        are different?  And even for commands like "cvs status"????  */
  47.     if (!iswritable (finfo->file))        /* fix the modes as a side effect */
  48.         xchmod (finfo->file, 1);
  49. #endif
  50.  
  51.     tocvsPath = wrap_tocvs_process_file (finfo->file);
  52.  
  53.     /* do the byte by byte compare */
  54.     if (xcmp (tocvsPath == NULL ? finfo->file : tocvsPath, tmp) == 0)
  55.     {
  56. #if 0
  57.         /* Why would we want to munge the modes?  And only if the
  58.            timestamps are different?  And even for commands like
  59.            "cvs status"????  */
  60.         if (cvswrite == FALSE)    /* fix the modes as a side effect */
  61.         xchmod (finfo->file, 0);
  62. #endif
  63.  
  64.         /* no difference was found, so fix the entries file */
  65.         ts = time_stamp (finfo->file);
  66.         Register (finfo->entries, finfo->file,
  67.               vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
  68.               options, vers->tag, vers->date, (char *) 0);
  69. #ifdef SERVER_SUPPORT
  70.         if (server_active)
  71.         {
  72.         /* We need to update the entries line on the client side.  */
  73.         server_update_entries
  74.           (finfo->file, finfo->update_dir, finfo->repository, SERVER_UPDATED);
  75.         }
  76. #endif
  77.         free (ts);
  78.  
  79.         /* update the entdata pointer in the vers_ts structure */
  80.         p = findnode (finfo->entries, finfo->file);
  81.         vers->entdata = (Entnode *) p->data;
  82.  
  83.         ret = 0;
  84.     }
  85.     else
  86.         ret = 1;            /* files were really different */
  87.         if (tocvsPath)
  88.     {
  89.         /* Need to call unlink myself because the noexec variable
  90.          * has been set to 1.  */
  91.         if (trace)
  92.         (void) fprintf (stderr, "%c-> unlink (%s)\n",
  93. #ifdef SERVER_SUPPORT
  94.                 (server_active) ? 'S' : ' ',
  95. #else
  96.                 ' ',
  97. #endif
  98.                 tocvsPath);
  99.         if ( CVS_UNLINK (tocvsPath) < 0)
  100.         error (0, errno, "could not remove %s", tocvsPath);
  101.     }
  102.     }
  103.     else
  104.     {
  105.     error (0, retcode == -1 ? errno : 0,
  106.            "could not check out revision %s of %s",
  107.            vers->vn_user, finfo->fullname);
  108.     ret = -1;            /* different since we couldn't tell */
  109.     }
  110.  
  111.     if (trace)
  112. #ifdef SERVER_SUPPORT
  113.     (void) fprintf (stderr, "%c-> unlink2 (%s)\n",
  114.             (server_active) ? 'S' : ' ', tmp);
  115. #else
  116.     (void) fprintf (stderr, "-> unlink (%s)\n", tmp);
  117. #endif
  118.     if (CVS_UNLINK (tmp) < 0)
  119.     error (0, errno, "could not remove %s", tmp);
  120.     free (tmp);
  121.     free (options);
  122.     return (ret);
  123. }
  124.