Commits

Nicolas Dumazet  committed fcbb064

reordering patches, updating against crew

  • Participants
  • Parent commits f78944f

Comments (0)

Files changed (7)

File inotify-moverepo

 It's not possible to (only) rescan the repository since self.dirstate points
 to wrong, old data. Just sys.exit(0), and restart a daemon when necessary.
 
-diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
---- a/hgext/inotify/server.py
-+++ b/hgext/inotify/server.py
-@@ -639,6 +639,13 @@
+diff --git a/hgext/inotify/linuxserver.py b/hgext/inotify/linuxserver.py
+--- a/hgext/inotify/linuxserver.py
++++ b/hgext/inotify/linuxserver.py
+@@ -338,6 +338,13 @@
              if evt.fullpath == self.wprefix[:-1]:
                  # events on the root of the repository
                  # itself, e.g. permission changes or repository move
 diff --git a/tests/test-inotify b/tests/test-inotify
 --- a/tests/test-inotify
 +++ b/tests/test-inotify
-@@ -93,4 +93,20 @@
+@@ -97,4 +97,20 @@
  echo b >> 1844/foo
  hg ci 1844 -m 'broken'
  
 diff --git a/tests/test-inotify.out b/tests/test-inotify.out
 --- a/tests/test-inotify.out
 +++ b/tests/test-inotify.out
-@@ -48,3 +48,7 @@
+@@ -50,3 +50,7 @@
  3 files updated, 1 files merged, 0 files removed, 0 files unresolved
  M a
  adding 1844/foo

File inotify-test-permissions

 
 Spotted in test-permissions when run with --inotify
 
-diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
---- a/hgext/inotify/server.py
-+++ b/hgext/inotify/server.py
-@@ -636,6 +636,10 @@
+diff --git a/hgext/inotify/linuxserver.py b/hgext/inotify/linuxserver.py
+--- a/hgext/inotify/linuxserver.py
++++ b/hgext/inotify/linuxserver.py
+@@ -335,6 +335,10 @@
              self.ui.note(_('%s reading %d events\n') %
                           (self.event_time(), len(events)))
          for evt in events:

File inotify-wronglstat

 # User Nicolas Dumazet <nicdumz.commits@gmail.com>
 # Date 1258596338 -32400
 
+diff --git a/hgext/inotify/linuxserver.py b/hgext/inotify/linuxserver.py
+--- a/hgext/inotify/linuxserver.py
++++ b/hgext/inotify/linuxserver.py
+@@ -346,6 +346,7 @@
+                     # Just die.
+                     sys.exit(0)
+                 continue
++            server.log(evt.fullpath)
+             assert evt.fullpath.startswith(self.wprefix)
+             wpath = evt.fullpath[self.prefixlen:]
+ 
 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
+ import sys
+ import tempfile
  
 +f = open("/home/nicdumz/inotify.log", "a")
 +def log(msg):
  class AlreadyStartedException(Exception): pass
  
  def join(a, b):
-@@ -440,6 +446,8 @@
+@@ -254,6 +260,8 @@
          # - None : fn is new
          # - a char in statuskeys: fn is a (tracked) file
  
          if self.ui.debugflag and oldstatus != newstatus:
              self.ui.note(_('status: %r %s -> %s\n') %
                               (wfn, oldstatus, newstatus))
-@@ -498,6 +506,8 @@
+@@ -284,6 +292,8 @@
      def check_dirstate(self):
          ds_info = self.dirstate_info()
          if ds_info == self.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
+@@ -372,6 +382,7 @@
+         self.fileno = self.sock.fileno
  
      def answer_stat_query(self, cs):
 +        log('STAT')
          names = cs.read().split('\0')
  
          states = names.pop()
-@@ -753,7 +765,7 @@
+@@ -389,7 +400,7 @@
                      for f in tree.lookup(states, fn, visited):
                          yield f
  
              genresult('l', self.repowatcher.statustrees['l']),
              genresult('m', self.repowatcher.statustrees['m']),
              genresult('a', self.repowatcher.statustrees['a']),
-@@ -766,6 +778,8 @@
+@@ -402,6 +413,8 @@
              'c' in states and genresult('n', self.repowatcher.tree) or [],
              visited
              ]]
 diff --git a/hgext/inotify/common.py b/hgext/inotify/common.py
 --- a/hgext/inotify/common.py
 +++ b/hgext/inotify/common.py
