]> scripts.mit.edu Git - wizard.git/commitdiff
Don't write out file if it has no newlines.
authorEdward Z. Yang <ezyang@mit.edu>
Sat, 5 Jun 2010 19:37:35 +0000 (12:37 -0700)
committerEdward Z. Yang <ezyang@mit.edu>
Sat, 5 Jun 2010 19:37:35 +0000 (12:37 -0700)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
wizard/merge.py

diff --git a/TODO b/TODO
index fc2a0deb815e3bc69bc43a6ac373aefd87fe38c5..0846d1ed1363ba16f70486c4b55b8bb19de47e80 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,7 +4,6 @@ TODO NOW:
 
 - MediaWiki 1.9.3 and 1.6.7
 
-- If no newlines at all, DON'T CARE (don't rewrite the file again!)
 - Plugin-ify!
 - Check for improper use of os.exists() when os.lexists() was meant
 
index dea36db700a504cf6cf29fb70cd52ee0c8c26ec9..8a25380749cd6019630795f402b3eb92ce3c144f 100644 (file)
@@ -163,7 +163,7 @@ def merge(common_id, theirs_id,
         except (IOError, shell.CallError): # hack
             continue
         if theirs_nl != ours_nl:
-            if ours_nl == None:
+            if ours_nl is None:
                 logging.debug("File had no newlines, ignoring newline style")
             else:
                 logging.info("Converting our file (3) from %s to %s newlines", repr(ours_nl), repr(theirs_nl))
@@ -172,7 +172,7 @@ def merge(common_id, theirs_id,
     prepare_config() # for Wizard, this usually genericizes config files
     ours_tree = shell.eval("git", "write-tree")
     logging.info("Merge wrote virtual tree for ours: %s", ours_tree)
-    # operations on the common tree
+    # operations on the common tree (pretty duplicate with the above)
     shell.call("git", "reset", "--hard", common_id)
     for file in git_diff_text(common_id, theirs_id):
         try:
@@ -181,9 +181,12 @@ def merge(common_id, theirs_id,
         except (IOError, shell.CallError): # hack
             continue
         if theirs_nl != common_nl:
-            logging.info("Converting common file (1) from %s to %s newlines", repr(common_nl), repr(theirs_nl))
-            convert_newline(file, theirs_nl)
-            shell.eval("git", "add", file)
+            if common_nl is None:
+                logging.debug("File had no newlines, ignoring newline style")
+            else:
+                logging.info("Converting common file (1) from %s to %s newlines", repr(common_nl), repr(theirs_nl))
+                convert_newline(file, theirs_nl)
+                shell.eval("git", "add", file)
     common_tree = shell.eval("git", "write-tree")
     logging.info("Merge wrote virtual tree for common: %s", common_tree)
     # construct merge commit graph