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