COIN-OR::LEMON - Graph Library

source: lemon/scripts/chg-len.py @ 926:ec0b1b423b8b

Last change on this file since 926:ec0b1b423b8b was 439:62c1ed05e83f, checked in by Alpar Juttner <alpar@…>, 16 years ago

chg-len.py does not scan any hg config file now

  • Property exe set to *
File size: 648 bytes
Line 
1#! /usr/bin/env python
2
3import sys
4
5from mercurial import ui, hg
6from mercurial import util
7
8util.rcpath = lambda : []
9
10if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
11    print """
12This utility just prints the length of the longest path
13in the revision graph from revison 0 to the current one.
14"""
15    exit(0)
16
17u = ui.ui()
18r = hg.repository(u, ".")
19N = r.changectx(".").rev()
20lengths=[0]*(N+1)
21for i in range(N+1):
22    p=r.changectx(i).parents()
23    if p[0]:
24        p0=lengths[p[0].rev()]
25    else:
26        p0=-1
27    if len(p)>1 and p[1]:
28        p1=lengths[p[1].rev()]
29    else:
30        p1=-1
31    lengths[i]=max(p0,p1)+1
32print lengths[N]
Note: See TracBrowser for help on using the repository browser.