- Timestamp:
- Dec 6, 2004, 5:42:11 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r195 r196 12 12 use File::Copy; 13 13 #use POSIX qw/getpgrp tcgetpgrp/; 14 use Getopt::Long; 14 15 15 16 ##################################################################### … … 19 20 my $SVN = "svn "; 20 21 my $svnOptions = ""; 22 # command line options get stored in options hash 23 my %options = (); 24 my $command; 21 25 22 26 ##################################################################### … … 75 79 $DASSCM_USER=$USER; 76 80 } 77 $svnOptions .= " --username $DASSCM_USER "81 #$svnOptions .= " --username $DASSCM_USER " 78 82 } 79 83 … … 107 111 } 108 112 113 109 114 sub run_command 110 115 { … … 125 130 126 131 132 133 sub run_interactive 134 { 135 system( @_ ); 136 if ($? == -1) { 137 printf "failed to execute: $!\n"; 138 } elsif ($? & 127) { 139 printf "child died with signal %d, %s coredump\n", 140 ($? & 127), ($? & 128) ? 'with' : 'without'; 141 } elsif( $? >> 8 != 0 ) { 142 printf "child exited with value %d\n", $? >> 8; 143 } 144 } 145 return( $? >> 8 ); 146 } 147 148 127 149 ##################################################################### 128 150 # … … 138 160 } 139 161 162 # 163 # add (is used for command add and commit) 164 # 140 165 sub add(@) 141 166 { … … 145 170 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 146 171 147 mkpath($dirname_repo); 172 if( $command eq "add" ) { 173 mkpath($dirname_repo); 174 } 148 175 149 176 # update complete repository 150 # (my $retcode, my @result)=run_command( "$SVN update $DASSCM_REPO" ); 151 # if( $retcode != 0 ) { 152 # print @result; 153 # die; 154 # } 155 system( "$SVN update $svnOptions $DASSCM_REPO" ); 177 my $retcode = run_interactive( "$SVN update $svnOptions $DASSCM_REPO" ); 156 178 157 179 copy( $filename_prod, $filename_repo ) or die $!; 158 180 159 # already checked in? 160 chdir($DASSCM_REPO); 161 # also add the path to filename. 162 for my $dir (split('/', $dirname_prod) ) { 163 if( $dir ) { 164 run_command( "$SVN add --non-recursive $dir" ); 165 chdir $dir; 181 if( $command eq "add" ) { 182 # already checked in? 183 chdir($DASSCM_REPO); 184 # also add the path to filename. 185 for my $dir (split('/', $dirname_prod) ) { 186 if( $dir ) { 187 run_command( "$SVN add --non-recursive $dir" ); 188 chdir $dir; 189 } 166 190 } 167 } 168 run_command( "$SVN add $basename" ); 191 run_command( "$SVN add $basename" ); 192 } 193 194 if( $options{'message'} ) { 195 $svnOptions .= " --message $options{'message'} "; 196 } 169 197 170 198 # commit calls $EDITOR. uses "system" here, to display output 171 system( "$SVN commit $svnOptions $DASSCM_REPO" ); 172 # TODO: commit (-m) 199 my $retcode = run_interactive( "$SVN commit $svnOptions --username $DASSCM_USER $DASSCM_REPO" ); 173 200 174 201 print $filename_prod."\n"; … … 184 211 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 185 212 186 system( "$SVN blame $svnOptions $filename_repo" ); 187 } 188 189 190 191 sub commit(@) 192 { 193 check_parameter(@_,1); 194 check_env(); 195 196 (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]); 197 198 # (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" ); 199 # if( $rc_update != 0 ) { 200 # print @result; 201 # die; 202 # } 203 system( "$SVN update $svnOptions $DASSCM_REPO" ); 204 205 copy( $filename_prod, $filename_repo ) or die $!; 206 207 # commit calls $EDITOR. uses "system" here, to display output 208 system( "$SVN commit $svnOptions $filename_repo" ); 209 # TODO: commit (-m) 210 } 213 my $retcode = run_interactive( "$SVN blame $svnOptions $filename_repo" ); 214 } 215 216 211 217 212 218 sub diff(@) … … 238 244 239 245 if ($number_arguments > 0) { 240 my $command = $ARGV[0]; 246 # get subcommand and remove it from @ARGV 247 $command = $ARGV[0]; 241 248 shift @ARGV; 242 #$command =~ s/[A-Z]/[a-z]/m; 243 #print "$command\n"; 249 250 251 # get command line options and store them in options hash 252 my $result = GetOptions ( \%options, 'message=s' ); 253 foreach my $option (keys %options) { 254 print $option.": ".$options{$option}."\n"; 255 } 244 256 245 257 $_=$command; … … 247 259 help(@ARGV); 248 260 } elsif (m/add/i) { 249 add(@ARGV); 261 # rewrite command. just to make sure 262 $command = "add"; 263 add( @ARGV); 264 } elsif (m/commit/i) { 265 # rewrite command. just to make sure 266 $command = "commit"; 267 add( @ARGV); 250 268 } elsif (m/blame/i) { 251 269 blame(@ARGV); 252 } elsif (m/commit/i) {253 commit(@ARGV);254 270 } elsif (m/diff/i) { 255 271 diff(@ARGV);
Note:
See TracChangeset
for help on using the changeset viewer.