summaryrefslogtreecommitdiff
path: root/subversion/libsvn_wc/diff_local.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_wc/diff_local.c')
-rw-r--r--subversion/libsvn_wc/diff_local.c160
1 files changed, 96 insertions, 64 deletions
diff --git a/subversion/libsvn_wc/diff_local.c b/subversion/libsvn_wc/diff_local.c
index 22b498f..e1cb329 100644
--- a/subversion/libsvn_wc/diff_local.c
+++ b/subversion/libsvn_wc/diff_local.c
@@ -1,6 +1,6 @@
/*
- * diff_pristine.c -- A simple diff walker which compares local files against
- * their pristine versions.
+ * diff_local.c -- A simple diff walker which compares local files against
+ * their pristine versions.
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@@ -41,8 +41,8 @@
#include "private/svn_diff_tree.h"
#include "wc.h"
+#include "wc_db.h"
#include "props.h"
-#include "translate.h"
#include "diff.h"
#include "svn_private_config.h"
@@ -89,9 +89,6 @@ struct diff_baton
/* Should this diff ignore node ancestry? */
svn_boolean_t ignore_ancestry;
- /* Should this diff not compare copied files with their source? */
- svn_boolean_t show_copies_as_adds;
-
/* Cancel function/baton */
svn_cancel_func_t cancel_func;
void *cancel_baton;
@@ -119,17 +116,17 @@ ensure_state(struct diff_baton *eb,
if (! relpath)
return SVN_NO_ERROR;
- /* Don't recurse on the anchor, as that might loop infinately because
+ /* Don't recurse on the anchor, as that might loop infinitely because
svn_dirent_dirname("/",...) -> "/"
svn_dirent_dirname("C:/",...) -> "C:/" (Windows) */
if (*relpath)
SVN_ERR(ensure_state(eb,
- svn_dirent_dirname(local_abspath,scratch_pool),
+ svn_dirent_dirname(local_abspath, scratch_pool),
FALSE,
scratch_pool));
}
else if (svn_dirent_is_child(eb->cur->local_abspath, local_abspath, NULL))
- SVN_ERR(ensure_state(eb, svn_dirent_dirname(local_abspath,scratch_pool),
+ SVN_ERR(ensure_state(eb, svn_dirent_dirname(local_abspath, scratch_pool),
FALSE,
scratch_pool));
else
@@ -421,23 +418,22 @@ diff_status_callback(void *baton,
/* Public Interface */
svn_error_t *
-svn_wc_diff6(svn_wc_context_t *wc_ctx,
- const char *local_abspath,
- const svn_wc_diff_callbacks4_t *callbacks,
- void *callback_baton,
- svn_depth_t depth,
- svn_boolean_t ignore_ancestry,
- svn_boolean_t show_copies_as_adds,
- svn_boolean_t use_git_diff_format,
- const apr_array_header_t *changelist_filter,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
- apr_pool_t *scratch_pool)
+svn_wc__diff7(const char **root_relpath,
+ svn_boolean_t *root_is_dir,
+ svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ svn_depth_t depth,
+ svn_boolean_t ignore_ancestry,
+ const apr_array_header_t *changelist_filter,
+ const svn_diff_tree_processor_t *diff_processor,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
struct diff_baton eb = { 0 };
svn_node_kind_t kind;
svn_boolean_t get_all;
- const svn_diff_tree_processor_t *processor;
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath,
@@ -446,30 +442,27 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
FALSE /* show_hidden */,
scratch_pool));
- if (kind == svn_node_dir)
- eb.anchor_abspath = local_abspath;
- else
- eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
-
- SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
- callbacks, callback_baton, TRUE,
- scratch_pool, scratch_pool));
-
- if (use_git_diff_format)
- show_copies_as_adds = TRUE;
- if (show_copies_as_adds)
- ignore_ancestry = FALSE;
+ eb.anchor_abspath = local_abspath;
+ if (root_relpath)
+ {
+ svn_boolean_t is_wcroot;
+ SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot,
+ wc_ctx->db, local_abspath, scratch_pool));
- /*
- if (reverse_order)
- processor = svn_diff__tree_processor_reverse_create(processor, NULL, pool);
- */
+ if (!is_wcroot)
+ eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
+ }
+ else if (kind != svn_node_dir)
+ eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
- if (! show_copies_as_adds && !use_git_diff_format)
- processor = svn_diff__tree_processor_copy_as_changed_create(processor,
- scratch_pool);
+ if (root_relpath)
+ *root_relpath = apr_pstrdup(result_pool,
+ svn_dirent_skip_ancestor(eb.anchor_abspath,
+ local_abspath));
+ if (root_is_dir)
+ *root_is_dir = (kind == svn_node_dir);
/* Apply changelist filtering to the output */
if (changelist_filter && changelist_filter->nelts)
@@ -477,19 +470,18 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
apr_hash_t *changelist_hash;
SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
- scratch_pool));
- processor = svn_wc__changelist_filter_tree_processor_create(
- processor, wc_ctx, local_abspath,
- changelist_hash, scratch_pool);
+ result_pool));
+ diff_processor = svn_wc__changelist_filter_tree_processor_create(
+ diff_processor, wc_ctx, local_abspath,
+ changelist_hash, result_pool);
}
eb.db = wc_ctx->db;
- eb.processor = processor;
+ eb.processor = diff_processor;
eb.ignore_ancestry = ignore_ancestry;
- eb.show_copies_as_adds = show_copies_as_adds;
eb.pool = scratch_pool;
- if (show_copies_as_adds || use_git_diff_format || !ignore_ancestry)
+ if (ignore_ancestry)
get_all = TRUE; /* We need unmodified descendants of copies */
else
get_all = FALSE;
@@ -512,22 +504,22 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
if (!ns->skip)
{
if (ns->propchanges)
- SVN_ERR(processor->dir_changed(ns->relpath,
- ns->left_src,
- ns->right_src,
- ns->left_props,
- ns->right_props,
- ns->propchanges,
- ns->baton,
- processor,
- ns->pool));
+ SVN_ERR(diff_processor->dir_changed(ns->relpath,
+ ns->left_src,
+ ns->right_src,
+ ns->left_props,
+ ns->right_props,
+ ns->propchanges,
+ ns->baton,
+ diff_processor,
+ ns->pool));
else
- SVN_ERR(processor->dir_closed(ns->relpath,
- ns->left_src,
- ns->right_src,
- ns->baton,
- processor,
- ns->pool));
+ SVN_ERR(diff_processor->dir_closed(ns->relpath,
+ ns->left_src,
+ ns->right_src,
+ ns->baton,
+ diff_processor,
+ ns->pool));
}
eb.cur = ns->parent;
svn_pool_clear(ns->pool);
@@ -535,3 +527,43 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
return SVN_NO_ERROR;
}
+
+svn_error_t *
+svn_wc_diff6(svn_wc_context_t *wc_ctx,
+ const char *local_abspath,
+ const svn_wc_diff_callbacks4_t *callbacks,
+ void *callback_baton,
+ svn_depth_t depth,
+ svn_boolean_t ignore_ancestry,
+ svn_boolean_t show_copies_as_adds,
+ svn_boolean_t use_git_diff_format,
+ const apr_array_header_t *changelist_filter,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *scratch_pool)
+{
+ const svn_diff_tree_processor_t *processor;
+
+ SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
+ callbacks, callback_baton, TRUE,
+ scratch_pool, scratch_pool));
+
+ if (use_git_diff_format)
+ show_copies_as_adds = TRUE;
+ if (show_copies_as_adds)
+ ignore_ancestry = FALSE;
+
+ if (! show_copies_as_adds && !use_git_diff_format)
+ processor = svn_diff__tree_processor_copy_as_changed_create(processor,
+ scratch_pool);
+
+ return svn_error_trace(svn_wc__diff7(NULL, NULL,
+ wc_ctx, local_abspath,
+ depth,
+ ignore_ancestry,
+ changelist_filter,
+ processor,
+ cancel_func, cancel_baton,
+ scratch_pool, scratch_pool));
+}
+