scripts/chg-len.py
author Peter Kovacs <kpeter@inf.elte.hu>
Fri, 09 Jan 2009 12:54:27 +0100
changeset 451 fbd6e04acf44
parent 284 a16cc721259e
child 422 62c1ed05e83f
permissions -rwxr-xr-x
Various doc improvements for graph adaptors (#67)

- Add notes about modifying the adapted graphs through adaptors
if it is possible.
- Add notes about the possible conversions between the Node, Arc and
Edge types of the adapted graphs and the adaptors.
- Hide the default values for template parameters (describe them
in the doc instead).
- More precise docs for template parameters.
- More precise docs for member functions.
- Add docs for important public typedefs.
- Unify the docs of the adaptors.
- Add \relates commands for the creator functions.
- Fixes and improvements the module documentation.
alpar@272
     1
#! /usr/bin/env python
alpar@272
     2
alpar@272
     3
import sys
alpar@376
     4
alpar@376
     5
from mercurial import ui, hg
alpar@272
     6
alpar@272
     7
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
alpar@272
     8
    print """
alpar@272
     9
This utility just prints the length of the longest path
alpar@272
    10
in the revision graph from revison 0 to the current one.
alpar@272
    11
"""
alpar@272
    12
    exit(0)
alpar@272
    13
alpar@376
    14
u = ui.ui()
alpar@376
    15
r = hg.repository(u, ".")
alpar@376
    16
N = r.changectx(".").rev()
alpar@376
    17
lengths=[0]*(N+1)
alpar@376
    18
for i in range(N+1):
alpar@376
    19
    p=r.changectx(i).parents()
alpar@376
    20
    if p[0]:
alpar@376
    21
        p0=lengths[p[0].rev()]
alpar@272
    22
    else:
alpar@376
    23
        p0=-1
alpar@376
    24
    if len(p)>1 and p[1]:
alpar@376
    25
        p1=lengths[p[1].rev()]
alpar@272
    26
    else:
alpar@376
    27
        p1=-1
alpar@376
    28
    lengths[i]=max(p0,p1)+1
alpar@376
    29
print lengths[N]