mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
dirstate: introduce a public case normalizing method
This commit is contained in:
parent
ebbe78951f
commit
c6bc26dacb
@ -362,16 +362,34 @@ class dirstate(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
self._ui.warn(_("not in dirstate: %s\n") % f)
|
self._ui.warn(_("not in dirstate: %s\n") % f)
|
||||||
|
|
||||||
def _normalize(self, path, knownpath):
|
def _normalize(self, path, isknown):
|
||||||
norm_path = os.path.normcase(path)
|
normed = os.path.normcase(path)
|
||||||
fold_path = self._foldmap.get(norm_path, None)
|
folded = self._foldmap.get(normed, None)
|
||||||
if fold_path is None:
|
if folded is None:
|
||||||
if knownpath or not os.path.lexists(os.path.join(self._root, path)):
|
if isknown or not os.path.lexists(os.path.join(self._root, path)):
|
||||||
fold_path = path
|
folded = path
|
||||||
else:
|
else:
|
||||||
fold_path = self._foldmap.setdefault(norm_path,
|
folded = self._foldmap.setdefault(normed,
|
||||||
util.fspath(path, self._root))
|
util.fspath(path, self._root))
|
||||||
return fold_path
|
return folded
|
||||||
|
|
||||||
|
def normalize(self, path, isknown=False):
|
||||||
|
'''
|
||||||
|
normalize the case of a pathname when on a casefolding filesystem
|
||||||
|
|
||||||
|
isknown specifies whether the filename came from walking the
|
||||||
|
disk, to avoid extra filesystem access
|
||||||
|
|
||||||
|
The normalized case is determined based on the following precedence:
|
||||||
|
|
||||||
|
- version of name already stored in the dirstate
|
||||||
|
- version of name stored on disk
|
||||||
|
- version provided via command arguments
|
||||||
|
'''
|
||||||
|
|
||||||
|
if self._checkcase:
|
||||||
|
return self._normalize(path, isknown)
|
||||||
|
return path
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self._map = {}
|
self._map = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user