summaryrefslogtreecommitdiff
path: root/ACE/bin/ChangeLogEditor/SVNFileLocator.pm
blob: 55a8674af81ff9f7834d71a7bcac403acbfca2e2 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package SVNFileLocator;

# ************************************************************
# Description   : Use SVN to determine the list of modified files.
# Author        : Chad Elliott
# Create Date   : 11/29/2005
# ************************************************************

# ************************************************************
# Pragmas
# ************************************************************

use strict;
use FileHandle;

use FileLocator;

use vars qw(@ISA);
@ISA = qw(FileLocator);

# ************************************************************
# Subroutine Section
# ************************************************************

sub locate {
  my($self)      = shift;
  my(@dirs)      = @_;
  my($fh)        = new FileHandle();
  my(@modified)  = ();
  my(@removed)   = ();
  my(@conflicts) = ();
  my(@unknown)   = ();
  my($error)     = undef;
  my($err)       = $self->tmpnam('cle_svn.err');

  if (open($fh, "svn status @dirs 2> $err |")) {
    while(<$fh>) {
      my($line) = $_;
      if ($line =~ /^([A-Z\s\?])([A-Z\s])[A-Z\s][\+\*\s][A-Z\s][A-Z\s]\s+(.*)$/) {
        my($content)  = $1;
        my($property) = $2;
        my($file)     = $3;

        ## Subversion differs from CVS in that it will print paths with
        ## windows style back-slashes instead of forward slashes.
        $file =~ s!\\!/!g if ($^O eq 'MSWin32');

        if ($property eq 'M' ||
            $content eq 'M'  || $content eq 'A' || $content eq 'R') {
          push(@modified, $file);
        }
        elsif ($content eq 'D') {
          push(@removed, $file);
        }
        elsif ($content eq 'C' || $property eq 'C') {
          push(@conflicts, $file);
        }
        elsif ($content eq '?' && index($line, $err) == -1) {
          push(@unknown, $file);
        }
      }
    }
    close($fh);

    $error = $self->process_errors($err);
  }
  else {
    $error = "Unable to run svn with error redirection.";
  }

  return \@modified, \@removed, \@conflicts, \@unknown, $error;
}


1;