# HG changeset patch # User Christian Ebert # Date 2011-09-08 18:30:25 # Node ID e4c65158b5e735a8fc62e05e3b8da7643fd700e8 # Parent 24efa83d81cb884a5598b156a9865fb90c867d0f 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 @@ class kwtemplater(object): 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 @@ Update and expand 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 ' adding c + $ ls -l c | cut -b 1-10 + -rw------- force expansion