@@ -55,12 +55,6 @@ class DeltaCode(object):
5555 def __init__ (self , new_path , old_path , options ):
5656 self .codebase1 = None
5757 self .codebase2 = None
58- self .new_files_fingerprint = (
59- dict ()
60- ) # map of { {new_file1:fingerprint},{new_file2:fingerprint},...} it will be needed when we need the fingerprints
61- self .old_files_fingerprint = (
62- dict ()
63- ) # map of { {old_file1:fingerprint},{old_file2:fingerprint},...}
6458 self .options = options
6559 self .deltas = []
6660 self .errors = []
@@ -70,6 +64,7 @@ def __init__(self, new_path, old_path, options):
7064 self .codebase2 = VirtualCodebase (old_path )
7165
7266 except Exception as exception :
67+ print (str (exception ))
7368 self .errors .append (str (exception ))
7469
7570 if self .codebase1 is not None or self .codebase2 is not None :
@@ -82,7 +77,7 @@ def __init__(self, new_path, old_path, options):
8277 self .license_diff ()
8378 self .copyright_diff ()
8479 self .stats .calculate_stats ()
85- self .similarity ()
80+ # self.similarity()
8681 # Sort deltas by score, descending, i.e., high > low, and then by
8782 # factors, alphabetically. Run the least significant sort first.
8883 self .deltas .sort (key = lambda Delta : Delta .factors , reverse = False )
@@ -119,13 +114,8 @@ def similarity(self):
119114 )
120115
121116 def create_deltas (
122- self , new_resource , old_resource , new_path , old_path , score , count , status
117+ self , new_resource , old_resource , new_path , old_path , score , status
123118 ):
124- count = count + 1
125- if new_resource :
126- new_resource .path = new_path
127- if old_resource :
128- old_resource .path = old_path
129119 delta = Delta (score , new_resource , old_resource )
130120 delta .status = status
131121 self .deltas .append (delta )
@@ -138,10 +128,12 @@ def determine_delta(self):
138128 """
139129
140130 old_files_sha1_considered_in_deltas = dict ()
141-
142- Delta .NEW_CODEBASE_OFFSET , Delta .OLD_CODEBASE_OFFSET = utils .align_trees (
143- self .codebase1 , self .codebase2
144- )
131+ try :
132+ Delta .NEW_CODEBASE_OFFSET , Delta .OLD_CODEBASE_OFFSET = utils .align_trees (
133+ self .codebase1 , self .codebase2
134+ )
135+ except utils .AlignmentException :
136+ Delta .NEW_CODEBASE_OFFSET , Delta .OLD_CODEBASE_OFFSET = 0 , 0
145137
146138 for new_resource in self .codebase1 .walk ():
147139 if new_resource .is_file :
@@ -170,9 +162,9 @@ def determine_delta(self):
170162 path_new ,
171163 path_old ,
172164 0 ,
173- self .stats .num_unmodified ,
174165 "unmodified" ,
175166 )
167+ self .stats .num_unmodified += 1
176168 break
177169 else :
178170 old_files_sha1_considered_in_deltas [
@@ -184,9 +176,9 @@ def determine_delta(self):
184176 path_new ,
185177 path_old ,
186178 20 ,
187- self .stats .num_modified ,
188179 "modified" ,
189180 )
181+ self .stats .num_modified += 1
190182 break
191183 else :
192184 if new_resource .sha1 == old_resource .sha1 :
@@ -200,9 +192,9 @@ def determine_delta(self):
200192 path_new ,
201193 path_old ,
202194 0 ,
203- self .stats .num_moved ,
204195 "moved" ,
205196 )
197+ self .stats .num_moved += 1
206198 break
207199
208200 if ADDED :
@@ -212,9 +204,9 @@ def determine_delta(self):
212204 path_new ,
213205 None ,
214206 100 ,
215- self .stats .num_added ,
216207 "added" ,
217208 )
209+ self .stats .num_added += 1
218210
219211 for old_resource_remaining in self .codebase2 .walk ():
220212 if (
@@ -233,9 +225,9 @@ def determine_delta(self):
233225 None ,
234226 path_old ,
235227 0 ,
236- self .stats .num_removed ,
237228 "removed" ,
238229 )
230+ self .stats .num_removed += 1
239231
240232 def license_diff (self ):
241233 """
@@ -376,19 +368,20 @@ def licenses_to_dict(self, file):
376368 return []
377369
378370 def file_to_dict (self , deltacode , file , new_file = True ):
371+
379372 path_offset = (
380373 Delta .NEW_CODEBASE_OFFSET if new_file else Delta .OLD_CODEBASE_OFFSET
381374 )
382375 if file :
383376 return OrderedDict (
384377 [
385- ("path" , file .path ),
378+ ("path" , "/" . join ( paths . split ( file .path )[ path_offset :]) ),
386379 ("type" , file .type ),
387380 ("name" , file .name ),
388381 ("size" , file .size ),
389382 ("sha1" , file .sha1 ),
390- ("fingerprint" , deltacode . old_files_fingerprint . get ( file . path , "" ) ),
391- ("original_path" , "/" . join ( paths . split ( file .path )[ path_offset :]) ),
383+ ("fingerprint" , "" ),
384+ ("original_path" , file .path ),
392385 ("licenses" , self .licenses_to_dict (file )),
393386 ("copyrights" , self .copyrights_to_dict (file )),
394387 ]
@@ -399,6 +392,8 @@ def to_dict(self, deltacode):
399392 Return an OrderedDict comprising the 'factors', 'score' and new and old
400393 'path' attributes of the object.
401394 """
395+ if not deltacode .options .get ("--all-delta-types" , "" ) == True and self .status == "unmodified" :
396+ return
402397 if self .new_file :
403398 new_file = self .new_file .to_dict ()
404399 else :
0 commit comments