Hg split ?

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Fri Oct 19 14:15:22 CDT 2007


Cool! Thanks a lot.
-peo

On 10/19/07, Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
> On 2007-10-19 14:25, Peter Arrenbrecht <peter.arrenbrecht at gmail.com> wrote:
> > I did take a look now because I needed something similar: Breaking up
> > an existing hg mq patch into multiple patches.
>
> You can use the -I (include) and -X (exclude) options of qrefresh to do
> something like this:
>
>     hg qpush foo-patch                  ; push original 'foo-patch'
>     hg qrefresh --git -I bin            ; refresh to include only bin/
>     hg qnew --git -f -e bar-patch       ; create new patch with the rest
>                                         ; of the modified files
>
> Now you should have two patches pushed:
>
>     foo-patch
>     bar-patch
>
> Repeat as many times as necessary to split bar-patch even more :)
>
> If you want to 'move' parts of a git-style patch from patch foo-patch to
> patch bar-patch, you can also use MQ and the `qfold' command.
>
> Continuing the sample above, let's say that you decided that the lib/
> directory of bar-patch should really be part of foo-patch along with the
> bin/ changes.  You can use MQ and qrefresh/qfold/qnew like this:
>
>     hg qpush foo-patch                  ; push original foo-patch
>     hg qpush bar-patch                  ; push original bar-patch
>     hg qrefresh --git -X lib            ; exclude lib/ from bar-patch
>     hg qnew -fe lib-patch               ; create new lib-patch
>
> Now you can either play with qguard/qpush/qpop to "move" the lib-patch
> between foo-patch and bar-patch, or qpop them all and manually edit the
> .hg/patches/series file.  Once you establish a patch order of:
>
>     foo-patch
>     lib-patch
>     bar-patch
>
> You can pop all the patches, push only foo-patch and "fold" the next
> one, the lib-patch, into foo-patch:
>
>     hg qpop -a                          ; start with a clean stack
>     hg qpush foo-patch                  ; push original foo-patch
>     hg qfold lib-patch                  ; join foo-patch and lib-patch
>
> That's what I commonly use to keep a stack of personal patches on top of
> various project-based workspaces at work, but YMMV :)
>
> - Giorgos
>
>


More information about the Mercurial mailing list