[PATCH 2 of 2] test-hybridencode: use store._dothybridencode(s)

Adrian Buehlmann adrian at cadifra.com
Wed Sep 19 04:41:32 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1348047558 -7200
# Node ID 558e5d6ca341e692ea0641e202515a4aaca8eb6a
# Parent  7762639e511c36a4bff4954b8989200e3f2ce683
test-hybridencode: use store._dothybridencode(s)

and compare it with the result of store._hybridencode(s, True)

diff --git a/tests/test-hybridencode.py b/tests/test-hybridencode.py
--- a/tests/test-hybridencode.py
+++ b/tests/test-hybridencode.py
@@ -1,22 +1,17 @@
-from mercurial import parsers, store
-
-hybridencode = lambda f: store._hybridencode(f, True)
-
-pathencode = getattr(parsers, 'pathencode', None)
-def pencode(f):
-    pe = pathencode(f)
-    if pe is None:
-        return store._hashencode(store.encodedir(f), True)
-    return pe
+from mercurial import store
 
 def show(s):
+    # show test input
     print "A = '%s'" % 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")
+
+    # show the result of the C implementation, if available
+    h = store._dothybridencode(s)
+    print "B = '%s'" % h.encode("string_escape")
+
+    # compare it with reference implementation in Python
+    r = store._hybridencode(s, True)
+    if h != r:
+        print "R = '%s'" % r.encode("string_escape")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")


More information about the Mercurial-devel mailing list