mercurial/context.py
changeset 21126 99b5eaf372a7
parent 21125 e94e90a4526e
child 21203 9f12d8665c7b
equal deleted inserted replaced
21125:e94e90a4526e 21126:99b5eaf372a7
   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):
   398         """
   398         """
   399         return the 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
   403         if n2 is None:
   403         if n2 is None:
   404             n2 = c2._parents[0]._node
   404             n2 = c2._parents[0]._node
   406         if not cahs:
   406         if not cahs:
   407             anc = nullid
   407             anc = nullid
   408         elif len(cahs) == 1:
   408         elif len(cahs) == 1:
   409             anc = cahs[0]
   409             anc = cahs[0]
   410         else:
   410         else:
   411             anc = self._repo.changelog.ancestor(self._node, n2)
   411             for r in self._repo.ui.configlist('merge', 'preferancestor'):
       
   412                 ctx = changectx(self._repo, r)
       
   413                 anc = ctx.node()
       
   414                 if anc in cahs:
       
   415                     break
       
   416             else:
       
   417                 anc = self._repo.changelog.ancestor(self._node, n2)
   412             self._repo.ui.status(
   418             self._repo.ui.status(
   413                 (_("note: using %s as ancestor of %s and %s\n") %
   419                 (_("note: using %s as ancestor of %s and %s\n") %
   414                  (short(anc), short(self._node), short(n2))))
   420                  (short(anc), short(self._node), short(n2))) +
       
   421                 ''.join(_("      alternatively, use --config "
       
   422                           "merge.preferancestor=%s\n") %
       
   423                         short(n) for n in sorted(cahs) if n != anc))
   415         return changectx(self._repo, anc)
   424         return changectx(self._repo, anc)
   416 
   425 
   417     def descendant(self, other):
   426     def descendant(self, other):
   418         """True if other is descendant of this changeset"""
   427         """True if other is descendant of this changeset"""
   419         return self._repo.changelog.descendant(self._rev, other._rev)
   428         return self._repo.changelog.descendant(self._rev, other._rev)