Beispiel #1
0
svn_error_t *
svn_editor_copy(svn_editor_t *editor,
                const char *src_relpath,
                svn_revnum_t src_revision,
                const char *dst_relpath,
                svn_revnum_t replaces_rev)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(src_relpath));
  SVN_ERR_ASSERT(svn_relpath_is_canonical(dst_relpath));
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ADD(editor, dst_relpath);
  VERIFY_PARENT_MAY_EXIST(editor, src_relpath);
  VERIFY_PARENT_MAY_EXIST(editor, dst_relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_copy)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_copy(editor->baton, src_relpath, src_revision,
                                  dst_relpath, replaces_rev,
                                  editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_ALLOW_ALTER(editor, dst_relpath);
  MARK_PARENT_STABLE(editor, dst_relpath);
  CLEAR_INCOMPLETE(editor, dst_relpath);

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #2
0
svn_error_t *
svn_editor_alter_symlink(svn_editor_t *editor,
                         const char *relpath,
                         svn_revnum_t revision,
                         const char *target,
                         apr_hash_t *props)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SVN_ERR_ASSERT(props != NULL || target != NULL);
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ALTER(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_alter_symlink)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_alter_symlink(editor->baton,
                                           relpath, revision,
                                           target, props,
                                           editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_COMPLETED(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #3
0
svn_error_t *
svn_editor_delete(svn_editor_t *editor,
                  const char *relpath,
                  svn_revnum_t revision)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_NOT_BE_COMPLETED(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);
  CHILD_DELETIONS_ALLOWED(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_delete)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_delete(editor->baton, relpath, revision,
                                    editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_COMPLETED(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #4
0
svn_error_t *
svn_editor_add_absent(svn_editor_t *editor,
                      const char *relpath,
                      svn_node_kind_t kind,
                      svn_revnum_t replaces_rev)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ADD(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);
  CHECK_UNKNOWN_CHILD(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_add_absent)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_add_absent(editor->baton, relpath, kind,
                                        replaces_rev, editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_COMPLETED(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);
  CLEAR_INCOMPLETE(editor, relpath);

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #5
0
svn_wc_conflict_version_t *
svn_wc_conflict_version_create2(const char *repos_url,
                                const char *repos_uuid,
                                const char *repos_relpath,
                                svn_revnum_t revision,
                                svn_node_kind_t kind,
                                apr_pool_t *result_pool)
{
  svn_wc_conflict_version_t *version;

  version = apr_pcalloc(result_pool, sizeof(*version));

    SVN_ERR_ASSERT_NO_RETURN(svn_uri_is_canonical(repos_url, result_pool)
                             && svn_relpath_is_canonical(repos_relpath)
                             && SVN_IS_VALID_REVNUM(revision)
                             /* ### repos_uuid can be NULL :( */);

  version->repos_url = repos_url;
  version->peg_rev = revision;
  version->path_in_repos = repos_relpath;
  version->node_kind = kind;
  version->repos_uuid = repos_uuid;

  return version;
}
Beispiel #6
0
svn_error_t *
svn_editor_alter_directory(svn_editor_t *editor,
                           const char *relpath,
                           svn_revnum_t revision,
                           const apr_array_header_t *children,
                           apr_hash_t *props)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SVN_ERR_ASSERT(children != NULL || props != NULL);
  /* ### validate children are just basenames?  */
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ALTER(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_alter_directory)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_alter_directory(editor->baton,
                                             relpath, revision,
                                             children, props,
                                             editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_COMPLETED(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);

#ifdef ENABLE_ORDERING_CHECK
  /* ### this is not entirely correct. we probably need to adjust the
     ### check_unknown_child() function for this scenario.  */
#if 0
  {
    int i;
    for (i = 0; i < children->nelts; i++)
      {
        const char *child_basename = APR_ARRAY_IDX(children, i, const char *);
        const char *child = svn_relpath_join(relpath, child_basename,
                                             editor->state_pool);

        apr_hash_set(editor->pending_incomplete_children, child,
                     APR_HASH_KEY_STRING, "");
        /* Perhaps MARK_ALLOW_ADD(editor, child); ? */
      }
  }
#endif
#endif

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #7
0
/* This is wrapper around read_str() (which see for details); it
   simply asks svn_path_is_canonical() of the string it reads,
   returning an error if the test fails.
   ### It seems this is only called for entrynames now
   */
static svn_error_t *
read_path(const char **result,
          char **buf, const char *end,
          apr_pool_t *pool)
{
    SVN_ERR(read_str(result, buf, end, pool));
    if (*result && **result && !svn_relpath_is_canonical(*result))
        return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL,
                                 _("Entry contains non-canonical path '%s'"),
                                 *result);
    return SVN_NO_ERROR;
}
Beispiel #8
0
svn_error_t *
svn_editor_add_directory(svn_editor_t *editor,
                         const char *relpath,
                         const apr_array_header_t *children,
                         apr_hash_t *props,
                         svn_revnum_t replaces_rev)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SVN_ERR_ASSERT(children != NULL);
  SVN_ERR_ASSERT(props != NULL);
  /* ### validate children are just basenames?  */
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ADD(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);
  CHECK_UNKNOWN_CHILD(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_add_directory)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_add_directory(editor->baton, relpath, children,
                                           props, replaces_rev,
                                           editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_ADDED_DIR(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);
  CLEAR_INCOMPLETE(editor, relpath);

#ifdef ENABLE_ORDERING_CHECK
  {
    int i;
    for (i = 0; i < children->nelts; i++)
      {
        const char *child_basename = APR_ARRAY_IDX(children, i, const char *);
        const char *child = svn_relpath_join(relpath, child_basename,
                                             editor->state_pool);

        svn_hash_sets(editor->pending_incomplete_children, child, "");
      }
  }
#endif

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #9
0
svn_client__pathrev_t *
svn_client__pathrev_create_with_relpath(const char *repos_root_url,
                                        const char *repos_uuid,
                                        svn_revnum_t rev,
                                        const char *relpath,
                                        apr_pool_t *result_pool)
{
  SVN_ERR_ASSERT_NO_RETURN(svn_relpath_is_canonical(relpath));

  return svn_client__pathrev_create(
           repos_root_url, repos_uuid, rev,
           svn_path_url_add_component2(repos_root_url, relpath, result_pool),
           result_pool);
}
Beispiel #10
0
svn_error_t *
svn_editor_alter_file(svn_editor_t *editor,
                      const char *relpath,
                      svn_revnum_t revision,
                      const svn_checksum_t *checksum,
                      svn_stream_t *contents,
                      apr_hash_t *props)
{
  svn_error_t *err = SVN_NO_ERROR;

  SVN_ERR_ASSERT(svn_relpath_is_canonical(relpath));
  SVN_ERR_ASSERT((checksum != NULL && contents != NULL)
                 || (checksum == NULL && contents == NULL));
  SVN_ERR_ASSERT(props != NULL || checksum != NULL);
  if (checksum)
    SVN_ERR_ASSERT(checksum->kind == SVN_EDITOR_CHECKSUM_KIND);
  SHOULD_NOT_BE_FINISHED(editor);
  SHOULD_ALLOW_ALTER(editor, relpath);
  VERIFY_PARENT_MAY_EXIST(editor, relpath);

  SVN_ERR(check_cancel(editor));

  if (editor->funcs.cb_alter_file)
    {
      START_CALLBACK(editor);
      err = editor->funcs.cb_alter_file(editor->baton,
                                        relpath, revision,
                                        checksum, contents, props,
                                        editor->scratch_pool);
      END_CALLBACK(editor);
    }

  MARK_COMPLETED(editor, relpath);
  MARK_PARENT_STABLE(editor, relpath);

  svn_pool_clear(editor->scratch_pool);
  return svn_error_trace(err);
}
Beispiel #11
0
/* If the components of RELPATH exactly match (after being
   URI-encoded) the final components of URL, return a copy of URL
   minus those components allocated in RESULT_POOL; otherwise, return
   NULL. */
static const char *
url_remove_final_relpath(const char *url,
                         const char *relpath,
                         apr_pool_t *result_pool,
                         apr_pool_t *scratch_pool)
{
  char *result = apr_pstrdup(result_pool, url);
  char *result_end;
  const char *relpath_end;

  SVN_ERR_ASSERT_NO_RETURN(svn_path_is_url(url));
  SVN_ERR_ASSERT_NO_RETURN(svn_relpath_is_canonical(relpath));

  if (relpath[0] == 0)
    return result;

  relpath = svn_path_uri_encode(relpath, scratch_pool);
  result_end = result + strlen(result) - 1;
  relpath_end = relpath + strlen(relpath) - 1;

  while (relpath_end >= relpath)
    {
      if (*result_end != *relpath_end)
        return NULL;

      relpath_end--;
      result_end--;
    }

  if (*result_end != '/')
    return NULL;

  *result_end = 0;

  return result;
}