vcs-svn: implement text-delta handling
[git/mingw.git] / test-svn-fe.c
blob66bd04022dab32e894c5e6ca18702b69ad0a0ed0
1 /*
2 * test-svn-fe: Code to exercise the svn import lib
3 */
5 #include "git-compat-util.h"
6 #include "vcs-svn/svndump.h"
7 #include "vcs-svn/svndiff.h"
8 #include "vcs-svn/sliding_window.h"
9 #include "vcs-svn/line_buffer.h"
11 int main(int argc, char *argv[])
13 static const char test_svnfe_usage[] =
14 "test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)";
15 if (argc == 2) {
16 if (svndump_init(argv[1]))
17 return 1;
18 svndump_read(NULL);
19 svndump_deinit();
20 svndump_reset();
21 return 0;
23 if (argc == 5 && !strcmp(argv[1], "-d")) {
24 struct line_buffer preimage = LINE_BUFFER_INIT;
25 struct line_buffer delta = LINE_BUFFER_INIT;
26 struct sliding_view preimage_view = SLIDING_VIEW_INIT(&preimage);
27 if (buffer_init(&preimage, argv[2]))
28 die_errno("cannot open preimage");
29 if (buffer_init(&delta, argv[3]))
30 die_errno("cannot open delta");
31 if (svndiff0_apply(&delta, (off_t) strtoull(argv[4], NULL, 0),
32 &preimage_view, stdout))
33 return 1;
34 if (buffer_deinit(&preimage))
35 die_errno("cannot close preimage");
36 if (buffer_deinit(&delta))
37 die_errno("cannot close delta");
38 buffer_reset(&preimage);
39 strbuf_release(&preimage_view.buf);
40 buffer_reset(&delta);
41 return 0;
43 usage(test_svnfe_usage);