comparison hgext/fsmonitor/__init__.py @ 32815:15e85dded933

fsmonitor: write state with wlock held and dirstate unchanged (issue5581) This means that the state will not be written if: (1) either the wlock can't be obtained (2) something else came along and changed the dirstate while we were in the middle of a status run.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 12 Jun 2017 15:34:31 -0700
parents de09138bf0f5
children 8bb4c69c4000
comparison
equal deleted inserted replaced
32814:2083d1643d69 32815:15e85dded933
483 # first time, but whatever. 483 # first time, but whatever.
484 stateunknown = True 484 stateunknown = True
485 else: 485 else:
486 stateunknown = listunknown 486 stateunknown = listunknown
487 487
488 if updatestate:
489 ps = poststatus(startclock)
490 self.addpostdsstatus(ps)
491
488 r = orig(node1, node2, match, listignored, listclean, stateunknown, 492 r = orig(node1, node2, match, listignored, listclean, stateunknown,
489 listsubrepos) 493 listsubrepos)
490 modified, added, removed, deleted, unknown, ignored, clean = r 494 modified, added, removed, deleted, unknown, ignored, clean = r
491
492 if updatestate:
493 notefiles = modified + added + removed + deleted + unknown
494 self._fsmonitorstate.set(
495 self._fsmonitorstate.getlastclock() or startclock,
496 _hashignore(self.dirstate._ignore),
497 notefiles)
498 495
499 if not listunknown: 496 if not listunknown:
500 unknown = [] 497 unknown = []
501 498
502 # don't do paranoid checks if we're not going to query Watchman anyway 499 # don't do paranoid checks if we're not going to query Watchman anyway
525 rv2) 522 rv2)
526 modified, added, removed, deleted, unknown, ignored, clean = rv2 523 modified, added, removed, deleted, unknown, ignored, clean = rv2
527 524
528 return scmutil.status( 525 return scmutil.status(
529 modified, added, removed, deleted, unknown, ignored, clean) 526 modified, added, removed, deleted, unknown, ignored, clean)
527
528 class poststatus(object):
529 def __init__(self, startclock):
530 self._startclock = startclock
531
532 def __call__(self, wctx, status):
533 clock = wctx.repo()._fsmonitorstate.getlastclock() or self._startclock
534 hashignore = _hashignore(wctx.repo().dirstate._ignore)
535 notefiles = (status.modified + status.added + status.removed +
536 status.deleted + status.unknown)
537 wctx.repo()._fsmonitorstate.set(clock, hashignore, notefiles)
530 538
531 def makedirstate(cls): 539 def makedirstate(cls):
532 class fsmonitordirstate(cls): 540 class fsmonitordirstate(cls):
533 def _fsmonitorinit(self, fsmonitorstate, watchmanclient): 541 def _fsmonitorinit(self, fsmonitorstate, watchmanclient):
534 # _fsmonitordisable is used in paranoid mode 542 # _fsmonitordisable is used in paranoid mode