rebaseline.py: set text mimetype for all .json files, so text diffs work
BUG=https://code.google.com/p/skia/issues/detail?id=1442
R=fmalita@google.com
Review URL: https://codereview.chromium.org/20017009
git-svn-id: http://skia.googlecode.com/svn/trunk@10311 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/rebaseline.py b/tools/rebaseline.py
index 2c9898f..5e83b83 100755
--- a/tools/rebaseline.py
+++ b/tools/rebaseline.py
@@ -17,6 +17,7 @@
import argparse
import os
import re
+import subprocess
import sys
import urllib2
@@ -147,6 +148,13 @@
self._exception_handler = exception_handler
self._add_new = add_new
self._image_filename_re = re.compile(gm_json.IMAGE_FILENAME_PATTERN)
+ self._using_svn = os.path.isdir(os.path.join(expectations_root, '.svn'))
+
+ # Executes subprocess.call(cmd).
+ # Raises an Exception if the command fails.
+ def _Call(self, cmd):
+ if subprocess.call(cmd) != 0:
+ raise _InternalException('error running command: ' + ' '.join(cmd))
# Returns the full contents of filepath, as a single string.
# If filepath looks like a URL, try to read it that way instead of as
@@ -254,6 +262,11 @@
# Write out updated expectations.
gm_json.WriteToFile(expectations_dict, expectations_json_filepath)
+ # Mark the JSON file as plaintext, so text-style diffs can be applied.
+ # Fixes https://code.google.com/p/skia/issues/detail?id=1442
+ if self._using_svn:
+ self._Call(['svn', 'propset', '--quiet', 'svn:mime-type',
+ 'text/x-json', expectations_json_filepath])
# main...