- Timestamp:
- Nov 10, 2009, 6:00:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dasscm/trunk/dasscm
r797 r800 91 91 print " add <path>\n"; 92 92 print " commit <path>\n"; 93 print " revert <path>\n"; 93 94 print " diff <path>\n"; 94 95 print " status <path>\n"; … … 97 98 print " permissions\n"; 98 99 print "\n"; 99 print "preparation:\n", " if dasscm is already configured,\n", 100 " use 'dasscm login' and then eg. 'add'.\n", 101 " The environment variables\n", " DASSCM_REPO\n", " DASSCM_PROD\n", 102 " DASSCM_USERNAME\n", " DASSCM_PASSWORD\n", 103 " are evaluated, but set automatically by 'dasscm login'.\n", "\n", 104 " If dasscm is not yet configured, read", " $doc_file\n"; 100 print "If dasscm is not yet configured, read $doc_file\n"; 105 101 } 106 102 … … 321 317 } 322 318 323 if ( not -r $filename_prod ) { 324 fatalerror( $filename_prod . " is not accessable" ); 319 # file must be readable. Only exception is, when file should be reverted 320 if ( $command ne "revert" ) { 321 if ( not -r $filename_prod ) { 322 fatalerror( $filename_prod . " is not accessable" ); 323 } 325 324 } 326 325 … … 333 332 ( my $basename, my $dirname_prod ) = fileparse($filename_prod); 334 333 335 # uses chdir to determine real directory in a unique way 336 chdir $dirname_prod or die $!; 337 $dirname_prod = normalize_path( cwd() ); 338 chdir $StartDirectory; 334 # normalize path. 335 # not done for reverting, because in this case, the directory may not exist 336 # and the correct path should already be stored in the repository 337 if ( $command ne "revert" ) { 338 # uses chdir to determine real directory in a unique way 339 chdir $dirname_prod or fatalerror( "failed to access directory $dirname_prod: " . $! ); 340 $dirname_prod = normalize_path( cwd() ); 341 chdir $StartDirectory; 342 } 339 343 340 344 my $dirname_repo = normalize_path( $DASSCM_REPO . "/" . $dirname_prod ); … … 372 376 or error "failed to copy $filename_prod to repository: $!"; 373 377 } 378 374 379 375 380 # … … 639 644 # remove it 640 645 print "removing $_\n"; 641 unlink($_); 646 # unlink doesn't work recursive, there "rm -rf" is used 647 #unlink($_); 648 system( "rm -rf $_" ); 642 649 } 643 650 } … … 1032 1039 } 1033 1040 1034 sub blame(@) 1041 1042 1043 # 1044 # revert: copies files back from repository to system 1045 # 1046 sub revert(@) 1035 1047 { 1036 1048 check_parameter( @_, 1 ); … … 1046 1058 = get_filenames( $_[0] ); 1047 1059 1048 my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo"); 1049 } 1050 1051 sub diff(@) 1060 # return code for the shell 1061 # default: error 1062 my $return_code = $RETURN_OK; 1063 1064 1065 # cleanup repository 1066 ##cleanup(); 1067 #svn_update(); 1068 1069 ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) = 1070 getModifiedFiles($filename_prod); 1071 my %changedfiles = %{$refChangedFiles}; 1072 my %removedfiles = %{$refRemovedFiles}; 1073 my %unknownfiles = %{$refUnknownFiles}; 1074 1075 if ( %removedfiles or %changedfiles or %unknownfiles ) { 1076 1077 if (%removedfiles) { 1078 print "DELETED files and directories. Recreated from repository:\n"; 1079 my @removedPaths = ( sort { length $a > length $b } keys %removedfiles ); 1080 print join( "\n", @removedPaths ) . "\n\n"; 1081 1082 # copy files one by one from local repository to system 1083 # and also create directories 1084 # paths are sorted, so that directories are created first 1085 for my $real_path ( @removedPaths ) { 1086 if( -d $removedfiles{"$real_path"} ) { 1087 mkpath("$real_path"); 1088 } else { 1089 copy( $removedfiles{"$real_path"}, $real_path ) or error( "failed to copy " . $removedfiles{"$real_path"} . " to " . $real_path . ": " . $! ); 1090 } 1091 } 1092 } 1093 1094 if (%changedfiles) { 1095 print "MODIFIED files. Copied from repository to the system:\n"; 1096 print join( "\n", ( keys %changedfiles ) ) . "\n\n"; 1097 1098 # copy files one by one from local repository to system 1099 for my $real_file ( keys(%changedfiles) ) { 1100 copy( $changedfiles{"$real_file"}, $real_file ); 1101 } 1102 1103 } 1104 1105 if (%unknownfiles) { 1106 print "UNKNOWN: insufficient permission to check files:\n"; 1107 print join( "\n", ( keys %unknownfiles ) ) . "\n\n"; 1108 1109 $return_code = $RETURN_NOK; 1110 } 1111 1112 } else { 1113 print "no modified files found in $dirname_repo\n"; 1114 } 1115 1116 return $return_code; 1117 } 1118 1119 1120 1121 sub blame(@) 1052 1122 { 1053 1123 check_parameter( @_, 1 ); … … 1063 1133 = get_filenames( $_[0] ); 1064 1134 1135 my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo"); 1136 } 1137 1138 sub diff(@) 1139 { 1140 check_parameter( @_, 1 ); 1141 check_env(); 1142 1143 ( 1144 my $basename, 1145 my $dirname_prod, 1146 my $dirname_repo, 1147 my $filename_prod, 1148 my $filename_repo 1149 ) 1150 = get_filenames( $_[0] ); 1151 1065 1152 #print "$basename,$dirname_prod,$dirname_repo\n"; 1066 1153 … … 1110 1197 if (%removedfiles) { 1111 1198 print "DELETED: files found in repository, but not in system:\n"; 1112 print join( "\n", ( keys %removedfiles ) ) . "\n\n";1199 print join( "\n", sort ( keys %removedfiles ) ) . "\n\n"; 1113 1200 } 1114 1201 … … 1325 1412 $command = "commit"; 1326 1413 commit(@ARGV); 1414 } elsif (m/^revert$/i) { 1415 $command = "revert"; 1416 $return_code = revert(@ARGV); 1327 1417 } elsif (m/^blame$/i) { 1328 1418 $command = "blame"; … … 1349 1439 $return_code = $RETURN_NOK; 1350 1440 } 1351 1352 # revert1353 1354 1441 } 1355 1442
Note:
See TracChangeset
for help on using the changeset viewer.