Shelve extension

Peter Hosey boredzo at gmail.com
Mon Feb 23 13:03:02 CST 2009


On Feb 23, 2009, at 10:41:22, Martin Geisler wrote:
>> 1. Add some changes to the index.
>> 2. Go for lunch.
>> 3. Review the index and working copy.
>> 4. Find that you missed a change that should be in the index.
>> 5. Add that.
>> 6. Refill your coffee/tea/soda/water container.
>> 7. Commit the index.
>> 8. Review the working copy.
>> 9. Add the rest of the changes.
>> 10. Commit #2.
>>
>> I'm certainly not a frequent Git user, but I do think the index is  
>> its
>> most important contribution to the field of version control.
>
> When the changes are in separate files, is this any different from:
>
> 1. hg commit -m 'Fixed bug.' foo.c foo.h
> 2. Go for lunch.
> 3. Review the last commit and working copy.
> 4. Find that you missed a change that should be in the last commit.
> 5. hg revert; hg commit -m 'Fixed bug.' foo.c foo.h bar.c
> 6. Refill your coffee/tea/soda/water container.
> 7. -- no need to commit here
> 8. Review the working copy.
> 9. Add the rest of the changes.
> 10. Commit #2.

For one thing, I think you meant rollback. :)

Other than that, not much. You probably won't have step 9 either.

But the key phrase in your example is “when the changes are in  
separate files”. Interactive commit (or add) is for the case when  
they aren't in separate files.

In that situation, the hg case becomes:

1. hg record -m 'Fixed bug.' foo.{h,c}
2. Go for lunch.
3. Review the last commit.
4. Find that you missed a change that should be in the last commit.
5. hg rollback
6. hg record -m 'Fixed bug.' foo.{h,c} (all over again)
7. Refill your coffee/tea/soda/water container.
8. Review the working copy.
9. hg record -m 'More changes' foo.{h,c}

Notice step 6: Go through all the changes all over again, including  
the ones you committed in step 1 (and had to roll back in step 5).  
With the index, you would simply go through the changes you haven't  
yet added, find the one you want, and add only that change (or only  
those changes) to the index.




More information about the Mercurial mailing list