wwread and wwrite methods for expansion in working dir kwmap-templates
authorChristian Ebert <blacktrash@gmx.net>
Sat, 14 Jul 2007 20:28:45 +0200
branchkwmap-templates
changeset 177 261a6844145e
parent 176 3aed363c9eaf
child 178 4a27c306c6a2
wwread and wwrite methods for expansion in working dir
hgkw/keyword.py
--- a/hgkw/keyword.py	Fri Jul 13 12:57:59 2007 +0200
+++ b/hgkw/keyword.py	Sat Jul 14 20:28:45 2007 +0200
@@ -167,17 +167,18 @@
             return text
         return self.re_kw.sub(r'$\1$', text)
 
-    def overwrite(self, candidates):
+    def overwrite(self, candidates, mn):
         '''Overwrites candidates in working dir expanding keywords.'''
         files = []
+        m = self.repo.manifest.read(mn)
         for f in candidates:
-            data = self.repo.wfile(f).read()
+            data = self.repo.wread(f)
             if not util.binary(data):
                 self.path = f
                 data, kwct = self.re_kw.subn(self.kwsub, data)
                 if kwct:
                     self.ui.debug(_('overwriting %s expanding keywords\n') % f)
-                    self.repo.wfile(f, 'w').write(data)
+                    self.repo.wwrite(f, data, m.flags(f))
                     files.append(f)
         if files:
             self.repo.dirstate.update(files, 'n')
@@ -271,13 +272,13 @@
                 if node is None:
                     return node
 
-                candidates = self.changelog.read(node)[3]
-                candidates = [f for f in candidates if kwfmatcher(f)
+                cl = self.changelog.read(node)
+                candidates = [f for f in cl[3] if kwfmatcher(f)
                               and f not in removed
                               and not os.path.islink(self.wjoin(f))]
                 if candidates:
                     kwt = kwtemplater(ui, self, node=node)
-                    kwt.overwrite(candidates)
+                    kwt.overwrite(candidates, cl[0])
 
                 return node
             finally: