Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please suggest a better workflow in Mercurial

I'm new to Mercurial and what I'm starting to realize is that my basic workflow may not be the most efficient way of working because I perform commits so frequently and for feature improvements that are so small that when I need to find some earlier step to revert to, it is extremely difficult.

Here's what I do after I have a project set up in Mercurial and have already completed my first commit.

  1. Make some changes to a file and get it to a state where a small improvement is working
  2. hg commit -m "improvement A works"
  3. Make some changes to the same file and get it to a state where the next minor improvement is working.
  4. hg commit -m "improvement B works"
  5. Check whether all of the minor improvements add up to a single minor feature working correctly.
  6. hg commit -m "feature A works"

If I find a mistake that was made in "improvement A", I open up history (with the Netbeans Mercurial visual plugin) and copy and paste some of the code back into my current version and start again from there.

This doesn't seem like a good system - I would appreciate any suggestions.

like image 321
uzo Avatar asked Sep 20 '09 18:09

uzo


2 Answers

I agree with Jon that branches are the solution, but I would create branches for features rather than for the individual improvements that make up a feature. The workflow pattern would then be this:

  1. Create branch for feature A.
  2. Complete work for improvement A and commit.
  3. Complete work for improvement B and commit.
  4. When the feature seems to be working, merge the feature A branch back into trunk.

If you find a mistake in an improvement A of feature A, instead of starting over, you switch to the feature A branch and do the following:

  1. Fix improvement A and commit.
  2. Merge the feature A branch back into trunk.
like image 174
las3rjock Avatar answered Nov 20 '22 02:11

las3rjock


You could isolate the changes for the improvements into branches maintaining a stable trunk.
Take a look at Branch wiki page.

Workflow pattern would be:

  1. Create branch for improvement A
  2. Complete work for improvement A and checkin
  3. Test changes and merge back into trunk if successful
  4. Create branch for improvement B
  5. Complete work for improvement B and checkin
  6. Test changes and merge back into trunk if successful

If you find a mistake you can abandon the branch (or correct the bug in the branch prior to merging back into trunk).

like image 7
Jon Avatar answered Nov 20 '22 01:11

Jon