[PATCH 08 of 10] store: refactor splitting off of "data/" in _hybridencode()

Adrian Buehlmann adrian at cadifra.com
Sat Sep 15 16:01:49 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1347738194 -7200
# Node ID be6fba3ba51bb4a5183da3cb08e871642dd382bc
# Parent  81a033bb29bcf70f217445984767a4886148df8f
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/".

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -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 = []


More information about the Mercurial-devel mailing list