update-copyright.py: Retain original file mode
authorBernhard Reutner-Fischer <aldot@gcc.gnu.org>
Mon, 30 Jan 2017 14:31:59 +0000 (15:31 +0100)
committerBernhard Reutner-Fischer <aldot@gcc.gnu.org>
Mon, 30 Jan 2017 14:31:59 +0000 (15:31 +0100)
2017-01-31  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

* update-copyright.py (Copyright.process_file): Retain original
file mode.

From-SVN: r245028

contrib/ChangeLog
contrib/update-copyright.py

index 15e74782076ab1a292d3f9cfd506ba18441e503f..87dc2337c5de77e23f56e559600a2fbbfabe8b75 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-31  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
+
+       * update-copyright.py (Copyright.process_file): Retain original
+       file mode.
+
 2017-01-29  Gerald Pfeifer  <gerald@pfeifer.com>
 
        * update-copyright.py: Fix the name of this script in examples.
index 289ce098f3f30ec4649a3a72dfc2c9b9d4ee4fad..f9852a8544f835fe3f980772d93972b77046b4db 100755 (executable)
@@ -393,8 +393,10 @@ class Copyright:
         lines = []
         changed = False
         line_filter = filter.get_line_filter (dir, filename)
+        mode = None
         with open (pathname, 'r') as file:
             prev = None
+            mode = os.fstat (file.fileno()).st_mode
             for line in file:
                 while line:
                     next_line = None
@@ -421,6 +423,7 @@ class Copyright:
             with open (tmp_pathname, 'w') as file:
                 for line in lines:
                     file.write (line)
+                os.fchmod (file.fileno(), mode)
             if self.use_quilt:
                 subprocess.call (['quilt', 'add', pathname])
             os.rename (tmp_pathname, pathname)