mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
tests: run test-hybridencode.py over both Python and C encoders
This ensures that the two always give the same answers.
This commit is contained in:
parent
a150198558
commit
3a8cc26af7
@ -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 @@ show('data/12345678/12345678/12345678/12345678/12345678/12345'
|
||||
'VWXYZ-1234567890-xxxxxxxxx-xxxxxxxxx-xxxxxxxx-xxxx'
|
||||
'xxxxx-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwww'
|
||||
'wwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user