Changeset 14258
- Timestamp:
- 2007-07-17T14:21:47+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/gti.pl
r13948 r14258 39 39 40 40 41 my $anonymous_cvs_root = ":pserver:cvs_anon\@cvs.scms.waikato.ac.nz:2402/usr/local/global-cvs/gsdl-src"; 41 #my $anonymous_cvs_root = ":pserver:cvs_anon\@cvs.scms.waikato.ac.nz:2402/usr/local/global-cvs/gsdl-src"; 42 #my $anonymous_svn_root = "http://http://svn.greenstone.org/gsdl/trunk/"; 42 43 my $gsdl_root_directory = "$ENV{'GSDLHOME'}"; 43 44 my $gti_log_file = &util::filename_cat($gsdl_root_directory, "etc", "gti.log"); … … 79 80 # 'target_file' => "gsdl-documentation/tutorials/xml-source/tutorial_{target_language_code}.xml" }, 80 81 81 # Greenstone.org82 # new Greenstone.org 82 83 { 'key' => "greenorg", 83 'file_type' => "macrofile", 84 'source_file' => "greenorg/macros/english.dm", 85 'target_file' => "greenorg/macros/{iso_639_1_target_language_name}.dm" } 84 'file_type' => "resource_bundle", 85 'source_file' => "greenstoneorg/website/classes/Gsc.properties", 86 'target_file' => "greenstoneorg/website/classes/Gsc_{iso_639_1_target_language_name}.properties" 87 # 'file_type' => "macrofile", 88 # 'source_file' => "greenorg/macros/english.dm", 89 # 'target_file' => "greenorg/macros/{iso_639_1_target_language_name}.dm" 90 } 86 91 ]; 87 92 … … 111 116 } 112 117 if ($gti_command =~ /^get-first-n-chunks-requiring-work$/i) { 113 print &get_first_n_chunks_requiring_work(@gti_command_arguments); 118 print &get_first_n_chunks_requiring_work(@gti_command_arguments); 114 119 } 115 120 if ($gti_command =~ /^get-language-status$/i) { 116 print &get_language_status(@gti_command_arguments); 121 print &get_language_status(@gti_command_arguments); 117 122 } 118 123 if ($gti_command =~ /^search-chunks$/i) { … … 248 253 my @source_file_lines = &read_file_lines($source_file_path); 249 254 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 250 255 251 256 my $target_file_path = &util::filename_cat($gsdl_root_directory, $target_file); 252 257 my @target_file_lines = &read_file_lines($target_file_path); … … 299 304 my $source_file_chunk_date = $source_file_key_to_last_update_date_mapping{$chunk_key}; 300 305 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}); 301 306 307 if(!defined $source_file_chunk_date){ 308 $source_file_chunk_date = ""; 309 } 310 302 311 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 303 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 312 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 304 313 $xml_response .= " <TargetFileText></TargetFileText>\n"; 305 314 $xml_response .= " </Chunk>\n"; … … 325 334 my $target_file_chunk_date = $target_file_key_to_last_update_date_mapping{$chunk_key}; 326 335 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping{$chunk_key}); 327 328 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 336 337 if(!defined $source_file_chunk_date){ 338 $source_file_chunk_date = ""; 339 } 340 341 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 329 342 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 330 343 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; … … 636 649 # The "2>/dev/null" is very important! If it is missing this will never return when run from the receptionist 637 650 # unless ($translation_file_is_not_in_cvs) { 638 my $source_file_cvs_status = `cd $gsdl_root_directory; cvs -d $anonymous_cvs_root update $source_file 2>/dev/null`; 651 #my $source_file_cvs_status = `cd $gsdl_root_directory; cvs -d $anonymous_cvs_root update $source_file 2>/dev/null`; 652 my $source_file_cvs_status = `cd $gsdl_root_directory; svn status $source_file 2>/dev/null`; 639 653 if ($source_file_cvs_status =~ /^C /) { 640 654 &throw_fatal_error("Source file $source_file_path conflicts with the repository."); … … 753 767 my $chunk_cvs_date = $key_to_cvs_date_mapping{$chunk_key}; 754 768 $key_to_last_update_date_mapping{$chunk_key} = $chunk_cvs_date; 755 769 756 770 # If a comment date exists and it is after the CVS date, use that instead 771 # need to convert the comment date format to SVN format 757 772 my $chunk_gti_comment = $key_to_gti_comment_mapping{$chunk_key}; 758 773 if (defined($chunk_gti_comment) && $chunk_gti_comment =~ /(\d?\d-\D\D\D-\d\d\d\d)/) { 759 my $chunk_comment_date = $1; 774 my $chunk_comment_date = $1; 760 775 if ((!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date))) { 761 776 $key_to_last_update_date_mapping{$chunk_key} = $chunk_comment_date; … … 774 789 # Use CVS to annotate each line of the file with the date it was last edited 775 790 # The "2>/dev/null" is very important! If it is missing this will never return when run from the receptionist 776 my $cvs_annotated_file = `cd $gsdl_root_directory; cvs -d $anonymous_cvs_root annotate -F $filename 2>/dev/null`; 791 # my $cvs_annotated_file = `cd $gsdl_root_directory; cvs -d $anonymous_cvs_root annotate -F $filename 2>/dev/null`; 792 # my $cvs_annotated_file = `cd $gsdl_root_directory; export PATH=.:/research/lh92/programs/subversion/bin; svn annotate -v --force $filename`; 793 my $cvs_annotated_file = `cd $gsdl_root_directory; svn annotate -v $filename`; 794 777 795 my @cvs_annotated_file_lines = split(/\n/, $cvs_annotated_file); 778 796 … … 780 798 foreach my $cvs_annotated_file_line (@cvs_annotated_file_lines) { 781 799 # Extract the date from the CVS annotation at the front 782 $cvs_annotated_file_line =~ s/^\S+\s+\(\S+\s+(\S+)\):\s//; 783 push(@cvs_annotated_file_lines_date, $1); 784 } 785 800 # cvs format : 07-Jun-02 801 # svn format : 2007-07-16 802 # $cvs_annotated_file_line =~ s/^\S+\s+\(\S+\s+(\S+)\):\s//; 803 $cvs_annotated_file_line =~ s/^\s+\S+\s+\S+\s(\S+)//; 804 805 push(@cvs_annotated_file_lines_date, $1); 806 807 # trim extra date information in svn annotation format 808 # 15:42:49 +1200 (Wed, 21 Jun 2006) 809 $cvs_annotated_file_line =~ s/^\s+\S+\s\S+\s\((.+?)\)\s//; 810 } 811 786 812 # Build a key to line mapping for the CVS annotated file, for matching the chunk key to the CVS date 787 813 my %key_to_line_mapping = &build_key_to_line_mapping(\@cvs_annotated_file_lines, $translation_file_type); 788 814 789 815 my %key_to_cvs_date_mapping = (); 790 816 foreach my $chunk_key (keys(%key_to_line_mapping)) { 791 817 my $chunk_starting_line = (split(/-/, $key_to_line_mapping{$chunk_key}))[0]; 792 818 my $chunk_finishing_line = (split(/-/, $key_to_line_mapping{$chunk_key}))[1]; 793 819 794 820 # Find the date this chunk was last edited, from the CVS annotation 795 my $chunk_date = $cvs_annotated_file_lines_date[$chunk_starting_line]; 821 my $chunk_date = $cvs_annotated_file_lines_date[$chunk_starting_line]; 796 822 for (my $l = ($chunk_starting_line + 1); $l <= $chunk_finishing_line; $l++) { 797 823 if (&is_date_after($cvs_annotated_file_lines_date[$l], $chunk_date)) { 798 824 # This part of the chunk has been updated more recently 799 825 $chunk_date = $cvs_annotated_file_lines_date[$l]; 826 800 827 } 801 828 } … … 861 888 my $source_chunk_last_update_date = $source_file_key_to_last_update_date_mapping->{$chunk_key}; 862 889 my $target_chunk_last_update_date = $target_file_key_to_last_update_date_mapping->{$chunk_key}; 863 if (defined($target_chunk_last_update_date) && &is_date_after($source_chunk_last_update_date, $target_chunk_last_update_date)) { 890 891 # print "key: $chunk_key\nsource date : $source_chunk_last_update_date\ntarget date : $target_chunk_last_update_date\nafter? ". &is_date_after($source_chunk_last_update_date, $target_chunk_last_update_date) . "\n\n"; 892 893 if (defined($target_chunk_last_update_date) && &is_date_after($source_chunk_last_update_date, $target_chunk_last_update_date)) { 864 894 # &log_message("Chunk with key $chunk_key needs updating."); 865 895 push(@target_file_keys_requiring_updating, $chunk_key); … … 903 933 904 934 # Returns 1 if $date1 is after $date2, 0 otherwise 905 sub is_date_after 935 sub is_date_after_cvs 906 936 { 907 937 my ($date1, $date2) = @_; … … 909 939 "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12); 910 940 941 if(!defined $date1) { 942 return 1; 943 } 944 911 945 my @date1parts = split(/-/, $date1); 912 946 my @date2parts = split(/-/, $date2); … … 915 949 my $year1 = $date1parts[2]; 916 950 if ($year1 < 80) { 917 $year1 += 2000;951 $year1 += 2000; 918 952 } 919 953 my $year2 = $date2parts[2]; 920 954 if ($year2 < 80) { 921 $year2 += 2000;955 $year2 += 2000; 922 956 } 923 957 … … 939 973 } 940 974 975 return 0; 976 } 977 978 sub is_date_after 979 { 980 my ($date1, $date2) = @_; 981 982 if(!defined $date1) { 983 return 1; 984 } 985 if(!defined $date2) { 986 return 0; 987 } 988 989 # 16-Aug-2006 990 if($date1=~ /(\d+?)-(\S\S\S)-(\d\d\d\d)/){ 991 my %months = ("Jan", "01", "Feb", "02", "Mar", "03", "Apr", "04", "May", "05", "Jun", "06", 992 "Jul", "07", "Aug", "08", "Sep", "09", "Oct", "10", "Nov", "11", "Dec", "12"); 993 $date1=$3 . "-" . $months{$2} . "-" . $1; 994 # print "** converted date1: $date1\n"; 995 } 996 if($date2=~ /(\d+?)-(\S\S\S)-(\d\d\d\d)/){ 997 my %months = ("Jan", "01", "Feb", "02", "Mar", "03", "Apr", "04", "May", "05", "Jun", "06", 998 "Jul", "07", "Aug", "08", "Sep", "09", "Oct", "10", "Nov", "11", "Dec", "12"); 999 $date2=$3 . "-" . $months{$2} . "-" . $1; 1000 # print "** converted date2: $date2\n"; 1001 } 1002 1003 1004 # 2006-08-16 1005 my @date1parts = split(/-/, $date1); 1006 my @date2parts = split(/-/, $date2); 1007 1008 # Compare year 1009 if ($date1parts[0] > $date2parts[0]) { 1010 return 1; 1011 } 1012 elsif ($date1parts[0] == $date2parts[0]) { 1013 # Year is the same, so compare month 1014 if ($date1parts[1] > $date2parts[1]) { 1015 return 1; 1016 } 1017 elsif ($date1parts[1] == $date2parts[1]) { 1018 # Month is the same, so compare day 1019 if ($date1parts[2] > $date2parts[2]) { 1020 return 1; 1021 } 1022 } 1023 } 1024 941 1025 return 0; 942 1026 }
Note:
See TracChangeset
for help on using the changeset viewer.