##// END OF EJS Templates
repair: no need to call filterunknown() in strip()...
Patrick Mezard -
r16623:def6a19c default
parent child Browse files
Show More
@@ -1,176 +1,172 b''
1 1 # repair.py - functions for repository repair for mercurial
2 2 #
3 3 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
4 4 # Copyright 2007 Matt Mackall
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 from mercurial import changegroup, bookmarks, phases
9 from mercurial import changegroup, bookmarks
10 10 from mercurial.node import short
11 11 from mercurial.i18n import _
12 12 import os
13 13 import errno
14 14
15 15 def _bundle(repo, bases, heads, node, suffix, compress=True):
16 16 """create a bundle with the specified revisions as a backup"""
17 17 cg = repo.changegroupsubset(bases, heads, 'strip')
18 18 backupdir = repo.join("strip-backup")
19 19 if not os.path.isdir(backupdir):
20 20 os.mkdir(backupdir)
21 21 name = os.path.join(backupdir, "%s-%s.hg" % (short(node), suffix))
22 22 if compress:
23 23 bundletype = "HG10BZ"
24 24 else:
25 25 bundletype = "HG10UN"
26 26 return changegroup.writebundle(cg, name, bundletype)
27 27
28 28 def _collectfiles(repo, striprev):
29 29 """find out the filelogs affected by the strip"""
30 30 files = set()
31 31
32 32 for x in xrange(striprev, len(repo)):
33 33 files.update(repo[x].files())
34 34
35 35 return sorted(files)
36 36
37 37 def _collectbrokencsets(repo, files, striprev):
38 38 """return the changesets which will be broken by the truncation"""
39 39 s = set()
40 40 def collectone(revlog):
41 41 links = (revlog.linkrev(i) for i in revlog)
42 42 # find the truncation point of the revlog
43 43 for lrev in links:
44 44 if lrev >= striprev:
45 45 break
46 46 # see if any revision after this point has a linkrev
47 47 # less than striprev (those will be broken by strip)
48 48 for lrev in links:
49 49 if lrev < striprev:
50 50 s.add(lrev)
51 51
52 52 collectone(repo.manifest)
53 53 for fname in files:
54 54 collectone(repo.file(fname))
55 55
56 56 return s
57 57
58 58 def strip(ui, repo, nodelist, backup="all", topic='backup'):
59 59 cl = repo.changelog
60 60 # TODO handle undo of merge sets
61 61 if isinstance(nodelist, str):
62 62 nodelist = [nodelist]
63 63 striplist = [cl.rev(node) for node in nodelist]
64 64 striprev = min(striplist)
65 65
66 66 keeppartialbundle = backup == 'strip'
67 67
68 68 # Some revisions with rev > striprev may not be descendants of striprev.
69 69 # We have to find these revisions and put them in a bundle, so that
70 70 # we can restore them after the truncations.
71 71 # To create the bundle we use repo.changegroupsubset which requires
72 72 # the list of heads and bases of the set of interesting revisions.
73 73 # (head = revision in the set that has no descendant in the set;
74 74 # base = revision in the set that has no ancestor in the set)
75 75 tostrip = set(striplist)
76 76 for rev in striplist:
77 77 for desc in cl.descendants(rev):
78 78 tostrip.add(desc)
79 79
80 80 files = _collectfiles(repo, striprev)
81 81 saverevs = _collectbrokencsets(repo, files, striprev)
82 82
83 83 # compute heads
84 84 saveheads = set(saverevs)
85 85 for r in xrange(striprev + 1, len(cl)):
86 86 if r not in tostrip:
87 87 saverevs.add(r)
88 88 saveheads.difference_update(cl.parentrevs(r))
89 89 saveheads.add(r)
90 90 saveheads = [cl.node(r) for r in saveheads]
91 91
92 92 # compute base nodes
93 93 if saverevs:
94 94 descendants = set(cl.descendants(*saverevs))
95 95 saverevs.difference_update(descendants)
96 96 savebases = [cl.node(r) for r in saverevs]
97 97 stripbases = [cl.node(r) for r in tostrip]
98 98
99 99 bm = repo._bookmarks
100 100 updatebm = []
101 101 for m in bm:
102 102 rev = repo[bm[m]].rev()
103 103 if rev in tostrip:
104 104 updatebm.append(m)
105 105
106 106 # create a changegroup for all the branches we need to keep
107 107 backupfile = None
108 108 if backup == "all":
109 109 backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
110 110 repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
111 111 if saveheads or savebases:
112 112 # do not compress partial bundle if we remove it from disk later
113 113 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
114 114 compress=keeppartialbundle)
115 115
116 116 mfst = repo.manifest
117 117
118 118 tr = repo.transaction("strip")
119 119 offset = len(tr.entries)
120 120
121 121 try:
122 122 tr.startgroup()
123 123 cl.strip(striprev, tr)
124 124 mfst.strip(striprev, tr)
125 125 for fn in files:
126 126 repo.file(fn).strip(striprev, tr)
127 127 tr.endgroup()
128 128
129 129 try:
130 130 for i in xrange(offset, len(tr.entries)):
131 131 file, troffset, ignore = tr.entries[i]
132 132 repo.sopener(file, 'a').truncate(troffset)
133 133 tr.close()
134 134 except:
135 135 tr.abort()
136 136 raise
137 137
138 138 if saveheads or savebases:
139 139 ui.note(_("adding branch\n"))
140 140 f = open(chgrpfile, "rb")
141 141 gen = changegroup.readbundle(f, chgrpfile)
142 142 if not repo.ui.verbose:
143 143 # silence internal shuffling chatter
144 144 repo.ui.pushbuffer()
145 145 repo.addchangegroup(gen, 'strip', 'bundle:' + chgrpfile, True)
146 146 if not repo.ui.verbose:
147 147 repo.ui.popbuffer()
148 148 f.close()
149 149 if not keeppartialbundle:
150 150 os.unlink(chgrpfile)
151 151
152 152 # remove undo files
153 153 for undofile in repo.undofiles():
154 154 try:
155 155 os.unlink(undofile)
156 156 except OSError, e:
157 157 if e.errno != errno.ENOENT:
158 158 ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
159 159
160 160 for m in updatebm:
161 161 bm[m] = repo['.'].node()
162 162 bookmarks.write(repo)
163 163 except:
164 164 if backupfile:
165 165 ui.warn(_("strip failed, full bundle stored in '%s'\n")
166 166 % backupfile)
167 167 elif saveheads:
168 168 ui.warn(_("strip failed, partial bundle stored in '%s'\n")
169 169 % chgrpfile)
170 170 raise
171 171
172 172 repo.destroyed()
173
174 # remove potential unknown phase
175 # XXX using to_strip data would be faster
176 phases.filterunknown(repo)
@@ -1,1107 +1,1109 b''
1 1 $ "$TESTDIR/hghave" symlink unix-permissions serve || exit 80
2 2
3 3 $ cat <<EOF >> $HGRCPATH
4 4 > [extensions]
5 5 > keyword =
6 6 > mq =
7 7 > notify =
8 8 > record =
9 9 > transplant =
10 10 > [ui]
11 11 > interactive = true
12 12 > EOF
13 13
14 14 Run kwdemo before [keyword] files are set up
15 15 as it would succeed without uisetup otherwise
16 16
17 17 $ hg --quiet kwdemo
18 18 [extensions]
19 19 keyword =
20 20 [keyword]
21 21 demo.txt =
22 22 [keywordset]
23 23 svn = False
24 24 [keywordmaps]
25 25 Author = {author|user}
26 26 Date = {date|utcdate}
27 27 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
28 28 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
29 29 RCSFile = {file|basename},v
30 30 RCSfile = {file|basename},v
31 31 Revision = {node|short}
32 32 Source = {root}/{file},v
33 33 $Author: test $
34 34 $Date: ????/??/?? ??:??:?? $ (glob)
35 35 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
36 36 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
37 37 $RCSFile: demo.txt,v $
38 38 $RCSfile: demo.txt,v $
39 39 $Revision: ???????????? $ (glob)
40 40 $Source: */demo.txt,v $ (glob)
41 41
42 42 $ hg --quiet kwdemo "Branch = {branches}"
43 43 [extensions]
44 44 keyword =
45 45 [keyword]
46 46 demo.txt =
47 47 [keywordset]
48 48 svn = False
49 49 [keywordmaps]
50 50 Branch = {branches}
51 51 $Branch: demobranch $
52 52
53 53 $ cat <<EOF >> $HGRCPATH
54 54 > [keyword]
55 55 > ** =
56 56 > b = ignore
57 57 > i = ignore
58 58 > [hooks]
59 59 > EOF
60 60 $ cp $HGRCPATH $HGRCPATH.nohooks
61 61 > cat <<EOF >> $HGRCPATH
62 62 > commit=
63 63 > commit.test=cp a hooktest
64 64 > EOF
65 65
66 66 $ hg init Test-bndl
67 67 $ cd Test-bndl
68 68
69 69 kwshrink should exit silently in empty/invalid repo
70 70
71 71 $ hg kwshrink
72 72
73 73 Symlinks cannot be created on Windows.
74 74 A bundle to test this was made with:
75 75 hg init t
76 76 cd t
77 77 echo a > a
78 78 ln -s a sym
79 79 hg add sym
80 80 hg ci -m addsym -u mercurial
81 81 hg bundle --base null ../test-keyword.hg
82 82
83 83 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
84 84 pulling from *test-keyword.hg (glob)
85 85 requesting all changes
86 86 adding changesets
87 87 adding manifests
88 88 adding file changes
89 89 added 1 changesets with 1 changes to 1 files
90 90 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 91
92 92 $ echo 'expand $Id$' > a
93 93 $ echo 'do not process $Id:' >> a
94 94 $ echo 'xxx $' >> a
95 95 $ echo 'ignore $Id$' > b
96 96
97 97 Output files as they were created
98 98
99 99 $ cat a b
100 100 expand $Id$
101 101 do not process $Id:
102 102 xxx $
103 103 ignore $Id$
104 104
105 105 no kwfiles
106 106
107 107 $ hg kwfiles
108 108
109 109 untracked candidates
110 110
111 111 $ hg -v kwfiles --unknown
112 112 k a
113 113
114 114 Add files and check status
115 115
116 116 $ hg addremove
117 117 adding a
118 118 adding b
119 119 $ hg status
120 120 A a
121 121 A b
122 122
123 123
124 124 Default keyword expansion including commit hook
125 125 Interrupted commit should not change state or run commit hook
126 126
127 127 $ hg --debug commit
128 128 abort: empty commit message
129 129 [255]
130 130 $ hg status
131 131 A a
132 132 A b
133 133
134 134 Commit with several checks
135 135
136 136 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
137 137 a
138 138 b
139 139 overwriting a expanding keywords
140 140 running hook commit.test: cp a hooktest
141 141 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
142 142 $ hg status
143 143 ? hooktest
144 144 $ hg debugrebuildstate
145 145 $ hg --quiet identify
146 146 ef63ca68695b
147 147
148 148 cat files in working directory with keywords expanded
149 149
150 150 $ cat a b
151 151 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
152 152 do not process $Id:
153 153 xxx $
154 154 ignore $Id$
155 155
156 156 hg cat files and symlink, no expansion
157 157
158 158 $ hg cat sym a b && echo
159 159 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
160 160 do not process $Id:
161 161 xxx $
162 162 ignore $Id$
163 163 a
164 164
165 165 $ diff a hooktest
166 166
167 167 $ cp $HGRCPATH.nohooks $HGRCPATH
168 168 $ rm hooktest
169 169
170 170 hg status of kw-ignored binary file starting with '\1\n'
171 171
172 172 >>> open("i", "wb").write("\1\nfoo")
173 173 $ hg -q commit -Am metasep i
174 174 $ hg status
175 175 >>> open("i", "wb").write("\1\nbar")
176 176 $ hg status
177 177 M i
178 178 $ hg -q commit -m "modify metasep" i
179 179 $ hg status --rev 2:3
180 180 M i
181 181 $ touch empty
182 182 $ hg -q commit -A -m "another file"
183 183 $ hg status -A --rev 3:4 i
184 184 C i
185 185
186 186 $ hg -q strip -n 2
187 187
188 188 Test hook execution
189 189
190 190 bundle
191 191
192 192 $ hg bundle --base null ../kw.hg
193 193 2 changesets found
194 194 $ cd ..
195 195 $ hg init Test
196 196 $ cd Test
197 197
198 198 Notify on pull to check whether keywords stay as is in email
199 199 ie. if patch.diff wrapper acts as it should
200 200
201 201 $ cat <<EOF >> $HGRCPATH
202 202 > [hooks]
203 203 > incoming.notify = python:hgext.notify.hook
204 204 > [notify]
205 205 > sources = pull
206 206 > diffstat = False
207 207 > maxsubject = 15
208 208 > [reposubs]
209 209 > * = Test
210 210 > EOF
211 211
212 212 Pull from bundle and trigger notify
213 213
214 214 $ hg pull -u ../kw.hg
215 215 pulling from ../kw.hg
216 216 requesting all changes
217 217 adding changesets
218 218 adding manifests
219 219 adding file changes
220 220 added 2 changesets with 3 changes to 3 files
221 221 Content-Type: text/plain; charset="us-ascii"
222 222 MIME-Version: 1.0
223 223 Content-Transfer-Encoding: 7bit
224 224 Date: * (glob)
225 225 Subject: changeset in...
226 226 From: mercurial
227 227 X-Hg-Notification: changeset a2392c293916
228 228 Message-Id: <hg.a2392c293916*> (glob)
229 229 To: Test
230 230
231 231 changeset a2392c293916 in $TESTTMP/Test (glob)
232 232 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
233 233 description:
234 234 addsym
235 235
236 236 diffs (6 lines):
237 237
238 238 diff -r 000000000000 -r a2392c293916 sym
239 239 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
240 240 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
241 241 @@ -0,0 +1,1 @@
242 242 +a
243 243 \ No newline at end of file
244 244 Content-Type: text/plain; charset="us-ascii"
245 245 MIME-Version: 1.0
246 246 Content-Transfer-Encoding: 7bit
247 247 Date:* (glob)
248 248 Subject: changeset in...
249 249 From: User Name <user@example.com>
250 250 X-Hg-Notification: changeset ef63ca68695b
251 251 Message-Id: <hg.ef63ca68695b*> (glob)
252 252 To: Test
253 253
254 254 changeset ef63ca68695b in $TESTTMP/Test (glob)
255 255 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
256 256 description:
257 257 absym
258 258
259 259 diffs (12 lines):
260 260
261 261 diff -r a2392c293916 -r ef63ca68695b a
262 262 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
263 263 +++ b/a Thu Jan 01 00:00:00 1970 +0000
264 264 @@ -0,0 +1,3 @@
265 265 +expand $Id$
266 266 +do not process $Id:
267 267 +xxx $
268 268 diff -r a2392c293916 -r ef63ca68695b b
269 269 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
270 270 +++ b/b Thu Jan 01 00:00:00 1970 +0000
271 271 @@ -0,0 +1,1 @@
272 272 +ignore $Id$
273 273 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
274 274
275 275 $ cp $HGRCPATH.nohooks $HGRCPATH
276 276
277 277 Touch files and check with status
278 278
279 279 $ touch a b
280 280 $ hg status
281 281
282 282 Update and expand
283 283
284 284 $ rm sym a b
285 285 $ hg update -C
286 286 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
287 287 $ cat a b
288 288 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
289 289 do not process $Id:
290 290 xxx $
291 291 ignore $Id$
292 292
293 293 Check whether expansion is filewise and file mode is preserved
294 294
295 295 $ echo '$Id$' > c
296 296 $ echo 'tests for different changenodes' >> c
297 297 $ chmod 600 c
298 298 $ ls -l c | cut -b 1-10
299 299 -rw-------
300 300
301 301 commit file c
302 302
303 303 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
304 304 adding c
305 305 $ ls -l c | cut -b 1-10
306 306 -rw-------
307 307
308 308 force expansion
309 309
310 310 $ hg -v kwexpand
311 311 overwriting a expanding keywords
312 312 overwriting c expanding keywords
313 313
314 314 compare changenodes in a and c
315 315
316 316 $ cat a c
317 317 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
318 318 do not process $Id:
319 319 xxx $
320 320 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
321 321 tests for different changenodes
322 322
323 323 record
324 324
325 325 $ echo '$Id$' > r
326 326 $ hg add r
327 327
328 328 record chunk
329 329
330 330 >>> lines = open('a').readlines()
331 331 >>> lines.insert(1, 'foo\n')
332 332 >>> lines.append('bar\n')
333 333 >>> open('a', 'w').writelines(lines)
334 334 $ hg record -d '1 10' -m rectest a<<EOF
335 335 > y
336 336 > y
337 337 > n
338 338 > EOF
339 339 diff --git a/a b/a
340 340 2 hunks, 2 lines changed
341 341 examine changes to 'a'? [Ynesfdaq?]
342 342 @@ -1,3 +1,4 @@
343 343 expand $Id$
344 344 +foo
345 345 do not process $Id:
346 346 xxx $
347 347 record change 1/2 to 'a'? [Ynesfdaq?]
348 348 @@ -2,2 +3,3 @@
349 349 do not process $Id:
350 350 xxx $
351 351 +bar
352 352 record change 2/2 to 'a'? [Ynesfdaq?]
353 353
354 354 $ hg identify
355 355 d17e03c92c97+ tip
356 356 $ hg status
357 357 M a
358 358 A r
359 359
360 360 Cat modified file a
361 361
362 362 $ cat a
363 363 expand $Id: a,v d17e03c92c97 1970/01/01 00:00:01 test $
364 364 foo
365 365 do not process $Id:
366 366 xxx $
367 367 bar
368 368
369 369 Diff remaining chunk
370 370
371 371 $ hg diff a
372 372 diff -r d17e03c92c97 a
373 373 --- a/a Wed Dec 31 23:59:51 1969 -0000
374 374 +++ b/a * (glob)
375 375 @@ -2,3 +2,4 @@
376 376 foo
377 377 do not process $Id:
378 378 xxx $
379 379 +bar
380 380
381 381 $ hg rollback
382 382 repository tip rolled back to revision 2 (undo commit)
383 383 working directory now based on revision 2
384 384
385 385 Record all chunks in file a
386 386
387 387 $ echo foo > msg
388 388
389 389 - do not use "hg record -m" here!
390 390
391 391 $ hg record -l msg -d '1 11' a<<EOF
392 392 > y
393 393 > y
394 394 > y
395 395 > EOF
396 396 diff --git a/a b/a
397 397 2 hunks, 2 lines changed
398 398 examine changes to 'a'? [Ynesfdaq?]
399 399 @@ -1,3 +1,4 @@
400 400 expand $Id$
401 401 +foo
402 402 do not process $Id:
403 403 xxx $
404 404 record change 1/2 to 'a'? [Ynesfdaq?]
405 405 @@ -2,2 +3,3 @@
406 406 do not process $Id:
407 407 xxx $
408 408 +bar
409 409 record change 2/2 to 'a'? [Ynesfdaq?]
410 410
411 411 File a should be clean
412 412
413 413 $ hg status -A a
414 414 C a
415 415
416 416 rollback and revert expansion
417 417
418 418 $ cat a
419 419 expand $Id: a,v 59f969a3b52c 1970/01/01 00:00:01 test $
420 420 foo
421 421 do not process $Id:
422 422 xxx $
423 423 bar
424 424 $ hg --verbose rollback
425 425 repository tip rolled back to revision 2 (undo commit)
426 426 working directory now based on revision 2
427 427 overwriting a expanding keywords
428 428 $ hg status a
429 429 M a
430 430 $ cat a
431 431 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
432 432 foo
433 433 do not process $Id:
434 434 xxx $
435 435 bar
436 436 $ echo '$Id$' > y
437 437 $ echo '$Id$' > z
438 438 $ hg add y
439 439 $ hg commit -Am "rollback only" z
440 440 $ cat z
441 441 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
442 442 $ hg --verbose rollback
443 443 repository tip rolled back to revision 2 (undo commit)
444 444 working directory now based on revision 2
445 445 overwriting z shrinking keywords
446 446
447 447 Only z should be overwritten
448 448
449 449 $ hg status a y z
450 450 M a
451 451 A y
452 452 A z
453 453 $ cat z
454 454 $Id$
455 455 $ hg forget y z
456 456 $ rm y z
457 457
458 458 record added file alone
459 459
460 460 $ hg -v record -l msg -d '1 12' r<<EOF
461 461 > y
462 462 > EOF
463 463 diff --git a/r b/r
464 464 new file mode 100644
465 465 examine changes to 'r'? [Ynesfdaq?]
466 466 r
467 467 committed changeset 3:899491280810
468 468 overwriting r expanding keywords
469 469 - status call required for dirstate.normallookup() check
470 470 $ hg status r
471 471 $ hg --verbose rollback
472 472 repository tip rolled back to revision 2 (undo commit)
473 473 working directory now based on revision 2
474 474 overwriting r shrinking keywords
475 475 $ hg forget r
476 476 $ rm msg r
477 477 $ hg update -C
478 478 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
479 479
480 480 record added keyword ignored file
481 481
482 482 $ echo '$Id$' > i
483 483 $ hg add i
484 484 $ hg --verbose record -d '1 13' -m recignored<<EOF
485 485 > y
486 486 > EOF
487 487 diff --git a/i b/i
488 488 new file mode 100644
489 489 examine changes to 'i'? [Ynesfdaq?]
490 490 i
491 491 committed changeset 3:5f40fe93bbdc
492 492 $ cat i
493 493 $Id$
494 494 $ hg -q rollback
495 495 $ hg forget i
496 496 $ rm i
497 497
498 498 Test patch queue repo
499 499
500 500 $ hg init --mq
501 501 $ hg qimport -r tip -n mqtest.diff
502 502 $ hg commit --mq -m mqtest
503 503
504 504 Keywords should not be expanded in patch
505 505
506 506 $ cat .hg/patches/mqtest.diff
507 507 # HG changeset patch
508 508 # User User Name <user@example.com>
509 509 # Date 1 0
510 510 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
511 511 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
512 512 cndiff
513 513
514 514 diff -r ef63ca68695b -r 40a904bbbe4c c
515 515 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
516 516 +++ b/c Thu Jan 01 00:00:01 1970 +0000
517 517 @@ -0,0 +1,2 @@
518 518 +$Id$
519 519 +tests for different changenodes
520 520
521 521 $ hg qpop
522 522 popping mqtest.diff
523 523 patch queue now empty
524 524
525 525 qgoto, implying qpush, should expand
526 526
527 527 $ hg qgoto mqtest.diff
528 528 applying mqtest.diff
529 529 now at: mqtest.diff
530 530 $ cat c
531 531 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
532 532 tests for different changenodes
533 533 $ hg cat c
534 534 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
535 535 tests for different changenodes
536 536
537 537 Keywords should not be expanded in filelog
538 538
539 539 $ hg --config 'extensions.keyword=!' cat c
540 540 $Id$
541 541 tests for different changenodes
542 542
543 543 qpop and move on
544 544
545 545 $ hg qpop
546 546 popping mqtest.diff
547 547 patch queue now empty
548 548
549 549 Copy and show added kwfiles
550 550
551 551 $ hg cp a c
552 552 $ hg kwfiles
553 553 a
554 554 c
555 555
556 556 Commit and show expansion in original and copy
557 557
558 558 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
559 559 c
560 560 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
561 removing unknown node 40a904bbbe4c from 1-phase boundary
561 562 overwriting c expanding keywords
562 563 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
563 564 $ cat a c
564 565 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
565 566 do not process $Id:
566 567 xxx $
567 568 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
568 569 do not process $Id:
569 570 xxx $
570 571
571 572 Touch copied c and check its status
572 573
573 574 $ touch c
574 575 $ hg status
575 576
576 577 Copy kwfile to keyword ignored file unexpanding keywords
577 578
578 579 $ hg --verbose copy a i
579 580 copying a to i
580 581 overwriting i shrinking keywords
581 582 $ head -n 1 i
582 583 expand $Id$
583 584 $ hg forget i
584 585 $ rm i
585 586
586 587 Copy ignored file to ignored file: no overwriting
587 588
588 589 $ hg --verbose copy b i
589 590 copying b to i
590 591 $ hg forget i
591 592 $ rm i
592 593
593 594 cp symlink file; hg cp -A symlink file (part1)
594 595 - copied symlink points to kwfile: overwrite
595 596
596 597 $ cp sym i
597 598 $ ls -l i
598 599 -rw-r--r--* (glob)
599 600 $ head -1 i
600 601 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
601 602 $ hg copy --after --verbose sym i
602 603 copying sym to i
603 604 overwriting i shrinking keywords
604 605 $ head -1 i
605 606 expand $Id$
606 607 $ hg forget i
607 608 $ rm i
608 609
609 610 Test different options of hg kwfiles
610 611
611 612 $ hg kwfiles
612 613 a
613 614 c
614 615 $ hg -v kwfiles --ignore
615 616 I b
616 617 I sym
617 618 $ hg kwfiles --all
618 619 K a
619 620 K c
620 621 I b
621 622 I sym
622 623
623 624 Diff specific revision
624 625
625 626 $ hg diff --rev 1
626 627 diff -r ef63ca68695b c
627 628 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
628 629 +++ b/c * (glob)
629 630 @@ -0,0 +1,3 @@
630 631 +expand $Id$
631 632 +do not process $Id:
632 633 +xxx $
633 634
634 635 Status after rollback:
635 636
636 637 $ hg rollback
637 638 repository tip rolled back to revision 1 (undo commit)
638 639 working directory now based on revision 1
639 640 $ hg status
640 641 A c
641 642 $ hg update --clean
642 643 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
643 644
644 645 cp symlink file; hg cp -A symlink file (part2)
645 646 - copied symlink points to kw ignored file: do not overwrite
646 647
647 648 $ cat a > i
648 649 $ ln -s i symignored
649 650 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
650 651 $ cp symignored x
651 652 $ hg copy --after --verbose symignored x
652 653 copying symignored to x
653 654 $ head -n 1 x
654 655 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
655 656 $ hg forget x
656 657 $ rm x
657 658
658 659 $ hg rollback
659 660 repository tip rolled back to revision 1 (undo commit)
660 661 working directory now based on revision 1
661 662 $ hg update --clean
662 663 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
663 664 $ rm i symignored
664 665
665 666 Custom keywordmaps as argument to kwdemo
666 667
667 668 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
668 669 [extensions]
669 670 keyword =
670 671 [keyword]
671 672 ** =
672 673 b = ignore
673 674 demo.txt =
674 675 i = ignore
675 676 [keywordset]
676 677 svn = False
677 678 [keywordmaps]
678 679 Xinfo = {author}: {desc}
679 680 $Xinfo: test: hg keyword configuration and expansion example $
680 681
681 682 Configure custom keywordmaps
682 683
683 684 $ cat <<EOF >>$HGRCPATH
684 685 > [keywordmaps]
685 686 > Id = {file} {node|short} {date|rfc822date} {author|user}
686 687 > Xinfo = {author}: {desc}
687 688 > EOF
688 689
689 690 Cat and hg cat files before custom expansion
690 691
691 692 $ cat a b
692 693 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
693 694 do not process $Id:
694 695 xxx $
695 696 ignore $Id$
696 697 $ hg cat sym a b && echo
697 698 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
698 699 do not process $Id:
699 700 xxx $
700 701 ignore $Id$
701 702 a
702 703
703 704 Write custom keyword and prepare multiline commit message
704 705
705 706 $ echo '$Xinfo$' >> a
706 707 $ cat <<EOF >> log
707 708 > firstline
708 709 > secondline
709 710 > EOF
710 711
711 712 Interrupted commit should not change state
712 713
713 714 $ hg commit
714 715 abort: empty commit message
715 716 [255]
716 717 $ hg status
717 718 M a
718 719 ? c
719 720 ? log
720 721
721 722 Commit with multiline message and custom expansion
722 723
723 724 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
724 725 a
726 removing unknown node 40a904bbbe4c from 1-phase boundary
725 727 overwriting a expanding keywords
726 728 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
727 729 $ rm log
728 730
729 731 Stat, verify and show custom expansion (firstline)
730 732
731 733 $ hg status
732 734 ? c
733 735 $ hg verify
734 736 checking changesets
735 737 checking manifests
736 738 crosschecking files in changesets and manifests
737 739 checking files
738 740 3 files, 3 changesets, 4 total revisions
739 741 $ cat a b
740 742 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
741 743 do not process $Id:
742 744 xxx $
743 745 $Xinfo: User Name <user@example.com>: firstline $
744 746 ignore $Id$
745 747 $ hg cat sym a b && echo
746 748 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
747 749 do not process $Id:
748 750 xxx $
749 751 $Xinfo: User Name <user@example.com>: firstline $
750 752 ignore $Id$
751 753 a
752 754
753 755 annotate
754 756
755 757 $ hg annotate a
756 758 1: expand $Id$
757 759 1: do not process $Id:
758 760 1: xxx $
759 761 2: $Xinfo$
760 762
761 763 remove with status checks
762 764
763 765 $ hg debugrebuildstate
764 766 $ hg remove a
765 767 $ hg --debug commit -m rma
766 768 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
767 769 $ hg status
768 770 ? c
769 771
770 772 Rollback, revert, and check expansion
771 773
772 774 $ hg rollback
773 775 repository tip rolled back to revision 2 (undo commit)
774 776 working directory now based on revision 2
775 777 $ hg status
776 778 R a
777 779 ? c
778 780 $ hg revert --no-backup --rev tip a
779 781 $ cat a
780 782 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
781 783 do not process $Id:
782 784 xxx $
783 785 $Xinfo: User Name <user@example.com>: firstline $
784 786
785 787 Clone to test global and local configurations
786 788
787 789 $ cd ..
788 790
789 791 Expansion in destinaton with global configuration
790 792
791 793 $ hg --quiet clone Test globalconf
792 794 $ cat globalconf/a
793 795 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
794 796 do not process $Id:
795 797 xxx $
796 798 $Xinfo: User Name <user@example.com>: firstline $
797 799
798 800 No expansion in destination with local configuration in origin only
799 801
800 802 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
801 803 $ cat localconf/a
802 804 expand $Id$
803 805 do not process $Id:
804 806 xxx $
805 807 $Xinfo$
806 808
807 809 Clone to test incoming
808 810
809 811 $ hg clone -r1 Test Test-a
810 812 adding changesets
811 813 adding manifests
812 814 adding file changes
813 815 added 2 changesets with 3 changes to 3 files
814 816 updating to branch default
815 817 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
816 818 $ cd Test-a
817 819 $ cat <<EOF >> .hg/hgrc
818 820 > [paths]
819 821 > default = ../Test
820 822 > EOF
821 823 $ hg incoming
822 824 comparing with $TESTTMP/Test (glob)
823 825 searching for changes
824 826 changeset: 2:bb948857c743
825 827 tag: tip
826 828 user: User Name <user@example.com>
827 829 date: Thu Jan 01 00:00:02 1970 +0000
828 830 summary: firstline
829 831
830 832 Imported patch should not be rejected
831 833
832 834 >>> import re
833 835 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
834 836 >>> open('a', 'wb').write(text)
835 837 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
836 838 a
837 839 overwriting a expanding keywords
838 840 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
839 841 $ hg export -o ../rejecttest.diff tip
840 842 $ cd ../Test
841 843 $ hg import ../rejecttest.diff
842 844 applying ../rejecttest.diff
843 845 $ cat a b
844 846 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
845 847 do not process $Id: rejecttest
846 848 xxx $
847 849 $Xinfo: User Name <user@example.com>: rejects? $
848 850 ignore $Id$
849 851
850 852 $ hg rollback
851 853 repository tip rolled back to revision 2 (undo import)
852 854 working directory now based on revision 2
853 855 $ hg update --clean
854 856 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
855 857
856 858 kwexpand/kwshrink on selected files
857 859
858 860 $ mkdir x
859 861 $ hg copy a x/a
860 862 $ hg --verbose kwshrink a
861 863 overwriting a shrinking keywords
862 864 - sleep required for dirstate.normal() check
863 865 $ sleep 1
864 866 $ hg status a
865 867 $ hg --verbose kwexpand a
866 868 overwriting a expanding keywords
867 869 $ hg status a
868 870
869 871 kwexpand x/a should abort
870 872
871 873 $ hg --verbose kwexpand x/a
872 874 abort: outstanding uncommitted changes
873 875 [255]
874 876 $ cd x
875 877 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
876 878 x/a
877 879 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
878 880 overwriting x/a expanding keywords
879 881 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
880 882 $ cat a
881 883 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
882 884 do not process $Id:
883 885 xxx $
884 886 $Xinfo: User Name <user@example.com>: xa $
885 887
886 888 kwshrink a inside directory x
887 889
888 890 $ hg --verbose kwshrink a
889 891 overwriting x/a shrinking keywords
890 892 $ cat a
891 893 expand $Id$
892 894 do not process $Id:
893 895 xxx $
894 896 $Xinfo$
895 897 $ cd ..
896 898
897 899 kwexpand nonexistent
898 900
899 901 $ hg kwexpand nonexistent
900 902 nonexistent:* (glob)
901 903
902 904
903 905 hg serve
904 906 - expand with hgweb file
905 907 - no expansion with hgweb annotate/changeset/filediff
906 908 - check errors
907 909
908 910 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
909 911 $ cat hg.pid >> $DAEMON_PIDS
910 912 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/a/?style=raw'
911 913 200 Script output follows
912 914
913 915 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
914 916 do not process $Id:
915 917 xxx $
916 918 $Xinfo: User Name <user@example.com>: firstline $
917 919 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/a/?style=raw'
918 920 200 Script output follows
919 921
920 922
921 923 user@1: expand $Id$
922 924 user@1: do not process $Id:
923 925 user@1: xxx $
924 926 user@2: $Xinfo$
925 927
926 928
927 929
928 930
929 931 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/tip/?style=raw'
930 932 200 Script output follows
931 933
932 934
933 935 # HG changeset patch
934 936 # User User Name <user@example.com>
935 937 # Date 3 0
936 938 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
937 939 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
938 940 xa
939 941
940 942 diff -r bb948857c743 -r b4560182a3f9 x/a
941 943 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
942 944 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
943 945 @@ -0,0 +1,4 @@
944 946 +expand $Id$
945 947 +do not process $Id:
946 948 +xxx $
947 949 +$Xinfo$
948 950
949 951 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/bb948857c743/a?style=raw'
950 952 200 Script output follows
951 953
952 954
953 955 diff -r ef63ca68695b -r bb948857c743 a
954 956 --- a/a Thu Jan 01 00:00:00 1970 +0000
955 957 +++ b/a Thu Jan 01 00:00:02 1970 +0000
956 958 @@ -1,3 +1,4 @@
957 959 expand $Id$
958 960 do not process $Id:
959 961 xxx $
960 962 +$Xinfo$
961 963
962 964
963 965
964 966
965 967 $ cat errors.log
966 968
967 969 Prepare merge and resolve tests
968 970
969 971 $ echo '$Id$' > m
970 972 $ hg add m
971 973 $ hg commit -m 4kw
972 974 $ echo foo >> m
973 975 $ hg commit -m 5foo
974 976
975 977 simplemerge
976 978
977 979 $ hg update 4
978 980 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
979 981 $ echo foo >> m
980 982 $ hg commit -m 6foo
981 983 created new head
982 984 $ hg merge
983 985 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
984 986 (branch merge, don't forget to commit)
985 987 $ hg commit -m simplemerge
986 988 $ cat m
987 989 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
988 990 foo
989 991
990 992 conflict: keyword should stay outside conflict zone
991 993
992 994 $ hg update 4
993 995 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
994 996 $ echo bar >> m
995 997 $ hg commit -m 8bar
996 998 created new head
997 999 $ hg merge
998 1000 merging m
999 1001 warning: conflicts during merge.
1000 1002 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1001 1003 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1002 1004 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1003 1005 [1]
1004 1006 $ cat m
1005 1007 $Id$
1006 1008 <<<<<<< local
1007 1009 bar
1008 1010 =======
1009 1011 foo
1010 1012 >>>>>>> other
1011 1013
1012 1014 resolve to local
1013 1015
1014 1016 $ HGMERGE=internal:local hg resolve -a
1015 1017 $ hg commit -m localresolve
1016 1018 $ cat m
1017 1019 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1018 1020 bar
1019 1021
1020 1022 Test restricted mode with transplant -b
1021 1023
1022 1024 $ hg update 6
1023 1025 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1024 1026 $ hg branch foo
1025 1027 marked working directory as branch foo
1026 1028 (branches are permanent and global, did you want a bookmark?)
1027 1029 $ mv a a.bak
1028 1030 $ echo foobranch > a
1029 1031 $ cat a.bak >> a
1030 1032 $ rm a.bak
1031 1033 $ hg commit -m 9foobranch
1032 1034 $ hg update default
1033 1035 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1034 1036 $ hg -y transplant -b foo tip
1035 1037 applying 4aa30d025d50
1036 1038 4aa30d025d50 transplanted to e00abbf63521
1037 1039
1038 1040 Expansion in changeset but not in file
1039 1041
1040 1042 $ hg tip -p
1041 1043 changeset: 11:e00abbf63521
1042 1044 tag: tip
1043 1045 parent: 9:800511b3a22d
1044 1046 user: test
1045 1047 date: Thu Jan 01 00:00:00 1970 +0000
1046 1048 summary: 9foobranch
1047 1049
1048 1050 diff -r 800511b3a22d -r e00abbf63521 a
1049 1051 --- a/a Thu Jan 01 00:00:00 1970 +0000
1050 1052 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1051 1053 @@ -1,3 +1,4 @@
1052 1054 +foobranch
1053 1055 expand $Id$
1054 1056 do not process $Id:
1055 1057 xxx $
1056 1058
1057 1059 $ head -n 2 a
1058 1060 foobranch
1059 1061 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1060 1062
1061 1063 Turn off expansion
1062 1064
1063 1065 $ hg -q rollback
1064 1066 $ hg -q update -C
1065 1067
1066 1068 kwshrink with unknown file u
1067 1069
1068 1070 $ cp a u
1069 1071 $ hg --verbose kwshrink
1070 1072 overwriting a shrinking keywords
1071 1073 overwriting m shrinking keywords
1072 1074 overwriting x/a shrinking keywords
1073 1075
1074 1076 Keywords shrunk in working directory, but not yet disabled
1075 1077 - cat shows unexpanded keywords
1076 1078 - hg cat shows expanded keywords
1077 1079
1078 1080 $ cat a b
1079 1081 expand $Id$
1080 1082 do not process $Id:
1081 1083 xxx $
1082 1084 $Xinfo$
1083 1085 ignore $Id$
1084 1086 $ hg cat sym a b && echo
1085 1087 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1086 1088 do not process $Id:
1087 1089 xxx $
1088 1090 $Xinfo: User Name <user@example.com>: firstline $
1089 1091 ignore $Id$
1090 1092 a
1091 1093
1092 1094 Now disable keyword expansion
1093 1095
1094 1096 $ rm "$HGRCPATH"
1095 1097 $ cat a b
1096 1098 expand $Id$
1097 1099 do not process $Id:
1098 1100 xxx $
1099 1101 $Xinfo$
1100 1102 ignore $Id$
1101 1103 $ hg cat sym a b && echo
1102 1104 expand $Id$
1103 1105 do not process $Id:
1104 1106 xxx $
1105 1107 $Xinfo$
1106 1108 ignore $Id$
1107 1109 a
General Comments 0
You need to be logged in to leave comments. Login now