store: refactor splitting off of "data/" in _hybridencode()
authorAdrian Buehlmann <adrian@cadifra.com>
Sat, 15 Sep 2012 21:43:14 +0200
changeset 17584 61cd71dc3797
parent 17581 54c832922e85
child 17585 8ed2783f338f
store: refactor splitting off of "data/" in _hybridencode() encodefilename() already calls encodedir(). Note that encodedir() skips the encoding if the path doesn't start with "data/".
mercurial/store.py
--- a/mercurial/store.py	Mon Sep 17 21:53:50 2012 +0200
+++ b/mercurial/store.py	Sat Sep 15 21:43:14 2012 +0200
@@ -200,13 +200,11 @@
     '''
     if not path.startswith('data/'):
         return path
-    # escape directories ending with .i and .d
-    path = encodedir(path)
-    ndpath = path[len('data/'):]
-    res = 'data/' + '/'.join(auxencode(encodefilename(ndpath)))
+    res = '/'.join(auxencode(encodefilename(path)))
     if len(res) > _maxstorepathlen:
+        path = encodedir(path)
         digest = _sha(path).hexdigest()
-        parts = auxencode(lowerencode(ndpath))
+        parts = auxencode(lowerencode(path))[1:]
         _root, ext = os.path.splitext(parts[-1])
         basename = parts[-1]
         sdirs = []