# HG changeset patch # User Adrian Buehlmann # Date 1302876930 -7200 # Node ID bc32bb0e909fd3389fdd8d253ca2966c1dad3233 # Parent 545091b1272415adc57139824656020e56ebb50c util: new function checkfilename checkfilename checks for restrictions on filenames imposed by Mercurial itself, irrespective of on what platform it is run. diff -r 545091b12724 -r bc32bb0e909f mercurial/dirstate.py --- a/mercurial/dirstate.py Fri Apr 15 16:15:28 2011 +0200 +++ b/mercurial/dirstate.py Fri Apr 15 16:15:30 2011 +0200 @@ -269,9 +269,7 @@ def _addpath(self, f, check=False): oldstate = self[f] if check or oldstate == "r": - if '\r' in f or '\n' in f: - raise util.Abort( - _("'\\n' and '\\r' disallowed in filenames: %r") % f) + util.checkfilename(f) if f in self._dirs: raise util.Abort(_('directory %r already in dirstate') % f) # shadows diff -r 545091b12724 -r bc32bb0e909f mercurial/util.py --- a/mercurial/util.py Fri Apr 15 16:15:28 2011 +0200 +++ b/mercurial/util.py Fri Apr 15 16:15:30 2011 +0200 @@ -493,6 +493,11 @@ return hardlink, num +def checkfilename(f): + '''Check that the filename f is an acceptable filename for a tracked file''' + if '\r' in f or '\n' in f: + raise Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) + _windows_reserved_filenames = '''con prn aux nul com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split()