- ($baseargf = $argf) =~ s/^.*\///;
- my @args = ();
- push(@args, "-L", $argf . " (" . $rev . ")");
- push(@args, "-L", $argf . " (local copy)");
- open(FI, "git show $rev:po/$baseargf|");
- open(FO, '>', $tmpfile);
- while(my $l = <FI>) {
- print FO $l;
+ my $filedir;
+ if ($argf =~ /^(.*)\/([^\/]+)$/) {
+ $baseargf = $2;
+ $filedir = $1;
+ chdir($filedir); # set working directory for the repo-command
+ }
+ else {
+ $baseargf = $argf;
+ $filedir = ".";
+ }
+ $filedir = getcwd();
+ my ($repo, $level) = searchRepo($filedir);
+ my $relargf = $baseargf; # argf relative to the top-most repo directory
+ my $topdir;
+ if (defined($level)) {
+ my $abspathpo = $filedir; # directory of the po-file
+ $topdir = $abspathpo;
+ #print "Level = $level, abs path = $abspathpo\n";
+ while ($level > 0) {
+ $topdir =~ s/\/([^\/]+)$//;
+ $relargf = "$1/$relargf";
+ $level--;
+ #print "Level = $level, topdir = $topdir, rel path = $relargf\n";
+ }
+ chdir($topdir);
+ }
+ else {
+ print "Could not find the repo-type\n";
+ exit(-1);
+ }
+ #check po-file
+ check_po_file_readable($baseargf, $relargf);
+ if ($repo eq ".git") {
+ my @args = ();
+ my $tmpfile = File::Temp->new();
+ $rev = getrev($repo, $rev, $argf);
+ push(@args, "-L", $argf . " (" . $rev . ")");
+ push(@args, "-L", $argf . " (local copy)");
+ print "git show $rev:$relargf\n";
+ open(FI, "git show $rev:$relargf|");
+ $tmpfile->unlink_on_destroy( 1 );
+ while(my $l = <FI>) {
+ print $tmpfile $l;
+ }
+ close(FI);
+ $tmpfile->seek( 0, SEEK_END ); # Flush()
+ push(@args, $tmpfile->filename, $argf);
+ print "===================================================================\n";
+ diff_po(@args);
+ }
+ elsif ($repo eq ".svn") {
+ # program svnversion needed here
+ $rev = getrev($repo, $rev, $argf);
+ # call it again indirectly
+ my @cmd = ("svn", "diff", "-r$rev", "--diff-cmd", $0, $relargf);
+ print "cmd = " . join(' ', @cmd) . "\n";
+ system(@cmd);
+ }
+ elsif ($repo eq ".hg") {
+ # for this to work, one has to edit ~/.hgrc
+ # Insert there
+ # [extensions]
+ # hgext.extdiff =
+ #
+ $rev = getrev($repo, $rev, $argf);
+ my @cmd = ("hg", "extdiff", "-r", "$rev", "-p", $0, $relargf);
+ print "cmd = " . join(' ', @cmd) . "\n";
+ system(@cmd);