version.py
changeset 132 0e857c4a67de
parent 119 df859bfdd3be
child 138 7dbe0ee1a27b
--- 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='.') :
     """