8 my $svn_repo_path = "/tmp/svn/samba.repo";
9 my $authors_file = "svn-authors";
11 my $svn_branch = "tags/release-4-0-0alpha2";
12 my $svn_start_rev = 26362;
13 my $basepath = "/tmp/svn/release-4-0-0alpha2";
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 load_last_svn_rev($;$)
25 my ($file, $default_rev) = @_;
27 $default_rev = 0 unless 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 "load_last_svn_rev: $v\n";
39 sub save_last_svn_rev($$)
41 my ($file, $rev) = @_;
42 util::FileSave($file, $rev);
43 print "save_last_svn_rev: $rev\n";
46 my $last_rev = $r->get_last_svn_rev($svn_branch);
47 my $start_rev = load_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 (sort keys %{$revs}) {
53 print "Get patch for rev: $rev\n";
54 my $p = $r->get_git_patch($revs->{$rev}->{branch}, $rev);
56 if (defined($p->{git_patch})) {
57 my $patch_path = "$patch_path/$rev.patch";
58 open(PATCH, ">$patch_path") or
59 die ("failed to $patch_path for write");
60 print PATCH $p->{git_patch}."\n";
63 my $applycmd = "cd $git_repo_path && git am --whitespace=nowarn --binary $patch_path";
65 print "Apply $rev.patch\n";
66 my $apply = `$applycmd` or die "$applycmd: failed";
69 save_last_svn_rev($last_svn_rev_file, $rev);