scripts/chg-len.py
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Wed, 05 Nov 2008 14:44:37 +0000
changeset 363 a637fb9d457b
parent 272 e63a95b68827
child 376 4b2382fd80ef
permissions -rwxr-xr-x
Revert to the canonical way of customizing CXXFLAGS

A default list of compiler flags is set via AM_CXXFLAGS Automake variable.
However this gets overridden by per-target CXXFLAGS variables (e.g.
foo_CXXFLAGS in case the foo target). Because of this you should append
$(AM_CXXFLAGS) to the end of the per-target CXXFLAGS variables (e.g.
foo_CXXFLAGS = ... $(AM_CXXFLAGS)).

After this default list of flags the contents of the CXXFLAGS user variable is
passed to the compiler. This variable has a default value determined by
configure (in case of g++ it is '-g -O2'). You can override this by specifying
CXXFLAGS when invoking make (e.g. make CXXFLAGS='-O3').
alpar@272
     1
#! /usr/bin/env python
alpar@272
     2
alpar@272
     3
import sys
alpar@272
     4
import os
alpar@272
     5
alpar@272
     6
if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
alpar@272
     7
    print """
alpar@272
     8
This utility just prints the length of the longest path
alpar@272
     9
in the revision graph from revison 0 to the current one.
alpar@272
    10
"""
alpar@272
    11
    exit(0)
alpar@284
    12
plist = os.popen("HGRCPATH='' hg parents --template='{rev}\n'").readlines()
alpar@272
    13
if len(plist)>1:
alpar@272
    14
    print "You are in the process of merging"
alpar@272
    15
    exit(1)
alpar@272
    16
PAR = int(plist[0])
alpar@272
    17
alpar@284
    18
f = os.popen("HGRCPATH='' hg log -r 0:tip --template='{rev} {parents}\n'").\
alpar@284
    19
    readlines()
alpar@272
    20
REV = -1
alpar@272
    21
lengths=[]
alpar@272
    22
for l in f:
alpar@272
    23
    REV+=1
alpar@272
    24
    s = l.split()
alpar@272
    25
    rev = int(s[0])
alpar@272
    26
    if REV != rev:
alpar@272
    27
        print "Something is seriously wrong"
alpar@272
    28
        exit(1)
alpar@272
    29
    if len(s) == 1:
alpar@272
    30
        par1 = par2 = rev - 1
alpar@272
    31
    elif len(s) == 2:
alpar@272
    32
        par1 = par2 = int(s[1].split(":")[0])
alpar@272
    33
    else:
alpar@272
    34
        par1 = int(s[1].split(":")[0])
alpar@272
    35
        par2 = int(s[2].split(":")[0])
alpar@272
    36
    if rev == 0:
alpar@272
    37
        lengths.append(0)
alpar@272
    38
    else:
alpar@272
    39
        lengths.append(max(lengths[par1],lengths[par2])+1)
alpar@272
    40
print lengths[PAR]