svn commit: r1925683 - in /subversion/branches/xpatch/subversion: include/svn_client.h libsvn_client/diff.c svn/diff-cmd.c

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <[email protected]>
Author: rinrab
Date: Sun May 18 19:00:51 2025
New Revision: 1925683

URL: http://svn.apache.org/viewvc?rev=1925683&view=rev
Log:
On the 'xpatch' branch: Add API functions for creating xpatch files, but
write constant text block for now. Then invoke those functions from the
cmdline when executed with --xpatch argument.

$ svn diff --xpatch
<?xml version="1.0" encoding="UTF-8" ?>
<xpatch>
  this is an xpatch
</xpatch>

* subversion/include/svn_client.h
  (svn_client_diff_xpatch,
   svn_client_diff_xpatch_peg): Declare functions.
* subversion/libsvn_client/diff.c
  (svn_client_diff_xpatch,
   svn_client_diff_xpatch_peg): Implement functions; They will require
   do_diff() local function later to drive the processor.
* subversion/svn/diff-cmd.c
  (svn_cl__diff): Use xpatch API when invoked with appropriate option.

Modified:
    subversion/branches/xpatch/subversion/include/svn_client.h
    subversion/branches/xpatch/subversion/libsvn_client/diff.c
    subversion/branches/xpatch/subversion/svn/diff-cmd.c

Modified: subversion/branches/xpatch/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/branches/xpatch/subversion/include/svn_client.h?rev=1925683&r1=1925682&r2=1925683&view=diff
==============================================================================
--- subversion/branches/xpatch/subversion/include/svn_client.h (original)
+++ subversion/branches/xpatch/subversion/include/svn_client.h Sun May 18 19:00:51 2025
@@ -3715,6 +3715,59 @@ svn_client_diff_summarize_peg(const char
                               svn_client_ctx_t *ctx,
                               apr_pool_t *pool);
 
