changeset 15070:e4c65158b5e7 stable

keyword: preserve file mode when overwriting
author Christian Ebert <blacktrash@gmx.net>
date Thu, 08 Sep 2011 19:30:25 +0100
parents 24efa83d81cb
children ad6eb7d7dbca
files hgext/keyword.py tests/test-keyword.t
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Sat Aug 27 04:56:12 2011 +0900
+++ b/hgext/keyword.py	Thu Sep 08 19:30:25 2011 +0100
@@ -270,7 +270,10 @@
                 data, found = _shrinktext(data, re_kw.subn)
             if found:
                 self.ui.note(msg % f)
+                fpath = self.repo.wjoin(f)
+                mode = os.lstat(fpath).st_mode
                 self.repo.wwrite(f, data, ctx.flags(f))
+                os.chmod(fpath, mode)
                 if kwcmd:
                     self.repo.dirstate.normal(f)
                 elif self.record:
--- a/tests/test-keyword.t	Sat Aug 27 04:56:12 2011 +0900
+++ b/tests/test-keyword.t	Thu Sep 08 19:30:25 2011 +0100
@@ -270,15 +270,20 @@
   xxx $
   ignore $Id$
 
-Check whether expansion is filewise
+Check whether expansion is filewise and file mode is preserved
 
   $ echo '$Id$' > c
   $ echo 'tests for different changenodes' >> c
+  $ chmod 600 c
+  $ ls -l c | cut -b 1-10
+  -rw-------
 
 commit file c
 
   $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
   adding c
+  $ ls -l c | cut -b 1-10
+  -rw-------
 
 force expansion