mercurial/merge.py
changeset 3157 56c59ba7aa76
parent 3155 c82ea81d6850
child 3161 1839e6e91c3a
equal deleted inserted replaced
3156:b1f10d3223c1 3157:56c59ba7aa76
    61 def workingmanifest(repo, man, status):
    61 def workingmanifest(repo, man, status):
    62     """
    62     """
    63     Update manifest to correspond to the working directory
    63     Update manifest to correspond to the working directory
    64     """
    64     """
    65 
    65 
       
    66     copied = repo.dirstate.copies()
    66     modified, added, removed, deleted, unknown = status[:5]
    67     modified, added, removed, deleted, unknown = status[:5]
    67     for i,l in (("a", added), ("m", modified), ("u", unknown)):
    68     for i,l in (("a", added), ("m", modified), ("u", unknown)):
    68         for f in l:
    69         for f in l:
    69             man[f] = man.get(f, nullid) + i
    70             man[f] = man.get(copied.get(f, f), nullid) + i
    70             man.set(f, util.is_exec(repo.wjoin(f), man.execf(f)))
    71             man.set(f, util.is_exec(repo.wjoin(f), man.execf(f)))
    71 
    72 
    72     for f in deleted + removed:
    73     for f in deleted + removed:
    73         del man[f]
    74         del man[f]
    74 
    75 
   130 def findcopies(repo, m1, m2, limit):
   131 def findcopies(repo, m1, m2, limit):
   131     """
   132     """
   132     Find moves and copies between m1 and m2 back to limit linkrev
   133     Find moves and copies between m1 and m2 back to limit linkrev
   133     """
   134     """
   134 
   135 
       
   136     dcopies = repo.dirstate.copies()
   135     copy = {}
   137     copy = {}
   136     match = {}
   138     match = {}
   137     u1 = nonoverlap(m1, m2)
   139     u1 = nonoverlap(m1, m2)
   138     u2 = nonoverlap(m2, m1)
   140     u2 = nonoverlap(m2, m1)
   139     ctx = util.cachefunc(lambda f,n: repo.filectx(f, fileid=n[:20]))
   141     ctx = util.cachefunc(lambda f,n: repo.filectx(f, fileid=n[:20]))
   145         if ca:
   147         if ca:
   146             copy[c.path()] = f2
   148             copy[c.path()] = f2
   147             copy[f2] = c.path()
   149             copy[f2] = c.path()
   148 
   150 
   149     for f in u1:
   151     for f in u1:
   150         c = ctx(f, m1[f])
   152         c = ctx(dcopies.get(f, f), m1[f])
   151         for of in findold(c, limit):
   153         for of in findold(c, limit):
   152             if of in m2:
   154             if of in m2:
   153                 checkpair(c, of, m2)
   155                 checkpair(c, of, m2)
   154             else:
   156             else:
   155                 match.setdefault(of, []).append(f)
   157                 match.setdefault(of, []).append(f)
   352                   (overwrite, branchmerge, bool(partial)))
   354                   (overwrite, branchmerge, bool(partial)))
   353     repo.ui.debug(_(" ancestor %s local %s remote %s\n") %
   355     repo.ui.debug(_(" ancestor %s local %s remote %s\n") %
   354                   (short(p1), short(p2), short(pa)))
   356                   (short(p1), short(p2), short(pa)))
   355 
   357 
   356     action = []
   358     action = []
       
   359 
       
   360     copy = {}
       
   361     if not (backwards or overwrite):
       
   362         copy = findcopies(repo, m1, m2, repo.changelog.rev(pa))
       
   363 
   357     m1 = workingmanifest(repo, m1, status)
   364     m1 = workingmanifest(repo, m1, status)
   358 
   365 
   359     if not force:
   366     if not force:
   360         checkunknown(repo, m2, status)
   367         checkunknown(repo, m2, status)
   361     if not branchmerge:
   368     if not branchmerge:
   362         action += forgetremoved(m2, status)
   369         action += forgetremoved(m2, status)
   363 
       
   364     copy = {}
       
   365     if not (backwards or overwrite):
       
   366         copy = findcopies(repo, m1, m2, repo.changelog.rev(pa))
       
   367 
   370 
   368     action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards, partial)
   371     action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards, partial)
   369     del m1, m2, ma
   372     del m1, m2, ma
   370 
   373 
   371     ### apply phase
   374     ### apply phase