hgkw/keyword.py
changeset 272 02d012b9dd56
parent 271 35f43e2ce5b6
child 273 a283665ad7cd
--- a/hgkw/keyword.py	Mon Oct 15 23:42:50 2007 +0200
+++ b/hgkw/keyword.py	Wed Oct 17 13:22:48 2007 +0200
@@ -321,17 +321,31 @@
         wlock = repo.wlock()
         lock = repo.lock()
         files, match, anypats = cmdutil.matchpats(repo, pats, opts)
+        fdict = dict.fromkeys(files)
+        fdict.pop('.', None)
         ctx = repo.changectx()
-        node = ctx.node()
         man = ctx.manifest()
-        try:
-            files = [f for src, f
-                     in repo.walk(node=node, files=files, match=match)
-                     if ui.kwfmatcher(f) and not man.linkf(f)]
-        except AttributeError:
-            _kwbailout(ui)
+        mfiles = man.keys()
+        mfiles.sort()
+        files = []
+        
+        def iskwfile(f):
+            try:
+                return ui.kwfmatcher(f) and not man.linkf(f)
+            except AttributeError:
+                _kwbailout(ui)
+
+        for f in mfiles:
+            for ff in fdict:
+                if ff == f or ff.startswith('%s/' % f):
+                    if iskwfile(ff):
+                        files.append(ff)
+                    del fdict[ff]
+                    break
+            if not f in files and match(f) and iskwfile(f):
+                files.append(f)
         if files:
-            kwt = kwtemplater(ui, repo, expand, node=node)
+            kwt = kwtemplater(ui, repo, expand, node=ctx.node())
             # 3rd argument sets commit to False
             kwt.overwrite(files, man, False)
     finally: