comparison mercurial/merge.py @ 31522:527a247f114f

merge: remove unnecessary matcher checks As part of changing manifest.diff to accept a matcher, a previous patch added matcher calls to each location in merge.manifestmerge that tested if 'x in mf' to maintain the same behavior as before. After analyzing it further, this matcher call isn't needed, and in fact hurts future patches ability to use the matcher here. Basically, all these 'if x in mf' checks were checking if a matched file's copy source was in the matcher as well. This meant if you passed a matcher for just file foo, it would not return file bar even if foo was a copy of bar. Since manifestmerge cares about copy information, let's allow all lookups of copy sources. We also update one spot with a 'is not None' check, since it wasn't obvious that the value could sometimes be None before, which broke when we called matcher(None). A future patch adds matcher optimizations to manifestmerge which causes this code path to get covered by existing tests.
author Durham Goode <durham@fb.com>
date Sun, 19 Mar 2017 11:42:17 -0700
parents 1b9b00aca8a3
children e960eba3581c
comparison
equal deleted inserted replaced
31521:2519994d25ca 31522:527a247f114f
856 elif n1: # file exists only on local side 856 elif n1: # file exists only on local side
857 if f in copied: 857 if f in copied:
858 pass # we'll deal with it on m2 side 858 pass # we'll deal with it on m2 side
859 elif f in movewithdir: # directory rename, move local 859 elif f in movewithdir: # directory rename, move local
860 f2 = movewithdir[f] 860 f2 = movewithdir[f]
861 if matcher(f2) and f2 in m2: 861 if f2 in m2:
862 actions[f2] = ('m', (f, f2, None, True, pa.node()), 862 actions[f2] = ('m', (f, f2, None, True, pa.node()),
863 "remote directory rename, both created") 863 "remote directory rename, both created")
864 else: 864 else:
865 actions[f2] = ('dm', (f, fl1), 865 actions[f2] = ('dm', (f, fl1),
866 "remote directory rename - move from " + f) 866 "remote directory rename - move from " + f)
885 elif n2: # file exists only on remote side 885 elif n2: # file exists only on remote side
886 if f in copied: 886 if f in copied:
887 pass # we'll deal with it on m1 side 887 pass # we'll deal with it on m1 side
888 elif f in movewithdir: 888 elif f in movewithdir:
889 f2 = movewithdir[f] 889 f2 = movewithdir[f]
890 if matcher(f2) and f2 in m1: 890 if f2 in m1:
891 actions[f2] = ('m', (f2, f, None, False, pa.node()), 891 actions[f2] = ('m', (f2, f, None, False, pa.node()),
892 "local directory rename, both created") 892 "local directory rename, both created")
893 else: 893 else:
894 actions[f2] = ('dg', (f, fl2), 894 actions[f2] = ('dg', (f, fl2),
895 "local directory rename - get from " + f) 895 "local directory rename - get from " + f)
896 elif f in copy: 896 elif f in copy:
897 f2 = copy[f] 897 f2 = copy[f]
898 if matcher(f2) and f2 in m2: 898 if f2 in m2:
899 actions[f] = ('m', (f2, f, f2, False, pa.node()), 899 actions[f] = ('m', (f2, f, f2, False, pa.node()),
900 "remote copied from " + f2) 900 "remote copied from " + f2)
901 else: 901 else:
902 actions[f] = ('m', (f2, f, f2, True, pa.node()), 902 actions[f] = ('m', (f2, f, f2, True, pa.node()),
903 "remote moved from " + f2) 903 "remote moved from " + f2)
925 for d in dirmove: 925 for d in dirmove:
926 if f.startswith(d): 926 if f.startswith(d):
927 # new file added in a directory that was moved 927 # new file added in a directory that was moved
928 df = dirmove[d] + f[len(d):] 928 df = dirmove[d] + f[len(d):]
929 break 929 break
930 if matcher(df) and df in m1: 930 if df is not None and df in m1:
931 actions[df] = ('m', (df, f, f, False, pa.node()), 931 actions[df] = ('m', (df, f, f, False, pa.node()),
932 "local directory rename - respect move from " + f) 932 "local directory rename - respect move from " + f)
933 elif acceptremote: 933 elif acceptremote:
934 actions[f] = ('c', (fl2,), "remote recreating") 934 actions[f] = ('c', (fl2,), "remote recreating")
935 else: 935 else: