- if (@UntranslatedKeys > 0) {
- print "Still " . 0 + @UntranslatedKeys . " $type messages found in $ARGV[1]\n";
- for my $l (@UntranslatedKeys) {
- print "> line $l: \"" . $rExtra->{$l} . "\"\n";
+ if ($rev eq "HEAD") {
+ $revnum = 0;
+ }
+ else {
+ return $rev if ($rev !~ /^(-|HEAD[-~])(\d+)$/);
+ $revnum = $2;
+ }
+ if ($repo eq ".hg") {
+ # try to get the revision of n-th previous change of the po-file
+ if (open(FIR, "hg log '$argf'|")) {
+ my $count = $revnum;
+ my $res = "-$revnum";
+ while (my $l = <FIR>) {
+ chomp($l);
+ if ($l =~ /:\s+(\d+):([^\s]+)$/) {
+ $res = $2;
+ last if ($count-- <= 0);
+ }
+ }
+ close(FIR);
+ return($res);
+ }
+ else {
+ return "-$revnum";
+ }
+ }
+ elsif ($repo eq ".git") {
+ # try to get the revision of n-th previous change of the po-file
+ if (open(FIR, "git log --skip=$revnum -1 '$argf'|")) {
+ my $res = "HEAD~$revnum";
+ while (my $l = <FIR>) {
+ chomp($l);
+ if ($l =~ /^commit\s+([^\s]+)$/) {
+ $res = $1;
+ last;
+ }
+ }
+ close(FIR);
+ return($res);
+ }
+ else {
+ return("HEAD~$revnum");
+ }
+ }
+ elsif ($repo eq ".svn") {
+ if (open(FIR, "svn log '$argf'|")) {
+ my $count = $revnum;
+ my $res = $rev;
+ while (my $l = <FIR>) {
+ chomp($l);
+ if ($l =~ /^r(\d+)\s+\|/) {
+ $res = $1;
+ last if ($count-- <= 0);
+ }
+ }
+ close(FIR);
+ return $res;
+ }
+ else {
+ if (open(VI, "svnversion |")) {
+ while (my $r1 = <VI>) {
+ chomp($r1);
+ if ($r1 =~ /^((\d+):)?(\d+)M?$/) {
+ $rev = $3-$revnum;
+ }
+ }
+ close(VI);
+ }
+ return $rev;