changeset 878:6cee57ad9045

pickle_atomic: unbreak old hg versions hg that use rename() instead of close()
author Augie Fackler <raf@durin42.com>
date Fri, 20 Apr 2012 18:35:07 -0500
parents 2c9f4c1686fa
children 055f9254d790
files hgsubversion/svnmeta.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -19,9 +19,14 @@ def pickle_atomic(data, file_path):
     This is present because I kept corrupting my revmap by managing to hit ^C
     during the pickle of that file.
     """
-    f = hgutil.atomictempfile(file_path, createmode=0644)
+    f = hgutil.atomictempfile(file_path, 'w+b', 0644)
     pickle.dump(data, f)
-    f.close()
+    # Older versions of hg have .rename() instead of .close on
+    # atomictempfile.
+    if getattr(hgutil.atomictempfile, 'rename', False):
+        f.rename()
+    else:
+        f.close()
 
 
 class SVNMeta(object):