~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_wc/diff_local.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
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.
4
4
 *
5
5
 * ====================================================================
6
6
 *    Licensed to the Apache Software Foundation (ASF) under one
41
41
#include "private/svn_diff_tree.h"
42
42
 
43
43
#include "wc.h"
 
44
#include "wc_db.h"
44
45
#include "props.h"
45
 
#include "translate.h"
46
46
#include "diff.h"
47
47
 
48
48
#include "svn_private_config.h"
89
89
  /* Should this diff ignore node ancestry? */
90
90
  svn_boolean_t ignore_ancestry;
91
91
 
92
 
  /* Should this diff not compare copied files with their source? */
93
 
  svn_boolean_t show_copies_as_adds;
94
 
 
95
92
  /* Cancel function/baton */
96
93
  svn_cancel_func_t cancel_func;
97
94
  void *cancel_baton;
119
116
      if (! relpath)
120
117
        return SVN_NO_ERROR;
121
118
 
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) */
125
122
      if (*relpath)
126
123
        SVN_ERR(ensure_state(eb,
127
 
                             svn_dirent_dirname(local_abspath,scratch_pool),
 
124
                             svn_dirent_dirname(local_abspath, scratch_pool),
128
125
                             FALSE,
129
126
                             scratch_pool));
130
127
    }
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),
133
130
                         FALSE,
134
131
                         scratch_pool));
135
132
  else
421
418
 
422
419
/* Public Interface */
423
420
svn_error_t *
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,
428
 
             svn_depth_t depth,
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,
434
 
             void *cancel_baton,
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,
 
425
              svn_depth_t depth,
 
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,
 
430
              void *cancel_baton,
 
431
              apr_pool_t *result_pool,
 
432
              apr_pool_t *scratch_pool)
436
433
{
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;
441
437
 
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 */,
447
443
                               scratch_pool));
448
444
 
449
 
  if (kind == svn_node_dir)
450
 
    eb.anchor_abspath = local_abspath;
451
 
  else
 
445
  eb.anchor_abspath = local_abspath;
 
446
 
 
447
  if (root_relpath)
 
448
    {
 
449
      svn_boolean_t is_wcroot;
 
450
 
 
451
      SVN_ERR(svn_wc__db_is_wcroot(&is_wcroot,
 
452
                                   wc_ctx->db, local_abspath, scratch_pool));
 
453
 
 
454
      if (!is_wcroot)
 
455
        eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
 
456
    }
 
457
  else if (kind != svn_node_dir)
452
458
    eb.anchor_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
453
459
 
454
 
  SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
455
 
                                      callbacks, callback_baton, TRUE,
456
 
                                      scratch_pool, scratch_pool));
457
 
 
458
 
  if (use_git_diff_format)
459
 
    show_copies_as_adds = TRUE;
460
 
  if (show_copies_as_adds)
461
 
    ignore_ancestry = FALSE;
462
 
 
463
 
 
464
 
 
465
 
  /*
466
 
  if (reverse_order)
467
 
    processor = svn_diff__tree_processor_reverse_create(processor, NULL, pool);
468
 
   */
469
 
 
470
 
  if (! show_copies_as_adds && !use_git_diff_format)
471
 
    processor = svn_diff__tree_processor_copy_as_changed_create(processor,
472
 
                                                                scratch_pool);
 
460
  if (root_relpath)
 
461
    *root_relpath = apr_pstrdup(result_pool,
 
462
                                svn_dirent_skip_ancestor(eb.anchor_abspath,
 
463
                                                         local_abspath));
 
464
  if (root_is_dir)
 
465
    *root_is_dir = (kind == svn_node_dir);
473
466
 
474
467
  /* Apply changelist filtering to the output */
475
468
  if (changelist_filter && changelist_filter->nelts)
477
470
      apr_hash_t *changelist_hash;
478
471
 
479
472
      SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
480
 
                                         scratch_pool));
481
 
      processor = svn_wc__changelist_filter_tree_processor_create(
482
 
                    processor, wc_ctx, local_abspath,
483
 
                    changelist_hash, scratch_pool);
 
473
                                         result_pool));
 
474
      diff_processor = svn_wc__changelist_filter_tree_processor_create(
 
475
                         diff_processor, wc_ctx, local_abspath,
 
476
                         changelist_hash, result_pool);
484
477
    }
485
478
 
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;
491
483
 
492
 
  if (show_copies_as_adds || use_git_diff_format || !ignore_ancestry)
 
484
  if (ignore_ancestry)
493
485
    get_all = TRUE; /* We need unmodified descendants of copies */
494
486
  else
495
487
    get_all = FALSE;
512
504
      if (!ns->skip)
513
505
        {
514
506
          if (ns->propchanges)
515
 
            SVN_ERR(processor->dir_changed(ns->relpath,
516
 
                                           ns->left_src,
517
 
                                           ns->right_src,
518
 
                                           ns->left_props,
519
 
                                           ns->right_props,
520
 
                                           ns->propchanges,
521
 
                                           ns->baton,
522
 
                                           processor,
523
 
                                           ns->pool));
 
507
            SVN_ERR(diff_processor->dir_changed(ns->relpath,
 
508
                                                ns->left_src,
 
509
                                                ns->right_src,
 
510
                                                ns->left_props,
 
511
                                                ns->right_props,
 
512
                                                ns->propchanges,
 
513
                                                ns->baton,
 
514
                                                diff_processor,
 
515
                                                ns->pool));
524
516
          else
525
 
            SVN_ERR(processor->dir_closed(ns->relpath,
526
 
                                          ns->left_src,
527
 
                                          ns->right_src,
528
 
                                          ns->baton,
529
 
                                          processor,
530
 
                                          ns->pool));
 
517
            SVN_ERR(diff_processor->dir_closed(ns->relpath,
 
518
                                               ns->left_src,
 
519
                                               ns->right_src,
 
520
                                               ns->baton,
 
521
                                               diff_processor,
 
522
                                               ns->pool));
531
523
        }
532
524
      eb.cur = ns->parent;
533
525
      svn_pool_clear(ns->pool);
535
527
 
536
528
  return SVN_NO_ERROR;
537
529
}
 
530
 
 
531
svn_error_t *
 
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,
 
536
             svn_depth_t depth,
 
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,
 
542
             void *cancel_baton,
 
543
             apr_pool_t *scratch_pool)
 
544
{
 
545
  const svn_diff_tree_processor_t *processor;
 
546
 
 
547
  SVN_ERR(svn_wc__wrap_diff_callbacks(&processor,
 
548
                                      callbacks, callback_baton, TRUE,
 
549
                                      scratch_pool, scratch_pool));
 
550
 
 
551
  if (use_git_diff_format)
 
552
    show_copies_as_adds = TRUE;
 
553
  if (show_copies_as_adds)
 
554
    ignore_ancestry = FALSE;
 
555
 
 
556
  if (! show_copies_as_adds && !use_git_diff_format)
 
557
    processor = svn_diff__tree_processor_copy_as_changed_create(processor,
 
558
                                                                scratch_pool);
 
559
 
 
560
  return svn_error_trace(svn_wc__diff7(NULL, NULL,
 
561
                                       wc_ctx, local_abspath,
 
562
                                       depth,
 
563
                                       ignore_ancestry,
 
564
                                       changelist_filter,
 
565
                                       processor,
 
566
                                       cancel_func, cancel_baton,
 
567
                                       scratch_pool, scratch_pool));
 
568
}
 
569