Mercurial Queues are a powerful tool for organizing changes into logically coherent commits. My current workflow often goes something like this:
- Make some changes implementing feature A (as a patch).
- Generate a series of patches moving on to feature B.
- Realize, after working on feature B, that feature A needs a small tweak, or a better commit message.
The relevant mq commands will get the job done in a jiffy. However, there’s a slight downside: after all that qpushing and qpopping, the patches in the series will lose their original dates, which means that qfinish will produce a tightly clustered series of patches that don’t actually reflect the true chronology of their development.
Fortunately, Mercurial provides the tools needed to preserve a meaningful chronological order. We’ll exploit hg log’s configurable formatting to make it generate a shell script that’ll set the dates for our patch series automatically. A pretty little hack, no? Here are the relevant incantations, assuming you want to modify a patch named P with revision number N:
hg log -r[[N]]:tip --template "hg qref -d '{date|date}'; hg qpush;\n" > d.sh
- Run
hg qgoto [[P]]
, then make whatever changes you need. - Run
bash d.sh
, which will restore the original dates for all patches in the queue following the modified one.