FreeBSD/contrib/subversion/subversion/libsvn_wc/workqueue.c
/* FILE_ABSPATH is the new text base of the newly-committed versioned file,
 * in repository-normal form (aka "detranslated" form).  Adjust the working
 * file accordingly.
 *
 * If eol and/or keyword translation would cause the working file to
 * change, then overwrite the working file with a translated copy of
 * the new text base (but only if the translated copy differs from the
 * current working file -- if they are the same, do nothing, to avoid
 * clobbering timestamps unnecessarily).
 *
 * Set the working file's executability according to its svn:executable
 * property.
 *
 * Set the working file's read-only attribute according to its properties
 * and lock status (see svn_wc__maybe_set_read_only()).
 *
 * If the working file was re-translated or had its executability or
 * read-only state changed,
 * then set OVERWROTE_WORKING to TRUE.  If the working file isn't
 * touched at all, then set to FALSE.
 *
 * Use SCRATCH_POOL for any temporary allocation.
 */
FILE_ABSPATH is the new text base of the newly-committed versioned file,
in repository-normal form (aka "detranslated" form).  Adjust the working
file accordingly.

If eol and/or keyword translation would cause the working file to
change, then overwrite the working file with a translated copy of
the new text base (but only if the translated copy differs from the
current working file -- if they are the same, do nothing, to avoid
clobbering timestamps unnecessarily).

Set the working file's executability according to its svn:executable
property.

Set the working file's read-only attribute according to its properties
and lock status ).

If the working file was re-translated or had its executability or
read-only state changed,
then set OVERWROTE_WORKING to TRUE.  If the working file isn't
touched at all, then set to FALSE.

Use SCRATCH_POOL for any temporary allocation.
FILE_ABSPATH is the new text base of the newly - committed versioned file in repository - normal form ( aka " detranslated " form ) . Adjust the working file accordingly . If eol and / or keyword translation would cause the working file to change then overwrite the working file with a translated copy of the new text base ( but only if the translated copy differs from the current working file -- if they are the same do nothing to avoid clobbering timestamps unnecessarily ) . Set the working file ' s executability according to its svn : executable property . Set the working file ' s read - only attribute according to its properties and lock status ) . If the working file was re - translated or had its executability or read - only state changed then set OVERWROTE_WORKING to TRUE . If the working file isn ' t touched at all then set to FALSE . Use SCRATCH_POOL for any temporary allocation .
static svn_error_t *
install_committed_file(svn_boolean_t *overwrote_working,
                       svn_wc__db_t *db,
                       const char *file_abspath,
                       svn_cancel_func_t cancel_func,
                       void *cancel_baton,
                       apr_pool_t *scratch_pool)
{
  svn_boolean_t same;
  const char *tmp_wfile;
  svn_boolean_t special;
  *overwrote_working = FALSE;
  {
    const char *tmp = file_abspath;
    SVN_ERR(svn_wc__internal_translated_file(&tmp_wfile, tmp, db,
                                             file_abspath,
                                             SVN_WC_TRANSLATE_FROM_NF,
                                             cancel_func, cancel_baton,
                                             scratch_pool, scratch_pool));
    SVN_ERR(svn_wc__get_translate_info(NULL, NULL,
                                       NULL,
                                       &special,
                                       db, file_abspath, NULL, FALSE,
                                       scratch_pool, scratch_pool));
    if (! special && tmp != tmp_wfile)
      SVN_ERR(svn_io_files_contents_same_p(&same, tmp_wfile,
                                           file_abspath, scratch_pool));
    else
      same = TRUE;
  }
  if (! same)
    {
      SVN_ERR(svn_io_file_rename(tmp_wfile, file_abspath, scratch_pool));
      *overwrote_working = TRUE;
    }
  SVN_ERR(svn_wc__sync_flags_with_props(overwrote_working, db, file_abspath,
                                        scratch_pool));
  return SVN_NO_ERROR;
}
static svn_error_t * install_committed_file ( svn_boolean_t * overwrote_working , svn_wc__db_t * db , const char * file_abspath , svn_cancel_func_t cancel_func , void * cancel_baton , apr_pool_t * scratch_pool ) { svn_boolean_t same ; const char * tmp_wfile ; svn_boolean_t special ; * overwrote_working = FALSE ; { const char * tmp = file_abspath ; SVN_ERR ( svn_wc__internal_translated_file ( & tmp_wfile , tmp , db , file_abspath , SVN_WC_TRANSLATE_FROM_NF , cancel_func , cancel_baton , scratch_pool , scratch_pool ) ) ; SVN_ERR ( svn_wc__get_translate_info ( NULL , NULL , NULL , & special , db , file_abspath , NULL , FALSE , scratch_pool , scratch_pool ) ) ; if ( ! special && tmp != tmp_wfile ) SVN_ERR ( svn_io_files_contents_same_p ( & same , tmp_wfile , file_abspath , scratch_pool ) ) ; else same = TRUE ; } if ( ! same ) { SVN_ERR ( svn_io_file_rename ( tmp_wfile , file_abspath , scratch_pool ) ) ; * overwrote_working = TRUE ; } SVN_ERR ( svn_wc__sync_flags_with_props ( overwrote_working , db , file_abspath , scratch_pool ) ) ; return SVN_NO_ERROR ; }
FILE_ABSPATH is the new text base of the newly-committed versioned file,
 in repository-normal form (aka "detranslated" form).
FILE_ABSPATH is the new text base of the newly - committed versioned file in repository - normal form ( aka " detranslated " form ) .
/* start off assuming that the working file isn't touched. */ /* In the commit, newlines and keywords may have been
   * canonicalized and/or contracted... Or they may not have
   * been.  It's kind of hard to know.  Here's how we find out:
   *
   *    1. Make a translated tmp copy of the committed text base,
   *       translated according to the versioned file's properties.
   *       Or, if no committed text base exists (the commit must have
   *       been a propchange only), make a translated tmp copy of the
   *       working file.
   *    2. Compare the translated tmpfile to the working file.
   *    3. If different, copy the tmpfile over working file.
   *
   * This means we only rewrite the working file if we absolutely
   * have to, which is good because it avoids changing the file's
   * timestamp unless necessary, so editors aren't tempted to
   * reread the file if they don't really need to.
   */ /* Copy and translate the new base-to-be file (if found, else the working
   * file) from repository-normal form to working form, writing a new
   * temporary file if any translation was actually done.  Set TMP_WFILE to
   * the translated file's path, which may be the source file's path if no
   * translation was done.  Set SAME to indicate whether the new working
   * text is the same as the old working text (or TRUE if it's a special
   * file). */ /* Copy and translate, if necessary. The output file will be deleted at
     * scratch_pool cleanup.
     * ### That's not quite safe: we might rename the file and then maybe
     * its path will get re-used for another temp file before pool clean-up.
     * Instead, we should take responsibility for deleting it. */ /* If the translation is a no-op, the text base and the working copy
     * file contain the same content, because we use the same props here
     * as were used to detranslate from working file to text base.
     *
     * In that case: don't replace the working file, but make sure
     * it has the right executable and read_write attributes set.
     */ /* Translated file returns the exact pointer if not translated. */ /* ### should be using OP_SYNC_FILE_FLAGS, or an internal version of
     ### that here. do we need to set *OVERWROTE_WORKING? */ /* ### Re: OVERWROTE_WORKING, the following function is rather liberal
     ### with setting that flag, so we should probably decide if we really
     ### care about it when syncing flags. */