##// END OF EJS Templates
fsmonitor: don't attempt state-leave if we didn't state-enter...
Wez Furlong -
r32335:35432917 default
parent child Browse files
Show More
@@ -601,6 +601,7 b' class state_update(object):'
601 601 self.distance = distance
602 602 self.partial = partial
603 603 self._lock = None
604 self.need_leave = False
604 605
605 606 def __enter__(self):
606 607 # We explicitly need to take a lock here, before we proceed to update
@@ -609,20 +610,21 b' class state_update(object):'
609 610 # immediately anyway, so this is effectively extending the lock
610 611 # around a couple of short sanity checks.
611 612 self._lock = self.repo.wlock()
612 self._state('state-enter')
613 self.need_leave = self._state('state-enter')
613 614 return self
614 615
615 616 def __exit__(self, type_, value, tb):
616 617 try:
617 status = 'ok' if type_ is None else 'failed'
618 self._state('state-leave', status=status)
618 if self.need_leave:
619 status = 'ok' if type_ is None else 'failed'
620 self._state('state-leave', status=status)
619 621 finally:
620 622 if self._lock:
621 623 self._lock.release()
622 624
623 625 def _state(self, cmd, status='ok'):
624 626 if not util.safehasattr(self.repo, '_watchmanclient'):
625 return
627 return False
626 628 try:
627 629 commithash = self.repo[self.node].hex()
628 630 self.repo._watchmanclient.command(cmd, {
@@ -637,10 +639,12 b' class state_update(object):'
637 639 # whether the working copy parent is changing
638 640 'partial': self.partial,
639 641 }})
642 return True
640 643 except Exception as e:
641 644 # Swallow any errors; fire and forget
642 645 self.repo.ui.log(
643 646 'watchman', 'Exception %s while running %s\n', e, cmd)
647 return False
644 648
645 649 # Bracket working copy updates with calls to the watchman state-enter
646 650 # and state-leave commands. This allows clients to perform more intelligent
General Comments 0
You need to be logged in to leave comments. Login now