comparison hgext/fsmonitor/__init__.py @ 51129:1625fe807c04

py3: pass unicode strings to hasattr() throughout I guess we missed these instances because they're not covered by tests.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 13 Nov 2023 09:19:11 -0800
parents d718eddf01d9
children 493034cc3265
comparison
equal deleted inserted replaced
51124:80bda4254b84 51129:1625fe807c04
330 dirignore = util.always 330 dirignore = util.always
331 331
332 matchfn = match.matchfn 332 matchfn = match.matchfn
333 matchalways = match.always() 333 matchalways = match.always()
334 dmap = self._map 334 dmap = self._map
335 if hasattr(dmap, b'_map'): 335 if hasattr(dmap, '_map'):
336 # for better performance, directly access the inner dirstate map if the 336 # for better performance, directly access the inner dirstate map if the
337 # standard dirstate implementation is in use. 337 # standard dirstate implementation is in use.
338 dmap = dmap._map 338 dmap = dmap._map
339 339
340 has_mtime = parsers.DIRSTATE_V2_HAS_MTIME 340 has_mtime = parsers.DIRSTATE_V2_HAS_MTIME
742 742
743 743
744 def wrapdirstate(orig, self): 744 def wrapdirstate(orig, self):
745 ds = orig(self) 745 ds = orig(self)
746 # only override the dirstate when Watchman is available for the repo 746 # only override the dirstate when Watchman is available for the repo
747 if hasattr(self, b'_fsmonitorstate'): 747 if hasattr(self, '_fsmonitorstate'):
748 makedirstate(self, ds) 748 makedirstate(self, ds)
749 return ds 749 return ds
750 750
751 751
752 def extsetup(ui): 752 def extsetup(ui):
809 # effectively extending the lock around several short sanity checks. 809 # effectively extending the lock around several short sanity checks.
810 if self.oldnode is None: 810 if self.oldnode is None:
811 self.oldnode = self.repo[b'.'].node() 811 self.oldnode = self.repo[b'.'].node()
812 812
813 if self.repo.currentwlock() is None: 813 if self.repo.currentwlock() is None:
814 if hasattr(self.repo, b'wlocknostateupdate'): 814 if hasattr(self.repo, 'wlocknostateupdate'):
815 self._lock = self.repo.wlocknostateupdate() 815 self._lock = self.repo.wlocknostateupdate()
816 else: 816 else:
817 self._lock = self.repo.wlock() 817 self._lock = self.repo.wlock()
818 self.need_leave = self._state(b'state-enter', hex(self.oldnode)) 818 self.need_leave = self._state(b'state-enter', hex(self.oldnode))
819 return self 819 return self
837 self.need_leave = False 837 self.need_leave = False
838 if self._lock: 838 if self._lock:
839 self._lock.release() 839 self._lock.release()
840 840
841 def _state(self, cmd, commithash, status=b'ok'): 841 def _state(self, cmd, commithash, status=b'ok'):
842 if not hasattr(self.repo, b'_watchmanclient'): 842 if not hasattr(self.repo, '_watchmanclient'):
843 return False 843 return False
844 try: 844 try:
845 self.repo._watchmanclient.command( 845 self.repo._watchmanclient.command(
846 cmd, 846 cmd,
847 { 847 {