Question

I'm using mercurial queues quite alot, and I'm really happy with them, but there is one workflow which I find overly complicated. It happens sometimes that I'm working on a patch, and then I realize I have been working on something that should be in a separate patch (like when I fixed a bug that I found while working on a feature, or added another feature for that I actually want to have in a separate patch).

So the state is for the working directory is: patches A,B,C applied, plus changes that should be put into patch C, and changes that should be in a new patch D.

My current workflow for that is as follows:

hg qnew D.patch files-for-patch-D..
hg qnew temp.patch # changes for patch C
hg qpop
hg qpop
# Now I'm on patch C
hg qfold temp.patch # Integrate changes into patch C
# Here I could have patch errors.. 
hg qpush

I know I could also do it like this

hg qrefresh files-for-patch-C..
hg qnew -m "..." new-feature.patch 

The downside with this approach is that the number of files for patch C is usually large, and it's awkward to have to put all of them onto the command line. The number of files for patch D is usually small in comparison.

Is there a better way to accomplish this than what I have outlined above?

Was it helpful?

Solution

I think you've covered the most typical approaches to this problem — I also run into it from time to time. One alternative solution I know of is to do

$ hg qrefresh -X files-for-patch-D
$ hg qnew D.patch

That is: exclude the few files that you changed for patch D, instead of trying to include all the right files for patch C.

You can also forcibly pop patch D (with hg qpop -f) instead of stashing your changes into a temporary patch. This only works if the files touched by patch D don't intersect with the changes in the working copy, i.e., when you haven't used qrecord from the record extension to create patch D.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top