##// END OF EJS Templates
keyword: add test
Christian Ebert -
r5816:3bd22fd3 default
parent child Browse files
Show More
@@ -0,0 +1,229 b''
1 #!/bin/sh
2
3 cat <<EOF >> $HGRCPATH
4 [extensions]
5 hgext.keyword =
6 [keyword]
7 * =
8 b = ignore
9 [hooks]
10 commit=
11 commit.test=cp a hooktest
12 EOF
13
14 echo % help
15 hg help keyword
16
17 echo % hg kwdemo
18 hg --quiet kwdemo --default \
19 | sed -e 's![^ ][^ ]*demo.txt,v!/TMP/demo.txt,v!' \
20 -e 's/,v [a-z0-9][a-z0-9]* /,v xxxxxxxxxxxx /' \
21 -e '/[$]Revision/ s/: [a-z0-9][a-z0-9]* /: xxxxxxxxxxxx /' \
22 -e 's! 20[0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]! 2000/00/00 00:00:00!'
23
24 hg --quiet kwdemo "Branch = {branches}"
25
26 hg init Test
27 cd Test
28
29 echo % kwshrink should exit silently in empty/invalid repo
30 hg kwshrink
31
32 echo 'expand $Id$' > a
33 echo 'do not process $Id:' >> a
34 echo 'xxx $' >> a
35 echo 'ignore $Id$' > b
36 ln -s a sym
37 echo % cat
38 cat sym a b
39
40 echo % addremove
41 hg addremove
42 echo % status
43 hg status
44
45 echo % default keyword expansion including commit hook
46 echo % interrupted commit should not change state or run commit hook
47 HGEDITOR=false hg --debug commit
48 echo % status
49 hg status
50
51 echo % commit
52 hg --debug commit -mabsym -d '0 0' -u 'User Name <user@example.com>'
53 echo % status
54 hg status
55 echo % identify
56 hg --quiet identify
57 echo % cat
58 cat sym a b
59 echo % hg cat
60 hg cat sym a b
61
62 echo
63 echo % diff a hooktest
64 diff a hooktest
65
66 echo % removing commit hook from config
67 sed -e '/\[hooks\]/,$ d' $HGRCPATH > $HGRCPATH.nohook
68 mv $HGRCPATH.nohook $HGRCPATH
69 rm hooktest
70
71 echo % touch
72 touch a b
73 echo % status
74 hg status
75
76 rm sym a b
77 echo % update
78 hg update
79 echo % cat
80 cat sym a b
81
82 echo % copy
83 hg cp a c
84
85 echo % kwfiles added
86 hg kwfiles
87
88 echo % commit
89 hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
90 echo % cat a c
91 cat a c
92 echo % touch copied c after 1 second
93 sleep 1
94 touch c
95 echo % status
96 hg status
97
98 echo % kwfiles
99 hg kwfiles
100
101 echo % diff --rev
102 hg diff --rev 0 | grep -v 'b/c'
103
104 echo % rollback
105 hg rollback
106 echo % status
107 hg status
108 echo % update -C
109 hg update --clean
110
111 echo % custom keyword expansion
112 echo % try with kwdemo
113 hg --quiet kwdemo "Xinfo = {author}: {desc}"
114
115 cat <<EOF >>$HGRCPATH
116 [keywordmaps]
117 Id = {file} {node|short} {date|rfc822date} {author|user}
118 Xinfo = {author}: {desc}
119 EOF
120
121 echo % cat
122 cat sym a b
123 echo % hg cat
124 hg cat sym a b
125
126 echo
127 echo '$Xinfo$' >> a
128 cat <<EOF >> log
129 firstline
130 secondline
131 EOF
132
133 echo % interrupted commit should not change state
134 HGEDITOR=false hg commit
135 echo % status
136 hg status
137
138 echo % commit
139 hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
140 rm log
141 echo % status
142 hg status
143
144 echo % cat
145 cat sym a b
146 echo % hg cat
147 hg cat sym a b
148 echo
149
150 echo % remove
151 hg remove a
152 hg --debug commit -m rma
153 echo % status
154 hg status
155 echo % rollback
156 hg rollback
157 echo % status
158 hg status
159 echo % revert a
160 hg revert --no-backup --rev tip a
161 echo % cat a
162 cat a
163
164 echo % clone to test incoming
165 cd ..
166 hg clone -r0 Test Test-a
167 cd Test-a
168 cat <<EOF >> .hg/hgrc
169 [paths]
170 default = ../Test
171 EOF
172 echo % incoming
173 # remove path to temp dir
174 hg incoming | sed -e 's/^\(comparing with \).*\(test-keyword.*\)/\1\2/'
175
176 sed -i.bak -e 's/Id.*/& rejecttest/' a
177 rm a.bak
178 echo % commit rejecttest
179 hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
180 echo % export
181 hg export -o ../rejecttest.diff tip
182
183 cd ../Test
184 echo % import
185 hg import ../rejecttest.diff
186 echo % cat
187 cat sym a b
188 echo
189 echo % rollback
190 hg rollback
191 echo % clean update
192 hg update --clean
193
194 echo % kwexpand/kwshrink on selected files
195 mkdir x
196 echo % copy a x/a
197 hg copy a x/a
198 echo % kwexpand a
199 hg --verbose kwexpand a
200 echo % kwexpand x/a should abort
201 hg --verbose kwexpand x/a
202 cd x
203 hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
204 echo % cat a
205 cat a
206 echo % kwshrink a inside directory x
207 hg --verbose kwshrink a
208 echo % cat a
209 cat a
210 cd - > /dev/null 2>&1
211
212 echo % kwexpand nonexistent
213 hg kwexpand nonexistent
214
215 echo % switch off expansion
216 echo % kwshrink with unknown file u
217 cp a u
218 hg --verbose kwshrink
219 echo % cat
220 cat sym a b
221 echo % hg cat
222 hg cat sym a b
223 echo
224 rm $HGRCPATH
225 echo % cat
226 cat sym a b
227 echo % hg cat
228 hg cat sym a b
229 echo
@@ -0,0 +1,344 b''
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
39 Expansions spanning more than one line and incremental expansions,
40 like CVS' $Log$, are not supported. A keyword template map
41 "Log = {desc}" expands to the first line of the changeset description.
42
43 list of commands:
44
45 kwdemo print [keywordmaps] configuration and an expansion example
46 kwexpand expand keywords in working directory
47 kwfiles print files currently configured for keyword expansion
48 kwshrink revert expanded keywords in working directory
49
50 use "hg -v help keyword" to show aliases and global options
51 % hg kwdemo
52 [extensions]
53 hgext.keyword =
54 [keyword]
55 * =
56 b = ignore
57 demo.txt =
58 [keywordmaps]
59 RCSFile = {file|basename},v
60 Author = {author|user}
61 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
62 Source = {root}/{file},v
63 Date = {date|utcdate}
64 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
65 Revision = {node|short}
66 $RCSFile: demo.txt,v $
67 $Author: test $
68 $Header: /TMP/demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
69 $Source: /TMP/demo.txt,v $
70 $Date: 2000/00/00 00:00:00 $
71 $Id: demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
72 $Revision: xxxxxxxxxxxx $
73 [extensions]
74 hgext.keyword =
75 [keyword]
76 * =
77 b = ignore
78 demo.txt =
79 [keywordmaps]
80 Branch = {branches}
81 $Branch: demobranch $
82 % kwshrink should exit silently in empty/invalid repo
83 % cat
84 expand $Id$
85 do not process $Id:
86 xxx $
87 expand $Id$
88 do not process $Id:
89 xxx $
90 ignore $Id$
91 % addremove
92 adding a
93 adding b
94 adding sym
95 % status
96 A a
97 A b
98 A sym
99 % default keyword expansion including commit hook
100 % interrupted commit should not change state or run commit hook
101 a
102 b
103 sym
104 transaction abort!
105 rollback completed
106 abort: edit failed: false exited with status 1
107 % status
108 A a
109 A b
110 A sym
111 % commit
112 a
113 b
114 sym
115 overwriting a expanding keywords
116 running hook commit.test: cp a hooktest
117 % status
118 ? hooktest
119 % identify
120 f782df5f9602
121 % cat
122 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
123 do not process $Id:
124 xxx $
125 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
126 do not process $Id:
127 xxx $
128 ignore $Id$
129 % hg cat
130 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
131 do not process $Id:
132 xxx $
133 ignore $Id$
134 a
135 % diff a hooktest
136 % removing commit hook from config
137 % touch
138 % status
139 % update
140 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 % cat
142 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
143 do not process $Id:
144 xxx $
145 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
146 do not process $Id:
147 xxx $
148 ignore $Id$
149 % copy
150 % kwfiles added
151 a
152 c
153 % commit
154 c
155 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
156 overwriting c expanding keywords
157 % cat a c
158 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
159 do not process $Id:
160 xxx $
161 expand $Id: c,v 0ba462c0f077 1970/01/01 00:00:01 user $
162 do not process $Id:
163 xxx $
164 % touch copied c after 1 second
165 % status
166 % kwfiles
167 a
168 c
169 % diff --rev
170 diff -r f782df5f9602 c
171 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
172 @@ -0,0 +1,3 @@
173 +expand $Id: c,v 0ba462c0f077 1970/01/01 00:00:01 user $
174 +do not process $Id:
175 +xxx $
176 % rollback
177 rolling back last transaction
178 % status
179 A c
180 % update -C
181 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
182 % custom keyword expansion
183 % try with kwdemo
184 [extensions]
185 hgext.keyword =
186 [keyword]
187 * =
188 b = ignore
189 demo.txt =
190 [keywordmaps]
191 Xinfo = {author}: {desc}
192 $Xinfo: test: hg keyword config and expansion example $
193 % cat
194 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
195 do not process $Id:
196 xxx $
197 expand $Id: a,v f782df5f9602 1970/01/01 00:00:00 user $
198 do not process $Id:
199 xxx $
200 ignore $Id$
201 % hg cat
202 expand $Id: a f782df5f9602 Thu, 01 Jan 1970 00:00:00 +0000 user $
203 do not process $Id:
204 xxx $
205 ignore $Id$
206 a
207 % interrupted commit should not change state
208 transaction abort!
209 rollback completed
210 abort: edit failed: false exited with status 1
211 % status
212 M a
213 ? log
214 % commit
215 a
216 overwriting a expanding keywords
217 % status
218 % cat
219 expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $
220 do not process $Id:
221 xxx $
222 $Xinfo: User Name <user@example.com>: firstline $
223 expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $
224 do not process $Id:
225 xxx $
226 $Xinfo: User Name <user@example.com>: firstline $
227 ignore $Id$
228 % hg cat
229 expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $
230 do not process $Id:
231 xxx $
232 $Xinfo: User Name <user@example.com>: firstline $
233 ignore $Id$
234 a
235 % remove
236 % status
237 % rollback
238 rolling back last transaction
239 % status
240 R a
241 % revert a
242 % cat a
243 expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $
244 do not process $Id:
245 xxx $
246 $Xinfo: User Name <user@example.com>: firstline $
247 % clone to test incoming
248 requesting all changes
249 adding changesets
250 adding manifests
251 adding file changes
252 added 1 changesets with 3 changes to 3 files
253 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 % incoming
255 comparing with test-keyword/Test-a/../Test
256 searching for changes
257 changeset: 1:0729690beff6
258 tag: tip
259 user: User Name <user@example.com>
260 date: Thu Jan 01 00:00:02 1970 +0000
261 summary: firstline
262
263 % commit rejecttest
264 a
265 overwriting a expanding keywords
266 % export
267 % import
268 applying ../rejecttest.diff
269 % cat
270 expand $Id: a 82983f13f138 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
271 do not process $Id: rejecttest
272 xxx $
273 $Xinfo: User Name <user@example.com>: rejects? $
274 expand $Id: a 82983f13f138 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
275 do not process $Id: rejecttest
276 xxx $
277 $Xinfo: User Name <user@example.com>: rejects? $
278 ignore $Id$
279
280 % rollback
281 rolling back last transaction
282 % clean update
283 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
284 % kwexpand/kwshrink on selected files
285 % copy a x/a
286 % kwexpand a
287 overwriting a expanding keywords
288 % kwexpand x/a should abort
289 abort: outstanding uncommitted changes in given files
290 x/a
291 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
292 overwriting x/a expanding keywords
293 % cat a
294 expand $Id: x/a f27c134d2d9b Thu, 01 Jan 1970 00:00:03 +0000 user $
295 do not process $Id:
296 xxx $
297 $Xinfo: User Name <user@example.com>: xa $
298 % kwshrink a inside directory x
299 overwriting x/a shrinking keywords
300 % cat a
301 expand $Id$
302 do not process $Id:
303 xxx $
304 $Xinfo$
305 % kwexpand nonexistent
306 nonexistent: No such file or directory
307 % switch off expansion
308 % kwshrink with unknown file u
309 overwriting a shrinking keywords
310 overwriting x/a shrinking keywords
311 % cat
312 expand $Id$
313 do not process $Id:
314 xxx $
315 $Xinfo$
316 expand $Id$
317 do not process $Id:
318 xxx $
319 $Xinfo$
320 ignore $Id$
321 % hg cat
322 expand $Id: a 0729690beff6 Thu, 01 Jan 1970 00:00:02 +0000 user $
323 do not process $Id:
324 xxx $
325 $Xinfo: User Name <user@example.com>: firstline $
326 ignore $Id$
327 a
328 % cat
329 expand $Id$
330 do not process $Id:
331 xxx $
332 $Xinfo$
333 expand $Id$
334 do not process $Id:
335 xxx $
336 $Xinfo$
337 ignore $Id$
338 % hg cat
339 expand $Id$
340 do not process $Id:
341 xxx $
342 $Xinfo$
343 ignore $Id$
344 a
General Comments 0
You need to be logged in to leave comments. Login now