# HG changeset patch # User Matt Mackall # Date 2007-12-28 05:55:40 # Node ID 2a54e2b177b6a4a143ac618c98c585cab6bc6e78 # Parent 6c8df073c3eee782aae14c8e388b05e5a10f41af bisect: use proper locking when updating bisect.state diff --git a/hgext/hbisect.py b/hgext/hbisect.py --- a/hgext/hbisect.py +++ b/hgext/hbisect.py @@ -132,10 +132,15 @@ the problem-free state "bad" and the pro state['skip'].append(node) # save state - f = repo.opener("bisect.state", "w") - for kind in state: - for node in state[kind]: - f.write("%s %s\n" % (kind, hg.hex(node))) + f = repo.opener("bisect.state", "w", atomictemp=True) + wlock = repo.wlock() + try: + for kind in state: + for node in state[kind]: + f.write("%s %s\n" % (kind, hg.hex(node))) + f.rename() + finally: + del wlock if not state['good'] or not state['bad']: return