Author: julianfoad
Date: Tue Jun 28 15:06:38 2011
New Revision: 1140674

URL: http://svn.apache.org/viewvc?rev=1140674&view=rev
Log:
Code simplifications. No functional change.

* subversion/libsvn_client/merge.c
  (find_unmerged_mergeinfo): Simplify path manipulations by recognizing that
    'join' followed by 'skip_ancestor' using the same parent is a no-op.

* subversion/svn/switch-cmd.c
  (svn_cl__switch): Eliminate a variable and some redundant assignments, and
    hoist common code out of an if-else.

Modified:
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/svn/switch-cmd.c

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1140674&r1=1140673&r2=1140674&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Tue Jun 28 15:06:38 2011
@@ -9874,13 +9874,11 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
 
       svn_pool_clear(iterpool);
 
-      source_path = path + strlen(target_repos_rel_path);
-      if (source_path[0] == '/')  /* Remove leading '/'. */
-        source_path++;
-      source_path = svn_relpath_join(source_repos_rel_path, source_path,
-                                     iterpool);
-      source_path_rel_to_session =
-        svn_relpath_skip_ancestor(source_repos_rel_path, source_path);
+      source_path_rel_to_session = path + strlen(target_repos_rel_path);
+      if (source_path_rel_to_session[0] == '/')  /* Remove leading '/'. */
+        source_path_rel_to_session++;
+      source_path = svn_relpath_join(source_repos_rel_path,
+                                     source_path_rel_to_session, iterpool);
 
       /* Convert this target path's natural history into mergeinfo. */
       SVN_ERR(svn_mergeinfo__mergeinfo_from_segments(

Modified: subversion/trunk/subversion/svn/switch-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/switch-cmd.c?rev=1140674&r1=1140673&r2=1140674&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/switch-cmd.c (original)
+++ subversion/trunk/subversion/svn/switch-cmd.c Tue Jun 28 15:06:38 2011
@@ -97,8 +97,7 @@ svn_cl__switch(apr_getopt_t *os,
   svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets;
-  const char *target = NULL, *switch_url = NULL;
-  const char *true_path;
+  const char *target, *switch_url;
   svn_opt_revision_t peg_revision;
   svn_depth_t depth;
   svn_boolean_t depth_is_sticky;
@@ -122,23 +121,15 @@ svn_cl__switch(apr_getopt_t *os,
   if (targets->nelts > 2)
     return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
 
-  /* Get the required SWITCH_URL and the optional TARGET arguments. */
+  /* Get the required SWITCH_URL and its optional PEG_REVISION, and the
+   * optional TARGET argument. */
+  SVN_ERR(svn_opt_parse_path(&peg_revision, &switch_url,
+                             APR_ARRAY_IDX(targets, 0, const char *),
+                             scratch_pool));
   if (targets->nelts == 1)
-    {
-      switch_url = APR_ARRAY_IDX(targets, 0, const char *);
-      target = "";
-    }
+    target = "";
   else
-    {
-      switch_url = APR_ARRAY_IDX(targets, 0, const char *);
-      target = APR_ARRAY_IDX(targets, 1, const char *);
-    }
-
-  /* Strip peg revision if targets contains an URI. */
-  SVN_ERR(svn_opt_parse_path(&peg_revision, &true_path, switch_url,
-                             scratch_pool));
-  APR_ARRAY_IDX(targets, 0, const char *) = true_path;
-  switch_url = true_path;
+    target = APR_ARRAY_IDX(targets, 1, const char *);
 
   /* Validate the switch_url */
   if (! svn_path_is_url(switch_url))


Reply via email to