@@ -36,20 +36,21 @@ class RevcheckRun
36
36
37
37
public array $ qaList = [];
38
38
public RevcheckData $ revData ;
39
+ private int $ slowPathCount = 0 ;
39
40
40
41
function __construct ( string $ sourceDir , string $ targetDir , bool $ writeResults = false )
41
42
{
42
43
$ this ->sourceDir = $ sourceDir ;
43
44
$ this ->targetDir = $ targetDir ;
44
45
45
- // load respective file tree
46
+ // Load respective file trees
46
47
$ this ->sourceFiles = new RevcheckFileList ( $ sourceDir );
47
48
$ this ->targetFiles = new RevcheckFileList ( $ targetDir );
48
49
49
- // original files get info from version control
50
+ // Source files get info from version control
50
51
GitLogParser::parseInto ( $ sourceDir , $ this ->sourceFiles );
51
52
52
- // translated files get info from file contents
53
+ // Target files get info from revtags
53
54
RevtagParser::parseInto ( $ targetDir , $ this ->targetFiles );
54
55
55
56
// match and mix
@@ -62,6 +63,9 @@ function __construct( string $sourceDir , string $targetDir , bool $writeResults
62
63
QaFileInfo::cacheSave ( $ this ->qaList );
63
64
$ this ->saveRevcheckData ();
64
65
}
66
+
67
+ if ( $ this ->slowPathCount > 1000 )
68
+ fprintf ( STDERR , "Warn: Slow path called {$ this ->slowPathCount } times. \n" );
65
69
}
66
70
67
71
private function calculateStatus ()
@@ -94,6 +98,8 @@ private function calculateStatus()
94
98
continue ;
95
99
}
96
100
101
+ // TODO remove $(source|target)H* with QA simplification
102
+
97
103
// Previous code compares uptodate on multiple hashs. The last hash or the last non-skipped hash.
98
104
// See https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L374
99
105
// and https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L392 .
@@ -110,7 +116,7 @@ private function calculateStatus()
110
116
111
117
// TranslatedOk
112
118
113
- if ( $ target ->revtag ->status == "ready " && ( $ sourceHsh1 == $ targetHash || $ sourceHsh2 == $ targetHash ) )
119
+ if ( $ target ->revtag ->status == "ready " && $ source -> isSyncHash ( $ target -> revtag -> revision ) )
114
120
{
115
121
$ source ->status = RevcheckStatus::TranslatedOk;
116
122
$ this ->filesOk [] = $ source ;
@@ -123,18 +129,9 @@ private function calculateStatus()
123
129
124
130
if ( $ target ->revtag ->status == "ready " )
125
131
{
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 );
138
135
}
139
136
else
140
137
{
@@ -160,7 +157,7 @@ private function calculateStatus()
160
157
asort ( $ this ->revData ->fileDetail );
161
158
}
162
159
163
- private function addData ( RevcheckFileInfo $ info , RevtagInfo |null $ revtag = null ) : void
160
+ private function addData ( RevcheckFileItem $ info , RevtagInfo |null $ revtag = null ) : void
164
161
{
165
162
$ file = new RevcheckDataFile ;
166
163
@@ -169,8 +166,8 @@ private function addData( RevcheckFileInfo $info , RevtagInfo|null $revtag = nul
169
166
$ file ->size = $ info ->size ;
170
167
$ file ->days = floor ( ( time () - $ info ->date ) / 86400 );
171
168
$ file ->status = $ info ->status ;
172
- $ file ->hashLast = $ info ->head ;
173
- $ file ->hashDiff = $ info ->diff ;
169
+ $ file ->hashLast = $ info ->hashLast ;
170
+ $ file ->hashDiff = $ info ->hashDiff ;
174
171
175
172
$ this ->revData ->addFile ( $ info ->file , $ file );
176
173
@@ -199,6 +196,7 @@ private function addData( RevcheckFileInfo $info , RevtagInfo|null $revtag = nul
199
196
{
200
197
case RevcheckStatus::TranslatedOld:
201
198
case RevcheckStatus::TranslatedWip:
199
+ $ this ->slowPathCount ++;
202
200
GitDiffParser::parseAddsDels ( $ this ->sourceDir , $ file );
203
201
}
204
202
}
@@ -240,16 +238,3 @@ private function saveRevcheckData()
240
238
file_put_contents ( __DIR__ . "/../../../.revcheck.json " , $ json );
241
239
}
242
240
}
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