[PATCH 2 of 4] inotify: don't fall over just because of a dangling symlink
Bryan O'Sullivan
bos at serpentine.com
Wed Dec 19 18:47:21 UTC 2012
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1355880812 28800
# Node ID d1828f471b089e81496fd56beba7d040d307fb2c
# Parent c8dfa0f461967438222e919afe39ef175a5bb7f6
inotify: don't fall over just because of a dangling symlink
Previously, the inotify server failed to start if .hg/inotify.sock was
a symlink that pointed to a non-existent path. This behaviour does not
seem to make any sense.
Now, if we encounter a broken symlink, we unlink it and continue.
diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -338,8 +338,7 @@
if os.path.exists(self.sockpath):
self.realsockpath = os.readlink(self.sockpath)
else:
- raise util.Abort('inotify-server: cannot start: '
- '.hg/inotify.sock is a broken symlink')
+ os.unlink(self.sockpath)
try:
self.sock.bind(self.realsockpath)
except socket.error, err:
diff --git a/tests/test-inotify-issue1208.t b/tests/test-inotify-issue1208.t
--- a/tests/test-inotify-issue1208.t
+++ b/tests/test-inotify-issue1208.t
@@ -6,16 +6,11 @@
$ hg init $p
$ cd $p
-fail
+dangling symlink should be deleted
$ ln -sf doesnotexist .hg/inotify.sock
- $ hg st
- abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
- inotify-client: could not start inotify server: child process failed to start
- $ hg inserve
- abort: inotify-server: cannot start: .hg/inotify.sock is a broken symlink
- [255]
- $ rm .hg/inotify.sock
+ $ hg --config inotify.pidfile=../hg.pid st
+ $ kill `cat ../hg.pid`
inserve
More information about the Mercurial-devel
mailing list