##// END OF EJS Templates
inotify: client: no repo use
Nicolas Dumazet -
r9351:206f7f4c default
parent child Browse files
Show More
@@ -25,7 +25,8 b' def serve(ui, repo, **opts):'
25 class service(object):
25 class service(object):
26 def init(self):
26 def init(self):
27 try:
27 try:
28 self.master = server.master(ui, repo, timeout)
28 self.master = server.master(ui, repo.dirstate,
29 repo.root, timeout)
29 except server.AlreadyStartedException, inst:
30 except server.AlreadyStartedException, inst:
30 raise util.Abort(str(inst))
31 raise util.Abort(str(inst))
31
32
@@ -29,12 +29,12 b' def start_server(function):'
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.
@@ -64,11 +64,12 b' def start_server(function):'
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:
@@ -807,10 +807,10 b' class server(pollable):'
807 raise
807 raise
808
808
809 class master(object):
809 class master(object):
810 def __init__(self, ui, repo, timeout=None):
810 def __init__(self, ui, dirstate, root, timeout=None):
811 self.ui = ui
811 self.ui = ui
812 self.repowatcher = repowatcher(ui, repo.dirstate, repo.root)
812 self.repowatcher = repowatcher(ui, dirstate, root)
813 self.server = server(ui, repo.root, self.repowatcher, timeout)
813 self.server = server(ui, root, self.repowatcher, timeout)
814
814
815 def shutdown(self):
815 def shutdown(self):
816 for obj in pollable.instances.itervalues():
816 for obj in pollable.instances.itervalues():
@@ -823,7 +823,7 b' class master(object):'
823 sys.exit(0)
823 sys.exit(0)
824 pollable.run()
824 pollable.run()
825
825
826 def start(ui, repo):
826 def start(ui, dirstate, root):
827 def closefds(ignore):
827 def closefds(ignore):
828 # (from python bug #1177468)
828 # (from python bug #1177468)
829 # close all inherited file descriptors
829 # close all inherited file descriptors
@@ -844,7 +844,7 b' def start(ui, repo):'
844 except OSError:
844 except OSError:
845 pass
845 pass
846
846
847 m = master(ui, repo)
847 m = master(ui, dirstate, root)
848 sys.stdout.flush()
848 sys.stdout.flush()
849 sys.stderr.flush()
849 sys.stderr.flush()
850
850
General Comments 0
You need to be logged in to leave comments. Login now