changeset 17589:b11024849db6

store: parameter path of _auxencode is now a list of strings
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 16 Sep 2012 11:36:06 +0200
parents 3d789dd72316
children eb0884680f5c
files mercurial/store.py
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Sun Sep 16 11:36:00 2012 +0200
+++ b/mercurial/store.py	Sun Sep 16 11:36:06 2012 +0200
@@ -130,22 +130,23 @@
     basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux"
     doesn't need encoding.
 
-    >>> _auxencode('.foo/aux.txt/txt.aux/con/prn/nul/foo.', True)
+    >>> s = '.foo/aux.txt/txt.aux/con/prn/nul/foo.'
+    >>> _auxencode(s.split('/'), True)
     ['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e']
-    >>> _auxencode('.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.', False)
+    >>> s = '.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.'
+    >>> _auxencode(s.split('/'), False)
     ['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e']
-    >>> _auxencode('foo. ', True)
+    >>> _auxencode(['foo. '], True)
     ['foo.~20']
-    >>> _auxencode(' .foo', True)
+    >>> _auxencode([' .foo'], True)
     ['~20.foo']
     '''
-    res = path.split('/')
-    for i, n in enumerate(res):
+    for i, n in enumerate(path):
         if not n:
             continue
         if dotencode and n[0] in '. ':
             n = "~%02x" % ord(n[0]) + n[1:]
-            res[i] = n
+            path[i] = n
         else:
             l = n.find('.')
             if l == -1:
@@ -156,11 +157,11 @@
                 # encode third letter ('aux' -> 'au~78')
                 ec = "~%02x" % ord(n[2])
                 n = n[0:2] + ec + n[3:]
-                res[i] = n
+                path[i] = n
         if n[-1] in '. ':
             # encode last period or space ('foo...' -> 'foo..~2e')
-            res[i] = n[:-1] + "~%02x" % ord(n[-1])
-    return res
+            path[i] = n[:-1] + "~%02x" % ord(n[-1])
+    return path
 
 _maxstorepathlen = 120
 _dirprefixlen = 8
@@ -196,11 +197,11 @@
     The string 'data/' at the beginning is replaced with 'dh/', if the hashed
     encoding was used.
     '''
-    res = '/'.join(auxencode(encodefilename(path)))
+    res = '/'.join(auxencode(encodefilename(path).split('/')))
     if len(res) > _maxstorepathlen:
         path = encodedir(path)
         digest = _sha(path).hexdigest()
-        parts = auxencode(lowerencode(path))[1:]
+        parts = auxencode(lowerencode(path).split('/')[1:])
         basename = parts[-1]
         _root, ext = os.path.splitext(basename)
         sdirs = []