diff --git a/mercurial/context.py b/mercurial/context.py index 91cb08a9e7fb2c98db04210c17342bc3c6efcee1_bWVyY3VyaWFsL2NvbnRleHQucHk=..cc4e13c92dfa441c735e3b383fa6ac6c071884ae_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644 --- a/mercurial/context.py +++ b/mercurial/context.py @@ -821,6 +821,11 @@ finally: wlock.release() + def ancestors(self): + for a in self._repo.changelog.ancestors( + *[p.rev() for p in self._parents]): + yield changectx(self._repo, a) + def remove(self, list, unlink=False): if unlink: for f in list: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py index 91cb08a9e7fb2c98db04210c17342bc3c6efcee1_bWVyY3VyaWFsL2xvY2FscmVwby5weQ==..cc4e13c92dfa441c735e3b383fa6ac6c071884ae_bWVyY3VyaWFsL2xvY2FscmVwby5weQ== 100644 --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -819,8 +819,8 @@ if not crev: self.ui.debug(" %s: searching for copy revision for %s\n" % (fname, cfname)) - for ancestor in self['.'].ancestors(): + for ancestor in self[None].ancestors(): if cfname in ancestor: crev = ancestor[cfname].filenode() break @@ -823,11 +823,16 @@ if cfname in ancestor: crev = ancestor[cfname].filenode() break - self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) - meta["copy"] = cfname - meta["copyrev"] = hex(crev) - fparent1, fparent2 = nullid, newfparent + if crev: + self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) + meta["copy"] = cfname + meta["copyrev"] = hex(crev) + fparent1, fparent2 = nullid, newfparent + else: + self.ui.warn(_("warning: can't find ancestor for '%s' " + "copied from '%s'!\n") % (fname, cfname)) + elif fparent2 != nullid: # is one parent an ancestor of the other? fparentancestor = flog.ancestor(fparent1, fparent2)