- Timestamp:
- Nov 9, 2004, 10:17:50 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r186 r187 17 17 18 18 # util functions 19 sub usage() 20 { 21 print "dasscm is intended to help versioning configuration files\n"; 22 } 23 19 24 sub check_env() 20 25 { … … 43 48 } 44 49 45 sub run_command 46 { 47 my $command = shift; 48 49 print "executing command: " . $command . "\n"; 50 51 open(RESULT, $command . ' 2>&1 |' ); 52 my @result = <RESULT>; 53 close(RESULT); 54 my $retcode = $?>>8; 55 56 print @result; 57 if( $retcode ) { print "return code: " . $retcode . "\n"; } 58 59 return($retcode, @result); 60 } 61 62 63 64 # functions 65 66 sub help(;@) 67 { 68 print "help for @_\n"; 69 } 70 71 sub add(@) 72 { 73 check_parameter(@_,1); 74 check_env(); 50 sub get_filenames(@) 51 { 75 52 my $filename_prod = $_[0]; 76 53 if ( !($filename_prod =~ m/^\//) ) { … … 93 70 my $filename_repo = "$dirname_repo/$basename"; 94 71 72 return ($basename,$dirname_prod,$dirname_repo,$filename_prod,$filename_repo); 73 } 74 75 sub run_command 76 { 77 my $command = shift; 78 79 #print "executing command: " . $command . "\n"; 80 81 open(RESULT, $command . ' 2>&1 |' ); 82 my @result = <RESULT>; 83 close(RESULT); 84 my $retcode = $?>>8; 85 86 #print @result; 87 #if( $retcode ) { print "return code: " . $retcode . "\n"; } 88 89 return($retcode, @result); 90 } 91 92 93 94 # functions 95 96 sub help(;@) 97 { 98 print "help for @_\n"; 99 } 100 101 sub add(@) 102 { 103 check_parameter(@_,1); 104 check_env(); 105 106 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 107 95 108 mkpath($dirname_repo); 96 109 97 110 # update complete repository 98 run_command( "$SVN update $DASSCM_REPO" ); 111 (my $retcode, my @result)=run_command( "$SVN update $DASSCM_REPO" ); 112 if( $retcode != 0 ) { 113 print @result; 114 die; 115 } 99 116 100 117 copy( $filename_prod, $filename_repo ) or die $!; … … 119 136 } 120 137 138 sub commit(@) 139 { 140 check_parameter(@_,1); 141 check_env(); 142 143 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 144 145 (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" ); 146 if( $rc_update != 0 ) { 147 print @result; 148 die; 149 } 150 151 # commit calls $EDITOR. uses "system" here, to display output 152 system( "$SVN commit $DASSCM_REPO" ); 153 # TODO: commit (-m) 154 } 155 156 sub diff(@) 157 { 158 check_parameter(@_,1); 159 check_env(); 160 161 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 162 163 #print "$basename,$dirname_prod,$dirname_repo\n"; 164 165 (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" ); 166 if( $rc_update != 0 ) { 167 print @result; 168 die; 169 } 170 171 (my $rc_diff, my @diff)=run_command( "diff $filename_repo $filename_prod" ); 172 print @diff; 173 } 121 174 122 175 # main 123 176 124 177 my $number_arguments = @ARGV; 125 print "$number_arguments\n";178 #print "$number_arguments\n"; 126 179 127 180 if ($number_arguments > 0) { … … 142 195 } elsif (m/activate/i) { 143 196 activate(@ARGV); 144 } 145 } 197 } else { 198 usage(); 199 check_env(); 200 } 201 }
Note:
See TracChangeset
for help on using the changeset viewer.