Title: [103002] trunk/Tools
Revision
103002
Author
[email protected]
Date
2011-12-15 17:08:25 -0800 (Thu, 15 Dec 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=74469
Escape paths to svn commands so our tools can handle filenames with @ symbols.

Reviewed by Adam Roben.

* Scripts/VCSUtils.pm:
(scmMoveOrRenameFile):
(scmAddExecutableBit):
(scmRemoveExecutableBit):
(determineSVNRoot):
(svnRevisionForDirectory):
(pathRelativeToSVNRepositoryRootForPath):
(svnStatus):
(escapeSubversionPath):
* Scripts/parse-malloc-history:
(main):
* Scripts/prepare-ChangeLog:
(diffCommand):
(statusCommand):
(findOriginalFileFromSvn):
(determinePropertyChanges):
* Scripts/resolve-ChangeLogs:
(conflictFiles):
(resolveConflict):
(showStatus):
* Scripts/svn-apply:
(patch):
(scmCopy):
(scmAdd):
(scmRemove):
* Scripts/svn-create-patch:
(findBaseUrl):
(findMimeType):
(findSourceFileAndRevision):
(generateDiff):
(generateFileList):
(manufacturePatchForAdditionWithHistory):
* Scripts/svn-unapply:
(patch):
(revertDirectories):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (103001 => 103002)


--- trunk/Tools/ChangeLog	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/ChangeLog	2011-12-16 01:08:25 UTC (rev 103002)
@@ -1,3 +1,46 @@
+2011-12-15  Stephanie Lewis  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=74469
+        Escape paths to svn commands so our tools can handle filenames with @ symbols.
+
+        Reviewed by Adam Roben.
+
+        * Scripts/VCSUtils.pm:
+        (scmMoveOrRenameFile):
+        (scmAddExecutableBit):
+        (scmRemoveExecutableBit):
+        (determineSVNRoot):
+        (svnRevisionForDirectory):
+        (pathRelativeToSVNRepositoryRootForPath):
+        (svnStatus):
+        (escapeSubversionPath):
+        * Scripts/parse-malloc-history:
+        (main):
+        * Scripts/prepare-ChangeLog:
+        (diffCommand):
+        (statusCommand):
+        (findOriginalFileFromSvn):
+        (determinePropertyChanges):
+        * Scripts/resolve-ChangeLogs:
+        (conflictFiles):
+        (resolveConflict):
+        (showStatus):
+        * Scripts/svn-apply:
+        (patch):
+        (scmCopy):
+        (scmAdd):
+        (scmRemove):
+        * Scripts/svn-create-patch:
+        (findBaseUrl):
+        (findMimeType):
+        (findSourceFileAndRevision):
+        (generateDiff):
+        (generateFileList):
+        (manufacturePatchForAdditionWithHistory):
+        * Scripts/svn-unapply:
+        (patch):
+        (revertDirectories):
+
 2011-12-15  Michael Bruning  <[email protected]>
 
         [qt][wk2] MiniBrowser: Add pressed state for viewport info button.

Modified: trunk/Tools/Scripts/VCSUtils.pm (103001 => 103002)


--- trunk/Tools/Scripts/VCSUtils.pm	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/VCSUtils.pm	2011-12-16 01:08:25 UTC (rev 103002)
@@ -55,6 +55,7 @@
         &decodeGitBinaryPatch
         &determineSVNRoot
         &determineVCSRoot
+        &escapeSubversionPath
         &exitStatus
         &fixChangeLogPatch
         &gitBranch
@@ -153,7 +154,9 @@
     my ($source, $destination) = @_;
     return if ! -e $source;
     if (isSVN()) {
-        system("svn", "move", $source, $destination);
+        my $escapedDestination = escapeSubversionPath($destination);
+        my $escapedSource = escapeSubversionPath($source);
+        system("svn", "move", $escapedSource, $escapedDestination);
     } elsif (isGit()) {
         system("git", "mv", $source, $destination);
     }
@@ -176,7 +179,8 @@
     my ($path) = @_;
 
     if (isSVN()) {
-        system("svn", "propset", "svn:executable", "on", $path) == 0 or die "Failed to run 'svn propset svn:executable on $path'.";
+        my $escapedPath = escapeSubversionPath($path);
+        system("svn", "propset", "svn:executable", "on", $escapedPath) == 0 or die "Failed to run 'svn propset svn:executable on $escapedPath'.";
     } elsif (isGit()) {
         chmod(0755, $path);
     }
@@ -187,7 +191,8 @@
     my ($path) = @_;
 
     if (isSVN()) {
-        system("svn", "propdel", "svn:executable", $path) == 0 or die "Failed to run 'svn propdel svn:executable $path'.";
+        my $escapedPath = escapeSubversionPath($path);
+        system("svn", "propdel", "svn:executable", $escapedPath) == 0 or die "Failed to run 'svn propdel svn:executable $escapedPath'.";
     } elsif (isGit()) {
         chmod(0664, $path);
     }
@@ -304,8 +309,9 @@
     while (1) {
         my $thisRoot;
         my $thisUUID;
+        my $escapedPath = escapeSubversionPath($path);
         # Ignore error messages in case we've run past the root of the checkout.
-        open INFO, "svn info '$path' 2> " . File::Spec->devnull() . " |" or die;
+        open INFO, "svn info '$escapedPath' 2> " . File::Spec->devnull() . " |" or die;
         while (<INFO>) {
             if (/^Repository Root: (.+)/) {
                 $thisRoot = $1;
@@ -361,7 +367,8 @@
     my $revision;
 
     if (isSVNDirectory($dir)) {
-        my $svnInfo = `LC_ALL=C svn info $dir | grep Revision:`;
+        my $escapedDir = escapeSubversionPath($dir);
+        my $svnInfo = `LC_ALL=C svn info $escapedDir | grep Revision:`;
         ($revision) = ($svnInfo =~ m/Revision: (\d+).*/g);
     } elsif (isGitDirectory($dir)) {
         my $gitLog = `cd $dir && LC_ALL=C git log --grep='git-svn-id: ' -n 1 | grep git-svn-id:`;
@@ -378,7 +385,8 @@
 
     my $svnInfo;
     if (isSVN()) {
-        $svnInfo = `LC_ALL=C svn info $relativePath`;
+        my $escapedRelativePath = escapeSubversionPath($relativePath);
+        $svnInfo = `LC_ALL=C svn info $escapedRelativePath`;
     } elsif (isGit()) {
         $svnInfo = `LC_ALL=C git svn info $relativePath`;
     }
@@ -523,8 +531,9 @@
 sub svnStatus($)
 {
     my ($fullPath) = @_;
+    my $escapedFullPath = escapeSubversionPath($fullPath);
     my $svnStatus;
-    open SVN, "svn status --non-interactive --non-recursive '$fullPath' |" or die;
+    open SVN, "svn status --non-interactive --non-recursive '$escapedFullPath' |" or die;
     if (-d $fullPath) {
         # When running "svn stat" on a directory, we can't assume that only one
         # status will be returned (since any files with a status below the
@@ -1967,4 +1976,11 @@
     return $out;
 }
 
+sub escapeSubversionPath($)
+{
+    my ($path) = @_;
+    $path .= "@" if $path =~ /@/;
+    return $path;
+}
+
 1;

Modified: trunk/Tools/Scripts/prepare-ChangeLog (103001 => 103002)


--- trunk/Tools/Scripts/prepare-ChangeLog	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2011-12-16 01:08:25 UTC (rev 103002)
@@ -1446,12 +1446,13 @@
 {
     my @paths = @_;
 
-    my $pathsString = "'" . join("' '", @paths) . "'"; 
-
     my $command;
     if (isSVN()) {
-        $command = "$SVN diff --diff-cmd diff -x -N $pathsString";
+        my @escapedPaths = map(escapeSubversionPath($_), @paths);
+        my $escapedPathsString = "'" . join("' '", @escapedPaths) . "'";
+        $command = "$SVN diff --diff-cmd diff -x -N $escapedPathsString";
     } elsif (isGit()) {
+        my $pathsString = "'" . join("' '", @paths) . "'"; 
         $command = "$GIT diff --no-ext-diff -U0 " . diffFromToString();
         $command .= " -- $pathsString" unless $gitCommit or $mergeBase;
     }
@@ -1463,11 +1464,13 @@
 {
     my @files = @_;
 
-    my $filesString = "\"" . join ("\" \"", @files) . "\"";
     my $command;
     if (isSVN()) {
-        $command = "$SVN stat $filesString";
+        my @escapedFiles = map(escapeSubversionPath($_), @files);
+        my $escapedFilesString = "'" . join("' '", @escapedFiles) . "'";
+        $command = "$SVN stat $escapedFilesString";
     } elsif (isGit()) {
+        my $filesString = "\"" . join ("\" \"", @files) . "\"";
         $command = "$GIT diff -r --name-status -M -C " . diffFromToString();
         $command .= " -- $filesString" unless $gitCommit;
     }
@@ -1508,7 +1511,8 @@
     }
     close INFO;
     my $sourceFile;
-    open INFO, "$SVN info '$file' |" or die;
+    my $escapedFile = escapeSubversionPath($file);
+    open INFO, "$SVN info '$escapedFile' |" or die;
     while (<INFO>) {
         if (/^Copied From URL: (.+?)[\r\n]*$/) {
             $sourceFile = File::Spec->abs2rel($1, $baseUrl);
@@ -1522,17 +1526,19 @@
 {
     my ($file, $isAdd, $original) = @_;
 
+    my $escapedFile = escapeSubversionPath($file);
     my %changes;
     if ($isAdd) {
         my %addedProperties;
         my %removedProperties;
-        open PROPLIST, "$SVN proplist '$file' |" or die;
+        open PROPLIST, "$SVN proplist '$escapedFile' |" or die;
         while (<PROPLIST>) {
             $addedProperties{$1} = 1 if /^  (.+?)[\r\n]*$/ && $1 ne 'svn:mergeinfo';
         }
         close PROPLIST;
         if ($original) {
-            open PROPLIST, "$SVN proplist '$original' |" or die;
+            my $escapedOriginal = escapeSubversionPath($original);
+            open PROPLIST, "$SVN proplist '$escapedOriginal' |" or die;
             while (<PROPLIST>) {
                 next unless /^  (.+?)[\r\n]*$/;
                 my $property = $1;
@@ -1546,7 +1552,7 @@
         $changes{"A"} = [sort keys %addedProperties] if %addedProperties;
         $changes{"D"} = [sort keys %removedProperties] if %removedProperties;
     } else {
-        open DIFF, "$SVN diff '$file' |" or die;
+        open DIFF, "$SVN diff '$escapedFile' |" or die;
         while (<DIFF>) {
             if (/^Property changes on:/) {
                 while (<DIFF>) {

Modified: trunk/Tools/Scripts/resolve-ChangeLogs (103001 => 103002)


--- trunk/Tools/Scripts/resolve-ChangeLogs	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/resolve-ChangeLogs	2011-12-16 01:08:25 UTC (rev 103002)
@@ -182,7 +182,8 @@
     }
 
     if ($isSVN) {
-        open STAT, "-|", $SVN, "status", $file or die $!;
+        my $escapedFile = escapeSubversionPath($file);
+        open STAT, "-|", $SVN, "status", $escapedFile or die $!;
         my $status = <STAT>;
         close STAT;
         if (!$status || $status !~ m/^C\s+/) {
@@ -193,7 +194,7 @@
         $fileMine = "${file}.mine" if -e "${file}.mine";
 
         my $currentRevision;
-        open INFO, "-|", $SVN, "info", $file or die $!;
+        open INFO, "-|", $SVN, "info", $escapedFile or die $!;
         while (my $line = <INFO>) {
             if ($line =~ m/^Revision: ([0-9]+)/) {
                 $currentRevision = $1;
@@ -465,7 +466,8 @@
     my ($file) = @_;
 
     if ($isSVN) {
-        system($SVN, "resolved", $file);
+        my $escapedFile = escapeSubversionPath($file);
+        system($SVN, "resolved", $escapedFile);
         die $! if WEXITSTATUS($?);
     } elsif ($isGit) {
         system($GIT, "add", $file);
@@ -480,7 +482,8 @@
     my ($file, $isConflictResolved) = @_;
 
     if ($isSVN) {
-        system($SVN, "status", $file);
+        my $escapedFile = escapeSubversionPath($file);
+        system($SVN, "status", $escapedFile);
     } elsif ($isGit) {
         my @args = qw(--name-status);
         unshift @args, qw(--cached) if $isConflictResolved;

Modified: trunk/Tools/Scripts/svn-apply (103001 => 103002)


--- trunk/Tools/Scripts/svn-apply	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/svn-apply	2011-12-16 01:08:25 UTC (rev 103002)
@@ -136,7 +136,8 @@
     for my $file (sort keys %sourceRevisions) {
         my $version = $sourceRevisions{$file};
         print "Getting version $version of $file\n";
-        system("svn", "update", "-r", $version, $file) == 0 or die "Failed to run svn update -r $version $file.";
+        my $escapedFile = escapeSubversionPath($file);
+        system("svn", "update", "-r", $version, $escapedFile) == 0 or die "Failed to run svn update -r $version $escapedFile.";
     }
 }
 
@@ -354,8 +355,9 @@
             applyPatch($patch, $fullPath) if $patch;
             unlink("$fullPath.orig") if -e "$fullPath.orig" && checksum($fullPath) eq checksum("$fullPath.orig");
             scmAdd($fullPath);
+            my $escapedFullPath = escapeSubversionPath("$fullPath.orig");
             # What is this for?
-            system("svn", "stat", "$fullPath.orig") if isSVN() && -e "$fullPath.orig";
+            system("svn", "stat", "$escapedFullPath") if isSVN() && -e "$fullPath.orig";
         }
     }
 
@@ -423,7 +425,9 @@
 {
     my ($source, $destination) = @_;
     if (isSVN()) {
-        system("svn", "copy", $source, $destination) == 0 or die "Failed to svn copy $source $destination.";
+        my $escapedSource = escapeSubversionPath($source);
+        my $escapedDestination = escapeSubversionPath($destination);
+        system("svn", "copy", $escapedSource, $escapedDestination) == 0 or die "Failed to svn copy $escapedSource $escapedDestination.";
     } elsif (isGit()) {
         system("cp", $source, $destination) == 0 or die "Failed to copy $source $destination.";
         system("git", "add", $destination) == 0 or die "Failed to git add $destination.";
@@ -434,7 +438,8 @@
 {
     my ($path) = @_;
     if (isSVN()) {
-        system("svn", "add", $path) == 0 or die "Failed to svn add $path.";
+        my $escapedPath = escapeSubversionPath($path);
+        system("svn", "add", $escapedPath) == 0 or die "Failed to svn add $escapedPath.";
     } elsif (isGit()) {
         system("git", "add", $path) == 0 or die "Failed to git add $path.";
     }
@@ -446,7 +451,8 @@
     if (isSVN()) {
         # SVN is very verbose when removing directories.  Squelch all output except the last line.
         my $svnOutput;
-        open SVN, "svn rm --force '$path' |" or die "svn rm --force '$path' failed!";
+        my $escapedPath = escapeSubversionPath($path);
+        open SVN, "svn rm --force '$escapedPath' |" or die "svn rm --force '$escapedPath' failed!";
         # Only print the last line.  Subversion outputs all changed statuses below $dir
         while (<SVN>) {
             $svnOutput = $_;

Modified: trunk/Tools/Scripts/svn-create-patch (103001 => 103002)


--- trunk/Tools/Scripts/svn-create-patch	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/svn-create-patch	2011-12-16 01:08:25 UTC (rev 103002)
@@ -156,7 +156,8 @@
 {
     my ($infoPath) = @_;
     my $baseUrl;
-    open INFO, "svn info '$infoPath' |" or die;
+    my $escapedInfoPath = escapeSubversionPath($infoPath);
+    open INFO, "svn info '$escapedInfoPath' |" or die;
     while (<INFO>) {
         if (/^URL: (.+?)[\r\n]*$/) {
             $baseUrl = $1;
@@ -170,7 +171,8 @@
 {
     my ($file, $revision) = @_;
     my $args = $revision ? "--revision $revision" : "";
-    open PROPGET, "svn propget svn:mime-type $args '$file' |" or die;
+    my $escapedFile = escapeSubversionPath($file);
+    open PROPGET, "svn propget svn:mime-type $args '$escapedFile' |" or die;
     my $mimeType = <PROPGET>;
     close PROPGET;
     # svn may output a different EOL sequence than $/, so avoid chomp.
@@ -200,7 +202,8 @@
     my $baseUrl = findBaseUrl(".");
     my $sourceFile;
     my $sourceRevision;
-    open INFO, "svn info '$file' |" or die;
+    my $escapedFile = escapeSubversionPath($file);
+    open INFO, "svn info '$escapedFile' |" or die;
     while (<INFO>) {
         if (/^Copied From URL: (.+?)[\r\n]*$/) {
             $sourceFile = File::Spec->abs2rel($1, $baseUrl);
@@ -227,7 +230,8 @@
     }
 
     my $diffOptions = diffOptionsForFile($file);
-    open DIFF, "svn diff --diff-cmd diff -x -$diffOptions '$file' |" or die;
+    my $escapedFile = escapeSubversionPath($file);
+    open DIFF, "svn diff --diff-cmd diff -x -$diffOptions '$escapedFile' |" or die;
     while (<DIFF>) {
         $patch .= $_;
     }
@@ -248,7 +252,8 @@
 {
     my ($statPath, $diffFiles) = @_;
     my %testDirectories = map { $_ => 1 } qw(LayoutTests);
-    open STAT, "svn stat '$statPath' |" or die;
+    my $escapedStatPath = escapeSubversionPath($statPath);
+    open STAT, "svn stat '$escapedStatPath' |" or die;
     while (my $line = <STAT>) {
         # svn may output a different EOL sequence than $/, so avoid chomp.
         $line =~ s/[\r\n]+$//g;
@@ -312,7 +317,8 @@
         my $mimeType = findMimeType($file, $sourceRevision);
         print "svn:mime-type = ${mimeType}\n\n";
     } else {
-        print `svn cat ${sourceFile} | diff -u $devNull - | tail -n +3`;
+        my $escapedSourceFile = escapeSubversionPath($sourceFile);
+        print `svn cat ${escapedSourceFile} | diff -u $devNull - | tail -n +3`;
     }
 }
 

Modified: trunk/Tools/Scripts/svn-unapply (103001 => 103002)


--- trunk/Tools/Scripts/svn-unapply	2011-12-16 00:59:39 UTC (rev 103001)
+++ trunk/Tools/Scripts/svn-unapply	2011-12-16 01:08:25 UTC (rev 103002)
@@ -168,11 +168,12 @@
     } else {
         # Either a deletion, an addition or a binary change.
 
+        my $escapedFullPath = escapeSubversionPath($fullPath);
         # FIXME: Add support for Git binary files.
         if ($isSvnBinary) {
             # Reverse binary change
             unlink($fullPath) if (-e $fullPath);
-            system "svn", "revert", $fullPath;
+            system "svn", "revert", $escapedFullPath;
         } elsif ($deletion) {
             # Reverse deletion
             rename($fullPath, "$fullPath.orig") if -e $fullPath;
@@ -186,7 +187,7 @@
 
             # Keep the version from the patch in case it's different from svn.
             rename($fullPath, $tempPath);
-            system "svn", "revert", $fullPath;
+            system "svn", "revert", $escapedFullPath;
             rename($tempPath, $fullPath);
 
             # This works around a bug in the svn client.
@@ -198,7 +199,7 @@
             unlink("$fullPath.orig") if -e "$fullPath.orig" && checksum($fullPath) eq checksum("$fullPath.orig");
 
             # Show status if the file is modifed
-            system "svn", "stat", $fullPath;
+            system "svn", "stat", $escapedFullPath;
         } elsif ($addition) {
             # Reverse addition
             #
@@ -207,7 +208,7 @@
             #        should be used here.
             unapplyPatch($patch, $fullPath, ["--force"]) if $patch;
             unlink($fullPath) if -z $fullPath;
-            system "svn", "revert", $fullPath;
+            system "svn", "revert", $escapedFullPath;
         }
     }
 
@@ -226,12 +227,13 @@
             next if (exists $checkedDirectories{$dir});
             if (-d $dir) {
                 my $svnOutput = svnStatus($dir);
+                my $escapedDir = escapeSubversionPath($dir);
                 if ($svnOutput && $svnOutput =~ m#A\s+$dir\n#) {
-                   system "svn", "revert", $dir;
+                   system "svn", "revert", $escapedDir;
                    rmdir $dir;
                 }
                 elsif ($svnOutput && $svnOutput =~ m#D\s+$dir\n#) {
-                   system "svn", "revert", $dir;
+                   system "svn", "revert", $escapedDir;
                 }
                 else {
                     # Modification
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to