Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (45 sloc) 1.287 kB
21746aa @barrbrain SVN dump parser
barrbrain authored
1 /*
2 * test-svn-fe: Code to exercise the svn import lib
3 */
4
5 #include "git-compat-util.h"
6 #include "vcs-svn/svndump.h"
ddcc8c5 @jrn vcs-svn: skeleton of an svn delta parser
jrn authored
7 #include "vcs-svn/svndiff.h"
8 #include "vcs-svn/sliding_window.h"
9 #include "vcs-svn/line_buffer.h"
21746aa @barrbrain SVN dump parser
barrbrain authored
10
b747e56 @jrn test-svn-fe: split off "test-svn-fe -d" into a separate function
jrn authored
11 static const char test_svnfe_usage[] =
12 "test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)";
13
14 static int apply_delta(int argc, char *argv[])
15 {
16 struct line_buffer preimage = LINE_BUFFER_INIT;
17 struct line_buffer delta = LINE_BUFFER_INIT;
fbdd4f6 @jrn vcs-svn: cap number of bytes read from sliding view
jrn authored
18 struct sliding_view preimage_view = SLIDING_VIEW_INIT(&preimage, -1);
b747e56 @jrn test-svn-fe: split off "test-svn-fe -d" into a separate function
jrn authored
19
20 if (argc != 5)
21 usage(test_svnfe_usage);
22
23 if (buffer_init(&preimage, argv[2]))
24 die_errno("cannot open preimage");
25 if (buffer_init(&delta, argv[3]))
26 die_errno("cannot open delta");
27 if (svndiff0_apply(&delta, (off_t) strtoull(argv[4], NULL, 0),
28 &preimage_view, stdout))
29 return 1;
30 if (buffer_deinit(&preimage))
31 die_errno("cannot close preimage");
32 if (buffer_deinit(&delta))
33 die_errno("cannot close delta");
34 strbuf_release(&preimage_view.buf);
35 return 0;
36 }
37
21746aa @barrbrain SVN dump parser
barrbrain authored
38 int main(int argc, char *argv[])
39 {
ddcc8c5 @jrn vcs-svn: skeleton of an svn delta parser
jrn authored
40 if (argc == 2) {
41 if (svndump_init(argv[1]))
42 return 1;
43 svndump_read(NULL);
44 svndump_deinit();
45 svndump_reset();
46 return 0;
47 }
b747e56 @jrn test-svn-fe: split off "test-svn-fe -d" into a separate function
jrn authored
48
49 if (argc >= 2 && !strcmp(argv[1], "-d"))
50 return apply_delta(argc, argv);
ddcc8c5 @jrn vcs-svn: skeleton of an svn delta parser
jrn authored
51 usage(test_svnfe_usage);
21746aa @barrbrain SVN dump parser
barrbrain authored
52 }
Something went wrong with that request. Please try again.