author | Bryan O'Sullivan <bos@serpentine.com> |
Fri, 25 Jan 2008 16:04:46 -0800 | |
changeset 5948 | 597d8402087d |
parent 5943 | ffaf2419de44 |
child 6051 | 1038b1458d7a |
permissions | -rw-r--r-- |
5816 | 1 |
% help |
2 |
keyword extension - keyword expansion in local repositories |
|
3 |
||
4 |
This extension expands RCS/CVS-like or self-customized $Keywords$ |
|
5 |
in tracked text files selected by your configuration. |
|
6 |
||
7 |
Keywords are only expanded in local repositories and not stored in |
|
8 |
the change history. The mechanism can be regarded as a convenience |
|
9 |
for the current user or for archive distribution. |
|
10 |
||
11 |
Configuration is done in the [keyword] and [keywordmaps] sections |
|
12 |
of hgrc files. |
|
13 |
||
14 |
Example: |
|
15 |
||
16 |
[keyword] |
|
17 |
# expand keywords in every python file except those matching "x*" |
|
18 |
**.py = |
|
19 |
x* = ignore |
|
20 |
||
21 |
Note: the more specific you are in your filename patterns |
|
22 |
the less you lose speed in huge repos. |
|
23 |
||
24 |
For [keywordmaps] template mapping and expansion demonstration and |
|
25 |
control run "hg kwdemo". |
|
26 |
||
27 |
An additional date template filter {date|utcdate} is provided. |
|
28 |
||
29 |
The default template mappings (view with "hg kwdemo -d") can be replaced |
|
30 |
with customized keywords and templates. |
|
31 |
Again, run "hg kwdemo" to control the results of your config changes. |
|
32 |
||
33 |
Before changing/disabling active keywords, run "hg kwshrink" to avoid |
|
34 |
the risk of inadvertedly storing expanded keywords in the change history. |
|
35 |
||
36 |
To force expansion after enabling it, or a configuration change, run |
|
37 |
"hg kwexpand". |
|
38 |
||
5884
a139f141dcae
keyword: support mq; handle (q)record more gracefully
Christian Ebert <blacktrash@gmx.net>
parents:
5856
diff
changeset
|
39 |
Also, when committing with the record extension or using mq's qrecord, be aware |
a139f141dcae
keyword: support mq; handle (q)record more gracefully
Christian Ebert <blacktrash@gmx.net>
parents:
5856
diff
changeset
|
40 |
that keywords cannot be updated. Again, run "hg kwexpand" on the files in |
a139f141dcae
keyword: support mq; handle (q)record more gracefully
Christian Ebert <blacktrash@gmx.net>
parents:
5856
diff
changeset
|
41 |
question to update keyword expansions after all changes have been checked in. |
a139f141dcae
keyword: support mq; handle (q)record more gracefully
Christian Ebert <blacktrash@gmx.net>
parents:
5856
diff
changeset
|
42 |
|
5816 | 43 |
Expansions spanning more than one line and incremental expansions, |
44 |
like CVS' $Log$, are not supported. A keyword template map |
|
45 |
"Log = {desc}" expands to the first line of the changeset description. |
|
46 |
||
47 |
list of commands: |
|
48 |
||
49 |
kwdemo print [keywordmaps] configuration and an expansion example |
|
50 |
kwexpand expand keywords in working directory |
|
51 |
kwfiles print files currently configured for keyword expansion |
|
52 |
kwshrink revert expanded keywords in working directory |
|
53 |
||
54 |
use "hg -v help keyword" to show aliases and global options |
|
55 |
% hg kwdemo |
|
56 |
[extensions] |
|
57 |
hgext.keyword = |
|
58 |
[keyword] |
|
59 |
* = |
|
60 |
b = ignore |
|
61 |
demo.txt = |
|
62 |
[keywordmaps] |
|
63 |
RCSFile = {file|basename},v |
|
64 |
Author = {author|user} |
|
65 |
Header = {root}/{file},v {node|short} {date|utcdate} {author|user} |
|
66 |
Source = {root}/{file},v |
|
67 |
Date = {date|utcdate} |
|
68 |
Id = {file|basename},v {node|short} {date|utcdate} {author|user} |
|
69 |
Revision = {node|short} |
|
70 |
$RCSFile: demo.txt,v $ |
|
71 |
$Author: test $ |
|
72 |
$Header: /TMP/demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $ |
|
73 |
$Source: /TMP/demo.txt,v $ |
|
74 |
$Date: 2000/00/00 00:00:00 $ |
|
75 |
$Id: demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $ |
|
76 |
$Revision: xxxxxxxxxxxx $ |
|
77 |
[extensions] |
|
78 |
hgext.keyword = |
|
79 |
[keyword] |
|
80 |
* = |
|
81 |
b = ignore |
|
82 |
demo.txt = |
|
83 |
[keywordmaps] |
|
84 |
Branch = {branches} |
|
85 |
$Branch: demobranch $ |
|
86 |
% kwshrink should exit silently in empty/invalid repo |
|
87 |
% cat |
|
88 |
expand $Id$ |
|
89 |
do not process $Id: |
|
90 |
xxx $ |
|
91 |
expand $Id$ |
|
92 |
do not process $Id: |
|
93 |
xxx $ |
|
94 |
ignore $Id$ |
|
95 |
% addremove |
|
96 |
adding a |
|
97 |
adding b |
|
98 |
adding sym |
|
99 |
% status |
|
100 |
A a |
|
101 |
A b |
|
102 |
A sym |
|
103 |
% default keyword expansion including commit hook |
|
104 |
% interrupted commit should not change state or run commit hook |
|
105 |
a |
|
106 |
b |
|
107 |
sym |
|
108 |
transaction abort! |
|
109 |
rollback completed |
|
5855
a6ccb957fd07
Solaris compatibility fixes for test-keyword:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5816
diff
changeset
|
110 |
abort: empty commit message |
5816 | 111 |
% status |
112 |
A a |
|
113 |
A b |
|
114 |
A sym |
|
115 |
% commit |
|
116 |
a |
|
117 |
b |
|
118 |
sym |
|
119 |
overwriting a expanding keywords |
|
120 |
running hook commit.test: cp a hooktest |
|
121 |
% status |
|
122 |
? hooktest |
|
123 |
% identify |
|
124 |
f782df5f9602 |
|
125 |
% cat |
|
126 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
127 |
do not process $Id: |
|
128 |
xxx $ |
|
129 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
130 |
do not process $Id: |
|
131 |
xxx $ |
|
132 |
ignore $Id$ |
|
133 |
% hg cat |
|
134 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
135 |
do not process $Id: |
|
136 |
xxx $ |
|
137 |
ignore $Id$ |
|
138 |
a |
|
139 |
% diff a hooktest |
|
140 |
% removing commit hook from config |
|
141 |
% touch |
|
142 |
% status |
|
143 |
% update |
|
144 |
3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
145 |
% cat |
|
146 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
147 |
do not process $Id: |
|
148 |
xxx $ |
|
149 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
150 |
do not process $Id: |
|
151 |
xxx $ |
|
152 |
ignore $Id$ |
|
5856
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
153 |
% check whether expansion is filewise |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
154 |
% commit c |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
155 |
adding c |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
156 |
% force expansion |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
157 |
overwriting a expanding keywords |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
158 |
overwriting c expanding keywords |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
159 |
% compare changenodes in a c |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
160 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
161 |
do not process $Id: |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
162 |
xxx $ |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
163 |
$Id: c,v ba4426d1938e 1970/01/01 00:00:01 user $ |
85888efbdfff
keyword: test that expansion is done filewise
Christian Ebert <blacktrash@gmx.net>
parents:
5855
diff
changeset
|
164 |
tests for different changenodes |
5894
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
165 |
% qimport |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
166 |
% keywords should not be expanded in patch |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
167 |
# HG changeset patch |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
168 |
# User User Name <user@example.com> |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
169 |
# Date 1 0 |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
170 |
# Node ID ba4426d1938ec9673e03ab274d88c44e24618f7f |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
171 |
# Parent f782df5f9602483b4e51c31a12315f353bba380c |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
172 |
cndiff |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
173 |
|
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
174 |
diff -r f782df5f9602 -r ba4426d1938e c |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
175 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
176 |
+++ b/c Thu Jan 01 00:00:01 1970 +0000 |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
177 |
@@ -0,0 +1,2 @@ |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
178 |
+$Id$ |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
179 |
+tests for different changenodes |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
180 |
% qpop |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
181 |
Patch queue now empty |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
182 |
% qgoto - should imply qpush |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
183 |
applying mqtest.diff |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
184 |
Now at: mqtest.diff |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
185 |
% cat |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
186 |
$Id: c,v ba4426d1938e 1970/01/01 00:00:01 user $ |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
187 |
tests for different changenodes |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
188 |
% qpop and move on |
e181665c1c79
keyword: add very simple mq test
Christian Ebert <blacktrash@gmx.net>
parents:
5885
diff
changeset
|
189 |
Patch queue now empty |
5816 | 190 |
% copy |
191 |
% kwfiles added |
|
192 |
a |
|
193 |
c |
|
194 |
% commit |
|
195 |
c |
|
196 |
c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292 |
|
197 |
overwriting c expanding keywords |
|
198 |
% cat a c |
|
199 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
200 |
do not process $Id: |
|
201 |
xxx $ |
|
202 |
expand $Id: c,v 0ba462c0f077 1970/01/01 00:00:01 user $ |
|
203 |
do not process $Id: |
|
204 |
xxx $ |
|
205 |
% touch copied c after 1 second |
|
206 |
% status |
|
207 |
% kwfiles |
|
208 |
a |
|
209 |
c |
|
210 |
% diff --rev |
|
211 |
diff -r f782df5f9602 c |
|
212 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
213 |
@@ -0,0 +1,3 @@ |
|
5885
53be157543d4
keyword: avoid extra diffs when not comparing against working dir
Christian Ebert <blacktrash@gmx.net>
parents:
5884
diff
changeset
|
214 |
+expand $Id$ |
5816 | 215 |
+do not process $Id: |
216 |
+xxx $ |
|
217 |
% rollback |
|
218 |
rolling back last transaction |
|
219 |
% status |
|
220 |
A c |
|
221 |
% update -C |
|
222 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
223 |
% custom keyword expansion |
|
224 |
% try with kwdemo |
|
225 |
[extensions] |
|
226 |
hgext.keyword = |
|
227 |
[keyword] |
|
228 |
* = |
|
229 |
b = ignore |
|
230 |
demo.txt = |
|
231 |
[keywordmaps] |
|
232 |
Xinfo = {author}: {desc} |
|
233 |
$Xinfo: test: hg keyword config and expansion example $ |
|
234 |
% cat |
|
235 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
236 |
do not process $Id: |
|
237 |
xxx $ |
|
238 |
expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $ |
|
239 |
do not process $Id: |
|
240 |
xxx $ |
|
241 |
ignore $Id$ |
|
242 |
% hg cat |
|
243 |
expand $Id: a f782df5f9602 Thu, 01 Jan 1970 00:00:00 +0000 user $ |
|
244 |
do not process $Id: |
|
245 |
xxx $ |
|
246 |
ignore $Id$ |
|
247 |
a |
|
248 |
% interrupted commit should not change state |
|
249 |
transaction abort! |
|
250 |
rollback completed |
|
5855
a6ccb957fd07
Solaris compatibility fixes for test-keyword:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5816
diff
changeset
|
251 |
abort: empty commit message |
5816 | 252 |
% status |
253 |
M a |
|
254 |
? log |
|
255 |
% commit |
|
256 |
a |
|
257 |
overwriting a expanding keywords |
|
258 |
% status |
|
259 |
% cat |
|
260 |
expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
261 |
do not process $Id: |
|
262 |
xxx $ |
|
263 |
$Xinfo: User Name <user@example.com>: firstline $ |
|
264 |
expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
265 |
do not process $Id: |
|
266 |
xxx $ |
|
267 |
$Xinfo: User Name <user@example.com>: firstline $ |
|
268 |
ignore $Id$ |
|
269 |
% hg cat |
|
270 |
expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
271 |
do not process $Id: |
|
272 |
xxx $ |
|
273 |
$Xinfo: User Name <user@example.com>: firstline $ |
|
274 |
ignore $Id$ |
|
275 |
a |
|
276 |
% remove |
|
277 |
% status |
|
278 |
% rollback |
|
279 |
rolling back last transaction |
|
280 |
% status |
|
281 |
R a |
|
282 |
% revert a |
|
283 |
% cat a |
|
284 |
expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
285 |
do not process $Id: |
|
286 |
xxx $ |
|
287 |
$Xinfo: User Name <user@example.com>: firstline $ |
|
288 |
% clone to test incoming |
|
289 |
requesting all changes |
|
290 |
adding changesets |
|
291 |
adding manifests |
|
292 |
adding file changes |
|
293 |
added 1 changesets with 3 changes to 3 files |
|
294 |
3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
295 |
% incoming |
|
5943
ffaf2419de44
Ensure that absolutized paths from hgrc do not contain ../ segments.
Jesse Glick <jesse.glick@sun.com>
parents:
5894
diff
changeset
|
296 |
comparing with test-keyword/Test |
5816 | 297 |
searching for changes |
298 |
changeset: 1:0729690beff6 |
|
299 |
tag: tip |
|
300 |
user: User Name <user@example.com> |
|
301 |
date: Thu Jan 01 00:00:02 1970 +0000 |
|
302 |
summary: firstline |
|
303 |
||
304 |
% commit rejecttest |
|
305 |
a |
|
306 |
overwriting a expanding keywords |
|
307 |
% export |
|
308 |
% import |
|
309 |
applying ../rejecttest.diff |
|
310 |
% cat |
|
311 |
expand $Id: a 82983f13f138 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest |
|
312 |
do not process $Id: rejecttest |
|
313 |
xxx $ |
|
314 |
$Xinfo: User Name <user@example.com>: rejects? $ |
|
315 |
expand $Id: a 82983f13f138 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest |
|
316 |
do not process $Id: rejecttest |
|
317 |
xxx $ |
|
318 |
$Xinfo: User Name <user@example.com>: rejects? $ |
|
319 |
ignore $Id$ |
|
320 |
||
321 |
% rollback |
|
322 |
rolling back last transaction |
|
323 |
% clean update |
|
324 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
325 |
% kwexpand/kwshrink on selected files |
|
326 |
% copy a x/a |
|
327 |
% kwexpand a |
|
328 |
overwriting a expanding keywords |
|
329 |
% kwexpand x/a should abort |
|
330 |
abort: outstanding uncommitted changes in given files |
|
331 |
x/a |
|
332 |
x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e |
|
333 |
overwriting x/a expanding keywords |
|
334 |
% cat a |
|
335 |
expand $Id: x/a f27c134d2d9b Thu, 01 Jan 1970 00:00:03 +0000 user $ |
|
336 |
do not process $Id: |
|
337 |
xxx $ |
|
338 |
$Xinfo: User Name <user@example.com>: xa $ |
|
339 |
% kwshrink a inside directory x |
|
340 |
overwriting x/a shrinking keywords |
|
341 |
% cat a |
|
342 |
expand $Id$ |
|
343 |
do not process $Id: |
|
344 |
xxx $ |
|
345 |
$Xinfo$ |
|
346 |
% kwexpand nonexistent |
|
347 |
nonexistent: No such file or directory |
|
348 |
% switch off expansion |
|
349 |
% kwshrink with unknown file u |
|
350 |
overwriting a shrinking keywords |
|
351 |
overwriting x/a shrinking keywords |
|
352 |
% cat |
|
353 |
expand $Id$ |
|
354 |
do not process $Id: |
|
355 |
xxx $ |
|
356 |
$Xinfo$ |
|
357 |
expand $Id$ |
|
358 |
do not process $Id: |
|
359 |
xxx $ |
|
360 |
$Xinfo$ |
|
361 |
ignore $Id$ |
|
362 |
% hg cat |
|
363 |
expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $ |
|
364 |
do not process $Id: |
|
365 |
xxx $ |
|
366 |
$Xinfo: User Name <user@example.com>: firstline $ |
|
367 |
ignore $Id$ |
|
368 |
a |
|
369 |
% cat |
|
370 |
expand $Id$ |
|
371 |
do not process $Id: |
|
372 |
xxx $ |
|
373 |
$Xinfo$ |
|
374 |
expand $Id$ |
|
375 |
do not process $Id: |
|
376 |
xxx $ |
|
377 |
$Xinfo$ |
|
378 |
ignore $Id$ |
|
379 |
% hg cat |
|
380 |
expand $Id$ |
|
381 |
do not process $Id: |
|
382 |
xxx $ |
|
383 |
$Xinfo$ |
|
384 |
ignore $Id$ |
|
385 |
a |