From 2cdf469e54f3d9b21b305c75678577575149162f Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 1 May 2017 19:44:08 +0000 Subject: TLTREE: support git/svn and git directly git-svn-id: svn://tug.org/texlive/trunk@44137 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLTREE.pm | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'Master/tlpkg/TeXLive') 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 = @_; -- cgit v1.2.3