comparison mercurial/commit.py @ 46679:d6fa9fbd375d stable

commit: reorder if-else conditional to give mergestate info priority Looking at the code now, I was unable to find a good reason as why we only rely on mergestate extras info after checking whether a filelog parent is ancestor of other or not. I mean if we have stored in mergestate that `other` was chosed, we should blindly pick that one. This cleanup will also help introduce more cases when both `fparent1` and `fparent2` are non-null but using info from mergestate, we can fastpath. The test change actually demonstrates the point of the patch. During merge we were getting the other side of the file but on commit we were marking that as merged. Differential Revision: https://phab.mercurial-scm.org/D10147
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 04 Mar 2021 17:35:58 +0530
parents 89a2afe31e82
children e2f7b2695ba1
comparison
equal deleted inserted replaced
46678:0d055849d5f9 46679:d6fa9fbd375d
353 ) 353 )
354 354
355 elif fparent1 == nullid: 355 elif fparent1 == nullid:
356 fparent1, fparent2 = fparent2, nullid 356 fparent1, fparent2 = fparent2, nullid
357 elif fparent2 != nullid: 357 elif fparent2 != nullid:
358 if ms.active() and ms.extras(fname).get(b'filenode-source') == b'other':
359 fparent1, fparent2 = fparent2, nullid
358 # is one parent an ancestor of the other? 360 # is one parent an ancestor of the other?
359 fparentancestors = flog.commonancestorsheads(fparent1, fparent2) 361 else:
360 if fparent1 in fparentancestors: 362 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
361 fparent1, fparent2 = fparent2, nullid 363 if fparent1 in fparentancestors:
362 elif fparent2 in fparentancestors:
363 fparent2 = nullid
364 elif not fparentancestors:
365 # TODO: this whole if-else might be simplified much more
366 if (
367 ms.active()
368 and ms.extras(fname).get(b'filenode-source') == b'other'
369 ):
370 fparent1, fparent2 = fparent2, nullid 364 fparent1, fparent2 = fparent2, nullid
365 elif fparent2 in fparentancestors:
366 fparent2 = nullid
371 367
372 force_new_node = False 368 force_new_node = False
373 # The file might have been deleted by merge code and user explicitly choose 369 # The file might have been deleted by merge code and user explicitly choose
374 # to revert the file and keep it. The other case can be where there is 370 # to revert the file and keep it. The other case can be where there is
375 # change-delete or delete-change conflict and user explicitly choose to keep 371 # change-delete or delete-change conflict and user explicitly choose to keep