# HG changeset patch # User Alpar Juttner # Date 2012-01-30 17:49:50 # Node ID 0b9a949569167be588a7e657d4a563fe03bcd690 # Parent cdd2c7dad989a1032b4b88389befb3c08f989bed Use hg templating instead of scripts/chg-len.py (#434) diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,29 +12,47 @@ SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.") ELSE() EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py + COMMAND + hg log -r. --template "{latesttag}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE HG_REVISION_PATH + OUTPUT_VARIABLE HG_REVISION_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) EXECUTE_PROCESS( - COMMAND hg id -i + COMMAND + hg log -r. --template "{latesttagdistance}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE HG_REVISION + OUTPUT_VARIABLE HG_REVISION_DIST ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - IF(HG_REVISION STREQUAL "") + EXECUTE_PROCESS( + COMMAND + hg log -r. --template "{node|short}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE HG_REVISION_ID + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + IF(HG_REVISION_TAG STREQUAL "") SET(HG_REVISION_ID "hg-tip") ELSE() - IF(HG_REVISION_PATH STREQUAL "") - SET(HG_REVISION_ID ${HG_REVISION}) + IF(HG_REVISION_TAG STREQUAL "null") + SET(HG_REVISION_TAG "trunk") + ELSEIF(HG_REVISION_TAG MATCHES "^r") + STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG) + ENDIF() + IF(HG_REVISION_DIST STREQUAL "0") + SET(HG_REVISION ${HG_REVISION_TAG}) ELSE() - SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION}) + SET(HG_REVISION + "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}") ENDIF() ENDIF() - SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.") + + SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.") ENDIF() SET(PROJECT_VERSION ${LEMON_VERSION}) diff --git a/scripts/chg-len.py b/scripts/chg-len.py deleted file mode 100755 --- a/scripts/chg-len.py +++ /dev/null @@ -1,46 +0,0 @@ -#! /usr/bin/env python -# -# This file is a part of LEMON, a generic C++ optimization library. -# -# Copyright (C) 2003-2009 -# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport -# (Egervary Research Group on Combinatorial Optimization, EGRES). -# -# Permission to use, modify and distribute this software is granted -# provided that this copyright notice appears in all copies. For -# precise terms see the accompanying LICENSE file. -# -# This software is provided "AS IS" with no warranty of any kind, -# express or implied, and with no claim as to its suitability for any -# purpose. - -import sys - -from mercurial import ui, hg -from mercurial import util - -util.rcpath = lambda : [] - -if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]: - print """ -This utility just prints the length of the longest path -in the revision graph from revison 0 to the current one. -""" - exit(0) - -u = ui.ui() -r = hg.repository(u, ".") -N = r.changectx(".").rev() -lengths=[0]*(N+1) -for i in range(N+1): - p=r.changectx(i).parents() - if p[0]: - p0=lengths[p[0].rev()] - else: - p0=-1 - if len(p)>1 and p[1]: - p1=lengths[p[1].rev()] - else: - p1=-1 - lengths[i]=max(p0,p1)+1 -print lengths[N]