diff -r c27614f2dec1 -r 854190becacb mercurial/util.py --- 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