You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/05/18 21:54:39 UTC
svn commit: r1595667 - in /subversion/trunk/subversion/libsvn_fs_x: ./
rep-cache.c rep-cache.h transaction.c
Author: stefan2
Date: Sun May 18 19:54:38 2014
New Revision: 1595667
URL: http://svn.apache.org/r1595667
Log:
Sync'ing FSX with FSFS:
Merge r1548170,1560673 from /subversion/libsvn_fs_fs into
subversion/libsvn_fs_x. Conflicts were due naming differences between
FSX and FSFS.
These are rep-cache.db handling patches.
Modified:
subversion/trunk/subversion/libsvn_fs_x/ (props changed)
subversion/trunk/subversion/libsvn_fs_x/rep-cache.c
subversion/trunk/subversion/libsvn_fs_x/rep-cache.h
subversion/trunk/subversion/libsvn_fs_x/transaction.c
Propchange: subversion/trunk/subversion/libsvn_fs_x/
------------------------------------------------------------------------------
Merged /subversion/trunk/subversion/libsvn_fs_fs:r1548170,1560673
Modified: subversion/trunk/subversion/libsvn_fs_x/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rep-cache.c?rev=1595667&r1=1595666&r2=1595667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rep-cache.c Sun May 18 19:54:38 2014
@@ -50,21 +50,6 @@ path_rep_cache_db(const char *fs_path,
return svn_dirent_join(fs_path, REP_CACHE_DB_NAME, result_pool);
}
-/* Check that REP refers to a revision that exists in FS. */
-static svn_error_t *
-rep_has_been_born(representation_t *rep,
- svn_fs_t *fs,
- apr_pool_t *pool)
-{
- svn_revnum_t revision = svn_fs_x__get_revnum(rep->id.change_set);
- SVN_ERR_ASSERT(rep);
-
- SVN_ERR(svn_fs_x__ensure_revision_exists(revision, fs, pool));
-
- return SVN_NO_ERROR;
-}
-
-
/** Library-private API's. **/
@@ -84,6 +69,31 @@ open_rep_cache(void *baton,
/* Open (or create) the sqlite database. It will be automatically
closed when fs->pool is destroyed. */
db_path = path_rep_cache_db(fs->path, pool);
+#ifndef WIN32
+ {
+ /* We want to extend the permissions that apply to the repository
+ as a whole when creating a new rep cache and not simply default
+ to umask. */
+ svn_boolean_t exists;
+
+ SVN_ERR(svn_fs_x__exists_rep_cache(&exists, fs, pool));
+ if (!exists)
+ {
+ const char *current = svn_fs_x__path_current(fs, pool);
+ svn_error_t *err = svn_io_file_create_empty(db_path, pool);
+
+ if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
+ /* A real error. */
+ return svn_error_trace(err);
+ else if (err)
+ /* Some other thread/process created the file. */
+ svn_error_clear(err);
+ else
+ /* We created the file. */
+ SVN_ERR(svn_io_copy_perms(current, db_path, pool));
+ }
+ }
+#endif
SVN_ERR(svn_sqlite__open(&sdb, db_path,
svn_sqlite__mode_rwcreate, statements,
0, NULL, 0,
@@ -265,7 +275,16 @@ svn_fs_x__get_rep_reference(representati
SVN_ERR(svn_sqlite__reset(stmt));
if (*rep)
- SVN_ERR(rep_has_been_born(*rep, fs, pool));
+ {
+ /* Check that REP refers to a revision that exists in FS. */
+ svn_revnum_t revision = svn_fs_x__get_revnum((*rep)->id.change_set);
+ svn_error_t *err = svn_fs_x__ensure_revision_exists(revision, fs, pool);
+ if (err)
+ return svn_error_createf(SVN_ERR_FS_CORRUPT, err,
+ "Checksum '%s' in rep-cache is beyond HEAD",
+ svn_checksum_to_cstring_display(checksum,
+ pool));
+ }
return SVN_NO_ERROR;
}
@@ -273,7 +292,6 @@ svn_fs_x__get_rep_reference(representati
svn_error_t *
svn_fs_x__set_rep_reference(svn_fs_t *fs,
representation_t *rep,
- svn_boolean_t reject_dup,
apr_pool_t *pool)
{
fs_x_data_t *ffd = fs->fsap_data;
@@ -312,33 +330,11 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs
svn_error_clear(err);
/* Constraint failed so the mapping for SHA1_CHECKSUM->REP
- should exist. If so, and the value is the same one we were
- about to write, that's cool -- just do nothing. If, however,
- the value is *different*, that's a red flag! */
+ should exist. If so that's cool -- just do nothing. If not,
+ that's a red flag! */
SVN_ERR(svn_fs_x__get_rep_reference(&old_rep, fs, &checksum, pool));
- if (old_rep)
- {
- if (reject_dup && (!svn_fs_x__id_part_eq(&old_rep->id, &rep->id)
- || (old_rep->size != rep->size)
- || (old_rep->expanded_size != rep->expanded_size)))
- return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
- apr_psprintf(pool,
- _("Representation key for checksum '%%s' exists "
- "in filesystem '%%s' with a different value "
- "(%%ld,%%%s,%%%s,%%%s) than what we were about "
- "to store (%%ld,%%%s,%%%s,%%%s)"),
- APR_OFF_T_FMT, SVN_FILESIZE_T_FMT,
- SVN_FILESIZE_T_FMT, APR_OFF_T_FMT,
- SVN_FILESIZE_T_FMT, SVN_FILESIZE_T_FMT),
- svn_checksum_to_cstring_display(&checksum, pool),
- fs->path, old_rep->id.change_set, old_rep->id.number,
- old_rep->size, old_rep->expanded_size, rep->id.change_set,
- rep->id.number, rep->size, rep->expanded_size);
- else
- return SVN_NO_ERROR;
- }
- else
+ if (!old_rep)
{
/* Something really odd at this point, we failed to insert the
checksum AND failed to read an existing checksum. Do we need
Modified: subversion/trunk/subversion/libsvn_fs_x/rep-cache.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rep-cache.h?rev=1595667&r1=1595666&r2=1595667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/rep-cache.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rep-cache.h Sun May 18 19:54:38 2014
@@ -62,7 +62,8 @@ svn_fs_x__walk_rep_reference(svn_fs_t *f
/* Return the representation REP in FS which has fulltext CHECKSUM.
REP is allocated in POOL. If the rep cache database has not been
- opened, just set *REP to NULL. */
+ opened, just set *REP to NULL. Returns SVN_ERR_FS_CORRUPT if
+ a reference beyond HEAD is detected. */
svn_error_t *
svn_fs_x__get_rep_reference(representation_t **rep,
svn_fs_t *fs,
@@ -70,16 +71,13 @@ svn_fs_x__get_rep_reference(representati
apr_pool_t *pool);
/* Set the representation REP in FS, using REP->CHECKSUM.
- Use POOL for temporary allocations.
+ Use POOL for temporary allocations. Returns SVN_ERR_FS_CORRUPT if
+ an existing reference beyond HEAD is detected.
- If the rep cache database has not been opened, this may be a no op.
-
- If REJECT_DUP is TRUE, return an error if there is an existing
- match for REP->CHECKSUM. */
+ If the rep cache database has not been opened, this may be a no op. */
svn_error_t *
svn_fs_x__set_rep_reference(svn_fs_t *fs,
representation_t *rep,
- svn_boolean_t reject_dup,
apr_pool_t *pool);
/* Delete from the cache all reps corresponding to revisions younger
Modified: subversion/trunk/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/transaction.c?rev=1595667&r1=1595666&r2=1595667&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/transaction.c Sun May 18 19:54:38 2014
@@ -3555,7 +3555,7 @@ write_reps_to_cache(svn_fs_t *fs,
/* FALSE because we don't care if another parallel commit happened to
* collide with us. (Non-parallel collisions will not be detected.) */
- SVN_ERR(svn_fs_x__set_rep_reference(fs, rep, FALSE, scratch_pool));
+ SVN_ERR(svn_fs_x__set_rep_reference(fs, rep, scratch_pool));
}
return SVN_NO_ERROR;