##// END OF EJS Templates
dirstate: factor out code to discover normalized path...
Siddharth Agarwal -
r24538:24df9207 default
parent child Browse files
Show More
@@ -464,20 +464,14 class dirstate(object):
464 self._droppath(f)
464 self._droppath(f)
465 del self._map[f]
465 del self._map[f]
466
466
467 def _normalize(self, path, isknown, ignoremissing=False, exists=None):
467 def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
468 normed = util.normcase(path)
469 folded = self._foldmap.get(normed, None)
470 if folded is None:
471 if isknown:
472 folded = path
473 else:
474 if exists is None:
468 if exists is None:
475 exists = os.path.lexists(os.path.join(self._root, path))
469 exists = os.path.lexists(os.path.join(self._root, path))
476 if not exists:
470 if not exists:
477 # Maybe a path component exists
471 # Maybe a path component exists
478 if not ignoremissing and '/' in path:
472 if not ignoremissing and '/' in path:
479 d, f = path.rsplit('/', 1)
473 d, f = path.rsplit('/', 1)
480 d = self._normalize(d, isknown, ignoremissing, None)
474 d = self._normalize(d, False, ignoremissing, None)
481 folded = d + "/" + f
475 folded = d + "/" + f
482 else:
476 else:
483 # No path components, preserve original case
477 # No path components, preserve original case
@@ -487,13 +481,24 class dirstate(object):
487 # against dirstate
481 # against dirstate
488 if '/' in normed:
482 if '/' in normed:
489 d, f = normed.rsplit('/', 1)
483 d, f = normed.rsplit('/', 1)
490 d = self._normalize(d, isknown, ignoremissing, True)
484 d = self._normalize(d, False, ignoremissing, True)
491 r = self._root + "/" + d
485 r = self._root + "/" + d
492 folded = d + "/" + util.fspath(f, r)
486 folded = d + "/" + util.fspath(f, r)
493 else:
487 else:
494 folded = util.fspath(normed, self._root)
488 folded = util.fspath(normed, self._root)
495 self._foldmap[normed] = folded
489 storemap[normed] = folded
490
491 return folded
496
492
493 def _normalize(self, path, isknown, ignoremissing=False, exists=None):
494 normed = util.normcase(path)
495 folded = self._foldmap.get(normed, None)
496 if folded is None:
497 if isknown:
498 folded = path
499 else:
500 folded = self._discoverpath(path, normed, ignoremissing, exists,
501 self._foldmap)
497 return folded
502 return folded
498
503
499 def normalize(self, path, isknown=False, ignoremissing=False):
504 def normalize(self, path, isknown=False, ignoremissing=False):
General Comments 0
You need to be logged in to leave comments. Login now