comparison mercurial/context.py @ 45091:6a5dcd754842

overlayworkingctx: remove unused `nofilechanges()` and `_compact()` methods Differential Revision: https://phab.mercurial-scm.org/D8733
author Manuel Jacob <me@manueljacob.de>
date Sat, 11 Jul 2020 03:17:42 +0200
parents d085fcb11c56
children 1476ec96965f
comparison
equal deleted inserted replaced
45090:0ecb3b11fcad 45091:6a5dcd754842
2525 ) 2525 )
2526 2526
2527 def isdirty(self, path): 2527 def isdirty(self, path):
2528 return path in self._cache 2528 return path in self._cache
2529 2529
2530 def nofilechanges(self):
2531 # We need to discard any keys that are actually clean before the empty
2532 # commit check.
2533 self._compact()
2534 return len(self._cache) == 0
2535
2536 def clean(self): 2530 def clean(self):
2537 self._cache = {} 2531 self._cache = {}
2538
2539 def _compact(self):
2540 """Removes keys from the cache that are actually clean, by comparing
2541 them with the underlying context.
2542
2543 This can occur during the merge process, e.g. by passing --tool :local
2544 to resolve a conflict.
2545 """
2546 keys = []
2547 # This won't be perfect, but can help performance significantly when
2548 # using things like remotefilelog.
2549 scmutil.prefetchfiles(
2550 self.repo(),
2551 [
2552 (
2553 self.p1().rev(),
2554 scmutil.matchfiles(self.repo(), self._cache.keys()),
2555 )
2556 ],
2557 )
2558
2559 for path in self._cache.keys():
2560 cache = self._cache[path]
2561 try:
2562 underlying = self._wrappedctx[path]
2563 if (
2564 underlying.data() == cache[b'data']
2565 and underlying.flags() == cache[b'flags']
2566 ):
2567 keys.append(path)
2568 except error.ManifestLookupError:
2569 # Path not in the underlying manifest (created).
2570 continue
2571
2572 for path in keys:
2573 del self._cache[path]
2574 return keys
2575 2532
2576 def _markdirty( 2533 def _markdirty(
2577 self, path, exists, data=None, date=None, flags=b'', copied=None 2534 self, path, exists, data=None, date=None, flags=b'', copied=None
2578 ): 2535 ):
2579 # data not provided, let's see if we already have some; if not, let's 2536 # data not provided, let's see if we already have some; if not, let's