Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I split work into multiple patches with mercurial queues?

If I've been churning away at the code for a while, and forgotten to create a patch series as I go, how do I create the patch series retrospectively? So far the only thing that comes to mind is:

# Prepare and test the first batch of changes.
$ hg qrecord -m 'first batch' 1.patch
$ hg qnew -m 'stash downstream changes' stash-1.patch
$ hg qdelete -k temp-1.patch
$ make hello
cc     hello.c   -o hello
hello.c: In function ‘main’:
hello.c:4: error: syntax error at end of input
make: *** [hello] Error 1
$ echo '}' >> hello.c
$ make hello
cc     hello.c   -o hello
$ hg qrefresh

# Recover the stashed changes.
$ patch -p1 < .hg/patches/last.patch

# And around we go again!
$ hg qrecord -m 'second batch' 2.patch
$ hg qnew -m 'stash downstream changes' stash-2.patch
$ hg qdelete -k stash-2.patch
$ make hello
...

This very cumbersome approach is also hazardous. I might forget the -k on qdelete, at which point I'll go bash my forehead against a brick wall for several minutes, or I might include too much or too little during the qrecord operation.

Is there a better way?

(What I'd really like is to be able to hg qpop to just before a patch I want to split, and use a currently non-existent command, hg qunrecord, to interactively suck changes out of the patch into my working directory. Once I'm happy with the changes, hg qnew -f could squeeze a new patch in front of the old one.)

like image 395
Marcelo Cantos Avatar asked Jan 26 '10 00:01

Marcelo Cantos


1 Answers

The MQTutorial explains how to split patches. So you could create a patch from you current work and split it into several patches.

like image 80
wierob Avatar answered Sep 28 '22 16:09

wierob