hgkw/keyword.py
branchkwmap-templates
changeset 128 fe37939db543
parent 126 47b45198a30d
child 129 15e8cd7f5295
equal deleted inserted replaced
127:f88ecc1a41fa 128:fe37939db543
     4 #
     4 #
     5 # This software may be used and distributed according to the terms
     5 # This software may be used and distributed according to the terms
     6 # of the GNU General Public License, incorporated herein by reference.
     6 # of the GNU General Public License, incorporated herein by reference.
     7 #
     7 #
     8 # $Id$
     8 # $Id$
     9 # 
     9 #
    10 # Keyword expansion hack against the grain of a DSCM
    10 # Keyword expansion hack against the grain of a DSCM
    11 # 
    11 #
    12 # There are many good reasons why this is not needed in a distributed
    12 # There are many good reasons why this is not needed in a distributed
    13 # SCM, still it may be useful in very small projects based on single
    13 # SCM, still it may be useful in very small projects based on single
    14 # files (like LaTeX packages), that are mostly addressed to an audience
    14 # files (like LaTeX packages), that are mostly addressed to an audience
    15 # not running a version control system.
    15 # not running a version control system.
    16 # 
    16 #
    17 # For in-depth discussion refer to
    17 # For in-depth discussion refer to
    18 # <http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan>.
    18 # <http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan>.
    19 #
    19 #
    20 # Keyword expansion is based on Mercurial's changeset template mappings.
    20 # Keyword expansion is based on Mercurial's changeset template mappings.
    21 # The extension provides an additional UTC-date filter ({date|utcdate}).
    21 # The extension provides an additional UTC-date filter ({date|utcdate}).
    22 #
    22 #
    23 # The user has the choice either to create his own keywords and their
    23 # The user has the choice either to create his own keywords and their
    24 # expansions or to use the CVS-like default ones.
    24 # expansions or to use the CVS-like default ones.
    25 # 
    25 #
    26 # Default $keywords$ and their $keyword: substition $ are:
    26 # Default $keywords$ and their $keyword: substition $ are:
    27 #     Revision: changeset id
    27 #     Revision: changeset id
    28 #     Author:   username
    28 #     Author:   username
    29 #     Date:     %Y/%m/%d %H:%M:%S [UTC]
    29 #     Date:     %Y/%m/%d %H:%M:%S [UTC]
    30 #     RCSFile:  basename,v
    30 #     RCSFile:  basename,v
    31 #     Source:   /path/to/basename,v
    31 #     Source:   /path/to/basename,v
    32 #     Id:       basename,v csetid %Y/%m/%d %H:%M:%S username
    32 #     Id:       basename,v csetid %Y/%m/%d %H:%M:%S username
    33 #     Header:   /path/to/basename,v csetid %Y/%m/%d %H:%M:%S username
    33 #     Header:   /path/to/basename,v csetid %Y/%m/%d %H:%M:%S username
    34 # 
    34 #
    35 # Expansions spanning more than one line are truncated to their first line.
    35 # Expansions spanning more than one line are truncated to their first line.
    36 # Incremental expansion (like CVS' $Log$) is not supported.
    36 # Incremental expansion (like CVS' $Log$) is not supported.
    37 # 
    37 #
    38 # Simple setup in hgrc:
    38 # Simple setup in hgrc:
    39 # 
    39 #
    40 #     # enable extension
    40 #     # enable extension
    41 #     keyword = /full/path/to/keyword.py
    41 #     keyword = /full/path/to/keyword.py
    42 #     # or, if script in hgext folder:
    42 #     # or, if script in hgext folder:
    43 #     # hgext.keyword =
    43 #     # hgext.keyword =
    44 #     
    44 #
    45 #     # filename patterns for expansion are configured in this section
    45 #     # filename patterns for expansion are configured in this section
    46 #     # files matching patterns with value 'ignore' are ignored
    46 #     # files matching patterns with value 'ignore' are ignored
    47 #     [keyword]
    47 #     [keyword]
    48 #     **.py =
    48 #     **.py =
    49 #     x* = ignore
    49 #     x* = ignore
    61 the text files selected by your configuration.
    61 the text files selected by your configuration.
    62 
    62 
    63 Keywords are only expanded in local repositories and not logged by
    63 Keywords are only expanded in local repositories and not logged by
    64 Mercurial internally. The mechanism can be regarded as a convenience
    64 Mercurial internally. The mechanism can be regarded as a convenience
    65 for the current user and may be turned off anytime.
    65 for the current user and may be turned off anytime.
    66  
    66 
    67 Substitution takes place on every commit and update of the working
    67 Substitution takes place on every commit and update of the working
    68 repository.
    68 repository.
    69 
    69 
    70 Configuration is done in the [keyword] and [keywordmaps] sections of
    70 Configuration is done in the [keyword] and [keywordmaps] sections of
    71 hgrc files.
    71 hgrc files.
    72 '''
    72 '''
    73  
    73 
    74 from mercurial.i18n import gettext as _
    74 from mercurial.i18n import gettext as _
    75 # above line for backwards compatibility of standalone version
    75 # above line for backwards compatibility of standalone version
    76 from mercurial import commands, cmdutil, templater, util
    76 from mercurial import commands, cmdutil, templater, util
    77 from mercurial import context, filelog, revlog
    77 from mercurial import context, filelog, revlog
    78 from mercurial.node import bin
    78 from mercurial.node import bin