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

Re: can I insert older versions of files? i.e. "here's backups of 3 months ago - put 'em in right revision order..."

From: Alan Jay Weiner <alan_at_ajw.com>
Date: 2004-07-19 03:52:05 CEST

>Per: Submission of older files into the REPOS, retain older date

>> > Maybe it's not worth it, but if it's possible to do, I'd really like to.
>>
>> It's not possible to do what you want. The only thing you can do is
>> what the rest of us have done:
>
>Actually, I just posed a similar question last week. I'll summarize
>what I have figured out so far....

Thanks, FRuG!
These notes did indeed help me! I'll expand on them to help others; I'm
running on Win2k and discovered some things...

>BACKGROUND NOTES:
>
>1) After importing the files into the REPOS, they'll have the 'current
>date/time' as the file date.

ick - hadn't realized that until I'd gone through my backups, committing all the
changes... so it looks like the entire project starts on 17 Jul 2004 - man, I
did a lot of work that day! :)

>2) When you 'export/checkout' the files, they'll have have "today's"
>date/time.
>
>3) You can retain original date/times, by turning on the
>'~/.subversion/config' option 'use-commit-times=yes'.
>
>4) You can turn on 'use-commit-times' globally for the whole system.
> (on the system that you are checking out files, /etc/subversion/config)

Thank you! I've set this on my system. For Windows users, you'll find
"config" in the user directory; on my machine it's:
C:\Documents and Settings\aweiner\Application Data\Subversion
(my user name is aweiner of course :)

That directory has config, servers, and README.txt, and an auth subdirectory
(automatically created when svn runs, if I remember correctly)

Edit config so you have these lines uncommented:

[miscellany]
use-commit-times = yes

I also uncommented: (and added *.obj to the list)

global-ignores = *.o *.obj *.tmp *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store

This is in the [miscellany] section also.

If you want to make these options global for everyone, copy that
C:\Documents and Settings\aweiner\Application Data\Subversion
directory (with config and servers files) to
C:\Documents and Settings\All Users\Application Data\Subversion

(qualification: I'm pretty sure that's right - I haven't done it yet 'cause
I'm just running Subversion locally on my notebook. And you probably should
*not* copy the "auth" subdirectory)

>SOLUTIONS:
>
>Here's two solutions . . . based on feedback from the 'Subversion
>Users' list and some of my own ideas:
>
>1) Use the 'svn:date' property to set the file date. [1]
> (I'm currently experimenting with a script to restore the dates
>after import)

I started playing with this - seems to work reasonably well. If I read things
right, then committing each file individually (creating a revision for each
file) then setting that revision to the desired timestamp will keep the files
matching the file's timestamp in my backups.

Yeah, seems like a lot of work for something I'll probably never care about...
:)

NOTES about changing svn:date on Windows:

1) the property name is 'svn:date' - the colon doesn't assign any meaning other
than it being a reserved name; i.e., ':' is just another letter. You could
create a property named "fred" if you want.
(I think this is right - confirmation, anyone?)

2) In order to change revision properties you need to create pre-revprop-change
and post-revprop-change scripts.
I believe they can be empty; they just need to exist to permit revision property
changes. (maybe they are needed - to return a "success" return code...)

They are both in the repository in the "hooks" directory. Subversion initially
populates that directory with templates (*.tmpl) for these hooks.

For Windows, they're batch (*.BAT) files.

NOTE WELL: the "success" return value for Windows is 0; the template returns 1
for success. Also note the changes to use Windows batch-file notation: % as a
environment-variable mark, double-equals in the if statement, etc.

NOTE: I tried doing "echo" messages and "pause" commands and had trouble - it
works in the post script, but didn't seem to work right in the pre-change
script. Not sure if I did something wrong or if it just doesn't work right in
the pre-change script. Just a warning...

Here's my pre-revprop-change.BAT file:

set REPOS=%1
set REV=%2
set USER=%3
set PROPNAME=%4

if "%PROPNAME%"=="svn:log" (
        set returnval=1
) else (
        set returnval=0
)

exit %returnval%

And here's my post-revprop-change.BAT file:

set REPOS=%1
set REV=%2
set USER=%3
set PROPNAME=%4

