aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-24 15:38:39 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-24 15:38:39 +0000
commit27e1c0070d29c36a59f4cdf323ef9a4fcd88d7e2 (patch)
tree274a8ca20891b5f65a30fce7017e3deafa5a5768 /tools
parent1c25e5a3aaeccd7d75dea0b0348885fe3a68a336 (diff)
rebaseline.py: set text mimetype for all .json files, so text diffs work
Diffstat (limited to 'tools')
-rwxr-xr-xtools/rebaseline.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/rebaseline.py b/tools/rebaseline.py
index 2c9898ff80..5e83b8378d 100755
--- a/tools/rebaseline.py
+++ b/tools/rebaseline.py
@@ -17,6 +17,7 @@ TODO(epoger): Fix indentation in this file (2-space indents, not 4-space).
import argparse
import os
import re
+import subprocess
import sys
import urllib2
@@ -147,6 +148,13 @@ class JsonRebaseliner(object):
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 @@ class JsonRebaseliner(object):
# 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...