mercurial/merge.py
changeset 6270 14f0fe2e2db7
parent 6269 ffdf70e74623
child 6271 01aed23355e9
equal deleted inserted replaced
6269:ffdf70e74623 6270:14f0fe2e2db7
   116 
   116 
   117     copy = {}
   117     copy = {}
   118     fullcopy = {}
   118     fullcopy = {}
   119     diverge = {}
   119     diverge = {}
   120 
   120 
   121     def checkcopies(c, man, aman):
   121     def checkcopies(f, m1, m2):
   122         '''check possible copies for filectx c'''
   122         '''check possible copies of f from m1 to m2'''
   123         for of in _findoldnames(c, limit):
   123         c1 = ctx(f, m1[f])
   124             fullcopy[c.path()] = of # remember for dir rename detection
   124         for of in _findoldnames(c1, limit):
   125             if of not in man: # original file not in other manifest?
   125             fullcopy[f] = of # remember for dir rename detection
       
   126             if of not in m2: # original file not in other manifest?
   126                 if of in ma:
   127                 if of in ma:
   127                     diverge.setdefault(of, []).append(c.path())
   128                     diverge.setdefault(of, []).append(f)
   128                 continue
   129                 continue
   129             # if the original file is unchanged on the other branch,
   130             # if the original file is unchanged on the other branch,
   130             # no merge needed
   131             # no merge needed
   131             if man[of] == aman.get(of):
   132             if m2[of] == ma.get(of):
   132                 continue
   133                 continue
   133             c2 = ctx(of, man[of])
   134             c2 = ctx(of, m2[of])
   134             ca = c.ancestor(c2)
   135             ca = c1.ancestor(c2)
   135             if not ca: # unrelated?
   136             if not ca: # unrelated?
   136                 continue
   137                 continue
   137             # named changed on only one side?
   138             # named changed on only one side?
   138             if ca.path() == c.path() or ca.path() == c2.path():
   139             if ca.path() == f or ca.path() == c2.path():
   139                 if c == ca and c2 == ca: # no merge needed, ignore copy
   140                 if c1 == ca and c2 == ca: # no merge needed, ignore copy
   140                     continue
   141                     continue
   141                 copy[c.path()] = of
   142                 copy[f] = of
   142 
   143 
   143     if not repo.ui.configbool("merge", "followcopies", True):
   144     if not repo.ui.configbool("merge", "followcopies", True):
   144         return {}, {}
   145         return {}, {}
   145 
   146 
   146     # avoid silly behavior for update from empty dir
   147     # avoid silly behavior for update from empty dir
   158     if u2:
   159     if u2:
   159         repo.ui.debug(_("  unmatched files in other:\n   %s\n")
   160         repo.ui.debug(_("  unmatched files in other:\n   %s\n")
   160                       % "\n   ".join(u2))
   161                       % "\n   ".join(u2))
   161 
   162 
   162     for f in u1:
   163     for f in u1:
   163         checkcopies(ctx(f, m1[f]), m2, ma)
   164         checkcopies(f, m1, m2)
   164 
   165 
   165     for f in u2:
   166     for f in u2:
   166         checkcopies(ctx(f, m2[f]), m1, ma)
   167         checkcopies(f, m2, m1)
   167 
   168 
   168     diverge2 = {}
   169     diverge2 = {}
   169     for of, fl in diverge.items():
   170     for of, fl in diverge.items():
   170         if len(fl) == 1:
   171         if len(fl) == 1:
   171             del diverge[of] # not actually divergent
   172             del diverge[of] # not actually divergent