Tuesday April 22, 2008 ![]() |
JMX, SNMP, Java, etc...Daniel Fuchs blogs on JMX, SNMP, Java, etc... |
... while working on uncommitted changes. Sometimes when you are working on a fix - or an RFE, you'd like to sync-up with your parent's repository and pull any changes it contains without having to commit your own work in progress. Here is my own recipe - direct from my mercurial cookbook. First you will need to make sure that the mq and fetch extensions are enabled in your .hgrc file. Ok, you don't really need fetch - you can do with the pull/update/merge/commit sequence - but personally I like fetch better. To enable mq and fetch, simply put those two lines under [extensions] in your .hgrc: [extensions] fetch= mq= Although I am not very comfortable with mq, since I don't speak diff & patch fluently, I have found it very useful for this use case. I am sure that mq is much more powerful than what my clumsy usage use it for - but I am now rather comfortable with the way I use it in this use case. The idea is as follows:
Before you start this sequence however - make sure to add all the new files
you have created to mercurial. You can use # make a Zip of your changes - just to be safe # (Note: the command below is in bash syntax) zip -r MyChanges.zip $(hg status -nma) # create a patch containing your changes hg qnew -f MyChanges # 'unapply' the patch, leaving the repository with # no uncommitted changes. hg qpop -a # Now hg status should see no uncommitted changes. # and hg heads should see only one head (tip) # now pull & update & merge hg fetch # now reapply the patch, to get back your changes as # new uncommitted changes: gpatch -p 1 < .hg/patches/MyChanges
There should be no problem applying the patch created by mq in
So if any At the end - you should have an updated repository again containing your uncommitted changes - on which you can continue working as if nothing had happened. If, after a while, you need to update again, you can redo that whole sequence. Just make sure to use a new name for your changes - for instance, MyChanges2. Well, that's my own recipe. I realize I might not be using the full power of mq, but it has worked for me until now... I hope it might help you too! Cheers, --daniel Tags: hg mercurial openjdk opensourcePosted by dfuchs ( Apr 22 2008, 02:00:58 PM CEST ) Permalink Comments [3] |
With mq, fetch is (almost) useless, coz you never merge anymore.
There's a nice post on dealing with .rej files at http://gnuarch.org/gnuarchwiki/Process_*.rej_files, Yes, it's emacs, but at least it tells you what .rej files are.
Why call gpatch instead of qpush? You can still fix the .reg hunks and do a qrefresh to update your patch file.
Posted by Weijun on April 22, 2008 at 06:15 PM CEST #
I haven't tried qpush yet. Maybe I should give it a try...
If I do qpush and just after hg status - what will I see? A list of modified files, or nothing?
I don't like qrefresh much because after qrefresh hg status no longer shows anything... And I like to see the list of files I've been working on with hg status...
Thanks for the suggestion anyway, I'll try it!
Cheers,
-- daniel
Posted by daniel on April 22, 2008 at 11:35 PM CEST #
qpush is similar to commit, it creates a new changeset, only managed by mq. I regard it as a safe commit, because with qpop/qpush, you can always remove/reapply the patch without fearing it will break anything.
After a qpush, hg status shows nothing.
Yes, after qrefresh, hg status shows nothing. But, that's what mq is meant for, saving the current changes into a patch file so that you can start another patch by calling qnew again. That's what a queue does anyway. If you start working on several bugs at the same time, you'll realize the benifit of it.
Posted by Weijun on April 23, 2008 at 01:44 AM CEST #