-@@ -29,6 +29,8 @@
+@@ -7,6 +7,7 @@
+ # GNU General Public License version 2, incorporated herein by reference.
+ 
+ import cStringIO, socket, struct
++import sys
  
  """
- 
-+import sys
-+
- version = 2
- 
- resphdrfmts = {
-@@ -46,6 +48,9 @@
+   Protocol between inotify clients and server:
+@@ -48,6 +49,9 @@
              s = sock.recv(65536)
              cs.write(s)
      finally:
 # Date 1250252389 14400
 # Node ID 165b9b88dd1c64cb074a444eef297114a0106e1e
 # Parent  52d4b0aaa4e8df03a7dbe97c108ddb1b1bf5cba0
-inotify: create a common, OS-independent server access point
+inotify: create a common, OS-independent server entry point
 
 * rename server.py to linuxserver.py
 * create server.py: it will contain OS-independent logic for servers, and will
  def _explain_watch_limit(ui, dirstate, rootabs):
      path = '/proc/sys/fs/inotify/max_user_watches'
      try:
-@@ -201,97 +149,12 @@
+@@ -201,103 +149,10 @@
          return wrapper
      return decorator
  
 -class directory(object):
 -    """
 -    Representing a directory
- 
+-
 -    * path is the relative path from repo root to this directory
 -    * files is a dict listing the files in this directory
 -        - keys are file names
 -                ret = d
 -        return ret
 -
--    def walk(self, states):
+-    def walk(self, states, visited=None):
 -        """
 -        yield (filename, status) pairs for items in the trees
 -        that have status in states.
 -            if st in states:
 -                yield join(self.path, file), st
 -        for dir in self.dirs.itervalues():
+-            if visited is not None:
+-                visited.add(dir.path)
 -            for e in dir.walk(states):
 -                yield e
 -
--    def lookup(self, states, path):
+-    def lookup(self, states, path, visited):
 -        """
 -        yield root-relative filenames that match path, and whose
 -        status are in states:
 -                tree = tree.dirs[dir]
 -        except KeyError:
 -            # path is not tracked
+-            visited.add(tree.path)
 -            return
 -
 -        try:
 -            # if path is a directory, walk it
--            for file, st in tree.dirs[last].walk(states):
+-            target = tree.dirs[last]
+-            visited.add(target.path)
+-            for file, st in target.walk(states, visited):
 -                yield file
 -        except KeyError:
 -            try:
 -                if tree.files[last] in states:
 -                    # path is a file
+-                    visited.add(tree.path)
 -                    yield path
 -            except KeyError:
 -                # path is not tracked
      Watches inotify events
      """
 -    statuskeys = 'almr!?'
-+
      mask = (
          inotify.IN_ATTRIB |
          inotify.IN_CREATE |
-@@ -306,11 +169,9 @@
+@@ -312,11 +167,9 @@
          0)
  
      def __init__(self, ui, dirstate, root):
          try:
              self.watcher = watcher.watcher()
          except OSError, err:
-@@ -318,18 +179,8 @@
+@@ -324,18 +177,8 @@
                               err.strerror)
          self.threshold = watcher.threshold(self.watcher)
          self.fileno = self.watcher.fileno
          self.handle_timeout()
          self.scan()
  
-@@ -347,15 +198,6 @@
+@@ -353,15 +196,6 @@
              return '+%.2f' % delta
          return '+%.1f' % delta
  
      def add_watch(self, path, mask):
          if not path:
              return
-@@ -376,101 +218,16 @@
+@@ -382,101 +216,16 @@
          self.add_watch(self.wprefix + '.hg', inotify.IN_DELETE)
          self.check_dirstate()
  
                  self.updatefile(wfn, self.getstat(wfn))
                  ds.pop(wfn, None)
          wtopdir = topdir
-@@ -489,56 +246,6 @@
+@@ -495,56 +244,6 @@
          self.check_deleted('!')
          self.check_deleted('r')
  
      @eventaction('c')
      def created(self, wpath):
          if wpath == '.hgignore':
-@@ -671,129 +378,19 @@
+@@ -677,136 +376,20 @@
          """
          return sorted(tuple[0][self.prefixlen:] for tuple in self.watcher)
  
 -            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:
 -                        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
  
      def handle_timeout(self):
          pass
--
+ 
 -    def answer_stat_query(self, cs):
 -        names = cs.read().split('\0')
 -
 -            # answer.
 -            self.repowatcher.handle_timeout()
 -
+-        visited = set()
 -        if not names:
 -            def genresult(states, tree):
 -                for fn, state in tree.walk(states):
 -        else:
 -            def genresult(states, tree):
 -                for fn in names:
