You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/01/12 17:33:56 UTC

svn commit: r1432470 - in /subversion/trunk/subversion/svn: cl-conflicts.c cl-conflicts.h conflict-callbacks.c info-cmd.c status.c tree-conflicts.c tree-conflicts.h

Author: rhuijben
Date: Sat Jan 12 16:33:55 2013
New Revision: 1432470

URL: http://svn.apache.org/viewvc?rev=1432470&view=rev
Log:
Following up on r1432454, make 'svn info' print more of the conflict
information that is now available, instead of still just printing
what we originally stored for conflicts in svn_wc_entry_t.

info.rnc needs updating after this patch. I expected to copy and paste
the missing pieces (src-left, etc.) from the tree conflicts, but these
aren't defined yet, while introduced in 1.6.

* subversion/svn/cl-conflicts.c
  Renamed from tree-conflicts.c
  (map_conflict_kind_xml): New map.
  (svn_cl__append_tree_conflict_info_xml): Rename to...
  (append_tree_conflict_info_xml): ... this and make static.
  (svn_cl__append_conflict_info_xml): New function that handles all conflict
    kinds.

* subversion/svn/cl-conflicts.h
  Renamed from tree-conflicts.h
  (svn_cl__append_tree_conflict_info_xml): Rename to...
  (svn_cl__append_conflict_info_xml): ... this. Update docstring.

* subversion/svn/conflict-callbacks.c
  (includes): Updated for rename.

* subversion/svn/info-cmd.c
  (includes): Follow rename.
  (print_info_xml): Delegate all conflict work to
    svn_cl__append_conflict_info_xml.
  (print_info): Print left and right version for the first conflict, instead
    of just for tree conflicts.

* subversion/svn/status.c
  (includes): Updated for rename.

* subversion/svn/tree-conflicts.c
  Renamed to cl-conflicts.c

* subversion/svn/tree-conflicts.h
  Renamed to cl-conflicts.h

Added:
    subversion/trunk/subversion/svn/cl-conflicts.c
      - copied, changed from r1432453, subversion/trunk/subversion/svn/tree-conflicts.c
    subversion/trunk/subversion/svn/cl-conflicts.h
      - copied, changed from r1432453, subversion/trunk/subversion/svn/tree-conflicts.h
Removed:
    subversion/trunk/subversion/svn/tree-conflicts.c
    subversion/trunk/subversion/svn/tree-conflicts.h
Modified:
    subversion/trunk/subversion/svn/conflict-callbacks.c
    subversion/trunk/subversion/svn/info-cmd.c
    subversion/trunk/subversion/svn/status.c

Copied: subversion/trunk/subversion/svn/cl-conflicts.c (from r1432453, subversion/trunk/subversion/svn/tree-conflicts.c)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl-conflicts.c?p2=subversion/trunk/subversion/svn/cl-conflicts.c&p1=subversion/trunk/subversion/svn/tree-conflicts.c&r1=1432453&r2=1432470&rev=1432470&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/tree-conflicts.c (original)
+++ subversion/trunk/subversion/svn/cl-conflicts.c Sat Jan 12 16:33:55 2013
@@ -1,5 +1,5 @@
 /*
- * tree-conflicts.c: Tree conflicts.
+ * conflicts.c: Tree conflicts.
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -21,7 +21,7 @@
  * ====================================================================
  */
 
-#include "tree-conflicts.h"
+#include "cl-conflicts.h"
 #include "svn_xml.h"
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
@@ -82,6 +82,14 @@ static const svn_token_map_t map_conflic
   { NULL,               0 }
 };
 
+static const svn_token_map_t map_conflict_kind_xml[] =
+{
+  { "text",             svn_wc_conflict_kind_text },
+  { "property",         svn_wc_conflict_kind_property },
+  { "tree",             svn_wc_conflict_kind_tree },
+  { NULL,               0 }
+};
+
 /* Return a localized string representation of CONFLICT->action. */
 static const char *
 action_str(const svn_wc_conflict_description2_t *conflict)
