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