Wednesday, December 16, 2009

Working with Patches

Today, I am into creating a patch for FireFox. Following this exercise, I am able to make a change and do incremental builds as listed in the lab. It's just to type make in a folder that's inside the tree. But every time it returned with an error, and this time they were all the same error unlike last time I tried to build Firefox. I figured I should build it on another box because of my previous build experiences. At the moment, I only had a laptop available, and I can see the build lines flies up a lot slower than they were in the other box. I got it compiled with just 2 tries.

Now, running Nightly, every time I browse to another webpage, the console would generate a bunch of "Hello World". I just did a printf statement in a random function in a random .cpp file. Now that's something satifying =]

Creating a patch from the changes I made is an easy task. It only requires 1 command to do the work.
hg diff -p -U 8 . > patch.txt

Now to test the patch if it works, I reverted the changes by replacing the file with the backup file I made earlier. Using another command to apply the patch:
patch -p1 < patch.txt

It successfully changes the file to the one I modified.

The last command to try is backing out the patch with
patch -R -p1 < patch.txt

Again, 1 command and it worked. I liked this lab far better than the one I had before =].

No comments:

Post a Comment