Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 21990:48e32c2c499b stable
context: call normal on the right object
dirstate.normal is the method that marks files as unchanged/normal.
Rev 20a30cd41d21 started caching dirstate.normal in order to improve
performance. However, there was an error in the patch: taking the wlock, under
some conditions depending on platform, can cause a new dirstate object to be
created. Caching dirstate.normal before calling wlock would then cause the
fixup calls below to be on the old dirstate object, effectively disappearing
into the ether.
On Unix and Unix-like OSes, the condition under which we create a new dirstate
object is 'the dirstate file has been modified since the last time we opened
it'. This happens pretty rarely, so the object is usually the same -- there's
little impact.
On Windows, the condition is 'always'. This means files in the lookup state are
never marked normal, so the bug has a serious performance impact since all the
files in the lookup state are re-read every time hg status is run.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 01 Aug 2014 18:30:18 -0700 |
parents | 3178e4989202 |
children | 6be1e1dbe6a0 17011b36aac7 |
comparison
equal
deleted
inserted
replaced
21975:8cab8a5006a5 | 21990:48e32c2c499b |
---|---|
1339 # update dirstate for files that are actually clean | 1339 # update dirstate for files that are actually clean |
1340 if fixup: | 1340 if fixup: |
1341 try: | 1341 try: |
1342 # updating the dirstate is optional | 1342 # updating the dirstate is optional |
1343 # so we don't wait on the lock | 1343 # so we don't wait on the lock |
1344 # wlock can invalidate the dirstate, so cache normal _after_ | |
1345 # taking the lock | |
1346 wlock = self._repo.wlock(False) | |
1344 normal = self._repo.dirstate.normal | 1347 normal = self._repo.dirstate.normal |
1345 wlock = self._repo.wlock(False) | |
1346 try: | 1348 try: |
1347 for f in fixup: | 1349 for f in fixup: |
1348 normal(f) | 1350 normal(f) |
1349 finally: | 1351 finally: |
1350 wlock.release() | 1352 wlock.release() |