This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (58 loc) · 1.8 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright Dave Abrahams 2013. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "svn_failure.hpp"
#include "svn_branch_analyzer.hpp"
#include <exception>
#include <iostream>
#include <svn_pools.h>
#include <svn_io.h>
#include <svn_fs.h>
namespace ryppl {
// Adapted from subversion/svndumpfilter/main.c
static svn_stream_t*
create_stdio_stream(
APR_DECLARE(apr_status_t) open_fn(apr_file_t **, apr_pool_t *),
apr_pool_t *pool)
{
apr_file_t *stdio_file;
apr_status_t apr_err = open_fn(&stdio_file, pool);
if (apr_err)
check_svn_failure(svn_error_wrap_apr(apr_err, "Can't open stdio file"));
return svn_stream_from_aprfile2(stdio_file, TRUE, pool);
}
}
int main()
{
// Create our top-level pool.
apr_initialize();
apr_allocator_t *allocator;
if (apr_allocator_create(&allocator))
return EXIT_FAILURE;
apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
apr_pool_t *pool;
pool = svn_pool_create_ex(NULL, allocator);
apr_allocator_owner_set(allocator, pool);
int exit_code = EXIT_FAILURE;
try
{
ryppl::check_svn_failure(svn_fs_initialize(pool));
ryppl::svn_branch_analyzer parse(pool);
parse(ryppl::create_stdio_stream(apr_file_open_stdin, pool));
exit_code = EXIT_SUCCESS;
}
catch(ryppl::svn_failure const& x)
{
std::cerr << "Failed with svn error: " << x.what() << std::endl;
}
catch(std::exception const& x)
{
std::cerr << "Failed with std::exception: " << x.what() << std::endl;
}
catch(...)
{
std::cerr << "Failed with unknown exception" << std::endl;
}
svn_pool_destroy(pool);
return exit_code;
}