Merge with stable

This commit is contained in:
Martin Geisler 2009-11-22 11:19:07 +01:00
commit e59875358e
5 changed files with 29 additions and 17 deletions

View File

@ -27,8 +27,8 @@ def start_server(function):
autostart = self.ui.configbool('inotify', 'autostart', True)
if err[0] == errno.ECONNREFUSED:
self.ui.warn(_('(found dead inotify server socket; '
'removing it)\n'))
self.ui.warn(_('inotify-client: found dead inotify server '
'socket; removing it\n'))
os.unlink(os.path.join(self.root, '.hg', 'inotify.sock'))
if err[0] in (errno.ECONNREFUSED, errno.ENOENT) and autostart:
self.ui.debug('(starting inotify server)\n')
@ -41,20 +41,20 @@ def start_server(function):
# inotify server while this one was starting.
self.ui.debug(str(inst))
except Exception, inst:
self.ui.warn(_('could not start inotify server: '
'%s\n') % inst)
self.ui.warn(_('inotify-client: could not start inotify '
'server: %s\n') % inst)
else:
try:
return function(self, *args)
except socket.error, err:
self.ui.warn(_('could not talk to new inotify '
'server: %s\n') % err[-1])
self.ui.warn(_('inotify-client: could not talk to new '
'inotify server: %s\n') % err[-1])
elif err[0] in (errno.ECONNREFUSED, errno.ENOENT):
# silently ignore normal errors if autostart is False
self.ui.debug('(inotify server not running)\n')
else:
self.ui.warn(_('failed to contact inotify server: %s\n')
% err[-1])
self.ui.warn(_('inotify-client: failed to contact inotify '
'server: %s\n') % err[-1])
self.ui.traceback()
raise QueryFailed('inotify query failed')
@ -97,7 +97,8 @@ class client(object):
version = ord(cs.read(1))
except TypeError:
# empty answer, assume the server crashed
self.ui.warn(_('received empty answer from inotify server'))
self.ui.warn(_('inotify-client: received empty answer from inotify '
'server'))
raise QueryFailed('server crashed')
if version != common.version:

View File

@ -691,9 +691,13 @@ class server(pollable):
self.sock.bind(self.sockpath)
except socket.error, err:
if err[0] == errno.EADDRINUSE:
raise AlreadyStartedException(_('could not start server: %s')
% err[1])
raise AlreadyStartedException( _('cannot start: socket is '
'already bound'))
if err[0] == "AF_UNIX path too long":
if os.path.islink(self.sockpath) and \
not os.path.exists(self.sockpath):
raise util.Abort('inotify-server: cannot start: '
'.hg/inotify.sock is a broken symlink')
tempdir = tempfile.mkdtemp(prefix="hg-inotify-")
self.realsockpath = os.path.join(tempdir, "inotify.sock")
try:
@ -706,8 +710,9 @@ class server(pollable):
pass
os.rmdir(tempdir)
if inst.errno == errno.EEXIST:
raise AlreadyStartedException(_('could not start server: %s')
% inst.strerror)
raise AlreadyStartedException(_('cannot start: tried '
'linking .hg/inotify.sock to a temporary socket but'
' .hg/inotify.sock already exists'))
raise
else:
raise
@ -841,7 +846,7 @@ def start(ui, dirstate, root, opts):
try:
self.master = master(ui, dirstate, root, timeout)
except AlreadyStartedException, inst:
raise util.Abort(str(inst))
raise util.Abort("inotify-server: %s" % inst)
def run(self):
try:

View File

@ -33,6 +33,10 @@ cat hg.pid >> "$DAEMON_PIDS"
# let the daemon finish its stuff
sleep 1
echo % cannot start, already bound
hg inserve
# issue907
hg status
echo % clean

View File

@ -1,7 +1,7 @@
% fail
abort: could not start server: File exists
could not talk to new inotify server: No such file or directory
abort: could not start server: File exists
abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
inotify-client: could not talk to new inotify server: No such file or directory
abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
% inserve
% status
? hg.pid

View File

@ -10,6 +10,8 @@ updating to branch default
8 files updated, 0 files merged, 0 files removed, 0 files unresolved
M a
% inserve
% cannot start, already bound
abort: inotify-server: cannot start: socket is already bound
? hg.pid
% clean
C a