tags:

views:

140

answers:

3

According to the guide, under the heading: Fixing errors in earlier revisions, it states this:

When you find a bug in some earlier revision you have two options: either you can fix it in the current code, or you can go back in history and fix the code exactly where you did it, which creates a cleaner history.

  1. How does going back in history make it cleaner? It still makes a new changeset at tip.
  2. Does it have something to do with what is recorded as it's parent?
  3. Is there a way to view the logs seeing the newly inserted changeset in that order?
  4. This lesson is under the main heading of Lone developer with nonlinear history. Is this good practice when working on a team?
A: 

I'm more familiar with subversion, but if you are allowed to make changes in "the past" then that would mean that you can alter all branches of a specific repository.

In other words, if you make a mistake in revision 100, and branch the code, the mistake will persist in both branches. Instead of fixing the code in both branches separately, you could fix the mistake once, in revision 100, and have it propagate down both branches.

kurige
Changing an existing committed revision is not recommended in either subversion nor mercurial. Mercurial specifically enables this behavior by the way it easily merges branches. I don't think subversion experience helps here.
Jason R. Coombs
You say it's not recommended, but your post above is all pros. I don't see why you *wouldn't* want to. Is my post above mistaken in any way? It would be very helpful if you would elaborate.
kurige
You don’t actually *change* the old commits and the fix won’t propagate automatically to all commits in-between. (That wouldn’t work anyway, because it would mean that you’d have to deal with loads of merge conflicts at each step.) What you do is fixing it on another branch and then merge that branch back to trunk.Changing the old commits would mean that they’d all get new ids and all your colleagues writing on the code would have to manually switch branches. It’d be a complete mess.
Debilski
@Debilski: exactly... I do this regularly and I'm in no way *changing* an old commit : )
Webinator
+3  A: 

1) It makes it cleaner by providing the fix closer to the creation of the bug. Thus, if you had multiple clones after the bug, each could pull in the fix changeset(s) which don't include any code related to subsequent changes. It does create a new changeset (tip). You will then want to merge that fix with all clones where relevant.

2) Yes. Because you're cloning the code where the bug was created, the revision history refers directly to the changeset where the bug originated, so it helps document (directly and not just through comments) why the change exists.

3) The changeset will never appear inserted - it must always be merged later in the tree, just as any other clone would be merged.

4) I don't see this approach as diverging from any team approach. In either case, you would need to communicate with the team to indicate where the fix is, or it would be in some master repository where you could merge the fix. I would say this approach is applicable in team environments.

Jason R. Coombs
+2  A: 

It’s cleaner in the sense of being more informative. You’ll end up with a merge commit which shows you via its parents exactly where the bug was introduced and where you removed it.

It’s also cleaner in the way that you’ll have a commit which solely removes the bug and take care about the merging stuff afterwards. That is, when you just fix the bug in the newest version of your code, you’ll have to do both bug fixing and taking care of new stuff at the same time, which makes it less clear, what the actual fix has been.

Debilski