Show More
@@ -600,14 +600,25 b' class state_update(object):' | |||||
600 | self.node = node |
|
600 | self.node = node | |
601 | self.distance = distance |
|
601 | self.distance = distance | |
602 | self.partial = partial |
|
602 | self.partial = partial | |
|
603 | self._lock = None | |||
603 |
|
604 | |||
604 | def __enter__(self): |
|
605 | def __enter__(self): | |
|
606 | # We explicitly need to take a lock here, before we proceed to update | |||
|
607 | # watchman about the update operation, so that we don't race with | |||
|
608 | # some other actor. merge.update is going to take the wlock almost | |||
|
609 | # immediately anyway, so this is effectively extending the lock | |||
|
610 | # around a couple of short sanity checks. | |||
|
611 | self._lock = self.repo.wlock() | |||
605 | self._state('state-enter') |
|
612 | self._state('state-enter') | |
606 | return self |
|
613 | return self | |
607 |
|
614 | |||
608 | def __exit__(self, type_, value, tb): |
|
615 | def __exit__(self, type_, value, tb): | |
609 | status = 'ok' if type_ is None else 'failed' |
|
616 | try: | |
610 | self._state('state-leave', status=status) |
|
617 | status = 'ok' if type_ is None else 'failed' | |
|
618 | self._state('state-leave', status=status) | |||
|
619 | finally: | |||
|
620 | if self._lock: | |||
|
621 | self._lock.release() | |||
611 |
|
622 | |||
612 | def _state(self, cmd, status='ok'): |
|
623 | def _state(self, cmd, status='ok'): | |
613 | if not util.safehasattr(self.repo, '_watchmanclient'): |
|
624 | if not util.safehasattr(self.repo, '_watchmanclient'): |
General Comments 0
You need to be logged in to leave comments.
Login now