hgkw/keyword.py
branchstable
changeset 606 7f928c9d56d0
parent 604 75621fa839fb
child 609 fefdf82b2320
equal deleted inserted replaced
605:894fa61f2e0b 606:7f928c9d56d0
    26 #
    26 #
    27 # Run "hg help keyword" and "hg kwdemo" to get info on configuration.
    27 # Run "hg help keyword" and "hg kwdemo" to get info on configuration.
    28 
    28 
    29 '''expand keywords in tracked files
    29 '''expand keywords in tracked files
    30 
    30 
    31 This extension expands RCS/CVS-like or self-customized $Keywords$ in
    31 This extension expands RCS/CVS-like or self-customized $Keywords$ in tracked
    32 tracked text files selected by your configuration.
    32 text files selected by your configuration.
    33 
    33 
    34 Keywords are only expanded in local repositories and not stored in the
    34 Keywords are only expanded in local repositories and not stored in the change
    35 change history. The mechanism can be regarded as a convenience for the
    35 history. The mechanism can be regarded as a convenience for the current user
    36 current user or for archive distribution.
    36 or for archive distribution.
    37 
    37 
    38 Configuration is done in the [keyword] and [keywordmaps] sections of
    38 Configuration is done in the [keyword] and [keywordmaps] sections of hgrc
    39 hgrc files.
    39 files.
    40 
    40 
    41 Example:
    41 Example:
    42 
    42 
    43     [keyword]
    43     [keyword]
    44     # expand keywords in every python file except those matching "x*"
    44     # expand keywords in every python file except those matching "x*"
    45     **.py =
    45     **.py =
    46     x*    = ignore
    46     x*    = ignore
    47 
    47 
    48 Note: the more specific you are in your filename patterns
    48 Note: the more specific you are in your filename patterns the less you lose
    49       the less you lose speed in huge repositories.
    49       speed in huge repositories.
    50 
    50 
    51 For [keywordmaps] template mapping and expansion demonstration and
    51 For [keywordmaps] template mapping and expansion demonstration and control run
    52 control run "hg kwdemo".
    52 "hg kwdemo".
    53 
    53 
    54 An additional date template filter {date|utcdate} is provided.
    54 An additional date template filter {date|utcdate} is provided.
    55 
    55 
    56 The default template mappings (view with "hg kwdemo -d") can be
    56 The default template mappings (view with "hg kwdemo -d") can be replaced with
    57 replaced with customized keywords and templates. Again, run "hg
    57 customized keywords and templates. Again, run "hg kwdemo" to control the
    58 kwdemo" to control the results of your config changes.
    58 results of your config changes.
    59 
    59 
    60 Before changing/disabling active keywords, run "hg kwshrink" to avoid
    60 Before changing/disabling active keywords, run "hg kwshrink" to avoid the risk
    61 the risk of inadvertently storing expanded keywords in the change
    61 of inadvertently storing expanded keywords in the change history.
    62 history.
    62 
    63 
    63 To force expansion after enabling it, or a configuration change, run "hg
    64 To force expansion after enabling it, or a configuration change, run
    64 kwexpand".
    65 "hg kwexpand".
    65 
    66 
    66 Also, when committing with the record extension or using mq's qrecord, be
    67 Also, when committing with the record extension or using mq's qrecord,
    67 aware that keywords cannot be updated. Again, run "hg kwexpand" on the files
    68 be aware that keywords cannot be updated. Again, run "hg kwexpand" on
    68 in question to update keyword expansions after all changes have been checked
    69 the files in question to update keyword expansions after all changes
    69 in.
    70 have been checked in.
    70 
    71 
    71 Expansions spanning more than one line and incremental expansions, like CVS'
    72 Expansions spanning more than one line and incremental expansions,
    72 $Log$, are not supported. A keyword template map "Log = {desc}" expands to the
    73 like CVS' $Log$, are not supported. A keyword template map
    73 first line of the changeset description.
    74 "Log = {desc}" expands to the first line of the changeset description.
       
    75 '''
    74 '''
    76 
    75 
    77 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
    76 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
    78 from mercurial import patch, localrepo, templater, templatefilters, util, match
    77 from mercurial import patch, localrepo, templater, templatefilters, util, match
    79 from mercurial.hgweb import webcommands
    78 from mercurial.hgweb import webcommands
   360     _kwfwrite(ui, repo, True, *pats, **opts)
   359     _kwfwrite(ui, repo, True, *pats, **opts)
   361 
   360 
   362 def files(ui, repo, *pats, **opts):
   361 def files(ui, repo, *pats, **opts):
   363     '''show files configured for keyword expansion
   362     '''show files configured for keyword expansion
   364 
   363 
   365     List which files in the working directory are matched by the
   364     List which files in the working directory are matched by the [keyword]
   366     [keyword] configuration patterns.
   365     configuration patterns.
   367 
   366 
   368     Useful to prevent inadvertent keyword expansion and to speed up
   367     Useful to prevent inadvertent keyword expansion and to speed up execution
   369     execution by including only files that are actual candidates
   368     by including only files that are actual candidates for expansion.
   370     for expansion.
   369 
   371 
   370     See "hg help keyword" on how to construct patterns both for inclusion and
   372     See "hg help keyword" on how to construct patterns both for
   371     exclusion of files.
   373     inclusion and exclusion of files.
       
   374 
   372 
   375     Use -u/--untracked to list untracked files as well.
   373     Use -u/--untracked to list untracked files as well.
   376 
   374 
   377     With -a/--all and -v/--verbose the codes used to show the status
   375     With -a/--all and -v/--verbose the codes used to show the status of files
   378     of files are:
   376     are:
   379     K = keyword expansion candidate
   377     K = keyword expansion candidate
   380     k = keyword expansion candidate (untracked)
   378     k = keyword expansion candidate (untracked)
   381     I = ignored
   379     I = ignored
   382     i = ignored (untracked)
   380     i = ignored (untracked)
   383     '''
   381     '''