[PATCH 1 of 2] Implement and test a builtin 'none:' filter

Mark Hammond mhammond at skippinet.com.au
Fri Apr 24 21:25:42 CDT 2009


# HG changeset patch
# User Mark Hammond <mhammond at skippinet.com.au>
# Date 1240625882 -36000
# Node ID 390b0842e5dd4c7d5ed9c5efcd82dbb1d29a1804
# Parent  4f13ed6ee5448cf5de72446f2b6a418e33f691da
Implement and test a builtin 'none:' filter

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -563,7 +563,9 @@
         for mf, fn, cmd in self.filterpats[filter]:
             if mf(filename):
                 self.ui.debug(_("filtering %s through %s\n") % (filename, cmd))
-                data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
+                if cmd != 'none:':
+                    data = fn(data, cmd, ui=self.ui, repo=self,
+                              filename=filename)
                 break
 
         return data
diff --git a/tests/test-win32text b/tests/test-win32text
--- a/tests/test-win32text
+++ b/tests/test-win32text
@@ -127,5 +127,30 @@
 python print.py < bin
 python print.py < f3
 python print.py < f4.bat
+
+echo "# check 'none:' encoding"
+
+python -c 'file("bin2", "wb").write("looks-like\x0Amixed line endings\x0D\x0A")'
+hg add bin2
+hg ci -m 9 -d'0 0'
+
+
+echo '[extensions]' > .hg/hgrc
+echo 'win32text = ' >> .hg/hgrc
+echo '[decode]' >> .hg/hgrc
+echo 'bin* = none:' >> .hg/hgrc
+echo '** = cleverdecode:' >> .hg/hgrc
+echo '[encode]' >> .hg/hgrc
+echo 'bin* = none:' >> .hg/hgrc
+echo '** = cleverencode:' >> .hg/hgrc
+cat .hg/hgrc
 echo
 
+rm f3 f4.bat bin bin2
+hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
+python print.py < bin
+python print.py < bin2
+python print.py < f3
+python print.py < f4.bat
+echo
+
diff --git a/tests/test-win32text.out b/tests/test-win32text.out
--- a/tests/test-win32text.out
+++ b/tests/test-win32text.out
@@ -201,4 +201,19 @@
 hello<NUL><CR><LF>
 some<LF>text<LF>
 rem empty<LF>
+# check 'none:' encoding
+[extensions]
+win32text = 
+[decode]
+bin* = none:
+** = cleverdecode:
+[encode]
+bin* = none:
+** = cleverencode:
 
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+hello<NUL><CR><LF>
+looks-like<LF>mixed line endings<CR><LF>
+some<CR><LF>text<CR><LF>
+rem empty<CR><LF>
+


More information about the Mercurial-devel mailing list