##// END OF EJS Templates
test-extension: add check for 'hg version -v' listing enabled extensions
Augie Fackler -
r21849:a3306b8c default
parent child Browse files
Show More
@@ -1,846 +1,905 b''
1 1 Test basic extension support
2 2
3 3 $ cat > foobar.py <<EOF
4 4 > import os
5 5 > from mercurial import cmdutil, commands
6 >
7 6 > cmdtable = {}
8 7 > command = cmdutil.command(cmdtable)
9 >
10 8 > def uisetup(ui):
11 9 > ui.write("uisetup called\\n")
12 >
13 10 > def reposetup(ui, repo):
14 11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
15 12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
16 >
17 13 > @command('foo', [], 'hg foo')
18 14 > def foo(ui, *args, **kwargs):
19 15 > ui.write("Foo\\n")
20 >
21 16 > @command('bar', [], 'hg bar', norepo=True)
22 17 > def bar(ui, *args, **kwargs):
23 18 > ui.write("Bar\\n")
24 >
25 19 > EOF
26 20 $ abspath=`pwd`/foobar.py
27 21
28 22 $ mkdir barfoo
29 23 $ cp foobar.py barfoo/__init__.py
30 24 $ barfoopath=`pwd`/barfoo
31 25
32 26 $ hg init a
33 27 $ cd a
34 28 $ echo foo > file
35 29 $ hg add file
36 30 $ hg commit -m 'add file'
37 31
38 32 $ echo '[extensions]' >> $HGRCPATH
39 33 $ echo "foobar = $abspath" >> $HGRCPATH
40 34 $ hg foo
41 35 uisetup called
42 36 reposetup called for a
43 37 ui == repo.ui
44 38 Foo
45 39
46 40 $ cd ..
47 41 $ hg clone a b
48 42 uisetup called
49 43 reposetup called for a
50 44 ui == repo.ui
51 45 reposetup called for b
52 46 ui == repo.ui
53 47 updating to branch default
54 48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 49
56 50 $ hg bar
57 51 uisetup called
58 52 Bar
59 53 $ echo 'foobar = !' >> $HGRCPATH
60 54
61 55 module/__init__.py-style
62 56
63 57 $ echo "barfoo = $barfoopath" >> $HGRCPATH
64 58 $ cd a
65 59 $ hg foo
66 60 uisetup called
67 61 reposetup called for a
68 62 ui == repo.ui
69 63 Foo
70 64 $ echo 'barfoo = !' >> $HGRCPATH
71 65
72 66 Check that extensions are loaded in phases:
73 67
74 68 $ cat > foo.py <<EOF
75 69 > import os
76 70 > name = os.path.basename(__file__).rsplit('.', 1)[0]
77 71 > print "1) %s imported" % name
78 72 > def uisetup(ui):
79 73 > print "2) %s uisetup" % name
80 74 > def extsetup():
81 75 > print "3) %s extsetup" % name
82 76 > def reposetup(ui, repo):
83 77 > print "4) %s reposetup" % name
84 78 > EOF
85 79
86 80 $ cp foo.py bar.py
87 81 $ echo 'foo = foo.py' >> $HGRCPATH
88 82 $ echo 'bar = bar.py' >> $HGRCPATH
89 83
90 84 Command with no output, we just want to see the extensions loaded:
91 85
92 86 $ hg paths
93 87 1) foo imported
94 88 1) bar imported
95 89 2) foo uisetup
96 90 2) bar uisetup
97 91 3) foo extsetup
98 92 3) bar extsetup
99 93 4) foo reposetup
100 94 4) bar reposetup
101 95
102 96 Check hgweb's load order:
103 97
104 98 $ cat > hgweb.cgi <<EOF
105 99 > #!/usr/bin/env python
106 100 > from mercurial import demandimport; demandimport.enable()
107 101 > from mercurial.hgweb import hgweb
108 102 > from mercurial.hgweb import wsgicgi
109 >
110 103 > application = hgweb('.', 'test repo')
111 104 > wsgicgi.launch(application)
112 105 > EOF
113 106
114 107 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
115 108 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
116 109 > | grep '^[0-9]) ' # ignores HTML output
117 110 1) foo imported
118 111 1) bar imported
119 112 2) foo uisetup
120 113 2) bar uisetup
121 114 3) foo extsetup
122 115 3) bar extsetup
123 116 4) foo reposetup
124 117 4) bar reposetup
125 118 4) foo reposetup
126 119 4) bar reposetup
127 120
128 121 $ echo 'foo = !' >> $HGRCPATH
129 122 $ echo 'bar = !' >> $HGRCPATH
130 123
131 124 Check "from __future__ import absolute_import" support for external libraries
132 125
133 126 #if windows
134 127 $ PATHSEP=";"
135 128 #else
136 129 $ PATHSEP=":"
137 130 #endif
138 131 $ export PATHSEP
139 132
140 133 $ mkdir $TESTTMP/libroot
141 134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
142 135 $ mkdir $TESTTMP/libroot/mod
143 136 $ touch $TESTTMP/libroot/mod/__init__.py
144 137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
145 138
146 139 #if absimport
147 140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
148 141 > from __future__ import absolute_import
149 142 > import ambig # should load "libroot/ambig.py"
150 143 > s = ambig.s
151 144 > EOF
152 145 $ cat > loadabs.py <<EOF
153 146 > import mod.ambigabs as ambigabs
154 147 > def extsetup():
155 148 > print 'ambigabs.s=%s' % ambigabs.s
156 149 > EOF
157 150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
158 151 ambigabs.s=libroot/ambig.py
159 152 $TESTTMP/a (glob)
160 153 #endif
161 154
162 155 #if no-py3k
163 156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
164 157 > import ambig # should load "libroot/mod/ambig.py"
165 158 > s = ambig.s
166 159 > EOF
167 160 $ cat > loadrel.py <<EOF
168 161 > import mod.ambigrel as ambigrel
169 162 > def extsetup():
170 163 > print 'ambigrel.s=%s' % ambigrel.s
171 164 > EOF
172 165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
173 166 ambigrel.s=libroot/mod/ambig.py
174 167 $TESTTMP/a (glob)
175 168 #endif
176 169
177 170 Check absolute/relative import of extension specific modules
178 171
179 172 $ mkdir $TESTTMP/extroot
180 173 $ cat > $TESTTMP/extroot/bar.py <<EOF
181 174 > s = 'this is extroot.bar'
182 175 > EOF
183 176 $ mkdir $TESTTMP/extroot/sub1
184 177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
185 178 > s = 'this is extroot.sub1.__init__'
186 179 > EOF
187 180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
188 181 > s = 'this is extroot.sub1.baz'
189 182 > EOF
190 183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
191 184 > s = 'this is extroot.__init__'
192 185 > import foo
193 186 > def extsetup(ui):
194 187 > ui.write('(extroot) ', foo.func(), '\n')
195 188 > EOF
196 189
197 190 $ cat > $TESTTMP/extroot/foo.py <<EOF
198 191 > # test absolute import
199 192 > buf = []
200 193 > def func():
201 194 > # "not locals" case
202 195 > import extroot.bar
203 196 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
204 >
205 197 > return '\n(extroot) '.join(buf)
206 >
207 198 > # "fromlist == ('*',)" case
208 199 > from extroot.bar import *
209 200 > buf.append('from extroot.bar import *: %s' % s)
210 >
211 201 > # "not fromlist" and "if '.' in name" case
212 202 > import extroot.sub1.baz
213 203 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
214 >
215 204 > # "not fromlist" and NOT "if '.' in name" case
216 205 > import extroot
217 206 > buf.append('import extroot: %s' % extroot.s)
218 >
219 207 > # NOT "not fromlist" and NOT "level != -1" case
220 208 > from extroot.bar import s
221 209 > buf.append('from extroot.bar import s: %s' % s)
222 210 > EOF
223 211 $ hg --config extensions.extroot=$TESTTMP/extroot root
224 212 (extroot) from extroot.bar import *: this is extroot.bar
225 213 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
226 214 (extroot) import extroot: this is extroot.__init__
227 215 (extroot) from extroot.bar import s: this is extroot.bar
228 216 (extroot) import extroot.bar in func(): this is extroot.bar
229 217 $TESTTMP/a (glob)
230 218
231 219 #if no-py3k
232 220 $ rm "$TESTTMP"/extroot/foo.*
233 221 $ cat > $TESTTMP/extroot/foo.py <<EOF
234 222 > # test relative import
235 223 > buf = []
236 224 > def func():
237 225 > # "not locals" case
238 226 > import bar
239 227 > buf.append('import bar in func(): %s' % bar.s)
240 >
241 228 > return '\n(extroot) '.join(buf)
242 >
243 229 > # "fromlist == ('*',)" case
244 230 > from bar import *
245 231 > buf.append('from bar import *: %s' % s)
246 >
247 232 > # "not fromlist" and "if '.' in name" case
248 233 > import sub1.baz
249 234 > buf.append('import sub1.baz: %s' % sub1.baz.s)
250 >
251 235 > # "not fromlist" and NOT "if '.' in name" case
252 236 > import sub1
253 237 > buf.append('import sub1: %s' % sub1.s)
254 >
255 238 > # NOT "not fromlist" and NOT "level != -1" case
256 239 > from bar import s
257 240 > buf.append('from bar import s: %s' % s)
258 241 > EOF
259 242 $ hg --config extensions.extroot=$TESTTMP/extroot root
260 243 (extroot) from bar import *: this is extroot.bar
261 244 (extroot) import sub1.baz: this is extroot.sub1.baz
262 245 (extroot) import sub1: this is extroot.sub1.__init__
263 246 (extroot) from bar import s: this is extroot.bar
264 247 (extroot) import bar in func(): this is extroot.bar
265 248 $TESTTMP/a (glob)
266 249 #endif
267 250
268 251 $ cd ..
269 252
270 253 hide outer repo
271 254 $ hg init
272 255
273 256 $ cat > empty.py <<EOF
274 257 > '''empty cmdtable
275 258 > '''
276 259 > cmdtable = {}
277 260 > EOF
278 261 $ emptypath=`pwd`/empty.py
279 262 $ echo "empty = $emptypath" >> $HGRCPATH
280 263 $ hg help empty
281 264 empty extension - empty cmdtable
282 265
283 266 no commands defined
284 267
268
285 269 $ echo 'empty = !' >> $HGRCPATH
286 270
287 271 $ cat > debugextension.py <<EOF
288 272 > '''only debugcommands
289 273 > '''
290 274 > from mercurial import cmdutil
291 275 > cmdtable = {}
292 276 > command = cmdutil.command(cmdtable)
293 >
294 277 > @command('debugfoobar', [], 'hg debugfoobar')
295 278 > def debugfoobar(ui, repo, *args, **opts):
296 279 > "yet another debug command"
297 280 > pass
298 >
299 281 > @command('foo', [], 'hg foo')
300 282 > def foo(ui, repo, *args, **opts):
301 283 > """yet another foo command
302 >
303 284 > This command has been DEPRECATED since forever.
304 285 > """
305 286 > pass
306 287 > EOF
307 288 $ debugpath=`pwd`/debugextension.py
308 289 $ echo "debugextension = $debugpath" >> $HGRCPATH
309 290
310 291 $ hg help debugextension
311 292 debugextension extension - only debugcommands
312 293
313 294 no commands defined
314 295
296
315 297 $ hg --verbose help debugextension
316 298 debugextension extension - only debugcommands
317 299
318 300 list of commands:
319 301
320 302 foo yet another foo command
321 303
322 304 global options:
323 305
324 306 -R --repository REPO repository root directory or name of overlay bundle
325 307 file
326 308 --cwd DIR change working directory
327 309 -y --noninteractive do not prompt, automatically pick the first choice for
328 310 all prompts
329 311 -q --quiet suppress output
330 312 -v --verbose enable additional output
331 313 --config CONFIG [+] set/override config option (use 'section.name=value')
332 314 --debug enable debugging output
333 315 --debugger start debugger
334 316 --encoding ENCODE set the charset encoding (default: ascii)
335 317 --encodingmode MODE set the charset encoding mode (default: strict)
336 318 --traceback always print a traceback on exception
337 319 --time time how long the command takes
338 320 --profile print command execution profile
339 321 --version output version information and exit
340 322 -h --help display help and exit
341 323 --hidden consider hidden changesets
342 324
343 325 [+] marked option can be specified multiple times
344 326
327
328
329
330
331
345 332 $ hg --debug help debugextension
346 333 debugextension extension - only debugcommands
347 334
348 335 list of commands:
349 336
350 337 debugfoobar yet another debug command
351 338 foo yet another foo command
352 339
353 340 global options:
354 341
355 342 -R --repository REPO repository root directory or name of overlay bundle
356 343 file
357 344 --cwd DIR change working directory
358 345 -y --noninteractive do not prompt, automatically pick the first choice for
359 346 all prompts
360 347 -q --quiet suppress output
361 348 -v --verbose enable additional output
362 349 --config CONFIG [+] set/override config option (use 'section.name=value')
363 350 --debug enable debugging output
364 351 --debugger start debugger
365 352 --encoding ENCODE set the charset encoding (default: ascii)
366 353 --encodingmode MODE set the charset encoding mode (default: strict)
367 354 --traceback always print a traceback on exception
368 355 --time time how long the command takes
369 356 --profile print command execution profile
370 357 --version output version information and exit
371 358 -h --help display help and exit
372 359 --hidden consider hidden changesets
373 360
374 361 [+] marked option can be specified multiple times
362
363
364
365
366
375 367 $ echo 'debugextension = !' >> $HGRCPATH
376 368
377 369 Extension module help vs command help:
378 370
379 371 $ echo 'extdiff =' >> $HGRCPATH
380 372 $ hg help extdiff
381 373 hg extdiff [OPT]... [FILE]...
382 374
383 375 use external program to diff repository (or selected files)
384 376
385 377 Show differences between revisions for the specified files, using an
386 378 external program. The default program used is diff, with default options
387 379 "-Npru".
388 380
389 381 To select a different program, use the -p/--program option. The program
390 382 will be passed the names of two directories to compare. To pass additional
391 383 options to the program, use -o/--option. These will be passed before the
392 384 names of the directories to compare.
393 385
394 386 When two revision arguments are given, then changes are shown between
395 387 those revisions. If only one revision is specified then that revision is
396 388 compared to the working directory, and, when no revisions are specified,
397 389 the working directory files are compared to its parent.
398 390
399 391 use "hg help -e extdiff" to show help for the extdiff extension
400 392
401 393 options:
402 394
403 395 -p --program CMD comparison program to run
404 396 -o --option OPT [+] pass option to comparison program
405 397 -r --rev REV [+] revision
406 398 -c --change REV change made by revision
407 399 -I --include PATTERN [+] include names matching the given patterns
408 400 -X --exclude PATTERN [+] exclude names matching the given patterns
409 401
410 402 [+] marked option can be specified multiple times
411 403
412 404 use "hg -v help extdiff" to show the global options
413 405
406
407
408
409
410
411
412
413
414
414 415 $ hg help --extension extdiff
415 416 extdiff extension - command to allow external programs to compare revisions
416 417
417 418 The extdiff Mercurial extension allows you to use external programs to compare
418 419 revisions, or revision with working directory. The external diff programs are
419 420 called with a configurable set of options and two non-option arguments: paths
420 421 to directories containing snapshots of files to compare.
421 422
422 423 The extdiff extension also allows you to configure new diff commands, so you
423 424 do not need to type "hg extdiff -p kdiff3" always.
424 425
425 426 [extdiff]
426 427 # add new command that runs GNU diff(1) in 'context diff' mode
427 428 cdiff = gdiff -Nprc5
428 429 ## or the old way:
429 430 #cmd.cdiff = gdiff
430 431 #opts.cdiff = -Nprc5
431 432
432 433 # add new command called vdiff, runs kdiff3
433 434 vdiff = kdiff3
434 435
435 436 # add new command called meld, runs meld (no need to name twice)
436 437 meld =
437 438
438 439 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
439 440 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
440 441 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
441 442 # your .vimrc
442 443 vimdiff = gvim -f "+next" \
443 444 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
444 445
445 446 Tool arguments can include variables that are expanded at runtime:
446 447
447 448 $parent1, $plabel1 - filename, descriptive label of first parent
448 449 $child, $clabel - filename, descriptive label of child revision
449 450 $parent2, $plabel2 - filename, descriptive label of second parent
450 451 $root - repository root
451 452 $parent is an alias for $parent1.
452 453
453 454 The extdiff extension will look in your [diff-tools] and [merge-tools]
454 455 sections for diff tool arguments, when none are specified in [extdiff].
455 456
456 457 [extdiff]
457 458 kdiff3 =
458 459
459 460 [diff-tools]
460 461 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
461 462
462 463 You can use -I/-X and list of file or directory names like normal "hg diff"
463 464 command. The extdiff extension makes snapshots of only needed files, so
464 465 running the external diff program will actually be pretty fast (at least
465 466 faster than having to compare the entire tree).
466 467
467 468 list of commands:
468 469
469 470 extdiff use external program to diff repository (or selected files)
470 471
471 472 use "hg -v help extdiff" to show builtin aliases and global options
472 473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
473 489 $ echo 'extdiff = !' >> $HGRCPATH
474 490
475 491 Test help topic with same name as extension
476 492
477 493 $ cat > multirevs.py <<EOF
478 494 > from mercurial import cmdutil, commands
479 495 > cmdtable = {}
480 496 > command = cmdutil.command(cmdtable)
481 497 > """multirevs extension
482 498 > Big multi-line module docstring."""
483 499 > @command('multirevs', [], 'ARG', norepo=True)
484 500 > def multirevs(ui, repo, arg, *args, **opts):
485 501 > """multirevs command"""
486 502 > pass
487 503 > EOF
488 504 $ echo "multirevs = multirevs.py" >> $HGRCPATH
489 505
490 506 $ hg help multirevs
491 507 Specifying Multiple Revisions
492 508 """""""""""""""""""""""""""""
493 509
494 510 When Mercurial accepts more than one revision, they may be specified
495 511 individually, or provided as a topologically continuous range, separated
496 512 by the ":" character.
497 513
498 514 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
499 515 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
500 516 specified, it defaults to revision number 0. If END is not specified, it
501 517 defaults to the tip. The range ":" thus means "all revisions".
502 518
503 519 If BEGIN is greater than END, revisions are treated in reverse order.
504 520
505 521 A range acts as a closed interval. This means that a range of 3:5 gives 3,
506 522 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
507 523
508 524 use "hg help -c multirevs" to see help for the multirevs command
509 525
526
527
528
529
530
510 531 $ hg help -c multirevs
511 532 hg multirevs ARG
512 533
513 534 multirevs command
514 535
515 536 use "hg -v help multirevs" to show the global options
516 537
538
539
517 540 $ hg multirevs
518 541 hg multirevs: invalid arguments
519 542 hg multirevs ARG
520 543
521 544 multirevs command
522 545
523 546 use "hg help multirevs" to show the full help text
524 547 [255]
525 548
549
550
526 551 $ echo "multirevs = !" >> $HGRCPATH
527 552
528 553 Issue811: Problem loading extensions twice (by site and by user)
529 554
530 555 $ debugpath=`pwd`/debugissue811.py
531 556 $ cat > debugissue811.py <<EOF
532 557 > '''show all loaded extensions
533 558 > '''
534 559 > from mercurial import cmdutil, commands, extensions
535 560 > cmdtable = {}
536 561 > command = cmdutil.command(cmdtable)
537 >
538 562 > @command('debugextensions', [], 'hg debugextensions', norepo=True)
539 563 > def debugextensions(ui):
540 564 > "yet another debug command"
541 565 > ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
542 >
543 566 > EOF
544 567 $ echo "debugissue811 = $debugpath" >> $HGRCPATH
545 568 $ echo "mq=" >> $HGRCPATH
546 569 $ echo "strip=" >> $HGRCPATH
547 570 $ echo "hgext.mq=" >> $HGRCPATH
548 571 $ echo "hgext/mq=" >> $HGRCPATH
549 572
550 573 Show extensions:
551 574 (note that mq force load strip, also checking it's not loaded twice)
552 575
553 576 $ hg debugextensions
554 577 debugissue811
555 578 strip
556 579 mq
557 580
558 581 Disabled extension commands:
559 582
560 583 $ ORGHGRCPATH=$HGRCPATH
561 584 $ HGRCPATH=
562 585 $ export HGRCPATH
563 586 $ hg help email
564 587 'email' is provided by the following extension:
565 588
566 589 patchbomb command to send changesets as (a series of) patch emails
567 590
568 591 use "hg help extensions" for information on enabling extensions
592
593
569 594 $ hg qdel
570 595 hg: unknown command 'qdel'
571 596 'qdelete' is provided by the following extension:
572 597
573 598 mq manage a stack of patches
574 599
575 600 use "hg help extensions" for information on enabling extensions
576 601 [255]
602
603
577 604 $ hg churn
578 605 hg: unknown command 'churn'
579 606 'churn' is provided by the following extension:
580 607
581 608 churn command to display statistics about repository history
582 609
583 610 use "hg help extensions" for information on enabling extensions
584 611 [255]
585 612
613
614
586 615 Disabled extensions:
587 616
588 617 $ hg help churn
589 618 churn extension - command to display statistics about repository history
590 619
591 620 use "hg help extensions" for information on enabling extensions
621
592 622 $ hg help patchbomb
593 623 patchbomb extension - command to send changesets as (a series of) patch emails
594 624
595 625 use "hg help extensions" for information on enabling extensions
596 626
627
597 628 Broken disabled extension and command:
598 629
599 630 $ mkdir hgext
600 631 $ echo > hgext/__init__.py
601 632 $ cat > hgext/broken.py <<EOF
602 633 > "broken extension'
603 634 > EOF
604 635 $ cat > path.py <<EOF
605 636 > import os, sys
606 637 > sys.path.insert(0, os.environ['HGEXTPATH'])
607 638 > EOF
608 639 $ HGEXTPATH=`pwd`
609 640 $ export HGEXTPATH
610 641
611 642 $ hg --config extensions.path=./path.py help broken
612 643 broken extension - (no help text available)
613 644
614 645 use "hg help extensions" for information on enabling extensions
615 646
647
616 648 $ cat > hgext/forest.py <<EOF
617 649 > cmdtable = None
618 650 > EOF
619 651 $ hg --config extensions.path=./path.py help foo > /dev/null
620 652 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
621 653 abort: no such help topic: foo
622 654 (try "hg help --keyword foo")
623 655 [255]
624 656
625 657 $ cat > throw.py <<EOF
626 658 > from mercurial import cmdutil, commands
627 659 > cmdtable = {}
628 660 > command = cmdutil.command(cmdtable)
629 661 > class Bogon(Exception): pass
630 >
631 662 > @command('throw', [], 'hg throw', norepo=True)
632 663 > def throw(ui, **opts):
633 664 > """throws an exception"""
634 665 > raise Bogon()
635 666 > EOF
636 667 No declared supported version, extension complains:
637 668 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
638 669 ** Unknown exception encountered with possibly-broken third-party extension throw
639 670 ** which supports versions unknown of Mercurial.
640 671 ** Please disable throw and try your action again.
641 672 ** If that fixes the bug please report it to the extension author.
642 673 ** Python * (glob)
643 674 ** Mercurial Distributed SCM * (glob)
644 675 ** Extensions loaded: throw
645 676 empty declaration of supported version, extension complains:
646 677 $ echo "testedwith = ''" >> throw.py
647 678 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
648 679 ** Unknown exception encountered with possibly-broken third-party extension throw
649 680 ** which supports versions unknown of Mercurial.
650 681 ** Please disable throw and try your action again.
651 682 ** If that fixes the bug please report it to the extension author.
652 683 ** Python * (glob)
653 684 ** Mercurial Distributed SCM (*) (glob)
654 685 ** Extensions loaded: throw
655 686 If the extension specifies a buglink, show that:
656 687 $ echo 'buglink = "http://example.com/bts"' >> throw.py
657 688 $ rm -f throw.pyc throw.pyo
658 689 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
659 690 ** Unknown exception encountered with possibly-broken third-party extension throw
660 691 ** which supports versions unknown of Mercurial.
661 692 ** Please disable throw and try your action again.
662 693 ** If that fixes the bug please report it to http://example.com/bts
663 694 ** Python * (glob)
664 695 ** Mercurial Distributed SCM (*) (glob)
665 696 ** Extensions loaded: throw
666 697 If the extensions declare outdated versions, accuse the older extension first:
667 698 $ echo "from mercurial import util" >> older.py
668 699 $ echo "util.version = lambda:'2.2'" >> older.py
669 700 $ echo "testedwith = '1.9.3'" >> older.py
670 701 $ echo "testedwith = '2.1.1'" >> throw.py
671 702 $ rm -f throw.pyc throw.pyo
672 703 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
673 704 > throw 2>&1 | egrep '^\*\*'
674 705 ** Unknown exception encountered with possibly-broken third-party extension older
675 706 ** which supports versions 1.9.3 of Mercurial.
676 707 ** Please disable older and try your action again.
677 708 ** If that fixes the bug please report it to the extension author.
678 709 ** Python * (glob)
679 710 ** Mercurial Distributed SCM (version 2.2)
680 711 ** Extensions loaded: throw, older
681 712 One extension only tested with older, one only with newer versions:
682 713 $ echo "util.version = lambda:'2.1.0'" >> older.py
683 714 $ rm -f older.pyc older.pyo
684 715 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
685 716 > throw 2>&1 | egrep '^\*\*'
686 717 ** Unknown exception encountered with possibly-broken third-party extension older
687 718 ** which supports versions 1.9.3 of Mercurial.
688 719 ** Please disable older and try your action again.
689 720 ** If that fixes the bug please report it to the extension author.
690 721 ** Python * (glob)
691 722 ** Mercurial Distributed SCM (version 2.1.0)
692 723 ** Extensions loaded: throw, older
693 724 Older extension is tested with current version, the other only with newer:
694 725 $ echo "util.version = lambda:'1.9.3'" >> older.py
695 726 $ rm -f older.pyc older.pyo
696 727 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
697 728 > throw 2>&1 | egrep '^\*\*'
698 729 ** Unknown exception encountered with possibly-broken third-party extension throw
699 730 ** which supports versions 2.1.1 of Mercurial.
700 731 ** Please disable throw and try your action again.
701 732 ** If that fixes the bug please report it to http://example.com/bts
702 733 ** Python * (glob)
703 734 ** Mercurial Distributed SCM (version 1.9.3)
704 735 ** Extensions loaded: throw, older
705 736
706 737 Declare the version as supporting this hg version, show regular bts link:
707 738 $ hgver=`python -c 'from mercurial import util; print util.version().split("+")[0]'`
708 739 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
709 740 $ rm -f throw.pyc throw.pyo
710 741 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
711 742 ** unknown exception encountered, please report by visiting
712 743 ** http://mercurial.selenic.com/wiki/BugTracker
713 744 ** Python * (glob)
714 745 ** Mercurial Distributed SCM (*) (glob)
715 746 ** Extensions loaded: throw
716 747
748 Test version number support in 'hg version':
749 $ echo '__version__ = (1, 2, 3)' >> throw.py
750 $ rm -f throw.pyc throw.pyo
751 $ hg version -v --config extensions.throw=throw.py
752 Mercurial Distributed SCM (version *) (glob)
753 (see http://mercurial.selenic.com for more information)
754
755 Copyright (C) 2005-* Matt Mackall and others (glob)
756 This is free software; see the source for copying conditions. There is NO
757 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
758
759 Enabled extensions:
760
761 throw 1.2.3
762 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
763 $ rm -f throw.pyc throw.pyo
764 $ hg version -v --config extensions.throw=throw.py
765 Mercurial Distributed SCM (version *) (glob)
766 (see http://mercurial.selenic.com for more information)
767
768 Copyright (C) 2005-* Matt Mackall and others (glob)
769 This is free software; see the source for copying conditions. There is NO
770 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
771
772 Enabled extensions:
773
774 throw 1.twentythree
775
717 776 Restore HGRCPATH
718 777
719 778 $ HGRCPATH=$ORGHGRCPATH
720 779 $ export HGRCPATH
721 780
722 781 Commands handling multiple repositories at a time should invoke only
723 782 "reposetup()" of extensions enabling in the target repository.
724 783
725 784 $ mkdir reposetup-test
726 785 $ cd reposetup-test
727 786
728 787 $ cat > $TESTTMP/reposetuptest.py <<EOF
729 788 > from mercurial import extensions
730 789 > def reposetup(ui, repo):
731 790 > ui.write('reposetup() for %s\n' % (repo.root))
732 791 > EOF
733 792 $ hg init src
734 793 $ echo a > src/a
735 794 $ hg -R src commit -Am '#0 at src/a'
736 795 adding a
737 796 $ echo '[extensions]' >> src/.hg/hgrc
738 797 $ echo '# enable extension locally' >> src/.hg/hgrc
739 798 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
740 799 $ hg -R src status
741 800 reposetup() for $TESTTMP/reposetup-test/src (glob)
742 801
743 802 $ hg clone -U src clone-dst1
744 803 reposetup() for $TESTTMP/reposetup-test/src (glob)
745 804 $ hg init push-dst1
746 805 $ hg -q -R src push push-dst1
747 806 reposetup() for $TESTTMP/reposetup-test/src (glob)
748 807 $ hg init pull-src1
749 808 $ hg -q -R pull-src1 pull src
750 809 reposetup() for $TESTTMP/reposetup-test/src (glob)
751 810
752 811 $ echo '[extensions]' >> $HGRCPATH
753 812 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
754 813 $ echo 'reposetuptest = !' >> $HGRCPATH
755 814 $ hg clone -U src clone-dst2
756 815 reposetup() for $TESTTMP/reposetup-test/src (glob)
757 816 $ hg init push-dst2
758 817 $ hg -q -R src push push-dst2
759 818 reposetup() for $TESTTMP/reposetup-test/src (glob)
760 819 $ hg init pull-src2
761 820 $ hg -q -R pull-src2 pull src
762 821 reposetup() for $TESTTMP/reposetup-test/src (glob)
763 822
764 823 $ echo '[extensions]' >> $HGRCPATH
765 824 $ echo '# enable extension globally' >> $HGRCPATH
766 825 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> $HGRCPATH
767 826 $ hg clone -U src clone-dst3
768 827 reposetup() for $TESTTMP/reposetup-test/src (glob)
769 828 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
770 829 $ hg init push-dst3
771 830 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
772 831 $ hg -q -R src push push-dst3
773 832 reposetup() for $TESTTMP/reposetup-test/src (glob)
774 833 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
775 834 $ hg init pull-src3
776 835 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
777 836 $ hg -q -R pull-src3 pull src
778 837 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
779 838 reposetup() for $TESTTMP/reposetup-test/src (glob)
780 839
781 840 $ echo '[extensions]' >> src/.hg/hgrc
782 841 $ echo '# disable extension locally' >> src/.hg/hgrc
783 842 $ echo 'reposetuptest = !' >> src/.hg/hgrc
784 843 $ hg clone -U src clone-dst4
785 844 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
786 845 $ hg init push-dst4
787 846 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
788 847 $ hg -q -R src push push-dst4
789 848 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
790 849 $ hg init pull-src4
791 850 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
792 851 $ hg -q -R pull-src4 pull src
793 852 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
794 853
795 854 disabling in command line overlays with all configuration
796 855 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
797 856 $ hg --config extensions.reposetuptest=! init push-dst5
798 857 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
799 858 $ hg --config extensions.reposetuptest=! init pull-src5
800 859 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
801 860
802 861 $ echo '[extensions]' >> $HGRCPATH
803 862 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
804 863 $ echo 'reposetuptest = !' >> $HGRCPATH
805 864 $ hg init parent
806 865 $ hg init parent/sub1
807 866 $ echo 1 > parent/sub1/1
808 867 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
809 868 adding 1
810 869 $ hg init parent/sub2
811 870 $ hg init parent/sub2/sub21
812 871 $ echo 21 > parent/sub2/sub21/21
813 872 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
814 873 adding 21
815 874 $ cat > parent/sub2/.hgsub <<EOF
816 875 > sub21 = sub21
817 876 > EOF
818 877 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
819 878 adding .hgsub
820 879 $ hg init parent/sub3
821 880 $ echo 3 > parent/sub3/3
822 881 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
823 882 adding 3
824 883 $ cat > parent/.hgsub <<EOF
825 884 > sub1 = sub1
826 885 > sub2 = sub2
827 886 > sub3 = sub3
828 887 > EOF
829 888 $ hg -R parent commit -Am '#0 at parent'
830 889 adding .hgsub
831 890 $ echo '[extensions]' >> parent/.hg/hgrc
832 891 $ echo '# enable extension locally' >> parent/.hg/hgrc
833 892 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
834 893 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
835 894 $ hg -R parent status -S -A
836 895 reposetup() for $TESTTMP/reposetup-test/parent (glob)
837 896 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
838 897 C .hgsub
839 898 C .hgsubstate
840 899 C sub1/1
841 900 C sub2/.hgsub
842 901 C sub2/.hgsubstate
843 902 C sub2/sub21/21
844 903 C sub3/3
845 904
846 905 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now