diff options
author | Norbert Preining <preining@logic.at> | 2017-05-01 19:44:08 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-05-01 19:44:08 +0000 |
commit | 2cdf469e54f3d9b21b305c75678577575149162f (patch) | |
tree | 87c2ef93eebb68d5a7c0502ddf3c4a9d56f9269c /Master/tlpkg/TeXLive | |
parent | 4e052b859bb3960916f2f41af1dfc6a49adb8916 (diff) |
TLTREE: support git/svn and git directly
git-svn-id: svn://tug.org/texlive/trunk@44137 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r-- | Master/tlpkg/TeXLive/TLTREE.pm | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Master/tlpkg/TeXLive/TLTREE.pm b/Master/tlpkg/TeXLive/TLTREE.pm index fa734190d27..8676008937d 100644 --- a/Master/tlpkg/TeXLive/TLTREE.pm +++ b/Master/tlpkg/TeXLive/TLTREE.pm @@ -72,6 +72,98 @@ sub init_from_files { $self->_initialize_lines(@lines); } + +sub init_from_git { + my $self = shift; + my $svnroot = $self->{'svnroot'}; + my $retval = $?; + my %files; + my @lines; + + my @foo = `cd $svnroot; git log --pretty=format:COMMIT=%h --name-only --diff-filter=A`; + if ($retval != 0) { + $retval /= 256 if $retval > 0; + tldie("TLTree: git log in $svnroot returned $retval, stopping.\n"); + } + chomp(@foo); + + my $curcom = ""; + for my $l (@foo) { + if ($l eq "") { + $curcom = ""; + next; + } elsif ($l =~ m/^COMMIT=([[:xdigit:]]*)$/) { + $curcom = $1; + $rev++; + next; + } else { + $files{$l} = $rev; + } + } + + # now reverse the order + for my $f (keys %files) { + my $n = - ( $files{$f} - $rev ) + 1; + push @lines, " $n $n dummy $f" + } + # TODO needs to be made better! + $self->{'revision'} = $rev; + $self->_initialize_lines(@lines); +} + +sub init_from_gitsvn { + my $self = shift; + my $svnroot = $self->{'svnroot'}; + my @foo = `cd $svnroot; git log --pretty=format:%h --name-only --diff-filter=A`; + chomp(@foo); + my $retval = $?; + if ($retval != 0) { + $retval /= 256 if $retval > 0; + tldie("TLTree: git log in $svnroot returned $retval, stopping.\n"); + } + my %com2rev; + my @lines; + my $curcom = ""; + my $currev = ""; + for my $l (@foo) { + if ($l eq "") { + $currev = ""; + $curcom = ""; + next; + } + if ($curcom eq "") { + # now we should get a commit! + # we could also pattern match on 8 hex digits, but that costs time! + $curcom = $l; + $currev = `git svn find-rev $curcom`; + chomp($currev); + if (!$currev) { + # found a commit without svn rev, try to find it under the parents + my $foo = $curcom; + my $nr = 0; + while (1) { + $foo .= "^"; + $nr++; + my $tr = `git svn find-rev $foo`; + chomp($tr); + if ($tr) { + # we add the number of parents to the currev + $currev = $tr + $nr; + last; + } + } + } + $com2rev{$curcom} = $currev; + } else { + # we got a file name + push @lines, " $currev $currev dummy $l" + } + } + # TODO needs to be made better! + $self->{'revision'} = 1; + $self->_initialize_lines(@lines); +} + sub _initialize_lines { my $self = shift; my @lines = @_; |