update-copyright.py: Retain original file mode

2017-01-31  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

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

From-SVN: r245028
This commit is contained in:
Bernhard Reutner-Fischer 2017-01-30 15:31:59 +01:00
parent 24fc4dd899
commit 357a7731e9
2 changed files with 8 additions and 0 deletions

View 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> 2017-01-29 Gerald Pfeifer <gerald@pfeifer.com>
* update-copyright.py: Fix the name of this script in examples. * update-copyright.py: Fix the name of this script in examples.

View File

@ -393,8 +393,10 @@ class Copyright:
lines = [] lines = []
changed = False changed = False
line_filter = filter.get_line_filter (dir, filename) line_filter = filter.get_line_filter (dir, filename)
mode = None
with open (pathname, 'r') as file: with open (pathname, 'r') as file:
prev = None prev = None
mode = os.fstat (file.fileno()).st_mode
for line in file: for line in file:
while line: while line:
next_line = None next_line = None
@ -421,6 +423,7 @@ class Copyright:
with open (tmp_pathname, 'w') as file: with open (tmp_pathname, 'w') as file:
for line in lines: for line in lines:
file.write (line) file.write (line)
os.fchmod (file.fileno(), mode)
if self.use_quilt: if self.use_quilt:
subprocess.call (['quilt', 'add', pathname]) subprocess.call (['quilt', 'add', pathname])
os.rename (tmp_pathname, pathname) os.rename (tmp_pathname, pathname)