##// END OF EJS Templates
dirstate: factor out code to discover normalized path...
Siddharth Agarwal -
r24538:24df9207 default
parent child Browse files
Show More
@@ -464,6 +464,32 b' 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 _discoverpath(self, path, normed, ignoremissing, exists, storemap):
468 if exists is None:
469 exists = os.path.lexists(os.path.join(self._root, path))
470 if not exists:
471 # Maybe a path component exists
472 if not ignoremissing and '/' in path:
473 d, f = path.rsplit('/', 1)
474 d = self._normalize(d, False, ignoremissing, None)
475 folded = d + "/" + f
476 else:
477 # No path components, preserve original case
478 folded = path
479 else:
480 # recursively normalize leading directory components
481 # against dirstate
482 if '/' in normed:
483 d, f = normed.rsplit('/', 1)
484 d = self._normalize(d, False, ignoremissing, True)
485 r = self._root + "/" + d
486 folded = d + "/" + util.fspath(f, r)
487 else:
488 folded = util.fspath(normed, self._root)
489 storemap[normed] = folded
490
491 return folded
492
467 def _normalize(self, path, isknown, ignoremissing=False, exists=None):
493 def _normalize(self, path, isknown, ignoremissing=False, exists=None):
468 normed = util.normcase(path)
494 normed = util.normcase(path)
469 folded = self._foldmap.get(normed, None)
495 folded = self._foldmap.get(normed, None)
@@ -471,29 +497,8 b' class dirstate(object):'
471 if isknown:
497 if isknown:
472 folded = path
498 folded = path
473 else:
499 else:
474 if exists is None:
500 folded = self._discoverpath(path, normed, ignoremissing, exists,
475 exists = os.path.lexists(os.path.join(self._root, path))
501 self._foldmap)
476 if not exists:
477 # Maybe a path component exists
478 if not ignoremissing and '/' in path:
479 d, f = path.rsplit('/', 1)
480 d = self._normalize(d, isknown, ignoremissing, None)
481 folded = d + "/" + f
482 else:
483 # No path components, preserve original case
484 folded = path
485 else:
486 # recursively normalize leading directory components
487 # against dirstate
488 if '/' in normed:
489 d, f = normed.rsplit('/', 1)
490 d = self._normalize(d, isknown, ignoremissing, True)
491 r = self._root + "/" + d
492 folded = d + "/" + util.fspath(f, r)
493 else:
494 folded = util.fspath(normed, self._root)
495 self._foldmap[normed] = folded
496
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