File: touch_modified.pl

package info (click to toggle)
arb 6.0.6-8
  • links: PTS, VCS
  • area: non-free
  • in suites: sid, trixie
  • size: 66,204 kB
  • sloc: ansic: 394,911; cpp: 250,290; makefile: 19,644; sh: 15,879; perl: 10,473; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (55 lines) | stat: -rwxr-xr-x 1,469 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl

use strict;
use warnings;
# use diagnostics;

# --------------------------------------------------------------------------------

my $ARBHOME = $ENV{ARBHOME};
if (not defined $ARBHOME) { die "Environmentvariable ARBHOME has be defined"; }
if (not -d $ARBHOME) { die "ARBHOME ('$ARBHOME') does not point to a valid directory"; }


sub main() {
  print "Touching modified files:\n";

  my $svn_status = "svn status";
  open(STATUS, $svn_status.'|') || die "can't execute '$svn_status' (Reason: $!)";
  foreach my $line (<STATUS>) {
    chomp($line);
    my $handled = 0;
    if ($line =~ /^([^\s]+)[\s+]+(.*)$/) {
      my ($st,$file) = ($1,$2);
      my $touch         = 0;

      if (($st eq 'M') or ($st eq 'R') or ($st eq 'A')) { # touch modified, replaced and added files
        $touch = 1;
      }
      elsif (($st eq '?') or ($st eq 'D')) { # ignore unknown and deleted files
        $handled = 1;
      }

      if ($touch==1) {
        if (-d $file) {
          $handled = 1;
        }
        else {
          if (not -f $file) { die "File '$file' not found (statusline='$line')" }

          my $touch_cmd = "touch '$file'";
          print '['.$touch_cmd."]\n";
          system($touch_cmd);
          $handled = 1;
        }
      }
    }
    elsif ($line =~ /^\s+M\s+\.$/) { # accept changed merge-info for rootdir
      $handled = 1;
    }
    if ($handled==0) { die "Can't handle status line '$line'"; }
  }
  close(STATUS);
}

main();