equal
deleted
inserted
replaced
1 from mercurial import parsers, store |
1 from mercurial import store |
2 |
|
3 hybridencode = lambda f: store._hybridencode(f, True) |
|
4 |
|
5 pathencode = getattr(parsers, 'pathencode', None) |
|
6 def pencode(f): |
|
7 pe = pathencode(f) |
|
8 if pe is None: |
|
9 return store._hashencode(store.encodedir(f), True) |
|
10 return pe |
|
11 |
2 |
12 def show(s): |
3 def show(s): |
|
4 # show test input |
13 print "A = '%s'" % s.encode("string_escape") |
5 print "A = '%s'" % s.encode("string_escape") |
14 he = hybridencode(s) |
6 |
15 print "B = '%s'" % he.encode("string_escape") |
7 # show the result of the C implementation, if available |
16 if pathencode: |
8 h = store._dothybridencode(s) |
17 pe = pencode(s) |
9 print "B = '%s'" % h.encode("string_escape") |
18 if pe != he: |
10 |
19 print "N = '%s'" % pe.encode("string_escape") |
11 # compare it with reference implementation in Python |
|
12 r = store._hybridencode(s, True) |
|
13 if h != r: |
|
14 print "R = '%s'" % r.encode("string_escape") |
20 print |
15 print |
21 |
16 |
22 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}") |
17 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}") |
23 |
18 |
24 print "uppercase char X is encoded as _x" |
19 print "uppercase char X is encoded as _x" |