2
* diff_pristine.c -- A simple diff walker which compares local files against
3
* their pristine versions.
2
* diff_local.c -- A simple diff walker which compares local files against
3
* their pristine versions.
5
5
* ====================================================================
6
6
* Licensed to the Apache Software Foundation (ASF) under one
89
89
/* Should this diff ignore node ancestry? */
90
90
svn_boolean_t ignore_ancestry;
92
/* Should this diff not compare copied files with their source? */
93
svn_boolean_t show_copies_as_adds;
95
92
/* Cancel function/baton */
96
93
svn_cancel_func_t cancel_func;
97
94
void *cancel_baton;
120
117
return SVN_NO_ERROR;
122
/* Don't recurse on the anchor, as that might loop infinately because
119
/* Don't recurse on the anchor, as that might loop infinitely because
123
120
svn_dirent_dirname("/",...) -> "/"
124
121
svn_dirent_dirname("C:/",...) -> "C:/" (Windows) */
126
123
SVN_ERR(ensure_state(eb,
127
svn_dirent_dirname(local_abspath,scratch_pool),
124
svn_dirent_dirname(local_abspath, scratch_pool),
131
128
else if (svn_dirent_is_child(eb->cur->local_abspath, local_abspath, NULL))
132
SVN_ERR(ensure_state(eb, svn_dirent_dirname(local_abspath,scratch_pool),
129
SVN_ERR(ensure_state(eb, svn_dirent_dirname(local_abspath, scratch_pool),
422
419
/* Public Interface */
424
svn_wc_diff6(svn_wc_context_t *wc_ctx,
425
const char *local_abspath,
426
const svn_wc_diff_callbacks4_t *callbacks,
427
void *callback_baton,
429
svn_boolean_t ignore_ancestry,
430
svn_boolean_t show_copies_as_adds,
431
svn_boolean_t use_git_diff_format,
432
const apr_array_header_t *changelist_filter,
433
svn_cancel_func_t cancel_func,
435
apr_pool_t *scratch_pool)
421
svn_wc__diff7(const char **root_relpath,
422
svn_boolean_t *root_is_dir,
423
svn_wc_context_t *wc_ctx,
424
const char *local_abspath,
426
svn_boolean_t ignore_ancestry,
427
const apr_array_header_t *changelist_filter,
428
const svn_diff_tree_processor_t *diff_processor,
429
svn_cancel_func_t cancel_func,
431
apr_pool_t *result_pool,
432
apr_pool_t *scratch_pool)
437
434
struct diff_baton eb = { 0 };
438
435
svn_node_kind_t kind;
439
436
svn_boolean_t get_all;
440
const svn_diff_tree_processor_t *processor;
442
438
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
443
439
SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, local_abspath,
446
442
FALSE /* show_hidden */,
449
if (kind == svn_node_dir)
450
eb.anchor_abspath = local_abspath;
445
eb.anchor_abspath = local_abspath;
449
svn_boolean_t is_wcroot;
451
SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot,
452
wc_ctx->db, local_abspath, scratch_pool));
455
eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
457
else if (kind != svn_node_dir)
452
458
eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
454
SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
455
callbacks, callback_baton, TRUE,
456
scratch_pool, scratch_pool));
458
if (use_git_diff_format)
459
show_copies_as_adds = TRUE;
460
if (show_copies_as_adds)
461
ignore_ancestry = FALSE;
467
processor = svn_diff__tree_processor_reverse_create(processor, NULL, pool);
470
if (! show_copies_as_adds && !use_git_diff_format)
471
processor = svn_diff__tree_processor_copy_as_changed_create(processor,
461
*root_relpath = apr_pstrdup(result_pool,
462
svn_dirent_skip_ancestor(eb.anchor_abspath,
465
*root_is_dir = (kind == svn_node_dir);
474
467
/* Apply changelist filtering to the output */
475
468
if (changelist_filter && changelist_filter->nelts)
477
470
apr_hash_t *changelist_hash;
479
472
SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
481
processor = svn_wc__changelist_filter_tree_processor_create(
482
processor, wc_ctx, local_abspath,
483
changelist_hash, scratch_pool);
474
diff_processor = svn_wc__changelist_filter_tree_processor_create(
475
diff_processor, wc_ctx, local_abspath,
476
changelist_hash, result_pool);
486
479
eb.db = wc_ctx->db;
487
eb.processor = processor;
480
eb.processor = diff_processor;
488
481
eb.ignore_ancestry = ignore_ancestry;
489
eb.show_copies_as_adds = show_copies_as_adds;
490
482
eb.pool = scratch_pool;
492
if (show_copies_as_adds || use_git_diff_format || !ignore_ancestry)
493
485
get_all = TRUE; /* We need unmodified descendants of copies */
514
506
if (ns->propchanges)
515
SVN_ERR(processor->dir_changed(ns->relpath,
507
SVN_ERR(diff_processor->dir_changed(ns->relpath,
525
SVN_ERR(processor->dir_closed(ns->relpath,
517
SVN_ERR(diff_processor->dir_closed(ns->relpath,
532
524
eb.cur = ns->parent;
533
525
svn_pool_clear(ns->pool);
536
528
return SVN_NO_ERROR;
532
svn_wc_diff6(svn_wc_context_t *wc_ctx,
533
const char *local_abspath,
534
const svn_wc_diff_callbacks4_t *callbacks,
535
void *callback_baton,
537
svn_boolean_t ignore_ancestry,
538
svn_boolean_t show_copies_as_adds,
539
svn_boolean_t use_git_diff_format,
540
const apr_array_header_t *changelist_filter,
541
svn_cancel_func_t cancel_func,
543
apr_pool_t *scratch_pool)
545
const svn_diff_tree_processor_t *processor;
547
SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
548
callbacks, callback_baton, TRUE,
549
scratch_pool, scratch_pool));
551
if (use_git_diff_format)
552
show_copies_as_adds = TRUE;
553
if (show_copies_as_adds)
554
ignore_ancestry = FALSE;
556
if (! show_copies_as_adds && !use_git_diff_format)
557
processor = svn_diff__tree_processor_copy_as_changed_create(processor,
560
return svn_error_trace(svn_wc__diff7(NULL, NULL,
561
wc_ctx, local_abspath,
566
cancel_func, cancel_baton,
567
scratch_pool, scratch_pool));