diff options
author | Daniel Willmann <daniel@totalueberwachung.de> | 2008-01-07 23:45:57 +0000 |
---|---|---|
committer | Daniel Willmann <daniel@totalueberwachung.de> | 2008-01-07 23:45:57 +0000 |
commit | 1bf5c3346ac395825d49f895922a61bcdbb238e5 (patch) | |
tree | ec4dc9efef3a2abccb92bdf4312ebd80c96a40b9 /contrib/mtn2git/status.py | |
parent | 22a6de3cdd938ecd144efec7e912cb7fa20debe6 (diff) | |
parent | bb3cd6d33b47a8aa00ad8dbef0411a7721720872 (diff) |
merge of '88e2766fe8aa4c69dc8688e0554e2e6d05bb9c67'
and 'f556521018478109967b108bb830f8109aefbb0e'
Diffstat (limited to 'contrib/mtn2git/status.py')
-rw-r--r-- | contrib/mtn2git/status.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/mtn2git/status.py b/contrib/mtn2git/status.py index 47d06b51fd..bd83f85acf 100644 --- a/contrib/mtn2git/status.py +++ b/contrib/mtn2git/status.py @@ -20,7 +20,7 @@ THE SOFTWARE. """ -import pickle +import os, pickle marks = {} last_mark = 0 @@ -39,9 +39,16 @@ def load(status_name): def store(status_name): global marks, last_mark, mark_file, former_heads, same_revisions - file = open(status_name, "wb") + file = open("%s.tmp-foo" % status_name, "wb") pickle.dump(marks, file) pickle.dump(last_mark, file) pickle.dump(former_heads, file) pickle.dump(same_revisions, file) file.close() + + # Almost atomic rename, without the risk to destroy something + try: + os.remove(status_name) + except: + pass + os.rename("%s.tmp-foo" % status_name, status_name) |