8 my $svn_repo_path = "/tmp/svn/samba.repo";
9 $svn_repo_path = "/home/svn/samba";
10 my $authors_file = "svn-authors";
12 my $svn_branch = "branches/SAMBA_4_0";
13 my $svn_start_rev = 25600;
14 $svn_start_rev = 26554;
15 my $basepath = "/tmp/svn/v4-0-test";
16 $basepath = "/data/git/metze/samba4-sync/samba4-draft";
18 my $patch_path = "$basepath/patches";
19 my $last_svn_rev_file = "$patch_path/latest.svnrev";
20 my $git_repo_path = "$basepath/git";
22 $ENV{LANG} = "en_US.UTF-8";
24 my $r = SVN2GitPatch->new($svn_repo_path, $authors_file);
26 sub load_last_svn_rev($;$)
28 my ($file, $default_rev) = @_;
30 $default_rev = 0 unless defined($default_rev);
32 my $v = util::FileLoad($file);
34 $v = $default_rev if $v eq "";
36 $v = $default_rev if $v == 0;
38 print "load_last_svn_rev: $v\n";
42 sub save_last_svn_rev($$)
44 my ($file, $rev) = @_;
45 util::FileSave($file, $rev);
46 print "save_last_svn_rev: $rev\n";
49 my $last_rev = $r->get_last_svn_rev($svn_branch);
50 my $start_rev = load_last_svn_rev($last_svn_rev_file, $svn_start_rev);
51 my $revs = $r->get_missing_svn_revs($svn_branch, $start_rev);
53 print "start: $start_rev last: $last_rev\n";
55 foreach my $rev (sort keys %{$revs}) {
56 print "Get patch for rev: $rev\n";
57 my $p = $r->get_git_patch($revs->{$rev}->{branch}, $rev);
59 if (defined($p->{git_patch})) {
60 my $patch_path = "$patch_path/$rev.patch";
61 open(PATCH, ">$patch_path") or
62 die ("failed to $patch_path for write");
63 print PATCH $p->{git_patch}."\n";
66 my $applycmd = "cd $git_repo_path && git am --whitespace=nowarn --binary $patch_path";
68 print "Apply $rev.patch\n";
69 my $apply = `$applycmd` or die "$applycmd: failed";
72 save_last_svn_rev($last_svn_rev_file, $rev);