Mercurial > public > mercurial-scm > hg-stable
diff mercurial/merge.py @ 4416:bb1800a7d7e1
merge: fix spurious merges for copies in linear updates
We make better use of contexts to accurately identify copies that
don't need merges.
Add a simple test and update other tests.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 08 May 2007 02:59:13 -0500 |
parents | 84cd52b48f94 |
children | 0912d8df5e19 |
line wrap: on
line diff
--- a/mercurial/merge.py Tue May 08 02:57:05 2007 -0500 +++ b/mercurial/merge.py Tue May 08 02:59:13 2007 -0500 @@ -8,7 +8,7 @@ from node import * from i18n import gettext as _ from demandload import * -demandload(globals(), "errno util os tempfile") +demandload(globals(), "errno util os tempfile context") def filemerge(repo, fw, fo, wctx, mctx): """perform a 3-way merge in the working directory @@ -123,6 +123,14 @@ f = dirname(f) return d + wctx = repo.workingctx() + + def makectx(f, n): + if len(n) == 20: + return repo.filectx(f, fileid=n) + return wctx.filectx(f) + ctx = util.cachefunc(makectx) + def findold(fctx): "find files that path was copied from, back to linkrev limit" old = {} @@ -160,7 +168,7 @@ # named changed on only one side? if ca.path() == c.path() or ca.path() == c2.path(): fullcopy[c.path()] = of # remember for dir rename detection - if c == c2: # no merge needed, ignore copy + if c == ca or c2 == ca: # no merge needed, ignore copy continue copy[c.path()] = of @@ -171,13 +179,11 @@ if not m1 or not m2 or not ma: return {} - dcopies = repo.dirstate.copies() u1 = nonoverlap(m1, m2, ma) u2 = nonoverlap(m2, m1, ma) - ctx = util.cachefunc(lambda f, n: repo.filectx(f, fileid=n[:20])) for f in u1: - checkcopies(ctx(dcopies.get(f, f), m1[f]), m2) + checkcopies(ctx(f, m1[f]), m2) for f in u2: checkcopies(ctx(f, m2[f]), m1)