Suma
Suma

Reputation: 34413

SVN commit with old date/time

Is there some way how to commit into the SVN repository with old time / date or how to edit the time / date post commit?

I have some archived sources which are very old, way before I have started using SVN, and I would now like to put them into the SVN and if possible to preserve their original date, so that SVN history matches the real date where files were edited.

Manipulating SVN server time is an obvious option, but it cannot be used here, as the SVN server is out of my control.

Upvotes: 13

Views: 14774

Answers (3)

Suma
Suma

Reputation: 34413

What I did eventually was:

  • install VisualSVN server on my workstation
  • create a new "local" SVN repository
  • take archives one by one, for each:
    • in the working copy delete everything but .svn file, to make sure files which were deleted are not left over
    • decompress the archive into the working copy
    • change system date to the date of the archive
    • add and delete as necessary and commit into the local repository
  • once done, use svnadmin dump the repository
  • on the main SVN server load the dump using svnadmin load

The steps above seem easier to me than installing the pre-revprop-change hook. (The one we currently have in place allows editing log message only.)

Note: instead of changing system date it would be also possible to edit the date in the dump file before loading it.

Upvotes: 1

Craig McQueen
Craig McQueen

Reputation: 43446

The date and time is in the "special" revision property, svn:date. You can modify it as so:

svn propedit svn:date --revprop -r 12345

or:

svn propset svn:date --revprop -r 12345 2009-02-12T00:44:04.921324Z

The revision (e.g. 12345 above) can also be HEAD meaning the latest revision.

The date is specified in ISO 8601 format.

You will need the repository to have the appropriate pre-revprop-change hook set up (in the hook directory in the repository) to allow svn:date to be modified. The templates that are provided with SVN repositories should be helpful.

Upvotes: 18

Dingo
Dingo

Reputation: 3395

Each revision has a property, svn:date. If you have permission to modify unversioned properties, you can change that value.

Upvotes: 2

Related Questions