Show More
@@ -17,19 +17,37 b' def checkfilename(f):' | |||
|
17 | 17 | def checkportable(ui, f): |
|
18 | 18 | '''Check if filename f is portable and warn or abort depending on config''' |
|
19 | 19 | checkfilename(f) |
|
20 | val = ui.config('ui', 'portablefilenames', 'warn') | |
|
21 | lval = val.lower() | |
|
22 | abort = os.name == 'nt' or lval == 'abort' | |
|
23 | bval = util.parsebool(val) | |
|
24 | if abort or lval == 'warn' or bval: | |
|
20 | if showportabilityalert(ui): | |
|
25 | 21 | msg = util.checkwinfilename(f) |
|
26 | 22 | if msg: |
|
27 | if abort: | |
|
28 | raise util.Abort("%s: %r" % (msg, f)) | |
|
29 | ui.warn(_("warning: %s: %r\n") % (msg, f)) | |
|
30 | elif bval is None and lval != 'ignore': | |
|
23 | portabilityalert(ui, "%s: %r" % (msg, f)) | |
|
24 | ||
|
25 | def checkportabilityalert(ui): | |
|
26 | '''check if the user's config requests nothing, a warning, or abort for | |
|
27 | non-portable filenames''' | |
|
28 | val = ui.config('ui', 'portablefilenames', 'warn') | |
|
29 | lval = val.lower() | |
|
30 | bval = util.parsebool(val) | |
|
31 | abort = os.name == 'nt' or lval == 'abort' | |
|
32 | warn = bval or lval == 'warn' | |
|
33 | if bval is None and not (warn or abort or lval == 'ignore'): | |
|
31 | 34 | raise error.ConfigError( |
|
32 | 35 | _("ui.portablefilenames value is invalid ('%s')") % val) |
|
36 | return abort, warn | |
|
37 | ||
|
38 | def showportabilityalert(ui): | |
|
39 | '''check if the user wants any notification of portability problems''' | |
|
40 | abort, warn = checkportabilityalert(ui) | |
|
41 | return abort or warn | |
|
42 | ||
|
43 | def portabilityalert(ui, msg): | |
|
44 | if not msg: | |
|
45 | return | |
|
46 | abort, warn = checkportabilityalert(ui) | |
|
47 | if abort: | |
|
48 | raise util.Abort("%s" % msg) | |
|
49 | elif warn: | |
|
50 | ui.warn(_("warning: %s\n") % msg) | |
|
33 | 51 | |
|
34 | 52 | class path_auditor(object): |
|
35 | 53 | '''ensure that a filesystem path contains no banned components. |
General Comments 0
You need to be logged in to leave comments.
Login now