Change download-baselines script to download images from skia-autogen SVN repo

I have copied the old version (which downloads the images from the buildbots
directly, but only works with our Mac buildbots) to download-baselines-old,
so we can use either version during a transition period.

Another difference: the new version sets the mimetype property of all image
files in the baseline_subdir, even those that have not changed.

BUG=386
http://code.google.com/p/skia/issues/detail?id=386 ('make buildbots write out RunGM image results to a browsable directory')
Review URL: https://codereview.appspot.com/5544056

git-svn-id: http://skia.googlecode.com/svn/trunk@3058 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/svn.py b/tools/svn.py
index ab811aa..b2f010c 100644
--- a/tools/svn.py
+++ b/tools/svn.py
@@ -5,6 +5,8 @@
 found in the LICENSE file.
 '''
 
+import fnmatch
+import os
 import re
 import subprocess
 
@@ -25,15 +27,25 @@
 
         @param args a list of arguments
         """
+        print 'RunCommand: %s' % args
         proc = subprocess.Popen(args, cwd=self._directory,
-                                stdout=subprocess.PIPE)
-        stdout = proc.communicate()[0]
-        returncode = proc.returncode
-        if returncode is not 0:
-            raise Exception('command "%s" failed in dir "%s": returncode=%s' %
-                            (args, self._directory, returncode))
+                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        (stdout, stderr) = proc.communicate()
+        if proc.returncode is not 0:
+            raise Exception('command "%s" failed in dir "%s": %s' %
+                            (args, self._directory, stderr))
         return stdout
 
+    def Checkout(self, url, path):
+        """Check out a working copy from a repository.
+        Returns stdout as a single string.
+
+        @param url URL from which to check out the working copy
+        @param path path (within self._directory) where the local copy will be
+        written
+        """
+        return self._RunCommand(['svn', 'checkout', url, path])
+
     def GetNewFiles(self):
         """Return a list of files which are in this directory but NOT under
         SVN control.
@@ -57,10 +69,7 @@
 
         @param filenames files to add to SVN control
         """
-        args = ['svn', 'add']
-        args.extend(filenames)
-        print '\n\nAddFiles: %s' % args
-        print self._RunCommand(args)
+        self._RunCommand(['svn', 'add'] + filenames)
 
     def SetProperty(self, filenames, property_name, property_value):
         """Sets a svn property for these files.
@@ -69,7 +78,19 @@
         @param property_name property_name to set for each file
         @param property_value what to set the property_name to
         """
-        args = ['svn', 'propset', property_name, property_value]
-        args.extend(filenames)
-        print '\n\nSetProperty: %s' % args
-        print self._RunCommand(args)
+        if filenames:
+            self._RunCommand(
+                ['svn', 'propset', property_name, property_value] + filenames)
+
+    def SetPropertyByFilenamePattern(self, filename_pattern,
+                                     property_name, property_value):
+        """Sets a svn property for all files matching filename_pattern.
+
+        @param filename_pattern set the property for all files whose names match
+               this Unix-style filename pattern (e.g., '*.jpg')
+        @param property_name property_name to set for each file
+        @param property_value what to set the property_name to
+        """
+        all_files = os.listdir(self._directory)
+        matching_files = fnmatch.filter(all_files, filename_pattern)
+        self.SetProperty(matching_files, property_name, property_value)