alpar@2: #! /usr/bin/env python alpar@2: # alpar@2: # This file is a part of LEMON, a generic C++ optimization library. alpar@2: # alpar@2: # Copyright (C) 2003-2009 alpar@2: # Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@2: # (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@2: # alpar@2: # Permission to use, modify and distribute this software is granted alpar@2: # provided that this copyright notice appears in all copies. For alpar@2: # precise terms see the accompanying LICENSE file. alpar@2: # alpar@2: # This software is provided "AS IS" with no warranty of any kind, alpar@2: # express or implied, and with no claim as to its suitability for any alpar@2: # purpose. alpar@2: alpar@2: import sys alpar@2: alpar@2: from mercurial import ui, hg alpar@2: from mercurial import util alpar@2: alpar@2: util.rcpath = lambda : [] alpar@2: alpar@2: if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]: alpar@2: print """ alpar@2: This utility just prints the length of the longest path alpar@2: in the revision graph from revison 0 to the current one. alpar@2: """ alpar@2: exit(0) alpar@2: alpar@2: u = ui.ui() alpar@2: r = hg.repository(u, ".") alpar@2: N = r.changectx(".").rev() alpar@2: lengths=[0]*(N+1) alpar@2: for i in range(N+1): alpar@2: p=r.changectx(i).parents() alpar@2: if p[0]: alpar@2: p0=lengths[p[0].rev()] alpar@2: else: alpar@2: p0=-1 alpar@2: if len(p)>1 and p[1]: alpar@2: p1=lengths[p[1].rev()] alpar@2: else: alpar@2: p1=-1 alpar@2: lengths[i]=max(p0,p1)+1 alpar@2: print lengths[N]