[PATCH] keyword: postpone manifest calculation in kwtemplater.overwrite

Christian Ebert blacktrash at gmx.net
Tue Jun 15 10:18:24 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1276614931 -7200
# Node ID 27ae53321cd66d0b70c882412e5b159d7881fd03
# Parent  938fefb57db50cfdb4576fba0a4135def2b0abf0
keyword: postpone manifest calculation in kwtemplater.overwrite

We can check for file existence in the working directory (needed
in case of recording) by simply using the given context and
calculate the manifest only when there are in fact candidates
for expansion/shrinking.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -191,12 +191,12 @@
 
     def overwrite(self, ctx, candidates, iswctx, expand):
         '''Overwrites selected files expanding/shrinking keywords.'''
-        mf = ctx.manifest()
         if self.record:
-            candidates = [f for f in ctx.files() if f in mf]
+            candidates = [f for f in ctx.files() if f in ctx]
         candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
         if candidates:
             self.restrict = True        # do not expand when reading
+            mf = ctx.manifest()
             msg = (expand and _('overwriting %s expanding keywords\n')
                    or _('overwriting %s shrinking keywords\n'))
             for f in candidates:


More information about the Mercurial-devel mailing list