You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/05/06 10:53:11 UTC

svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h

Author: julianfoad
Date: Thu May  6 08:53:11 2010
New Revision: 941617

URL: http://svn.apache.org/viewvc?rev=941617&view=rev
Log:
Add a function for looking up a pristine text's SHA-1 checksum from its MD-5
checksum - the inverse of svn_wc__db_pristine_get_md5().

* subversion/libsvn_wc/wc_db.c,
  subversion/libsvn_wc/wc_db.h
  (svn_wc__db_pristine_get_md5): Rename parameters in the function prototype
    to match the function definition.
  (svn_wc__db_pristine_get_sha1): New function.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_PRISTINE_SHA1_CHECKSUM): New query.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=941617&r1=941616&r2=941617&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu May  6 08:53:11 2010
@@ -289,6 +289,11 @@ SELECT md5_checksum
 FROM pristine
 WHERE checksum = ?1
 
+-- STMT_SELECT_PRISTINE_SHA1_CHECKSUM
+SELECT checksum
+FROM pristine
+WHERE md5_checksum = ?1
+
 -- STMT_SELECT_ANY_PRISTINE_REFERENCE
 SELECT 1 FROM base_node
   WHERE checksum = ?1 OR checksum = ?2

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=941617&r1=941616&r2=941617&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu May  6 08:53:11 2010
@@ -7467,6 +7467,45 @@ svn_wc__db_pristine_get_md5(const svn_ch
 
 
 svn_error_t *
+svn_wc__db_pristine_get_sha1(const svn_checksum_t **sha1_checksum,
+                             svn_wc__db_t *db,
+                             const char *wri_abspath,
+                             const svn_checksum_t *md5_checksum,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool)
+{
+  svn_wc__db_pdh_t *pdh;
+  const char *local_relpath;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
+  SVN_ERR_ASSERT(md5_checksum->kind == svn_checksum_md5);
+
+  SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, wri_abspath,
+                              svn_sqlite__mode_readonly,
+                              scratch_pool, scratch_pool));
+  VERIFY_USABLE_PDH(pdh);
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+                                    STMT_SELECT_PRISTINE_SHA1_CHECKSUM));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, md5_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  if (!have_row)
+    return svn_error_createf(SVN_ERR_WC_DB_ERROR, svn_sqlite__reset(stmt),
+                             _("The pristine text with MD5 checksum '%s' was "
+                               "not found"),
+                             svn_checksum_to_cstring_display(md5_checksum,
+                                                             scratch_pool));
+
+  SVN_ERR(svn_sqlite__column_checksum(sha1_checksum, stmt, 0, result_pool));
+  SVN_ERR_ASSERT((*sha1_checksum)->kind == svn_checksum_sha1);
+
+  return svn_error_return(svn_sqlite__reset(stmt));
+}
+
+
+svn_error_t *
 svn_wc__db_temp_remove_subdir_record(svn_wc__db_t *db,
                                      const char *local_abspath,
                                      apr_pool_t *scratch_pool)

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=941617&r1=941616&r2=941617&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Thu May  6 08:53:11 2010
@@ -852,20 +852,40 @@ svn_wc__db_pristine_install(svn_wc__db_t
                             apr_pool_t *scratch_pool);
 
 
-/* Set *PRISTINE_MD5_CHECKSUM to the MD-5 checksum of a pristine text
-   identified by its SHA-1 checksum PRISTINE_SHA1_CHECKSUM. Return an error
+/* Set *MD5_CHECKSUM to the MD-5 checksum of a pristine text
+   identified by its SHA-1 checksum SHA1_CHECKSUM. Return an error
    if the pristine text does not exist or its MD5 checksum is not found.
 
-   Allocate *PRISTINE_MD5_CHECKSUM in RESULT_POOL. */
+   Allocate *MD5_CHECKSUM in RESULT_POOL. */
 svn_error_t *