+/**
+ * Produce a diff in xpatch format, which saves the entire working copy
+ * state, including copies, and can be applied trough a full merge of
+ * the file produced, making Subversion's conflict handling working.
+ *
+ * Writes the output to @a outstream, which should be writable. This stream
+ * can be opened using a svn_stream_open_writable() function, or any other
+ * function, producing writable stream as well.
+ *
+ * See svn_client_diff7() for a description of the other parameters.
+ *
+ * @since New in 1.15.
+ */
+svn_error_t *
+svn_client_diff_xpatch(const char *path_or_url1,
+                       const svn_opt_revision_t *revision1,
+                       const char *path_or_url2,
+                       const svn_opt_revision_t *revision2,
+                       svn_depth_t depth,
+                       svn_boolean_t ignore_ancestry,
+                       const apr_array_header_t *changelists,
+                       svn_stream_t *outstream,
+                       svn_client_ctx_t *ctx,
+                       apr_pool_t *pool);
+
+/**
+ * Produce a diff in xpatch format, which saves the entire working copy
+ * state, including copies, and can be applied trough a full merge of
+ * the file produced, making Subversion's conflict handling working.
+ * The differences will be produced between the filesystem object
+ * @a path_or_url in peg revision @a peg_revision, as it changed between
+ * @a start_revision and @a end_revision. @a path_or_url can be either a
+ * working-copy path or URL.
+ *
+ * Writes the output to @a outstream, which should be writable. This stream
+ * can be opened using a svn_stream_open_writable() function, or any other
+ * function, producing writable stream as well.
+ *
+ * See svn_client_diff_peg7() for a description of the other parameters.
+ *
+ * @since New in 1.15.
+ */
+svn_error_t *
+svn_client_diff_xpatch_peg(const char *path_or_url,
+                           const svn_opt_revision_t *peg_revision,
+                           const svn_opt_revision_t *start_revision,
+                           const svn_opt_revision_t *end_revision,
+                           svn_depth_t depth,
+                           svn_boolean_t ignore_ancestry,
+                           svn_stream_t *outstream,
+                           svn_client_ctx_t *ctx,
+                           apr_pool_t *pool);
+
 /** @} */
 
 /**

Modified: subversion/branches/xpatch/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/xpatch/subversion/libsvn_client/diff.c?rev=1925683&r1=1925682&r2=1925683&view=diff
==============================================================================
--- subversion/branches/xpatch/subversion/libsvn_client/diff.c (original)
+++ subversion/branches/xpatch/subversion/libsvn_client/diff.c Sun May 18 19:00:51 2025
@@ -1422,3 +1422,40 @@ svn_client_diff_summarize_peg2(const cha
                                  diff_processor, ctx, pool, pool));
 }
 
+#define TEST_XPATCH "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" APR_EOL_STR \
+                    "<xpatch>"                                    APR_EOL_STR \
+                    "  this is an xpatch"                         APR_EOL_STR \
+                    "</xpatch>"                                   APR_EOL_STR
+
+svn_error_t *
+svn_client_diff_xpatch(const char *path_or_url1,
+                       const svn_opt_revision_t *revision1,
+                       const char *path_or_url2,
+                       const svn_opt_revision_t *revision2,
+                       svn_depth_t depth,
+                       svn_boolean_t ignore_ancestry,
+                       const apr_array_header_t *changelists,
+                       svn_stream_t *outstream,
+                       svn_client_ctx_t *ctx,
+                       apr_pool_t *pool)
+{
+  apr_size_t len = sizeof(TEST_XPATCH);
+  SVN_ERR(svn_stream_write(outstream, TEST_XPATCH, &len));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_client_diff_xpatch_peg(const char *path_or_url,
+                           const svn_opt_revision_t *peg_revision,
+                           const svn_opt_revision_t *start_revision,
+                           const svn_opt_revision_t *end_revision,
+                           svn_depth_t depth,
+                           svn_boolean_t ignore_ancestry,
+                           svn_stream_t *outstream,
+                           svn_client_ctx_t *ctx,
+                           apr_pool_t *pool)
+{
+  apr_size_t len = sizeof(TEST_XPATCH);
+  SVN_ERR(svn_stream_write(outstream, TEST_XPATCH, &len));
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/xpatch/subversion/svn/diff-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/xpatch/subversion/svn/diff-cmd.c?rev=1925683&r1=1925682&r2=1925683&view=diff
==============================================================================
--- subversion/branches/xpatch/subversion/svn/diff-cmd.c (original)
+++ subversion/branches/xpatch/subversion/svn/diff-cmd.c Sun May 18 19:00:51 2025
@@ -481,6 +481,17 @@ svn_cl__diff(apr_getopt_t *os,
                                 summarize_func, summarize_baton,
                                 ctx, iterpool));
             }
+          else if (opt_state->diff.xpatch)
+            SVN_ERR(svn_client_diff_xpatch(
+                     target1,
+                     &(opt_state->start_revision),
+                     target2,
+                     &(opt_state->end_revision),
+                     opt_state->depth,
+                     ! opt_state->diff.notice_ancestry,
+                     opt_state->changelists,
+                     outstream,
+                     ctx, iterpool));
           else
             SVN_ERR(svn_client_diff7(
                      options,
@@ -539,6 +550,16 @@ svn_cl__diff(apr_getopt_t *os,
                                 summarize_func, summarize_baton,
                                 ctx, iterpool));
             }
+          else if (opt_state->diff.xpatch)
+            SVN_ERR(svn_client_diff_xpatch_peg(
+                                truepath,
+                                &peg_revision,
+                                &opt_state->start_revision,
+                                &opt_state->end_revision,
+                                opt_state->depth,
+                                ! opt_state->diff.notice_ancestry,
+                                outstream,
+                                ctx, iterpool));
           else
             SVN_ERR(svn_client_diff_peg7(
                      options,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.