# HG changeset patch # User Tero Marttila # Date 1234738465 -7200 # Node ID 0e857c4a67dee87835e4afb4ba73ed208e97cf64 # Parent 67f5d2fdca1d88e5a41fd01e9bf802485757f467 cache version across calls to version_mercurial, so as to avoid opening the repo every time diff -r 67f5d2fdca1d -r 0e857c4a67de helpers.py --- a/helpers.py Mon Feb 16 00:52:20 2009 +0200 +++ b/helpers.py Mon Feb 16 00:54:25 2009 +0200 @@ -22,7 +22,6 @@ # list of (month_num, month_name) for the months in the year months = list(enumerate(_calendar.month_name))[1:] - def version_link (self) : """ diff -r 67f5d2fdca1d -r 0e857c4a67de version.py --- a/version.py Mon Feb 16 00:52:20 2009 +0200 +++ b/version.py Mon Feb 16 00:54:25 2009 +0200 @@ -4,11 +4,20 @@ Currently this only supports mercurial """ +# only load this once +_VERSION = None + def version_mercurial (path) : """ Returns a (branch, tags, parents, modified) tuple for the given repo's working copy """ + global _VERSION + + # cached? + if _VERSION : + return _VERSION + # code adapted from mercurial.commands.identify from mercurial import ui, hg, util from mercurial.node import short @@ -36,7 +45,8 @@ modified = bool(ctx.files() + ctx.deleted()) # done - return (branch, tags, parents, modified) + _VERSION = (branch, tags, parents, modified) + return _VERSION def version_string (path='.') : """