##// END OF EJS Templates
scmutil: introduce casecollisionauditor...
Adrian Buehlmann -
r14138:c18204fd default
parent child Browse files
Show More
@@ -1314,14 +1314,15 b' def add(ui, repo, match, dryrun, listsub'
1314 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
1314 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
1315 names = []
1315 names = []
1316 wctx = repo[None]
1316 wctx = repo[None]
1317 existing = None
1317 cca = None
1318 if scmutil.showportabilityalert(ui):
1318 abort, warn = scmutil.checkportabilityalert(ui)
1319 existing = dict([(fn.lower(), fn) for fn in wctx])
1319 if abort or warn:
1320 cca = scmutil.casecollisionauditor(ui, abort, wctx)
1320 for f in repo.walk(match):
1321 for f in repo.walk(match):
1321 exact = match.exact(f)
1322 exact = match.exact(f)
1322 if exact or f not in repo.dirstate:
1323 if exact or f not in repo.dirstate:
1323 if existing:
1324 if cca:
1324 scmutil.checkcasecollision(ui, f, existing)
1325 cca(f)
1325 names.append(f)
1326 names.append(f)
1326 if ui.verbose or not exact:
1327 if ui.verbose or not exact:
1327 ui.status(_('adding %s\n') % match.rel(join(f)))
1328 ui.status(_('adding %s\n') % match.rel(join(f)))
@@ -17,15 +17,14 b' def checkfilename(f):'
17 def checkportable(ui, f):
17 def checkportable(ui, f):
18 '''Check if filename f is portable and warn or abort depending on config'''
18 '''Check if filename f is portable and warn or abort depending on config'''
19 checkfilename(f)
19 checkfilename(f)
20 if showportabilityalert(ui):
20 abort, warn = checkportabilityalert(ui)
21 if abort or warn:
21 msg = util.checkwinfilename(f)
22 msg = util.checkwinfilename(f)
22 if msg:
23 if msg:
23 portabilityalert(ui, "%s: %r" % (msg, f))
24 msg = "%s: %r" % (msg, f)
24
25 if abort:
25 def checkcasecollision(ui, f, files):
26 raise util.Abort(msg)
26 if f.lower() in files and files[f.lower()] != f:
27 ui.warn(_("warning: %s\n") % msg)
27 portabilityalert(ui, _('possible case-folding collision for %s') % f)
28 files[f.lower()] = f
29
28
30 def checkportabilityalert(ui):
29 def checkportabilityalert(ui):
31 '''check if the user's config requests nothing, a warning, or abort for
30 '''check if the user's config requests nothing, a warning, or abort for
@@ -40,19 +39,23 b' def checkportabilityalert(ui):'
40 _("ui.portablefilenames value is invalid ('%s')") % val)
39 _("ui.portablefilenames value is invalid ('%s')") % val)
41 return abort, warn
40 return abort, warn
42
41
43 def showportabilityalert(ui):
42 class casecollisionauditor(object):
44 '''check if the user wants any notification of portability problems'''
43 def __init__(self, ui, abort, existingiter):
45 abort, warn = checkportabilityalert(ui)
44 self._ui = ui
46 return abort or warn
45 self._abort = abort
46 self._map = {}
47 for f in existingiter:
48 self._map[f.lower()] = f
47
49
48 def portabilityalert(ui, msg):
50 def __call__(self, f):
49 if not msg:
51 fl = f.lower()
50 return
52 map = self._map
51 abort, warn = checkportabilityalert(ui)
53 if fl in map and map[fl] != f:
52 if abort:
54 msg = _('possible case-folding collision for %s') % f
53 raise util.Abort("%s" % msg)
55 if self._abort:
54 elif warn:
56 raise util.Abort(msg)
55 ui.warn(_("warning: %s\n") % msg)
57 self._ui.warn(_("warning: %s\n") % msg)
58 map[fl] = f
56
59
57 class path_auditor(object):
60 class path_auditor(object):
58 '''ensure that a filesystem path contains no banned components.
61 '''ensure that a filesystem path contains no banned components.
General Comments 0
You need to be logged in to leave comments. Login now