##// END OF EJS Templates
dirstate: introduce a public case normalizing method
Matt Mackall -
r13717:bc41d08a stable
parent child Browse files
Show More
@@ -362,16 +362,34 b' class dirstate(object):'
362 except KeyError:
362 except KeyError:
363 self._ui.warn(_("not in dirstate: %s\n") % f)
363 self._ui.warn(_("not in dirstate: %s\n") % f)
364
364
365 def _normalize(self, path, knownpath):
365 def _normalize(self, path, isknown):
366 norm_path = os.path.normcase(path)
366 normed = os.path.normcase(path)
367 fold_path = self._foldmap.get(norm_path, None)
367 folded = self._foldmap.get(normed, None)
368 if fold_path is None:
368 if folded is None:
369 if knownpath or not os.path.lexists(os.path.join(self._root, path)):
369 if isknown or not os.path.lexists(os.path.join(self._root, path)):
370 fold_path = path
370 folded = path
371 else:
371 else:
372 fold_path = self._foldmap.setdefault(norm_path,
372 folded = self._foldmap.setdefault(normed,
373 util.fspath(path, self._root))
373 util.fspath(path, self._root))
374 return fold_path
374 return folded
375
376 def normalize(self, path, isknown=False):
377 '''
378 normalize the case of a pathname when on a casefolding filesystem
379
380 isknown specifies whether the filename came from walking the
381 disk, to avoid extra filesystem access
382
383 The normalized case is determined based on the following precedence:
384
385 - version of name already stored in the dirstate
386 - version of name stored on disk
387 - version provided via command arguments
388 '''
389
390 if self._checkcase:
391 return self._normalize(path, isknown)
392 return path
375
393
376 def clear(self):
394 def clear(self):
377 self._map = {}
395 self._map = {}
General Comments 0
You need to be logged in to leave comments. Login now