Index: tools/svndiff.py |
=================================================================== |
--- tools/svndiff.py (revision 11593) |
+++ tools/svndiff.py (working copy) |
@@ -223,7 +223,12 @@ |
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 @@ |
# 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 @@ |
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, |
@@ -283,6 +290,7 @@ |
# Run skdiff: compare original_flattened_dir against modified_flattened_dir |
RunCommand('%s %s %s %s' % (path_to_skdiff, original_flattened_dir, |
modified_flattened_dir, diff_dir)) |
+ |
print '\nskdiff results are ready in file://%s/index.html' % diff_dir |
def RaiseUsageException(): |