Author: rhuijben
Date: Tue Apr 12 12:00:48 2011
New Revision: 1091381
URL: http://svn.apache.org/viewvc?rev=1091381&view=rev
Log:
The update editor shouldn't use the ultimate base wrappers when it can
directly use the wc-db and pristine apis; especially if it is the only
user of most of these apis that expose to much pristine internals.
* subversion/libsvn_wc/update_editor.c
(file_baton): Constify the resulting checksums and add the original checksum
to avoid retrieving it in a few places.
(open_file): Read checksum when we are reading anyway.
(apply_textdelta): Use checksum from baton instead of retrieving it two
times.
(merge_file): Find the path via the checksum instead of from the db.
(close_file): Use the checksum from the baton instead of retrieving it.
* subversion/libsvn_wc/wc_db_pristine.c
(svn_wc__db_pristine_read): Remove the transitational md5->sha1 fixup.
Modified:
subversion/trunk/subversion/libsvn_wc/update_editor.c
subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1091381&r1=1091380&r2=1091381&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 12 12:00:48
2011
@@ -836,8 +836,11 @@ struct file_baton
/* If there are file content changes, these are the checksums of the
resulting new text base, which is in the pristine store, else NULL. */
- svn_checksum_t *new_text_base_md5_checksum;
- svn_checksum_t *new_text_base_sha1_checksum;
+ const svn_checksum_t *new_text_base_md5_checksum;
+ const svn_checksum_t *new_text_base_sha1_checksum;
+
+ /* The checksum of the file before the update */
+ const svn_checksum_t *original_checksum;
/* Set if we've received an apply_textdelta for this file. */
svn_boolean_t received_textdelta;
@@ -3138,19 +3141,20 @@ open_file(const char *path,
/* If replacing, make sure the .svn entry already exists. */
SVN_ERR(svn_wc__db_read_info(&status, &wc_kind, &fb->old_revision, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &fb->original_checksum,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, &have_work, &conflicted, NULL,
eb->db, fb->local_abspath,
- scratch_pool, scratch_pool));
+ fb->pool, scratch_pool));
if (have_work)
SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, &fb->old_revision,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
+ NULL, &fb->original_checksum, NULL, NULL,
NULL, NULL,
eb->db, fb->local_abspath,
- scratch_pool, scratch_pool));
+ fb->pool, scratch_pool));
/* Is this path a conflict victim? */
if (conflicted)
@@ -3217,6 +3221,7 @@ apply_textdelta(void *file_baton,
struct file_baton *fb = file_baton;
apr_pool_t *handler_pool = svn_pool_create(fb->pool);
struct handler_baton *hb = apr_pcalloc(handler_pool, sizeof(*hb));
+ struct edit_baton *eb = fb->edit_baton;
svn_error_t *err;
const char *recorded_base_checksum;
svn_stream_t *source;
@@ -3240,12 +3245,16 @@ apply_textdelta(void *file_baton,
for replaced nodes because we didn't store the checksum of the "revert
base". In WC-NG, we do and we can.) */
{
- const svn_checksum_t *checksum;
+ const svn_checksum_t *checksum = fb->original_checksum;
+
+ /* If we have a checksum that we want to compare to a MD5 checksum,
+ ensure that it is a MD5 checksum */
+ if (checksum
+ && expected_base_checksum
+ && checksum->kind != svn_checksum_md5)
+ SVN_ERR(svn_wc__db_pristine_get_md5(&checksum, eb->db, fb->local_abspath,
+ checksum, pool, pool));
- SVN_ERR(svn_wc__get_ultimate_base_checksums(NULL, &checksum,
- fb->edit_baton->db,
- fb->local_abspath,
- pool, pool));
recorded_base_checksum = svn_checksum_to_cstring(checksum, pool);
if (recorded_base_checksum && expected_base_checksum
&& strcmp(expected_base_checksum, recorded_base_checksum) != 0)
@@ -3274,11 +3283,11 @@ apply_textdelta(void *file_baton,
if (! fb->adding_file)
{
- SVN_ERR(svn_wc__get_ultimate_base_contents(&source, fb->edit_baton->db,
- fb->local_abspath,
- handler_pool, handler_pool));
- if (source == NULL)
- source = svn_stream_empty(handler_pool);
+ SVN_ERR_ASSERT(!fb->original_checksum || fb->original_checksum->kind ==
svn_checksum_sha1);
+ SVN_ERR(svn_wc__db_pristine_read(&source, fb->edit_baton->db,
+ fb->local_abspath,
+ fb->original_checksum,
+ handler_pool, handler_pool));
}
else
{
@@ -3546,9 +3555,10 @@ merge_file(svn_skel_t **work_items,
delete_left = TRUE;
}
else
- SVN_ERR(svn_wc__ultimate_base_text_path_to_read(
- &merge_left, eb->db, fb->local_abspath,
- result_pool, scratch_pool));
+ SVN_ERR(svn_wc__db_pristine_get_path(&merge_left, eb->db,
+ fb->local_abspath,
+ fb->original_checksum,
+ result_pool, scratch_pool));
/* Merge the changes from the old textbase to the new
textbase into the file we're updating.
@@ -4029,15 +4039,7 @@ close_file(void *file_baton,
/* If we don't have a NEW checksum, then the base must not have changed.
Just carry over the old checksum. */
if (new_checksum == NULL)
- {
- SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL,
- NULL, NULL, NULL,
- NULL, NULL, NULL,
- NULL, NULL,
- &new_checksum, NULL, NULL, NULL, NULL,
- eb->db, fb->local_abspath,
- scratch_pool, scratch_pool));
- }
+ new_checksum = fb->original_checksum;
/* The adm crawler skips file externals for us, so we only have to check
for them at the editor target path. */
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c?rev=1091381&r1=1091380&r2=1091381&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pristine.c Tue Apr 12 12:00:48
2011
@@ -215,12 +215,6 @@ svn_wc__db_pristine_read(svn_stream_t **
SVN_ERR_ASSERT(contents != NULL);
SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
SVN_ERR_ASSERT(sha1_checksum != NULL);
- /* ### Transitional: accept MD-5 and look up the SHA-1. Return an error
- * if the pristine text is not in the store. */
- if (sha1_checksum->kind != svn_checksum_sha1)
- SVN_ERR(svn_wc__db_pristine_get_sha1(&sha1_checksum, db, wri_abspath,
- sha1_checksum,
- scratch_pool, scratch_pool));
SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,