# HG changeset patch # User Greg Ward # Date 2010-06-03 14:18:33 # Node ID 7b5d05e0fb1e9d69a545d74ccf05b463b346c895 # Parent 0e5ce2325795325e41f6df9203373d2858e88f88 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.) diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py --- a/contrib/shrink-revlog.py +++ b/contrib/shrink-revlog.py @@ -190,10 +190,7 @@ def shrink(ui, repo, **opts): 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 @@ def shrink(ui, repo, **opts): 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: