Show More
@@ -667,7 +667,7 b' def overridecopy(orig, ui, repo, pats, o' | |||||
667 | try: |
|
667 | try: | |
668 | origcopyfile = util.copyfile |
|
668 | origcopyfile = util.copyfile | |
669 | copiedfiles = [] |
|
669 | copiedfiles = [] | |
670 | def overridecopyfile(src, dest): |
|
670 | def overridecopyfile(src, dest, *args, **kwargs): | |
671 | if (lfutil.shortname in src and |
|
671 | if (lfutil.shortname in src and | |
672 | dest.startswith(repo.wjoin(lfutil.shortname))): |
|
672 | dest.startswith(repo.wjoin(lfutil.shortname))): | |
673 | destlfile = dest.replace(lfutil.shortname, '') |
|
673 | destlfile = dest.replace(lfutil.shortname, '') | |
@@ -675,7 +675,7 b' def overridecopy(orig, ui, repo, pats, o' | |||||
675 | raise IOError('', |
|
675 | raise IOError('', | |
676 | _('destination largefile already exists')) |
|
676 | _('destination largefile already exists')) | |
677 | copiedfiles.append((src, dest)) |
|
677 | copiedfiles.append((src, dest)) | |
678 | origcopyfile(src, dest) |
|
678 | origcopyfile(src, dest, *args, **kwargs) | |
679 |
|
679 | |||
680 | util.copyfile = overridecopyfile |
|
680 | util.copyfile = overridecopyfile | |
681 | result += orig(ui, repo, listpats, opts, rename) |
|
681 | result += orig(ui, repo, listpats, opts, rename) |
@@ -1192,7 +1192,9 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
1192 | os.rename(src, tmp) |
|
1192 | os.rename(src, tmp) | |
1193 | os.rename(tmp, target) |
|
1193 | os.rename(tmp, target) | |
1194 | else: |
|
1194 | else: | |
1195 | util.copyfile(src, target) |
|
1195 | # Preserve stat info on renames, not on copies; this matches | |
|
1196 | # Linux CLI behavior. | |||
|
1197 | util.copyfile(src, target, copystat=rename) | |||
1196 | srcexists = True |
|
1198 | srcexists = True | |
1197 | except IOError as inst: |
|
1199 | except IOError as inst: | |
1198 | if inst.errno == errno.ENOENT: |
|
1200 | if inst.errno == errno.ENOENT: |
@@ -657,3 +657,36 b' check illegal path components' | |||||
657 | [255] |
|
657 | [255] | |
658 | $ hg status -C |
|
658 | $ hg status -C | |
659 |
|
659 | |||
|
660 | check that stat information such as mtime is preserved on rename - it's unclear | |||
|
661 | whether the `touch` and `stat` commands are portable, so we mimic them using | |||
|
662 | python. Not all platforms support precision of even one-second granularity, so | |||
|
663 | we allow a rather generous fudge factor here; 1234567890 is 2009, and the | |||
|
664 | primary thing we care about is that it's not the machine's current time; | |||
|
665 | hopefully it's really unlikely for a machine to have such a broken clock that | |||
|
666 | this test fails. :) | |||
|
667 | ||||
|
668 | $ mkdir mtime | |||
|
669 | Create the file (as empty), then update its mtime and atime to be 1234567890. | |||
|
670 | >>> import os | |||
|
671 | >>> filename = "mtime/f" | |||
|
672 | >>> mtime = 1234567890 | |||
|
673 | >>> open(filename, "w").close() | |||
|
674 | >>> os.utime(filename, (mtime, mtime)) | |||
|
675 | $ hg ci -qAm 'add mtime dir' | |||
|
676 | "hg cp" does not preserve the mtime, so it should be newer than the 2009 | |||
|
677 | timestamp. | |||
|
678 | $ hg cp -q mtime mtime_cp | |||
|
679 | >>> from __future__ import print_function | |||
|
680 | >>> import os | |||
|
681 | >>> filename = "mtime_cp/f" | |||
|
682 | >>> print(os.stat(filename).st_mtime < 1234567999) | |||
|
683 | False | |||
|
684 | "hg mv" preserves the mtime, so it should be ~equal to the 2009 timestamp | |||
|
685 | (modulo some fudge factor due to not every system supporting 1s-level | |||
|
686 | precision). | |||
|
687 | $ hg mv -q mtime mtime_mv | |||
|
688 | >>> from __future__ import print_function | |||
|
689 | >>> import os | |||
|
690 | >>> filename = "mtime_mv/f" | |||
|
691 | >>> print(os.stat(filename).st_mtime < 1234567999) | |||
|
692 | True |
General Comments 0
You need to be logged in to leave comments.
Login now