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

« back to all changes in this revision

Viewing changes to tools/dev/svnraisetreeconflict/svnraisetreeconflict.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:
49
49
 
50
50
#define OPT_VERSION SVN_OPT_FIRST_LONGOPT_ID
51
51
 
52
 
/** A statement macro, similar to @c SVN_INT_ERR, but issues a
53
 
 * message saying "svnraisetreeconflict:" instead of "svn:".
54
 
 *
55
 
 * Evaluate @a expr. If it yields an error, handle that error and
56
 
 * return @c EXIT_FAILURE.
57
 
 */
58
 
#define SVNRAISETC_INT_ERR(expr)                                 \
59
 
  do {                                                           \
60
 
    svn_error_t *svn_err__temp = (expr);                         \
61
 
    if (svn_err__temp) {                                         \
62
 
      svn_handle_error2(svn_err__temp, stderr, FALSE,            \
63
 
                        "svnraisetreeconflict: ");               \
64
 
      svn_error_clear(svn_err__temp);                            \
65
 
      return EXIT_FAILURE; }                                     \
66
 
  } while (0)
67
 
 
68
52
static svn_error_t *
69
53
version(apr_pool_t *pool)
70
54
{
78
62
  svn_error_clear(svn_cmdline_fprintf
79
63
                  (stderr, pool,
80
64
                   _("Type 'svnraisetreeconflict --help' for usage.\n")));
81
 
  exit(1);
82
65
}
83
66
 
84
67
/***************************************************************************
224
207
  right = svn_wc_conflict_version_create2(repos_url2, NULL, path_in_repos2,
225
208
                                          peg_rev2, kind2, pool);
226
209
  c = svn_wc_conflict_description_create_tree2(wc_abspath, kind,
227
 
                                              operation, left, right, pool);
 
210
                                               operation, left, right, pool);
228
211
  c->action = (svn_wc_conflict_action_t)action;
229
212
  c->reason = (svn_wc_conflict_reason_t)reason;
230
213
 
295
278
      get_enum_str(node_kind_map, svn_node_file),
296
279
      get_enum_str(node_kind_map, svn_node_none)
297
280
      ));
298
 
  exit(0);
299
281
}
300
282
 
301
283
 
311
293
    };
312
294
  SVN_VERSION_DEFINE(my_version);
313
295
 
314
 
  return svn_ver_check_list(&my_version, checklist);
 
296
  return svn_ver_check_list2(&my_version, checklist, svn_ver_equal);
315
297
}
316
298
 
317
 
int
318
 
main(int argc, const char *argv[])
 
299
/*
 
300
 * On success, leave *EXIT_CODE untouched and return SVN_NO_ERROR. On error,
 
301
 * either return an error to be displayed, or set *EXIT_CODE to non-zero and
 
302
 * return SVN_NO_ERROR.
 
303
 */
 
304
static svn_error_t *
 