--                    for f in tree.lookup(states, fn):
+-                    for f in tree.lookup(states, fn, visited):
 -                        yield f
 -
 -        return ['\0'.join(r) for r in [
 -                or [],
 -            [],
 -            'c' in states and genresult('n', self.repowatcher.tree) or [],
+-            visited
 -            ]]
 -
 -    def answer_dbug_query(self):
  
      def shutdown(self):
          self.sock.close()
-@@ -806,11 +403,20 @@
+@@ -819,11 +402,20 @@
              if err.errno != errno.ENOENT:
                  raise
  
  
      def shutdown(self):
          for obj in pollable.instances.itervalues():
-@@ -822,30 +428,3 @@
+@@ -835,35 +427,3 @@
          if os.getenv('TIME_STARTUP'):
              sys.exit(0)
          pollable.run()
 -            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:
 -            finally:
 -                self.master.shutdown()
 -
--    runargs = None
 -    if 'inserve' not in sys.argv:
 -        runargs = [sys.argv[0], 'inserve', '-R', root]
+-    else:
+-        runargs = sys.argv[:]
+-
+-    pidfile = ui.config('inotify', 'pidfile')
+-    if opts['daemon'] and pidfile is not None and 'pid-file' not in runargs:
+-        runargs.append("--pid-file=%s" % pidfile)
 -
 -    service = service()
 -    logfile = ui.config('inotify', 'log')
  class directory(object):
      """
      Representing a directory
-@@ -287,23 +156,11 @@
+@@ -293,23 +162,11 @@
                  # path is not tracked
                  pass
  
  
      def __init__(self, ui, dirstate, root):
          self.ui = ui
-@@ -311,41 +168,18 @@
+@@ -317,41 +174,18 @@
  
          self.wprefix = join(root, '')
          self.prefixlen = len(self.wprefix)
  
      def dirstate_info(self):
          try:
-@@ -356,26 +190,6 @@
+@@ -362,26 +196,6 @@
                  raise
              return 0, 0
  
      def filestatus(self, fn, st):
          try:
              type_, mode, size, time = self.dirstate._map[fn][:4]
-@@ -449,7 +263,6 @@
+@@ -455,7 +269,6 @@
              if newstatus != 'n':
                  self.statustrees[newstatus].dir(root).files[fn] = newstatus
  
      def check_deleted(self, key):
          # Files that had been deleted but were present in the dirstate
          # may have vanished from the dirstate; we must clean them up.
-@@ -462,33 +275,6 @@
+@@ -468,33 +281,6 @@
              del self.statustrees[key].dir(root).files[fn]
              del self.tree.dir(root).files[fn]
  
      def check_dirstate(self):
          ds_info = self.dirstate_info()
          if ds_info == self.ds_info:
-@@ -496,11 +282,9 @@
+@@ -502,11 +288,9 @@
          self.ds_info = ds_info
          if not self.ui.debugflag:
              self.last_event = None
  
      def update_hgignore(self):
          # An update of the ignore file can potentially change the
-@@ -539,139 +323,7 @@
+@@ -545,139 +329,7 @@
              self.statcache.pop(wpath, None)
              raise
  
      """
      Listens for client queries on unix socket inotify.sock
      """
-@@ -707,10 +359,6 @@
+@@ -718,10 +370,6 @@
                  raise
          self.sock.listen(5)
          self.fileno = self.sock.fileno
  
      def answer_stat_query(self, cs):
          names = cs.read().split('\0')
-@@ -719,12 +367,6 @@
+@@ -730,12 +378,6 @@
  
          self.ui.note(_('answering query for %r\n') % states)
  
 -            # answer.
 -            self.repowatcher.handle_timeout()
 -
+         visited = set()
          if not names:
              def genresult(states, tree):
-                 for fn, state in tree.walk(states):
-@@ -751,11 +393,7 @@
+@@ -764,11 +406,7 @@
      def answer_dbug_query(self):
          return ['\0'.join(self.repowatcher.debug())]
  
          sock, addr = self.sock.accept()
  
          cs = common.recvcs(sock)
-@@ -795,33 +433,12 @@
+@@ -808,33 +446,12 @@
              if err[0] != errno.EPIPE:
                  raise
  
+separate
 runtest-inotify
+test-import
 inotify-test-permissions
 inotify-moverepo
 inotify-wronglstat
 pyfs
-separate
 activate-inot-mac
 proto
 exclude

File test-import

Empty file added.