##// END OF EJS Templates
ui: add an option to prompt for the username when it isn't provided...
Benoit Boissinot -
r6862:7192876a default
parent child Browse files
Show More
@@ -1,717 +1,723 b''
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
218 218 Email example:
219 219
220 220 [email]
221 221 from = Joseph User <joe.user@example.com>
222 222 method = /usr/sbin/sendmail
223 223
224 224 [[extensions]]
225 225 extensions::
226 226 Mercurial has an extension mechanism for adding new features. To
227 227 enable an extension, create an entry for it in this section.
228 228
229 229 If you know that the extension is already in Python's search path,
230 230 you can give the name of the module, followed by "=", with nothing
231 231 after the "=".
232 232
233 233 Otherwise, give a name that you choose, followed by "=", followed by
234 234 the path to the ".py" file (including the file name extension) that
235 235 defines the extension.
236 236
237 237 To explicitly disable an extension that is enabled in an hgrc of
238 238 broader scope, prepend its path with '!', as in
239 239 'hgext.foo = !/ext/path' or 'hgext.foo = !' when no path is supplied.
240 240
241 241 Example for ~/.hgrc:
242 242
243 243 [extensions]
244 244 # (the mq extension will get loaded from mercurial's path)
245 245 hgext.mq =
246 246 # (this extension will get loaded from the file specified)
247 247 myfeature = ~/.hgext/myfeature.py
248 248
249 249 [[format]]
250 250 format::
251 251
252 252 usestore;;
253 253 Enable or disable the "store" repository format which improves
254 254 compatibility with systems that fold case or otherwise mangle
255 255 filenames. Enabled by default. Disabling this option will allow
256 256 you to store longer filenames in some situations at the expense of
257 257 compatibility.
258 258
259 259 [[merge-patterns]]
260 260 merge-patterns::
261 261 This section specifies merge tools to associate with particular file
262 262 patterns. Tools matched here will take precedence over the default
263 263 merge tool. Patterns are globs by default, rooted at the repository root.
264 264
265 265 Example:
266 266
267 267 [merge-patterns]
268 268 **.c = kdiff3
269 269 **.jpg = myimgmerge
270 270
271 271 [[merge-tools]]
272 272 merge-tools::
273 273 This section configures external merge tools to use for file-level
274 274 merges.
275 275
276 276 Example ~/.hgrc:
277 277
278 278 [merge-tools]
279 279 # Override stock tool location
280 280 kdiff3.executable = ~/bin/kdiff3
281 281 # Specify command line
282 282 kdiff3.args = $base $local $other -o $output
283 283 # Give higher priority
284 284 kdiff3.priority = 1
285 285
286 286 # Define new tool
287 287 myHtmlTool.args = -m $local $other $base $output
288 288 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
289 289 myHtmlTool.priority = 1
290 290
291 291 Supported arguments:
292 292
293 293 priority;;
294 294 The priority in which to evaluate this tool.
295 295 Default: 0.
296 296 executable;;
297 297 Either just the name of the executable or its pathname.
298 298 Default: the tool name.
299 299 args;;
300 300 The arguments to pass to the tool executable. You can refer to the files
301 301 being merged as well as the output file through these variables: $base,
302 302 $local, $other, $output.
303 303 Default: $local $base $other
304 304 premerge;;
305 305 Attempt to run internal non-interactive 3-way merge tool before
306 306 launching external tool.
307 307 Default: True
308 308 binary;;
309 309 This tool can merge binary files. Defaults to False, unless tool
310 310 was selected by file pattern match.
311 311 symlink;;
312 312 This tool can merge symlinks. Defaults to False, even if tool was
313 313 selected by file pattern match.
314 314 checkconflicts;;
315 315 Check whether there are conflicts even though the tool reported
316 316 success.
317 317 Default: False
318 318 checkchanged;;
319 319 Check whether outputs were written even though the tool reported
320 320 success.
321 321 Default: False
322 322 fixeol;;
323 323 Attempt to fix up EOL changes caused by the merge tool.
324 324 Default: False
325 325 gui;;
326 326 This tool requires a graphical interface to run. Default: False
327 327 regkey;;
328 328 Windows registry key which describes install location of this tool.
329 329 Mercurial will search for this key first under HKEY_CURRENT_USER and
330 330 then under HKEY_LOCAL_MACHINE. Default: None
331 331 regname;;
332 332 Name of value to read from specified registry key. Defaults to the
333 333 unnamed (default) value.
334 334 regappend;;
335 335 String to append to the value read from the registry, typically the
336 336 executable name of the tool. Default: None
337 337
338 338 [[hooks]]
339 339 hooks::
340 340 Commands or Python functions that get automatically executed by
341 341 various actions such as starting or finishing a commit. Multiple
342 342 hooks can be run for the same action by appending a suffix to the
343 343 action. Overriding a site-wide hook can be done by changing its
344 344 value or setting it to an empty string.
345 345
346 346 Example .hg/hgrc:
347 347
348 348 [hooks]
349 349 # do not use the site-wide hook
350 350 incoming =
351 351 incoming.email = /my/email/hook
352 352 incoming.autobuild = /my/build/hook
353 353
354 354 Most hooks are run with environment variables set that give added
355 355 useful information. For each hook below, the environment variables
356 356 it is passed are listed with names of the form "$HG_foo".
357 357
358 358 changegroup;;
359 359 Run after a changegroup has been added via push, pull or
360 360 unbundle. ID of the first new changeset is in $HG_NODE. URL from
361 361 which changes came is in $HG_URL.
362 362 commit;;
363 363 Run after a changeset has been created in the local repository.
364 364 ID of the newly created changeset is in $HG_NODE. Parent
365 365 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
366 366 incoming;;
367 367 Run after a changeset has been pulled, pushed, or unbundled into
368 368 the local repository. The ID of the newly arrived changeset is in
369 369 $HG_NODE. URL that was source of changes came is in $HG_URL.
370 370 outgoing;;
371 371 Run after sending changes from local repository to another. ID of
372 372 first changeset sent is in $HG_NODE. Source of operation is in
373 373 $HG_SOURCE; see "preoutgoing" hook for description.
374 374 post-<command>;;
375 375 Run after successful invocations of the associated command. The
376 376 contents of the command line are passed as $HG_ARGS and the result
377 377 code in $HG_RESULT. Hook failure is ignored.
378 378 pre-<command>;;
379 379 Run before executing the associated command. The contents of the
380 380 command line are passed as $HG_ARGS. If the hook returns failure,
381 381 the command doesn't execute and Mercurial returns the failure code.
382 382 prechangegroup;;
383 383 Run before a changegroup is added via push, pull or unbundle.
384 384 Exit status 0 allows the changegroup to proceed. Non-zero status
385 385 will cause the push, pull or unbundle to fail. URL from which
386 386 changes will come is in $HG_URL.
387 387 precommit;;
388 388 Run before starting a local commit. Exit status 0 allows the
389 389 commit to proceed. Non-zero status will cause the commit to fail.
390 390 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
391 391 preoutgoing;;
392 392 Run before collecting changes to send from the local repository to
393 393 another. Non-zero status will cause failure. This lets you
394 394 prevent pull over http or ssh. Also prevents against local pull,
395 395 push (outbound) or bundle commands, but not effective, since you
396 396 can just copy files instead then. Source of operation is in
397 397 $HG_SOURCE. If "serve", operation is happening on behalf of
398 398 remote ssh or http repository. If "push", "pull" or "bundle",
399 399 operation is happening on behalf of repository on same system.
400 400 pretag;;
401 401 Run before creating a tag. Exit status 0 allows the tag to be
402 402 created. Non-zero status will cause the tag to fail. ID of
403 403 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
404 404 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
405 405 pretxnchangegroup;;
406 406 Run after a changegroup has been added via push, pull or unbundle,
407 407 but before the transaction has been committed. Changegroup is
408 408 visible to hook program. This lets you validate incoming changes
409 409 before accepting them. Passed the ID of the first new changeset
410 410 in $HG_NODE. Exit status 0 allows the transaction to commit.
411 411 Non-zero status will cause the transaction to be rolled back and
412 412 the push, pull or unbundle will fail. URL that was source of
413 413 changes is in $HG_URL.
414 414 pretxncommit;;
415 415 Run after a changeset has been created but the transaction not yet
416 416 committed. Changeset is visible to hook program. This lets you
417 417 validate commit message and changes. Exit status 0 allows the
418 418 commit to proceed. Non-zero status will cause the transaction to
419 419 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
420 420 IDs are in $HG_PARENT1 and $HG_PARENT2.
421 421 preupdate;;
422 422 Run before updating the working directory. Exit status 0 allows
423 423 the update to proceed. Non-zero status will prevent the update.
424 424 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
425 425 of second new parent is in $HG_PARENT2.
426 426 tag;;
427 427 Run after a tag is created. ID of tagged changeset is in
428 428 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
429 429 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
430 430 update;;
431 431 Run after updating the working directory. Changeset ID of first
432 432 new parent is in $HG_PARENT1. If merge, ID of second new parent
433 433 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
434 434 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
435 435
436 436 Note: it is generally better to use standard hooks rather than the
437 437 generic pre- and post- command hooks as they are guaranteed to be
438 438 called in the appropriate contexts for influencing transactions.
439 439 Also, hooks like "commit" will be called in all contexts that
440 440 generate a commit (eg. tag) and not just the commit command.
441 441
442 442 Note2: Environment variables with empty values may not be passed to
443 443 hooks on platforms like Windows. For instance, $HG_PARENT2 will
444 444 not be available under Windows for non-merge changesets while being
445 445 set to an empty value under Unix-like systems.
446 446
447 447 The syntax for Python hooks is as follows:
448 448
449 449 hookname = python:modulename.submodule.callable
450 450
451 451 Python hooks are run within the Mercurial process. Each hook is
452 452 called with at least three keyword arguments: a ui object (keyword
453 453 "ui"), a repository object (keyword "repo"), and a "hooktype"
454 454 keyword that tells what kind of hook is used. Arguments listed as
455 455 environment variables above are passed as keyword arguments, with no
456 456 "HG_" prefix, and names in lower case.
457 457
458 458 If a Python hook returns a "true" value or raises an exception, this
459 459 is treated as failure of the hook.
460 460
461 461 [[http_proxy]]
462 462 http_proxy::
463 463 Used to access web-based Mercurial repositories through a HTTP
464 464 proxy.
465 465 host;;
466 466 Host name and (optional) port of the proxy server, for example
467 467 "myproxy:8000".
468 468 no;;
469 469 Optional. Comma-separated list of host names that should bypass
470 470 the proxy.
471 471 passwd;;
472 472 Optional. Password to authenticate with at the proxy server.
473 473 user;;
474 474 Optional. User name to authenticate with at the proxy server.
475 475
476 476 [[smtp]]
477 477 smtp::
478 478 Configuration for extensions that need to send email messages.
479 479 host;;
480 480 Host name of mail server, e.g. "mail.example.com".
481 481 port;;
482 482 Optional. Port to connect to on mail server. Default: 25.
483 483 tls;;
484 484 Optional. Whether to connect to mail server using TLS. True or
485 485 False. Default: False.
486 486 username;;
487 487 Optional. User name to authenticate to SMTP server with.
488 488 If username is specified, password must also be specified.
489 489 Default: none.
490 490 password;;
491 491 Optional. Password to authenticate to SMTP server with.
492 492 If username is specified, password must also be specified.
493 493 Default: none.
494 494 local_hostname;;
495 495 Optional. It's the hostname that the sender can use to identify itself
496 496 to the MTA.
497 497
498 498 [[paths]]
499 499 paths::
500 500 Assigns symbolic names to repositories. The left side is the
501 501 symbolic name, and the right gives the directory or URL that is the
502 502 location of the repository. Default paths can be declared by
503 503 setting the following entries.
504 504 default;;
505 505 Directory or URL to use when pulling if no source is specified.
506 506 Default is set to repository from which the current repository
507 507 was cloned.
508 508 default-push;;
509 509 Optional. Directory or URL to use when pushing if no destination
510 510 is specified.
511 511
512 512 [[server]]
513 513 server::
514 514 Controls generic server settings.
515 515 uncompressed;;
516 516 Whether to allow clients to clone a repo using the uncompressed
517 517 streaming protocol. This transfers about 40% more data than a
518 518 regular clone, but uses less memory and CPU on both server and
519 519 client. Over a LAN (100Mbps or better) or a very fast WAN, an
520 520 uncompressed streaming clone is a lot faster (~10x) than a regular
521 521 clone. Over most WAN connections (anything slower than about
522 522 6Mbps), uncompressed streaming is slower, because of the extra
523 523 data transfer overhead. Default is False.
524 524
525 525 [[trusted]]
526 526 trusted::
527 527 For security reasons, Mercurial will not use the settings in
528 528 the .hg/hgrc file from a repository if it doesn't belong to a
529 529 trusted user or to a trusted group. The main exception is the
530 530 web interface, which automatically uses some safe settings, since
531 531 it's common to serve repositories from different users.
532 532
533 533 This section specifies what users and groups are trusted. The
534 534 current user is always trusted. To trust everybody, list a user
535 535 or a group with name "*".
536 536
537 537 users;;
538 538 Comma-separated list of trusted users.
539 539 groups;;
540 540 Comma-separated list of trusted groups.
541 541
542 542 [[ui]]
543 543 ui::
544 544 User interface controls.
545 545 archivemeta;;
546 546 Whether to include the .hg_archival.txt file containing metadata
547 547 (hashes for the repository base and for tip) in archives created by
548 548 the hg archive command or downloaded via hgweb.
549 549 Default is true.
550 askusername;;
551 Whether to prompt for a username when committing. If True, and
552 neither $HGUSER nor $EMAIL has been specified, then the user will
553 be prompted to enter a username. If no username is entered, the
554 default USER@HOST is used instead.
555 Default is False.
550 556 debug;;
551 557 Print debugging information. True or False. Default is False.
552 558 editor;;
553 559 The editor to use during a commit. Default is $EDITOR or "vi".
554 560 fallbackencoding;;
555 561 Encoding to try if it's not possible to decode the changelog using
556 562 UTF-8. Default is ISO-8859-1.
557 563 ignore;;
558 564 A file to read per-user ignore patterns from. This file should be in
559 565 the same format as a repository-wide .hgignore file. This option
560 566 supports hook syntax, so if you want to specify multiple ignore
561 567 files, you can do so by setting something like
562 568 "ignore.other = ~/.hgignore2". For details of the ignore file
563 569 format, see the hgignore(5) man page.
564 570 interactive;;
565 571 Allow to prompt the user. True or False. Default is True.
566 572 logtemplate;;
567 573 Template string for commands that print changesets.
568 574 merge;;
569 575 The conflict resolution program to use during a manual merge.
570 576 There are some internal tools available:
571 577
572 578 internal:local;;
573 579 keep the local version
574 580 internal:other;;
575 581 use the other version
576 582 internal:merge;;
577 583 use the internal non-interactive merge tool
578 584 internal:fail;;
579 585 fail to merge
580 586
581 587 See the merge-tools section for more information on configuring tools.
582 588
583 589 patch;;
584 590 command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if
585 591 unset.
586 592 quiet;;
587 593 Reduce the amount of output printed. True or False. Default is False.
588 594 remotecmd;;
589 595 remote command to use for clone/push/pull operations. Default is 'hg'.
590 596 report_untrusted;;
591 597 Warn if a .hg/hgrc file is ignored due to not being owned by a
592 598 trusted user or group. True or False. Default is True.
593 599 slash;;
594 600 Display paths using a slash ("/") as the path separator. This only
595 601 makes a difference on systems where the default path separator is not
596 602 the slash character (e.g. Windows uses the backslash character ("\")).
597 603 Default is False.
598 604 ssh;;
599 605 command to use for SSH connections. Default is 'ssh'.
600 606 strict;;
601 607 Require exact command names, instead of allowing unambiguous
602 608 abbreviations. True or False. Default is False.
603 609 style;;
604 610 Name of style to use for command output.
605 611 timeout;;
606 612 The timeout used when a lock is held (in seconds), a negative value
607 613 means no timeout. Default is 600.
608 614 username;;
609 615 The committer of a changeset created when running "commit".
610 616 Typically a person's name and email address, e.g. "Fred Widget
611 617 <fred@example.com>". Default is $EMAIL or username@hostname.
612 618 If the username in hgrc is empty, it has to be specified manually or
613 619 in a different hgrc file (e.g. $HOME/.hgrc, if the admin set "username ="
614 620 in the system hgrc).
615 621 verbose;;
616 622 Increase the amount of output printed. True or False. Default is False.
617 623
618 624
619 625 [[web]]
620 626 web::
621 627 Web interface configuration.
622 628 accesslog;;
623 629 Where to output the access log. Default is stdout.
624 630 address;;
625 631 Interface address to bind to. Default is all.
626 632 allow_archive;;
627 633 List of archive format (bz2, gz, zip) allowed for downloading.
628 634 Default is empty.
629 635 allowbz2;;
630 636 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
631 637 Default is false.
632 638 allowgz;;
633 639 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
634 640 Default is false.
635 641 allowpull;;
636 642 Whether to allow pulling from the repository. Default is true.
637 643 allow_push;;
638 644 Whether to allow pushing to the repository. If empty or not set,
639 645 push is not allowed. If the special value "*", any remote user
640 646 can push, including unauthenticated users. Otherwise, the remote
641 647 user must have been authenticated, and the authenticated user name
642 648 must be present in this list (separated by whitespace or ",").
643 649 The contents of the allow_push list are examined after the
644 650 deny_push list.
645 651 allowzip;;
646 652 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
647 653 Default is false. This feature creates temporary files.
648 654 baseurl;;
649 655 Base URL to use when publishing URLs in other locations, so
650 656 third-party tools like email notification hooks can construct URLs.
651 657 Example: "http://hgserver/repos/"
652 658 contact;;
653 659 Name or email address of the person in charge of the repository.
654 660 Defaults to ui.username or $EMAIL or "unknown" if unset or empty.
655 661 deny_push;;
656 662 Whether to deny pushing to the repository. If empty or not set,
657 663 push is not denied. If the special value "*", all remote users
658 664 are denied push. Otherwise, unauthenticated users are all denied,
659 665 and any authenticated user name present in this list (separated by
660 666 whitespace or ",") is also denied. The contents of the deny_push
661 667 list are examined before the allow_push list.
662 668 description;;
663 669 Textual description of the repository's purpose or contents.
664 670 Default is "unknown".
665 671 encoding;;
666 672 Character encoding name.
667 673 Example: "UTF-8"
668 674 errorlog;;
669 675 Where to output the error log. Default is stderr.
670 676 hidden;;
671 677 Whether to hide the repository in the hgwebdir index. Default is false.
672 678 ipv6;;
673 679 Whether to use IPv6. Default is false.
674 680 name;;
675 681 Repository name to use in the web interface. Default is current
676 682 working directory.
677 683 maxchanges;;
678 684 Maximum number of changes to list on the changelog. Default is 10.
679 685 maxfiles;;
680 686 Maximum number of files to list per changeset. Default is 10.
681 687 port;;
682 688 Port to listen on. Default is 8000.
683 689 prefix;;
684 690 Prefix path to serve from. Default is '' (server root).
685 691 push_ssl;;
686 692 Whether to require that inbound pushes be transported over SSL to
687 693 prevent password sniffing. Default is true.
688 694 staticurl;;
689 695 Base URL to use for static files. If unset, static files (e.g.
690 696 the hgicon.png favicon) will be served by the CGI script itself.
691 697 Use this setting to serve them directly with the HTTP server.
692 698 Example: "http://hgserver/static/"
693 699 stripes;;
694 700 How many lines a "zebra stripe" should span in multiline output.
695 701 Default is 1; set to 0 to disable.
696 702 style;;
697 703 Which template map style to use.
698 704 templates;;
699 705 Where to find the HTML templates. Default is install path.
700 706
701 707
702 708 AUTHOR
703 709 ------
704 710 Bryan O'Sullivan <bos@serpentine.com>.
705 711
706 712 Mercurial was written by Matt Mackall <mpm@selenic.com>.
707 713
708 714 SEE ALSO
709 715 --------
710 716 hg(1), hgignore(5)
711 717
712 718 COPYING
713 719 -------
714 720 This manual page is copyright 2005 Bryan O'Sullivan.
715 721 Mercurial is copyright 2005-2007 Matt Mackall.
716 722 Free use of this software is granted under the terms of the GNU General
717 723 Public License (GPL).
@@ -1,482 +1,484 b''
1 1 # ui.py - user interface bits 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 from i18n import _
9 9 import errno, getpass, os, re, socket, sys, tempfile
10 10 import ConfigParser, traceback, util
11 11
12 12 def dupconfig(orig):
13 13 new = util.configparser(orig.defaults())
14 14 updateconfig(orig, new)
15 15 return new
16 16
17 17 def updateconfig(source, dest, sections=None):
18 18 if not sections:
19 19 sections = source.sections()
20 20 for section in sections:
21 21 if not dest.has_section(section):
22 22 dest.add_section(section)
23 23 for name, value in source.items(section, raw=True):
24 24 dest.set(section, name, value)
25 25
26 26 class ui(object):
27 27 _isatty = None
28 28
29 29 def __init__(self, verbose=False, debug=False, quiet=False,
30 30 interactive=True, traceback=False, report_untrusted=True,
31 31 parentui=None):
32 32 self.overlay = None
33 33 self.buffers = []
34 34 if parentui is None:
35 35 # this is the parent of all ui children
36 36 self.parentui = None
37 37 self.quiet = quiet
38 38 self.verbose = verbose
39 39 self.debugflag = debug
40 40 self.interactive = interactive
41 41 self.traceback = traceback
42 42 self.report_untrusted = report_untrusted
43 43 self.trusted_users = {}
44 44 self.trusted_groups = {}
45 45 # if ucdata is not None, its keys must be a superset of cdata's
46 46 self.cdata = util.configparser()
47 47 self.ucdata = None
48 48 # we always trust global config files
49 49 self.check_trusted = False
50 50 self.readconfig(util.rcpath())
51 51 self.check_trusted = True
52 52 self.updateopts(verbose, debug, quiet, interactive)
53 53 else:
54 54 # parentui may point to an ui object which is already a child
55 55 self.parentui = parentui.parentui or parentui
56 56 self.trusted_users = parentui.trusted_users.copy()
57 57 self.trusted_groups = parentui.trusted_groups.copy()
58 58 self.cdata = dupconfig(self.parentui.cdata)
59 59 if self.parentui.ucdata:
60 60 self.ucdata = dupconfig(self.parentui.ucdata)
61 61 if self.parentui.overlay:
62 62 self.overlay = dupconfig(self.parentui.overlay)
63 63 if self.parentui is not parentui and parentui.overlay is not None:
64 64 if self.overlay is None:
65 65 self.overlay = util.configparser()
66 66 updateconfig(parentui.overlay, self.overlay)
67 67 self.buffers = parentui.buffers
68 68
69 69 def __getattr__(self, key):
70 70 return getattr(self.parentui, key)
71 71
72 72 def isatty(self):
73 73 if ui._isatty is None:
74 74 ui._isatty = sys.stdin.isatty()
75 75 return ui._isatty
76 76
77 77 def updateopts(self, verbose=False, debug=False, quiet=False,
78 78 interactive=True, traceback=False, config=[]):
79 79 for section, name, value in config:
80 80 self.setconfig(section, name, value)
81 81
82 82 if quiet or verbose or debug:
83 83 self.setconfig('ui', 'quiet', str(bool(quiet)))
84 84 self.setconfig('ui', 'verbose', str(bool(verbose)))
85 85 self.setconfig('ui', 'debug', str(bool(debug)))
86 86
87 87 self.verbosity_constraints()
88 88
89 89 if not interactive:
90 90 self.setconfig('ui', 'interactive', 'False')
91 91 self.interactive = False
92 92
93 93 self.traceback = self.traceback or traceback
94 94
95 95 def verbosity_constraints(self):
96 96 self.quiet = self.configbool('ui', 'quiet')
97 97 self.verbose = self.configbool('ui', 'verbose')
98 98 self.debugflag = self.configbool('ui', 'debug')
99 99
100 100 if self.debugflag:
101 101 self.verbose = True
102 102 self.quiet = False
103 103 elif self.verbose and self.quiet:
104 104 self.quiet = self.verbose = False
105 105
106 106 def _is_trusted(self, fp, f, warn=True):
107 107 if not self.check_trusted:
108 108 return True
109 109 st = util.fstat(fp)
110 110 if util.isowner(fp, st):
111 111 return True
112 112 tusers = self.trusted_users
113 113 tgroups = self.trusted_groups
114 114 if not tusers:
115 115 user = util.username()
116 116 if user is not None:
117 117 self.trusted_users[user] = 1
118 118 self.fixconfig(section='trusted')
119 119 if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
120 120 user = util.username(st.st_uid)
121 121 group = util.groupname(st.st_gid)
122 122 if user not in tusers and group not in tgroups:
123 123 if warn and self.report_untrusted:
124 124 self.warn(_('Not trusting file %s from untrusted '
125 125 'user %s, group %s\n') % (f, user, group))
126 126 return False
127 127 return True
128 128
129 129 def readconfig(self, fn, root=None):
130 130 if isinstance(fn, basestring):
131 131 fn = [fn]
132 132 for f in fn:
133 133 try:
134 134 fp = open(f)
135 135 except IOError:
136 136 continue
137 137 cdata = self.cdata
138 138 trusted = self._is_trusted(fp, f)
139 139 if not trusted:
140 140 if self.ucdata is None:
141 141 self.ucdata = dupconfig(self.cdata)
142 142 cdata = self.ucdata
143 143 elif self.ucdata is not None:
144 144 # use a separate configparser, so that we don't accidentally
145 145 # override ucdata settings later on.
146 146 cdata = util.configparser()
147 147
148 148 try:
149 149 cdata.readfp(fp, f)
150 150 except ConfigParser.ParsingError, inst:
151 151 msg = _("Failed to parse %s\n%s") % (f, inst)
152 152 if trusted:
153 153 raise util.Abort(msg)
154 154 self.warn(_("Ignored: %s\n") % msg)
155 155
156 156 if trusted:
157 157 if cdata != self.cdata:
158 158 updateconfig(cdata, self.cdata)
159 159 if self.ucdata is not None:
160 160 updateconfig(cdata, self.ucdata)
161 161 # override data from config files with data set with ui.setconfig
162 162 if self.overlay:
163 163 updateconfig(self.overlay, self.cdata)
164 164 if root is None:
165 165 root = os.path.expanduser('~')
166 166 self.fixconfig(root=root)
167 167
168 168 def readsections(self, filename, *sections):
169 169 """Read filename and add only the specified sections to the config data
170 170
171 171 The settings are added to the trusted config data.
172 172 """
173 173 if not sections:
174 174 return
175 175
176 176 cdata = util.configparser()
177 177 try:
178 178 try:
179 179 fp = open(filename)
180 180 except IOError, inst:
181 181 raise util.Abort(_("unable to open %s: %s") %
182 182 (filename, getattr(inst, "strerror", inst)))
183 183 try:
184 184 cdata.readfp(fp, filename)
185 185 finally:
186 186 fp.close()
187 187 except ConfigParser.ParsingError, inst:
188 188 raise util.Abort(_("failed to parse %s\n%s") % (filename, inst))
189 189
190 190 for section in sections:
191 191 if not cdata.has_section(section):
192 192 cdata.add_section(section)
193 193
194 194 updateconfig(cdata, self.cdata, sections)
195 195 if self.ucdata:
196 196 updateconfig(cdata, self.ucdata, sections)
197 197
198 198 def fixconfig(self, section=None, name=None, value=None, root=None):
199 199 # translate paths relative to root (or home) into absolute paths
200 200 if section is None or section == 'paths':
201 201 if root is None:
202 202 root = os.getcwd()
203 203 items = section and [(name, value)] or []
204 204 for cdata in self.cdata, self.ucdata, self.overlay:
205 205 if not cdata: continue
206 206 if not items and cdata.has_section('paths'):
207 207 pathsitems = cdata.items('paths')
208 208 else:
209 209 pathsitems = items
210 210 for n, path in pathsitems:
211 211 if path and "://" not in path and not os.path.isabs(path):
212 212 cdata.set("paths", n,
213 213 os.path.normpath(os.path.join(root, path)))
214 214
215 215 # update verbosity/interactive/report_untrusted settings
216 216 if section is None or section == 'ui':
217 217 if name is None or name in ('quiet', 'verbose', 'debug'):
218 218 self.verbosity_constraints()
219 219 if name is None or name == 'interactive':
220 220 interactive = self.configbool("ui", "interactive", None)
221 221 if interactive is None and self.interactive:
222 222 self.interactive = self.isatty()
223 223 else:
224 224 self.interactive = interactive
225 225 if name is None or name == 'report_untrusted':
226 226 self.report_untrusted = (
227 227 self.configbool("ui", "report_untrusted", True))
228 228
229 229 # update trust information
230 230 if (section is None or section == 'trusted') and self.trusted_users:
231 231 for user in self.configlist('trusted', 'users'):
232 232 self.trusted_users[user] = 1
233 233 for group in self.configlist('trusted', 'groups'):
234 234 self.trusted_groups[group] = 1
235 235
236 236 def setconfig(self, section, name, value):
237 237 if not self.overlay:
238 238 self.overlay = util.configparser()
239 239 for cdata in (self.overlay, self.cdata, self.ucdata):
240 240 if not cdata: continue
241 241 if not cdata.has_section(section):
242 242 cdata.add_section(section)
243 243 cdata.set(section, name, value)
244 244 self.fixconfig(section, name, value)
245 245
246 246 def _get_cdata(self, untrusted):
247 247 if untrusted and self.ucdata:
248 248 return self.ucdata
249 249 return self.cdata
250 250
251 251 def _config(self, section, name, default, funcname, untrusted, abort):
252 252 cdata = self._get_cdata(untrusted)
253 253 if cdata.has_option(section, name):
254 254 try:
255 255 func = getattr(cdata, funcname)
256 256 return func(section, name)
257 257 except (ConfigParser.InterpolationError, ValueError), inst:
258 258 msg = _("Error in configuration section [%s] "
259 259 "parameter '%s':\n%s") % (section, name, inst)
260 260 if abort:
261 261 raise util.Abort(msg)
262 262 self.warn(_("Ignored: %s\n") % msg)
263 263 return default
264 264
265 265 def _configcommon(self, section, name, default, funcname, untrusted):
266 266 value = self._config(section, name, default, funcname,
267 267 untrusted, abort=True)
268 268 if self.debugflag and not untrusted and self.ucdata:
269 269 uvalue = self._config(section, name, None, funcname,
270 270 untrusted=True, abort=False)
271 271 if uvalue is not None and uvalue != value:
272 272 self.warn(_("Ignoring untrusted configuration option "
273 273 "%s.%s = %s\n") % (section, name, uvalue))
274 274 return value
275 275
276 276 def config(self, section, name, default=None, untrusted=False):
277 277 return self._configcommon(section, name, default, 'get', untrusted)
278 278
279 279 def configbool(self, section, name, default=False, untrusted=False):
280 280 return self._configcommon(section, name, default, 'getboolean',
281 281 untrusted)
282 282
283 283 def configlist(self, section, name, default=None, untrusted=False):
284 284 """Return a list of comma/space separated strings"""
285 285 result = self.config(section, name, untrusted=untrusted)
286 286 if result is None:
287 287 result = default or []
288 288 if isinstance(result, basestring):
289 289 result = result.replace(",", " ").split()
290 290 return result
291 291
292 292 def has_section(self, section, untrusted=False):
293 293 '''tell whether section exists in config.'''
294 294 cdata = self._get_cdata(untrusted)
295 295 return cdata.has_section(section)
296 296
297 297 def _configitems(self, section, untrusted, abort):
298 298 items = {}
299 299 cdata = self._get_cdata(untrusted)
300 300 if cdata.has_section(section):
301 301 try:
302 302 items.update(dict(cdata.items(section)))
303 303 except ConfigParser.InterpolationError, inst:
304 304 msg = _("Error in configuration section [%s]:\n"
305 305 "%s") % (section, inst)
306 306 if abort:
307 307 raise util.Abort(msg)
308 308 self.warn(_("Ignored: %s\n") % msg)
309 309 return items
310 310
311 311 def configitems(self, section, untrusted=False):
312 312 items = self._configitems(section, untrusted=untrusted, abort=True)
313 313 if self.debugflag and not untrusted and self.ucdata:
314 314 uitems = self._configitems(section, untrusted=True, abort=False)
315 315 for k in util.sort(uitems):
316 316 if uitems[k] != items.get(k):
317 317 self.warn(_("Ignoring untrusted configuration option "
318 318 "%s.%s = %s\n") % (section, k, uitems[k]))
319 319 return util.sort(items.items())
320 320
321 321 def walkconfig(self, untrusted=False):
322 322 cdata = self._get_cdata(untrusted)
323 323 sections = cdata.sections()
324 324 sections.sort()
325 325 for section in sections:
326 326 for name, value in self.configitems(section, untrusted):
327 327 yield section, name, str(value).replace('\n', '\\n')
328 328
329 329 def username(self):
330 330 """Return default username to be used in commits.
331 331
332 332 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
333 333 and stop searching if one of these is set.
334 If not found, use ($LOGNAME or $USER or $LNAME or
335 $USERNAME) +"@full.hostname".
334 If not found and ui.askusername is True, ask the user, else use
335 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
336 336 """
337 337 user = os.environ.get("HGUSER")
338 338 if user is None:
339 339 user = self.config("ui", "username")
340 340 if user is None:
341 341 user = os.environ.get("EMAIL")
342 if user is None and self.configbool("ui", "askusername"):
343 user = self.prompt(_("Enter a commit username:"), default=None)
342 344 if user is None:
343 345 try:
344 346 user = '%s@%s' % (util.getuser(), socket.getfqdn())
345 347 self.warn(_("No username found, using '%s' instead\n") % user)
346 348 except KeyError:
347 349 pass
348 350 if not user:
349 351 raise util.Abort(_("Please specify a username."))
350 352 if "\n" in user:
351 353 raise util.Abort(_("username %s contains a newline\n") % `user`)
352 354 return user
353 355
354 356 def shortuser(self, user):
355 357 """Return a short representation of a user name or email address."""
356 358 if not self.verbose: user = util.shortuser(user)
357 359 return user
358 360
359 361 def expandpath(self, loc, default=None):
360 362 """Return repository location relative to cwd or from [paths]"""
361 363 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
362 364 return loc
363 365
364 366 path = self.config("paths", loc)
365 367 if not path and default is not None:
366 368 path = self.config("paths", default)
367 369 return path or loc
368 370
369 371 def pushbuffer(self):
370 372 self.buffers.append([])
371 373
372 374 def popbuffer(self):
373 375 return "".join(self.buffers.pop())
374 376
375 377 def write(self, *args):
376 378 if self.buffers:
377 379 self.buffers[-1].extend([str(a) for a in args])
378 380 else:
379 381 for a in args:
380 382 sys.stdout.write(str(a))
381 383
382 384 def write_err(self, *args):
383 385 try:
384 386 if not sys.stdout.closed: sys.stdout.flush()
385 387 for a in args:
386 388 sys.stderr.write(str(a))
387 389 # stderr may be buffered under win32 when redirected to files,
388 390 # including stdout.
389 391 if not sys.stderr.closed: sys.stderr.flush()
390 392 except IOError, inst:
391 393 if inst.errno != errno.EPIPE:
392 394 raise
393 395
394 396 def flush(self):
395 397 try: sys.stdout.flush()
396 398 except: pass
397 399 try: sys.stderr.flush()
398 400 except: pass
399 401
400 402 def _readline(self, prompt=''):
401 403 if self.isatty():
402 404 try:
403 405 # magically add command line editing support, where
404 406 # available
405 407 import readline
406 408 # force demandimport to really load the module
407 409 readline.read_history_file
408 410 except ImportError:
409 411 pass
410 412 line = raw_input(prompt)
411 413 # When stdin is in binary mode on Windows, it can cause
412 414 # raw_input() to emit an extra trailing carriage return
413 415 if os.linesep == '\r\n' and line and line[-1] == '\r':
414 416 line = line[:-1]
415 417 return line
416 418
417 419 def prompt(self, msg, pat=None, default="y"):
418 420 """Prompt user with msg, read response, and ensure it matches pat
419 421
420 422 If not interactive -- the default is returned
421 423 """
422 424 if not self.interactive: return default
423 425 while True:
424 426 try:
425 427 r = self._readline(msg + ' ')
426 428 if not r:
427 429 return default
428 430 if not pat or re.match(pat, r):
429 431 return r
430 432 else:
431 433 self.write(_("unrecognized response\n"))
432 434 except EOFError:
433 435 raise util.Abort(_('response expected'))
434 436
435 437 def getpass(self, prompt=None, default=None):
436 438 if not self.interactive: return default
437 439 return getpass.getpass(prompt or _('password: '))
438 440 def status(self, *msg):
439 441 if not self.quiet: self.write(*msg)
440 442 def warn(self, *msg):
441 443 self.write_err(*msg)
442 444 def note(self, *msg):
443 445 if self.verbose: self.write(*msg)
444 446 def debug(self, *msg):
445 447 if self.debugflag: self.write(*msg)
446 448 def edit(self, text, user):
447 449 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
448 450 text=True)
449 451 try:
450 452 f = os.fdopen(fd, "w")
451 453 f.write(text)
452 454 f.close()
453 455
454 456 editor = self.geteditor()
455 457
456 458 util.system("%s \"%s\"" % (editor, name),
457 459 environ={'HGUSER': user},
458 460 onerr=util.Abort, errprefix=_("edit failed"))
459 461
460 462 f = open(name)
461 463 t = f.read()
462 464 f.close()
463 465 t = re.sub("(?m)^HG:.*\n", "", t)
464 466 finally:
465 467 os.unlink(name)
466 468
467 469 return t
468 470
469 471 def print_exc(self):
470 472 '''print exception traceback if traceback printing enabled.
471 473 only to call in exception handler. returns true if traceback
472 474 printed.'''
473 475 if self.traceback:
474 476 traceback.print_exc()
475 477 return self.traceback
476 478
477 479 def geteditor(self):
478 480 '''return editor to use'''
479 481 return (os.environ.get("HGEDITOR") or
480 482 self.config("ui", "editor") or
481 483 os.environ.get("VISUAL") or
482 484 os.environ.get("EDITOR", "vi"))
General Comments 0
You need to be logged in to leave comments. Login now