mercurial/util.py
changeset 30417 854190becacb
parent 30395 10514a92860e
parent 30319 b496a464399c
child 30418 1156ec81f709
--- a/mercurial/util.py	Sat Nov 12 03:06:07 2016 +0000
+++ b/mercurial/util.py	Wed Nov 16 23:29:28 2016 -0500
@@ -1499,6 +1499,24 @@
         except AttributeError:
             return False
 
+    def avoidambig(self, path, old):
+        """Change file stat of specified path to avoid ambiguity
+
+        'old' should be previous filestat of 'path'.
+
+        This skips avoiding ambiguity, if a process doesn't have
+        appropriate privileges for 'path'.
+        """
+        advanced = (old.stat.st_mtime + 1) & 0x7fffffff
+        try:
+            os.utime(path, (advanced, advanced))
+        except OSError as inst:
+            if inst.errno == errno.EPERM:
+                # utime() on the file created by another user causes EPERM,
+                # if a process doesn't have appropriate privileges
+                return
+            raise
+
     def __ne__(self, other):
         return not self == other