Changeset 237
- Timestamp:
- Oct 8, 2008, 8:49:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r236 r237 12 12 use File::Compare; 13 13 use File::Copy; 14 use File::Find; 14 15 use File::stat; 15 16 use File::Path; … … 36 37 my $svnCheckoutCredentials = ""; 37 38 my $svnPasswordCredentials = ""; 39 my $DIFF = "diff --exclude .svn "; 38 40 39 41 # command line options get stored in options hash … … 218 220 { 219 221 my $filename_prod = $_[0]; 222 223 # remove leading './' from relative directories 224 #$filename_prod =~ s/^\.\///; 225 220 226 if ( !( $filename_prod =~ m/^\// ) ) { 221 227 $filename_prod = cwd() . "/" . $filename_prod; … … 224 230 if( not -r $filename_prod ) { 225 231 fatalerror( $filename_prod . " is not accessable" ); 226 } elsif( -l $filename_prod ) { 227 my $dest = readlink($filename_prod); 228 # TODO: 229 # default: disallow, but offer cmd switch to activate 230 # (or check, if file is already checked in and has been a link before) 231 warning( "'$filename_prod' is a link to '$dest'.", "Please check, if '$dest' should be stored in repository instead" ); 232 if( ! -f $dest ) { 233 fatalerror( "link target '$dest' is not a regular file. Giving up" ); 234 } 235 } elsif( ! -f $filename_prod ) { 236 fatalerror( $filename_prod . " is not a regular file. Only regular files can be checked in." ); 237 } 232 } 233 # elsif( -l $filename_prod ) { 234 # my $dest = readlink($filename_prod); 235 # # TODO: 236 # # default: disallow, but offer cmd switch to activate 237 # # (or check, if file is already checked in and has been a link before) 238 # warning( "'$filename_prod' is a link to '$dest'.", "Please check, if '$dest' should be stored in repository instead" ); 239 # if( ! -f $dest ) { 240 # fatalerror( "link target '$dest' is not a regular file. Giving up" ); 241 # } 242 # } elsif( ! -f $filename_prod ) { 243 # #fatalerror( $filename_prod . " is not a regular file" ); 244 # } 238 245 239 246 # TODO: dirname buggy: eg. "/etc/" is reduced to "/", 240 247 # "/etc" is used as filename 241 248 my $dirname_prod = dirname($filename_prod); 249 my $oldpath = cwd(); 242 250 chdir $dirname_prod or die $!; 243 251 $dirname_prod = cwd(); 252 chdir $oldpath; 244 253 my $basename = basename($filename_prod); 245 254 … … 407 416 } 408 417 418 419 sub get_files( @ ) 420 { 421 my @files = (); 422 my @links = (); 423 my @dirs = (); 424 my @others = (); 425 426 if( @_ ) { 427 find( { wanted => sub { 428 my $fullname = cwd() . "/" . $_; 429 if ( -l $_ ) { 430 # soft link 431 # important: check for links first 432 # to exclude them from further checks 433 push( @links, $fullname ); 434 } elsif ( -d $_ ) { 435 push( @dirs, $fullname ); 436 } elsif( -f $_ ) { 437 # regular file 438 push( @files, $fullname ); 439 } else { 440 push( @others, $fullname ); 441 } 442 } }, @_ ); 443 } 444 445 # don't rely on others. 446 # If more specific file types are needed, 447 # they will be added 448 return { 449 files => \@files, 450 links => \@links, 451 dirs => \@dirs, 452 others => \@others 453 }; 454 } 455 456 457 409 458 ##################################################################### 410 459 # … … 502 551 } 503 552 553 554 555 # 556 # helper function for "add" command 557 # 504 558 sub add_helper(@) 505 559 { … … 517 571 } 518 572 519 copy( $filename_prod, $filename_repo ) or die"failed to copy $filename_prod to repository: $!";573 copy( $filename_prod, $filename_repo ) or error "failed to copy $filename_prod to repository: $!"; 520 574 521 575 if ( $command eq "add" ) { 522 576 577 my $oldpath = cwd(); 523 578 # already checked in? 524 579 chdir($DASSCM_REPO); … … 538 593 print join( "\n", @out ); 539 594 } 540 } 541 } 595 chdir($oldpath); 596 } 597 } 598 542 599 543 600 # … … 554 611 svn_update(); 555 612 556 # TODO: check all files 557 558 for my $file (@_) { 613 # get all regular files and links 614 my $href_files = get_files( @_ ); 615 616 #print Dumper( $href_files ); 617 618 my @files = @{$href_files->{files}}; 619 my @links = @{$href_files->{links}}; 620 621 if( @files ) { 622 my $number = $#files + 1; 623 print "files to check-in ($number): \n"; 624 print join( "\n", @files ); 625 print "\n"; 626 } 627 628 if( @links ) { 629 my $number = $#links + 1; 630 print "\n"; 631 print "ignoring links ($number):\n"; 632 print join( "\n", @links ); 633 print "\n"; 634 } 635 636 # copy files one by one to local repository 637 for my $file (@files) { 559 638 # add file 560 639 add_helper( $file ); … … 571 650 } 572 651 573 # commit calls $EDITOR. uses "interactive" here, to display output 652 # commit calls $EDITOR. 653 # use "interactive" here, to display output 574 654 my $retcode = 575 655 run_interactive( … … 621 701 622 702 ( my $rc_diff, my @diff ) = 623 run_command( "diff$filename_repo $filename_prod");703 run_command( $DIFF . " $filename_repo $filename_prod"); 624 704 print @diff; 625 705 }
Note:
See TracChangeset
for help on using the changeset viewer.