1429 if not self._running: |
1429 if not self._running: |
1430 fh.close() |
1430 fh.close() |
1431 return |
1431 return |
1432 |
1432 |
1433 self._queue.put(fh, block=True, timeout=None) |
1433 self._queue.put(fh, block=True, timeout=None) |
|
1434 |
|
1435 class checkambigatclosing(closewrapbase): |
|
1436 """Proxy for a file object, to avoid ambiguity of file stat |
|
1437 |
|
1438 See also util.filestat for detail about "ambiguity of file stat". |
|
1439 |
|
1440 This proxy is useful only if the target file is guarded by any |
|
1441 lock (e.g. repo.lock or repo.wlock) |
|
1442 |
|
1443 Do not instantiate outside of the vfs layer. |
|
1444 """ |
|
1445 def __init__(self, fh): |
|
1446 super(checkambigatclosing, self).__init__(fh) |
|
1447 object.__setattr__(self, '_oldstat', util.filestat(fh.name)) |
|
1448 |
|
1449 def _checkambig(self): |
|
1450 oldstat = self._oldstat |
|
1451 if oldstat.stat: |
|
1452 newstat = util.filestat(self._origfh.name) |
|
1453 if newstat.isambig(oldstat): |
|
1454 # stat of changed file is ambiguous to original one |
|
1455 advanced = (oldstat.stat.st_mtime + 1) & 0x7fffffff |
|
1456 os.utime(self._origfh.name, (advanced, advanced)) |
|
1457 |
|
1458 def __exit__(self, exc_type, exc_value, exc_tb): |
|
1459 self._origfh.__exit__(exc_type, exc_value, exc_tb) |
|
1460 self._checkambig() |
|
1461 |
|
1462 def close(self): |
|
1463 self._origfh.close() |
|
1464 self._checkambig() |