@@ -96,7 +104,6 @@ reason_str(const svn_wc_conflict_descrip
   return _(svn_token__to_word(map_conflict_reason_human, conflict->reason));
 }
 
-
 svn_error_t *
 svn_cl__get_human_readable_tree_conflict_description(
   const char **desc,
@@ -178,11 +185,10 @@ add_conflict_version_xml(svn_stringbuf_t
 }
 
 
-svn_error_t *
-svn_cl__append_tree_conflict_info_xml(
-  svn_stringbuf_t *str,
-  const svn_wc_conflict_description2_t *conflict,
-  apr_pool_t *pool)
+static svn_error_t *
+append_tree_conflict_info_xml(svn_stringbuf_t *str,
+                              const svn_wc_conflict_description2_t *conflict,
+                              apr_pool_t *pool)
 {
   apr_hash_t *att_hash = apr_hash_make(pool);
   const char *tmp;
@@ -225,3 +231,76 @@ svn_cl__append_tree_conflict_info_xml(
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_cl__append_conflict_info_xml(svn_stringbuf_t *str,
+                                 const svn_wc_conflict_description2_t *conflict,
+                                 apr_pool_t *scratch_pool)
+{
+  apr_hash_t *att_hash;
+  const char *kind;
+  if (conflict->kind == svn_wc_conflict_kind_tree)
+    {
+      /* Uses other element type */
+      return svn_error_trace(
+                append_tree_conflict_info_xml(str, conflict, scratch_pool));
+    }
+
+  att_hash = apr_hash_make(scratch_pool);
+
+  apr_hash_set(att_hash, "operation", APR_HASH_KEY_STRING,
+               svn_cl__operation_str_xml(conflict->operation, scratch_pool));
+
+
+  kind = svn_token__to_word(map_conflict_kind_xml, conflict->kind);
+  apr_hash_set(att_hash, "kind", APR_HASH_KEY_STRING, kind);
+
+  /* "<conflict>" */
+  svn_xml_make_open_tag_hash(&str, scratch_pool,
+                             svn_xml_normal, "conflict", att_hash);
+
+  if (conflict->src_left_version)
+    SVN_ERR(add_conflict_version_xml(&str,
+                                     "source-left",
+                                     conflict->src_left_version,
+                                     scratch_pool));
+
+  if (conflict->src_right_version)
+    SVN_ERR(add_conflict_version_xml(&str,
+                                     "source-right",
+                                     conflict->src_right_version,
+                                     scratch_pool));
+
+  switch (conflict->kind)
+    {
+      case svn_wc_conflict_kind_text:
+        /* "<prev-base-file> xx </prev-base-file>" */
+        svn_cl__xml_tagged_cdata(&str, scratch_pool, "prev-base-file",
+                                 conflict->base_abspath);
+
+        /* "<prev-wc-file> xx </prev-wc-file>" */
+        svn_cl__xml_tagged_cdata(&str, scratch_pool, "prev-wc-file",
+                                 conflict->my_abspath);
+
+        /* "<cur-base-file> xx </cur-base-file>" */
+        svn_cl__xml_tagged_cdata(&str, scratch_pool, "cur-base-file",
+                                 conflict->their_abspath);
+
+        break;
+
+      case svn_wc_conflict_kind_property:
+        /* "<prop-file> xx </prop-file>" */
+        svn_cl__xml_tagged_cdata(&str, scratch_pool, "prop-file",
+                                 conflict->their_abspath);
+        break;
+
+      default:
+      case svn_wc_conflict_kind_tree:
+        SVN_ERR_MALFUNCTION(); /* Handled separately */
+        break;
+    }
+
+  /* "</conflict>" */
+  svn_xml_make_close_tag(&str, scratch_pool, "conflict");
+
+  return SVN_NO_ERROR;
+}

Copied: subversion/trunk/subversion/svn/cl-conflicts.h (from r1432453, subversion/trunk/subversion/svn/tree-conflicts.h)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl-conflicts.h?p2=subversion/trunk/subversion/svn/cl-conflicts.h&p1=subversion/trunk/subversion/svn/tree-conflicts.h&r1=1432453&r2=1432470&rev=1432470&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/tree-conflicts.h (original)
+++ subversion/trunk/subversion/svn/cl-conflicts.h Sat Jan 12 16:33:55 2013
@@ -1,5 +1,5 @@
 /*
- * tree-conflicts.h: Tree conflicts.
+ * conflicts.h: Conflicts handling
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -23,8 +23,8 @@
 
 
 
-#ifndef SVN_TREE_CONFLICTS_H
-#define SVN_TREE_CONFLICTS_H
+#ifndef SVN_CONFLICTS_H
+#define SVN_CONFLICTS_H
 
 /*** Includes. ***/
 #include <apr_pools.h>
@@ -52,11 +52,11 @@ svn_cl__get_human_readable_tree_conflict
   apr_pool_t *pool);
 
 /**
- * Append to @a str an XML representation of the tree conflict data
+ * Append to @a str an XML representation of the conflict data
  * for @a conflict, in a format suitable for 'svn info --xml'.
  */
 svn_error_t *
-svn_cl__append_tree_conflict_info_xml(
+svn_cl__append_conflict_info_xml(
   svn_stringbuf_t *str,
   const svn_wc_conflict_description2_t *conflict,
   apr_pool_t *pool);
@@ -65,4 +65,4 @@ svn_cl__append_tree_conflict_info_xml(
 }
 #endif /* __cplusplus */
 
-#endif /* SVN_TREE_CONFLICTS_H */
+#endif /* SVN_CONFLICTS_H */

Modified: subversion/trunk/subversion/svn/conflict-callbacks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/conflict-callbacks.c?rev=1432470&r1=1432469&r2=1432470&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/conflict-callbacks.c (original)
+++ subversion/trunk/subversion/svn/conflict-callbacks.c Sat Jan 12 16:33:55 2013
@@ -36,7 +36,7 @@
 #include "svn_sorts.h"
 
 #include "cl.h"
-#include "tree-conflicts.h"
+#include "cl-conflicts.h"
 
 #include "private/svn_cmdline_private.h"
 

Modified: subversion/trunk/subversion/svn/info-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/info-cmd.c?rev=1432470&r1=1432469&r2=1432470&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/info-cmd.c (original)
+++ subversion/trunk/subversion/svn/info-cmd.c Sat Jan 12 16:33:55 2013
@@ -40,7 +40,7 @@
 #include "cl.h"
 
 #include "svn_private_config.h"
-#include "tree-conflicts.h"
+#include "cl-conflicts.h"
 
 
 /*** Code. ***/
@@ -240,47 +240,7 @@ print_info_xml(void *baton,
                       APR_ARRAY_IDX(info->wc_info->conflicts, i,
                                     const svn_wc_conflict_description2_t *);
 
-          switch (conflict->kind)
-            {
-              case svn_wc_conflict_kind_text:
-                /* "<conflict>" */
-                svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "conflict",
-                                      NULL);
-
-                /* "<prev-base-file> xx </prev-base-file>" */
-                svn_cl__xml_tagged_cdata(&sb, pool, "prev-base-file",
-                                         conflict->base_abspath);
-
-                /* "<prev-wc-file> xx </prev-wc-file>" */
-                svn_cl__xml_tagged_cdata(&sb, pool, "prev-wc-file",
-                                         conflict->my_abspath);
-
-                /* "<cur-base-file> xx </cur-base-file>" */
-                svn_cl__xml_tagged_cdata(&sb, pool, "cur-base-file",
-                                         conflict->their_abspath);
-
-                /* "</conflict>" */
-                svn_xml_make_close_tag(&sb, pool, "conflict");
-              break;
-
-              case svn_wc_conflict_kind_property:
-                /* "<conflict>" */
-                svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "conflict",
-                                      NULL);
-
-                /* "<prop-file> xx </prop-file>" */
-                svn_cl__xml_tagged_cdata(&sb, pool, "prop-file",
-                                         conflict->their_abspath);
-
-                /* "</conflict>" */
-                svn_xml_make_close_tag(&sb, pool, "conflict");
-              break;
-
-              case svn_wc_conflict_kind_tree:
-                SVN_ERR(svn_cl__append_tree_conflict_info_xml(sb, conflict,
-                                                              pool));
-              break;
-            }
+          SVN_ERR(svn_cl__append_conflict_info_xml(sb, conflict, pool));
         }
     }
 
