Patchwork [3,of,3,STABLE] scmutil: ignore EPERM at os.utime, which avoids ambiguity at closing

mail settings
Submitter Katsunori FUJIWARA
Date Nov. 12, 2016, 9:16 p.m.
Message ID <e0ff47999b1384e42bdc.1478985370@feefifofum>
Download mbox | patch
Permalink /patch/17526/
State Accepted
Delegated to: Yuya Nishihara
Headers show


Katsunori FUJIWARA - Nov. 12, 2016, 9:16 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <>
# Date 1478985142 -32400
#      Sun Nov 13 06:12:22 2016 +0900
# Branch stable
# Node ID e0ff47999b1384e42bdc99f5026c7e2ed5405047
# Parent  bff5ccbe5ead56aac7fff30f48a486007d469f3f
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

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, introduced by e38d85be978f
  - _playback() in, introduced by 599912a62ff6

This is a variant of issue5418.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1457,8 +1457,7 @@  class checkambigatclosing(closewrapbase)
             newstat = util.filestat(
             if newstat.isambig(oldstat):
                 # stat of changed file is ambiguous to original one
-                advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff
-                os.utime(, (advanced, advanced))
+                newstat.avoidambig(, oldstat)
     def __exit__(self, exc_type, exc_value, exc_tb):
         self._origfh.__exit__(exc_type, exc_value, exc_tb)