I’ve got my IDE set to commit locally every time I save anything. I’d ideally like to keep an uncensored record of my idiot fumblings for the rare occasions they may be useful. But most of the time it makes my history way to detailed.
I’d like to know a good strategy to keep that history but be able to ignore it most of the time. My IDE is running my own script every time I save, so I have control over that.
I’m pretty new to Mercurial, so a basic answer might be all I need here. But what are all the steps I should do when committing, merging, and reporting to be able to mostly ignore these automatic commits, but without actually squashing them? Or am I better off giving up and just squashing?
Edit – My point here is that if Mercurial wants to keep all your history (which I agree with), it should let you filter that history to avoid seeing the stuff you might be tempted to squash. I would prefer not to squash, I’m just asking for help in a strategy to (in regular usage, though not quite always) make it look as much as possible like I did squash my history.
You want to keep a detailed history in your repo, but you want to have (and be able to export) an idealized history that only contains “reasonable” revsets, right? I can sympathize.
Solution 1: Use tags to mark interesting points in the history, and learn to ignore all the messy bits between them.
Solution 2: Use two branches and merge. Do your development in branch
default, and keep a parallel branchrelease. (You could call itclean, but in effect you are managing releases). Wheneverdefaultis in a stable state that you want to checkpoint, switch to branchreleaseand merge into it the current state ofdefault— in batches, if you wish. If you never commit anything directly torelease, there will never be a merge conflict.Result: You can update to any revision of
releaseand expect a functioning state. You can runhg log -r releaseand you will only see the chosen checkpoints. You can examine the full log to see how everything happened. Drawbacks: Because thereleasebranch depends ondefault, you can’t push it to another repo without bringingdefaultwith it. Alsohg glog -r releasewill look weird because of the repeated merges.Solution 3: Use named branches as above, but use the
rebaseextension instead of merging. It has an option to copy, rather than move outright, the rebased changesets; and it has an option--collapsethat will convert a set of revisions into a single one. Whenever you have a set of revisionsr1:tipyou want to finalize, copy them fromdefaulttoreleaseas follows:This pushes ONE revision at the head of
releasethat is equivalent to the entire changeset from r1 to the head ofdefault. The--keepoption makes it a copy, not a destructive rewrite. The advantage is that thereleasebranch looks just as you wanted: nice and clean, and you can push it without dragging the default branch with it. The disadvantage is that you cannot relate its stages to the revisions indefault, so I’d recommend method 2 unless you really have to hide the intermediate revisions. (Also: it’s not as easy to squash your history in multiple batches, since rebase will move/copy all descendants of the “source” revision.)All of these require you to do some extra work. This is inevitable, since mercurial has no way of knowing which revsets you’d like to squash.