8 my $svn_repo_path = "/tmp/svn/samba.repo";
9 my $authors_file = "svn-authors";
11 my $svn_branch = "branches/SAMBA_4_0";
12 my $svn_start_rev = 25600;
13 my $basepath = "/tmp/svn/v4-0-test";
15 my $patch_path = "$basepath/patches";
16 my $last_svn_rev_file = "$patch_path/latest.svnrev";
17 my $git_repo_path = "$basepath/git";
19 $ENV{LANG} = "en_US.UTF-8";
21 my $r = SVN2GitPatch->new($svn_repo_path, $authors_file);
23 sub get_last_svn_rev($;$)
25 my ($file, $default_rev) = @_;
27 $default_rev = 25600 if defined($default_rev);
29 my $v = util::FileLoad($file);
31 $v = $default_rev if $v eq "";
33 $v = $default_rev if $v == 0;
35 print "get_last_svn_rev: $v\n";
39 sub set_last_svn_rev($$)
41 my ($file, $rev) = @_;
42 util::FileSave($file, $rev);
43 print "set_last_svn_rev: $rev\n";
46 my $last_rev = $r->get_last_svn_rev($svn_branch);
47 my $start_rev = get_last_svn_rev($last_svn_rev_file, $svn_start_rev);
48 my @revs = $r->get_missing_svn_revs($svn_branch, $start_rev);
50 print "start: $start_rev last: $last_rev\n";
52 foreach my $rev (@revs) {
54 print "Get patch for rev: $rev\n";
55 my $p = $r->get_git_patch($svn_branch, $rev);
57 next unless defined($p->{git_patch});
59 my $patch_path = "$patch_path/$rev.patch";
60 open(PATCH, ">$patch_path") or die ("failed to $patch_path for write");
61 print PATCH $p->{git_patch}."\n";
64 my $applycmd = "cd $git_repo_path && git am --whitespace=nowarn --binary $patch_path";
66 my $apply = `$applycmd` or die "$applycmd: failed";
68 set_last_svn_rev($last_svn_rev_file, $rev);