10 my $pool = SVN
::Pool
->new_default;
12 my $mirror = '/path/to/mirror';
14 my $repos = SVN
::Repos
::open($mirror);
15 my $fs = $repos->fs();
17 my $uuid = $fs->revision_prop(0, 'svn:sync-from-uuid');
18 my $url = $fs->revision_prop(0, 'svn:sync-from-url');
19 my $maxrev = int($fs->revision_prop(0, 'svn:sync-last-merged-rev'));
21 print "# SVN_UUID: $uuid\n";
22 print "# SVN_URL: $url\n";
23 print "# MAX_REV: $maxrev\n";
29 $repos->get_logs([''], 1, $maxrev, 1, 0, sub {
30 my ($paths, $rev, $author, $date, $log, $pool) = @_;
31 my $pool = SVN
::Pool
->new_default_sub;
33 print "# SVN_AUTHOR: $author\n";
34 print "# SVN_DATE: $date\n";
36 my $GIT_COMMITTER_NAME=$author;
37 my $GIT_COMMITTER_EMAIL=$author.'@'.$uuid;
38 my $GIT_COMMITTER_DATE=int(str2time
($date)).' +0000';
40 my @commitlogfile = File
::Temp
->new();
41 $commitlog = $commitlogfile[FH
];
43 print $commitlog "commit refs/heads/master\n";
44 print $commitlog "committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n";
45 print $commitlog 'data '.length($log)."\n$log\n";
47 my $root = $fs->revision_root($rev, $pool);
49 for my $file (keys %$paths) {
50 my $node = $paths->{$file};
51 my $action = $node->action;
54 my $path = substr($file, 1);
55 print $commitlog "D $path\n";
59 if ($root->is_dir($file, $pool) ) {
60 my $path = substr($file, 1);
61 print $commitlog "D $path\n";
62 modifydir
($root, $file, $pool);
64 modifyfile
($root, $file, $pool);
68 seek $commitlog, 0, 0;
70 while (<$commitlog>) {
75 print "progress to revision $rev\n"
79 my ($root, $dir, $pool) = @_;
80 my $pool = SVN
::Pool
->new_default_sub;
82 my $dirents = $root->dir_entries($dir, $pool);
83 for my $name (keys %$dirents) {
84 my $entry = $dirents->{$name};
85 if ($entry->kind == $SVN::Node
::dir
) {
86 modifydir
($root, $dir.'/'.$name, $pool);
88 modifyfile
($root, $dir.'/'.$name, $pool);
94 my ($root, $file, $pool) = @_;
95 my $pool = SVN
::Pool
->new_default_sub;
97 my $proplist = $root->node_proplist($file, $pool);
98 my $md5 = $root->file_md5_checksum($file, $pool);
99 # Strip the leading slash from the path for git
100 my $path = substr($file, 1);
104 if (defined $proplist->{'svn:special'}) {
108 $mode = defined $proplist->{'svn:executable'} ?
'100755' : '100644';
111 my $mark = $marks->{$md5};
112 if (!defined $mark) {
114 $marks->{$md5} = $mark;
115 my $length = $root->file_length($file, $pool);
116 $length -= 5 if $mode == '120000';
117 my $contents = $root->file_contents($file, $pool);
118 print "# MD5: $md5\n";
119 print "blob\nmark :$mark\n";
120 print "data $length\n";
123 read $contents, $linkprefix, 5 if $mode == '120000';
124 while (<$contents>) {
130 print $commitlog "M $mode :$mark $path\n";