[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kde-common/svn/hooks
From:       Dirk Mueller <mueller () kde ! org>
Date:       2007-10-11 8:29:54
Message-ID: 1192091394.691169.17057.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 724049 by mueller:

don't load the svnlook output all into memory before
processing it


 M  +16 -73    test-eol-style.pl  


--- trunk/KDE/kde-common/svn/hooks/test-eol-style.pl #724048:724049
@@ -62,16 +62,16 @@
 
 # Figure out what files have changed using svnlook.
 my $last_filename = "";
-foreach my $line (&read_from_process($svnlook, 'diff', $repos, '-t', $txn))
-  {
-    if ($line =~ /^\+\+\+ (\S+)\t/) {
+open(IN, "-|") || exec $svnlook, 'diff', $repos, '-t', $txn;
+while(<IN>) {
+    if (/^\+\+\+ (\S+)\t/) {
       $last_filename = $1;
       next;
     }
 
-    next if ($line !~ /^\+/);
+    next if ($_ !~ /^\+/);
 
-    if ($line =~ /(?:\r\n|\n\r|\r)$/) {
+    if (/(?:\r\n|\n\r|\r)$/) {
         print STDERR "=== $last_filename\n";
         print STDERR "eol style violation detected.\n";
         print STDERR "forgot to set svn:eol-style to native for checkout\n";
@@ -79,8 +79,18 @@
 
         exit 1;
     }
-  }
+}
+close(IN);
 
+my $result = $?;
+my $exit   = $result >> 8;
+my $signal = $result & 127;
+my $cd     = $result & 128 ? "with core dump" : "";
+if ($signal or $cd)
+{
+    warn "$0: pipe from `@_' failed $cd: exit=$exit signal=$signal\n";
+}
+
 exit 0;
 
 sub usage
@@ -88,70 +98,3 @@
   warn "@_\n" if @_;
   die "usage: $0 REPOS TXN-NAME\n";
 }
-
-sub safe_read_from_pipe
-{
-  unless (@_)
-    {
-      die "$0: safe_read_from_pipe passed no arguments.\n";
-    }
-  my $pid = open(SAFE_READ, '-|');
-  unless (defined $pid)
-    {
-      die "$0: cannot fork: $!\n";
-    }
-  unless ($pid)
-    {
-      open(STDERR, ">&STDOUT")
-        or die "$0: cannot dup STDOUT: $!\n";
-      exec(@_)
-        or die "$0: cannot exec `@_': $!\n";
-    }
-  my @output;
-  while (<SAFE_READ>)
-    {
-      chomp;
-      push(@output, $_);
-    }
-  close(SAFE_READ);
-  my $result = $?;
-  my $exit   = $result >> 8;
-  my $signal = $result & 127;
-  my $cd     = $result & 128 ? "with core dump" : "";
-  if ($signal or $cd)
-    {
-      warn "$0: pipe from `@_' failed $cd: exit=$exit signal=$signal\n";
-    }
-  if (wantarray)
-    {
-      return ($result, @output);
-    }
-  else
-    {
-      return $result;
-    }
-}
-
-sub read_from_process
-  {
-  unless (@_)
-    {
-      die "$0: read_from_process passed no arguments.\n";
-    }
-  my ($status, @output) = &safe_read_from_pipe(@_);
-  if ($status)
-    {
-      if (@output)
-        {
-          die "$0: `@_' failed with this output:\n", join("\n", @output), "\n";
-        }
-      else
-        {
-          die "$0: `@_' failed with no output.\n";
-        }
-    }
-  else
-    {
-      return @output;
-    }
-}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic