Changeset 275
- Timestamp:
- Mar 5, 2009, 12:49:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r274 r275 55 55 my $svnCheckoutCredentials = ""; 56 56 my $svnPasswordCredentials = ""; 57 57 58 # flag. Set to true by svn_update 58 59 # This prevents, that svn_update is called multiple times … … 64 65 # subcommand, that gets executed (add, commit, ...) 65 66 my $command; 66 67 67 68 68 my $verbose = 0; … … 161 161 } 162 162 163 164 163 # 165 164 # check and evaluate environment variables … … 263 262 } 264 263 265 266 267 264 # 268 265 # has been intendend, … … 297 294 # herefore make sure, that if filename is a directory, 298 295 # it will end by "/" 299 if ( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) {296 if ( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) { 300 297 $filename_prod = $filename_prod . '/'; 301 298 } … … 321 318 ); 322 319 } 323 324 320 325 321 sub copy_file_to_repository( $ ) … … 333 329 my $filename_prod, 334 330 my $filename_repo 335 )336 = get_filenames( $filename);331 ) 332 = get_filenames($filename); 337 333 338 334 # TODO: are permissions also copied? 339 335 copy( $filename_prod, $filename_repo ) 340 or error "failed to copy $filename_prod to repository: $!"; 341 } 342 336 or error "failed to copy $filename_prod to repository: $!"; 337 } 343 338 344 339 # … … 496 491 497 492 # use this flag to do only one update per run 498 if ( !$svnRepositoryIsUptodate ) {493 if ( !$svnRepositoryIsUptodate ) { 499 494 ( my $rc_update, my @result ) = 500 run_command( 501 "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'"); 495 run_command( 496 "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'" 497 ); 502 498 print @result; 503 499 if ( $rc_update != 0 ) { 504 500 fatalerror(); 505 501 } elsif ( not $update_path ) { 502 506 503 # set this flag if a full update is done 507 504 $svnRepositoryIsUptodate = 1; … … 509 506 } 510 507 } 511 512 513 508 514 509 sub svn_ls( ;@ ) … … 531 526 my @others = (); 532 527 533 if ( -f $filename_prod ) {534 @files = ( $filename_prod);528 if ( -f $filename_prod ) { 529 @files = ($filename_prod); 535 530 } elsif ( -d $dirname_repo ) { 536 531 find( … … 540 535 $name =~ s|^$dirname_repo||; 541 536 if ( $name =~ m/\.svn/ ) { 537 542 538 # skip svn meta data 543 539 } elsif ( -l $_ ) { 544 540 545 541 # soft link 546 542 # important: check for links first … … 548 544 push( @links, $name ); 549 545 } elsif ( -d $_ ) { 550 546 551 547 # directories 552 548 push( @dirs, $name ); 553 549 } elsif ( -f $_ ) { 554 550 555 551 # regular file 556 552 push( @files, $name ); … … 558 554 push( @others, $name ); 559 555 } 560 556 } 561 557 }, 562 ( $dirname_repo)558 ($dirname_repo) 563 559 ); 564 560 } … … 567 563 } 568 564 569 570 571 565 sub svn_revert( ;$ ) 572 566 { 573 567 my $path = shift || $DASSCM_REPO; 574 568 575 ( my $rc_update, my @result ) = 576 run_command( "$SVN revert -R '$path'" ); 569 ( my $rc_update, my @result ) = run_command("$SVN revert -R '$path'"); 577 570 578 571 if ( $rc_update != 0 ) { 579 572 print "\n", @result; 580 error( "failed to revert subversion repository changes" ); 581 } 582 } 583 573 error("failed to revert subversion repository changes"); 574 } 575 } 584 576 585 577 sub getModifiedFiles( ;$ ) … … 594 586 = get_filenames( $_[0] ); 595 587 596 my @files = svn_ls( $filename_prod);588 my @files = svn_ls($filename_prod); 597 589 598 590 # stores result from status (cvscheck) … … 625 617 } 626 618 627 628 619 # 629 620 # from an array of files/dirs, … … 741 732 } 742 733 743 744 734 # 745 735 # initialize local checkout directory (initial checkout) … … 761 751 } 762 752 763 764 765 753 sub ls(@) 766 754 { … … 770 758 my @files = svn_ls(@_); 771 759 772 if ( @files) {760 if (@files) { 773 761 print join( "\n", @files ); 774 762 print "\n"; 775 763 } 776 764 } 777 778 779 765 780 766 sub update(@) … … 815 801 for my $dir ( split( '/', $dirname_prod ) ) { 816 802 if ($dir) { 817 my ( $rc, @out ) = 818 run_command( "$SVN add --non-recursive '$dir'" ); 803 my ( $rc, @out ) = run_command("$SVN add --non-recursive '$dir'"); 819 804 if ( $rc > 0 ) { 820 805 print join( "\n", @out ); … … 823 808 } 824 809 } 825 my ( $rc, @out ) = run_command( "$SVN add '$basename'");810 my ( $rc, @out ) = run_command("$SVN add '$basename'"); 826 811 if ( $rc > 0 ) { 827 812 print join( "\n", @out ); … … 830 815 831 816 } 832 833 834 817 835 818 # … … 901 884 } 902 885 903 904 905 886 # 906 887 # checks in all modified files 907 888 # 908 889 sub commit(@) 909 {910 check_parameter( @_, 1 );911 check_env();912 913 (914 my $basename,915 my $dirname_prod,916 my $dirname_repo,917 my $filename_prod,918 my $filename_repo919 )920 = get_filenames( $_[0] );921 922 923 #924 # update local repository925 #926 svn_update();927 928 ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $filename_prod );929 my %changedfiles = %{$refChangedFiles};930 my %removedfiles = %{$refRemovedFiles};931 932 if( %removedfiles ) {933 my $removedFilesString = '"' . join( '" "', values(%removedfiles) ) . '"';934 my ( $rc, @out ) = run_command( "$SVN rm $removedFilesString" );935 if ( $rc > 0 ) {936 print join( "\n", @out );937 }938 }939 940 # copy files one by one to local repository941 for my $file ( keys(%changedfiles) ) {942 copy_file_to_repository( $file );943 }944 945 # create new permissions file946 permissions();947 948 # add permissions file949 add_helper($permissions_file);950 951 if ( $options{'message'} ) {952 $svnOptions .= " --message \"$options{'message'}\" ";953 }954 955 # commit calls $EDITOR.956 # use "interactive" here, to display output957 my $retcode =958 run_interactive(959 "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"960 );961 962 # svn commit does not deliever an error return code, if commit is canceld,963 # so a revert is performed in any case964 svn_revert();965 }966 967 968 969 sub blame(@)970 890 { 971 891 check_parameter( @_, 1 ); … … 981 901 = get_filenames( $_[0] ); 982 902 983 my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo"); 984 } 985 986 sub diff(@) 903 # 904 # update local repository 905 # 906 svn_update(); 907 908 ( my $refChangedFiles, my $refRemovedFiles ) = 909 getModifiedFiles($filename_prod); 910 my %changedfiles = %{$refChangedFiles}; 911 my %removedfiles = %{$refRemovedFiles}; 912 913 if (%removedfiles) { 914 my $removedFilesString = 915 '"' . join( '" "', values(%removedfiles) ) . '"'; 916 my ( $rc, @out ) = run_command("$SVN rm $removedFilesString"); 917 if ( $rc > 0 ) { 918 print join( "\n", @out ); 919 } 920 } 921 922 # copy files one by one to local repository 923 for my $file ( keys(%changedfiles) ) { 924 copy_file_to_repository($file); 925 } 926 927 # create new permissions file 928 permissions(); 929 930 # add permissions file 931 add_helper($permissions_file); 932 933 if ( $options{'message'} ) { 934 $svnOptions .= " --message \"$options{'message'}\" "; 935 } 936 937 # commit calls $EDITOR. 938 # use "interactive" here, to display output 939 my $retcode = 940 run_interactive( 941 "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO" 942 ); 943 944 # svn commit does not deliever an error return code, if commit is canceld, 945 # so a revert is performed in any case 946 svn_revert(); 947 } 948 949 sub blame(@) 987 950 { 988 951 check_parameter( @_, 1 ); … … 998 961 = get_filenames( $_[0] ); 999 962 963 my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo"); 964 } 965 966 sub diff(@) 967 { 968 check_parameter( @_, 1 ); 969 check_env(); 970 971 ( 972 my $basename, 973 my $dirname_prod, 974 my $dirname_repo, 975 my $filename_prod, 976 my $filename_repo 977 ) 978 = get_filenames( $_[0] ); 979 1000 980 #print "$basename,$dirname_prod,$dirname_repo\n"; 1001 981 … … 1026 1006 = get_filenames( $_[0] || "/" ); 1027 1007 1028 1029 1008 # return code for the shell 1030 1009 # default: error … … 1036 1015 svn_update(); 1037 1016 1038 ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dirname_prod ); 1017 ( my $refChangedFiles, my $refRemovedFiles ) = 1018 getModifiedFiles($dirname_prod); 1039 1019 my %changedfiles = %{$refChangedFiles}; 1040 1020 my %removedfiles = %{$refRemovedFiles}; 1041 1021 1042 if ( %removedfiles or %changedfiles ) {1022 if ( %removedfiles or %changedfiles ) { 1043 1023 if (%removedfiles) { 1044 1024 print "deleted files (found in repository, but not in system):\n"; … … 1063 1043 } 1064 1044 1065 1066 1067 1045 sub permissions() 1068 1046 { … … 1076 1054 1077 1055 my $dir = $DASSCM_REPO; 1078 my @files = svn_ls( "/");1056 my @files = svn_ls("/"); 1079 1057 1080 1058 if (@files) { … … 1112 1090 } 1113 1091 1114 1115 1092 # 1116 1093 # remove all uncommited changes in the repository … … 1121 1098 check_env(); 1122 1099 1123 svn_revert( $DASSCM_REPO ); 1124 } 1125 1126 1100 svn_revert($DASSCM_REPO); 1101 } 1127 1102 1128 1103 #####################################################################
Note:
See TracChangeset
for help on using the changeset viewer.