# HG changeset patch # User Augie Fackler # Date 1224095360 18000 # Node ID d01196ca1e39295031ecda76614baed02fa17ac3 # Parent 05800c403321b3c6e9d404e1cf36b4eee4d0dc1a Fix non-atomic write of the last_revision_handled_file which was causing problems if the write got interrupted in the wrong spot. diff --git a/fetch_command.py b/fetch_command.py --- a/fetch_command.py +++ b/fetch_command.py @@ -87,8 +87,12 @@ def fetch_revisions(ui, svn_url, hg_repo else: stupid_svn_server_pull_rev(ui, svn, hg_editor, r) converted = True - open(hg_editor.last_revision_handled_file, - 'w').write(str(r.revnum)) + tmpfile = '%s_tmp' % hg_editor.last_revision_handled_file + fp = open(tmpfile, 'w') + fp.write(str(r.revnum)) + fp.close() + merc_util.rename(tmpfile, + hg_editor.last_revision_handled_file) except core.SubversionException, e: if hasattr(e, 'message') and ( 'Server sent unexpected return value (502 Bad Gateway)'