Mercurial > hg
changeset 17608:776240123525
store: extract functions _encodefname and _decodefname
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Tue, 18 Sep 2012 19:51:48 +0200 |
parents | cc58dc47cb5e |
children | cbc180cfd60b |
files | mercurial/store.py |
diffstat | 1 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/store.py Tue Sep 18 11:44:16 2012 +0200 +++ b/mercurial/store.py Tue Sep 18 19:51:48 2012 +0200 @@ -93,10 +93,24 @@ pass else: raise KeyError - return (lambda s: "".join([cmap[c] for c in encodedir(s)]), - lambda s: decodedir("".join(list(decode(s))))) + return (lambda s: ''.join([cmap[c] for c in s]), + lambda s: ''.join(list(decode(s)))) + +_encodefname, _decodefname = _buildencodefun() -encodefilename, decodefilename = _buildencodefun() +def encodefilename(s): + ''' + >>> encodefilename('foo.i/bar.d/bla.hg/hi:world?/HELLO') + 'foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o' + ''' + return _encodefname(encodedir(s)) + +def decodefilename(s): + ''' + >>> decodefilename('foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o') + 'foo.i/bar.d/bla.hg/hi:world?/HELLO' + ''' + return decodedir(_decodefname(s)) def _buildlowerencodefun(): '''