@@ -150,6 +150,19 @@ sub new
150
150
}
151
151
close (P4) or die (" error on close 'p4 have' pipe: $! " );
152
152
153
+ open (WHERE, ' -|' , " $cd p4 where $depot " ) or
154
+ die (" unable to execute p4 where: $! " );
155
+ my ($depot_path , $workspace_path , $workspace_dir );
156
+ while (<WHERE>) {
157
+ if (/ ^(\S +)\s *(\S +)\s *(\S +)$ / ) {
158
+ $depot_path = substr ($1 , 0, -4); # remove the '/...' tail
159
+ $workspace_path = substr ($2 , 0, -4);
160
+ $workspace_dir = substr ($3 , 0, -4);
161
+ last ;
162
+ }
163
+ }
164
+ close (WHERE) or die (" error on close 'p4 where' pipe: $! " );
165
+
153
166
# check for local edits...
154
167
open (EDITS, ' -|' , " $cd p4 opened $depot$dots " ) or
155
168
die (" unable to execute p4 opened: $! " );
@@ -158,7 +171,19 @@ sub new
158
171
/ ^(.+?)(#[0-9]+) - (edit|add|delete) (default change|change (\S +)) / )
159
172
{
160
173
# file is locally edited...append modify time or MD5 signature to the version ID
161
- my $data = $filehash {$1 };
174
+ my $data ;
175
+ if (exists ($filehash {$1 })) {
176
+ die (" unexpected 'add' state" ) if ' add' eq $3 ;
177
+ $data = $filehash {$1 };
178
+ } else {
179
+ die (" unexpected 'add' state" ) unless ' add' eq $3 ;
180
+ my $trimmed = substr ($1 , length ($depot_path ));
181
+ my $full_name = $workspace_dir . $trimmed ;
182
+ $data = [$full_name , $1 , $trimmed , ' #add' ];
183
+ $filehash {$full_name } = $data ;
184
+ $filehash {$1 } = $data ;
185
+ $filehash {$trimmed } = $data unless $trimmed eq $full_name ;
186
+ }
162
187
if (!$local_edit ) {
163
188
die (" $1$2 has local changes - see '--local-edit' flag" );
164
189
}
0 commit comments