- Timestamp:
- Mar 3, 2009, 6:18:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r267 r268 36 36 # commands that require write access (and therefore a login) 37 37 # to the repository server 38 my @COMMANDS_REQUIRE_WRITE = ( "add", "commit" );38 my @COMMANDS_REQUIRE_WRITE = ( "add", "commit", "commitall" ); 39 39 40 40 # configuration file … … 50 50 my $StartDirectory = cwd(); 51 51 52 my $diff = "diff --exclude .svn "; 52 53 my $SVN = "svn "; 53 54 my $svnOptions = ""; 54 55 my $svnCheckoutCredentials = ""; 55 56 my $svnPasswordCredentials = ""; 56 my $diff = "diff --exclude .svn "; 57 # flag. Set to true by svn_update 58 # This prevents, that svn_update is called multiple times 59 my $svnRepositoryIsUptodate = 0; 57 60 58 61 # command line options get stored in options hash … … 61 64 # subcommand, that gets executed (add, commit, ...) 62 65 my $command; 66 63 67 64 68 my $verbose = 0; … … 82 86 print " add <filename>\n"; 83 87 print " commit <filename>\n"; 88 print " commitall\n"; 84 89 print " diff <filename>\n"; 85 90 print " status\n"; … … 455 460 sub svn_update( ;$ ) 456 461 { 457 my $update_path = shift || $DASSCM_REPO; 458 ( my $rc_update, my @result ) = 459 run_command( 460 "$SVN update --non-interactive $svnCheckoutCredentials $update_path"); 461 print @result; 462 if ( $rc_update != 0 ) { 463 fatalerror(); 464 } 465 } 462 if( ! $svnRepositoryIsUptodate ) { 463 my $update_path = shift || $DASSCM_REPO; 464 ( my $rc_update, my @result ) = 465 run_command( 466 "$SVN update --non-interactive $svnCheckoutCredentials $update_path"); 467 print @result; 468 if ( $rc_update != 0 ) { 469 fatalerror(); 470 } else { 471 $svnRepositoryIsUptodate = 1; 472 } 473 } 474 } 475 476 466 477 467 478 sub svn_getStoredFiles( ;$ ) … … 486 497 return @result; 487 498 } 499 500 501 sub getModifiedFiles( ;$ ) 502 { 503 # TODO: get_filenames? 504 #my $rel_path = shift || ""; 505 #my $path = "${DASSCM_REPO}/${rel_path}"; 506 my $path = ${DASSCM_REPO}; 507 my @files = svn_getStoredFiles($path); 508 509 # stores result from status (cvscheck) 510 my %removedfiles = (); 511 my %changedfiles = (); 512 513 # create list of modified files 514 if (@files) { 515 516 foreach my $file (@files) { 517 518 my $realfile = "/" . $file; 519 my $cvsworkfile = "${DASSCM_REPO}/${file}"; 520 521 if ( -d $realfile ) { 522 ## directory. do nothing 523 } elsif ( !-r $realfile ) { 524 $removedfiles{"$realfile"} = $cvsworkfile; 525 } else { 526 ( -r "$cvsworkfile" ) 527 || die("Fehler: $cvsworkfile ist nicht lesbar"); 528 if ( compare( $cvsworkfile, $realfile ) != 0 ) { 529 $changedfiles{"$realfile"} = $cvsworkfile; 530 } 531 } 532 } 533 } 534 535 return ( \%changedfiles, \%removedfiles ); 536 } 537 488 538 489 539 # … … 692 742 } 693 743 744 745 694 746 # 695 747 # add (is used for command add and commit) … … 720 772 } 721 773 774 # TODO: check in links and also link target? At least warn about link target 722 775 if (@links) { 723 776 my $number = $#links + 1; … … 753 806 "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO" 754 807 ); 755 756 #print $filename_prod. "\n"; 757 #print $dirname_repo. "\n"; 758 } 808 } 809 810 811 812 # 813 # checks in all modified files 814 # 815 sub commitall(@) 816 { 817 check_parameter( @_, 1 ); 818 check_env(); 819 820 # TODO: get_filenames? 821 #my $rel_path = shift || ""; 822 #my $path = "${DASSCM_REPO}/${rel_path}"; 823 my $dir = ${DASSCM_REPO}; 824 825 # 826 # update local repository 827 # 828 svn_update(); 829 830 ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dir ); 831 my %changedfiles = %{$refChangedFiles}; 832 my %removedfiles = %{$refRemovedFiles}; 833 834 if( %removedfiles ) { 835 my $removedFilesString = '"' . join( '" "', values(%removedfiles) ) . '"'; 836 my ( $rc, @out ) = run_command( "$SVN rm $removedFilesString" ); 837 if ( $rc > 0 ) { 838 print join( "\n", @out ); 839 } 840 } 841 842 # add will care about the rest, including permission file and commiting 843 add( keys %changedfiles ); 844 } 845 846 759 847 760 848 sub blame(@) … … 819 907 # TODO: start at subdirectories ? 820 908 my $dir = $DASSCM_REPO; 821 my @files = svn_getStoredFiles($dir); 822 823 # Liste der geänderten Files ausgeben, falls nicht leer 824 if (@files) { 825 826 # stores result from status (cvscheck) 827 my %removedfiles = (); 828 my %changedfiles = (); 829 830 foreach my $file (@files) { 831 832 my $realfile = "/" . $file; 833 my $cvsworkfile = "${DASSCM_REPO}/${file}"; 834 835 if ( -d $realfile ) { 836 837 # directory. do nothing 838 } elsif ( !-r $realfile ) { 839 $removedfiles{"$realfile"} = $cvsworkfile; 840 } else { 841 ( -r "$cvsworkfile" ) 842 || die("Fehler: $cvsworkfile ist nicht lesbar"); 843 if ( compare( $cvsworkfile, $realfile ) != 0 ) { 844 $changedfiles{"$realfile"} = $cvsworkfile; 845 } 846 } 847 } 848 909 ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dir ); 910 my %changedfiles = %{$refChangedFiles}; 911 my %removedfiles = %{$refRemovedFiles}; 912 913 if( %removedfiles or %changedfiles ) { 849 914 if (%removedfiles) { 850 915 print "deleted files (found in repository, but not in system):\n"; … … 866 931 } 867 932 868 print "\n";869 870 933 return $return_code; 871 934 } 935 936 872 937 873 938 sub permissions(@) … … 918 983 } 919 984 } 985 986 920 987 921 988 ##################################################################### … … 987 1054 $command = "update"; 988 1055 update(@ARGV); 1056 } elsif ( (m/commitall/i) || (m/cia/i) ) { 1057 $command = "commitall"; 1058 commitall(@ARGV); 989 1059 } elsif (m/add/i) { 990 1060 $command = "add"; 991 1061 add(@ARGV); 992 } elsif ( (m/commit/i) || (m/c i/i) ) {1062 } elsif ( (m/commit/i) || (m/checkin/i) || (m/ci/i) ) { 993 1063 $command = "commit"; 994 1064 add(@ARGV); … … 1013 1083 1014 1084 # cleanup (svn-commit.tmp) 1015 # commitall1016 1085 # revert 1017 1086 # activate
Note:
See TracChangeset
for help on using the changeset viewer.