|
1 % help |
|
2 keyword extension - keyword expansion in local repositories |
|
3 |
|
4 This extension expands RCS/CVS-like or self-customized $Keywords$ |
|
5 in the text files selected by your configuration. |
|
6 |
|
7 Keywords are only expanded in local repositories and not logged by |
|
8 Mercurial internally. The mechanism can be regarded as a convenience |
|
9 for the current user or archive distribution. |
|
10 |
|
11 Configuration is done in the [keyword] and [keywordmaps] sections of |
|
12 hgrc files. |
|
13 |
|
14 Example: |
|
15 [extensions] |
|
16 hgext.keyword = |
|
17 |
|
18 [keyword] |
|
19 # expand keywords in every python file except those matching "x*" |
|
20 **.py = |
|
21 x* = ignore |
|
22 |
|
23 Note: the more specific you are in your [keyword] filename patterns |
|
24 the less you lose speed in huge repos. |
|
25 |
|
26 For a [keywordmaps] template mapping and expansion demonstration |
|
27 run "hg kwdemo". |
|
28 |
|
29 An additional date template filter {date|utcdate} is provided. |
|
30 |
|
31 You can replace the default template mappings with customized keywords |
|
32 and templates of your choice. |
|
33 Again, run "hg kwdemo" to control the results of your config changes. |
|
34 |
|
35 When you change keyword configuration, especially the active keywords, |
|
36 and do not want to store expanded keywords in change history, run |
|
37 "hg kwshrink", and then change configuration. |
|
38 |
|
39 Caveat: "hg import" fails if the patch context contains an active |
|
40 keyword. In that case run "hg kwshrink", reimport, and then |
|
41 "hg kwexpand". |
|
42 Or, better, use bundle/unbundle to share changes. |
|
43 |
|
44 list of commands (use "hg help -v keyword" to show aliases and global options): |
|
45 |
|
46 kwdemo print [keywordmaps] configuration and an expansion example |
|
47 kwexpand expand keywords in working directory |
|
48 kwshrink revert expanded keywords in working directory |
|
49 % hg kwdemo |
|
50 [keyword] |
|
51 demo.txt = |
|
52 [keywordmaps] |
|
53 RCSFile = {file|basename},v |
|
54 Author = {author|user} |
|
55 Header = {root}/{file},v {node|short} {date|utcdate} {author|user} |
|
56 Source = {root}/{file},v |
|
57 Date = {date|utcdate} |
|
58 Id = {file|basename},v {node|short} {date|utcdate} {author|user} |
|
59 Revision = {node|short} |
|
60 $RCSFile: demo.txt,v $ |
|
61 $Author: test $ |
|
62 $Header: /TMP/demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $ |
|
63 $Source: /TMP/demo.txt,v $ |
|
64 $Date: 2000/00/00 00:00:00 $ |
|
65 $Id: demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $ |
|
66 $Revision: xxxxxxxxxxxx $ |
|
67 % kwshrink should abort in empty/invalid repo |
|
68 abort: no changeset found! |
|
69 % cat |
|
70 expand $Id$ |
|
71 ignore $Id$ |
|
72 % default keyword expansion |
|
73 % commit |
|
74 adding a |
|
75 adding b |
|
76 a |
|
77 b |
|
78 overwriting a expanding keywords |
|
79 % status |
|
80 % identify |
|
81 65cbcc9534b0 |
|
82 % cat |
|
83 expand $Id: a,v 65cbcc9534b0 1970/01/01 00:00:00 user $ |
|
84 ignore $Id$ |
|
85 % hg cat |
|
86 expand $Id: a,v 65cbcc9534b0 1970/01/01 00:00:00 user $ |
|
87 ignore $Id$ |
|
88 % touch |
|
89 % status |
|
90 % update |
|
91 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
92 % cat |
|
93 expand $Id: a,v 65cbcc9534b0 1970/01/01 00:00:00 user $ |
|
94 ignore $Id$ |
|
95 % copy |
|
96 % commit |
|
97 c |
|
98 c: copy a:e6cc15c9eb5fd3c09ec691b667cf6ccd6dfb936e |
|
99 overwriting c expanding keywords |
|
100 % cat a c |
|
101 expand $Id: a,v 65cbcc9534b0 1970/01/01 00:00:00 user $ |
|
102 expand $Id: c,v 9460ba56f8d0 1970/01/01 00:00:01 user $ |
|
103 % touch copied c |
|
104 % status |
|
105 % rollback |
|
106 rolling back last transaction |
|
107 % status |
|
108 A c |
|
109 % update -C |
|
110 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
111 % custom keyword expansion |
|
112 % try with kwdemo |
|
113 [keyword] |
|
114 demo.txt = |
|
115 [keywordmaps] |
|
116 Xinfo = {author}: {desc} |
|
117 $Xinfo: test: hg keyword config and expansion example $ |
|
118 % cat |
|
119 expand $Id: a,v 65cbcc9534b0 1970/01/01 00:00:00 user $ |
|
120 ignore $Id$ |
|
121 % hg cat |
|
122 expand $Id: a 65cbcc9534b0 Thu, 01 Jan 1970 00:00:00 +0000 user $ |
|
123 ignore $Id$ |
|
124 % interrupted commit |
|
125 abort: edit failed: false exited with status 1 |
|
126 transaction abort! |
|
127 rollback completed |
|
128 % status |
|
129 M a |
|
130 ? log |
|
131 % commit |
|
132 a |
|
133 overwriting a expanding keywords |
|
134 % status |
|
135 % cat |
|
136 expand $Id: a 6ade9dd7b017 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
137 $Xinfo: User Name <user@example.com>: firstline $ |
|
138 ignore $Id$ |
|
139 % hg cat |
|
140 expand $Id: a 6ade9dd7b017 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
141 $Xinfo: User Name <user@example.com>: firstline $ |
|
142 ignore $Id$ |
|
143 requesting all changes |
|
144 adding changesets |
|
145 adding manifests |
|
146 adding file changes |
|
147 added 1 changesets with 2 changes to 2 files |
|
148 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
149 % incoming |
|
150 searching for changes |
|
151 changeset: 1:6ade9dd7b017 |
|
152 tag: tip |
|
153 user: User Name <user@example.com> |
|
154 date: Thu Jan 01 00:00:02 1970 +0000 |
|
155 summary: firstline |
|
156 |
|
157 % switch off expansion |
|
158 % kwshrink |
|
159 overwriting a shrinking keywords |
|
160 % cat |
|
161 expand $Id$ |
|
162 $Xinfo$ |
|
163 ignore $Id$ |
|
164 % hg cat |
|
165 expand $Id: a 6ade9dd7b017 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
166 $Xinfo: User Name <user@example.com>: firstline $ |
|
167 ignore $Id$ |
|
168 % cat |
|
169 expand $Id$ |
|
170 $Xinfo$ |
|
171 ignore $Id$ |
|
172 % hg cat |
|
173 expand $Id$ |
|
174 $Xinfo$ |
|
175 ignore $Id$ |