# HG changeset patch # User Bryan O'Sullivan # Date 1355346577 28800 # Node ID 8c019d2fd7c03f073f7b879ccb87f3e2891bce8a # Parent 3807ec0c6bbaeac7a27ea9105204291ba2acb368 store: switch to C-based hashed path encoding diff -r 3807ec0c6bba -r 8c019d2fd7c0 mercurial/store.py --- a/mercurial/store.py Wed Dec 12 13:09:36 2012 -0800 +++ b/mercurial/store.py Wed Dec 12 13:09:37 2012 -0800 @@ -255,22 +255,17 @@ return res def _pathencode(path): + de = encodedir(path) if len(path) > _maxstorepathlen: - return None - ef = _encodefname(encodedir(path)).split('/') + return _hashencode(de, True) + ef = _encodefname(de).split('/') res = '/'.join(_auxencode(ef, True)) if len(res) > _maxstorepathlen: - return None + return _hashencode(de, True) return res _pathencode = getattr(parsers, 'pathencode', _pathencode) -def _dothybridencode(f): - ef = _pathencode(f) - if ef is None: - return _hashencode(encodedir(f), True) - return ef - def _plainhybridencode(f): return _hybridencode(f, False) @@ -456,7 +451,7 @@ class fncachestore(basicstore): def __init__(self, path, vfstype, dotencode): if dotencode: - encode = _dothybridencode + encode = _pathencode else: encode = _plainhybridencode self.encode = encode diff -r 3807ec0c6bba -r 8c019d2fd7c0 tests/test-hybridencode.py --- a/tests/test-hybridencode.py Wed Dec 12 13:09:36 2012 -0800 +++ b/tests/test-hybridencode.py Wed Dec 12 13:09:37 2012 -0800 @@ -5,7 +5,7 @@ print "A = '%s'" % s.encode("string_escape") # show the result of the C implementation, if available - h = store._dothybridencode(s) + h = store._pathencode(s) print "B = '%s'" % h.encode("string_escape") # compare it with reference implementation in Python diff -r 3807ec0c6bba -r 8c019d2fd7c0 tests/test-pathencode.py --- a/tests/test-pathencode.py Wed Dec 12 13:09:36 2012 -0800 +++ b/tests/test-pathencode.py Wed Dec 12 13:09:37 2012 -0800 @@ -154,7 +154,7 @@ def runtests(rng, seed, count): nerrs = 0 for p in genpath(rng, count): - h = store._dothybridencode(p) # uses C implementation, if available + h = store._pathencode(p) # uses C implementation, if available r = store._hybridencode(p, True) # reference implementation in Python if h != r: if nerrs == 0: