Mercurial > hg
comparison mercurial/merge.py @ 45296:cb0cd87e16b4
merge: unify logic of couple of if-else's in manifestmerge()
Right now manifestmerge() contains very nested if-else conditions and it's not
easy to understand what is happening. I was looking for easy unifications and
found these two.
Differential Revision: https://phab.mercurial-scm.org/D8834
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 25 Jul 2020 01:17:35 +0530 |
parents | 4e6a2889dd1d |
children | e98f7c5babd7 |
comparison
equal
deleted
inserted
replaced
45295:6a8eafaeff3b | 45296:cb0cd87e16b4 |
---|---|
758 if f not in ma: | 758 if f not in ma: |
759 # TODO: what if they're renamed from different sources? | 759 # TODO: what if they're renamed from different sources? |
760 fa = branch_copies1.copy.get( | 760 fa = branch_copies1.copy.get( |
761 f, None | 761 f, None |
762 ) or branch_copies2.copy.get(f, None) | 762 ) or branch_copies2.copy.get(f, None) |
763 args, msg = None, None | |
763 if fa is not None: | 764 if fa is not None: |
764 mresult.addfile( | 765 args = (f, f, fa, False, pa.node()) |
765 f, | 766 msg = b'both renamed from %s' % fa |
766 mergestatemod.ACTION_MERGE, | |
767 (f, f, fa, False, pa.node()), | |
768 b'both renamed from %s' % fa, | |
769 ) | |
770 else: | 767 else: |
771 mresult.addfile( | 768 args = (f, f, None, False, pa.node()) |
772 f, | 769 msg = b'both created' |
773 mergestatemod.ACTION_MERGE, | 770 mresult.addfile(f, mergestatemod.ACTION_MERGE, args, msg) |
774 (f, f, None, False, pa.node()), | |
775 b'both created', | |
776 ) | |
777 else: | 771 else: |
778 a = ma[f] | 772 a = ma[f] |
779 fla = ma.flags(f) | 773 fla = ma.flags(f) |
780 nol = b'l' not in fl1 + fl2 + fla | 774 nol = b'l' not in fl1 + fl2 + fla |
781 if n2 == a and fl2 == fla: | 775 if n2 == a and fl2 == fla: |
896 (f, fl2), | 890 (f, fl2), |
897 b'local directory rename - get from %s' % f, | 891 b'local directory rename - get from %s' % f, |
898 ) | 892 ) |
899 elif f in branch_copies2.copy: | 893 elif f in branch_copies2.copy: |
900 f2 = branch_copies2.copy[f] | 894 f2 = branch_copies2.copy[f] |
895 msg, args = None, None | |
901 if f2 in m2: | 896 if f2 in m2: |
902 mresult.addfile( | 897 args = (f2, f, f2, False, pa.node()) |
903 f, | 898 msg = b'remote copied from %s' % f2 |
904 mergestatemod.ACTION_MERGE, | |
905 (f2, f, f2, False, pa.node()), | |
906 b'remote copied from %s' % f2, | |
907 ) | |
908 else: | 899 else: |
909 mresult.addfile( | 900 args = (f2, f, f2, True, pa.node()) |
910 f, | 901 msg = b'remote moved from %s' % f2 |
911 mergestatemod.ACTION_MERGE, | 902 mresult.addfile(f, mergestatemod.ACTION_MERGE, args, msg) |
912 (f2, f, f2, True, pa.node()), | |
913 b'remote moved from %s' % f2, | |
914 ) | |
915 elif f not in ma: | 903 elif f not in ma: |
916 # local unknown, remote created: the logic is described by the | 904 # local unknown, remote created: the logic is described by the |
917 # following table: | 905 # following table: |
918 # | 906 # |
919 # force branchmerge different | action | 907 # force branchmerge different | action |