[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r940898 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c libsvn_wc/wc_db.h tests/libsvn_wc/pristine-store-test.c

From: Greg Stein <gstein_at_gmail.com>
Date: Tue, 4 May 2010 13:41:18 -0400

On Tue, May 4, 2010 at 11:14, <julianfoad_at_apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue May  4 15:14:13 2010
> @@ -2560,6 +2560,75 @@ svn_wc__db_pristine_install(svn_wc__db_t
>
>
>  svn_error_t *
> +svn_wc__db_pristine_remove(svn_wc__db_t *db,
> +                           const char *wri_abspath,
> +                           const svn_checksum_t *sha1_checksum,
> +                           apr_pool_t *scratch_pool)
> +{
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath;
> +  const char *pristine_abspath;
> +  svn_error_t *err;
> +  const svn_checksum_t *md5_checksum;
> +  svn_boolean_t is_referenced = FALSE;

Why initialize this? It will be unconditionally set below.

> +
> +  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
> +  SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
> +
> +  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, wri_abspath,
> +                              svn_sqlite__mode_readwrite,
> +                              scratch_pool, scratch_pool));
> +  VERIFY_USABLE_PDH(pdh);
> +
> +  err = get_pristine_fname(&pristine_abspath, pdh, sha1_checksum,
> +#ifndef SVN__SKIP_SUBDIR
> +                           TRUE /* create_subdir */,
> +#endif
> +                           scratch_pool, scratch_pool);
> +  SVN_ERR(err);

Why compute the path so early? This won't be needed unless/until you
actually determine the file should be removed.

> +
> +  /* Find whether the SHA-1 (or the MD-5) is referenced; set IS_REFERENCED. */
> +  {
> +    svn_sqlite__stmt_t *stmt;
> +
> +    /* ### Transitional: look for references to its MD-5 as well. */
> +    SVN_ERR(svn_wc__db_pristine_get_md5(&md5_checksum, db, wri_abspath,
> +                                        sha1_checksum, scratch_pool, scratch_pool));
> +
> +    SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                      STMT_SELECT_ANY_PRISTINE_REFERENCE));
> +    SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
> +    SVN_ERR(svn_sqlite__bind_checksum(stmt, 2, md5_checksum, scratch_pool));
> +    SVN_ERR(svn_sqlite__step(&is_referenced, stmt));
> +
> +    SVN_ERR(svn_sqlite__reset(stmt));
> +  }
> +
> +  /* If not referenced, remove first the PRISTINE table row, then the file. */
> +  if (! is_referenced)
> +    {
> +      svn_sqlite__stmt_t *stmt;
> +
> +      /* Remove the DB row. */
> +      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                        STMT_DELETE_PRISTINE));
> +      SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
> +      SVN_ERR(svn_sqlite__update(NULL, stmt));
> +
> +      /* Remove the file */
> +      SVN_ERR(svn_io_remove_file2(pristine_abspath, TRUE, scratch_pool));
> +    SVN_DBG(("Was referenced: '%s'\n",
> +           svn_checksum_to_cstring_display(md5_checksum, scratch_pool)));

Here...

> +    }
> +  else
> +    SVN_DBG(("Not referenced: '%s'\n",
> +           svn_checksum_to_cstring_display(md5_checksum, scratch_pool)));

... and here. SVN_DBG cannot be left in the committed source code. The
macro does not exist in release builds.

>...
> +++ subversion/trunk/subversion/libsvn_wc/wc_db.h Tue May  4 15:14:13 2010
> @@ -866,6 +866,16 @@ svn_wc__db_pristine_get_md5(const svn_ch
>                             apr_pool_t *scratch_pool);
>
>
> +/* Remove the pristine text with SHA-1 checksum SHA1_CHECKSUM from the
> + * pristine store, iff it is not referenced by any of the (other) WC DB
> + * tables. */

Also remember that we don't want to remove pristines why
administrative locks (WCLOCK) are present. That may signify a commit
is occurring and needed pristines are transiently living in the
pristine storage.

>...

Cheers,
-g
Received on 2010-05-04 19:41:49 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.