mercurial/posix.py
changeset 41289 593f6359681d
parent 40792 47e3f554df35
child 41504 587a3c976892
--- a/mercurial/posix.py	Wed Jan 16 16:49:15 2019 -0800
+++ b/mercurial/posix.py	Thu Jan 10 14:57:01 2019 +0100
@@ -153,7 +153,7 @@
         # Turn off all +x bits
         os.chmod(f, s & 0o666)
 
-def copymode(src, dst, mode=None):
+def copymode(src, dst, mode=None, enforcewritable=False):
     '''Copy the file mode from the file at path src to dst.
     If src doesn't exist, we're using mode instead. If mode is None, we're
     using umask.'''
@@ -166,7 +166,13 @@
         if st_mode is None:
             st_mode = ~umask
         st_mode &= 0o666
-    os.chmod(dst, st_mode)
+
+    new_mode = st_mode
+
+    if enforcewritable:
+        new_mode |= stat.S_IWUSR
+
+    os.chmod(dst, new_mode)
 
 def checkexec(path):
     """