[PATCH 3 of 5 v5] tests: run test-hybridencode.py over both Python and C encoders

Bryan O'Sullivan bos at serpentine.com
Mon Sep 10 15:35:00 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1347309263 25200
# Node ID bcdd253d7a435e625ce7879e6d01f66f68c52d7d
# Parent  16373c8d5e1d3bba4383184993c8382362c2db47
tests: run test-hybridencode.py over both Python and C encoders

This ensures that the two always give the same answers.

diff --git a/tests/test-hybridencode.py b/tests/test-hybridencode.py
--- a/tests/test-hybridencode.py
+++ b/tests/test-hybridencode.py
@@ -1,13 +1,23 @@
-from mercurial import store
+from mercurial import store, parsers
 
 auxencode = lambda f: store._auxencode(f, True)
 hybridencode = lambda f: store._hybridencode(f, auxencode)
 
-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), auxencode)
+    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 !#%&'()+,-.;=[]^`{}")
@@ -424,4 +434,3 @@
           'VWXYZ-1234567890-xxxxxxxxx-xxxxxxxxx-xxxxxxxx-xxxx'
           'xxxxx-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwww'
           'wwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww')
-


More information about the Mercurial-devel mailing list