I fixed a bug in Oddmu that was driving me nuts. What I want is this: after editing a page, the diff shows you the changes you made in the last hour; if you make many small changes they are collapsed. All I have at my disposal is the file itself and the backup. The code I had would rename the file to the backup file only if the backup file was more than 1h old before saving. Here's what I would do: create file (1), edit file (2), edit the file (3), wait an hour, edit file (4), edit file (5). The diff at (2) shows the diff from 1→2. The diff at (3) shows the diff from 1→3 (yay!). The diff at (4) shows the diff from 3→4 (yay!). The diff at (5) shows the diff from 4→5 (oh no!). As a user, all I noticed was that sometimes the backup function didn't work as intended. Since I didn't know what had gone wrong, my automated tests only went from 1 to 4. The answer to the problem is that the backup file is made by renaming so its modification time remains unchanged. Thus, when edit 5 is about to be saved, the timestamp of the backup is the timestamp of 3, which is old, and therefore overwritten. As a user who comes back to the page after an hour, however, I would like the last diff to be from 3→5.

The solution is to set the timestamp to "now" after renaming the file to the backup file. That means when edit 4 is about to be saved, 3 is moved to the backup and gets a new timestamp. When 5 is about to be saved, the backup isn't old enough and the diff shows 3→5.

The only thing I feel bad about is that the timestamp of the backup file is no longer the timestamp of the original file but the timestamp of "when it was made the backup file", as if I had copied the file.

I think this is OK?