# HG changeset patch # User Pierre-Yves David # Date 2012-02-01 11:20:10 # Node ID 140b6282ac79006018df175eff05e49f10c8591f # Parent 74d00b5d00ccc2efb26e45e2054460d0c13e1175 mq: prevent rewriting operation on public changeset The following operation are denied if the mq changeset is public * qrefresh * qpop * qfold note: qimport was already denied. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1313,6 +1313,10 @@ class queue(object): if heads != [self.applied[-1].node]: raise util.Abort(_("popping would remove a revision not " "managed by this patch queue")) + if not repo[self.applied[-1].node].mutable(): + raise util.Abort( + _("popping would remove an immutable revision"), + hint=_('see "hg help phases" for details')) # we know there are no local changes, so we can make a simplified # form of hg.update. @@ -1374,6 +1378,9 @@ class queue(object): (top, patchfn) = (self.applied[-1].node, self.applied[-1].name) if repo.changelog.heads(top) != [top]: raise util.Abort(_("cannot refresh a revision with children")) + if not repo[top].mutable(): + raise util.Abort(_("cannot refresh immutable revision"), + hint=_('see "hg help phases" for details')) inclsubs = self.checksubstate(repo) diff --git a/tests/test-mq-safety.t b/tests/test-mq-safety.t --- a/tests/test-mq-safety.t +++ b/tests/test-mq-safety.t @@ -1,5 +1,6 @@ $ echo '[extensions]' >> $HGRCPATH - $ echo 'mq =' >> $HGRCPATH + $ echo 'hgext.mq =' >> $HGRCPATH + $ echo 'hgext.graphlog =' >> $HGRCPATH $ hg init repo $ cd repo @@ -17,6 +18,35 @@ $ echo bar >> foo $ hg qrefresh -m 'append bar' +Try to operate on public mq changeset + + $ hg qpop + popping bar + now at: foo + $ hg phase --public qbase + $ echo babar >> foo + $ hg qref + abort: cannot refresh immutable revision + (see "hg help phases" for details) + [255] + $ hg revert -a + reverting foo + $ hg qpop + abort: popping would remove an immutable revision + (see "hg help phases" for details) + [255] + $ hg qfold bar + abort: cannot refresh immutable revision + (see "hg help phases" for details) + [255] + $ hg revert -a + reverting foo + +restore state for remaining test + + $ hg qpush + applying bar + now at: bar try to commit on top of a patch