store: use native fncache encoding function if available
authorBryan O'Sullivan <bryano@fb.com>
Tue, 18 Sep 2012 16:25:20 -0700
changeset 17618 7840d81a80ec
parent 17617 4038071af82a
child 17619 431e3e827ab0
store: use native fncache encoding function if available This currently falls back to Python for hashed encoding.
mercurial/store.py
--- a/mercurial/store.py	Tue Sep 18 16:09:02 2012 -0700
+++ b/mercurial/store.py	Tue Sep 18 16:25:20 2012 -0700
@@ -422,8 +422,16 @@
 def _plainhybridencode(f):
     return _hybridencode(f, False)
 
-def _dothybridencode(f):
-    return _hybridencode(f, True)
+_pathencode = getattr(parsers, 'pathencode', None)
+if _pathencode:
+    def _dothybridencode(f):
+        ef = _pathencode(f)
+        if ef is None:
+            return _hashencode(dotencode(f), True)
+        return ef
+else:
+    def _dothybridencode(f):
+        return _hybridencode(f, True)
 
 class fncachestore(basicstore):
     def __init__(self, path, openertype, dotencode):