scripts/chg-len.py
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Wed, 18 Nov 2009 18:37:21 +0000
changeset 793 7c0ad6bd6a63
parent 422 62c1ed05e83f
permissions -rwxr-xr-x
Optionally use valgrind when running tests + other build system fixes
alpar@272
     1
#! /usr/bin/env python
alpar@733
     2
#
alpar@733
     3
# This file is a part of LEMON, a generic C++ optimization library.
alpar@733
     4
#
alpar@733
     5
# Copyright (C) 2003-2009
alpar@733
     6
# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@733
     7
# (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@733
     8
#
alpar@733
     9
# Permission to use, modify and distribute this software is granted
alpar@733
    10
# provided that this copyright notice appears in all copies. For
alpar@733
    11
# precise terms see the accompanying LICENSE file.
alpar@733
    12
#
alpar@733
    13
# This software is provided "AS IS" with no warranty of any kind,
alpar@733
    14
# express or implied, and with no claim as to its suitability for any
alpar@733
    15
# purpose.
alpar@272
    16
alpar@272
    17
import sys
alpar@376
    18
alpar@376
    19
from mercurial import ui, hg
alpar@422
    20
from mercurial import util
alpar@422
    21
alpar@422
    22
util.rcpath = lambda : []
alpar@272
    23
alpar@272
    24
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
alpar@272
    25
    print """
alpar@272
    26
This utility just prints the length of the longest path
alpar@272
    27
in the revision graph from revison 0 to the current one.
alpar@272
    28
"""
alpar@272
    29
    exit(0)
alpar@272
    30
alpar@376
    31
u = ui.ui()
alpar@376
    32
r = hg.repository(u, ".")
alpar@376
    33
N = r.changectx(".").rev()
alpar@376
    34
lengths=[0]*(N+1)
alpar@376
    35
for i in range(N+1):
alpar@376
    36
    p=r.changectx(i).parents()
alpar@376
    37
    if p[0]:
alpar@376
    38
        p0=lengths[p[0].rev()]
alpar@272
    39
    else:
alpar@376
    40
        p0=-1
alpar@376
    41
    if len(p)>1 and p[1]:
alpar@376
    42
        p1=lengths[p[1].rev()]
alpar@272
    43
    else:
alpar@376
    44
        p1=-1
alpar@376
    45
    lengths[i]=max(p0,p1)+1
alpar@376
    46
print lengths[N]