cache version across calls to version_mercurial, so as to avoid opening the repo every time
--- 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) :
"""
--- 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='.') :
"""