Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 6875:0d714a48ab53
add a fix for issue 1175
If we copy a file followed by an update, it's possible for the parent
manifest to no longer contain the source file of the copy, which could cause
commit to fail. If this happens, we search backwares from the first
parent to find the most likely original revision.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Aug 2008 18:01:03 -0500 |
parents | 8dc21876261e |
children | 077f1e637cd8 1d38f3605b20 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sun Aug 10 18:01:03 2008 -0500 +++ b/mercurial/localrepo.py Sun Aug 10 18:01:03 2008 -0500 @@ -708,7 +708,7 @@ # \- 2 --- 4 as the merge base # - cr = manifest1.get(cf, nullid) + cr = manifest1.get(cf) nfp = fp2 if manifest2: # branch merge @@ -717,6 +717,24 @@ cr = manifest2[cf] nfp = fp1 + # find source in nearest ancestor if we've lost track + if not cr: + self.ui.debug(_(" %s: searching for copy revision for %s\n") % + (fn, cf)) + p1 = self.dirstate.parents()[0] + rev = self.changelog.rev(p1) + seen = {-1:None} + visit = [rev] + while visit: + for p in self.changelog.parentrevs(visit.pop(0)): + if p not in seen: + seen[p] = True + visit.append(p) + ctx = self.changectx(p) + if cf in ctx: + cr = ctx[cf].filenode() + break + self.ui.debug(_(" %s: copy %s:%s\n") % (fn, cf, hex(cr))) meta["copy"] = cf meta["copyrev"] = hex(cr)