diff mercurial/cmdutil.py @ 27391:4eeef1b2d689

merge with stable
author Matt Mackall <mpm@selenic.com>
date Wed, 16 Dec 2015 17:40:01 -0600
parents 43c00ca887d1 d9e3ebe56970
children c84a07530040
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Dec 15 07:57:04 2015 +0000
+++ b/mercurial/cmdutil.py	Wed Dec 16 17:40:01 2015 -0600
@@ -7,7 +7,7 @@
 
 from node import hex, bin, nullid, nullrev, short
 from i18n import _
-import os, sys, errno, re, tempfile, cStringIO, shutil
+import os, sys, errno, re, tempfile, cStringIO
 import util, scmutil, templater, patch, error, templatekw, revlog, copies
 import match as matchmod
 import repair, graphmod, revset, phases, obsolete, pathutil
@@ -167,8 +167,7 @@
                                                dir=backupdir)
                 os.close(fd)
                 ui.debug('backup %r as %r\n' % (f, tmpname))
-                util.copyfile(repo.wjoin(f), tmpname)
-                shutil.copystat(repo.wjoin(f), tmpname)
+                util.copyfile(repo.wjoin(f), tmpname, copystat=True)
                 backups[f] = tmpname
 
             fp = cStringIO.StringIO()
@@ -217,15 +216,12 @@
                         # to be treated as unmodified
                         dirstate.normallookup(realname)
 
-                    util.copyfile(tmpname, repo.wjoin(realname))
-                    # Our calls to copystat() here and above are a
-                    # hack to trick any editors that have f open that
-                    # we haven't modified them.
+                    # copystat=True here and above are a hack to trick any
+                    # editors that have f open that we haven't modified them.
                     #
-                    # Also note that this racy as an editor could
-                    # notice the file's mtime before we've finished
-                    # writing it.
-                    shutil.copystat(tmpname, repo.wjoin(realname))
+                    # Also note that this racy as an editor could notice the
+                    # file's mtime before we've finished writing it.
+                    util.copyfile(tmpname, repo.wjoin(realname), copystat=True)
                     os.unlink(tmpname)
                 if tobackup:
                     os.rmdir(backupdir)