comparison mercurial/chgserver.py @ 36781:ffa3026d4196

cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime The latter is floating point by default, and we've been doing os.stat_float_times(False). Unfortunately, os.stat_float_times was removed between Python 3.7.0a1 and 3.7.0b2, so we have to stop using it. Differential Revision: https://phab.mercurial-scm.org/D2696
author Augie Fackler <augie@google.com>
date Mon, 05 Mar 2018 12:30:20 -0500
parents 72b91f905065
children 5bc7ff103081
comparison
equal deleted inserted replaced
36780:f3c314020beb 36781:ffa3026d4196
43 import hashlib 43 import hashlib
44 import inspect 44 import inspect
45 import os 45 import os
46 import re 46 import re
47 import socket 47 import socket
48 import stat
48 import struct 49 import struct
49 import time 50 import time
50 51
51 from .i18n import _ 52 from .i18n import _
52 53
159 race conditions). We need to calculate confighash without importing. 160 race conditions). We need to calculate confighash without importing.
160 """ 161 """
161 def trystat(path): 162 def trystat(path):
162 try: 163 try:
163 st = os.stat(path) 164 st = os.stat(path)
164 return (st.st_mtime, st.st_size) 165 return (st[stat.ST_MTIME], st.st_size)
165 except OSError: 166 except OSError:
166 # could be ENOENT, EPERM etc. not fatal in any case 167 # could be ENOENT, EPERM etc. not fatal in any case
167 pass 168 pass
168 return _hashlist(map(trystat, paths))[:12] 169 return _hashlist(map(trystat, paths))[:12]
169 170
544 os.symlink(os.path.basename(self._realaddress), tempaddress) 545 os.symlink(os.path.basename(self._realaddress), tempaddress)
545 util.rename(tempaddress, self._baseaddress) 546 util.rename(tempaddress, self._baseaddress)
546 547
547 def _issocketowner(self): 548 def _issocketowner(self):
548 try: 549 try:
549 stat = os.stat(self._realaddress) 550 st = os.stat(self._realaddress)
550 return (stat.st_ino == self._socketstat.st_ino and 551 return (st.st_ino == self._socketstat.st_ino and
551 stat.st_mtime == self._socketstat.st_mtime) 552 st[stat.ST_MTIME] == self._socketstat[stat.ST_MTIME])
552 except OSError: 553 except OSError:
553 return False 554 return False
554 555
555 def unlinksocket(self, address): 556 def unlinksocket(self, address):
556 if not self._issocketowner(): 557 if not self._issocketowner():