filectx does not need filelog; more nokwcommands kwmap-templates
authorChristian Ebert <blacktrash@gmx.net>
Fri, 29 Jun 2007 16:21:48 +0200
branchkwmap-templates
changeset 173 5329863fb64e
parent 172 ad0da655bd12
child 174 c5f655d5d8b4
filectx does not need filelog; more nokwcommands Improve docs.
hgkw/keyword.py
--- a/hgkw/keyword.py	Fri Jun 29 01:18:49 2007 +0200
+++ b/hgkw/keyword.py	Fri Jun 29 16:21:48 2007 +0200
@@ -98,8 +98,8 @@
         'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}',
         }
 
-nokwcommands = ('add', 'remove', 'addremove', 'rollback',
-                'incoming', 'outgoing', 'export', 'bundle', 'push')
+nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
+                'incoming', 'outgoing', 'push', 'remove', 'rename', 'rollback')
 
 def utcdate(date):
     '''Returns hgdate in cvs-like UTC format.'''
@@ -153,11 +153,11 @@
         keywordsub = templater.firstline(self.ui.popbuffer())
         return '$%s: %s $' % (kw, keywordsub)
 
-    def expand(self, node, flog, data):
+    def expand(self, node, data):
         '''Returns data with expanded keywords.'''
         if util.binary(data):
             return data
-        c = context.filectx(self.repo, self.path, fileid=node, filelog=flog)
+        c = context.filectx(self.repo, self.path, fileid=node)
         self.node = c.node()
         return self.re_kw.sub(self.kwsub, data)
 
@@ -184,7 +184,7 @@
 
 class kwfilelog(filelog.filelog):
     '''
-    Superclass over filelog to customize its read, add, cmp methods.
+    Subclass of filelog to hook into its read, add, cmp methods.
     Keywords are "stored" unexpanded, and expanded on reading.
     '''
     def __init__(self, opener, path, kwtemplater):
@@ -194,7 +194,7 @@
     def read(self, node):
         '''Substitutes keywords when reading filelog.'''
         data = super(kwfilelog, self).read(node)
-        return self.kwtemplater.expand(node, super(kwfilelog, self), data)
+        return self.kwtemplater.expand(node, data)
 
     def add(self, text, meta, tr, link, p1=None, p2=None):
         '''Removes keyword substitutions when adding to filelog.'''
@@ -231,10 +231,14 @@
     kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
 
     class kwrepo(repo.__class__):
+        '''
+        Subclass of repo's class attribute to wrap its file and commit methods.
+        '''
+
         def file(self, f):
+            '''Opens kwfilelog instead of filelog if needed.'''
             if f[0] == '/':
                 f = f[1:]
-            # only use kwfilelog when needed
             if kwfmatcher(f):
                 kwt = kwtemplater(repo.ui, self, path=f)
                 return kwfilelog(self.sopener, f, kwt)