[PATCH 1 of 2 v2] scmutil: refactor ui.portablefilesnames processing
Adrian Buehlmann
adrian at cadifra.com
Sat Apr 30 06:16:18 CDT 2011
On 2011-04-30 12:44, Kevin Gessner wrote:
> # HG changeset patch
> # User Kevin Gessner <kevin at kevingessner.com>
> # Date 1304154504 -7200
> # Node ID d5b8f451667fe0a06ea9ff0f549b329e3406310d
> # Parent 3c616f512a5b55dfc269b7da5818df66b286c680
> scmutil: refactor ui.portablefilesnames processing
>
> The ui.portablefilenames config handling is generally useful for notifying the
> user of various portability problems.
>
> diff -r 3c616f512a5b -r d5b8f451667f mercurial/scmutil.py
> --- a/mercurial/scmutil.py Fri Apr 29 22:21:13 2011 +0300
> +++ b/mercurial/scmutil.py Sat Apr 30 11:08:24 2011 +0200
> @@ -17,16 +17,22 @@
> def checkportable(ui, f):
> '''Check if filename f is portable and warn or abort depending on config'''
> checkfilename(f)
> + msg = util.checkwinfilename(f)
> + if msg:
> + alertportable(ui, "%s: %r" % (msg, f))
> +
> +def alertportable(ui, msg):
> + if not msg:
> + return
> val = ui.config('ui', 'portablefilenames', 'warn')
> lval = val.lower()
> abort = os.name == 'nt' or lval == 'abort'
> bval = util.parsebool(val)
> - if abort or lval == 'warn' or bval:
> - msg = util.checkwinfilename(f)
> - if msg:
> - if abort:
> - raise util.Abort("%s: %r" % (msg, f))
> - ui.warn(_("warning: %s: %r\n") % (msg, f))
> + warn = bval or lval == 'warn'
> + if abort:
> + raise util.Abort("%s" % msg)
> + elif warn:
> + ui.warn(_("warning: %s\n") % msg)
> elif bval is None and lval != 'ignore':
> raise error.ConfigError(
> _("ui.portablefilenames value is invalid ('%s')") % val)
I don't care that much about this particular patch at all, but let me
just explain why I made the code as it was before this patch: I didn't
call checkwinfilename if the config option said 'ignore' or 'false'
(thus not having to pay the price of calling it in vain).
More information about the Mercurial-devel
mailing list