author | Peter Kovacs <kpeter@inf.elte.hu> |
Mon, 01 Mar 2010 02:28:44 +0100 | |
changeset 57 | 18404ec968ca |
permissions | -rwxr-xr-x |
alpar@17 | 1 |
#! /usr/bin/env python |
alpar@17 | 2 |
|
alpar@17 | 3 |
import sys |
alpar@17 | 4 |
import os |
alpar@17 | 5 |
|
alpar@17 | 6 |
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]: |
alpar@17 | 7 |
print """ |
alpar@17 | 8 |
This utility just prints the length of the longest path |
alpar@17 | 9 |
in the revision graph from revison 0 to the current one. |
alpar@17 | 10 |
""" |
alpar@17 | 11 |
exit(0) |
alpar@17 | 12 |
plist = os.popen("HGRCPATH='' hg parents --template='{rev}\n'").readlines() |
alpar@17 | 13 |
if len(plist)>1: |
alpar@17 | 14 |
print "You are in the process of merging" |
alpar@17 | 15 |
exit(1) |
alpar@17 | 16 |
PAR = int(plist[0]) |
alpar@17 | 17 |
|
alpar@17 | 18 |
f = os.popen("HGRCPATH='' hg log -r 0:tip --template='{rev} {parents}\n'").\ |
alpar@17 | 19 |
readlines() |
alpar@17 | 20 |
REV = -1 |
alpar@17 | 21 |
lengths=[] |
alpar@17 | 22 |
for l in f: |
alpar@17 | 23 |
REV+=1 |
alpar@17 | 24 |
s = l.split() |
alpar@17 | 25 |
rev = int(s[0]) |
alpar@17 | 26 |
if REV != rev: |
alpar@17 | 27 |
print "Something is seriously wrong" |
alpar@17 | 28 |
exit(1) |
alpar@17 | 29 |
if len(s) == 1: |
alpar@17 | 30 |
par1 = par2 = rev - 1 |
alpar@17 | 31 |
elif len(s) == 2: |
alpar@17 | 32 |
par1 = par2 = int(s[1].split(":")[0]) |
alpar@17 | 33 |
else: |
alpar@17 | 34 |
par1 = int(s[1].split(":")[0]) |
alpar@17 | 35 |
par2 = int(s[2].split(":")[0]) |
alpar@17 | 36 |
if rev == 0: |
alpar@17 | 37 |
lengths.append(0) |
alpar@17 | 38 |
else: |
alpar@17 | 39 |
lengths.append(max(lengths[par1],lengths[par2])+1) |
alpar@17 | 40 |
print lengths[PAR] |