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..
Function:
===================
svnImport() {
curdir="$1"
ls -1 | while read filename; do
filetime=`ls -ld
--time-style=+'%Y-%m-%dT%H:%M:%S.000000Z' "$filename"|awk '{print
$6}'`
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'."
else
svn propset --revprop -r $rev svn:date
"$filetime">/dev/null
fi
if [ -d "$filename" ]; then
# Recurse
cd "$filename"; olddir="$curdir"
svnImport "$curdir$filename/"
curdir="$olddir"; cd ..
fi
done
}
===================
Example usage:
$ <copy/paste above function>
$ cd stuff-to-import/
$ svn co svn://localhost/my-empty-repo/trunk/ .
$ svnImport
Useful?
---------------------------------------------------------------------
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