code: def is_ancestor(self, commit1, commit2, patch=False):
          
          result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2),
                           "--template", "exists", patch=patch)
          return "exists" in result
docs: Returns True if commit1 is a direct ancestor of commit2, or False
          otherwise.
  
          This method considers a commit to be a direct ancestor of itself