comparison mercurial/scmutil.py @ 13962:8b252e826c68

add: introduce a warning message for non-portable filenames (issue2756) (BC) On POSIX platforms, the 'add', 'addremove', 'copy' and 'rename' commands now warn if a file has a name that can't be checked out on Windows. Example: $ hg add con.xml warning: filename contains 'con', which is reserved on Windows: 'con.xml' $ hg status A con.xml The file is added despite the warning. The warning is ON by default. It can be suppressed by setting the config option 'portablefilenames' in section 'ui' to 'ignore' or 'false': $ hg --config ui.portablefilenames=ignore add con.xml $ hg sta A con.xml If ui.portablefilenames is set to 'abort', then the command is aborted: $ hg --config ui.portablefilenames=abort add con.xml abort: filename contains 'con', which is reserved on Windows: 'con.xml' On Windows, the ui.portablefilenames config setting is irrelevant and the command is always aborted if a problematic filename is found.
author Adrian Buehlmann <adrian@cadifra.com>
date Tue, 19 Apr 2011 12:42:53 +0200
parents
children d13913355390
comparison
equal deleted inserted replaced
13961:1708a0cad774 13962:8b252e826c68
1 # scmutil.py - Mercurial core utility functions
2 #
3 # Copyright Matt Mackall <mpm@selenic.com>
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7
8 from i18n import _
9 import util, error
10 import os
11
12 def checkportable(ui, f):
13 '''Check if filename f is portable and warn or abort depending on config'''
14 util.checkfilename(f)
15 val = ui.config('ui', 'portablefilenames', 'warn')
16 lval = val.lower()
17 abort = os.name == 'nt' or lval == 'abort'
18 bval = util.parsebool(val)
19 if abort or lval == 'warn' or bval:
20 msg = util.checkwinfilename(f)
21 if msg:
22 if abort:
23 raise util.Abort("%s: %r" % (msg, f))
24 ui.warn(_("warning: %s: %r\n") % (msg, f))
25 elif bval is None and lval != 'ignore':
26 raise error.ConfigError(
27 _("ui.portablefilenames value is invalid ('%s')") % val)