gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
chg-len.py does not scan any hg config file now
0 1 0
default
1 file changed with 3 insertions and 0 deletions:
↑ Collapse diff ↑
Show white space 48 line context
1 1
#! /usr/bin/env python
2 2

	
3 3
import sys
4 4

	
5 5
from mercurial import ui, hg
6
from mercurial import util
7

	
8
util.rcpath = lambda : []
6 9

	
7 10
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
8 11
    print """
9 12
This utility just prints the length of the longest path
10 13
in the revision graph from revison 0 to the current one.
11 14
"""
12 15
    exit(0)
13 16

	
14 17
u = ui.ui()
15 18
r = hg.repository(u, ".")
16 19
N = r.changectx(".").rev()
17 20
lengths=[0]*(N+1)
18 21
for i in range(N+1):
19 22
    p=r.changectx(i).parents()
20 23
    if p[0]:
21 24
        p0=lengths[p[0].rev()]
22 25
    else:
23 26
        p0=-1
24 27
    if len(p)>1 and p[1]:
25 28
        p1=lengths[p[1].rev()]
26 29
    else:
27 30
        p1=-1
28 31
    lengths[i]=max(p0,p1)+1
29 32
print lengths[N]
0 comments (0 inline)