aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-07 19:57:35 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-07 19:57:35 +0000
commit3c8d9cb8a7e78df44b2edb027085ec1647c82b61 (patch)
tree30cf8635fb577d35fa110a95e78fd71a074d679e /tools
parentc0445fec1983465a2c985a2c88e796678585d68a (diff)
Make svndiff.py work on Windows and with svn 1.7.
R=epoger@google.com Review URL: https://codereview.chromium.org/25447003 git-svn-id: http://skia.googlecode.com/svn/trunk@11642 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r--tools/svn.py4
-rwxr-xr-xtools/svndiff.py27
2 files changed, 19 insertions, 12 deletions
diff --git a/tools/svn.py b/tools/svn.py
index 72d8ad8a2a..aac89703ad 100644
--- a/tools/svn.py
+++ b/tools/svn.py
@@ -135,7 +135,7 @@ class Svn:
if status & STATUS_NOT_UNDER_SVN_CONTROL:
status_types_string += '\?'
status_regex_string = '^[%s].....\s+(.+)$' % status_types_string
- stdout = self._RunCommand([SVN, 'status'])
+ stdout = self._RunCommand([SVN, 'status']).replace('\r', '')
status_regex = re.compile(status_regex_string, re.MULTILINE)
files = status_regex.findall(stdout)
return files
@@ -179,5 +179,5 @@ class Svn:
version you wish to obtain
@param dest_path destination to which to write the base content
"""
- self._RunCommand([SVN, 'export', '--revision', 'BASE',
+ self._RunCommand([SVN, 'export', '--revision', 'BASE', '--force',
file_within_repo, dest_path])
diff --git a/tools/svndiff.py b/tools/svndiff.py
index 9e51eee22c..196eace52e 100755
--- a/tools/svndiff.py
+++ b/tools/svndiff.py
@@ -223,7 +223,12 @@ def SvnDiff(path_to_skdiff, dest_dir, source_dir):
dest_dir = os.path.abspath(dest_dir)
os.chdir(source_dir)
- using_svn = os.path.isdir('.svn')
+ svn_repo = svn.Svn('.')
+ using_svn = True
+ try:
+ svn_repo.GetInfo()
+ except:
+ using_svn = False
# Prepare temporary directories.
modified_flattened_dir = os.path.join(dest_dir, 'modified_flattened')
@@ -236,7 +241,6 @@ def SvnDiff(path_to_skdiff, dest_dir, source_dir):
# Get a list of all locally modified (including added/deleted) files,
# descending subdirectories.
if using_svn:
- svn_repo = svn.Svn('.')
modified_file_paths = svn_repo.GetFilesWithStatus(
svn.STATUS_ADDED | svn.STATUS_DELETED | svn.STATUS_MODIFIED)
else:
@@ -249,23 +253,26 @@ def SvnDiff(path_to_skdiff, dest_dir, source_dir):
if modified_file_path.endswith('.json'):
# Special handling for JSON files, in the hopes that they
# contain GM result summaries.
- (_unused, original_file_path) = tempfile.mkstemp()
+ original_file = tempfile.NamedTemporaryFile(delete = False)
+ original_file.close()
if using_svn:
svn_repo.ExportBaseVersionOfFile(
- modified_file_path, original_file_path)
+ modified_file_path, original_file.name)
else:
_GitExportBaseVersionOfFile(
- modified_file_path, original_file_path)
- platform_prefix = re.sub(os.sep, '__',
- os.path.dirname(modified_file_path)) + '__'
- _CallJsonDiff(old_json_path=original_file_path,
+ modified_file_path, original_file.name)
+ original_directory = os.path.dirname(original_file.name)
+ platform_prefix = (re.sub(re.escape(os.sep), '__',
+ os.path.splitdrive(original_directory)[1])
+ + '__')
+ _CallJsonDiff(old_json_path=original_file.name,
new_json_path=modified_file_path,
old_flattened_dir=original_flattened_dir,
new_flattened_dir=modified_flattened_dir,
filename_prefix=platform_prefix)
- os.remove(original_file_path)
+ os.remove(original_file.name)
else:
- dest_filename = re.sub(os.sep, '__', modified_file_path)
+ dest_filename = re.sub(re.escape(os.sep), '__', modified_file_path)
# If the file had STATUS_DELETED, it won't exist anymore...
if os.path.isfile(modified_file_path):
shutil.copyfile(modified_file_path,