comparison hgext/inotify/client.py @ 9351:206f7f4c5c2a

inotify: client: no repo use
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Mon, 29 Jun 2009 01:27:34 +0900
parents 5d8021ac0e19
children 4c041f1ee1b4
comparison
equal deleted inserted replaced
9350:b789ea382fc0 9351:206f7f4c5c2a
27 autostart = self.ui.configbool('inotify', 'autostart', True) 27 autostart = self.ui.configbool('inotify', 'autostart', True)
28 28
29 if err[0] == errno.ECONNREFUSED: 29 if err[0] == errno.ECONNREFUSED:
30 self.ui.warn(_('(found dead inotify server socket; ' 30 self.ui.warn(_('(found dead inotify server socket; '
31 'removing it)\n')) 31 'removing it)\n'))
32 os.unlink(self.repo.join('inotify.sock')) 32 os.unlink(os.path.join(self.root, '.hg', 'inotify.sock'))
33 if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart: 33 if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
34 self.ui.debug(_('(starting inotify server)\n')) 34 self.ui.debug(_('(starting inotify server)\n'))
35 try: 35 try:
36 try: 36 try:
37 server.start(self.ui, self.repo) 37 server.start(self.ui, self.dirstate, self.root)
38 except server.AlreadyStartedException, inst: 38 except server.AlreadyStartedException, inst:
39 # another process may have started its own 39 # another process may have started its own
40 # inotify server while this one was starting. 40 # inotify server while this one was starting.
41 self.ui.debug(str(inst)) 41 self.ui.debug(str(inst))
42 except Exception, inst: 42 except Exception, inst:
62 62
63 63
64 class client(object): 64 class client(object):
65 def __init__(self, ui, repo): 65 def __init__(self, ui, repo):
66 self.ui = ui 66 self.ui = ui
67 self.repo = repo 67 self.dirstate = repo.dirstate
68 self.root = repo.root
68 self.sock = socket.socket(socket.AF_UNIX) 69 self.sock = socket.socket(socket.AF_UNIX)
69 70
70 def _connect(self): 71 def _connect(self):
71 sockpath = self.repo.join('inotify.sock') 72 sockpath = os.path.join(self.root, '.hg', 'inotify.sock')
72 try: 73 try:
73 self.sock.connect(sockpath) 74 self.sock.connect(sockpath)
74 except socket.error, err: 75 except socket.error, err:
75 if err[0] == "AF_UNIX path too long": 76 if err[0] == "AF_UNIX path too long":
76 sockpath = os.readlink(sockpath) 77 sockpath = os.readlink(sockpath)