Bug 995762 - don't evaluate diff unless it's needed; r=gps
authorMike Shal <mshal@mozilla.com>
Mon, 14 Apr 2014 13:53:20 -0400
changeset 179150 a0aa1d05d7cf680b0249c6775d40f4a798bb2483
parent 179149 9cfb2db23c7792ddfed2b295402f4a5f2d79b31c
child 179151 4cdd83fb7046762098d1e6b47c7ac0749d89b399
push id26607
push userryanvm@gmail.com
push dateFri, 18 Apr 2014 02:31:26 +0000
treeherdermozilla-central@7fe3ee0cf8be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs995762
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 995762 - don't evaluate diff unless it's needed; r=gps
python/mozbuild/mozbuild/config_status.py
python/mozbuild/mozbuild/test/test_util.py
python/mozbuild/mozbuild/util.py
--- a/python/mozbuild/mozbuild/config_status.py
+++ b/python/mozbuild/mozbuild/config_status.py
@@ -147,17 +147,17 @@ def config_status(topobjdir='.', topsrcd
     print('Reticulating splines...', file=sys.stderr)
     summary = the_backend.consume(definitions)
 
     for line in summary.summaries():
         print(line, file=sys.stderr)
 
     if options.diff:
         for path, diff in sorted(summary.file_diffs.items()):
-            print(diff)
+            print('\n'.join(diff))
 
     # Advertise Visual Studio if appropriate.
     if os.name == 'nt' and options.backend == 'RecursiveMake':
         print(VISUAL_STUDIO_ADVERTISEMENT)
 
     # Advertise Eclipse if it is appropriate.
     if MachCommandConditions.is_android(env):
         if options.backend == 'RecursiveMake':
--- a/python/mozbuild/mozbuild/test/test_util.py
+++ b/python/mozbuild/mozbuild/test/test_util.py
@@ -123,32 +123,32 @@ class TestFileAvoidWrite(unittest.TestCa
     def test_diff_update(self):
         """Diffs are produced on file update."""
 
         with MockedOpen({'file': 'old'}):
             faw = FileAvoidWrite('file', capture_diff=True)
             faw.write('new')
             faw.close()
 
-            self.assertIsInstance(faw.diff, unicode)
-            self.assertIn('-old', faw.diff)
-            self.assertIn('+new', faw.diff)
+            diff = '\n'.join(faw.diff)
+            self.assertIn('-old', diff)
+            self.assertIn('+new', diff)
 
     def test_diff_create(self):
         """Diffs are produced when files are created."""
 
         tmpdir = tempfile.mkdtemp()
         try:
             path = os.path.join(tmpdir, 'file')
             faw = FileAvoidWrite(path, capture_diff=True)
             faw.write('new')
             faw.close()
 
-            self.assertIsInstance(faw.diff, unicode)
-            self.assertIn('+new', faw.diff)
+            diff = '\n'.join(faw.diff)
+            self.assertIn('+new', diff)
         finally:
             shutil.rmtree(tmpdir)
 
 class TestResolveTargetToMake(unittest.TestCase):
     def setUp(self):
         self.topobjdir = data_path
 
     def assertResolve(self, path, expected):
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -162,18 +162,18 @@ class FileAvoidWrite(StringIO):
         with open(self.name, 'w') as file:
             file.write(buf)
 
         if self._capture_diff:
             try:
                 old_lines = old_content.splitlines() if old_content else []
                 new_lines = buf.splitlines()
 
-                self.diff = '\n'.join(difflib.unified_diff(old_lines, new_lines,
-                    self.name, self.name, n=4, lineterm=''))
+                self.diff = difflib.unified_diff(old_lines, new_lines,
+                    self.name, self.name, n=4, lineterm='')
             # FileAvoidWrite isn't unicode/bytes safe. So, files with non-ascii
             # content or opened and written in different modes may involve
             # implicit conversion and this will make Python unhappy. Since
             # diffing isn't a critical feature, we just ignore the failure.
             # This can go away once FileAvoidWrite uses io.BytesIO and
             # io.StringIO. But that will require a lot of work.
             except (UnicodeDecodeError, UnicodeEncodeError):
                 self.diff = 'Binary or non-ascii file changed: %s' % self.name