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

Re: Status of meta-data-versioning (mod time)?

From: Oliver Betz <list_ob_at_gmx.net>
Date: 2005-07-13 09:10:38 CEST

Dirk Schenkewitz <schenkewitz@docomolab-euro.com> wrote:

> >>- People, including me, want to know "when was the last change to
> >> that file?", even if the file was laying around for some time
> >> (months/years!) before being put under subversion control. This
> >> problem cannot be solved using --use-commit-times.
> >
> > It can if you make one commit per file on initial import. Slow and
> > ugly, but it works tolerably.
>
> No, it does not work at all. "use-commit-times = yes" sets the mtime
> of a checked out file to the time of the commit, the original mtime is
> lost when the next one does a checkout that creates this file. I just

right, but the commit shouldn't be so long past the modification, so
you get approximately the time when the file was modified last.

My problem was to keep the timestamp on initial import of "legacy"
projects.

BTW: I repeat my suggestion that a commit using "use-commit-times"
should "touch" the files so that the wc has the same timestamp as the
commit time.

> tested, with "use-commit-times = yes":

[example snipped]

> If you do commits for each single file at a time, you can keep the
> *order* of the original mtimes, that's all.

in your example, you added the file without tweaking the svn:date
property of the commit.

[my "adjust commit time" hack]

> If I may I ask: How do you do that? Maybe it is your hack that would

see below. Comments welcom, I'm not a Perl monk.

Oliver

- snip -

#!/usr/bin/perl
# import files to subversion one by one and adjust commit date to file's mtime
# this method is extremly slow!
# directory timestamps are not kept ad commits are not in chronological order

# 2005-07-11 Oliver Betz

# caution: stat() fails on filenames with foreign characters.
# maybe conflicting translations from svn and perl?

use strict;

use HTTP::Date qw(time2isoz);
use File::stat; # by-name access to mtime

my $rev; # revision of committed file
my @svnstat; # list of files
my $filename; # path to current file
my $mtime; # mtime of current file
my $more = 1; # process more directories

$ENV{Lang}="C"; # else we might get localized responses

while ($more){
  $more = 0; # assume we had nothing more to do
  @svnstat = split /\n/, `svn stat`; # get all (not ignored) files
  foreach (@svnstat) {
    next unless $_ =~ /^\?.....\s+(\S.+)$/; # use only files not yet under version control
    $filename = $1;
    if (-d $filename) {$more = 1}; # we add another directory -> repeat loop
    $mtime = (stat($filename))->mtime;

    print `svn add -N "$filename"`; # put under svn control
    $rev=`svn ci -m "mtime keeping add of $filename"`; # commit this file immediately
    print "$rev"; # complete response (several lines)
    die "wrong response $rev" unless $rev =~ /Committed revision (\d+)\./;
    $rev = $1; # numerical value -> $rev
    $mtime = time2isoz($mtime);
    $mtime =~ s/\s/T/; # special format of svn time: 2005-07-11T09:17:35.000000Z
    $mtime =~ s/Z/.000000Z/; # svn time has us resolution
    `svn propset svn:date $mtime --revprop -r $rev`;
  };
}
print "ready\n";

__END__

-- 
Oliver Betz, Muenchen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Jul 13 09:12:14 2005

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