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