Hello!
I've made some improvements of revcheck.php script and hope you'll
like them too so they could be taken into the svn:
1) fixed E_NOTICE errors
2) added console option --show-uptodate, which if supplied will also
show all up-to-date files in documentation. It can be useful to track
the translation progress with very obsolete status (as Russian one,
for example) so after some change translator will see one more green
(up-to-date) file than one less orange (untranslated) file from other
same orange 8.
I tried to keep BC as much as possible, hope there is no errors (at
least new :)).
--
Regards,
Shein Alexey
Index: doc-base/scripts/revcheck.php
===
--- doc-base/scripts/revcheck.php (revision 293138)
+++ doc-base/scripts/revcheck.php (revision )
@@ -22,14 +22,14 @@
$Id: revcheck.php 293138 2010-01-05 10:21:11Z rquadling $
*/
-if ($argc < 2 || $argc > 3) {
+if ($argc < 2 || $argc > 4) {
?>
Check the revision of translated files against
the actual english xml files, and print statistics
Usage:
-[]
+[] [--show-uptodate]
must be a valid language code used
in the repository
@@ -37,6 +37,9 @@
If you specify , the script only checks
the files maintained by the person you add here
+ If you specify --show-uptodate option, the script will
+ also show uptodate files in the common file list
+
Read more about Revision comments and related
functionality in the PHP Documentation Howto:
http://php.net/dochowto
@@ -76,17 +79,40 @@
REV_WIP => "wip",
);
+function init_revisions() {
+ global $CSS;
+ return array_fill_keys(array_keys($CSS), 0);
+}
+
+function init_files_by_maint($persons) {
+ $result = array();
+ foreach($persons as $item) {
+$result[$item['nick']] = init_revisions();
+ }
+
+ return $result;
+}
+
+$file_sizes_by_mark = $files_by_mark = init_revisions();
+
// Option for the link to svn.php.net:
define('SVN_OPT', '&view=patch');
define('SVN_OPT_NOWS', '');
// Initializing variables from parameters
$LANG = $argv[1];
+$MAINT = "";
+$SHOW_UPTODATE = FALSE;
if ($argc == 3) {
-$MAINT = $argv[2];
+ if ($argv[2] == '--show-uptodate') {
+ $SHOW_UPTODATE = TRUE;
-} else {
+} else {
-$MAINT = "";
+ $MAINT = $argv[2];
-}
+ }
+} elseif ($argc == 4) {
+$MAINT = $argv[2];
+$SHOW_UPTODATE = ($argv[3] == '--show-uptodate');
+}
// Main directory of the PHP documentation (depends on the
// sapi used). We do need the trailing slash!
@@ -172,7 +198,7 @@
function get_file_status($file) {
// The information is contained in these global arrays and vars
- global $DOCDIR, $LANG, $MAINT, $files_by_mark, $files_by_maint;
+ global $DOCDIR, $LANG, $MAINT, $SHOW_UPTODATE, $files_by_mark, $files_by_maint;
global $file_sizes_by_mark;
global $missing_files, $missing_tags, $using_rev;
@@ -246,23 +272,17 @@
$en_rev = $en_rev;
}
- // If the file is up-to-date
- if ($rev_diff === 0 && trim($this_status) === "ready") {
-// Store file by status and maintainer
-$files_by_mark[REV_UPTODATE]++;
-$files_by_maint[$this_maint][REV_UPTODATE]++;
-$file_sizes_by_mark[REV_UPTODATE] += $en_size;
-
-return FALSE;
- }
-
// Compute times and diffs
$en_date= intval((time() - filemtime($file)) / 86400);
$trans_date = intval((time() - filemtime($trans_file)) / 86400);
$date_diff = $en_date - $trans_date;
- // Make decision on file category by revision, date and size
- if ($rev_diff >= ALERT_REV || $size_diff >= ALERT_SIZE || $date_diff <= ALERT_DATE) {
+ // If the file is up-to-date
+ if ($rev_diff === 0 && trim($this_status) === "ready") {
+ $status_mark = REV_UPTODATE;
+ }
+ // Or make decision on file category by revision, date and size
+ elseif ($rev_diff >= ALERT_REV || $size_diff >= ALERT_SIZE || $date_diff <= ALERT_DATE) {
$status_mark = REV_CRITICAL;
} elseif ($rev_diff === "n/a") {
$status_mark = REV_NOREV;
@@ -277,6 +297,10 @@
$files_by_maint[$this_maint][$status_mark]++;
$file_sizes_by_mark[$status_mark] += $en_size;
+ if (REV_UPTODATE === $status_mark && !$SHOW_UPTODATE) {
+return FALSE;
+ }
+
return array(
"full_name" => $file,
"short_name" => basename($trans_file),
@@ -579,6 +603,7 @@
// Add WIP files to maintainers file count and figure out,
// if we need to use optional date and revision columns
$using_date = FALSE; $using_rev = FALSE;
+$files_by_maint = init_files_by_maint($translation['persons']);
foreach ($translation["files"] as $num => $fileinfo) {
$files_by_maint[$fileinfo["person"]][REV_WIP]++;
if (isset($fileinfo["date"])) { $using_date = TRUE; }