34 # |
34 # |
35 # Run "hg help keyword" and "hg kwdemo" to get info on configuration. |
35 # Run "hg help keyword" and "hg kwdemo" to get info on configuration. |
36 |
36 |
37 '''expand keywords in tracked files |
37 '''expand keywords in tracked files |
38 |
38 |
39 This extension expands RCS/CVS-like or self-customized $Keywords$ in |
39 This extension expands RCS/CVS-like or self-customized $Keywords$ in tracked |
40 tracked text files selected by your configuration. |
40 text files selected by your configuration. |
41 |
41 |
42 Keywords are only expanded in local repositories and not stored in the |
42 Keywords are only expanded in local repositories and not stored in the change |
43 change history. The mechanism can be regarded as a convenience for the |
43 history. The mechanism can be regarded as a convenience for the current user |
44 current user or for archive distribution. |
44 or for archive distribution. |
45 |
45 |
46 Configuration is done in the [keyword] and [keywordmaps] sections of |
46 Configuration is done in the [keyword] and [keywordmaps] sections of hgrc |
47 hgrc files. |
47 files. |
48 |
48 |
49 Example: |
49 Example: |
50 |
50 |
51 [keyword] |
51 [keyword] |
52 # expand keywords in every python file except those matching "x*" |
52 # expand keywords in every python file except those matching "x*" |
53 **.py = |
53 **.py = |
54 x* = ignore |
54 x* = ignore |
55 |
55 |
56 Note: the more specific you are in your filename patterns |
56 Note: the more specific you are in your filename patterns the less you lose |
57 the less you lose speed in huge repositories. |
57 speed in huge repositories. |
58 |
58 |
59 For [keywordmaps] template mapping and expansion demonstration and |
59 For [keywordmaps] template mapping and expansion demonstration and control run |
60 control run "hg kwdemo". |
60 "hg kwdemo". |
61 |
61 |
62 An additional date template filter {date|utcdate} is provided. |
62 An additional date template filter {date|utcdate} is provided. |
63 |
63 |
64 The default template mappings (view with "hg kwdemo -d") can be |
64 The default template mappings (view with "hg kwdemo -d") can be replaced with |
65 replaced with customized keywords and templates. Again, run "hg |
65 customized keywords and templates. Again, run "hg kwdemo" to control the |
66 kwdemo" to control the results of your config changes. |
66 results of your config changes. |
67 |
67 |
68 Before changing/disabling active keywords, run "hg kwshrink" to avoid |
68 Before changing/disabling active keywords, run "hg kwshrink" to avoid the risk |
69 the risk of inadvertently storing expanded keywords in the change |
69 of inadvertently storing expanded keywords in the change history. |
70 history. |
70 |
71 |
71 To force expansion after enabling it, or a configuration change, run "hg |
72 To force expansion after enabling it, or a configuration change, run |
72 kwexpand". |
73 "hg kwexpand". |
73 |
74 |
74 Also, when committing with the record extension or using mq's qrecord, be |
75 Also, when committing with the record extension or using mq's qrecord, |
75 aware that keywords cannot be updated. Again, run "hg kwexpand" on the files |
76 be aware that keywords cannot be updated. Again, run "hg kwexpand" on |
76 in question to update keyword expansions after all changes have been checked |
77 the files in question to update keyword expansions after all changes |
77 in. |
78 have been checked in. |
78 |
79 |
79 Expansions spanning more than one line and incremental expansions, like CVS' |
80 Expansions spanning more than one line and incremental expansions, |
80 $Log$, are not supported. A keyword template map "Log = {desc}" expands to the |
81 like CVS' $Log$, are not supported. A keyword template map |
81 first line of the changeset description. |
82 "Log = {desc}" expands to the first line of the changeset description. |
|
83 |
82 |
84 Caveat: With Mercurial versions prior to 4574925db5c0 "hg import" might |
83 Caveat: With Mercurial versions prior to 4574925db5c0 "hg import" might |
85 cause rejects if the patch context contains an active keyword. |
84 cause rejects if the patch context contains an active keyword. In that |
86 In that case run "hg kwshrink", and then reimport. |
85 case run "hg kwshrink", and then reimport. Or, better, use |
87 Or, better, use bundle/unbundle to share changes. |
86 bundle/unbundle to share changes. |
88 ''' |
87 ''' |
89 |
88 |
90 from mercurial import commands, cmdutil, fancyopts, filelog |
89 from mercurial import commands, cmdutil, fancyopts, filelog |
91 from mercurial import localrepo, patch, revlog, templater, util |
90 from mercurial import localrepo, patch, revlog, templater, util |
92 from mercurial.node import nullid, hex |
91 from mercurial.node import nullid, hex |