Author: rhuijben
Date: Sat Dec 14 23:49:21 2013
New Revision: 1550985
URL: http://svn.apache.org/r1550985
Log:
In the update editor: extract a bit of code from make_dir_baton and make_file
baton to a function of its own in preparation for a tweak that removes the
wc_db call.
* subversion/libsvn_wc/update_editor.c
(calculate_new_relpath): New function.
(make_dir_baton): Extracted from here, which is now a caller.
(make_file_baton): Call calculate_new_relpath.
Modified:
subversion/trunk/subversion/libsvn_wc/update_editor.c
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1550985&r1=1550984&r2=1550985&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Sat Dec 14 23:49:21
2013
@@ -489,44 +489,18 @@ cleanup_edit_baton(void *edit_baton)
return APR_SUCCESS;
}
-/* Make a new dir baton in a subpool of PB->pool. PB is the parent baton.
- If PATH and PB are NULL, this is the root directory of the edit; in this
- case, make the new dir baton in a subpool of EB->pool.
- ADDING should be TRUE if we are adding this directory. */
+/* Calculate the new repos_relpath for a directory or file */
static svn_error_t *
-make_dir_baton(struct dir_baton **d_p,
- const char *path,
- struct edit_baton *eb,
- struct dir_baton *pb,
- svn_boolean_t adding,
- apr_pool_t *scratch_pool)
+calculate_new_relpath(const char **new_relpath,
+ svn_wc__db_t *db,
+ const char *local_abspath,
+ svn_boolean_t adding,
+ struct edit_baton *eb,
+ struct dir_baton *pb,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
- apr_pool_t *dir_pool;
- struct dir_baton *d;
-
- if (pb != NULL)
- dir_pool = svn_pool_create(pb->pool);
- else
- dir_pool = svn_pool_create(eb->pool);
-
- SVN_ERR_ASSERT(path || (! pb));
-
- /* Okay, no easy out, so allocate and initialize a dir baton. */
- d = apr_pcalloc(dir_pool, sizeof(*d));
-
- /* Construct the PATH and baseNAME of this directory. */
- if (path)
- {
- d->name = svn_dirent_basename(path, dir_pool);
- SVN_ERR(path_join_under_root(&d->local_abspath,
- pb->local_abspath, d->name, dir_pool));
- }
- else
- {
- /* This is the root baton. */
- d->name = NULL;
- d->local_abspath = eb->anchor_abspath;
- }
+ const char *name = svn_dirent_basename(local_abspath, NULL);
/* Figure out the new_relpath for this directory. */
if (eb->switch_relpath)
@@ -540,7 +514,7 @@ make_dir_baton(struct dir_baton **d_p,
/* No parent baton and target_basename=="" means that we are
the target of the switch. Thus, our NEW_RELPATH will be
the SWITCH_RELPATH. */
- d->new_relpath = eb->switch_relpath;
+ *new_relpath = eb->switch_relpath;
}
else
{
@@ -548,11 +522,11 @@ make_dir_baton(struct dir_baton **d_p,
children is the target); therefore, it must already exist.
Get its old REPOS_RELPATH, as it won't be changing. */
SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL,
- &d->new_relpath, NULL, NULL,
+ new_relpath, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
- eb->db, d->local_abspath,
- dir_pool, scratch_pool));
+ db, local_abspath,
+ result_pool, scratch_pool));
}
}
else
@@ -563,12 +537,13 @@ make_dir_baton(struct dir_baton **d_p,
NEW_RELPATH to the SWITCH_RELPATH.
Otherwise, we simply extend NEW_RELPATH from the parent. */
+
if (pb->parent_baton == NULL
- && strcmp(eb->target_basename, d->name) == 0)
- d->new_relpath = eb->switch_relpath;
+ && strcmp(eb->target_basename, name) == 0)
+ *new_relpath = eb->switch_relpath;
else
- d->new_relpath = svn_relpath_join(pb->new_relpath, d->name,
- dir_pool);
+ *new_relpath = svn_relpath_join(pb->new_relpath, name,
+ result_pool);
}
}
else /* must be an update */
@@ -578,20 +553,64 @@ make_dir_baton(struct dir_baton **d_p,
if (adding)
{
SVN_ERR_ASSERT(pb != NULL);
- d->new_relpath = svn_relpath_join(pb->new_relpath, d->name,
- dir_pool);
+ *new_relpath = svn_relpath_join(pb->new_relpath, name, result_pool);
}
else
{
- SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, &d->new_relpath,
+ SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, new_relpath,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
- eb->db, d->local_abspath,
- dir_pool, scratch_pool));
- SVN_ERR_ASSERT(d->new_relpath);
+ db, local_abspath,
+ result_pool, scratch_pool));
+ SVN_ERR_ASSERT(*new_relpath);
}
}
+ return SVN_NO_ERROR;
+}
+
+/* Make a new dir baton in a subpool of PB->pool. PB is the parent baton.
+ If PATH and PB are NULL, this is the root directory of the edit; in this
+ case, make the new dir baton in a subpool of EB->pool.
+ ADDING should be TRUE if we are adding this directory. */
+static svn_error_t *
+make_dir_baton(struct dir_baton **d_p,
+ const char *path,
+ struct edit_baton *eb,
+ struct dir_baton *pb,
+ svn_boolean_t adding,
+ apr_pool_t *scratch_pool)
+{
+ apr_pool_t *dir_pool;
+ struct dir_baton *d;
+
+ if (pb != NULL)
+ dir_pool = svn_pool_create(pb->pool);
+ else
+ dir_pool = svn_pool_create(eb->pool);
+
+ SVN_ERR_ASSERT(path || (! pb));
+
+ /* Okay, no easy out, so allocate and initialize a dir baton. */
+ d = apr_pcalloc(dir_pool, sizeof(*d));
+
+ /* Construct the PATH and baseNAME of this directory. */
+ if (path)
+ {
+ d->name = svn_dirent_basename(path, dir_pool);
+ SVN_ERR(path_join_under_root(&d->local_abspath,
+ pb->local_abspath, d->name, dir_pool));
+ }
+ else
+ {
+ /* This is the root baton. */
+ d->name = NULL;
+ d->local_abspath = eb->anchor_abspath;
+ }
+
+ SVN_ERR(calculate_new_relpath(&d->new_relpath, eb->db, d->local_abspath,
adding,
+ eb, pb, dir_pool, scratch_pool));
+
d->edit_baton = eb;
d->parent_baton = pb;
d->pool = dir_pool;
@@ -622,7 +641,6 @@ make_dir_baton(struct dir_baton **d_p,
return SVN_NO_ERROR;
}
-
/* Forward declarations. */
static svn_error_t *
already_in_a_tree_conflict(svn_boolean_t *conflicted,
@@ -784,39 +802,8 @@ make_file_baton(struct file_baton **f_p,
SVN_ERR(path_join_under_root(&f->local_abspath,
pb->local_abspath, f->name, file_pool));
- /* Figure out the new URL for this file. */
- if (eb->switch_relpath)
- {
- /* Handle switches... */
-
- /* This file has a parent directory. If there is
- no grandparent, then we may have anchored at the parent,
- and self is the target. If we match the target, then set
- NEW_RELPATH to the SWITCH_RELPATH.
-
- Otherwise, we simply extend NEW_RELPATH from the parent. */
- if (pb->parent_baton == NULL
- && strcmp(eb->target_basename, f->name) == 0)
- f->new_relpath = eb->switch_relpath;
- else
- f->new_relpath = svn_relpath_join(pb->new_relpath, f->name,
- file_pool);
- }
- else /* must be an update */
- {
- if (adding)
- f->new_relpath = svn_relpath_join(pb->new_relpath, f->name, file_pool);
- else
- {
- SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, &f->new_relpath,
- NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL,
- eb->db, f->local_abspath,
- file_pool, scratch_pool));
- SVN_ERR_ASSERT(f->new_relpath);
- }
- }
+ SVN_ERR(calculate_new_relpath(&f->new_relpath, eb->db, f->local_abspath,
adding,
+ eb, pb, file_pool, scratch_pool));
f->pool = file_pool;
f->edit_baton = pb->edit_baton;