Show More
@@ -1,963 +1,983 | |||||
1 | ====== |
|
1 | ====== | |
2 | hgrc |
|
2 | hgrc | |
3 | ====== |
|
3 | ====== | |
4 |
|
4 | |||
5 | --------------------------------- |
|
5 | --------------------------------- | |
6 | configuration files for Mercurial |
|
6 | configuration files for Mercurial | |
7 | --------------------------------- |
|
7 | --------------------------------- | |
8 |
|
8 | |||
9 | :Author: Bryan O'Sullivan <bos@serpentine.com> |
|
9 | :Author: Bryan O'Sullivan <bos@serpentine.com> | |
10 | :Organization: Mercurial |
|
10 | :Organization: Mercurial | |
11 | :Manual section: 5 |
|
11 | :Manual section: 5 | |
12 | :Manual group: Mercurial Manual |
|
12 | :Manual group: Mercurial Manual | |
13 |
|
13 | |||
14 | .. contents:: |
|
14 | .. contents:: | |
15 | :backlinks: top |
|
15 | :backlinks: top | |
16 | :class: htmlonly |
|
16 | :class: htmlonly | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | Synopsis |
|
19 | Synopsis | |
20 | -------- |
|
20 | -------- | |
21 |
|
21 | |||
22 | The Mercurial system uses a set of configuration files to control |
|
22 | The Mercurial system uses a set of configuration files to control | |
23 | aspects of its behavior. |
|
23 | aspects of its behavior. | |
24 |
|
24 | |||
25 | Files |
|
25 | Files | |
26 | ----- |
|
26 | ----- | |
27 |
|
27 | |||
28 | Mercurial reads configuration data from several files, if they exist. |
|
28 | Mercurial reads configuration data from several files, if they exist. | |
29 | The names of these files depend on the system on which Mercurial is |
|
29 | The names of these files depend on the system on which Mercurial is | |
30 | installed. ``*.rc`` files from a single directory are read in |
|
30 | installed. ``*.rc`` files from a single directory are read in | |
31 | alphabetical order, later ones overriding earlier ones. Where multiple |
|
31 | alphabetical order, later ones overriding earlier ones. Where multiple | |
32 | paths are given below, settings from earlier paths override later |
|
32 | paths are given below, settings from earlier paths override later | |
33 | ones. |
|
33 | ones. | |
34 |
|
34 | |||
35 | | (Unix, Windows) ``<repo>/.hg/hgrc`` |
|
35 | | (Unix, Windows) ``<repo>/.hg/hgrc`` | |
36 |
|
36 | |||
37 | Per-repository configuration options that only apply in a |
|
37 | Per-repository configuration options that only apply in a | |
38 | particular repository. This file is not version-controlled, and |
|
38 | particular repository. This file is not version-controlled, and | |
39 | will not get transferred during a "clone" operation. Options in |
|
39 | will not get transferred during a "clone" operation. Options in | |
40 | this file override options in all other configuration files. On |
|
40 | this file override options in all other configuration files. On | |
41 | Unix, most of this file will be ignored if it doesn't belong to a |
|
41 | Unix, most of this file will be ignored if it doesn't belong to a | |
42 | trusted user or to a trusted group. See the documentation for the |
|
42 | trusted user or to a trusted group. See the documentation for the | |
43 | trusted_ section below for more details. |
|
43 | trusted_ section below for more details. | |
44 |
|
44 | |||
45 | | (Unix) ``$HOME/.hgrc`` |
|
45 | | (Unix) ``$HOME/.hgrc`` | |
46 | | (Windows) ``%USERPROFILE%\.hgrc`` |
|
46 | | (Windows) ``%USERPROFILE%\.hgrc`` | |
47 | | (Windows) ``%USERPROFILE%\Mercurial.ini`` |
|
47 | | (Windows) ``%USERPROFILE%\Mercurial.ini`` | |
48 | | (Windows) ``%HOME%\.hgrc`` |
|
48 | | (Windows) ``%HOME%\.hgrc`` | |
49 | | (Windows) ``%HOME%\Mercurial.ini`` |
|
49 | | (Windows) ``%HOME%\Mercurial.ini`` | |
50 |
|
50 | |||
51 | Per-user configuration file(s), for the user running Mercurial. On |
|
51 | Per-user configuration file(s), for the user running Mercurial. On | |
52 | Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these |
|
52 | Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these | |
53 | files apply to all Mercurial commands executed by this user in any |
|
53 | files apply to all Mercurial commands executed by this user in any | |
54 | directory. Options in these files override per-system and per-installation |
|
54 | directory. Options in these files override per-system and per-installation | |
55 | options. |
|
55 | options. | |
56 |
|
56 | |||
57 | | (Unix) ``/etc/mercurial/hgrc`` |
|
57 | | (Unix) ``/etc/mercurial/hgrc`` | |
58 | | (Unix) ``/etc/mercurial/hgrc.d/*.rc`` |
|
58 | | (Unix) ``/etc/mercurial/hgrc.d/*.rc`` | |
59 |
|
59 | |||
60 | Per-system configuration files, for the system on which Mercurial |
|
60 | Per-system configuration files, for the system on which Mercurial | |
61 | is running. Options in these files apply to all Mercurial commands |
|
61 | is running. Options in these files apply to all Mercurial commands | |
62 | executed by any user in any directory. Options in these files |
|
62 | executed by any user in any directory. Options in these files | |
63 | override per-installation options. |
|
63 | override per-installation options. | |
64 |
|
64 | |||
65 | | (Unix) ``<install-root>/etc/mercurial/hgrc`` |
|
65 | | (Unix) ``<install-root>/etc/mercurial/hgrc`` | |
66 | | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc`` |
|
66 | | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc`` | |
67 |
|
67 | |||
68 | Per-installation configuration files, searched for in the |
|
68 | Per-installation configuration files, searched for in the | |
69 | directory where Mercurial is installed. ``<install-root>`` is the |
|
69 | directory where Mercurial is installed. ``<install-root>`` is the | |
70 | parent directory of the **hg** executable (or symlink) being run. For |
|
70 | parent directory of the **hg** executable (or symlink) being run. For | |
71 | example, if installed in ``/shared/tools/bin/hg``, Mercurial will look |
|
71 | example, if installed in ``/shared/tools/bin/hg``, Mercurial will look | |
72 | in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply |
|
72 | in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply | |
73 | to all Mercurial commands executed by any user in any directory. |
|
73 | to all Mercurial commands executed by any user in any directory. | |
74 |
|
74 | |||
75 | | (Windows) ``<install-dir>\Mercurial.ini`` |
|
75 | | (Windows) ``<install-dir>\Mercurial.ini`` | |
76 | | (Windows) ``<install-dir>\hgrc.d\*.rc`` |
|
76 | | (Windows) ``<install-dir>\hgrc.d\*.rc`` | |
77 | | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` |
|
77 | | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` | |
78 |
|
78 | |||
79 | Per-installation/system configuration files, for the system on |
|
79 | Per-installation/system configuration files, for the system on | |
80 | which Mercurial is running. Options in these files apply to all |
|
80 | which Mercurial is running. Options in these files apply to all | |
81 | Mercurial commands executed by any user in any directory. Registry |
|
81 | Mercurial commands executed by any user in any directory. Registry | |
82 | keys contain PATH-like strings, every part of which must reference |
|
82 | keys contain PATH-like strings, every part of which must reference | |
83 | a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will |
|
83 | a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will | |
84 | be read. Mercurial checks each of these locations in the specified |
|
84 | be read. Mercurial checks each of these locations in the specified | |
85 | order until one or more configuration files are detected. If the |
|
85 | order until one or more configuration files are detected. If the | |
86 | pywin32 extensions are not installed, Mercurial will only look for |
|
86 | pywin32 extensions are not installed, Mercurial will only look for | |
87 | site-wide configuration in ``C:\Mercurial\Mercurial.ini``. |
|
87 | site-wide configuration in ``C:\Mercurial\Mercurial.ini``. | |
88 |
|
88 | |||
89 | Syntax |
|
89 | Syntax | |
90 | ------ |
|
90 | ------ | |
91 |
|
91 | |||
92 | A configuration file consists of sections, led by a ``[section]`` header |
|
92 | A configuration file consists of sections, led by a ``[section]`` header | |
93 | and followed by ``name = value`` entries:: |
|
93 | and followed by ``name = value`` entries:: | |
94 |
|
94 | |||
95 | [spam] |
|
95 | [spam] | |
96 | eggs=ham |
|
96 | eggs=ham | |
97 | green= |
|
97 | green= | |
98 | eggs |
|
98 | eggs | |
99 |
|
99 | |||
100 | Each line contains one entry. If the lines that follow are indented, |
|
100 | Each line contains one entry. If the lines that follow are indented, | |
101 | they are treated as continuations of that entry. Leading whitespace is |
|
101 | they are treated as continuations of that entry. Leading whitespace is | |
102 | removed from values. Empty lines are skipped. Lines beginning with |
|
102 | removed from values. Empty lines are skipped. Lines beginning with | |
103 | ``#`` or ``;`` are ignored and may be used to provide comments. |
|
103 | ``#`` or ``;`` are ignored and may be used to provide comments. | |
104 |
|
104 | |||
105 | A line of the form ``%include file`` will include ``file`` into the |
|
105 | A line of the form ``%include file`` will include ``file`` into the | |
106 | current configuration file. The inclusion is recursive, which means |
|
106 | current configuration file. The inclusion is recursive, which means | |
107 | that included files can include other files. Filenames are relative to |
|
107 | that included files can include other files. Filenames are relative to | |
108 | the configuration file in which the ``%include`` directive is found. |
|
108 | the configuration file in which the ``%include`` directive is found. | |
109 |
|
109 | |||
110 | A line with ``%unset name`` will remove ``name`` from the current |
|
110 | A line with ``%unset name`` will remove ``name`` from the current | |
111 | section, if it has been set previously. |
|
111 | section, if it has been set previously. | |
112 |
|
112 | |||
113 |
|
113 | |||
114 | Sections |
|
114 | Sections | |
115 | -------- |
|
115 | -------- | |
116 |
|
116 | |||
117 | This section describes the different sections that may appear in a |
|
117 | This section describes the different sections that may appear in a | |
118 | Mercurial "hgrc" file, the purpose of each section, its possible keys, |
|
118 | Mercurial "hgrc" file, the purpose of each section, its possible keys, | |
119 | and their possible values. |
|
119 | and their possible values. | |
120 |
|
120 | |||
121 | ``alias`` |
|
121 | ``alias`` | |
122 | """"""""" |
|
122 | """"""""" | |
123 | Defines command aliases. |
|
123 | Defines command aliases. | |
124 | Aliases allow you to define your own commands in terms of other |
|
124 | Aliases allow you to define your own commands in terms of other | |
125 | commands (or aliases), optionally including arguments. |
|
125 | commands (or aliases), optionally including arguments. | |
126 |
|
126 | |||
127 | Alias definitions consist of lines of the form:: |
|
127 | Alias definitions consist of lines of the form:: | |
128 |
|
128 | |||
129 | <alias> = <command> [<argument]... |
|
129 | <alias> = <command> [<argument]... | |
130 |
|
130 | |||
131 | For example, this definition:: |
|
131 | For example, this definition:: | |
132 |
|
132 | |||
133 | latest = log --limit 5 |
|
133 | latest = log --limit 5 | |
134 |
|
134 | |||
135 | creates a new command ``latest`` that shows only the five most recent |
|
135 | creates a new command ``latest`` that shows only the five most recent | |
136 | changesets. You can define subsequent aliases using earlier ones:: |
|
136 | changesets. You can define subsequent aliases using earlier ones:: | |
137 |
|
137 | |||
138 | stable5 = latest -b stable |
|
138 | stable5 = latest -b stable | |
139 |
|
139 | |||
140 | .. note:: It is possible to create aliases with the same names as |
|
140 | .. note:: It is possible to create aliases with the same names as | |
141 | existing commands, which will then override the original |
|
141 | existing commands, which will then override the original | |
142 | definitions. This is almost always a bad idea! |
|
142 | definitions. This is almost always a bad idea! | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | ``auth`` |
|
145 | ``auth`` | |
146 | """""""" |
|
146 | """""""" | |
147 | Authentication credentials for HTTP authentication. Each line has |
|
147 | Authentication credentials for HTTP authentication. Each line has | |
148 | the following format:: |
|
148 | the following format:: | |
149 |
|
149 | |||
150 | <name>.<argument> = <value> |
|
150 | <name>.<argument> = <value> | |
151 |
|
151 | |||
152 | where ``<name>`` is used to group arguments into authentication |
|
152 | where ``<name>`` is used to group arguments into authentication | |
153 | entries. Example:: |
|
153 | entries. Example:: | |
154 |
|
154 | |||
155 | foo.prefix = hg.intevation.org/mercurial |
|
155 | foo.prefix = hg.intevation.org/mercurial | |
156 | foo.username = foo |
|
156 | foo.username = foo | |
157 | foo.password = bar |
|
157 | foo.password = bar | |
158 | foo.schemes = http https |
|
158 | foo.schemes = http https | |
159 |
|
159 | |||
160 | bar.prefix = secure.example.org |
|
160 | bar.prefix = secure.example.org | |
161 | bar.key = path/to/file.key |
|
161 | bar.key = path/to/file.key | |
162 | bar.cert = path/to/file.cert |
|
162 | bar.cert = path/to/file.cert | |
163 | bar.schemes = https |
|
163 | bar.schemes = https | |
164 |
|
164 | |||
165 | Supported arguments: |
|
165 | Supported arguments: | |
166 |
|
166 | |||
167 | ``prefix`` |
|
167 | ``prefix`` | |
168 | Either ``*`` or a URI prefix with or without the scheme part. |
|
168 | Either ``*`` or a URI prefix with or without the scheme part. | |
169 | The authentication entry with the longest matching prefix is used |
|
169 | The authentication entry with the longest matching prefix is used | |
170 | (where ``*`` matches everything and counts as a match of length |
|
170 | (where ``*`` matches everything and counts as a match of length | |
171 | 1). If the prefix doesn't include a scheme, the match is performed |
|
171 | 1). If the prefix doesn't include a scheme, the match is performed | |
172 | against the URI with its scheme stripped as well, and the schemes |
|
172 | against the URI with its scheme stripped as well, and the schemes | |
173 | argument, q.v., is then subsequently consulted. |
|
173 | argument, q.v., is then subsequently consulted. | |
174 | ``username`` |
|
174 | ``username`` | |
175 | Optional. Username to authenticate with. If not given, and the |
|
175 | Optional. Username to authenticate with. If not given, and the | |
176 | remote site requires basic or digest authentication, the user |
|
176 | remote site requires basic or digest authentication, the user | |
177 | will be prompted for it. |
|
177 | will be prompted for it. | |
178 | ``password`` |
|
178 | ``password`` | |
179 | Optional. Password to authenticate with. If not given, and the |
|
179 | Optional. Password to authenticate with. If not given, and the | |
180 | remote site requires basic or digest authentication, the user |
|
180 | remote site requires basic or digest authentication, the user | |
181 | will be prompted for it. |
|
181 | will be prompted for it. | |
182 | ``key`` |
|
182 | ``key`` | |
183 | Optional. PEM encoded client certificate key file. |
|
183 | Optional. PEM encoded client certificate key file. | |
184 | ``cert`` |
|
184 | ``cert`` | |
185 | Optional. PEM encoded client certificate chain file. |
|
185 | Optional. PEM encoded client certificate chain file. | |
186 | ``schemes`` |
|
186 | ``schemes`` | |
187 | Optional. Space separated list of URI schemes to use this |
|
187 | Optional. Space separated list of URI schemes to use this | |
188 | authentication entry with. Only used if the prefix doesn't include |
|
188 | authentication entry with. Only used if the prefix doesn't include | |
189 | a scheme. Supported schemes are http and https. They will match |
|
189 | a scheme. Supported schemes are http and https. They will match | |
190 | static-http and static-https respectively, as well. |
|
190 | static-http and static-https respectively, as well. | |
191 | Default: https. |
|
191 | Default: https. | |
192 |
|
192 | |||
193 | If no suitable authentication entry is found, the user is prompted |
|
193 | If no suitable authentication entry is found, the user is prompted | |
194 | for credentials as usual if required by the remote. |
|
194 | for credentials as usual if required by the remote. | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | ``decode/encode`` |
|
197 | ``decode/encode`` | |
198 | """"""""""""""""" |
|
198 | """"""""""""""""" | |
199 | Filters for transforming files on checkout/checkin. This would |
|
199 | Filters for transforming files on checkout/checkin. This would | |
200 | typically be used for newline processing or other |
|
200 | typically be used for newline processing or other | |
201 | localization/canonicalization of files. |
|
201 | localization/canonicalization of files. | |
202 |
|
202 | |||
203 | Filters consist of a filter pattern followed by a filter command. |
|
203 | Filters consist of a filter pattern followed by a filter command. | |
204 | Filter patterns are globs by default, rooted at the repository root. |
|
204 | Filter patterns are globs by default, rooted at the repository root. | |
205 | For example, to match any file ending in ``.txt`` in the root |
|
205 | For example, to match any file ending in ``.txt`` in the root | |
206 | directory only, use the pattern ``*.txt``. To match any file ending |
|
206 | directory only, use the pattern ``*.txt``. To match any file ending | |
207 | in ``.c`` anywhere in the repository, use the pattern ``**.c``. |
|
207 | in ``.c`` anywhere in the repository, use the pattern ``**.c``. | |
208 | For each file only the first matching filter applies. |
|
208 | For each file only the first matching filter applies. | |
209 |
|
209 | |||
210 | The filter command can start with a specifier, either ``pipe:`` or |
|
210 | The filter command can start with a specifier, either ``pipe:`` or | |
211 | ``tempfile:``. If no specifier is given, ``pipe:`` is used by default. |
|
211 | ``tempfile:``. If no specifier is given, ``pipe:`` is used by default. | |
212 |
|
212 | |||
213 | A ``pipe:`` command must accept data on stdin and return the transformed |
|
213 | A ``pipe:`` command must accept data on stdin and return the transformed | |
214 | data on stdout. |
|
214 | data on stdout. | |
215 |
|
215 | |||
216 | Pipe example:: |
|
216 | Pipe example:: | |
217 |
|
217 | |||
218 | [encode] |
|
218 | [encode] | |
219 | # uncompress gzip files on checkin to improve delta compression |
|
219 | # uncompress gzip files on checkin to improve delta compression | |
220 | # note: not necessarily a good idea, just an example |
|
220 | # note: not necessarily a good idea, just an example | |
221 | *.gz = pipe: gunzip |
|
221 | *.gz = pipe: gunzip | |
222 |
|
222 | |||
223 | [decode] |
|
223 | [decode] | |
224 | # recompress gzip files when writing them to the working dir (we |
|
224 | # recompress gzip files when writing them to the working dir (we | |
225 | # can safely omit "pipe:", because it's the default) |
|
225 | # can safely omit "pipe:", because it's the default) | |
226 | *.gz = gzip |
|
226 | *.gz = gzip | |
227 |
|
227 | |||
228 | A ``tempfile:`` command is a template. The string ``INFILE`` is replaced |
|
228 | A ``tempfile:`` command is a template. The string ``INFILE`` is replaced | |
229 | with the name of a temporary file that contains the data to be |
|
229 | with the name of a temporary file that contains the data to be | |
230 | filtered by the command. The string ``OUTFILE`` is replaced with the name |
|
230 | filtered by the command. The string ``OUTFILE`` is replaced with the name | |
231 | of an empty temporary file, where the filtered data must be written by |
|
231 | of an empty temporary file, where the filtered data must be written by | |
232 | the command. |
|
232 | the command. | |
233 |
|
233 | |||
234 | .. note:: The tempfile mechanism is recommended for Windows systems, |
|
234 | .. note:: The tempfile mechanism is recommended for Windows systems, | |
235 | where the standard shell I/O redirection operators often have |
|
235 | where the standard shell I/O redirection operators often have | |
236 | strange effects and may corrupt the contents of your files. |
|
236 | strange effects and may corrupt the contents of your files. | |
237 |
|
237 | |||
238 | The most common usage is for LF <-> CRLF translation on Windows. For |
|
238 | The most common usage is for LF <-> CRLF translation on Windows. For | |
239 | this, use the "smart" converters which check for binary files:: |
|
239 | this, use the "smart" converters which check for binary files:: | |
240 |
|
240 | |||
241 | [extensions] |
|
241 | [extensions] | |
242 | hgext.win32text = |
|
242 | hgext.win32text = | |
243 | [encode] |
|
243 | [encode] | |
244 | ** = cleverencode: |
|
244 | ** = cleverencode: | |
245 | [decode] |
|
245 | [decode] | |
246 | ** = cleverdecode: |
|
246 | ** = cleverdecode: | |
247 |
|
247 | |||
248 | or if you only want to translate certain files:: |
|
248 | or if you only want to translate certain files:: | |
249 |
|
249 | |||
250 | [extensions] |
|
250 | [extensions] | |
251 | hgext.win32text = |
|
251 | hgext.win32text = | |
252 | [encode] |
|
252 | [encode] | |
253 | **.txt = dumbencode: |
|
253 | **.txt = dumbencode: | |
254 | [decode] |
|
254 | [decode] | |
255 | **.txt = dumbdecode: |
|
255 | **.txt = dumbdecode: | |
256 |
|
256 | |||
257 |
|
257 | |||
258 | ``defaults`` |
|
258 | ``defaults`` | |
259 | """""""""""" |
|
259 | """""""""""" | |
260 |
|
260 | |||
261 | (defaults are deprecated. Don't use them. Use aliases instead) |
|
261 | (defaults are deprecated. Don't use them. Use aliases instead) | |
262 |
|
262 | |||
263 | Use the ``[defaults]`` section to define command defaults, i.e. the |
|
263 | Use the ``[defaults]`` section to define command defaults, i.e. the | |
264 | default options/arguments to pass to the specified commands. |
|
264 | default options/arguments to pass to the specified commands. | |
265 |
|
265 | |||
266 | The following example makes ``hg log`` run in verbose mode, and ``hg |
|
266 | The following example makes ``hg log`` run in verbose mode, and ``hg | |
267 | status`` show only the modified files, by default:: |
|
267 | status`` show only the modified files, by default:: | |
268 |
|
268 | |||
269 | [defaults] |
|
269 | [defaults] | |
270 | log = -v |
|
270 | log = -v | |
271 | status = -m |
|
271 | status = -m | |
272 |
|
272 | |||
273 | The actual commands, instead of their aliases, must be used when |
|
273 | The actual commands, instead of their aliases, must be used when | |
274 | defining command defaults. The command defaults will also be applied |
|
274 | defining command defaults. The command defaults will also be applied | |
275 | to the aliases of the commands defined. |
|
275 | to the aliases of the commands defined. | |
276 |
|
276 | |||
277 |
|
277 | |||
278 | ``diff`` |
|
278 | ``diff`` | |
279 | """""""" |
|
279 | """""""" | |
280 |
|
280 | |||
281 | Settings used when displaying diffs. They are all Boolean and |
|
281 | Settings used when displaying diffs. They are all Boolean and | |
282 | defaults to False. |
|
282 | defaults to False. | |
283 |
|
283 | |||
284 | ``git`` |
|
284 | ``git`` | |
285 | Use git extended diff format. |
|
285 | Use git extended diff format. | |
286 | ``nodates`` |
|
286 | ``nodates`` | |
287 | Don't include dates in diff headers. |
|
287 | Don't include dates in diff headers. | |
288 | ``showfunc`` |
|
288 | ``showfunc`` | |
289 | Show which function each change is in. |
|
289 | Show which function each change is in. | |
290 | ``ignorews`` |
|
290 | ``ignorews`` | |
291 | Ignore white space when comparing lines. |
|
291 | Ignore white space when comparing lines. | |
292 | ``ignorewsamount`` |
|
292 | ``ignorewsamount`` | |
293 | Ignore changes in the amount of white space. |
|
293 | Ignore changes in the amount of white space. | |
294 | ``ignoreblanklines`` |
|
294 | ``ignoreblanklines`` | |
295 | Ignore changes whose lines are all blank. |
|
295 | Ignore changes whose lines are all blank. | |
296 |
|
296 | |||
297 | ``email`` |
|
297 | ``email`` | |
298 | """"""""" |
|
298 | """"""""" | |
299 | Settings for extensions that send email messages. |
|
299 | Settings for extensions that send email messages. | |
300 |
|
300 | |||
301 | ``from`` |
|
301 | ``from`` | |
302 | Optional. Email address to use in "From" header and SMTP envelope |
|
302 | Optional. Email address to use in "From" header and SMTP envelope | |
303 | of outgoing messages. |
|
303 | of outgoing messages. | |
304 | ``to`` |
|
304 | ``to`` | |
305 | Optional. Comma-separated list of recipients' email addresses. |
|
305 | Optional. Comma-separated list of recipients' email addresses. | |
306 | ``cc`` |
|
306 | ``cc`` | |
307 | Optional. Comma-separated list of carbon copy recipients' |
|
307 | Optional. Comma-separated list of carbon copy recipients' | |
308 | email addresses. |
|
308 | email addresses. | |
309 | ``bcc`` |
|
309 | ``bcc`` | |
310 | Optional. Comma-separated list of blind carbon copy recipients' |
|
310 | Optional. Comma-separated list of blind carbon copy recipients' | |
311 | email addresses. |
|
311 | email addresses. | |
312 | ``method`` |
|
312 | ``method`` | |
313 | Optional. Method to use to send email messages. If value is ``smtp`` |
|
313 | Optional. Method to use to send email messages. If value is ``smtp`` | |
314 | (default), use SMTP (see the SMTP_ section for configuration). |
|
314 | (default), use SMTP (see the SMTP_ section for configuration). | |
315 | Otherwise, use as name of program to run that acts like sendmail |
|
315 | Otherwise, use as name of program to run that acts like sendmail | |
316 | (takes ``-f`` option for sender, list of recipients on command line, |
|
316 | (takes ``-f`` option for sender, list of recipients on command line, | |
317 | message on stdin). Normally, setting this to ``sendmail`` or |
|
317 | message on stdin). Normally, setting this to ``sendmail`` or | |
318 | ``/usr/sbin/sendmail`` is enough to use sendmail to send messages. |
|
318 | ``/usr/sbin/sendmail`` is enough to use sendmail to send messages. | |
319 | ``charsets`` |
|
319 | ``charsets`` | |
320 | Optional. Comma-separated list of character sets considered |
|
320 | Optional. Comma-separated list of character sets considered | |
321 | convenient for recipients. Addresses, headers, and parts not |
|
321 | convenient for recipients. Addresses, headers, and parts not | |
322 | containing patches of outgoing messages will be encoded in the |
|
322 | containing patches of outgoing messages will be encoded in the | |
323 | first character set to which conversion from local encoding |
|
323 | first character set to which conversion from local encoding | |
324 | (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct |
|
324 | (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct | |
325 | conversion fails, the text in question is sent as is. Defaults to |
|
325 | conversion fails, the text in question is sent as is. Defaults to | |
326 | empty (explicit) list. |
|
326 | empty (explicit) list. | |
327 |
|
327 | |||
328 | Order of outgoing email character sets: |
|
328 | Order of outgoing email character sets: | |
329 |
|
329 | |||
330 | 1. ``us-ascii``: always first, regardless of settings |
|
330 | 1. ``us-ascii``: always first, regardless of settings | |
331 | 2. ``email.charsets``: in order given by user |
|
331 | 2. ``email.charsets``: in order given by user | |
332 | 3. ``ui.fallbackencoding``: if not in email.charsets |
|
332 | 3. ``ui.fallbackencoding``: if not in email.charsets | |
333 | 4. ``$HGENCODING``: if not in email.charsets |
|
333 | 4. ``$HGENCODING``: if not in email.charsets | |
334 | 5. ``utf-8``: always last, regardless of settings |
|
334 | 5. ``utf-8``: always last, regardless of settings | |
335 |
|
335 | |||
336 | Email example:: |
|
336 | Email example:: | |
337 |
|
337 | |||
338 | [email] |
|
338 | [email] | |
339 | from = Joseph User <joe.user@example.com> |
|
339 | from = Joseph User <joe.user@example.com> | |
340 | method = /usr/sbin/sendmail |
|
340 | method = /usr/sbin/sendmail | |
341 | # charsets for western Europeans |
|
341 | # charsets for western Europeans | |
342 | # us-ascii, utf-8 omitted, as they are tried first and last |
|
342 | # us-ascii, utf-8 omitted, as they are tried first and last | |
343 | charsets = iso-8859-1, iso-8859-15, windows-1252 |
|
343 | charsets = iso-8859-1, iso-8859-15, windows-1252 | |
344 |
|
344 | |||
345 |
|
345 | |||
346 | ``extensions`` |
|
346 | ``extensions`` | |
347 | """""""""""""" |
|
347 | """""""""""""" | |
348 |
|
348 | |||
349 | Mercurial has an extension mechanism for adding new features. To |
|
349 | Mercurial has an extension mechanism for adding new features. To | |
350 | enable an extension, create an entry for it in this section. |
|
350 | enable an extension, create an entry for it in this section. | |
351 |
|
351 | |||
352 | If you know that the extension is already in Python's search path, |
|
352 | If you know that the extension is already in Python's search path, | |
353 | you can give the name of the module, followed by ``=``, with nothing |
|
353 | you can give the name of the module, followed by ``=``, with nothing | |
354 | after the ``=``. |
|
354 | after the ``=``. | |
355 |
|
355 | |||
356 | Otherwise, give a name that you choose, followed by ``=``, followed by |
|
356 | Otherwise, give a name that you choose, followed by ``=``, followed by | |
357 | the path to the ``.py`` file (including the file name extension) that |
|
357 | the path to the ``.py`` file (including the file name extension) that | |
358 | defines the extension. |
|
358 | defines the extension. | |
359 |
|
359 | |||
360 | To explicitly disable an extension that is enabled in an hgrc of |
|
360 | To explicitly disable an extension that is enabled in an hgrc of | |
361 | broader scope, prepend its path with ``!``, as in |
|
361 | broader scope, prepend its path with ``!``, as in | |
362 | ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not |
|
362 | ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not | |
363 | supplied. |
|
363 | supplied. | |
364 |
|
364 | |||
365 | Example for ``~/.hgrc``:: |
|
365 | Example for ``~/.hgrc``:: | |
366 |
|
366 | |||
367 | [extensions] |
|
367 | [extensions] | |
368 | # (the mq extension will get loaded from Mercurial's path) |
|
368 | # (the mq extension will get loaded from Mercurial's path) | |
369 | hgext.mq = |
|
369 | hgext.mq = | |
370 | # (this extension will get loaded from the file specified) |
|
370 | # (this extension will get loaded from the file specified) | |
371 | myfeature = ~/.hgext/myfeature.py |
|
371 | myfeature = ~/.hgext/myfeature.py | |
372 |
|
372 | |||
373 |
|
373 | |||
374 | ``format`` |
|
374 | ``format`` | |
375 | """""""""" |
|
375 | """""""""" | |
376 |
|
376 | |||
377 | ``usestore`` |
|
377 | ``usestore`` | |
378 | Enable or disable the "store" repository format which improves |
|
378 | Enable or disable the "store" repository format which improves | |
379 | compatibility with systems that fold case or otherwise mangle |
|
379 | compatibility with systems that fold case or otherwise mangle | |
380 | filenames. Enabled by default. Disabling this option will allow |
|
380 | filenames. Enabled by default. Disabling this option will allow | |
381 | you to store longer filenames in some situations at the expense of |
|
381 | you to store longer filenames in some situations at the expense of | |
382 | compatibility and ensures that the on-disk format of newly created |
|
382 | compatibility and ensures that the on-disk format of newly created | |
383 | repositories will be compatible with Mercurial before version 0.9.4. |
|
383 | repositories will be compatible with Mercurial before version 0.9.4. | |
384 |
|
384 | |||
385 | ``usefncache`` |
|
385 | ``usefncache`` | |
386 | Enable or disable the "fncache" repository format which enhances |
|
386 | Enable or disable the "fncache" repository format which enhances | |
387 | the "store" repository format (which has to be enabled to use |
|
387 | the "store" repository format (which has to be enabled to use | |
388 | fncache) to allow longer filenames and avoids using Windows |
|
388 | fncache) to allow longer filenames and avoids using Windows | |
389 | reserved names, e.g. "nul". Enabled by default. Disabling this |
|
389 | reserved names, e.g. "nul". Enabled by default. Disabling this | |
390 | option ensures that the on-disk format of newly created |
|
390 | option ensures that the on-disk format of newly created | |
391 | repositories will be compatible with Mercurial before version 1.1. |
|
391 | repositories will be compatible with Mercurial before version 1.1. | |
392 |
|
392 | |||
393 | ``merge-patterns`` |
|
393 | ``merge-patterns`` | |
394 | """""""""""""""""" |
|
394 | """""""""""""""""" | |
395 |
|
395 | |||
396 | This section specifies merge tools to associate with particular file |
|
396 | This section specifies merge tools to associate with particular file | |
397 | patterns. Tools matched here will take precedence over the default |
|
397 | patterns. Tools matched here will take precedence over the default | |
398 | merge tool. Patterns are globs by default, rooted at the repository |
|
398 | merge tool. Patterns are globs by default, rooted at the repository | |
399 | root. |
|
399 | root. | |
400 |
|
400 | |||
401 | Example:: |
|
401 | Example:: | |
402 |
|
402 | |||
403 | [merge-patterns] |
|
403 | [merge-patterns] | |
404 | **.c = kdiff3 |
|
404 | **.c = kdiff3 | |
405 | **.jpg = myimgmerge |
|
405 | **.jpg = myimgmerge | |
406 |
|
406 | |||
407 | ``merge-tools`` |
|
407 | ``merge-tools`` | |
408 | """"""""""""""" |
|
408 | """"""""""""""" | |
409 |
|
409 | |||
410 | This section configures external merge tools to use for file-level |
|
410 | This section configures external merge tools to use for file-level | |
411 | merges. |
|
411 | merges. | |
412 |
|
412 | |||
413 | Example ``~/.hgrc``:: |
|
413 | Example ``~/.hgrc``:: | |
414 |
|
414 | |||
415 | [merge-tools] |
|
415 | [merge-tools] | |
416 | # Override stock tool location |
|
416 | # Override stock tool location | |
417 | kdiff3.executable = ~/bin/kdiff3 |
|
417 | kdiff3.executable = ~/bin/kdiff3 | |
418 | # Specify command line |
|
418 | # Specify command line | |
419 | kdiff3.args = $base $local $other -o $output |
|
419 | kdiff3.args = $base $local $other -o $output | |
420 | # Give higher priority |
|
420 | # Give higher priority | |
421 | kdiff3.priority = 1 |
|
421 | kdiff3.priority = 1 | |
422 |
|
422 | |||
423 | # Define new tool |
|
423 | # Define new tool | |
424 | myHtmlTool.args = -m $local $other $base $output |
|
424 | myHtmlTool.args = -m $local $other $base $output | |
425 | myHtmlTool.regkey = Software\FooSoftware\HtmlMerge |
|
425 | myHtmlTool.regkey = Software\FooSoftware\HtmlMerge | |
426 | myHtmlTool.priority = 1 |
|
426 | myHtmlTool.priority = 1 | |
427 |
|
427 | |||
428 | Supported arguments: |
|
428 | Supported arguments: | |
429 |
|
429 | |||
430 | ``priority`` |
|
430 | ``priority`` | |
431 | The priority in which to evaluate this tool. |
|
431 | The priority in which to evaluate this tool. | |
432 | Default: 0. |
|
432 | Default: 0. | |
433 | ``executable`` |
|
433 | ``executable`` | |
434 | Either just the name of the executable or its pathname. |
|
434 | Either just the name of the executable or its pathname. | |
435 | Default: the tool name. |
|
435 | Default: the tool name. | |
436 | ``args`` |
|
436 | ``args`` | |
437 | The arguments to pass to the tool executable. You can refer to the |
|
437 | The arguments to pass to the tool executable. You can refer to the | |
438 | files being merged as well as the output file through these |
|
438 | files being merged as well as the output file through these | |
439 | variables: ``$base``, ``$local``, ``$other``, ``$output``. |
|
439 | variables: ``$base``, ``$local``, ``$other``, ``$output``. | |
440 | Default: ``$local $base $other`` |
|
440 | Default: ``$local $base $other`` | |
441 | ``premerge`` |
|
441 | ``premerge`` | |
442 | Attempt to run internal non-interactive 3-way merge tool before |
|
442 | Attempt to run internal non-interactive 3-way merge tool before | |
443 | launching external tool. |
|
443 | launching external tool. | |
444 | Default: True |
|
444 | Default: True | |
445 | ``binary`` |
|
445 | ``binary`` | |
446 | This tool can merge binary files. Defaults to False, unless tool |
|
446 | This tool can merge binary files. Defaults to False, unless tool | |
447 | was selected by file pattern match. |
|
447 | was selected by file pattern match. | |
448 | ``symlink`` |
|
448 | ``symlink`` | |
449 | This tool can merge symlinks. Defaults to False, even if tool was |
|
449 | This tool can merge symlinks. Defaults to False, even if tool was | |
450 | selected by file pattern match. |
|
450 | selected by file pattern match. | |
451 | ``checkconflicts`` |
|
451 | ``checkconflicts`` | |
452 | Check whether there are conflicts even though the tool reported |
|
452 | Check whether there are conflicts even though the tool reported | |
453 | success. |
|
453 | success. | |
454 | Default: False |
|
454 | Default: False | |
455 | ``checkchanged`` |
|
455 | ``checkchanged`` | |
456 | Check whether outputs were written even though the tool reported |
|
456 | Check whether outputs were written even though the tool reported | |
457 | success. |
|
457 | success. | |
458 | Default: False |
|
458 | Default: False | |
459 | ``fixeol`` |
|
459 | ``fixeol`` | |
460 | Attempt to fix up EOL changes caused by the merge tool. |
|
460 | Attempt to fix up EOL changes caused by the merge tool. | |
461 | Default: False |
|
461 | Default: False | |
462 | ``gui`` |
|
462 | ``gui`` | |
463 | This tool requires a graphical interface to run. Default: False |
|
463 | This tool requires a graphical interface to run. Default: False | |
464 | ``regkey`` |
|
464 | ``regkey`` | |
465 | Windows registry key which describes install location of this |
|
465 | Windows registry key which describes install location of this | |
466 | tool. Mercurial will search for this key first under |
|
466 | tool. Mercurial will search for this key first under | |
467 | ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``. |
|
467 | ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``. | |
468 | Default: None |
|
468 | Default: None | |
469 | ``regname`` |
|
469 | ``regname`` | |
470 | Name of value to read from specified registry key. Defaults to the |
|
470 | Name of value to read from specified registry key. Defaults to the | |
471 | unnamed (default) value. |
|
471 | unnamed (default) value. | |
472 | ``regappend`` |
|
472 | ``regappend`` | |
473 | String to append to the value read from the registry, typically |
|
473 | String to append to the value read from the registry, typically | |
474 | the executable name of the tool. |
|
474 | the executable name of the tool. | |
475 | Default: None |
|
475 | Default: None | |
476 |
|
476 | |||
477 |
|
477 | |||
478 | ``hooks`` |
|
478 | ``hooks`` | |
479 | """"""""" |
|
479 | """"""""" | |
480 | Commands or Python functions that get automatically executed by |
|
480 | Commands or Python functions that get automatically executed by | |
481 | various actions such as starting or finishing a commit. Multiple |
|
481 | various actions such as starting or finishing a commit. Multiple | |
482 | hooks can be run for the same action by appending a suffix to the |
|
482 | hooks can be run for the same action by appending a suffix to the | |
483 | action. Overriding a site-wide hook can be done by changing its |
|
483 | action. Overriding a site-wide hook can be done by changing its | |
484 | value or setting it to an empty string. |
|
484 | value or setting it to an empty string. | |
485 |
|
485 | |||
486 | Example ``.hg/hgrc``:: |
|
486 | Example ``.hg/hgrc``:: | |
487 |
|
487 | |||
488 | [hooks] |
|
488 | [hooks] | |
489 | # update working directory after adding changesets |
|
489 | # update working directory after adding changesets | |
490 | changegroup.update = hg update |
|
490 | changegroup.update = hg update | |
491 | # do not use the site-wide hook |
|
491 | # do not use the site-wide hook | |
492 | incoming = |
|
492 | incoming = | |
493 | incoming.email = /my/email/hook |
|
493 | incoming.email = /my/email/hook | |
494 | incoming.autobuild = /my/build/hook |
|
494 | incoming.autobuild = /my/build/hook | |
495 |
|
495 | |||
496 | Most hooks are run with environment variables set that give useful |
|
496 | Most hooks are run with environment variables set that give useful | |
497 | additional information. For each hook below, the environment |
|
497 | additional information. For each hook below, the environment | |
498 | variables it is passed are listed with names of the form ``$HG_foo``. |
|
498 | variables it is passed are listed with names of the form ``$HG_foo``. | |
499 |
|
499 | |||
500 | ``changegroup`` |
|
500 | ``changegroup`` | |
501 | Run after a changegroup has been added via push, pull or unbundle. |
|
501 | Run after a changegroup has been added via push, pull or unbundle. | |
502 | ID of the first new changeset is in ``$HG_NODE``. URL from which |
|
502 | ID of the first new changeset is in ``$HG_NODE``. URL from which | |
503 | changes came is in ``$HG_URL``. |
|
503 | changes came is in ``$HG_URL``. | |
504 | ``commit`` |
|
504 | ``commit`` | |
505 | Run after a changeset has been created in the local repository. ID |
|
505 | Run after a changeset has been created in the local repository. ID | |
506 | of the newly created changeset is in ``$HG_NODE``. Parent changeset |
|
506 | of the newly created changeset is in ``$HG_NODE``. Parent changeset | |
507 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
507 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. | |
508 | ``incoming`` |
|
508 | ``incoming`` | |
509 | Run after a changeset has been pulled, pushed, or unbundled into |
|
509 | Run after a changeset has been pulled, pushed, or unbundled into | |
510 | the local repository. The ID of the newly arrived changeset is in |
|
510 | the local repository. The ID of the newly arrived changeset is in | |
511 | ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``. |
|
511 | ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``. | |
512 | ``outgoing`` |
|
512 | ``outgoing`` | |
513 | Run after sending changes from local repository to another. ID of |
|
513 | Run after sending changes from local repository to another. ID of | |
514 | first changeset sent is in ``$HG_NODE``. Source of operation is in |
|
514 | first changeset sent is in ``$HG_NODE``. Source of operation is in | |
515 | ``$HG_SOURCE``; see "preoutgoing" hook for description. |
|
515 | ``$HG_SOURCE``; see "preoutgoing" hook for description. | |
516 | ``post-<command>`` |
|
516 | ``post-<command>`` | |
517 | Run after successful invocations of the associated command. The |
|
517 | Run after successful invocations of the associated command. The | |
518 | contents of the command line are passed as ``$HG_ARGS`` and the result |
|
518 | contents of the command line are passed as ``$HG_ARGS`` and the result | |
519 | code in ``$HG_RESULT``. Hook failure is ignored. |
|
519 | code in ``$HG_RESULT``. Hook failure is ignored. | |
520 | ``pre-<command>`` |
|
520 | ``pre-<command>`` | |
521 | Run before executing the associated command. The contents of the |
|
521 | Run before executing the associated command. The contents of the | |
522 | command line are passed as ``$HG_ARGS``. If the hook returns failure, |
|
522 | command line are passed as ``$HG_ARGS``. If the hook returns failure, | |
523 | the command doesn't execute and Mercurial returns the failure |
|
523 | the command doesn't execute and Mercurial returns the failure | |
524 | code. |
|
524 | code. | |
525 | ``prechangegroup`` |
|
525 | ``prechangegroup`` | |
526 | Run before a changegroup is added via push, pull or unbundle. Exit |
|
526 | Run before a changegroup is added via push, pull or unbundle. Exit | |
527 | status 0 allows the changegroup to proceed. Non-zero status will |
|
527 | status 0 allows the changegroup to proceed. Non-zero status will | |
528 | cause the push, pull or unbundle to fail. URL from which changes |
|
528 | cause the push, pull or unbundle to fail. URL from which changes | |
529 | will come is in ``$HG_URL``. |
|
529 | will come is in ``$HG_URL``. | |
530 | ``precommit`` |
|
530 | ``precommit`` | |
531 | Run before starting a local commit. Exit status 0 allows the |
|
531 | Run before starting a local commit. Exit status 0 allows the | |
532 | commit to proceed. Non-zero status will cause the commit to fail. |
|
532 | commit to proceed. Non-zero status will cause the commit to fail. | |
533 | Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
533 | Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. | |
534 | ``preoutgoing`` |
|
534 | ``preoutgoing`` | |
535 | Run before collecting changes to send from the local repository to |
|
535 | Run before collecting changes to send from the local repository to | |
536 | another. Non-zero status will cause failure. This lets you prevent |
|
536 | another. Non-zero status will cause failure. This lets you prevent | |
537 | pull over HTTP or SSH. Also prevents against local pull, push |
|
537 | pull over HTTP or SSH. Also prevents against local pull, push | |
538 | (outbound) or bundle commands, but not effective, since you can |
|
538 | (outbound) or bundle commands, but not effective, since you can | |
539 | just copy files instead then. Source of operation is in |
|
539 | just copy files instead then. Source of operation is in | |
540 | ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote |
|
540 | ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote | |
541 | SSH or HTTP repository. If "push", "pull" or "bundle", operation |
|
541 | SSH or HTTP repository. If "push", "pull" or "bundle", operation | |
542 | is happening on behalf of repository on same system. |
|
542 | is happening on behalf of repository on same system. | |
543 | ``pretag`` |
|
543 | ``pretag`` | |
544 | Run before creating a tag. Exit status 0 allows the tag to be |
|
544 | Run before creating a tag. Exit status 0 allows the tag to be | |
545 | created. Non-zero status will cause the tag to fail. ID of |
|
545 | created. Non-zero status will cause the tag to fail. ID of | |
546 | changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is |
|
546 | changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is | |
547 | local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``. |
|
547 | local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``. | |
548 | ``pretxnchangegroup`` |
|
548 | ``pretxnchangegroup`` | |
549 | Run after a changegroup has been added via push, pull or unbundle, |
|
549 | Run after a changegroup has been added via push, pull or unbundle, | |
550 | but before the transaction has been committed. Changegroup is |
|
550 | but before the transaction has been committed. Changegroup is | |
551 | visible to hook program. This lets you validate incoming changes |
|
551 | visible to hook program. This lets you validate incoming changes | |
552 | before accepting them. Passed the ID of the first new changeset in |
|
552 | before accepting them. Passed the ID of the first new changeset in | |
553 | ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero |
|
553 | ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero | |
554 | status will cause the transaction to be rolled back and the push, |
|
554 | status will cause the transaction to be rolled back and the push, | |
555 | pull or unbundle will fail. URL that was source of changes is in |
|
555 | pull or unbundle will fail. URL that was source of changes is in | |
556 | ``$HG_URL``. |
|
556 | ``$HG_URL``. | |
557 | ``pretxncommit`` |
|
557 | ``pretxncommit`` | |
558 | Run after a changeset has been created but the transaction not yet |
|
558 | Run after a changeset has been created but the transaction not yet | |
559 | committed. Changeset is visible to hook program. This lets you |
|
559 | committed. Changeset is visible to hook program. This lets you | |
560 | validate commit message and changes. Exit status 0 allows the |
|
560 | validate commit message and changes. Exit status 0 allows the | |
561 | commit to proceed. Non-zero status will cause the transaction to |
|
561 | commit to proceed. Non-zero status will cause the transaction to | |
562 | be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset |
|
562 | be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset | |
563 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
563 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. | |
564 | ``preupdate`` |
|
564 | ``preupdate`` | |
565 | Run before updating the working directory. Exit status 0 allows |
|
565 | Run before updating the working directory. Exit status 0 allows | |
566 | the update to proceed. Non-zero status will prevent the update. |
|
566 | the update to proceed. Non-zero status will prevent the update. | |
567 | Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID |
|
567 | Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID | |
568 | of second new parent is in ``$HG_PARENT2``. |
|
568 | of second new parent is in ``$HG_PARENT2``. | |
569 | ``tag`` |
|
569 | ``tag`` | |
570 | Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``. |
|
570 | Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``. | |
571 | Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in |
|
571 | Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in | |
572 | repository if ``$HG_LOCAL=0``. |
|
572 | repository if ``$HG_LOCAL=0``. | |
573 | ``update`` |
|
573 | ``update`` | |
574 | Run after updating the working directory. Changeset ID of first |
|
574 | Run after updating the working directory. Changeset ID of first | |
575 | new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is |
|
575 | new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is | |
576 | in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the |
|
576 | in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the | |
577 | update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``. |
|
577 | update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``. | |
578 |
|
578 | |||
579 | .. note:: It is generally better to use standard hooks rather than the |
|
579 | .. note:: It is generally better to use standard hooks rather than the | |
580 | generic pre- and post- command hooks as they are guaranteed to be |
|
580 | generic pre- and post- command hooks as they are guaranteed to be | |
581 | called in the appropriate contexts for influencing transactions. |
|
581 | called in the appropriate contexts for influencing transactions. | |
582 | Also, hooks like "commit" will be called in all contexts that |
|
582 | Also, hooks like "commit" will be called in all contexts that | |
583 | generate a commit (e.g. tag) and not just the commit command. |
|
583 | generate a commit (e.g. tag) and not just the commit command. | |
584 |
|
584 | |||
585 | .. note:: Environment variables with empty values may not be passed to |
|
585 | .. note:: Environment variables with empty values may not be passed to | |
586 | hooks on platforms such as Windows. As an example, ``$HG_PARENT2`` |
|
586 | hooks on platforms such as Windows. As an example, ``$HG_PARENT2`` | |
587 | will have an empty value under Unix-like platforms for non-merge |
|
587 | will have an empty value under Unix-like platforms for non-merge | |
588 | changesets, while it will not be available at all under Windows. |
|
588 | changesets, while it will not be available at all under Windows. | |
589 |
|
589 | |||
590 | The syntax for Python hooks is as follows:: |
|
590 | The syntax for Python hooks is as follows:: | |
591 |
|
591 | |||
592 | hookname = python:modulename.submodule.callable |
|
592 | hookname = python:modulename.submodule.callable | |
593 | hookname = python:/path/to/python/module.py:callable |
|
593 | hookname = python:/path/to/python/module.py:callable | |
594 |
|
594 | |||
595 | Python hooks are run within the Mercurial process. Each hook is |
|
595 | Python hooks are run within the Mercurial process. Each hook is | |
596 | called with at least three keyword arguments: a ui object (keyword |
|
596 | called with at least three keyword arguments: a ui object (keyword | |
597 | ``ui``), a repository object (keyword ``repo``), and a ``hooktype`` |
|
597 | ``ui``), a repository object (keyword ``repo``), and a ``hooktype`` | |
598 | keyword that tells what kind of hook is used. Arguments listed as |
|
598 | keyword that tells what kind of hook is used. Arguments listed as | |
599 | environment variables above are passed as keyword arguments, with no |
|
599 | environment variables above are passed as keyword arguments, with no | |
600 | ``HG_`` prefix, and names in lower case. |
|
600 | ``HG_`` prefix, and names in lower case. | |
601 |
|
601 | |||
602 | If a Python hook returns a "true" value or raises an exception, this |
|
602 | If a Python hook returns a "true" value or raises an exception, this | |
603 | is treated as a failure. |
|
603 | is treated as a failure. | |
604 |
|
604 | |||
605 |
|
605 | |||
606 | ``http_proxy`` |
|
606 | ``http_proxy`` | |
607 | """""""""""""" |
|
607 | """""""""""""" | |
608 | Used to access web-based Mercurial repositories through a HTTP |
|
608 | Used to access web-based Mercurial repositories through a HTTP | |
609 | proxy. |
|
609 | proxy. | |
610 |
|
610 | |||
611 | ``host`` |
|
611 | ``host`` | |
612 | Host name and (optional) port of the proxy server, for example |
|
612 | Host name and (optional) port of the proxy server, for example | |
613 | "myproxy:8000". |
|
613 | "myproxy:8000". | |
614 | ``no`` |
|
614 | ``no`` | |
615 | Optional. Comma-separated list of host names that should bypass |
|
615 | Optional. Comma-separated list of host names that should bypass | |
616 | the proxy. |
|
616 | the proxy. | |
617 | ``passwd`` |
|
617 | ``passwd`` | |
618 | Optional. Password to authenticate with at the proxy server. |
|
618 | Optional. Password to authenticate with at the proxy server. | |
619 | ``user`` |
|
619 | ``user`` | |
620 | Optional. User name to authenticate with at the proxy server. |
|
620 | Optional. User name to authenticate with at the proxy server. | |
621 |
|
621 | |||
622 | ``smtp`` |
|
622 | ``smtp`` | |
623 | """""""" |
|
623 | """""""" | |
624 | Configuration for extensions that need to send email messages. |
|
624 | Configuration for extensions that need to send email messages. | |
625 |
|
625 | |||
626 | ``host`` |
|
626 | ``host`` | |
627 | Host name of mail server, e.g. "mail.example.com". |
|
627 | Host name of mail server, e.g. "mail.example.com". | |
628 | ``port`` |
|
628 | ``port`` | |
629 | Optional. Port to connect to on mail server. Default: 25. |
|
629 | Optional. Port to connect to on mail server. Default: 25. | |
630 | ``tls`` |
|
630 | ``tls`` | |
631 | Optional. Whether to connect to mail server using TLS. True or |
|
631 | Optional. Whether to connect to mail server using TLS. True or | |
632 | False. Default: False. |
|
632 | False. Default: False. | |
633 | ``username`` |
|
633 | ``username`` | |
634 | Optional. User name to authenticate to SMTP server with. If |
|
634 | Optional. User name to authenticate to SMTP server with. If | |
635 | username is specified, password must also be specified. |
|
635 | username is specified, password must also be specified. | |
636 | Default: none. |
|
636 | Default: none. | |
637 | ``password`` |
|
637 | ``password`` | |
638 | Optional. Password to authenticate to SMTP server with. If |
|
638 | Optional. Password to authenticate to SMTP server with. If | |
639 | username is specified, password must also be specified. |
|
639 | username is specified, password must also be specified. | |
640 | Default: none. |
|
640 | Default: none. | |
641 | ``local_hostname`` |
|
641 | ``local_hostname`` | |
642 | Optional. It's the hostname that the sender can use to identify |
|
642 | Optional. It's the hostname that the sender can use to identify | |
643 | itself to the MTA. |
|
643 | itself to the MTA. | |
644 |
|
644 | |||
645 |
|
645 | |||
646 | ``patch`` |
|
646 | ``patch`` | |
647 | """"""""" |
|
647 | """"""""" | |
648 | Settings used when applying patches, for instance through the 'import' |
|
648 | Settings used when applying patches, for instance through the 'import' | |
649 | command or with Mercurial Queues extension. |
|
649 | command or with Mercurial Queues extension. | |
650 |
|
650 | |||
651 | ``eol`` |
|
651 | ``eol`` | |
652 | When set to 'strict' patch content and patched files end of lines |
|
652 | When set to 'strict' patch content and patched files end of lines | |
653 | are preserved. When set to ``lf`` or ``crlf``, both files end of |
|
653 | are preserved. When set to ``lf`` or ``crlf``, both files end of | |
654 | lines are ignored when patching and the result line endings are |
|
654 | lines are ignored when patching and the result line endings are | |
655 | normalized to either LF (Unix) or CRLF (Windows). When set to |
|
655 | normalized to either LF (Unix) or CRLF (Windows). When set to | |
656 | ``auto``, end of lines are again ignored while patching but line |
|
656 | ``auto``, end of lines are again ignored while patching but line | |
657 | endings in patched files are normalized to their original setting |
|
657 | endings in patched files are normalized to their original setting | |
658 | on a per-file basis. If target file does not exist or has no end |
|
658 | on a per-file basis. If target file does not exist or has no end | |
659 | of line, patch line endings are preserved. |
|
659 | of line, patch line endings are preserved. | |
660 | Default: strict. |
|
660 | Default: strict. | |
661 |
|
661 | |||
662 |
|
662 | |||
663 | ``paths`` |
|
663 | ``paths`` | |
664 | """"""""" |
|
664 | """"""""" | |
665 | Assigns symbolic names to repositories. The left side is the |
|
665 | Assigns symbolic names to repositories. The left side is the | |
666 | symbolic name, and the right gives the directory or URL that is the |
|
666 | symbolic name, and the right gives the directory or URL that is the | |
667 | location of the repository. Default paths can be declared by setting |
|
667 | location of the repository. Default paths can be declared by setting | |
668 | the following entries. |
|
668 | the following entries. | |
669 |
|
669 | |||
670 | ``default`` |
|
670 | ``default`` | |
671 | Directory or URL to use when pulling if no source is specified. |
|
671 | Directory or URL to use when pulling if no source is specified. | |
672 | Default is set to repository from which the current repository was |
|
672 | Default is set to repository from which the current repository was | |
673 | cloned. |
|
673 | cloned. | |
674 | ``default-push`` |
|
674 | ``default-push`` | |
675 | Optional. Directory or URL to use when pushing if no destination |
|
675 | Optional. Directory or URL to use when pushing if no destination | |
676 | is specified. |
|
676 | is specified. | |
677 |
|
677 | |||
678 |
|
678 | |||
679 | ``profiling`` |
|
679 | ``profiling`` | |
680 | """"""""""""" |
|
680 | """"""""""""" | |
681 | Specifies profiling format and file output. In this section |
|
681 | Specifies profiling format and file output. In this section | |
682 | description, 'profiling data' stands for the raw data collected |
|
682 | description, 'profiling data' stands for the raw data collected | |
683 | during profiling, while 'profiling report' stands for a statistical |
|
683 | during profiling, while 'profiling report' stands for a statistical | |
684 | text report generated from the profiling data. The profiling is done |
|
684 | text report generated from the profiling data. The profiling is done | |
685 | using lsprof. |
|
685 | using lsprof. | |
686 |
|
686 | |||
687 | ``format`` |
|
687 | ``format`` | |
688 | Profiling format. |
|
688 | Profiling format. | |
689 | Default: text. |
|
689 | Default: text. | |
690 |
|
690 | |||
691 | ``text`` |
|
691 | ``text`` | |
692 | Generate a profiling report. When saving to a file, it should be |
|
692 | Generate a profiling report. When saving to a file, it should be | |
693 | noted that only the report is saved, and the profiling data is |
|
693 | noted that only the report is saved, and the profiling data is | |
694 | not kept. |
|
694 | not kept. | |
695 | ``kcachegrind`` |
|
695 | ``kcachegrind`` | |
696 | Format profiling data for kcachegrind use: when saving to a |
|
696 | Format profiling data for kcachegrind use: when saving to a | |
697 | file, the generated file can directly be loaded into |
|
697 | file, the generated file can directly be loaded into | |
698 | kcachegrind. |
|
698 | kcachegrind. | |
699 | ``output`` |
|
699 | ``output`` | |
700 | File path where profiling data or report should be saved. If the |
|
700 | File path where profiling data or report should be saved. If the | |
701 | file exists, it is replaced. Default: None, data is printed on |
|
701 | file exists, it is replaced. Default: None, data is printed on | |
702 | stderr |
|
702 | stderr | |
703 |
|
703 | |||
704 | ``server`` |
|
704 | ``server`` | |
705 | """""""""" |
|
705 | """""""""" | |
706 | Controls generic server settings. |
|
706 | Controls generic server settings. | |
707 |
|
707 | |||
708 | ``uncompressed`` |
|
708 | ``uncompressed`` | |
709 | Whether to allow clients to clone a repository using the |
|
709 | Whether to allow clients to clone a repository using the | |
710 | uncompressed streaming protocol. This transfers about 40% more |
|
710 | uncompressed streaming protocol. This transfers about 40% more | |
711 | data than a regular clone, but uses less memory and CPU on both |
|
711 | data than a regular clone, but uses less memory and CPU on both | |
712 | server and client. Over a LAN (100 Mbps or better) or a very fast |
|
712 | server and client. Over a LAN (100 Mbps or better) or a very fast | |
713 | WAN, an uncompressed streaming clone is a lot faster (~10x) than a |
|
713 | WAN, an uncompressed streaming clone is a lot faster (~10x) than a | |
714 | regular clone. Over most WAN connections (anything slower than |
|
714 | regular clone. Over most WAN connections (anything slower than | |
715 | about 6 Mbps), uncompressed streaming is slower, because of the |
|
715 | about 6 Mbps), uncompressed streaming is slower, because of the | |
716 | extra data transfer overhead. Default is False. |
|
716 | extra data transfer overhead. Default is False. | |
717 |
|
717 | |||
718 |
|
718 | |||
719 | ``trusted`` |
|
719 | ``trusted`` | |
720 | """"""""""" |
|
720 | """"""""""" | |
721 | For security reasons, Mercurial will not use the settings in the |
|
721 | For security reasons, Mercurial will not use the settings in the | |
722 | ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted |
|
722 | ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted | |
723 | user or to a trusted group. The main exception is the web interface, |
|
723 | user or to a trusted group. The main exception is the web interface, | |
724 | which automatically uses some safe settings, since it's common to |
|
724 | which automatically uses some safe settings, since it's common to | |
725 | serve repositories from different users. |
|
725 | serve repositories from different users. | |
726 |
|
726 | |||
727 | This section specifies what users and groups are trusted. The |
|
727 | This section specifies what users and groups are trusted. The | |
728 | current user is always trusted. To trust everybody, list a user or a |
|
728 | current user is always trusted. To trust everybody, list a user or a | |
729 | group with name ``*``. |
|
729 | group with name ``*``. | |
730 |
|
730 | |||
731 | ``users`` |
|
731 | ``users`` | |
732 | Comma-separated list of trusted users. |
|
732 | Comma-separated list of trusted users. | |
733 | ``groups`` |
|
733 | ``groups`` | |
734 | Comma-separated list of trusted groups. |
|
734 | Comma-separated list of trusted groups. | |
735 |
|
735 | |||
736 |
|
736 | |||
737 | ``ui`` |
|
737 | ``ui`` | |
738 | """""" |
|
738 | """""" | |
739 |
|
739 | |||
740 | User interface controls. |
|
740 | User interface controls. | |
741 |
|
741 | |||
742 | ``archivemeta`` |
|
742 | ``archivemeta`` | |
743 | Whether to include the .hg_archival.txt file containing meta data |
|
743 | Whether to include the .hg_archival.txt file containing meta data | |
744 | (hashes for the repository base and for tip) in archives created |
|
744 | (hashes for the repository base and for tip) in archives created | |
745 | by the hg archive command or downloaded via hgweb. |
|
745 | by the hg archive command or downloaded via hgweb. | |
746 | Default is True. |
|
746 | Default is True. | |
747 | ``askusername`` |
|
747 | ``askusername`` | |
748 | Whether to prompt for a username when committing. If True, and |
|
748 | Whether to prompt for a username when committing. If True, and | |
749 | neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will |
|
749 | neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will | |
750 | be prompted to enter a username. If no username is entered, the |
|
750 | be prompted to enter a username. If no username is entered, the | |
751 | default ``USER@HOST`` is used instead. |
|
751 | default ``USER@HOST`` is used instead. | |
752 | Default is False. |
|
752 | Default is False. | |
753 | ``debug`` |
|
753 | ``debug`` | |
754 | Print debugging information. True or False. Default is False. |
|
754 | Print debugging information. True or False. Default is False. | |
755 | ``editor`` |
|
755 | ``editor`` | |
756 | The editor to use during a commit. Default is ``$EDITOR`` or ``vi``. |
|
756 | The editor to use during a commit. Default is ``$EDITOR`` or ``vi``. | |
757 | ``fallbackencoding`` |
|
757 | ``fallbackencoding`` | |
758 | Encoding to try if it's not possible to decode the changelog using |
|
758 | Encoding to try if it's not possible to decode the changelog using | |
759 | UTF-8. Default is ISO-8859-1. |
|
759 | UTF-8. Default is ISO-8859-1. | |
760 | ``ignore`` |
|
760 | ``ignore`` | |
761 | A file to read per-user ignore patterns from. This file should be |
|
761 | A file to read per-user ignore patterns from. This file should be | |
762 | in the same format as a repository-wide .hgignore file. This |
|
762 | in the same format as a repository-wide .hgignore file. This | |
763 | option supports hook syntax, so if you want to specify multiple |
|
763 | option supports hook syntax, so if you want to specify multiple | |
764 | ignore files, you can do so by setting something like |
|
764 | ignore files, you can do so by setting something like | |
765 | ``ignore.other = ~/.hgignore2``. For details of the ignore file |
|
765 | ``ignore.other = ~/.hgignore2``. For details of the ignore file | |
766 | format, see the |hgignore(5)|_ man page. |
|
766 | format, see the |hgignore(5)|_ man page. | |
767 | ``interactive`` |
|
767 | ``interactive`` | |
768 | Allow to prompt the user. True or False. Default is True. |
|
768 | Allow to prompt the user. True or False. Default is True. | |
769 | ``logtemplate`` |
|
769 | ``logtemplate`` | |
770 | Template string for commands that print changesets. |
|
770 | Template string for commands that print changesets. | |
771 | ``merge`` |
|
771 | ``merge`` | |
772 | The conflict resolution program to use during a manual merge. |
|
772 | The conflict resolution program to use during a manual merge. | |
773 | There are some internal tools available: |
|
773 | There are some internal tools available: | |
774 |
|
774 | |||
775 | ``internal:local`` |
|
775 | ``internal:local`` | |
776 | keep the local version |
|
776 | keep the local version | |
777 | ``internal:other`` |
|
777 | ``internal:other`` | |
778 | use the other version |
|
778 | use the other version | |
779 | ``internal:merge`` |
|
779 | ``internal:merge`` | |
780 | use the internal non-interactive merge tool |
|
780 | use the internal non-interactive merge tool | |
781 | ``internal:fail`` |
|
781 | ``internal:fail`` | |
782 | fail to merge |
|
782 | fail to merge | |
783 |
|
783 | |||
784 | For more information on configuring merge tools see the |
|
784 | For more information on configuring merge tools see the | |
785 | merge-tools_ section. |
|
785 | merge-tools_ section. | |
786 |
|
786 | |||
787 | ``patch`` |
|
787 | ``patch`` | |
788 | command to use to apply patches. Look for ``gpatch`` or ``patch`` in |
|
788 | command to use to apply patches. Look for ``gpatch`` or ``patch`` in | |
789 | PATH if unset. |
|
789 | PATH if unset. | |
790 | ``quiet`` |
|
790 | ``quiet`` | |
791 | Reduce the amount of output printed. True or False. Default is False. |
|
791 | Reduce the amount of output printed. True or False. Default is False. | |
792 | ``remotecmd`` |
|
792 | ``remotecmd`` | |
793 | remote command to use for clone/push/pull operations. Default is ``hg``. |
|
793 | remote command to use for clone/push/pull operations. Default is ``hg``. | |
794 | ``report_untrusted`` |
|
794 | ``report_untrusted`` | |
795 | Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a |
|
795 | Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a | |
796 | trusted user or group. True or False. Default is True. |
|
796 | trusted user or group. True or False. Default is True. | |
797 | ``slash`` |
|
797 | ``slash`` | |
798 | Display paths using a slash (``/``) as the path separator. This |
|
798 | Display paths using a slash (``/``) as the path separator. This | |
799 | only makes a difference on systems where the default path |
|
799 | only makes a difference on systems where the default path | |
800 | separator is not the slash character (e.g. Windows uses the |
|
800 | separator is not the slash character (e.g. Windows uses the | |
801 | backslash character (``\``)). |
|
801 | backslash character (``\``)). | |
802 | Default is False. |
|
802 | Default is False. | |
803 | ``ssh`` |
|
803 | ``ssh`` | |
804 | command to use for SSH connections. Default is ``ssh``. |
|
804 | command to use for SSH connections. Default is ``ssh``. | |
805 | ``strict`` |
|
805 | ``strict`` | |
806 | Require exact command names, instead of allowing unambiguous |
|
806 | Require exact command names, instead of allowing unambiguous | |
807 | abbreviations. True or False. Default is False. |
|
807 | abbreviations. True or False. Default is False. | |
808 | ``style`` |
|
808 | ``style`` | |
809 | Name of style to use for command output. |
|
809 | Name of style to use for command output. | |
810 | ``timeout`` |
|
810 | ``timeout`` | |
811 | The timeout used when a lock is held (in seconds), a negative value |
|
811 | The timeout used when a lock is held (in seconds), a negative value | |
812 | means no timeout. Default is 600. |
|
812 | means no timeout. Default is 600. | |
813 | ``traceback`` |
|
813 | ``traceback`` | |
814 | Mercurial always prints a traceback when an unknown exception |
|
814 | Mercurial always prints a traceback when an unknown exception | |
815 | occurs. Setting this to True will make Mercurial print a traceback |
|
815 | occurs. Setting this to True will make Mercurial print a traceback | |
816 | on all exceptions, even those recognized by Mercurial (such as |
|
816 | on all exceptions, even those recognized by Mercurial (such as | |
817 | IOError or MemoryError). Default is False. |
|
817 | IOError or MemoryError). Default is False. | |
818 | ``username`` |
|
818 | ``username`` | |
819 | The committer of a changeset created when running "commit". |
|
819 | The committer of a changeset created when running "commit". | |
820 | Typically a person's name and email address, e.g. ``Fred Widget |
|
820 | Typically a person's name and email address, e.g. ``Fred Widget | |
821 | <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If |
|
821 | <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If | |
822 | the username in hgrc is empty, it has to be specified manually or |
|
822 | the username in hgrc is empty, it has to be specified manually or | |
823 | in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set |
|
823 | in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set | |
824 | ``username =`` in the system hgrc). |
|
824 | ``username =`` in the system hgrc). | |
825 | ``verbose`` |
|
825 | ``verbose`` | |
826 | Increase the amount of output printed. True or False. Default is False. |
|
826 | Increase the amount of output printed. True or False. Default is False. | |
827 |
|
827 | |||
828 |
|
828 | |||
829 | ``web`` |
|
829 | ``web`` | |
830 | """"""" |
|
830 | """"""" | |
831 | Web interface configuration. |
|
831 | Web interface configuration. | |
832 |
|
832 | |||
833 | ``accesslog`` |
|
833 | ``accesslog`` | |
834 | Where to output the access log. Default is stdout. |
|
834 | Where to output the access log. Default is stdout. | |
835 | ``address`` |
|
835 | ``address`` | |
836 | Interface address to bind to. Default is all. |
|
836 | Interface address to bind to. Default is all. | |
837 | ``allow_archive`` |
|
837 | ``allow_archive`` | |
838 | List of archive format (bz2, gz, zip) allowed for downloading. |
|
838 | List of archive format (bz2, gz, zip) allowed for downloading. | |
839 | Default is empty. |
|
839 | Default is empty. | |
840 | ``allowbz2`` |
|
840 | ``allowbz2`` | |
841 | (DEPRECATED) Whether to allow .tar.bz2 downloading of repository |
|
841 | (DEPRECATED) Whether to allow .tar.bz2 downloading of repository | |
842 | revisions. |
|
842 | revisions. | |
843 | Default is False. |
|
843 | Default is False. | |
844 | ``allowgz`` |
|
844 | ``allowgz`` | |
845 | (DEPRECATED) Whether to allow .tar.gz downloading of repository |
|
845 | (DEPRECATED) Whether to allow .tar.gz downloading of repository | |
846 | revisions. |
|
846 | revisions. | |
847 | Default is False. |
|
847 | Default is False. | |
848 | ``allowpull`` |
|
848 | ``allowpull`` | |
849 | Whether to allow pulling from the repository. Default is True. |
|
849 | Whether to allow pulling from the repository. Default is True. | |
850 | ``allow_push`` |
|
850 | ``allow_push`` | |
851 | Whether to allow pushing to the repository. If empty or not set, |
|
851 | Whether to allow pushing to the repository. If empty or not set, | |
852 | push is not allowed. If the special value ``*``, any remote user can |
|
852 | push is not allowed. If the special value ``*``, any remote user can | |
853 | push, including unauthenticated users. Otherwise, the remote user |
|
853 | push, including unauthenticated users. Otherwise, the remote user | |
854 | must have been authenticated, and the authenticated user name must |
|
854 | must have been authenticated, and the authenticated user name must | |
855 | be present in this list (separated by whitespace or ``,``). The |
|
855 | be present in this list (separated by whitespace or ``,``). The | |
856 | contents of the allow_push list are examined after the deny_push |
|
856 | contents of the allow_push list are examined after the deny_push | |
857 | list. |
|
857 | list. | |
858 | ``allow_read`` |
|
858 | ``allow_read`` | |
859 | If the user has not already been denied repository access due to |
|
859 | If the user has not already been denied repository access due to | |
860 | the contents of deny_read, this list determines whether to grant |
|
860 | the contents of deny_read, this list determines whether to grant | |
861 | repository access to the user. If this list is not empty, and the |
|
861 | repository access to the user. If this list is not empty, and the | |
862 | user is unauthenticated or not present in the list (separated by |
|
862 | user is unauthenticated or not present in the list (separated by | |
863 | whitespace or ``,``), then access is denied for the user. If the |
|
863 | whitespace or ``,``), then access is denied for the user. If the | |
864 | list is empty or not set, then access is permitted to all users by |
|
864 | list is empty or not set, then access is permitted to all users by | |
865 | default. Setting allow_read to the special value ``*`` is equivalent |
|
865 | default. Setting allow_read to the special value ``*`` is equivalent | |
866 | to it not being set (i.e. access is permitted to all users). The |
|
866 | to it not being set (i.e. access is permitted to all users). The | |
867 | contents of the allow_read list are examined after the deny_read |
|
867 | contents of the allow_read list are examined after the deny_read | |
868 | list. |
|
868 | list. | |
869 | ``allowzip`` |
|
869 | ``allowzip`` | |
870 | (DEPRECATED) Whether to allow .zip downloading of repository |
|
870 | (DEPRECATED) Whether to allow .zip downloading of repository | |
871 | revisions. Default is False. This feature creates temporary files. |
|
871 | revisions. Default is False. This feature creates temporary files. | |
872 | ``baseurl`` |
|
872 | ``baseurl`` | |
873 | Base URL to use when publishing URLs in other locations, so |
|
873 | Base URL to use when publishing URLs in other locations, so | |
874 | third-party tools like email notification hooks can construct |
|
874 | third-party tools like email notification hooks can construct | |
875 | URLs. Example: ``http://hgserver/repos/``. |
|
875 | URLs. Example: ``http://hgserver/repos/``. | |
|
876 | ``cacerts`` | |||
|
877 | Path to file containing a list of PEM encoded certificate authorities | |||
|
878 | that may be used to verify an SSL server's identity. The form must be | |||
|
879 | as follows:: | |||
|
880 | ||||
|
881 | -----BEGIN CERTIFICATE----- | |||
|
882 | ... (certificate in base64 PEM encoding) ... | |||
|
883 | -----END CERTIFICATE----- | |||
|
884 | -----BEGIN CERTIFICATE----- | |||
|
885 | ... (certificate in base64 PEM encoding) ... | |||
|
886 | -----END CERTIFICATE----- | |||
|
887 | ||||
|
888 | This feature is only supported when using Python 2.6. If you wish to | |||
|
889 | use it with earlier versions of Python, install the backported | |||
|
890 | version of the ssl library that is available from | |||
|
891 | ``http://pypi.python.org``. | |||
|
892 | ||||
|
893 | You can use OpenSSL's CA certificate file if your platform has one. | |||
|
894 | On most Linux systems this will be ``/etc/ssl/certs/ca-certificates.crt``. | |||
|
895 | Otherwise you will have to generate this file manually. | |||
876 | ``contact`` |
|
896 | ``contact`` | |
877 | Name or email address of the person in charge of the repository. |
|
897 | Name or email address of the person in charge of the repository. | |
878 | Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty. |
|
898 | Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty. | |
879 | ``deny_push`` |
|
899 | ``deny_push`` | |
880 | Whether to deny pushing to the repository. If empty or not set, |
|
900 | Whether to deny pushing to the repository. If empty or not set, | |
881 | push is not denied. If the special value ``*``, all remote users are |
|
901 | push is not denied. If the special value ``*``, all remote users are | |
882 | denied push. Otherwise, unauthenticated users are all denied, and |
|
902 | denied push. Otherwise, unauthenticated users are all denied, and | |
883 | any authenticated user name present in this list (separated by |
|
903 | any authenticated user name present in this list (separated by | |
884 | whitespace or ``,``) is also denied. The contents of the deny_push |
|
904 | whitespace or ``,``) is also denied. The contents of the deny_push | |
885 | list are examined before the allow_push list. |
|
905 | list are examined before the allow_push list. | |
886 | ``deny_read`` |
|
906 | ``deny_read`` | |
887 | Whether to deny reading/viewing of the repository. If this list is |
|
907 | Whether to deny reading/viewing of the repository. If this list is | |
888 | not empty, unauthenticated users are all denied, and any |
|
908 | not empty, unauthenticated users are all denied, and any | |
889 | authenticated user name present in this list (separated by |
|
909 | authenticated user name present in this list (separated by | |
890 | whitespace or ``,``) is also denied access to the repository. If set |
|
910 | whitespace or ``,``) is also denied access to the repository. If set | |
891 | to the special value ``*``, all remote users are denied access |
|
911 | to the special value ``*``, all remote users are denied access | |
892 | (rarely needed ;). If deny_read is empty or not set, the |
|
912 | (rarely needed ;). If deny_read is empty or not set, the | |
893 | determination of repository access depends on the presence and |
|
913 | determination of repository access depends on the presence and | |
894 | content of the allow_read list (see description). If both |
|
914 | content of the allow_read list (see description). If both | |
895 | deny_read and allow_read are empty or not set, then access is |
|
915 | deny_read and allow_read are empty or not set, then access is | |
896 | permitted to all users by default. If the repository is being |
|
916 | permitted to all users by default. If the repository is being | |
897 | served via hgwebdir, denied users will not be able to see it in |
|
917 | served via hgwebdir, denied users will not be able to see it in | |
898 | the list of repositories. The contents of the deny_read list have |
|
918 | the list of repositories. The contents of the deny_read list have | |
899 | priority over (are examined before) the contents of the allow_read |
|
919 | priority over (are examined before) the contents of the allow_read | |
900 | list. |
|
920 | list. | |
901 | ``descend`` |
|
921 | ``descend`` | |
902 | hgwebdir indexes will not descend into subdirectories. Only repositories |
|
922 | hgwebdir indexes will not descend into subdirectories. Only repositories | |
903 | directly in the current path will be shown (other repositories are still |
|
923 | directly in the current path will be shown (other repositories are still | |
904 | available from the index corresponding to their containing path). |
|
924 | available from the index corresponding to their containing path). | |
905 | ``description`` |
|
925 | ``description`` | |
906 | Textual description of the repository's purpose or contents. |
|
926 | Textual description of the repository's purpose or contents. | |
907 | Default is "unknown". |
|
927 | Default is "unknown". | |
908 | ``encoding`` |
|
928 | ``encoding`` | |
909 | Character encoding name. |
|
929 | Character encoding name. | |
910 | Example: "UTF-8" |
|
930 | Example: "UTF-8" | |
911 | ``errorlog`` |
|
931 | ``errorlog`` | |
912 | Where to output the error log. Default is stderr. |
|
932 | Where to output the error log. Default is stderr. | |
913 | ``hidden`` |
|
933 | ``hidden`` | |
914 | Whether to hide the repository in the hgwebdir index. |
|
934 | Whether to hide the repository in the hgwebdir index. | |
915 | Default is False. |
|
935 | Default is False. | |
916 | ``ipv6`` |
|
936 | ``ipv6`` | |
917 | Whether to use IPv6. Default is False. |
|
937 | Whether to use IPv6. Default is False. | |
918 | ``name`` |
|
938 | ``name`` | |
919 | Repository name to use in the web interface. Default is current |
|
939 | Repository name to use in the web interface. Default is current | |
920 | working directory. |
|
940 | working directory. | |
921 | ``maxchanges`` |
|
941 | ``maxchanges`` | |
922 | Maximum number of changes to list on the changelog. Default is 10. |
|
942 | Maximum number of changes to list on the changelog. Default is 10. | |
923 | ``maxfiles`` |
|
943 | ``maxfiles`` | |
924 | Maximum number of files to list per changeset. Default is 10. |
|
944 | Maximum number of files to list per changeset. Default is 10. | |
925 | ``port`` |
|
945 | ``port`` | |
926 | Port to listen on. Default is 8000. |
|
946 | Port to listen on. Default is 8000. | |
927 | ``prefix`` |
|
947 | ``prefix`` | |
928 | Prefix path to serve from. Default is '' (server root). |
|
948 | Prefix path to serve from. Default is '' (server root). | |
929 | ``push_ssl`` |
|
949 | ``push_ssl`` | |
930 | Whether to require that inbound pushes be transported over SSL to |
|
950 | Whether to require that inbound pushes be transported over SSL to | |
931 | prevent password sniffing. Default is True. |
|
951 | prevent password sniffing. Default is True. | |
932 | ``staticurl`` |
|
952 | ``staticurl`` | |
933 | Base URL to use for static files. If unset, static files (e.g. the |
|
953 | Base URL to use for static files. If unset, static files (e.g. the | |
934 | hgicon.png favicon) will be served by the CGI script itself. Use |
|
954 | hgicon.png favicon) will be served by the CGI script itself. Use | |
935 | this setting to serve them directly with the HTTP server. |
|
955 | this setting to serve them directly with the HTTP server. | |
936 | Example: ``http://hgserver/static/``. |
|
956 | Example: ``http://hgserver/static/``. | |
937 | ``stripes`` |
|
957 | ``stripes`` | |
938 | How many lines a "zebra stripe" should span in multiline output. |
|
958 | How many lines a "zebra stripe" should span in multiline output. | |
939 | Default is 1; set to 0 to disable. |
|
959 | Default is 1; set to 0 to disable. | |
940 | ``style`` |
|
960 | ``style`` | |
941 | Which template map style to use. |
|
961 | Which template map style to use. | |
942 | ``templates`` |
|
962 | ``templates`` | |
943 | Where to find the HTML templates. Default is install path. |
|
963 | Where to find the HTML templates. Default is install path. | |
944 |
|
964 | |||
945 |
|
965 | |||
946 | Author |
|
966 | Author | |
947 | ------ |
|
967 | ------ | |
948 | Bryan O'Sullivan <bos@serpentine.com>. |
|
968 | Bryan O'Sullivan <bos@serpentine.com>. | |
949 |
|
969 | |||
950 | Mercurial was written by Matt Mackall <mpm@selenic.com>. |
|
970 | Mercurial was written by Matt Mackall <mpm@selenic.com>. | |
951 |
|
971 | |||
952 | See Also |
|
972 | See Also | |
953 | -------- |
|
973 | -------- | |
954 | |hg(1)|_, |hgignore(5)|_ |
|
974 | |hg(1)|_, |hgignore(5)|_ | |
955 |
|
975 | |||
956 | Copying |
|
976 | Copying | |
957 | ------- |
|
977 | ------- | |
958 | This manual page is copyright 2005 Bryan O'Sullivan. |
|
978 | This manual page is copyright 2005 Bryan O'Sullivan. | |
959 | Mercurial is copyright 2005-2010 Matt Mackall. |
|
979 | Mercurial is copyright 2005-2010 Matt Mackall. | |
960 | Free use of this software is granted under the terms of the GNU General |
|
980 | Free use of this software is granted under the terms of the GNU General | |
961 | Public License version 2 or any later version. |
|
981 | Public License version 2 or any later version. | |
962 |
|
982 | |||
963 | .. include:: common.txt |
|
983 | .. include:: common.txt |
@@ -1,560 +1,614 | |||||
1 | # url.py - HTTP handling for mercurial |
|
1 | # url.py - HTTP handling for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005, 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005, 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> | |
4 | # Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> |
|
4 | # Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> | |
5 | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
|
5 | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | |
6 | # |
|
6 | # | |
7 | # This software may be used and distributed according to the terms of the |
|
7 | # This software may be used and distributed according to the terms of the | |
8 | # GNU General Public License version 2 or any later version. |
|
8 | # GNU General Public License version 2 or any later version. | |
9 |
|
9 | |||
10 | import urllib, urllib2, urlparse, httplib, os, re, socket, cStringIO |
|
10 | import urllib, urllib2, urlparse, httplib, os, re, socket, cStringIO | |
11 | from i18n import _ |
|
11 | from i18n import _ | |
12 | import keepalive, util |
|
12 | import keepalive, util | |
13 |
|
13 | |||
14 | def hidepassword(url): |
|
14 | def hidepassword(url): | |
15 | '''hide user credential in a url string''' |
|
15 | '''hide user credential in a url string''' | |
16 | scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) |
|
16 | scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) | |
17 | netloc = re.sub('([^:]*):([^@]*)@(.*)', r'\1:***@\3', netloc) |
|
17 | netloc = re.sub('([^:]*):([^@]*)@(.*)', r'\1:***@\3', netloc) | |
18 | return urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) |
|
18 | return urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) | |
19 |
|
19 | |||
20 | def removeauth(url): |
|
20 | def removeauth(url): | |
21 | '''remove all authentication information from a url string''' |
|
21 | '''remove all authentication information from a url string''' | |
22 | scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) |
|
22 | scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) | |
23 | netloc = netloc[netloc.find('@')+1:] |
|
23 | netloc = netloc[netloc.find('@')+1:] | |
24 | return urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) |
|
24 | return urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) | |
25 |
|
25 | |||
26 | def netlocsplit(netloc): |
|
26 | def netlocsplit(netloc): | |
27 | '''split [user[:passwd]@]host[:port] into 4-tuple.''' |
|
27 | '''split [user[:passwd]@]host[:port] into 4-tuple.''' | |
28 |
|
28 | |||
29 | a = netloc.find('@') |
|
29 | a = netloc.find('@') | |
30 | if a == -1: |
|
30 | if a == -1: | |
31 | user, passwd = None, None |
|
31 | user, passwd = None, None | |
32 | else: |
|
32 | else: | |
33 | userpass, netloc = netloc[:a], netloc[a + 1:] |
|
33 | userpass, netloc = netloc[:a], netloc[a + 1:] | |
34 | c = userpass.find(':') |
|
34 | c = userpass.find(':') | |
35 | if c == -1: |
|
35 | if c == -1: | |
36 | user, passwd = urllib.unquote(userpass), None |
|
36 | user, passwd = urllib.unquote(userpass), None | |
37 | else: |
|
37 | else: | |
38 | user = urllib.unquote(userpass[:c]) |
|
38 | user = urllib.unquote(userpass[:c]) | |
39 | passwd = urllib.unquote(userpass[c + 1:]) |
|
39 | passwd = urllib.unquote(userpass[c + 1:]) | |
40 | c = netloc.find(':') |
|
40 | c = netloc.find(':') | |
41 | if c == -1: |
|
41 | if c == -1: | |
42 | host, port = netloc, None |
|
42 | host, port = netloc, None | |
43 | else: |
|
43 | else: | |
44 | host, port = netloc[:c], netloc[c + 1:] |
|
44 | host, port = netloc[:c], netloc[c + 1:] | |
45 | return host, port, user, passwd |
|
45 | return host, port, user, passwd | |
46 |
|
46 | |||
47 | def netlocunsplit(host, port, user=None, passwd=None): |
|
47 | def netlocunsplit(host, port, user=None, passwd=None): | |
48 | '''turn host, port, user, passwd into [user[:passwd]@]host[:port].''' |
|
48 | '''turn host, port, user, passwd into [user[:passwd]@]host[:port].''' | |
49 | if port: |
|
49 | if port: | |
50 | hostport = host + ':' + port |
|
50 | hostport = host + ':' + port | |
51 | else: |
|
51 | else: | |
52 | hostport = host |
|
52 | hostport = host | |
53 | if user: |
|
53 | if user: | |
54 | if passwd: |
|
54 | if passwd: | |
55 | userpass = urllib.quote(user) + ':' + urllib.quote(passwd) |
|
55 | userpass = urllib.quote(user) + ':' + urllib.quote(passwd) | |
56 | else: |
|
56 | else: | |
57 | userpass = urllib.quote(user) |
|
57 | userpass = urllib.quote(user) | |
58 | return userpass + '@' + hostport |
|
58 | return userpass + '@' + hostport | |
59 | return hostport |
|
59 | return hostport | |
60 |
|
60 | |||
61 | _safe = ('abcdefghijklmnopqrstuvwxyz' |
|
61 | _safe = ('abcdefghijklmnopqrstuvwxyz' | |
62 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
|
62 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
63 | '0123456789' '_.-/') |
|
63 | '0123456789' '_.-/') | |
64 | _safeset = None |
|
64 | _safeset = None | |
65 | _hex = None |
|
65 | _hex = None | |
66 | def quotepath(path): |
|
66 | def quotepath(path): | |
67 | '''quote the path part of a URL |
|
67 | '''quote the path part of a URL | |
68 |
|
68 | |||
69 | This is similar to urllib.quote, but it also tries to avoid |
|
69 | This is similar to urllib.quote, but it also tries to avoid | |
70 | quoting things twice (inspired by wget): |
|
70 | quoting things twice (inspired by wget): | |
71 |
|
71 | |||
72 | >>> quotepath('abc def') |
|
72 | >>> quotepath('abc def') | |
73 | 'abc%20def' |
|
73 | 'abc%20def' | |
74 | >>> quotepath('abc%20def') |
|
74 | >>> quotepath('abc%20def') | |
75 | 'abc%20def' |
|
75 | 'abc%20def' | |
76 | >>> quotepath('abc%20 def') |
|
76 | >>> quotepath('abc%20 def') | |
77 | 'abc%20%20def' |
|
77 | 'abc%20%20def' | |
78 | >>> quotepath('abc def%20') |
|
78 | >>> quotepath('abc def%20') | |
79 | 'abc%20def%20' |
|
79 | 'abc%20def%20' | |
80 | >>> quotepath('abc def%2') |
|
80 | >>> quotepath('abc def%2') | |
81 | 'abc%20def%252' |
|
81 | 'abc%20def%252' | |
82 | >>> quotepath('abc def%') |
|
82 | >>> quotepath('abc def%') | |
83 | 'abc%20def%25' |
|
83 | 'abc%20def%25' | |
84 | ''' |
|
84 | ''' | |
85 | global _safeset, _hex |
|
85 | global _safeset, _hex | |
86 | if _safeset is None: |
|
86 | if _safeset is None: | |
87 | _safeset = set(_safe) |
|
87 | _safeset = set(_safe) | |
88 | _hex = set('abcdefABCDEF0123456789') |
|
88 | _hex = set('abcdefABCDEF0123456789') | |
89 | l = list(path) |
|
89 | l = list(path) | |
90 | for i in xrange(len(l)): |
|
90 | for i in xrange(len(l)): | |
91 | c = l[i] |
|
91 | c = l[i] | |
92 | if (c == '%' and i + 2 < len(l) and |
|
92 | if (c == '%' and i + 2 < len(l) and | |
93 | l[i + 1] in _hex and l[i + 2] in _hex): |
|
93 | l[i + 1] in _hex and l[i + 2] in _hex): | |
94 | pass |
|
94 | pass | |
95 | elif c not in _safeset: |
|
95 | elif c not in _safeset: | |
96 | l[i] = '%%%02X' % ord(c) |
|
96 | l[i] = '%%%02X' % ord(c) | |
97 | return ''.join(l) |
|
97 | return ''.join(l) | |
98 |
|
98 | |||
99 | class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
|
99 | class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): | |
100 | def __init__(self, ui): |
|
100 | def __init__(self, ui): | |
101 | urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
|
101 | urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) | |
102 | self.ui = ui |
|
102 | self.ui = ui | |
103 |
|
103 | |||
104 | def find_user_password(self, realm, authuri): |
|
104 | def find_user_password(self, realm, authuri): | |
105 | authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password( |
|
105 | authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password( | |
106 | self, realm, authuri) |
|
106 | self, realm, authuri) | |
107 | user, passwd = authinfo |
|
107 | user, passwd = authinfo | |
108 | if user and passwd: |
|
108 | if user and passwd: | |
109 | self._writedebug(user, passwd) |
|
109 | self._writedebug(user, passwd) | |
110 | return (user, passwd) |
|
110 | return (user, passwd) | |
111 |
|
111 | |||
112 | if not user: |
|
112 | if not user: | |
113 | auth = self.readauthtoken(authuri) |
|
113 | auth = self.readauthtoken(authuri) | |
114 | if auth: |
|
114 | if auth: | |
115 | user, passwd = auth.get('username'), auth.get('password') |
|
115 | user, passwd = auth.get('username'), auth.get('password') | |
116 | if not user or not passwd: |
|
116 | if not user or not passwd: | |
117 | if not self.ui.interactive(): |
|
117 | if not self.ui.interactive(): | |
118 | raise util.Abort(_('http authorization required')) |
|
118 | raise util.Abort(_('http authorization required')) | |
119 |
|
119 | |||
120 | self.ui.write(_("http authorization required\n")) |
|
120 | self.ui.write(_("http authorization required\n")) | |
121 | self.ui.status(_("realm: %s\n") % realm) |
|
121 | self.ui.status(_("realm: %s\n") % realm) | |
122 | if user: |
|
122 | if user: | |
123 | self.ui.status(_("user: %s\n") % user) |
|
123 | self.ui.status(_("user: %s\n") % user) | |
124 | else: |
|
124 | else: | |
125 | user = self.ui.prompt(_("user:"), default=None) |
|
125 | user = self.ui.prompt(_("user:"), default=None) | |
126 |
|
126 | |||
127 | if not passwd: |
|
127 | if not passwd: | |
128 | passwd = self.ui.getpass() |
|
128 | passwd = self.ui.getpass() | |
129 |
|
129 | |||
130 | self.add_password(realm, authuri, user, passwd) |
|
130 | self.add_password(realm, authuri, user, passwd) | |
131 | self._writedebug(user, passwd) |
|
131 | self._writedebug(user, passwd) | |
132 | return (user, passwd) |
|
132 | return (user, passwd) | |
133 |
|
133 | |||
134 | def _writedebug(self, user, passwd): |
|
134 | def _writedebug(self, user, passwd): | |
135 | msg = _('http auth: user %s, password %s\n') |
|
135 | msg = _('http auth: user %s, password %s\n') | |
136 | self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set')) |
|
136 | self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set')) | |
137 |
|
137 | |||
138 | def readauthtoken(self, uri): |
|
138 | def readauthtoken(self, uri): | |
139 | # Read configuration |
|
139 | # Read configuration | |
140 | config = dict() |
|
140 | config = dict() | |
141 | for key, val in self.ui.configitems('auth'): |
|
141 | for key, val in self.ui.configitems('auth'): | |
142 | group, setting = key.split('.', 1) |
|
142 | group, setting = key.split('.', 1) | |
143 | gdict = config.setdefault(group, dict()) |
|
143 | gdict = config.setdefault(group, dict()) | |
144 | gdict[setting] = val |
|
144 | gdict[setting] = val | |
145 |
|
145 | |||
146 | # Find the best match |
|
146 | # Find the best match | |
147 | scheme, hostpath = uri.split('://', 1) |
|
147 | scheme, hostpath = uri.split('://', 1) | |
148 | bestlen = 0 |
|
148 | bestlen = 0 | |
149 | bestauth = None |
|
149 | bestauth = None | |
150 | for auth in config.itervalues(): |
|
150 | for auth in config.itervalues(): | |
151 | prefix = auth.get('prefix') |
|
151 | prefix = auth.get('prefix') | |
152 | if not prefix: |
|
152 | if not prefix: | |
153 | continue |
|
153 | continue | |
154 | p = prefix.split('://', 1) |
|
154 | p = prefix.split('://', 1) | |
155 | if len(p) > 1: |
|
155 | if len(p) > 1: | |
156 | schemes, prefix = [p[0]], p[1] |
|
156 | schemes, prefix = [p[0]], p[1] | |
157 | else: |
|
157 | else: | |
158 | schemes = (auth.get('schemes') or 'https').split() |
|
158 | schemes = (auth.get('schemes') or 'https').split() | |
159 | if (prefix == '*' or hostpath.startswith(prefix)) and \ |
|
159 | if (prefix == '*' or hostpath.startswith(prefix)) and \ | |
160 | len(prefix) > bestlen and scheme in schemes: |
|
160 | len(prefix) > bestlen and scheme in schemes: | |
161 | bestlen = len(prefix) |
|
161 | bestlen = len(prefix) | |
162 | bestauth = auth |
|
162 | bestauth = auth | |
163 | return bestauth |
|
163 | return bestauth | |
164 |
|
164 | |||
165 | class proxyhandler(urllib2.ProxyHandler): |
|
165 | class proxyhandler(urllib2.ProxyHandler): | |
166 | def __init__(self, ui): |
|
166 | def __init__(self, ui): | |
167 | proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') |
|
167 | proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') | |
168 | # XXX proxyauthinfo = None |
|
168 | # XXX proxyauthinfo = None | |
169 |
|
169 | |||
170 | if proxyurl: |
|
170 | if proxyurl: | |
171 | # proxy can be proper url or host[:port] |
|
171 | # proxy can be proper url or host[:port] | |
172 | if not (proxyurl.startswith('http:') or |
|
172 | if not (proxyurl.startswith('http:') or | |
173 | proxyurl.startswith('https:')): |
|
173 | proxyurl.startswith('https:')): | |
174 | proxyurl = 'http://' + proxyurl + '/' |
|
174 | proxyurl = 'http://' + proxyurl + '/' | |
175 | snpqf = urlparse.urlsplit(proxyurl) |
|
175 | snpqf = urlparse.urlsplit(proxyurl) | |
176 | proxyscheme, proxynetloc, proxypath, proxyquery, proxyfrag = snpqf |
|
176 | proxyscheme, proxynetloc, proxypath, proxyquery, proxyfrag = snpqf | |
177 | hpup = netlocsplit(proxynetloc) |
|
177 | hpup = netlocsplit(proxynetloc) | |
178 |
|
178 | |||
179 | proxyhost, proxyport, proxyuser, proxypasswd = hpup |
|
179 | proxyhost, proxyport, proxyuser, proxypasswd = hpup | |
180 | if not proxyuser: |
|
180 | if not proxyuser: | |
181 | proxyuser = ui.config("http_proxy", "user") |
|
181 | proxyuser = ui.config("http_proxy", "user") | |
182 | proxypasswd = ui.config("http_proxy", "passwd") |
|
182 | proxypasswd = ui.config("http_proxy", "passwd") | |
183 |
|
183 | |||
184 | # see if we should use a proxy for this url |
|
184 | # see if we should use a proxy for this url | |
185 | no_list = ["localhost", "127.0.0.1"] |
|
185 | no_list = ["localhost", "127.0.0.1"] | |
186 | no_list.extend([p.lower() for |
|
186 | no_list.extend([p.lower() for | |
187 | p in ui.configlist("http_proxy", "no")]) |
|
187 | p in ui.configlist("http_proxy", "no")]) | |
188 | no_list.extend([p.strip().lower() for |
|
188 | no_list.extend([p.strip().lower() for | |
189 | p in os.getenv("no_proxy", '').split(',') |
|
189 | p in os.getenv("no_proxy", '').split(',') | |
190 | if p.strip()]) |
|
190 | if p.strip()]) | |
191 | # "http_proxy.always" config is for running tests on localhost |
|
191 | # "http_proxy.always" config is for running tests on localhost | |
192 | if ui.configbool("http_proxy", "always"): |
|
192 | if ui.configbool("http_proxy", "always"): | |
193 | self.no_list = [] |
|
193 | self.no_list = [] | |
194 | else: |
|
194 | else: | |
195 | self.no_list = no_list |
|
195 | self.no_list = no_list | |
196 |
|
196 | |||
197 | proxyurl = urlparse.urlunsplit(( |
|
197 | proxyurl = urlparse.urlunsplit(( | |
198 | proxyscheme, netlocunsplit(proxyhost, proxyport, |
|
198 | proxyscheme, netlocunsplit(proxyhost, proxyport, | |
199 | proxyuser, proxypasswd or ''), |
|
199 | proxyuser, proxypasswd or ''), | |
200 | proxypath, proxyquery, proxyfrag)) |
|
200 | proxypath, proxyquery, proxyfrag)) | |
201 | proxies = {'http': proxyurl, 'https': proxyurl} |
|
201 | proxies = {'http': proxyurl, 'https': proxyurl} | |
202 | ui.debug('proxying through http://%s:%s\n' % |
|
202 | ui.debug('proxying through http://%s:%s\n' % | |
203 | (proxyhost, proxyport)) |
|
203 | (proxyhost, proxyport)) | |
204 | else: |
|
204 | else: | |
205 | proxies = {} |
|
205 | proxies = {} | |
206 |
|
206 | |||
207 | # urllib2 takes proxy values from the environment and those |
|
207 | # urllib2 takes proxy values from the environment and those | |
208 | # will take precedence if found, so drop them |
|
208 | # will take precedence if found, so drop them | |
209 | for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: |
|
209 | for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: | |
210 | try: |
|
210 | try: | |
211 | if env in os.environ: |
|
211 | if env in os.environ: | |
212 | del os.environ[env] |
|
212 | del os.environ[env] | |
213 | except OSError: |
|
213 | except OSError: | |
214 | pass |
|
214 | pass | |
215 |
|
215 | |||
216 | urllib2.ProxyHandler.__init__(self, proxies) |
|
216 | urllib2.ProxyHandler.__init__(self, proxies) | |
217 | self.ui = ui |
|
217 | self.ui = ui | |
218 |
|
218 | |||
219 | def proxy_open(self, req, proxy, type_): |
|
219 | def proxy_open(self, req, proxy, type_): | |
220 | host = req.get_host().split(':')[0] |
|
220 | host = req.get_host().split(':')[0] | |
221 | if host in self.no_list: |
|
221 | if host in self.no_list: | |
222 | return None |
|
222 | return None | |
223 |
|
223 | |||
224 | # work around a bug in Python < 2.4.2 |
|
224 | # work around a bug in Python < 2.4.2 | |
225 | # (it leaves a "\n" at the end of Proxy-authorization headers) |
|
225 | # (it leaves a "\n" at the end of Proxy-authorization headers) | |
226 | baseclass = req.__class__ |
|
226 | baseclass = req.__class__ | |
227 | class _request(baseclass): |
|
227 | class _request(baseclass): | |
228 | def add_header(self, key, val): |
|
228 | def add_header(self, key, val): | |
229 | if key.lower() == 'proxy-authorization': |
|
229 | if key.lower() == 'proxy-authorization': | |
230 | val = val.strip() |
|
230 | val = val.strip() | |
231 | return baseclass.add_header(self, key, val) |
|
231 | return baseclass.add_header(self, key, val) | |
232 | req.__class__ = _request |
|
232 | req.__class__ = _request | |
233 |
|
233 | |||
234 | return urllib2.ProxyHandler.proxy_open(self, req, proxy, type_) |
|
234 | return urllib2.ProxyHandler.proxy_open(self, req, proxy, type_) | |
235 |
|
235 | |||
236 | class httpsendfile(file): |
|
236 | class httpsendfile(file): | |
237 | def __len__(self): |
|
237 | def __len__(self): | |
238 | return os.fstat(self.fileno()).st_size |
|
238 | return os.fstat(self.fileno()).st_size | |
239 |
|
239 | |||
240 | def _gen_sendfile(connection): |
|
240 | def _gen_sendfile(connection): | |
241 | def _sendfile(self, data): |
|
241 | def _sendfile(self, data): | |
242 | # send a file |
|
242 | # send a file | |
243 | if isinstance(data, httpsendfile): |
|
243 | if isinstance(data, httpsendfile): | |
244 | # if auth required, some data sent twice, so rewind here |
|
244 | # if auth required, some data sent twice, so rewind here | |
245 | data.seek(0) |
|
245 | data.seek(0) | |
246 | for chunk in util.filechunkiter(data): |
|
246 | for chunk in util.filechunkiter(data): | |
247 | connection.send(self, chunk) |
|
247 | connection.send(self, chunk) | |
248 | else: |
|
248 | else: | |
249 | connection.send(self, data) |
|
249 | connection.send(self, data) | |
250 | return _sendfile |
|
250 | return _sendfile | |
251 |
|
251 | |||
252 | has_https = hasattr(urllib2, 'HTTPSHandler') |
|
252 | has_https = hasattr(urllib2, 'HTTPSHandler') | |
253 | if has_https: |
|
253 | if has_https: | |
254 | try: |
|
254 | try: | |
255 | # avoid using deprecated/broken FakeSocket in python 2.6 |
|
255 | # avoid using deprecated/broken FakeSocket in python 2.6 | |
256 | import ssl |
|
256 | import ssl | |
257 | _ssl_wrap_socket = ssl.wrap_socket |
|
257 | _ssl_wrap_socket = ssl.wrap_socket | |
|
258 | CERT_REQUIRED = ssl.CERT_REQUIRED | |||
258 | except ImportError: |
|
259 | except ImportError: | |
259 | def _ssl_wrap_socket(sock, key_file, cert_file): |
|
260 | CERT_REQUIRED = 2 | |
|
261 | ||||
|
262 | def _ssl_wrap_socket(sock, key_file, cert_file, | |||
|
263 | cert_reqs=CERT_REQUIRED, ca_certs=None): | |||
|
264 | if ca_certs: | |||
|
265 | raise util.Abort(_( | |||
|
266 | 'certificate checking requires Python 2.6')) | |||
|
267 | ||||
260 | ssl = socket.ssl(sock, key_file, cert_file) |
|
268 | ssl = socket.ssl(sock, key_file, cert_file) | |
261 | return httplib.FakeSocket(sock, ssl) |
|
269 | return httplib.FakeSocket(sock, ssl) | |
262 |
|
270 | |||
|
271 | _GLOBAL_DEFAULT_TIMEOUT = object() | |||
|
272 | ||||
|
273 | try: | |||
|
274 | _create_connection = socket.create_connection | |||
|
275 | except ImportError: | |||
|
276 | def _create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, | |||
|
277 | source_address=None): | |||
|
278 | # lifted from Python 2.6 | |||
|
279 | ||||
|
280 | msg = "getaddrinfo returns an empty list" | |||
|
281 | host, port = address | |||
|
282 | for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): | |||
|
283 | af, socktype, proto, canonname, sa = res | |||
|
284 | sock = None | |||
|
285 | try: | |||
|
286 | sock = socket.socket(af, socktype, proto) | |||
|
287 | if timeout is not _GLOBAL_DEFAULT_TIMEOUT: | |||
|
288 | sock.settimeout(timeout) | |||
|
289 | if source_address: | |||
|
290 | sock.bind(source_address) | |||
|
291 | sock.connect(sa) | |||
|
292 | return sock | |||
|
293 | ||||
|
294 | except socket.error, msg: | |||
|
295 | if sock is not None: | |||
|
296 | sock.close() | |||
|
297 | ||||
|
298 | raise socket.error, msg | |||
|
299 | ||||
263 | class httpconnection(keepalive.HTTPConnection): |
|
300 | class httpconnection(keepalive.HTTPConnection): | |
264 | # must be able to send big bundle as stream. |
|
301 | # must be able to send big bundle as stream. | |
265 | send = _gen_sendfile(keepalive.HTTPConnection) |
|
302 | send = _gen_sendfile(keepalive.HTTPConnection) | |
266 |
|
303 | |||
267 | def connect(self): |
|
304 | def connect(self): | |
268 | if has_https and self.realhost: # use CONNECT proxy |
|
305 | if has_https and self.realhost: # use CONNECT proxy | |
269 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
306 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
270 | self.sock.connect((self.host, self.port)) |
|
307 | self.sock.connect((self.host, self.port)) | |
271 | if _generic_proxytunnel(self): |
|
308 | if _generic_proxytunnel(self): | |
272 | # we do not support client x509 certificates |
|
309 | # we do not support client x509 certificates | |
273 | self.sock = _ssl_wrap_socket(self.sock, None, None) |
|
310 | self.sock = _ssl_wrap_socket(self.sock, None, None) | |
274 | else: |
|
311 | else: | |
275 | keepalive.HTTPConnection.connect(self) |
|
312 | keepalive.HTTPConnection.connect(self) | |
276 |
|
313 | |||
277 | def getresponse(self): |
|
314 | def getresponse(self): | |
278 | proxyres = getattr(self, 'proxyres', None) |
|
315 | proxyres = getattr(self, 'proxyres', None) | |
279 | if proxyres: |
|
316 | if proxyres: | |
280 | if proxyres.will_close: |
|
317 | if proxyres.will_close: | |
281 | self.close() |
|
318 | self.close() | |
282 | self.proxyres = None |
|
319 | self.proxyres = None | |
283 | return proxyres |
|
320 | return proxyres | |
284 | return keepalive.HTTPConnection.getresponse(self) |
|
321 | return keepalive.HTTPConnection.getresponse(self) | |
285 |
|
322 | |||
286 | # general transaction handler to support different ways to handle |
|
323 | # general transaction handler to support different ways to handle | |
287 | # HTTPS proxying before and after Python 2.6.3. |
|
324 | # HTTPS proxying before and after Python 2.6.3. | |
288 | def _generic_start_transaction(handler, h, req): |
|
325 | def _generic_start_transaction(handler, h, req): | |
289 | if hasattr(req, '_tunnel_host') and req._tunnel_host: |
|
326 | if hasattr(req, '_tunnel_host') and req._tunnel_host: | |
290 | tunnel_host = req._tunnel_host |
|
327 | tunnel_host = req._tunnel_host | |
291 | if tunnel_host[:7] not in ['http://', 'https:/']: |
|
328 | if tunnel_host[:7] not in ['http://', 'https:/']: | |
292 | tunnel_host = 'https://' + tunnel_host |
|
329 | tunnel_host = 'https://' + tunnel_host | |
293 | new_tunnel = True |
|
330 | new_tunnel = True | |
294 | else: |
|
331 | else: | |
295 | tunnel_host = req.get_selector() |
|
332 | tunnel_host = req.get_selector() | |
296 | new_tunnel = False |
|
333 | new_tunnel = False | |
297 |
|
334 | |||
298 | if new_tunnel or tunnel_host == req.get_full_url(): # has proxy |
|
335 | if new_tunnel or tunnel_host == req.get_full_url(): # has proxy | |
299 | urlparts = urlparse.urlparse(tunnel_host) |
|
336 | urlparts = urlparse.urlparse(tunnel_host) | |
300 | if new_tunnel or urlparts[0] == 'https': # only use CONNECT for HTTPS |
|
337 | if new_tunnel or urlparts[0] == 'https': # only use CONNECT for HTTPS | |
301 | if ':' in urlparts[1]: |
|
338 | if ':' in urlparts[1]: | |
302 | realhost, realport = urlparts[1].split(':') |
|
339 | realhost, realport = urlparts[1].split(':') | |
303 | realport = int(realport) |
|
340 | realport = int(realport) | |
304 | else: |
|
341 | else: | |
305 | realhost = urlparts[1] |
|
342 | realhost = urlparts[1] | |
306 | realport = 443 |
|
343 | realport = 443 | |
307 |
|
344 | |||
308 | h.realhost = realhost |
|
345 | h.realhost = realhost | |
309 | h.realport = realport |
|
346 | h.realport = realport | |
310 | h.headers = req.headers.copy() |
|
347 | h.headers = req.headers.copy() | |
311 | h.headers.update(handler.parent.addheaders) |
|
348 | h.headers.update(handler.parent.addheaders) | |
312 | return |
|
349 | return | |
313 |
|
350 | |||
314 | h.realhost = None |
|
351 | h.realhost = None | |
315 | h.realport = None |
|
352 | h.realport = None | |
316 | h.headers = None |
|
353 | h.headers = None | |
317 |
|
354 | |||
318 | def _generic_proxytunnel(self): |
|
355 | def _generic_proxytunnel(self): | |
319 | proxyheaders = dict( |
|
356 | proxyheaders = dict( | |
320 | [(x, self.headers[x]) for x in self.headers |
|
357 | [(x, self.headers[x]) for x in self.headers | |
321 | if x.lower().startswith('proxy-')]) |
|
358 | if x.lower().startswith('proxy-')]) | |
322 | self._set_hostport(self.host, self.port) |
|
359 | self._set_hostport(self.host, self.port) | |
323 | self.send('CONNECT %s:%d HTTP/1.0\r\n' % (self.realhost, self.realport)) |
|
360 | self.send('CONNECT %s:%d HTTP/1.0\r\n' % (self.realhost, self.realport)) | |
324 | for header in proxyheaders.iteritems(): |
|
361 | for header in proxyheaders.iteritems(): | |
325 | self.send('%s: %s\r\n' % header) |
|
362 | self.send('%s: %s\r\n' % header) | |
326 | self.send('\r\n') |
|
363 | self.send('\r\n') | |
327 |
|
364 | |||
328 | # majority of the following code is duplicated from |
|
365 | # majority of the following code is duplicated from | |
329 | # httplib.HTTPConnection as there are no adequate places to |
|
366 | # httplib.HTTPConnection as there are no adequate places to | |
330 | # override functions to provide the needed functionality |
|
367 | # override functions to provide the needed functionality | |
331 | res = self.response_class(self.sock, |
|
368 | res = self.response_class(self.sock, | |
332 | strict=self.strict, |
|
369 | strict=self.strict, | |
333 | method=self._method) |
|
370 | method=self._method) | |
334 |
|
371 | |||
335 | while True: |
|
372 | while True: | |
336 | version, status, reason = res._read_status() |
|
373 | version, status, reason = res._read_status() | |
337 | if status != httplib.CONTINUE: |
|
374 | if status != httplib.CONTINUE: | |
338 | break |
|
375 | break | |
339 | while True: |
|
376 | while True: | |
340 | skip = res.fp.readline().strip() |
|
377 | skip = res.fp.readline().strip() | |
341 | if not skip: |
|
378 | if not skip: | |
342 | break |
|
379 | break | |
343 | res.status = status |
|
380 | res.status = status | |
344 | res.reason = reason.strip() |
|
381 | res.reason = reason.strip() | |
345 |
|
382 | |||
346 | if res.status == 200: |
|
383 | if res.status == 200: | |
347 | while True: |
|
384 | while True: | |
348 | line = res.fp.readline() |
|
385 | line = res.fp.readline() | |
349 | if line == '\r\n': |
|
386 | if line == '\r\n': | |
350 | break |
|
387 | break | |
351 | return True |
|
388 | return True | |
352 |
|
389 | |||
353 | if version == 'HTTP/1.0': |
|
390 | if version == 'HTTP/1.0': | |
354 | res.version = 10 |
|
391 | res.version = 10 | |
355 | elif version.startswith('HTTP/1.'): |
|
392 | elif version.startswith('HTTP/1.'): | |
356 | res.version = 11 |
|
393 | res.version = 11 | |
357 | elif version == 'HTTP/0.9': |
|
394 | elif version == 'HTTP/0.9': | |
358 | res.version = 9 |
|
395 | res.version = 9 | |
359 | else: |
|
396 | else: | |
360 | raise httplib.UnknownProtocol(version) |
|
397 | raise httplib.UnknownProtocol(version) | |
361 |
|
398 | |||
362 | if res.version == 9: |
|
399 | if res.version == 9: | |
363 | res.length = None |
|
400 | res.length = None | |
364 | res.chunked = 0 |
|
401 | res.chunked = 0 | |
365 | res.will_close = 1 |
|
402 | res.will_close = 1 | |
366 | res.msg = httplib.HTTPMessage(cStringIO.StringIO()) |
|
403 | res.msg = httplib.HTTPMessage(cStringIO.StringIO()) | |
367 | return False |
|
404 | return False | |
368 |
|
405 | |||
369 | res.msg = httplib.HTTPMessage(res.fp) |
|
406 | res.msg = httplib.HTTPMessage(res.fp) | |
370 | res.msg.fp = None |
|
407 | res.msg.fp = None | |
371 |
|
408 | |||
372 | # are we using the chunked-style of transfer encoding? |
|
409 | # are we using the chunked-style of transfer encoding? | |
373 | trenc = res.msg.getheader('transfer-encoding') |
|
410 | trenc = res.msg.getheader('transfer-encoding') | |
374 | if trenc and trenc.lower() == "chunked": |
|
411 | if trenc and trenc.lower() == "chunked": | |
375 | res.chunked = 1 |
|
412 | res.chunked = 1 | |
376 | res.chunk_left = None |
|
413 | res.chunk_left = None | |
377 | else: |
|
414 | else: | |
378 | res.chunked = 0 |
|
415 | res.chunked = 0 | |
379 |
|
416 | |||
380 | # will the connection close at the end of the response? |
|
417 | # will the connection close at the end of the response? | |
381 | res.will_close = res._check_close() |
|
418 | res.will_close = res._check_close() | |
382 |
|
419 | |||
383 | # do we have a Content-Length? |
|
420 | # do we have a Content-Length? | |
384 | # NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked" |
|
421 | # NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked" | |
385 | length = res.msg.getheader('content-length') |
|
422 | length = res.msg.getheader('content-length') | |
386 | if length and not res.chunked: |
|
423 | if length and not res.chunked: | |
387 | try: |
|
424 | try: | |
388 | res.length = int(length) |
|
425 | res.length = int(length) | |
389 | except ValueError: |
|
426 | except ValueError: | |
390 | res.length = None |
|
427 | res.length = None | |
391 | else: |
|
428 | else: | |
392 | if res.length < 0: # ignore nonsensical negative lengths |
|
429 | if res.length < 0: # ignore nonsensical negative lengths | |
393 | res.length = None |
|
430 | res.length = None | |
394 | else: |
|
431 | else: | |
395 | res.length = None |
|
432 | res.length = None | |
396 |
|
433 | |||
397 | # does the body have a fixed length? (of zero) |
|
434 | # does the body have a fixed length? (of zero) | |
398 | if (status == httplib.NO_CONTENT or status == httplib.NOT_MODIFIED or |
|
435 | if (status == httplib.NO_CONTENT or status == httplib.NOT_MODIFIED or | |
399 | 100 <= status < 200 or # 1xx codes |
|
436 | 100 <= status < 200 or # 1xx codes | |
400 | res._method == 'HEAD'): |
|
437 | res._method == 'HEAD'): | |
401 | res.length = 0 |
|
438 | res.length = 0 | |
402 |
|
439 | |||
403 | # if the connection remains open, and we aren't using chunked, and |
|
440 | # if the connection remains open, and we aren't using chunked, and | |
404 | # a content-length was not provided, then assume that the connection |
|
441 | # a content-length was not provided, then assume that the connection | |
405 | # WILL close. |
|
442 | # WILL close. | |
406 | if (not res.will_close and |
|
443 | if (not res.will_close and | |
407 | not res.chunked and |
|
444 | not res.chunked and | |
408 | res.length is None): |
|
445 | res.length is None): | |
409 | res.will_close = 1 |
|
446 | res.will_close = 1 | |
410 |
|
447 | |||
411 | self.proxyres = res |
|
448 | self.proxyres = res | |
412 |
|
449 | |||
413 | return False |
|
450 | return False | |
414 |
|
451 | |||
415 | class httphandler(keepalive.HTTPHandler): |
|
452 | class httphandler(keepalive.HTTPHandler): | |
416 | def http_open(self, req): |
|
453 | def http_open(self, req): | |
417 | return self.do_open(httpconnection, req) |
|
454 | return self.do_open(httpconnection, req) | |
418 |
|
455 | |||
419 | def _start_transaction(self, h, req): |
|
456 | def _start_transaction(self, h, req): | |
420 | _generic_start_transaction(self, h, req) |
|
457 | _generic_start_transaction(self, h, req) | |
421 | return keepalive.HTTPHandler._start_transaction(self, h, req) |
|
458 | return keepalive.HTTPHandler._start_transaction(self, h, req) | |
422 |
|
459 | |||
423 | def __del__(self): |
|
460 | def __del__(self): | |
424 | self.close_all() |
|
461 | self.close_all() | |
425 |
|
462 | |||
426 | if has_https: |
|
463 | if has_https: | |
427 | class BetterHTTPS(httplib.HTTPSConnection): |
|
464 | class BetterHTTPS(httplib.HTTPSConnection): | |
428 | send = keepalive.safesend |
|
465 | send = keepalive.safesend | |
429 |
|
466 | |||
|
467 | def connect(self): | |||
|
468 | if hasattr(self, 'ui'): | |||
|
469 | cacerts = self.ui.config('web', 'cacerts') | |||
|
470 | else: | |||
|
471 | cacerts = None | |||
|
472 | ||||
|
473 | if cacerts: | |||
|
474 | sock = _create_connection((self.host, self.port)) | |||
|
475 | self.sock = _ssl_wrap_socket(sock, self.key_file, | |||
|
476 | self.cert_file, cert_reqs=CERT_REQUIRED, | |||
|
477 | ca_certs=cacerts) | |||
|
478 | self.ui.debug(_('server identity verification succeeded\n')) | |||
|
479 | else: | |||
|
480 | httplib.HTTPSConnection.connect(self) | |||
|
481 | ||||
430 | class httpsconnection(BetterHTTPS): |
|
482 | class httpsconnection(BetterHTTPS): | |
431 | response_class = keepalive.HTTPResponse |
|
483 | response_class = keepalive.HTTPResponse | |
432 | # must be able to send big bundle as stream. |
|
484 | # must be able to send big bundle as stream. | |
433 | send = _gen_sendfile(BetterHTTPS) |
|
485 | send = _gen_sendfile(BetterHTTPS) | |
434 | getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) |
|
486 | getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) | |
435 |
|
487 | |||
436 | def connect(self): |
|
488 | def connect(self): | |
437 | if self.realhost: # use CONNECT proxy |
|
489 | if self.realhost: # use CONNECT proxy | |
438 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
490 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
439 | self.sock.connect((self.host, self.port)) |
|
491 | self.sock.connect((self.host, self.port)) | |
440 | if _generic_proxytunnel(self): |
|
492 | if _generic_proxytunnel(self): | |
441 | self.sock = _ssl_wrap_socket(self.sock, self.cert_file, |
|
493 | self.sock = _ssl_wrap_socket(self.sock, self.cert_file, | |
442 | self.key_file) |
|
494 | self.key_file) | |
443 | else: |
|
495 | else: | |
444 | BetterHTTPS.connect(self) |
|
496 | BetterHTTPS.connect(self) | |
445 |
|
497 | |||
446 | class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): |
|
498 | class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): | |
447 | def __init__(self, ui): |
|
499 | def __init__(self, ui): | |
448 | keepalive.KeepAliveHandler.__init__(self) |
|
500 | keepalive.KeepAliveHandler.__init__(self) | |
449 | urllib2.HTTPSHandler.__init__(self) |
|
501 | urllib2.HTTPSHandler.__init__(self) | |
450 | self.ui = ui |
|
502 | self.ui = ui | |
451 | self.pwmgr = passwordmgr(self.ui) |
|
503 | self.pwmgr = passwordmgr(self.ui) | |
452 |
|
504 | |||
453 | def _start_transaction(self, h, req): |
|
505 | def _start_transaction(self, h, req): | |
454 | _generic_start_transaction(self, h, req) |
|
506 | _generic_start_transaction(self, h, req) | |
455 | return keepalive.KeepAliveHandler._start_transaction(self, h, req) |
|
507 | return keepalive.KeepAliveHandler._start_transaction(self, h, req) | |
456 |
|
508 | |||
457 | def https_open(self, req): |
|
509 | def https_open(self, req): | |
458 | self.auth = self.pwmgr.readauthtoken(req.get_full_url()) |
|
510 | self.auth = self.pwmgr.readauthtoken(req.get_full_url()) | |
459 | return self.do_open(self._makeconnection, req) |
|
511 | return self.do_open(self._makeconnection, req) | |
460 |
|
512 | |||
461 | def _makeconnection(self, host, port=None, *args, **kwargs): |
|
513 | def _makeconnection(self, host, port=None, *args, **kwargs): | |
462 | keyfile = None |
|
514 | keyfile = None | |
463 | certfile = None |
|
515 | certfile = None | |
464 |
|
516 | |||
465 | if args: # key_file |
|
517 | if args: # key_file | |
466 | keyfile = args.pop(0) |
|
518 | keyfile = args.pop(0) | |
467 | if args: # cert_file |
|
519 | if args: # cert_file | |
468 | certfile = args.pop(0) |
|
520 | certfile = args.pop(0) | |
469 |
|
521 | |||
470 | # if the user has specified different key/cert files in |
|
522 | # if the user has specified different key/cert files in | |
471 | # hgrc, we prefer these |
|
523 | # hgrc, we prefer these | |
472 | if self.auth and 'key' in self.auth and 'cert' in self.auth: |
|
524 | if self.auth and 'key' in self.auth and 'cert' in self.auth: | |
473 | keyfile = self.auth['key'] |
|
525 | keyfile = self.auth['key'] | |
474 | certfile = self.auth['cert'] |
|
526 | certfile = self.auth['cert'] | |
475 |
|
527 | |||
476 |
|
|
528 | conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs) | |
|
529 | conn.ui = self.ui | |||
|
530 | return conn | |||
477 |
|
531 | |||
478 | # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if |
|
532 | # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if | |
479 | # it doesn't know about the auth type requested. This can happen if |
|
533 | # it doesn't know about the auth type requested. This can happen if | |
480 | # somebody is using BasicAuth and types a bad password. |
|
534 | # somebody is using BasicAuth and types a bad password. | |
481 | class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): |
|
535 | class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): | |
482 | def http_error_auth_reqed(self, auth_header, host, req, headers): |
|
536 | def http_error_auth_reqed(self, auth_header, host, req, headers): | |
483 | try: |
|
537 | try: | |
484 | return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( |
|
538 | return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( | |
485 | self, auth_header, host, req, headers) |
|
539 | self, auth_header, host, req, headers) | |
486 | except ValueError, inst: |
|
540 | except ValueError, inst: | |
487 | arg = inst.args[0] |
|
541 | arg = inst.args[0] | |
488 | if arg.startswith("AbstractDigestAuthHandler doesn't know "): |
|
542 | if arg.startswith("AbstractDigestAuthHandler doesn't know "): | |
489 | return |
|
543 | return | |
490 | raise |
|
544 | raise | |
491 |
|
545 | |||
492 | def getauthinfo(path): |
|
546 | def getauthinfo(path): | |
493 | scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) |
|
547 | scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) | |
494 | if not urlpath: |
|
548 | if not urlpath: | |
495 | urlpath = '/' |
|
549 | urlpath = '/' | |
496 | if scheme != 'file': |
|
550 | if scheme != 'file': | |
497 | # XXX: why are we quoting the path again with some smart |
|
551 | # XXX: why are we quoting the path again with some smart | |
498 | # heuristic here? Anyway, it cannot be done with file:// |
|
552 | # heuristic here? Anyway, it cannot be done with file:// | |
499 | # urls since path encoding is os/fs dependent (see |
|
553 | # urls since path encoding is os/fs dependent (see | |
500 | # urllib.pathname2url() for details). |
|
554 | # urllib.pathname2url() for details). | |
501 | urlpath = quotepath(urlpath) |
|
555 | urlpath = quotepath(urlpath) | |
502 | host, port, user, passwd = netlocsplit(netloc) |
|
556 | host, port, user, passwd = netlocsplit(netloc) | |
503 |
|
557 | |||
504 | # urllib cannot handle URLs with embedded user or passwd |
|
558 | # urllib cannot handle URLs with embedded user or passwd | |
505 | url = urlparse.urlunsplit((scheme, netlocunsplit(host, port), |
|
559 | url = urlparse.urlunsplit((scheme, netlocunsplit(host, port), | |
506 | urlpath, query, frag)) |
|
560 | urlpath, query, frag)) | |
507 | if user: |
|
561 | if user: | |
508 | netloc = host |
|
562 | netloc = host | |
509 | if port: |
|
563 | if port: | |
510 | netloc += ':' + port |
|
564 | netloc += ':' + port | |
511 | # Python < 2.4.3 uses only the netloc to search for a password |
|
565 | # Python < 2.4.3 uses only the netloc to search for a password | |
512 | authinfo = (None, (url, netloc), user, passwd or '') |
|
566 | authinfo = (None, (url, netloc), user, passwd or '') | |
513 | else: |
|
567 | else: | |
514 | authinfo = None |
|
568 | authinfo = None | |
515 | return url, authinfo |
|
569 | return url, authinfo | |
516 |
|
570 | |||
517 | handlerfuncs = [] |
|
571 | handlerfuncs = [] | |
518 |
|
572 | |||
519 | def opener(ui, authinfo=None): |
|
573 | def opener(ui, authinfo=None): | |
520 | ''' |
|
574 | ''' | |
521 | construct an opener suitable for urllib2 |
|
575 | construct an opener suitable for urllib2 | |
522 | authinfo will be added to the password manager |
|
576 | authinfo will be added to the password manager | |
523 | ''' |
|
577 | ''' | |
524 | handlers = [httphandler()] |
|
578 | handlers = [httphandler()] | |
525 | if has_https: |
|
579 | if has_https: | |
526 | handlers.append(httpshandler(ui)) |
|
580 | handlers.append(httpshandler(ui)) | |
527 |
|
581 | |||
528 | handlers.append(proxyhandler(ui)) |
|
582 | handlers.append(proxyhandler(ui)) | |
529 |
|
583 | |||
530 | passmgr = passwordmgr(ui) |
|
584 | passmgr = passwordmgr(ui) | |
531 | if authinfo is not None: |
|
585 | if authinfo is not None: | |
532 | passmgr.add_password(*authinfo) |
|
586 | passmgr.add_password(*authinfo) | |
533 | user, passwd = authinfo[2:4] |
|
587 | user, passwd = authinfo[2:4] | |
534 | ui.debug('http auth: user %s, password %s\n' % |
|
588 | ui.debug('http auth: user %s, password %s\n' % | |
535 | (user, passwd and '*' * len(passwd) or 'not set')) |
|
589 | (user, passwd and '*' * len(passwd) or 'not set')) | |
536 |
|
590 | |||
537 | handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), |
|
591 | handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), | |
538 | httpdigestauthhandler(passmgr))) |
|
592 | httpdigestauthhandler(passmgr))) | |
539 | handlers.extend([h(ui, passmgr) for h in handlerfuncs]) |
|
593 | handlers.extend([h(ui, passmgr) for h in handlerfuncs]) | |
540 | opener = urllib2.build_opener(*handlers) |
|
594 | opener = urllib2.build_opener(*handlers) | |
541 |
|
595 | |||
542 | # 1.0 here is the _protocol_ version |
|
596 | # 1.0 here is the _protocol_ version | |
543 | opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] |
|
597 | opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] | |
544 | opener.addheaders.append(('Accept', 'application/mercurial-0.1')) |
|
598 | opener.addheaders.append(('Accept', 'application/mercurial-0.1')) | |
545 | return opener |
|
599 | return opener | |
546 |
|
600 | |||
547 | scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://') |
|
601 | scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://') | |
548 |
|
602 | |||
549 | def open(ui, url, data=None): |
|
603 | def open(ui, url, data=None): | |
550 | scheme = None |
|
604 | scheme = None | |
551 | m = scheme_re.search(url) |
|
605 | m = scheme_re.search(url) | |
552 | if m: |
|
606 | if m: | |
553 | scheme = m.group(1).lower() |
|
607 | scheme = m.group(1).lower() | |
554 | if not scheme: |
|
608 | if not scheme: | |
555 | path = util.normpath(os.path.abspath(url)) |
|
609 | path = util.normpath(os.path.abspath(url)) | |
556 | url = 'file://' + urllib.pathname2url(path) |
|
610 | url = 'file://' + urllib.pathname2url(path) | |
557 | authinfo = None |
|
611 | authinfo = None | |
558 | else: |
|
612 | else: | |
559 | url, authinfo = getauthinfo(url) |
|
613 | url, authinfo = getauthinfo(url) | |
560 | return opener(ui, authinfo).open(url, data) |
|
614 | return opener(ui, authinfo).open(url, data) |
General Comments 0
You need to be logged in to leave comments.
Login now