Show More
@@ -1,1710 +1,1720 b'' | |||
|
1 | 1 | The Mercurial system uses a set of configuration files to control |
|
2 | 2 | aspects of its behavior. |
|
3 | 3 | |
|
4 | 4 | The configuration files use a simple ini-file format. A configuration |
|
5 | 5 | file consists of sections, led by a ``[section]`` header and followed |
|
6 | 6 | by ``name = value`` entries:: |
|
7 | 7 | |
|
8 | 8 | [ui] |
|
9 | 9 | username = Firstname Lastname <firstname.lastname@example.net> |
|
10 | 10 | verbose = True |
|
11 | 11 | |
|
12 | 12 | The above entries will be referred to as ``ui.username`` and |
|
13 | 13 | ``ui.verbose``, respectively. See the Syntax section below. |
|
14 | 14 | |
|
15 | 15 | Files |
|
16 | 16 | ===== |
|
17 | 17 | |
|
18 | 18 | Mercurial reads configuration data from several files, if they exist. |
|
19 | 19 | These files do not exist by default and you will have to create the |
|
20 | 20 | appropriate configuration files yourself: global configuration like |
|
21 | 21 | the username setting is typically put into |
|
22 | 22 | ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local |
|
23 | 23 | configuration is put into the per-repository ``<repo>/.hg/hgrc`` file. |
|
24 | 24 | |
|
25 | 25 | The names of these files depend on the system on which Mercurial is |
|
26 | 26 | installed. ``*.rc`` files from a single directory are read in |
|
27 | 27 | alphabetical order, later ones overriding earlier ones. Where multiple |
|
28 | 28 | paths are given below, settings from earlier paths override later |
|
29 | 29 | ones. |
|
30 | 30 | |
|
31 | 31 | .. container:: verbose.unix |
|
32 | 32 | |
|
33 | 33 | On Unix, the following files are consulted: |
|
34 | 34 | |
|
35 | 35 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
36 | 36 | - ``$HOME/.hgrc`` (per-user) |
|
37 | 37 | - ``<install-root>/etc/mercurial/hgrc`` (per-installation) |
|
38 | 38 | - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation) |
|
39 | 39 | - ``/etc/mercurial/hgrc`` (per-system) |
|
40 | 40 | - ``/etc/mercurial/hgrc.d/*.rc`` (per-system) |
|
41 | - ``<internal>/default.d/*.rc`` (defaults) | |
|
41 | 42 | |
|
42 | 43 | .. container:: verbose.windows |
|
43 | 44 | |
|
44 | 45 | On Windows, the following files are consulted: |
|
45 | 46 | |
|
46 | 47 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
47 | 48 | - ``%USERPROFILE%\.hgrc`` (per-user) |
|
48 | 49 | - ``%USERPROFILE%\Mercurial.ini`` (per-user) |
|
49 | 50 | - ``%HOME%\.hgrc`` (per-user) |
|
50 | 51 | - ``%HOME%\Mercurial.ini`` (per-user) |
|
51 | 52 | - ``<install-dir>\Mercurial.ini`` (per-installation) |
|
52 | 53 | - ``<install-dir>\hgrc.d\*.rc`` (per-installation) |
|
53 | 54 | - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation) |
|
55 | - ``<internal>/default.d/*.rc`` (defaults) | |
|
54 | 56 | |
|
55 | 57 | .. note:: |
|
56 | 58 | |
|
57 | 59 | The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial`` |
|
58 | 60 | is used when running 32-bit Python on 64-bit Windows. |
|
59 | 61 | |
|
60 | 62 | .. container:: verbose.plan9 |
|
61 | 63 | |
|
62 | 64 | On Plan9, the following files are consulted: |
|
63 | 65 | |
|
64 | 66 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
65 | 67 | - ``$home/lib/hgrc`` (per-user) |
|
66 | 68 | - ``<install-root>/lib/mercurial/hgrc`` (per-installation) |
|
67 | 69 | - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation) |
|
68 | 70 | - ``/lib/mercurial/hgrc`` (per-system) |
|
69 | 71 | - ``/lib/mercurial/hgrc.d/*.rc`` (per-system) |
|
72 | - ``<internal>/default.d/*.rc`` (defaults) | |
|
70 | 73 | |
|
71 | 74 | Per-repository configuration options only apply in a |
|
72 | 75 | particular repository. This file is not version-controlled, and |
|
73 | 76 | will not get transferred during a "clone" operation. Options in |
|
74 | 77 | this file override options in all other configuration files. On |
|
75 | 78 | Plan 9 and Unix, most of this file will be ignored if it doesn't |
|
76 | 79 | belong to a trusted user or to a trusted group. See the documentation |
|
77 | 80 | for the ``[trusted]`` section below for more details. |
|
78 | 81 | |
|
79 | 82 | Per-user configuration file(s) are for the user running Mercurial. On |
|
80 | 83 | Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these |
|
81 | 84 | files apply to all Mercurial commands executed by this user in any |
|
82 | 85 | directory. Options in these files override per-system and per-installation |
|
83 | 86 | options. |
|
84 | 87 | |
|
85 | 88 | Per-installation configuration files are searched for in the |
|
86 | 89 | directory where Mercurial is installed. ``<install-root>`` is the |
|
87 | 90 | parent directory of the **hg** executable (or symlink) being run. For |
|
88 | 91 | example, if installed in ``/shared/tools/bin/hg``, Mercurial will look |
|
89 | 92 | in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply |
|
90 | 93 | to all Mercurial commands executed by any user in any directory. |
|
91 | 94 | |
|
92 | 95 | Per-installation configuration files are for the system on |
|
93 | 96 | which Mercurial is running. Options in these files apply to all |
|
94 | 97 | Mercurial commands executed by any user in any directory. Registry |
|
95 | 98 | keys contain PATH-like strings, every part of which must reference |
|
96 | 99 | a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will |
|
97 | 100 | be read. Mercurial checks each of these locations in the specified |
|
98 | 101 | order until one or more configuration files are detected. |
|
99 | 102 | |
|
100 | 103 | Per-system configuration files are for the system on which Mercurial |
|
101 | 104 | is running. Options in these files apply to all Mercurial commands |
|
102 | 105 | executed by any user in any directory. Options in these files |
|
103 | 106 | override per-installation options. |
|
104 | 107 | |
|
108 | Mercurial comes with some default configuration. The default configuration | |
|
109 | files are installed with Mercurial and will be overwritten on upgrades. Default | |
|
110 | configuration files should never be edited by users or administrators but can | |
|
111 | be overridden in other configuration files. So far the directory only contains | |
|
112 | merge tool configuration but packagers can also put other default configuration | |
|
113 | there. | |
|
114 | ||
|
105 | 115 | Syntax |
|
106 | 116 | ====== |
|
107 | 117 | |
|
108 | 118 | A configuration file consists of sections, led by a ``[section]`` header |
|
109 | 119 | and followed by ``name = value`` entries (sometimes called |
|
110 | 120 | ``configuration keys``):: |
|
111 | 121 | |
|
112 | 122 | [spam] |
|
113 | 123 | eggs=ham |
|
114 | 124 | green= |
|
115 | 125 | eggs |
|
116 | 126 | |
|
117 | 127 | Each line contains one entry. If the lines that follow are indented, |
|
118 | 128 | they are treated as continuations of that entry. Leading whitespace is |
|
119 | 129 | removed from values. Empty lines are skipped. Lines beginning with |
|
120 | 130 | ``#`` or ``;`` are ignored and may be used to provide comments. |
|
121 | 131 | |
|
122 | 132 | Configuration keys can be set multiple times, in which case Mercurial |
|
123 | 133 | will use the value that was configured last. As an example:: |
|
124 | 134 | |
|
125 | 135 | [spam] |
|
126 | 136 | eggs=large |
|
127 | 137 | ham=serrano |
|
128 | 138 | eggs=small |
|
129 | 139 | |
|
130 | 140 | This would set the configuration key named ``eggs`` to ``small``. |
|
131 | 141 | |
|
132 | 142 | It is also possible to define a section multiple times. A section can |
|
133 | 143 | be redefined on the same and/or on different configuration files. For |
|
134 | 144 | example:: |
|
135 | 145 | |
|
136 | 146 | [foo] |
|
137 | 147 | eggs=large |
|
138 | 148 | ham=serrano |
|
139 | 149 | eggs=small |
|
140 | 150 | |
|
141 | 151 | [bar] |
|
142 | 152 | eggs=ham |
|
143 | 153 | green= |
|
144 | 154 | eggs |
|
145 | 155 | |
|
146 | 156 | [foo] |
|
147 | 157 | ham=prosciutto |
|
148 | 158 | eggs=medium |
|
149 | 159 | bread=toasted |
|
150 | 160 | |
|
151 | 161 | This would set the ``eggs``, ``ham``, and ``bread`` configuration keys |
|
152 | 162 | of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``, |
|
153 | 163 | respectively. As you can see there only thing that matters is the last |
|
154 | 164 | value that was set for each of the configuration keys. |
|
155 | 165 | |
|
156 | 166 | If a configuration key is set multiple times in different |
|
157 | 167 | configuration files the final value will depend on the order in which |
|
158 | 168 | the different configuration files are read, with settings from earlier |
|
159 | 169 | paths overriding later ones as described on the ``Files`` section |
|
160 | 170 | above. |
|
161 | 171 | |
|
162 | 172 | A line of the form ``%include file`` will include ``file`` into the |
|
163 | 173 | current configuration file. The inclusion is recursive, which means |
|
164 | 174 | that included files can include other files. Filenames are relative to |
|
165 | 175 | the configuration file in which the ``%include`` directive is found. |
|
166 | 176 | Environment variables and ``~user`` constructs are expanded in |
|
167 | 177 | ``file``. This lets you do something like:: |
|
168 | 178 | |
|
169 | 179 | %include ~/.hgrc.d/$HOST.rc |
|
170 | 180 | |
|
171 | 181 | to include a different configuration file on each computer you use. |
|
172 | 182 | |
|
173 | 183 | A line with ``%unset name`` will remove ``name`` from the current |
|
174 | 184 | section, if it has been set previously. |
|
175 | 185 | |
|
176 | 186 | The values are either free-form text strings, lists of text strings, |
|
177 | 187 | or Boolean values. Boolean values can be set to true using any of "1", |
|
178 | 188 | "yes", "true", or "on" and to false using "0", "no", "false", or "off" |
|
179 | 189 | (all case insensitive). |
|
180 | 190 | |
|
181 | 191 | List values are separated by whitespace or comma, except when values are |
|
182 | 192 | placed in double quotation marks:: |
|
183 | 193 | |
|
184 | 194 | allow_read = "John Doe, PhD", brian, betty |
|
185 | 195 | |
|
186 | 196 | Quotation marks can be escaped by prefixing them with a backslash. Only |
|
187 | 197 | quotation marks at the beginning of a word is counted as a quotation |
|
188 | 198 | (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``). |
|
189 | 199 | |
|
190 | 200 | Sections |
|
191 | 201 | ======== |
|
192 | 202 | |
|
193 | 203 | This section describes the different sections that may appear in a |
|
194 | 204 | Mercurial configuration file, the purpose of each section, its possible |
|
195 | 205 | keys, and their possible values. |
|
196 | 206 | |
|
197 | 207 | ``alias`` |
|
198 | 208 | --------- |
|
199 | 209 | |
|
200 | 210 | Defines command aliases. |
|
201 | 211 | Aliases allow you to define your own commands in terms of other |
|
202 | 212 | commands (or aliases), optionally including arguments. Positional |
|
203 | 213 | arguments in the form of ``$1``, ``$2``, etc in the alias definition |
|
204 | 214 | are expanded by Mercurial before execution. Positional arguments not |
|
205 | 215 | already used by ``$N`` in the definition are put at the end of the |
|
206 | 216 | command to be executed. |
|
207 | 217 | |
|
208 | 218 | Alias definitions consist of lines of the form:: |
|
209 | 219 | |
|
210 | 220 | <alias> = <command> [<argument>]... |
|
211 | 221 | |
|
212 | 222 | For example, this definition:: |
|
213 | 223 | |
|
214 | 224 | latest = log --limit 5 |
|
215 | 225 | |
|
216 | 226 | creates a new command ``latest`` that shows only the five most recent |
|
217 | 227 | changesets. You can define subsequent aliases using earlier ones:: |
|
218 | 228 | |
|
219 | 229 | stable5 = latest -b stable |
|
220 | 230 | |
|
221 | 231 | .. note:: |
|
222 | 232 | |
|
223 | 233 | It is possible to create aliases with the same names as |
|
224 | 234 | existing commands, which will then override the original |
|
225 | 235 | definitions. This is almost always a bad idea! |
|
226 | 236 | |
|
227 | 237 | An alias can start with an exclamation point (``!``) to make it a |
|
228 | 238 | shell alias. A shell alias is executed with the shell and will let you |
|
229 | 239 | run arbitrary commands. As an example, :: |
|
230 | 240 | |
|
231 | 241 | echo = !echo $@ |
|
232 | 242 | |
|
233 | 243 | will let you do ``hg echo foo`` to have ``foo`` printed in your |
|
234 | 244 | terminal. A better example might be:: |
|
235 | 245 | |
|
236 | 246 | purge = !$HG status --no-status --unknown -0 | xargs -0 rm |
|
237 | 247 | |
|
238 | 248 | which will make ``hg purge`` delete all unknown files in the |
|
239 | 249 | repository in the same manner as the purge extension. |
|
240 | 250 | |
|
241 | 251 | Positional arguments like ``$1``, ``$2``, etc. in the alias definition |
|
242 | 252 | expand to the command arguments. Unmatched arguments are |
|
243 | 253 | removed. ``$0`` expands to the alias name and ``$@`` expands to all |
|
244 | 254 | arguments separated by a space. ``"$@"`` (with quotes) expands to all |
|
245 | 255 | arguments quoted individually and separated by a space. These expansions |
|
246 | 256 | happen before the command is passed to the shell. |
|
247 | 257 | |
|
248 | 258 | Shell aliases are executed in an environment where ``$HG`` expands to |
|
249 | 259 | the path of the Mercurial that was used to execute the alias. This is |
|
250 | 260 | useful when you want to call further Mercurial commands in a shell |
|
251 | 261 | alias, as was done above for the purge alias. In addition, |
|
252 | 262 | ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg |
|
253 | 263 | echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``. |
|
254 | 264 | |
|
255 | 265 | .. note:: |
|
256 | 266 | |
|
257 | 267 | Some global configuration options such as ``-R`` are |
|
258 | 268 | processed before shell aliases and will thus not be passed to |
|
259 | 269 | aliases. |
|
260 | 270 | |
|
261 | 271 | |
|
262 | 272 | ``annotate`` |
|
263 | 273 | ------------ |
|
264 | 274 | |
|
265 | 275 | Settings used when displaying file annotations. All values are |
|
266 | 276 | Booleans and default to False. See ``diff`` section for related |
|
267 | 277 | options for the diff command. |
|
268 | 278 | |
|
269 | 279 | ``ignorews`` |
|
270 | 280 | Ignore white space when comparing lines. |
|
271 | 281 | |
|
272 | 282 | ``ignorewsamount`` |
|
273 | 283 | Ignore changes in the amount of white space. |
|
274 | 284 | |
|
275 | 285 | ``ignoreblanklines`` |
|
276 | 286 | Ignore changes whose lines are all blank. |
|
277 | 287 | |
|
278 | 288 | |
|
279 | 289 | ``auth`` |
|
280 | 290 | -------- |
|
281 | 291 | |
|
282 | 292 | Authentication credentials for HTTP authentication. This section |
|
283 | 293 | allows you to store usernames and passwords for use when logging |
|
284 | 294 | *into* HTTP servers. See the ``[web]`` configuration section if |
|
285 | 295 | you want to configure *who* can login to your HTTP server. |
|
286 | 296 | |
|
287 | 297 | Each line has the following format:: |
|
288 | 298 | |
|
289 | 299 | <name>.<argument> = <value> |
|
290 | 300 | |
|
291 | 301 | where ``<name>`` is used to group arguments into authentication |
|
292 | 302 | entries. Example:: |
|
293 | 303 | |
|
294 | 304 | foo.prefix = hg.intevation.org/mercurial |
|
295 | 305 | foo.username = foo |
|
296 | 306 | foo.password = bar |
|
297 | 307 | foo.schemes = http https |
|
298 | 308 | |
|
299 | 309 | bar.prefix = secure.example.org |
|
300 | 310 | bar.key = path/to/file.key |
|
301 | 311 | bar.cert = path/to/file.cert |
|
302 | 312 | bar.schemes = https |
|
303 | 313 | |
|
304 | 314 | Supported arguments: |
|
305 | 315 | |
|
306 | 316 | ``prefix`` |
|
307 | 317 | Either ``*`` or a URI prefix with or without the scheme part. |
|
308 | 318 | The authentication entry with the longest matching prefix is used |
|
309 | 319 | (where ``*`` matches everything and counts as a match of length |
|
310 | 320 | 1). If the prefix doesn't include a scheme, the match is performed |
|
311 | 321 | against the URI with its scheme stripped as well, and the schemes |
|
312 | 322 | argument, q.v., is then subsequently consulted. |
|
313 | 323 | |
|
314 | 324 | ``username`` |
|
315 | 325 | Optional. Username to authenticate with. If not given, and the |
|
316 | 326 | remote site requires basic or digest authentication, the user will |
|
317 | 327 | be prompted for it. Environment variables are expanded in the |
|
318 | 328 | username letting you do ``foo.username = $USER``. If the URI |
|
319 | 329 | includes a username, only ``[auth]`` entries with a matching |
|
320 | 330 | username or without a username will be considered. |
|
321 | 331 | |
|
322 | 332 | ``password`` |
|
323 | 333 | Optional. Password to authenticate with. If not given, and the |
|
324 | 334 | remote site requires basic or digest authentication, the user |
|
325 | 335 | will be prompted for it. |
|
326 | 336 | |
|
327 | 337 | ``key`` |
|
328 | 338 | Optional. PEM encoded client certificate key file. Environment |
|
329 | 339 | variables are expanded in the filename. |
|
330 | 340 | |
|
331 | 341 | ``cert`` |
|
332 | 342 | Optional. PEM encoded client certificate chain file. Environment |
|
333 | 343 | variables are expanded in the filename. |
|
334 | 344 | |
|
335 | 345 | ``schemes`` |
|
336 | 346 | Optional. Space separated list of URI schemes to use this |
|
337 | 347 | authentication entry with. Only used if the prefix doesn't include |
|
338 | 348 | a scheme. Supported schemes are http and https. They will match |
|
339 | 349 | static-http and static-https respectively, as well. |
|
340 | 350 | Default: https. |
|
341 | 351 | |
|
342 | 352 | If no suitable authentication entry is found, the user is prompted |
|
343 | 353 | for credentials as usual if required by the remote. |
|
344 | 354 | |
|
345 | 355 | |
|
346 | 356 | ``committemplate`` |
|
347 | 357 | ------------------ |
|
348 | 358 | |
|
349 | 359 | ``changeset`` configuration in this section is used as the template to |
|
350 | 360 | customize the text shown in the editor when committing. |
|
351 | 361 | |
|
352 | 362 | In addition to pre-defined template keywords, commit log specific one |
|
353 | 363 | below can be used for customization: |
|
354 | 364 | |
|
355 | 365 | ``extramsg`` |
|
356 | 366 | String: Extra message (typically 'Leave message empty to abort |
|
357 | 367 | commit.'). This may be changed by some commands or extensions. |
|
358 | 368 | |
|
359 | 369 | For example, the template configuration below shows as same text as |
|
360 | 370 | one shown by default:: |
|
361 | 371 | |
|
362 | 372 | [committemplate] |
|
363 | 373 | changeset = {desc}\n\n |
|
364 | 374 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
365 | 375 | HG: {extramsg} |
|
366 | 376 | HG: -- |
|
367 | 377 | HG: user: {author}\n{ifeq(p2rev, "-1", "", |
|
368 | 378 | "HG: branch merge\n") |
|
369 | 379 | }HG: branch '{branch}'\n{if(currentbookmark, |
|
370 | 380 | "HG: bookmark '{currentbookmark}'\n") }{subrepos % |
|
371 | 381 | "HG: subrepo {subrepo}\n" }{file_adds % |
|
372 | 382 | "HG: added {file}\n" }{file_mods % |
|
373 | 383 | "HG: changed {file}\n" }{file_dels % |
|
374 | 384 | "HG: removed {file}\n" }{if(files, "", |
|
375 | 385 | "HG: no files changed\n")} |
|
376 | 386 | |
|
377 | 387 | .. note:: |
|
378 | 388 | |
|
379 | 389 | For some problematic encodings (see :hg:`help win32mbcs` for |
|
380 | 390 | detail), this customization should be configured carefully, to |
|
381 | 391 | avoid showing broken characters. |
|
382 | 392 | |
|
383 | 393 | For example, if multibyte character ending with backslash (0x5c) is |
|
384 | 394 | followed by ASCII character 'n' in the customized template, |
|
385 | 395 | sequence of backslash and 'n' is treated as line-feed unexpectedly |
|
386 | 396 | (and multibyte character is broken, too). |
|
387 | 397 | |
|
388 | 398 | Customized template is used for commands below (``--edit`` may be |
|
389 | 399 | required): |
|
390 | 400 | |
|
391 | 401 | - :hg:`backout` |
|
392 | 402 | - :hg:`commit` |
|
393 | 403 | - :hg:`fetch` (for merge commit only) |
|
394 | 404 | - :hg:`graft` |
|
395 | 405 | - :hg:`histedit` |
|
396 | 406 | - :hg:`import` |
|
397 | 407 | - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh` |
|
398 | 408 | - :hg:`rebase` |
|
399 | 409 | - :hg:`shelve` |
|
400 | 410 | - :hg:`sign` |
|
401 | 411 | - :hg:`tag` |
|
402 | 412 | - :hg:`transplant` |
|
403 | 413 | |
|
404 | 414 | Configuring items below instead of ``changeset`` allows showing |
|
405 | 415 | customized message only for specific actions, or showing different |
|
406 | 416 | messages for each action. |
|
407 | 417 | |
|
408 | 418 | - ``changeset.backout`` for :hg:`backout` |
|
409 | 419 | - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges |
|
410 | 420 | - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other |
|
411 | 421 | - ``changeset.commit.normal.merge`` for :hg:`commit` on merges |
|
412 | 422 | - ``changeset.commit.normal.normal`` for :hg:`commit` on other |
|
413 | 423 | - ``changeset.fetch`` for :hg:`fetch` (impling merge commit) |
|
414 | 424 | - ``changeset.gpg.sign`` for :hg:`sign` |
|
415 | 425 | - ``changeset.graft`` for :hg:`graft` |
|
416 | 426 | - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit` |
|
417 | 427 | - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit` |
|
418 | 428 | - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit` |
|
419 | 429 | - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit` |
|
420 | 430 | - ``changeset.import.bypass`` for :hg:`import --bypass` |
|
421 | 431 | - ``changeset.import.normal.merge`` for :hg:`import` on merges |
|
422 | 432 | - ``changeset.import.normal.normal`` for :hg:`import` on other |
|
423 | 433 | - ``changeset.mq.qnew`` for :hg:`qnew` |
|
424 | 434 | - ``changeset.mq.qfold`` for :hg:`qfold` |
|
425 | 435 | - ``changeset.mq.qrefresh`` for :hg:`qrefresh` |
|
426 | 436 | - ``changeset.rebase.collapse`` for :hg:`rebase --collapse` |
|
427 | 437 | - ``changeset.rebase.merge`` for :hg:`rebase` on merges |
|
428 | 438 | - ``changeset.rebase.normal`` for :hg:`rebase` on other |
|
429 | 439 | - ``changeset.shelve.shelve`` for :hg:`shelve` |
|
430 | 440 | - ``changeset.tag.add`` for :hg:`tag` without ``--remove`` |
|
431 | 441 | - ``changeset.tag.remove`` for :hg:`tag --remove` |
|
432 | 442 | - ``changeset.transplant.merge`` for :hg:`transplant` on merges |
|
433 | 443 | - ``changeset.transplant.normal`` for :hg:`transplant` on other |
|
434 | 444 | |
|
435 | 445 | These dot-separated lists of names are treated as hierarchical ones. |
|
436 | 446 | For example, ``changeset.tag.remove`` customizes the commit message |
|
437 | 447 | only for :hg:`tag --remove`, but ``changeset.tag`` customizes the |
|
438 | 448 | commit message for :hg:`tag` regardless of ``--remove`` option. |
|
439 | 449 | |
|
440 | 450 | At the external editor invocation for committing, corresponding |
|
441 | 451 | dot-separated list of names without ``changeset.`` prefix |
|
442 | 452 | (e.g. ``commit.normal.normal``) is in ``HGEDITFORM`` environment variable. |
|
443 | 453 | |
|
444 | 454 | In this section, items other than ``changeset`` can be referred from |
|
445 | 455 | others. For example, the configuration to list committed files up |
|
446 | 456 | below can be referred as ``{listupfiles}``:: |
|
447 | 457 | |
|
448 | 458 | [committemplate] |
|
449 | 459 | listupfiles = {file_adds % |
|
450 | 460 | "HG: added {file}\n" }{file_mods % |
|
451 | 461 | "HG: changed {file}\n" }{file_dels % |
|
452 | 462 | "HG: removed {file}\n" }{if(files, "", |
|
453 | 463 | "HG: no files changed\n")} |
|
454 | 464 | |
|
455 | 465 | ``decode/encode`` |
|
456 | 466 | ----------------- |
|
457 | 467 | |
|
458 | 468 | Filters for transforming files on checkout/checkin. This would |
|
459 | 469 | typically be used for newline processing or other |
|
460 | 470 | localization/canonicalization of files. |
|
461 | 471 | |
|
462 | 472 | Filters consist of a filter pattern followed by a filter command. |
|
463 | 473 | Filter patterns are globs by default, rooted at the repository root. |
|
464 | 474 | For example, to match any file ending in ``.txt`` in the root |
|
465 | 475 | directory only, use the pattern ``*.txt``. To match any file ending |
|
466 | 476 | in ``.c`` anywhere in the repository, use the pattern ``**.c``. |
|
467 | 477 | For each file only the first matching filter applies. |
|
468 | 478 | |
|
469 | 479 | The filter command can start with a specifier, either ``pipe:`` or |
|
470 | 480 | ``tempfile:``. If no specifier is given, ``pipe:`` is used by default. |
|
471 | 481 | |
|
472 | 482 | A ``pipe:`` command must accept data on stdin and return the transformed |
|
473 | 483 | data on stdout. |
|
474 | 484 | |
|
475 | 485 | Pipe example:: |
|
476 | 486 | |
|
477 | 487 | [encode] |
|
478 | 488 | # uncompress gzip files on checkin to improve delta compression |
|
479 | 489 | # note: not necessarily a good idea, just an example |
|
480 | 490 | *.gz = pipe: gunzip |
|
481 | 491 | |
|
482 | 492 | [decode] |
|
483 | 493 | # recompress gzip files when writing them to the working dir (we |
|
484 | 494 | # can safely omit "pipe:", because it's the default) |
|
485 | 495 | *.gz = gzip |
|
486 | 496 | |
|
487 | 497 | A ``tempfile:`` command is a template. The string ``INFILE`` is replaced |
|
488 | 498 | with the name of a temporary file that contains the data to be |
|
489 | 499 | filtered by the command. The string ``OUTFILE`` is replaced with the name |
|
490 | 500 | of an empty temporary file, where the filtered data must be written by |
|
491 | 501 | the command. |
|
492 | 502 | |
|
493 | 503 | .. note:: |
|
494 | 504 | |
|
495 | 505 | The tempfile mechanism is recommended for Windows systems, |
|
496 | 506 | where the standard shell I/O redirection operators often have |
|
497 | 507 | strange effects and may corrupt the contents of your files. |
|
498 | 508 | |
|
499 | 509 | This filter mechanism is used internally by the ``eol`` extension to |
|
500 | 510 | translate line ending characters between Windows (CRLF) and Unix (LF) |
|
501 | 511 | format. We suggest you use the ``eol`` extension for convenience. |
|
502 | 512 | |
|
503 | 513 | |
|
504 | 514 | ``defaults`` |
|
505 | 515 | ------------ |
|
506 | 516 | |
|
507 | 517 | (defaults are deprecated. Don't use them. Use aliases instead) |
|
508 | 518 | |
|
509 | 519 | Use the ``[defaults]`` section to define command defaults, i.e. the |
|
510 | 520 | default options/arguments to pass to the specified commands. |
|
511 | 521 | |
|
512 | 522 | The following example makes :hg:`log` run in verbose mode, and |
|
513 | 523 | :hg:`status` show only the modified files, by default:: |
|
514 | 524 | |
|
515 | 525 | [defaults] |
|
516 | 526 | log = -v |
|
517 | 527 | status = -m |
|
518 | 528 | |
|
519 | 529 | The actual commands, instead of their aliases, must be used when |
|
520 | 530 | defining command defaults. The command defaults will also be applied |
|
521 | 531 | to the aliases of the commands defined. |
|
522 | 532 | |
|
523 | 533 | |
|
524 | 534 | ``diff`` |
|
525 | 535 | -------- |
|
526 | 536 | |
|
527 | 537 | Settings used when displaying diffs. Everything except for ``unified`` |
|
528 | 538 | is a Boolean and defaults to False. See ``annotate`` section for |
|
529 | 539 | related options for the annotate command. |
|
530 | 540 | |
|
531 | 541 | ``git`` |
|
532 | 542 | Use git extended diff format. |
|
533 | 543 | |
|
534 | 544 | ``nobinary`` |
|
535 | 545 | Omit git binary patches. |
|
536 | 546 | |
|
537 | 547 | ``nodates`` |
|
538 | 548 | Don't include dates in diff headers. |
|
539 | 549 | |
|
540 | 550 | ``showfunc`` |
|
541 | 551 | Show which function each change is in. |
|
542 | 552 | |
|
543 | 553 | ``ignorews`` |
|
544 | 554 | Ignore white space when comparing lines. |
|
545 | 555 | |
|
546 | 556 | ``ignorewsamount`` |
|
547 | 557 | Ignore changes in the amount of white space. |
|
548 | 558 | |
|
549 | 559 | ``ignoreblanklines`` |
|
550 | 560 | Ignore changes whose lines are all blank. |
|
551 | 561 | |
|
552 | 562 | ``unified`` |
|
553 | 563 | Number of lines of context to show. |
|
554 | 564 | |
|
555 | 565 | ``email`` |
|
556 | 566 | --------- |
|
557 | 567 | |
|
558 | 568 | Settings for extensions that send email messages. |
|
559 | 569 | |
|
560 | 570 | ``from`` |
|
561 | 571 | Optional. Email address to use in "From" header and SMTP envelope |
|
562 | 572 | of outgoing messages. |
|
563 | 573 | |
|
564 | 574 | ``to`` |
|
565 | 575 | Optional. Comma-separated list of recipients' email addresses. |
|
566 | 576 | |
|
567 | 577 | ``cc`` |
|
568 | 578 | Optional. Comma-separated list of carbon copy recipients' |
|
569 | 579 | email addresses. |
|
570 | 580 | |
|
571 | 581 | ``bcc`` |
|
572 | 582 | Optional. Comma-separated list of blind carbon copy recipients' |
|
573 | 583 | email addresses. |
|
574 | 584 | |
|
575 | 585 | ``method`` |
|
576 | 586 | Optional. Method to use to send email messages. If value is ``smtp`` |
|
577 | 587 | (default), use SMTP (see the ``[smtp]`` section for configuration). |
|
578 | 588 | Otherwise, use as name of program to run that acts like sendmail |
|
579 | 589 | (takes ``-f`` option for sender, list of recipients on command line, |
|
580 | 590 | message on stdin). Normally, setting this to ``sendmail`` or |
|
581 | 591 | ``/usr/sbin/sendmail`` is enough to use sendmail to send messages. |
|
582 | 592 | |
|
583 | 593 | ``charsets`` |
|
584 | 594 | Optional. Comma-separated list of character sets considered |
|
585 | 595 | convenient for recipients. Addresses, headers, and parts not |
|
586 | 596 | containing patches of outgoing messages will be encoded in the |
|
587 | 597 | first character set to which conversion from local encoding |
|
588 | 598 | (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct |
|
589 | 599 | conversion fails, the text in question is sent as is. Defaults to |
|
590 | 600 | empty (explicit) list. |
|
591 | 601 | |
|
592 | 602 | Order of outgoing email character sets: |
|
593 | 603 | |
|
594 | 604 | 1. ``us-ascii``: always first, regardless of settings |
|
595 | 605 | 2. ``email.charsets``: in order given by user |
|
596 | 606 | 3. ``ui.fallbackencoding``: if not in email.charsets |
|
597 | 607 | 4. ``$HGENCODING``: if not in email.charsets |
|
598 | 608 | 5. ``utf-8``: always last, regardless of settings |
|
599 | 609 | |
|
600 | 610 | Email example:: |
|
601 | 611 | |
|
602 | 612 | [email] |
|
603 | 613 | from = Joseph User <joe.user@example.com> |
|
604 | 614 | method = /usr/sbin/sendmail |
|
605 | 615 | # charsets for western Europeans |
|
606 | 616 | # us-ascii, utf-8 omitted, as they are tried first and last |
|
607 | 617 | charsets = iso-8859-1, iso-8859-15, windows-1252 |
|
608 | 618 | |
|
609 | 619 | |
|
610 | 620 | ``extensions`` |
|
611 | 621 | -------------- |
|
612 | 622 | |
|
613 | 623 | Mercurial has an extension mechanism for adding new features. To |
|
614 | 624 | enable an extension, create an entry for it in this section. |
|
615 | 625 | |
|
616 | 626 | If you know that the extension is already in Python's search path, |
|
617 | 627 | you can give the name of the module, followed by ``=``, with nothing |
|
618 | 628 | after the ``=``. |
|
619 | 629 | |
|
620 | 630 | Otherwise, give a name that you choose, followed by ``=``, followed by |
|
621 | 631 | the path to the ``.py`` file (including the file name extension) that |
|
622 | 632 | defines the extension. |
|
623 | 633 | |
|
624 | 634 | To explicitly disable an extension that is enabled in an hgrc of |
|
625 | 635 | broader scope, prepend its path with ``!``, as in ``foo = !/ext/path`` |
|
626 | 636 | or ``foo = !`` when path is not supplied. |
|
627 | 637 | |
|
628 | 638 | Example for ``~/.hgrc``:: |
|
629 | 639 | |
|
630 | 640 | [extensions] |
|
631 | 641 | # (the progress extension will get loaded from Mercurial's path) |
|
632 | 642 | progress = |
|
633 | 643 | # (this extension will get loaded from the file specified) |
|
634 | 644 | myfeature = ~/.hgext/myfeature.py |
|
635 | 645 | |
|
636 | 646 | |
|
637 | 647 | ``format`` |
|
638 | 648 | ---------- |
|
639 | 649 | |
|
640 | 650 | ``usestore`` |
|
641 | 651 | Enable or disable the "store" repository format which improves |
|
642 | 652 | compatibility with systems that fold case or otherwise mangle |
|
643 | 653 | filenames. Enabled by default. Disabling this option will allow |
|
644 | 654 | you to store longer filenames in some situations at the expense of |
|
645 | 655 | compatibility and ensures that the on-disk format of newly created |
|
646 | 656 | repositories will be compatible with Mercurial before version 0.9.4. |
|
647 | 657 | |
|
648 | 658 | ``usefncache`` |
|
649 | 659 | Enable or disable the "fncache" repository format which enhances |
|
650 | 660 | the "store" repository format (which has to be enabled to use |
|
651 | 661 | fncache) to allow longer filenames and avoids using Windows |
|
652 | 662 | reserved names, e.g. "nul". Enabled by default. Disabling this |
|
653 | 663 | option ensures that the on-disk format of newly created |
|
654 | 664 | repositories will be compatible with Mercurial before version 1.1. |
|
655 | 665 | |
|
656 | 666 | ``dotencode`` |
|
657 | 667 | Enable or disable the "dotencode" repository format which enhances |
|
658 | 668 | the "fncache" repository format (which has to be enabled to use |
|
659 | 669 | dotencode) to avoid issues with filenames starting with ._ on |
|
660 | 670 | Mac OS X and spaces on Windows. Enabled by default. Disabling this |
|
661 | 671 | option ensures that the on-disk format of newly created |
|
662 | 672 | repositories will be compatible with Mercurial before version 1.7. |
|
663 | 673 | |
|
664 | 674 | ``graph`` |
|
665 | 675 | --------- |
|
666 | 676 | |
|
667 | 677 | Web graph view configuration. This section let you change graph |
|
668 | 678 | elements display properties by branches, for instance to make the |
|
669 | 679 | ``default`` branch stand out. |
|
670 | 680 | |
|
671 | 681 | Each line has the following format:: |
|
672 | 682 | |
|
673 | 683 | <branch>.<argument> = <value> |
|
674 | 684 | |
|
675 | 685 | where ``<branch>`` is the name of the branch being |
|
676 | 686 | customized. Example:: |
|
677 | 687 | |
|
678 | 688 | [graph] |
|
679 | 689 | # 2px width |
|
680 | 690 | default.width = 2 |
|
681 | 691 | # red color |
|
682 | 692 | default.color = FF0000 |
|
683 | 693 | |
|
684 | 694 | Supported arguments: |
|
685 | 695 | |
|
686 | 696 | ``width`` |
|
687 | 697 | Set branch edges width in pixels. |
|
688 | 698 | |
|
689 | 699 | ``color`` |
|
690 | 700 | Set branch edges color in hexadecimal RGB notation. |
|
691 | 701 | |
|
692 | 702 | ``hooks`` |
|
693 | 703 | --------- |
|
694 | 704 | |
|
695 | 705 | Commands or Python functions that get automatically executed by |
|
696 | 706 | various actions such as starting or finishing a commit. Multiple |
|
697 | 707 | hooks can be run for the same action by appending a suffix to the |
|
698 | 708 | action. Overriding a site-wide hook can be done by changing its |
|
699 | 709 | value or setting it to an empty string. Hooks can be prioritized |
|
700 | 710 | by adding a prefix of ``priority`` to the hook name on a new line |
|
701 | 711 | and setting the priority. The default priority is 0 if |
|
702 | 712 | not specified. |
|
703 | 713 | |
|
704 | 714 | Example ``.hg/hgrc``:: |
|
705 | 715 | |
|
706 | 716 | [hooks] |
|
707 | 717 | # update working directory after adding changesets |
|
708 | 718 | changegroup.update = hg update |
|
709 | 719 | # do not use the site-wide hook |
|
710 | 720 | incoming = |
|
711 | 721 | incoming.email = /my/email/hook |
|
712 | 722 | incoming.autobuild = /my/build/hook |
|
713 | 723 | # force autobuild hook to run before other incoming hooks |
|
714 | 724 | priority.incoming.autobuild = 1 |
|
715 | 725 | |
|
716 | 726 | Most hooks are run with environment variables set that give useful |
|
717 | 727 | additional information. For each hook below, the environment |
|
718 | 728 | variables it is passed are listed with names of the form ``$HG_foo``. |
|
719 | 729 | |
|
720 | 730 | ``changegroup`` |
|
721 | 731 | Run after a changegroup has been added via push, pull or unbundle. |
|
722 | 732 | ID of the first new changeset is in ``$HG_NODE``. URL from which |
|
723 | 733 | changes came is in ``$HG_URL``. |
|
724 | 734 | |
|
725 | 735 | ``commit`` |
|
726 | 736 | Run after a changeset has been created in the local repository. ID |
|
727 | 737 | of the newly created changeset is in ``$HG_NODE``. Parent changeset |
|
728 | 738 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
729 | 739 | |
|
730 | 740 | ``incoming`` |
|
731 | 741 | Run after a changeset has been pulled, pushed, or unbundled into |
|
732 | 742 | the local repository. The ID of the newly arrived changeset is in |
|
733 | 743 | ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``. |
|
734 | 744 | |
|
735 | 745 | ``outgoing`` |
|
736 | 746 | Run after sending changes from local repository to another. ID of |
|
737 | 747 | first changeset sent is in ``$HG_NODE``. Source of operation is in |
|
738 | 748 | ``$HG_SOURCE``; see "preoutgoing" hook for description. |
|
739 | 749 | |
|
740 | 750 | ``post-<command>`` |
|
741 | 751 | Run after successful invocations of the associated command. The |
|
742 | 752 | contents of the command line are passed as ``$HG_ARGS`` and the result |
|
743 | 753 | code in ``$HG_RESULT``. Parsed command line arguments are passed as |
|
744 | 754 | ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of |
|
745 | 755 | the python data internally passed to <command>. ``$HG_OPTS`` is a |
|
746 | 756 | dictionary of options (with unspecified options set to their defaults). |
|
747 | 757 | ``$HG_PATS`` is a list of arguments. Hook failure is ignored. |
|
748 | 758 | |
|
749 | 759 | ``pre-<command>`` |
|
750 | 760 | Run before executing the associated command. The contents of the |
|
751 | 761 | command line are passed as ``$HG_ARGS``. Parsed command line arguments |
|
752 | 762 | are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string |
|
753 | 763 | representations of the data internally passed to <command>. ``$HG_OPTS`` |
|
754 | 764 | is a dictionary of options (with unspecified options set to their |
|
755 | 765 | defaults). ``$HG_PATS`` is a list of arguments. If the hook returns |
|
756 | 766 | failure, the command doesn't execute and Mercurial returns the failure |
|
757 | 767 | code. |
|
758 | 768 | |
|
759 | 769 | ``prechangegroup`` |
|
760 | 770 | Run before a changegroup is added via push, pull or unbundle. Exit |
|
761 | 771 | status 0 allows the changegroup to proceed. Non-zero status will |
|
762 | 772 | cause the push, pull or unbundle to fail. URL from which changes |
|
763 | 773 | will come is in ``$HG_URL``. |
|
764 | 774 | |
|
765 | 775 | ``precommit`` |
|
766 | 776 | Run before starting a local commit. Exit status 0 allows the |
|
767 | 777 | commit to proceed. Non-zero status will cause the commit to fail. |
|
768 | 778 | Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
769 | 779 | |
|
770 | 780 | ``prelistkeys`` |
|
771 | 781 | Run before listing pushkeys (like bookmarks) in the |
|
772 | 782 | repository. Non-zero status will cause failure. The key namespace is |
|
773 | 783 | in ``$HG_NAMESPACE``. |
|
774 | 784 | |
|
775 | 785 | ``preoutgoing`` |
|
776 | 786 | Run before collecting changes to send from the local repository to |
|
777 | 787 | another. Non-zero status will cause failure. This lets you prevent |
|
778 | 788 | pull over HTTP or SSH. Also prevents against local pull, push |
|
779 | 789 | (outbound) or bundle commands, but not effective, since you can |
|
780 | 790 | just copy files instead then. Source of operation is in |
|
781 | 791 | ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote |
|
782 | 792 | SSH or HTTP repository. If "push", "pull" or "bundle", operation |
|
783 | 793 | is happening on behalf of repository on same system. |
|
784 | 794 | |
|
785 | 795 | ``prepushkey`` |
|
786 | 796 | Run before a pushkey (like a bookmark) is added to the |
|
787 | 797 | repository. Non-zero status will cause the key to be rejected. The |
|
788 | 798 | key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``, |
|
789 | 799 | the old value (if any) is in ``$HG_OLD``, and the new value is in |
|
790 | 800 | ``$HG_NEW``. |
|
791 | 801 | |
|
792 | 802 | ``pretag`` |
|
793 | 803 | Run before creating a tag. Exit status 0 allows the tag to be |
|
794 | 804 | created. Non-zero status will cause the tag to fail. ID of |
|
795 | 805 | changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is |
|
796 | 806 | local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``. |
|
797 | 807 | |
|
798 | 808 | ``pretxnchangegroup`` |
|
799 | 809 | Run after a changegroup has been added via push, pull or unbundle, |
|
800 | 810 | but before the transaction has been committed. Changegroup is |
|
801 | 811 | visible to hook program. This lets you validate incoming changes |
|
802 | 812 | before accepting them. Passed the ID of the first new changeset in |
|
803 | 813 | ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero |
|
804 | 814 | status will cause the transaction to be rolled back and the push, |
|
805 | 815 | pull or unbundle will fail. URL that was source of changes is in |
|
806 | 816 | ``$HG_URL``. |
|
807 | 817 | |
|
808 | 818 | ``pretxncommit`` |
|
809 | 819 | Run after a changeset has been created but the transaction not yet |
|
810 | 820 | committed. Changeset is visible to hook program. This lets you |
|
811 | 821 | validate commit message and changes. Exit status 0 allows the |
|
812 | 822 | commit to proceed. Non-zero status will cause the transaction to |
|
813 | 823 | be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset |
|
814 | 824 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
815 | 825 | |
|
816 | 826 | ``preupdate`` |
|
817 | 827 | Run before updating the working directory. Exit status 0 allows |
|
818 | 828 | the update to proceed. Non-zero status will prevent the update. |
|
819 | 829 | Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID |
|
820 | 830 | of second new parent is in ``$HG_PARENT2``. |
|
821 | 831 | |
|
822 | 832 | ``listkeys`` |
|
823 | 833 | Run after listing pushkeys (like bookmarks) in the repository. The |
|
824 | 834 | key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a |
|
825 | 835 | dictionary containing the keys and values. |
|
826 | 836 | |
|
827 | 837 | ``pushkey`` |
|
828 | 838 | Run after a pushkey (like a bookmark) is added to the |
|
829 | 839 | repository. The key namespace is in ``$HG_NAMESPACE``, the key is in |
|
830 | 840 | ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new |
|
831 | 841 | value is in ``$HG_NEW``. |
|
832 | 842 | |
|
833 | 843 | ``tag`` |
|
834 | 844 | Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``. |
|
835 | 845 | Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in |
|
836 | 846 | repository if ``$HG_LOCAL=0``. |
|
837 | 847 | |
|
838 | 848 | ``update`` |
|
839 | 849 | Run after updating the working directory. Changeset ID of first |
|
840 | 850 | new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is |
|
841 | 851 | in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the |
|
842 | 852 | update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``. |
|
843 | 853 | |
|
844 | 854 | .. note:: |
|
845 | 855 | |
|
846 | 856 | It is generally better to use standard hooks rather than the |
|
847 | 857 | generic pre- and post- command hooks as they are guaranteed to be |
|
848 | 858 | called in the appropriate contexts for influencing transactions. |
|
849 | 859 | Also, hooks like "commit" will be called in all contexts that |
|
850 | 860 | generate a commit (e.g. tag) and not just the commit command. |
|
851 | 861 | |
|
852 | 862 | .. note:: |
|
853 | 863 | |
|
854 | 864 | Environment variables with empty values may not be passed to |
|
855 | 865 | hooks on platforms such as Windows. As an example, ``$HG_PARENT2`` |
|
856 | 866 | will have an empty value under Unix-like platforms for non-merge |
|
857 | 867 | changesets, while it will not be available at all under Windows. |
|
858 | 868 | |
|
859 | 869 | The syntax for Python hooks is as follows:: |
|
860 | 870 | |
|
861 | 871 | hookname = python:modulename.submodule.callable |
|
862 | 872 | hookname = python:/path/to/python/module.py:callable |
|
863 | 873 | |
|
864 | 874 | Python hooks are run within the Mercurial process. Each hook is |
|
865 | 875 | called with at least three keyword arguments: a ui object (keyword |
|
866 | 876 | ``ui``), a repository object (keyword ``repo``), and a ``hooktype`` |
|
867 | 877 | keyword that tells what kind of hook is used. Arguments listed as |
|
868 | 878 | environment variables above are passed as keyword arguments, with no |
|
869 | 879 | ``HG_`` prefix, and names in lower case. |
|
870 | 880 | |
|
871 | 881 | If a Python hook returns a "true" value or raises an exception, this |
|
872 | 882 | is treated as a failure. |
|
873 | 883 | |
|
874 | 884 | |
|
875 | 885 | ``hostfingerprints`` |
|
876 | 886 | -------------------- |
|
877 | 887 | |
|
878 | 888 | Fingerprints of the certificates of known HTTPS servers. |
|
879 | 889 | A HTTPS connection to a server with a fingerprint configured here will |
|
880 | 890 | only succeed if the servers certificate matches the fingerprint. |
|
881 | 891 | This is very similar to how ssh known hosts works. |
|
882 | 892 | The fingerprint is the SHA-1 hash value of the DER encoded certificate. |
|
883 | 893 | The CA chain and web.cacerts is not used for servers with a fingerprint. |
|
884 | 894 | |
|
885 | 895 | For example:: |
|
886 | 896 | |
|
887 | 897 | [hostfingerprints] |
|
888 | 898 | hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0 |
|
889 | 899 | |
|
890 | 900 | This feature is only supported when using Python 2.6 or later. |
|
891 | 901 | |
|
892 | 902 | |
|
893 | 903 | ``http_proxy`` |
|
894 | 904 | -------------- |
|
895 | 905 | |
|
896 | 906 | Used to access web-based Mercurial repositories through a HTTP |
|
897 | 907 | proxy. |
|
898 | 908 | |
|
899 | 909 | ``host`` |
|
900 | 910 | Host name and (optional) port of the proxy server, for example |
|
901 | 911 | "myproxy:8000". |
|
902 | 912 | |
|
903 | 913 | ``no`` |
|
904 | 914 | Optional. Comma-separated list of host names that should bypass |
|
905 | 915 | the proxy. |
|
906 | 916 | |
|
907 | 917 | ``passwd`` |
|
908 | 918 | Optional. Password to authenticate with at the proxy server. |
|
909 | 919 | |
|
910 | 920 | ``user`` |
|
911 | 921 | Optional. User name to authenticate with at the proxy server. |
|
912 | 922 | |
|
913 | 923 | ``always`` |
|
914 | 924 | Optional. Always use the proxy, even for localhost and any entries |
|
915 | 925 | in ``http_proxy.no``. True or False. Default: False. |
|
916 | 926 | |
|
917 | 927 | ``merge-patterns`` |
|
918 | 928 | ------------------ |
|
919 | 929 | |
|
920 | 930 | This section specifies merge tools to associate with particular file |
|
921 | 931 | patterns. Tools matched here will take precedence over the default |
|
922 | 932 | merge tool. Patterns are globs by default, rooted at the repository |
|
923 | 933 | root. |
|
924 | 934 | |
|
925 | 935 | Example:: |
|
926 | 936 | |
|
927 | 937 | [merge-patterns] |
|
928 | 938 | **.c = kdiff3 |
|
929 | 939 | **.jpg = myimgmerge |
|
930 | 940 | |
|
931 | 941 | ``merge-tools`` |
|
932 | 942 | --------------- |
|
933 | 943 | |
|
934 | 944 | This section configures external merge tools to use for file-level |
|
935 | 945 | merges. This section has likely been preconfigured at install time. |
|
936 | 946 | Use :hg:`config merge-tools` to check the existing configuration. |
|
937 | 947 | Also see :hg:`help merge-tools` for more details. |
|
938 | 948 | |
|
939 | 949 | Example ``~/.hgrc``:: |
|
940 | 950 | |
|
941 | 951 | [merge-tools] |
|
942 | 952 | # Override stock tool location |
|
943 | 953 | kdiff3.executable = ~/bin/kdiff3 |
|
944 | 954 | # Specify command line |
|
945 | 955 | kdiff3.args = $base $local $other -o $output |
|
946 | 956 | # Give higher priority |
|
947 | 957 | kdiff3.priority = 1 |
|
948 | 958 | |
|
949 | 959 | # Changing the priority of preconfigured tool |
|
950 | 960 | vimdiff.priority = 0 |
|
951 | 961 | |
|
952 | 962 | # Define new tool |
|
953 | 963 | myHtmlTool.args = -m $local $other $base $output |
|
954 | 964 | myHtmlTool.regkey = Software\FooSoftware\HtmlMerge |
|
955 | 965 | myHtmlTool.priority = 1 |
|
956 | 966 | |
|
957 | 967 | Supported arguments: |
|
958 | 968 | |
|
959 | 969 | ``priority`` |
|
960 | 970 | The priority in which to evaluate this tool. |
|
961 | 971 | Default: 0. |
|
962 | 972 | |
|
963 | 973 | ``executable`` |
|
964 | 974 | Either just the name of the executable or its pathname. On Windows, |
|
965 | 975 | the path can use environment variables with ${ProgramFiles} syntax. |
|
966 | 976 | Default: the tool name. |
|
967 | 977 | |
|
968 | 978 | ``args`` |
|
969 | 979 | The arguments to pass to the tool executable. You can refer to the |
|
970 | 980 | files being merged as well as the output file through these |
|
971 | 981 | variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning |
|
972 | 982 | of ``$local`` and ``$other`` can vary depending on which action is being |
|
973 | 983 | performed. During and update or merge, ``$local`` represents the original |
|
974 | 984 | state of the file, while ``$other`` represents the commit you are updating |
|
975 | 985 | to or the commit you are merging with. During a rebase ``$local`` |
|
976 | 986 | represents the destination of the rebase, and ``$other`` represents the |
|
977 | 987 | commit being rebased. |
|
978 | 988 | Default: ``$local $base $other`` |
|
979 | 989 | |
|
980 | 990 | ``premerge`` |
|
981 | 991 | Attempt to run internal non-interactive 3-way merge tool before |
|
982 | 992 | launching external tool. Options are ``true``, ``false``, ``keep`` or |
|
983 | 993 | ``keep-merge3``. The ``keep`` option will leave markers in the file if the |
|
984 | 994 | premerge fails. The ``keep-merge3`` will do the same but include information |
|
985 | 995 | about the base of the merge in the marker (see internal :merge3 in |
|
986 | 996 | :hg:`help merge-tools`). |
|
987 | 997 | Default: True |
|
988 | 998 | |
|
989 | 999 | ``binary`` |
|
990 | 1000 | This tool can merge binary files. Defaults to False, unless tool |
|
991 | 1001 | was selected by file pattern match. |
|
992 | 1002 | |
|
993 | 1003 | ``symlink`` |
|
994 | 1004 | This tool can merge symlinks. Defaults to False, even if tool was |
|
995 | 1005 | selected by file pattern match. |
|
996 | 1006 | |
|
997 | 1007 | ``check`` |
|
998 | 1008 | A list of merge success-checking options: |
|
999 | 1009 | |
|
1000 | 1010 | ``changed`` |
|
1001 | 1011 | Ask whether merge was successful when the merged file shows no changes. |
|
1002 | 1012 | ``conflicts`` |
|
1003 | 1013 | Check whether there are conflicts even though the tool reported success. |
|
1004 | 1014 | ``prompt`` |
|
1005 | 1015 | Always prompt for merge success, regardless of success reported by tool. |
|
1006 | 1016 | |
|
1007 | 1017 | ``fixeol`` |
|
1008 | 1018 | Attempt to fix up EOL changes caused by the merge tool. |
|
1009 | 1019 | Default: False |
|
1010 | 1020 | |
|
1011 | 1021 | ``gui`` |
|
1012 | 1022 | This tool requires a graphical interface to run. Default: False |
|
1013 | 1023 | |
|
1014 | 1024 | ``regkey`` |
|
1015 | 1025 | Windows registry key which describes install location of this |
|
1016 | 1026 | tool. Mercurial will search for this key first under |
|
1017 | 1027 | ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``. |
|
1018 | 1028 | Default: None |
|
1019 | 1029 | |
|
1020 | 1030 | ``regkeyalt`` |
|
1021 | 1031 | An alternate Windows registry key to try if the first key is not |
|
1022 | 1032 | found. The alternate key uses the same ``regname`` and ``regappend`` |
|
1023 | 1033 | semantics of the primary key. The most common use for this key |
|
1024 | 1034 | is to search for 32bit applications on 64bit operating systems. |
|
1025 | 1035 | Default: None |
|
1026 | 1036 | |
|
1027 | 1037 | ``regname`` |
|
1028 | 1038 | Name of value to read from specified registry key. Defaults to the |
|
1029 | 1039 | unnamed (default) value. |
|
1030 | 1040 | |
|
1031 | 1041 | ``regappend`` |
|
1032 | 1042 | String to append to the value read from the registry, typically |
|
1033 | 1043 | the executable name of the tool. |
|
1034 | 1044 | Default: None |
|
1035 | 1045 | |
|
1036 | 1046 | |
|
1037 | 1047 | ``patch`` |
|
1038 | 1048 | --------- |
|
1039 | 1049 | |
|
1040 | 1050 | Settings used when applying patches, for instance through the 'import' |
|
1041 | 1051 | command or with Mercurial Queues extension. |
|
1042 | 1052 | |
|
1043 | 1053 | ``eol`` |
|
1044 | 1054 | When set to 'strict' patch content and patched files end of lines |
|
1045 | 1055 | are preserved. When set to ``lf`` or ``crlf``, both files end of |
|
1046 | 1056 | lines are ignored when patching and the result line endings are |
|
1047 | 1057 | normalized to either LF (Unix) or CRLF (Windows). When set to |
|
1048 | 1058 | ``auto``, end of lines are again ignored while patching but line |
|
1049 | 1059 | endings in patched files are normalized to their original setting |
|
1050 | 1060 | on a per-file basis. If target file does not exist or has no end |
|
1051 | 1061 | of line, patch line endings are preserved. |
|
1052 | 1062 | Default: strict. |
|
1053 | 1063 | |
|
1054 | 1064 | |
|
1055 | 1065 | ``paths`` |
|
1056 | 1066 | --------- |
|
1057 | 1067 | |
|
1058 | 1068 | Assigns symbolic names to repositories. The left side is the |
|
1059 | 1069 | symbolic name, and the right gives the directory or URL that is the |
|
1060 | 1070 | location of the repository. Default paths can be declared by setting |
|
1061 | 1071 | the following entries. |
|
1062 | 1072 | |
|
1063 | 1073 | ``default`` |
|
1064 | 1074 | Directory or URL to use when pulling if no source is specified. |
|
1065 | 1075 | Default is set to repository from which the current repository was |
|
1066 | 1076 | cloned. |
|
1067 | 1077 | |
|
1068 | 1078 | ``default-push`` |
|
1069 | 1079 | Optional. Directory or URL to use when pushing if no destination |
|
1070 | 1080 | is specified. |
|
1071 | 1081 | |
|
1072 | 1082 | Custom paths can be defined by assigning the path to a name that later can be |
|
1073 | 1083 | used from the command line. Example:: |
|
1074 | 1084 | |
|
1075 | 1085 | [paths] |
|
1076 | 1086 | my_path = http://example.com/path |
|
1077 | 1087 | |
|
1078 | 1088 | To push to the path defined in ``my_path`` run the command:: |
|
1079 | 1089 | |
|
1080 | 1090 | hg push my_path |
|
1081 | 1091 | |
|
1082 | 1092 | |
|
1083 | 1093 | ``phases`` |
|
1084 | 1094 | ---------- |
|
1085 | 1095 | |
|
1086 | 1096 | Specifies default handling of phases. See :hg:`help phases` for more |
|
1087 | 1097 | information about working with phases. |
|
1088 | 1098 | |
|
1089 | 1099 | ``publish`` |
|
1090 | 1100 | Controls draft phase behavior when working as a server. When true, |
|
1091 | 1101 | pushed changesets are set to public in both client and server and |
|
1092 | 1102 | pulled or cloned changesets are set to public in the client. |
|
1093 | 1103 | Default: True |
|
1094 | 1104 | |
|
1095 | 1105 | ``new-commit`` |
|
1096 | 1106 | Phase of newly-created commits. |
|
1097 | 1107 | Default: draft |
|
1098 | 1108 | |
|
1099 | 1109 | ``checksubrepos`` |
|
1100 | 1110 | Check the phase of the current revision of each subrepository. Allowed |
|
1101 | 1111 | values are "ignore", "follow" and "abort". For settings other than |
|
1102 | 1112 | "ignore", the phase of the current revision of each subrepository is |
|
1103 | 1113 | checked before committing the parent repository. If any of those phases is |
|
1104 | 1114 | greater than the phase of the parent repository (e.g. if a subrepo is in a |
|
1105 | 1115 | "secret" phase while the parent repo is in "draft" phase), the commit is |
|
1106 | 1116 | either aborted (if checksubrepos is set to "abort") or the higher phase is |
|
1107 | 1117 | used for the parent repository commit (if set to "follow"). |
|
1108 | 1118 | Default: "follow" |
|
1109 | 1119 | |
|
1110 | 1120 | |
|
1111 | 1121 | ``profiling`` |
|
1112 | 1122 | ------------- |
|
1113 | 1123 | |
|
1114 | 1124 | Specifies profiling type, format, and file output. Two profilers are |
|
1115 | 1125 | supported: an instrumenting profiler (named ``ls``), and a sampling |
|
1116 | 1126 | profiler (named ``stat``). |
|
1117 | 1127 | |
|
1118 | 1128 | In this section description, 'profiling data' stands for the raw data |
|
1119 | 1129 | collected during profiling, while 'profiling report' stands for a |
|
1120 | 1130 | statistical text report generated from the profiling data. The |
|
1121 | 1131 | profiling is done using lsprof. |
|
1122 | 1132 | |
|
1123 | 1133 | ``type`` |
|
1124 | 1134 | The type of profiler to use. |
|
1125 | 1135 | Default: ls. |
|
1126 | 1136 | |
|
1127 | 1137 | ``ls`` |
|
1128 | 1138 | Use Python's built-in instrumenting profiler. This profiler |
|
1129 | 1139 | works on all platforms, but each line number it reports is the |
|
1130 | 1140 | first line of a function. This restriction makes it difficult to |
|
1131 | 1141 | identify the expensive parts of a non-trivial function. |
|
1132 | 1142 | ``stat`` |
|
1133 | 1143 | Use a third-party statistical profiler, statprof. This profiler |
|
1134 | 1144 | currently runs only on Unix systems, and is most useful for |
|
1135 | 1145 | profiling commands that run for longer than about 0.1 seconds. |
|
1136 | 1146 | |
|
1137 | 1147 | ``format`` |
|
1138 | 1148 | Profiling format. Specific to the ``ls`` instrumenting profiler. |
|
1139 | 1149 | Default: text. |
|
1140 | 1150 | |
|
1141 | 1151 | ``text`` |
|
1142 | 1152 | Generate a profiling report. When saving to a file, it should be |
|
1143 | 1153 | noted that only the report is saved, and the profiling data is |
|
1144 | 1154 | not kept. |
|
1145 | 1155 | ``kcachegrind`` |
|
1146 | 1156 | Format profiling data for kcachegrind use: when saving to a |
|
1147 | 1157 | file, the generated file can directly be loaded into |
|
1148 | 1158 | kcachegrind. |
|
1149 | 1159 | |
|
1150 | 1160 | ``frequency`` |
|
1151 | 1161 | Sampling frequency. Specific to the ``stat`` sampling profiler. |
|
1152 | 1162 | Default: 1000. |
|
1153 | 1163 | |
|
1154 | 1164 | ``output`` |
|
1155 | 1165 | File path where profiling data or report should be saved. If the |
|
1156 | 1166 | file exists, it is replaced. Default: None, data is printed on |
|
1157 | 1167 | stderr |
|
1158 | 1168 | |
|
1159 | 1169 | ``sort`` |
|
1160 | 1170 | Sort field. Specific to the ``ls`` instrumenting profiler. |
|
1161 | 1171 | One of ``callcount``, ``reccallcount``, ``totaltime`` and |
|
1162 | 1172 | ``inlinetime``. |
|
1163 | 1173 | Default: inlinetime. |
|
1164 | 1174 | |
|
1165 | 1175 | ``limit`` |
|
1166 | 1176 | Number of lines to show. Specific to the ``ls`` instrumenting profiler. |
|
1167 | 1177 | Default: 30. |
|
1168 | 1178 | |
|
1169 | 1179 | ``nested`` |
|
1170 | 1180 | Show at most this number of lines of drill-down info after each main entry. |
|
1171 | 1181 | This can help explain the difference between Total and Inline. |
|
1172 | 1182 | Specific to the ``ls`` instrumenting profiler. |
|
1173 | 1183 | Default: 5. |
|
1174 | 1184 | |
|
1175 | 1185 | ``revsetalias`` |
|
1176 | 1186 | --------------- |
|
1177 | 1187 | |
|
1178 | 1188 | Alias definitions for revsets. See :hg:`help revsets` for details. |
|
1179 | 1189 | |
|
1180 | 1190 | ``server`` |
|
1181 | 1191 | ---------- |
|
1182 | 1192 | |
|
1183 | 1193 | Controls generic server settings. |
|
1184 | 1194 | |
|
1185 | 1195 | ``uncompressed`` |
|
1186 | 1196 | Whether to allow clients to clone a repository using the |
|
1187 | 1197 | uncompressed streaming protocol. This transfers about 40% more |
|
1188 | 1198 | data than a regular clone, but uses less memory and CPU on both |
|
1189 | 1199 | server and client. Over a LAN (100 Mbps or better) or a very fast |
|
1190 | 1200 | WAN, an uncompressed streaming clone is a lot faster (~10x) than a |
|
1191 | 1201 | regular clone. Over most WAN connections (anything slower than |
|
1192 | 1202 | about 6 Mbps), uncompressed streaming is slower, because of the |
|
1193 | 1203 | extra data transfer overhead. This mode will also temporarily hold |
|
1194 | 1204 | the write lock while determining what data to transfer. |
|
1195 | 1205 | Default is True. |
|
1196 | 1206 | |
|
1197 | 1207 | ``preferuncompressed`` |
|
1198 | 1208 | When set, clients will try to use the uncompressed streaming |
|
1199 | 1209 | protocol. Default is False. |
|
1200 | 1210 | |
|
1201 | 1211 | ``validate`` |
|
1202 | 1212 | Whether to validate the completeness of pushed changesets by |
|
1203 | 1213 | checking that all new file revisions specified in manifests are |
|
1204 | 1214 | present. Default is False. |
|
1205 | 1215 | |
|
1206 | 1216 | ``smtp`` |
|
1207 | 1217 | -------- |
|
1208 | 1218 | |
|
1209 | 1219 | Configuration for extensions that need to send email messages. |
|
1210 | 1220 | |
|
1211 | 1221 | ``host`` |
|
1212 | 1222 | Host name of mail server, e.g. "mail.example.com". |
|
1213 | 1223 | |
|
1214 | 1224 | ``port`` |
|
1215 | 1225 | Optional. Port to connect to on mail server. Default: 465 (if |
|
1216 | 1226 | ``tls`` is smtps) or 25 (otherwise). |
|
1217 | 1227 | |
|
1218 | 1228 | ``tls`` |
|
1219 | 1229 | Optional. Method to enable TLS when connecting to mail server: starttls, |
|
1220 | 1230 | smtps or none. Default: none. |
|
1221 | 1231 | |
|
1222 | 1232 | ``verifycert`` |
|
1223 | 1233 | Optional. Verification for the certificate of mail server, when |
|
1224 | 1234 | ``tls`` is starttls or smtps. "strict", "loose" or False. For |
|
1225 | 1235 | "strict" or "loose", the certificate is verified as same as the |
|
1226 | 1236 | verification for HTTPS connections (see ``[hostfingerprints]`` and |
|
1227 | 1237 | ``[web] cacerts`` also). For "strict", sending email is also |
|
1228 | 1238 | aborted, if there is no configuration for mail server in |
|
1229 | 1239 | ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for |
|
1230 | 1240 | :hg:`email` overwrites this as "loose". Default: "strict". |
|
1231 | 1241 | |
|
1232 | 1242 | ``username`` |
|
1233 | 1243 | Optional. User name for authenticating with the SMTP server. |
|
1234 | 1244 | Default: none. |
|
1235 | 1245 | |
|
1236 | 1246 | ``password`` |
|
1237 | 1247 | Optional. Password for authenticating with the SMTP server. If not |
|
1238 | 1248 | specified, interactive sessions will prompt the user for a |
|
1239 | 1249 | password; non-interactive sessions will fail. Default: none. |
|
1240 | 1250 | |
|
1241 | 1251 | ``local_hostname`` |
|
1242 | 1252 | Optional. It's the hostname that the sender can use to identify |
|
1243 | 1253 | itself to the MTA. |
|
1244 | 1254 | |
|
1245 | 1255 | |
|
1246 | 1256 | ``subpaths`` |
|
1247 | 1257 | ------------ |
|
1248 | 1258 | |
|
1249 | 1259 | Subrepository source URLs can go stale if a remote server changes name |
|
1250 | 1260 | or becomes temporarily unavailable. This section lets you define |
|
1251 | 1261 | rewrite rules of the form:: |
|
1252 | 1262 | |
|
1253 | 1263 | <pattern> = <replacement> |
|
1254 | 1264 | |
|
1255 | 1265 | where ``pattern`` is a regular expression matching a subrepository |
|
1256 | 1266 | source URL and ``replacement`` is the replacement string used to |
|
1257 | 1267 | rewrite it. Groups can be matched in ``pattern`` and referenced in |
|
1258 | 1268 | ``replacements``. For instance:: |
|
1259 | 1269 | |
|
1260 | 1270 | http://server/(.*)-hg/ = http://hg.server/\1/ |
|
1261 | 1271 | |
|
1262 | 1272 | rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``. |
|
1263 | 1273 | |
|
1264 | 1274 | Relative subrepository paths are first made absolute, and the |
|
1265 | 1275 | rewrite rules are then applied on the full (absolute) path. The rules |
|
1266 | 1276 | are applied in definition order. |
|
1267 | 1277 | |
|
1268 | 1278 | ``trusted`` |
|
1269 | 1279 | ----------- |
|
1270 | 1280 | |
|
1271 | 1281 | Mercurial will not use the settings in the |
|
1272 | 1282 | ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted |
|
1273 | 1283 | user or to a trusted group, as various hgrc features allow arbitrary |
|
1274 | 1284 | commands to be run. This issue is often encountered when configuring |
|
1275 | 1285 | hooks or extensions for shared repositories or servers. However, |
|
1276 | 1286 | the web interface will use some safe settings from the ``[web]`` |
|
1277 | 1287 | section. |
|
1278 | 1288 | |
|
1279 | 1289 | This section specifies what users and groups are trusted. The |
|
1280 | 1290 | current user is always trusted. To trust everybody, list a user or a |
|
1281 | 1291 | group with name ``*``. These settings must be placed in an |
|
1282 | 1292 | *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the |
|
1283 | 1293 | user or service running Mercurial. |
|
1284 | 1294 | |
|
1285 | 1295 | ``users`` |
|
1286 | 1296 | Comma-separated list of trusted users. |
|
1287 | 1297 | |
|
1288 | 1298 | ``groups`` |
|
1289 | 1299 | Comma-separated list of trusted groups. |
|
1290 | 1300 | |
|
1291 | 1301 | |
|
1292 | 1302 | ``ui`` |
|
1293 | 1303 | ------ |
|
1294 | 1304 | |
|
1295 | 1305 | User interface controls. |
|
1296 | 1306 | |
|
1297 | 1307 | ``archivemeta`` |
|
1298 | 1308 | Whether to include the .hg_archival.txt file containing meta data |
|
1299 | 1309 | (hashes for the repository base and for tip) in archives created |
|
1300 | 1310 | by the :hg:`archive` command or downloaded via hgweb. |
|
1301 | 1311 | Default is True. |
|
1302 | 1312 | |
|
1303 | 1313 | ``askusername`` |
|
1304 | 1314 | Whether to prompt for a username when committing. If True, and |
|
1305 | 1315 | neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will |
|
1306 | 1316 | be prompted to enter a username. If no username is entered, the |
|
1307 | 1317 | default ``USER@HOST`` is used instead. |
|
1308 | 1318 | Default is False. |
|
1309 | 1319 | |
|
1310 | 1320 | ``commitsubrepos`` |
|
1311 | 1321 | Whether to commit modified subrepositories when committing the |
|
1312 | 1322 | parent repository. If False and one subrepository has uncommitted |
|
1313 | 1323 | changes, abort the commit. |
|
1314 | 1324 | Default is False. |
|
1315 | 1325 | |
|
1316 | 1326 | ``debug`` |
|
1317 | 1327 | Print debugging information. True or False. Default is False. |
|
1318 | 1328 | |
|
1319 | 1329 | ``editor`` |
|
1320 | 1330 | The editor to use during a commit. Default is ``$EDITOR`` or ``vi``. |
|
1321 | 1331 | |
|
1322 | 1332 | ``fallbackencoding`` |
|
1323 | 1333 | Encoding to try if it's not possible to decode the changelog using |
|
1324 | 1334 | UTF-8. Default is ISO-8859-1. |
|
1325 | 1335 | |
|
1326 | 1336 | ``ignore`` |
|
1327 | 1337 | A file to read per-user ignore patterns from. This file should be |
|
1328 | 1338 | in the same format as a repository-wide .hgignore file. This |
|
1329 | 1339 | option supports hook syntax, so if you want to specify multiple |
|
1330 | 1340 | ignore files, you can do so by setting something like |
|
1331 | 1341 | ``ignore.other = ~/.hgignore2``. For details of the ignore file |
|
1332 | 1342 | format, see the ``hgignore(5)`` man page. |
|
1333 | 1343 | |
|
1334 | 1344 | ``interactive`` |
|
1335 | 1345 | Allow to prompt the user. True or False. Default is True. |
|
1336 | 1346 | |
|
1337 | 1347 | ``logtemplate`` |
|
1338 | 1348 | Template string for commands that print changesets. |
|
1339 | 1349 | |
|
1340 | 1350 | ``merge`` |
|
1341 | 1351 | The conflict resolution program to use during a manual merge. |
|
1342 | 1352 | For more information on merge tools see :hg:`help merge-tools`. |
|
1343 | 1353 | For configuring merge tools see the ``[merge-tools]`` section. |
|
1344 | 1354 | |
|
1345 | 1355 | ``mergemarkers`` |
|
1346 | 1356 | Sets the merge conflict marker label styling. The ``detailed`` |
|
1347 | 1357 | style uses the ``mergemarkertemplate`` setting to style the labels. |
|
1348 | 1358 | The ``basic`` style just uses 'local' and 'other' as the marker label. |
|
1349 | 1359 | One of ``basic`` or ``detailed``. |
|
1350 | 1360 | Default is ``basic``. |
|
1351 | 1361 | |
|
1352 | 1362 | ``mergemarkertemplate`` |
|
1353 | 1363 | The template used to print the commit description next to each conflict |
|
1354 | 1364 | marker during merge conflicts. See :hg:`help templates` for the template |
|
1355 | 1365 | format. |
|
1356 | 1366 | Defaults to showing the hash, tags, branches, bookmarks, author, and |
|
1357 | 1367 | the first line of the commit description. |
|
1358 | 1368 | You have to pay attention to encodings of managed files, if you |
|
1359 | 1369 | use non-ASCII characters in tags, branches, bookmarks, author |
|
1360 | 1370 | and/or commit descriptions. At template expansion, non-ASCII |
|
1361 | 1371 | characters use the encoding specified by ``--encoding`` global |
|
1362 | 1372 | option, ``HGENCODING`` or other locale setting environment |
|
1363 | 1373 | variables. The difference of encoding between merged file and |
|
1364 | 1374 | conflict markers causes serious problem. |
|
1365 | 1375 | |
|
1366 | 1376 | ``portablefilenames`` |
|
1367 | 1377 | Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``. |
|
1368 | 1378 | Default is ``warn``. |
|
1369 | 1379 | If set to ``warn`` (or ``true``), a warning message is printed on POSIX |
|
1370 | 1380 | platforms, if a file with a non-portable filename is added (e.g. a file |
|
1371 | 1381 | with a name that can't be created on Windows because it contains reserved |
|
1372 | 1382 | parts like ``AUX``, reserved characters like ``:``, or would cause a case |
|
1373 | 1383 | collision with an existing file). |
|
1374 | 1384 | If set to ``ignore`` (or ``false``), no warning is printed. |
|
1375 | 1385 | If set to ``abort``, the command is aborted. |
|
1376 | 1386 | On Windows, this configuration option is ignored and the command aborted. |
|
1377 | 1387 | |
|
1378 | 1388 | ``quiet`` |
|
1379 | 1389 | Reduce the amount of output printed. True or False. Default is False. |
|
1380 | 1390 | |
|
1381 | 1391 | ``remotecmd`` |
|
1382 | 1392 | remote command to use for clone/push/pull operations. Default is ``hg``. |
|
1383 | 1393 | |
|
1384 | 1394 | ``reportoldssl`` |
|
1385 | 1395 | Warn if an SSL certificate is unable to be used due to using Python |
|
1386 | 1396 | 2.5 or earlier. True or False. Default is True. |
|
1387 | 1397 | |
|
1388 | 1398 | ``report_untrusted`` |
|
1389 | 1399 | Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a |
|
1390 | 1400 | trusted user or group. True or False. Default is True. |
|
1391 | 1401 | |
|
1392 | 1402 | ``slash`` |
|
1393 | 1403 | Display paths using a slash (``/``) as the path separator. This |
|
1394 | 1404 | only makes a difference on systems where the default path |
|
1395 | 1405 | separator is not the slash character (e.g. Windows uses the |
|
1396 | 1406 | backslash character (``\``)). |
|
1397 | 1407 | Default is False. |
|
1398 | 1408 | |
|
1399 | 1409 | ``ssh`` |
|
1400 | 1410 | command to use for SSH connections. Default is ``ssh``. |
|
1401 | 1411 | |
|
1402 | 1412 | ``strict`` |
|
1403 | 1413 | Require exact command names, instead of allowing unambiguous |
|
1404 | 1414 | abbreviations. True or False. Default is False. |
|
1405 | 1415 | |
|
1406 | 1416 | ``style`` |
|
1407 | 1417 | Name of style to use for command output. |
|
1408 | 1418 | |
|
1409 | 1419 | ``timeout`` |
|
1410 | 1420 | The timeout used when a lock is held (in seconds), a negative value |
|
1411 | 1421 | means no timeout. Default is 600. |
|
1412 | 1422 | |
|
1413 | 1423 | ``traceback`` |
|
1414 | 1424 | Mercurial always prints a traceback when an unknown exception |
|
1415 | 1425 | occurs. Setting this to True will make Mercurial print a traceback |
|
1416 | 1426 | on all exceptions, even those recognized by Mercurial (such as |
|
1417 | 1427 | IOError or MemoryError). Default is False. |
|
1418 | 1428 | |
|
1419 | 1429 | ``username`` |
|
1420 | 1430 | The committer of a changeset created when running "commit". |
|
1421 | 1431 | Typically a person's name and email address, e.g. ``Fred Widget |
|
1422 | 1432 | <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If |
|
1423 | 1433 | the username in hgrc is empty, it has to be specified manually or |
|
1424 | 1434 | in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set |
|
1425 | 1435 | ``username =`` in the system hgrc). Environment variables in the |
|
1426 | 1436 | username are expanded. |
|
1427 | 1437 | |
|
1428 | 1438 | ``verbose`` |
|
1429 | 1439 | Increase the amount of output printed. True or False. Default is False. |
|
1430 | 1440 | |
|
1431 | 1441 | |
|
1432 | 1442 | ``web`` |
|
1433 | 1443 | ------- |
|
1434 | 1444 | |
|
1435 | 1445 | Web interface configuration. The settings in this section apply to |
|
1436 | 1446 | both the builtin webserver (started by :hg:`serve`) and the script you |
|
1437 | 1447 | run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI |
|
1438 | 1448 | and WSGI). |
|
1439 | 1449 | |
|
1440 | 1450 | The Mercurial webserver does no authentication (it does not prompt for |
|
1441 | 1451 | usernames and passwords to validate *who* users are), but it does do |
|
1442 | 1452 | authorization (it grants or denies access for *authenticated users* |
|
1443 | 1453 | based on settings in this section). You must either configure your |
|
1444 | 1454 | webserver to do authentication for you, or disable the authorization |
|
1445 | 1455 | checks. |
|
1446 | 1456 | |
|
1447 | 1457 | For a quick setup in a trusted environment, e.g., a private LAN, where |
|
1448 | 1458 | you want it to accept pushes from anybody, you can use the following |
|
1449 | 1459 | command line:: |
|
1450 | 1460 | |
|
1451 | 1461 | $ hg --config web.allow_push=* --config web.push_ssl=False serve |
|
1452 | 1462 | |
|
1453 | 1463 | Note that this will allow anybody to push anything to the server and |
|
1454 | 1464 | that this should not be used for public servers. |
|
1455 | 1465 | |
|
1456 | 1466 | The full set of options is: |
|
1457 | 1467 | |
|
1458 | 1468 | ``accesslog`` |
|
1459 | 1469 | Where to output the access log. Default is stdout. |
|
1460 | 1470 | |
|
1461 | 1471 | ``address`` |
|
1462 | 1472 | Interface address to bind to. Default is all. |
|
1463 | 1473 | |
|
1464 | 1474 | ``allow_archive`` |
|
1465 | 1475 | List of archive format (bz2, gz, zip) allowed for downloading. |
|
1466 | 1476 | Default is empty. |
|
1467 | 1477 | |
|
1468 | 1478 | ``allowbz2`` |
|
1469 | 1479 | (DEPRECATED) Whether to allow .tar.bz2 downloading of repository |
|
1470 | 1480 | revisions. |
|
1471 | 1481 | Default is False. |
|
1472 | 1482 | |
|
1473 | 1483 | ``allowgz`` |
|
1474 | 1484 | (DEPRECATED) Whether to allow .tar.gz downloading of repository |
|
1475 | 1485 | revisions. |
|
1476 | 1486 | Default is False. |
|
1477 | 1487 | |
|
1478 | 1488 | ``allowpull`` |
|
1479 | 1489 | Whether to allow pulling from the repository. Default is True. |
|
1480 | 1490 | |
|
1481 | 1491 | ``allow_push`` |
|
1482 | 1492 | Whether to allow pushing to the repository. If empty or not set, |
|
1483 | 1493 | push is not allowed. If the special value ``*``, any remote user can |
|
1484 | 1494 | push, including unauthenticated users. Otherwise, the remote user |
|
1485 | 1495 | must have been authenticated, and the authenticated user name must |
|
1486 | 1496 | be present in this list. The contents of the allow_push list are |
|
1487 | 1497 | examined after the deny_push list. |
|
1488 | 1498 | |
|
1489 | 1499 | ``allow_read`` |
|
1490 | 1500 | If the user has not already been denied repository access due to |
|
1491 | 1501 | the contents of deny_read, this list determines whether to grant |
|
1492 | 1502 | repository access to the user. If this list is not empty, and the |
|
1493 | 1503 | user is unauthenticated or not present in the list, then access is |
|
1494 | 1504 | denied for the user. If the list is empty or not set, then access |
|
1495 | 1505 | is permitted to all users by default. Setting allow_read to the |
|
1496 | 1506 | special value ``*`` is equivalent to it not being set (i.e. access |
|
1497 | 1507 | is permitted to all users). The contents of the allow_read list are |
|
1498 | 1508 | examined after the deny_read list. |
|
1499 | 1509 | |
|
1500 | 1510 | ``allowzip`` |
|
1501 | 1511 | (DEPRECATED) Whether to allow .zip downloading of repository |
|
1502 | 1512 | revisions. Default is False. This feature creates temporary files. |
|
1503 | 1513 | |
|
1504 | 1514 | ``archivesubrepos`` |
|
1505 | 1515 | Whether to recurse into subrepositories when archiving. Default is |
|
1506 | 1516 | False. |
|
1507 | 1517 | |
|
1508 | 1518 | ``baseurl`` |
|
1509 | 1519 | Base URL to use when publishing URLs in other locations, so |
|
1510 | 1520 | third-party tools like email notification hooks can construct |
|
1511 | 1521 | URLs. Example: ``http://hgserver/repos/``. |
|
1512 | 1522 | |
|
1513 | 1523 | ``cacerts`` |
|
1514 | 1524 | Path to file containing a list of PEM encoded certificate |
|
1515 | 1525 | authority certificates. Environment variables and ``~user`` |
|
1516 | 1526 | constructs are expanded in the filename. If specified on the |
|
1517 | 1527 | client, then it will verify the identity of remote HTTPS servers |
|
1518 | 1528 | with these certificates. |
|
1519 | 1529 | |
|
1520 | 1530 | This feature is only supported when using Python 2.6 or later. If you wish |
|
1521 | 1531 | to use it with earlier versions of Python, install the backported |
|
1522 | 1532 | version of the ssl library that is available from |
|
1523 | 1533 | ``http://pypi.python.org``. |
|
1524 | 1534 | |
|
1525 | 1535 | To disable SSL verification temporarily, specify ``--insecure`` from |
|
1526 | 1536 | command line. |
|
1527 | 1537 | |
|
1528 | 1538 | You can use OpenSSL's CA certificate file if your platform has |
|
1529 | 1539 | one. On most Linux systems this will be |
|
1530 | 1540 | ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to |
|
1531 | 1541 | generate this file manually. The form must be as follows:: |
|
1532 | 1542 | |
|
1533 | 1543 | -----BEGIN CERTIFICATE----- |
|
1534 | 1544 | ... (certificate in base64 PEM encoding) ... |
|
1535 | 1545 | -----END CERTIFICATE----- |
|
1536 | 1546 | -----BEGIN CERTIFICATE----- |
|
1537 | 1547 | ... (certificate in base64 PEM encoding) ... |
|
1538 | 1548 | -----END CERTIFICATE----- |
|
1539 | 1549 | |
|
1540 | 1550 | ``cache`` |
|
1541 | 1551 | Whether to support caching in hgweb. Defaults to True. |
|
1542 | 1552 | |
|
1543 | 1553 | ``collapse`` |
|
1544 | 1554 | With ``descend`` enabled, repositories in subdirectories are shown at |
|
1545 | 1555 | a single level alongside repositories in the current path. With |
|
1546 | 1556 | ``collapse`` also enabled, repositories residing at a deeper level than |
|
1547 | 1557 | the current path are grouped behind navigable directory entries that |
|
1548 | 1558 | lead to the locations of these repositories. In effect, this setting |
|
1549 | 1559 | collapses each collection of repositories found within a subdirectory |
|
1550 | 1560 | into a single entry for that subdirectory. Default is False. |
|
1551 | 1561 | |
|
1552 | 1562 | ``comparisoncontext`` |
|
1553 | 1563 | Number of lines of context to show in side-by-side file comparison. If |
|
1554 | 1564 | negative or the value ``full``, whole files are shown. Default is 5. |
|
1555 | 1565 | This setting can be overridden by a ``context`` request parameter to the |
|
1556 | 1566 | ``comparison`` command, taking the same values. |
|
1557 | 1567 | |
|
1558 | 1568 | ``contact`` |
|
1559 | 1569 | Name or email address of the person in charge of the repository. |
|
1560 | 1570 | Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty. |
|
1561 | 1571 | |
|
1562 | 1572 | ``deny_push`` |
|
1563 | 1573 | Whether to deny pushing to the repository. If empty or not set, |
|
1564 | 1574 | push is not denied. If the special value ``*``, all remote users are |
|
1565 | 1575 | denied push. Otherwise, unauthenticated users are all denied, and |
|
1566 | 1576 | any authenticated user name present in this list is also denied. The |
|
1567 | 1577 | contents of the deny_push list are examined before the allow_push list. |
|
1568 | 1578 | |
|
1569 | 1579 | ``deny_read`` |
|
1570 | 1580 | Whether to deny reading/viewing of the repository. If this list is |
|
1571 | 1581 | not empty, unauthenticated users are all denied, and any |
|
1572 | 1582 | authenticated user name present in this list is also denied access to |
|
1573 | 1583 | the repository. If set to the special value ``*``, all remote users |
|
1574 | 1584 | are denied access (rarely needed ;). If deny_read is empty or not set, |
|
1575 | 1585 | the determination of repository access depends on the presence and |
|
1576 | 1586 | content of the allow_read list (see description). If both |
|
1577 | 1587 | deny_read and allow_read are empty or not set, then access is |
|
1578 | 1588 | permitted to all users by default. If the repository is being |
|
1579 | 1589 | served via hgwebdir, denied users will not be able to see it in |
|
1580 | 1590 | the list of repositories. The contents of the deny_read list have |
|
1581 | 1591 | priority over (are examined before) the contents of the allow_read |
|
1582 | 1592 | list. |
|
1583 | 1593 | |
|
1584 | 1594 | ``descend`` |
|
1585 | 1595 | hgwebdir indexes will not descend into subdirectories. Only repositories |
|
1586 | 1596 | directly in the current path will be shown (other repositories are still |
|
1587 | 1597 | available from the index corresponding to their containing path). |
|
1588 | 1598 | |
|
1589 | 1599 | ``description`` |
|
1590 | 1600 | Textual description of the repository's purpose or contents. |
|
1591 | 1601 | Default is "unknown". |
|
1592 | 1602 | |
|
1593 | 1603 | ``encoding`` |
|
1594 | 1604 | Character encoding name. Default is the current locale charset. |
|
1595 | 1605 | Example: "UTF-8" |
|
1596 | 1606 | |
|
1597 | 1607 | ``errorlog`` |
|
1598 | 1608 | Where to output the error log. Default is stderr. |
|
1599 | 1609 | |
|
1600 | 1610 | ``guessmime`` |
|
1601 | 1611 | Control MIME types for raw download of file content. |
|
1602 | 1612 | Set to True to let hgweb guess the content type from the file |
|
1603 | 1613 | extension. This will serve HTML files as ``text/html`` and might |
|
1604 | 1614 | allow cross-site scripting attacks when serving untrusted |
|
1605 | 1615 | repositories. Default is False. |
|
1606 | 1616 | |
|
1607 | 1617 | ``hidden`` |
|
1608 | 1618 | Whether to hide the repository in the hgwebdir index. |
|
1609 | 1619 | Default is False. |
|
1610 | 1620 | |
|
1611 | 1621 | ``ipv6`` |
|
1612 | 1622 | Whether to use IPv6. Default is False. |
|
1613 | 1623 | |
|
1614 | 1624 | ``logoimg`` |
|
1615 | 1625 | File name of the logo image that some templates display on each page. |
|
1616 | 1626 | The file name is relative to ``staticurl``. That is, the full path to |
|
1617 | 1627 | the logo image is "staticurl/logoimg". |
|
1618 | 1628 | If unset, ``hglogo.png`` will be used. |
|
1619 | 1629 | |
|
1620 | 1630 | ``logourl`` |
|
1621 | 1631 | Base URL to use for logos. If unset, ``http://mercurial.selenic.com/`` |
|
1622 | 1632 | will be used. |
|
1623 | 1633 | |
|
1624 | 1634 | ``maxchanges`` |
|
1625 | 1635 | Maximum number of changes to list on the changelog. Default is 10. |
|
1626 | 1636 | |
|
1627 | 1637 | ``maxfiles`` |
|
1628 | 1638 | Maximum number of files to list per changeset. Default is 10. |
|
1629 | 1639 | |
|
1630 | 1640 | ``maxshortchanges`` |
|
1631 | 1641 | Maximum number of changes to list on the shortlog, graph or filelog |
|
1632 | 1642 | pages. Default is 60. |
|
1633 | 1643 | |
|
1634 | 1644 | ``name`` |
|
1635 | 1645 | Repository name to use in the web interface. Default is current |
|
1636 | 1646 | working directory. |
|
1637 | 1647 | |
|
1638 | 1648 | ``port`` |
|
1639 | 1649 | Port to listen on. Default is 8000. |
|
1640 | 1650 | |
|
1641 | 1651 | ``prefix`` |
|
1642 | 1652 | Prefix path to serve from. Default is '' (server root). |
|
1643 | 1653 | |
|
1644 | 1654 | ``push_ssl`` |
|
1645 | 1655 | Whether to require that inbound pushes be transported over SSL to |
|
1646 | 1656 | prevent password sniffing. Default is True. |
|
1647 | 1657 | |
|
1648 | 1658 | ``staticurl`` |
|
1649 | 1659 | Base URL to use for static files. If unset, static files (e.g. the |
|
1650 | 1660 | hgicon.png favicon) will be served by the CGI script itself. Use |
|
1651 | 1661 | this setting to serve them directly with the HTTP server. |
|
1652 | 1662 | Example: ``http://hgserver/static/``. |
|
1653 | 1663 | |
|
1654 | 1664 | ``stripes`` |
|
1655 | 1665 | How many lines a "zebra stripe" should span in multi-line output. |
|
1656 | 1666 | Default is 1; set to 0 to disable. |
|
1657 | 1667 | |
|
1658 | 1668 | ``style`` |
|
1659 | 1669 | Which template map style to use. The available options are the names of |
|
1660 | 1670 | subdirectories in the HTML templates path. Default is ``paper``. |
|
1661 | 1671 | Example: ``monoblue`` |
|
1662 | 1672 | |
|
1663 | 1673 | ``templates`` |
|
1664 | 1674 | Where to find the HTML templates. The default path to the HTML templates |
|
1665 | 1675 | can be obtained from ``hg debuginstall``. |
|
1666 | 1676 | |
|
1667 | 1677 | ``websub`` |
|
1668 | 1678 | ---------- |
|
1669 | 1679 | |
|
1670 | 1680 | Web substitution filter definition. You can use this section to |
|
1671 | 1681 | define a set of regular expression substitution patterns which |
|
1672 | 1682 | let you automatically modify the hgweb server output. |
|
1673 | 1683 | |
|
1674 | 1684 | The default hgweb templates only apply these substitution patterns |
|
1675 | 1685 | on the revision description fields. You can apply them anywhere |
|
1676 | 1686 | you want when you create your own templates by adding calls to the |
|
1677 | 1687 | "websub" filter (usually after calling the "escape" filter). |
|
1678 | 1688 | |
|
1679 | 1689 | This can be used, for example, to convert issue references to links |
|
1680 | 1690 | to your issue tracker, or to convert "markdown-like" syntax into |
|
1681 | 1691 | HTML (see the examples below). |
|
1682 | 1692 | |
|
1683 | 1693 | Each entry in this section names a substitution filter. |
|
1684 | 1694 | The value of each entry defines the substitution expression itself. |
|
1685 | 1695 | The websub expressions follow the old interhg extension syntax, |
|
1686 | 1696 | which in turn imitates the Unix sed replacement syntax:: |
|
1687 | 1697 | |
|
1688 | 1698 | patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i] |
|
1689 | 1699 | |
|
1690 | 1700 | You can use any separator other than "/". The final "i" is optional |
|
1691 | 1701 | and indicates that the search must be case insensitive. |
|
1692 | 1702 | |
|
1693 | 1703 | Examples:: |
|
1694 | 1704 | |
|
1695 | 1705 | [websub] |
|
1696 | 1706 | issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i |
|
1697 | 1707 | italic = s/\b_(\S+)_\b/<i>\1<\/i>/ |
|
1698 | 1708 | bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/ |
|
1699 | 1709 | |
|
1700 | 1710 | ``worker`` |
|
1701 | 1711 | ---------- |
|
1702 | 1712 | |
|
1703 | 1713 | Parallel master/worker configuration. We currently perform working |
|
1704 | 1714 | directory updates in parallel on Unix-like systems, which greatly |
|
1705 | 1715 | helps performance. |
|
1706 | 1716 | |
|
1707 | 1717 | ``numcpus`` |
|
1708 | 1718 | Number of CPUs to use for parallel operations. Default is 4 or the |
|
1709 | 1719 | number of CPUs on the system, whichever is larger. A zero or |
|
1710 | 1720 | negative value is treated as ``use the default``. |
@@ -1,1022 +1,1028 b'' | |||
|
1 | 1 | # scmutil.py - Mercurial core utility functions |
|
2 | 2 | # |
|
3 | 3 | # Copyright Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | 9 | from mercurial.node import nullrev |
|
10 | 10 | import util, error, osutil, revset, similar, encoding, phases, parsers |
|
11 | 11 | import pathutil |
|
12 | 12 | import match as matchmod |
|
13 | 13 | import os, errno, re, glob, tempfile |
|
14 | 14 | |
|
15 | 15 | if os.name == 'nt': |
|
16 | 16 | import scmwindows as scmplatform |
|
17 | 17 | else: |
|
18 | 18 | import scmposix as scmplatform |
|
19 | 19 | |
|
20 | 20 | systemrcpath = scmplatform.systemrcpath |
|
21 | 21 | userrcpath = scmplatform.userrcpath |
|
22 | 22 | |
|
23 | 23 | class status(tuple): |
|
24 | 24 | '''Named tuple with a list of files per status. The 'deleted', 'unknown' |
|
25 | 25 | and 'ignored' properties are only relevant to the working copy. |
|
26 | 26 | ''' |
|
27 | 27 | |
|
28 | 28 | __slots__ = () |
|
29 | 29 | |
|
30 | 30 | def __new__(cls, modified, added, removed, deleted, unknown, ignored, |
|
31 | 31 | clean): |
|
32 | 32 | return tuple.__new__(cls, (modified, added, removed, deleted, unknown, |
|
33 | 33 | ignored, clean)) |
|
34 | 34 | |
|
35 | 35 | @property |
|
36 | 36 | def modified(self): |
|
37 | 37 | '''files that have been modified''' |
|
38 | 38 | return self[0] |
|
39 | 39 | |
|
40 | 40 | @property |
|
41 | 41 | def added(self): |
|
42 | 42 | '''files that have been added''' |
|
43 | 43 | return self[1] |
|
44 | 44 | |
|
45 | 45 | @property |
|
46 | 46 | def removed(self): |
|
47 | 47 | '''files that have been removed''' |
|
48 | 48 | return self[2] |
|
49 | 49 | |
|
50 | 50 | @property |
|
51 | 51 | def deleted(self): |
|
52 | 52 | '''files that are in the dirstate, but have been deleted from the |
|
53 | 53 | working copy (aka "missing") |
|
54 | 54 | ''' |
|
55 | 55 | return self[3] |
|
56 | 56 | |
|
57 | 57 | @property |
|
58 | 58 | def unknown(self): |
|
59 | 59 | '''files not in the dirstate that are not ignored''' |
|
60 | 60 | return self[4] |
|
61 | 61 | |
|
62 | 62 | @property |
|
63 | 63 | def ignored(self): |
|
64 | 64 | '''files not in the dirstate that are ignored (by _dirignore())''' |
|
65 | 65 | return self[5] |
|
66 | 66 | |
|
67 | 67 | @property |
|
68 | 68 | def clean(self): |
|
69 | 69 | '''files that have not been modified''' |
|
70 | 70 | return self[6] |
|
71 | 71 | |
|
72 | 72 | def __repr__(self, *args, **kwargs): |
|
73 | 73 | return (('<status modified=%r, added=%r, removed=%r, deleted=%r, ' |
|
74 | 74 | 'unknown=%r, ignored=%r, clean=%r>') % self) |
|
75 | 75 | |
|
76 | 76 | def itersubrepos(ctx1, ctx2): |
|
77 | 77 | """find subrepos in ctx1 or ctx2""" |
|
78 | 78 | # Create a (subpath, ctx) mapping where we prefer subpaths from |
|
79 | 79 | # ctx1. The subpaths from ctx2 are important when the .hgsub file |
|
80 | 80 | # has been modified (in ctx2) but not yet committed (in ctx1). |
|
81 | 81 | subpaths = dict.fromkeys(ctx2.substate, ctx2) |
|
82 | 82 | subpaths.update(dict.fromkeys(ctx1.substate, ctx1)) |
|
83 | 83 | for subpath, ctx in sorted(subpaths.iteritems()): |
|
84 | 84 | yield subpath, ctx.sub(subpath) |
|
85 | 85 | |
|
86 | 86 | def nochangesfound(ui, repo, excluded=None): |
|
87 | 87 | '''Report no changes for push/pull, excluded is None or a list of |
|
88 | 88 | nodes excluded from the push/pull. |
|
89 | 89 | ''' |
|
90 | 90 | secretlist = [] |
|
91 | 91 | if excluded: |
|
92 | 92 | for n in excluded: |
|
93 | 93 | if n not in repo: |
|
94 | 94 | # discovery should not have included the filtered revision, |
|
95 | 95 | # we have to explicitly exclude it until discovery is cleanup. |
|
96 | 96 | continue |
|
97 | 97 | ctx = repo[n] |
|
98 | 98 | if ctx.phase() >= phases.secret and not ctx.extinct(): |
|
99 | 99 | secretlist.append(n) |
|
100 | 100 | |
|
101 | 101 | if secretlist: |
|
102 | 102 | ui.status(_("no changes found (ignored %d secret changesets)\n") |
|
103 | 103 | % len(secretlist)) |
|
104 | 104 | else: |
|
105 | 105 | ui.status(_("no changes found\n")) |
|
106 | 106 | |
|
107 | 107 | def checknewlabel(repo, lbl, kind): |
|
108 | 108 | # Do not use the "kind" parameter in ui output. |
|
109 | 109 | # It makes strings difficult to translate. |
|
110 | 110 | if lbl in ['tip', '.', 'null']: |
|
111 | 111 | raise util.Abort(_("the name '%s' is reserved") % lbl) |
|
112 | 112 | for c in (':', '\0', '\n', '\r'): |
|
113 | 113 | if c in lbl: |
|
114 | 114 | raise util.Abort(_("%r cannot be used in a name") % c) |
|
115 | 115 | try: |
|
116 | 116 | int(lbl) |
|
117 | 117 | raise util.Abort(_("cannot use an integer as a name")) |
|
118 | 118 | except ValueError: |
|
119 | 119 | pass |
|
120 | 120 | |
|
121 | 121 | def checkfilename(f): |
|
122 | 122 | '''Check that the filename f is an acceptable filename for a tracked file''' |
|
123 | 123 | if '\r' in f or '\n' in f: |
|
124 | 124 | raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) |
|
125 | 125 | |
|
126 | 126 | def checkportable(ui, f): |
|
127 | 127 | '''Check if filename f is portable and warn or abort depending on config''' |
|
128 | 128 | checkfilename(f) |
|
129 | 129 | abort, warn = checkportabilityalert(ui) |
|
130 | 130 | if abort or warn: |
|
131 | 131 | msg = util.checkwinfilename(f) |
|
132 | 132 | if msg: |
|
133 | 133 | msg = "%s: %r" % (msg, f) |
|
134 | 134 | if abort: |
|
135 | 135 | raise util.Abort(msg) |
|
136 | 136 | ui.warn(_("warning: %s\n") % msg) |
|
137 | 137 | |
|
138 | 138 | def checkportabilityalert(ui): |
|
139 | 139 | '''check if the user's config requests nothing, a warning, or abort for |
|
140 | 140 | non-portable filenames''' |
|
141 | 141 | val = ui.config('ui', 'portablefilenames', 'warn') |
|
142 | 142 | lval = val.lower() |
|
143 | 143 | bval = util.parsebool(val) |
|
144 | 144 | abort = os.name == 'nt' or lval == 'abort' |
|
145 | 145 | warn = bval or lval == 'warn' |
|
146 | 146 | if bval is None and not (warn or abort or lval == 'ignore'): |
|
147 | 147 | raise error.ConfigError( |
|
148 | 148 | _("ui.portablefilenames value is invalid ('%s')") % val) |
|
149 | 149 | return abort, warn |
|
150 | 150 | |
|
151 | 151 | class casecollisionauditor(object): |
|
152 | 152 | def __init__(self, ui, abort, dirstate): |
|
153 | 153 | self._ui = ui |
|
154 | 154 | self._abort = abort |
|
155 | 155 | allfiles = '\0'.join(dirstate._map) |
|
156 | 156 | self._loweredfiles = set(encoding.lower(allfiles).split('\0')) |
|
157 | 157 | self._dirstate = dirstate |
|
158 | 158 | # The purpose of _newfiles is so that we don't complain about |
|
159 | 159 | # case collisions if someone were to call this object with the |
|
160 | 160 | # same filename twice. |
|
161 | 161 | self._newfiles = set() |
|
162 | 162 | |
|
163 | 163 | def __call__(self, f): |
|
164 | 164 | if f in self._newfiles: |
|
165 | 165 | return |
|
166 | 166 | fl = encoding.lower(f) |
|
167 | 167 | if fl in self._loweredfiles and f not in self._dirstate: |
|
168 | 168 | msg = _('possible case-folding collision for %s') % f |
|
169 | 169 | if self._abort: |
|
170 | 170 | raise util.Abort(msg) |
|
171 | 171 | self._ui.warn(_("warning: %s\n") % msg) |
|
172 | 172 | self._loweredfiles.add(fl) |
|
173 | 173 | self._newfiles.add(f) |
|
174 | 174 | |
|
175 | 175 | class abstractvfs(object): |
|
176 | 176 | """Abstract base class; cannot be instantiated""" |
|
177 | 177 | |
|
178 | 178 | def __init__(self, *args, **kwargs): |
|
179 | 179 | '''Prevent instantiation; don't call this from subclasses.''' |
|
180 | 180 | raise NotImplementedError('attempted instantiating ' + str(type(self))) |
|
181 | 181 | |
|
182 | 182 | def tryread(self, path): |
|
183 | 183 | '''gracefully return an empty string for missing files''' |
|
184 | 184 | try: |
|
185 | 185 | return self.read(path) |
|
186 | 186 | except IOError, inst: |
|
187 | 187 | if inst.errno != errno.ENOENT: |
|
188 | 188 | raise |
|
189 | 189 | return "" |
|
190 | 190 | |
|
191 | 191 | def open(self, path, mode="r", text=False, atomictemp=False): |
|
192 | 192 | self.open = self.__call__ |
|
193 | 193 | return self.__call__(path, mode, text, atomictemp) |
|
194 | 194 | |
|
195 | 195 | def read(self, path): |
|
196 | 196 | fp = self(path, 'rb') |
|
197 | 197 | try: |
|
198 | 198 | return fp.read() |
|
199 | 199 | finally: |
|
200 | 200 | fp.close() |
|
201 | 201 | |
|
202 | 202 | def write(self, path, data): |
|
203 | 203 | fp = self(path, 'wb') |
|
204 | 204 | try: |
|
205 | 205 | return fp.write(data) |
|
206 | 206 | finally: |
|
207 | 207 | fp.close() |
|
208 | 208 | |
|
209 | 209 | def append(self, path, data): |
|
210 | 210 | fp = self(path, 'ab') |
|
211 | 211 | try: |
|
212 | 212 | return fp.write(data) |
|
213 | 213 | finally: |
|
214 | 214 | fp.close() |
|
215 | 215 | |
|
216 | 216 | def chmod(self, path, mode): |
|
217 | 217 | return os.chmod(self.join(path), mode) |
|
218 | 218 | |
|
219 | 219 | def exists(self, path=None): |
|
220 | 220 | return os.path.exists(self.join(path)) |
|
221 | 221 | |
|
222 | 222 | def fstat(self, fp): |
|
223 | 223 | return util.fstat(fp) |
|
224 | 224 | |
|
225 | 225 | def isdir(self, path=None): |
|
226 | 226 | return os.path.isdir(self.join(path)) |
|
227 | 227 | |
|
228 | 228 | def isfile(self, path=None): |
|
229 | 229 | return os.path.isfile(self.join(path)) |
|
230 | 230 | |
|
231 | 231 | def islink(self, path=None): |
|
232 | 232 | return os.path.islink(self.join(path)) |
|
233 | 233 | |
|
234 | 234 | def lexists(self, path=None): |
|
235 | 235 | return os.path.lexists(self.join(path)) |
|
236 | 236 | |
|
237 | 237 | def lstat(self, path=None): |
|
238 | 238 | return os.lstat(self.join(path)) |
|
239 | 239 | |
|
240 | 240 | def listdir(self, path=None): |
|
241 | 241 | return os.listdir(self.join(path)) |
|
242 | 242 | |
|
243 | 243 | def makedir(self, path=None, notindexed=True): |
|
244 | 244 | return util.makedir(self.join(path), notindexed) |
|
245 | 245 | |
|
246 | 246 | def makedirs(self, path=None, mode=None): |
|
247 | 247 | return util.makedirs(self.join(path), mode) |
|
248 | 248 | |
|
249 | 249 | def makelock(self, info, path): |
|
250 | 250 | return util.makelock(info, self.join(path)) |
|
251 | 251 | |
|
252 | 252 | def mkdir(self, path=None): |
|
253 | 253 | return os.mkdir(self.join(path)) |
|
254 | 254 | |
|
255 | 255 | def mkstemp(self, suffix='', prefix='tmp', dir=None, text=False): |
|
256 | 256 | fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, |
|
257 | 257 | dir=self.join(dir), text=text) |
|
258 | 258 | dname, fname = util.split(name) |
|
259 | 259 | if dir: |
|
260 | 260 | return fd, os.path.join(dir, fname) |
|
261 | 261 | else: |
|
262 | 262 | return fd, fname |
|
263 | 263 | |
|
264 | 264 | def readdir(self, path=None, stat=None, skip=None): |
|
265 | 265 | return osutil.listdir(self.join(path), stat, skip) |
|
266 | 266 | |
|
267 | 267 | def readlock(self, path): |
|
268 | 268 | return util.readlock(self.join(path)) |
|
269 | 269 | |
|
270 | 270 | def rename(self, src, dst): |
|
271 | 271 | return util.rename(self.join(src), self.join(dst)) |
|
272 | 272 | |
|
273 | 273 | def readlink(self, path): |
|
274 | 274 | return os.readlink(self.join(path)) |
|
275 | 275 | |
|
276 | 276 | def setflags(self, path, l, x): |
|
277 | 277 | return util.setflags(self.join(path), l, x) |
|
278 | 278 | |
|
279 | 279 | def stat(self, path=None): |
|
280 | 280 | return os.stat(self.join(path)) |
|
281 | 281 | |
|
282 | 282 | def unlink(self, path=None): |
|
283 | 283 | return util.unlink(self.join(path)) |
|
284 | 284 | |
|
285 | 285 | def unlinkpath(self, path=None, ignoremissing=False): |
|
286 | 286 | return util.unlinkpath(self.join(path), ignoremissing) |
|
287 | 287 | |
|
288 | 288 | def utime(self, path=None, t=None): |
|
289 | 289 | return os.utime(self.join(path), t) |
|
290 | 290 | |
|
291 | 291 | class vfs(abstractvfs): |
|
292 | 292 | '''Operate files relative to a base directory |
|
293 | 293 | |
|
294 | 294 | This class is used to hide the details of COW semantics and |
|
295 | 295 | remote file access from higher level code. |
|
296 | 296 | ''' |
|
297 | 297 | def __init__(self, base, audit=True, expandpath=False, realpath=False): |
|
298 | 298 | if expandpath: |
|
299 | 299 | base = util.expandpath(base) |
|
300 | 300 | if realpath: |
|
301 | 301 | base = os.path.realpath(base) |
|
302 | 302 | self.base = base |
|
303 | 303 | self._setmustaudit(audit) |
|
304 | 304 | self.createmode = None |
|
305 | 305 | self._trustnlink = None |
|
306 | 306 | |
|
307 | 307 | def _getmustaudit(self): |
|
308 | 308 | return self._audit |
|
309 | 309 | |
|
310 | 310 | def _setmustaudit(self, onoff): |
|
311 | 311 | self._audit = onoff |
|
312 | 312 | if onoff: |
|
313 | 313 | self.audit = pathutil.pathauditor(self.base) |
|
314 | 314 | else: |
|
315 | 315 | self.audit = util.always |
|
316 | 316 | |
|
317 | 317 | mustaudit = property(_getmustaudit, _setmustaudit) |
|
318 | 318 | |
|
319 | 319 | @util.propertycache |
|
320 | 320 | def _cansymlink(self): |
|
321 | 321 | return util.checklink(self.base) |
|
322 | 322 | |
|
323 | 323 | @util.propertycache |
|
324 | 324 | def _chmod(self): |
|
325 | 325 | return util.checkexec(self.base) |
|
326 | 326 | |
|
327 | 327 | def _fixfilemode(self, name): |
|
328 | 328 | if self.createmode is None or not self._chmod: |
|
329 | 329 | return |
|
330 | 330 | os.chmod(name, self.createmode & 0666) |
|
331 | 331 | |
|
332 | 332 | def __call__(self, path, mode="r", text=False, atomictemp=False): |
|
333 | 333 | if self._audit: |
|
334 | 334 | r = util.checkosfilename(path) |
|
335 | 335 | if r: |
|
336 | 336 | raise util.Abort("%s: %r" % (r, path)) |
|
337 | 337 | self.audit(path) |
|
338 | 338 | f = self.join(path) |
|
339 | 339 | |
|
340 | 340 | if not text and "b" not in mode: |
|
341 | 341 | mode += "b" # for that other OS |
|
342 | 342 | |
|
343 | 343 | nlink = -1 |
|
344 | 344 | if mode not in ('r', 'rb'): |
|
345 | 345 | dirname, basename = util.split(f) |
|
346 | 346 | # If basename is empty, then the path is malformed because it points |
|
347 | 347 | # to a directory. Let the posixfile() call below raise IOError. |
|
348 | 348 | if basename: |
|
349 | 349 | if atomictemp: |
|
350 | 350 | util.ensuredirs(dirname, self.createmode) |
|
351 | 351 | return util.atomictempfile(f, mode, self.createmode) |
|
352 | 352 | try: |
|
353 | 353 | if 'w' in mode: |
|
354 | 354 | util.unlink(f) |
|
355 | 355 | nlink = 0 |
|
356 | 356 | else: |
|
357 | 357 | # nlinks() may behave differently for files on Windows |
|
358 | 358 | # shares if the file is open. |
|
359 | 359 | fd = util.posixfile(f) |
|
360 | 360 | nlink = util.nlinks(f) |
|
361 | 361 | if nlink < 1: |
|
362 | 362 | nlink = 2 # force mktempcopy (issue1922) |
|
363 | 363 | fd.close() |
|
364 | 364 | except (OSError, IOError), e: |
|
365 | 365 | if e.errno != errno.ENOENT: |
|
366 | 366 | raise |
|
367 | 367 | nlink = 0 |
|
368 | 368 | util.ensuredirs(dirname, self.createmode) |
|
369 | 369 | if nlink > 0: |
|
370 | 370 | if self._trustnlink is None: |
|
371 | 371 | self._trustnlink = nlink > 1 or util.checknlink(f) |
|
372 | 372 | if nlink > 1 or not self._trustnlink: |
|
373 | 373 | util.rename(util.mktempcopy(f), f) |
|
374 | 374 | fp = util.posixfile(f, mode) |
|
375 | 375 | if nlink == 0: |
|
376 | 376 | self._fixfilemode(f) |
|
377 | 377 | return fp |
|
378 | 378 | |
|
379 | 379 | def symlink(self, src, dst): |
|
380 | 380 | self.audit(dst) |
|
381 | 381 | linkname = self.join(dst) |
|
382 | 382 | try: |
|
383 | 383 | os.unlink(linkname) |
|
384 | 384 | except OSError: |
|
385 | 385 | pass |
|
386 | 386 | |
|
387 | 387 | util.ensuredirs(os.path.dirname(linkname), self.createmode) |
|
388 | 388 | |
|
389 | 389 | if self._cansymlink: |
|
390 | 390 | try: |
|
391 | 391 | os.symlink(src, linkname) |
|
392 | 392 | except OSError, err: |
|
393 | 393 | raise OSError(err.errno, _('could not symlink to %r: %s') % |
|
394 | 394 | (src, err.strerror), linkname) |
|
395 | 395 | else: |
|
396 | 396 | self.write(dst, src) |
|
397 | 397 | |
|
398 | 398 | def join(self, path): |
|
399 | 399 | if path: |
|
400 | 400 | return os.path.join(self.base, path) |
|
401 | 401 | else: |
|
402 | 402 | return self.base |
|
403 | 403 | |
|
404 | 404 | opener = vfs |
|
405 | 405 | |
|
406 | 406 | class auditvfs(object): |
|
407 | 407 | def __init__(self, vfs): |
|
408 | 408 | self.vfs = vfs |
|
409 | 409 | |
|
410 | 410 | def _getmustaudit(self): |
|
411 | 411 | return self.vfs.mustaudit |
|
412 | 412 | |
|
413 | 413 | def _setmustaudit(self, onoff): |
|
414 | 414 | self.vfs.mustaudit = onoff |
|
415 | 415 | |
|
416 | 416 | mustaudit = property(_getmustaudit, _setmustaudit) |
|
417 | 417 | |
|
418 | 418 | class filtervfs(abstractvfs, auditvfs): |
|
419 | 419 | '''Wrapper vfs for filtering filenames with a function.''' |
|
420 | 420 | |
|
421 | 421 | def __init__(self, vfs, filter): |
|
422 | 422 | auditvfs.__init__(self, vfs) |
|
423 | 423 | self._filter = filter |
|
424 | 424 | |
|
425 | 425 | def __call__(self, path, *args, **kwargs): |
|
426 | 426 | return self.vfs(self._filter(path), *args, **kwargs) |
|
427 | 427 | |
|
428 | 428 | def join(self, path): |
|
429 | 429 | if path: |
|
430 | 430 | return self.vfs.join(self._filter(path)) |
|
431 | 431 | else: |
|
432 | 432 | return self.vfs.join(path) |
|
433 | 433 | |
|
434 | 434 | filteropener = filtervfs |
|
435 | 435 | |
|
436 | 436 | class readonlyvfs(abstractvfs, auditvfs): |
|
437 | 437 | '''Wrapper vfs preventing any writing.''' |
|
438 | 438 | |
|
439 | 439 | def __init__(self, vfs): |
|
440 | 440 | auditvfs.__init__(self, vfs) |
|
441 | 441 | |
|
442 | 442 | def __call__(self, path, mode='r', *args, **kw): |
|
443 | 443 | if mode not in ('r', 'rb'): |
|
444 | 444 | raise util.Abort('this vfs is read only') |
|
445 | 445 | return self.vfs(path, mode, *args, **kw) |
|
446 | 446 | |
|
447 | 447 | |
|
448 | 448 | def walkrepos(path, followsym=False, seen_dirs=None, recurse=False): |
|
449 | 449 | '''yield every hg repository under path, always recursively. |
|
450 | 450 | The recurse flag will only control recursion into repo working dirs''' |
|
451 | 451 | def errhandler(err): |
|
452 | 452 | if err.filename == path: |
|
453 | 453 | raise err |
|
454 | 454 | samestat = getattr(os.path, 'samestat', None) |
|
455 | 455 | if followsym and samestat is not None: |
|
456 | 456 | def adddir(dirlst, dirname): |
|
457 | 457 | match = False |
|
458 | 458 | dirstat = os.stat(dirname) |
|
459 | 459 | for lstdirstat in dirlst: |
|
460 | 460 | if samestat(dirstat, lstdirstat): |
|
461 | 461 | match = True |
|
462 | 462 | break |
|
463 | 463 | if not match: |
|
464 | 464 | dirlst.append(dirstat) |
|
465 | 465 | return not match |
|
466 | 466 | else: |
|
467 | 467 | followsym = False |
|
468 | 468 | |
|
469 | 469 | if (seen_dirs is None) and followsym: |
|
470 | 470 | seen_dirs = [] |
|
471 | 471 | adddir(seen_dirs, path) |
|
472 | 472 | for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): |
|
473 | 473 | dirs.sort() |
|
474 | 474 | if '.hg' in dirs: |
|
475 | 475 | yield root # found a repository |
|
476 | 476 | qroot = os.path.join(root, '.hg', 'patches') |
|
477 | 477 | if os.path.isdir(os.path.join(qroot, '.hg')): |
|
478 | 478 | yield qroot # we have a patch queue repo here |
|
479 | 479 | if recurse: |
|
480 | 480 | # avoid recursing inside the .hg directory |
|
481 | 481 | dirs.remove('.hg') |
|
482 | 482 | else: |
|
483 | 483 | dirs[:] = [] # don't descend further |
|
484 | 484 | elif followsym: |
|
485 | 485 | newdirs = [] |
|
486 | 486 | for d in dirs: |
|
487 | 487 | fname = os.path.join(root, d) |
|
488 | 488 | if adddir(seen_dirs, fname): |
|
489 | 489 | if os.path.islink(fname): |
|
490 | 490 | for hgname in walkrepos(fname, True, seen_dirs): |
|
491 | 491 | yield hgname |
|
492 | 492 | else: |
|
493 | 493 | newdirs.append(d) |
|
494 | 494 | dirs[:] = newdirs |
|
495 | 495 | |
|
496 | 496 | def osrcpath(): |
|
497 | 497 | '''return default os-specific hgrc search path''' |
|
498 | path = systemrcpath() | |
|
498 | path = [] | |
|
499 | defaultpath = os.path.join(util.datapath, 'default.d') | |
|
500 | if os.path.isdir(defaultpath): | |
|
501 | for f, kind in osutil.listdir(defaultpath): | |
|
502 | if f.endswith('.rc'): | |
|
503 | path.append(os.path.join(defaultpath, f)) | |
|
504 | path.extend(systemrcpath()) | |
|
499 | 505 | path.extend(userrcpath()) |
|
500 | 506 | path = [os.path.normpath(f) for f in path] |
|
501 | 507 | return path |
|
502 | 508 | |
|
503 | 509 | _rcpath = None |
|
504 | 510 | |
|
505 | 511 | def rcpath(): |
|
506 | 512 | '''return hgrc search path. if env var HGRCPATH is set, use it. |
|
507 | 513 | for each item in path, if directory, use files ending in .rc, |
|
508 | 514 | else use item. |
|
509 | 515 | make HGRCPATH empty to only look in .hg/hgrc of current repo. |
|
510 | 516 | if no HGRCPATH, use default os-specific path.''' |
|
511 | 517 | global _rcpath |
|
512 | 518 | if _rcpath is None: |
|
513 | 519 | if 'HGRCPATH' in os.environ: |
|
514 | 520 | _rcpath = [] |
|
515 | 521 | for p in os.environ['HGRCPATH'].split(os.pathsep): |
|
516 | 522 | if not p: |
|
517 | 523 | continue |
|
518 | 524 | p = util.expandpath(p) |
|
519 | 525 | if os.path.isdir(p): |
|
520 | 526 | for f, kind in osutil.listdir(p): |
|
521 | 527 | if f.endswith('.rc'): |
|
522 | 528 | _rcpath.append(os.path.join(p, f)) |
|
523 | 529 | else: |
|
524 | 530 | _rcpath.append(p) |
|
525 | 531 | else: |
|
526 | 532 | _rcpath = osrcpath() |
|
527 | 533 | return _rcpath |
|
528 | 534 | |
|
529 | 535 | def revsingle(repo, revspec, default='.'): |
|
530 | 536 | if not revspec and revspec != 0: |
|
531 | 537 | return repo[default] |
|
532 | 538 | |
|
533 | 539 | l = revrange(repo, [revspec]) |
|
534 | 540 | if not l: |
|
535 | 541 | raise util.Abort(_('empty revision set')) |
|
536 | 542 | return repo[l.last()] |
|
537 | 543 | |
|
538 | 544 | def revpair(repo, revs): |
|
539 | 545 | if not revs: |
|
540 | 546 | return repo.dirstate.p1(), None |
|
541 | 547 | |
|
542 | 548 | l = revrange(repo, revs) |
|
543 | 549 | |
|
544 | 550 | if not l: |
|
545 | 551 | first = second = None |
|
546 | 552 | elif l.isascending(): |
|
547 | 553 | first = l.min() |
|
548 | 554 | second = l.max() |
|
549 | 555 | elif l.isdescending(): |
|
550 | 556 | first = l.max() |
|
551 | 557 | second = l.min() |
|
552 | 558 | else: |
|
553 | 559 | first = l.first() |
|
554 | 560 | second = l.last() |
|
555 | 561 | |
|
556 | 562 | if first is None: |
|
557 | 563 | raise util.Abort(_('empty revision range')) |
|
558 | 564 | |
|
559 | 565 | if first == second and len(revs) == 1 and _revrangesep not in revs[0]: |
|
560 | 566 | return repo.lookup(first), None |
|
561 | 567 | |
|
562 | 568 | return repo.lookup(first), repo.lookup(second) |
|
563 | 569 | |
|
564 | 570 | _revrangesep = ':' |
|
565 | 571 | |
|
566 | 572 | def revrange(repo, revs): |
|
567 | 573 | """Yield revision as strings from a list of revision specifications.""" |
|
568 | 574 | |
|
569 | 575 | def revfix(repo, val, defval): |
|
570 | 576 | if not val and val != 0 and defval is not None: |
|
571 | 577 | return defval |
|
572 | 578 | return repo[val].rev() |
|
573 | 579 | |
|
574 | 580 | seen, l = set(), revset.baseset([]) |
|
575 | 581 | for spec in revs: |
|
576 | 582 | if l and not seen: |
|
577 | 583 | seen = set(l) |
|
578 | 584 | # attempt to parse old-style ranges first to deal with |
|
579 | 585 | # things like old-tag which contain query metacharacters |
|
580 | 586 | try: |
|
581 | 587 | if isinstance(spec, int): |
|
582 | 588 | seen.add(spec) |
|
583 | 589 | l = l + revset.baseset([spec]) |
|
584 | 590 | continue |
|
585 | 591 | |
|
586 | 592 | if _revrangesep in spec: |
|
587 | 593 | start, end = spec.split(_revrangesep, 1) |
|
588 | 594 | start = revfix(repo, start, 0) |
|
589 | 595 | end = revfix(repo, end, len(repo) - 1) |
|
590 | 596 | if end == nullrev and start < 0: |
|
591 | 597 | start = nullrev |
|
592 | 598 | rangeiter = repo.changelog.revs(start, end) |
|
593 | 599 | if not seen and not l: |
|
594 | 600 | # by far the most common case: revs = ["-1:0"] |
|
595 | 601 | l = revset.baseset(rangeiter) |
|
596 | 602 | # defer syncing seen until next iteration |
|
597 | 603 | continue |
|
598 | 604 | newrevs = set(rangeiter) |
|
599 | 605 | if seen: |
|
600 | 606 | newrevs.difference_update(seen) |
|
601 | 607 | seen.update(newrevs) |
|
602 | 608 | else: |
|
603 | 609 | seen = newrevs |
|
604 | 610 | l = l + revset.baseset(sorted(newrevs, reverse=start > end)) |
|
605 | 611 | continue |
|
606 | 612 | elif spec and spec in repo: # single unquoted rev |
|
607 | 613 | rev = revfix(repo, spec, None) |
|
608 | 614 | if rev in seen: |
|
609 | 615 | continue |
|
610 | 616 | seen.add(rev) |
|
611 | 617 | l = l + revset.baseset([rev]) |
|
612 | 618 | continue |
|
613 | 619 | except error.RepoLookupError: |
|
614 | 620 | pass |
|
615 | 621 | |
|
616 | 622 | # fall through to new-style queries if old-style fails |
|
617 | 623 | m = revset.match(repo.ui, spec, repo) |
|
618 | 624 | if seen or l: |
|
619 | 625 | dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen] |
|
620 | 626 | l = l + revset.baseset(dl) |
|
621 | 627 | seen.update(dl) |
|
622 | 628 | else: |
|
623 | 629 | l = m(repo, revset.spanset(repo)) |
|
624 | 630 | |
|
625 | 631 | return l |
|
626 | 632 | |
|
627 | 633 | def expandpats(pats): |
|
628 | 634 | '''Expand bare globs when running on windows. |
|
629 | 635 | On posix we assume it already has already been done by sh.''' |
|
630 | 636 | if not util.expandglobs: |
|
631 | 637 | return list(pats) |
|
632 | 638 | ret = [] |
|
633 | 639 | for kindpat in pats: |
|
634 | 640 | kind, pat = matchmod._patsplit(kindpat, None) |
|
635 | 641 | if kind is None: |
|
636 | 642 | try: |
|
637 | 643 | globbed = glob.glob(pat) |
|
638 | 644 | except re.error: |
|
639 | 645 | globbed = [pat] |
|
640 | 646 | if globbed: |
|
641 | 647 | ret.extend(globbed) |
|
642 | 648 | continue |
|
643 | 649 | ret.append(kindpat) |
|
644 | 650 | return ret |
|
645 | 651 | |
|
646 | 652 | def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'): |
|
647 | 653 | '''Return a matcher and the patterns that were used. |
|
648 | 654 | The matcher will warn about bad matches.''' |
|
649 | 655 | if pats == ("",): |
|
650 | 656 | pats = [] |
|
651 | 657 | if not globbed and default == 'relpath': |
|
652 | 658 | pats = expandpats(pats or []) |
|
653 | 659 | |
|
654 | 660 | m = ctx.match(pats, opts.get('include'), opts.get('exclude'), |
|
655 | 661 | default) |
|
656 | 662 | def badfn(f, msg): |
|
657 | 663 | ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) |
|
658 | 664 | m.bad = badfn |
|
659 | 665 | return m, pats |
|
660 | 666 | |
|
661 | 667 | def match(ctx, pats=[], opts={}, globbed=False, default='relpath'): |
|
662 | 668 | '''Return a matcher that will warn about bad matches.''' |
|
663 | 669 | return matchandpats(ctx, pats, opts, globbed, default)[0] |
|
664 | 670 | |
|
665 | 671 | def matchall(repo): |
|
666 | 672 | '''Return a matcher that will efficiently match everything.''' |
|
667 | 673 | return matchmod.always(repo.root, repo.getcwd()) |
|
668 | 674 | |
|
669 | 675 | def matchfiles(repo, files): |
|
670 | 676 | '''Return a matcher that will efficiently match exactly these files.''' |
|
671 | 677 | return matchmod.exact(repo.root, repo.getcwd(), files) |
|
672 | 678 | |
|
673 | 679 | def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): |
|
674 | 680 | if dry_run is None: |
|
675 | 681 | dry_run = opts.get('dry_run') |
|
676 | 682 | if similarity is None: |
|
677 | 683 | similarity = float(opts.get('similarity') or 0) |
|
678 | 684 | # we'd use status here, except handling of symlinks and ignore is tricky |
|
679 | 685 | m = match(repo[None], pats, opts) |
|
680 | 686 | rejected = [] |
|
681 | 687 | m.bad = lambda x, y: rejected.append(x) |
|
682 | 688 | |
|
683 | 689 | added, unknown, deleted, removed = _interestingfiles(repo, m) |
|
684 | 690 | |
|
685 | 691 | unknownset = set(unknown) |
|
686 | 692 | toprint = unknownset.copy() |
|
687 | 693 | toprint.update(deleted) |
|
688 | 694 | for abs in sorted(toprint): |
|
689 | 695 | if repo.ui.verbose or not m.exact(abs): |
|
690 | 696 | rel = m.rel(abs) |
|
691 | 697 | if abs in unknownset: |
|
692 | 698 | status = _('adding %s\n') % ((pats and rel) or abs) |
|
693 | 699 | else: |
|
694 | 700 | status = _('removing %s\n') % ((pats and rel) or abs) |
|
695 | 701 | repo.ui.status(status) |
|
696 | 702 | |
|
697 | 703 | renames = _findrenames(repo, m, added + unknown, removed + deleted, |
|
698 | 704 | similarity) |
|
699 | 705 | |
|
700 | 706 | if not dry_run: |
|
701 | 707 | _markchanges(repo, unknown, deleted, renames) |
|
702 | 708 | |
|
703 | 709 | for f in rejected: |
|
704 | 710 | if f in m.files(): |
|
705 | 711 | return 1 |
|
706 | 712 | return 0 |
|
707 | 713 | |
|
708 | 714 | def marktouched(repo, files, similarity=0.0): |
|
709 | 715 | '''Assert that files have somehow been operated upon. files are relative to |
|
710 | 716 | the repo root.''' |
|
711 | 717 | m = matchfiles(repo, files) |
|
712 | 718 | rejected = [] |
|
713 | 719 | m.bad = lambda x, y: rejected.append(x) |
|
714 | 720 | |
|
715 | 721 | added, unknown, deleted, removed = _interestingfiles(repo, m) |
|
716 | 722 | |
|
717 | 723 | if repo.ui.verbose: |
|
718 | 724 | unknownset = set(unknown) |
|
719 | 725 | toprint = unknownset.copy() |
|
720 | 726 | toprint.update(deleted) |
|
721 | 727 | for abs in sorted(toprint): |
|
722 | 728 | if abs in unknownset: |
|
723 | 729 | status = _('adding %s\n') % abs |
|
724 | 730 | else: |
|
725 | 731 | status = _('removing %s\n') % abs |
|
726 | 732 | repo.ui.status(status) |
|
727 | 733 | |
|
728 | 734 | renames = _findrenames(repo, m, added + unknown, removed + deleted, |
|
729 | 735 | similarity) |
|
730 | 736 | |
|
731 | 737 | _markchanges(repo, unknown, deleted, renames) |
|
732 | 738 | |
|
733 | 739 | for f in rejected: |
|
734 | 740 | if f in m.files(): |
|
735 | 741 | return 1 |
|
736 | 742 | return 0 |
|
737 | 743 | |
|
738 | 744 | def _interestingfiles(repo, matcher): |
|
739 | 745 | '''Walk dirstate with matcher, looking for files that addremove would care |
|
740 | 746 | about. |
|
741 | 747 | |
|
742 | 748 | This is different from dirstate.status because it doesn't care about |
|
743 | 749 | whether files are modified or clean.''' |
|
744 | 750 | added, unknown, deleted, removed = [], [], [], [] |
|
745 | 751 | audit_path = pathutil.pathauditor(repo.root) |
|
746 | 752 | |
|
747 | 753 | ctx = repo[None] |
|
748 | 754 | dirstate = repo.dirstate |
|
749 | 755 | walkresults = dirstate.walk(matcher, sorted(ctx.substate), True, False, |
|
750 | 756 | full=False) |
|
751 | 757 | for abs, st in walkresults.iteritems(): |
|
752 | 758 | dstate = dirstate[abs] |
|
753 | 759 | if dstate == '?' and audit_path.check(abs): |
|
754 | 760 | unknown.append(abs) |
|
755 | 761 | elif dstate != 'r' and not st: |
|
756 | 762 | deleted.append(abs) |
|
757 | 763 | # for finding renames |
|
758 | 764 | elif dstate == 'r': |
|
759 | 765 | removed.append(abs) |
|
760 | 766 | elif dstate == 'a': |
|
761 | 767 | added.append(abs) |
|
762 | 768 | |
|
763 | 769 | return added, unknown, deleted, removed |
|
764 | 770 | |
|
765 | 771 | def _findrenames(repo, matcher, added, removed, similarity): |
|
766 | 772 | '''Find renames from removed files to added ones.''' |
|
767 | 773 | renames = {} |
|
768 | 774 | if similarity > 0: |
|
769 | 775 | for old, new, score in similar.findrenames(repo, added, removed, |
|
770 | 776 | similarity): |
|
771 | 777 | if (repo.ui.verbose or not matcher.exact(old) |
|
772 | 778 | or not matcher.exact(new)): |
|
773 | 779 | repo.ui.status(_('recording removal of %s as rename to %s ' |
|
774 | 780 | '(%d%% similar)\n') % |
|
775 | 781 | (matcher.rel(old), matcher.rel(new), |
|
776 | 782 | score * 100)) |
|
777 | 783 | renames[new] = old |
|
778 | 784 | return renames |
|
779 | 785 | |
|
780 | 786 | def _markchanges(repo, unknown, deleted, renames): |
|
781 | 787 | '''Marks the files in unknown as added, the files in deleted as removed, |
|
782 | 788 | and the files in renames as copied.''' |
|
783 | 789 | wctx = repo[None] |
|
784 | 790 | wlock = repo.wlock() |
|
785 | 791 | try: |
|
786 | 792 | wctx.forget(deleted) |
|
787 | 793 | wctx.add(unknown) |
|
788 | 794 | for new, old in renames.iteritems(): |
|
789 | 795 | wctx.copy(old, new) |
|
790 | 796 | finally: |
|
791 | 797 | wlock.release() |
|
792 | 798 | |
|
793 | 799 | def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): |
|
794 | 800 | """Update the dirstate to reflect the intent of copying src to dst. For |
|
795 | 801 | different reasons it might not end with dst being marked as copied from src. |
|
796 | 802 | """ |
|
797 | 803 | origsrc = repo.dirstate.copied(src) or src |
|
798 | 804 | if dst == origsrc: # copying back a copy? |
|
799 | 805 | if repo.dirstate[dst] not in 'mn' and not dryrun: |
|
800 | 806 | repo.dirstate.normallookup(dst) |
|
801 | 807 | else: |
|
802 | 808 | if repo.dirstate[origsrc] == 'a' and origsrc == src: |
|
803 | 809 | if not ui.quiet: |
|
804 | 810 | ui.warn(_("%s has not been committed yet, so no copy " |
|
805 | 811 | "data will be stored for %s.\n") |
|
806 | 812 | % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))) |
|
807 | 813 | if repo.dirstate[dst] in '?r' and not dryrun: |
|
808 | 814 | wctx.add([dst]) |
|
809 | 815 | elif not dryrun: |
|
810 | 816 | wctx.copy(origsrc, dst) |
|
811 | 817 | |
|
812 | 818 | def readrequires(opener, supported): |
|
813 | 819 | '''Reads and parses .hg/requires and checks if all entries found |
|
814 | 820 | are in the list of supported features.''' |
|
815 | 821 | requirements = set(opener.read("requires").splitlines()) |
|
816 | 822 | missings = [] |
|
817 | 823 | for r in requirements: |
|
818 | 824 | if r not in supported: |
|
819 | 825 | if not r or not r[0].isalnum(): |
|
820 | 826 | raise error.RequirementError(_(".hg/requires file is corrupt")) |
|
821 | 827 | missings.append(r) |
|
822 | 828 | missings.sort() |
|
823 | 829 | if missings: |
|
824 | 830 | raise error.RequirementError( |
|
825 | 831 | _("repository requires features unknown to this Mercurial: %s") |
|
826 | 832 | % " ".join(missings), |
|
827 | 833 | hint=_("see http://mercurial.selenic.com/wiki/MissingRequirement" |
|
828 | 834 | " for more information")) |
|
829 | 835 | return requirements |
|
830 | 836 | |
|
831 | 837 | class filecachesubentry(object): |
|
832 | 838 | def __init__(self, path, stat): |
|
833 | 839 | self.path = path |
|
834 | 840 | self.cachestat = None |
|
835 | 841 | self._cacheable = None |
|
836 | 842 | |
|
837 | 843 | if stat: |
|
838 | 844 | self.cachestat = filecachesubentry.stat(self.path) |
|
839 | 845 | |
|
840 | 846 | if self.cachestat: |
|
841 | 847 | self._cacheable = self.cachestat.cacheable() |
|
842 | 848 | else: |
|
843 | 849 | # None means we don't know yet |
|
844 | 850 | self._cacheable = None |
|
845 | 851 | |
|
846 | 852 | def refresh(self): |
|
847 | 853 | if self.cacheable(): |
|
848 | 854 | self.cachestat = filecachesubentry.stat(self.path) |
|
849 | 855 | |
|
850 | 856 | def cacheable(self): |
|
851 | 857 | if self._cacheable is not None: |
|
852 | 858 | return self._cacheable |
|
853 | 859 | |
|
854 | 860 | # we don't know yet, assume it is for now |
|
855 | 861 | return True |
|
856 | 862 | |
|
857 | 863 | def changed(self): |
|
858 | 864 | # no point in going further if we can't cache it |
|
859 | 865 | if not self.cacheable(): |
|
860 | 866 | return True |
|
861 | 867 | |
|
862 | 868 | newstat = filecachesubentry.stat(self.path) |
|
863 | 869 | |
|
864 | 870 | # we may not know if it's cacheable yet, check again now |
|
865 | 871 | if newstat and self._cacheable is None: |
|
866 | 872 | self._cacheable = newstat.cacheable() |
|
867 | 873 | |
|
868 | 874 | # check again |
|
869 | 875 | if not self._cacheable: |
|
870 | 876 | return True |
|
871 | 877 | |
|
872 | 878 | if self.cachestat != newstat: |
|
873 | 879 | self.cachestat = newstat |
|
874 | 880 | return True |
|
875 | 881 | else: |
|
876 | 882 | return False |
|
877 | 883 | |
|
878 | 884 | @staticmethod |
|
879 | 885 | def stat(path): |
|
880 | 886 | try: |
|
881 | 887 | return util.cachestat(path) |
|
882 | 888 | except OSError, e: |
|
883 | 889 | if e.errno != errno.ENOENT: |
|
884 | 890 | raise |
|
885 | 891 | |
|
886 | 892 | class filecacheentry(object): |
|
887 | 893 | def __init__(self, paths, stat=True): |
|
888 | 894 | self._entries = [] |
|
889 | 895 | for path in paths: |
|
890 | 896 | self._entries.append(filecachesubentry(path, stat)) |
|
891 | 897 | |
|
892 | 898 | def changed(self): |
|
893 | 899 | '''true if any entry has changed''' |
|
894 | 900 | for entry in self._entries: |
|
895 | 901 | if entry.changed(): |
|
896 | 902 | return True |
|
897 | 903 | return False |
|
898 | 904 | |
|
899 | 905 | def refresh(self): |
|
900 | 906 | for entry in self._entries: |
|
901 | 907 | entry.refresh() |
|
902 | 908 | |
|
903 | 909 | class filecache(object): |
|
904 | 910 | '''A property like decorator that tracks files under .hg/ for updates. |
|
905 | 911 | |
|
906 | 912 | Records stat info when called in _filecache. |
|
907 | 913 | |
|
908 | 914 | On subsequent calls, compares old stat info with new info, and recreates the |
|
909 | 915 | object when any of the files changes, updating the new stat info in |
|
910 | 916 | _filecache. |
|
911 | 917 | |
|
912 | 918 | Mercurial either atomic renames or appends for files under .hg, |
|
913 | 919 | so to ensure the cache is reliable we need the filesystem to be able |
|
914 | 920 | to tell us if a file has been replaced. If it can't, we fallback to |
|
915 | 921 | recreating the object on every call (essentially the same behaviour as |
|
916 | 922 | propertycache). |
|
917 | 923 | |
|
918 | 924 | ''' |
|
919 | 925 | def __init__(self, *paths): |
|
920 | 926 | self.paths = paths |
|
921 | 927 | |
|
922 | 928 | def join(self, obj, fname): |
|
923 | 929 | """Used to compute the runtime path of a cached file. |
|
924 | 930 | |
|
925 | 931 | Users should subclass filecache and provide their own version of this |
|
926 | 932 | function to call the appropriate join function on 'obj' (an instance |
|
927 | 933 | of the class that its member function was decorated). |
|
928 | 934 | """ |
|
929 | 935 | return obj.join(fname) |
|
930 | 936 | |
|
931 | 937 | def __call__(self, func): |
|
932 | 938 | self.func = func |
|
933 | 939 | self.name = func.__name__ |
|
934 | 940 | return self |
|
935 | 941 | |
|
936 | 942 | def __get__(self, obj, type=None): |
|
937 | 943 | # do we need to check if the file changed? |
|
938 | 944 | if self.name in obj.__dict__: |
|
939 | 945 | assert self.name in obj._filecache, self.name |
|
940 | 946 | return obj.__dict__[self.name] |
|
941 | 947 | |
|
942 | 948 | entry = obj._filecache.get(self.name) |
|
943 | 949 | |
|
944 | 950 | if entry: |
|
945 | 951 | if entry.changed(): |
|
946 | 952 | entry.obj = self.func(obj) |
|
947 | 953 | else: |
|
948 | 954 | paths = [self.join(obj, path) for path in self.paths] |
|
949 | 955 | |
|
950 | 956 | # We stat -before- creating the object so our cache doesn't lie if |
|
951 | 957 | # a writer modified between the time we read and stat |
|
952 | 958 | entry = filecacheentry(paths, True) |
|
953 | 959 | entry.obj = self.func(obj) |
|
954 | 960 | |
|
955 | 961 | obj._filecache[self.name] = entry |
|
956 | 962 | |
|
957 | 963 | obj.__dict__[self.name] = entry.obj |
|
958 | 964 | return entry.obj |
|
959 | 965 | |
|
960 | 966 | def __set__(self, obj, value): |
|
961 | 967 | if self.name not in obj._filecache: |
|
962 | 968 | # we add an entry for the missing value because X in __dict__ |
|
963 | 969 | # implies X in _filecache |
|
964 | 970 | paths = [self.join(obj, path) for path in self.paths] |
|
965 | 971 | ce = filecacheentry(paths, False) |
|
966 | 972 | obj._filecache[self.name] = ce |
|
967 | 973 | else: |
|
968 | 974 | ce = obj._filecache[self.name] |
|
969 | 975 | |
|
970 | 976 | ce.obj = value # update cached copy |
|
971 | 977 | obj.__dict__[self.name] = value # update copy returned by obj.x |
|
972 | 978 | |
|
973 | 979 | def __delete__(self, obj): |
|
974 | 980 | try: |
|
975 | 981 | del obj.__dict__[self.name] |
|
976 | 982 | except KeyError: |
|
977 | 983 | raise AttributeError(self.name) |
|
978 | 984 | |
|
979 | 985 | class dirs(object): |
|
980 | 986 | '''a multiset of directory names from a dirstate or manifest''' |
|
981 | 987 | |
|
982 | 988 | def __init__(self, map, skip=None): |
|
983 | 989 | self._dirs = {} |
|
984 | 990 | addpath = self.addpath |
|
985 | 991 | if util.safehasattr(map, 'iteritems') and skip is not None: |
|
986 | 992 | for f, s in map.iteritems(): |
|
987 | 993 | if s[0] != skip: |
|
988 | 994 | addpath(f) |
|
989 | 995 | else: |
|
990 | 996 | for f in map: |
|
991 | 997 | addpath(f) |
|
992 | 998 | |
|
993 | 999 | def addpath(self, path): |
|
994 | 1000 | dirs = self._dirs |
|
995 | 1001 | for base in finddirs(path): |
|
996 | 1002 | if base in dirs: |
|
997 | 1003 | dirs[base] += 1 |
|
998 | 1004 | return |
|
999 | 1005 | dirs[base] = 1 |
|
1000 | 1006 | |
|
1001 | 1007 | def delpath(self, path): |
|
1002 | 1008 | dirs = self._dirs |
|
1003 | 1009 | for base in finddirs(path): |
|
1004 | 1010 | if dirs[base] > 1: |
|
1005 | 1011 | dirs[base] -= 1 |
|
1006 | 1012 | return |
|
1007 | 1013 | del dirs[base] |
|
1008 | 1014 | |
|
1009 | 1015 | def __iter__(self): |
|
1010 | 1016 | return self._dirs.iterkeys() |
|
1011 | 1017 | |
|
1012 | 1018 | def __contains__(self, d): |
|
1013 | 1019 | return d in self._dirs |
|
1014 | 1020 | |
|
1015 | 1021 | if util.safehasattr(parsers, 'dirs'): |
|
1016 | 1022 | dirs = parsers.dirs |
|
1017 | 1023 | |
|
1018 | 1024 | def finddirs(path): |
|
1019 | 1025 | pos = path.rfind('/') |
|
1020 | 1026 | while pos != -1: |
|
1021 | 1027 | yield path[:pos] |
|
1022 | 1028 | pos = path.rfind('/', 0, pos) |
@@ -1,628 +1,629 b'' | |||
|
1 | 1 | # |
|
2 | 2 | # This is the mercurial setup script. |
|
3 | 3 | # |
|
4 | 4 | # 'python setup.py install', or |
|
5 | 5 | # 'python setup.py --help' for more options |
|
6 | 6 | |
|
7 | 7 | import sys, platform |
|
8 | 8 | if getattr(sys, 'version_info', (0, 0, 0)) < (2, 4, 0, 'final'): |
|
9 | 9 | raise SystemExit("Mercurial requires Python 2.4 or later.") |
|
10 | 10 | |
|
11 | 11 | if sys.version_info[0] >= 3: |
|
12 | 12 | def b(s): |
|
13 | 13 | '''A helper function to emulate 2.6+ bytes literals using string |
|
14 | 14 | literals.''' |
|
15 | 15 | return s.encode('latin1') |
|
16 | 16 | printf = eval('print') |
|
17 | 17 | libdir_escape = 'unicode_escape' |
|
18 | 18 | else: |
|
19 | 19 | libdir_escape = 'string_escape' |
|
20 | 20 | def b(s): |
|
21 | 21 | '''A helper function to emulate 2.6+ bytes literals using string |
|
22 | 22 | literals.''' |
|
23 | 23 | return s |
|
24 | 24 | def printf(*args, **kwargs): |
|
25 | 25 | f = kwargs.get('file', sys.stdout) |
|
26 | 26 | end = kwargs.get('end', '\n') |
|
27 | 27 | f.write(b(' ').join(args) + end) |
|
28 | 28 | |
|
29 | 29 | # Solaris Python packaging brain damage |
|
30 | 30 | try: |
|
31 | 31 | import hashlib |
|
32 | 32 | sha = hashlib.sha1() |
|
33 | 33 | except ImportError: |
|
34 | 34 | try: |
|
35 | 35 | import sha |
|
36 | 36 | sha.sha # silence unused import warning |
|
37 | 37 | except ImportError: |
|
38 | 38 | raise SystemExit( |
|
39 | 39 | "Couldn't import standard hashlib (incomplete Python install).") |
|
40 | 40 | |
|
41 | 41 | try: |
|
42 | 42 | import zlib |
|
43 | 43 | zlib.compressobj # silence unused import warning |
|
44 | 44 | except ImportError: |
|
45 | 45 | raise SystemExit( |
|
46 | 46 | "Couldn't import standard zlib (incomplete Python install).") |
|
47 | 47 | |
|
48 | 48 | # The base IronPython distribution (as of 2.7.1) doesn't support bz2 |
|
49 | 49 | isironpython = False |
|
50 | 50 | try: |
|
51 | 51 | isironpython = (platform.python_implementation() |
|
52 | 52 | .lower().find("ironpython") != -1) |
|
53 | 53 | except AttributeError: |
|
54 | 54 | pass |
|
55 | 55 | |
|
56 | 56 | if isironpython: |
|
57 | 57 | sys.stderr.write("warning: IronPython detected (no bz2 support)\n") |
|
58 | 58 | else: |
|
59 | 59 | try: |
|
60 | 60 | import bz2 |
|
61 | 61 | bz2.BZ2Compressor # silence unused import warning |
|
62 | 62 | except ImportError: |
|
63 | 63 | raise SystemExit( |
|
64 | 64 | "Couldn't import standard bz2 (incomplete Python install).") |
|
65 | 65 | |
|
66 | 66 | import os, stat, subprocess, time |
|
67 | 67 | import re |
|
68 | 68 | import shutil |
|
69 | 69 | import tempfile |
|
70 | 70 | from distutils import log |
|
71 | 71 | from distutils.core import setup, Command, Extension |
|
72 | 72 | from distutils.dist import Distribution |
|
73 | 73 | from distutils.command.build import build |
|
74 | 74 | from distutils.command.build_ext import build_ext |
|
75 | 75 | from distutils.command.build_py import build_py |
|
76 | 76 | from distutils.command.install_lib import install_lib |
|
77 | 77 | from distutils.command.install_scripts import install_scripts |
|
78 | 78 | from distutils.spawn import spawn, find_executable |
|
79 | 79 | from distutils import cygwinccompiler, file_util |
|
80 | 80 | from distutils.errors import CCompilerError, DistutilsExecError |
|
81 | 81 | from distutils.sysconfig import get_python_inc, get_config_var |
|
82 | 82 | from distutils.version import StrictVersion |
|
83 | 83 | |
|
84 | 84 | convert2to3 = '--c2to3' in sys.argv |
|
85 | 85 | if convert2to3: |
|
86 | 86 | try: |
|
87 | 87 | from distutils.command.build_py import build_py_2to3 as build_py |
|
88 | 88 | from lib2to3.refactor import get_fixers_from_package as getfixers |
|
89 | 89 | except ImportError: |
|
90 | 90 | if sys.version_info[0] < 3: |
|
91 | 91 | raise SystemExit("--c2to3 is only compatible with python3.") |
|
92 | 92 | raise |
|
93 | 93 | sys.path.append('contrib') |
|
94 | 94 | elif sys.version_info[0] >= 3: |
|
95 | 95 | raise SystemExit("setup.py with python3 needs --c2to3 (experimental)") |
|
96 | 96 | |
|
97 | 97 | scripts = ['hg'] |
|
98 | 98 | if os.name == 'nt': |
|
99 | 99 | scripts.append('contrib/win32/hg.bat') |
|
100 | 100 | |
|
101 | 101 | # simplified version of distutils.ccompiler.CCompiler.has_function |
|
102 | 102 | # that actually removes its temporary files. |
|
103 | 103 | def hasfunction(cc, funcname): |
|
104 | 104 | tmpdir = tempfile.mkdtemp(prefix='hg-install-') |
|
105 | 105 | devnull = oldstderr = None |
|
106 | 106 | try: |
|
107 | 107 | try: |
|
108 | 108 | fname = os.path.join(tmpdir, 'funcname.c') |
|
109 | 109 | f = open(fname, 'w') |
|
110 | 110 | f.write('int main(void) {\n') |
|
111 | 111 | f.write(' %s();\n' % funcname) |
|
112 | 112 | f.write('}\n') |
|
113 | 113 | f.close() |
|
114 | 114 | # Redirect stderr to /dev/null to hide any error messages |
|
115 | 115 | # from the compiler. |
|
116 | 116 | # This will have to be changed if we ever have to check |
|
117 | 117 | # for a function on Windows. |
|
118 | 118 | devnull = open('/dev/null', 'w') |
|
119 | 119 | oldstderr = os.dup(sys.stderr.fileno()) |
|
120 | 120 | os.dup2(devnull.fileno(), sys.stderr.fileno()) |
|
121 | 121 | objects = cc.compile([fname], output_dir=tmpdir) |
|
122 | 122 | cc.link_executable(objects, os.path.join(tmpdir, "a.out")) |
|
123 | 123 | except Exception: |
|
124 | 124 | return False |
|
125 | 125 | return True |
|
126 | 126 | finally: |
|
127 | 127 | if oldstderr is not None: |
|
128 | 128 | os.dup2(oldstderr, sys.stderr.fileno()) |
|
129 | 129 | if devnull is not None: |
|
130 | 130 | devnull.close() |
|
131 | 131 | shutil.rmtree(tmpdir) |
|
132 | 132 | |
|
133 | 133 | # py2exe needs to be installed to work |
|
134 | 134 | try: |
|
135 | 135 | import py2exe |
|
136 | 136 | py2exe.Distribution # silence unused import warning |
|
137 | 137 | py2exeloaded = True |
|
138 | 138 | # import py2exe's patched Distribution class |
|
139 | 139 | from distutils.core import Distribution |
|
140 | 140 | except ImportError: |
|
141 | 141 | py2exeloaded = False |
|
142 | 142 | |
|
143 | 143 | def runcmd(cmd, env): |
|
144 | 144 | if sys.platform == 'plan9': |
|
145 | 145 | # subprocess kludge to work around issues in half-baked Python |
|
146 | 146 | # ports, notably bichued/python: |
|
147 | 147 | _, out, err = os.popen3(cmd) |
|
148 | 148 | return str(out), str(err) |
|
149 | 149 | else: |
|
150 | 150 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
|
151 | 151 | stderr=subprocess.PIPE, env=env) |
|
152 | 152 | out, err = p.communicate() |
|
153 | 153 | return out, err |
|
154 | 154 | |
|
155 | 155 | def runhg(cmd, env): |
|
156 | 156 | out, err = runcmd(cmd, env) |
|
157 | 157 | # If root is executing setup.py, but the repository is owned by |
|
158 | 158 | # another user (as in "sudo python setup.py install") we will get |
|
159 | 159 | # trust warnings since the .hg/hgrc file is untrusted. That is |
|
160 | 160 | # fine, we don't want to load it anyway. Python may warn about |
|
161 | 161 | # a missing __init__.py in mercurial/locale, we also ignore that. |
|
162 | 162 | err = [e for e in err.splitlines() |
|
163 | 163 | if not e.startswith(b('not trusting file')) \ |
|
164 | 164 | and not e.startswith(b('warning: Not importing')) \ |
|
165 | 165 | and not e.startswith(b('obsolete feature not enabled'))] |
|
166 | 166 | if err: |
|
167 | 167 | printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
|
168 | 168 | printf(b('\n').join([b(' ') + e for e in err]), file=sys.stderr) |
|
169 | 169 | return '' |
|
170 | 170 | return out |
|
171 | 171 | |
|
172 | 172 | version = '' |
|
173 | 173 | |
|
174 | 174 | # Execute hg out of this directory with a custom environment which |
|
175 | 175 | # includes the pure Python modules in mercurial/pure. We also take |
|
176 | 176 | # care to not use any hgrc files and do no localization. |
|
177 | 177 | pypath = ['mercurial', os.path.join('mercurial', 'pure')] |
|
178 | 178 | env = {'PYTHONPATH': os.pathsep.join(pypath), |
|
179 | 179 | 'HGRCPATH': '', |
|
180 | 180 | 'LANGUAGE': 'C'} |
|
181 | 181 | if 'LD_LIBRARY_PATH' in os.environ: |
|
182 | 182 | env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
|
183 | 183 | if 'SystemRoot' in os.environ: |
|
184 | 184 | # Copy SystemRoot into the custom environment for Python 2.6 |
|
185 | 185 | # under Windows. Otherwise, the subprocess will fail with |
|
186 | 186 | # error 0xc0150004. See: http://bugs.python.org/issue3440 |
|
187 | 187 | env['SystemRoot'] = os.environ['SystemRoot'] |
|
188 | 188 | |
|
189 | 189 | if os.path.isdir('.hg'): |
|
190 | 190 | cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] |
|
191 | 191 | numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()] |
|
192 | 192 | hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() |
|
193 | 193 | if numerictags: # tag(s) found |
|
194 | 194 | version = numerictags[-1] |
|
195 | 195 | if hgid.endswith('+'): # propagate the dirty status to the tag |
|
196 | 196 | version += '+' |
|
197 | 197 | else: # no tag found |
|
198 | 198 | cmd = [sys.executable, 'hg', 'parents', '--template', |
|
199 | 199 | '{latesttag}+{latesttagdistance}-'] |
|
200 | 200 | version = runhg(cmd, env) + hgid |
|
201 | 201 | if version.endswith('+'): |
|
202 | 202 | version += time.strftime('%Y%m%d') |
|
203 | 203 | elif os.path.exists('.hg_archival.txt'): |
|
204 | 204 | kw = dict([[t.strip() for t in l.split(':', 1)] |
|
205 | 205 | for l in open('.hg_archival.txt')]) |
|
206 | 206 | if 'tag' in kw: |
|
207 | 207 | version = kw['tag'] |
|
208 | 208 | elif 'latesttag' in kw: |
|
209 | 209 | version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw |
|
210 | 210 | else: |
|
211 | 211 | version = kw.get('node', '')[:12] |
|
212 | 212 | |
|
213 | 213 | if version: |
|
214 | 214 | f = open("mercurial/__version__.py", "w") |
|
215 | 215 | f.write('# this file is autogenerated by setup.py\n') |
|
216 | 216 | f.write('version = "%s"\n' % version) |
|
217 | 217 | f.close() |
|
218 | 218 | |
|
219 | 219 | |
|
220 | 220 | try: |
|
221 | 221 | from mercurial import __version__ |
|
222 | 222 | version = __version__.version |
|
223 | 223 | except ImportError: |
|
224 | 224 | version = 'unknown' |
|
225 | 225 | |
|
226 | 226 | class hgbuild(build): |
|
227 | 227 | # Insert hgbuildmo first so that files in mercurial/locale/ are found |
|
228 | 228 | # when build_py is run next. |
|
229 | 229 | sub_commands = [('build_mo', None), |
|
230 | 230 | |
|
231 | 231 | # We also need build_ext before build_py. Otherwise, when 2to3 is |
|
232 | 232 | # called (in build_py), it will not find osutil & friends, |
|
233 | 233 | # thinking that those modules are global and, consequently, making |
|
234 | 234 | # a mess, now that all module imports are global. |
|
235 | 235 | |
|
236 | 236 | ('build_ext', build.has_ext_modules), |
|
237 | 237 | ] + build.sub_commands |
|
238 | 238 | |
|
239 | 239 | class hgbuildmo(build): |
|
240 | 240 | |
|
241 | 241 | description = "build translations (.mo files)" |
|
242 | 242 | |
|
243 | 243 | def run(self): |
|
244 | 244 | if not find_executable('msgfmt'): |
|
245 | 245 | self.warn("could not find msgfmt executable, no translations " |
|
246 | 246 | "will be built") |
|
247 | 247 | return |
|
248 | 248 | |
|
249 | 249 | podir = 'i18n' |
|
250 | 250 | if not os.path.isdir(podir): |
|
251 | 251 | self.warn("could not find %s/ directory" % podir) |
|
252 | 252 | return |
|
253 | 253 | |
|
254 | 254 | join = os.path.join |
|
255 | 255 | for po in os.listdir(podir): |
|
256 | 256 | if not po.endswith('.po'): |
|
257 | 257 | continue |
|
258 | 258 | pofile = join(podir, po) |
|
259 | 259 | modir = join('locale', po[:-3], 'LC_MESSAGES') |
|
260 | 260 | mofile = join(modir, 'hg.mo') |
|
261 | 261 | mobuildfile = join('mercurial', mofile) |
|
262 | 262 | cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile] |
|
263 | 263 | if sys.platform != 'sunos5': |
|
264 | 264 | # msgfmt on Solaris does not know about -c |
|
265 | 265 | cmd.append('-c') |
|
266 | 266 | self.mkpath(join('mercurial', modir)) |
|
267 | 267 | self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
|
268 | 268 | |
|
269 | 269 | |
|
270 | 270 | class hgdist(Distribution): |
|
271 | 271 | pure = 0 |
|
272 | 272 | |
|
273 | 273 | global_options = Distribution.global_options + \ |
|
274 | 274 | [('pure', None, "use pure (slow) Python " |
|
275 | 275 | "code instead of C extensions"), |
|
276 | 276 | ('c2to3', None, "(experimental!) convert " |
|
277 | 277 | "code with 2to3"), |
|
278 | 278 | ] |
|
279 | 279 | |
|
280 | 280 | def has_ext_modules(self): |
|
281 | 281 | # self.ext_modules is emptied in hgbuildpy.finalize_options which is |
|
282 | 282 | # too late for some cases |
|
283 | 283 | return not self.pure and Distribution.has_ext_modules(self) |
|
284 | 284 | |
|
285 | 285 | class hgbuildext(build_ext): |
|
286 | 286 | |
|
287 | 287 | def build_extension(self, ext): |
|
288 | 288 | try: |
|
289 | 289 | build_ext.build_extension(self, ext) |
|
290 | 290 | except CCompilerError: |
|
291 | 291 | if not getattr(ext, 'optional', False): |
|
292 | 292 | raise |
|
293 | 293 | log.warn("Failed to build optional extension '%s' (skipping)", |
|
294 | 294 | ext.name) |
|
295 | 295 | |
|
296 | 296 | class hgbuildpy(build_py): |
|
297 | 297 | if convert2to3: |
|
298 | 298 | fixer_names = sorted(set(getfixers("lib2to3.fixes") + |
|
299 | 299 | getfixers("hgfixes"))) |
|
300 | 300 | |
|
301 | 301 | def finalize_options(self): |
|
302 | 302 | build_py.finalize_options(self) |
|
303 | 303 | |
|
304 | 304 | if self.distribution.pure: |
|
305 | 305 | if self.py_modules is None: |
|
306 | 306 | self.py_modules = [] |
|
307 | 307 | for ext in self.distribution.ext_modules: |
|
308 | 308 | if ext.name.startswith("mercurial."): |
|
309 | 309 | self.py_modules.append("mercurial.pure.%s" % ext.name[10:]) |
|
310 | 310 | self.distribution.ext_modules = [] |
|
311 | 311 | else: |
|
312 | 312 | h = os.path.join(get_python_inc(), 'Python.h') |
|
313 | 313 | if not os.path.exists(h): |
|
314 | 314 | raise SystemExit('Python headers are required to build ' |
|
315 | 315 | 'Mercurial but weren\'t found in %s' % h) |
|
316 | 316 | |
|
317 | 317 | def find_modules(self): |
|
318 | 318 | modules = build_py.find_modules(self) |
|
319 | 319 | for module in modules: |
|
320 | 320 | if module[0] == "mercurial.pure": |
|
321 | 321 | if module[1] != "__init__": |
|
322 | 322 | yield ("mercurial", module[1], module[2]) |
|
323 | 323 | else: |
|
324 | 324 | yield module |
|
325 | 325 | |
|
326 | 326 | class buildhgextindex(Command): |
|
327 | 327 | description = 'generate prebuilt index of hgext (for frozen package)' |
|
328 | 328 | user_options = [] |
|
329 | 329 | _indexfilename = 'hgext/__index__.py' |
|
330 | 330 | |
|
331 | 331 | def initialize_options(self): |
|
332 | 332 | pass |
|
333 | 333 | |
|
334 | 334 | def finalize_options(self): |
|
335 | 335 | pass |
|
336 | 336 | |
|
337 | 337 | def run(self): |
|
338 | 338 | if os.path.exists(self._indexfilename): |
|
339 | 339 | f = open(self._indexfilename, 'w') |
|
340 | 340 | f.write('# empty\n') |
|
341 | 341 | f.close() |
|
342 | 342 | |
|
343 | 343 | # here no extension enabled, disabled() lists up everything |
|
344 | 344 | code = ('import pprint; from mercurial import extensions; ' |
|
345 | 345 | 'pprint.pprint(extensions.disabled())') |
|
346 | 346 | out, err = runcmd([sys.executable, '-c', code], env) |
|
347 | 347 | if err: |
|
348 | 348 | raise DistutilsExecError(err) |
|
349 | 349 | |
|
350 | 350 | f = open(self._indexfilename, 'w') |
|
351 | 351 | f.write('# this file is autogenerated by setup.py\n') |
|
352 | 352 | f.write('docs = ') |
|
353 | 353 | f.write(out) |
|
354 | 354 | f.close() |
|
355 | 355 | |
|
356 | 356 | class buildhgexe(build_ext): |
|
357 | 357 | description = 'compile hg.exe from mercurial/exewrapper.c' |
|
358 | 358 | |
|
359 | 359 | def build_extensions(self): |
|
360 | 360 | if os.name != 'nt': |
|
361 | 361 | return |
|
362 | 362 | if isinstance(self.compiler, HackedMingw32CCompiler): |
|
363 | 363 | self.compiler.compiler_so = self.compiler.compiler # no -mdll |
|
364 | 364 | self.compiler.dll_libraries = [] # no -lmsrvc90 |
|
365 | 365 | hv = sys.hexversion |
|
366 | 366 | pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff) |
|
367 | 367 | f = open('mercurial/hgpythonlib.h', 'wb') |
|
368 | 368 | f.write('/* this file is autogenerated by setup.py */\n') |
|
369 | 369 | f.write('#define HGPYTHONLIB "%s"\n' % pythonlib) |
|
370 | 370 | f.close() |
|
371 | 371 | objects = self.compiler.compile(['mercurial/exewrapper.c'], |
|
372 | 372 | output_dir=self.build_temp) |
|
373 | 373 | dir = os.path.dirname(self.get_ext_fullpath('dummy')) |
|
374 | 374 | target = os.path.join(dir, 'hg') |
|
375 | 375 | self.compiler.link_executable(objects, target, |
|
376 | 376 | libraries=[], |
|
377 | 377 | output_dir=self.build_temp) |
|
378 | 378 | |
|
379 | 379 | class hginstalllib(install_lib): |
|
380 | 380 | ''' |
|
381 | 381 | This is a specialization of install_lib that replaces the copy_file used |
|
382 | 382 | there so that it supports setting the mode of files after copying them, |
|
383 | 383 | instead of just preserving the mode that the files originally had. If your |
|
384 | 384 | system has a umask of something like 027, preserving the permissions when |
|
385 | 385 | copying will lead to a broken install. |
|
386 | 386 | |
|
387 | 387 | Note that just passing keep_permissions=False to copy_file would be |
|
388 | 388 | insufficient, as it might still be applying a umask. |
|
389 | 389 | ''' |
|
390 | 390 | |
|
391 | 391 | def run(self): |
|
392 | 392 | realcopyfile = file_util.copy_file |
|
393 | 393 | def copyfileandsetmode(*args, **kwargs): |
|
394 | 394 | src, dst = args[0], args[1] |
|
395 | 395 | dst, copied = realcopyfile(*args, **kwargs) |
|
396 | 396 | if copied: |
|
397 | 397 | st = os.stat(src) |
|
398 | 398 | # Persist executable bit (apply it to group and other if user |
|
399 | 399 | # has it) |
|
400 | 400 | if st[stat.ST_MODE] & stat.S_IXUSR: |
|
401 | 401 | setmode = 0755 |
|
402 | 402 | else: |
|
403 | 403 | setmode = 0644 |
|
404 | 404 | os.chmod(dst, (stat.S_IMODE(st[stat.ST_MODE]) & ~0777) | |
|
405 | 405 | setmode) |
|
406 | 406 | file_util.copy_file = copyfileandsetmode |
|
407 | 407 | try: |
|
408 | 408 | install_lib.run(self) |
|
409 | 409 | finally: |
|
410 | 410 | file_util.copy_file = realcopyfile |
|
411 | 411 | |
|
412 | 412 | class hginstallscripts(install_scripts): |
|
413 | 413 | ''' |
|
414 | 414 | This is a specialization of install_scripts that replaces the @LIBDIR@ with |
|
415 | 415 | the configured directory for modules. If possible, the path is made relative |
|
416 | 416 | to the directory for scripts. |
|
417 | 417 | ''' |
|
418 | 418 | |
|
419 | 419 | def initialize_options(self): |
|
420 | 420 | install_scripts.initialize_options(self) |
|
421 | 421 | |
|
422 | 422 | self.install_lib = None |
|
423 | 423 | |
|
424 | 424 | def finalize_options(self): |
|
425 | 425 | install_scripts.finalize_options(self) |
|
426 | 426 | self.set_undefined_options('install', |
|
427 | 427 | ('install_lib', 'install_lib')) |
|
428 | 428 | |
|
429 | 429 | def run(self): |
|
430 | 430 | install_scripts.run(self) |
|
431 | 431 | |
|
432 | 432 | if (os.path.splitdrive(self.install_dir)[0] != |
|
433 | 433 | os.path.splitdrive(self.install_lib)[0]): |
|
434 | 434 | # can't make relative paths from one drive to another, so use an |
|
435 | 435 | # absolute path instead |
|
436 | 436 | libdir = self.install_lib |
|
437 | 437 | else: |
|
438 | 438 | common = os.path.commonprefix((self.install_dir, self.install_lib)) |
|
439 | 439 | rest = self.install_dir[len(common):] |
|
440 | 440 | uplevel = len([n for n in os.path.split(rest) if n]) |
|
441 | 441 | |
|
442 | 442 | libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):] |
|
443 | 443 | |
|
444 | 444 | for outfile in self.outfiles: |
|
445 | 445 | fp = open(outfile, 'rb') |
|
446 | 446 | data = fp.read() |
|
447 | 447 | fp.close() |
|
448 | 448 | |
|
449 | 449 | # skip binary files |
|
450 | 450 | if b('\0') in data: |
|
451 | 451 | continue |
|
452 | 452 | |
|
453 | 453 | data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape)) |
|
454 | 454 | fp = open(outfile, 'wb') |
|
455 | 455 | fp.write(data) |
|
456 | 456 | fp.close() |
|
457 | 457 | |
|
458 | 458 | cmdclass = {'build': hgbuild, |
|
459 | 459 | 'build_mo': hgbuildmo, |
|
460 | 460 | 'build_ext': hgbuildext, |
|
461 | 461 | 'build_py': hgbuildpy, |
|
462 | 462 | 'build_hgextindex': buildhgextindex, |
|
463 | 463 | 'install_lib': hginstalllib, |
|
464 | 464 | 'install_scripts': hginstallscripts, |
|
465 | 465 | 'build_hgexe': buildhgexe, |
|
466 | 466 | } |
|
467 | 467 | |
|
468 | 468 | packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient', |
|
469 | 469 | 'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf', |
|
470 | 470 | 'hgext.largefiles'] |
|
471 | 471 | |
|
472 | 472 | pymodules = [] |
|
473 | 473 | |
|
474 | 474 | common_depends = ['mercurial/util.h'] |
|
475 | 475 | |
|
476 | 476 | extmodules = [ |
|
477 | 477 | Extension('mercurial.base85', ['mercurial/base85.c'], |
|
478 | 478 | depends=common_depends), |
|
479 | 479 | Extension('mercurial.bdiff', ['mercurial/bdiff.c'], |
|
480 | 480 | depends=common_depends), |
|
481 | 481 | Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'], |
|
482 | 482 | depends=common_depends), |
|
483 | 483 | Extension('mercurial.mpatch', ['mercurial/mpatch.c'], |
|
484 | 484 | depends=common_depends), |
|
485 | 485 | Extension('mercurial.parsers', ['mercurial/dirs.c', |
|
486 | 486 | 'mercurial/parsers.c', |
|
487 | 487 | 'mercurial/pathencode.c'], |
|
488 | 488 | depends=common_depends), |
|
489 | 489 | ] |
|
490 | 490 | |
|
491 | 491 | osutil_ldflags = [] |
|
492 | 492 | |
|
493 | 493 | if sys.platform == 'darwin': |
|
494 | 494 | osutil_ldflags += ['-framework', 'ApplicationServices'] |
|
495 | 495 | |
|
496 | 496 | # disable osutil.c under windows + python 2.4 (issue1364) |
|
497 | 497 | if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'): |
|
498 | 498 | pymodules.append('mercurial.pure.osutil') |
|
499 | 499 | else: |
|
500 | 500 | extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c'], |
|
501 | 501 | extra_link_args=osutil_ldflags, |
|
502 | 502 | depends=common_depends)) |
|
503 | 503 | |
|
504 | 504 | # the -mno-cygwin option has been deprecated for years |
|
505 | 505 | Mingw32CCompiler = cygwinccompiler.Mingw32CCompiler |
|
506 | 506 | |
|
507 | 507 | class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler): |
|
508 | 508 | def __init__(self, *args, **kwargs): |
|
509 | 509 | Mingw32CCompiler.__init__(self, *args, **kwargs) |
|
510 | 510 | for i in 'compiler compiler_so linker_exe linker_so'.split(): |
|
511 | 511 | try: |
|
512 | 512 | getattr(self, i).remove('-mno-cygwin') |
|
513 | 513 | except ValueError: |
|
514 | 514 | pass |
|
515 | 515 | |
|
516 | 516 | cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler |
|
517 | 517 | |
|
518 | 518 | packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', |
|
519 | 519 | 'help/*.txt', |
|
520 | 'default.d/*.rc', | |
|
520 | 521 | 'dummycert.pem']} |
|
521 | 522 | |
|
522 | 523 | def ordinarypath(p): |
|
523 | 524 | return p and p[0] != '.' and p[-1] != '~' |
|
524 | 525 | |
|
525 | 526 | for root in ('templates',): |
|
526 | 527 | for curdir, dirs, files in os.walk(os.path.join('mercurial', root)): |
|
527 | 528 | curdir = curdir.split(os.sep, 1)[1] |
|
528 | 529 | dirs[:] = filter(ordinarypath, dirs) |
|
529 | 530 | for f in filter(ordinarypath, files): |
|
530 | 531 | f = os.path.join(curdir, f) |
|
531 | 532 | packagedata['mercurial'].append(f) |
|
532 | 533 | |
|
533 | 534 | datafiles = [] |
|
534 | 535 | setupversion = version |
|
535 | 536 | extra = {} |
|
536 | 537 | |
|
537 | 538 | if py2exeloaded: |
|
538 | 539 | extra['console'] = [ |
|
539 | 540 | {'script':'hg', |
|
540 | 541 | 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others', |
|
541 | 542 | 'product_version':version}] |
|
542 | 543 | # sub command of 'build' because 'py2exe' does not handle sub_commands |
|
543 | 544 | build.sub_commands.insert(0, ('build_hgextindex', None)) |
|
544 | 545 | |
|
545 | 546 | if os.name == 'nt': |
|
546 | 547 | # Windows binary file versions for exe/dll files must have the |
|
547 | 548 | # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 |
|
548 | 549 | setupversion = version.split('+', 1)[0] |
|
549 | 550 | |
|
550 | 551 | if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): |
|
551 | 552 | version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines() |
|
552 | 553 | if version: |
|
553 | 554 | version = version[0] |
|
554 | 555 | xcode4 = (version.startswith('Xcode') and |
|
555 | 556 | StrictVersion(version.split()[1]) >= StrictVersion('4.0')) |
|
556 | 557 | xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None |
|
557 | 558 | else: |
|
558 | 559 | # xcodebuild returns empty on OS X Lion with XCode 4.3 not |
|
559 | 560 | # installed, but instead with only command-line tools. Assume |
|
560 | 561 | # that only happens on >= Lion, thus no PPC support. |
|
561 | 562 | xcode4 = True |
|
562 | 563 | xcode51 = False |
|
563 | 564 | |
|
564 | 565 | # XCode 4.0 dropped support for ppc architecture, which is hardcoded in |
|
565 | 566 | # distutils.sysconfig |
|
566 | 567 | if xcode4: |
|
567 | 568 | os.environ['ARCHFLAGS'] = '' |
|
568 | 569 | |
|
569 | 570 | # XCode 5.1 changes clang such that it now fails to compile if the |
|
570 | 571 | # -mno-fused-madd flag is passed, but the version of Python shipped with |
|
571 | 572 | # OS X 10.9 Mavericks includes this flag. This causes problems in all |
|
572 | 573 | # C extension modules, and a bug has been filed upstream at |
|
573 | 574 | # http://bugs.python.org/issue21244. We also need to patch this here |
|
574 | 575 | # so Mercurial can continue to compile in the meantime. |
|
575 | 576 | if xcode51: |
|
576 | 577 | cflags = get_config_var('CFLAGS') |
|
577 | 578 | if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None: |
|
578 | 579 | os.environ['CFLAGS'] = ( |
|
579 | 580 | os.environ.get('CFLAGS', '') + ' -Qunused-arguments') |
|
580 | 581 | |
|
581 | 582 | setup(name='mercurial', |
|
582 | 583 | version=setupversion, |
|
583 | 584 | author='Matt Mackall and many others', |
|
584 | 585 | author_email='mercurial@selenic.com', |
|
585 | 586 | url='http://mercurial.selenic.com/', |
|
586 | 587 | download_url='http://mercurial.selenic.com/release/', |
|
587 | 588 | description=('Fast scalable distributed SCM (revision control, version ' |
|
588 | 589 | 'control) system'), |
|
589 | 590 | long_description=('Mercurial is a distributed SCM tool written in Python.' |
|
590 | 591 | ' It is used by a number of large projects that require' |
|
591 | 592 | ' fast, reliable distributed revision control, such as ' |
|
592 | 593 | 'Mozilla.'), |
|
593 | 594 | license='GNU GPLv2 or any later version', |
|
594 | 595 | classifiers=[ |
|
595 | 596 | 'Development Status :: 6 - Mature', |
|
596 | 597 | 'Environment :: Console', |
|
597 | 598 | 'Intended Audience :: Developers', |
|
598 | 599 | 'Intended Audience :: System Administrators', |
|
599 | 600 | 'License :: OSI Approved :: GNU General Public License (GPL)', |
|
600 | 601 | 'Natural Language :: Danish', |
|
601 | 602 | 'Natural Language :: English', |
|
602 | 603 | 'Natural Language :: German', |
|
603 | 604 | 'Natural Language :: Italian', |
|
604 | 605 | 'Natural Language :: Japanese', |
|
605 | 606 | 'Natural Language :: Portuguese (Brazilian)', |
|
606 | 607 | 'Operating System :: Microsoft :: Windows', |
|
607 | 608 | 'Operating System :: OS Independent', |
|
608 | 609 | 'Operating System :: POSIX', |
|
609 | 610 | 'Programming Language :: C', |
|
610 | 611 | 'Programming Language :: Python', |
|
611 | 612 | 'Topic :: Software Development :: Version Control', |
|
612 | 613 | ], |
|
613 | 614 | scripts=scripts, |
|
614 | 615 | packages=packages, |
|
615 | 616 | py_modules=pymodules, |
|
616 | 617 | ext_modules=extmodules, |
|
617 | 618 | data_files=datafiles, |
|
618 | 619 | package_data=packagedata, |
|
619 | 620 | cmdclass=cmdclass, |
|
620 | 621 | distclass=hgdist, |
|
621 | 622 | options={'py2exe': {'packages': ['hgext', 'email']}, |
|
622 | 623 | 'bdist_mpkg': {'zipdist': False, |
|
623 | 624 | 'license': 'COPYING', |
|
624 | 625 | 'readme': 'contrib/macosx/Readme.html', |
|
625 | 626 | 'welcome': 'contrib/macosx/Welcome.html', |
|
626 | 627 | }, |
|
627 | 628 | }, |
|
628 | 629 | **extra) |
General Comments 0
You need to be logged in to leave comments.
Login now