hgkw/keyword.py
branchkwmap-templates
changeset 146 df9de07ce002
parent 145 1c2cefa97b96
child 147 11a031a33ea2
equal deleted inserted replaced
145:1c2cefa97b96 146:df9de07ce002
    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:
       
    27 #     Revision: changeset id
       
    28 #     Author:   username
       
    29 #     Date:     %Y/%m/%d %H:%M:%S [UTC]
       
    30 #     RCSFile:  basename,v
       
    31 #     Source:   /path/to/basename,v
       
    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
       
    34 #
       
    35 # Expansions spanning more than one line are truncated to their first line.
    26 # Expansions spanning more than one line are truncated to their first line.
    36 # Incremental expansion (like CVS' $Log$) is not supported.
    27 # Incremental expansion (like CVS' $Log$) is not supported.
    37 #
    28 #
    38 # Simple setup in hgrc:
    29 # Setup in hgrc:
    39 #
    30 #
    40 #     # enable extension
    31 #     # enable extension
    41 #     keyword = /full/path/to/keyword.py
    32 #     keyword = /full/path/to/keyword.py
    42 #     # or, if script in hgext folder:
    33 #     # or, if script in hgext folder:
    43 #     # hgext.keyword =
    34 #     # hgext.keyword =
    44 #
       
    45 #     # filename patterns for expansion are configured in this section
       
    46 #     # files matching patterns with value 'ignore' are ignored
       
    47 #     [keyword]
       
    48 #     **.py =
       
    49 #     x* = ignore
       
    50 #     ...
       
    51 #     # in case you prefer your own keyword maps over the cvs-like defaults:
       
    52 #     [keywordmaps]
       
    53 #     HGdate = {date|rfc822date}
       
    54 #     lastlog = {desc} ## same as {desc|firstline} in this context
       
    55 #     checked in by = {author}
       
    56 #     ...
       
    57 
    35 
    58 '''keyword expansion in local repositories
    36 '''keyword expansion in local repositories
    59 
    37 
    60 This extension expands RCS/CVS-like or self-customized keywords in
    38 This extension expands RCS/CVS-like or self-customized keywords in
    61 the text files selected by your configuration.
    39 the text files selected by your configuration.
    67 Substitution takes place on every commit and update of the working
    45 Substitution takes place on every commit and update of the working
    68 repository.
    46 repository.
    69 
    47 
    70 Configuration is done in the [keyword] and [keywordmaps] sections of
    48 Configuration is done in the [keyword] and [keywordmaps] sections of
    71 hgrc files.
    49 hgrc files.
       
    50 
       
    51 Example:
       
    52      # filename patterns for expansion are configured in this section
       
    53      # files matching patterns with value 'ignore' are ignored
       
    54      [keyword]
       
    55      **.py =
       
    56      x* = ignore
       
    57      ...
       
    58      # in case you prefer your own keyword maps over the cvs-like defaults:
       
    59      [keywordmaps]
       
    60      HGdate = {date|rfc822date}
       
    61      lastlog = {desc} ## same as {desc|firstline} in this context
       
    62      checked in by = {author}
       
    63      ...
       
    64 
       
    65 If you do not have any [keywordmaps] configured the extension falls back on
       
    66 the following defaults:
       
    67 
       
    68      Revision: changeset id
       
    69      Author: username
       
    70      Date: %Y/%m/%d %H:%M:%S [UTC]
       
    71      RCSFile: basename,v
       
    72      Source: /path/to/basename,v
       
    73      Id: basename,v csetid %Y/%m/%d %H:%M:%S username
       
    74      Header: /path/to/basename,v csetid %Y/%m/%d %H:%M:%S username
    72 '''
    75 '''
    73 
    76 
    74 try:
    77 try:
    75     from mercurial.demandload import * # stable
    78     from mercurial.demandload import * # stable
    76     from mercurial.i18n import gettext as _
    79     from mercurial.i18n import gettext as _
    77     demandload(globals(), 'mercurial:cmdutil,templater,util')
    80     demandload(globals(), 'mercurial:cmdutil,templater,util')
    78     demandload(globals(), 'mercurial:context,filelog,revlog')
    81     demandload(globals(), 'mercurial:context,filelog,revlog')
    79     demandload(globals(), 're time')
    82     demandload(globals(), 're time')
    80 except ImportError: # demandimport
    83 except ImportError:                    # demandimport
    81     from mercurial.i18n import _
    84     from mercurial.i18n import _
    82     from mercurial import cmdutil, templater, util
    85     from mercurial import cmdutil, templater, util
    83     from mercurial import context, filelog, revlog
    86     from mercurial import context, filelog, revlog
    84     import re, time
    87     import re, time
    85 
    88