##// END OF EJS Templates
tests: use debuginstall to retrieve hg version
timeless -
r29198:a3e5e1fb default
parent child Browse files
Show More
@@ -1,1270 +1,1270 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 6 > cmdtable = {}
7 7 > command = cmdutil.command(cmdtable)
8 8 > def uisetup(ui):
9 9 > ui.write("uisetup called\\n")
10 10 > ui.flush()
11 11 > def reposetup(ui, repo):
12 12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
13 13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
14 14 > ui.flush()
15 15 > @command('foo', [], 'hg foo')
16 16 > def foo(ui, *args, **kwargs):
17 17 > ui.write("Foo\\n")
18 18 > @command('bar', [], 'hg bar', norepo=True)
19 19 > def bar(ui, *args, **kwargs):
20 20 > ui.write("Bar\\n")
21 21 > EOF
22 22 $ abspath=`pwd`/foobar.py
23 23
24 24 $ mkdir barfoo
25 25 $ cp foobar.py barfoo/__init__.py
26 26 $ barfoopath=`pwd`/barfoo
27 27
28 28 $ hg init a
29 29 $ cd a
30 30 $ echo foo > file
31 31 $ hg add file
32 32 $ hg commit -m 'add file'
33 33
34 34 $ echo '[extensions]' >> $HGRCPATH
35 35 $ echo "foobar = $abspath" >> $HGRCPATH
36 36 $ hg foo
37 37 uisetup called
38 38 reposetup called for a
39 39 ui == repo.ui
40 40 Foo
41 41
42 42 $ cd ..
43 43 $ hg clone a b
44 44 uisetup called
45 45 reposetup called for a
46 46 ui == repo.ui
47 47 reposetup called for b
48 48 ui == repo.ui
49 49 updating to branch default
50 50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 51
52 52 $ hg bar
53 53 uisetup called
54 54 Bar
55 55 $ echo 'foobar = !' >> $HGRCPATH
56 56
57 57 module/__init__.py-style
58 58
59 59 $ echo "barfoo = $barfoopath" >> $HGRCPATH
60 60 $ cd a
61 61 $ hg foo
62 62 uisetup called
63 63 reposetup called for a
64 64 ui == repo.ui
65 65 Foo
66 66 $ echo 'barfoo = !' >> $HGRCPATH
67 67
68 68 Check that extensions are loaded in phases:
69 69
70 70 $ cat > foo.py <<EOF
71 71 > import os
72 72 > name = os.path.basename(__file__).rsplit('.', 1)[0]
73 73 > print "1) %s imported" % name
74 74 > def uisetup(ui):
75 75 > print "2) %s uisetup" % name
76 76 > def extsetup():
77 77 > print "3) %s extsetup" % name
78 78 > def reposetup(ui, repo):
79 79 > print "4) %s reposetup" % name
80 80 > EOF
81 81
82 82 $ cp foo.py bar.py
83 83 $ echo 'foo = foo.py' >> $HGRCPATH
84 84 $ echo 'bar = bar.py' >> $HGRCPATH
85 85
86 86 Command with no output, we just want to see the extensions loaded:
87 87
88 88 $ hg paths
89 89 1) foo imported
90 90 1) bar imported
91 91 2) foo uisetup
92 92 2) bar uisetup
93 93 3) foo extsetup
94 94 3) bar extsetup
95 95 4) foo reposetup
96 96 4) bar reposetup
97 97
98 98 Check hgweb's load order:
99 99
100 100 $ cat > hgweb.cgi <<EOF
101 101 > #!/usr/bin/env python
102 102 > from mercurial import demandimport; demandimport.enable()
103 103 > from mercurial.hgweb import hgweb
104 104 > from mercurial.hgweb import wsgicgi
105 105 > application = hgweb('.', 'test repo')
106 106 > wsgicgi.launch(application)
107 107 > EOF
108 108
109 109 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
110 110 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
111 111 > | grep '^[0-9]) ' # ignores HTML output
112 112 1) foo imported
113 113 1) bar imported
114 114 2) foo uisetup
115 115 2) bar uisetup
116 116 3) foo extsetup
117 117 3) bar extsetup
118 118 4) foo reposetup
119 119 4) bar reposetup
120 120
121 121 $ echo 'foo = !' >> $HGRCPATH
122 122 $ echo 'bar = !' >> $HGRCPATH
123 123
124 124 Check "from __future__ import absolute_import" support for external libraries
125 125
126 126 #if windows
127 127 $ PATHSEP=";"
128 128 #else
129 129 $ PATHSEP=":"
130 130 #endif
131 131 $ export PATHSEP
132 132
133 133 $ mkdir $TESTTMP/libroot
134 134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
135 135 $ mkdir $TESTTMP/libroot/mod
136 136 $ touch $TESTTMP/libroot/mod/__init__.py
137 137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
138 138
139 139 #if absimport
140 140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
141 141 > from __future__ import absolute_import
142 142 > import ambig # should load "libroot/ambig.py"
143 143 > s = ambig.s
144 144 > EOF
145 145 $ cat > loadabs.py <<EOF
146 146 > import mod.ambigabs as ambigabs
147 147 > def extsetup():
148 148 > print 'ambigabs.s=%s' % ambigabs.s
149 149 > EOF
150 150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
151 151 ambigabs.s=libroot/ambig.py
152 152 $TESTTMP/a (glob)
153 153 #endif
154 154
155 155 #if no-py3k
156 156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
157 157 > import ambig # should load "libroot/mod/ambig.py"
158 158 > s = ambig.s
159 159 > EOF
160 160 $ cat > loadrel.py <<EOF
161 161 > import mod.ambigrel as ambigrel
162 162 > def extsetup():
163 163 > print 'ambigrel.s=%s' % ambigrel.s
164 164 > EOF
165 165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
166 166 ambigrel.s=libroot/mod/ambig.py
167 167 $TESTTMP/a (glob)
168 168 #endif
169 169
170 170 Check absolute/relative import of extension specific modules
171 171
172 172 $ mkdir $TESTTMP/extroot
173 173 $ cat > $TESTTMP/extroot/bar.py <<EOF
174 174 > s = 'this is extroot.bar'
175 175 > EOF
176 176 $ mkdir $TESTTMP/extroot/sub1
177 177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
178 178 > s = 'this is extroot.sub1.__init__'
179 179 > EOF
180 180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
181 181 > s = 'this is extroot.sub1.baz'
182 182 > EOF
183 183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
184 184 > s = 'this is extroot.__init__'
185 185 > import foo
186 186 > def extsetup(ui):
187 187 > ui.write('(extroot) ', foo.func(), '\n')
188 188 > ui.flush()
189 189 > EOF
190 190
191 191 $ cat > $TESTTMP/extroot/foo.py <<EOF
192 192 > # test absolute import
193 193 > buf = []
194 194 > def func():
195 195 > # "not locals" case
196 196 > import extroot.bar
197 197 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
198 198 > return '\n(extroot) '.join(buf)
199 199 > # "fromlist == ('*',)" case
200 200 > from extroot.bar import *
201 201 > buf.append('from extroot.bar import *: %s' % s)
202 202 > # "not fromlist" and "if '.' in name" case
203 203 > import extroot.sub1.baz
204 204 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
205 205 > # "not fromlist" and NOT "if '.' in name" case
206 206 > import extroot
207 207 > buf.append('import extroot: %s' % extroot.s)
208 208 > # NOT "not fromlist" and NOT "level != -1" case
209 209 > from extroot.bar import s
210 210 > buf.append('from extroot.bar import s: %s' % s)
211 211 > EOF
212 212 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
213 213 (extroot) from extroot.bar import *: this is extroot.bar
214 214 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
215 215 (extroot) import extroot: this is extroot.__init__
216 216 (extroot) from extroot.bar import s: this is extroot.bar
217 217 (extroot) import extroot.bar in func(): this is extroot.bar
218 218 $TESTTMP/a (glob)
219 219
220 220 #if no-py3k
221 221 $ rm "$TESTTMP"/extroot/foo.*
222 222 $ cat > $TESTTMP/extroot/foo.py <<EOF
223 223 > # test relative import
224 224 > buf = []
225 225 > def func():
226 226 > # "not locals" case
227 227 > import bar
228 228 > buf.append('import bar in func(): %s' % bar.s)
229 229 > return '\n(extroot) '.join(buf)
230 230 > # "fromlist == ('*',)" case
231 231 > from bar import *
232 232 > buf.append('from bar import *: %s' % s)
233 233 > # "not fromlist" and "if '.' in name" case
234 234 > import sub1.baz
235 235 > buf.append('import sub1.baz: %s' % sub1.baz.s)
236 236 > # "not fromlist" and NOT "if '.' in name" case
237 237 > import sub1
238 238 > buf.append('import sub1: %s' % sub1.s)
239 239 > # NOT "not fromlist" and NOT "level != -1" case
240 240 > from bar import s
241 241 > buf.append('from bar import s: %s' % s)
242 242 > EOF
243 243 $ hg --config extensions.extroot=$TESTTMP/extroot root
244 244 (extroot) from bar import *: this is extroot.bar
245 245 (extroot) import sub1.baz: this is extroot.sub1.baz
246 246 (extroot) import sub1: this is extroot.sub1.__init__
247 247 (extroot) from bar import s: this is extroot.bar
248 248 (extroot) import bar in func(): this is extroot.bar
249 249 $TESTTMP/a (glob)
250 250 #endif
251 251
252 252 $ cd ..
253 253
254 254 hide outer repo
255 255 $ hg init
256 256
257 257 $ cat > empty.py <<EOF
258 258 > '''empty cmdtable
259 259 > '''
260 260 > cmdtable = {}
261 261 > EOF
262 262 $ emptypath=`pwd`/empty.py
263 263 $ echo "empty = $emptypath" >> $HGRCPATH
264 264 $ hg help empty
265 265 empty extension - empty cmdtable
266 266
267 267 no commands defined
268 268
269 269
270 270 $ echo 'empty = !' >> $HGRCPATH
271 271
272 272 $ cat > debugextension.py <<EOF
273 273 > '''only debugcommands
274 274 > '''
275 275 > from mercurial import cmdutil
276 276 > cmdtable = {}
277 277 > command = cmdutil.command(cmdtable)
278 278 > @command('debugfoobar', [], 'hg debugfoobar')
279 279 > def debugfoobar(ui, repo, *args, **opts):
280 280 > "yet another debug command"
281 281 > pass
282 282 > @command('foo', [], 'hg foo')
283 283 > def foo(ui, repo, *args, **opts):
284 284 > """yet another foo command
285 285 > This command has been DEPRECATED since forever.
286 286 > """
287 287 > pass
288 288 > EOF
289 289 $ debugpath=`pwd`/debugextension.py
290 290 $ echo "debugextension = $debugpath" >> $HGRCPATH
291 291
292 292 $ hg help debugextension
293 293 hg debugextensions
294 294
295 295 show information about active extensions
296 296
297 297 options:
298 298
299 299 (some details hidden, use --verbose to show complete help)
300 300
301 301
302 302 $ hg --verbose help debugextension
303 303 hg debugextensions
304 304
305 305 show information about active extensions
306 306
307 307 options:
308 308
309 309 -T --template TEMPLATE display with template (EXPERIMENTAL)
310 310
311 311 global options ([+] can be repeated):
312 312
313 313 -R --repository REPO repository root directory or name of overlay bundle
314 314 file
315 315 --cwd DIR change working directory
316 316 -y --noninteractive do not prompt, automatically pick the first choice for
317 317 all prompts
318 318 -q --quiet suppress output
319 319 -v --verbose enable additional output
320 320 --config CONFIG [+] set/override config option (use 'section.name=value')
321 321 --debug enable debugging output
322 322 --debugger start debugger
323 323 --encoding ENCODE set the charset encoding (default: ascii)
324 324 --encodingmode MODE set the charset encoding mode (default: strict)
325 325 --traceback always print a traceback on exception
326 326 --time time how long the command takes
327 327 --profile print command execution profile
328 328 --version output version information and exit
329 329 -h --help display help and exit
330 330 --hidden consider hidden changesets
331 331
332 332
333 333
334 334
335 335
336 336
337 337 $ hg --debug help debugextension
338 338 hg debugextensions
339 339
340 340 show information about active extensions
341 341
342 342 options:
343 343
344 344 -T --template TEMPLATE display with template (EXPERIMENTAL)
345 345
346 346 global options ([+] can be repeated):
347 347
348 348 -R --repository REPO repository root directory or name of overlay bundle
349 349 file
350 350 --cwd DIR change working directory
351 351 -y --noninteractive do not prompt, automatically pick the first choice for
352 352 all prompts
353 353 -q --quiet suppress output
354 354 -v --verbose enable additional output
355 355 --config CONFIG [+] set/override config option (use 'section.name=value')
356 356 --debug enable debugging output
357 357 --debugger start debugger
358 358 --encoding ENCODE set the charset encoding (default: ascii)
359 359 --encodingmode MODE set the charset encoding mode (default: strict)
360 360 --traceback always print a traceback on exception
361 361 --time time how long the command takes
362 362 --profile print command execution profile
363 363 --version output version information and exit
364 364 -h --help display help and exit
365 365 --hidden consider hidden changesets
366 366
367 367
368 368
369 369
370 370
371 371 $ echo 'debugextension = !' >> $HGRCPATH
372 372
373 373 Asking for help about a deprecated extension should do something useful:
374 374
375 375 $ hg help glog
376 376 'glog' is provided by the following extension:
377 377
378 378 graphlog command to view revision graphs from a shell (DEPRECATED)
379 379
380 380 (use "hg help extensions" for information on enabling extensions)
381 381
382 382 Extension module help vs command help:
383 383
384 384 $ echo 'extdiff =' >> $HGRCPATH
385 385 $ hg help extdiff
386 386 hg extdiff [OPT]... [FILE]...
387 387
388 388 use external program to diff repository (or selected files)
389 389
390 390 Show differences between revisions for the specified files, using an
391 391 external program. The default program used is diff, with default options
392 392 "-Npru".
393 393
394 394 To select a different program, use the -p/--program option. The program
395 395 will be passed the names of two directories to compare. To pass additional
396 396 options to the program, use -o/--option. These will be passed before the
397 397 names of the directories to compare.
398 398
399 399 When two revision arguments are given, then changes are shown between
400 400 those revisions. If only one revision is specified then that revision is
401 401 compared to the working directory, and, when no revisions are specified,
402 402 the working directory files are compared to its parent.
403 403
404 404 (use "hg help -e extdiff" to show help for the extdiff extension)
405 405
406 406 options ([+] can be repeated):
407 407
408 408 -p --program CMD comparison program to run
409 409 -o --option OPT [+] pass option to comparison program
410 410 -r --rev REV [+] revision
411 411 -c --change REV change made by revision
412 412 --patch compare patches for two revisions
413 413 -I --include PATTERN [+] include names matching the given patterns
414 414 -X --exclude PATTERN [+] exclude names matching the given patterns
415 415 -S --subrepos recurse into subrepositories
416 416
417 417 (some details hidden, use --verbose to show complete help)
418 418
419 419
420 420
421 421
422 422
423 423
424 424
425 425
426 426
427 427
428 428 $ hg help --extension extdiff
429 429 extdiff extension - command to allow external programs to compare revisions
430 430
431 431 The extdiff Mercurial extension allows you to use external programs to compare
432 432 revisions, or revision with working directory. The external diff programs are
433 433 called with a configurable set of options and two non-option arguments: paths
434 434 to directories containing snapshots of files to compare.
435 435
436 436 The extdiff extension also allows you to configure new diff commands, so you
437 437 do not need to type 'hg extdiff -p kdiff3' always.
438 438
439 439 [extdiff]
440 440 # add new command that runs GNU diff(1) in 'context diff' mode
441 441 cdiff = gdiff -Nprc5
442 442 ## or the old way:
443 443 #cmd.cdiff = gdiff
444 444 #opts.cdiff = -Nprc5
445 445
446 446 # add new command called meld, runs meld (no need to name twice). If
447 447 # the meld executable is not available, the meld tool in [merge-tools]
448 448 # will be used, if available
449 449 meld =
450 450
451 451 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
452 452 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
453 453 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
454 454 # your .vimrc
455 455 vimdiff = gvim -f "+next" \
456 456 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
457 457
458 458 Tool arguments can include variables that are expanded at runtime:
459 459
460 460 $parent1, $plabel1 - filename, descriptive label of first parent
461 461 $child, $clabel - filename, descriptive label of child revision
462 462 $parent2, $plabel2 - filename, descriptive label of second parent
463 463 $root - repository root
464 464 $parent is an alias for $parent1.
465 465
466 466 The extdiff extension will look in your [diff-tools] and [merge-tools]
467 467 sections for diff tool arguments, when none are specified in [extdiff].
468 468
469 469 [extdiff]
470 470 kdiff3 =
471 471
472 472 [diff-tools]
473 473 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
474 474
475 475 You can use -I/-X and list of file or directory names like normal 'hg diff'
476 476 command. The extdiff extension makes snapshots of only needed files, so
477 477 running the external diff program will actually be pretty fast (at least
478 478 faster than having to compare the entire tree).
479 479
480 480 list of commands:
481 481
482 482 extdiff use external program to diff repository (or selected files)
483 483
484 484 (use "hg help -v -e extdiff" to show built-in aliases and global options)
485 485
486 486
487 487
488 488
489 489
490 490
491 491
492 492
493 493
494 494
495 495
496 496
497 497
498 498
499 499
500 500
501 501 $ echo 'extdiff = !' >> $HGRCPATH
502 502
503 503 Test help topic with same name as extension
504 504
505 505 $ cat > multirevs.py <<EOF
506 506 > from mercurial import cmdutil, commands
507 507 > cmdtable = {}
508 508 > command = cmdutil.command(cmdtable)
509 509 > """multirevs extension
510 510 > Big multi-line module docstring."""
511 511 > @command('multirevs', [], 'ARG', norepo=True)
512 512 > def multirevs(ui, repo, arg, *args, **opts):
513 513 > """multirevs command"""
514 514 > pass
515 515 > EOF
516 516 $ echo "multirevs = multirevs.py" >> $HGRCPATH
517 517
518 518 $ hg help multirevs
519 519 Specifying Multiple Revisions
520 520 """""""""""""""""""""""""""""
521 521
522 522 When Mercurial accepts more than one revision, they may be specified
523 523 individually, or provided as a topologically continuous range, separated
524 524 by the ":" character.
525 525
526 526 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
527 527 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
528 528 specified, it defaults to revision number 0. If END is not specified, it
529 529 defaults to the tip. The range ":" thus means "all revisions".
530 530
531 531 If BEGIN is greater than END, revisions are treated in reverse order.
532 532
533 533 A range acts as a closed interval. This means that a range of 3:5 gives 3,
534 534 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
535 535
536 536 use "hg help -c multirevs" to see help for the multirevs command
537 537
538 538
539 539
540 540
541 541
542 542
543 543 $ hg help -c multirevs
544 544 hg multirevs ARG
545 545
546 546 multirevs command
547 547
548 548 (some details hidden, use --verbose to show complete help)
549 549
550 550
551 551
552 552 $ hg multirevs
553 553 hg multirevs: invalid arguments
554 554 hg multirevs ARG
555 555
556 556 multirevs command
557 557
558 558 (use "hg multirevs -h" to show more help)
559 559 [255]
560 560
561 561
562 562
563 563 $ echo "multirevs = !" >> $HGRCPATH
564 564
565 565 Issue811: Problem loading extensions twice (by site and by user)
566 566
567 567 $ cat <<EOF >> $HGRCPATH
568 568 > mq =
569 569 > strip =
570 570 > hgext.mq =
571 571 > hgext/mq =
572 572 > EOF
573 573
574 574 Show extensions:
575 575 (note that mq force load strip, also checking it's not loaded twice)
576 576
577 577 $ hg debugextensions
578 578 mq
579 579 strip
580 580
581 581 For extensions, which name matches one of its commands, help
582 582 message should ask '-v -e' to get list of built-in aliases
583 583 along with extension help itself
584 584
585 585 $ mkdir $TESTTMP/d
586 586 $ cat > $TESTTMP/d/dodo.py <<EOF
587 587 > """
588 588 > This is an awesome 'dodo' extension. It does nothing and
589 589 > writes 'Foo foo'
590 590 > """
591 591 > from mercurial import cmdutil, commands
592 592 > cmdtable = {}
593 593 > command = cmdutil.command(cmdtable)
594 594 > @command('dodo', [], 'hg dodo')
595 595 > def dodo(ui, *args, **kwargs):
596 596 > """Does nothing"""
597 597 > ui.write("I do nothing. Yay\\n")
598 598 > @command('foofoo', [], 'hg foofoo')
599 599 > def foofoo(ui, *args, **kwargs):
600 600 > """Writes 'Foo foo'"""
601 601 > ui.write("Foo foo\\n")
602 602 > EOF
603 603 $ dodopath=$TESTTMP/d/dodo.py
604 604
605 605 $ echo "dodo = $dodopath" >> $HGRCPATH
606 606
607 607 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
608 608 $ hg help -e dodo
609 609 dodo extension -
610 610
611 611 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
612 612
613 613 list of commands:
614 614
615 615 dodo Does nothing
616 616 foofoo Writes 'Foo foo'
617 617
618 618 (use "hg help -v -e dodo" to show built-in aliases and global options)
619 619
620 620 Make sure that '-v -e' prints list of built-in aliases along with
621 621 extension help itself
622 622 $ hg help -v -e dodo
623 623 dodo extension -
624 624
625 625 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
626 626
627 627 list of commands:
628 628
629 629 dodo Does nothing
630 630 foofoo Writes 'Foo foo'
631 631
632 632 global options ([+] can be repeated):
633 633
634 634 -R --repository REPO repository root directory or name of overlay bundle
635 635 file
636 636 --cwd DIR change working directory
637 637 -y --noninteractive do not prompt, automatically pick the first choice for
638 638 all prompts
639 639 -q --quiet suppress output
640 640 -v --verbose enable additional output
641 641 --config CONFIG [+] set/override config option (use 'section.name=value')
642 642 --debug enable debugging output
643 643 --debugger start debugger
644 644 --encoding ENCODE set the charset encoding (default: ascii)
645 645 --encodingmode MODE set the charset encoding mode (default: strict)
646 646 --traceback always print a traceback on exception
647 647 --time time how long the command takes
648 648 --profile print command execution profile
649 649 --version output version information and exit
650 650 -h --help display help and exit
651 651 --hidden consider hidden changesets
652 652
653 653 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
654 654 $ hg help -v dodo
655 655 hg dodo
656 656
657 657 Does nothing
658 658
659 659 (use "hg help -e dodo" to show help for the dodo extension)
660 660
661 661 options:
662 662
663 663 --mq operate on patch repository
664 664
665 665 global options ([+] can be repeated):
666 666
667 667 -R --repository REPO repository root directory or name of overlay bundle
668 668 file
669 669 --cwd DIR change working directory
670 670 -y --noninteractive do not prompt, automatically pick the first choice for
671 671 all prompts
672 672 -q --quiet suppress output
673 673 -v --verbose enable additional output
674 674 --config CONFIG [+] set/override config option (use 'section.name=value')
675 675 --debug enable debugging output
676 676 --debugger start debugger
677 677 --encoding ENCODE set the charset encoding (default: ascii)
678 678 --encodingmode MODE set the charset encoding mode (default: strict)
679 679 --traceback always print a traceback on exception
680 680 --time time how long the command takes
681 681 --profile print command execution profile
682 682 --version output version information and exit
683 683 -h --help display help and exit
684 684 --hidden consider hidden changesets
685 685
686 686 In case when extension name doesn't match any of its commands,
687 687 help message should ask for '-v' to get list of built-in aliases
688 688 along with extension help
689 689 $ cat > $TESTTMP/d/dudu.py <<EOF
690 690 > """
691 691 > This is an awesome 'dudu' extension. It does something and
692 692 > also writes 'Beep beep'
693 693 > """
694 694 > from mercurial import cmdutil, commands
695 695 > cmdtable = {}
696 696 > command = cmdutil.command(cmdtable)
697 697 > @command('something', [], 'hg something')
698 698 > def something(ui, *args, **kwargs):
699 699 > """Does something"""
700 700 > ui.write("I do something. Yaaay\\n")
701 701 > @command('beep', [], 'hg beep')
702 702 > def beep(ui, *args, **kwargs):
703 703 > """Writes 'Beep beep'"""
704 704 > ui.write("Beep beep\\n")
705 705 > EOF
706 706 $ dudupath=$TESTTMP/d/dudu.py
707 707
708 708 $ echo "dudu = $dudupath" >> $HGRCPATH
709 709
710 710 $ hg help -e dudu
711 711 dudu extension -
712 712
713 713 This is an awesome 'dudu' extension. It does something and also writes 'Beep
714 714 beep'
715 715
716 716 list of commands:
717 717
718 718 beep Writes 'Beep beep'
719 719 something Does something
720 720
721 721 (use "hg help -v dudu" to show built-in aliases and global options)
722 722
723 723 In case when extension name doesn't match any of its commands,
724 724 help options '-v' and '-v -e' should be equivalent
725 725 $ hg help -v dudu
726 726 dudu extension -
727 727
728 728 This is an awesome 'dudu' extension. It does something and also writes 'Beep
729 729 beep'
730 730
731 731 list of commands:
732 732
733 733 beep Writes 'Beep beep'
734 734 something Does something
735 735
736 736 global options ([+] can be repeated):
737 737
738 738 -R --repository REPO repository root directory or name of overlay bundle
739 739 file
740 740 --cwd DIR change working directory
741 741 -y --noninteractive do not prompt, automatically pick the first choice for
742 742 all prompts
743 743 -q --quiet suppress output
744 744 -v --verbose enable additional output
745 745 --config CONFIG [+] set/override config option (use 'section.name=value')
746 746 --debug enable debugging output
747 747 --debugger start debugger
748 748 --encoding ENCODE set the charset encoding (default: ascii)
749 749 --encodingmode MODE set the charset encoding mode (default: strict)
750 750 --traceback always print a traceback on exception
751 751 --time time how long the command takes
752 752 --profile print command execution profile
753 753 --version output version information and exit
754 754 -h --help display help and exit
755 755 --hidden consider hidden changesets
756 756
757 757 $ hg help -v -e dudu
758 758 dudu extension -
759 759
760 760 This is an awesome 'dudu' extension. It does something and also writes 'Beep
761 761 beep'
762 762
763 763 list of commands:
764 764
765 765 beep Writes 'Beep beep'
766 766 something Does something
767 767
768 768 global options ([+] can be repeated):
769 769
770 770 -R --repository REPO repository root directory or name of overlay bundle
771 771 file
772 772 --cwd DIR change working directory
773 773 -y --noninteractive do not prompt, automatically pick the first choice for
774 774 all prompts
775 775 -q --quiet suppress output
776 776 -v --verbose enable additional output
777 777 --config CONFIG [+] set/override config option (use 'section.name=value')
778 778 --debug enable debugging output
779 779 --debugger start debugger
780 780 --encoding ENCODE set the charset encoding (default: ascii)
781 781 --encodingmode MODE set the charset encoding mode (default: strict)
782 782 --traceback always print a traceback on exception
783 783 --time time how long the command takes
784 784 --profile print command execution profile
785 785 --version output version information and exit
786 786 -h --help display help and exit
787 787 --hidden consider hidden changesets
788 788
789 789 Disabled extension commands:
790 790
791 791 $ ORGHGRCPATH=$HGRCPATH
792 792 $ HGRCPATH=
793 793 $ export HGRCPATH
794 794 $ hg help email
795 795 'email' is provided by the following extension:
796 796
797 797 patchbomb command to send changesets as (a series of) patch emails
798 798
799 799 (use "hg help extensions" for information on enabling extensions)
800 800
801 801
802 802 $ hg qdel
803 803 hg: unknown command 'qdel'
804 804 'qdelete' is provided by the following extension:
805 805
806 806 mq manage a stack of patches
807 807
808 808 (use "hg help extensions" for information on enabling extensions)
809 809 [255]
810 810
811 811
812 812 $ hg churn
813 813 hg: unknown command 'churn'
814 814 'churn' is provided by the following extension:
815 815
816 816 churn command to display statistics about repository history
817 817
818 818 (use "hg help extensions" for information on enabling extensions)
819 819 [255]
820 820
821 821
822 822
823 823 Disabled extensions:
824 824
825 825 $ hg help churn
826 826 churn extension - command to display statistics about repository history
827 827
828 828 (use "hg help extensions" for information on enabling extensions)
829 829
830 830 $ hg help patchbomb
831 831 patchbomb extension - command to send changesets as (a series of) patch emails
832 832
833 833 (use "hg help extensions" for information on enabling extensions)
834 834
835 835
836 836 Broken disabled extension and command:
837 837
838 838 $ mkdir hgext
839 839 $ echo > hgext/__init__.py
840 840 $ cat > hgext/broken.py <<EOF
841 841 > "broken extension'
842 842 > EOF
843 843 $ cat > path.py <<EOF
844 844 > import os, sys
845 845 > sys.path.insert(0, os.environ['HGEXTPATH'])
846 846 > EOF
847 847 $ HGEXTPATH=`pwd`
848 848 $ export HGEXTPATH
849 849
850 850 $ hg --config extensions.path=./path.py help broken
851 851 broken extension - (no help text available)
852 852
853 853 (use "hg help extensions" for information on enabling extensions)
854 854
855 855
856 856 $ cat > hgext/forest.py <<EOF
857 857 > cmdtable = None
858 858 > EOF
859 859 $ hg --config extensions.path=./path.py help foo > /dev/null
860 860 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
861 861 abort: no such help topic: foo
862 862 (try "hg help --keyword foo")
863 863 [255]
864 864
865 865 $ cat > throw.py <<EOF
866 866 > from mercurial import cmdutil, commands, util
867 867 > cmdtable = {}
868 868 > command = cmdutil.command(cmdtable)
869 869 > class Bogon(Exception): pass
870 870 > @command('throw', [], 'hg throw', norepo=True)
871 871 > def throw(ui, **opts):
872 872 > """throws an exception"""
873 873 > raise Bogon()
874 874 > EOF
875 875
876 876 No declared supported version, extension complains:
877 877 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
878 878 ** Unknown exception encountered with possibly-broken third-party extension throw
879 879 ** which supports versions unknown of Mercurial.
880 880 ** Please disable throw and try your action again.
881 881 ** If that fixes the bug please report it to the extension author.
882 882 ** Python * (glob)
883 883 ** Mercurial Distributed SCM * (glob)
884 884 ** Extensions loaded: throw
885 885
886 886 empty declaration of supported version, extension complains:
887 887 $ echo "testedwith = ''" >> throw.py
888 888 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
889 889 ** Unknown exception encountered with possibly-broken third-party extension throw
890 890 ** which supports versions unknown of Mercurial.
891 891 ** Please disable throw and try your action again.
892 892 ** If that fixes the bug please report it to the extension author.
893 893 ** Python * (glob)
894 894 ** Mercurial Distributed SCM (*) (glob)
895 895 ** Extensions loaded: throw
896 896
897 897 If the extension specifies a buglink, show that:
898 898 $ echo 'buglink = "http://example.com/bts"' >> throw.py
899 899 $ rm -f throw.pyc throw.pyo
900 900 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
901 901 ** Unknown exception encountered with possibly-broken third-party extension throw
902 902 ** which supports versions unknown of Mercurial.
903 903 ** Please disable throw and try your action again.
904 904 ** If that fixes the bug please report it to http://example.com/bts
905 905 ** Python * (glob)
906 906 ** Mercurial Distributed SCM (*) (glob)
907 907 ** Extensions loaded: throw
908 908
909 909 If the extensions declare outdated versions, accuse the older extension first:
910 910 $ echo "from mercurial import util" >> older.py
911 911 $ echo "util.version = lambda:'2.2'" >> older.py
912 912 $ echo "testedwith = '1.9.3'" >> older.py
913 913 $ echo "testedwith = '2.1.1'" >> throw.py
914 914 $ rm -f throw.pyc throw.pyo
915 915 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
916 916 > throw 2>&1 | egrep '^\*\*'
917 917 ** Unknown exception encountered with possibly-broken third-party extension older
918 918 ** which supports versions 1.9 of Mercurial.
919 919 ** Please disable older and try your action again.
920 920 ** If that fixes the bug please report it to the extension author.
921 921 ** Python * (glob)
922 922 ** Mercurial Distributed SCM (version 2.2)
923 923 ** Extensions loaded: throw, older
924 924
925 925 One extension only tested with older, one only with newer versions:
926 926 $ echo "util.version = lambda:'2.1'" >> older.py
927 927 $ rm -f older.pyc older.pyo
928 928 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
929 929 > throw 2>&1 | egrep '^\*\*'
930 930 ** Unknown exception encountered with possibly-broken third-party extension older
931 931 ** which supports versions 1.9 of Mercurial.
932 932 ** Please disable older and try your action again.
933 933 ** If that fixes the bug please report it to the extension author.
934 934 ** Python * (glob)
935 935 ** Mercurial Distributed SCM (version 2.1)
936 936 ** Extensions loaded: throw, older
937 937
938 938 Older extension is tested with current version, the other only with newer:
939 939 $ echo "util.version = lambda:'1.9.3'" >> older.py
940 940 $ rm -f older.pyc older.pyo
941 941 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
942 942 > throw 2>&1 | egrep '^\*\*'
943 943 ** Unknown exception encountered with possibly-broken third-party extension throw
944 944 ** which supports versions 2.1 of Mercurial.
945 945 ** Please disable throw and try your action again.
946 946 ** If that fixes the bug please report it to http://example.com/bts
947 947 ** Python * (glob)
948 948 ** Mercurial Distributed SCM (version 1.9.3)
949 949 ** Extensions loaded: throw, older
950 950
951 951 Ability to point to a different point
952 952 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
953 953 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
954 954 ** unknown exception encountered, please report by visiting
955 955 ** Your Local Goat Lenders
956 956 ** Python * (glob)
957 957 ** Mercurial Distributed SCM (*) (glob)
958 958 ** Extensions loaded: throw, older
959 959
960 960 Declare the version as supporting this hg version, show regular bts link:
961 $ hgver=`$PYTHON -c 'from mercurial import util; print util.version().split("+")[0]'`
961 $ hgver=`hg debuginstall -T '{hgver}'`
962 962 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
963 963 $ if [ -z "$hgver" ]; then
964 964 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
965 965 > fi
966 966 $ rm -f throw.pyc throw.pyo
967 967 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
968 968 ** unknown exception encountered, please report by visiting
969 969 ** https://mercurial-scm.org/wiki/BugTracker
970 970 ** Python * (glob)
971 971 ** Mercurial Distributed SCM (*) (glob)
972 972 ** Extensions loaded: throw
973 973
974 974 Patch version is ignored during compatibility check
975 975 $ echo "testedwith = '3.2'" >> throw.py
976 976 $ echo "util.version = lambda:'3.2.2'" >> throw.py
977 977 $ rm -f throw.pyc throw.pyo
978 978 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
979 979 ** unknown exception encountered, please report by visiting
980 980 ** https://mercurial-scm.org/wiki/BugTracker
981 981 ** Python * (glob)
982 982 ** Mercurial Distributed SCM (*) (glob)
983 983 ** Extensions loaded: throw
984 984
985 985 Test version number support in 'hg version':
986 986 $ echo '__version__ = (1, 2, 3)' >> throw.py
987 987 $ rm -f throw.pyc throw.pyo
988 988 $ hg version -v
989 989 Mercurial Distributed SCM (version *) (glob)
990 990 (see https://mercurial-scm.org for more information)
991 991
992 992 Copyright (C) 2005-* Matt Mackall and others (glob)
993 993 This is free software; see the source for copying conditions. There is NO
994 994 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
995 995
996 996 Enabled extensions:
997 997
998 998
999 999 $ hg version -v --config extensions.throw=throw.py
1000 1000 Mercurial Distributed SCM (version *) (glob)
1001 1001 (see https://mercurial-scm.org for more information)
1002 1002
1003 1003 Copyright (C) 2005-* Matt Mackall and others (glob)
1004 1004 This is free software; see the source for copying conditions. There is NO
1005 1005 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1006 1006
1007 1007 Enabled extensions:
1008 1008
1009 1009 throw external 1.2.3
1010 1010 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
1011 1011 $ rm -f throw.pyc throw.pyo
1012 1012 $ hg version -v --config extensions.throw=throw.py
1013 1013 Mercurial Distributed SCM (version *) (glob)
1014 1014 (see https://mercurial-scm.org for more information)
1015 1015
1016 1016 Copyright (C) 2005-* Matt Mackall and others (glob)
1017 1017 This is free software; see the source for copying conditions. There is NO
1018 1018 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1019 1019
1020 1020 Enabled extensions:
1021 1021
1022 1022 throw external 1.twentythree
1023 1023
1024 1024 Refuse to load extensions with minimum version requirements
1025 1025
1026 1026 $ cat > minversion1.py << EOF
1027 1027 > from mercurial import util
1028 1028 > util.version = lambda: '3.5.2'
1029 1029 > minimumhgversion = '3.6'
1030 1030 > EOF
1031 1031 $ hg --config extensions.minversion=minversion1.py version
1032 1032 (third party extension minversion requires version 3.6 or newer of Mercurial; disabling)
1033 1033 Mercurial Distributed SCM (version 3.5.2)
1034 1034 (see https://mercurial-scm.org for more information)
1035 1035
1036 1036 Copyright (C) 2005-* Matt Mackall and others (glob)
1037 1037 This is free software; see the source for copying conditions. There is NO
1038 1038 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1039 1039
1040 1040 $ cat > minversion2.py << EOF
1041 1041 > from mercurial import util
1042 1042 > util.version = lambda: '3.6'
1043 1043 > minimumhgversion = '3.7'
1044 1044 > EOF
1045 1045 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1046 1046 (third party extension minversion requires version 3.7 or newer of Mercurial; disabling)
1047 1047
1048 1048 Can load version that is only off by point release
1049 1049
1050 1050 $ cat > minversion2.py << EOF
1051 1051 > from mercurial import util
1052 1052 > util.version = lambda: '3.6.1'
1053 1053 > minimumhgversion = '3.6'
1054 1054 > EOF
1055 1055 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1056 1056 [1]
1057 1057
1058 1058 Can load minimum version identical to current
1059 1059
1060 1060 $ cat > minversion3.py << EOF
1061 1061 > from mercurial import util
1062 1062 > util.version = lambda: '3.5'
1063 1063 > minimumhgversion = '3.5'
1064 1064 > EOF
1065 1065 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1066 1066 [1]
1067 1067
1068 1068 Restore HGRCPATH
1069 1069
1070 1070 $ HGRCPATH=$ORGHGRCPATH
1071 1071 $ export HGRCPATH
1072 1072
1073 1073 Commands handling multiple repositories at a time should invoke only
1074 1074 "reposetup()" of extensions enabling in the target repository.
1075 1075
1076 1076 $ mkdir reposetup-test
1077 1077 $ cd reposetup-test
1078 1078
1079 1079 $ cat > $TESTTMP/reposetuptest.py <<EOF
1080 1080 > from mercurial import extensions
1081 1081 > def reposetup(ui, repo):
1082 1082 > ui.write('reposetup() for %s\n' % (repo.root))
1083 1083 > ui.flush()
1084 1084 > EOF
1085 1085 $ hg init src
1086 1086 $ echo a > src/a
1087 1087 $ hg -R src commit -Am '#0 at src/a'
1088 1088 adding a
1089 1089 $ echo '[extensions]' >> src/.hg/hgrc
1090 1090 $ echo '# enable extension locally' >> src/.hg/hgrc
1091 1091 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1092 1092 $ hg -R src status
1093 1093 reposetup() for $TESTTMP/reposetup-test/src (glob)
1094 1094
1095 1095 $ hg clone -U src clone-dst1
1096 1096 reposetup() for $TESTTMP/reposetup-test/src (glob)
1097 1097 $ hg init push-dst1
1098 1098 $ hg -q -R src push push-dst1
1099 1099 reposetup() for $TESTTMP/reposetup-test/src (glob)
1100 1100 $ hg init pull-src1
1101 1101 $ hg -q -R pull-src1 pull src
1102 1102 reposetup() for $TESTTMP/reposetup-test/src (glob)
1103 1103
1104 1104 $ cat <<EOF >> $HGRCPATH
1105 1105 > [extensions]
1106 1106 > # disable extension globally and explicitly
1107 1107 > reposetuptest = !
1108 1108 > EOF
1109 1109 $ hg clone -U src clone-dst2
1110 1110 reposetup() for $TESTTMP/reposetup-test/src (glob)
1111 1111 $ hg init push-dst2
1112 1112 $ hg -q -R src push push-dst2
1113 1113 reposetup() for $TESTTMP/reposetup-test/src (glob)
1114 1114 $ hg init pull-src2
1115 1115 $ hg -q -R pull-src2 pull src
1116 1116 reposetup() for $TESTTMP/reposetup-test/src (glob)
1117 1117
1118 1118 $ cat <<EOF >> $HGRCPATH
1119 1119 > [extensions]
1120 1120 > # enable extension globally
1121 1121 > reposetuptest = $TESTTMP/reposetuptest.py
1122 1122 > EOF
1123 1123 $ hg clone -U src clone-dst3
1124 1124 reposetup() for $TESTTMP/reposetup-test/src (glob)
1125 1125 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1126 1126 $ hg init push-dst3
1127 1127 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1128 1128 $ hg -q -R src push push-dst3
1129 1129 reposetup() for $TESTTMP/reposetup-test/src (glob)
1130 1130 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1131 1131 $ hg init pull-src3
1132 1132 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1133 1133 $ hg -q -R pull-src3 pull src
1134 1134 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1135 1135 reposetup() for $TESTTMP/reposetup-test/src (glob)
1136 1136
1137 1137 $ echo '[extensions]' >> src/.hg/hgrc
1138 1138 $ echo '# disable extension locally' >> src/.hg/hgrc
1139 1139 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1140 1140 $ hg clone -U src clone-dst4
1141 1141 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1142 1142 $ hg init push-dst4
1143 1143 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1144 1144 $ hg -q -R src push push-dst4
1145 1145 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1146 1146 $ hg init pull-src4
1147 1147 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1148 1148 $ hg -q -R pull-src4 pull src
1149 1149 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1150 1150
1151 1151 disabling in command line overlays with all configuration
1152 1152 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1153 1153 $ hg --config extensions.reposetuptest=! init push-dst5
1154 1154 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1155 1155 $ hg --config extensions.reposetuptest=! init pull-src5
1156 1156 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1157 1157
1158 1158 $ cat <<EOF >> $HGRCPATH
1159 1159 > [extensions]
1160 1160 > # disable extension globally and explicitly
1161 1161 > reposetuptest = !
1162 1162 > EOF
1163 1163 $ hg init parent
1164 1164 $ hg init parent/sub1
1165 1165 $ echo 1 > parent/sub1/1
1166 1166 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1167 1167 adding 1
1168 1168 $ hg init parent/sub2
1169 1169 $ hg init parent/sub2/sub21
1170 1170 $ echo 21 > parent/sub2/sub21/21
1171 1171 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1172 1172 adding 21
1173 1173 $ cat > parent/sub2/.hgsub <<EOF
1174 1174 > sub21 = sub21
1175 1175 > EOF
1176 1176 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1177 1177 adding .hgsub
1178 1178 $ hg init parent/sub3
1179 1179 $ echo 3 > parent/sub3/3
1180 1180 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1181 1181 adding 3
1182 1182 $ cat > parent/.hgsub <<EOF
1183 1183 > sub1 = sub1
1184 1184 > sub2 = sub2
1185 1185 > sub3 = sub3
1186 1186 > EOF
1187 1187 $ hg -R parent commit -Am '#0 at parent'
1188 1188 adding .hgsub
1189 1189 $ echo '[extensions]' >> parent/.hg/hgrc
1190 1190 $ echo '# enable extension locally' >> parent/.hg/hgrc
1191 1191 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1192 1192 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1193 1193 $ hg -R parent status -S -A
1194 1194 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1195 1195 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1196 1196 C .hgsub
1197 1197 C .hgsubstate
1198 1198 C sub1/1
1199 1199 C sub2/.hgsub
1200 1200 C sub2/.hgsubstate
1201 1201 C sub2/sub21/21
1202 1202 C sub3/3
1203 1203
1204 1204 $ cd ..
1205 1205
1206 1206 Test compatibility with extension commands that don't use @command (issue5137)
1207 1207
1208 1208 $ hg init deprecated
1209 1209 $ cd deprecated
1210 1210
1211 1211 $ cat <<EOF > deprecatedcmd.py
1212 1212 > def deprecatedcmd(repo, ui):
1213 1213 > pass
1214 1214 > cmdtable = {
1215 1215 > 'deprecatedcmd': (deprecatedcmd, [], ''),
1216 1216 > }
1217 1217 > EOF
1218 1218 $ cat <<EOF > .hg/hgrc
1219 1219 > [extensions]
1220 1220 > deprecatedcmd = `pwd`/deprecatedcmd.py
1221 1221 > mq = !
1222 1222 > hgext.mq = !
1223 1223 > hgext/mq = !
1224 1224 > [alias]
1225 1225 > deprecatedalias = deprecatedcmd
1226 1226 > EOF
1227 1227
1228 1228 $ hg deprecatedcmd
1229 1229 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1230 1230 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1231 1231
1232 1232 $ hg deprecatedalias
1233 1233 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedalias'
1234 1234 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1235 1235
1236 1236 no warning unless command is executed:
1237 1237
1238 1238 $ hg paths
1239 1239
1240 1240 but mq iterates over command table:
1241 1241
1242 1242 $ hg --config extensions.mq= paths
1243 1243 devel-warn: missing attribute 'norepo', use @command decorator to register 'deprecatedcmd'
1244 1244 (compatibility will be dropped after Mercurial-3.8, update your code.) at: * (glob)
1245 1245
1246 1246 $ cd ..
1247 1247
1248 1248 Test synopsis and docstring extending
1249 1249
1250 1250 $ hg init exthelp
1251 1251 $ cat > exthelp.py <<EOF
1252 1252 > from mercurial import commands, extensions
1253 1253 > def exbookmarks(orig, *args, **opts):
1254 1254 > return orig(*args, **opts)
1255 1255 > def uisetup(ui):
1256 1256 > synopsis = ' GREPME [--foo] [-x]'
1257 1257 > docstring = '''
1258 1258 > GREPME make sure that this is in the help!
1259 1259 > '''
1260 1260 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1261 1261 > synopsis, docstring)
1262 1262 > EOF
1263 1263 $ abspath=`pwd`/exthelp.py
1264 1264 $ echo '[extensions]' >> $HGRCPATH
1265 1265 $ echo "exthelp = $abspath" >> $HGRCPATH
1266 1266 $ cd exthelp
1267 1267 $ hg help bookmarks | grep GREPME
1268 1268 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1269 1269 GREPME make sure that this is in the help!
1270 1270
General Comments 0
You need to be logged in to leave comments. Login now