1.1 --- a/scripts/chg-len.py Fri Oct 16 10:21:37 2009 +0200
1.2 +++ b/scripts/chg-len.py Thu Nov 05 15:50:01 2009 +0100
1.3 @@ -1,7 +1,25 @@
1.4 #! /usr/bin/env python
1.5 +#
1.6 +# This file is a part of LEMON, a generic C++ optimization library.
1.7 +#
1.8 +# Copyright (C) 2003-2009
1.9 +# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 +# (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 +#
1.12 +# Permission to use, modify and distribute this software is granted
1.13 +# provided that this copyright notice appears in all copies. For
1.14 +# precise terms see the accompanying LICENSE file.
1.15 +#
1.16 +# This software is provided "AS IS" with no warranty of any kind,
1.17 +# express or implied, and with no claim as to its suitability for any
1.18 +# purpose.
1.19
1.20 import sys
1.21 -import os
1.22 +
1.23 +from mercurial import ui, hg
1.24 +from mercurial import util
1.25 +
1.26 +util.rcpath = lambda : []
1.27
1.28 if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
1.29 print """
1.30 @@ -9,32 +27,20 @@
1.31 in the revision graph from revison 0 to the current one.
1.32 """
1.33 exit(0)
1.34 -plist = os.popen("HGRCPATH='' hg parents --template='{rev}\n'").readlines()
1.35 -if len(plist)>1:
1.36 - print "You are in the process of merging"
1.37 - exit(1)
1.38 -PAR = int(plist[0])
1.39
1.40 -f = os.popen("HGRCPATH='' hg log -r 0:tip --template='{rev} {parents}\n'").\
1.41 - readlines()
1.42 -REV = -1
1.43 -lengths=[]
1.44 -for l in f:
1.45 - REV+=1
1.46 - s = l.split()
1.47 - rev = int(s[0])
1.48 - if REV != rev:
1.49 - print "Something is seriously wrong"
1.50 - exit(1)
1.51 - if len(s) == 1:
1.52 - par1 = par2 = rev - 1
1.53 - elif len(s) == 2:
1.54 - par1 = par2 = int(s[1].split(":")[0])
1.55 +u = ui.ui()
1.56 +r = hg.repository(u, ".")
1.57 +N = r.changectx(".").rev()
1.58 +lengths=[0]*(N+1)
1.59 +for i in range(N+1):
1.60 + p=r.changectx(i).parents()
1.61 + if p[0]:
1.62 + p0=lengths[p[0].rev()]
1.63 else:
1.64 - par1 = int(s[1].split(":")[0])
1.65 - par2 = int(s[2].split(":")[0])
1.66 - if rev == 0:
1.67 - lengths.append(0)
1.68 + p0=-1
1.69 + if len(p)>1 and p[1]:
1.70 + p1=lengths[p[1].rev()]
1.71 else:
1.72 - lengths.append(max(lengths[par1],lengths[par2])+1)
1.73 -print lengths[PAR]
1.74 + p1=-1
1.75 + lengths[i]=max(p0,p1)+1
1.76 +print lengths[N]