-
We previously covered splitting a patch file into 2 separate patches.
-
In this video, we'll do the opposite, we'll show how to combine 2 patches into a single patch file.
-
I'll also show you how to move files in your patch queue.
-
So if you look here I setup 4 patches, you can see them here 1.diff, 2.diff, 3.diff, and 4.diff.
-
And each one of these patches, just contains a single added text file.
-
1.txt, 2.txt, 3.txt, and 4.txt respectively.
-
So if I just open up 1.diff just to show you, you can see that it has a single file 1.txt
-
and that file just says hi
-
And same thing for 2.diff, it says hi2. And it has 2.txt.
-
And same thing for 3 and 4.
-
So right now I have all 4 patches applied.
-
I'm just going to go and unapply all of them except for 1.diff
-
And you can see that it popped 4, 3, and 2.
-
And we're now at 1.diff.
-
And now let's say we wanted both 1.txt and 2.txt inside the same patch file.
-
Then what you can do is you can do hg qfold, and type 2.diff
-
And remember right now, only 1.diff is applied.
-
OK so that folded, so now when I go hg qapplied.
-
You'll see that 1.diff is the only one that is applied just like before.
-
But if I go hg qseries, you'll see that there's only 1.diff which is applied,
-
and 3 and 4.diff are not applied
-
And there's no 2.diff.
-
And that's because if I look inside 1.diff, you'll see that it has both those files.
-
Now another thing you can do, is you can actually fold a patch that's not in sequence.
-
So for example if I wanted to fold 4.diff inside 1.diff, I can do that.
-
I just do hg qfold 4.diff, and again only 1.diff is applied right now.
-
And when I go look at that file, 1.diff, you'll see now that it has 1.txt, 2.txt, and 4.txt in it.
-
Quit.
-
And if I look at my series now.
-
You'll see that I only have 1 and 3.
-
1 contains 1.txt, 2.txt, and 4.txt.
-
And 3 just contains 3.txt.
-
Now another useful thing you can do, is you can actually move around files in your patch queue.
-
So I'm just going to pop everything.
-
And let's say we wanted just 3.diff to appear before 1.diff.
-
We can do that with hg qpush --move and just type the name of the patch 3.diff
-
And that will actually apply that patch, and move it as the next patch.
-
So now when I do hg qseries, you'll see that 3 appears right now, and it's applied.
-
And 1.diff comes after that.
-
So both folding and moving patches should come up a lot as you work.
-
And hg qfold and hg qpush --move will help you do those things.