comparison hgext/fsmonitor/state.py @ 31215:15c998528c36

fsmonitor: remove use of repo.opener This has been deprecated, so we need to switch to the appropriate vfs apis.
author Durham Goode <durham@fb.com>
date Tue, 07 Mar 2017 12:52:00 -0800
parents 29b35dac3b1f
children 1b25c648d5b7
comparison
equal deleted inserted replaced
31214:167b69ccc62c 31215:15c998528c36
18 _version = 4 18 _version = 4
19 _versionformat = ">I" 19 _versionformat = ">I"
20 20
21 class state(object): 21 class state(object):
22 def __init__(self, repo): 22 def __init__(self, repo):
23 self._opener = repo.opener 23 self._vfs = repo.vfs
24 self._ui = repo.ui 24 self._ui = repo.ui
25 self._rootdir = pathutil.normasprefix(repo.root) 25 self._rootdir = pathutil.normasprefix(repo.root)
26 self._lastclock = None 26 self._lastclock = None
27 27
28 self.mode = self._ui.config('fsmonitor', 'mode', default='on') 28 self.mode = self._ui.config('fsmonitor', 'mode', default='on')
31 self.timeout = float(self._ui.config( 31 self.timeout = float(self._ui.config(
32 'fsmonitor', 'timeout', default='2')) 32 'fsmonitor', 'timeout', default='2'))
33 33
34 def get(self): 34 def get(self):
35 try: 35 try:
36 file = self._opener('fsmonitor.state', 'rb') 36 file = self._vfs('fsmonitor.state', 'rb')
37 except IOError as inst: 37 except IOError as inst:
38 if inst.errno != errno.ENOENT: 38 if inst.errno != errno.ENOENT:
39 raise 39 raise
40 return None, None, None 40 return None, None, None
41 41
89 if clock is None: 89 if clock is None:
90 self.invalidate() 90 self.invalidate()
91 return 91 return
92 92
93 try: 93 try:
94 file = self._opener('fsmonitor.state', 'wb', atomictemp=True) 94 file = self._vfs('fsmonitor.state', 'wb', atomictemp=True)
95 except (IOError, OSError): 95 except (IOError, OSError):
96 self._ui.warn(_("warning: unable to write out fsmonitor state\n")) 96 self._ui.warn(_("warning: unable to write out fsmonitor state\n"))
97 return 97 return
98 98
99 with file: 99 with file: