Commits

Anonymous committed aa5826d

+2 patches on messages

Comments (0)

Files changed (4)

+# HG changeset patch
+# User Nicolas Dumazet <nicdumz.commits@gmail.com>
+# Date 1258596361 -32400
+inotify: prefix error messages by inotify-(client|server)
+
+make sure that all warning and abort messages use the same format.
+
+diff --git a/hgext/inotify/client.py b/hgext/inotify/client.py
+--- a/hgext/inotify/client.py
++++ b/hgext/inotify/client.py
+@@ -27,8 +27,8 @@
+             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 @@
+                         # 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,18 +97,19 @@
+             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:
+-            self.ui.warn(_('(inotify: received response from incompatible '
+-                      'server version %d)\n') % version)
++            self.ui.warn(_('inotify-client: received response from incompatible'
++                      ' inotify server version %d)\n') % version)
+             raise QueryFailed('incompatible server version')
+ 
+         readtype = cs.read(4)
+         if readtype != type:
+-            self.ui.warn(_('(inotify: received \'%s\' response when expecting'
+-                       ' \'%s\')\n') % (readtype, type))
++            self.ui.warn(_('inotify-client: received \'%s\' response when '
++                           'expecting \'%s\'\n') % (readtype, type))
+             raise QueryFailed('wrong response type')
+ 
+         hdrfmt = common.resphdrfmts[type]
+diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
+--- a/hgext/inotify/server.py
++++ b/hgext/inotify/server.py
+@@ -691,8 +691,8 @@
+             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":
+                 tempdir = tempfile.mkdtemp(prefix="hg-inotify-")
+                 self.realsockpath = os.path.join(tempdir, "inotify.sock")
+@@ -706,8 +706,9 @@
+                         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 +842,7 @@
+             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:
+diff --git a/tests/test-inotify-issue1208.out b/tests/test-inotify-issue1208.out
+--- a/tests/test-inotify-issue1208.out
++++ b/tests/test-inotify-issue1208.out
+@@ -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: tried linking .hg/inotify.sock to a temporary socket but .hg/inotify.sock already exists
++inotify-client: could not talk to new inotify server: No such file or directory
++abort: inotify-server: cannot start: tried linking .hg/inotify.sock to a temporary socket but .hg/inotify.sock already exists
+ % inserve
+ % status
+ ? hg.pid

inotify-wronglstat

+# HG changeset patch
+# User Nicolas Dumazet <nicdumz.commits@gmail.com>
+# Date 1258596338 -32400
+
+diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
+--- a/hgext/inotify/server.py
++++ b/hgext/inotify/server.py
+@@ -17,6 +17,12 @@
+ except ImportError:
+     raise
+ 
++f = open("/home/nicdumz/inotify.log", "a")
++def log(msg):
++    print >> f, msg
++    f.flush()
++
++
+ class AlreadyStartedException(Exception): pass
+ 
+ def join(a, b):
+@@ -440,6 +446,8 @@
+         # - None : fn is new
+         # - a char in statuskeys: fn is a (tracked) file
+ 
++        log(_('status: %r %s -> %s') %
++                         (wfn, oldstatus, newstatus))
+         if self.ui.debugflag and oldstatus != newstatus:
+             self.ui.note(_('status: %r %s -> %s\n') %
+                              (wfn, oldstatus, newstatus))
+@@ -498,6 +506,8 @@
+     def check_dirstate(self):
+         ds_info = self.dirstate_info()
+         if ds_info == self.ds_info:
++            log('SAME')
++            log(repr(ds_info))
+             return
+         self.ds_info = ds_info
+         if not self.ui.debugflag:
+@@ -647,6 +657,7 @@
+                     # Just die.
+                     sys.exit(0)
+                 continue
++            log(evt.fullpath)
+             assert evt.fullpath.startswith(self.wprefix)
+             wpath = evt.fullpath[self.prefixlen:]
+ 
+@@ -730,6 +741,7 @@
+         pass
+ 
+     def answer_stat_query(self, cs):
++        log('STAT')
+         names = cs.read().split('\0')
+ 
+         states = names.pop()
+@@ -753,7 +765,7 @@
+                     for f in tree.lookup(states, fn, visited):
+                         yield f
+ 
+-        return ['\0'.join(r) for r in [
++        r = ['\0'.join(r) for r in [
+             genresult('l', self.repowatcher.statustrees['l']),
+             genresult('m', self.repowatcher.statustrees['m']),
+             genresult('a', self.repowatcher.statustrees['a']),
+@@ -766,6 +778,8 @@
+             'c' in states and genresult('n', self.repowatcher.tree) or [],
+             visited
+             ]]
++        log(repr(r))
++        return r
+ 
+     def answer_dbug_query(self):
+         return ['\0'.join(self.repowatcher.debug())]
+diff --git a/tests/test-revert b/tests/test-revert
+--- a/tests/test-revert
++++ b/tests/test-revert
+@@ -13,9 +13,12 @@
+ echo 12 > c
+ echo %% should show b unknown and c modified
+ hg status
++sleep 2
+ hg add b
+ echo %% should show b added and c modified
++echo "MARKER" >> /home/nicdumz/inotify.log
+ hg status
++echo "MARKER" >> /home/nicdumz/inotify.log
+ hg rm a
+ echo %% should show a removed, b added and c modified
+ hg status
 implicit-inotify
 pidfile
+inot-messages
+inotify-brokenlink
 runtest-inotify
 inotify-test-permissions
 inotify-moverepo
+inotify-wronglstat
 pyfs
 separate
 activate-inot-mac