scripts/chg-len.py
author Peter Kovacs <kpeter@inf.elte.hu>
Sun, 30 Nov 2008 21:53:24 +0100
changeset 406 a578265aa8a6
parent 284 a16cc721259e
child 422 62c1ed05e83f
permissions -rwxr-xr-x
Improvements in groups.dox (#188)

- Unify the notations used for formulas.
- Add 'namespace lemon {...}' to simplify the references.
- Improved doc for algorithm groups.
- Extend the doc of the "shortest path" and "minimum cost flow" modules.
     1 #! /usr/bin/env python
     2 
     3 import sys
     4 
     5 from mercurial import ui, hg
     6 
     7 if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
     8     print """
     9 This utility just prints the length of the longest path
    10 in the revision graph from revison 0 to the current one.
    11 """
    12     exit(0)
    13 
    14 u = ui.ui()
    15 r = hg.repository(u, ".")
    16 N = r.changectx(".").rev()
    17 lengths=[0]*(N+1)
    18 for i in range(N+1):
    19     p=r.changectx(i).parents()
    20     if p[0]:
    21         p0=lengths[p[0].rev()]
    22     else:
    23         p0=-1
    24     if len(p)>1 and p[1]:
    25         p1=lengths[p[1].rev()]
    26     else:
    27         p1=-1
    28     lengths[i]=max(p0,p1)+1
    29 print lengths[N]