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