scmutil: ignore EPERM at os.utime, which avoids ambiguity at closing stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 13 Nov 2016 06:12:22 +0900
branchstable
changeset 30321 e0ff47999b13
parent 30320 bff5ccbe5ead
child 30417 854190becacb
child 30419 819f96b82fa4
scmutil: ignore EPERM at os.utime, which avoids ambiguity at closing According to POSIX specification, just having group write access to a file causes EPERM at invocation of os.utime() with an explicit time information (e.g. working on the repository shared by group access permission). To ignore EPERM at closing file object in such case, this patch makes checkambigatclosing._checkambig() use filestat.avoidambig() introduced by previous patch. Some functions below imply this code path at truncation of an existing (= might be owned by another user) file. - strip() in repair.py, introduced by e38d85be978f - _playback() in transaction.py, introduced by 599912a62ff6 This is a variant of issue5418.
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Sun Nov 13 06:11:56 2016 +0900
+++ b/mercurial/scmutil.py	Sun Nov 13 06:12:22 2016 +0900
@@ -1457,8 +1457,7 @@
             newstat = util.filestat(self._origfh.name)
             if newstat.isambig(oldstat):
                 # stat of changed file is ambiguous to original one
-                advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff
-                os.utime(self._origfh.name, (advanced, advanced))
+                newstat.avoidambig(self._origfh.name, oldstat)
 
     def __exit__(self, exc_type, exc_value, exc_tb):
         self._origfh.__exit__(exc_type, exc_value, exc_tb)