Author: julianfoad
Date: Fri Mar 16 15:19:24 2018
New Revision: 1826993

URL: http://svn.apache.org/viewvc?rev=1826993&view=rev
Log:
Viewspec: support output in a new 'svn-viewspec.py' format 2.

This does not yet provide a way to select the svn command-line format,
or svn-viewspec.py format 1, although the code to do is still present.

* subversion/svn/info-cmd.c
  (layout_list_baton_t): Add a format selector.
  (depth_to_viewspec_py): Support 'excluded'.
  (output_svn_viewspec_py): Support 'excluded' and revisions and switched.
  (cl_layout_list): Set the format number to 2.

Modified:
    subversion/trunk/subversion/svn/info-cmd.c

Modified: subversion/trunk/subversion/svn/info-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/info-cmd.c?rev=1826993&r1=1826992&r2=1826993&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/info-cmd.c (original)
+++ subversion/trunk/subversion/svn/info-cmd.c Fri Mar 16 15:19:24 2018
@@ -50,6 +50,7 @@ struct layout_list_baton_t
   svn_boolean_t checkout;
   const char *target;
   const char *target_abspath;
+  int vs_py_format;
 };
 
 /* Output as 'svn' command-line commands.
@@ -142,6 +143,8 @@ depth_to_viewspec_py(svn_depth_t depth,
       return "/~";
     case svn_depth_empty:
       return "";
+    case svn_depth_exclude:
+      return "!";
     default:
       break;
     }
@@ -172,24 +175,22 @@ output_svn_viewspec_py(void *layout_bato
   const char *rev_str = "";
   const char *repos_rel_url = "";
 
-  if (depth == svn_depth_exclude)
-    {
-      return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                               _("svn-viewspec.py format 1 does not support "
-                                 "the 'excluded' state found at '%s'"),
-                               relpath);
-    }
   depth_str = ((depth_changed || llb->checkout)
                ? depth_to_viewspec_py(depth, scratch_pool)
                : "");
+  if (llb->vs_py_format >= 2
+      && SVN_IS_VALID_REVNUM(revision)
+      && depth >= svn_depth_empty)
+    rev_str = apr_psprintf(scratch_pool, "@%ld", revision);
 
   if (llb->checkout)
     {
       SVN_ERR(svn_cmdline_printf(scratch_pool,
-                                 "Format: 1\n"
+                                 "Format: %d\n"
                                  "Url: %s\n"
+                                 "Revision: %ld\n"
                                  "\n",
-                                 url));
+                                 llb->vs_py_format, url, revision));
       llb->checkout = FALSE;
 
       if (depth == svn_depth_empty)
@@ -199,17 +200,24 @@ output_svn_viewspec_py(void *layout_bato
     }
   else if (not_present)
     {
-      return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                               _("svn-viewspec.py format 1 does not support "
-                                 "the 'not-present' state found at '%s'"),
-                               relpath);
+      /* Easiest way to create a not present node: update to r0 */
+      if (llb->vs_py_format < 2)
+        return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+                                 _("svn-viewspec.py format 1 does not support "
+                                   "the 'not-present' state found at '%s'"),
+                                 relpath);
+      rev_str = "@0";
     }
   else if (url_changed)
     {
-      return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                               _("svn-viewspec.py format 1 does not support "
-                                 "the 'switched' state found at '%s'"),
-                               relpath);
+      if (llb->vs_py_format < 2)
+        return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+                                 _("svn-viewspec.py format 1 does not support "
+                                   "the 'switched' state found at '%s'"),
+                                 relpath);
+      repos_rel_url = svn_uri_skip_ancestor(repos_root_url, url,
+                                            scratch_pool);
+      repos_rel_url = apr_psprintf(scratch_pool, "^/%s", repos_rel_url);
     }
   else if (!(revision_changed || depth_changed))
     return SVN_NO_ERROR;
@@ -250,6 +258,8 @@ cl_layout_list(apr_array_header_t *targe
   if (TRUE)
     {
       /* svn-viewspec.py format */
+      llb.vs_py_format = 2;
+
       SVN_ERR(svn_client_layout_list(list_abspath,
                                      output_svn_viewspec_py, &llb,
                                      ctx, scratch_pool));


Reply via email to