Merge with crew
authorMatt Mackall <mpm@selenic.com>
Wed, 16 Dec 2009 17:39:42 -0600
changeset 10094 4e2fb6cc0e1e
parent 10091 0ce645cc3f20 (diff)
parent 10093 a43ae5777221 (current diff)
child 10096 a223894ca044
Merge with crew
--- a/hgext/inotify/linuxserver.py	Thu Dec 17 00:32:26 2009 +0100
+++ b/hgext/inotify/linuxserver.py	Wed Dec 16 17:39:42 2009 -0600
@@ -170,6 +170,7 @@
         server.repowatcher.__init__(self, ui, dirstate, root)
 
         self.lastevent = {}
+        self.dirty = False
         try:
             self.watcher = watcher.watcher()
         except OSError, err:
@@ -214,7 +215,6 @@
     def setup(self):
         self.ui.note(_('watching directories under %r\n') % self.wprefix)
         self.add_watch(self.wprefix + '.hg', inotify.IN_DELETE)
-        self.check_dirstate()
 
     def scan(self, topdir=''):
         ds = self.dirstate._map.copy()
@@ -250,7 +250,7 @@
             self.update_hgignore()
         try:
             st = self.stat(wpath)
-            if stat.S_ISREG(st[0]):
+            if stat.S_ISREG(st[0]) or stat.S_ISLNK(st[0]):
                 self.updatefile(wpath, st)
         except OSError:
             pass
@@ -272,8 +272,6 @@
         if wpath == '.hgignore':
             self.update_hgignore()
         elif wpath.startswith('.hg/'):
-            if wpath == '.hg/wlock':
-                self.check_dirstate()
             return
 
         self.deletefile(wpath, self.dirstate[wpath])
@@ -335,6 +333,10 @@
             self.ui.note(_('%s reading %d events\n') %
                          (self.event_time(), len(events)))
         for evt in events:
+            if evt.fullpath == self.wprefix[:-1]:
+                # events on the root of the repository
+                # itself, e.g. permission changes or repository move
+                continue
             assert evt.fullpath.startswith(self.wprefix)
             wpath = evt.fullpath[self.prefixlen:]
 
@@ -343,16 +345,26 @@
             if wpath.startswith('.hg/') and evt.mask & inotify.IN_ISDIR:
                 # ignore subdirectories of .hg/ (merge, patches...)
                 continue
+            if wpath == ".hg/wlock":
+                if evt.mask & inotify.IN_DELETE:
+                    self.dirstate.invalidate()
+                    self.dirty = False
+                    self.scan()
+                elif evt.mask & inotify.IN_CREATE:
+                    self.dirty = True
+            else:
+                if self.dirty:
+                    continue
 
-            if evt.mask & inotify.IN_UNMOUNT:
-                self.process_unmount(wpath, evt)
-            elif evt.mask & (inotify.IN_MODIFY | inotify.IN_ATTRIB):
-                self.process_modify(wpath, evt)
-            elif evt.mask & (inotify.IN_DELETE | inotify.IN_DELETE_SELF |
-                             inotify.IN_MOVED_FROM):
-                self.process_delete(wpath, evt)
-            elif evt.mask & (inotify.IN_CREATE | inotify.IN_MOVED_TO):
-                self.process_create(wpath, evt)
+                if evt.mask & inotify.IN_UNMOUNT:
+                    self.process_unmount(wpath, evt)
+                elif evt.mask & (inotify.IN_MODIFY | inotify.IN_ATTRIB):
+                    self.process_modify(wpath, evt)
+                elif evt.mask & (inotify.IN_DELETE | inotify.IN_DELETE_SELF |
+                                 inotify.IN_MOVED_FROM):
+                    self.process_delete(wpath, evt)
+                elif evt.mask & (inotify.IN_CREATE | inotify.IN_MOVED_TO):
+                    self.process_create(wpath, evt)
 
         self.lastevent.clear()
 
--- a/hgext/inotify/server.py	Thu Dec 17 00:32:26 2009 +0100
+++ b/hgext/inotify/server.py	Wed Dec 16 17:39:42 2009 -0600
@@ -281,17 +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:
-            return
-        self.ds_info = ds_info
-        if not self.ui.debugflag:
-            self.last_event = None
-        self.dirstate.invalidate()
-        self.handle_timeout()
-        self.scan()
-
     def update_hgignore(self):
         # An update of the ignore file can potentially change the
         # states of all unknown and ignored files.
--- a/tests/run-tests.py	Thu Dec 17 00:32:26 2009 +0100
+++ b/tests/run-tests.py	Wed Dec 16 17:39:42 2009 -0600
@@ -251,9 +251,8 @@
 
     return missing, failed
 
-def showdiff(expected, output):
-    for line in difflib.unified_diff(expected, output,
-            "Expected output", "Test output"):
+def showdiff(expected, output, ref, err):
+    for line in difflib.unified_diff(expected, output, ref, err):
         sys.stdout.write(line)
 
 def findprogram(program):
@@ -452,13 +451,13 @@
         if not options.verbose:
             skips.append((test, msg))
         else:
-            print "\nSkipping %s: %s" % (test, msg)
+            print "\nSkipping %s: %s" % (testpath, msg)
         return None
 
     def fail(msg):
         fails.append((test, msg))
         if not options.nodiff:
-            print "\nERROR: %s %s" % (test, msg)
+            print "\nERROR: %s %s" % (testpath, msg)
         return None
 
     vlog("# Test", test)
@@ -565,7 +564,7 @@
         else:
             fail("output changed")
         if not options.nodiff:
-            showdiff(refout, out)
+            showdiff(refout, out, ref, err)
         ret = 1
     elif ret:
         mark = '!'