--- a/tests/test-mq-qrefresh.t Mon Nov 22 16:05:31 2010 +0100
+++ b/tests/test-mq-qrefresh.t Tue Nov 16 13:06:07 2010 -0600
@@ -487,3 +487,76 @@
$ cd ..
+
+Issue2499: refuse to add .hgsub{,state} to a patch
+
+ $ hg init repo-2499
+ $ cd repo-2499
+ $ hg qinit
+ $ hg qnew -m 0 0.diff
+ $ echo a > a
+ $ hg init sub
+ $ cd sub
+ $ echo b > b
+ $ hg ci -Am 0sub
+ adding b
+ $ cd ..
+
+test when adding
+ $ echo sub = sub > .hgsub
+ $ echo `hg id -i --debug sub` sub > .hgsubstate
+ $ hg add
+ adding .hgsub
+ adding .hgsubstate
+ adding a
+ $ hg qrefresh
+ warning: not adding .hgsub
+ warning: not adding .hgsubstate
+ $ hg qfinish -a
+ $ hg status
+ A .hgsub
+ A .hgsubstate
+ $ hg forget .hgsubstate
+ $ rm .hgsubstate
+
+add subrepo with a real commit
+ $ hg ci -m 1
+ committing subrepository sub
+ $ hg qnew -m 2 2.diff
+
+test when modifying
+ $ echo sub2 = sub2 >> .hgsub
+ $ hg qrefresh
+ warning: not refreshing .hgsub
+ $ echo 0000000000000000000000000000000000000000 sub2 >> .hgsubstate
+ $ hg qrefresh
+ warning: not refreshing .hgsub
+ warning: not refreshing .hgsubstate
+ $ hg revert --no-backup .hgsub .hgsubstate
+
+test when removing
+ $ hg rm .hgsub
+ $ hg rm .hgsubstate
+ $ hg qrefresh
+ warning: not removing .hgsub
+ warning: not removing .hgsubstate
+ $ hg status
+ R .hgsub
+ R .hgsubstate
+ $ hg revert --no-backup .hgsub .hgsubstate
+
+test when deleting
+ $ rm .hgsub .hgsubstate
+ $ hg qrefresh
+ warning: not removing .hgsub
+ warning: not removing .hgsubstate
+ refresh interrupted while patch was popped! (revert --all, qpush to recover)
+ abort: No such file or directory: $TESTTMP/repo-2499/.hgsub
+ [255]
+ $ hg status
+ ! .hgsub
+ ! .hgsubstate
+ $ hg cat -r1 .hgsub > .hgsub
+ $ hg revert --no-backup .hgsubstate
+
+ $ cd ..