[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

commit.c suggestion

From: Asbjørn Pettersen <asbgpe_at_gmail.com>
Date: 2006-10-18 19:09:35 CEST

Found some "copy&paste" code in /libsvn_repos/commit.c
Made one new function, called newdirb() replacing 2 code blocks

My suggestion:

static svn_error_t *newdirb(const char *path,
                const void *parent_baton,
                const svn_boolean_t was_copied,
                const svn_revnum_t base_revision,
                apr_pool_t *pool,
                void **child_baton)
{
  struct dir_baton *new_dirb;
  struct dir_baton *pb = (struct dir_baton *)parent_baton;
  struct edit_baton *eb = pb->edit_baton;
  const char *full_path = svn_path_join(eb->base_path, path, pool);

  /* Build a new dir baton for this directory */
  new_dirb = apr_pcalloc(pool, sizeof(*new_dirb));
  new_dirb->edit_baton = eb;
  new_dirb->parent = pb;
  new_dirb->pool = pool;
  new_dirb->path = full_path;
  new_dirb->was_copied = was_copied;
  new_dirb->base_rev = base_revision;

  *child_baton = new_dirb;
  return SVN_NO_ERROR;
}

----------------------------------------------

add_directory()
{
..
#if 1
  return (newdirb(path, parent_baton, was_copied, SVN_INVALID_REVNUM,
           pool, child_baton));
#else
  /* Build a new dir baton for this directory. */
  new_dirb = apr_pcalloc(pool, sizeof(*new_dirb));
  new_dirb->edit_baton = eb;
  new_dirb->parent = pb;
  new_dirb->pool = pool;
  new_dirb->path = full_path;
  new_dirb->was_copied = was_copied;
  new_dirb->base_rev = SVN_INVALID_REVNUM;

  *child_baton = new_dirb;

  return SVN_NO_ERROR;
#endif
}

open_directory()
{
...
#if 1
  return (newdirb(path, parent_baton, pb->was_copied, base_revision,
          pool, child_baton));
#else
  /* Build a new dir baton for this directory */
  new_dirb = apr_pcalloc(pool, sizeof(*new_dirb));
  new_dirb->edit_baton = eb;
  new_dirb->parent = pb;
  new_dirb->pool = pool;
  new_dirb->path = full_path;
  new_dirb->was_copied = pb->was_copied;
  new_dirb->base_rev = base_revision;

  *child_baton = new_dirb;

  return SVN_NO_ERROR;
#endif
}
Received on Wed Oct 18 19:10:35 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.