updated git and svn scripts
[xrzperl.git] / svn-resolver
blobc25073f822644f67cb184f15f08ea144a56c26c1
1 #!/usr/bin/perl -w
2 ###APPNAME: svn-resolver
3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Sun May 23 00:40:42 2010
5 ###APPVER: 0.1
6 ###APPDESC: svn-resolver
7 ###APPUSAGE: [ "STATUE_MARK ACTION" ...]
8 ###APPEXAMPLE: svn status | svn-resolver '?add'\n\t svn status | svn-resolver '?delete'\n\t svn status | svn-resolver '?ignore'
9 ###APPOPTION:
10 use strict;
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
14 #OR nothing will work
15 use lib $ENV{XR_PERL_MODULE_DIR};
17 use MyPlace::Script::Usage qw/help_required help_even_empty/;
18 exit 0 if(help_required($0,@ARGV));
19 #exit 0 if(help_even_empty($0,@ARGV));
21 sub process {
22 my $arg=shift @_;
23 my @args = split(/\s+/,$arg);
24 print STDERR join(" ","svn",@args,@_),"\n";
25 system("svn",@args,@_) == 0;
29 sub ignore {
30 open FO,"|-","svn","propset","svn:ignore","-F","-",".";
31 foreach(@_) {
32 print $_,"\n";
34 close FO;
37 sub action {
38 my ($action_exp,$item)=@_;
39 my $action;
40 my $arg;
41 if($action_exp =~ /([^\s]+)\s+(.+)/) {
42 $action = $1;
43 $arg = $2;
45 else {
46 $action = $action_exp;
47 $arg = "";
49 if($action eq 'ignore') {
50 &ignore($arg,$item);
52 else {
53 &process("$action $arg",$item);
57 my %ACTION = (
60 foreach(@ARGV) {
61 if(/\s*(.)\s*(.+)\s*$/) {
62 $ACTION{$1}=$2;
63 # }
64 # else {
65 # die("Unkonw usage!\n");
69 while(<STDIN>) {
70 print STDERR $_;
71 chomp;
72 if(/^\s*(.)\s*(.+)\s*$/) {
73 if($ACTION{$1}) {
74 &action($ACTION{$1},$2);
78 exit 0;