tests: run test-hybridencode.py over both Python and C encoders
authorBryan O'Sullivan <bryano@fb.com>
Tue, 18 Sep 2012 16:09:02 -0700
changeset 17617 4038071af82a
parent 17616 9535a0dc41f2
child 17618 7840d81a80ec
tests: run test-hybridencode.py over both Python and C encoders This ensures that the two always give the same answers.
tests/test-hybridencode.py
--- a/tests/test-hybridencode.py	Tue Sep 18 15:42:19 2012 -0700
+++ b/tests/test-hybridencode.py	Tue Sep 18 16:09:02 2012 -0700
@@ -1,12 +1,22 @@
-from mercurial import store
+from mercurial import parsers, store
 
 hybridencode = lambda f: store._hybridencode(f, True)
 
-enc = hybridencode # used for 'dotencode' repo format
+pathencode = getattr(parsers, 'pathencode', None)
+def pencode(f):
+    pe = pathencode(f)
+    if pe is None:
+        return store._hashencode(store.encodedir(f), True)
+    return pe
 
 def show(s):
     print "A = '%s'" % s.encode("string_escape")
-    print "B = '%s'" % enc(s).encode("string_escape")
+    he = hybridencode(s)
+    print "B = '%s'" % he.encode("string_escape")
+    if pathencode:
+        pe = pencode(s)
+        if pe != he:
+            print "N = '%s'" % pe.encode("string_escape")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")
@@ -450,4 +460,3 @@
           'VWXYZ-1234567890-xxxxxxxxx-xxxxxxxxx-xxxxxxxx-xxxx'
           'xxxxx-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwww'
           'wwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww')
-