📄 fs_skels.c
字号:
/* ...where unfinished transactions have a base node-revision-id. */
transaction->revision = SVN_INVALID_REVNUM;
transaction->base_id = svn_fs_base__id_parse (base_id_or_rev->data,
base_id_or_rev->len, pool);
}
/* ROOT-ID */
transaction->root_id = svn_fs_base__id_parse (root_id->data,
root_id->len, pool);
/* PROPLIST */
SVN_ERR (svn_fs_base__parse_proplist_skel (&(transaction->proplist),
proplist, pool));
/* COPIES */
if ((len = svn_fs_base__list_length (copies)))
{
const char *copy_id;
apr_array_header_t *txncopies;
skel_t *cpy = copies->children;
txncopies = apr_array_make (pool, len, sizeof (copy_id));
while (cpy)
{
copy_id = apr_pstrmemdup (pool, cpy->data, cpy->len);
(*((const char **)(apr_array_push (txncopies)))) = copy_id;
cpy = cpy->next;
}
transaction->copies = txncopies;
}
/* Return the structure. */
*transaction_p = transaction;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__parse_representation_skel (representation_t **rep_p,
skel_t *skel,
apr_pool_t *pool)
{
representation_t *rep;
skel_t *header_skel;
/* Validate the skel. */
if (! is_valid_representation_skel (skel))
return skel_err ("representation");
header_skel = skel->children;
/* Create the returned structure */
rep = apr_pcalloc (pool, sizeof (*rep));
/* KIND */
if (svn_fs_base__matches_atom (header_skel->children, "fulltext"))
rep->kind = rep_kind_fulltext;
else
rep->kind = rep_kind_delta;
/* TXN */
rep->txn_id = apr_pstrmemdup (pool, header_skel->children->next->data,
header_skel->children->next->len);
/* CHECKSUM */
if (header_skel->children->next->next)
{
memcpy (rep->checksum,
header_skel->children->next->next->children->next->data,
APR_MD5_DIGESTSIZE);
}
else
{
/* Older repository, no checksum, so manufacture an all-zero checksum */
memset (rep->checksum, 0, APR_MD5_DIGESTSIZE);
}
/* KIND-SPECIFIC stuff */
if (rep->kind == rep_kind_fulltext)
{
/* "fulltext"-specific. */
rep->contents.fulltext.string_key
= apr_pstrmemdup (pool,
skel->children->next->data,
skel->children->next->len);
}
else
{
/* "delta"-specific. */
skel_t *chunk_skel = skel->children->next;
rep_delta_chunk_t *chunk;
apr_array_header_t *chunks;
/* Alloc the chunk array. */
chunks = apr_array_make (pool, svn_fs_base__list_length (skel) - 1,
sizeof (chunk));
/* Process the chunks. */
while (chunk_skel)
{
skel_t *window_skel = chunk_skel->children->next;
skel_t *diff_skel = window_skel->children;
/* Allocate a chunk and its window */
chunk = apr_palloc (pool, sizeof (*chunk));
/* Populate the window */
chunk->version
= (apr_byte_t)atoi (apr_pstrmemdup
(pool,
diff_skel->children->next->data,
diff_skel->children->next->len));
chunk->string_key
= apr_pstrmemdup (pool,
diff_skel->children->next->next->data,
diff_skel->children->next->next->len);
chunk->size
= atoi (apr_pstrmemdup (pool,
window_skel->children->next->data,
window_skel->children->next->len));
chunk->rep_key
= apr_pstrmemdup (pool,
window_skel->children->next->next->data,
window_skel->children->next->next->len);
chunk->offset =
svn__atoui64 (apr_pstrmemdup (pool,
chunk_skel->children->data,
chunk_skel->children->len));
/* Add this chunk to the array. */
(*((rep_delta_chunk_t **)(apr_array_push (chunks)))) = chunk;
/* Next... */
chunk_skel = chunk_skel->next;
}
/* Add the chunks array to the representation. */
rep->contents.delta.chunks = chunks;
}
/* Return the structure. */
*rep_p = rep;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__parse_node_revision_skel (node_revision_t **noderev_p,
skel_t *skel,
apr_pool_t *pool)
{
node_revision_t *noderev;
skel_t *header_skel;
/* Validate the skel. */
if (! is_valid_node_revision_skel (skel))
return skel_err ("node-revision");
header_skel = skel->children;
/* Create the returned structure */
noderev = apr_pcalloc (pool, sizeof (*noderev));
/* KIND */
if (svn_fs_base__matches_atom (header_skel->children, "dir"))
noderev->kind = svn_node_dir;
else
noderev->kind = svn_node_file;
/* CREATED-PATH */
noderev->created_path = apr_pstrmemdup (pool,
header_skel->children->next->data,
header_skel->children->next->len);
/* PREDECESSOR-ID */
if (header_skel->children->next->next)
{
noderev->predecessor_id
= svn_fs_base__id_parse (header_skel->children->next->next->data,
header_skel->children->next->next->len, pool);
/* PREDECESSOR-COUNT */
noderev->predecessor_count = -1;
if (header_skel->children->next->next->next)
noderev->predecessor_count =
atoi (apr_pstrmemdup (pool,
header_skel->children->next->next->next->data,
header_skel->children->next->next->next->len));
}
/* PROP-KEY */
if (skel->children->next->len)
noderev->prop_key = apr_pstrmemdup (pool, skel->children->next->data,
skel->children->next->len);
/* DATA-KEY */
if (skel->children->next->next->len)
noderev->data_key = apr_pstrmemdup (pool, skel->children->next->next->data,
skel->children->next->next->len);
/* EDIT-DATA-KEY (optional, files only) */
if ((noderev->kind == svn_node_file)
&& skel->children->next->next->next
&& skel->children->next->next->next->len)
noderev->edit_key
= apr_pstrmemdup (pool, skel->children->next->next->next->data,
skel->children->next->next->next->len);
/* Return the structure. */
*noderev_p = noderev;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__parse_copy_skel (copy_t **copy_p,
skel_t *skel,
apr_pool_t *pool)
{
copy_t *copy;
/* Validate the skel. */
if (! is_valid_copy_skel (skel))
return skel_err ("copy");
/* Create the returned structure */
copy = apr_pcalloc (pool, sizeof (*copy));
/* KIND */
if (svn_fs_base__matches_atom (skel->children, "soft-copy"))
copy->kind = copy_kind_soft;
else
copy->kind = copy_kind_real;
/* SRC-PATH */
copy->src_path = apr_pstrmemdup (pool,
skel->children->next->data,
skel->children->next->len);
/* SRC-TXN-ID */
copy->src_txn_id = apr_pstrmemdup (pool,
skel->children->next->next->data,
skel->children->next->next->len);
/* DST-NODE-ID */
copy->dst_noderev_id
= svn_fs_base__id_parse (skel->children->next->next->next->data,
skel->children->next->next->next->len, pool);
/* Return the structure. */
*copy_p = copy;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__parse_entries_skel (apr_hash_t **entries_p,
skel_t *skel,
apr_pool_t *pool)
{
apr_hash_t *entries = NULL;
int len = svn_fs_base__list_length (skel);
skel_t *elt;
if (! (len >= 0))
return skel_err ("entries");
if (len > 0)
{
/* Else, allocate a hash and populate it. */
entries = apr_hash_make (pool);
/* Check entries are well-formed as we go along. */
for (elt = skel->children; elt; elt = elt->next)
{
const char *name;
svn_fs_id_t *id;
/* ENTRY must be a list of two elements. */
if (svn_fs_base__list_length (elt) != 2)
return skel_err ("entries");
/* Get the entry's name and ID. */
name = apr_pstrmemdup (pool, elt->children->data,
elt->children->len);
id = svn_fs_base__id_parse (elt->children->next->data,
elt->children->next->len, pool);
/* Add the entry to the hash. */
apr_hash_set (entries, name, elt->children->len, id);
}
}
/* Return the structure. */
*entries_p = entries;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__parse_change_skel (change_t **change_p,
skel_t *skel,
apr_pool_t *pool)
{
change_t *change;
svn_fs_path_change_kind_t kind;
/* Validate the skel. */
if (! is_valid_change_skel (skel, &kind))
return skel_err ("change");
/* Create the returned structure */
change = apr_pcalloc (pool, sizeof (*change));
/* PATH */
change->path = apr_pstrmemdup (pool, skel->children->next->data,
skel->children->next->len);
/* NODE-REV-ID */
if (skel->children->next->next->len)
change->noderev_id = svn_fs_base__id_parse
(skel->children->next->next->data, skel->children->next->next->len,
pool);
/* KIND */
change->kind = kind;
/* TEXT-MOD */
if (skel->children->next->next->next->next->len)
change->text_mod = TRUE;
/* PROP-MOD */
if (skel->children->next->next->next->next->next->len)
change->prop_mod = TRUE;
/* Return the structure. */
*change_p = change;
return SVN_NO_ERROR;
}
/*** Unparsing (conversion from native FS type to skeleton) ***/
svn_error_t *
svn_fs_base__unparse_proplist_skel (skel_t **skel_p,
apr_hash_t *proplist,
apr_pool_t *pool)
{
skel_t *skel = svn_fs_base__make_empty_list (pool);
apr_hash_index_t *hi;
/* Create the skel. */
if (proplist)
{
/* Loop over hash entries */
for (hi = apr_hash_first (pool, proplist); hi; hi = apr_hash_next (hi))
{
const void *key;
void *val;
apr_ssize_t klen;
svn_string_t *value;
apr_hash_this (hi, &key, &klen, &val);
value = val;
/* VALUE */
svn_fs_base__prepend (svn_fs_base__mem_atom (value->data, \
value->len, pool),
skel);
/* NAME */
svn_fs_base__prepend (svn_fs_base__mem_atom (key, klen, pool), skel);
}
}
/* Validate and return the skel. */
if (! is_valid_proplist_skel (skel))
return skel_err ("proplist");
*skel_p = skel;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__unparse_revision_skel (skel_t **skel_p,
const revision_t *revision,
apr_pool_t *pool)
{
skel_t *skel;
/* Create the skel. */
skel = svn_fs_base__make_empty_list (pool);
/* TXN_ID */
svn_fs_base__prepend (svn_fs_base__str_atom (revision->txn_id, pool), skel);
/* "revision" */
svn_fs_base__prepend (svn_fs_base__str_atom ("revision", pool), skel);
/* Validate and return the skel. */
if (! is_valid_revision_skel (skel))
return skel_err ("revision");
*skel_p = skel;
return SVN_NO_ERROR;
}
svn_error_t *
svn_fs_base__unparse_transaction_skel (skel_t **skel_p,
const transaction_t *transaction,
apr_pool_t *pool)
{
skel_t *skel;
skel_t *proplist_skel, *copies_skel, *header_skel;
svn_string_t *id_str;
transaction_kind_t kind;
/* Create the skel. */
skel = svn_fs_base__make_empty_list (pool);
switch (transaction->kind)
{
case transaction_kind_committed:
header_skel = svn_fs_base__str_atom ("committed", pool);
if ((transaction->base_id)
|| (! SVN_IS_VALID_REVNUM (transaction->revision)))
return skel_err ("transaction");
break;
case transaction_kind_dead:
header_skel = svn_fs_base__str_atom ("dead", pool);
if ((! transaction->base_id)
|| (SVN_IS_VALID_REVNUM (transaction->revision)))
return skel_err ("transaction");
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -