undo + mv => unexpected
Matthew Dillon
dillon at apollo.backplane.com
Wed Jul 16 14:22:26 PDT 2008
:`undo -i' seems to track the wrong file after mv, see below.
:Contents of file is correct;
:`hammer history' seems correct.
:
: -thomas
Ok, I figured out what is going on here. What is happening is
that doing a 'rename' does not modify the file, so no new history
is being added. A file create modifies the file, of course. A 'rm'
will also modify the file because it drops the hardlink count by 1,
but a 'mv' does not have to modify the file.
The undo program fetches the history internally in order to get the
most recent transaction id, and then tries to open the file using
that transaction id before printing the history.
however, when you've mv'd the file, that transaction id will be prior
to when the mv was made, so undo's attempt to open the file using
the new name will fail.
Pretty cool!
For the moment, so things work somewhat as expected, I will adjust
the undo program to attempt to open the 'current' file under its new
name if it is unable to open the file via the transaction id. That
will help display the history, but the diff feature will probably still
fail.
So undo isn't going to be perfect, it will not be able to access the
file for any period prior to it being renamed unless you also know
the original name (prior to the mv). If you do know that name then you
are golden.
-Matt
More information about the Bugs
mailing list