svn_test_editor.c

来自「linux subdivision ying gai ke yi le ba」· C语言 代码 · 共 589 行 · 第 1/2 页

C
589
字号
close_file_or_dir (void *baton,
                   svn_boolean_t is_dir,
                   apr_pool_t *pool)
{
  struct node_baton *nb = baton;
  struct edit_baton *eb = nb->edit_baton;
  svn_stringbuf_t *str;

  str = svn_stringbuf_createf (pool,
                               "[%s] close_%s (%s)\n",
                               eb->editor_name, 
                               is_dir ? "directory" : "file",
                               nb->path);
  SVN_ERR (print (eb, nb->indent_level, str));
  if (eb->verbose)
    SVN_ERR (newline (eb));

  return SVN_NO_ERROR;    
}


static svn_error_t *
test_add_directory (const char *path,
                    void *parent_baton,
                    const char *copyfrom_path,
                    svn_revnum_t copyfrom_revision,
                    apr_pool_t *pool,
                    void **child_baton)
{
  return add_or_open (path, parent_baton, copyfrom_path, copyfrom_revision,
                      pool, child_baton, TRUE, "add");
}


static svn_error_t *
test_open_directory (const char *path,
                     void *parent_baton,
                     svn_revnum_t base_revision,
                     apr_pool_t *pool,
                     void **child_baton)
{
  return add_or_open (path, parent_baton, NULL, base_revision,
                      pool, child_baton, TRUE, "open");
}


static svn_error_t *
test_add_file (const char *path,
               void *parent_baton,
               const char *copyfrom_path,
               svn_revnum_t copyfrom_revision,
               apr_pool_t *pool,
               void **file_baton)
{
  return add_or_open (path, parent_baton, copyfrom_path, copyfrom_revision,
                      pool, file_baton, FALSE, "add");
}


static svn_error_t *
test_open_file (const char *path,
                void *parent_baton,
                svn_revnum_t base_revision,
                apr_pool_t *pool,
                void **file_baton)
{
  return add_or_open (path, parent_baton, NULL, base_revision,
                      pool, file_baton, FALSE, "open");
}


static svn_error_t *
test_close_directory (void *dir_baton,
                      apr_pool_t *pool)
{
  return close_file_or_dir (dir_baton, TRUE, pool);
}


static svn_error_t *
absent_file_or_dir (const char *path,
                    void *baton,
                    svn_boolean_t is_dir,
                    apr_pool_t *pool)
{
  struct node_baton *nb = baton;
  struct edit_baton *eb = nb->edit_baton;
  svn_stringbuf_t *str;

  str = svn_stringbuf_createf (pool,
                               "[%s] absent_%s (%s)\n",
                               eb->editor_name, 
                               is_dir ? "directory" : "file",
                               nb->path);
  SVN_ERR (print (eb, nb->indent_level, str));
  if (eb->verbose)
    SVN_ERR (newline (eb));

  return SVN_NO_ERROR;    
}


static svn_error_t *
test_absent_directory (const char *path,
                       void *baton,
                       apr_pool_t *pool)
{
  return absent_file_or_dir (path, baton, TRUE, pool);
}


static svn_error_t *
test_close_file (void *file_baton,
                 const char *text_checksum,
                 apr_pool_t *pool)
{
  return close_file_or_dir (file_baton, FALSE, pool);
}


static svn_error_t *
test_absent_file (const char *path,
                  void *baton,
                  apr_pool_t *pool)
{
  return absent_file_or_dir (path, baton, FALSE, pool);
}


static svn_error_t *
test_close_edit (void *edit_baton,
                 apr_pool_t *pool)
{
  struct edit_baton *eb = edit_baton;
  svn_stringbuf_t *str;

  str = svn_stringbuf_createf (pool, "[%s] close_edit\n", eb->editor_name);
  SVN_ERR (print (eb, 0, str));

  if (eb->verbose)
    SVN_ERR (newline (eb));

  return SVN_NO_ERROR;
}

static svn_error_t *
test_abort_edit (void *edit_baton,
                 apr_pool_t *pool)
{
  struct edit_baton *eb = edit_baton;
  svn_stringbuf_t *str;

  str = svn_stringbuf_createf (pool, "[%s] ***ABORT_EDIT***\n", 
                               eb->editor_name);
  SVN_ERR (print (eb, 0, str));

  if (eb->verbose)
    SVN_ERR (newline (eb));

  return SVN_NO_ERROR;
}

