diff hgext/win32text.py @ 5966:11af38a592ae

Register data filters in a localrepo instead of util - Changing data filters implementation is easier, adddatafilter() can rewrap filter after inspecting their prototype - Custom data filters really belongs to localrepo, mixing them with generic wrapper like "pipefilter" or "tempfilter" looks wrong. - util.filtertable should not be accessed from extensions
author Patrick Mezard <pmezard@gmail.com>
date Mon, 28 Jan 2008 21:39:47 +0100
parents a5fe27b83a4a
children f8ad3b76e923
line wrap: on
line diff
--- a/hgext/win32text.py	Mon Jan 28 16:35:02 2008 +0100
+++ b/hgext/win32text.py	Mon Jan 28 21:39:47 2008 +0100
@@ -62,12 +62,12 @@
         return dumbencode(s, cmd)
     return s
 
-util.filtertable.update({
+_filters = {
     'dumbdecode:': dumbdecode,
     'dumbencode:': dumbencode,
     'cleverdecode:': cleverdecode,
     'cleverencode:': cleverencode,
-    })
+    }
 
 def forbidcrlf(ui, repo, hooktype, node, **kwargs):
     halt = False
@@ -99,3 +99,10 @@
                   '[decode]\n'
                   '** = cleverdecode:\n'))
     return halt
+
+def reposetup(ui, repo):
+    if not repo.local():
+        return
+    for name, fn in _filters.iteritems():
+        repo.adddatafilter(name, fn)
+