comparison 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
comparison
equal deleted inserted replaced
6874:8dc21876261e 6875:0d714a48ab53
706 # 0 --- 1 --- 3 rev4 reverts the content change from rev2 706 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
707 # \ / merging rev3 and rev4 should use bar@rev2 707 # \ / merging rev3 and rev4 should use bar@rev2
708 # \- 2 --- 4 as the merge base 708 # \- 2 --- 4 as the merge base
709 # 709 #
710 710
711 cr = manifest1.get(cf, nullid) 711 cr = manifest1.get(cf)
712 nfp = fp2 712 nfp = fp2
713 713
714 if manifest2: # branch merge 714 if manifest2: # branch merge
715 if fp2 == nullid: # copied on remote side 715 if fp2 == nullid: # copied on remote side
716 if fp1 != nullid or cf in manifest2: 716 if fp1 != nullid or cf in manifest2:
717 cr = manifest2[cf] 717 cr = manifest2[cf]
718 nfp = fp1 718 nfp = fp1
719
720 # find source in nearest ancestor if we've lost track
721 if not cr:
722 self.ui.debug(_(" %s: searching for copy revision for %s\n") %
723 (fn, cf))
724 p1 = self.dirstate.parents()[0]
725 rev = self.changelog.rev(p1)
726 seen = {-1:None}
727 visit = [rev]
728 while visit:
729 for p in self.changelog.parentrevs(visit.pop(0)):
730 if p not in seen:
731 seen[p] = True
732 visit.append(p)
733 ctx = self.changectx(p)
734 if cf in ctx:
735 cr = ctx[cf].filenode()
736 break
719 737
720 self.ui.debug(_(" %s: copy %s:%s\n") % (fn, cf, hex(cr))) 738 self.ui.debug(_(" %s: copy %s:%s\n") % (fn, cf, hex(cr)))
721 meta["copy"] = cf 739 meta["copy"] = cf
722 meta["copyrev"] = hex(cr) 740 meta["copyrev"] = hex(cr)
723 fp1, fp2 = nullid, nfp 741 fp1, fp2 = nullid, nfp