##// END OF EJS Templates
ability to load hooks from arbitrary python module
Alexander Solovyov -
r7916:f779e199 default
parent child Browse files
Show More
@@ -1,773 +1,774
1 1 HGRC(5)
2 2 =======
3 3 Bryan O'Sullivan <bos@serpentine.com>
4 4
5 5 NAME
6 6 ----
7 7 hgrc - configuration files for Mercurial
8 8
9 9 SYNOPSIS
10 10 --------
11 11
12 12 The Mercurial system uses a set of configuration files to control
13 13 aspects of its behaviour.
14 14
15 15 FILES
16 16 -----
17 17
18 18 Mercurial reads configuration data from several files, if they exist.
19 19 The names of these files depend on the system on which Mercurial is
20 20 installed. *.rc files from a single directory are read in
21 21 alphabetical order, later ones overriding earlier ones. Where
22 22 multiple paths are given below, settings from later paths override
23 23 earlier ones.
24 24
25 25 (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc::
26 26 (Unix) <install-root>/etc/mercurial/hgrc::
27 27 Per-installation configuration files, searched for in the
28 28 directory where Mercurial is installed. <install-root> is the
29 29 parent directory of the hg executable (or symlink) being run.
30 30 For example, if installed in /shared/tools/bin/hg, Mercurial will
31 31 look in /shared/tools/etc/mercurial/hgrc. Options in these files
32 32 apply to all Mercurial commands executed by any user in any
33 33 directory.
34 34
35 35 (Unix) /etc/mercurial/hgrc.d/*.rc::
36 36 (Unix) /etc/mercurial/hgrc::
37 37 Per-system configuration files, for the system on which Mercurial
38 38 is running. Options in these files apply to all Mercurial
39 39 commands executed by any user in any directory. Options in these
40 40 files override per-installation options.
41 41
42 42 (Windows) <install-dir>\Mercurial.ini::
43 43 or else::
44 44 (Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial::
45 45 or else::
46 46 (Windows) C:\Mercurial\Mercurial.ini::
47 47 Per-installation/system configuration files, for the system on
48 48 which Mercurial is running. Options in these files apply to all
49 49 Mercurial commands executed by any user in any directory.
50 50 Registry keys contain PATH-like strings, every part of which must
51 51 reference a Mercurial.ini file or be a directory where *.rc files
52 52 will be read.
53 53
54 54 (Unix) $HOME/.hgrc::
55 55 (Windows) %HOME%\Mercurial.ini::
56 56 (Windows) %HOME%\.hgrc::
57 57 (Windows) %USERPROFILE%\Mercurial.ini::
58 58 (Windows) %USERPROFILE%\.hgrc::
59 59 Per-user configuration file(s), for the user running Mercurial.
60 60 On Windows 9x, %HOME% is replaced by %APPDATA%.
61 61 Options in these files apply to all Mercurial commands executed
62 62 by this user in any directory. Options in thes files override
63 63 per-installation and per-system options.
64 64
65 65 (Unix, Windows) <repo>/.hg/hgrc::
66 66 Per-repository configuration options that only apply in a
67 67 particular repository. This file is not version-controlled, and
68 68 will not get transferred during a "clone" operation. Options in
69 69 this file override options in all other configuration files.
70 70 On Unix, most of this file will be ignored if it doesn't belong
71 71 to a trusted user or to a trusted group. See the documentation
72 72 for the trusted section below for more details.
73 73
74 74 SYNTAX
75 75 ------
76 76
77 77 A configuration file consists of sections, led by a "[section]" header
78 78 and followed by "name: value" entries; "name=value" is also accepted.
79 79
80 80 [spam]
81 81 eggs=ham
82 82 green=
83 83 eggs
84 84
85 85 Each line contains one entry. If the lines that follow are indented,
86 86 they are treated as continuations of that entry.
87 87
88 88 Leading whitespace is removed from values. Empty lines are skipped.
89 89
90 90 The optional values can contain format strings which refer to other
91 91 values in the same section, or values in a special DEFAULT section.
92 92
93 93 Lines beginning with "#" or ";" are ignored and may be used to provide
94 94 comments.
95 95
96 96 SECTIONS
97 97 --------
98 98
99 99 This section describes the different sections that may appear in a
100 100 Mercurial "hgrc" file, the purpose of each section, its possible
101 101 keys, and their possible values.
102 102
103 103 [[decode]]
104 104 decode/encode::
105 105 Filters for transforming files on checkout/checkin. This would
106 106 typically be used for newline processing or other
107 107 localization/canonicalization of files.
108 108
109 109 Filters consist of a filter pattern followed by a filter command.
110 110 Filter patterns are globs by default, rooted at the repository
111 111 root. For example, to match any file ending in ".txt" in the root
112 112 directory only, use the pattern "*.txt". To match any file ending
113 113 in ".c" anywhere in the repository, use the pattern "**.c".
114 114
115 115 The filter command can start with a specifier, either "pipe:" or
116 116 "tempfile:". If no specifier is given, "pipe:" is used by default.
117 117
118 118 A "pipe:" command must accept data on stdin and return the
119 119 transformed data on stdout.
120 120
121 121 Pipe example:
122 122
123 123 [encode]
124 124 # uncompress gzip files on checkin to improve delta compression
125 125 # note: not necessarily a good idea, just an example
126 126 *.gz = pipe: gunzip
127 127
128 128 [decode]
129 129 # recompress gzip files when writing them to the working dir (we
130 130 # can safely omit "pipe:", because it's the default)
131 131 *.gz = gzip
132 132
133 133 A "tempfile:" command is a template. The string INFILE is replaced
134 134 with the name of a temporary file that contains the data to be
135 135 filtered by the command. The string OUTFILE is replaced with the
136 136 name of an empty temporary file, where the filtered data must be
137 137 written by the command.
138 138
139 139 NOTE: the tempfile mechanism is recommended for Windows systems,
140 140 where the standard shell I/O redirection operators often have
141 141 strange effects and may corrupt the contents of your files.
142 142
143 143 The most common usage is for LF <-> CRLF translation on Windows.
144 144 For this, use the "smart" convertors which check for binary files:
145 145
146 146 [extensions]
147 147 hgext.win32text =
148 148 [encode]
149 149 ** = cleverencode:
150 150 [decode]
151 151 ** = cleverdecode:
152 152
153 153 or if you only want to translate certain files:
154 154
155 155 [extensions]
156 156 hgext.win32text =
157 157 [encode]
158 158 **.txt = dumbencode:
159 159 [decode]
160 160 **.txt = dumbdecode:
161 161
162 162 [[defaults]]
163 163 defaults::
164 164 Use the [defaults] section to define command defaults, i.e. the
165 165 default options/arguments to pass to the specified commands.
166 166
167 167 The following example makes 'hg log' run in verbose mode, and
168 168 'hg status' show only the modified files, by default.
169 169
170 170 [defaults]
171 171 log = -v
172 172 status = -m
173 173
174 174 The actual commands, instead of their aliases, must be used when
175 175 defining command defaults. The command defaults will also be
176 176 applied to the aliases of the commands defined.
177 177
178 178 [[diff]]
179 179 diff::
180 180 Settings used when displaying diffs. They are all boolean and
181 181 defaults to False.
182 182 git;;
183 183 Use git extended diff format.
184 184 nodates;;
185 185 Don't include dates in diff headers.
186 186 showfunc;;
187 187 Show which function each change is in.
188 188 ignorews;;
189 189 Ignore white space when comparing lines.
190 190 ignorewsamount;;
191 191 Ignore changes in the amount of white space.
192 192 ignoreblanklines;;
193 193 Ignore changes whose lines are all blank.
194 194
195 195 [[email]]
196 196 email::
197 197 Settings for extensions that send email messages.
198 198 from;;
199 199 Optional. Email address to use in "From" header and SMTP envelope
200 200 of outgoing messages.
201 201 to;;
202 202 Optional. Comma-separated list of recipients' email addresses.
203 203 cc;;
204 204 Optional. Comma-separated list of carbon copy recipients'
205 205 email addresses.
206 206 bcc;;
207 207 Optional. Comma-separated list of blind carbon copy
208 208 recipients' email addresses. Cannot be set interactively.
209 209 method;;
210 210 Optional. Method to use to send email messages. If value is
211 211 "smtp" (default), use SMTP (see section "[smtp]" for
212 212 configuration). Otherwise, use as name of program to run that
213 213 acts like sendmail (takes "-f" option for sender, list of
214 214 recipients on command line, message on stdin). Normally, setting
215 215 this to "sendmail" or "/usr/sbin/sendmail" is enough to use
216 216 sendmail to send messages.
217 217 charsets;;
218 218 Optional. Comma-separated list of charsets considered
219 219 convenient for recipients. Addresses, headers, and parts not
220 220 containing patches of outgoing messages will be encoded in
221 221 the first charset to which conversion from local encoding
222 222 ($HGENCODING, ui.fallbackencoding) succeeds. If correct
223 223 conversion fails, the text in question is sent as is.
224 224 Defaults to empty (explicit) list.
225 225
226 226 Order of outgoing email charsets:
227 227
228 228 us-ascii always first, regardless of settings
229 229 email.charsets in order given by user
230 230 ui.fallbackencoding if not in email.charsets
231 231 $HGENCODING if not in email.charsets
232 232 utf-8 always last, regardless of settings
233 233
234 234 Email example:
235 235
236 236 [email]
237 237 from = Joseph User <joe.user@example.com>
238 238 method = /usr/sbin/sendmail
239 239 # charsets for western europeans
240 240 # us-ascii, utf-8 omitted, as they are tried first and last
241 241 charsets = iso-8859-1, iso-8859-15, windows-1252
242 242
243 243 [[extensions]]
244 244 extensions::
245 245 Mercurial has an extension mechanism for adding new features. To
246 246 enable an extension, create an entry for it in this section.
247 247
248 248 If you know that the extension is already in Python's search path,
249 249 you can give the name of the module, followed by "=", with nothing
250 250 after the "=".
251 251
252 252 Otherwise, give a name that you choose, followed by "=", followed by
253 253 the path to the ".py" file (including the file name extension) that
254 254 defines the extension.
255 255
256 256 To explicitly disable an extension that is enabled in an hgrc of
257 257 broader scope, prepend its path with '!', as in
258 258 'hgext.foo = !/ext/path' or 'hgext.foo = !' when no path is supplied.
259 259
260 260 Example for ~/.hgrc:
261 261
262 262 [extensions]
263 263 # (the mq extension will get loaded from mercurial's path)
264 264 hgext.mq =
265 265 # (this extension will get loaded from the file specified)
266 266 myfeature = ~/.hgext/myfeature.py
267 267
268 268 [[format]]
269 269 format::
270 270
271 271 usestore;;
272 272 Enable or disable the "store" repository format which improves
273 273 compatibility with systems that fold case or otherwise mangle
274 274 filenames. Enabled by default. Disabling this option will allow
275 275 you to store longer filenames in some situations at the expense of
276 276 compatibility and ensures that the on-disk format of newly created
277 277 repositories will be compatible with Mercurial before version 0.9.4.
278 278
279 279 usefncache;;
280 280 Enable or disable the "fncache" repository format which enhances
281 281 the "store" repository format (which has to be enabled to use
282 282 fncache) to allow longer filenames and avoids using Windows reserved
283 283 names, e.g. "nul". Enabled by default. Disabling this option ensures
284 284 that the on-disk format of newly created repositories will be
285 285 compatible with Mercurial before version 1.1.
286 286
287 287 [[merge-patterns]]
288 288 merge-patterns::
289 289 This section specifies merge tools to associate with particular file
290 290 patterns. Tools matched here will take precedence over the default
291 291 merge tool. Patterns are globs by default, rooted at the repository root.
292 292
293 293 Example:
294 294
295 295 [merge-patterns]
296 296 **.c = kdiff3
297 297 **.jpg = myimgmerge
298 298
299 299 [[merge-tools]]
300 300 merge-tools::
301 301 This section configures external merge tools to use for file-level
302 302 merges.
303 303
304 304 Example ~/.hgrc:
305 305
306 306 [merge-tools]
307 307 # Override stock tool location
308 308 kdiff3.executable = ~/bin/kdiff3
309 309 # Specify command line
310 310 kdiff3.args = $base $local $other -o $output
311 311 # Give higher priority
312 312 kdiff3.priority = 1
313 313
314 314 # Define new tool
315 315 myHtmlTool.args = -m $local $other $base $output
316 316 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
317 317 myHtmlTool.priority = 1
318 318
319 319 Supported arguments:
320 320
321 321 priority;;
322 322 The priority in which to evaluate this tool.
323 323 Default: 0.
324 324 executable;;
325 325 Either just the name of the executable or its pathname.
326 326 Default: the tool name.
327 327 args;;
328 328 The arguments to pass to the tool executable. You can refer to the files
329 329 being merged as well as the output file through these variables: $base,
330 330 $local, $other, $output.
331 331 Default: $local $base $other
332 332 premerge;;
333 333 Attempt to run internal non-interactive 3-way merge tool before
334 334 launching external tool.
335 335 Default: True
336 336 binary;;
337 337 This tool can merge binary files. Defaults to False, unless tool
338 338 was selected by file pattern match.
339 339 symlink;;
340 340 This tool can merge symlinks. Defaults to False, even if tool was
341 341 selected by file pattern match.
342 342 checkconflicts;;
343 343 Check whether there are conflicts even though the tool reported
344 344 success.
345 345 Default: False
346 346 checkchanged;;
347 347 Check whether outputs were written even though the tool reported
348 348 success.
349 349 Default: False
350 350 fixeol;;
351 351 Attempt to fix up EOL changes caused by the merge tool.
352 352 Default: False
353 353 gui;;
354 354 This tool requires a graphical interface to run. Default: False
355 355 regkey;;
356 356 Windows registry key which describes install location of this tool.
357 357 Mercurial will search for this key first under HKEY_CURRENT_USER and
358 358 then under HKEY_LOCAL_MACHINE. Default: None
359 359 regname;;
360 360 Name of value to read from specified registry key. Defaults to the
361 361 unnamed (default) value.
362 362 regappend;;
363 363 String to append to the value read from the registry, typically the
364 364 executable name of the tool. Default: None
365 365
366 366 [[hooks]]
367 367 hooks::
368 368 Commands or Python functions that get automatically executed by
369 369 various actions such as starting or finishing a commit. Multiple
370 370 hooks can be run for the same action by appending a suffix to the
371 371 action. Overriding a site-wide hook can be done by changing its
372 372 value or setting it to an empty string.
373 373
374 374 Example .hg/hgrc:
375 375
376 376 [hooks]
377 377 # do not use the site-wide hook
378 378 incoming =
379 379 incoming.email = /my/email/hook
380 380 incoming.autobuild = /my/build/hook
381 381
382 382 Most hooks are run with environment variables set that give added
383 383 useful information. For each hook below, the environment variables
384 384 it is passed are listed with names of the form "$HG_foo".
385 385
386 386 changegroup;;
387 387 Run after a changegroup has been added via push, pull or
388 388 unbundle. ID of the first new changeset is in $HG_NODE. URL from
389 389 which changes came is in $HG_URL.
390 390 commit;;
391 391 Run after a changeset has been created in the local repository.
392 392 ID of the newly created changeset is in $HG_NODE. Parent
393 393 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
394 394 incoming;;
395 395 Run after a changeset has been pulled, pushed, or unbundled into
396 396 the local repository. The ID of the newly arrived changeset is in
397 397 $HG_NODE. URL that was source of changes came is in $HG_URL.
398 398 outgoing;;
399 399 Run after sending changes from local repository to another. ID of
400 400 first changeset sent is in $HG_NODE. Source of operation is in
401 401 $HG_SOURCE; see "preoutgoing" hook for description.
402 402 post-<command>;;
403 403 Run after successful invocations of the associated command. The
404 404 contents of the command line are passed as $HG_ARGS and the result
405 405 code in $HG_RESULT. Hook failure is ignored.
406 406 pre-<command>;;
407 407 Run before executing the associated command. The contents of the
408 408 command line are passed as $HG_ARGS. If the hook returns failure,
409 409 the command doesn't execute and Mercurial returns the failure code.
410 410 prechangegroup;;
411 411 Run before a changegroup is added via push, pull or unbundle.
412 412 Exit status 0 allows the changegroup to proceed. Non-zero status
413 413 will cause the push, pull or unbundle to fail. URL from which
414 414 changes will come is in $HG_URL.
415 415 precommit;;
416 416 Run before starting a local commit. Exit status 0 allows the
417 417 commit to proceed. Non-zero status will cause the commit to fail.
418 418 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
419 419 preoutgoing;;
420 420 Run before collecting changes to send from the local repository to
421 421 another. Non-zero status will cause failure. This lets you
422 422 prevent pull over http or ssh. Also prevents against local pull,
423 423 push (outbound) or bundle commands, but not effective, since you
424 424 can just copy files instead then. Source of operation is in
425 425 $HG_SOURCE. If "serve", operation is happening on behalf of
426 426 remote ssh or http repository. If "push", "pull" or "bundle",
427 427 operation is happening on behalf of repository on same system.
428 428 pretag;;
429 429 Run before creating a tag. Exit status 0 allows the tag to be
430 430 created. Non-zero status will cause the tag to fail. ID of
431 431 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
432 432 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
433 433 pretxnchangegroup;;
434 434 Run after a changegroup has been added via push, pull or unbundle,
435 435 but before the transaction has been committed. Changegroup is
436 436 visible to hook program. This lets you validate incoming changes
437 437 before accepting them. Passed the ID of the first new changeset
438 438 in $HG_NODE. Exit status 0 allows the transaction to commit.
439 439 Non-zero status will cause the transaction to be rolled back and
440 440 the push, pull or unbundle will fail. URL that was source of
441 441 changes is in $HG_URL.
442 442 pretxncommit;;
443 443 Run after a changeset has been created but the transaction not yet
444 444 committed. Changeset is visible to hook program. This lets you
445 445 validate commit message and changes. Exit status 0 allows the
446 446 commit to proceed. Non-zero status will cause the transaction to
447 447 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
448 448 IDs are in $HG_PARENT1 and $HG_PARENT2.
449 449 preupdate;;
450 450 Run before updating the working directory. Exit status 0 allows
451 451 the update to proceed. Non-zero status will prevent the update.
452 452 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
453 453 of second new parent is in $HG_PARENT2.
454 454 tag;;
455 455 Run after a tag is created. ID of tagged changeset is in
456 456 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
457 457 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
458 458 update;;
459 459 Run after updating the working directory. Changeset ID of first
460 460 new parent is in $HG_PARENT1. If merge, ID of second new parent
461 461 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
462 462 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
463 463
464 464 Note: it is generally better to use standard hooks rather than the
465 465 generic pre- and post- command hooks as they are guaranteed to be
466 466 called in the appropriate contexts for influencing transactions.
467 467 Also, hooks like "commit" will be called in all contexts that
468 468 generate a commit (eg. tag) and not just the commit command.
469 469
470 470 Note2: Environment variables with empty values may not be passed to
471 471 hooks on platforms like Windows. For instance, $HG_PARENT2 will
472 472 not be available under Windows for non-merge changesets while being
473 473 set to an empty value under Unix-like systems.
474 474
475 475 The syntax for Python hooks is as follows:
476 476
477 477 hookname = python:modulename.submodule.callable
478 hookname = python:/path/to/python/module.py:callable
478 479
479 480 Python hooks are run within the Mercurial process. Each hook is
480 481 called with at least three keyword arguments: a ui object (keyword
481 482 "ui"), a repository object (keyword "repo"), and a "hooktype"
482 483 keyword that tells what kind of hook is used. Arguments listed as
483 484 environment variables above are passed as keyword arguments, with no
484 485 "HG_" prefix, and names in lower case.
485 486
486 487 If a Python hook returns a "true" value or raises an exception, this
487 488 is treated as failure of the hook.
488 489
489 490 [[http_proxy]]
490 491 http_proxy::
491 492 Used to access web-based Mercurial repositories through a HTTP
492 493 proxy.
493 494 host;;
494 495 Host name and (optional) port of the proxy server, for example
495 496 "myproxy:8000".
496 497 no;;
497 498 Optional. Comma-separated list of host names that should bypass
498 499 the proxy.
499 500 passwd;;
500 501 Optional. Password to authenticate with at the proxy server.
501 502 user;;
502 503 Optional. User name to authenticate with at the proxy server.
503 504
504 505 [[smtp]]
505 506 smtp::
506 507 Configuration for extensions that need to send email messages.
507 508 host;;
508 509 Host name of mail server, e.g. "mail.example.com".
509 510 port;;
510 511 Optional. Port to connect to on mail server. Default: 25.
511 512 tls;;
512 513 Optional. Whether to connect to mail server using TLS. True or
513 514 False. Default: False.
514 515 username;;
515 516 Optional. User name to authenticate to SMTP server with.
516 517 If username is specified, password must also be specified.
517 518 Default: none.
518 519 password;;
519 520 Optional. Password to authenticate to SMTP server with.
520 521 If username is specified, password must also be specified.
521 522 Default: none.
522 523 local_hostname;;
523 524 Optional. It's the hostname that the sender can use to identify itself
524 525 to the MTA.
525 526
526 527 [[paths]]
527 528 paths::
528 529 Assigns symbolic names to repositories. The left side is the
529 530 symbolic name, and the right gives the directory or URL that is the
530 531 location of the repository. Default paths can be declared by
531 532 setting the following entries.
532 533 default;;
533 534 Directory or URL to use when pulling if no source is specified.
534 535 Default is set to repository from which the current repository
535 536 was cloned.
536 537 default-push;;
537 538 Optional. Directory or URL to use when pushing if no destination
538 539 is specified.
539 540
540 541 [[server]]
541 542 server::
542 543 Controls generic server settings.
543 544 uncompressed;;
544 545 Whether to allow clients to clone a repo using the uncompressed
545 546 streaming protocol. This transfers about 40% more data than a
546 547 regular clone, but uses less memory and CPU on both server and
547 548 client. Over a LAN (100Mbps or better) or a very fast WAN, an
548 549 uncompressed streaming clone is a lot faster (~10x) than a regular
549 550 clone. Over most WAN connections (anything slower than about
550 551 6Mbps), uncompressed streaming is slower, because of the extra
551 552 data transfer overhead. Default is False.
552 553
553 554 [[trusted]]
554 555 trusted::
555 556 For security reasons, Mercurial will not use the settings in
556 557 the .hg/hgrc file from a repository if it doesn't belong to a
557 558 trusted user or to a trusted group. The main exception is the
558 559 web interface, which automatically uses some safe settings, since
559 560 it's common to serve repositories from different users.
560 561
561 562 This section specifies what users and groups are trusted. The
562 563 current user is always trusted. To trust everybody, list a user
563 564 or a group with name "*".
564 565
565 566 users;;
566 567 Comma-separated list of trusted users.
567 568 groups;;
568 569 Comma-separated list of trusted groups.
569 570
570 571 [[ui]]
571 572 ui::
572 573 User interface controls.
573 574 archivemeta;;
574 575 Whether to include the .hg_archival.txt file containing metadata
575 576 (hashes for the repository base and for tip) in archives created by
576 577 the hg archive command or downloaded via hgweb.
577 578 Default is true.
578 579 askusername;;
579 580 Whether to prompt for a username when committing. If True, and
580 581 neither $HGUSER nor $EMAIL has been specified, then the user will
581 582 be prompted to enter a username. If no username is entered, the
582 583 default USER@HOST is used instead.
583 584 Default is False.
584 585 debug;;
585 586 Print debugging information. True or False. Default is False.
586 587 editor;;
587 588 The editor to use during a commit. Default is $EDITOR or "vi".
588 589 fallbackencoding;;
589 590 Encoding to try if it's not possible to decode the changelog using
590 591 UTF-8. Default is ISO-8859-1.
591 592 ignore;;
592 593 A file to read per-user ignore patterns from. This file should be in
593 594 the same format as a repository-wide .hgignore file. This option
594 595 supports hook syntax, so if you want to specify multiple ignore
595 596 files, you can do so by setting something like
596 597 "ignore.other = ~/.hgignore2". For details of the ignore file
597 598 format, see the hgignore(5) man page.
598 599 interactive;;
599 600 Allow to prompt the user. True or False. Default is True.
600 601 logtemplate;;
601 602 Template string for commands that print changesets.
602 603 merge;;
603 604 The conflict resolution program to use during a manual merge.
604 605 There are some internal tools available:
605 606
606 607 internal:local;;
607 608 keep the local version
608 609 internal:other;;
609 610 use the other version
610 611 internal:merge;;
611 612 use the internal non-interactive merge tool
612 613 internal:fail;;
613 614 fail to merge
614 615
615 616 See the merge-tools section for more information on configuring tools.
616 617
617 618 patch;;
618 619 command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if
619 620 unset.
620 621 quiet;;
621 622 Reduce the amount of output printed. True or False. Default is False.
622 623 remotecmd;;
623 624 remote command to use for clone/push/pull operations. Default is 'hg'.
624 625 report_untrusted;;
625 626 Warn if a .hg/hgrc file is ignored due to not being owned by a
626 627 trusted user or group. True or False. Default is True.
627 628 slash;;
628 629 Display paths using a slash ("/") as the path separator. This only
629 630 makes a difference on systems where the default path separator is not
630 631 the slash character (e.g. Windows uses the backslash character ("\")).
631 632 Default is False.
632 633 ssh;;
633 634 command to use for SSH connections. Default is 'ssh'.
634 635 strict;;
635 636 Require exact command names, instead of allowing unambiguous
636 637 abbreviations. True or False. Default is False.
637 638 style;;
638 639 Name of style to use for command output.
639 640 timeout;;
640 641 The timeout used when a lock is held (in seconds), a negative value
641 642 means no timeout. Default is 600.
642 643 username;;
643 644 The committer of a changeset created when running "commit".
644 645 Typically a person's name and email address, e.g. "Fred Widget
645 646 <fred@example.com>". Default is $EMAIL or username@hostname.
646 647 If the username in hgrc is empty, it has to be specified manually or
647 648 in a different hgrc file (e.g. $HOME/.hgrc, if the admin set "username ="
648 649 in the system hgrc).
649 650 verbose;;
650 651 Increase the amount of output printed. True or False. Default is False.
651 652
652 653
653 654 [[web]]
654 655 web::
655 656 Web interface configuration.
656 657 accesslog;;
657 658 Where to output the access log. Default is stdout.
658 659 address;;
659 660 Interface address to bind to. Default is all.
660 661 allow_archive;;
661 662 List of archive format (bz2, gz, zip) allowed for downloading.
662 663 Default is empty.
663 664 allowbz2;;
664 665 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
665 666 Default is false.
666 667 allowgz;;
667 668 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
668 669 Default is false.
669 670 allowpull;;
670 671 Whether to allow pulling from the repository. Default is true.
671 672 allow_push;;
672 673 Whether to allow pushing to the repository. If empty or not set,
673 674 push is not allowed. If the special value "*", any remote user
674 675 can push, including unauthenticated users. Otherwise, the remote
675 676 user must have been authenticated, and the authenticated user name
676 677 must be present in this list (separated by whitespace or ",").
677 678 The contents of the allow_push list are examined after the
678 679 deny_push list.
679 680 allow_read;;
680 681 If the user has not already been denied repository access due to the
681 682 contents of deny_read, this list determines whether to grant repository
682 683 access to the user. If this list is not empty, and the user is
683 684 unauthenticated or not present in the list (separated by whitespace or ","),
684 685 then access is denied for the user. If the list is empty or not set, then
685 686 access is permitted to all users by default. Setting allow_read to the
686 687 special value "*" is equivalent to it not being set (i.e. access is
687 688 permitted to all users). The contents of the allow_read list are examined
688 689 after the deny_read list.
689 690 allowzip;;
690 691 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
691 692 Default is false. This feature creates temporary files.
692 693 baseurl;;
693 694 Base URL to use when publishing URLs in other locations, so
694 695 third-party tools like email notification hooks can construct URLs.
695 696 Example: "http://hgserver/repos/"
696 697 contact;;
697 698 Name or email address of the person in charge of the repository.
698 699 Defaults to ui.username or $EMAIL or "unknown" if unset or empty.
699 700 deny_push;;
700 701 Whether to deny pushing to the repository. If empty or not set,
701 702 push is not denied. If the special value "*", all remote users
702 703 are denied push. Otherwise, unauthenticated users are all denied,
703 704 and any authenticated user name present in this list (separated by
704 705 whitespace or ",") is also denied. The contents of the deny_push
705 706 list are examined before the allow_push list.
706 707 deny_read;;
707 708 Whether to deny reading/viewing of the repository. If this list is not
708 709 empty, unauthenticated users are all denied, and any authenticated user name
709 710 present in this list (separated by whitespace or ",") is also denied access
710 711 to the repository. If set to the special value "*", all remote users are
711 712 denied access (rarely needed ;). If deny_read is empty or not set, the
712 713 determination of repository access depends on the presence and content of
713 714 the allow_read list (see description). If both deny_read and allow_read are
714 715 empty or not set, then access is permitted to all users by default. If the
715 716 repository is being served via hgwebdir, denied users will not be able to
716 717 see it in the list of repositories. The contents of the deny_read list have
717 718 priority over (are examined before) the contents of the allow_read list.
718 719 description;;
719 720 Textual description of the repository's purpose or contents.
720 721 Default is "unknown".
721 722 encoding;;
722 723 Character encoding name.
723 724 Example: "UTF-8"
724 725 errorlog;;
725 726 Where to output the error log. Default is stderr.
726 727 hidden;;
727 728 Whether to hide the repository in the hgwebdir index. Default is false.
728 729 ipv6;;
729 730 Whether to use IPv6. Default is false.
730 731 name;;
731 732 Repository name to use in the web interface. Default is current
732 733 working directory.
733 734 maxchanges;;
734 735 Maximum number of changes to list on the changelog. Default is 10.
735 736 maxfiles;;
736 737 Maximum number of files to list per changeset. Default is 10.
737 738 port;;
738 739 Port to listen on. Default is 8000.
739 740 prefix;;
740 741 Prefix path to serve from. Default is '' (server root).
741 742 push_ssl;;
742 743 Whether to require that inbound pushes be transported over SSL to
743 744 prevent password sniffing. Default is true.
744 745 staticurl;;
745 746 Base URL to use for static files. If unset, static files (e.g.
746 747 the hgicon.png favicon) will be served by the CGI script itself.
747 748 Use this setting to serve them directly with the HTTP server.
748 749 Example: "http://hgserver/static/"
749 750 stripes;;
750 751 How many lines a "zebra stripe" should span in multiline output.
751 752 Default is 1; set to 0 to disable.
752 753 style;;
753 754 Which template map style to use.
754 755 templates;;
755 756 Where to find the HTML templates. Default is install path.
756 757
757 758
758 759 AUTHOR
759 760 ------
760 761 Bryan O'Sullivan <bos@serpentine.com>.
761 762
762 763 Mercurial was written by Matt Mackall <mpm@selenic.com>.
763 764
764 765 SEE ALSO
765 766 --------
766 767 hg(1), hgignore(5)
767 768
768 769 COPYING
769 770 -------
770 771 This manual page is copyright 2005 Bryan O'Sullivan.
771 772 Mercurial is copyright 2005-2007 Matt Mackall.
772 773 Free use of this software is granted under the terms of the GNU General
773 774 Public License (GPL).
@@ -1,116 +1,119
1 1 # extensions.py - extension handling for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 import imp, os
9 9 import util, cmdutil
10 10 from i18n import _
11 11
12 12 _extensions = {}
13 13 _order = []
14 14
15 15 def extensions():
16 16 for name in _order:
17 17 module = _extensions[name]
18 18 if module:
19 19 yield name, module
20 20
21 21 def find(name):
22 22 '''return module with given extension name'''
23 23 try:
24 24 return _extensions[name]
25 25 except KeyError:
26 26 for k, v in _extensions.iteritems():
27 27 if k.endswith('.' + name) or k.endswith('/' + name):
28 28 return v
29 29 raise KeyError(name)
30 30
31 def loadpath(path, module_name):
32 module_name = module_name.replace('.', '_')
33 path = os.path.expanduser(path)
34 if os.path.isdir(path):
35 # module/__init__.py style
36 d, f = os.path.split(path)
37 fd, fpath, desc = imp.find_module(f, [d])
38 return imp.load_module(module_name, fd, fpath, desc)
39 else:
40 return imp.load_source(module_name, path)
41
31 42 def load(ui, name, path):
32 43 if name.startswith('hgext.') or name.startswith('hgext/'):
33 44 shortname = name[6:]
34 45 else:
35 46 shortname = name
36 47 if shortname in _extensions:
37 48 return
38 49 _extensions[shortname] = None
39 50 if path:
40 51 # the module will be loaded in sys.modules
41 52 # choose an unique name so that it doesn't
42 53 # conflicts with other modules
43 module_name = "hgext_%s" % name.replace('.', '_')
44 if os.path.isdir(path):
45 # module/__init__.py style
46 d, f = os.path.split(path)
47 fd, fpath, desc = imp.find_module(f, [d])
48 mod = imp.load_module(module_name, fd, fpath, desc)
49 else:
50 mod = imp.load_source(module_name, path)
54 mod = loadpath(path, 'hgext.%s' % name)
51 55 else:
52 56 def importh(name):
53 57 mod = __import__(name)
54 58 components = name.split('.')
55 59 for comp in components[1:]:
56 60 mod = getattr(mod, comp)
57 61 return mod
58 62 try:
59 63 mod = importh("hgext.%s" % name)
60 64 except ImportError:
61 65 mod = importh(name)
62 66 _extensions[shortname] = mod
63 67 _order.append(shortname)
64 68
65 69 uisetup = getattr(mod, 'uisetup', None)
66 70 if uisetup:
67 71 uisetup(ui)
68 72
69 73 def loadall(ui):
70 74 result = ui.configitems("extensions")
71 75 for (name, path) in result:
72 76 if path:
73 77 if path[0] == '!':
74 78 continue
75 path = os.path.expanduser(path)
76 79 try:
77 80 load(ui, name, path)
78 81 except KeyboardInterrupt:
79 82 raise
80 83 except Exception, inst:
81 84 if path:
82 85 ui.warn(_("*** failed to import extension %s from %s: %s\n")
83 86 % (name, path, inst))
84 87 else:
85 88 ui.warn(_("*** failed to import extension %s: %s\n")
86 89 % (name, inst))
87 90 if ui.print_exc():
88 91 return 1
89 92
90 93 def wrapcommand(table, command, wrapper):
91 94 aliases, entry = cmdutil.findcmd(command, table)
92 95 for alias, e in table.iteritems():
93 96 if e is entry:
94 97 key = alias
95 98 break
96 99
97 100 origfn = entry[0]
98 101 def wrap(*args, **kwargs):
99 102 return util.checksignature(wrapper)(
100 103 util.checksignature(origfn), *args, **kwargs)
101 104
102 105 wrap.__doc__ = getattr(origfn, '__doc__')
103 106 wrap.__module__ = getattr(origfn, '__module__')
104 107
105 108 newentry = list(entry)
106 109 newentry[0] = wrap
107 110 table[key] = tuple(newentry)
108 111 return entry
109 112
110 113 def wrapfunction(container, funcname, wrapper):
111 114 def wrap(*args, **kwargs):
112 115 return wrapper(origfn, *args, **kwargs)
113 116
114 117 origfn = getattr(container, funcname)
115 118 setattr(container, funcname, wrap)
116 119 return origfn
@@ -1,121 +1,127
1 1 # hook.py - hook support for mercurial
2 2 #
3 3 # Copyright 2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from i18n import _
9 9 import util, os, sys
10 from mercurial import extensions
10 11
11 12 def _pythonhook(ui, repo, name, hname, funcname, args, throw):
12 13 '''call python hook. hook is callable object, looked up as
13 14 name in python module. if callable returns "true", hook
14 15 fails, else passes. if hook raises exception, treated as
15 16 hook failure. exception propagates if throw is "true".
16 17
17 18 reason for "true" meaning "hook failed" is so that
18 19 unmodified commands (e.g. mercurial.commands.update) can
19 20 be run as hooks without wrappers to convert return values.'''
20 21
21 22 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
22 23 obj = funcname
23 24 if not callable(obj):
24 25 d = funcname.rfind('.')
25 26 if d == -1:
26 27 raise util.Abort(_('%s hook is invalid ("%s" not in '
27 28 'a module)') % (hname, funcname))
28 29 modname = funcname[:d]
29 30 try:
30 31 obj = __import__(modname)
31 32 except ImportError:
32 33 try:
33 34 # extensions are loaded with hgext_ prefix
34 35 obj = __import__("hgext_%s" % modname)
35 36 except ImportError:
36 37 raise util.Abort(_('%s hook is invalid '
37 38 '(import of "%s" failed)') %
38 39 (hname, modname))
39 40 try:
40 41 for p in funcname.split('.')[1:]:
41 42 obj = getattr(obj, p)
42 43 except AttributeError:
43 44 raise util.Abort(_('%s hook is invalid '
44 45 '("%s" is not defined)') %
45 46 (hname, funcname))
46 47 if not callable(obj):
47 48 raise util.Abort(_('%s hook is invalid '
48 49 '("%s" is not callable)') %
49 50 (hname, funcname))
50 51 try:
51 52 r = obj(ui=ui, repo=repo, hooktype=name, **args)
52 53 except KeyboardInterrupt:
53 54 raise
54 55 except Exception, exc:
55 56 if isinstance(exc, util.Abort):
56 57 ui.warn(_('error: %s hook failed: %s\n') %
57 58 (hname, exc.args[0]))
58 59 else:
59 60 ui.warn(_('error: %s hook raised an exception: '
60 61 '%s\n') % (hname, exc))
61 62 if throw:
62 63 raise
63 64 ui.print_exc()
64 65 return True
65 66 if r:
66 67 if throw:
67 68 raise util.Abort(_('%s hook failed') % hname)
68 69 ui.warn(_('warning: %s hook failed\n') % hname)
69 70 return r
70 71
71 72 def _exthook(ui, repo, name, cmd, args, throw):
72 73 ui.note(_("running hook %s: %s\n") % (name, cmd))
73 74
74 75 env = {}
75 76 for k, v in args.iteritems():
76 77 if callable(v):
77 78 v = v()
78 79 env['HG_' + k.upper()] = v
79 80
80 81 if repo:
81 82 cwd = repo.root
82 83 else:
83 84 cwd = os.getcwd()
84 85 r = util.system(cmd, environ=env, cwd=cwd)
85 86 if r:
86 87 desc, r = util.explain_exit(r)
87 88 if throw:
88 89 raise util.Abort(_('%s hook %s') % (name, desc))
89 90 ui.warn(_('warning: %s hook %s\n') % (name, desc))
90 91 return r
91 92
92 93 _redirect = False
93 94 def redirect(state):
94 95 global _redirect
95 96 _redirect = state
96 97
97 98 def hook(ui, repo, name, throw=False, **args):
98 99 r = False
99 100
100 101 if _redirect:
101 102 # temporarily redirect stdout to stderr
102 103 oldstdout = os.dup(sys.__stdout__.fileno())
103 104 os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
104 105
105 106 try:
106 107 for hname, cmd in util.sort(ui.configitems('hooks')):
107 108 if hname.split('.')[0] != name or not cmd:
108 109 continue
109 110 if callable(cmd):
110 111 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
111 112 elif cmd.startswith('python:'):
112 r = _pythonhook(ui, repo, name, hname, cmd[7:].strip(),
113 args, throw) or r
113 if cmd.count(':') == 2:
114 path, cmd = cmd[7:].split(':')
115 mod = extensions.loadpath(path, 'hgkook.%s' % hname)
116 hookfn = getattr(mod, cmd)
117 else:
118 hookfn = cmd[7:].strip()
119 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
114 120 else:
115 121 r = _exthook(ui, repo, hname, cmd, args, throw) or r
116 122 finally:
117 123 if _redirect:
118 124 os.dup2(oldstdout, sys.__stdout__.fileno())
119 125 os.close(oldstdout)
120 126
121 127 return r
General Comments 0
You need to be logged in to leave comments. Login now