Changeset 274
- Timestamp:
- Mar 5, 2009, 12:47:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r271 r274 36 36 # commands that require write access (and therefore a login) 37 37 # to the repository server 38 my @COMMANDS_REQUIRE_WRITE = ( "add", "commit" , "commitall");38 my @COMMANDS_REQUIRE_WRITE = ( "add", "commit" ); 39 39 40 40 # configuration file … … 81 81 print " help <subcommand>\n"; 82 82 print " init\n"; 83 print " login \n";84 print " up \n";85 print " ls \n";86 print " add < filename>\n";87 print " commit < filename>\n";88 print " commitall\n";89 print " diff <filename>\n";90 print " status\n";83 print " login <username>\n"; 84 print " up <path>\n"; 85 print " ls <path>\n"; 86 print " add <path>\n"; 87 print " commit <path>\n"; 88 print " diff <path>\n"; 89 print " status <path>\n"; 90 print " cleanup\n"; 91 91 print " permissions\n"; 92 92 print "\n"; … … 293 293 } 294 294 295 # TODO:dirname buggy: eg. "/etc/" is reduced to "/",296 # 297 # therefore make sure, that if filename is a directory,298 # 295 # dirname buggy: eg. "/etc/" is reduced to "/", 296 # "/etc" is used as filename 297 # herefore make sure, that if filename is a directory, 298 # it will end by "/" 299 299 if( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) { 300 300 $filename_prod = $filename_prod . '/'; … … 337 337 338 338 # TODO: are permissions also copied? 339 340 print "$filename: $filename_prod, $filename_repo\n";341 339 copy( $filename_prod, $filename_repo ) 342 340 or error "failed to copy $filename_prod to repository: $!"; … … 570 568 571 569 570 571 sub svn_revert( ;$ ) 572 { 573 my $path = shift || $DASSCM_REPO; 574 575 ( my $rc_update, my @result ) = 576 run_command( "$SVN revert -R '$path'" ); 577 578 if ( $rc_update != 0 ) { 579 print "\n", @result; 580 error( "failed to revert subversion repository changes" ); 581 } 582 } 583 584 572 585 sub getModifiedFiles( ;$ ) 573 586 { … … 757 770 my @files = svn_ls(@_); 758 771 759 print join( "\n", @files ); 760 print "\n"; 772 if( @files ) { 773 print join( "\n", @files ); 774 print "\n"; 775 } 761 776 } 762 777 … … 788 803 = get_filenames( $_[0] ); 789 804 790 if ( $command eq "add" ) { 791 mkpath($dirname_repo); 792 } 805 mkpath($dirname_repo); 793 806 794 807 # TODO: are permissions also copied? … … 796 809 or error "failed to copy $filename_prod to repository: $!"; 797 810 798 if ( $command eq "add" ) { 799 800 # already checked in? 801 chdir $DASSCM_REPO; 802 803 # also add the path to filename. 804 for my $dir ( split( '/', $dirname_prod ) ) { 805 if ($dir) { 806 my ( $rc, @out ) = 807 run_command( "$SVN add --non-recursive \"" . $dir . "\"" ); 808 if ( $rc > 0 ) { 809 print join( "\n", @out ); 810 } 811 chdir $dir; 811 # already checked in? 812 chdir $DASSCM_REPO; 813 814 # also add the path to filename. 815 for my $dir ( split( '/', $dirname_prod ) ) { 816 if ($dir) { 817 my ( $rc, @out ) = 818 run_command( "$SVN add --non-recursive '$dir'" ); 819 if ( $rc > 0 ) { 820 print join( "\n", @out ); 812 821 } 813 } 814 my ( $rc, @out ) = run_command( "$SVN add \"" . $basename . "\"" ); 815 if ( $rc > 0 ) { 816 print join( "\n", @out ); 817 } 818 chdir $StartDirectory; 819 } 820 } 821 822 823 824 # 825 # add (is used for command add and commit) 822 chdir $dir; 823 } 824 } 825 my ( $rc, @out ) = run_command( "$SVN add '$basename'" ); 826 if ( $rc > 0 ) { 827 print join( "\n", @out ); 828 } 829 chdir $StartDirectory; 830 831 } 832 833 834 835 # 836 # adding new files (or directories) 826 837 # 827 838 sub add(@) … … 884 895 "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO" 885 896 ); 886 } 887 888 889 890 # 891 # checks in all modified files 892 # 893 sub commitall(@) 894 { 895 check_parameter( @_, 1 ); 896 check_env(); 897 898 # 899 # update local repository 900 # 901 svn_update(); 902 903 ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( "/" ); 904 my %changedfiles = %{$refChangedFiles}; 905 my %removedfiles = %{$refRemovedFiles}; 906 907 if( %removedfiles ) { 908 my $removedFilesString = '"' . join( '" "', values(%removedfiles) ) . '"'; 909 my ( $rc, @out ) = run_command( "$SVN rm $removedFilesString" ); 910 if ( $rc > 0 ) { 911 print join( "\n", @out ); 912 } 913 } 914 915 # add will care about the rest, including permission file and commiting 916 add( keys %changedfiles ); 897 898 # svn commit does not deliever an error return code, if commit is canceld, 899 # so a revert is performed in any case 900 svn_revert(); 917 901 } 918 902 … … 975 959 "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO" 976 960 ); 961 962 # svn commit does not deliever an error return code, if commit is canceld, 963 # so a revert is performed in any case 964 svn_revert(); 977 965 } 978 966 … … 1125 1113 1126 1114 1115 # 1116 # remove all uncommited changes in the repository 1117 # 1118 sub cleanup() 1119 { 1120 check_parameter( @_, 1 ); 1121 check_env(); 1122 1123 svn_revert( $DASSCM_REPO ); 1124 } 1125 1126 1127 1127 1128 1128 ##################################################################### … … 1180 1180 # 1181 1181 $_ = $command; 1182 if (m/ help/i) {1182 if (m/^help$/i) { 1183 1183 help(@ARGV); 1184 } elsif (m/ login/i) {1184 } elsif (m/^login$/i) { 1185 1185 $command = "login"; 1186 1186 login(@ARGV); 1187 } elsif (m/ init/i) {1187 } elsif (m/^init$/i) { 1188 1188 $command = "init"; 1189 1189 init(@ARGV); 1190 } elsif (m/ ls/i) {1190 } elsif (m/^ls$/i) { 1191 1191 $command = "ls"; 1192 1192 ls(@ARGV); 1193 } elsif ( (m/ update/i) || (m/up/i) ) {1193 } elsif ( (m/^update$/i) || (m/^up$/i) ) { 1194 1194 $command = "update"; 1195 1195 update(@ARGV); 1196 } elsif ( (m/commitall/i) || (m/cia/i) ) { 1197 $command = "commitall"; 1198 commitall(@ARGV); 1199 } elsif (m/add/i) { 1196 } elsif (m/^add$/i) { 1200 1197 $command = "add"; 1201 1198 add(@ARGV); 1202 } elsif ( (m/ commit/i) || (m/checkin/i) || (m/ci/i) ) {1199 } elsif ( (m/^commit$/i) || (m/^checkin$/i) || (m/^ci$/i) ) { 1203 1200 $command = "commit"; 1204 1201 commit(@ARGV); 1205 } elsif (m/ blame/i) {1202 } elsif (m/^blame$/i) { 1206 1203 $command = "blame"; 1207 1204 blame(@ARGV); 1208 } elsif (m/ diff/i) {1205 } elsif (m/^diff$/i) { 1209 1206 $command = "diff"; 1210 1207 diff(@ARGV); 1211 } elsif ( (m/ status/i) || (m/st/i) ) {1208 } elsif ( (m/^status$/i) || (m/^st$/i) ) { 1212 1209 $command = "status"; 1213 1210 $return_code = status(@ARGV); 1214 } elsif (m/ permissions/i) {1211 } elsif (m/^permissions$/i) { 1215 1212 $command = "permissions"; 1216 1213 permissions(); 1214 } elsif (m/^cleanup$/i) { 1215 $command = "cleanup"; 1216 cleanup(); 1217 1217 } else { 1218 1218 print "unknown command: $command\n\n"; … … 1222 1222 } 1223 1223 1224 # cleanup (svn-commit.tmp)1225 1224 # revert 1226 # activate1227 # rm1228 1225 1229 1226 }
Note:
See TracChangeset
for help on using the changeset viewer.