version.py
changeset 132 0e857c4a67de
parent 119 df859bfdd3be
child 138 7dbe0ee1a27b
equal deleted inserted replaced
131:67f5d2fdca1d 132:0e857c4a67de
     2     Figuring out the project version
     2     Figuring out the project version
     3 
     3 
     4     Currently this only supports mercurial
     4     Currently this only supports mercurial
     5 """
     5 """
     6 
     6 
       
     7 # only load this once
       
     8 _VERSION = None
       
     9 
     7 def version_mercurial (path) :
    10 def version_mercurial (path) :
     8     """
    11     """
     9         Returns a (branch, tags, parents, modified) tuple for the given repo's working copy
    12         Returns a (branch, tags, parents, modified) tuple for the given repo's working copy
    10     """
    13     """
       
    14 
       
    15     global _VERSION
       
    16 
       
    17     # cached?
       
    18     if _VERSION :
       
    19         return _VERSION
    11 
    20 
    12     # code adapted from mercurial.commands.identify
    21     # code adapted from mercurial.commands.identify
    13     from mercurial import ui, hg, util
    22     from mercurial import ui, hg, util
    14     from mercurial.node import short
    23     from mercurial.node import short
    15     
    24     
    34 
    43 
    35     # local modifications?
    44     # local modifications?
    36     modified = bool(ctx.files() + ctx.deleted())
    45     modified = bool(ctx.files() + ctx.deleted())
    37 
    46 
    38     # done
    47     # done
    39     return (branch, tags, parents, modified)
    48     _VERSION = (branch, tags, parents, modified)
       
    49     return _VERSION
    40 
    50 
    41 def version_string (path='.') :
    51 def version_string (path='.') :
    42     """
    52     """
    43         Return a version string representing the version of the software at the given path.
    53         Return a version string representing the version of the software at the given path.
    44 
    54