alpar@272: #! /usr/bin/env python
alpar@272: 
alpar@272: import sys
alpar@376: 
alpar@376: from mercurial import ui, hg
alpar@422: from mercurial import util
alpar@422: 
alpar@422: util.rcpath = lambda : []
alpar@272: 
alpar@272: if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
alpar@272:     print """
alpar@272: This utility just prints the length of the longest path
alpar@272: in the revision graph from revison 0 to the current one.
alpar@272: """
alpar@272:     exit(0)
alpar@272: 
alpar@376: u = ui.ui()
alpar@376: r = hg.repository(u, ".")
alpar@376: N = r.changectx(".").rev()
alpar@376: lengths=[0]*(N+1)
alpar@376: for i in range(N+1):
alpar@376:     p=r.changectx(i).parents()
alpar@376:     if p[0]:
alpar@376:         p0=lengths[p[0].rev()]
alpar@272:     else:
alpar@376:         p0=-1
alpar@376:     if len(p)>1 and p[1]:
alpar@376:         p1=lengths[p[1].rev()]
alpar@272:     else:
alpar@376:         p1=-1
alpar@376:     lengths[i]=max(p0,p1)+1
alpar@376: print lengths[N]