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