[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: original timestamp preservation

From: Molle Bestefich <molle.bestefich_at_gmail.com>
Date: 2005-07-07 12:41:11 CEST

Peter McNab wrote:
> Ben Collins-Sussman wrote:
> > This question keeps coming up, over and over, in both IRC and the
> > users@ list:
> >
> > When I import a project into subversion, why aren't the original
> > timestamps being preserved?
> >
> > A lot of newbies are surprised. Some are frustrated and throw insults
> > at the project. And to make things worse, the answers they get back
> > are mixed.
> Maybe a compromise would satisfy a number of folk, like me.
> I inherited two large code bases, (over 2000 source files and hundreds
> of binary data files) with no recourse to the originating team.
> The only historic information available was contained in the last
> modified date-time stamp for each file.
> On import the whole historic perspective is lost.
> It would be really, really, helpful if the original date-time stamps
> could be preserved at the point of importing them into a their new
> repositories.
> There-after, the most meaningful time is of course the commit time.

That problem can be solved at import time, at least if you're willing
to import each file into it's own revision.

That way you can set the svn:date for each revision, effectively
getting a commit time that corresponds to each file's last
modification time.

Here's an example bash script (function, really) to accomplish just that..

svnImport() {
        ls -1 | while read filename; do
                filetime=`ls -ld
--time-style=+'%Y-%m-%dT%H:%M:%S.000000Z' "$filename"|awk '{print
                echo "Importing $curdir$filename with time $filetime."
                svn add -N "$filename"
                rev=`svn ci -m "Import $filename."|grep -i "committed
revision"|awk '{print $3}'|awk -F. '{print $1}'`
                if [ -z "$rev" ]; then
                        echo "import: skipped '$filename'."
                        svn propset --revprop -r $rev svn:date
                if [ -d "$filename" ]; then
                        # Recurse
                        cd "$filename"; olddir="$curdir"
                        svnImport "$curdir$filename/"
                        curdir="$olddir"; cd ..

Example usage:
$ <copy/paste above function>
$ cd stuff-to-import/
$ svn co svn://localhost/my-empty-repo/trunk/ .
$ svnImport


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 7 12:44:27 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.