static svn_error_t *
test_apply_textdelta (void *file_baton,
                      const char *base_checksum,
                      apr_pool_t *pool,
                      svn_txdelta_window_handler_t *handler,
                      void **handler_baton)
{
  struct node_baton *nb = file_baton;
  struct edit_baton *eb = nb->edit_baton;
  svn_stringbuf_t *str;

  /* Set the value of HANDLER and HANDLER_BATON here */
  *handler        = my_vcdiff_windoweater;
  *handler_baton  = nb;

  str = svn_stringbuf_createf (pool, "[%s] apply_textdelta (%s)\n",
                               eb->editor_name, nb->path);
  SVN_ERR (print (eb, nb->indent_level + 1, str));

  if (eb->verbose)
    SVN_ERR (newline (eb));

  return SVN_NO_ERROR;
}


static svn_error_t * 
change_prop (void *baton,
             const char *name,
             const svn_string_t *value,
             apr_pool_t *pool,
             svn_boolean_t is_dir)
{
  struct node_baton *nb = baton;
  struct edit_baton *eb = nb->edit_baton;
  svn_stringbuf_t *str;

  str = svn_stringbuf_createf (pool, "[%s] change_%s_prop (%s)\n", 
                               eb->editor_name, 
                               is_dir ? "directory" : "file", nb->path);
  SVN_ERR (print (eb, nb->indent_level + 1, str));

  /* We're done if non-verbose */
  if (! eb->verbose)
    return SVN_NO_ERROR;

  str = svn_stringbuf_createf (pool, "name: %s\n", name);
  SVN_ERR (print (eb, nb->indent_level + 1, str));

  str = svn_stringbuf_createf (pool, "value: %s\n", 
                               value ? value->data : "(null)");
  SVN_ERR (print (eb, nb->indent_level + 1, str));

  SVN_ERR (newline (eb));

  return SVN_NO_ERROR;
}


static svn_error_t *
test_change_file_prop (void *file_baton,
                       const char *name, 
                       const svn_string_t *value,
                       apr_pool_t *pool)
{
  return change_prop (file_baton, name, value, pool, FALSE);
}


static svn_error_t *
test_change_dir_prop (void *parent_baton,
                       const char *name, 
                       const svn_string_t *value,
                       apr_pool_t *pool)
{
  return change_prop (parent_baton, name, value, pool, TRUE);
}


/*---------------------------------------------------------------*/

/** Public interface:  svn_test_get_editor() **/


svn_error_t *
svn_test_get_editor (const svn_delta_editor_t **editor,
                     void **edit_baton,
                     const char *editor_name,
                     svn_stream_t *out_stream,
                     int indentation,
                     svn_boolean_t verbose,
                     const char *path,
                     apr_pool_t *pool)
{
  svn_delta_editor_t *my_editor;
  struct edit_baton *my_edit_baton;

  /* Set up the editor. */
  my_editor = svn_delta_default_editor (pool);
  my_editor->set_target_revision = test_set_target_revision;
  my_editor->open_root           = test_open_root;
  my_editor->delete_entry        = test_delete_entry;
  my_editor->add_directory       = test_add_directory;
  my_editor->open_directory      = test_open_directory;
  my_editor->close_directory     = test_close_directory;
  my_editor->absent_directory    = test_absent_directory;
  my_editor->add_file            = test_add_file;
  my_editor->open_file           = test_open_file;
  my_editor->close_file          = test_close_file;
  my_editor->absent_file         = test_absent_file;
  my_editor->apply_textdelta     = test_apply_textdelta;
  my_editor->change_file_prop    = test_change_file_prop;
  my_editor->change_dir_prop     = test_change_dir_prop;
  my_editor->close_edit          = test_close_edit;
  my_editor->abort_edit          = test_abort_edit;

  /* Set up the edit baton. */
  my_edit_baton = apr_pcalloc (pool, sizeof (*my_edit_baton));
  my_edit_baton->root_path = apr_pstrdup (pool, path);
  my_edit_baton->editor_name = apr_pstrdup (pool, editor_name);
  my_edit_baton->pool = pool;
  my_edit_baton->indentation = indentation;
  my_edit_baton->verbose = verbose;
  my_edit_baton->out_stream = out_stream;

  *editor = my_editor;
  *edit_baton = my_edit_baton;

  return SVN_NO_ERROR;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?