version.py
changeset 138 7dbe0ee1a27b
parent 132 0e857c4a67de
equal deleted inserted replaced
137:a25d1bf758e6 138:7dbe0ee1a27b
    17     # cached?
    17     # cached?
    18     if _VERSION :
    18     if _VERSION :
    19         return _VERSION
    19         return _VERSION
    20 
    20 
    21     # code adapted from mercurial.commands.identify
    21     # code adapted from mercurial.commands.identify
    22     from mercurial import ui, hg, util
    22     from mercurial import ui, hg, encoding
    23     from mercurial.node import short
    23     from mercurial.node import short
    24     
    24     
    25     # open the repo
    25     # open the repo
    26     repo = hg.repository(ui.ui(), path)
    26     repo = hg.repository(ui.ui(), path)
    27 
    27 
    28     # the working copy change context
    28     # the working copy change context
    29     ctx = repo.workingctx()
    29     ctx = repo[None]
    30 
    30 
    31     # branch
    31     # branch
    32     branch = util.tolocal(ctx.branch())
    32     branch = encoding.tolocal(ctx.branch())
    33     
    33     
    34     # map default -> None
    34     # map default -> None
    35     if branch == 'default' :
    35     if branch == 'default' :
    36         branch = None
    36         branch = None
    37     
    37     
    53         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.
    54 
    54 
    55         Currently, this assumes that the given path points to a local Mercurial repo.
    55         Currently, this assumes that the given path points to a local Mercurial repo.
    56     """
    56     """
    57     
    57     
    58     # get info
    58     try :
    59     branch, tags, parents, modified = version_mercurial(path)
    59         # get info
       
    60         branch, tags, parents, modified = version_mercurial(path)
       
    61 
       
    62     except :
       
    63         # XXX: ignore
       
    64         raise
    60 
    65 
    61     # tags: <tag> [ "-" <tag> [ ... ]]
    66     # tags: <tag> [ "-" <tag> [ ... ]]
    62     if tags :
    67     if tags :
    63         return '-'.join(tags)
    68         return '-'.join(tags)
    64 
    69