[PATCH 1 of 2 STABLE] keyword: preserve file mode when overwriting
Christian Ebert
blacktrash at gmx.net
Wed Aug 31 05:31:39 CDT 2011
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1314786419 -7200
# Node ID bb7bae89a25576ed97549cb32095b9c997e08179
# Parent 6ab8b17adc03c423b53fb50951058915edc4ca60
keyword: preserve file mode when overwriting
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -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:
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -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 at example.com>'
adding c
+ $ ls -l c | cut -b 1-10
+ -rw-------
force expansion
More information about the Mercurial-devel
mailing list