-svn_wc__db_pristine_get_md5(const svn_checksum_t **pristine_md5_checksum,
+svn_wc__db_pristine_get_md5(const svn_checksum_t **md5_checksum,
                             svn_wc__db_t *db,
                             const char *wri_abspath,
-                            const svn_checksum_t *pristine_sha1_checksum,
+                            const svn_checksum_t *sha1_checksum,
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool);
 
 
+/* Set *SHA1_CHECKSUM to the SHA-1 checksum of a pristine text
+   identified by its MD-5 checksum MD5_CHECKSUM. Return an error
+   if the pristine text does not exist or its SHA-1 checksum is not found.
+
+   Note: The MD-5 checksum is not strictly guaranteed to be unique in the
+   database table, although duplicates are expected to be extremely rare.
+   ### TODO: The behaviour is currently unspecified if the MD-5 checksum is
+   not unique. Need to see whether this function is going to stay in use,
+   and, if so, address this somehow.
+
+   Allocate *SHA1_CHECKSUM in RESULT_POOL. */
+svn_error_t *
+svn_wc__db_pristine_get_sha1(const svn_checksum_t **sha1_checksum,
+                             svn_wc__db_t *db,
+                             const char *wri_abspath,
+                             const svn_checksum_t *md5_checksum,
+                             apr_pool_t *result_pool,
+                             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. */



Re: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h

Posted by Greg Stein <gs...@gmail.com>.
On Thu, May 6, 2010 at 08:13, Julian Foad <ju...@wandisco.com> wrote:
> Bert Huijben wrote:
>> > -----Original Message-----
>> > From: julianfoad@apache.org [mailto:julianfoad@apache.org]
>> > Sent: donderdag 6 mei 2010 10:53
>> > To: commits@subversion.apache.org
>> > Subject: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc:
>> > wc-queries.sql wc_db.c wc_db.h
>> >
>> > Author: julianfoad
>> > Date: Thu May  6 08:53:11 2010
>> > New Revision: 941617
>> >
>> > URL: http://svn.apache.org/viewvc?rev=941617&view=rev
>> > Log:
>> > Add a function for looking up a pristine text's SHA-1 checksum from its MD-5
>> > checksum - the inverse of svn_wc__db_pristine_get_md5().
>> >
>> > * subversion/libsvn_wc/wc_db.c,
>> >   subversion/libsvn_wc/wc_db.h
>> >   (svn_wc__db_pristine_get_md5): Rename parameters in the function
>> > prototype
>> >     to match the function definition.
>> >   (svn_wc__db_pristine_get_sha1): New function.
>>
>> I think you should make this a '_temp_' function as we should not do
>> this conversion in 1.7.0. (But it is very useful in the intermediate
>> state where we are now).
>> Or is it needed for the commit processing via the old API?
>
> Oh, OK... I thought all the functions were considered temp until we
> review them.  Can I leave it for now as I know I'll be coming back to it
> later anyway.  I don't know yet whether it will be needed.  I'll find
> out soon when I write that old API stuff :-)

svn_wc__db_temp_* are functions that we KNOW should not be part of the
"final" API. They generally break some abstraction or perform some
work on the database in a non-ideal fashion.

Cheers,
-g

RE: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h

Posted by Julian Foad <ju...@wandisco.com>.
Bert Huijben wrote:
> > -----Original Message-----
> > From: julianfoad@apache.org [mailto:julianfoad@apache.org]
> > Sent: donderdag 6 mei 2010 10:53
> > To: commits@subversion.apache.org
> > Subject: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc:
> > wc-queries.sql wc_db.c wc_db.h
> > 
> > Author: julianfoad
> > Date: Thu May  6 08:53:11 2010
> > New Revision: 941617
> > 
> > URL: http://svn.apache.org/viewvc?rev=941617&view=rev
> > Log:
> > Add a function for looking up a pristine text's SHA-1 checksum from its MD-5
> > checksum - the inverse of svn_wc__db_pristine_get_md5().
> > 
> > * subversion/libsvn_wc/wc_db.c,
> >   subversion/libsvn_wc/wc_db.h
> >   (svn_wc__db_pristine_get_md5): Rename parameters in the function
> > prototype
> >     to match the function definition.
> >   (svn_wc__db_pristine_get_sha1): New function.
> 
> I think you should make this a '_temp_' function as we should not do
> this conversion in 1.7.0. (But it is very useful in the intermediate
> state where we are now). 
> Or is it needed for the commit processing via the old API?

Oh, OK... I thought all the functions were considered temp until we
review them.  Can I leave it for now as I know I'll be coming back to it
later anyway.  I don't know yet whether it will be needed.  I'll find
out soon when I write that old API stuff :-)

- Julian


RE: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c wc_db.h

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: julianfoad@apache.org [mailto:julianfoad@apache.org]
> Sent: donderdag 6 mei 2010 10:53
> To: commits@subversion.apache.org
> Subject: svn commit: r941617 - in /subversion/trunk/subversion/libsvn_wc:
> wc-queries.sql wc_db.c wc_db.h
> 
> Author: julianfoad
> Date: Thu May  6 08:53:11 2010
> New Revision: 941617
> 
> URL: http://svn.apache.org/viewvc?rev=941617&view=rev
> Log:
> Add a function for looking up a pristine text's SHA-1 checksum from its MD-5
> checksum - the inverse of svn_wc__db_pristine_get_md5().
> 
> * subversion/libsvn_wc/wc_db.c,
>   subversion/libsvn_wc/wc_db.h
>   (svn_wc__db_pristine_get_md5): Rename parameters in the function
> prototype
>     to match the function definition.
>   (svn_wc__db_pristine_get_sha1): New function.

I think you should make this a '_temp_' function as we should not do this conversion in 1.7.0. (But it is very useful in the intermediate state where we are now). 
Or is it needed for the commit processing via the old API?

	Bert