propchange-email.pl "%REPOS%" "%REV%" "%USER%" "%PROPNAME%" email@domain.com

You can comment out the last line if you don't have Perl or don't want
property-change emails...

The command to show the properties for the most recent revision ("HEAD") is:
        svn proplist -v --revprop -r head

This will show something like:

        Unversioned properties on revision 3:
          svn:log : Removed file/folder
          svn:author : TVPVR
          svn:date : 2004-07-17T21:27:21.625000Z

The date format is ISO 8601, see http://www.w3.org/TR/NOTE-datetime

It is in this format: (this is copied from that page)
              YYYY-MM-DDThh:mm:ss.sTZD
where:
     YYYY = four-digit year
     MM = two-digit month (01=January, etc.)
     DD = two-digit day of month (01 through 31)
     hh = two digits of hour (00 through 23) (am/pm NOT allowed)
     mm = two digits of minute (00 through 59)
     ss = two digits of second (00 through 59)
     s = one or more digits representing a decimal fraction of a second
     TZD = time zone designator (Z or +hh:mm or -hh:mm)

(Note the 'T' seperating the date and time)

To set the time of a revision, the command is:

        svn propset svn:date '2004-07-17T12:00:00.000000Z' --revprop -r 3

HOWEVER: if you use the single-quotes in a Windows DOS box (aka "command
prompt") you'll get the error:
        svn: 'pre-revprop-change' hook failed with error output:

(no error output is given; just the error message)

NOTE: If you try to look at the repository log, you'll also get an error "Date
parsing failed"

Google is your friend; I found an archived message at
http://www.contactor.se/~dast/svnusers/archive-2004-05/0748.shtml
that says the single-quotes get saved as part of the svn:date property value (on
Windows)

So the *real* command to use is:
        svn propset svn:date 2004-07-17T12:00:00.000000Z --revprop -r 3
You'll get a response:
        property 'svn:date' set on repository revision '3'

And
        svn proplist -v --revprop -r 3

will then return:
        Unversioned properties on revision 3:
          svn:log : Removed file/folder
          svn:author : TVPVR
          svn:date : 2004-07-17T12:00:00.000000Z

>2) Dump the entire REPOS, then 'by a script' modify the commit times
>in that file for each
> file based on original files-date/times. Then re-import into a new REPOS.

Haven't tried dumping the REPO - may do that to see about how I could insert
intermediate backups (i.e., "I just found another backup from November..." :)

But that also - do I really care???

Yeah, I would - if someone *else* had done the work to import all the backups!
(big grin!!)

>Neither one is 'elegant' nor clean.

Yeah, and for limited likely use...

>FEATURE REQUEST:
>
>Ability to 1) Import or 2) Check-in , with SVN and retain the file
>dates, per option '--retain-file-dates' (or something like that). :)

I would *very* much like this too - I'm rather anal about timestamps, and it
really bothers me that they could change...

(to be honest - I think it's more that I'm used to a certain way of working, and
Subversion is a bit different. Not necessarily better/worse - just I'm old and
cranky and don't wanna change... I suspect once I'm using it for a few months
and it's all second-nature, I won't care about it at all...)

>
>Thanks,
>-FRuG
>
>Notes:
>[1] Original message:
>------------------------------------------------------------------------------------------------
>Ben Collins-Sussman <sussman@collab.net> Fri, 09 Jul 2004 19:50:43 -0500
>
>Here's a possible trick:
>
>Organize your files into buckets, categorized by original dates. Then
>commit each "bucket" of files in chronological order. This results in a
>bunch of revisions in the repository. Then you can tweak each
>revision's 'svn:date' property, so it *appears* that each bucket of
>files was committed on a certain date.
>
>In other words, because a revision's svn:date property is tweakable, you
>can make the "commit times" of the files match the original times.
>------------------------------------------------------------------------------------------------

Ah - this is what I just asked Ben... I guess it *will* work... :)

The downside (or at least one...) is that any particular revision will not be a
complete change; some files will have been committed while others haven't yet.
But making a tag after the last file is committed would do it.

Thanks again Ben and FRuG!

- Al -

-- 
--  Alan Weiner  --  alan_at_ajw.com  --  http://www.ajw.com
Palm OS Certified Developer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Jul 19 03:53:01 2004

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