def reachable(self, node, stop=None):
        """return the set of all nodes ancestral to a given node, including
         the node itself, stopping when stop is matched"""
        reachable = set((node,))
        visit = [node]
        if stop:
            stopn = self.rev(stop)
        else:
            stopn = 0
        while visit:
            n = visit.pop(0)
            if n == stop:
                continue
            if n == nullid:
                continue
            for p in self.parents(n):
                if self.rev(p) < stopn:
                    continue
                if p not in reachable:
                    reachable.add(p)
                    visit.append(p)
        return reachable