##// END OF EJS Templates
inotify: improve error messages...
Nicolas Dumazet -
r9900:89399000 stable
parent child Browse files
Show More
@@ -27,8 +27,8 def start_server(function):
27 27 autostart = self.ui.configbool('inotify', 'autostart', True)
28 28
29 29 if err[0] == errno.ECONNREFUSED:
30 self.ui.warn(_('(found dead inotify server socket; '
31 'removing it)\n'))
30 self.ui.warn(_('inotify-client: found dead inotify server '
31 'socket; removing it\n'))
32 32 os.unlink(os.path.join(self.root, '.hg', 'inotify.sock'))
33 33 if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
34 34 self.ui.debug('(starting inotify server)\n')
@@ -41,20 +41,20 def start_server(function):
41 41 # inotify server while this one was starting.
42 42 self.ui.debug(str(inst))
43 43 except Exception, inst:
44 self.ui.warn(_('could not start inotify server: '
45 '%s\n') % inst)
44 self.ui.warn(_('inotify-client: could not start inotify '
45 'server: %s\n') % inst)
46 46 else:
47 47 try:
48 48 return function(self, *args)
49 49 except socket.error, err:
50 self.ui.warn(_('could not talk to new inotify '
51 'server: %s\n') % err[-1])
50 self.ui.warn(_('inotify-client: could not talk to new '
51 'inotify server: %s\n') % err[-1])
52 52 elif err[0] in (errno.ECONNREFUSED, errno.ENOENT):
53 53 # silently ignore normal errors if autostart is False
54 54 self.ui.debug('(inotify server not running)\n')
55 55 else:
56 self.ui.warn(_('failed to contact inotify server: %s\n')
57 % err[-1])
56 self.ui.warn(_('inotify-client: failed to contact inotify '
57 'server: %s\n') % err[-1])
58 58
59 59 self.ui.traceback()
60 60 raise QueryFailed('inotify query failed')
@@ -97,7 +97,8 class client(object):
97 97 version = ord(cs.read(1))
98 98 except TypeError:
99 99 # empty answer, assume the server crashed
100 self.ui.warn(_('received empty answer from inotify server'))
100 self.ui.warn(_('inotify-client: received empty answer from inotify '
101 'server'))
101 102 raise QueryFailed('server crashed')
102 103
103 104 if version != common.version:
@@ -691,9 +691,13 class server(pollable):
691 691 self.sock.bind(self.sockpath)
692 692 except socket.error, err:
693 693 if err[0] == errno.EADDRINUSE:
694 raise AlreadyStartedException(_('could not start server: %s')
695 % err[1])
694 raise AlreadyStartedException( _('cannot start: socket is '
695 'already bound'))
696 696 if err[0] == "AF_UNIX path too long":
697 if os.path.islink(self.sockpath) and \
698 not os.path.exists(self.sockpath):
699 raise util.Abort('inotify-server: cannot start: '
700 '.hg/inotify.sock is a broken symlink')
697 701 tempdir = tempfile.mkdtemp(prefix="hg-inotify-")
698 702 self.realsockpath = os.path.join(tempdir, "inotify.sock")
699 703 try:
@@ -706,8 +710,9 class server(pollable):
706 710 pass
707 711 os.rmdir(tempdir)
708 712 if inst.errno == errno.EEXIST:
709 raise AlreadyStartedException(_('could not start server: %s')
710 % inst.strerror)
713 raise AlreadyStartedException(_('cannot start: tried '
714 'linking .hg/inotify.sock to a temporary socket but'
715 ' .hg/inotify.sock already exists'))
711 716 raise
712 717 else:
713 718 raise
@@ -841,7 +846,7 def start(ui, dirstate, root, opts):
841 846 try:
842 847 self.master = master(ui, dirstate, root, timeout)
843 848 except AlreadyStartedException, inst:
844 raise util.Abort(str(inst))
849 raise util.Abort("inotify-server: %s" % inst)
845 850
846 851 def run(self):
847 852 try:
@@ -33,6 +33,10 cat hg.pid >> "$DAEMON_PIDS"
33 33
34 34 # let the daemon finish its stuff
35 35 sleep 1
36
37 echo % cannot start, already bound
38 hg inserve
39
36 40 # issue907
37 41 hg status
38 42 echo % clean
@@ -1,7 +1,7
1 1 % fail
2 abort: could not start server: File exists
3 could not talk to new inotify server: No such file or directory
4 abort: could not start server: File exists
2 abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
3 inotify-client: could not talk to new inotify server: No such file or directory
4 abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
5 5 % inserve
6 6 % status
7 7 ? hg.pid
@@ -10,6 +10,8 updating to branch default
10 10 8 files updated, 0 files merged, 0 files removed, 0 files unresolved
11 11 M a
12 12 % inserve
13 % cannot start, already bound
14 abort: inotify-server: cannot start: socket is already bound
13 15 ? hg.pid
14 16 % clean
15 17 C a
General Comments 0
You need to be logged in to leave comments. Login now