Search code examples
mercurialmercurial-queue

hg update --mq not working?


I am using: Mercurial Distributed SCM (version 1.9.1), and I've done the following:

D:\code\mqtest>hg init
D:\code\mqtest>hg qinit -c
D:\code\mqtest>echo NonQueue > first
D:\code\mqtest>hg st
? first
D:\code\mqtest>hg add first
D:\code\mqtest>hg commit -m nonqueue
D:\code\mqtest>hg log
changeset:   0:2d4bac63616a
tag:         tip
user:        Tempos
date:        Mon Sep 26 00:52:49 2011 +0300
summary:     nonqueue

D:\code\mqtest>hg log --mq
D:\code\mqtest>hg qnew a
D:\code\mqtest>echo Queue0 > first
D:\code\mqtest>hg st
M first   
D:\code\mqtest>hg qref
D:\code\mqtest>hg qcommit -m "queue 0"
D:\code\mqtest>echo Queue1 > first
D:\code\mqtest>hg qref
D:\code\mqtest>hg qcommit -m "queue 1"
D:\code\mqtest>echo Queue2 > first
D:\code\mqtest>hg qref
D:\code\mqtest>hg qcommit -m "queue 2"
D:\code\mqtest>hg st
D:\code\mqtest>hg log --mq
changeset:   2:38d08315a300
tag:         tip
user:        Tempos
date:        Mon Sep 26 00:53:46 2011 +0300
summary:     queue 2

changeset:   1:bb8b7da2e728
user:        Tempos
date:        Mon Sep 26 00:53:33 2011 +0300
summary:     queue 1

changeset:   0:1ac551a65492
user:        Tempos
date:        Mon Sep 26 00:53:22 2011 +0300
summary:     queue 0

And I tried to switch back to a particular revision in the mq:

D:\code\mqtest>hg up -r 0 --mq
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
D:\code\mqtest>cat first
Queue2

Why am I not seeing the Queue0 content?


Solution

  • When you update the patches inside .hg\patches with hg --mq update, then you're changing the mq patches behind mq's back. In other words: the patches themselves get the new content, but they are not re-applied automatically.

    So the workflow you want is to do:

    > hg qpop -a
    > hg --mq update -r X
    > hg qpush -a
    

    where you first remove all patches, update them to look like you want, and then re-apply them.

    Having hg --mq update do this for you would actually be an interesting idea, and I know that you're not the first one to be surprised about the lack of integration between the two commands.