Пример #1
0
/* Implement svn_repos_path_change_receiver_t.
 * Convert CHANGE and add it to the CHANGES list in *BATON. */
static svn_error_t *
log4_path_change_receiver(void *baton,
                          svn_repos_path_change_t *change,
                          apr_pool_t *scratch_pool)
{
  log_entry_receiver_baton_t *b = baton;
  svn_log_changed_path2_t *change_copy;
  const char *path = apr_pstrmemdup(b->changes_pool, change->path.data,
                                    change->path.len);

  /* Create a deep copy of the temporary CHANGE struct. */
  change_copy = svn_log_changed_path2_create(b->changes_pool);
  change_copy->action = path_change_kind_to_char(change->change_kind);

  if (change->copyfrom_path)
    change_copy->copyfrom_path = apr_pstrdup(b->changes_pool,
                                             change->copyfrom_path);

  change_copy->copyfrom_rev = change->copyfrom_rev;
  change_copy->node_kind = change->node_kind;
  change_copy->text_modified = change->text_mod ? svn_tristate_true
                                                : svn_tristate_false;
  change_copy->props_modified = change->prop_mod ? svn_tristate_true
                                                 : svn_tristate_false;

  /* Auto-create the CHANGES container (happens for each first change
   * in any revison. */
  if (b->changes == NULL)
    b->changes = svn_hash__make(b->changes_pool);

  /* Add change to per-revision collection. */
  apr_hash_set(b->changes, path, change->path.len, change_copy);

  return SVN_NO_ERROR;
}
Пример #2
0
/* Given a revision file FILE that has been pre-positioned at the
   beginning of a Node-Rev header block, read in that header block and
   store it in the apr_hash_t HEADERS.  All allocations will be from
   RESULT_POOL. */
static svn_error_t *
read_header_block(apr_hash_t **headers,
                  svn_stream_t *stream,
                  apr_pool_t *result_pool)
{
  *headers = svn_hash__make(result_pool);

  while (1)
    {
      svn_stringbuf_t *header_str;
      const char *name, *value;
      apr_size_t i = 0;
      apr_size_t name_len;
      svn_boolean_t eof;

      SVN_ERR(svn_stream_readline(stream, &header_str, "\n", &eof,
                                  result_pool));

      if (eof || header_str->len == 0)
        break; /* end of header block */

      while (header_str->data[i] != ':')
        {
          if (header_str->data[i] == '\0')
            return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                     _("Found malformed header '%s' in "
                                       "revision file"),
                                     header_str->data);
          i++;
        }

      /* Create a 'name' string and point to it. */
      header_str->data[i] = '\0';
      name = header_str->data;
      name_len = i;

      /* Check if we have enough data to parse. */
      if (i + 2 > header_str->len)
        {
          /* Restore the original line for the error. */
          header_str->data[i] = ':';
          return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                   _("Found malformed header '%s' in "
                                     "revision file"),
                                   header_str->data);
        }

      /* Skip over the NULL byte and the space following it. */
      i += 2;

      value = header_str->data + i;

      /* header_str is safely in our pool, so we can use bits of it as
         key and value. */
      apr_hash_set(*headers, name, name_len, value);
    }

  return SVN_NO_ERROR;
}