[PATCH 7 of 7 resend] store: switch to C-based hashed path encoding

Bryan O'Sullivan bos at serpentine.com
Wed Dec 12 15:11:02 CST 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1355346577 28800
# Node ID 5d1203a09c9d873a935917102db7b93afcf50a5e
# Parent  b23eec6a55ee3292b46abdb980adf9d9096d3e1f
store: switch to C-based hashed path encoding

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -255,22 +255,17 @@ def _hybridencode(path, dotencode):
     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 _fncachevfs(scmutil.abstractvfs, s
 class fncachestore(basicstore):
     def __init__(self, path, vfstype, dotencode):
         if dotencode:
-            encode = _dothybridencode
+            encode = _pathencode
         else:
             encode = _plainhybridencode
         self.encode = encode
diff --git a/tests/test-hybridencode.py b/tests/test-hybridencode.py
--- a/tests/test-hybridencode.py
+++ b/tests/test-hybridencode.py
@@ -5,7 +5,7 @@ def show(s):
     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


More information about the Mercurial-devel mailing list