@@ -482,12 +442,10 @@ print_info(void *baton,
 
           for (i = 0; i < info->wc_info->conflicts->nelts; i++)
             {
-                const svn_wc_conflict_description2_t *conflict =
-                      APR_ARRAY_IDX(info->wc_info->conflicts, i,
-                                    const svn_wc_conflict_description2_t *);
-                const char *desc;
-                const char *src_left_version;
-                const char *src_right_version;
+              const svn_wc_conflict_description2_t *conflict =
+                    APR_ARRAY_IDX(info->wc_info->conflicts, i,
+                                  const svn_wc_conflict_description2_t *);
+              const char *desc;
 
               switch (conflict->kind)
                 {
@@ -526,33 +484,45 @@ print_info(void *baton,
                         svn_cl__get_human_readable_tree_conflict_description(
                                                     &desc, conflict, pool));
 
-                    src_left_version =
-                          svn_cl__node_description(conflict->src_left_version,
-                                                   info->repos_root_URL, pool);
-
-                    src_right_version =
-                          svn_cl__node_description(conflict->src_right_version,
-                                                   info->repos_root_URL, pool);
-
                     SVN_ERR(svn_cmdline_printf(pool, "%s: %s\n",
                                                _("Tree conflict"), desc));
-
-                    if (src_left_version)
-                        SVN_ERR(svn_cmdline_printf(pool, "  %s: %s\n",
-                                   _("Source  left"), /* (1) */
-                                   src_left_version));
-                    /* (1): Sneaking in a space in "Source  left" so that
-                     * it is the same length as "Source right" while it still
-                     * starts in the same column. That's just a tiny tweak in
-                     * the English `svn'. */
-
-                    if (src_right_version)
-                        SVN_ERR(svn_cmdline_printf(pool, "  %s: %s\n",
-                                                   _("Source right"),
-                                                   src_right_version));
                   break;
                 }
             }
+
+          /* We only store one left and right version for all conflicts, which is
+             referenced from all conflicts.
+             Print it after the conflicts to match the 1.6/1.7 output where it is
+             only available for tree conflicts */
+          {
+            const char *src_left_version;
+            const char *src_right_version;
+            const svn_wc_conflict_description2_t *conflict =
+                  APR_ARRAY_IDX(info->wc_info->conflicts, 0,
+                                const svn_wc_conflict_description2_t *);
+
+            src_left_version =
+                        svn_cl__node_description(conflict->src_left_version,
+                                                 info->repos_root_URL, pool);
+
+            src_right_version =
+                        svn_cl__node_description(conflict->src_right_version,
+                                                 info->repos_root_URL, pool);
+
+            if (src_left_version)
+              SVN_ERR(svn_cmdline_printf(pool, "  %s: %s\n",
+                                         _("Source  left"), /* (1) */
+                                         src_left_version));
+            /* (1): Sneaking in a space in "Source  left" so that
+             * it is the same length as "Source right" while it still
+             * starts in the same column. That's just a tiny tweak in
+             * the English `svn'. */
+
+            if (src_right_version)
+              SVN_ERR(svn_cmdline_printf(pool, "  %s: %s\n",
+                                         _("Source right"),
+                                         src_right_version));
+          }
         }
     }
 

Modified: subversion/trunk/subversion/svn/status.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/status.c?rev=1432470&r1=1432469&r2=1432470&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/status.c (original)
+++ subversion/trunk/subversion/svn/status.c Sat Jan 12 16:33:55 2013
@@ -33,7 +33,7 @@
 #include "svn_time.h"
 #include "cl.h"
 #include "svn_private_config.h"
-#include "tree-conflicts.h"
+#include "cl-conflicts.h"
 #include "private/svn_wc_private.h"
 
 /* Return the single character representation of STATUS */