Merge with default stable
authorChristian Ebert <blacktrash@gmx.net>
Wed, 14 Sep 2011 15:34:32 +0100
branchstable
changeset 983 06a1ec674ee8
parent 980 d487504115fe (current diff)
parent 982 639bb4617c70 (diff)
child 985 d60568a69465
Merge with default
--- a/hgkw/keyword.py	Tue Aug 09 12:56:43 2011 +0200
+++ b/hgkw/keyword.py	Wed Sep 14 15:34:32 2011 +0100
@@ -257,7 +257,6 @@
             msg = _('overwriting %s expanding keywords\n')
         else:
             msg = _('overwriting %s shrinking keywords\n')
-        lctx = ctx
         for f in candidates:
             if self.restrict:
                 data = self.repo.file(f).read(mf[f])
@@ -267,15 +266,17 @@
                 continue
             if expand:
                 if lookup:
-                    lctx = self.linkctx(f, mf[f])
-                data, found = self.substitute(data, f, lctx, re_kw.subn)
+                    ctx = self.linkctx(f, mf[f])
+                data, found = self.substitute(data, f, ctx, re_kw.subn)
             elif self.restrict:
                 found = re_kw.search(data)
             else:
                 data, found = _shrinktext(data, re_kw.subn)
             if found:
                 self.ui.note(msg % f)
-                self.repo.wwrite(f, data, ctx.flags(f))
+                fp = self.repo.wopener(f, "wb", atomictemp=True)
+                fp.write(data)
+                fp.close()
                 if kwcmd:
                     self.repo.dirstate.normal(f)
                 elif self.record:
--- a/tests/test-keyword.t	Tue Aug 09 12:56:43 2011 +0200
+++ b/tests/test-keyword.t	Wed Sep 14 15:34:32 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
 
@@ -439,6 +444,8 @@
   r
   committed changeset 3:899491280810
   overwriting r expanding keywords
+ - status call required for dirstate.normallookup() check
+  $ hg status r
   $ hg --verbose rollback
   repository tip rolled back to revision 2 (undo commit)
   working directory now based on revision 2
@@ -829,6 +836,8 @@
   $ hg copy a x/a
   $ hg --verbose kwshrink a
   overwriting a shrinking keywords
+ - sleep required for dirstate.normal() check
+  $ sleep 1
   $ hg status a
   $ hg --verbose kwexpand a
   overwriting a expanding keywords