# HG changeset patch # User Kevin Bullock # Date 1289934367 21600 # Node ID f08df4d38442bf641859f3de860ce0e5b6ba7763 # Parent 99210fb3bc0a94dfe1b8a81825faa367ca98a128 mq: ignore subrepos (issue2499) If MQ allows modifying .hgsub or .hgsubstate in a patch, it can easily lead to an inconsistent subrepo state. This patch prevents qrefresh from adding any modifications to .hgsub or .hgsubstate to a patch. The user is warned that these files are not included in the patch. The tests test both the slightly irrational and the pathological cases. diff -r 99210fb3bc0a -r f08df4d38442 hgext/mq.py --- a/hgext/mq.py Mon Nov 22 16:05:31 2010 +0100 +++ b/hgext/mq.py Tue Nov 16 13:06:07 2010 -0600 @@ -1295,12 +1295,18 @@ # local dirstate. in this case, we want them to only # show up in the added section for x in m: + if x == '.hgsub' or x == '.hgsubstate': + self.ui.warn(_('warning: not refreshing %s\n') % x) + continue if x not in aa: mm.append(x) # we might end up with files added by the local dirstate that # were deleted by the patch. In this case, they should only # show up in the changed section. for x in a: + if x == '.hgsub' or x == '.hgsubstate': + self.ui.warn(_('warning: not adding %s\n') % x) + continue if x in dd: del dd[dd.index(x)] mm.append(x) @@ -1310,6 +1316,9 @@ # are not in the add or change column of the patch forget = [] for x in d + r: + if x == '.hgsub' or x == '.hgsubstate': + self.ui.warn(_('warning: not removing %s\n') % x) + continue if x in aa: del aa[aa.index(x)] forget.append(x) diff -r 99210fb3bc0a -r f08df4d38442 tests/test-mq-qrefresh.t --- 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 ..