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 2012/12/27 23:58:37 UTC
svn commit: r1426358 - in
/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs: cached_data.c
low_level.c low_level.h recovery.c
Author: stefan2
Date: Thu Dec 27 22:58:37 2012
New Revision: 1426358
URL: http://svn.apache.org/viewvc?rev=1426358&view=rev
Log:
On fsfs-format7 branch: continue defining the low-level API.
Consistently use the term "rep_header" instead of rep_line and rep_args.
* subversion/libsvn_fs_fs/low_level.h
(svn_fs_fs__rep_header_t): renamed from rep_args_t; add docstrings
(svn_fs_fs__read_rep_header): renamed from read_rep_line; update signature
(svn_fs_fs__write_rep_header): renamed from write_rep_line; update signature
* subversion/libsvn_fs_fs/low_level.c
(svn_fs_fs__read_rep_header): renamed from read_rep_line; update
(svn_fs_fs__write_rep_header): renamed from write_rep_line; update
* subversion/libsvn_fs_fs/cached_data.c
(create_rep_state_body,
create_rep_state,
svn_fs_fs__check_rep,
build_rep_list,
svn_fs_fs__get_file_delta_stream): adapt to API rename
* subversion/libsvn_fs_fs/recovery.c
(recover_find_max_ids): ditto
Modified:
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1426358&r1=1426357&r2=1426358&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Thu Dec 27 22:58:37 2012
@@ -346,7 +346,7 @@ typedef struct rep_state_t
/* See create_rep_state, which wraps this and adds another error. */
static svn_error_t *
create_rep_state_body(rep_state_t **rep_state,
- rep_args_t **rep_args,
+ svn_fs_fs__rep_header_t **rep_header,
apr_file_t **file_hint,
svn_revnum_t *rev_hint,
representation_t *rep,
@@ -355,7 +355,7 @@ create_rep_state_body(rep_state_t **rep_
{
fs_fs_data_t *ffd = fs->fsap_data;
rep_state_t *rs = apr_pcalloc(pool, sizeof(*rs));
- rep_args_t *ra;
+ svn_fs_fs__rep_header_t *rh;
unsigned char buf[4];
/* If the hint is
@@ -398,15 +398,17 @@ create_rep_state_body(rep_state_t **rep_
rs->window_cache = ffd->txdelta_window_cache;
rs->combined_cache = ffd->combined_window_cache;
- SVN_ERR(read_rep_line(&ra, svn_stream_from_aprfile2(rs->file, TRUE, pool),
- pool));
+ SVN_ERR(svn_fs_fs__read_rep_header(&rh,
+ svn_stream_from_aprfile2(rs->file,
+ TRUE, pool),
+ pool));
SVN_ERR(get_file_offset(&rs->start, rs->file, pool));
rs->off = rs->start;
rs->end = rs->start + rep->size;
*rep_state = rs;
- *rep_args = ra;
+ *rep_header = rh;
- if (ra->is_delta == FALSE)
+ if (rh->is_delta == FALSE)
/* This is a plaintext, so just return the current rep_state. */
return SVN_NO_ERROR;
@@ -437,14 +439,14 @@ create_rep_state_body(rep_state_t **rep_
*/
static svn_error_t *
create_rep_state(rep_state_t **rep_state,
- rep_args_t **rep_args,
+ svn_fs_fs__rep_header_t **rep_header,
apr_file_t **file_hint,
svn_revnum_t *rev_hint,
representation_t *rep,
svn_fs_t *fs,
apr_pool_t *pool)
{
- svn_error_t *err = create_rep_state_body(rep_state, rep_args,
+ svn_error_t *err = create_rep_state_body(rep_state, rep_header,
file_hint, rev_hint,
rep, fs, pool);
if (err && err->apr_err == SVN_ERR_FS_CORRUPT)
@@ -475,10 +477,10 @@ svn_fs_fs__check_rep(representation_t *r
apr_pool_t *pool)
{
rep_state_t *rs;
- rep_args_t *rep_args;
+ svn_fs_fs__rep_header_t *rep_header;
/* ### Should this be using read_rep_line() directly? */
- SVN_ERR(create_rep_state(&rs, &rep_args, NULL, NULL, rep, fs, pool));
+ SVN_ERR(create_rep_state(&rs, &rep_header, NULL, NULL, rep, fs, pool));
return SVN_NO_ERROR;
}
@@ -730,7 +732,7 @@ build_rep_list(apr_array_header_t **list
{
representation_t rep;
rep_state_t *rs = NULL;
- rep_args_t *rep_args;
+ svn_fs_fs__rep_header_t *rep_header;
svn_boolean_t is_cached = FALSE;
apr_file_t *last_file = NULL;
svn_revnum_t last_revision;
@@ -743,7 +745,7 @@ build_rep_list(apr_array_header_t **list
*expanded_size = first_rep->expanded_size;
/* for the top-level rep, we need the rep_args */
- SVN_ERR(create_rep_state(&rs, &rep_args, &last_file,
+ SVN_ERR(create_rep_state(&rs, &rep_header, &last_file,
&last_revision, &rep, fs, pool));
/* Unknown size or empty representation?
@@ -753,15 +755,15 @@ build_rep_list(apr_array_header_t **list
Please note that for all non-empty deltas have
a 4-byte header _plus_ some data. */
if (*expanded_size == 0)
- if (! rep_args->is_delta || first_rep->size != 4)
+ if (! rep_header->is_delta || first_rep->size != 4)
*expanded_size = first_rep->size;
while (1)
{
/* fetch state, if that has not been done already */
if (!rs)
- SVN_ERR(create_rep_state(&rs, &rep_args, &last_file,
- &last_revision, &rep, fs, pool));
+ SVN_ERR(create_rep_state(&rs, &rep_header, &last_file,
+ &last_revision, &rep, fs, pool));
SVN_ERR(get_cached_combined_window(window_p, rs, &is_cached, pool));
if (is_cached)
@@ -774,7 +776,7 @@ build_rep_list(apr_array_header_t **list
return SVN_NO_ERROR;
}
- if (rep_args->is_delta == FALSE)
+ if (rep_header->is_delta == FALSE)
{
/* This is a plaintext, so just return the current rep_state. */
*src_state = rs;
@@ -783,15 +785,15 @@ build_rep_list(apr_array_header_t **list
/* Push this rep onto the list. If it's self-compressed, we're done. */
APR_ARRAY_PUSH(*list, rep_state_t *) = rs;
- if (rep_args->is_delta_vs_empty)
+ if (rep_header->is_delta_vs_empty)
{
*src_state = NULL;
return SVN_NO_ERROR;
}
- rep.revision = rep_args->base_revision;
- rep.offset = rep_args->base_offset;
- rep.size = rep_args->base_length;
+ rep.revision = rep_header->base_revision;
+ rep.offset = rep_header->base_offset;
+ rep.size = rep_header->base_length;
rep.txn_id = NULL;
rs = NULL;
@@ -1324,16 +1326,16 @@ svn_fs_fs__get_file_delta_stream(svn_txd
if (source && source->data_rep && target->data_rep)
{
rep_state_t *rep_state;
- rep_args_t *rep_args;
+ svn_fs_fs__rep_header_t *rep_header;
/* Read target's base rep if any. */
- SVN_ERR(create_rep_state(&rep_state, &rep_args, NULL, NULL,
+ SVN_ERR(create_rep_state(&rep_state, &rep_header, NULL, NULL,
target->data_rep, fs, pool));
/* If that matches source, then use this delta as is. */
- if (rep_args->is_delta
- && (rep_args->is_delta_vs_empty
- || (rep_args->base_revision == source->data_rep->revision
- && rep_args->base_offset == source->data_rep->offset)))
+ if (rep_header->is_delta
+ && (rep_header->is_delta_vs_empty
+ || (rep_header->base_revision == source->data_rep->revision
+ && rep_header->base_offset == source->data_rep->offset)))
{
/* Create the delta read baton. */
struct delta_read_baton *drb = apr_pcalloc(pool, sizeof(*drb));
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c?rev=1426358&r1=1426357&r2=1426358&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c Thu Dec 27 22:58:37 2012
@@ -591,38 +591,31 @@ svn_fs_fs__write_noderev(svn_stream_t *o
representation entry. Return the parsed entry in *REP_ARGS_P.
Perform all allocations in POOL. */
svn_error_t *
-read_rep_line(rep_args_t **rep_args_p,
- svn_stream_t *stream,
- apr_pool_t *pool)
+svn_fs_fs__read_rep_header(svn_fs_fs__rep_header_t **header,
+ svn_stream_t *stream,
+ apr_pool_t *pool)
{
svn_stringbuf_t *buffer;
- rep_args_t *rep_args;
char *str, *last_str;
apr_int64_t val;
svn_boolean_t eol = FALSE;
SVN_ERR(svn_stream_readline(stream, &buffer, "\n", &eol, pool));
- rep_args = apr_pcalloc(pool, sizeof(*rep_args));
- rep_args->is_delta = FALSE;
-
+ *header = apr_pcalloc(pool, sizeof(*header));
if (strcmp(buffer->data, REP_PLAIN) == 0)
- {
- *rep_args_p = rep_args;
- return SVN_NO_ERROR;
- }
+ return SVN_NO_ERROR;
if (strcmp(buffer->data, REP_DELTA) == 0)
{
/* This is a delta against the empty stream. */
- rep_args->is_delta = TRUE;
- rep_args->is_delta_vs_empty = TRUE;
- *rep_args_p = rep_args;
+ (*header)->is_delta = TRUE;
+ (*header)->is_delta_vs_empty = TRUE;
return SVN_NO_ERROR;
}
- rep_args->is_delta = TRUE;
- rep_args->is_delta_vs_empty = FALSE;
+ (*header)->is_delta = TRUE;
+ (*header)->is_delta_vs_empty = FALSE;
/* We have hopefully a DELTA vs. a non-empty base revision. */
last_str = buffer->data;
@@ -633,21 +626,20 @@ read_rep_line(rep_args_t **rep_args_p,
str = svn_cstring_tokenize(" ", &last_str);
if (! str)
goto error;
- rep_args->base_revision = SVN_STR_TO_REV(str);
+ (*header)->base_revision = SVN_STR_TO_REV(str);
str = svn_cstring_tokenize(" ", &last_str);
if (! str)
goto error;
SVN_ERR(svn_cstring_atoi64(&val, str));
- rep_args->base_offset = (apr_off_t)val;
+ (*header)->base_offset = (apr_off_t)val;
str = svn_cstring_tokenize(" ", &last_str);
if (! str)
goto error;
SVN_ERR(svn_cstring_atoi64(&val, str));
- rep_args->base_length = (svn_filesize_t)val;
+ (*header)->base_length = (svn_filesize_t)val;
- *rep_args_p = rep_args;
return SVN_NO_ERROR;
error:
@@ -656,29 +648,29 @@ read_rep_line(rep_args_t **rep_args_p,
}
svn_error_t *
-write_rep_line(rep_args_t *rep_args,
- svn_stream_t *stream,
- apr_pool_t *pool)
+svn_fs_fs__write_rep_header(svn_fs_fs__rep_header_t *header,
+ svn_stream_t *stream,
+ apr_pool_t *pool)
{
- const char *header;
+ const char *text;
- if (rep_args->is_delta)
+ if (header->is_delta)
{
- header = REP_PLAIN "\n";
+ text = REP_PLAIN "\n";
}
- else if (rep_args->is_delta_vs_empty)
+ else if (header->is_delta_vs_empty)
{
- header = REP_DELTA "\n";
+ text = REP_DELTA "\n";
}
else
{
- header = apr_psprintf(pool, REP_DELTA " %ld %" APR_OFF_T_FMT " %"
- SVN_FILESIZE_T_FMT "\n",
- rep_args->base_revision, rep_args->base_offset,
- rep_args->base_length);
+ text = apr_psprintf(pool, REP_DELTA " %ld %" APR_OFF_T_FMT " %"
+ SVN_FILESIZE_T_FMT "\n",
+ header->base_revision, header->base_offset,
+ header->base_length);
}
- return svn_error_trace(svn_stream_puts(stream, header));
+ return svn_error_trace(svn_stream_puts(stream, text));
}
/* Read the next entry in the changes record from file FILE and store
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h?rev=1426358&r1=1426357&r2=1426358&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.h Thu Dec 27 22:58:37 2012
@@ -105,6 +105,13 @@ svn_fs_fs__unparse_representation(repres
svn_boolean_t may_be_corrupt,
apr_pool_t *pool);
+/* Read a node-revision from STREAM. Set *NODEREV to the new structure,
+ allocated in POOL. */
+svn_error_t *
+svn_fs_fs__read_noderev(node_revision_t **noderev,
+ svn_stream_t *stream,
+ apr_pool_t *pool);
+
/* Write the node-revision NODEREV into the stream OUTFILE, compatible with
filesystem format FORMAT. Only write mergeinfo-related metadata if
INCLUDE_MERGEINFO is true. Temporary allocations are from POOL. */
@@ -115,38 +122,45 @@ svn_fs_fs__write_noderev(svn_stream_t *o
svn_boolean_t include_mergeinfo,
apr_pool_t *pool);
-/* Read a node-revision from STREAM. Set *NODEREV to the new structure,
- allocated in POOL. */
-svn_error_t *
-svn_fs_fs__read_noderev(node_revision_t **noderev,
- svn_stream_t *stream,
- apr_pool_t *pool);
-
-/* This structure is used to hold the information associated with a
- REP line. */
-typedef struct rep_args_t
+/* This structure is used to hold the information stored in a representation
+ * header. */
+typedef struct svn_fs_fs__rep_header_t
{
+ /* if TRUE, this is a DELTA rep, PLAIN otherwise */
svn_boolean_t is_delta;
+
+ /* if IS_DELTA is TRUE, this flag indicates that there is no base rep,
+ * i.e. this rep is simply self-compressed. Ignored for PLAIN reps
+ * but should be FALSE in that case. */
svn_boolean_t is_delta_vs_empty;
+ /* if this rep is a delta against some other rep, that base rep can
+ * be found in this revision. Should be 0 if there is no base rep. */
svn_revnum_t base_revision;
+
+ /* if this rep is a delta against some other rep, that base rep can
+ * be found at this offset within the base rep's revision. Should be 0
+ * if there is no base rep. */
apr_off_t base_offset;
+
+ /* if this rep is a delta against some other rep, this is the (deltified)
+ * size of that base rep. Should be 0 if there is no base rep. */
svn_filesize_t base_length;
-} rep_args_t;
+} svn_fs_fs__rep_header_t;
/* Read the next line from file FILE and parse it as a text
representation entry. Return the parsed entry in *REP_ARGS_P.
Perform all allocations in POOL. */
svn_error_t *
-read_rep_line(rep_args_t **rep_args_p,
- svn_stream_t *stream,
- apr_pool_t *pool);
-
-svn_error_t *
-write_rep_line(rep_args_t *rep_args,
- svn_stream_t *stream,
- apr_pool_t *pool);
-
+svn_fs_fs__read_rep_header(svn_fs_fs__rep_header_t **header,
+ svn_stream_t *stream,
+ apr_pool_t *pool);
+
+/* Write the representation HEADER to STREAM. Use POOL for allocations. */
+svn_error_t *
+svn_fs_fs__write_rep_header(svn_fs_fs__rep_header_t *header,
+ svn_stream_t *stream,
+ apr_pool_t *pool);
/* Fetch all the changes from FILE and store them in *CHANGES. Do all
allocations in POOL. */
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c?rev=1426358&r1=1426357&r2=1426358&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/recovery.c Thu Dec 27 22:58:37 2012
@@ -149,7 +149,7 @@ recover_find_max_ids(svn_fs_t *fs, svn_r
char *max_node_id, char *max_copy_id,
apr_pool_t *pool)
{
- rep_args_t *ra;
+ svn_fs_fs__rep_header_t *header;
struct recover_read_from_file_baton baton;
svn_stream_t *stream;
apr_hash_t *entries;
@@ -185,8 +185,8 @@ recover_find_max_ids(svn_fs_t *fs, svn_r
SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
baton.stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
- SVN_ERR(read_rep_line(&ra, baton.stream, pool));
- if (ra->is_delta)
+ SVN_ERR(svn_fs_fs__read_rep_header(&header, baton.stream, pool));
+ if (header->is_delta)
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Recovery encountered a deltified directory "
"representation"));