subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1656769 - in /subversion/branches/pin-externals/subversion: include/private/svn_wc_private.h libsvn_client/copy.c libsvn_wc/externals.c tests/cmdline/externals_tests.py
Date Tue, 03 Feb 2015 15:57:22 GMT
Author: stsp
Date: Tue Feb  3 15:57:22 2015
New Revision: 1656769

URL: http://svn.apache.org/r1656769
Log:
On the pin-externals branch, support the legacy svn:externals syntax.

This avoids confusing old clients in cases where the legacy syntax is
used on purpose and 'svn copy --pin-externals' is used.

Suggested by: brane
              julianfoad

* subversion/include/private/svn_wc_private.h
  (svn_wc__parse_externals_description): Declare.

* subversion/libsvn_client/copy.c
  (pin_externals_prop): Preserve syntax format while pinning externals.

* subversion/libsvn_wc/externals.c
  (svn_wc__parse_externals_description): Extended version of
   svn_wc_parse_externals_description3() which returns information about
   the syntax used to define each external.
  (svn_wc_parse_externals_description3): Re-implement as a wrapper around
   svn_wc__parse_externals_description().

* subversion/tests/cmdline/externals_tests.py
  (copy_pin_externals): Adjust expected output. Two externals use legacy format.

Modified:
    subversion/branches/pin-externals/subversion/include/private/svn_wc_private.h
    subversion/branches/pin-externals/subversion/libsvn_client/copy.c
    subversion/branches/pin-externals/subversion/libsvn_wc/externals.c
    subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py

Modified: subversion/branches/pin-externals/subversion/include/private/svn_wc_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/include/private/svn_wc_private.h?rev=1656769&r1=1656768&r2=1656769&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/include/private/svn_wc_private.h (original)
+++ subversion/branches/pin-externals/subversion/include/private/svn_wc_private.h Tue Feb
 3 15:57:22 2015
@@ -1259,7 +1259,28 @@ svn_wc__resolve_relative_external_url(co
                                       apr_pool_t *result_pool,
                                       apr_pool_t *scratch_pool);
 
+typedef enum svn_wc__external_description_format_t
+{
+  /* LOCALPATH [-r PEG] URL */
+  svn_wc__external_description_format_1 = 0,
 
+  /* [-r REV] URL[@PEG] LOCALPATH, introduced in Subversion 1.5 */
+  svn_wc__external_description_format_2
+} svn_wc__external_description_format_t;
+
+/* Like svn_wc_parse_externals_description3() but returns an additional array
+ * with elements of type svn_wc__external_description_format_t. Each element
+ * of which indicates the format of the syntax used to define the corresponding
+ * external. @a description_formats_p may be NULL if not required by the caller.
+ */
+svn_error_t *
+svn_wc__parse_externals_description(apr_array_header_t **externals_p,
+                                    apr_array_header_t **description_formats_p,
+                                    const char *defining_directory,
+                                    const char *desc,
+                                    svn_boolean_t canonicalize_url,
+                                    apr_pool_t *pool);
+  
 /**
  * Set @a *editor and @a *edit_baton to an editor that generates
  * #svn_wc_status3_t structures and sends them through @a status_func /

Modified: subversion/branches/pin-externals/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_client/copy.c?rev=1656769&r1=1656768&r2=1656769&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/libsvn_client/copy.c (original)
+++ subversion/branches/pin-externals/subversion/libsvn_client/copy.c Tue Feb  3 15:57:22
2015
@@ -193,10 +193,12 @@ pin_externals_prop(svn_string_t **pinned
 {
   svn_stringbuf_t *buf;
   apr_array_header_t *external_items;
+  apr_array_header_t *description_formats;
   int i;
   apr_pool_t *iterpool;
 
-  SVN_ERR(svn_wc_parse_externals_description3(&external_items,
+  SVN_ERR(svn_wc__parse_externals_description(&external_items,
+                                              &description_formats,
                                               local_abspath_or_url,
                                               externals_prop_val->data,
                                               FALSE /* canonicalize_url */,
