@@ -36,20 +36,21 @@ class RevcheckRun
3636
3737 public array $ qaList = [];
3838 public RevcheckData $ revData ;
39+ private int $ slowPathCount = 0 ;
3940
4041 function __construct ( string $ sourceDir , string $ targetDir , bool $ writeResults = false )
4142 {
4243 $ this ->sourceDir = $ sourceDir ;
4344 $ this ->targetDir = $ targetDir ;
4445
45- // load respective file tree
46+ // Load respective file trees
4647 $ this ->sourceFiles = new RevcheckFileList ( $ sourceDir );
4748 $ this ->targetFiles = new RevcheckFileList ( $ targetDir );
4849
49- // original files get info from version control
50+ // Source files get info from version control
5051 GitLogParser::parseInto ( $ sourceDir , $ this ->sourceFiles );
5152
52- // translated files get info from file contents
53+ // Target files get info from revtags
5354 RevtagParser::parseInto ( $ targetDir , $ this ->targetFiles );
5455
5556 // match and mix
@@ -62,6 +63,9 @@ function __construct( string $sourceDir , string $targetDir , bool $writeResults
6263 QaFileInfo::cacheSave ( $ this ->qaList );
6364 $ this ->saveRevcheckData ();
6465 }
66+
67+ if ( $ this ->slowPathCount > 1000 )
68+ fprintf ( STDERR , "Warn: Slow path called {$ this ->slowPathCount } times. \n" );
6569 }
6670
6771 private function calculateStatus ()
@@ -94,6 +98,8 @@ private function calculateStatus()
9498 continue ;
9599 }
96100
101+ // TODO remove $(source|target)H* with QA simplification
102+
97103 // Previous code compares uptodate on multiple hashs. The last hash or the last non-skipped hash.
98104 // See https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L374
99105 // and https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L392 .
@@ -110,7 +116,7 @@ private function calculateStatus()
110116
111117 // TranslatedOk
112118
113- if ( $ target ->revtag ->status == "ready " && ( $ sourceHsh1 == $ targetHash || $ sourceHsh2 == $ targetHash ) )
119+ if ( $ target ->revtag ->status == "ready " && $ source -> isSyncHash ( $ target -> revtag -> revision ) )
114120 {
115121 $ source ->status = RevcheckStatus::TranslatedOk;
116122 $ this ->filesOk [] = $ source ;
@@ -123,18 +129,9 @@ private function calculateStatus()
123129
124130 if ( $ target ->revtag ->status == "ready " )
125131 {
126- if ( FIXED_SKIP_REVCHECK && $ source ->diff == "skip " && TestFixedHashMinusTwo ( $ source ->file , $ targetHash ) )
127- {
128- $ source ->status = RevcheckStatus::TranslatedOk;
129- $ this ->filesOk [] = $ source ;
130- $ this ->addData ( $ source , $ target ->revtag );
131- }
132- else
133- {
134- $ source ->status = RevcheckStatus::TranslatedOld;
135- $ this ->filesOld [] = $ source ;
136- $ this ->addData ( $ source , $ target ->revtag );
137- }
132+ $ source ->status = RevcheckStatus::TranslatedOld;
133+ $ this ->filesOld [] = $ source ;
134+ $ this ->addData ( $ source , $ target ->revtag );
138135 }
139136 else
140137 {
@@ -160,7 +157,7 @@ private function calculateStatus()
160157 asort ( $ this ->revData ->fileDetail );
161158 }
162159
163- private function addData ( RevcheckFileInfo $ info , RevtagInfo |null $ revtag = null ) : void
160+ private function addData ( RevcheckFileItem $ info , RevtagInfo |null $ revtag = null ) : void
164161 {
165162 $ file = new RevcheckDataFile ;
166163
@@ -169,8 +166,8 @@ private function addData( RevcheckFileInfo $info , RevtagInfo|null $revtag = nul
169166 $ file ->size = $ info ->size ;
170167 $ file ->days = floor ( ( time () - $ info ->date ) / 86400 );
171168 $ file ->status = $ info ->status ;
172- $ file ->hashLast = $ info ->head ;
173- $ file ->hashDiff = $ info ->diff ;
169+ $ file ->hashLast = $ info ->hashLast ;
170+ $ file ->hashDiff = $ info ->hashDiff ;
174171
175172 $ this ->revData ->addFile ( $ info ->file , $ file );
176173
@@ -199,6 +196,7 @@ private function addData( RevcheckFileInfo $info , RevtagInfo|null $revtag = nul
199196 {
200197 case RevcheckStatus::TranslatedOld:
201198 case RevcheckStatus::TranslatedWip:
199+ $ this ->slowPathCount ++;
202200 GitDiffParser::parseAddsDels ( $ this ->sourceDir , $ file );
203201 }
204202 }
@@ -240,16 +238,3 @@ private function saveRevcheckData()
240238 file_put_contents ( __DIR__ . "/../../../.revcheck.json " , $ json );
241239 }
242240}
243-
244- function TestFixedHashMinusTwo ($ filename , $ hash ) :bool
245- {
246- assert ( FIXED_SKIP_REVCHECK ); // if deleted, delete entire funciont.
247-
248- // See mentions of FIXED_SKIP_REVCHECK on all.php for an explanation
249-
250- $ cwd = getcwd ();
251- chdir ( 'en ' );
252- $ hashes = explode ( "\n" , `git log -2 --format=%H -- {$ filename }` );
253- chdir ( $ cwd );
254- return ( $ hashes [1 ] == $ hash ); // $trFile->hash
255- }
0 commit comments