updated git and svn scripts
[xrzperl.git] / svndump
blob1b0e5f20371b35857c5fcca0ba79cf678ebf41c2
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 our $PROGRAM_DIR = $ENV{XR_PERL_SOURCE_DIR};
10 unless($PROGRAM_DIR) {
11 $PROGRAM_DIR = $0;
12 $PROGRAM_DIR =~ s/[^\/\\]+$//;
13 $PROGRAM_DIR =~ s/\/+$//;
14 $PROGRAM_DIR = "." unless($PROGRAM_DIR);
16 unshift @INC,
17 map "$PROGRAM_DIR/$_",qw{modules lib ../modules ..lib};
20 my %OPTS;
21 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man/;
23 if(@ARGV)
25 require Getopt::Long;
26 require MyPlace::Usage;
27 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
28 MyPlace::Usage::Process(\%OPTS,$VERSION);
30 else
32 require MyPlace::Usage;
33 MyPlace::Usage::PrintHelp();
34 exit 0;
37 sub run {
38 my $exit = system(@_);
39 die("fatal error: $! while executing [",join(" ",@_),"]\n") if($exit);
40 return 1;
42 sub create_repo {
43 my $DEST = shift;
44 if(! -d $DEST) {
45 print STDERR "creating local repository $DEST...\n";
46 run(qw/svnadmin create/,$DEST);
47 my $hook = "$DEST/hooks/pre-revprop-change";
48 print STDERR "creating pre-revprop-change hook in $DEST...\n";
49 open FO,'>',$hook or die("fatal error\n");
50 print FO "#!/bin/sh\nexit 0\n";
51 close FO;
52 run(qw/chmod a+x/,$hook);
57 my $action = shift;
58 my $dst = shift;
59 unless($dst) {
60 $dst = $action;
61 $action = 'load';
64 if($action eq 'load') {
65 create_repo($dst);
66 run('svnadmin','load',$dst);
68 else {
69 run('svnadmin',$action,$dst,@ARGV);
74 __END__
76 =pod
78 =head1 NAME
80 svndump - PERL script
82 =head1 SYNOPSIS
84 svndump [options] ...
86 =head1 OPTIONS
88 =over 12
90 =item B<--version>
92 Print version infomation.
94 =item B<-h>,B<--help>
96 Print a brief help message and exits.
98 =item B<--manual>,B<--man>
100 View application manual
102 =item B<--edit-me>
104 Invoke 'editor' against the source
106 =back
108 =head1 DESCRIPTION
110 ___DESC___
112 =head1 CHANGELOG
114 2010-11-21 03:48 xiaoranzzz <xiaoranzzz@myplace.hell>
116 * file created.
118 =head1 AUTHOR
120 xiaoranzzz <xiaoranzzz@myplace.hell>
122 =cut
124 # vim:filetype=perl