##// END OF EJS Templates
py3: suppress the output from .write() calls in more tests...
Matt Harbison -
r39987:a339b5e0 default
parent child Browse files
Show More
@@ -1,1030 +1,1030 b''
1 1 #if windows
2 2 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
3 3 #else
4 4 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
5 5 #endif
6 6 $ export PYTHONPATH
7 7
8 8 typical client does not want echo-back messages, so test without it:
9 9
10 10 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
11 11 $ mv $HGRCPATH.new $HGRCPATH
12 12
13 13 $ hg init repo
14 14 $ cd repo
15 15
16 16 >>> from __future__ import absolute_import, print_function
17 17 >>> import os
18 18 >>> import sys
19 19 >>> from hgclient import check, readchannel, runcommand
20 20 >>> @check
21 21 ... def hellomessage(server):
22 22 ... ch, data = readchannel(server)
23 23 ... print('%c, %r' % (ch, data))
24 24 ... # run an arbitrary command to make sure the next thing the server
25 25 ... # sends isn't part of the hello message
26 26 ... runcommand(server, ['id'])
27 27 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
28 28 *** runcommand id
29 29 000000000000 tip
30 30
31 31 >>> from hgclient import check
32 32 >>> @check
33 33 ... def unknowncommand(server):
34 34 ... server.stdin.write('unknowncommand\n')
35 35 abort: unknown command unknowncommand
36 36
37 37 >>> from hgclient import check, readchannel, runcommand
38 38 >>> @check
39 39 ... def checkruncommand(server):
40 40 ... # hello block
41 41 ... readchannel(server)
42 42 ...
43 43 ... # no args
44 44 ... runcommand(server, [])
45 45 ...
46 46 ... # global options
47 47 ... runcommand(server, ['id', '--quiet'])
48 48 ...
49 49 ... # make sure global options don't stick through requests
50 50 ... runcommand(server, ['id'])
51 51 ...
52 52 ... # --config
53 53 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
54 54 ...
55 55 ... # make sure --config doesn't stick
56 56 ... runcommand(server, ['id'])
57 57 ...
58 58 ... # negative return code should be masked
59 59 ... runcommand(server, ['id', '-runknown'])
60 60 *** runcommand
61 61 Mercurial Distributed SCM
62 62
63 63 basic commands:
64 64
65 65 add add the specified files on the next commit
66 66 annotate show changeset information by line for each file
67 67 clone make a copy of an existing repository
68 68 commit commit the specified files or all outstanding changes
69 69 diff diff repository (or selected files)
70 70 export dump the header and diffs for one or more changesets
71 71 forget forget the specified files on the next commit
72 72 init create a new repository in the given directory
73 73 log show revision history of entire repository or files
74 74 merge merge another revision into working directory
75 75 pull pull changes from the specified source
76 76 push push changes to the specified destination
77 77 remove remove the specified files on the next commit
78 78 serve start stand-alone webserver
79 79 status show changed files in the working directory
80 80 summary summarize working directory state
81 81 update update working directory (or switch revisions)
82 82
83 83 (use 'hg help' for the full list of commands or 'hg -v' for details)
84 84 *** runcommand id --quiet
85 85 000000000000
86 86 *** runcommand id
87 87 000000000000 tip
88 88 *** runcommand id --config ui.quiet=True
89 89 000000000000
90 90 *** runcommand id
91 91 000000000000 tip
92 92 *** runcommand id -runknown
93 93 abort: unknown revision 'unknown'!
94 94 [255]
95 95
96 96 >>> from hgclient import check, readchannel
97 97 >>> @check
98 98 ... def inputeof(server):
99 99 ... readchannel(server)
100 100 ... server.stdin.write('runcommand\n')
101 101 ... # close stdin while server is waiting for input
102 102 ... server.stdin.close()
103 103 ...
104 104 ... # server exits with 1 if the pipe closed while reading the command
105 105 ... print('server exit code =', server.wait())
106 106 server exit code = 1
107 107
108 108 >>> from hgclient import check, readchannel, runcommand, stringio
109 109 >>> @check
110 110 ... def serverinput(server):
111 111 ... readchannel(server)
112 112 ...
113 113 ... patch = """
114 114 ... # HG changeset patch
115 115 ... # User test
116 116 ... # Date 0 0
117 117 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
118 118 ... # Parent 0000000000000000000000000000000000000000
119 119 ... 1
120 120 ...
121 121 ... diff -r 000000000000 -r c103a3dec114 a
122 122 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
123 123 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
124 124 ... @@ -0,0 +1,1 @@
125 125 ... +1
126 126 ... """
127 127 ...
128 128 ... runcommand(server, ['import', '-'], input=stringio(patch))
129 129 ... runcommand(server, ['log'])
130 130 *** runcommand import -
131 131 applying patch from stdin
132 132 *** runcommand log
133 133 changeset: 0:eff892de26ec
134 134 tag: tip
135 135 user: test
136 136 date: Thu Jan 01 00:00:00 1970 +0000
137 137 summary: 1
138 138
139 139
140 140 check strict parsing of early options:
141 141
142 142 >>> import os
143 143 >>> from hgclient import check, readchannel, runcommand
144 144 >>> os.environ['HGPLAIN'] = '+strictflags'
145 145 >>> @check
146 146 ... def cwd(server):
147 147 ... readchannel(server)
148 148 ... runcommand(server, ['log', '-b', '--config=alias.log=!echo pwned',
149 149 ... 'default'])
150 150 *** runcommand log -b --config=alias.log=!echo pwned default
151 151 abort: unknown revision '--config=alias.log=!echo pwned'!
152 152 [255]
153 153
154 154 check that "histedit --commands=-" can read rules from the input channel:
155 155
156 156 >>> import cStringIO
157 157 >>> from hgclient import check, readchannel, runcommand
158 158 >>> @check
159 159 ... def serverinput(server):
160 160 ... readchannel(server)
161 161 ... rules = 'pick eff892de26ec\n'
162 162 ... runcommand(server, ['histedit', '0', '--commands=-',
163 163 ... '--config', 'extensions.histedit='],
164 164 ... input=cStringIO.StringIO(rules))
165 165 *** runcommand histedit 0 --commands=- --config extensions.histedit=
166 166
167 167 check that --cwd doesn't persist between requests:
168 168
169 169 $ mkdir foo
170 170 $ touch foo/bar
171 171 >>> from hgclient import check, readchannel, runcommand
172 172 >>> @check
173 173 ... def cwd(server):
174 174 ... readchannel(server)
175 175 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
176 176 ... runcommand(server, ['st', 'foo/bar'])
177 177 *** runcommand --cwd foo st bar
178 178 ? bar
179 179 *** runcommand st foo/bar
180 180 ? foo/bar
181 181
182 182 $ rm foo/bar
183 183
184 184
185 185 check that local configs for the cached repo aren't inherited when -R is used:
186 186
187 187 $ cat <<EOF >> .hg/hgrc
188 188 > [ui]
189 189 > foo = bar
190 190 > EOF
191 191
192 192 #if no-extraextensions
193 193
194 194 >>> from hgclient import check, readchannel, runcommand, sep
195 195 >>> @check
196 196 ... def localhgrc(server):
197 197 ... readchannel(server)
198 198 ...
199 199 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
200 200 ... # show it
201 201 ... runcommand(server, ['showconfig'], outfilter=sep)
202 202 ...
203 203 ... # but not for this repo
204 204 ... runcommand(server, ['init', 'foo'])
205 205 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
206 206 *** runcommand showconfig
207 207 bundle.mainreporoot=$TESTTMP/repo
208 208 devel.all-warnings=true
209 209 devel.default-date=0 0
210 210 extensions.fsmonitor= (fsmonitor !)
211 211 largefiles.usercache=$TESTTMP/.cache/largefiles
212 212 lfs.usercache=$TESTTMP/.cache/lfs
213 213 ui.slash=True
214 214 ui.interactive=False
215 215 ui.mergemarkers=detailed
216 216 ui.foo=bar
217 217 ui.nontty=true
218 218 web.address=localhost
219 219 web\.ipv6=(?:True|False) (re)
220 220 web.server-header=testing stub value
221 221 *** runcommand init foo
222 222 *** runcommand -R foo showconfig ui defaults
223 223 ui.slash=True
224 224 ui.interactive=False
225 225 ui.mergemarkers=detailed
226 226 ui.nontty=true
227 227 #endif
228 228
229 229 $ rm -R foo
230 230
231 231 #if windows
232 232 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
233 233 #else
234 234 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
235 235 #endif
236 236
237 237 $ cat <<EOF > hook.py
238 238 > from __future__ import print_function
239 239 > import sys
240 240 > def hook(**args):
241 241 > print('hook talking')
242 242 > print('now try to read something: %r' % sys.stdin.read())
243 243 > EOF
244 244
245 245 >>> from hgclient import check, readchannel, runcommand, stringio
246 246 >>> @check
247 247 ... def hookoutput(server):
248 248 ... readchannel(server)
249 249 ... runcommand(server, ['--config',
250 250 ... 'hooks.pre-identify=python:hook.hook',
251 251 ... 'id'],
252 252 ... input=stringio('some input'))
253 253 *** runcommand --config hooks.pre-identify=python:hook.hook id
254 254 eff892de26ec tip
255 255 hook talking
256 256 now try to read something: ''
257 257
258 258 Clean hook cached version
259 259 $ rm hook.py*
260 260 $ rm -Rf __pycache__
261 261
262 262 $ echo a >> a
263 263 >>> import os
264 264 >>> from hgclient import check, readchannel, runcommand
265 265 >>> @check
266 266 ... def outsidechanges(server):
267 267 ... readchannel(server)
268 268 ... runcommand(server, ['status'])
269 269 ... os.system('hg ci -Am2')
270 270 ... runcommand(server, ['tip'])
271 271 ... runcommand(server, ['status'])
272 272 *** runcommand status
273 273 M a
274 274 *** runcommand tip
275 275 changeset: 1:d3a0a68be6de
276 276 tag: tip
277 277 user: test
278 278 date: Thu Jan 01 00:00:00 1970 +0000
279 279 summary: 2
280 280
281 281 *** runcommand status
282 282
283 283 >>> import os
284 284 >>> from hgclient import check, readchannel, runcommand
285 285 >>> @check
286 286 ... def bookmarks(server):
287 287 ... readchannel(server)
288 288 ... runcommand(server, ['bookmarks'])
289 289 ...
290 290 ... # changes .hg/bookmarks
291 291 ... os.system('hg bookmark -i bm1')
292 292 ... os.system('hg bookmark -i bm2')
293 293 ... runcommand(server, ['bookmarks'])
294 294 ...
295 295 ... # changes .hg/bookmarks.current
296 296 ... os.system('hg upd bm1 -q')
297 297 ... runcommand(server, ['bookmarks'])
298 298 ...
299 299 ... runcommand(server, ['bookmarks', 'bm3'])
300 300 ... f = open('a', 'ab')
301 ... f.write('a\n')
301 ... f.write('a\n') and None
302 302 ... f.close()
303 303 ... runcommand(server, ['commit', '-Amm'])
304 304 ... runcommand(server, ['bookmarks'])
305 305 ... print('')
306 306 *** runcommand bookmarks
307 307 no bookmarks set
308 308 *** runcommand bookmarks
309 309 bm1 1:d3a0a68be6de
310 310 bm2 1:d3a0a68be6de
311 311 *** runcommand bookmarks
312 312 * bm1 1:d3a0a68be6de
313 313 bm2 1:d3a0a68be6de
314 314 *** runcommand bookmarks bm3
315 315 *** runcommand commit -Amm
316 316 *** runcommand bookmarks
317 317 bm1 1:d3a0a68be6de
318 318 bm2 1:d3a0a68be6de
319 319 * bm3 2:aef17e88f5f0
320 320
321 321
322 322 >>> import os
323 323 >>> from hgclient import check, readchannel, runcommand
324 324 >>> @check
325 325 ... def tagscache(server):
326 326 ... readchannel(server)
327 327 ... runcommand(server, ['id', '-t', '-r', '0'])
328 328 ... os.system('hg tag -r 0 foo')
329 329 ... runcommand(server, ['id', '-t', '-r', '0'])
330 330 *** runcommand id -t -r 0
331 331
332 332 *** runcommand id -t -r 0
333 333 foo
334 334
335 335 >>> import os
336 336 >>> from hgclient import check, readchannel, runcommand
337 337 >>> @check
338 338 ... def setphase(server):
339 339 ... readchannel(server)
340 340 ... runcommand(server, ['phase', '-r', '.'])
341 341 ... os.system('hg phase -r . -p')
342 342 ... runcommand(server, ['phase', '-r', '.'])
343 343 *** runcommand phase -r .
344 344 3: draft
345 345 *** runcommand phase -r .
346 346 3: public
347 347
348 348 $ echo a >> a
349 349 >>> from hgclient import check, readchannel, runcommand
350 350 >>> @check
351 351 ... def rollback(server):
352 352 ... readchannel(server)
353 353 ... runcommand(server, ['phase', '-r', '.', '-p'])
354 354 ... runcommand(server, ['commit', '-Am.'])
355 355 ... runcommand(server, ['rollback'])
356 356 ... runcommand(server, ['phase', '-r', '.'])
357 357 ... print('')
358 358 *** runcommand phase -r . -p
359 359 no phases changed
360 360 *** runcommand commit -Am.
361 361 *** runcommand rollback
362 362 repository tip rolled back to revision 3 (undo commit)
363 363 working directory now based on revision 3
364 364 *** runcommand phase -r .
365 365 3: public
366 366
367 367
368 368 >>> import os
369 369 >>> from hgclient import check, readchannel, runcommand
370 370 >>> @check
371 371 ... def branch(server):
372 372 ... readchannel(server)
373 373 ... runcommand(server, ['branch'])
374 374 ... os.system('hg branch foo')
375 375 ... runcommand(server, ['branch'])
376 376 ... os.system('hg branch default')
377 377 *** runcommand branch
378 378 default
379 379 marked working directory as branch foo
380 380 (branches are permanent and global, did you want a bookmark?)
381 381 *** runcommand branch
382 382 foo
383 383 marked working directory as branch default
384 384 (branches are permanent and global, did you want a bookmark?)
385 385
386 386 $ touch .hgignore
387 387 >>> import os
388 388 >>> from hgclient import check, readchannel, runcommand
389 389 >>> @check
390 390 ... def hgignore(server):
391 391 ... readchannel(server)
392 392 ... runcommand(server, ['commit', '-Am.'])
393 393 ... f = open('ignored-file', 'ab')
394 ... f.write('')
394 ... f.write('') and None
395 395 ... f.close()
396 396 ... f = open('.hgignore', 'ab')
397 397 ... f.write('ignored-file')
398 398 ... f.close()
399 399 ... runcommand(server, ['status', '-i', '-u'])
400 400 ... print('')
401 401 *** runcommand commit -Am.
402 402 adding .hgignore
403 403 *** runcommand status -i -u
404 404 I ignored-file
405 405
406 406
407 407 cache of non-public revisions should be invalidated on repository change
408 408 (issue4855):
409 409
410 410 >>> import os
411 411 >>> from hgclient import check, readchannel, runcommand
412 412 >>> @check
413 413 ... def phasesetscacheaftercommit(server):
414 414 ... readchannel(server)
415 415 ... # load _phasecache._phaserevs and _phasesets
416 416 ... runcommand(server, ['log', '-qr', 'draft()'])
417 417 ... # create draft commits by another process
418 418 ... for i in range(5, 7):
419 419 ... f = open('a', 'ab')
420 420 ... f.seek(0, os.SEEK_END)
421 ... f.write('a\n')
421 ... f.write('a\n') and None
422 422 ... f.close()
423 423 ... os.system('hg commit -Aqm%d' % i)
424 424 ... # new commits should be listed as draft revisions
425 425 ... runcommand(server, ['log', '-qr', 'draft()'])
426 426 ... print('')
427 427 *** runcommand log -qr draft()
428 428 4:7966c8e3734d
429 429 *** runcommand log -qr draft()
430 430 4:7966c8e3734d
431 431 5:41f6602d1c4f
432 432 6:10501e202c35
433 433
434 434
435 435 >>> import os
436 436 >>> from hgclient import check, readchannel, runcommand
437 437 >>> @check
438 438 ... def phasesetscacheafterstrip(server):
439 439 ... readchannel(server)
440 440 ... # load _phasecache._phaserevs and _phasesets
441 441 ... runcommand(server, ['log', '-qr', 'draft()'])
442 442 ... # strip cached revisions by another process
443 443 ... os.system('hg --config extensions.strip= strip -q 5')
444 444 ... # shouldn't abort by "unknown revision '6'"
445 445 ... runcommand(server, ['log', '-qr', 'draft()'])
446 446 ... print('')
447 447 *** runcommand log -qr draft()
448 448 4:7966c8e3734d
449 449 5:41f6602d1c4f
450 450 6:10501e202c35
451 451 *** runcommand log -qr draft()
452 452 4:7966c8e3734d
453 453
454 454
455 455 cache of phase roots should be invalidated on strip (issue3827):
456 456
457 457 >>> import os
458 458 >>> from hgclient import check, readchannel, runcommand, sep
459 459 >>> @check
460 460 ... def phasecacheafterstrip(server):
461 461 ... readchannel(server)
462 462 ...
463 463 ... # create new head, 5:731265503d86
464 464 ... runcommand(server, ['update', '-C', '0'])
465 465 ... f = open('a', 'ab')
466 ... f.write('a\n')
466 ... f.write('a\n') and None
467 467 ... f.close()
468 468 ... runcommand(server, ['commit', '-Am.', 'a'])
469 469 ... runcommand(server, ['log', '-Gq'])
470 470 ...
471 471 ... # make it public; draft marker moves to 4:7966c8e3734d
472 472 ... runcommand(server, ['phase', '-p', '.'])
473 473 ... # load _phasecache.phaseroots
474 474 ... runcommand(server, ['phase', '.'], outfilter=sep)
475 475 ...
476 476 ... # strip 1::4 outside server
477 477 ... os.system('hg -q --config extensions.mq= strip 1')
478 478 ...
479 479 ... # shouldn't raise "7966c8e3734d: no node!"
480 480 ... runcommand(server, ['branches'])
481 481 *** runcommand update -C 0
482 482 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
483 483 (leaving bookmark bm3)
484 484 *** runcommand commit -Am. a
485 485 created new head
486 486 *** runcommand log -Gq
487 487 @ 5:731265503d86
488 488 |
489 489 | o 4:7966c8e3734d
490 490 | |
491 491 | o 3:b9b85890c400
492 492 | |
493 493 | o 2:aef17e88f5f0
494 494 | |
495 495 | o 1:d3a0a68be6de
496 496 |/
497 497 o 0:eff892de26ec
498 498
499 499 *** runcommand phase -p .
500 500 *** runcommand phase .
501 501 5: public
502 502 *** runcommand branches
503 503 default 1:731265503d86
504 504
505 505 in-memory cache must be reloaded if transaction is aborted. otherwise
506 506 changelog and manifest would have invalid node:
507 507
508 508 $ echo a >> a
509 509 >>> from hgclient import check, readchannel, runcommand
510 510 >>> @check
511 511 ... def txabort(server):
512 512 ... readchannel(server)
513 513 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
514 514 ... '-mfoo'])
515 515 ... runcommand(server, ['verify'])
516 516 *** runcommand commit --config hooks.pretxncommit=false -mfoo
517 517 transaction abort!
518 518 rollback completed
519 519 abort: pretxncommit hook exited with status 1
520 520 [255]
521 521 *** runcommand verify
522 522 checking changesets
523 523 checking manifests
524 524 crosschecking files in changesets and manifests
525 525 checking files
526 526 checked 2 changesets with 2 changes to 1 files
527 527 $ hg revert --no-backup -aq
528 528
529 529 $ cat >> .hg/hgrc << EOF
530 530 > [experimental]
531 531 > evolution.createmarkers=True
532 532 > EOF
533 533
534 534 >>> import os
535 535 >>> from hgclient import check, readchannel, runcommand
536 536 >>> @check
537 537 ... def obsolete(server):
538 538 ... readchannel(server)
539 539 ...
540 540 ... runcommand(server, ['up', 'null'])
541 541 ... runcommand(server, ['phase', '-df', 'tip'])
542 542 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
543 543 ... if os.name == 'nt':
544 544 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
545 545 ... os.system(cmd)
546 546 ... runcommand(server, ['log', '--hidden'])
547 547 ... runcommand(server, ['log'])
548 548 *** runcommand up null
549 549 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
550 550 *** runcommand phase -df tip
551 551 obsoleted 1 changesets
552 552 *** runcommand log --hidden
553 553 changeset: 1:731265503d86
554 554 tag: tip
555 555 user: test
556 556 date: Thu Jan 01 00:00:00 1970 +0000
557 557 obsolete: pruned
558 558 summary: .
559 559
560 560 changeset: 0:eff892de26ec
561 561 bookmark: bm1
562 562 bookmark: bm2
563 563 bookmark: bm3
564 564 user: test
565 565 date: Thu Jan 01 00:00:00 1970 +0000
566 566 summary: 1
567 567
568 568 *** runcommand log
569 569 changeset: 0:eff892de26ec
570 570 bookmark: bm1
571 571 bookmark: bm2
572 572 bookmark: bm3
573 573 tag: tip
574 574 user: test
575 575 date: Thu Jan 01 00:00:00 1970 +0000
576 576 summary: 1
577 577
578 578
579 579 $ cat <<EOF >> .hg/hgrc
580 580 > [extensions]
581 581 > mq =
582 582 > EOF
583 583
584 584 >>> import os
585 585 >>> from hgclient import check, readchannel, runcommand
586 586 >>> @check
587 587 ... def mqoutsidechanges(server):
588 588 ... readchannel(server)
589 589 ...
590 590 ... # load repo.mq
591 591 ... runcommand(server, ['qapplied'])
592 592 ... os.system('hg qnew 0.diff')
593 593 ... # repo.mq should be invalidated
594 594 ... runcommand(server, ['qapplied'])
595 595 ...
596 596 ... runcommand(server, ['qpop', '--all'])
597 597 ... os.system('hg qqueue --create foo')
598 598 ... # repo.mq should be recreated to point to new queue
599 599 ... runcommand(server, ['qqueue', '--active'])
600 600 *** runcommand qapplied
601 601 *** runcommand qapplied
602 602 0.diff
603 603 *** runcommand qpop --all
604 604 popping 0.diff
605 605 patch queue now empty
606 606 *** runcommand qqueue --active
607 607 foo
608 608
609 609 $ cat <<EOF > dbgui.py
610 610 > import os
611 611 > import sys
612 612 > from mercurial import commands, registrar
613 613 > cmdtable = {}
614 614 > command = registrar.command(cmdtable)
615 615 > @command(b"debuggetpass", norepo=True)
616 616 > def debuggetpass(ui):
617 617 > ui.write("%s\\n" % ui.getpass())
618 618 > @command(b"debugprompt", norepo=True)
619 619 > def debugprompt(ui):
620 620 > ui.write("%s\\n" % ui.prompt("prompt:"))
621 621 > @command(b"debugreadstdin", norepo=True)
622 622 > def debugreadstdin(ui):
623 623 > ui.write("read: %r\n" % sys.stdin.read(1))
624 624 > @command(b"debugwritestdout", norepo=True)
625 625 > def debugwritestdout(ui):
626 626 > os.write(1, "low-level stdout fd and\n")
627 627 > sys.stdout.write("stdout should be redirected to stderr\n")
628 628 > sys.stdout.flush()
629 629 > EOF
630 630 $ cat <<EOF >> .hg/hgrc
631 631 > [extensions]
632 632 > dbgui = dbgui.py
633 633 > EOF
634 634
635 635 >>> from hgclient import check, readchannel, runcommand, stringio
636 636 >>> @check
637 637 ... def getpass(server):
638 638 ... readchannel(server)
639 639 ... runcommand(server, ['debuggetpass', '--config',
640 640 ... 'ui.interactive=True'],
641 641 ... input=stringio('1234\n'))
642 642 ... runcommand(server, ['debuggetpass', '--config',
643 643 ... 'ui.interactive=True'],
644 644 ... input=stringio('\n'))
645 645 ... runcommand(server, ['debuggetpass', '--config',
646 646 ... 'ui.interactive=True'],
647 647 ... input=stringio(''))
648 648 ... runcommand(server, ['debugprompt', '--config',
649 649 ... 'ui.interactive=True'],
650 650 ... input=stringio('5678\n'))
651 651 ... runcommand(server, ['debugreadstdin'])
652 652 ... runcommand(server, ['debugwritestdout'])
653 653 *** runcommand debuggetpass --config ui.interactive=True
654 654 password: 1234
655 655 *** runcommand debuggetpass --config ui.interactive=True
656 656 password:
657 657 *** runcommand debuggetpass --config ui.interactive=True
658 658 password: abort: response expected
659 659 [255]
660 660 *** runcommand debugprompt --config ui.interactive=True
661 661 prompt: 5678
662 662 *** runcommand debugreadstdin
663 663 read: ''
664 664 *** runcommand debugwritestdout
665 665 low-level stdout fd and
666 666 stdout should be redirected to stderr
667 667
668 668
669 669 run commandserver in commandserver, which is silly but should work:
670 670
671 671 >>> from __future__ import print_function
672 672 >>> from hgclient import check, readchannel, runcommand, stringio
673 673 >>> @check
674 674 ... def nested(server):
675 675 ... print('%c, %r' % readchannel(server))
676 676 ... class nestedserver(object):
677 677 ... stdin = stringio('getencoding\n')
678 678 ... stdout = stringio()
679 679 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
680 680 ... output=nestedserver.stdout, input=nestedserver.stdin)
681 681 ... nestedserver.stdout.seek(0)
682 682 ... print('%c, %r' % readchannel(nestedserver)) # hello
683 683 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
684 684 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
685 685 *** runcommand serve --cmdserver pipe
686 686 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
687 687 r, '*' (glob)
688 688
689 689
690 690 start without repository:
691 691
692 692 $ cd ..
693 693
694 694 >>> from __future__ import print_function
695 695 >>> from hgclient import check, readchannel, runcommand
696 696 >>> @check
697 697 ... def hellomessage(server):
698 698 ... ch, data = readchannel(server)
699 699 ... print('%c, %r' % (ch, data))
700 700 ... # run an arbitrary command to make sure the next thing the server
701 701 ... # sends isn't part of the hello message
702 702 ... runcommand(server, ['id'])
703 703 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
704 704 *** runcommand id
705 705 abort: there is no Mercurial repository here (.hg not found)
706 706 [255]
707 707
708 708 >>> from hgclient import check, readchannel, runcommand
709 709 >>> @check
710 710 ... def startwithoutrepo(server):
711 711 ... readchannel(server)
712 712 ... runcommand(server, ['init', 'repo2'])
713 713 ... runcommand(server, ['id', '-R', 'repo2'])
714 714 *** runcommand init repo2
715 715 *** runcommand id -R repo2
716 716 000000000000 tip
717 717
718 718
719 719 don't fall back to cwd if invalid -R path is specified (issue4805):
720 720
721 721 $ cd repo
722 722 $ hg serve --cmdserver pipe -R ../nonexistent
723 723 abort: repository ../nonexistent not found!
724 724 [255]
725 725 $ cd ..
726 726
727 727
728 728 unix domain socket:
729 729
730 730 $ cd repo
731 731 $ hg update -q
732 732
733 733 #if unix-socket unix-permissions
734 734
735 735 >>> from __future__ import print_function
736 736 >>> from hgclient import check, readchannel, runcommand, stringio, unixserver
737 737 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
738 738 >>> def hellomessage(conn):
739 739 ... ch, data = readchannel(conn)
740 740 ... print('%c, %r' % (ch, data))
741 741 ... runcommand(conn, ['id'])
742 742 >>> check(hellomessage, server.connect)
743 743 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
744 744 *** runcommand id
745 745 eff892de26ec tip bm1/bm2/bm3
746 746 >>> def unknowncommand(conn):
747 747 ... readchannel(conn)
748 748 ... conn.stdin.write('unknowncommand\n')
749 749 >>> check(unknowncommand, server.connect) # error sent to server.log
750 750 >>> def serverinput(conn):
751 751 ... readchannel(conn)
752 752 ... patch = """
753 753 ... # HG changeset patch
754 754 ... # User test
755 755 ... # Date 0 0
756 756 ... 2
757 757 ...
758 758 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
759 759 ... --- a/a
760 760 ... +++ b/a
761 761 ... @@ -1,1 +1,2 @@
762 762 ... 1
763 763 ... +2
764 764 ... """
765 765 ... runcommand(conn, ['import', '-'], input=stringio(patch))
766 766 ... runcommand(conn, ['log', '-rtip', '-q'])
767 767 >>> check(serverinput, server.connect)
768 768 *** runcommand import -
769 769 applying patch from stdin
770 770 *** runcommand log -rtip -q
771 771 2:1ed24be7e7a0
772 772 >>> server.shutdown()
773 773
774 774 $ cat .hg/server.log
775 775 listening at .hg/server.sock
776 776 abort: unknown command unknowncommand
777 777 killed!
778 778 $ rm .hg/server.log
779 779
780 780 if server crashed before hello, traceback will be sent to 'e' channel as
781 781 last ditch:
782 782
783 783 $ cat <<EOF >> .hg/hgrc
784 784 > [cmdserver]
785 785 > log = inexistent/path.log
786 786 > EOF
787 787 >>> from __future__ import print_function
788 788 >>> from hgclient import check, readchannel, unixserver
789 789 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
790 790 >>> def earlycrash(conn):
791 791 ... while True:
792 792 ... try:
793 793 ... ch, data = readchannel(conn)
794 794 ... if not data.startswith(' '):
795 795 ... print('%c, %r' % (ch, data))
796 796 ... except EOFError:
797 797 ... break
798 798 >>> check(earlycrash, server.connect)
799 799 e, 'Traceback (most recent call last):\n'
800 800 e, "IOError: *" (glob)
801 801 >>> server.shutdown()
802 802
803 803 $ cat .hg/server.log | grep -v '^ '
804 804 listening at .hg/server.sock
805 805 Traceback (most recent call last):
806 806 IOError: * (glob)
807 807 killed!
808 808 #endif
809 809 #if no-unix-socket
810 810
811 811 $ hg serve --cmdserver unix -a .hg/server.sock
812 812 abort: unsupported platform
813 813 [255]
814 814
815 815 #endif
816 816
817 817 $ cd ..
818 818
819 819 Test that accessing to invalid changelog cache is avoided at
820 820 subsequent operations even if repo object is reused even after failure
821 821 of transaction (see 0a7610758c42 also)
822 822
823 823 "hg log" after failure of transaction is needed to detect invalid
824 824 cache in repoview: this can't detect by "hg verify" only.
825 825
826 826 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
827 827 4) are tested, because '00changelog.i' are differently changed in each
828 828 cases.
829 829
830 830 $ cat > $TESTTMP/failafterfinalize.py <<EOF
831 831 > # extension to abort transaction after finalization forcibly
832 832 > from mercurial import commands, error, extensions, lock as lockmod
833 833 > from mercurial import registrar
834 834 > cmdtable = {}
835 835 > command = registrar.command(cmdtable)
836 836 > configtable = {}
837 837 > configitem = registrar.configitem(configtable)
838 838 > configitem('failafterfinalize', 'fail',
839 839 > default=None,
840 840 > )
841 841 > def fail(tr):
842 842 > raise error.Abort('fail after finalization')
843 843 > def reposetup(ui, repo):
844 844 > class failrepo(repo.__class__):
845 845 > def commitctx(self, ctx, error=False):
846 846 > if self.ui.configbool('failafterfinalize', 'fail'):
847 847 > # 'sorted()' by ASCII code on category names causes
848 848 > # invoking 'fail' after finalization of changelog
849 849 > # using "'cl-%i' % id(self)" as category name
850 850 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
851 851 > return super(failrepo, self).commitctx(ctx, error)
852 852 > repo.__class__ = failrepo
853 853 > EOF
854 854
855 855 $ hg init repo3
856 856 $ cd repo3
857 857
858 858 $ cat <<EOF >> $HGRCPATH
859 859 > [ui]
860 860 > logtemplate = {rev} {desc|firstline} ({files})\n
861 861 >
862 862 > [extensions]
863 863 > failafterfinalize = $TESTTMP/failafterfinalize.py
864 864 > EOF
865 865
866 866 - test failure with "empty changelog"
867 867
868 868 $ echo foo > foo
869 869 $ hg add foo
870 870
871 871 (failure before finalization)
872 872
873 873 >>> from hgclient import check, readchannel, runcommand
874 874 >>> @check
875 875 ... def abort(server):
876 876 ... readchannel(server)
877 877 ... runcommand(server, ['commit',
878 878 ... '--config', 'hooks.pretxncommit=false',
879 879 ... '-mfoo'])
880 880 ... runcommand(server, ['log'])
881 881 ... runcommand(server, ['verify', '-q'])
882 882 *** runcommand commit --config hooks.pretxncommit=false -mfoo
883 883 transaction abort!
884 884 rollback completed
885 885 abort: pretxncommit hook exited with status 1
886 886 [255]
887 887 *** runcommand log
888 888 *** runcommand verify -q
889 889
890 890 (failure after finalization)
891 891
892 892 >>> from hgclient import check, readchannel, runcommand
893 893 >>> @check
894 894 ... def abort(server):
895 895 ... readchannel(server)
896 896 ... runcommand(server, ['commit',
897 897 ... '--config', 'failafterfinalize.fail=true',
898 898 ... '-mfoo'])
899 899 ... runcommand(server, ['log'])
900 900 ... runcommand(server, ['verify', '-q'])
901 901 *** runcommand commit --config failafterfinalize.fail=true -mfoo
902 902 transaction abort!
903 903 rollback completed
904 904 abort: fail after finalization
905 905 [255]
906 906 *** runcommand log
907 907 *** runcommand verify -q
908 908
909 909 - test failure with "not-empty changelog"
910 910
911 911 $ echo bar > bar
912 912 $ hg add bar
913 913 $ hg commit -mbar bar
914 914
915 915 (failure before finalization)
916 916
917 917 >>> from hgclient import check, readchannel, runcommand
918 918 >>> @check
919 919 ... def abort(server):
920 920 ... readchannel(server)
921 921 ... runcommand(server, ['commit',
922 922 ... '--config', 'hooks.pretxncommit=false',
923 923 ... '-mfoo', 'foo'])
924 924 ... runcommand(server, ['log'])
925 925 ... runcommand(server, ['verify', '-q'])
926 926 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
927 927 transaction abort!
928 928 rollback completed
929 929 abort: pretxncommit hook exited with status 1
930 930 [255]
931 931 *** runcommand log
932 932 0 bar (bar)
933 933 *** runcommand verify -q
934 934
935 935 (failure after finalization)
936 936
937 937 >>> from hgclient import check, readchannel, runcommand
938 938 >>> @check
939 939 ... def abort(server):
940 940 ... readchannel(server)
941 941 ... runcommand(server, ['commit',
942 942 ... '--config', 'failafterfinalize.fail=true',
943 943 ... '-mfoo', 'foo'])
944 944 ... runcommand(server, ['log'])
945 945 ... runcommand(server, ['verify', '-q'])
946 946 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
947 947 transaction abort!
948 948 rollback completed
949 949 abort: fail after finalization
950 950 [255]
951 951 *** runcommand log
952 952 0 bar (bar)
953 953 *** runcommand verify -q
954 954
955 955 $ cd ..
956 956
957 957 Test symlink traversal over cached audited paths:
958 958 -------------------------------------------------
959 959
960 960 #if symlink
961 961
962 962 set up symlink hell
963 963
964 964 $ mkdir merge-symlink-out
965 965 $ hg init merge-symlink
966 966 $ cd merge-symlink
967 967 $ touch base
968 968 $ hg commit -qAm base
969 969 $ ln -s ../merge-symlink-out a
970 970 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
971 971 $ hg up -q 0
972 972 $ mkdir a
973 973 $ touch a/poisoned
974 974 $ hg commit -qAm 'file a/poisoned'
975 975 $ hg log -G -T '{rev}: {desc}\n'
976 976 @ 2: file a/poisoned
977 977 |
978 978 | o 1: symlink a -> ../merge-symlink-out
979 979 |/
980 980 o 0: base
981 981
982 982
983 983 try trivial merge after update: cache of audited paths should be discarded,
984 984 and the merge should fail (issue5628)
985 985
986 986 $ hg up -q null
987 987 >>> from hgclient import check, readchannel, runcommand
988 988 >>> @check
989 989 ... def merge(server):
990 990 ... readchannel(server)
991 991 ... # audit a/poisoned as a good path
992 992 ... runcommand(server, ['up', '-qC', '2'])
993 993 ... runcommand(server, ['up', '-qC', '1'])
994 994 ... # here a is a symlink, so a/poisoned is bad
995 995 ... runcommand(server, ['merge', '2'])
996 996 *** runcommand up -qC 2
997 997 *** runcommand up -qC 1
998 998 *** runcommand merge 2
999 999 abort: path 'a/poisoned' traverses symbolic link 'a'
1000 1000 [255]
1001 1001 $ ls ../merge-symlink-out
1002 1002
1003 1003 cache of repo.auditor should be discarded, so matcher would never traverse
1004 1004 symlinks:
1005 1005
1006 1006 $ hg up -qC 0
1007 1007 $ touch ../merge-symlink-out/poisoned
1008 1008 >>> from hgclient import check, readchannel, runcommand
1009 1009 >>> @check
1010 1010 ... def files(server):
1011 1011 ... readchannel(server)
1012 1012 ... runcommand(server, ['up', '-qC', '2'])
1013 1013 ... # audit a/poisoned as a good path
1014 1014 ... runcommand(server, ['files', 'a/poisoned'])
1015 1015 ... runcommand(server, ['up', '-qC', '0'])
1016 1016 ... runcommand(server, ['up', '-qC', '1'])
1017 1017 ... # here 'a' is a symlink, so a/poisoned should be warned
1018 1018 ... runcommand(server, ['files', 'a/poisoned'])
1019 1019 *** runcommand up -qC 2
1020 1020 *** runcommand files a/poisoned
1021 1021 a/poisoned
1022 1022 *** runcommand up -qC 0
1023 1023 *** runcommand up -qC 1
1024 1024 *** runcommand files a/poisoned
1025 1025 abort: path 'a/poisoned' traverses symbolic link 'a'
1026 1026 [255]
1027 1027
1028 1028 $ cd ..
1029 1029
1030 1030 #endif
@@ -1,1480 +1,1480 b''
1 1 #require no-reposimplestore
2 2
3 3 Run kwdemo outside a repo
4 4 $ hg -q --config extensions.keyword= --config keywordmaps.Foo="{author|user}" kwdemo
5 5 [extensions]
6 6 keyword =
7 7 [keyword]
8 8 demo.txt =
9 9 [keywordset]
10 10 svn = False
11 11 [keywordmaps]
12 12 Foo = {author|user}
13 13 $Foo: test $
14 14
15 15 $ cat <<EOF >> $HGRCPATH
16 16 > [extensions]
17 17 > keyword =
18 18 > mq =
19 19 > notify =
20 20 > record =
21 21 > transplant =
22 22 > [ui]
23 23 > interactive = true
24 24 > EOF
25 25
26 26 hide outer repo
27 27 $ hg init
28 28
29 29 Run kwdemo before [keyword] files are set up
30 30 as it would succeed without uisetup otherwise
31 31
32 32 $ hg --quiet kwdemo
33 33 [extensions]
34 34 keyword =
35 35 [keyword]
36 36 demo.txt =
37 37 [keywordset]
38 38 svn = False
39 39 [keywordmaps]
40 40 Author = {author|user}
41 41 Date = {date|utcdate}
42 42 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
43 43 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
44 44 RCSFile = {file|basename},v
45 45 RCSfile = {file|basename},v
46 46 Revision = {node|short}
47 47 Source = {root}/{file},v
48 48 $Author: test $
49 49 $Date: ????/??/?? ??:??:?? $ (glob)
50 50 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
51 51 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
52 52 $RCSFile: demo.txt,v $
53 53 $RCSfile: demo.txt,v $
54 54 $Revision: ???????????? $ (glob)
55 55 $Source: */demo.txt,v $ (glob)
56 56
57 57 $ hg --quiet kwdemo "Branch = {branches}"
58 58 [extensions]
59 59 keyword =
60 60 [keyword]
61 61 demo.txt =
62 62 [keywordset]
63 63 svn = False
64 64 [keywordmaps]
65 65 Branch = {branches}
66 66 $Branch: demobranch $
67 67
68 68 (test template filter svnisodate and svnutcdate)
69 69
70 70 $ hg --quiet kwdemo --config keywordset.svn=True
71 71 [extensions]
72 72 keyword =
73 73 [keyword]
74 74 demo.txt =
75 75 [keywordset]
76 76 svn = True
77 77 [keywordmaps]
78 78 Author = {author|user}
79 79 Date = {date|svnisodate}
80 80 Id = {file|basename},v {node|short} {date|svnutcdate} {author|user}
81 81 LastChangedBy = {author|user}
82 82 LastChangedDate = {date|svnisodate}
83 83 LastChangedRevision = {node|short}
84 84 Revision = {node|short}
85 85 $Author: test $
86 86 $Date: ????-??-?? ??:??:?? ????? (???, ?? ??? ????) $ (glob)
87 87 $Id: demo.txt,v ???????????? ????-??-?? ??:??:??Z test $ (glob)
88 88 $LastChangedBy: test $
89 89 $LastChangedDate: ????-??-?? ??:??:?? ????? (???, ?? ??? ????) $ (glob)
90 90 $LastChangedRevision: ???????????? $ (glob)
91 91 $Revision: ???????????? $ (glob)
92 92
93 93 $ cat <<EOF >> $HGRCPATH
94 94 > [keyword]
95 95 > ** =
96 96 > b = ignore
97 97 > i = ignore
98 98 > [hooks]
99 99 > EOF
100 100 $ cp $HGRCPATH $HGRCPATH.nohooks
101 101 > cat <<EOF >> $HGRCPATH
102 102 > commit=
103 103 > commit.test=cp a hooktest
104 104 > EOF
105 105
106 106 $ hg init Test-bndl
107 107 $ cd Test-bndl
108 108
109 109 kwshrink should exit silently in empty/invalid repo
110 110
111 111 $ hg kwshrink
112 112
113 113 Symlinks cannot be created on Windows.
114 114 A bundle to test this was made with:
115 115 hg init t
116 116 cd t
117 117 echo a > a
118 118 ln -s a sym
119 119 hg add sym
120 120 hg ci -m addsym -u mercurial
121 121 hg bundle --base null ../test-keyword.hg
122 122
123 123 $ hg unbundle "$TESTDIR"/bundles/test-keyword.hg
124 124 adding changesets
125 125 adding manifests
126 126 adding file changes
127 127 added 1 changesets with 1 changes to 1 files
128 128 new changesets a2392c293916 (1 drafts)
129 129 (run 'hg update' to get a working copy)
130 130 $ hg up a2392c293916
131 131 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 132
133 133 $ echo 'expand $Id$' > a
134 134 $ echo 'do not process $Id:' >> a
135 135 $ echo 'xxx $' >> a
136 136 $ echo 'ignore $Id$' > b
137 137
138 138 Output files as they were created
139 139
140 140 $ cat a b
141 141 expand $Id$
142 142 do not process $Id:
143 143 xxx $
144 144 ignore $Id$
145 145
146 146 no kwfiles
147 147
148 148 $ hg kwfiles
149 149
150 150 untracked candidates
151 151
152 152 $ hg -v kwfiles --unknown
153 153 k a
154 154
155 155 Add files and check status
156 156
157 157 $ hg addremove
158 158 adding a
159 159 adding b
160 160 $ hg status
161 161 A a
162 162 A b
163 163
164 164
165 165 Default keyword expansion including commit hook
166 166 Interrupted commit should not change state or run commit hook
167 167
168 168 $ hg --debug commit
169 169 abort: empty commit message
170 170 [255]
171 171 $ hg status
172 172 A a
173 173 A b
174 174
175 175 Commit with several checks
176 176
177 177 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
178 178 committing files:
179 179 a
180 180 b
181 181 committing manifest
182 182 committing changelog
183 183 overwriting a expanding keywords
184 184 updating the branch cache
185 185 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
186 186 running hook commit.test: cp a hooktest
187 187 $ hg status
188 188 ? hooktest
189 189 $ hg debugrebuildstate
190 190 $ hg --quiet identify
191 191 ef63ca68695b
192 192
193 193 cat files in working directory with keywords expanded
194 194
195 195 $ cat a b
196 196 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
197 197 do not process $Id:
198 198 xxx $
199 199 ignore $Id$
200 200
201 201 hg cat files and symlink, no expansion
202 202
203 203 $ hg cat sym a b && echo
204 204 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
205 205 do not process $Id:
206 206 xxx $
207 207 ignore $Id$
208 208 a
209 209
210 210 $ diff a hooktest
211 211
212 212 $ cp $HGRCPATH.nohooks $HGRCPATH
213 213 $ rm hooktest
214 214
215 215 hg status of kw-ignored binary file starting with '\1\n'
216 216
217 217 >>> open("i", "wb").write("\1\nfoo") and None
218 218 $ hg -q commit -Am metasep i
219 219 $ hg status
220 >>> open("i", "wb").write("\1\nbar")
220 >>> open("i", "wb").write("\1\nbar") and None
221 221 $ hg status
222 222 M i
223 223 $ hg -q commit -m "modify metasep" i
224 224 $ hg status --rev 2:3
225 225 M i
226 226 $ touch empty
227 227 $ hg -q commit -A -m "another file"
228 228 $ hg status -A --rev 3:4 i
229 229 C i
230 230
231 231 $ hg -q strip --no-backup 2
232 232
233 233 Test hook execution
234 234
235 235 bundle
236 236
237 237 $ hg bundle --base null ../kw.hg
238 238 2 changesets found
239 239 $ cd ..
240 240 $ hg init Test
241 241 $ cd Test
242 242
243 243 Notify on pull to check whether keywords stay as is in email
244 244 ie. if patch.diff wrapper acts as it should
245 245
246 246 $ cat <<EOF >> $HGRCPATH
247 247 > [hooks]
248 248 > incoming.notify = python:hgext.notify.hook
249 249 > [notify]
250 250 > sources = pull
251 251 > diffstat = False
252 252 > maxsubject = 15
253 253 > [reposubs]
254 254 > * = Test
255 255 > EOF
256 256
257 257 Pull from bundle and trigger notify
258 258
259 259 $ hg pull -u ../kw.hg
260 260 pulling from ../kw.hg
261 261 requesting all changes
262 262 adding changesets
263 263 adding manifests
264 264 adding file changes
265 265 added 2 changesets with 3 changes to 3 files
266 266 new changesets a2392c293916:ef63ca68695b (2 drafts)
267 267 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
268 268 MIME-Version: 1.0
269 269 Content-Type: text/plain; charset="us-ascii"
270 270 Content-Transfer-Encoding: 7bit
271 271 Date: * (glob)
272 272 Subject: changeset in...
273 273 From: mercurial
274 274 X-Hg-Notification: changeset a2392c293916
275 275 Message-Id: <hg.a2392c293916*> (glob)
276 276 To: Test
277 277
278 278 changeset a2392c293916 in $TESTTMP/Test
279 279 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
280 280 description:
281 281 addsym
282 282
283 283 diffs (6 lines):
284 284
285 285 diff -r 000000000000 -r a2392c293916 sym
286 286 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
287 287 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
288 288 @@ -0,0 +1,1 @@
289 289 +a
290 290 \ No newline at end of file
291 291 MIME-Version: 1.0
292 292 Content-Type: text/plain; charset="us-ascii"
293 293 Content-Transfer-Encoding: 7bit
294 294 Date:* (glob)
295 295 Subject: changeset in...
296 296 From: User Name <user@example.com>
297 297 X-Hg-Notification: changeset ef63ca68695b
298 298 Message-Id: <hg.ef63ca68695b*> (glob)
299 299 To: Test
300 300
301 301 changeset ef63ca68695b in $TESTTMP/Test
302 302 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
303 303 description:
304 304 absym
305 305
306 306 diffs (12 lines):
307 307
308 308 diff -r a2392c293916 -r ef63ca68695b a
309 309 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
310 310 +++ b/a Thu Jan 01 00:00:00 1970 +0000
311 311 @@ -0,0 +1,3 @@
312 312 +expand $Id$
313 313 +do not process $Id:
314 314 +xxx $
315 315 diff -r a2392c293916 -r ef63ca68695b b
316 316 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
317 317 +++ b/b Thu Jan 01 00:00:00 1970 +0000
318 318 @@ -0,0 +1,1 @@
319 319 +ignore $Id$
320 320
321 321 $ cp $HGRCPATH.nohooks $HGRCPATH
322 322
323 323 Touch files and check with status
324 324
325 325 $ touch a b
326 326 $ hg status
327 327
328 328 Update and expand
329 329
330 330 $ rm sym a b
331 331 $ hg update -C
332 332 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 333 $ cat a b
334 334 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
335 335 do not process $Id:
336 336 xxx $
337 337 ignore $Id$
338 338
339 339 Check whether expansion is filewise and file mode is preserved
340 340
341 341 $ echo '$Id$' > c
342 342 $ echo 'tests for different changenodes' >> c
343 343 #if unix-permissions
344 344 $ chmod 600 c
345 345 $ ls -l c | cut -b 1-10
346 346 -rw-------
347 347 #endif
348 348
349 349 commit file c
350 350
351 351 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
352 352 adding c
353 353 #if unix-permissions
354 354 $ ls -l c | cut -b 1-10
355 355 -rw-------
356 356 #endif
357 357
358 358 force expansion
359 359
360 360 $ hg -v kwexpand
361 361 overwriting a expanding keywords
362 362 overwriting c expanding keywords
363 363
364 364 compare changenodes in a and c
365 365
366 366 $ cat a c
367 367 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
368 368 do not process $Id:
369 369 xxx $
370 370 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
371 371 tests for different changenodes
372 372
373 373 record
374 374
375 375 $ echo '$Id$' > r
376 376 $ hg add r
377 377
378 378 record chunk
379 379
380 380 >>> lines = open('a', 'rb').readlines()
381 381 >>> lines.insert(1, 'foo\n')
382 382 >>> lines.append('bar\n')
383 383 >>> open('a', 'wb').writelines(lines)
384 384 $ hg record -d '10 1' -m rectest a<<EOF
385 385 > y
386 386 > y
387 387 > n
388 388 > EOF
389 389 diff --git a/a b/a
390 390 2 hunks, 2 lines changed
391 391 examine changes to 'a'? [Ynesfdaq?] y
392 392
393 393 @@ -1,3 +1,4 @@
394 394 expand $Id$
395 395 +foo
396 396 do not process $Id:
397 397 xxx $
398 398 record change 1/2 to 'a'? [Ynesfdaq?] y
399 399
400 400 @@ -2,2 +3,3 @@
401 401 do not process $Id:
402 402 xxx $
403 403 +bar
404 404 record change 2/2 to 'a'? [Ynesfdaq?] n
405 405
406 406
407 407 $ hg identify
408 408 5f5eb23505c3+ tip
409 409 $ hg status
410 410 M a
411 411 A r
412 412
413 413 Cat modified file a
414 414
415 415 $ cat a
416 416 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
417 417 foo
418 418 do not process $Id:
419 419 xxx $
420 420 bar
421 421
422 422 Diff remaining chunk
423 423
424 424 $ hg diff a
425 425 diff -r 5f5eb23505c3 a
426 426 --- a/a Thu Jan 01 00:00:09 1970 -0000
427 427 +++ b/a * (glob)
428 428 @@ -2,3 +2,4 @@
429 429 foo
430 430 do not process $Id:
431 431 xxx $
432 432 +bar
433 433
434 434 $ hg rollback
435 435 repository tip rolled back to revision 2 (undo commit)
436 436 working directory now based on revision 2
437 437
438 438 Record all chunks in file a
439 439
440 440 $ echo foo > msg
441 441
442 442 - do not use "hg record -m" here!
443 443
444 444 $ hg record -l msg -d '11 1' a<<EOF
445 445 > y
446 446 > y
447 447 > y
448 448 > EOF
449 449 diff --git a/a b/a
450 450 2 hunks, 2 lines changed
451 451 examine changes to 'a'? [Ynesfdaq?] y
452 452
453 453 @@ -1,3 +1,4 @@
454 454 expand $Id$
455 455 +foo
456 456 do not process $Id:
457 457 xxx $
458 458 record change 1/2 to 'a'? [Ynesfdaq?] y
459 459
460 460 @@ -2,2 +3,3 @@
461 461 do not process $Id:
462 462 xxx $
463 463 +bar
464 464 record change 2/2 to 'a'? [Ynesfdaq?] y
465 465
466 466
467 467 File a should be clean
468 468
469 469 $ hg status -A a
470 470 C a
471 471
472 472 rollback and revert expansion
473 473
474 474 $ cat a
475 475 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
476 476 foo
477 477 do not process $Id:
478 478 xxx $
479 479 bar
480 480 $ hg --verbose rollback
481 481 repository tip rolled back to revision 2 (undo commit)
482 482 working directory now based on revision 2
483 483 overwriting a expanding keywords
484 484 $ hg status a
485 485 M a
486 486 $ cat a
487 487 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
488 488 foo
489 489 do not process $Id:
490 490 xxx $
491 491 bar
492 492 $ echo '$Id$' > y
493 493 $ echo '$Id$' > z
494 494 $ hg add y
495 495 $ hg commit -Am "rollback only" z
496 496 $ cat z
497 497 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
498 498 $ hg --verbose rollback
499 499 repository tip rolled back to revision 2 (undo commit)
500 500 working directory now based on revision 2
501 501 overwriting z shrinking keywords
502 502
503 503 Only z should be overwritten
504 504
505 505 $ hg status a y z
506 506 M a
507 507 A y
508 508 A z
509 509 $ cat z
510 510 $Id$
511 511 $ hg forget y z
512 512 $ rm y z
513 513
514 514 record added file alone
515 515
516 516 $ hg -v record -l msg -d '12 2' r<<EOF
517 517 > y
518 518 > y
519 519 > EOF
520 520 diff --git a/r b/r
521 521 new file mode 100644
522 522 examine changes to 'r'? [Ynesfdaq?] y
523 523
524 524 @@ -0,0 +1,1 @@
525 525 +$Id$
526 526 record this change to 'r'? [Ynesfdaq?] y
527 527
528 528 resolving manifests
529 529 patching file r
530 530 committing files:
531 531 r
532 532 committing manifest
533 533 committing changelog
534 534 committed changeset 3:82a2f715724d
535 535 overwriting r expanding keywords
536 536 $ hg status r
537 537 $ hg --verbose rollback
538 538 repository tip rolled back to revision 2 (undo commit)
539 539 working directory now based on revision 2
540 540 overwriting r shrinking keywords
541 541 $ hg forget r
542 542 $ rm msg r
543 543 $ hg update -C
544 544 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
545 545
546 546 record added keyword ignored file
547 547
548 548 $ echo '$Id$' > i
549 549 $ hg add i
550 550 $ hg --verbose record -d '13 1' -m recignored<<EOF
551 551 > y
552 552 > y
553 553 > EOF
554 554 diff --git a/i b/i
555 555 new file mode 100644
556 556 examine changes to 'i'? [Ynesfdaq?] y
557 557
558 558 @@ -0,0 +1,1 @@
559 559 +$Id$
560 560 record this change to 'i'? [Ynesfdaq?] y
561 561
562 562 resolving manifests
563 563 patching file i
564 564 committing files:
565 565 i
566 566 committing manifest
567 567 committing changelog
568 568 committed changeset 3:9f40ceb5a072
569 569 $ cat i
570 570 $Id$
571 571 $ hg -q rollback
572 572 $ hg forget i
573 573 $ rm i
574 574
575 575 amend
576 576
577 577 $ echo amend >> a
578 578 $ echo amend >> b
579 579 $ hg -q commit -d '14 1' -m 'prepare amend'
580 580
581 581 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
582 582 overwriting a expanding keywords
583 583 $ hg -q id
584 584 67d8c481a6be
585 585 $ head -1 a
586 586 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
587 587
588 588 $ hg -q strip --no-backup tip
589 589
590 590 Test patch queue repo
591 591
592 592 $ hg init --mq
593 593 $ hg qimport -r tip -n mqtest.diff
594 594 $ hg commit --mq -m mqtest
595 595
596 596 Keywords should not be expanded in patch
597 597
598 598 $ cat .hg/patches/mqtest.diff
599 599 # HG changeset patch
600 600 # User User Name <user@example.com>
601 601 # Date 1 0
602 602 # Thu Jan 01 00:00:01 1970 +0000
603 603 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
604 604 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
605 605 cndiff
606 606
607 607 diff -r ef63ca68695b -r 40a904bbbe4c c
608 608 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
609 609 +++ b/c Thu Jan 01 00:00:01 1970 +0000
610 610 @@ -0,0 +1,2 @@
611 611 +$Id$
612 612 +tests for different changenodes
613 613
614 614 $ hg qpop
615 615 popping mqtest.diff
616 616 patch queue now empty
617 617
618 618 qgoto, implying qpush, should expand
619 619
620 620 $ hg qgoto mqtest.diff
621 621 applying mqtest.diff
622 622 now at: mqtest.diff
623 623 $ cat c
624 624 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
625 625 tests for different changenodes
626 626 $ hg cat c
627 627 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
628 628 tests for different changenodes
629 629
630 630 Keywords should not be expanded in filelog
631 631
632 632 $ hg --config 'extensions.keyword=!' cat c
633 633 $Id$
634 634 tests for different changenodes
635 635
636 636 qpop and move on
637 637
638 638 $ hg qpop
639 639 popping mqtest.diff
640 640 patch queue now empty
641 641
642 642 Copy and show added kwfiles
643 643
644 644 $ hg cp a c
645 645 $ hg kwfiles
646 646 a
647 647 c
648 648
649 649 Commit and show expansion in original and copy
650 650
651 651 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
652 652 committing files:
653 653 c
654 654 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
655 655 committing manifest
656 656 committing changelog
657 657 overwriting c expanding keywords
658 658 updating the branch cache
659 659 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
660 660 $ cat a c
661 661 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
662 662 do not process $Id:
663 663 xxx $
664 664 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
665 665 do not process $Id:
666 666 xxx $
667 667
668 668 Touch copied c and check its status
669 669
670 670 $ touch c
671 671 $ hg status
672 672
673 673 Copy kwfile to keyword ignored file unexpanding keywords
674 674
675 675 $ hg --verbose copy a i
676 676 copying a to i
677 677 overwriting i shrinking keywords
678 678 $ head -n 1 i
679 679 expand $Id$
680 680 $ hg forget i
681 681 $ rm i
682 682
683 683 Copy ignored file to ignored file: no overwriting
684 684
685 685 $ hg --verbose copy b i
686 686 copying b to i
687 687 $ hg forget i
688 688 $ rm i
689 689
690 690 cp symlink file; hg cp -A symlink file (part1)
691 691 - copied symlink points to kwfile: overwrite
692 692
693 693 #if symlink
694 694 $ cp sym i
695 695 $ ls -l i
696 696 -rw-r--r--* (glob)
697 697 $ head -1 i
698 698 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
699 699 $ hg copy --after --verbose sym i
700 700 copying sym to i
701 701 overwriting i shrinking keywords
702 702 $ head -1 i
703 703 expand $Id$
704 704 $ hg forget i
705 705 $ rm i
706 706 #endif
707 707
708 708 Test different options of hg kwfiles
709 709
710 710 $ hg kwfiles
711 711 a
712 712 c
713 713 $ hg -v kwfiles --ignore
714 714 I b
715 715 I sym
716 716 $ hg kwfiles --all
717 717 K a
718 718 K c
719 719 I b
720 720 I sym
721 721
722 722 Diff specific revision
723 723
724 724 $ hg diff --rev 1
725 725 diff -r ef63ca68695b c
726 726 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
727 727 +++ b/c * (glob)
728 728 @@ -0,0 +1,3 @@
729 729 +expand $Id$
730 730 +do not process $Id:
731 731 +xxx $
732 732
733 733 Status after rollback:
734 734
735 735 $ hg rollback
736 736 repository tip rolled back to revision 1 (undo commit)
737 737 working directory now based on revision 1
738 738 $ hg status
739 739 A c
740 740 $ hg update --clean
741 741 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
742 742
743 743 #if symlink
744 744
745 745 cp symlink file; hg cp -A symlink file (part2)
746 746 - copied symlink points to kw ignored file: do not overwrite
747 747
748 748 $ cat a > i
749 749 $ ln -s i symignored
750 750 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
751 751 $ cp symignored x
752 752 $ hg copy --after --verbose symignored x
753 753 copying symignored to x
754 754 $ head -n 1 x
755 755 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
756 756 $ hg forget x
757 757 $ rm x
758 758
759 759 $ hg rollback
760 760 repository tip rolled back to revision 1 (undo commit)
761 761 working directory now based on revision 1
762 762 $ hg update --clean
763 763 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
764 764 $ rm i symignored
765 765
766 766 #endif
767 767
768 768 Custom keywordmaps as argument to kwdemo
769 769
770 770 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
771 771 [extensions]
772 772 keyword =
773 773 [keyword]
774 774 ** =
775 775 b = ignore
776 776 demo.txt =
777 777 i = ignore
778 778 [keywordset]
779 779 svn = False
780 780 [keywordmaps]
781 781 Xinfo = {author}: {desc}
782 782 $Xinfo: test: hg keyword configuration and expansion example $
783 783
784 784 Configure custom keywordmaps
785 785
786 786 $ cat <<EOF >>$HGRCPATH
787 787 > [keywordmaps]
788 788 > Id = {file} {node|short} {date|rfc822date} {author|user}
789 789 > Xinfo = {author}: {desc}
790 790 > EOF
791 791
792 792 Cat and hg cat files before custom expansion
793 793
794 794 $ cat a b
795 795 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
796 796 do not process $Id:
797 797 xxx $
798 798 ignore $Id$
799 799 $ hg cat sym a b && echo
800 800 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
801 801 do not process $Id:
802 802 xxx $
803 803 ignore $Id$
804 804 a
805 805
806 806 Write custom keyword and prepare multi-line commit message
807 807
808 808 $ echo '$Xinfo$' >> a
809 809 $ cat <<EOF >> log
810 810 > firstline
811 811 > secondline
812 812 > EOF
813 813
814 814 Interrupted commit should not change state
815 815
816 816 $ hg commit
817 817 abort: empty commit message
818 818 [255]
819 819 $ hg status
820 820 M a
821 821 ? c
822 822 ? log
823 823
824 824 Commit with multi-line message and custom expansion
825 825
826 826 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
827 827 committing files:
828 828 a
829 829 committing manifest
830 830 committing changelog
831 831 overwriting a expanding keywords
832 832 updating the branch cache
833 833 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
834 834 $ rm log
835 835
836 836 Stat, verify and show custom expansion (firstline)
837 837
838 838 $ hg status
839 839 ? c
840 840 $ hg verify
841 841 checking changesets
842 842 checking manifests
843 843 crosschecking files in changesets and manifests
844 844 checking files
845 845 checked 3 changesets with 4 changes to 3 files
846 846 $ cat a b
847 847 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
848 848 do not process $Id:
849 849 xxx $
850 850 $Xinfo: User Name <user@example.com>: firstline $
851 851 ignore $Id$
852 852 $ hg cat sym a b && echo
853 853 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
854 854 do not process $Id:
855 855 xxx $
856 856 $Xinfo: User Name <user@example.com>: firstline $
857 857 ignore $Id$
858 858 a
859 859
860 860 annotate
861 861
862 862 $ hg annotate a
863 863 1: expand $Id$
864 864 1: do not process $Id:
865 865 1: xxx $
866 866 2: $Xinfo$
867 867
868 868 remove with status checks
869 869
870 870 $ hg debugrebuildstate
871 871 $ hg remove a
872 872 $ hg --debug commit -m rma
873 873 committing files:
874 874 committing manifest
875 875 committing changelog
876 876 updating the branch cache
877 877 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
878 878 $ hg status
879 879 ? c
880 880
881 881 Rollback, revert, and check expansion
882 882
883 883 $ hg rollback
884 884 repository tip rolled back to revision 2 (undo commit)
885 885 working directory now based on revision 2
886 886 $ hg status
887 887 R a
888 888 ? c
889 889 $ hg revert --no-backup --rev tip a
890 890 $ cat a
891 891 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
892 892 do not process $Id:
893 893 xxx $
894 894 $Xinfo: User Name <user@example.com>: firstline $
895 895
896 896 Clone to test global and local configurations
897 897
898 898 $ cd ..
899 899
900 900 Expansion in destination with global configuration
901 901
902 902 $ hg --quiet clone Test globalconf
903 903 $ cat globalconf/a
904 904 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
905 905 do not process $Id:
906 906 xxx $
907 907 $Xinfo: User Name <user@example.com>: firstline $
908 908
909 909 No expansion in destination with local configuration in origin only
910 910
911 911 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
912 912 $ cat localconf/a
913 913 expand $Id$
914 914 do not process $Id:
915 915 xxx $
916 916 $Xinfo$
917 917
918 918 Clone to test incoming
919 919
920 920 $ hg clone -r1 Test Test-a
921 921 adding changesets
922 922 adding manifests
923 923 adding file changes
924 924 added 2 changesets with 3 changes to 3 files
925 925 new changesets a2392c293916:ef63ca68695b
926 926 updating to branch default
927 927 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
928 928 $ cd Test-a
929 929 $ cat <<EOF >> .hg/hgrc
930 930 > [paths]
931 931 > default = ../Test
932 932 > EOF
933 933 $ hg incoming
934 934 comparing with $TESTTMP/Test
935 935 searching for changes
936 936 changeset: 2:bb948857c743
937 937 tag: tip
938 938 user: User Name <user@example.com>
939 939 date: Thu Jan 01 00:00:02 1970 +0000
940 940 summary: firstline
941 941
942 942 Imported patch should not be rejected
943 943
944 944 >>> import re
945 945 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
946 >>> open('a', 'wb').write(text)
946 >>> open('a', 'wb').write(text) and None
947 947 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
948 948 committing files:
949 949 a
950 950 committing manifest
951 951 committing changelog
952 952 overwriting a expanding keywords
953 953 updating the branch cache
954 954 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
955 955 $ hg export -o ../rejecttest.diff tip
956 956 $ cd ../Test
957 957 $ hg import ../rejecttest.diff
958 958 applying ../rejecttest.diff
959 959 $ cat a b
960 960 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
961 961 do not process $Id: rejecttest
962 962 xxx $
963 963 $Xinfo: User Name <user@example.com>: rejects? $
964 964 ignore $Id$
965 965
966 966 $ hg rollback
967 967 repository tip rolled back to revision 2 (undo import)
968 968 working directory now based on revision 2
969 969 $ hg update --clean
970 970 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
971 971
972 972 kwexpand/kwshrink on selected files
973 973
974 974 $ mkdir x
975 975 $ hg copy a x/a
976 976 $ hg --verbose kwshrink a
977 977 overwriting a shrinking keywords
978 978 - sleep required for dirstate.normal() check
979 979 $ sleep 1
980 980 $ hg status a
981 981 $ hg --verbose kwexpand a
982 982 overwriting a expanding keywords
983 983 $ hg status a
984 984
985 985 kwexpand x/a should abort
986 986
987 987 $ hg --verbose kwexpand x/a
988 988 abort: outstanding uncommitted changes
989 989 [255]
990 990 $ cd x
991 991 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
992 992 committing files:
993 993 x/a
994 994 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
995 995 committing manifest
996 996 committing changelog
997 997 overwriting x/a expanding keywords
998 998 updating the branch cache
999 999 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
1000 1000 $ cat a
1001 1001 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
1002 1002 do not process $Id:
1003 1003 xxx $
1004 1004 $Xinfo: User Name <user@example.com>: xa $
1005 1005
1006 1006 kwshrink a inside directory x
1007 1007
1008 1008 $ hg --verbose kwshrink a
1009 1009 overwriting x/a shrinking keywords
1010 1010 $ cat a
1011 1011 expand $Id$
1012 1012 do not process $Id:
1013 1013 xxx $
1014 1014 $Xinfo$
1015 1015 $ cd ..
1016 1016
1017 1017 kwexpand nonexistent
1018 1018
1019 1019 $ hg kwexpand nonexistent
1020 1020 nonexistent:* (glob)
1021 1021
1022 1022
1023 1023 #if serve
1024 1024 hg serve
1025 1025 - expand with hgweb file
1026 1026 - no expansion with hgweb annotate/changeset/filediff/comparison
1027 1027 - expand with hgweb file, again
1028 1028 - check errors
1029 1029
1030 1030 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1031 1031 $ cat hg.pid >> $DAEMON_PIDS
1032 1032 $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
1033 1033 200 Script output follows
1034 1034
1035 1035 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1036 1036 do not process $Id:
1037 1037 xxx $
1038 1038 $Xinfo: User Name <user@example.com>: firstline $
1039 1039 $ get-with-headers.py localhost:$HGPORT 'annotate/tip/a/?style=raw'
1040 1040 200 Script output follows
1041 1041
1042 1042
1043 1043 user@1: expand $Id$
1044 1044 user@1: do not process $Id:
1045 1045 user@1: xxx $
1046 1046 user@2: $Xinfo$
1047 1047
1048 1048
1049 1049
1050 1050
1051 1051 $ get-with-headers.py localhost:$HGPORT 'rev/tip/?style=raw'
1052 1052 200 Script output follows
1053 1053
1054 1054
1055 1055 # HG changeset patch
1056 1056 # User User Name <user@example.com>
1057 1057 # Date 3 0
1058 1058 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
1059 1059 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
1060 1060 xa
1061 1061
1062 1062 diff -r bb948857c743 -r b4560182a3f9 x/a
1063 1063 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1064 1064 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
1065 1065 @@ -0,0 +1,4 @@
1066 1066 +expand $Id$
1067 1067 +do not process $Id:
1068 1068 +xxx $
1069 1069 +$Xinfo$
1070 1070
1071 1071 $ get-with-headers.py localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
1072 1072 200 Script output follows
1073 1073
1074 1074
1075 1075 diff -r ef63ca68695b -r bb948857c743 a
1076 1076 --- a/a Thu Jan 01 00:00:00 1970 +0000
1077 1077 +++ b/a Thu Jan 01 00:00:02 1970 +0000
1078 1078 @@ -1,3 +1,4 @@
1079 1079 expand $Id$
1080 1080 do not process $Id:
1081 1081 xxx $
1082 1082 +$Xinfo$
1083 1083
1084 1084
1085 1085
1086 1086
1087 1087 $ get-with-headers.py localhost:$HGPORT 'comparison/bb948857c743/a' | grep '\$[a-zA-Z]'
1088 1088 <td class="source equal"><a href="#l1r1"> 1</a> expand $Id$</td>
1089 1089 <td class="source equal"><a href="#l1r1"> 1</a> expand $Id$</td>
1090 1090 <td class="source equal"><a href="#l2r2"> 2</a> do not process $Id:</td>
1091 1091 <td class="source equal"><a href="#l2r2"> 2</a> do not process $Id:</td>
1092 1092 <td class="source insert"><a href="#r4"> 4</a> $Xinfo$</td>
1093 1093
1094 1094 (check "kwweb_skip"-ed webcommand doesn't suppress expanding keywords
1095 1095 at subsequent webcommands)
1096 1096
1097 1097 $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
1098 1098 200 Script output follows
1099 1099
1100 1100 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1101 1101 do not process $Id:
1102 1102 xxx $
1103 1103 $Xinfo: User Name <user@example.com>: firstline $
1104 1104
1105 1105 $ killdaemons.py
1106 1106 $ cat errors.log
1107 1107 #endif
1108 1108
1109 1109 Prepare merge and resolve tests
1110 1110
1111 1111 $ echo '$Id$' > m
1112 1112 $ hg add m
1113 1113 $ hg commit -m 4kw
1114 1114 $ echo foo >> m
1115 1115 $ hg commit -m 5foo
1116 1116
1117 1117 simplemerge
1118 1118
1119 1119 $ hg update 4
1120 1120 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1121 1121 $ echo foo >> m
1122 1122 $ hg commit -m 6foo
1123 1123 created new head
1124 1124 $ hg merge
1125 1125 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1126 1126 (branch merge, don't forget to commit)
1127 1127 $ hg commit -m simplemerge
1128 1128 $ cat m
1129 1129 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1130 1130 foo
1131 1131
1132 1132 conflict: keyword should stay outside conflict zone
1133 1133
1134 1134 $ hg update 4
1135 1135 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1136 1136 $ echo bar >> m
1137 1137 $ hg commit -m 8bar
1138 1138 created new head
1139 1139 $ hg merge
1140 1140 merging m
1141 1141 warning: conflicts while merging m! (edit, then use 'hg resolve --mark')
1142 1142 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1143 1143 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1144 1144 [1]
1145 1145 $ cat m
1146 1146 $Id$
1147 1147 <<<<<<< working copy: 88a80c8d172e - test: 8bar
1148 1148 bar
1149 1149 =======
1150 1150 foo
1151 1151 >>>>>>> merge rev: 85d2d2d732a5 - test: simplemerge
1152 1152
1153 1153 resolve to local, m must contain hash of last change (local parent)
1154 1154
1155 1155 $ hg resolve -t internal:local -a
1156 1156 (no more unresolved files)
1157 1157 $ hg commit -m localresolve
1158 1158 $ cat m
1159 1159 $Id: m 88a80c8d172e Thu, 01 Jan 1970 00:00:00 +0000 test $
1160 1160 bar
1161 1161
1162 1162 Test restricted mode with transplant -b
1163 1163
1164 1164 $ hg update 6
1165 1165 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1166 1166 $ hg branch foo
1167 1167 marked working directory as branch foo
1168 1168 (branches are permanent and global, did you want a bookmark?)
1169 1169 $ mv a a.bak
1170 1170 $ echo foobranch > a
1171 1171 $ cat a.bak >> a
1172 1172 $ rm a.bak
1173 1173 $ hg commit -m 9foobranch
1174 1174 $ hg update default
1175 1175 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1176 1176 $ hg -y transplant -b foo tip
1177 1177 applying 4aa30d025d50
1178 1178 4aa30d025d50 transplanted to e00abbf63521
1179 1179
1180 1180 Expansion in changeset but not in file
1181 1181
1182 1182 $ hg tip -p
1183 1183 changeset: 11:e00abbf63521
1184 1184 tag: tip
1185 1185 parent: 9:800511b3a22d
1186 1186 user: test
1187 1187 date: Thu Jan 01 00:00:00 1970 +0000
1188 1188 summary: 9foobranch
1189 1189
1190 1190 diff -r 800511b3a22d -r e00abbf63521 a
1191 1191 --- a/a Thu Jan 01 00:00:00 1970 +0000
1192 1192 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1193 1193 @@ -1,3 +1,4 @@
1194 1194 +foobranch
1195 1195 expand $Id$
1196 1196 do not process $Id:
1197 1197 xxx $
1198 1198
1199 1199 $ head -n 2 a
1200 1200 foobranch
1201 1201 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1202 1202
1203 1203 Turn off expansion
1204 1204
1205 1205 $ hg -q rollback
1206 1206 $ hg -q update -C
1207 1207
1208 1208 kwshrink with unknown file u
1209 1209
1210 1210 $ cp a u
1211 1211 $ hg --verbose kwshrink
1212 1212 overwriting a shrinking keywords
1213 1213 overwriting m shrinking keywords
1214 1214 overwriting x/a shrinking keywords
1215 1215
1216 1216 Keywords shrunk in working directory, but not yet disabled
1217 1217 - cat shows unexpanded keywords
1218 1218 - hg cat shows expanded keywords
1219 1219
1220 1220 $ cat a b
1221 1221 expand $Id$
1222 1222 do not process $Id:
1223 1223 xxx $
1224 1224 $Xinfo$
1225 1225 ignore $Id$
1226 1226 $ hg cat sym a b && echo
1227 1227 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1228 1228 do not process $Id:
1229 1229 xxx $
1230 1230 $Xinfo: User Name <user@example.com>: firstline $
1231 1231 ignore $Id$
1232 1232 a
1233 1233
1234 1234 Now disable keyword expansion
1235 1235
1236 1236 $ cp $HGRCPATH $HGRCPATH.backup
1237 1237 $ rm "$HGRCPATH"
1238 1238 $ cat a b
1239 1239 expand $Id$
1240 1240 do not process $Id:
1241 1241 xxx $
1242 1242 $Xinfo$
1243 1243 ignore $Id$
1244 1244 $ hg cat sym a b && echo
1245 1245 expand $Id$
1246 1246 do not process $Id:
1247 1247 xxx $
1248 1248 $Xinfo$
1249 1249 ignore $Id$
1250 1250 a
1251 1251
1252 1252 enable keyword expansion again
1253 1253
1254 1254 $ cat $HGRCPATH.backup >> $HGRCPATH
1255 1255
1256 1256 Test restricted mode with unshelve
1257 1257
1258 1258 $ cat <<EOF >> $HGRCPATH
1259 1259 > [extensions]
1260 1260 > shelve =
1261 1261 > EOF
1262 1262
1263 1263 $ echo xxxx >> a
1264 1264 $ hg diff
1265 1265 diff -r 800511b3a22d a
1266 1266 --- a/a Thu Jan 01 00:00:00 1970 +0000
1267 1267 +++ b/a * (glob)
1268 1268 @@ -2,3 +2,4 @@
1269 1269 do not process $Id:
1270 1270 xxx $
1271 1271 $Xinfo$
1272 1272 +xxxx
1273 1273 $ hg shelve -q --name tmp
1274 1274 $ hg shelve --list --patch
1275 1275 tmp (*)* changes to: localresolve (glob)
1276 1276
1277 1277 diff --git a/a b/a
1278 1278 --- a/a
1279 1279 +++ b/a
1280 1280 @@ -2,3 +2,4 @@
1281 1281 do not process $Id:
1282 1282 xxx $
1283 1283 $Xinfo$
1284 1284 +xxxx
1285 1285
1286 1286 $ hg update -q -C 10
1287 1287 $ hg unshelve -q tmp
1288 1288 $ hg diff
1289 1289 diff -r 4aa30d025d50 a
1290 1290 --- a/a Thu Jan 01 00:00:00 1970 +0000
1291 1291 +++ b/a * (glob)
1292 1292 @@ -3,3 +3,4 @@
1293 1293 do not process $Id:
1294 1294 xxx $
1295 1295 $Xinfo$
1296 1296 +xxxx
1297 1297
1298 1298 Test restricted mode with rebase
1299 1299
1300 1300 $ cat <<EOF >> $HGRCPATH
1301 1301 > [extensions]
1302 1302 > rebase =
1303 1303 > EOF
1304 1304
1305 1305 $ hg update -q -C 9
1306 1306
1307 1307 $ echo xxxx >> a
1308 1308 $ hg commit -m '#11'
1309 1309 $ hg diff -c 11
1310 1310 diff -r 800511b3a22d -r b07670694489 a
1311 1311 --- a/a Thu Jan 01 00:00:00 1970 +0000
1312 1312 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1313 1313 @@ -2,3 +2,4 @@
1314 1314 do not process $Id:
1315 1315 xxx $
1316 1316 $Xinfo$
1317 1317 +xxxx
1318 1318
1319 1319 $ hg diff -c 10
1320 1320 diff -r 27d48ee14f67 -r 4aa30d025d50 a
1321 1321 --- a/a Thu Jan 01 00:00:00 1970 +0000
1322 1322 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1323 1323 @@ -1,3 +1,4 @@
1324 1324 +foobranch
1325 1325 expand $Id$
1326 1326 do not process $Id:
1327 1327 xxx $
1328 1328
1329 1329 $ hg rebase -q -s 10 -d 11 --keep
1330 1330 $ hg diff -r 9 -r 12 a
1331 1331 diff -r 800511b3a22d -r 1939b927726c a
1332 1332 --- a/a Thu Jan 01 00:00:00 1970 +0000
1333 1333 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1334 1334 @@ -1,4 +1,6 @@
1335 1335 +foobranch
1336 1336 expand $Id$
1337 1337 do not process $Id:
1338 1338 xxx $
1339 1339 $Xinfo$
1340 1340 +xxxx
1341 1341
1342 1342 Test restricted mode with graft
1343 1343
1344 1344 $ hg graft -q 10
1345 1345 $ hg diff -r 9 -r 13 a
1346 1346 diff -r 800511b3a22d -r 01a68de1003a a
1347 1347 --- a/a Thu Jan 01 00:00:00 1970 +0000
1348 1348 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1349 1349 @@ -1,4 +1,6 @@
1350 1350 +foobranch
1351 1351 expand $Id$
1352 1352 do not process $Id:
1353 1353 xxx $
1354 1354 $Xinfo$
1355 1355 +xxxx
1356 1356
1357 1357 Test restricted mode with backout
1358 1358
1359 1359 $ hg backout -q 11 --no-commit
1360 1360 $ hg diff a
1361 1361 diff -r 01a68de1003a a
1362 1362 --- a/a Thu Jan 01 00:00:00 1970 +0000
1363 1363 +++ b/a * (glob)
1364 1364 @@ -3,4 +3,3 @@
1365 1365 do not process $Id:
1366 1366 xxx $
1367 1367 $Xinfo$
1368 1368 -xxxx
1369 1369
1370 1370 Test restricted mode with histedit
1371 1371
1372 1372 $ cat <<EOF >> $HGRCPATH
1373 1373 > [extensions]
1374 1374 > histedit =
1375 1375 > EOF
1376 1376
1377 1377 $ hg commit -m 'backout #11'
1378 1378 $ hg histedit -q --command - 13 <<EOF
1379 1379 > pick 49f5f2d940c3 14 backout #11
1380 1380 > pick 01a68de1003a 13 9foobranch
1381 1381 > EOF
1382 1382
1383 1383 Test restricted mode with fetch (with merge)
1384 1384
1385 1385 $ cat <<EOF >> $HGRCPATH
1386 1386 > [extensions]
1387 1387 > fetch =
1388 1388 > EOF
1389 1389
1390 1390 $ hg clone -q -r 9 . ../fetch-merge
1391 1391 $ cd ../fetch-merge
1392 1392 $ hg -R ../Test export 10 | hg import -q -
1393 1393 $ hg fetch -q -r 11
1394 1394 $ hg diff -r 9 a
1395 1395 diff -r 800511b3a22d a
1396 1396 --- a/a Thu Jan 01 00:00:00 1970 +0000
1397 1397 +++ b/a * (glob)
1398 1398 @@ -1,4 +1,6 @@
1399 1399 +foobranch
1400 1400 expand $Id$
1401 1401 do not process $Id:
1402 1402 xxx $
1403 1403 $Xinfo$
1404 1404 +xxxx
1405 1405
1406 1406 Test that patch.diff(), which is implied by "hg diff" or so, doesn't
1407 1407 suppress expanding keywords at subsequent commands
1408 1408
1409 1409 #if windows
1410 1410 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
1411 1411 #else
1412 1412 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
1413 1413 #endif
1414 1414 $ export PYTHONPATH
1415 1415
1416 1416 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
1417 1417 $ mv $HGRCPATH.new $HGRCPATH
1418 1418
1419 1419 >>> from __future__ import print_function
1420 1420 >>> from hgclient import check, readchannel, runcommand
1421 1421 >>> @check
1422 1422 ... def check(server):
1423 1423 ... # hello block
1424 1424 ... readchannel(server)
1425 1425 ...
1426 1426 ... runcommand(server, ['cat', 'm'])
1427 1427 ... runcommand(server, ['diff', '-c', '.', 'm'])
1428 1428 ... runcommand(server, ['cat', 'm'])
1429 1429 *** runcommand cat m
1430 1430 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1431 1431 bar
1432 1432 *** runcommand diff -c . m
1433 1433 *** runcommand cat m
1434 1434 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1435 1435 bar
1436 1436
1437 1437 $ cd ..
1438 1438
1439 1439 #if serve
1440 1440
1441 1441 Test that keywords are expanded only in repositories, which enable
1442 1442 keyword extension, even if multiple repositories are served in a
1443 1443 process
1444 1444
1445 1445 $ cat >> fetch-merge/.hg/hgrc <<EOF
1446 1446 > [extensions]
1447 1447 > keyword = !
1448 1448 > EOF
1449 1449
1450 1450 $ cat > paths.conf <<EOF
1451 1451 > [paths]
1452 1452 > enabled=Test
1453 1453 > disabled=fetch-merge
1454 1454 > EOF
1455 1455
1456 1456 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E error.log --webdir-conf paths.conf
1457 1457 $ cat hg.pid >> $DAEMON_PIDS
1458 1458
1459 1459 $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
1460 1460 200 Script output follows
1461 1461
1462 1462 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1463 1463 bar
1464 1464
1465 1465 $ get-with-headers.py localhost:$HGPORT 'disabled/file/tip/m/?style=raw'
1466 1466 200 Script output follows
1467 1467
1468 1468 $Id$
1469 1469 bar
1470 1470
1471 1471 (check expansion again, for safety)
1472 1472
1473 1473 $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
1474 1474 200 Script output follows
1475 1475
1476 1476 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1477 1477 bar
1478 1478
1479 1479 $ killdaemons.py
1480 1480 #endif
@@ -1,464 +1,464 b''
1 1 #testcases sshv1 sshv2
2 2
3 3 #if sshv2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [experimental]
6 6 > sshpeer.advertise-v2 = true
7 7 > sshserver.support-v2 = true
8 8 > EOF
9 9 #endif
10 10
11 11 This file contains testcases that tend to be related to the wire protocol part
12 12 of largefiles.
13 13
14 14 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
15 15 $ mkdir "${USERCACHE}"
16 16 $ cat >> $HGRCPATH <<EOF
17 17 > [extensions]
18 18 > largefiles=
19 19 > purge=
20 20 > rebase=
21 21 > transplant=
22 22 > [phases]
23 23 > publish=False
24 24 > [largefiles]
25 25 > minsize=2
26 26 > patterns=glob:**.dat
27 27 > usercache=${USERCACHE}
28 28 > [web]
29 29 > allow-archive = zip
30 30 > [hooks]
31 31 > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status"
32 32 > EOF
33 33
34 34
35 35 #if serve
36 36 vanilla clients not locked out from largefiles servers on vanilla repos
37 37 $ mkdir r1
38 38 $ cd r1
39 39 $ hg init
40 40 $ echo c1 > f1
41 41 $ hg add f1
42 42 $ hg commit -m "m1"
43 43 Invoking status precommit hook
44 44 A f1
45 45 $ cd ..
46 46 $ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid
47 47 $ cat hg.pid >> $DAEMON_PIDS
48 48 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2
49 49 requesting all changes
50 50 adding changesets
51 51 adding manifests
52 52 adding file changes
53 53 added 1 changesets with 1 changes to 1 files
54 54 new changesets b6eb3a2e2efe (1 drafts)
55 55 updating to branch default
56 56 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
57 57
58 58 largefiles clients still work with vanilla servers
59 59 $ hg serve --config extensions.largefiles=! -R r1 -d -p $HGPORT1 --pid-file hg.pid
60 60 $ cat hg.pid >> $DAEMON_PIDS
61 61 $ hg clone http://localhost:$HGPORT1 r3
62 62 requesting all changes
63 63 adding changesets
64 64 adding manifests
65 65 adding file changes
66 66 added 1 changesets with 1 changes to 1 files
67 67 new changesets b6eb3a2e2efe (1 drafts)
68 68 updating to branch default
69 69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 70 #endif
71 71
72 72 vanilla clients locked out from largefiles http repos
73 73 $ mkdir r4
74 74 $ cd r4
75 75 $ hg init
76 76 $ echo c1 > f1
77 77 $ hg add --large f1
78 78 $ hg commit -m "m1"
79 79 Invoking status precommit hook
80 80 A f1
81 81 $ cd ..
82 82
83 83 largefiles can be pushed locally (issue3583)
84 84 $ hg init dest
85 85 $ cd r4
86 86 $ hg outgoing ../dest
87 87 comparing with ../dest
88 88 searching for changes
89 89 changeset: 0:639881c12b4c
90 90 tag: tip
91 91 user: test
92 92 date: Thu Jan 01 00:00:00 1970 +0000
93 93 summary: m1
94 94
95 95 $ hg push ../dest
96 96 pushing to ../dest
97 97 searching for changes
98 98 adding changesets
99 99 adding manifests
100 100 adding file changes
101 101 added 1 changesets with 1 changes to 1 files
102 102
103 103 exit code with nothing outgoing (issue3611)
104 104 $ hg outgoing ../dest
105 105 comparing with ../dest
106 106 searching for changes
107 107 no changes found
108 108 [1]
109 109 $ cd ..
110 110
111 111 #if serve
112 112 $ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid
113 113 $ cat hg.pid >> $DAEMON_PIDS
114 114 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5
115 115 abort: remote error:
116 116
117 117 This repository uses the largefiles extension.
118 118
119 119 Please enable it in your Mercurial config file.
120 120 [255]
121 121
122 122 used all HGPORTs, kill all daemons
123 123 $ killdaemons.py
124 124 #endif
125 125
126 126 vanilla clients locked out from largefiles ssh repos
127 127 $ hg --config extensions.largefiles=! clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/r4 r5
128 128 remote:
129 129 remote: This repository uses the largefiles extension.
130 130 remote:
131 131 remote: Please enable it in your Mercurial config file.
132 132 remote:
133 133 remote: -
134 134 abort: remote error
135 135 (check previous remote output)
136 136 [255]
137 137
138 138 #if serve
139 139
140 140 largefiles clients refuse to push largefiles repos to vanilla servers
141 141 $ mkdir r6
142 142 $ cd r6
143 143 $ hg init
144 144 $ echo c1 > f1
145 145 $ hg add f1
146 146 $ hg commit -m "m1"
147 147 Invoking status precommit hook
148 148 A f1
149 149 $ cat >> .hg/hgrc <<!
150 150 > [web]
151 151 > push_ssl = false
152 152 > allow_push = *
153 153 > !
154 154 $ cd ..
155 155 $ hg clone r6 r7
156 156 updating to branch default
157 157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 158 $ cd r7
159 159 $ echo c2 > f2
160 160 $ hg add --large f2
161 161 $ hg commit -m "m2"
162 162 Invoking status precommit hook
163 163 A f2
164 164 $ hg verify --large
165 165 checking changesets
166 166 checking manifests
167 167 crosschecking files in changesets and manifests
168 168 checking files
169 169 checked 2 changesets with 2 changes to 2 files
170 170 searching 1 changesets for largefiles
171 171 verified existence of 1 revisions of 1 largefiles
172 172 $ hg serve --config extensions.largefiles=! -R ../r6 -d -p $HGPORT --pid-file ../hg.pid
173 173 $ cat ../hg.pid >> $DAEMON_PIDS
174 174 $ hg push http://localhost:$HGPORT
175 175 pushing to http://localhost:$HGPORT/
176 176 searching for changes
177 177 abort: http://localhost:$HGPORT/ does not appear to be a largefile store
178 178 [255]
179 179 $ cd ..
180 180
181 181 putlfile errors are shown (issue3123)
182 182 Corrupt the cached largefile in r7 and move it out of the servers usercache
183 183 $ mv r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 .
184 184 $ echo 'client side corruption' > r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
185 185 $ rm "$USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8"
186 186 $ hg init empty
187 187 $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \
188 188 > --config 'web.allow_push=*' --config web.push_ssl=False
189 189 $ cat hg.pid >> $DAEMON_PIDS
190 190 $ hg push -R r7 http://localhost:$HGPORT1
191 191 pushing to http://localhost:$HGPORT1/
192 192 searching for changes
193 193 remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash
194 194 abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/
195 195 [255]
196 196 $ mv 4cdac4d8b084d0b599525cf732437fb337d422a8 r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
197 197 Push of file that exists on server but is corrupted - magic healing would be nice ... but too magic
198 198 $ echo "server side corruption" > empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
199 199 $ hg push -R r7 http://localhost:$HGPORT1
200 200 pushing to http://localhost:$HGPORT1/
201 201 searching for changes
202 202 remote: adding changesets
203 203 remote: adding manifests
204 204 remote: adding file changes
205 205 remote: added 2 changesets with 2 changes to 2 files
206 206 $ cat empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
207 207 server side corruption
208 208 $ rm -rf empty
209 209
210 210 Push a largefiles repository to a served empty repository
211 211 $ hg init r8
212 212 $ echo c3 > r8/f1
213 213 $ hg add --large r8/f1 -R r8
214 214 $ hg commit -m "m1" -R r8
215 215 Invoking status precommit hook
216 216 A f1
217 217 $ hg init empty
218 218 $ hg serve -R empty -d -p $HGPORT2 --pid-file hg.pid \
219 219 > --config 'web.allow_push=*' --config web.push_ssl=False
220 220 $ cat hg.pid >> $DAEMON_PIDS
221 221 $ rm "${USERCACHE}"/*
222 222 $ hg push -R r8 http://localhost:$HGPORT2/#default
223 223 pushing to http://localhost:$HGPORT2/
224 224 searching for changes
225 225 remote: adding changesets
226 226 remote: adding manifests
227 227 remote: adding file changes
228 228 remote: added 1 changesets with 1 changes to 1 files
229 229 $ [ -f "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
230 230 $ [ -f empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
231 231
232 232 Clone over http, no largefiles pulled on clone.
233 233
234 234 $ hg clone http://localhost:$HGPORT2/#default http-clone -U
235 235 adding changesets
236 236 adding manifests
237 237 adding file changes
238 238 added 1 changesets with 1 changes to 1 files
239 239 new changesets cf03e5bb9936 (1 drafts)
240 240
241 241 Archive contains largefiles
242 242 >>> import os
243 243 >>> import urllib2
244 244 >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2']
245 245 >>> with open('archive.zip', 'w') as f:
246 ... f.write(urllib2.urlopen(u).read())
246 ... f.write(urllib2.urlopen(u).read()) and None
247 247 $ unzip -t archive.zip
248 248 Archive: archive.zip
249 249 testing: empty-default/.hg_archival.txt*OK (glob)
250 250 testing: empty-default/f1*OK (glob)
251 251 No errors detected in compressed data of archive.zip.
252 252
253 253 test 'verify' with remotestore:
254 254
255 255 $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90
256 256 $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
257 257 $ hg -R http-clone verify --large --lfa
258 258 checking changesets
259 259 checking manifests
260 260 crosschecking files in changesets and manifests
261 261 checking files
262 262 checked 1 changesets with 1 changes to 1 files
263 263 searching 1 changesets for largefiles
264 264 changeset 0:cf03e5bb9936: f1 missing
265 265 verified existence of 1 revisions of 1 largefiles
266 266 [1]
267 267 $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
268 268 $ hg -R http-clone -q verify --large --lfa
269 269
270 270 largefiles pulled on update - a largefile missing on the server:
271 271 $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
272 272 $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
273 273 getting changed largefiles
274 274 f1: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 not available from http://localhost:$HGPORT2/
275 275 0 largefiles updated, 0 removed
276 276 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
277 277 $ hg -R http-clone st
278 278 ! f1
279 279 $ hg -R http-clone up -Cqr null
280 280
281 281 largefiles pulled on update - a largefile corrupted on the server:
282 282 $ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90
283 283 $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
284 284 getting changed largefiles
285 285 f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27)
286 286 0 largefiles updated, 0 removed
287 287 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 288 $ hg -R http-clone st
289 289 ! f1
290 290 $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
291 291 $ [ ! -f http-clone/f1 ]
292 292 $ [ ! -f http-clone-usercache ]
293 293 $ hg -R http-clone verify --large --lfc
294 294 checking changesets
295 295 checking manifests
296 296 crosschecking files in changesets and manifests
297 297 checking files
298 298 checked 1 changesets with 1 changes to 1 files
299 299 searching 1 changesets for largefiles
300 300 verified contents of 1 revisions of 1 largefiles
301 301 $ hg -R http-clone up -Cqr null
302 302
303 303 largefiles pulled on update - no server side problems:
304 304 $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
305 305 $ hg -R http-clone --debug up --config largefiles.usercache=http-clone-usercache --config progress.debug=true
306 306 resolving manifests
307 307 branchmerge: False, force: False, partial: False
308 308 ancestor: 000000000000, local: 000000000000+, remote: cf03e5bb9936
309 309 .hglf/f1: remote created -> g
310 310 getting .hglf/f1
311 311 updating: .hglf/f1 1/1 files (100.00%)
312 312 getting changed largefiles
313 313 using http://localhost:$HGPORT2/
314 314 sending capabilities command
315 315 sending statlfile command
316 316 getting largefiles: 0/1 files (0.00%)
317 317 getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90
318 318 sending getlfile command
319 319 found 02a439e5c31c526465ab1a0ca1f431f76b827b90 in store
320 320 1 largefiles updated, 0 removed
321 321 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
322 322
323 323 $ ls http-clone-usercache/*
324 324 http-clone-usercache/02a439e5c31c526465ab1a0ca1f431f76b827b90
325 325
326 326 $ rm -rf empty http-clone*
327 327
328 328 used all HGPORTs, kill all daemons
329 329 $ killdaemons.py
330 330
331 331 largefiles should batch verify remote calls
332 332
333 333 $ hg init batchverifymain
334 334 $ cd batchverifymain
335 335 $ echo "aaa" >> a
336 336 $ hg add --large a
337 337 $ hg commit -m "a"
338 338 Invoking status precommit hook
339 339 A a
340 340 $ echo "bbb" >> b
341 341 $ hg add --large b
342 342 $ hg commit -m "b"
343 343 Invoking status precommit hook
344 344 A b
345 345 $ cd ..
346 346 $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
347 347 > -A access.log
348 348 $ cat hg.pid >> $DAEMON_PIDS
349 349 $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone
350 350 requesting all changes
351 351 adding changesets
352 352 adding manifests
353 353 adding file changes
354 354 added 2 changesets with 2 changes to 2 files
355 355 new changesets 567253b0f523:04d19c27a332 (2 drafts)
356 356 $ hg -R batchverifyclone verify --large --lfa
357 357 checking changesets
358 358 checking manifests
359 359 crosschecking files in changesets and manifests
360 360 checking files
361 361 checked 2 changesets with 2 changes to 2 files
362 362 searching 2 changesets for largefiles
363 363 verified existence of 2 revisions of 2 largefiles
364 364 $ tail -1 access.log
365 365 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
366 366 $ hg -R batchverifyclone update
367 367 getting changed largefiles
368 368 2 largefiles updated, 0 removed
369 369 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
370 370
371 371 Clear log file before next test
372 372
373 373 $ printf "" > access.log
374 374
375 375 Verify should check file on remote server only when file is not
376 376 available locally.
377 377
378 378 $ echo "ccc" >> batchverifymain/c
379 379 $ hg -R batchverifymain status
380 380 ? c
381 381 $ hg -R batchverifymain add --large batchverifymain/c
382 382 $ hg -R batchverifymain commit -m "c"
383 383 Invoking status precommit hook
384 384 A c
385 385 $ hg -R batchverifyclone pull
386 386 pulling from http://localhost:$HGPORT/
387 387 searching for changes
388 388 adding changesets
389 389 adding manifests
390 390 adding file changes
391 391 added 1 changesets with 1 changes to 1 files
392 392 new changesets 6bba8cb6935d (1 drafts)
393 393 (run 'hg update' to get a working copy)
394 394 $ hg -R batchverifyclone verify --lfa
395 395 checking changesets
396 396 checking manifests
397 397 crosschecking files in changesets and manifests
398 398 checking files
399 399 checked 3 changesets with 3 changes to 3 files
400 400 searching 3 changesets for largefiles
401 401 verified existence of 3 revisions of 3 largefiles
402 402 $ tail -1 access.log
403 403 $LOCALIP - - [$LOGDATE$] "GET /?cmd=statlfile HTTP/1.1" 200 - x-hgarg-1:sha=c8559c3c9cfb42131794b7d8009230403b9b454c x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
404 404
405 405 $ killdaemons.py
406 406
407 407 largefiles should not ask for password again after successful authorization
408 408
409 409 $ hg init credentialmain
410 410 $ cd credentialmain
411 411 $ echo "aaa" >> a
412 412 $ hg add --large a
413 413 $ hg commit -m "a"
414 414 Invoking status precommit hook
415 415 A a
416 416
417 417 Before running server clear the user cache to force clone to download
418 418 a large file from the server rather than to get it from the cache
419 419
420 420 $ rm "${USERCACHE}"/*
421 421
422 422 $ cd ..
423 423 $ cat << EOT > userpass.py
424 424 > import base64
425 425 > from mercurial.hgweb import common
426 426 > def perform_authentication(hgweb, req, op):
427 427 > auth = req.headers.get(b'Authorization')
428 428 > if not auth:
429 429 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
430 430 > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
431 431 > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
432 432 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
433 433 > def extsetup():
434 434 > common.permhooks.insert(0, perform_authentication)
435 435 > EOT
436 436 $ hg serve --config extensions.x=userpass.py -R credentialmain \
437 437 > -d -p $HGPORT --pid-file hg.pid -A access.log
438 438 $ cat hg.pid >> $DAEMON_PIDS
439 439 $ cat << EOF > get_pass.py
440 440 > import getpass
441 441 > def newgetpass(arg):
442 442 > return "pass"
443 443 > getpass.getpass = newgetpass
444 444 > EOF
445 445 $ hg clone --config ui.interactive=true --config extensions.getpass=get_pass.py \
446 446 > http://user@localhost:$HGPORT credentialclone
447 447 http authorization required for http://localhost:$HGPORT/
448 448 realm: mercurial
449 449 user: user
450 450 password: requesting all changes
451 451 adding changesets
452 452 adding manifests
453 453 adding file changes
454 454 added 1 changesets with 1 changes to 1 files
455 455 new changesets 567253b0f523 (1 drafts)
456 456 updating to branch default
457 457 getting changed largefiles
458 458 1 largefiles updated, 0 removed
459 459 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
460 460
461 461 $ killdaemons.py
462 462 $ rm hg.pid access.log
463 463
464 464 #endif
@@ -1,1172 +1,1172 b''
1 1 #require no-reposimplestore no-chg
2 2
3 3 $ hg init requirements
4 4 $ cd requirements
5 5
6 6 # LFS not loaded by default.
7 7
8 8 $ hg config extensions
9 9 [1]
10 10
11 11 # Adding lfs to requires file will auto-load lfs extension.
12 12
13 13 $ echo lfs >> .hg/requires
14 14 $ hg config extensions
15 15 extensions.lfs=
16 16
17 17 # But only if there is no config entry for the extension already.
18 18
19 19 $ cat > .hg/hgrc << EOF
20 20 > [extensions]
21 21 > lfs=!
22 22 > EOF
23 23
24 24 $ hg config extensions
25 25 abort: repository requires features unknown to this Mercurial: lfs!
26 26 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
27 27 [255]
28 28
29 29 $ cat > .hg/hgrc << EOF
30 30 > [extensions]
31 31 > lfs=
32 32 > EOF
33 33
34 34 $ hg config extensions
35 35 extensions.lfs=
36 36
37 37 $ cat > .hg/hgrc << EOF
38 38 > [extensions]
39 39 > lfs = missing.py
40 40 > EOF
41 41
42 42 $ hg config extensions
43 43 *** failed to import extension lfs from missing.py: [Errno 2] $ENOENT$: 'missing.py'
44 44 abort: repository requires features unknown to this Mercurial: lfs!
45 45 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
46 46 [255]
47 47
48 48 $ cd ..
49 49
50 50 # Initial setup
51 51
52 52 $ cat >> $HGRCPATH << EOF
53 53 > [extensions]
54 54 > lfs=
55 55 > [lfs]
56 56 > # Test deprecated config
57 57 > threshold=1000B
58 58 > EOF
59 59
60 60 $ LONG=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
61 61
62 62 # Prepare server and enable extension
63 63 $ hg init server
64 64 $ hg clone -q server client
65 65 $ cd client
66 66
67 67 # Commit small file
68 68 $ echo s > smallfile
69 69 $ echo '**.py = LF' > .hgeol
70 70 $ hg --config lfs.track='"size(\">1000B\")"' commit -Aqm "add small file"
71 71 hg: parse error: unsupported file pattern: size(">1000B")
72 72 (paths must be prefixed with "path:")
73 73 [255]
74 74 $ hg --config lfs.track='size(">1000B")' commit -Aqm "add small file"
75 75
76 76 # Commit large file
77 77 $ echo $LONG > largefile
78 78 $ grep lfs .hg/requires
79 79 [1]
80 80 $ hg commit --traceback -Aqm "add large file"
81 81 $ grep lfs .hg/requires
82 82 lfs
83 83
84 84 # Ensure metadata is stored
85 85 $ hg debugdata largefile 0
86 86 version https://git-lfs.github.com/spec/v1
87 87 oid sha256:f11e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
88 88 size 1501
89 89 x-is-binary 0
90 90
91 91 # Check the blobstore is populated
92 92 $ find .hg/store/lfs/objects | sort
93 93 .hg/store/lfs/objects
94 94 .hg/store/lfs/objects/f1
95 95 .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
96 96
97 97 # Check the blob stored contains the actual contents of the file
98 98 $ cat .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
99 99 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
100 100
101 101 # Push changes to the server
102 102
103 103 $ hg push
104 104 pushing to $TESTTMP/server
105 105 searching for changes
106 106 abort: lfs.url needs to be configured
107 107 [255]
108 108
109 109 $ cat >> $HGRCPATH << EOF
110 110 > [lfs]
111 111 > url=file:$TESTTMP/dummy-remote/
112 112 > EOF
113 113
114 114 Push to a local non-lfs repo with the extension enabled will add the
115 115 lfs requirement
116 116
117 117 $ grep lfs $TESTTMP/server/.hg/requires
118 118 [1]
119 119 $ hg push -v | egrep -v '^(uncompressed| )'
120 120 pushing to $TESTTMP/server
121 121 searching for changes
122 122 lfs: found f11e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b in the local lfs store
123 123 2 changesets found
124 124 adding changesets
125 125 adding manifests
126 126 adding file changes
127 127 added 2 changesets with 3 changes to 3 files
128 128 calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs
129 129 $ grep lfs $TESTTMP/server/.hg/requires
130 130 lfs
131 131
132 132 # Unknown URL scheme
133 133
134 134 $ hg push --config lfs.url=ftp://foobar
135 135 abort: lfs: unknown url scheme: ftp
136 136 [255]
137 137
138 138 $ cd ../
139 139
140 140 # Initialize new client (not cloning) and setup extension
141 141 $ hg init client2
142 142 $ cd client2
143 143 $ cat >> .hg/hgrc <<EOF
144 144 > [paths]
145 145 > default = $TESTTMP/server
146 146 > EOF
147 147
148 148 # Pull from server
149 149
150 150 Pulling a local lfs repo into a local non-lfs repo with the extension
151 151 enabled adds the lfs requirement
152 152
153 153 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
154 154 $TESTTMP/server/.hg/requires:lfs
155 155 $ hg pull default
156 156 pulling from $TESTTMP/server
157 157 requesting all changes
158 158 adding changesets
159 159 adding manifests
160 160 adding file changes
161 161 added 2 changesets with 3 changes to 3 files
162 162 new changesets 0ead593177f7:b88141481348
163 163 (run 'hg update' to get a working copy)
164 164 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
165 165 .hg/requires:lfs
166 166 $TESTTMP/server/.hg/requires:lfs
167 167
168 168 # Check the blobstore is not yet populated
169 169 $ [ -d .hg/store/lfs/objects ]
170 170 [1]
171 171
172 172 # Update to the last revision containing the large file
173 173 $ hg update
174 174 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 175
176 176 # Check the blobstore has been populated on update
177 177 $ find .hg/store/lfs/objects | sort
178 178 .hg/store/lfs/objects
179 179 .hg/store/lfs/objects/f1
180 180 .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
181 181
182 182 # Check the contents of the file are fetched from blobstore when requested
183 183 $ hg cat -r . largefile
184 184 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
185 185
186 186 # Check the file has been copied in the working copy
187 187 $ cat largefile
188 188 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
189 189
190 190 $ cd ..
191 191
192 192 # Check rename, and switch between large and small files
193 193
194 194 $ hg init repo3
195 195 $ cd repo3
196 196 $ cat >> .hg/hgrc << EOF
197 197 > [lfs]
198 198 > track=size(">10B")
199 199 > EOF
200 200
201 201 $ echo LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS > large
202 202 $ echo SHORTER > small
203 203 $ hg add . -q
204 204 $ hg commit -m 'commit with lfs content'
205 205
206 206 $ hg files -r . 'set:added()'
207 207 large
208 208 small
209 209 $ hg files -r . 'set:added() & lfs()'
210 210 large
211 211
212 212 $ hg mv large l
213 213 $ hg mv small s
214 214 $ hg status 'set:removed()'
215 215 R large
216 216 R small
217 217 $ hg status 'set:removed() & lfs()'
218 218 R large
219 219 $ hg commit -m 'renames'
220 220
221 221 $ hg files -r . 'set:copied()'
222 222 l
223 223 s
224 224 $ hg files -r . 'set:copied() & lfs()'
225 225 l
226 226 $ hg status --change . 'set:removed()'
227 227 R large
228 228 R small
229 229 $ hg status --change . 'set:removed() & lfs()'
230 230 R large
231 231
232 232 $ echo SHORT > l
233 233 $ echo BECOME-LARGER-FROM-SHORTER > s
234 234 $ hg commit -m 'large to small, small to large'
235 235
236 236 $ echo 1 >> l
237 237 $ echo 2 >> s
238 238 $ hg commit -m 'random modifications'
239 239
240 240 $ echo RESTORE-TO-BE-LARGE > l
241 241 $ echo SHORTER > s
242 242 $ hg commit -m 'switch large and small again'
243 243
244 244 # Test lfs_files template
245 245
246 246 $ hg log -r 'all()' -T '{rev} {join(lfs_files, ", ")}\n'
247 247 0 large
248 248 1 l, large
249 249 2 s
250 250 3 s
251 251 4 l
252 252
253 253 # Push and pull the above repo
254 254
255 255 $ hg --cwd .. init repo4
256 256 $ hg push ../repo4
257 257 pushing to ../repo4
258 258 searching for changes
259 259 adding changesets
260 260 adding manifests
261 261 adding file changes
262 262 added 5 changesets with 10 changes to 4 files
263 263
264 264 $ hg --cwd .. init repo5
265 265 $ hg --cwd ../repo5 pull ../repo3
266 266 pulling from ../repo3
267 267 requesting all changes
268 268 adding changesets
269 269 adding manifests
270 270 adding file changes
271 271 added 5 changesets with 10 changes to 4 files
272 272 new changesets fd47a419c4f7:5adf850972b9
273 273 (run 'hg update' to get a working copy)
274 274
275 275 $ cd ..
276 276
277 277 # Test clone
278 278
279 279 $ hg init repo6
280 280 $ cd repo6
281 281 $ cat >> .hg/hgrc << EOF
282 282 > [lfs]
283 283 > track=size(">30B")
284 284 > EOF
285 285
286 286 $ echo LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES > large
287 287 $ echo SMALL > small
288 288 $ hg commit -Aqm 'create a lfs file' large small
289 289 $ hg debuglfsupload -r 'all()' -v
290 290 lfs: found 8e92251415339ae9b148c8da89ed5ec665905166a1ab11b09dca8fad83344738 in the local lfs store
291 291
292 292 $ cd ..
293 293
294 294 $ hg clone repo6 repo7
295 295 updating to branch default
296 296 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
297 297 $ cd repo7
298 298 $ cat large
299 299 LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES
300 300 $ cat small
301 301 SMALL
302 302
303 303 $ cd ..
304 304
305 305 $ hg --config extensions.share= share repo7 sharedrepo
306 306 updating working directory
307 307 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
308 308 $ grep lfs sharedrepo/.hg/requires
309 309 lfs
310 310
311 311 # Test rename and status
312 312
313 313 $ hg init repo8
314 314 $ cd repo8
315 315 $ cat >> .hg/hgrc << EOF
316 316 > [lfs]
317 317 > track=size(">10B")
318 318 > EOF
319 319
320 320 $ echo THIS-IS-LFS-BECAUSE-10-BYTES > a1
321 321 $ echo SMALL > a2
322 322 $ hg commit -m a -A a1 a2
323 323 $ hg status
324 324 $ hg mv a1 b1
325 325 $ hg mv a2 a1
326 326 $ hg mv b1 a2
327 327 $ hg commit -m b
328 328 $ hg status
329 329 >>> with open('a2', 'wb') as f:
330 ... f.write(b'\1\nSTART-WITH-HG-FILELOG-METADATA')
330 ... f.write(b'\1\nSTART-WITH-HG-FILELOG-METADATA') and None
331 331 >>> with open('a1', 'wb') as f:
332 ... f.write(b'\1\nMETA\n')
332 ... f.write(b'\1\nMETA\n') and None
333 333 $ hg commit -m meta
334 334 $ hg status
335 335 $ hg log -T '{rev}: {file_copies} | {file_dels} | {file_adds}\n'
336 336 2: | |
337 337 1: a1 (a2)a2 (a1) | |
338 338 0: | | a1 a2
339 339
340 340 $ for n in a1 a2; do
341 341 > for r in 0 1 2; do
342 342 > printf '\n%s @ %s\n' $n $r
343 343 > hg debugdata $n $r
344 344 > done
345 345 > done
346 346
347 347 a1 @ 0
348 348 version https://git-lfs.github.com/spec/v1
349 349 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
350 350 size 29
351 351 x-is-binary 0
352 352
353 353 a1 @ 1
354 354 \x01 (esc)
355 355 copy: a2
356 356 copyrev: 50470ad23cf937b1f4b9f80bfe54df38e65b50d9
357 357 \x01 (esc)
358 358 SMALL
359 359
360 360 a1 @ 2
361 361 \x01 (esc)
362 362 \x01 (esc)
363 363 \x01 (esc)
364 364 META
365 365
366 366 a2 @ 0
367 367 SMALL
368 368
369 369 a2 @ 1
370 370 version https://git-lfs.github.com/spec/v1
371 371 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
372 372 size 29
373 373 x-hg-copy a1
374 374 x-hg-copyrev be23af27908a582af43e5cda209a5a9b319de8d4
375 375 x-is-binary 0
376 376
377 377 a2 @ 2
378 378 version https://git-lfs.github.com/spec/v1
379 379 oid sha256:876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
380 380 size 32
381 381 x-is-binary 0
382 382
383 383 # Verify commit hashes include rename metadata
384 384
385 385 $ hg log -T '{rev}:{node|short} {desc}\n'
386 386 2:0fae949de7fa meta
387 387 1:9cd6bdffdac0 b
388 388 0:7f96794915f7 a
389 389
390 390 $ cd ..
391 391
392 392 # Test bundle
393 393
394 394 $ hg init repo9
395 395 $ cd repo9
396 396 $ cat >> .hg/hgrc << EOF
397 397 > [lfs]
398 398 > track=size(">10B")
399 399 > [diff]
400 400 > git=1
401 401 > EOF
402 402
403 403 $ for i in 0 single two three 4; do
404 404 > echo 'THIS-IS-LFS-'$i > a
405 405 > hg commit -m a-$i -A a
406 406 > done
407 407
408 408 $ hg update 2 -q
409 409 $ echo 'THIS-IS-LFS-2-CHILD' > a
410 410 $ hg commit -m branching -q
411 411
412 412 $ hg bundle --base 1 bundle.hg -v
413 413 lfs: found 5ab7a3739a5feec94a562d070a14f36dba7cad17e5484a4a89eea8e5f3166888 in the local lfs store
414 414 lfs: found a9c7d1cd6ce2b9bbdf46ed9a862845228717b921c089d0d42e3bcaed29eb612e in the local lfs store
415 415 lfs: found f693890c49c409ec33673b71e53f297681f76c1166daf33b2ad7ebf8b1d3237e in the local lfs store
416 416 lfs: found fda198fea753eb66a252e9856915e1f5cddbe41723bd4b695ece2604ad3c9f75 in the local lfs store
417 417 4 changesets found
418 418 uncompressed size of bundle content:
419 419 * (changelog) (glob)
420 420 * (manifests) (glob)
421 421 * a (glob)
422 422 $ hg --config extensions.strip= strip -r 2 --no-backup --force -q
423 423 $ hg -R bundle.hg log -p -T '{rev} {desc}\n' a
424 424 5 branching
425 425 diff --git a/a b/a
426 426 --- a/a
427 427 +++ b/a
428 428 @@ -1,1 +1,1 @@
429 429 -THIS-IS-LFS-two
430 430 +THIS-IS-LFS-2-CHILD
431 431
432 432 4 a-4
433 433 diff --git a/a b/a
434 434 --- a/a
435 435 +++ b/a
436 436 @@ -1,1 +1,1 @@
437 437 -THIS-IS-LFS-three
438 438 +THIS-IS-LFS-4
439 439
440 440 3 a-three
441 441 diff --git a/a b/a
442 442 --- a/a
443 443 +++ b/a
444 444 @@ -1,1 +1,1 @@
445 445 -THIS-IS-LFS-two
446 446 +THIS-IS-LFS-three
447 447
448 448 2 a-two
449 449 diff --git a/a b/a
450 450 --- a/a
451 451 +++ b/a
452 452 @@ -1,1 +1,1 @@
453 453 -THIS-IS-LFS-single
454 454 +THIS-IS-LFS-two
455 455
456 456 1 a-single
457 457 diff --git a/a b/a
458 458 --- a/a
459 459 +++ b/a
460 460 @@ -1,1 +1,1 @@
461 461 -THIS-IS-LFS-0
462 462 +THIS-IS-LFS-single
463 463
464 464 0 a-0
465 465 diff --git a/a b/a
466 466 new file mode 100644
467 467 --- /dev/null
468 468 +++ b/a
469 469 @@ -0,0 +1,1 @@
470 470 +THIS-IS-LFS-0
471 471
472 472 $ hg bundle -R bundle.hg --base 1 bundle-again.hg -q
473 473 $ hg -R bundle-again.hg log -p -T '{rev} {desc}\n' a
474 474 5 branching
475 475 diff --git a/a b/a
476 476 --- a/a
477 477 +++ b/a
478 478 @@ -1,1 +1,1 @@
479 479 -THIS-IS-LFS-two
480 480 +THIS-IS-LFS-2-CHILD
481 481
482 482 4 a-4
483 483 diff --git a/a b/a
484 484 --- a/a
485 485 +++ b/a
486 486 @@ -1,1 +1,1 @@
487 487 -THIS-IS-LFS-three
488 488 +THIS-IS-LFS-4
489 489
490 490 3 a-three
491 491 diff --git a/a b/a
492 492 --- a/a
493 493 +++ b/a
494 494 @@ -1,1 +1,1 @@
495 495 -THIS-IS-LFS-two
496 496 +THIS-IS-LFS-three
497 497
498 498 2 a-two
499 499 diff --git a/a b/a
500 500 --- a/a
501 501 +++ b/a
502 502 @@ -1,1 +1,1 @@
503 503 -THIS-IS-LFS-single
504 504 +THIS-IS-LFS-two
505 505
506 506 1 a-single
507 507 diff --git a/a b/a
508 508 --- a/a
509 509 +++ b/a
510 510 @@ -1,1 +1,1 @@
511 511 -THIS-IS-LFS-0
512 512 +THIS-IS-LFS-single
513 513
514 514 0 a-0
515 515 diff --git a/a b/a
516 516 new file mode 100644
517 517 --- /dev/null
518 518 +++ b/a
519 519 @@ -0,0 +1,1 @@
520 520 +THIS-IS-LFS-0
521 521
522 522 $ cd ..
523 523
524 524 # Test isbinary
525 525
526 526 $ hg init repo10
527 527 $ cd repo10
528 528 $ cat >> .hg/hgrc << EOF
529 529 > [extensions]
530 530 > lfs=
531 531 > [lfs]
532 532 > track=all()
533 533 > EOF
534 534 $ "$PYTHON" <<'EOF'
535 535 > def write(path, content):
536 536 > with open(path, 'wb') as f:
537 537 > f.write(content)
538 538 > write('a', b'\0\0')
539 539 > write('b', b'\1\n')
540 540 > write('c', b'\1\n\0')
541 541 > write('d', b'xx')
542 542 > EOF
543 543 $ hg add a b c d
544 544 $ hg diff --stat
545 545 a | Bin
546 546 b | 1 +
547 547 c | Bin
548 548 d | 1 +
549 549 4 files changed, 2 insertions(+), 0 deletions(-)
550 550 $ hg commit -m binarytest
551 551 $ cat > $TESTTMP/dumpbinary.py << EOF
552 552 > from mercurial.utils import (
553 553 > stringutil,
554 554 > )
555 555 > def reposetup(ui, repo):
556 556 > for n in (b'a', b'b', b'c', b'd'):
557 557 > ui.write((b'%s: binary=%s\n')
558 558 > % (n, stringutil.pprint(repo[b'.'][n].isbinary())))
559 559 > EOF
560 560 $ hg --config extensions.dumpbinary=$TESTTMP/dumpbinary.py id --trace
561 561 a: binary=True
562 562 b: binary=False
563 563 c: binary=True
564 564 d: binary=False
565 565 b55353847f02 tip
566 566
567 567 Binary blobs don't need to be present to be skipped in filesets. (And their
568 568 absence doesn't cause an abort.)
569 569
570 570 $ rm .hg/store/lfs/objects/96/a296d224f285c67bee93c30f8a309157f0daa35dc5b87e410b78630a09cfc7
571 571 $ rm .hg/store/lfs/objects/92/f76135a4baf4faccb8586a60faf830c2bdfce147cefa188aaf4b790bd01b7e
572 572
573 573 $ hg files --debug -r . 'set:eol("unix")' --config 'experimental.lfs.disableusercache=True'
574 574 lfs: found c04b5bb1a5b2eb3e9cd4805420dba5a9d133da5b7adeeafb5474c4adae9faa80 in the local lfs store
575 575 2 b
576 576 lfs: found 5dde896887f6754c9b15bfe3a441ae4806df2fde94001311e08bf110622e0bbe in the local lfs store
577 577
578 578 $ hg files --debug -r . 'set:binary()' --config 'experimental.lfs.disableusercache=True'
579 579 2 a
580 580 3 c
581 581
582 582 $ cd ..
583 583
584 584 # Test fctx.cmp fastpath - diff without LFS blobs
585 585
586 586 $ hg init repo12
587 587 $ cd repo12
588 588 $ cat >> .hg/hgrc <<EOF
589 589 > [lfs]
590 590 > threshold=1
591 591 > EOF
592 592 $ cat > ../patch.diff <<EOF
593 593 > # HG changeset patch
594 594 > 2
595 595 >
596 596 > diff --git a/a b/a
597 597 > old mode 100644
598 598 > new mode 100755
599 599 > EOF
600 600
601 601 $ for i in 1 2 3; do
602 602 > cp ../repo10/a a
603 603 > if [ $i = 3 ]; then
604 604 > # make a content-only change
605 605 > hg import -q --bypass ../patch.diff
606 606 > hg update -q
607 607 > rm ../patch.diff
608 608 > else
609 609 > echo $i >> a
610 610 > hg commit -m $i -A a
611 611 > fi
612 612 > done
613 613 $ [ -d .hg/store/lfs/objects ]
614 614
615 615 $ cd ..
616 616
617 617 $ hg clone repo12 repo13 --noupdate
618 618 $ cd repo13
619 619 $ hg log --removed -p a -T '{desc}\n' --config diff.nobinary=1 --git
620 620 2
621 621 diff --git a/a b/a
622 622 old mode 100644
623 623 new mode 100755
624 624
625 625 2
626 626 diff --git a/a b/a
627 627 Binary file a has changed
628 628
629 629 1
630 630 diff --git a/a b/a
631 631 new file mode 100644
632 632 Binary file a has changed
633 633
634 634 $ [ -d .hg/store/lfs/objects ]
635 635 [1]
636 636
637 637 $ cd ..
638 638
639 639 # Test filter
640 640
641 641 $ hg init repo11
642 642 $ cd repo11
643 643 $ cat >> .hg/hgrc << EOF
644 644 > [lfs]
645 645 > track=(**.a & size(">5B")) | (**.b & !size(">5B"))
646 646 > | (**.c & "path:d" & !"path:d/c.c") | size(">10B")
647 647 > EOF
648 648
649 649 $ mkdir a
650 650 $ echo aaaaaa > a/1.a
651 651 $ echo a > a/2.a
652 652 $ echo aaaaaa > 1.b
653 653 $ echo a > 2.b
654 654 $ echo a > 1.c
655 655 $ mkdir d
656 656 $ echo a > d/c.c
657 657 $ echo a > d/d.c
658 658 $ echo aaaaaaaaaaaa > x
659 659 $ hg add . -q
660 660 $ hg commit -m files
661 661
662 662 $ for p in a/1.a a/2.a 1.b 2.b 1.c d/c.c d/d.c x; do
663 663 > if hg debugdata $p 0 2>&1 | grep git-lfs >/dev/null; then
664 664 > echo "${p}: is lfs"
665 665 > else
666 666 > echo "${p}: not lfs"
667 667 > fi
668 668 > done
669 669 a/1.a: is lfs
670 670 a/2.a: not lfs
671 671 1.b: not lfs
672 672 2.b: is lfs
673 673 1.c: not lfs
674 674 d/c.c: not lfs
675 675 d/d.c: is lfs
676 676 x: is lfs
677 677
678 678 $ cd ..
679 679
680 680 # Verify the repos
681 681
682 682 $ cat > $TESTTMP/dumpflog.py << EOF
683 683 > # print raw revision sizes, flags, and hashes for certain files
684 684 > import hashlib
685 685 > from mercurial.node import short
686 686 > from mercurial import (
687 687 > pycompat,
688 688 > revlog,
689 689 > )
690 690 > from mercurial.utils import (
691 691 > stringutil,
692 692 > )
693 693 > def hash(rawtext):
694 694 > h = hashlib.sha512()
695 695 > h.update(rawtext)
696 696 > return pycompat.sysbytes(h.hexdigest()[:4])
697 697 > def reposetup(ui, repo):
698 698 > # these 2 files are interesting
699 699 > for name in [b'l', b's']:
700 700 > fl = repo.file(name)
701 701 > if len(fl) == 0:
702 702 > continue
703 703 > sizes = [fl._revlog.rawsize(i) for i in fl]
704 704 > texts = [fl.revision(i, raw=True) for i in fl]
705 705 > flags = [int(fl._revlog.flags(i)) for i in fl]
706 706 > hashes = [hash(t) for t in texts]
707 707 > pycompat.stdout.write(b' %s: rawsizes=%r flags=%r hashes=%s\n'
708 708 > % (name, sizes, flags, stringutil.pprint(hashes)))
709 709 > EOF
710 710
711 711 $ for i in client client2 server repo3 repo4 repo5 repo6 repo7 repo8 repo9 \
712 712 > repo10; do
713 713 > echo 'repo:' $i
714 714 > hg --cwd $i verify --config extensions.dumpflog=$TESTTMP/dumpflog.py -q
715 715 > done
716 716 repo: client
717 717 repo: client2
718 718 repo: server
719 719 repo: repo3
720 720 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
721 721 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
722 722 repo: repo4
723 723 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
724 724 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
725 725 repo: repo5
726 726 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
727 727 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
728 728 repo: repo6
729 729 repo: repo7
730 730 repo: repo8
731 731 repo: repo9
732 732 repo: repo10
733 733
734 734 repo13 doesn't have any cached lfs files and its source never pushed its
735 735 files. Therefore, the files don't exist in the remote store. Use the files in
736 736 the user cache.
737 737
738 738 $ test -d $TESTTMP/repo13/.hg/store/lfs/objects
739 739 [1]
740 740
741 741 $ hg --config extensions.share= share repo13 repo14
742 742 updating working directory
743 743 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
744 744 $ hg -R repo14 -q verify
745 745
746 746 $ hg clone repo13 repo15
747 747 updating to branch default
748 748 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
749 749 $ hg -R repo15 -q verify
750 750
751 751 If the source repo doesn't have the blob (maybe it was pulled or cloned with
752 752 --noupdate), the blob is still accessible via the global cache to send to the
753 753 remote store.
754 754
755 755 $ rm -rf $TESTTMP/repo15/.hg/store/lfs
756 756 $ hg init repo16
757 757 $ hg -R repo15 push repo16
758 758 pushing to repo16
759 759 searching for changes
760 760 adding changesets
761 761 adding manifests
762 762 adding file changes
763 763 added 3 changesets with 2 changes to 1 files
764 764 $ hg -R repo15 -q verify
765 765
766 766 Test damaged file scenarios. (This also damages the usercache because of the
767 767 hardlinks.)
768 768
769 769 $ echo 'damage' >> repo5/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
770 770
771 771 Repo with damaged lfs objects in any revision will fail verification.
772 772
773 773 $ hg -R repo5 verify
774 774 checking changesets
775 775 checking manifests
776 776 crosschecking files in changesets and manifests
777 777 checking files
778 778 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
779 779 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
780 780 checked 5 changesets with 10 changes to 4 files
781 781 2 integrity errors encountered!
782 782 (first damaged changeset appears to be 0)
783 783 [1]
784 784
785 785 Updates work after cloning a damaged repo, if the damaged lfs objects aren't in
786 786 the update destination. Those objects won't be added to the new repo's store
787 787 because they aren't accessed.
788 788
789 789 $ hg clone -v repo5 fromcorrupt
790 790 updating to branch default
791 791 resolving manifests
792 792 getting l
793 793 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the usercache
794 794 getting s
795 795 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
796 796 $ test -f fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
797 797 [1]
798 798
799 799 Verify will copy/link all lfs objects into the local store that aren't already
800 800 present. Bypass the corrupted usercache to show that verify works when fed by
801 801 the (uncorrupted) remote store.
802 802
803 803 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v
804 804 repository uses revlog format 1
805 805 checking changesets
806 806 checking manifests
807 807 crosschecking files in changesets and manifests
808 808 checking files
809 809 lfs: adding 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e to the usercache
810 810 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
811 811 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
812 812 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
813 813 lfs: adding 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 to the usercache
814 814 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
815 815 lfs: adding b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c to the usercache
816 816 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
817 817 checked 5 changesets with 10 changes to 4 files
818 818
819 819 Verify will not copy/link a corrupted file from the usercache into the local
820 820 store, and poison it. (The verify with a good remote now works.)
821 821
822 822 $ rm -r fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
823 823 $ hg -R fromcorrupt verify -v
824 824 repository uses revlog format 1
825 825 checking changesets
826 826 checking manifests
827 827 crosschecking files in changesets and manifests
828 828 checking files
829 829 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
830 830 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
831 831 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
832 832 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
833 833 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
834 834 checked 5 changesets with 10 changes to 4 files
835 835 2 integrity errors encountered!
836 836 (first damaged changeset appears to be 0)
837 837 [1]
838 838 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v
839 839 repository uses revlog format 1
840 840 checking changesets
841 841 checking manifests
842 842 crosschecking files in changesets and manifests
843 843 checking files
844 844 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the usercache
845 845 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
846 846 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
847 847 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
848 848 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
849 849 checked 5 changesets with 10 changes to 4 files
850 850
851 851 Damaging a file required by the update destination fails the update.
852 852
853 853 $ echo 'damage' >> $TESTTMP/dummy-remote/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
854 854 $ hg --config lfs.usercache=emptycache clone -v repo5 fromcorrupt2
855 855 updating to branch default
856 856 resolving manifests
857 857 abort: corrupt remote lfs object: 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
858 858 [255]
859 859
860 860 A corrupted lfs blob is not transferred from a file://remotestore to the
861 861 usercache or local store.
862 862
863 863 $ test -f emptycache/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
864 864 [1]
865 865 $ test -f fromcorrupt2/.hg/store/lfs/objects/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
866 866 [1]
867 867
868 868 $ hg -R fromcorrupt2 verify
869 869 checking changesets
870 870 checking manifests
871 871 crosschecking files in changesets and manifests
872 872 checking files
873 873 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
874 874 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
875 875 checked 5 changesets with 10 changes to 4 files
876 876 2 integrity errors encountered!
877 877 (first damaged changeset appears to be 0)
878 878 [1]
879 879
880 880 Corrupt local files are not sent upstream. (The alternate dummy remote
881 881 avoids the corrupt lfs object in the original remote.)
882 882
883 883 $ mkdir $TESTTMP/dummy-remote2
884 884 $ hg init dest
885 885 $ hg -R fromcorrupt2 --config lfs.url=file:///$TESTTMP/dummy-remote2 push -v dest
886 886 pushing to dest
887 887 searching for changes
888 888 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
889 889 abort: detected corrupt lfs object: 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
890 890 (run hg verify)
891 891 [255]
892 892
893 893 $ hg -R fromcorrupt2 --config lfs.url=file:///$TESTTMP/dummy-remote2 verify -v
894 894 repository uses revlog format 1
895 895 checking changesets
896 896 checking manifests
897 897 crosschecking files in changesets and manifests
898 898 checking files
899 899 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
900 900 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
901 901 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
902 902 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
903 903 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
904 904 checked 5 changesets with 10 changes to 4 files
905 905 2 integrity errors encountered!
906 906 (first damaged changeset appears to be 0)
907 907 [1]
908 908
909 909 $ cat $TESTTMP/dummy-remote2/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b | $TESTDIR/f --sha256
910 910 sha256=22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
911 911 $ cat fromcorrupt2/.hg/store/lfs/objects/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b | $TESTDIR/f --sha256
912 912 sha256=22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
913 913 $ test -f $TESTTMP/dummy-remote2/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
914 914 [1]
915 915
916 916 Accessing a corrupt file will complain
917 917
918 918 $ hg --cwd fromcorrupt2 cat -r 0 large
919 919 abort: integrity check failed on data/large.i:0!
920 920 [255]
921 921
922 922 lfs -> normal -> lfs round trip conversions are possible. The 'none()'
923 923 predicate on the command line will override whatever is configured globally and
924 924 locally, and ensures everything converts to a regular file. For lfs -> normal,
925 925 there's no 'lfs' destination repo requirement. For normal -> lfs, there is.
926 926
927 927 $ hg --config extensions.convert= --config 'lfs.track=none()' \
928 928 > convert repo8 convert_normal
929 929 initializing destination convert_normal repository
930 930 scanning source...
931 931 sorting...
932 932 converting...
933 933 2 a
934 934 1 b
935 935 0 meta
936 936 $ grep 'lfs' convert_normal/.hg/requires
937 937 [1]
938 938 $ hg --cwd convert_normal cat a1 -r 0 -T '{rawdata}'
939 939 THIS-IS-LFS-BECAUSE-10-BYTES
940 940
941 941 $ hg --config extensions.convert= --config lfs.threshold=10B \
942 942 > convert convert_normal convert_lfs
943 943 initializing destination convert_lfs repository
944 944 scanning source...
945 945 sorting...
946 946 converting...
947 947 2 a
948 948 1 b
949 949 0 meta
950 950
951 951 $ hg --cwd convert_lfs cat -r 0 a1 -T '{rawdata}'
952 952 version https://git-lfs.github.com/spec/v1
953 953 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
954 954 size 29
955 955 x-is-binary 0
956 956 $ hg --cwd convert_lfs debugdata a1 0
957 957 version https://git-lfs.github.com/spec/v1
958 958 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
959 959 size 29
960 960 x-is-binary 0
961 961 $ hg --cwd convert_lfs log -r 0 -T "{lfs_files % '{lfspointer % '{key}={value}\n'}'}"
962 962 version=https://git-lfs.github.com/spec/v1
963 963 oid=sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
964 964 size=29
965 965 x-is-binary=0
966 966 $ hg --cwd convert_lfs log -r 0 \
967 967 > -T '{lfs_files % "{get(lfspointer, "oid")}\n"}{lfs_files % "{lfspointer.oid}\n"}'
968 968 sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
969 969 sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
970 970 $ hg --cwd convert_lfs log -r 0 -T '{lfs_files % "{lfspointer}\n"}'
971 971 version=https://git-lfs.github.com/spec/v1 oid=sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024 size=29 x-is-binary=0
972 972 $ hg --cwd convert_lfs \
973 973 > log -r 'all()' -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}'
974 974 0: a1: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
975 975 1: a2: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
976 976 2: a2: 876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
977 977
978 978 $ grep 'lfs' convert_lfs/.hg/requires
979 979 lfs
980 980
981 981 The hashes in all stages of the conversion are unchanged.
982 982
983 983 $ hg -R repo8 log -T '{node|short}\n'
984 984 0fae949de7fa
985 985 9cd6bdffdac0
986 986 7f96794915f7
987 987 $ hg -R convert_normal log -T '{node|short}\n'
988 988 0fae949de7fa
989 989 9cd6bdffdac0
990 990 7f96794915f7
991 991 $ hg -R convert_lfs log -T '{node|short}\n'
992 992 0fae949de7fa
993 993 9cd6bdffdac0
994 994 7f96794915f7
995 995
996 996 This convert is trickier, because it contains deleted files (via `hg mv`)
997 997
998 998 $ hg --config extensions.convert= --config lfs.threshold=1000M \
999 999 > convert repo3 convert_normal2
1000 1000 initializing destination convert_normal2 repository
1001 1001 scanning source...
1002 1002 sorting...
1003 1003 converting...
1004 1004 4 commit with lfs content
1005 1005 3 renames
1006 1006 2 large to small, small to large
1007 1007 1 random modifications
1008 1008 0 switch large and small again
1009 1009 $ grep 'lfs' convert_normal2/.hg/requires
1010 1010 [1]
1011 1011 $ hg --cwd convert_normal2 debugdata large 0
1012 1012 LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS
1013 1013
1014 1014 $ hg --config extensions.convert= --config lfs.threshold=10B \
1015 1015 > convert convert_normal2 convert_lfs2
1016 1016 initializing destination convert_lfs2 repository
1017 1017 scanning source...
1018 1018 sorting...
1019 1019 converting...
1020 1020 4 commit with lfs content
1021 1021 3 renames
1022 1022 2 large to small, small to large
1023 1023 1 random modifications
1024 1024 0 switch large and small again
1025 1025 $ grep 'lfs' convert_lfs2/.hg/requires
1026 1026 lfs
1027 1027 $ hg --cwd convert_lfs2 debugdata large 0
1028 1028 version https://git-lfs.github.com/spec/v1
1029 1029 oid sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
1030 1030 size 39
1031 1031 x-is-binary 0
1032 1032
1033 1033 $ hg -R convert_lfs2 config --debug extensions | grep lfs
1034 1034 $TESTTMP/convert_lfs2/.hg/hgrc:*: extensions.lfs= (glob)
1035 1035
1036 1036 Committing deleted files works:
1037 1037
1038 1038 $ hg init $TESTTMP/repo-del
1039 1039 $ cd $TESTTMP/repo-del
1040 1040 $ echo 1 > A
1041 1041 $ hg commit -m 'add A' -A A
1042 1042 $ hg rm A
1043 1043 $ hg commit -m 'rm A'
1044 1044
1045 1045 Bad .hglfs files will block the commit with a useful message
1046 1046
1047 1047 $ cat > .hglfs << EOF
1048 1048 > [track]
1049 1049 > **.test = size(">5B")
1050 1050 > bad file ... no commit
1051 1051 > EOF
1052 1052
1053 1053 $ echo x > file.txt
1054 1054 $ hg ci -Aqm 'should fail'
1055 1055 hg: parse error at .hglfs:3: bad file ... no commit
1056 1056 [255]
1057 1057
1058 1058 $ cat > .hglfs << EOF
1059 1059 > [track]
1060 1060 > **.test = size(">5B")
1061 1061 > ** = nonexistent()
1062 1062 > EOF
1063 1063
1064 1064 $ hg ci -Aqm 'should fail'
1065 1065 abort: parse error in .hglfs: unknown identifier: nonexistent
1066 1066 [255]
1067 1067
1068 1068 '**' works out to mean all files.
1069 1069
1070 1070 $ cat > .hglfs << EOF
1071 1071 > [track]
1072 1072 > path:.hglfs = none()
1073 1073 > **.test = size(">5B")
1074 1074 > **.exclude = none()
1075 1075 > ** = size(">10B")
1076 1076 > EOF
1077 1077
1078 1078 The LFS policy takes effect without tracking the .hglfs file
1079 1079
1080 1080 $ echo 'largefile' > lfs.test
1081 1081 $ echo '012345678901234567890' > nolfs.exclude
1082 1082 $ echo '01234567890123456' > lfs.catchall
1083 1083 $ hg add *
1084 1084 $ hg ci -qm 'before add .hglfs'
1085 1085 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1086 1086 2: lfs.catchall: d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
1087 1087 lfs.test: 5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
1088 1088
1089 1089 The .hglfs file works when tracked
1090 1090
1091 1091 $ echo 'largefile2' > lfs.test
1092 1092 $ echo '012345678901234567890a' > nolfs.exclude
1093 1093 $ echo '01234567890123456a' > lfs.catchall
1094 1094 $ hg ci -Aqm 'after adding .hglfs'
1095 1095 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1096 1096 3: lfs.catchall: 31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1097 1097 lfs.test: 8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1098 1098
1099 1099 The LFS policy stops when the .hglfs is gone
1100 1100
1101 1101 $ mv .hglfs .hglfs_
1102 1102 $ echo 'largefile3' > lfs.test
1103 1103 $ echo '012345678901234567890abc' > nolfs.exclude
1104 1104 $ echo '01234567890123456abc' > lfs.catchall
1105 1105 $ hg ci -qm 'file test' -X .hglfs
1106 1106 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1107 1107 4:
1108 1108
1109 1109 $ mv .hglfs_ .hglfs
1110 1110 $ echo '012345678901234567890abc' > lfs.test
1111 1111 $ hg ci -m 'back to lfs'
1112 1112 $ hg rm lfs.test
1113 1113 $ hg ci -qm 'remove lfs'
1114 1114
1115 1115 {lfs_files} will list deleted files too
1116 1116
1117 1117 $ hg log -T "{lfs_files % '{rev} {file}: {lfspointer.oid}\n'}"
1118 1118 6 lfs.test:
1119 1119 5 lfs.test: sha256:43f8f41171b6f62a6b61ba4ce98a8a6c1649240a47ebafd43120aa215ac9e7f6
1120 1120 3 lfs.catchall: sha256:31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1121 1121 3 lfs.test: sha256:8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1122 1122 2 lfs.catchall: sha256:d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
1123 1123 2 lfs.test: sha256:5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
1124 1124
1125 1125 $ hg log -r 'file("set:lfs()")' -T '{rev} {join(lfs_files, ", ")}\n'
1126 1126 2 lfs.catchall, lfs.test
1127 1127 3 lfs.catchall, lfs.test
1128 1128 5 lfs.test
1129 1129 6 lfs.test
1130 1130
1131 1131 $ cd ..
1132 1132
1133 1133 Unbundling adds a requirement to a non-lfs repo, if necessary.
1134 1134
1135 1135 $ hg bundle -R $TESTTMP/repo-del -qr 0 --base null nolfs.hg
1136 1136 $ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg
1137 1137 $ hg init unbundle
1138 1138 $ hg pull -R unbundle -q nolfs.hg
1139 1139 $ grep lfs unbundle/.hg/requires
1140 1140 [1]
1141 1141 $ hg pull -R unbundle -q lfs.hg
1142 1142 $ grep lfs unbundle/.hg/requires
1143 1143 lfs
1144 1144
1145 1145 $ hg init no_lfs
1146 1146 $ cat >> no_lfs/.hg/hgrc <<EOF
1147 1147 > [experimental]
1148 1148 > changegroup3 = True
1149 1149 > [extensions]
1150 1150 > lfs=!
1151 1151 > EOF
1152 1152 $ cp -R no_lfs no_lfs2
1153 1153
1154 1154 Pushing from a local lfs repo to a local repo without an lfs requirement and
1155 1155 with lfs disabled, fails.
1156 1156
1157 1157 $ hg push -R convert_lfs2 no_lfs
1158 1158 pushing to no_lfs
1159 1159 abort: required features are not supported in the destination: lfs
1160 1160 [255]
1161 1161 $ grep lfs no_lfs/.hg/requires
1162 1162 [1]
1163 1163
1164 1164 Pulling from a local lfs repo to a local repo without an lfs requirement and
1165 1165 with lfs disabled, fails.
1166 1166
1167 1167 $ hg pull -R no_lfs2 convert_lfs2
1168 1168 pulling from convert_lfs2
1169 1169 abort: required features are not supported in the destination: lfs
1170 1170 [255]
1171 1171 $ grep lfs no_lfs2/.hg/requires
1172 1172 [1]
General Comments 0
You need to be logged in to leave comments. Login now