[PATCH] inotify: Do not access inotify when dirstate is dirty (issue1811)

Nicolas Dumazet nicdumz at gmail.com
Thu Nov 12 23:38:48 CST 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1257917939 -32400
# Node ID 1446f28f1cd47c64de40e528de10075db384ebb5
# Parent  9e7b2c49d25ddf8ba3a73bea2bf5b483911e773a
inotify: Do not access inotify when dirstate is dirty (issue1811)

Original patch was provided by Simon Heimberg

It delegates dirstate computation to dirstate.status when dirstate is dirty:
better be slow from time to time instead of using wrong data.

This solves issue1719. As the last component, issue1810, is still not solved,
test-inotify-dirty-dirstate will fail for now. It emphasizes a regression due
to 7c01599dd340:

changeset:   9515:7c01599dd340
user:        Nicolas Dumazet <nicdumz.commits at gmail.com>
date:        Sun Aug 16 11:11:37 2009 +0900
summary:     inotify: use cmdutil.service instead of local daemonizing code

Ancestors of 7c01599dd30 are passing the test, when applied this patch.
Regression has to be investigated, but this patch is important since it affects
often mq operations.

diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py
--- a/hgext/inotify/__init__.py
+++ b/hgext/inotify/__init__.py
@@ -46,7 +46,7 @@
             files = match.files()
             if '.' in files:
                 files = []
-            if self._inotifyon and not ignored:
+            if self._inotifyon and not ignored and not self._dirty:
                 cli = client(ui, repo)
                 try:
                     result = cli.statusquery(files, match, False,
diff --git a/tests/test-inotify-dirty-dirstate b/tests/test-inotify-dirty-dirstate
new file mode 100755
--- /dev/null
+++ b/tests/test-inotify-dirty-dirstate
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# issues when status queries are issued when dirstate is dirty
+
+"$TESTDIR/hghave" inotify || exit 80
+
+echo "[extensions]" >> $HGRCPATH
+echo "inotify=" >> $HGRCPATH
+echo "fetch=" >> $HGRCPATH
+
+echo % issue1810: inotify and fetch
+mkdir test; cd test
+hg init
+
+echo foo > foo
+hg add
+hg ci -m foo
+
+cd ..
+
+hg clone test test2
+cd test2
+echo bar > bar
+hg add
+hg ci -m bar
+cd ../test
+echo spam > spam
+hg add
+hg ci -m spam
+cd ../test2
+hg st
+
+# abort, outstanding changes
+hg fetch -q
+hg st
+cd ..
+
+
+echo % issue1719: inotify and mq
+
+echo "mq=" >> $HGRCPATH
+
+hg init test-1719
+cd test-1719
+
+echo % inserve
+hg inserve -d --pid-file=hg.pid
+cat hg.pid >> "$DAEMON_PIDS"
+
+echo content > file
+hg add file
+
+hg qnew -f test.patch
+
+hg status
+hg qpop
+
+echo % st should not output anything
+hg status
+
+hg qpush
+
+echo % st should not output anything
+hg status
+
+hg qrefresh
+hg status
diff --git a/tests/test-inotify-dirty-dirstate.out b/tests/test-inotify-dirty-dirstate.out
new file mode 100644
--- /dev/null
+++ b/tests/test-inotify-dirty-dirstate.out
@@ -0,0 +1,18 @@
+% issue1810: inotify and fetch
+adding foo
+updating working directory
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+adding bar
+adding spam
+% issue1719: inotify and mq
+% inserve
+? hg.pid
+popping test.patch
+patch queue now empty
+% st should not output anything
+? hg.pid
+applying test.patch
+now at: test.patch
+% st should not output anything
+? hg.pid
+? hg.pid


More information about the Mercurial-devel mailing list