3 #=======================================================================
5 # File ID: 2530c5b0-f744-11dd-a6f8-000475e441b9
6 # Stores the file date in a special svn property.
9 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = "0.00";
36 Getopt
::Long
::Configure
("bundling");
39 "debug" => \
$Opt{'debug'},
40 "directories|d" => \
$Opt{'directories'},
41 "help|h" => \
$Opt{'help'},
42 "verbose|v+" => \
$Opt{'verbose'},
43 "version" => \
$Opt{'version'},
45 ) || die("$progname: Option error. Use -h for help.\n");
47 my $PROP_NAME = "filedate";
50 $Opt{'debug'} && ($Debug = 1);
51 $Opt{'help'} && usage
(0);
52 if ($Opt{'version'}) {
57 for my $File (@ARGV) {
59 my @stat_array = lstat($File);
60 if (scalar(@stat_array)) {
61 if (-d
$File && !$Opt{'directories'}) {
62 warn("$progname: $File: Ignoring directory\n");
64 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
65 $atime, $mtime, $ctime, $blksize, $blocks) = @stat_array;
66 my @TA = gmtime($mtime);
67 my $date_str = sprintf("%04u-%02u-%02uT%02u:%02u:%02uZ",
68 $TA[5]+1900, $TA[4]+1, $TA[3], $TA[2], $TA[1], $TA[0]);
69 mysyst
($CMD_SVN, "propset", $PROP_NAME, $date_str, $File);
72 warn("$progname: $File: Unable to lstat() file\n");
80 my $system_txt = sprintf("system(\"%s\");", join("\", \"", @Args));
91 print("debug: Press ENTER...");
97 # Print program version {{{
98 print("$progname v$VERSION\n");
103 # Send the help message to stdout {{{
106 if ($Opt{'verbose'}) {
112 Define a "$PROP_NAME" property containing the timestamp of a
113 file/symlink/directory on Subversion-controlled files.
115 Usage: $progname [options] [file [files [...]]]
120 Also set the property on directories, default action is to ignore
125 Increase level of verbosity. Can be repeated.
127 Print version information.
129 Print debugging messages.
137 # Print a status message to stderr based on verbosity level {{{
138 my ($verbose_level, $Txt) = @_;
140 if ($Opt{'verbose'} >= $verbose_level) {
141 print(STDERR
"$progname: $Txt\n");
147 # Print a debugging message {{{
149 my @call_info = caller;
150 chomp(my $Txt = shift);
151 my $File = $call_info[1];
153 $File =~ s
#^.*/(.*?)$#$1#;
154 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
161 # Plain Old Documentation (POD) {{{
171 svnfiledate [options] [file [files [...]]]
175 Define a "$PROP_NAME" property containing the timestamp of a
176 file/symlink/directory on Subversion-controlled files.
182 =item B<-d>, B<--directories>
184 Also set the property on directories, default action is to ignore those.
186 =item B<-h>, B<--help>
188 Print a brief help summary.
190 =item B<-v>, B<--verbose>
192 Increase level of verbosity. Can be repeated.
196 Print version information.
200 Print debugging messages.
206 It’s non-standard. The Subversion client doesn’t have anything like this
207 yet, so it will probably change in the future.
211 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
215 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
216 This is free software; see the file F<COPYING> for legalese stuff.
220 This program is free software: you can redistribute it and/or modify it
221 under the terms of the GNU General Public License as published by the
222 Free Software Foundation, either version 2 of the License, or (at your
223 option) any later version.
225 This program is distributed in the hope that it will be useful, but
226 WITHOUT ANY WARRANTY; without even the implied warranty of
227 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
228 See the GNU General Public License for more details.
230 You should have received a copy of the GNU General Public License along
232 If not, see L<http://www.gnu.org/licenses/>.
240 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :