##// END OF EJS Templates
record: don't dereference symlinks while copying over stat data...
Siddharth Agarwal -
r27370:d9e3ebe5 stable
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7
7
8 from node import hex, bin, nullid, nullrev, short
8 from node import hex, bin, nullid, nullrev, short
9 from i18n import _
9 from i18n import _
10 import os, sys, errno, re, tempfile, cStringIO, shutil
10 import os, sys, errno, re, tempfile, cStringIO
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
12 import match as matchmod
12 import match as matchmod
13 import repair, graphmod, revset, phases, obsolete, pathutil
13 import repair, graphmod, revset, phases, obsolete, pathutil
@@ -166,8 +166,7 b' def dorecord(ui, repo, commitfunc, cmdsu'
166 dir=backupdir)
166 dir=backupdir)
167 os.close(fd)
167 os.close(fd)
168 ui.debug('backup %r as %r\n' % (f, tmpname))
168 ui.debug('backup %r as %r\n' % (f, tmpname))
169 util.copyfile(repo.wjoin(f), tmpname)
169 util.copyfile(repo.wjoin(f), tmpname, copystat=True)
170 shutil.copystat(repo.wjoin(f), tmpname)
171 backups[f] = tmpname
170 backups[f] = tmpname
172
171
173 fp = cStringIO.StringIO()
172 fp = cStringIO.StringIO()
@@ -216,15 +215,12 b' def dorecord(ui, repo, commitfunc, cmdsu'
216 # to be treated as unmodified
215 # to be treated as unmodified
217 dirstate.normallookup(realname)
216 dirstate.normallookup(realname)
218
217
219 util.copyfile(tmpname, repo.wjoin(realname))
218 # copystat=True here and above are a hack to trick any
220 # Our calls to copystat() here and above are a
219 # editors that have f open that we haven't modified them.
221 # hack to trick any editors that have f open that
222 # we haven't modified them.
223 #
220 #
224 # Also note that this racy as an editor could
221 # Also note that this racy as an editor could notice the
225 # notice the file's mtime before we've finished
222 # file's mtime before we've finished writing it.
226 # writing it.
223 util.copyfile(tmpname, repo.wjoin(realname), copystat=True)
227 shutil.copystat(tmpname, repo.wjoin(realname))
228 os.unlink(tmpname)
224 os.unlink(tmpname)
229 if tobackup:
225 if tobackup:
230 os.rmdir(backupdir)
226 os.rmdir(backupdir)
General Comments 0
You need to be logged in to leave comments. Login now