diff options
Diffstat (limited to 'Master/tlpkg/bin/update-commit-svn-list.pl')
-rw-r--r-- | Master/tlpkg/bin/update-commit-svn-list.pl | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/update-commit-svn-list.pl b/Master/tlpkg/bin/update-commit-svn-list.pl new file mode 100644 index 00000000000..c098b1f79d7 --- /dev/null +++ b/Master/tlpkg/bin/update-commit-svn-list.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +$^W = 1; + +use strict; + +if ($#ARGV < 1) { + die("usage: $0 git-dir commit-rev-file"); +} + +my $svnroot = $ARGV[0]; +my $comrevfile = $ARGV[1]; + +init_from_git($svnroot, $comrevfile); + +sub find_last_done_com { + my $lastrev = ""; + my $comrevfile = shift; + if (open (COMREV, "<$comrevfile")) { + my $foo = <COMREV>; + chomp($foo); + ($lastrev, undef) = split(" ", $foo); + close(COMREV); + } + return $lastrev; +} + +sub init_from_git { + my ($svnroot, $comrevfile) = @_; + + my $lastrev = find_last_done_com($comrevfile); + printf STDERR "calling cd $svnroot; git --no-pager log --pretty=format:%%h $lastrev..HEAD\n"; + my @foo = `cd $svnroot; git --no-pager log --pretty=format:%h $lastrev..HEAD`; + chomp(@foo); + my $retval = $?; + if ($retval != 0) { + $retval /= 256 if $retval > 0; + die("TLTree: git log in $svnroot returned $retval, stopping.\n"); + } + for my $c (@foo) { + print STDERR "calling cd $svnroot; git --no-pager svn find-rev $c\n"; + my $r = `cd $svnroot; git --no-pager svn find-rev $c`; + chomp($r); + if (!$r) { + # found a commit without svn rev, try to find it under the parents + my $foo = $c; + my $nr = 0; + while (1) { + $foo .= "^"; + $nr++; + my $tr = `cd $svnroot; git --no-pager svn find-rev $foo`; + chomp($tr); + if ($tr) { + # we add the number of parents to the currev + $r = "$c+$nr"; # that is NOT addition! + last; + } + } + } + print "$c $r\n"; + } +} + |