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

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 12, 2012, 9:11 p.m.
Message ID <5d1203a09c9d873a9359.1355346662@australite.local>
Download mbox | patch
Permalink /patch/75/
State Accepted
Commit 8c019d2fd7c03f073f7b879ccb87f3e2891bce8a
Delegated to: Matt Mackall
Headers show

Comments

Bryan O'Sullivan - Dec. 12, 2012, 9:11 p.m.
# 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

Patch

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