10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
13 map "$PROGRAM_DIR$_",qw{modules lib
../modules
..lib
};
17 my @OPTIONS = qw
/help|h|? version|ver manual|man dump|d/;
22 require MyPlace
::Usage
;
23 Getopt
::Long
::GetOptions
(\
%OPTS,@OPTIONS);
24 MyPlace
::Usage
::Process
(\
%OPTS,$VERSION);
29 print "[$head] ",join(" ",@_),"\n";
35 die("[$head] fatal: ",join(" ",@_)," failed!\n") unless(run
($head,@_));
40 run
(qw
/git remote add/,$name,$url);
41 print "fetch [$name]$url ...\n";
42 run_or_die
(qw
/git fetch -v/,$name);
47 open FI
,"<",$file or return undef;
59 foreach my $m_from (keys %{$MACRO}) {
60 my $m_to = $MACRO->{$m_from};
67 if(m/^([^.=]+)\.([^=]+?)\s*=\s*(.+)$/) {
68 $config{$1}->{$2} = $3;
70 $MACRO->{"\\\$$2\\\$"} = $3;
73 elsif(m/^([^=]+?)\s*=\s*(.+)$/) {
80 $config{MACRO
} = $MACRO;
84 my $F_DUMP = $OPTS{dump};
86 my $REPO_FILE = ".repos";
87 my $REPO_PROP = "gsvn:repos";
88 my $AUTHOR_FILE = ".authors";
95 $target = "." unless($target);
97 print "[$target] init project repos...\n";
101 open FI
,"<",$REPO_FILE or die("$!\n");
105 elsif(-d
".svn" or -d
".SVN") {
106 print STDERR
"[$target] reading $REPO_PROP...\n";
107 @CONFIG_DATA = split("\n",qx/git svn propget gsvn:repos ./);
110 my %CONFIG = parse_config
({'\$target\$'=>$target},@CONFIG_DATA);
113 print Data
::Dumper
->Dump([\
%CONFIG],['*CONFIG']);
117 print "[$target] init stopped, no repos config data found\n";
120 if($CONFIG{user
} and $CONFIG{user
} =~ m/\s*([^<]+)\s*<([^>]+)>/) {
121 my($name,$email) = ($1,$2);
122 run_or_die
($target,qw
/git config user.name/,$name);
124 run_or_die
($target,qw
/git config user.email/,$email);
126 if($CONFIG{authors
}) {
127 print "[$target] writting $AUTHOR_FILE ...\n";
128 open FO
,">",$AUTHOR_FILE or die("$!\n");
129 foreach my $id (keys %{$CONFIG{authors
}}) {
130 my $mapto = $CONFIG{authors
}->{$id};
132 print FO
"$id = $mapto\n";
135 # cat_file($AUTHOR_FILE);
136 # print "[$target] add $AUTHOR_FILE to .gitignore ...\n";
137 # open FO,">>",".gitignore" or die("$!\n");
138 # print FO $AUTHOR_FILE,"\n";
140 # cat_file(".gitignore");
141 run_or_die
($target,qw
/git config svn.authorsfile/,$AUTHOR_FILE);
144 print "[$target] fetching git repositories ...\n";
145 foreach my $reponame (keys %{$CONFIG{git
}}) {
146 my $url = $CONFIG{git
}->{$reponame};
147 run
($target,qw
/git remote add/,$reponame,$url);
148 print "[$target] fetching [$reponame] $url ...\n";
149 run_or_die
($target,qw
/git fetch/,$reponame);
160 foreach my $wd (@ARGV) {
161 chdir $wd or die("$!: $wd\n");
178 gsvn-pull-remote - PERL script
182 gsvn-pull-remote [options] ...
190 Print version infomation.
192 =item B<-h>,B<--help>
194 Print a brief help message and exits.
196 =item B<--manual>,B<--man>
198 View application manual
202 Invoke 'editor' against the source
212 2010-11-02 xiaoranzzz <xiaoranzzz@myplace.hell>
218 xiaoranzzz <xiaoranzzz@myplace.hell>