equal
deleted
inserted
replaced
1565 shutil.copymode(src, dest) |
1565 shutil.copymode(src, dest) |
1566 if oldstat and oldstat.stat: |
1566 if oldstat and oldstat.stat: |
1567 newstat = filestat.frompath(dest) |
1567 newstat = filestat.frompath(dest) |
1568 if newstat.isambig(oldstat): |
1568 if newstat.isambig(oldstat): |
1569 # stat of copied file is ambiguous to original one |
1569 # stat of copied file is ambiguous to original one |
1570 advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
1570 advanced = ( |
|
1571 oldstat.stat[stat.ST_MTIME] + 1) & 0x7fffffff |
1571 os.utime(dest, (advanced, advanced)) |
1572 os.utime(dest, (advanced, advanced)) |
1572 except shutil.Error as inst: |
1573 except shutil.Error as inst: |
1573 raise Abort(str(inst)) |
1574 raise Abort(str(inst)) |
1574 |
1575 |
1575 def copyfiles(src, dst, hardlink=None, progress=lambda t, pos: None): |
1576 def copyfiles(src, dst, hardlink=None, progress=lambda t, pos: None): |
1961 try: |
1962 try: |
1962 # if ambiguity between stat of new and old file is |
1963 # if ambiguity between stat of new and old file is |
1963 # avoided, comparison of size, ctime and mtime is enough |
1964 # avoided, comparison of size, ctime and mtime is enough |
1964 # to exactly detect change of a file regardless of platform |
1965 # to exactly detect change of a file regardless of platform |
1965 return (self.stat.st_size == old.stat.st_size and |
1966 return (self.stat.st_size == old.stat.st_size and |
1966 self.stat.st_ctime == old.stat.st_ctime and |
1967 self.stat[stat.ST_CTIME] == old.stat[stat.ST_CTIME] and |
1967 self.stat.st_mtime == old.stat.st_mtime) |
1968 self.stat[stat.ST_MTIME] == old.stat[stat.ST_MTIME]) |
1968 except AttributeError: |
1969 except AttributeError: |
1969 pass |
1970 pass |
1970 try: |
1971 try: |
1971 return self.stat is None and old.stat is None |
1972 return self.stat is None and old.stat is None |
1972 except AttributeError: |
1973 except AttributeError: |
2001 |
2002 |
2002 Advancing mtime "if isambig(oldstat)" ensures "S[n-1].mtime != |
2003 Advancing mtime "if isambig(oldstat)" ensures "S[n-1].mtime != |
2003 S[n].mtime", even if size of a file isn't changed. |
2004 S[n].mtime", even if size of a file isn't changed. |
2004 """ |
2005 """ |
2005 try: |
2006 try: |
2006 return (self.stat.st_ctime == old.stat.st_ctime) |
2007 return (self.stat[stat.ST_CTIME] == old.stat[stat.ST_CTIME]) |
2007 except AttributeError: |
2008 except AttributeError: |
2008 return False |
2009 return False |
2009 |
2010 |
2010 def avoidambig(self, path, old): |
2011 def avoidambig(self, path, old): |
2011 """Change file stat of specified path to avoid ambiguity |
2012 """Change file stat of specified path to avoid ambiguity |
2016 appropriate privileges for 'path'. This returns False in this |
2017 appropriate privileges for 'path'. This returns False in this |
2017 case. |
2018 case. |
2018 |
2019 |
2019 Otherwise, this returns True, as "ambiguity is avoided". |
2020 Otherwise, this returns True, as "ambiguity is avoided". |
2020 """ |
2021 """ |
2021 advanced = (old.stat.st_mtime + 1) & 0x7fffffff |
2022 advanced = (old.stat[stat.ST_MTIME] + 1) & 0x7fffffff |
2022 try: |
2023 try: |
2023 os.utime(path, (advanced, advanced)) |
2024 os.utime(path, (advanced, advanced)) |
2024 except OSError as inst: |
2025 except OSError as inst: |
2025 if inst.errno == errno.EPERM: |
2026 if inst.errno == errno.EPERM: |
2026 # utime() on the file created by another user causes EPERM, |
2027 # utime() on the file created by another user causes EPERM, |
2067 if oldstat and oldstat.stat: |
2068 if oldstat and oldstat.stat: |
2068 rename(self._tempname, filename) |
2069 rename(self._tempname, filename) |
2069 newstat = filestat.frompath(filename) |
2070 newstat = filestat.frompath(filename) |
2070 if newstat.isambig(oldstat): |
2071 if newstat.isambig(oldstat): |
2071 # stat of changed file is ambiguous to original one |
2072 # stat of changed file is ambiguous to original one |
2072 advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
2073 advanced = (oldstat.stat[stat.ST_MTIME] + 1) & 0x7fffffff |
2073 os.utime(filename, (advanced, advanced)) |
2074 os.utime(filename, (advanced, advanced)) |
2074 else: |
2075 else: |
2075 rename(self._tempname, filename) |
2076 rename(self._tempname, filename) |
2076 |
2077 |
2077 def discard(self): |
2078 def discard(self): |