Created
April 24, 2009 16:40
-
-
Save yannk/101201 to your computer and use it in GitHub Desktop.
svn-diff.pl <branch> generate diffs that Review Board can understand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $branch = shift; | |
my $head = `git rev-list --date-order --max-count=1 $branch`; | |
my $svnrev = `git svn find-rev $head`; | |
my $diff = `git diff --find-copies-harder --no-prefix $branch...`; | |
my $space = " "; | |
chomp $svnrev; | |
my @lines = split /\n/, $diff; | |
for (my $i = 0; $i < scalar @lines; $i++) { | |
my $line = $lines[$i]; | |
if ($line =~ m{^--- /dev/null.*}) { | |
my ($newfile) = $lines[$i + 1] =~ m{^\+\+\+ (.+)\s*$}; | |
$line =~ s{/dev/null.*$}{$newfile$space(revision 0)}; | |
print "$line\n"; | |
next; | |
} | |
$line =~ s/^(--- .*)/$1$space(revision $svnrev)/; | |
$line =~ s/^(\+\+\+ .*)/$1$space(working copy)/; | |
print "$line\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment