##// END OF EJS Templates
record: move copystat() hack out of util.copyfile() and into record...
Brodie Rao -
r13099:a08b49d2 default
parent child Browse files
Show More
@@ -10,7 +10,7 b''
10 10 from mercurial.i18n import gettext, _
11 11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch
12 12 from mercurial import util
13 import copy, cStringIO, errno, os, re, tempfile
13 import copy, cStringIO, errno, os, re, shutil, tempfile
14 14
15 15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
16 16
@@ -475,6 +475,7 b' def dorecord(ui, repo, commitfunc, *pats'
475 475 os.close(fd)
476 476 ui.debug('backup %r as %r\n' % (f, tmpname))
477 477 util.copyfile(repo.wjoin(f), tmpname)
478 shutil.copystat(repo.wjoin(f), tmpname)
478 479 backups[f] = tmpname
479 480
480 481 fp = cStringIO.StringIO()
@@ -521,6 +522,14 b' def dorecord(ui, repo, commitfunc, *pats'
521 522 for realname, tmpname in backups.iteritems():
522 523 ui.debug('restoring %r to %r\n' % (tmpname, realname))
523 524 util.copyfile(tmpname, repo.wjoin(realname))
525 # Our calls to copystat() here and above are a
526 # hack to trick any editors that have f open that
527 # we haven't modified them.
528 #
529 # Also note that this racy as an editor could
530 # notice the file's mtime before we've finished
531 # writing it.
532 shutil.copystat(tmpname, repo.wjoin(realname))
524 533 os.unlink(tmpname)
525 534 os.rmdir(backupdir)
526 535 except OSError:
@@ -452,7 +452,7 b' def copyfile(src, dest):'
452 452 else:
453 453 try:
454 454 shutil.copyfile(src, dest)
455 shutil.copystat(src, dest)
455 shutil.copymode(src, dest)
456 456 except shutil.Error, inst:
457 457 raise Abort(str(inst))
458 458
General Comments 0
You need to be logged in to leave comments. Login now