@@ -207,6 +209,7 @@ pin_externals_prop(svn_string_t **pinned
   for (i = 0; i < external_items->nelts; i++)
     {
       svn_wc_external_item2_t *item;
+      svn_wc__external_description_format_t format;
       svn_opt_revision_t external_pegrev;
       const char *pinned_desc;
       const char *rev_str;
@@ -215,6 +218,8 @@ pin_externals_prop(svn_string_t **pinned
       svn_pool_clear(iterpool);
 
       item = APR_ARRAY_IDX(external_items, i, svn_wc_external_item2_t *);
+      format = APR_ARRAY_IDX(description_formats, i,
+                             svn_wc__external_description_format_t);
 
       if (item->peg_revision.kind == svn_opt_revision_date)
         {
@@ -309,8 +314,29 @@ pin_externals_prop(svn_string_t **pinned
         peg_rev_str = apr_psprintf(iterpool, "@%ld",
                                    external_pegrev.value.number);
 
-      pinned_desc = apr_psprintf(iterpool, "%s%s%s %s\n", rev_str, item->url,
-                                 peg_rev_str, item->target_dir);
+      switch (format)
+        {
+          case svn_wc__external_description_format_1:
+            if (rev_str[0] == '\0')
+              rev_str = apr_psprintf(iterpool, "-r%ld ",
+                                     external_pegrev.value.number);
+            pinned_desc = apr_psprintf(iterpool, "%s %s%s\n", item->target_dir,
+                                       rev_str, item->url);
+            break;
+
+          case svn_wc__external_description_format_2:
+            pinned_desc = apr_psprintf(iterpool, "%s%s%s %s\n", rev_str, item->url,
+                                       peg_rev_str, item->target_dir);
+            break;
+
+          default:
+            return svn_error_createf(
+                     SVN_ERR_CLIENT_INVALID_EXTERNALS_DESCRIPTION, NULL,
+                     _("%s property defined at '%s' is using an unsupported "
+                       "syntax"), SVN_PROP_EXTERNALS,
+                     svn_dirent_local_style(local_abspath_or_url, iterpool));
+        }
+
       svn_stringbuf_appendcstr(buf, pinned_desc);
     }
   svn_pool_destroy(iterpool);

Modified: subversion/branches/pin-externals/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_wc/externals.c?rev=1656769&r1=1656768&r2=1656769&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/libsvn_wc/externals.c (original)
+++ subversion/branches/pin-externals/subversion/libsvn_wc/externals.c Tue Feb  3 15:57:22
2015
@@ -158,7 +158,8 @@ find_and_remove_externals_revision(int *
 }
 
 svn_error_t *
-svn_wc_parse_externals_description3(apr_array_header_t **externals_p,
+svn_wc__parse_externals_description(apr_array_header_t **externals_p,
+                                    apr_array_header_t **description_formats_p,
                                     const char *defining_directory,
                                     const char *desc,
                                     svn_boolean_t canonicalize_url,
@@ -166,6 +167,7 @@ svn_wc_parse_externals_description3(apr_
 {
   int i;
   apr_array_header_t *externals = NULL;
+  apr_array_header_t *description_formats = NULL;
   apr_array_header_t *lines = svn_cstring_split(desc, "\n\r", TRUE, pool);
   const char *defining_directory_display = svn_path_is_url(defining_directory) ?
     defining_directory : svn_dirent_local_style(defining_directory, pool);
@@ -175,6 +177,10 @@ svn_wc_parse_externals_description3(apr_
   if (externals_p)
     externals = apr_array_make(pool, 1, sizeof(svn_wc_external_item2_t *));
 
+  if (description_formats_p)
+    description_formats =
+      apr_array_make(pool, 1, sizeof(svn_wc__external_description_format_t));
+
   for (i = 0; i < lines->nelts; i++)
     {
       const char *line = APR_ARRAY_IDX(lines, i, const char *);
@@ -186,6 +192,7 @@ svn_wc_parse_externals_description3(apr_
       const char *token1;
       svn_boolean_t token0_is_url;
       svn_boolean_t token1_is_url;
+      svn_wc__external_description_format_t format;
 
       /* Index into line_parts where the revision specification
          started. */
@@ -290,12 +297,14 @@ svn_wc_parse_externals_description3(apr_
           SVN_ERR(svn_opt_parse_path(&item->peg_revision, &item->url,
                                      token0, pool));
           item->target_dir = token1;
+          format = svn_wc__external_description_format_2;
         }
       else
         {
           item->target_dir = token0;
           item->url = token1;
           item->peg_revision = item->revision;
+          format = svn_wc__external_description_format_1;
         }
 
       SVN_ERR(svn_opt_resolve_revisions(&item->peg_revision,
@@ -333,15 +342,35 @@ svn_wc_parse_externals_description3(apr_
 
       if (externals)
         APR_ARRAY_PUSH(externals, svn_wc_external_item2_t *) = item;
+      if (description_formats)
+        APR_ARRAY_PUSH(description_formats,
+                       svn_wc__external_description_format_t) = format;
     }
 
   if (externals_p)
     *externals_p = externals;
+  if (description_formats_p)
+    *description_formats_p = description_formats;
 
   return SVN_NO_ERROR;
 }
 
 svn_error_t *
+svn_wc_parse_externals_description3(apr_array_header_t **externals_p,
+                                    const char *defining_directory,
+                                    const char *desc,
+                                    svn_boolean_t canonicalize_url,
+                                    apr_pool_t *pool)
+{
+  return svn_error_trace(svn_wc__parse_externals_description(externals_p,
+                                                             NULL,
+                                                             defining_directory,
+                                                             desc,
+                                                             canonicalize_url,
+                                                             pool));
+}
+
+svn_error_t *
 svn_wc__externals_find_target_dups(apr_array_header_t **duplicate_targets,
                                    apr_array_header_t *externals,
                                    apr_pool_t *pool,

Modified: subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py?rev=1656769&r1=1656768&r2=1656769&view=diff
==============================================================================
--- subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/branches/pin-externals/subversion/tests/cmdline/externals_tests.py Tue Feb
 3 15:57:22 2015
@@ -3586,8 +3586,8 @@ def copy_pin_externals(sbox):
                                        'propget', 'svn:externals',
                                        target)
     expected_output = [
-      '%s@%d exdir_G\n' % (external_url_for["A/C/exdir_G"],
-                           other_external_youngest_rev),
+      'exdir_G -r%d %s\n' % (other_external_youngest_rev,
+                             external_url_for["A/C/exdir_G"]),
       # Note: A/D/H was last changed in r5, but exdir_H's external
       # definition's URL is already pinned to r1.
       '-r1 %s exdir_H\n' % external_url_for["A/C/exdir_H"],
@@ -3605,7 +3605,7 @@ def copy_pin_externals(sbox):
                            other_external_youngest_rev),
       '%s@%d exdir_A/G\n' % (external_url_for["A/D/exdir_A/G/"],
                              other_external_youngest_rev),
-      '-r1 %s@1 exdir_A/H\n' % external_url_for["A/D/exdir_A/H"],
+      'exdir_A/H -r1 %s\n' % external_url_for["A/D/exdir_A/H"],
       '%s@%d x/y/z/blah\n' % (external_url_for["A/D/x/y/z/blah"],
                               other_external_youngest_rev),
       '\n',



Mime
View raw message