@@ -139,14 +139,14 @@ def conflicts(self):
139139 def _merge_base_values (self ):
140140 if self .head == self .update :
141141 self .merged_root = self .head
142- elif self .head == self .root :
143- self .merged_root = self .update
144- elif self .update == self .root :
145- self .merged_root = self .head
146142 elif self .head == NOTHING :
147143 self .merged_root = self .update
148144 elif self .update == NOTHING :
149145 self .merged_root = self .head
146+ elif self .head == self .root :
147+ self .merged_root = self .update
148+ elif self .update == self .root :
149+ self .merged_root = self .head
150150 else :
151151 strategy = self ._get_rule_for_field (self .key_path )
152152 self .merged_root , conflict = {
@@ -171,10 +171,19 @@ def _merge_dicts(self):
171171 self ._solve_dict_conflicts (non_list_merger , e .content )
172172
173173 self ._restore_lists ()
174+ remove_patches = []
175+ other_patches = []
176+ for patch_ in non_list_merger .unified_patches :
177+ if patch_ [0 ] == 'remove' :
178+ remove_patches .append (patch_ )
179+ else :
180+ other_patches .append (patch_ )
181+ remove_patches_deduped = dedupe_list (remove_patches )
182+ unified_patches = remove_patches_deduped + other_patches
174183 self .merged_root = patch (
175- dedupe_list ( non_list_merger . unified_patches ) ,
176- self .root
177- )
184+ unified_patches ,
185+ self .root
186+ )
178187
179188 def _solve_dict_conflicts (self , non_list_merger , conflicts ):
180189 strategies = [self ._get_custom_strategy (conflict )
0 commit comments