Bug 1258916 part 3 - Skip rather than throw when replacing a file with an identical one. r=dbaron draft
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 24 Mar 2016 09:48:05 +0800
changeset 350724 5a7da2a77c7188620b153adf38a90c0c8fabe0ba
parent 350723 f66bac4e7a794c68a630d84c1cf30751f2b0eea0
child 350725 36b6484806b42a44a80ed7a395856507cb924876
push id15401
push userxquan@mozilla.com
push dateThu, 14 Apr 2016 07:33:24 +0000
reviewersdbaron
bugs1258916
milestone48.0a1
Bug 1258916 part 3 - Skip rather than throw when replacing a file with an identical one. r=dbaron MozReview-Commit-ID: DJi5NzYlTQw
layout/reftests/w3c-css/import-tests.py
--- a/layout/reftests/w3c-css/import-tests.py
+++ b/layout/reftests/w3c-css/import-tests.py
@@ -2,16 +2,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 import os
 from optparse import OptionParser
 from subprocess import Popen, PIPE
 import xml.dom.minidom
 import html5lib
+import filecmp
 import shutil
 import sys
 import re
 
 # FIXME:
 #   * Import more tests rather than just the very limited set currently
 #     chosen.
 #   * Read in a (checked-in) input file with a list of test assertions
@@ -130,16 +131,19 @@ def copy_file(test, srcfile, destname, i
     logname = srcfile[len(gSrcPath):]
     gLog.write("Importing " + to_unix_path_sep(logname) +
                " to " + to_unix_path_sep(destname) + "\n")
     destfile = os.path.join(gDestPath, destname)
     destdir = os.path.dirname(destfile)
     if not os.path.exists(destdir):
         os.makedirs(destdir)
     if os.path.exists(destfile):
+        if filecmp.cmp(srcfile, destfile):
+            print "Warning: duplicate file {}".format(destname)
+            return
         raise StandardError("file " + destfile + " already exists")
     copy_and_prefix(test, srcfile, destfile, gPrefixedProperties, isSupportFile)
 
 def copy_support_files(test, dirname, spec):
     if dirname in support_dirs_mapped:
         return
     support_dirs_mapped.add(dirname)
     support_dir = os.path.join(dirname, "support")