mercurial/context.py
branchstable
changeset 21203 9f12d8665c7b
parent 21126 99b5eaf372a7
child 21238 25d6fdc0294a
equal deleted inserted replaced
21202:c04e5e937139 21203:9f12d8665c7b
   392         if fileid is None:
   392         if fileid is None:
   393             fileid = self.filenode(path)
   393             fileid = self.filenode(path)
   394         return filectx(self._repo, path, fileid=fileid,
   394         return filectx(self._repo, path, fileid=fileid,
   395                        changectx=self, filelog=filelog)
   395                        changectx=self, filelog=filelog)
   396 
   396 
   397     def ancestor(self, c2):
   397     def ancestor(self, c2, warn=False):
   398         """
   398         """
   399         return the "best" ancestor context of self and c2
   399         return the "best" ancestor context of self and c2
   400         """
   400         """
   401         # deal with workingctxs
   401         # deal with workingctxs
   402         n2 = c2._node
   402         n2 = c2._node
   413                 anc = ctx.node()
   413                 anc = ctx.node()
   414                 if anc in cahs:
   414                 if anc in cahs:
   415                     break
   415                     break
   416             else:
   416             else:
   417                 anc = self._repo.changelog.ancestor(self._node, n2)
   417                 anc = self._repo.changelog.ancestor(self._node, n2)
   418             self._repo.ui.status(
   418             if warn:
   419                 (_("note: using %s as ancestor of %s and %s\n") %
   419                 self._repo.ui.status(
   420                  (short(anc), short(self._node), short(n2))) +
   420                     (_("note: using %s as ancestor of %s and %s\n") %
   421                 ''.join(_("      alternatively, use --config "
   421                      (short(anc), short(self._node), short(n2))) +
   422                           "merge.preferancestor=%s\n") %
   422                     ''.join(_("      alternatively, use --config "
   423                         short(n) for n in sorted(cahs) if n != anc))
   423                               "merge.preferancestor=%s\n") %
       
   424                             short(n) for n in sorted(cahs) if n != anc))
   424         return changectx(self._repo, anc)
   425         return changectx(self._repo, anc)
   425 
   426 
   426     def descendant(self, other):
   427     def descendant(self, other):
   427         """True if other is descendant of this changeset"""
   428         """True if other is descendant of this changeset"""
   428         return self._repo.changelog.descendant(self._rev, other._rev)
   429         return self._repo.changelog.descendant(self._rev, other._rev)