You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/09/06 15:27:43 UTC

svn commit: r1701488 - /subversion/trunk/contrib/hook-scripts/check-mime-type.pl

Author: julianfoad
Date: Sun Sep  6 13:27:43 2015
New Revision: 1701488

URL: http://svn.apache.org/r1701488
Log:
Fix check-mime-type.pl so that it also works for svnlook versions from 1.7.8
(r1416637).

In r1416637, svnlook proplist --verbose output changed from propname : propval
format, to an indented output:

Properties on ...
  propname1
    propval1
    propval2

This change makes check-mime-type aware of both the pre 1.7.8 and 1.7.8+
formats.

Patch by: Brett Randall <javabrett{_AT_}gmail.com>

Modified:
    subversion/trunk/contrib/hook-scripts/check-mime-type.pl

Modified: subversion/trunk/contrib/hook-scripts/check-mime-type.pl
URL: http://svn.apache.org/viewvc/subversion/trunk/contrib/hook-scripts/check-mime-type.pl?rev=1701488&r1=1701487&r2=1701488&view=diff
==============================================================================
--- subversion/trunk/contrib/hook-scripts/check-mime-type.pl (original)
+++ subversion/trunk/contrib/hook-scripts/check-mime-type.pl Sun Sep  6 13:27:43 2015
@@ -119,17 +119,48 @@ foreach my $path ( @files_added )
 
 		# Parse the complete list of property values of the file $path to extract
 		# the mime-type and eol-style
-		foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t',
-		                  $txn, '--verbose', '--', $path))
+
+		my @output = &read_from_process($svnlook, 'proplist', $repos, '-t',
+					$txn, '--verbose', '--', $path);
+		my $output_line = 0;
+
+		foreach my $prop (@output)
 			{
-				if ($prop =~ /^\s*svn:mime-type : (\S+)/)
+				if ($prop =~ /^\s*svn:mime-type( : (\S+))?/)
 					{
-						$mime_type = $1;
+						$mime_type = $2;
+						# 1.7.8 (r1416637) onwards changed the format of svnloop proplist --verbose
+						# from propname : propvalue format, to values in an indent list on following lines
+						if (not $mime_type)
+							{
+								if ($output_line + 1 >= scalar(@output))
+									{
+										die "$0: Unexpected EOF reading proplist.\n";
+									}
+								my $next_line_pval_indented = $output[$output_line + 1];
+								if ($next_line_pval_indented =~ /^\s{4}(.*)/)
+									{
+										$mime_type = $1;
+									}
+							}
 					}
-				elsif ($prop =~ /^\s*svn:eol-style : (\S+)/)
+				elsif ($prop =~ /^\s*svn:eol-style( : (\S+))?/)
 					{
-						$eol_style = $1;
+						$eol_style = $2;
+						if (not $eol_style)
+							{
+								if ($output_line + 1 >= scalar(@output))
+									{
+										die "$0: Unexpected EOF reading proplist.\n";
+									}
+								my $next_line_pval_indented = $output[$output_line + 1];
+								if ($next_line_pval_indented =~ /^\s{4}(.*)/)
+									{
+										$eol_style = $1;
+									}
+							}
 					}
+				$output_line++;
 			}
 
 		# Detect error conditions and add them to @errors