summaryrefslogtreecommitdiff
path: root/Master/tlpkg
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg')
-rw-r--r--Master/tlpkg/TeXLive/TLTREE.pm92
-rwxr-xr-xMaster/tlpkg/bin/tl-update-tlpdb12
-rw-r--r--Master/tlpkg/bin/update-commit-svn-list.pl63
3 files changed, 167 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 = @_;
diff --git a/Master/tlpkg/bin/tl-update-tlpdb b/Master/tlpkg/bin/tl-update-tlpdb
index 562da3af3e8..f8d95726b5e 100755
--- a/Master/tlpkg/bin/tl-update-tlpdb
+++ b/Master/tlpkg/bin/tl-update-tlpdb
@@ -31,6 +31,8 @@ my $help = 0;
my $opt_dry_run = 0;
my $opt_fix_reverse_revisions = 0; # needs svn commit
my $opt_fromfiles = 0;
+my $opt_fromgit = 0;
+my $opt_fromgitsvn = 0;
my $opt_no_commit = 0; # do/don't commit the changes
my $opt_no_revision_check = 0;
my $opt_nobinsplit = 0;
@@ -48,6 +50,8 @@ GetOptions(
"fix-reverse-revisions!" => \$opt_fix_reverse_revisions,
"keep-revisions" => \$opt_keep_revisions,
"from-files" => \$opt_fromfiles,
+ "from-git" => \$opt_fromgit,
+ "from-gitsvn" => \$opt_fromgitsvn,
"master=s" => \$opt_master,
"no-bin-split!" => \$opt_nobinsplit,
"no-commit!" => \$opt_no_commit,
@@ -70,6 +74,10 @@ sub main {
die "$progname: Master $opt_master not a directory, goodbye.\n";
}
+ if ($opt_fromfiles + $opt_fromgit + $opt_fromgitsvn > 1) {
+ die "$progname: only one option --from[lines|git|gitsvn] can be given.\n";
+ }
+
$opt_catalogue = "/home/httpd/html/catalogue"
if ! $opt_catalogue;
@@ -317,6 +325,10 @@ sub create_tlpdb {
my $tltree = TeXLive::TLTREE->new ("svnroot" => $opt_master);
if ($opt_fromfiles) {
$tltree->init_from_files;
+ } elsif ($opt_fromgit) {
+ $tltree->init_from_git;
+ } elsif ($opt_fromgitsvn) {
+ $tltree->init_from_gitsvn;
} else {
$tltree->init_from_svn;
}
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";
+ }
+}
+