As I mentioned in a previous blog post, one of the features for my v0.1 release will be implementing a expand/collapse feature for pushloghtml. Well, turns out that ted has already started working on that. He’s already filed a bug and released a patch for it. According to him its not quite done and a couple of things need to be changed.
So, my first job was to download the patch and apply it to my repo. So I headed over to Bugzilla and looked up the bug. There were 2 patches that I needed to download…
- One for pushlog-feed.py
- Another for gitweb_mozilla
Before you read the following take into account that I’ve never applied any kind of a patch before so this is purely from the point of a beginner. So I was looking for a way to download the patch so that I could apply it. But apparently there is no download link available on BugZIlla (it took me almost 20 mins to realize that). They should really look to put in some sort of download link/button. In the end I just ended up using the crude method of “Save Page As” to download the patch file.
Now onto applying the patch. I had no idea how to do that so I tried using tortoiseMerge since I already had that installed. It is apparently capable of applying a patch. I added the path of the diff file and the directory where I wanted it to apply the patch in the two text boxes below and then clicked the OK button. Nothing happened at all. Nothing got loaded, no error message, no nothing. This had me a bit bewildered and frustrated. tortoiseMerge was basically useless.
Now onto the next option which was hg itself. I knew that there was a way since I had read about it in some documentation when I was getting know hg at the start of my project. So I headed over to google to perform a search. I tried various things such as “apply a patch hg”, “patch hg”, “install patch hg” and “mercurial apply patch”. The last one gave me a couple of good results. One was at hgbook and another was documentation about hg queues but neither of them was a straight up guide of how to install patches. I tried many different google searches but I just couldn’t find any simple and easy guide explaining how one would install a patch using hg. Well, here I am to the rescue. The following is a simple guide that gives instructions on installing a simple patch using hg…
- Download the .patch or .diff file onto your machine
- Navigate to the repo that you want to install the patch to i.e. testRepo (I will using repo name for this example, substitute it with your repo name when you are trying to apply a patch yourself)
- Open testRepo.hghgrc (the config file)
- Add the following to hgrc and save (This enables queues for hg so that we can use commands that we need, qimport and qpush)
- Now open up a command prompt and navigate to your repo directory
- Type in hg qimport <full-path-of-patch-file> and press enter
- The above command should create a patch folder within testRepo.hgpatches
- Next navigate to testRepo.hgpatches
- Type in hg qpush <patch-file-name>
- Done! The patch should have been applied (if you get an error such as “abort: local changes found, refresh first” then that means you have made changes to the original files and the patch won’t work)
In my trials and tribulations while trying to apply a patch I had to first figure out what hg queues did and how to use them. I tried to just type in hg qimport but I just got a “command does not exist” error. I didn’t realize that I had to import something until ted gave me a push in the right direction. A simple guide would have really helped.
Try hg import.
Next time take a look at hg help.
Actually I did try using hg import but it didn’t work for me for some reason. Some sort of error, but I can’t recall what it was now.
Maybe hg import is a more straight forward way of doing it but I couldn’t get it to work
`hg import` is definitely the right way to import patches. What was the error you were getting?
`hg import` just worked perfectly for me.
I think you should update your blog post to reflect the standard way of applying a *.diff file.
You can use hg patch (a synonym for hg import) just like you would use the regular old patch command:
hg patch -p0 patchfile
I like the –no-commit option to hg patch so I can make sure it all looks good before committing:
hg patch –no-commit -p0 patchfile
I am definitely sure that this will work for some but still they might encounter some minor problems which can be solved easily.
i have read your previous post. this one is better than the previous one. looking forward to read more post from you
Actually, I’m just planning to try the TortoiseMerge. To found out if it really works.
TortoiseMerge all about having the history of your working progress. But to really see and check the history, you must be able to see and check what has changed between two points in time,
Thank goodness for bugzilla! I use it frequently for internet marketing consulting. Great post. Thanks for sharing!
‘hg import’ does not bring any hassle. so what was happening in your case?
Thanks for all the information. Nice of you to put the step by step guide. It was so easy for me to follow.
I see a lot of interesting articles on your blog. You have to spend a lot of time writing, i know how to save you a lot of time, there is a tool that creates unique, google
friendly articles in couple of minutes, just search in google