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

« back to all changes in this revision

Viewing changes to tools/diff/diff3.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:
28
28
#include "svn_pools.h"
29
29
#include "svn_diff.h"
30
30
#include "svn_io.h"
 
31
#include "svn_opt.h"
 
32
#include "private/svn_token.h"
31
33
 
32
34
 
33
35
static svn_error_t *
34
36
do_diff3(svn_stream_t *ostream,
35
 
         const char *original, const char *modified, const char *latest,
 
37
         const char *original,
 
38
         const char *modified,
 
39
         const char *latest,
 
40
         const char *conflict_original,
 
41
         const char *conflict_modified,
 
42
         const char *conflict_latest,
 
43
         svn_diff_conflict_display_style_t conflict_style,
36
44
         svn_boolean_t *has_changes,
37
45
         apr_pool_t *pool)
38
46
{
43
51
 
44
52
  *has_changes = svn_diff_contains_diffs(diff);
45
53
 
46
 
  SVN_ERR(svn_diff_file_output_merge2(ostream, diff,
 
54
  SVN_ERR(svn_diff_file_output_merge3(ostream, diff,
47
55
                                      original, modified, latest,
48
 
                                      NULL, NULL, NULL, NULL,
49
 
                                      svn_diff_conflict_display_modified_latest,
 
56
                                      conflict_original,
 
57
                                      conflict_modified,
 
58
                                      conflict_latest,
 
59
                                      "=======",
 
60
                                      conflict_style,
 
61
                                      NULL, NULL, /* cancel */
50
62
                                      pool));
51
63
 
52
64
  return NULL;
53
65
}
54
66
 
55
 
int main(int argc, char *argv[])
 
67
int main(int argc, const char *argv[])
56
68
{
57
69
  apr_pool_t *pool;
58
70
  svn_stream_t *ostream;
59
71
  int rc;
60
 
  svn_error_t *svn_err;
 
72
  svn_error_t *svn_err = SVN_NO_ERROR;
 
73
  apr_getopt_t *opts;
 
74
  svn_boolean_t help = FALSE;
 
75
 
 
76
  enum {
 
77
    conflict_style_opt = SVN_OPT_FIRST_LONGOPT_ID
 
78
  };
 
79
  static const apr_getopt_option_t options[] = {
 
80
    {"conflict-style", conflict_style_opt, 1, ""},
 
81
    {"label", 'L', 1, ""},
 
82
    {"show-overlap", 'E', 0, ""},
 
83
    {"merge", 'm', 0, ""},
 
84
    {"help", 'h', 0, ""},
 
85
    {NULL, '?', 0, ""},
 
86
    {NULL, 0, 0, NULL}
 
87
  };
 
88
  svn_diff_conflict_display_style_t conflict_style
 
89
    = svn_diff_conflict_display_modified_latest;
 
90
  const svn_token_map_t style_map[] = {
 
91
    { "modified-latest",
 
92
      svn_diff_conflict_display_modified_latest },
 
93
    { "resolved-modified-latest",
 
94
      svn_diff_conflict_display_resolved_modified_latest },
 
95
    { "modified-original-latest",
 
96
      svn_diff_conflict_display_modified_original_latest },
 
97
    { "modified",
 
98
      svn_diff_conflict_display_modified },
 
99
    { "latest",
 
100
      svn_diff_conflict_display_latest },
 
101
    { "only-conflicts",
 
102
      svn_diff_conflict_display_only_conflicts },
 
103
    {NULL, 0}
 
104
  };
 
105
  const char *conflict_original = NULL;
 
106
  const char *conflict_modified = NULL;
 
107
  const char *conflict_latest = NULL;
61
108
 
62
109
  apr_initialize();
63
110
 
64
111
  pool = svn_pool_create(NULL);
65
112
 
66
 
  svn_err = svn_stream_for_stdout(&ostream, pool);
 
113
  apr_getopt_init(&opts, pool, argc, argv);
 
114
  opts->interleave = 1;
 
115
  while (!svn_err)
 
116
    {
 
117
      int opt;
 
118
      const char *arg;
 
119
      apr_status_t status = apr_getopt_long(opts, options, &opt, &arg);
 
120
 
 
121
      if (APR_STATUS_IS_EOF(status))
 
122
        break;
 
123
      if (status != APR_SUCCESS)
 
124
        {
 
125
          svn_err = svn_error_wrap_apr(status, "getopt failure");
 
126
          break;
 
127
        }
 
128
      switch (opt)
 
129
        {
 
130
        case conflict_style_opt:
 
131
          {
 
132
            int val;
 
133
            svn_err = svn_token__from_word_err(&val, style_map, arg);
 
134
            conflict_style = val;
 
135
            break;
 
136
          }
 
137
        case 'L':
 
138
          if (!conflict_modified)
 
139
            conflict_modified = apr_pstrcat(pool, "<<<<<<< ", arg, SVN_VA_NULL);
 
140
          else if (!conflict_original)
 
141
            conflict_original = apr_pstrcat(pool, "||||||| ", arg, SVN_VA_NULL);
 
142
          else if (!conflict_latest)
 
143
            conflict_latest = apr_pstrcat(pool, ">>>>>>> ", arg, SVN_VA_NULL);
 
144
          else
 
145
            svn_err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
 
146
                                       "too many labels");
 
147
          break;
 
148
        case 'E':
 
149
        case 'm':
 
150
          /* These are allowed and ignored so that all the options
 
151
             passed when invoking --diff3-cmd are accepted as that
 
152
             makes it easier to use this as an external diff3
 
153
             program. */
 
154
          break;
 
155
        case 'h':
 
156
        case '?':
 
157
          help = TRUE;
 
158
          break;
 
159
        }
 
160
    }
 
161
 
 
162
  if (!svn_err)
 
163
    svn_err = svn_stream_for_stdout(&ostream, pool);
67
164
  if (svn_err)
68
165
    {
69
166
      svn_handle_error2(svn_err, stdout, FALSE, "diff3: ");
 
167
      svn_error_clear(svn_err);
70
168
      rc = 2;
71
169
    }
72
 
  else if (argc == 4)
 
170
  else if (argc - opts->ind == 3 && !help)
73
171
    {
74
172
      svn_boolean_t has_changes;
75
173
 
76
 
      svn_err = do_diff3(ostream, argv[2], argv[1], argv[3],
77
 
                         &has_changes, pool);
 
174
      svn_err = do_diff3(ostream, argv[argc-2], argv[argc-3], argv[argc-1],
 
175
                         conflict_original, conflict_modified, conflict_latest,
 
176
                         conflict_style, &has_changes, pool);
78
177
      if (svn_err == NULL)
79
178
        {
80
179
          rc = has_changes ? 1 : 0;
88
187
  else
89
188
    {
90
189
      svn_error_clear(svn_stream_printf(ostream, pool,
91
 
                                        "Usage: %s <mine> <older> <yours>\n",
92
 
                                        argv[0]));
 
190
        "Usage: %s [options] <mine> <older> <yours>\n"
 
191
        "Options:\n"
 
192
        "  --conflict-style STYLE\n"
 
193
        "    where STYLE can be:\n"
 
194
        "      %s\n"
 
195
        "      %s\n"
 
196
        "      %s\n"
 
197
        "      %s\n"
 
198
        "      %s\n"
 
199
        "      %s\n"
 
200
        "\n"
 
201
        "  --label [-L] LABEL\n"
 
202
        "    can be repeated up to three times\n"
 
203
        "\n"
 
204
        "  --merge [-m]\n"
 
205
        "    ignored (present for compatibility)\n"
 
206
        "\n"
 
207
        "  --show-overlap [-E]\n"
 
208
        "    ignored (present for compatibility)\n",
 
209
        argv[0],
 
210
        svn_token__to_word(style_map,
 
211
                           svn_diff_conflict_display_modified_latest),
 
212
        svn_token__to_word(style_map,
 
213
                           svn_diff_conflict_display_resolved_modified_latest),
 
214
        svn_token__to_word(style_map,
 
215
                           svn_diff_conflict_display_modified_original_latest),
 
216
        svn_token__to_word(style_map,
 
217
                           svn_diff_conflict_display_modified),
 
218
        svn_token__to_word(style_map,
 
219
                           svn_diff_conflict_display_latest),
 
220
        svn_token__to_word(style_map,
 
221
                           svn_diff_conflict_display_only_conflicts)));
93
222
      rc = 2;
94
223
    }
95
224