Reputation: 893
When using a versioning system, one is often tempted producing 'clean' commits, ie commits that actually make sense, and are compilable (and nice to read for other developers).
As a natural effect of this, commits are usually done pretty late ('when it works').
It mitigates one of the benefits of version control : being able to revert to a state where 'it used to work' and where you wouldn't have rage-deleted a huge chunk of code which wasn't yet committed.
Eclipse has a built-in function for this (local history), but it is IDE dependent.
Is there any similar mechanism with one of the popular VCS (git, mercurial..), potentially as an extension/plugin?
Ideally, it wouldn't interfere with the main commit history, but maintain a parallel 'history of uncommitted changes'.
If such a thing doesn't exist, I might be tempted to write one.
Clarification : I'm well aware of the local branch + rebase or histedit, but I'm asking for an automated and easy to setup solution. If I have to commit frequently I may has well forget/get lazy about doing it, especially if it implies manual clean up (the rebase part) later, for each real commit. The main goal is to provide a safety net for the developer, and people usually realise they need that net just when they are already falling...
Upvotes: 2
Views: 111
Reputation: 1216
In mercurial, the way I do exactly this is to use "hg commit --amend" in conjunction with the evolve extension.
Normally, (assuming your current revision is a head changeset) "commit --amend" will modify your current parent changeset. So you would do this at each point you decide you have something worth saving. This keeps the history clean as you desire.
When used in conjunction with the evolve extension, "commit --amend" preserves the previous commit as a hidden changeset. These hidden changes are visible using "hg log -hidden" (and also in tortoise when the right button is pressed). So you can go back and view all your partial work, but the hidden changesets will not be pushed.
PS. Don't worry too much about the "experimental" status of the evolve extension. It's well tested.
Upvotes: 0
Reputation: 97282
You can have (in Mercurial, f.e ):
push -b $MAINLINE
instead of default "push-all" you'll not publish any unfinished work)Upvotes: 0
Reputation: 1533
I am not aware of any tool that does this, but you can do it using Git.
Create a local branch and work on that (commit often, revert, etc).
Once you are happy with the work, you can use git rebase -i
to squash all the small commits into one (or more) large commits into your development branch.
Upvotes: 3