# HG changeset patch # User Adrian Buehlmann # Date 2012-09-18 09:44:16 # Node ID cc58dc47cb5ea2e737e9c095191f22a8b400cdca # Parent 318fb32b980e9974bb7202e7b0f49a1456d338f8 store: use fast C implementation of encodedir() if it's available For a netbeans clone on Windows 7 x64: Encoding all paths in the fncache: Before: $ hg perffncacheencode ! wall 3.639000 comb 3.634823 user 3.634823 sys 0.000000 (best of 3) After: $ hg perffncacheencode ! wall 3.470000 comb 3.463222 user 3.463222 sys 0.000000 (best of 3) Writing fncache: Before: $ hg perffncachewrite ! wall 0.103000 comb 0.093601 user 0.093601 sys 0.000000 (best of 95) After: $ hg perffncachewrite ! wall 0.081000 comb 0.078001 user 0.062400 sys 0.015600 (best of 100) diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -6,22 +6,22 @@ # GNU General Public License version 2 or any later version. from i18n import _ -import osutil, scmutil, util +import osutil, scmutil, util, parsers import os, stat, errno _sha = util.sha1 # This avoids a collision between a file named foo and a dir named # foo.i or foo.d -def encodedir(path): +def _encodedir(path): ''' - >>> encodedir('data/foo.i') + >>> _encodedir('data/foo.i') 'data/foo.i' - >>> encodedir('data/foo.i/bla.i') + >>> _encodedir('data/foo.i/bla.i') 'data/foo.i.hg/bla.i' - >>> encodedir('data/foo.i.hg/bla.i') + >>> _encodedir('data/foo.i.hg/bla.i') 'data/foo.i.hg.hg/bla.i' - >>> encodedir('data/foo.i\\ndata/foo.i/bla.i\\ndata/foo.i.hg/bla.i\\n') + >>> _encodedir('data/foo.i\\ndata/foo.i/bla.i\\ndata/foo.i.hg/bla.i\\n') 'data/foo.i\\ndata/foo.i.hg/bla.i\\ndata/foo.i.hg.hg/bla.i\\n' ''' return (path @@ -29,6 +29,8 @@ def encodedir(path): .replace(".i/", ".i.hg/") .replace(".d/", ".d.hg/")) +encodedir = getattr(parsers, 'encodedir', _encodedir) + def decodedir(path): ''' >>> decodedir('data/foo.i')