Show More
@@ -10,7 +10,7 b'' | |||||
10 | from mercurial.i18n import gettext, _ |
|
10 | from mercurial.i18n import gettext, _ | |
11 | from mercurial import cmdutil, commands, extensions, hg, mdiff, patch |
|
11 | from mercurial import cmdutil, commands, extensions, hg, mdiff, patch | |
12 | from mercurial import util |
|
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 | lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') |
|
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 | os.close(fd) |
|
475 | os.close(fd) | |
476 | ui.debug('backup %r as %r\n' % (f, tmpname)) |
|
476 | ui.debug('backup %r as %r\n' % (f, tmpname)) | |
477 | util.copyfile(repo.wjoin(f), tmpname) |
|
477 | util.copyfile(repo.wjoin(f), tmpname) | |
|
478 | shutil.copystat(repo.wjoin(f), tmpname) | |||
478 | backups[f] = tmpname |
|
479 | backups[f] = tmpname | |
479 |
|
480 | |||
480 | fp = cStringIO.StringIO() |
|
481 | fp = cStringIO.StringIO() | |
@@ -521,6 +522,14 b' def dorecord(ui, repo, commitfunc, *pats' | |||||
521 | for realname, tmpname in backups.iteritems(): |
|
522 | for realname, tmpname in backups.iteritems(): | |
522 | ui.debug('restoring %r to %r\n' % (tmpname, realname)) |
|
523 | ui.debug('restoring %r to %r\n' % (tmpname, realname)) | |
523 | util.copyfile(tmpname, repo.wjoin(realname)) |
|
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 | os.unlink(tmpname) |
|
533 | os.unlink(tmpname) | |
525 | os.rmdir(backupdir) |
|
534 | os.rmdir(backupdir) | |
526 | except OSError: |
|
535 | except OSError: |
@@ -452,7 +452,7 b' def copyfile(src, dest):' | |||||
452 | else: |
|
452 | else: | |
453 | try: |
|
453 | try: | |
454 | shutil.copyfile(src, dest) |
|
454 | shutil.copyfile(src, dest) | |
455 |
shutil.copy |
|
455 | shutil.copymode(src, dest) | |
456 | except shutil.Error, inst: |
|
456 | except shutil.Error, inst: | |
457 | raise Abort(str(inst)) |
|
457 | raise Abort(str(inst)) | |
458 |
|
458 |
General Comments 0
You need to be logged in to leave comments.
Login now