Steve Cohen
Steve Cohen

Reputation: 4859

Is it possible to create an SVN tag, preserving the timestamps of the source files?

It seems that when using svn copy to create a tag, all files get the current timestamp. I would like to have an exact duplicate including the timestamps of the original files. Is this possible?

Upvotes: 0

Views: 372

Answers (2)

David W.
David W.

Reputation: 107040

How did you create a tag? Did you use svn cp on a working directory you've checked out somewhere, or did you use the URL form of the svn copy command? To create tags and branches, you should use the URL form:

$ svn cp --parents -r$rev \
    -m"Creating tag 4.10 for project from Revision $rev" \
    http://repo/svn/trunk/proj@$rev http://repo/svn/tags/4.10/proj

Note I use -m to set the commit message because the copy is done on the server and committed immediately. If I didn't include this, and SVN_EDITOR or EDITOR is set, you'll be asked for a commit message.

Note I also use --parent and I use -r and revision pinning (the @$rev on the end). This makes sure I tag the revision I want. The --parents will automatically create any parent directories if they are missing. It never hurts to have it.

No working directory is involved. Everything is done directly on the server. No physical files are copied over.

If you do it this way, the timestamps of the files in the tags are the same as what they were on the trunk or the branch. It will be the timestamp of their last commit. If you do svn cp on local files, the copied files will have the timestamp of when you did the copy. Not to mention that it takes much longer to do.

Upvotes: 0

DJ.
DJ.

Reputation: 6784

You'll need to turn on use-commit-times configuration. This is the snippet of that configuration from SVN Book

use-commit-times

Normally your working copy files have timestamps that reflect the last time they were touched by any process, whether your own editor or some svn subcommand. This is generally convenient for people developing software, because build systems often look at timestamps as a way of deciding which files need to be recompiled.

In other situations, however, it's sometimes nice for the working copy files to have timestamps that reflect the last time they were changed in the repository. The svn export command always places these “last-commit timestamps” on trees that it produces. By setting this config variable to yes, the svn checkout, svn update, svn switch, and svn revert commands will also set last-commit timestamps on files that they touch.

Upvotes: 1

Related Questions