305
sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
319
306
{
320
 
  apr_pool_t *pool;
321
 
  svn_error_t *err;
322
307
  apr_getopt_t *os;
323
308
  const apr_getopt_option_t options[] =
324
309
    {
329
314
    };
330
315
  apr_array_header_t *remaining_argv;
331
316
 
332
 
  /* Initialize the app. */
333
 
  if (svn_cmdline_init("svnraisetreeconflict", stderr) != EXIT_SUCCESS)
334
 
    return EXIT_FAILURE;
335
 
 
336
 
  /* Create our top-level pool.  Use a separate mutexless allocator,
337
 
   * given this application is single threaded.
338
 
   */
339
 
  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
340
 
 
341
317
  /* Check library versions */
342
 
  err = check_lib_versions();
343
 
  if (err)
344
 
    return svn_cmdline_handle_exit_error(err, pool, "svnraisetreeconflict: ");
 
318
  SVN_ERR(check_lib_versions());
345
319
 
346
320
#if defined(WIN32) || defined(__CYGWIN__)
347
321
  /* Set the working copy administrative directory name. */
348
322
  if (getenv("SVN_ASP_DOT_NET_HACK"))
349
323
    {
350
 
      err = svn_wc_set_adm_dir("_svn", pool);
351
 
      if (err)
352
 
        return svn_cmdline_handle_exit_error(err, pool, "svnraisetreeconflict: ");
 
324
      SVN_ERR(svn_wc_set_adm_dir("_svn", pool));
353
325
    }
354
326
#endif
355
327
 
356
 
  err = svn_cmdline__getopt_init(&os, argc, argv, pool);
357
 
  if (err)
358
 
    return svn_cmdline_handle_exit_error(err, pool, "svnraisetreeconflict: ");
 
328
  SVN_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
359
329
 
360
330
  os->interleave = 1;
361
331
  while (1)
366
336
      if (APR_STATUS_IS_EOF(status))
367
337
        break;
368
338
      if (status != APR_SUCCESS)
369
 
        usage(pool);  /* this will exit() */
 
339
        {
 
340
          usage(pool);
 
341
          *exit_code = EXIT_FAILURE;
 
342
          return SVN_NO_ERROR;
 
343
        }
370
344
 
371
345
      switch (opt)
372
346
        {
373
347
        case 'h':
374
348
          help(options, pool);
375
 
          break;
 
349
          return SVN_NO_ERROR;
376
350
        case OPT_VERSION:
377
 
          SVNRAISETC_INT_ERR(version(pool));
378
 
          exit(0);
379
 
          break;
 
351
          SVN_ERR(version(pool));
 
352
          return SVN_NO_ERROR;
380
353
        default:
381
 
          usage(pool);  /* this will exit() */
 
354
          usage(pool);
 
355
          *exit_code = EXIT_FAILURE;
 
356
          return SVN_NO_ERROR;
382
357
        }
383
358
    }
384
359
 
388
363
    {
389
364
      const char *s;
390
365
 
391
 
      SVNRAISETC_INT_ERR(svn_utf_cstring_to_utf8(&s, os->argv[os->ind++],
392
 
                                                 pool));
 
366
      SVN_ERR(svn_utf_cstring_to_utf8(&s, os->argv[os->ind++], pool));
393
367
      APR_ARRAY_PUSH(remaining_argv, const char *) = s;
394
368
    }
395
369
 
396
370
  if (remaining_argv->nelts < 1)
397
 
    usage(pool);  /* this will exit() */
 
371
    {
 
372
      usage(pool);
 
373
      *exit_code = EXIT_FAILURE;
 
374
      return SVN_NO_ERROR;
 
375
    }
398
376
 
399
377
  /* Do the main task */
400
 
  SVNRAISETC_INT_ERR(raise_tree_conflict(remaining_argv->nelts,
401
 
                                         (const char **)remaining_argv->elts,
402
 
                                         pool));
 
378
  SVN_ERR(raise_tree_conflict(remaining_argv->nelts,
 
379
                              (const char **)remaining_argv->elts,
 
380
                              pool));
 
381
 
 
382
  return SVN_NO_ERROR;
 
383
}
 
384
 
 
385
int
 
386
main(int argc, const char *argv[])
 
387
{
 
388
  apr_pool_t *pool;
 
389
  int exit_code = EXIT_SUCCESS;
 
390
  svn_error_t *err;
 
391
 
 
392
  /* Initialize the app. */
 
393
  if (svn_cmdline_init("svnraisetreeconflict", stderr) != EXIT_SUCCESS)
 
394
    return EXIT_FAILURE;
 
395
 
 
396
  /* Create our top-level pool.  Use a separate mutexless allocator,
 
397
   * given this application is single threaded.
 
398
   */
 
399
  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
400
 
 
401
  err = sub_main(&exit_code, argc, argv, pool);
 
402
 
 
403
  /* Flush stdout and report if it fails. It would be flushed on exit anyway
 
404
     but this makes sure that output is not silently lost if it fails. */
 
405
  err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
 
406
 
 
407
  if (err)
 
408
    {
 
409
      exit_code = EXIT_FAILURE;
 
410
      svn_cmdline_handle_exit_error(err, NULL, "svnraisetreeconflict: ");
 
411
    }
403
412
 
404
413
  svn_pool_destroy(pool);
405
 
 
406
 
  /* Flush stdout to make sure that the user will see any printing errors. */
407
 
  SVNRAISETC_INT_ERR(svn_cmdline_fflush(stdout));
408
 
 
409
 
  return EXIT_SUCCESS;
 
414
  return exit_code;
410
415
}