Show More
@@ -432,7 +432,8 b' class dirstate(object):' | |||||
432 | self._map = {} |
|
432 | self._map = {} | |
433 | self._copymap = {} |
|
433 | self._copymap = {} | |
434 | # ignore HG_PENDING because identity is used only for writing |
|
434 | # ignore HG_PENDING because identity is used only for writing | |
435 |
self._identity = util.filestat( |
|
435 | self._identity = util.filestat.frompath( | |
|
436 | self._opener.join(self._filename)) | |||
436 | try: |
|
437 | try: | |
437 | fp = self._opendirstatefile() |
|
438 | fp = self._opendirstatefile() | |
438 | try: |
|
439 | try: |
@@ -1098,7 +1098,7 b' def copyfile(src, dest, hardlink=False, ' | |||||
1098 | oldstat = None |
|
1098 | oldstat = None | |
1099 | if os.path.lexists(dest): |
|
1099 | if os.path.lexists(dest): | |
1100 | if checkambig: |
|
1100 | if checkambig: | |
1101 | oldstat = checkambig and filestat(dest) |
|
1101 | oldstat = checkambig and filestat.frompath(dest) | |
1102 | unlink(dest) |
|
1102 | unlink(dest) | |
1103 | if hardlink: |
|
1103 | if hardlink: | |
1104 | # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks |
|
1104 | # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks | |
@@ -1128,7 +1128,7 b' def copyfile(src, dest, hardlink=False, ' | |||||
1128 | else: |
|
1128 | else: | |
1129 | shutil.copymode(src, dest) |
|
1129 | shutil.copymode(src, dest) | |
1130 | if oldstat and oldstat.stat: |
|
1130 | if oldstat and oldstat.stat: | |
1131 | newstat = filestat(dest) |
|
1131 | newstat = filestat.frompath(dest) | |
1132 | if newstat.isambig(oldstat): |
|
1132 | if newstat.isambig(oldstat): | |
1133 | # stat of copied file is ambiguous to original one |
|
1133 | # stat of copied file is ambiguous to original one | |
1134 | advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
|
1134 | advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff | |
@@ -1506,13 +1506,18 b' class filestat(object):' | |||||
1506 | exists. Otherwise, it is None. This can avoid preparative |
|
1506 | exists. Otherwise, it is None. This can avoid preparative | |
1507 | 'exists()' examination on client side of this class. |
|
1507 | 'exists()' examination on client side of this class. | |
1508 | """ |
|
1508 | """ | |
1509 |
def __init__(self, |
|
1509 | def __init__(self, stat): | |
|
1510 | self.stat = stat | |||
|
1511 | ||||
|
1512 | @classmethod | |||
|
1513 | def frompath(cls, path): | |||
1510 | try: |
|
1514 | try: | |
1511 |
|
|
1515 | stat = os.stat(path) | |
1512 | except OSError as err: |
|
1516 | except OSError as err: | |
1513 | if err.errno != errno.ENOENT: |
|
1517 | if err.errno != errno.ENOENT: | |
1514 | raise |
|
1518 | raise | |
1515 |
|
|
1519 | stat = None | |
|
1520 | return cls(stat) | |||
1516 |
|
1521 | |||
1517 | __hash__ = object.__hash__ |
|
1522 | __hash__ = object.__hash__ | |
1518 |
|
1523 | |||
@@ -1622,10 +1627,10 b' class atomictempfile(object):' | |||||
1622 | if not self._fp.closed: |
|
1627 | if not self._fp.closed: | |
1623 | self._fp.close() |
|
1628 | self._fp.close() | |
1624 | filename = localpath(self.__name) |
|
1629 | filename = localpath(self.__name) | |
1625 | oldstat = self._checkambig and filestat(filename) |
|
1630 | oldstat = self._checkambig and filestat.frompath(filename) | |
1626 | if oldstat and oldstat.stat: |
|
1631 | if oldstat and oldstat.stat: | |
1627 | rename(self._tempname, filename) |
|
1632 | rename(self._tempname, filename) | |
1628 | newstat = filestat(filename) |
|
1633 | newstat = filestat.frompath(filename) | |
1629 | if newstat.isambig(oldstat): |
|
1634 | if newstat.isambig(oldstat): | |
1630 | # stat of changed file is ambiguous to original one |
|
1635 | # stat of changed file is ambiguous to original one | |
1631 | advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
|
1636 | advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
@@ -176,11 +176,11 b' class abstractvfs(object):' | |||||
176 | """ |
|
176 | """ | |
177 | srcpath = self.join(src) |
|
177 | srcpath = self.join(src) | |
178 | dstpath = self.join(dst) |
|
178 | dstpath = self.join(dst) | |
179 | oldstat = checkambig and util.filestat(dstpath) |
|
179 | oldstat = checkambig and util.filestat.frompath(dstpath) | |
180 | if oldstat and oldstat.stat: |
|
180 | if oldstat and oldstat.stat: | |
181 | def dorename(spath, dpath): |
|
181 | def dorename(spath, dpath): | |
182 | ret = util.rename(spath, dpath) |
|
182 | ret = util.rename(spath, dpath) | |
183 | newstat = util.filestat(dpath) |
|
183 | newstat = util.filestat.frompath(dpath) | |
184 | if newstat.isambig(oldstat): |
|
184 | if newstat.isambig(oldstat): | |
185 | # stat of renamed file is ambiguous to original one |
|
185 | # stat of renamed file is ambiguous to original one | |
186 | return ret, newstat.avoidambig(dpath, oldstat) |
|
186 | return ret, newstat.avoidambig(dpath, oldstat) | |
@@ -625,12 +625,12 b' class checkambigatclosing(closewrapbase)' | |||||
625 | """ |
|
625 | """ | |
626 | def __init__(self, fh): |
|
626 | def __init__(self, fh): | |
627 | super(checkambigatclosing, self).__init__(fh) |
|
627 | super(checkambigatclosing, self).__init__(fh) | |
628 | object.__setattr__(self, r'_oldstat', util.filestat(fh.name)) |
|
628 | object.__setattr__(self, r'_oldstat', util.filestat.frompath(fh.name)) | |
629 |
|
629 | |||
630 | def _checkambig(self): |
|
630 | def _checkambig(self): | |
631 | oldstat = self._oldstat |
|
631 | oldstat = self._oldstat | |
632 | if oldstat.stat: |
|
632 | if oldstat.stat: | |
633 | newstat = util.filestat(self._origfh.name) |
|
633 | newstat = util.filestat.frompath(self._origfh.name) | |
634 | if newstat.isambig(oldstat): |
|
634 | if newstat.isambig(oldstat): | |
635 | # stat of changed file is ambiguous to original one |
|
635 | # stat of changed file is ambiguous to original one | |
636 | newstat.avoidambig(self._origfh.name, oldstat) |
|
636 | newstat.avoidambig(self._origfh.name, oldstat) |
General Comments 0
You need to be logged in to leave comments.
Login now