whatsnew.pl 2.54 KB
Newer Older
1
#!/usr/bin/perl
Romanian Language Team's avatar
Romanian Language Team committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

# $Id$
#
# find what's out of sync in a folder compared to the original one
# usage
#  <script> root-folder original-folder translation-folder [newer|nomatch] [dirs]
#    newer   - report newer files in original if translation present
#    nomatch - report files in original that have no corespondent transl
#    dirs    - print dirs also
#  ex: whatsnew.pl '..' english romanian newer
#

$action = "newer";
$rdir   = ".."; #root dir
$odir   = "english";
$tdir   = "romanian";
$nodir  = "nodir";

20 21
die "Unsupported since the move to git\n";

Romanian Language Team's avatar
Romanian Language Team committed
22 23 24 25 26 27 28 29 30 31 32 33
&usage;

if ($ARGV[0]) { $rdir = $ARGV[0]; };
if ($ARGV[1]) { $odir = $ARGV[1]; };
if ($ARGV[2]) { $tdir = $ARGV[2]; };
if ($ARGV[3]) { $action = $ARGV[3]; };
if ( !($action =~ m/^newer$/i)  && !($action =~ m/^nomatch$/i))
{
    die "Unsupported action: $action \n"
}
if ($ARGV[4]) { $nodir = $ARGV[4]; };

34 35
#first update current branch, then the reference one
printf "Updating from CVS repository **local branch**...\n";
36
`cvs update -d`;
37

Romanian Language Team's avatar
Romanian Language Team committed
38 39 40 41
chdir $rdir || die "*** No such root dir: $rdir\n";
chomp($rdir = `pwd`);

chdir $odir || die "*** No such dir: $rdir + $odir\n";
42
printf "\nUpdating from CVS repository **reference branch**...\n";
43
`cvs update -d`;
Romanian Language Team's avatar
Romanian Language Team committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

chdir ".." || die "*** No such root dir: $rdir\n";
@files  = `find "./$odir" -name '*' -print`;
#print @files;

for ($i=$#files; $i>=0; $i--)
{
    chomp $files[$i];
    if ( $files[$i] =~ m=/CVS= ) { goto _loop;}
    
    $tfile = $files[$i];
    $tfile =~ s=$odir=$tdir=;
    $mtimeo = (stat($files[$i]))[9];
    $mtimet = (stat($tfile))[9];
    
    if ( $action =~ m/newer/i )
    {
        if ( ($mtimeo > $mtimet) && -e $tfile )
        {
            print "Newer original than translation: $files[$i] \n";
        }
        
        if ( !(-e $tfile) && -d $files[$i] && !($nodir =~m/nodir/i) )
        {
            print "Original dir without correspondent: $files[$i] \n";
        }
    }
    elsif ( $action =~ m/nomatch/i )
    {
        if ( -f $files[$i] && !(-e $tfile) )
        {
            print "File without translation: $files[$i] \n";
        }
        elsif ( -d $files[$i] && !(-e $tfile)  && !($nodir =~m/nodir/i) )
        {
            print "Dir without correspondent: $files[$i] \n";
        }
        else
        {
            #
        }
    }

_loop:
}

print "\n=== Done ===\n";

#----------------------------------------------------------------
sub usage
{
    print "\nUsage: \n";
    print "  <script> root-folder original-folder translation-folder [newer|nomatch] [dirs]\n\n";
}
#----------------------------------------------------------------