changeset 17624:ae103510f6aa

store: add a fallback _pathencode Python function which does the equivalent of parsers.pathencode, so it can be used as a default
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 19 Sep 2012 14:00:23 +0200
parents 448e6ed7c557
children b83c18204c36
files mercurial/store.py
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Wed Sep 19 13:58:51 2012 +0200
+++ b/mercurial/store.py	Wed Sep 19 14:00:23 2012 +0200
@@ -254,20 +254,24 @@
         res = _hashencode(path, dotencode)
     return res
 
+def _pathencode(path):
+    ef = _encodefname(encodedir(path)).split('/')
+    res = '/'.join(_auxencode(ef, True))
+    if len(res) > _maxstorepathlen:
+        return None
+    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)
 
-_pathencode = getattr(parsers, 'pathencode', None)
-if _pathencode:
-    def _dothybridencode(f):
-        ef = _pathencode(f)
-        if ef is None:
-            return _hashencode(encodedir(f), True)
-        return ef
-else:
-    def _dothybridencode(f):
-        return _hybridencode(f, True)
-
 def _calcmode(path):
     try:
         # files in .hg/ will be created using this mode