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 |
|
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 | |
@@ -167,8 +167,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
167 | dir=backupdir) |
|
167 | dir=backupdir) | |
168 | os.close(fd) |
|
168 | os.close(fd) | |
169 | ui.debug('backup %r as %r\n' % (f, tmpname)) |
|
169 | ui.debug('backup %r as %r\n' % (f, tmpname)) | |
170 | util.copyfile(repo.wjoin(f), tmpname) |
|
170 | util.copyfile(repo.wjoin(f), tmpname, copystat=True) | |
171 | shutil.copystat(repo.wjoin(f), tmpname) |
|
|||
172 | backups[f] = tmpname |
|
171 | backups[f] = tmpname | |
173 |
|
172 | |||
174 | fp = cStringIO.StringIO() |
|
173 | fp = cStringIO.StringIO() | |
@@ -217,15 +216,12 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
217 | # to be treated as unmodified |
|
216 | # to be treated as unmodified | |
218 | dirstate.normallookup(realname) |
|
217 | dirstate.normallookup(realname) | |
219 |
|
218 | |||
220 | util.copyfile(tmpname, repo.wjoin(realname)) |
|
219 | # copystat=True here and above are a hack to trick any | |
221 | # Our calls to copystat() here and above are a |
|
220 | # editors that have f open that we haven't modified them. | |
222 | # hack to trick any editors that have f open that |
|
|||
223 | # we haven't modified them. |
|
|||
224 | # |
|
221 | # | |
225 | # Also note that this racy as an editor could |
|
222 | # Also note that this racy as an editor could notice the | |
226 |
# |
|
223 | # file's mtime before we've finished writing it. | |
227 | # writing it. |
|
224 | util.copyfile(tmpname, repo.wjoin(realname), copystat=True) | |
228 | shutil.copystat(tmpname, repo.wjoin(realname)) |
|
|||
229 | os.unlink(tmpname) |
|
225 | os.unlink(tmpname) | |
230 | if tobackup: |
|
226 | if tobackup: | |
231 | os.rmdir(backupdir) |
|
227 | os.rmdir(backupdir) |
@@ -990,8 +990,9 b' def checksignature(func):' | |||||
990 |
|
990 | |||
991 | return check |
|
991 | return check | |
992 |
|
992 | |||
993 | def copyfile(src, dest, hardlink=False): |
|
993 | def copyfile(src, dest, hardlink=False, copystat=False): | |
994 |
|
|
994 | '''copy a file, preserving mode and optionally other stat info like | |
|
995 | atime/mtime''' | |||
995 | if os.path.lexists(dest): |
|
996 | if os.path.lexists(dest): | |
996 | unlink(dest) |
|
997 | unlink(dest) | |
997 | # hardlinks are problematic on CIFS, quietly ignore this flag |
|
998 | # hardlinks are problematic on CIFS, quietly ignore this flag | |
@@ -1004,10 +1005,16 b' def copyfile(src, dest, hardlink=False):' | |||||
1004 | pass # fall back to normal copy |
|
1005 | pass # fall back to normal copy | |
1005 | if os.path.islink(src): |
|
1006 | if os.path.islink(src): | |
1006 | os.symlink(os.readlink(src), dest) |
|
1007 | os.symlink(os.readlink(src), dest) | |
|
1008 | # copytime is ignored for symlinks, but in general copytime isn't needed | |||
|
1009 | # for them anyway | |||
1007 | else: |
|
1010 | else: | |
1008 | try: |
|
1011 | try: | |
1009 | shutil.copyfile(src, dest) |
|
1012 | shutil.copyfile(src, dest) | |
1010 |
|
|
1013 | if copystat: | |
|
1014 | # copystat also copies mode | |||
|
1015 | shutil.copystat(src, dest) | |||
|
1016 | else: | |||
|
1017 | shutil.copymode(src, dest) | |||
1011 | except shutil.Error as inst: |
|
1018 | except shutil.Error as inst: | |
1012 | raise Abort(str(inst)) |
|
1019 | raise Abort(str(inst)) | |
1013 |
|
1020 |
General Comments 0
You need to be logged in to leave comments.
Login now