shrink-revlog: use util.mktempcopy() to preserve mode of index file.
authorGreg Ward <greg-hg@gerg.ca>
Thu, 03 Jun 2010 10:18:33 -0400
changeset 11294 7b5d05e0fb1e
parent 11293 0e5ce2325795
child 11295 07e425d63dbd
shrink-revlog: use util.mktempcopy() to preserve mode of index file. (There's still a chmod() call to manually preserve the mode of the data file.)
contrib/shrink-revlog.py
--- a/contrib/shrink-revlog.py	Sat Jun 05 09:58:02 2010 -0500
+++ b/contrib/shrink-revlog.py	Thu Jun 03 10:18:33 2010 -0400
@@ -190,10 +190,7 @@
 
     ui.write(_('shrinking %s\n') % indexfn)
     prefix = os.path.basename(indexfn)[:-1]
-    (tmpfd, tmpindexfn) = tempfile.mkstemp(dir=os.path.dirname(indexfn),
-                                           prefix=prefix,
-                                           suffix='.i')
-    os.close(tmpfd)
+    tmpindexfn = util.mktempcopy(indexfn, emptyok=True)
 
     r1 = revlog.revlog(util.opener(os.getcwd(), audit=False), indexfn)
     r2 = revlog.revlog(util.opener(os.getcwd(), audit=False), tmpindexfn)
@@ -255,9 +252,6 @@
             util.os_link(indexfn, oldindexfn)
             ignoremissing(util.os_link)(datafn, olddatafn)
 
-            # mkstemp() creates files only readable by the owner
-            os.chmod(tmpindexfn, os.stat(indexfn).st_mode)
-
             # rename
             util.rename(tmpindexfn, indexfn)
             try: