changeset 21957:555f788b964b

show diff if jvmci.make generation modifies an existing file
author Doug Simon <doug.simon@oracle.com>
date Sat, 13 Jun 2015 00:25:30 +0200
parents 35affb9c707a
children ab37091f0980
files mx/mx_graal_makefile.py mxtool/mx.py
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mx/mx_graal_makefile.py	Sat Jun 13 00:22:48 2015 +0200
+++ b/mx/mx_graal_makefile.py	Sat Jun 13 00:25:30 2015 +0200
@@ -61,7 +61,7 @@
         if opts.output == None:
             print contents
         else:
-            if mx.update_file(opts.output, contents):
+            if mx.update_file(opts.output, contents, showDiff=True):
                 return 1
     return 0
 
--- a/mxtool/mx.py	Sat Jun 13 00:22:48 2015 +0200
+++ b/mxtool/mx.py	Sat Jun 13 00:25:30 2015 +0200
@@ -2591,7 +2591,7 @@
     abort('Could not download to ' + path + ' from any of the following URLs:\n\n    ' +
               '\n    '.join(urls) + '\n\nPlease use a web browser to do the download manually')
 
-def update_file(path, content):
+def update_file(path, content, showDiff=False):
     """
     Updates a file with some given content if the content differs from what's in
     the file already. The return value indicates if the file was updated.
@@ -2607,12 +2607,19 @@
             return False
 
         if existed and _opts.backup_modified:
-            shutil.move(path, path + '.orig')
+                shutil.move(path, path + '.orig')
 
         with open(path, 'wb') as f:
             f.write(content)
 
-        log(('modified ' if existed else 'created ') + path)
+        if existed:
+            log('modified ' + path)
+            if showDiff:
+                log('diff: ' + path)
+                log(''.join(difflib.unified_diff(old.splitlines(1), content.splitlines(1))))
+
+        else:
+            log('created ' + path)
         return True
     except IOError as e:
         abort('Error while writing to ' + path + ': ' + str(e))