Show More
@@ -1,2516 +1,2523 | |||
|
1 | 1 | The Mercurial system uses a set of configuration files to control |
|
2 | 2 | aspects of its behavior. |
|
3 | 3 | |
|
4 | 4 | Troubleshooting |
|
5 | 5 | =============== |
|
6 | 6 | |
|
7 | 7 | If you're having problems with your configuration, |
|
8 | 8 | :hg:`config --debug` can help you understand what is introducing |
|
9 | 9 | a setting into your environment. |
|
10 | 10 | |
|
11 | 11 | See :hg:`help config.syntax` and :hg:`help config.files` |
|
12 | 12 | for information about how and where to override things. |
|
13 | 13 | |
|
14 | 14 | Structure |
|
15 | 15 | ========= |
|
16 | 16 | |
|
17 | 17 | The configuration files use a simple ini-file format. A configuration |
|
18 | 18 | file consists of sections, led by a ``[section]`` header and followed |
|
19 | 19 | by ``name = value`` entries:: |
|
20 | 20 | |
|
21 | 21 | [ui] |
|
22 | 22 | username = Firstname Lastname <firstname.lastname@example.net> |
|
23 | 23 | verbose = True |
|
24 | 24 | |
|
25 | 25 | The above entries will be referred to as ``ui.username`` and |
|
26 | 26 | ``ui.verbose``, respectively. See :hg:`help config.syntax`. |
|
27 | 27 | |
|
28 | 28 | Files |
|
29 | 29 | ===== |
|
30 | 30 | |
|
31 | 31 | Mercurial reads configuration data from several files, if they exist. |
|
32 | 32 | These files do not exist by default and you will have to create the |
|
33 | 33 | appropriate configuration files yourself: |
|
34 | 34 | |
|
35 | 35 | Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file. |
|
36 | 36 | |
|
37 | 37 | Global configuration like the username setting is typically put into: |
|
38 | 38 | |
|
39 | 39 | .. container:: windows |
|
40 | 40 | |
|
41 | 41 | - ``%USERPROFILE%\mercurial.ini`` (on Windows) |
|
42 | 42 | |
|
43 | 43 | .. container:: unix.plan9 |
|
44 | 44 | |
|
45 | 45 | - ``$HOME/.hgrc`` (on Unix, Plan9) |
|
46 | 46 | |
|
47 | 47 | The names of these files depend on the system on which Mercurial is |
|
48 | 48 | installed. ``*.rc`` files from a single directory are read in |
|
49 | 49 | alphabetical order, later ones overriding earlier ones. Where multiple |
|
50 | 50 | paths are given below, settings from earlier paths override later |
|
51 | 51 | ones. |
|
52 | 52 | |
|
53 | 53 | .. container:: verbose.unix |
|
54 | 54 | |
|
55 | 55 | On Unix, the following files are consulted: |
|
56 | 56 | |
|
57 | 57 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
58 | 58 | - ``$HOME/.hgrc`` (per-user) |
|
59 | 59 | - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user) |
|
60 | 60 | - ``<install-root>/etc/mercurial/hgrc`` (per-installation) |
|
61 | 61 | - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation) |
|
62 | 62 | - ``/etc/mercurial/hgrc`` (per-system) |
|
63 | 63 | - ``/etc/mercurial/hgrc.d/*.rc`` (per-system) |
|
64 | 64 | - ``<internal>/default.d/*.rc`` (defaults) |
|
65 | 65 | |
|
66 | 66 | .. container:: verbose.windows |
|
67 | 67 | |
|
68 | 68 | On Windows, the following files are consulted: |
|
69 | 69 | |
|
70 | 70 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
71 | 71 | - ``%USERPROFILE%\.hgrc`` (per-user) |
|
72 | 72 | - ``%USERPROFILE%\Mercurial.ini`` (per-user) |
|
73 | 73 | - ``%HOME%\.hgrc`` (per-user) |
|
74 | 74 | - ``%HOME%\Mercurial.ini`` (per-user) |
|
75 | 75 | - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation) |
|
76 | 76 | - ``<install-dir>\hgrc.d\*.rc`` (per-installation) |
|
77 | 77 | - ``<install-dir>\Mercurial.ini`` (per-installation) |
|
78 | 78 | - ``<internal>/default.d/*.rc`` (defaults) |
|
79 | 79 | |
|
80 | 80 | .. note:: |
|
81 | 81 | |
|
82 | 82 | The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial`` |
|
83 | 83 | is used when running 32-bit Python on 64-bit Windows. |
|
84 | 84 | |
|
85 | 85 | .. container:: windows |
|
86 | 86 | |
|
87 | 87 | On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. |
|
88 | 88 | |
|
89 | 89 | .. container:: verbose.plan9 |
|
90 | 90 | |
|
91 | 91 | On Plan9, the following files are consulted: |
|
92 | 92 | |
|
93 | 93 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
94 | 94 | - ``$home/lib/hgrc`` (per-user) |
|
95 | 95 | - ``<install-root>/lib/mercurial/hgrc`` (per-installation) |
|
96 | 96 | - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation) |
|
97 | 97 | - ``/lib/mercurial/hgrc`` (per-system) |
|
98 | 98 | - ``/lib/mercurial/hgrc.d/*.rc`` (per-system) |
|
99 | 99 | - ``<internal>/default.d/*.rc`` (defaults) |
|
100 | 100 | |
|
101 | 101 | Per-repository configuration options only apply in a |
|
102 | 102 | particular repository. This file is not version-controlled, and |
|
103 | 103 | will not get transferred during a "clone" operation. Options in |
|
104 | 104 | this file override options in all other configuration files. |
|
105 | 105 | |
|
106 | 106 | .. container:: unix.plan9 |
|
107 | 107 | |
|
108 | 108 | On Plan 9 and Unix, most of this file will be ignored if it doesn't |
|
109 | 109 | belong to a trusted user or to a trusted group. See |
|
110 | 110 | :hg:`help config.trusted` for more details. |
|
111 | 111 | |
|
112 | 112 | Per-user configuration file(s) are for the user running Mercurial. Options |
|
113 | 113 | in these files apply to all Mercurial commands executed by this user in any |
|
114 | 114 | directory. Options in these files override per-system and per-installation |
|
115 | 115 | options. |
|
116 | 116 | |
|
117 | 117 | Per-installation configuration files are searched for in the |
|
118 | 118 | directory where Mercurial is installed. ``<install-root>`` is the |
|
119 | 119 | parent directory of the **hg** executable (or symlink) being run. |
|
120 | 120 | |
|
121 | 121 | .. container:: unix.plan9 |
|
122 | 122 | |
|
123 | 123 | For example, if installed in ``/shared/tools/bin/hg``, Mercurial |
|
124 | 124 | will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these |
|
125 | 125 | files apply to all Mercurial commands executed by any user in any |
|
126 | 126 | directory. |
|
127 | 127 | |
|
128 | 128 | Per-installation configuration files are for the system on |
|
129 | 129 | which Mercurial is running. Options in these files apply to all |
|
130 | 130 | Mercurial commands executed by any user in any directory. Registry |
|
131 | 131 | keys contain PATH-like strings, every part of which must reference |
|
132 | 132 | a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will |
|
133 | 133 | be read. Mercurial checks each of these locations in the specified |
|
134 | 134 | order until one or more configuration files are detected. |
|
135 | 135 | |
|
136 | 136 | Per-system configuration files are for the system on which Mercurial |
|
137 | 137 | is running. Options in these files apply to all Mercurial commands |
|
138 | 138 | executed by any user in any directory. Options in these files |
|
139 | 139 | override per-installation options. |
|
140 | 140 | |
|
141 | 141 | Mercurial comes with some default configuration. The default configuration |
|
142 | 142 | files are installed with Mercurial and will be overwritten on upgrades. Default |
|
143 | 143 | configuration files should never be edited by users or administrators but can |
|
144 | 144 | be overridden in other configuration files. So far the directory only contains |
|
145 | 145 | merge tool configuration but packagers can also put other default configuration |
|
146 | 146 | there. |
|
147 | 147 | |
|
148 | 148 | Syntax |
|
149 | 149 | ====== |
|
150 | 150 | |
|
151 | 151 | A configuration file consists of sections, led by a ``[section]`` header |
|
152 | 152 | and followed by ``name = value`` entries (sometimes called |
|
153 | 153 | ``configuration keys``):: |
|
154 | 154 | |
|
155 | 155 | [spam] |
|
156 | 156 | eggs=ham |
|
157 | 157 | green= |
|
158 | 158 | eggs |
|
159 | 159 | |
|
160 | 160 | Each line contains one entry. If the lines that follow are indented, |
|
161 | 161 | they are treated as continuations of that entry. Leading whitespace is |
|
162 | 162 | removed from values. Empty lines are skipped. Lines beginning with |
|
163 | 163 | ``#`` or ``;`` are ignored and may be used to provide comments. |
|
164 | 164 | |
|
165 | 165 | Configuration keys can be set multiple times, in which case Mercurial |
|
166 | 166 | will use the value that was configured last. As an example:: |
|
167 | 167 | |
|
168 | 168 | [spam] |
|
169 | 169 | eggs=large |
|
170 | 170 | ham=serrano |
|
171 | 171 | eggs=small |
|
172 | 172 | |
|
173 | 173 | This would set the configuration key named ``eggs`` to ``small``. |
|
174 | 174 | |
|
175 | 175 | It is also possible to define a section multiple times. A section can |
|
176 | 176 | be redefined on the same and/or on different configuration files. For |
|
177 | 177 | example:: |
|
178 | 178 | |
|
179 | 179 | [foo] |
|
180 | 180 | eggs=large |
|
181 | 181 | ham=serrano |
|
182 | 182 | eggs=small |
|
183 | 183 | |
|
184 | 184 | [bar] |
|
185 | 185 | eggs=ham |
|
186 | 186 | green= |
|
187 | 187 | eggs |
|
188 | 188 | |
|
189 | 189 | [foo] |
|
190 | 190 | ham=prosciutto |
|
191 | 191 | eggs=medium |
|
192 | 192 | bread=toasted |
|
193 | 193 | |
|
194 | 194 | This would set the ``eggs``, ``ham``, and ``bread`` configuration keys |
|
195 | 195 | of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``, |
|
196 | 196 | respectively. As you can see there only thing that matters is the last |
|
197 | 197 | value that was set for each of the configuration keys. |
|
198 | 198 | |
|
199 | 199 | If a configuration key is set multiple times in different |
|
200 | 200 | configuration files the final value will depend on the order in which |
|
201 | 201 | the different configuration files are read, with settings from earlier |
|
202 | 202 | paths overriding later ones as described on the ``Files`` section |
|
203 | 203 | above. |
|
204 | 204 | |
|
205 | 205 | A line of the form ``%include file`` will include ``file`` into the |
|
206 | 206 | current configuration file. The inclusion is recursive, which means |
|
207 | 207 | that included files can include other files. Filenames are relative to |
|
208 | 208 | the configuration file in which the ``%include`` directive is found. |
|
209 | 209 | Environment variables and ``~user`` constructs are expanded in |
|
210 | 210 | ``file``. This lets you do something like:: |
|
211 | 211 | |
|
212 | 212 | %include ~/.hgrc.d/$HOST.rc |
|
213 | 213 | |
|
214 | 214 | to include a different configuration file on each computer you use. |
|
215 | 215 | |
|
216 | 216 | A line with ``%unset name`` will remove ``name`` from the current |
|
217 | 217 | section, if it has been set previously. |
|
218 | 218 | |
|
219 | 219 | The values are either free-form text strings, lists of text strings, |
|
220 | 220 | or Boolean values. Boolean values can be set to true using any of "1", |
|
221 | 221 | "yes", "true", or "on" and to false using "0", "no", "false", or "off" |
|
222 | 222 | (all case insensitive). |
|
223 | 223 | |
|
224 | 224 | List values are separated by whitespace or comma, except when values are |
|
225 | 225 | placed in double quotation marks:: |
|
226 | 226 | |
|
227 | 227 | allow_read = "John Doe, PhD", brian, betty |
|
228 | 228 | |
|
229 | 229 | Quotation marks can be escaped by prefixing them with a backslash. Only |
|
230 | 230 | quotation marks at the beginning of a word is counted as a quotation |
|
231 | 231 | (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``). |
|
232 | 232 | |
|
233 | 233 | Sections |
|
234 | 234 | ======== |
|
235 | 235 | |
|
236 | 236 | This section describes the different sections that may appear in a |
|
237 | 237 | Mercurial configuration file, the purpose of each section, its possible |
|
238 | 238 | keys, and their possible values. |
|
239 | 239 | |
|
240 | 240 | ``alias`` |
|
241 | 241 | --------- |
|
242 | 242 | |
|
243 | 243 | Defines command aliases. |
|
244 | 244 | |
|
245 | 245 | Aliases allow you to define your own commands in terms of other |
|
246 | 246 | commands (or aliases), optionally including arguments. Positional |
|
247 | 247 | arguments in the form of ``$1``, ``$2``, etc. in the alias definition |
|
248 | 248 | are expanded by Mercurial before execution. Positional arguments not |
|
249 | 249 | already used by ``$N`` in the definition are put at the end of the |
|
250 | 250 | command to be executed. |
|
251 | 251 | |
|
252 | 252 | Alias definitions consist of lines of the form:: |
|
253 | 253 | |
|
254 | 254 | <alias> = <command> [<argument>]... |
|
255 | 255 | |
|
256 | 256 | For example, this definition:: |
|
257 | 257 | |
|
258 | 258 | latest = log --limit 5 |
|
259 | 259 | |
|
260 | 260 | creates a new command ``latest`` that shows only the five most recent |
|
261 | 261 | changesets. You can define subsequent aliases using earlier ones:: |
|
262 | 262 | |
|
263 | 263 | stable5 = latest -b stable |
|
264 | 264 | |
|
265 | 265 | .. note:: |
|
266 | 266 | |
|
267 | 267 | It is possible to create aliases with the same names as |
|
268 | 268 | existing commands, which will then override the original |
|
269 | 269 | definitions. This is almost always a bad idea! |
|
270 | 270 | |
|
271 | 271 | An alias can start with an exclamation point (``!``) to make it a |
|
272 | 272 | shell alias. A shell alias is executed with the shell and will let you |
|
273 | 273 | run arbitrary commands. As an example, :: |
|
274 | 274 | |
|
275 | 275 | echo = !echo $@ |
|
276 | 276 | |
|
277 | 277 | will let you do ``hg echo foo`` to have ``foo`` printed in your |
|
278 | 278 | terminal. A better example might be:: |
|
279 | 279 | |
|
280 | 280 | purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f |
|
281 | 281 | |
|
282 | 282 | which will make ``hg purge`` delete all unknown files in the |
|
283 | 283 | repository in the same manner as the purge extension. |
|
284 | 284 | |
|
285 | 285 | Positional arguments like ``$1``, ``$2``, etc. in the alias definition |
|
286 | 286 | expand to the command arguments. Unmatched arguments are |
|
287 | 287 | removed. ``$0`` expands to the alias name and ``$@`` expands to all |
|
288 | 288 | arguments separated by a space. ``"$@"`` (with quotes) expands to all |
|
289 | 289 | arguments quoted individually and separated by a space. These expansions |
|
290 | 290 | happen before the command is passed to the shell. |
|
291 | 291 | |
|
292 | 292 | Shell aliases are executed in an environment where ``$HG`` expands to |
|
293 | 293 | the path of the Mercurial that was used to execute the alias. This is |
|
294 | 294 | useful when you want to call further Mercurial commands in a shell |
|
295 | 295 | alias, as was done above for the purge alias. In addition, |
|
296 | 296 | ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg |
|
297 | 297 | echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``. |
|
298 | 298 | |
|
299 | 299 | .. note:: |
|
300 | 300 | |
|
301 | 301 | Some global configuration options such as ``-R`` are |
|
302 | 302 | processed before shell aliases and will thus not be passed to |
|
303 | 303 | aliases. |
|
304 | 304 | |
|
305 | 305 | |
|
306 | 306 | ``annotate`` |
|
307 | 307 | ------------ |
|
308 | 308 | |
|
309 | 309 | Settings used when displaying file annotations. All values are |
|
310 | 310 | Booleans and default to False. See :hg:`help config.diff` for |
|
311 | 311 | related options for the diff command. |
|
312 | 312 | |
|
313 | 313 | ``ignorews`` |
|
314 | 314 | Ignore white space when comparing lines. |
|
315 | 315 | |
|
316 | 316 | ``ignorewseol`` |
|
317 | 317 | Ignore white space at the end of a line when comparing lines. |
|
318 | 318 | |
|
319 | 319 | ``ignorewsamount`` |
|
320 | 320 | Ignore changes in the amount of white space. |
|
321 | 321 | |
|
322 | 322 | ``ignoreblanklines`` |
|
323 | 323 | Ignore changes whose lines are all blank. |
|
324 | 324 | |
|
325 | 325 | |
|
326 | 326 | ``auth`` |
|
327 | 327 | -------- |
|
328 | 328 | |
|
329 | 329 | Authentication credentials and other authentication-like configuration |
|
330 | 330 | for HTTP connections. This section allows you to store usernames and |
|
331 | 331 | passwords for use when logging *into* HTTP servers. See |
|
332 | 332 | :hg:`help config.web` if you want to configure *who* can login to |
|
333 | 333 | your HTTP server. |
|
334 | 334 | |
|
335 | 335 | The following options apply to all hosts. |
|
336 | 336 | |
|
337 | 337 | ``cookiefile`` |
|
338 | 338 | Path to a file containing HTTP cookie lines. Cookies matching a |
|
339 | 339 | host will be sent automatically. |
|
340 | 340 | |
|
341 | 341 | The file format uses the Mozilla cookies.txt format, which defines cookies |
|
342 | 342 | on their own lines. Each line contains 7 fields delimited by the tab |
|
343 | 343 | character (domain, is_domain_cookie, path, is_secure, expires, name, |
|
344 | 344 | value). For more info, do an Internet search for "Netscape cookies.txt |
|
345 | 345 | format." |
|
346 | 346 | |
|
347 | 347 | Note: the cookies parser does not handle port numbers on domains. You |
|
348 | 348 | will need to remove ports from the domain for the cookie to be recognized. |
|
349 | 349 | This could result in a cookie being disclosed to an unwanted server. |
|
350 | 350 | |
|
351 | 351 | The cookies file is read-only. |
|
352 | 352 | |
|
353 | 353 | Other options in this section are grouped by name and have the following |
|
354 | 354 | format:: |
|
355 | 355 | |
|
356 | 356 | <name>.<argument> = <value> |
|
357 | 357 | |
|
358 | 358 | where ``<name>`` is used to group arguments into authentication |
|
359 | 359 | entries. Example:: |
|
360 | 360 | |
|
361 | 361 | foo.prefix = hg.intevation.de/mercurial |
|
362 | 362 | foo.username = foo |
|
363 | 363 | foo.password = bar |
|
364 | 364 | foo.schemes = http https |
|
365 | 365 | |
|
366 | 366 | bar.prefix = secure.example.org |
|
367 | 367 | bar.key = path/to/file.key |
|
368 | 368 | bar.cert = path/to/file.cert |
|
369 | 369 | bar.schemes = https |
|
370 | 370 | |
|
371 | 371 | Supported arguments: |
|
372 | 372 | |
|
373 | 373 | ``prefix`` |
|
374 | 374 | Either ``*`` or a URI prefix with or without the scheme part. |
|
375 | 375 | The authentication entry with the longest matching prefix is used |
|
376 | 376 | (where ``*`` matches everything and counts as a match of length |
|
377 | 377 | 1). If the prefix doesn't include a scheme, the match is performed |
|
378 | 378 | against the URI with its scheme stripped as well, and the schemes |
|
379 | 379 | argument, q.v., is then subsequently consulted. |
|
380 | 380 | |
|
381 | 381 | ``username`` |
|
382 | 382 | Optional. Username to authenticate with. If not given, and the |
|
383 | 383 | remote site requires basic or digest authentication, the user will |
|
384 | 384 | be prompted for it. Environment variables are expanded in the |
|
385 | 385 | username letting you do ``foo.username = $USER``. If the URI |
|
386 | 386 | includes a username, only ``[auth]`` entries with a matching |
|
387 | 387 | username or without a username will be considered. |
|
388 | 388 | |
|
389 | 389 | ``password`` |
|
390 | 390 | Optional. Password to authenticate with. If not given, and the |
|
391 | 391 | remote site requires basic or digest authentication, the user |
|
392 | 392 | will be prompted for it. |
|
393 | 393 | |
|
394 | 394 | ``key`` |
|
395 | 395 | Optional. PEM encoded client certificate key file. Environment |
|
396 | 396 | variables are expanded in the filename. |
|
397 | 397 | |
|
398 | 398 | ``cert`` |
|
399 | 399 | Optional. PEM encoded client certificate chain file. Environment |
|
400 | 400 | variables are expanded in the filename. |
|
401 | 401 | |
|
402 | 402 | ``schemes`` |
|
403 | 403 | Optional. Space separated list of URI schemes to use this |
|
404 | 404 | authentication entry with. Only used if the prefix doesn't include |
|
405 | 405 | a scheme. Supported schemes are http and https. They will match |
|
406 | 406 | static-http and static-https respectively, as well. |
|
407 | 407 | (default: https) |
|
408 | 408 | |
|
409 | 409 | If no suitable authentication entry is found, the user is prompted |
|
410 | 410 | for credentials as usual if required by the remote. |
|
411 | 411 | |
|
412 | 412 | ``color`` |
|
413 | 413 | --------- |
|
414 | 414 | |
|
415 | 415 | Configure the Mercurial color mode. For details about how to define your custom |
|
416 | 416 | effect and style see :hg:`help color`. |
|
417 | 417 | |
|
418 | 418 | ``mode`` |
|
419 | 419 | String: control the method used to output color. One of ``auto``, ``ansi``, |
|
420 | 420 | ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will |
|
421 | 421 | use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a |
|
422 | 422 | terminal. Any invalid value will disable color. |
|
423 | 423 | |
|
424 | 424 | ``pagermode`` |
|
425 | 425 | String: optional override of ``color.mode`` used with pager. |
|
426 | 426 | |
|
427 | 427 | On some systems, terminfo mode may cause problems when using |
|
428 | 428 | color with ``less -R`` as a pager program. less with the -R option |
|
429 | 429 | will only display ECMA-48 color codes, and terminfo mode may sometimes |
|
430 | 430 | emit codes that less doesn't understand. You can work around this by |
|
431 | 431 | either using ansi mode (or auto mode), or by using less -r (which will |
|
432 | 432 | pass through all terminal control codes, not just color control |
|
433 | 433 | codes). |
|
434 | 434 | |
|
435 | 435 | On some systems (such as MSYS in Windows), the terminal may support |
|
436 | 436 | a different color mode than the pager program. |
|
437 | 437 | |
|
438 | 438 | ``commands`` |
|
439 | 439 | ------------ |
|
440 | 440 | |
|
441 | 441 | ``status.relative`` |
|
442 | 442 | Make paths in :hg:`status` output relative to the current directory. |
|
443 | 443 | (default: False) |
|
444 | 444 | |
|
445 | 445 | ``update.check`` |
|
446 | 446 | Determines what level of checking :hg:`update` will perform before moving |
|
447 | 447 | to a destination revision. Valid values are ``abort``, ``none``, |
|
448 | 448 | ``linear``, and ``noconflict``. ``abort`` always fails if the working |
|
449 | 449 | directory has uncommitted changes. ``none`` performs no checking, and may |
|
450 | 450 | result in a merge with uncommitted changes. ``linear`` allows any update |
|
451 | 451 | as long as it follows a straight line in the revision history, and may |
|
452 | 452 | trigger a merge with uncommitted changes. ``noconflict`` will allow any |
|
453 | 453 | update which would not trigger a merge with uncommitted changes, if any |
|
454 | 454 | are present. |
|
455 | 455 | (default: ``linear``) |
|
456 | 456 | |
|
457 | 457 | ``update.requiredest`` |
|
458 | 458 | Require that the user pass a destination when running :hg:`update`. |
|
459 | 459 | For example, :hg:`update .::` will be allowed, but a plain :hg:`update` |
|
460 | 460 | will be disallowed. |
|
461 | 461 | (default: False) |
|
462 | 462 | |
|
463 | 463 | ``committemplate`` |
|
464 | 464 | ------------------ |
|
465 | 465 | |
|
466 | 466 | ``changeset`` |
|
467 | 467 | String: configuration in this section is used as the template to |
|
468 | 468 | customize the text shown in the editor when committing. |
|
469 | 469 | |
|
470 | 470 | In addition to pre-defined template keywords, commit log specific one |
|
471 | 471 | below can be used for customization: |
|
472 | 472 | |
|
473 | 473 | ``extramsg`` |
|
474 | 474 | String: Extra message (typically 'Leave message empty to abort |
|
475 | 475 | commit.'). This may be changed by some commands or extensions. |
|
476 | 476 | |
|
477 | 477 | For example, the template configuration below shows as same text as |
|
478 | 478 | one shown by default:: |
|
479 | 479 | |
|
480 | 480 | [committemplate] |
|
481 | 481 | changeset = {desc}\n\n |
|
482 | 482 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
483 | 483 | HG: {extramsg} |
|
484 | 484 | HG: -- |
|
485 | 485 | HG: user: {author}\n{ifeq(p2rev, "-1", "", |
|
486 | 486 | "HG: branch merge\n") |
|
487 | 487 | }HG: branch '{branch}'\n{if(activebookmark, |
|
488 | 488 | "HG: bookmark '{activebookmark}'\n") }{subrepos % |
|
489 | 489 | "HG: subrepo {subrepo}\n" }{file_adds % |
|
490 | 490 | "HG: added {file}\n" }{file_mods % |
|
491 | 491 | "HG: changed {file}\n" }{file_dels % |
|
492 | 492 | "HG: removed {file}\n" }{if(files, "", |
|
493 | 493 | "HG: no files changed\n")} |
|
494 | 494 | |
|
495 | 495 | ``diff()`` |
|
496 | 496 | String: show the diff (see :hg:`help templates` for detail) |
|
497 | 497 | |
|
498 | 498 | Sometimes it is helpful to show the diff of the changeset in the editor without |
|
499 | 499 | having to prefix 'HG: ' to each line so that highlighting works correctly. For |
|
500 | 500 | this, Mercurial provides a special string which will ignore everything below |
|
501 | 501 | it:: |
|
502 | 502 | |
|
503 | 503 | HG: ------------------------ >8 ------------------------ |
|
504 | 504 | |
|
505 | 505 | For example, the template configuration below will show the diff below the |
|
506 | 506 | extra message:: |
|
507 | 507 | |
|
508 | 508 | [committemplate] |
|
509 | 509 | changeset = {desc}\n\n |
|
510 | 510 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
511 | 511 | HG: {extramsg} |
|
512 | 512 | HG: ------------------------ >8 ------------------------ |
|
513 | 513 | HG: Do not touch the line above. |
|
514 | 514 | HG: Everything below will be removed. |
|
515 | 515 | {diff()} |
|
516 | 516 | |
|
517 | 517 | .. note:: |
|
518 | 518 | |
|
519 | 519 | For some problematic encodings (see :hg:`help win32mbcs` for |
|
520 | 520 | detail), this customization should be configured carefully, to |
|
521 | 521 | avoid showing broken characters. |
|
522 | 522 | |
|
523 | 523 | For example, if a multibyte character ending with backslash (0x5c) is |
|
524 | 524 | followed by the ASCII character 'n' in the customized template, |
|
525 | 525 | the sequence of backslash and 'n' is treated as line-feed unexpectedly |
|
526 | 526 | (and the multibyte character is broken, too). |
|
527 | 527 | |
|
528 | 528 | Customized template is used for commands below (``--edit`` may be |
|
529 | 529 | required): |
|
530 | 530 | |
|
531 | 531 | - :hg:`backout` |
|
532 | 532 | - :hg:`commit` |
|
533 | 533 | - :hg:`fetch` (for merge commit only) |
|
534 | 534 | - :hg:`graft` |
|
535 | 535 | - :hg:`histedit` |
|
536 | 536 | - :hg:`import` |
|
537 | 537 | - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh` |
|
538 | 538 | - :hg:`rebase` |
|
539 | 539 | - :hg:`shelve` |
|
540 | 540 | - :hg:`sign` |
|
541 | 541 | - :hg:`tag` |
|
542 | 542 | - :hg:`transplant` |
|
543 | 543 | |
|
544 | 544 | Configuring items below instead of ``changeset`` allows showing |
|
545 | 545 | customized message only for specific actions, or showing different |
|
546 | 546 | messages for each action. |
|
547 | 547 | |
|
548 | 548 | - ``changeset.backout`` for :hg:`backout` |
|
549 | 549 | - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges |
|
550 | 550 | - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other |
|
551 | 551 | - ``changeset.commit.normal.merge`` for :hg:`commit` on merges |
|
552 | 552 | - ``changeset.commit.normal.normal`` for :hg:`commit` on other |
|
553 | 553 | - ``changeset.fetch`` for :hg:`fetch` (impling merge commit) |
|
554 | 554 | - ``changeset.gpg.sign`` for :hg:`sign` |
|
555 | 555 | - ``changeset.graft`` for :hg:`graft` |
|
556 | 556 | - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit` |
|
557 | 557 | - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit` |
|
558 | 558 | - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit` |
|
559 | 559 | - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit` |
|
560 | 560 | - ``changeset.import.bypass`` for :hg:`import --bypass` |
|
561 | 561 | - ``changeset.import.normal.merge`` for :hg:`import` on merges |
|
562 | 562 | - ``changeset.import.normal.normal`` for :hg:`import` on other |
|
563 | 563 | - ``changeset.mq.qnew`` for :hg:`qnew` |
|
564 | 564 | - ``changeset.mq.qfold`` for :hg:`qfold` |
|
565 | 565 | - ``changeset.mq.qrefresh`` for :hg:`qrefresh` |
|
566 | 566 | - ``changeset.rebase.collapse`` for :hg:`rebase --collapse` |
|
567 | 567 | - ``changeset.rebase.merge`` for :hg:`rebase` on merges |
|
568 | 568 | - ``changeset.rebase.normal`` for :hg:`rebase` on other |
|
569 | 569 | - ``changeset.shelve.shelve`` for :hg:`shelve` |
|
570 | 570 | - ``changeset.tag.add`` for :hg:`tag` without ``--remove`` |
|
571 | 571 | - ``changeset.tag.remove`` for :hg:`tag --remove` |
|
572 | 572 | - ``changeset.transplant.merge`` for :hg:`transplant` on merges |
|
573 | 573 | - ``changeset.transplant.normal`` for :hg:`transplant` on other |
|
574 | 574 | |
|
575 | 575 | These dot-separated lists of names are treated as hierarchical ones. |
|
576 | 576 | For example, ``changeset.tag.remove`` customizes the commit message |
|
577 | 577 | only for :hg:`tag --remove`, but ``changeset.tag`` customizes the |
|
578 | 578 | commit message for :hg:`tag` regardless of ``--remove`` option. |
|
579 | 579 | |
|
580 | 580 | When the external editor is invoked for a commit, the corresponding |
|
581 | 581 | dot-separated list of names without the ``changeset.`` prefix |
|
582 | 582 | (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment |
|
583 | 583 | variable. |
|
584 | 584 | |
|
585 | 585 | In this section, items other than ``changeset`` can be referred from |
|
586 | 586 | others. For example, the configuration to list committed files up |
|
587 | 587 | below can be referred as ``{listupfiles}``:: |
|
588 | 588 | |
|
589 | 589 | [committemplate] |
|
590 | 590 | listupfiles = {file_adds % |
|
591 | 591 | "HG: added {file}\n" }{file_mods % |
|
592 | 592 | "HG: changed {file}\n" }{file_dels % |
|
593 | 593 | "HG: removed {file}\n" }{if(files, "", |
|
594 | 594 | "HG: no files changed\n")} |
|
595 | 595 | |
|
596 | 596 | ``decode/encode`` |
|
597 | 597 | ----------------- |
|
598 | 598 | |
|
599 | 599 | Filters for transforming files on checkout/checkin. This would |
|
600 | 600 | typically be used for newline processing or other |
|
601 | 601 | localization/canonicalization of files. |
|
602 | 602 | |
|
603 | 603 | Filters consist of a filter pattern followed by a filter command. |
|
604 | 604 | Filter patterns are globs by default, rooted at the repository root. |
|
605 | 605 | For example, to match any file ending in ``.txt`` in the root |
|
606 | 606 | directory only, use the pattern ``*.txt``. To match any file ending |
|
607 | 607 | in ``.c`` anywhere in the repository, use the pattern ``**.c``. |
|
608 | 608 | For each file only the first matching filter applies. |
|
609 | 609 | |
|
610 | 610 | The filter command can start with a specifier, either ``pipe:`` or |
|
611 | 611 | ``tempfile:``. If no specifier is given, ``pipe:`` is used by default. |
|
612 | 612 | |
|
613 | 613 | A ``pipe:`` command must accept data on stdin and return the transformed |
|
614 | 614 | data on stdout. |
|
615 | 615 | |
|
616 | 616 | Pipe example:: |
|
617 | 617 | |
|
618 | 618 | [encode] |
|
619 | 619 | # uncompress gzip files on checkin to improve delta compression |
|
620 | 620 | # note: not necessarily a good idea, just an example |
|
621 | 621 | *.gz = pipe: gunzip |
|
622 | 622 | |
|
623 | 623 | [decode] |
|
624 | 624 | # recompress gzip files when writing them to the working dir (we |
|
625 | 625 | # can safely omit "pipe:", because it's the default) |
|
626 | 626 | *.gz = gzip |
|
627 | 627 | |
|
628 | 628 | A ``tempfile:`` command is a template. The string ``INFILE`` is replaced |
|
629 | 629 | with the name of a temporary file that contains the data to be |
|
630 | 630 | filtered by the command. The string ``OUTFILE`` is replaced with the name |
|
631 | 631 | of an empty temporary file, where the filtered data must be written by |
|
632 | 632 | the command. |
|
633 | 633 | |
|
634 | 634 | .. container:: windows |
|
635 | 635 | |
|
636 | 636 | .. note:: |
|
637 | 637 | |
|
638 | 638 | The tempfile mechanism is recommended for Windows systems, |
|
639 | 639 | where the standard shell I/O redirection operators often have |
|
640 | 640 | strange effects and may corrupt the contents of your files. |
|
641 | 641 | |
|
642 | 642 | This filter mechanism is used internally by the ``eol`` extension to |
|
643 | 643 | translate line ending characters between Windows (CRLF) and Unix (LF) |
|
644 | 644 | format. We suggest you use the ``eol`` extension for convenience. |
|
645 | 645 | |
|
646 | 646 | |
|
647 | 647 | ``defaults`` |
|
648 | 648 | ------------ |
|
649 | 649 | |
|
650 | 650 | (defaults are deprecated. Don't use them. Use aliases instead.) |
|
651 | 651 | |
|
652 | 652 | Use the ``[defaults]`` section to define command defaults, i.e. the |
|
653 | 653 | default options/arguments to pass to the specified commands. |
|
654 | 654 | |
|
655 | 655 | The following example makes :hg:`log` run in verbose mode, and |
|
656 | 656 | :hg:`status` show only the modified files, by default:: |
|
657 | 657 | |
|
658 | 658 | [defaults] |
|
659 | 659 | log = -v |
|
660 | 660 | status = -m |
|
661 | 661 | |
|
662 | 662 | The actual commands, instead of their aliases, must be used when |
|
663 | 663 | defining command defaults. The command defaults will also be applied |
|
664 | 664 | to the aliases of the commands defined. |
|
665 | 665 | |
|
666 | 666 | |
|
667 | 667 | ``diff`` |
|
668 | 668 | -------- |
|
669 | 669 | |
|
670 | 670 | Settings used when displaying diffs. Everything except for ``unified`` |
|
671 | 671 | is a Boolean and defaults to False. See :hg:`help config.annotate` |
|
672 | 672 | for related options for the annotate command. |
|
673 | 673 | |
|
674 | 674 | ``git`` |
|
675 | 675 | Use git extended diff format. |
|
676 | 676 | |
|
677 | 677 | ``nobinary`` |
|
678 | 678 | Omit git binary patches. |
|
679 | 679 | |
|
680 | 680 | ``nodates`` |
|
681 | 681 | Don't include dates in diff headers. |
|
682 | 682 | |
|
683 | 683 | ``noprefix`` |
|
684 | 684 | Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode. |
|
685 | 685 | |
|
686 | 686 | ``showfunc`` |
|
687 | 687 | Show which function each change is in. |
|
688 | 688 | |
|
689 | 689 | ``ignorews`` |
|
690 | 690 | Ignore white space when comparing lines. |
|
691 | 691 | |
|
692 | 692 | ``ignorewsamount`` |
|
693 | 693 | Ignore changes in the amount of white space. |
|
694 | 694 | |
|
695 | 695 | ``ignoreblanklines`` |
|
696 | 696 | Ignore changes whose lines are all blank. |
|
697 | 697 | |
|
698 | 698 | ``unified`` |
|
699 | 699 | Number of lines of context to show. |
|
700 | 700 | |
|
701 | 701 | ``email`` |
|
702 | 702 | --------- |
|
703 | 703 | |
|
704 | 704 | Settings for extensions that send email messages. |
|
705 | 705 | |
|
706 | 706 | ``from`` |
|
707 | 707 | Optional. Email address to use in "From" header and SMTP envelope |
|
708 | 708 | of outgoing messages. |
|
709 | 709 | |
|
710 | 710 | ``to`` |
|
711 | 711 | Optional. Comma-separated list of recipients' email addresses. |
|
712 | 712 | |
|
713 | 713 | ``cc`` |
|
714 | 714 | Optional. Comma-separated list of carbon copy recipients' |
|
715 | 715 | email addresses. |
|
716 | 716 | |
|
717 | 717 | ``bcc`` |
|
718 | 718 | Optional. Comma-separated list of blind carbon copy recipients' |
|
719 | 719 | email addresses. |
|
720 | 720 | |
|
721 | 721 | ``method`` |
|
722 | 722 | Optional. Method to use to send email messages. If value is ``smtp`` |
|
723 | 723 | (default), use SMTP (see the ``[smtp]`` section for configuration). |
|
724 | 724 | Otherwise, use as name of program to run that acts like sendmail |
|
725 | 725 | (takes ``-f`` option for sender, list of recipients on command line, |
|
726 | 726 | message on stdin). Normally, setting this to ``sendmail`` or |
|
727 | 727 | ``/usr/sbin/sendmail`` is enough to use sendmail to send messages. |
|
728 | 728 | |
|
729 | 729 | ``charsets`` |
|
730 | 730 | Optional. Comma-separated list of character sets considered |
|
731 | 731 | convenient for recipients. Addresses, headers, and parts not |
|
732 | 732 | containing patches of outgoing messages will be encoded in the |
|
733 | 733 | first character set to which conversion from local encoding |
|
734 | 734 | (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct |
|
735 | 735 | conversion fails, the text in question is sent as is. |
|
736 | 736 | (default: '') |
|
737 | 737 | |
|
738 | 738 | Order of outgoing email character sets: |
|
739 | 739 | |
|
740 | 740 | 1. ``us-ascii``: always first, regardless of settings |
|
741 | 741 | 2. ``email.charsets``: in order given by user |
|
742 | 742 | 3. ``ui.fallbackencoding``: if not in email.charsets |
|
743 | 743 | 4. ``$HGENCODING``: if not in email.charsets |
|
744 | 744 | 5. ``utf-8``: always last, regardless of settings |
|
745 | 745 | |
|
746 | 746 | Email example:: |
|
747 | 747 | |
|
748 | 748 | [email] |
|
749 | 749 | from = Joseph User <joe.user@example.com> |
|
750 | 750 | method = /usr/sbin/sendmail |
|
751 | 751 | # charsets for western Europeans |
|
752 | 752 | # us-ascii, utf-8 omitted, as they are tried first and last |
|
753 | 753 | charsets = iso-8859-1, iso-8859-15, windows-1252 |
|
754 | 754 | |
|
755 | 755 | |
|
756 | 756 | ``extensions`` |
|
757 | 757 | -------------- |
|
758 | 758 | |
|
759 | 759 | Mercurial has an extension mechanism for adding new features. To |
|
760 | 760 | enable an extension, create an entry for it in this section. |
|
761 | 761 | |
|
762 | 762 | If you know that the extension is already in Python's search path, |
|
763 | 763 | you can give the name of the module, followed by ``=``, with nothing |
|
764 | 764 | after the ``=``. |
|
765 | 765 | |
|
766 | 766 | Otherwise, give a name that you choose, followed by ``=``, followed by |
|
767 | 767 | the path to the ``.py`` file (including the file name extension) that |
|
768 | 768 | defines the extension. |
|
769 | 769 | |
|
770 | 770 | To explicitly disable an extension that is enabled in an hgrc of |
|
771 | 771 | broader scope, prepend its path with ``!``, as in ``foo = !/ext/path`` |
|
772 | 772 | or ``foo = !`` when path is not supplied. |
|
773 | 773 | |
|
774 | 774 | Example for ``~/.hgrc``:: |
|
775 | 775 | |
|
776 | 776 | [extensions] |
|
777 | 777 | # (the churn extension will get loaded from Mercurial's path) |
|
778 | 778 | churn = |
|
779 | 779 | # (this extension will get loaded from the file specified) |
|
780 | 780 | myfeature = ~/.hgext/myfeature.py |
|
781 | 781 | |
|
782 | 782 | |
|
783 | 783 | ``format`` |
|
784 | 784 | ---------- |
|
785 | 785 | |
|
786 | 786 | ``usegeneraldelta`` |
|
787 | 787 | Enable or disable the "generaldelta" repository format which improves |
|
788 | 788 | repository compression by allowing "revlog" to store delta against arbitrary |
|
789 | 789 | revision instead of the previous stored one. This provides significant |
|
790 | 790 | improvement for repositories with branches. |
|
791 | 791 | |
|
792 | 792 | Repositories with this on-disk format require Mercurial version 1.9. |
|
793 | 793 | |
|
794 | 794 | Enabled by default. |
|
795 | 795 | |
|
796 | 796 | ``dotencode`` |
|
797 | 797 | Enable or disable the "dotencode" repository format which enhances |
|
798 | 798 | the "fncache" repository format (which has to be enabled to use |
|
799 | 799 | dotencode) to avoid issues with filenames starting with ._ on |
|
800 | 800 | Mac OS X and spaces on Windows. |
|
801 | 801 | |
|
802 | 802 | Repositories with this on-disk format require Mercurial version 1.7. |
|
803 | 803 | |
|
804 | 804 | Enabled by default. |
|
805 | 805 | |
|
806 | 806 | ``usefncache`` |
|
807 | 807 | Enable or disable the "fncache" repository format which enhances |
|
808 | 808 | the "store" repository format (which has to be enabled to use |
|
809 | 809 | fncache) to allow longer filenames and avoids using Windows |
|
810 | 810 | reserved names, e.g. "nul". |
|
811 | 811 | |
|
812 | 812 | Repositories with this on-disk format require Mercurial version 1.1. |
|
813 | 813 | |
|
814 | 814 | Enabled by default. |
|
815 | 815 | |
|
816 | 816 | ``usestore`` |
|
817 | 817 | Enable or disable the "store" repository format which improves |
|
818 | 818 | compatibility with systems that fold case or otherwise mangle |
|
819 | 819 | filenames. Disabling this option will allow you to store longer filenames |
|
820 | 820 | in some situations at the expense of compatibility. |
|
821 | 821 | |
|
822 | 822 | Repositories with this on-disk format require Mercurial version 0.9.4. |
|
823 | 823 | |
|
824 | 824 | Enabled by default. |
|
825 | 825 | |
|
826 | 826 | ``graph`` |
|
827 | 827 | --------- |
|
828 | 828 | |
|
829 | 829 | Web graph view configuration. This section let you change graph |
|
830 | 830 | elements display properties by branches, for instance to make the |
|
831 | 831 | ``default`` branch stand out. |
|
832 | 832 | |
|
833 | 833 | Each line has the following format:: |
|
834 | 834 | |
|
835 | 835 | <branch>.<argument> = <value> |
|
836 | 836 | |
|
837 | 837 | where ``<branch>`` is the name of the branch being |
|
838 | 838 | customized. Example:: |
|
839 | 839 | |
|
840 | 840 | [graph] |
|
841 | 841 | # 2px width |
|
842 | 842 | default.width = 2 |
|
843 | 843 | # red color |
|
844 | 844 | default.color = FF0000 |
|
845 | 845 | |
|
846 | 846 | Supported arguments: |
|
847 | 847 | |
|
848 | 848 | ``width`` |
|
849 | 849 | Set branch edges width in pixels. |
|
850 | 850 | |
|
851 | 851 | ``color`` |
|
852 | 852 | Set branch edges color in hexadecimal RGB notation. |
|
853 | 853 | |
|
854 | 854 | ``hooks`` |
|
855 | 855 | --------- |
|
856 | 856 | |
|
857 | 857 | Commands or Python functions that get automatically executed by |
|
858 | 858 | various actions such as starting or finishing a commit. Multiple |
|
859 | 859 | hooks can be run for the same action by appending a suffix to the |
|
860 | 860 | action. Overriding a site-wide hook can be done by changing its |
|
861 | 861 | value or setting it to an empty string. Hooks can be prioritized |
|
862 | 862 | by adding a prefix of ``priority.`` to the hook name on a new line |
|
863 | 863 | and setting the priority. The default priority is 0. |
|
864 | 864 | |
|
865 | 865 | Example ``.hg/hgrc``:: |
|
866 | 866 | |
|
867 | 867 | [hooks] |
|
868 | 868 | # update working directory after adding changesets |
|
869 | 869 | changegroup.update = hg update |
|
870 | 870 | # do not use the site-wide hook |
|
871 | 871 | incoming = |
|
872 | 872 | incoming.email = /my/email/hook |
|
873 | 873 | incoming.autobuild = /my/build/hook |
|
874 | 874 | # force autobuild hook to run before other incoming hooks |
|
875 | 875 | priority.incoming.autobuild = 1 |
|
876 | 876 | |
|
877 | 877 | Most hooks are run with environment variables set that give useful |
|
878 | 878 | additional information. For each hook below, the environment variables |
|
879 | 879 | it is passed are listed with names in the form ``$HG_foo``. The |
|
880 | 880 | ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks. |
|
881 | 881 | They contain the type of hook which triggered the run and the full name |
|
882 | 882 | of the hook in the config, respectively. In the example above, this will |
|
883 | 883 | be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``. |
|
884 | 884 | |
|
885 | 885 | ``changegroup`` |
|
886 | 886 | Run after a changegroup has been added via push, pull or unbundle. The ID of |
|
887 | 887 | the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``. |
|
888 | 888 | The URL from which changes came is in ``$HG_URL``. |
|
889 | 889 | |
|
890 | 890 | ``commit`` |
|
891 | 891 | Run after a changeset has been created in the local repository. The ID |
|
892 | 892 | of the newly created changeset is in ``$HG_NODE``. Parent changeset |
|
893 | 893 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
894 | 894 | |
|
895 | 895 | ``incoming`` |
|
896 | 896 | Run after a changeset has been pulled, pushed, or unbundled into |
|
897 | 897 | the local repository. The ID of the newly arrived changeset is in |
|
898 | 898 | ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``. |
|
899 | 899 | |
|
900 | 900 | ``outgoing`` |
|
901 | 901 | Run after sending changes from the local repository to another. The ID of |
|
902 | 902 | first changeset sent is in ``$HG_NODE``. The source of operation is in |
|
903 | 903 | ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`. |
|
904 | 904 | |
|
905 | 905 | ``post-<command>`` |
|
906 | 906 | Run after successful invocations of the associated command. The |
|
907 | 907 | contents of the command line are passed as ``$HG_ARGS`` and the result |
|
908 | 908 | code in ``$HG_RESULT``. Parsed command line arguments are passed as |
|
909 | 909 | ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of |
|
910 | 910 | the python data internally passed to <command>. ``$HG_OPTS`` is a |
|
911 | 911 | dictionary of options (with unspecified options set to their defaults). |
|
912 | 912 | ``$HG_PATS`` is a list of arguments. Hook failure is ignored. |
|
913 | 913 | |
|
914 | 914 | ``fail-<command>`` |
|
915 | 915 | Run after a failed invocation of an associated command. The contents |
|
916 | 916 | of the command line are passed as ``$HG_ARGS``. Parsed command line |
|
917 | 917 | arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain |
|
918 | 918 | string representations of the python data internally passed to |
|
919 | 919 | <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified |
|
920 | 920 | options set to their defaults). ``$HG_PATS`` is a list of arguments. |
|
921 | 921 | Hook failure is ignored. |
|
922 | 922 | |
|
923 | 923 | ``pre-<command>`` |
|
924 | 924 | Run before executing the associated command. The contents of the |
|
925 | 925 | command line are passed as ``$HG_ARGS``. Parsed command line arguments |
|
926 | 926 | are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string |
|
927 | 927 | representations of the data internally passed to <command>. ``$HG_OPTS`` |
|
928 | 928 | is a dictionary of options (with unspecified options set to their |
|
929 | 929 | defaults). ``$HG_PATS`` is a list of arguments. If the hook returns |
|
930 | 930 | failure, the command doesn't execute and Mercurial returns the failure |
|
931 | 931 | code. |
|
932 | 932 | |
|
933 | 933 | ``prechangegroup`` |
|
934 | 934 | Run before a changegroup is added via push, pull or unbundle. Exit |
|
935 | 935 | status 0 allows the changegroup to proceed. A non-zero status will |
|
936 | 936 | cause the push, pull or unbundle to fail. The URL from which changes |
|
937 | 937 | will come is in ``$HG_URL``. |
|
938 | 938 | |
|
939 | 939 | ``precommit`` |
|
940 | 940 | Run before starting a local commit. Exit status 0 allows the |
|
941 | 941 | commit to proceed. A non-zero status will cause the commit to fail. |
|
942 | 942 | Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
943 | 943 | |
|
944 | 944 | ``prelistkeys`` |
|
945 | 945 | Run before listing pushkeys (like bookmarks) in the |
|
946 | 946 | repository. A non-zero status will cause failure. The key namespace is |
|
947 | 947 | in ``$HG_NAMESPACE``. |
|
948 | 948 | |
|
949 | 949 | ``preoutgoing`` |
|
950 | 950 | Run before collecting changes to send from the local repository to |
|
951 | 951 | another. A non-zero status will cause failure. This lets you prevent |
|
952 | 952 | pull over HTTP or SSH. It can also prevent propagating commits (via |
|
953 | 953 | local pull, push (outbound) or bundle commands), but not completely, |
|
954 | 954 | since you can just copy files instead. The source of operation is in |
|
955 | 955 | ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote |
|
956 | 956 | SSH or HTTP repository. If "push", "pull" or "bundle", the operation |
|
957 | 957 | is happening on behalf of a repository on same system. |
|
958 | 958 | |
|
959 | 959 | ``prepushkey`` |
|
960 | 960 | Run before a pushkey (like a bookmark) is added to the |
|
961 | 961 | repository. A non-zero status will cause the key to be rejected. The |
|
962 | 962 | key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``, |
|
963 | 963 | the old value (if any) is in ``$HG_OLD``, and the new value is in |
|
964 | 964 | ``$HG_NEW``. |
|
965 | 965 | |
|
966 | 966 | ``pretag`` |
|
967 | 967 | Run before creating a tag. Exit status 0 allows the tag to be |
|
968 | 968 | created. A non-zero status will cause the tag to fail. The ID of the |
|
969 | 969 | changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The |
|
970 | 970 | tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``. |
|
971 | 971 | |
|
972 | 972 | ``pretxnopen`` |
|
973 | 973 | Run before any new repository transaction is open. The reason for the |
|
974 | 974 | transaction will be in ``$HG_TXNNAME``, and a unique identifier for the |
|
975 | 975 | transaction will be in ``HG_TXNID``. A non-zero status will prevent the |
|
976 | 976 | transaction from being opened. |
|
977 | 977 | |
|
978 | 978 | ``pretxnclose`` |
|
979 | 979 | Run right before the transaction is actually finalized. Any repository change |
|
980 | 980 | will be visible to the hook program. This lets you validate the transaction |
|
981 | 981 | content or change it. Exit status 0 allows the commit to proceed. A non-zero |
|
982 | 982 | status will cause the transaction to be rolled back. The reason for the |
|
983 | 983 | transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for |
|
984 | 984 | the transaction will be in ``HG_TXNID``. The rest of the available data will |
|
985 | 985 | vary according the transaction type. New changesets will add ``$HG_NODE`` |
|
986 | 986 | (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last |
|
987 | 987 | added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and |
|
988 | 988 | phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1`` |
|
989 | 989 | respectively, etc. |
|
990 | 990 | |
|
991 | 991 | ``pretxnclose-bookmark`` |
|
992 | 992 | Run right before a bookmark change is actually finalized. Any repository |
|
993 | 993 | change will be visible to the hook program. This lets you validate the |
|
994 | 994 | transaction content or change it. Exit status 0 allows the commit to |
|
995 | 995 | proceed. A non-zero status will cause the transaction to be rolled back. |
|
996 | 996 | The name of the bookmark will be available in ``$HG_BOOKMARK``, the new |
|
997 | 997 | bookmark location will be available in ``$HG_NODE`` while the previous |
|
998 | 998 | location will be available in ``$HG_OLDNODE``. In case of a bookmark |
|
999 | 999 | creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE`` |
|
1000 | 1000 | will be empty. |
|
1001 | 1001 | In addition, the reason for the transaction opening will be in |
|
1002 | 1002 | ``$HG_TXNNAME``, and a unique identifier for the transaction will be in |
|
1003 | 1003 | ``HG_TXNID``. |
|
1004 | 1004 | |
|
1005 | ``pretxnclose-phase`` | |
|
1006 | Run right before a phase change is actually finalized. Any repository change | |
|
1007 | will be visible to the hook program. This lets you validate the transaction | |
|
1008 | content or change it. Exit status 0 allows the commit to proceed. A non-zero | |
|
1009 | status will cause the transaction to be rolled back. | |
|
1010 | The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE`` | |
|
1011 | while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE`` | |
|
1012 | will be empty. In addition, the reason for the transaction opening will be in | |
|
1013 | ``$HG_TXNNAME``, and a unique identifier for the transaction will be in | |
|
1014 | ``HG_TXNID``. | |
|
1015 | ||
|
1005 | 1016 | ``txnclose`` |
|
1006 | 1017 | Run after any repository transaction has been committed. At this |
|
1007 | 1018 | point, the transaction can no longer be rolled back. The hook will run |
|
1008 | 1019 | after the lock is released. See :hg:`help config.hooks.pretxnclose` for |
|
1009 | 1020 | details about available variables. |
|
1010 | 1021 | |
|
1011 | 1022 | ``txnclose-bookmark`` |
|
1012 | 1023 | Run after any bookmark change has been committed. At this point, the |
|
1013 | 1024 | transaction can no longer be rolled back. The hook will run after the lock |
|
1014 | 1025 | is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details |
|
1015 | 1026 | about available variables. |
|
1016 | 1027 | |
|
1017 | 1028 | ``txnclose-phase`` |
|
1018 | 1029 | Run after any phase change has been committed. At this point, the |
|
1019 | 1030 | transaction can no longer be rolled back. The hook will run after the lock |
|
1020 | is released. | |
|
1021 | The affected node is available in ``$HG_NODE``, the new phase will be | |
|
1022 | available in ``$HG_PHASE`` while the previous phase will be available in | |
|
1023 | ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE`` will be empty. In | |
|
1024 | addition, the reason for the transaction opening will be in ``$HG_TXNNAME``, | |
|
1025 | and a unique identifier for the transaction will be in ``HG_TXNID``. | |
|
1031 | is released. See :hg:`help config.hooks.pretxnclose-phase` for details about | |
|
1032 | available variables. | |
|
1026 | 1033 | |
|
1027 | 1034 | ``txnabort`` |
|
1028 | 1035 | Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose` |
|
1029 | 1036 | for details about available variables. |
|
1030 | 1037 | |
|
1031 | 1038 | ``pretxnchangegroup`` |
|
1032 | 1039 | Run after a changegroup has been added via push, pull or unbundle, but before |
|
1033 | 1040 | the transaction has been committed. The changegroup is visible to the hook |
|
1034 | 1041 | program. This allows validation of incoming changes before accepting them. |
|
1035 | 1042 | The ID of the first new changeset is in ``$HG_NODE`` and last is in |
|
1036 | 1043 | ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero |
|
1037 | 1044 | status will cause the transaction to be rolled back, and the push, pull or |
|
1038 | 1045 | unbundle will fail. The URL that was the source of changes is in ``$HG_URL``. |
|
1039 | 1046 | |
|
1040 | 1047 | ``pretxncommit`` |
|
1041 | 1048 | Run after a changeset has been created, but before the transaction is |
|
1042 | 1049 | committed. The changeset is visible to the hook program. This allows |
|
1043 | 1050 | validation of the commit message and changes. Exit status 0 allows the |
|
1044 | 1051 | commit to proceed. A non-zero status will cause the transaction to |
|
1045 | 1052 | be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent |
|
1046 | 1053 | changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
1047 | 1054 | |
|
1048 | 1055 | ``preupdate`` |
|
1049 | 1056 | Run before updating the working directory. Exit status 0 allows |
|
1050 | 1057 | the update to proceed. A non-zero status will prevent the update. |
|
1051 | 1058 | The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a |
|
1052 | 1059 | merge, the ID of second new parent is in ``$HG_PARENT2``. |
|
1053 | 1060 | |
|
1054 | 1061 | ``listkeys`` |
|
1055 | 1062 | Run after listing pushkeys (like bookmarks) in the repository. The |
|
1056 | 1063 | key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a |
|
1057 | 1064 | dictionary containing the keys and values. |
|
1058 | 1065 | |
|
1059 | 1066 | ``pushkey`` |
|
1060 | 1067 | Run after a pushkey (like a bookmark) is added to the |
|
1061 | 1068 | repository. The key namespace is in ``$HG_NAMESPACE``, the key is in |
|
1062 | 1069 | ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new |
|
1063 | 1070 | value is in ``$HG_NEW``. |
|
1064 | 1071 | |
|
1065 | 1072 | ``tag`` |
|
1066 | 1073 | Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``. |
|
1067 | 1074 | The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in |
|
1068 | 1075 | the repository if ``$HG_LOCAL=0``. |
|
1069 | 1076 | |
|
1070 | 1077 | ``update`` |
|
1071 | 1078 | Run after updating the working directory. The changeset ID of first |
|
1072 | 1079 | new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new |
|
1073 | 1080 | parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the |
|
1074 | 1081 | update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``. |
|
1075 | 1082 | |
|
1076 | 1083 | .. note:: |
|
1077 | 1084 | |
|
1078 | 1085 | It is generally better to use standard hooks rather than the |
|
1079 | 1086 | generic pre- and post- command hooks, as they are guaranteed to be |
|
1080 | 1087 | called in the appropriate contexts for influencing transactions. |
|
1081 | 1088 | Also, hooks like "commit" will be called in all contexts that |
|
1082 | 1089 | generate a commit (e.g. tag) and not just the commit command. |
|
1083 | 1090 | |
|
1084 | 1091 | .. note:: |
|
1085 | 1092 | |
|
1086 | 1093 | Environment variables with empty values may not be passed to |
|
1087 | 1094 | hooks on platforms such as Windows. As an example, ``$HG_PARENT2`` |
|
1088 | 1095 | will have an empty value under Unix-like platforms for non-merge |
|
1089 | 1096 | changesets, while it will not be available at all under Windows. |
|
1090 | 1097 | |
|
1091 | 1098 | The syntax for Python hooks is as follows:: |
|
1092 | 1099 | |
|
1093 | 1100 | hookname = python:modulename.submodule.callable |
|
1094 | 1101 | hookname = python:/path/to/python/module.py:callable |
|
1095 | 1102 | |
|
1096 | 1103 | Python hooks are run within the Mercurial process. Each hook is |
|
1097 | 1104 | called with at least three keyword arguments: a ui object (keyword |
|
1098 | 1105 | ``ui``), a repository object (keyword ``repo``), and a ``hooktype`` |
|
1099 | 1106 | keyword that tells what kind of hook is used. Arguments listed as |
|
1100 | 1107 | environment variables above are passed as keyword arguments, with no |
|
1101 | 1108 | ``HG_`` prefix, and names in lower case. |
|
1102 | 1109 | |
|
1103 | 1110 | If a Python hook returns a "true" value or raises an exception, this |
|
1104 | 1111 | is treated as a failure. |
|
1105 | 1112 | |
|
1106 | 1113 | |
|
1107 | 1114 | ``hostfingerprints`` |
|
1108 | 1115 | -------------------- |
|
1109 | 1116 | |
|
1110 | 1117 | (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.) |
|
1111 | 1118 | |
|
1112 | 1119 | Fingerprints of the certificates of known HTTPS servers. |
|
1113 | 1120 | |
|
1114 | 1121 | A HTTPS connection to a server with a fingerprint configured here will |
|
1115 | 1122 | only succeed if the servers certificate matches the fingerprint. |
|
1116 | 1123 | This is very similar to how ssh known hosts works. |
|
1117 | 1124 | |
|
1118 | 1125 | The fingerprint is the SHA-1 hash value of the DER encoded certificate. |
|
1119 | 1126 | Multiple values can be specified (separated by spaces or commas). This can |
|
1120 | 1127 | be used to define both old and new fingerprints while a host transitions |
|
1121 | 1128 | to a new certificate. |
|
1122 | 1129 | |
|
1123 | 1130 | The CA chain and web.cacerts is not used for servers with a fingerprint. |
|
1124 | 1131 | |
|
1125 | 1132 | For example:: |
|
1126 | 1133 | |
|
1127 | 1134 | [hostfingerprints] |
|
1128 | 1135 | hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33 |
|
1129 | 1136 | hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33 |
|
1130 | 1137 | |
|
1131 | 1138 | ``hostsecurity`` |
|
1132 | 1139 | ---------------- |
|
1133 | 1140 | |
|
1134 | 1141 | Used to specify global and per-host security settings for connecting to |
|
1135 | 1142 | other machines. |
|
1136 | 1143 | |
|
1137 | 1144 | The following options control default behavior for all hosts. |
|
1138 | 1145 | |
|
1139 | 1146 | ``ciphers`` |
|
1140 | 1147 | Defines the cryptographic ciphers to use for connections. |
|
1141 | 1148 | |
|
1142 | 1149 | Value must be a valid OpenSSL Cipher List Format as documented at |
|
1143 | 1150 | https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT. |
|
1144 | 1151 | |
|
1145 | 1152 | This setting is for advanced users only. Setting to incorrect values |
|
1146 | 1153 | can significantly lower connection security or decrease performance. |
|
1147 | 1154 | You have been warned. |
|
1148 | 1155 | |
|
1149 | 1156 | This option requires Python 2.7. |
|
1150 | 1157 | |
|
1151 | 1158 | ``minimumprotocol`` |
|
1152 | 1159 | Defines the minimum channel encryption protocol to use. |
|
1153 | 1160 | |
|
1154 | 1161 | By default, the highest version of TLS supported by both client and server |
|
1155 | 1162 | is used. |
|
1156 | 1163 | |
|
1157 | 1164 | Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``. |
|
1158 | 1165 | |
|
1159 | 1166 | When running on an old Python version, only ``tls1.0`` is allowed since |
|
1160 | 1167 | old versions of Python only support up to TLS 1.0. |
|
1161 | 1168 | |
|
1162 | 1169 | When running a Python that supports modern TLS versions, the default is |
|
1163 | 1170 | ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this |
|
1164 | 1171 | weakens security and should only be used as a feature of last resort if |
|
1165 | 1172 | a server does not support TLS 1.1+. |
|
1166 | 1173 | |
|
1167 | 1174 | Options in the ``[hostsecurity]`` section can have the form |
|
1168 | 1175 | ``hostname``:``setting``. This allows multiple settings to be defined on a |
|
1169 | 1176 | per-host basis. |
|
1170 | 1177 | |
|
1171 | 1178 | The following per-host settings can be defined. |
|
1172 | 1179 | |
|
1173 | 1180 | ``ciphers`` |
|
1174 | 1181 | This behaves like ``ciphers`` as described above except it only applies |
|
1175 | 1182 | to the host on which it is defined. |
|
1176 | 1183 | |
|
1177 | 1184 | ``fingerprints`` |
|
1178 | 1185 | A list of hashes of the DER encoded peer/remote certificate. Values have |
|
1179 | 1186 | the form ``algorithm``:``fingerprint``. e.g. |
|
1180 | 1187 | ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``. |
|
1181 | 1188 | In addition, colons (``:``) can appear in the fingerprint part. |
|
1182 | 1189 | |
|
1183 | 1190 | The following algorithms/prefixes are supported: ``sha1``, ``sha256``, |
|
1184 | 1191 | ``sha512``. |
|
1185 | 1192 | |
|
1186 | 1193 | Use of ``sha256`` or ``sha512`` is preferred. |
|
1187 | 1194 | |
|
1188 | 1195 | If a fingerprint is specified, the CA chain is not validated for this |
|
1189 | 1196 | host and Mercurial will require the remote certificate to match one |
|
1190 | 1197 | of the fingerprints specified. This means if the server updates its |
|
1191 | 1198 | certificate, Mercurial will abort until a new fingerprint is defined. |
|
1192 | 1199 | This can provide stronger security than traditional CA-based validation |
|
1193 | 1200 | at the expense of convenience. |
|
1194 | 1201 | |
|
1195 | 1202 | This option takes precedence over ``verifycertsfile``. |
|
1196 | 1203 | |
|
1197 | 1204 | ``minimumprotocol`` |
|
1198 | 1205 | This behaves like ``minimumprotocol`` as described above except it |
|
1199 | 1206 | only applies to the host on which it is defined. |
|
1200 | 1207 | |
|
1201 | 1208 | ``verifycertsfile`` |
|
1202 | 1209 | Path to file a containing a list of PEM encoded certificates used to |
|
1203 | 1210 | verify the server certificate. Environment variables and ``~user`` |
|
1204 | 1211 | constructs are expanded in the filename. |
|
1205 | 1212 | |
|
1206 | 1213 | The server certificate or the certificate's certificate authority (CA) |
|
1207 | 1214 | must match a certificate from this file or certificate verification |
|
1208 | 1215 | will fail and connections to the server will be refused. |
|
1209 | 1216 | |
|
1210 | 1217 | If defined, only certificates provided by this file will be used: |
|
1211 | 1218 | ``web.cacerts`` and any system/default certificates will not be |
|
1212 | 1219 | used. |
|
1213 | 1220 | |
|
1214 | 1221 | This option has no effect if the per-host ``fingerprints`` option |
|
1215 | 1222 | is set. |
|
1216 | 1223 | |
|
1217 | 1224 | The format of the file is as follows:: |
|
1218 | 1225 | |
|
1219 | 1226 | -----BEGIN CERTIFICATE----- |
|
1220 | 1227 | ... (certificate in base64 PEM encoding) ... |
|
1221 | 1228 | -----END CERTIFICATE----- |
|
1222 | 1229 | -----BEGIN CERTIFICATE----- |
|
1223 | 1230 | ... (certificate in base64 PEM encoding) ... |
|
1224 | 1231 | -----END CERTIFICATE----- |
|
1225 | 1232 | |
|
1226 | 1233 | For example:: |
|
1227 | 1234 | |
|
1228 | 1235 | [hostsecurity] |
|
1229 | 1236 | hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 |
|
1230 | 1237 | hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33 |
|
1231 | 1238 | hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2 |
|
1232 | 1239 | foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem |
|
1233 | 1240 | |
|
1234 | 1241 | To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1 |
|
1235 | 1242 | when connecting to ``hg.example.com``:: |
|
1236 | 1243 | |
|
1237 | 1244 | [hostsecurity] |
|
1238 | 1245 | minimumprotocol = tls1.2 |
|
1239 | 1246 | hg.example.com:minimumprotocol = tls1.1 |
|
1240 | 1247 | |
|
1241 | 1248 | ``http_proxy`` |
|
1242 | 1249 | -------------- |
|
1243 | 1250 | |
|
1244 | 1251 | Used to access web-based Mercurial repositories through a HTTP |
|
1245 | 1252 | proxy. |
|
1246 | 1253 | |
|
1247 | 1254 | ``host`` |
|
1248 | 1255 | Host name and (optional) port of the proxy server, for example |
|
1249 | 1256 | "myproxy:8000". |
|
1250 | 1257 | |
|
1251 | 1258 | ``no`` |
|
1252 | 1259 | Optional. Comma-separated list of host names that should bypass |
|
1253 | 1260 | the proxy. |
|
1254 | 1261 | |
|
1255 | 1262 | ``passwd`` |
|
1256 | 1263 | Optional. Password to authenticate with at the proxy server. |
|
1257 | 1264 | |
|
1258 | 1265 | ``user`` |
|
1259 | 1266 | Optional. User name to authenticate with at the proxy server. |
|
1260 | 1267 | |
|
1261 | 1268 | ``always`` |
|
1262 | 1269 | Optional. Always use the proxy, even for localhost and any entries |
|
1263 | 1270 | in ``http_proxy.no``. (default: False) |
|
1264 | 1271 | |
|
1265 | 1272 | ``merge`` |
|
1266 | 1273 | --------- |
|
1267 | 1274 | |
|
1268 | 1275 | This section specifies behavior during merges and updates. |
|
1269 | 1276 | |
|
1270 | 1277 | ``checkignored`` |
|
1271 | 1278 | Controls behavior when an ignored file on disk has the same name as a tracked |
|
1272 | 1279 | file in the changeset being merged or updated to, and has different |
|
1273 | 1280 | contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``, |
|
1274 | 1281 | abort on such files. With ``warn``, warn on such files and back them up as |
|
1275 | 1282 | ``.orig``. With ``ignore``, don't print a warning and back them up as |
|
1276 | 1283 | ``.orig``. (default: ``abort``) |
|
1277 | 1284 | |
|
1278 | 1285 | ``checkunknown`` |
|
1279 | 1286 | Controls behavior when an unknown file that isn't ignored has the same name |
|
1280 | 1287 | as a tracked file in the changeset being merged or updated to, and has |
|
1281 | 1288 | different contents. Similar to ``merge.checkignored``, except for files that |
|
1282 | 1289 | are not ignored. (default: ``abort``) |
|
1283 | 1290 | |
|
1284 | 1291 | ``merge-patterns`` |
|
1285 | 1292 | ------------------ |
|
1286 | 1293 | |
|
1287 | 1294 | This section specifies merge tools to associate with particular file |
|
1288 | 1295 | patterns. Tools matched here will take precedence over the default |
|
1289 | 1296 | merge tool. Patterns are globs by default, rooted at the repository |
|
1290 | 1297 | root. |
|
1291 | 1298 | |
|
1292 | 1299 | Example:: |
|
1293 | 1300 | |
|
1294 | 1301 | [merge-patterns] |
|
1295 | 1302 | **.c = kdiff3 |
|
1296 | 1303 | **.jpg = myimgmerge |
|
1297 | 1304 | |
|
1298 | 1305 | ``merge-tools`` |
|
1299 | 1306 | --------------- |
|
1300 | 1307 | |
|
1301 | 1308 | This section configures external merge tools to use for file-level |
|
1302 | 1309 | merges. This section has likely been preconfigured at install time. |
|
1303 | 1310 | Use :hg:`config merge-tools` to check the existing configuration. |
|
1304 | 1311 | Also see :hg:`help merge-tools` for more details. |
|
1305 | 1312 | |
|
1306 | 1313 | Example ``~/.hgrc``:: |
|
1307 | 1314 | |
|
1308 | 1315 | [merge-tools] |
|
1309 | 1316 | # Override stock tool location |
|
1310 | 1317 | kdiff3.executable = ~/bin/kdiff3 |
|
1311 | 1318 | # Specify command line |
|
1312 | 1319 | kdiff3.args = $base $local $other -o $output |
|
1313 | 1320 | # Give higher priority |
|
1314 | 1321 | kdiff3.priority = 1 |
|
1315 | 1322 | |
|
1316 | 1323 | # Changing the priority of preconfigured tool |
|
1317 | 1324 | meld.priority = 0 |
|
1318 | 1325 | |
|
1319 | 1326 | # Disable a preconfigured tool |
|
1320 | 1327 | vimdiff.disabled = yes |
|
1321 | 1328 | |
|
1322 | 1329 | # Define new tool |
|
1323 | 1330 | myHtmlTool.args = -m $local $other $base $output |
|
1324 | 1331 | myHtmlTool.regkey = Software\FooSoftware\HtmlMerge |
|
1325 | 1332 | myHtmlTool.priority = 1 |
|
1326 | 1333 | |
|
1327 | 1334 | Supported arguments: |
|
1328 | 1335 | |
|
1329 | 1336 | ``priority`` |
|
1330 | 1337 | The priority in which to evaluate this tool. |
|
1331 | 1338 | (default: 0) |
|
1332 | 1339 | |
|
1333 | 1340 | ``executable`` |
|
1334 | 1341 | Either just the name of the executable or its pathname. |
|
1335 | 1342 | |
|
1336 | 1343 | .. container:: windows |
|
1337 | 1344 | |
|
1338 | 1345 | On Windows, the path can use environment variables with ${ProgramFiles} |
|
1339 | 1346 | syntax. |
|
1340 | 1347 | |
|
1341 | 1348 | (default: the tool name) |
|
1342 | 1349 | |
|
1343 | 1350 | ``args`` |
|
1344 | 1351 | The arguments to pass to the tool executable. You can refer to the |
|
1345 | 1352 | files being merged as well as the output file through these |
|
1346 | 1353 | variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning |
|
1347 | 1354 | of ``$local`` and ``$other`` can vary depending on which action is being |
|
1348 | 1355 | performed. During and update or merge, ``$local`` represents the original |
|
1349 | 1356 | state of the file, while ``$other`` represents the commit you are updating |
|
1350 | 1357 | to or the commit you are merging with. During a rebase ``$local`` |
|
1351 | 1358 | represents the destination of the rebase, and ``$other`` represents the |
|
1352 | 1359 | commit being rebased. |
|
1353 | 1360 | (default: ``$local $base $other``) |
|
1354 | 1361 | |
|
1355 | 1362 | ``premerge`` |
|
1356 | 1363 | Attempt to run internal non-interactive 3-way merge tool before |
|
1357 | 1364 | launching external tool. Options are ``true``, ``false``, ``keep`` or |
|
1358 | 1365 | ``keep-merge3``. The ``keep`` option will leave markers in the file if the |
|
1359 | 1366 | premerge fails. The ``keep-merge3`` will do the same but include information |
|
1360 | 1367 | about the base of the merge in the marker (see internal :merge3 in |
|
1361 | 1368 | :hg:`help merge-tools`). |
|
1362 | 1369 | (default: True) |
|
1363 | 1370 | |
|
1364 | 1371 | ``binary`` |
|
1365 | 1372 | This tool can merge binary files. (default: False, unless tool |
|
1366 | 1373 | was selected by file pattern match) |
|
1367 | 1374 | |
|
1368 | 1375 | ``symlink`` |
|
1369 | 1376 | This tool can merge symlinks. (default: False) |
|
1370 | 1377 | |
|
1371 | 1378 | ``check`` |
|
1372 | 1379 | A list of merge success-checking options: |
|
1373 | 1380 | |
|
1374 | 1381 | ``changed`` |
|
1375 | 1382 | Ask whether merge was successful when the merged file shows no changes. |
|
1376 | 1383 | ``conflicts`` |
|
1377 | 1384 | Check whether there are conflicts even though the tool reported success. |
|
1378 | 1385 | ``prompt`` |
|
1379 | 1386 | Always prompt for merge success, regardless of success reported by tool. |
|
1380 | 1387 | |
|
1381 | 1388 | ``fixeol`` |
|
1382 | 1389 | Attempt to fix up EOL changes caused by the merge tool. |
|
1383 | 1390 | (default: False) |
|
1384 | 1391 | |
|
1385 | 1392 | ``gui`` |
|
1386 | 1393 | This tool requires a graphical interface to run. (default: False) |
|
1387 | 1394 | |
|
1388 | 1395 | .. container:: windows |
|
1389 | 1396 | |
|
1390 | 1397 | ``regkey`` |
|
1391 | 1398 | Windows registry key which describes install location of this |
|
1392 | 1399 | tool. Mercurial will search for this key first under |
|
1393 | 1400 | ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``. |
|
1394 | 1401 | (default: None) |
|
1395 | 1402 | |
|
1396 | 1403 | ``regkeyalt`` |
|
1397 | 1404 | An alternate Windows registry key to try if the first key is not |
|
1398 | 1405 | found. The alternate key uses the same ``regname`` and ``regappend`` |
|
1399 | 1406 | semantics of the primary key. The most common use for this key |
|
1400 | 1407 | is to search for 32bit applications on 64bit operating systems. |
|
1401 | 1408 | (default: None) |
|
1402 | 1409 | |
|
1403 | 1410 | ``regname`` |
|
1404 | 1411 | Name of value to read from specified registry key. |
|
1405 | 1412 | (default: the unnamed (default) value) |
|
1406 | 1413 | |
|
1407 | 1414 | ``regappend`` |
|
1408 | 1415 | String to append to the value read from the registry, typically |
|
1409 | 1416 | the executable name of the tool. |
|
1410 | 1417 | (default: None) |
|
1411 | 1418 | |
|
1412 | 1419 | ``pager`` |
|
1413 | 1420 | --------- |
|
1414 | 1421 | |
|
1415 | 1422 | Setting used to control when to paginate and with what external tool. See |
|
1416 | 1423 | :hg:`help pager` for details. |
|
1417 | 1424 | |
|
1418 | 1425 | ``pager`` |
|
1419 | 1426 | Define the external tool used as pager. |
|
1420 | 1427 | |
|
1421 | 1428 | If no pager is set, Mercurial uses the environment variable $PAGER. |
|
1422 | 1429 | If neither pager.pager, nor $PAGER is set, a default pager will be |
|
1423 | 1430 | used, typically `less` on Unix and `more` on Windows. Example:: |
|
1424 | 1431 | |
|
1425 | 1432 | [pager] |
|
1426 | 1433 | pager = less -FRX |
|
1427 | 1434 | |
|
1428 | 1435 | ``ignore`` |
|
1429 | 1436 | List of commands to disable the pager for. Example:: |
|
1430 | 1437 | |
|
1431 | 1438 | [pager] |
|
1432 | 1439 | ignore = version, help, update |
|
1433 | 1440 | |
|
1434 | 1441 | ``patch`` |
|
1435 | 1442 | --------- |
|
1436 | 1443 | |
|
1437 | 1444 | Settings used when applying patches, for instance through the 'import' |
|
1438 | 1445 | command or with Mercurial Queues extension. |
|
1439 | 1446 | |
|
1440 | 1447 | ``eol`` |
|
1441 | 1448 | When set to 'strict' patch content and patched files end of lines |
|
1442 | 1449 | are preserved. When set to ``lf`` or ``crlf``, both files end of |
|
1443 | 1450 | lines are ignored when patching and the result line endings are |
|
1444 | 1451 | normalized to either LF (Unix) or CRLF (Windows). When set to |
|
1445 | 1452 | ``auto``, end of lines are again ignored while patching but line |
|
1446 | 1453 | endings in patched files are normalized to their original setting |
|
1447 | 1454 | on a per-file basis. If target file does not exist or has no end |
|
1448 | 1455 | of line, patch line endings are preserved. |
|
1449 | 1456 | (default: strict) |
|
1450 | 1457 | |
|
1451 | 1458 | ``fuzz`` |
|
1452 | 1459 | The number of lines of 'fuzz' to allow when applying patches. This |
|
1453 | 1460 | controls how much context the patcher is allowed to ignore when |
|
1454 | 1461 | trying to apply a patch. |
|
1455 | 1462 | (default: 2) |
|
1456 | 1463 | |
|
1457 | 1464 | ``paths`` |
|
1458 | 1465 | --------- |
|
1459 | 1466 | |
|
1460 | 1467 | Assigns symbolic names and behavior to repositories. |
|
1461 | 1468 | |
|
1462 | 1469 | Options are symbolic names defining the URL or directory that is the |
|
1463 | 1470 | location of the repository. Example:: |
|
1464 | 1471 | |
|
1465 | 1472 | [paths] |
|
1466 | 1473 | my_server = https://example.com/my_repo |
|
1467 | 1474 | local_path = /home/me/repo |
|
1468 | 1475 | |
|
1469 | 1476 | These symbolic names can be used from the command line. To pull |
|
1470 | 1477 | from ``my_server``: :hg:`pull my_server`. To push to ``local_path``: |
|
1471 | 1478 | :hg:`push local_path`. |
|
1472 | 1479 | |
|
1473 | 1480 | Options containing colons (``:``) denote sub-options that can influence |
|
1474 | 1481 | behavior for that specific path. Example:: |
|
1475 | 1482 | |
|
1476 | 1483 | [paths] |
|
1477 | 1484 | my_server = https://example.com/my_path |
|
1478 | 1485 | my_server:pushurl = ssh://example.com/my_path |
|
1479 | 1486 | |
|
1480 | 1487 | The following sub-options can be defined: |
|
1481 | 1488 | |
|
1482 | 1489 | ``pushurl`` |
|
1483 | 1490 | The URL to use for push operations. If not defined, the location |
|
1484 | 1491 | defined by the path's main entry is used. |
|
1485 | 1492 | |
|
1486 | 1493 | ``pushrev`` |
|
1487 | 1494 | A revset defining which revisions to push by default. |
|
1488 | 1495 | |
|
1489 | 1496 | When :hg:`push` is executed without a ``-r`` argument, the revset |
|
1490 | 1497 | defined by this sub-option is evaluated to determine what to push. |
|
1491 | 1498 | |
|
1492 | 1499 | For example, a value of ``.`` will push the working directory's |
|
1493 | 1500 | revision by default. |
|
1494 | 1501 | |
|
1495 | 1502 | Revsets specifying bookmarks will not result in the bookmark being |
|
1496 | 1503 | pushed. |
|
1497 | 1504 | |
|
1498 | 1505 | The following special named paths exist: |
|
1499 | 1506 | |
|
1500 | 1507 | ``default`` |
|
1501 | 1508 | The URL or directory to use when no source or remote is specified. |
|
1502 | 1509 | |
|
1503 | 1510 | :hg:`clone` will automatically define this path to the location the |
|
1504 | 1511 | repository was cloned from. |
|
1505 | 1512 | |
|
1506 | 1513 | ``default-push`` |
|
1507 | 1514 | (deprecated) The URL or directory for the default :hg:`push` location. |
|
1508 | 1515 | ``default:pushurl`` should be used instead. |
|
1509 | 1516 | |
|
1510 | 1517 | ``phases`` |
|
1511 | 1518 | ---------- |
|
1512 | 1519 | |
|
1513 | 1520 | Specifies default handling of phases. See :hg:`help phases` for more |
|
1514 | 1521 | information about working with phases. |
|
1515 | 1522 | |
|
1516 | 1523 | ``publish`` |
|
1517 | 1524 | Controls draft phase behavior when working as a server. When true, |
|
1518 | 1525 | pushed changesets are set to public in both client and server and |
|
1519 | 1526 | pulled or cloned changesets are set to public in the client. |
|
1520 | 1527 | (default: True) |
|
1521 | 1528 | |
|
1522 | 1529 | ``new-commit`` |
|
1523 | 1530 | Phase of newly-created commits. |
|
1524 | 1531 | (default: draft) |
|
1525 | 1532 | |
|
1526 | 1533 | ``checksubrepos`` |
|
1527 | 1534 | Check the phase of the current revision of each subrepository. Allowed |
|
1528 | 1535 | values are "ignore", "follow" and "abort". For settings other than |
|
1529 | 1536 | "ignore", the phase of the current revision of each subrepository is |
|
1530 | 1537 | checked before committing the parent repository. If any of those phases is |
|
1531 | 1538 | greater than the phase of the parent repository (e.g. if a subrepo is in a |
|
1532 | 1539 | "secret" phase while the parent repo is in "draft" phase), the commit is |
|
1533 | 1540 | either aborted (if checksubrepos is set to "abort") or the higher phase is |
|
1534 | 1541 | used for the parent repository commit (if set to "follow"). |
|
1535 | 1542 | (default: follow) |
|
1536 | 1543 | |
|
1537 | 1544 | |
|
1538 | 1545 | ``profiling`` |
|
1539 | 1546 | ------------- |
|
1540 | 1547 | |
|
1541 | 1548 | Specifies profiling type, format, and file output. Two profilers are |
|
1542 | 1549 | supported: an instrumenting profiler (named ``ls``), and a sampling |
|
1543 | 1550 | profiler (named ``stat``). |
|
1544 | 1551 | |
|
1545 | 1552 | In this section description, 'profiling data' stands for the raw data |
|
1546 | 1553 | collected during profiling, while 'profiling report' stands for a |
|
1547 | 1554 | statistical text report generated from the profiling data. The |
|
1548 | 1555 | profiling is done using lsprof. |
|
1549 | 1556 | |
|
1550 | 1557 | ``enabled`` |
|
1551 | 1558 | Enable the profiler. |
|
1552 | 1559 | (default: false) |
|
1553 | 1560 | |
|
1554 | 1561 | This is equivalent to passing ``--profile`` on the command line. |
|
1555 | 1562 | |
|
1556 | 1563 | ``type`` |
|
1557 | 1564 | The type of profiler to use. |
|
1558 | 1565 | (default: stat) |
|
1559 | 1566 | |
|
1560 | 1567 | ``ls`` |
|
1561 | 1568 | Use Python's built-in instrumenting profiler. This profiler |
|
1562 | 1569 | works on all platforms, but each line number it reports is the |
|
1563 | 1570 | first line of a function. This restriction makes it difficult to |
|
1564 | 1571 | identify the expensive parts of a non-trivial function. |
|
1565 | 1572 | ``stat`` |
|
1566 | 1573 | Use a statistical profiler, statprof. This profiler is most |
|
1567 | 1574 | useful for profiling commands that run for longer than about 0.1 |
|
1568 | 1575 | seconds. |
|
1569 | 1576 | |
|
1570 | 1577 | ``format`` |
|
1571 | 1578 | Profiling format. Specific to the ``ls`` instrumenting profiler. |
|
1572 | 1579 | (default: text) |
|
1573 | 1580 | |
|
1574 | 1581 | ``text`` |
|
1575 | 1582 | Generate a profiling report. When saving to a file, it should be |
|
1576 | 1583 | noted that only the report is saved, and the profiling data is |
|
1577 | 1584 | not kept. |
|
1578 | 1585 | ``kcachegrind`` |
|
1579 | 1586 | Format profiling data for kcachegrind use: when saving to a |
|
1580 | 1587 | file, the generated file can directly be loaded into |
|
1581 | 1588 | kcachegrind. |
|
1582 | 1589 | |
|
1583 | 1590 | ``statformat`` |
|
1584 | 1591 | Profiling format for the ``stat`` profiler. |
|
1585 | 1592 | (default: hotpath) |
|
1586 | 1593 | |
|
1587 | 1594 | ``hotpath`` |
|
1588 | 1595 | Show a tree-based display containing the hot path of execution (where |
|
1589 | 1596 | most time was spent). |
|
1590 | 1597 | ``bymethod`` |
|
1591 | 1598 | Show a table of methods ordered by how frequently they are active. |
|
1592 | 1599 | ``byline`` |
|
1593 | 1600 | Show a table of lines in files ordered by how frequently they are active. |
|
1594 | 1601 | ``json`` |
|
1595 | 1602 | Render profiling data as JSON. |
|
1596 | 1603 | |
|
1597 | 1604 | ``frequency`` |
|
1598 | 1605 | Sampling frequency. Specific to the ``stat`` sampling profiler. |
|
1599 | 1606 | (default: 1000) |
|
1600 | 1607 | |
|
1601 | 1608 | ``output`` |
|
1602 | 1609 | File path where profiling data or report should be saved. If the |
|
1603 | 1610 | file exists, it is replaced. (default: None, data is printed on |
|
1604 | 1611 | stderr) |
|
1605 | 1612 | |
|
1606 | 1613 | ``sort`` |
|
1607 | 1614 | Sort field. Specific to the ``ls`` instrumenting profiler. |
|
1608 | 1615 | One of ``callcount``, ``reccallcount``, ``totaltime`` and |
|
1609 | 1616 | ``inlinetime``. |
|
1610 | 1617 | (default: inlinetime) |
|
1611 | 1618 | |
|
1612 | 1619 | ``limit`` |
|
1613 | 1620 | Number of lines to show. Specific to the ``ls`` instrumenting profiler. |
|
1614 | 1621 | (default: 30) |
|
1615 | 1622 | |
|
1616 | 1623 | ``nested`` |
|
1617 | 1624 | Show at most this number of lines of drill-down info after each main entry. |
|
1618 | 1625 | This can help explain the difference between Total and Inline. |
|
1619 | 1626 | Specific to the ``ls`` instrumenting profiler. |
|
1620 | 1627 | (default: 5) |
|
1621 | 1628 | |
|
1622 | 1629 | ``showmin`` |
|
1623 | 1630 | Minimum fraction of samples an entry must have for it to be displayed. |
|
1624 | 1631 | Can be specified as a float between ``0.0`` and ``1.0`` or can have a |
|
1625 | 1632 | ``%`` afterwards to allow values up to ``100``. e.g. ``5%``. |
|
1626 | 1633 | |
|
1627 | 1634 | Only used by the ``stat`` profiler. |
|
1628 | 1635 | |
|
1629 | 1636 | For the ``hotpath`` format, default is ``0.05``. |
|
1630 | 1637 | For the ``chrome`` format, default is ``0.005``. |
|
1631 | 1638 | |
|
1632 | 1639 | The option is unused on other formats. |
|
1633 | 1640 | |
|
1634 | 1641 | ``showmax`` |
|
1635 | 1642 | Maximum fraction of samples an entry can have before it is ignored in |
|
1636 | 1643 | display. Values format is the same as ``showmin``. |
|
1637 | 1644 | |
|
1638 | 1645 | Only used by the ``stat`` profiler. |
|
1639 | 1646 | |
|
1640 | 1647 | For the ``chrome`` format, default is ``0.999``. |
|
1641 | 1648 | |
|
1642 | 1649 | The option is unused on other formats. |
|
1643 | 1650 | |
|
1644 | 1651 | ``progress`` |
|
1645 | 1652 | ------------ |
|
1646 | 1653 | |
|
1647 | 1654 | Mercurial commands can draw progress bars that are as informative as |
|
1648 | 1655 | possible. Some progress bars only offer indeterminate information, while others |
|
1649 | 1656 | have a definite end point. |
|
1650 | 1657 | |
|
1651 | 1658 | ``delay`` |
|
1652 | 1659 | Number of seconds (float) before showing the progress bar. (default: 3) |
|
1653 | 1660 | |
|
1654 | 1661 | ``changedelay`` |
|
1655 | 1662 | Minimum delay before showing a new topic. When set to less than 3 * refresh, |
|
1656 | 1663 | that value will be used instead. (default: 1) |
|
1657 | 1664 | |
|
1658 | 1665 | ``estimateinterval`` |
|
1659 | 1666 | Maximum sampling interval in seconds for speed and estimated time |
|
1660 | 1667 | calculation. (default: 60) |
|
1661 | 1668 | |
|
1662 | 1669 | ``refresh`` |
|
1663 | 1670 | Time in seconds between refreshes of the progress bar. (default: 0.1) |
|
1664 | 1671 | |
|
1665 | 1672 | ``format`` |
|
1666 | 1673 | Format of the progress bar. |
|
1667 | 1674 | |
|
1668 | 1675 | Valid entries for the format field are ``topic``, ``bar``, ``number``, |
|
1669 | 1676 | ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the |
|
1670 | 1677 | last 20 characters of the item, but this can be changed by adding either |
|
1671 | 1678 | ``-<num>`` which would take the last num characters, or ``+<num>`` for the |
|
1672 | 1679 | first num characters. |
|
1673 | 1680 | |
|
1674 | 1681 | (default: topic bar number estimate) |
|
1675 | 1682 | |
|
1676 | 1683 | ``width`` |
|
1677 | 1684 | If set, the maximum width of the progress information (that is, min(width, |
|
1678 | 1685 | term width) will be used). |
|
1679 | 1686 | |
|
1680 | 1687 | ``clear-complete`` |
|
1681 | 1688 | Clear the progress bar after it's done. (default: True) |
|
1682 | 1689 | |
|
1683 | 1690 | ``disable`` |
|
1684 | 1691 | If true, don't show a progress bar. |
|
1685 | 1692 | |
|
1686 | 1693 | ``assume-tty`` |
|
1687 | 1694 | If true, ALWAYS show a progress bar, unless disable is given. |
|
1688 | 1695 | |
|
1689 | 1696 | ``rebase`` |
|
1690 | 1697 | ---------- |
|
1691 | 1698 | |
|
1692 | 1699 | ``allowdivergence`` |
|
1693 | 1700 | Default to False, when True allow creating divergence when performing |
|
1694 | 1701 | rebase of obsolete changesets. |
|
1695 | 1702 | |
|
1696 | 1703 | ``revsetalias`` |
|
1697 | 1704 | --------------- |
|
1698 | 1705 | |
|
1699 | 1706 | Alias definitions for revsets. See :hg:`help revsets` for details. |
|
1700 | 1707 | |
|
1701 | 1708 | ``server`` |
|
1702 | 1709 | ---------- |
|
1703 | 1710 | |
|
1704 | 1711 | Controls generic server settings. |
|
1705 | 1712 | |
|
1706 | 1713 | ``compressionengines`` |
|
1707 | 1714 | List of compression engines and their relative priority to advertise |
|
1708 | 1715 | to clients. |
|
1709 | 1716 | |
|
1710 | 1717 | The order of compression engines determines their priority, the first |
|
1711 | 1718 | having the highest priority. If a compression engine is not listed |
|
1712 | 1719 | here, it won't be advertised to clients. |
|
1713 | 1720 | |
|
1714 | 1721 | If not set (the default), built-in defaults are used. Run |
|
1715 | 1722 | :hg:`debuginstall` to list available compression engines and their |
|
1716 | 1723 | default wire protocol priority. |
|
1717 | 1724 | |
|
1718 | 1725 | Older Mercurial clients only support zlib compression and this setting |
|
1719 | 1726 | has no effect for legacy clients. |
|
1720 | 1727 | |
|
1721 | 1728 | ``uncompressed`` |
|
1722 | 1729 | Whether to allow clients to clone a repository using the |
|
1723 | 1730 | uncompressed streaming protocol. This transfers about 40% more |
|
1724 | 1731 | data than a regular clone, but uses less memory and CPU on both |
|
1725 | 1732 | server and client. Over a LAN (100 Mbps or better) or a very fast |
|
1726 | 1733 | WAN, an uncompressed streaming clone is a lot faster (~10x) than a |
|
1727 | 1734 | regular clone. Over most WAN connections (anything slower than |
|
1728 | 1735 | about 6 Mbps), uncompressed streaming is slower, because of the |
|
1729 | 1736 | extra data transfer overhead. This mode will also temporarily hold |
|
1730 | 1737 | the write lock while determining what data to transfer. |
|
1731 | 1738 | (default: True) |
|
1732 | 1739 | |
|
1733 | 1740 | ``uncompressedallowsecret`` |
|
1734 | 1741 | Whether to allow stream clones when the repository contains secret |
|
1735 | 1742 | changesets. (default: False) |
|
1736 | 1743 | |
|
1737 | 1744 | ``preferuncompressed`` |
|
1738 | 1745 | When set, clients will try to use the uncompressed streaming |
|
1739 | 1746 | protocol. (default: False) |
|
1740 | 1747 | |
|
1741 | 1748 | ``disablefullbundle`` |
|
1742 | 1749 | When set, servers will refuse attempts to do pull-based clones. |
|
1743 | 1750 | If this option is set, ``preferuncompressed`` and/or clone bundles |
|
1744 | 1751 | are highly recommended. Partial clones will still be allowed. |
|
1745 | 1752 | (default: False) |
|
1746 | 1753 | |
|
1747 | 1754 | ``concurrent-push-mode`` |
|
1748 | 1755 | Level of allowed race condition between two pushing clients. |
|
1749 | 1756 | |
|
1750 | 1757 | - 'strict': push is abort if another client touched the repository |
|
1751 | 1758 | while the push was preparing. (default) |
|
1752 | 1759 | - 'check-related': push is only aborted if it affects head that got also |
|
1753 | 1760 | affected while the push was preparing. |
|
1754 | 1761 | |
|
1755 | 1762 | This requires compatible client (version 4.3 and later). Old client will |
|
1756 | 1763 | use 'strict'. |
|
1757 | 1764 | |
|
1758 | 1765 | ``validate`` |
|
1759 | 1766 | Whether to validate the completeness of pushed changesets by |
|
1760 | 1767 | checking that all new file revisions specified in manifests are |
|
1761 | 1768 | present. (default: False) |
|
1762 | 1769 | |
|
1763 | 1770 | ``maxhttpheaderlen`` |
|
1764 | 1771 | Instruct HTTP clients not to send request headers longer than this |
|
1765 | 1772 | many bytes. (default: 1024) |
|
1766 | 1773 | |
|
1767 | 1774 | ``bundle1`` |
|
1768 | 1775 | Whether to allow clients to push and pull using the legacy bundle1 |
|
1769 | 1776 | exchange format. (default: True) |
|
1770 | 1777 | |
|
1771 | 1778 | ``bundle1gd`` |
|
1772 | 1779 | Like ``bundle1`` but only used if the repository is using the |
|
1773 | 1780 | *generaldelta* storage format. (default: True) |
|
1774 | 1781 | |
|
1775 | 1782 | ``bundle1.push`` |
|
1776 | 1783 | Whether to allow clients to push using the legacy bundle1 exchange |
|
1777 | 1784 | format. (default: True) |
|
1778 | 1785 | |
|
1779 | 1786 | ``bundle1gd.push`` |
|
1780 | 1787 | Like ``bundle1.push`` but only used if the repository is using the |
|
1781 | 1788 | *generaldelta* storage format. (default: True) |
|
1782 | 1789 | |
|
1783 | 1790 | ``bundle1.pull`` |
|
1784 | 1791 | Whether to allow clients to pull using the legacy bundle1 exchange |
|
1785 | 1792 | format. (default: True) |
|
1786 | 1793 | |
|
1787 | 1794 | ``bundle1gd.pull`` |
|
1788 | 1795 | Like ``bundle1.pull`` but only used if the repository is using the |
|
1789 | 1796 | *generaldelta* storage format. (default: True) |
|
1790 | 1797 | |
|
1791 | 1798 | Large repositories using the *generaldelta* storage format should |
|
1792 | 1799 | consider setting this option because converting *generaldelta* |
|
1793 | 1800 | repositories to the exchange format required by the bundle1 data |
|
1794 | 1801 | format can consume a lot of CPU. |
|
1795 | 1802 | |
|
1796 | 1803 | ``zliblevel`` |
|
1797 | 1804 | Integer between ``-1`` and ``9`` that controls the zlib compression level |
|
1798 | 1805 | for wire protocol commands that send zlib compressed output (notably the |
|
1799 | 1806 | commands that send repository history data). |
|
1800 | 1807 | |
|
1801 | 1808 | The default (``-1``) uses the default zlib compression level, which is |
|
1802 | 1809 | likely equivalent to ``6``. ``0`` means no compression. ``9`` means |
|
1803 | 1810 | maximum compression. |
|
1804 | 1811 | |
|
1805 | 1812 | Setting this option allows server operators to make trade-offs between |
|
1806 | 1813 | bandwidth and CPU used. Lowering the compression lowers CPU utilization |
|
1807 | 1814 | but sends more bytes to clients. |
|
1808 | 1815 | |
|
1809 | 1816 | This option only impacts the HTTP server. |
|
1810 | 1817 | |
|
1811 | 1818 | ``zstdlevel`` |
|
1812 | 1819 | Integer between ``1`` and ``22`` that controls the zstd compression level |
|
1813 | 1820 | for wire protocol commands. ``1`` is the minimal amount of compression and |
|
1814 | 1821 | ``22`` is the highest amount of compression. |
|
1815 | 1822 | |
|
1816 | 1823 | The default (``3``) should be significantly faster than zlib while likely |
|
1817 | 1824 | delivering better compression ratios. |
|
1818 | 1825 | |
|
1819 | 1826 | This option only impacts the HTTP server. |
|
1820 | 1827 | |
|
1821 | 1828 | See also ``server.zliblevel``. |
|
1822 | 1829 | |
|
1823 | 1830 | ``smtp`` |
|
1824 | 1831 | -------- |
|
1825 | 1832 | |
|
1826 | 1833 | Configuration for extensions that need to send email messages. |
|
1827 | 1834 | |
|
1828 | 1835 | ``host`` |
|
1829 | 1836 | Host name of mail server, e.g. "mail.example.com". |
|
1830 | 1837 | |
|
1831 | 1838 | ``port`` |
|
1832 | 1839 | Optional. Port to connect to on mail server. (default: 465 if |
|
1833 | 1840 | ``tls`` is smtps; 25 otherwise) |
|
1834 | 1841 | |
|
1835 | 1842 | ``tls`` |
|
1836 | 1843 | Optional. Method to enable TLS when connecting to mail server: starttls, |
|
1837 | 1844 | smtps or none. (default: none) |
|
1838 | 1845 | |
|
1839 | 1846 | ``username`` |
|
1840 | 1847 | Optional. User name for authenticating with the SMTP server. |
|
1841 | 1848 | (default: None) |
|
1842 | 1849 | |
|
1843 | 1850 | ``password`` |
|
1844 | 1851 | Optional. Password for authenticating with the SMTP server. If not |
|
1845 | 1852 | specified, interactive sessions will prompt the user for a |
|
1846 | 1853 | password; non-interactive sessions will fail. (default: None) |
|
1847 | 1854 | |
|
1848 | 1855 | ``local_hostname`` |
|
1849 | 1856 | Optional. The hostname that the sender can use to identify |
|
1850 | 1857 | itself to the MTA. |
|
1851 | 1858 | |
|
1852 | 1859 | |
|
1853 | 1860 | ``subpaths`` |
|
1854 | 1861 | ------------ |
|
1855 | 1862 | |
|
1856 | 1863 | Subrepository source URLs can go stale if a remote server changes name |
|
1857 | 1864 | or becomes temporarily unavailable. This section lets you define |
|
1858 | 1865 | rewrite rules of the form:: |
|
1859 | 1866 | |
|
1860 | 1867 | <pattern> = <replacement> |
|
1861 | 1868 | |
|
1862 | 1869 | where ``pattern`` is a regular expression matching a subrepository |
|
1863 | 1870 | source URL and ``replacement`` is the replacement string used to |
|
1864 | 1871 | rewrite it. Groups can be matched in ``pattern`` and referenced in |
|
1865 | 1872 | ``replacements``. For instance:: |
|
1866 | 1873 | |
|
1867 | 1874 | http://server/(.*)-hg/ = http://hg.server/\1/ |
|
1868 | 1875 | |
|
1869 | 1876 | rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``. |
|
1870 | 1877 | |
|
1871 | 1878 | Relative subrepository paths are first made absolute, and the |
|
1872 | 1879 | rewrite rules are then applied on the full (absolute) path. If ``pattern`` |
|
1873 | 1880 | doesn't match the full path, an attempt is made to apply it on the |
|
1874 | 1881 | relative path alone. The rules are applied in definition order. |
|
1875 | 1882 | |
|
1876 | 1883 | ``templatealias`` |
|
1877 | 1884 | ----------------- |
|
1878 | 1885 | |
|
1879 | 1886 | Alias definitions for templates. See :hg:`help templates` for details. |
|
1880 | 1887 | |
|
1881 | 1888 | ``templates`` |
|
1882 | 1889 | ------------- |
|
1883 | 1890 | |
|
1884 | 1891 | Use the ``[templates]`` section to define template strings. |
|
1885 | 1892 | See :hg:`help templates` for details. |
|
1886 | 1893 | |
|
1887 | 1894 | ``trusted`` |
|
1888 | 1895 | ----------- |
|
1889 | 1896 | |
|
1890 | 1897 | Mercurial will not use the settings in the |
|
1891 | 1898 | ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted |
|
1892 | 1899 | user or to a trusted group, as various hgrc features allow arbitrary |
|
1893 | 1900 | commands to be run. This issue is often encountered when configuring |
|
1894 | 1901 | hooks or extensions for shared repositories or servers. However, |
|
1895 | 1902 | the web interface will use some safe settings from the ``[web]`` |
|
1896 | 1903 | section. |
|
1897 | 1904 | |
|
1898 | 1905 | This section specifies what users and groups are trusted. The |
|
1899 | 1906 | current user is always trusted. To trust everybody, list a user or a |
|
1900 | 1907 | group with name ``*``. These settings must be placed in an |
|
1901 | 1908 | *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the |
|
1902 | 1909 | user or service running Mercurial. |
|
1903 | 1910 | |
|
1904 | 1911 | ``users`` |
|
1905 | 1912 | Comma-separated list of trusted users. |
|
1906 | 1913 | |
|
1907 | 1914 | ``groups`` |
|
1908 | 1915 | Comma-separated list of trusted groups. |
|
1909 | 1916 | |
|
1910 | 1917 | |
|
1911 | 1918 | ``ui`` |
|
1912 | 1919 | ------ |
|
1913 | 1920 | |
|
1914 | 1921 | User interface controls. |
|
1915 | 1922 | |
|
1916 | 1923 | ``archivemeta`` |
|
1917 | 1924 | Whether to include the .hg_archival.txt file containing meta data |
|
1918 | 1925 | (hashes for the repository base and for tip) in archives created |
|
1919 | 1926 | by the :hg:`archive` command or downloaded via hgweb. |
|
1920 | 1927 | (default: True) |
|
1921 | 1928 | |
|
1922 | 1929 | ``askusername`` |
|
1923 | 1930 | Whether to prompt for a username when committing. If True, and |
|
1924 | 1931 | neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will |
|
1925 | 1932 | be prompted to enter a username. If no username is entered, the |
|
1926 | 1933 | default ``USER@HOST`` is used instead. |
|
1927 | 1934 | (default: False) |
|
1928 | 1935 | |
|
1929 | 1936 | ``clonebundles`` |
|
1930 | 1937 | Whether the "clone bundles" feature is enabled. |
|
1931 | 1938 | |
|
1932 | 1939 | When enabled, :hg:`clone` may download and apply a server-advertised |
|
1933 | 1940 | bundle file from a URL instead of using the normal exchange mechanism. |
|
1934 | 1941 | |
|
1935 | 1942 | This can likely result in faster and more reliable clones. |
|
1936 | 1943 | |
|
1937 | 1944 | (default: True) |
|
1938 | 1945 | |
|
1939 | 1946 | ``clonebundlefallback`` |
|
1940 | 1947 | Whether failure to apply an advertised "clone bundle" from a server |
|
1941 | 1948 | should result in fallback to a regular clone. |
|
1942 | 1949 | |
|
1943 | 1950 | This is disabled by default because servers advertising "clone |
|
1944 | 1951 | bundles" often do so to reduce server load. If advertised bundles |
|
1945 | 1952 | start mass failing and clients automatically fall back to a regular |
|
1946 | 1953 | clone, this would add significant and unexpected load to the server |
|
1947 | 1954 | since the server is expecting clone operations to be offloaded to |
|
1948 | 1955 | pre-generated bundles. Failing fast (the default behavior) ensures |
|
1949 | 1956 | clients don't overwhelm the server when "clone bundle" application |
|
1950 | 1957 | fails. |
|
1951 | 1958 | |
|
1952 | 1959 | (default: False) |
|
1953 | 1960 | |
|
1954 | 1961 | ``clonebundleprefers`` |
|
1955 | 1962 | Defines preferences for which "clone bundles" to use. |
|
1956 | 1963 | |
|
1957 | 1964 | Servers advertising "clone bundles" may advertise multiple available |
|
1958 | 1965 | bundles. Each bundle may have different attributes, such as the bundle |
|
1959 | 1966 | type and compression format. This option is used to prefer a particular |
|
1960 | 1967 | bundle over another. |
|
1961 | 1968 | |
|
1962 | 1969 | The following keys are defined by Mercurial: |
|
1963 | 1970 | |
|
1964 | 1971 | BUNDLESPEC |
|
1965 | 1972 | A bundle type specifier. These are strings passed to :hg:`bundle -t`. |
|
1966 | 1973 | e.g. ``gzip-v2`` or ``bzip2-v1``. |
|
1967 | 1974 | |
|
1968 | 1975 | COMPRESSION |
|
1969 | 1976 | The compression format of the bundle. e.g. ``gzip`` and ``bzip2``. |
|
1970 | 1977 | |
|
1971 | 1978 | Server operators may define custom keys. |
|
1972 | 1979 | |
|
1973 | 1980 | Example values: ``COMPRESSION=bzip2``, |
|
1974 | 1981 | ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``. |
|
1975 | 1982 | |
|
1976 | 1983 | By default, the first bundle advertised by the server is used. |
|
1977 | 1984 | |
|
1978 | 1985 | ``color`` |
|
1979 | 1986 | When to colorize output. Possible value are Boolean ("yes" or "no"), or |
|
1980 | 1987 | "debug", or "always". (default: "yes"). "yes" will use color whenever it |
|
1981 | 1988 | seems possible. See :hg:`help color` for details. |
|
1982 | 1989 | |
|
1983 | 1990 | ``commitsubrepos`` |
|
1984 | 1991 | Whether to commit modified subrepositories when committing the |
|
1985 | 1992 | parent repository. If False and one subrepository has uncommitted |
|
1986 | 1993 | changes, abort the commit. |
|
1987 | 1994 | (default: False) |
|
1988 | 1995 | |
|
1989 | 1996 | ``debug`` |
|
1990 | 1997 | Print debugging information. (default: False) |
|
1991 | 1998 | |
|
1992 | 1999 | ``editor`` |
|
1993 | 2000 | The editor to use during a commit. (default: ``$EDITOR`` or ``vi``) |
|
1994 | 2001 | |
|
1995 | 2002 | ``fallbackencoding`` |
|
1996 | 2003 | Encoding to try if it's not possible to decode the changelog using |
|
1997 | 2004 | UTF-8. (default: ISO-8859-1) |
|
1998 | 2005 | |
|
1999 | 2006 | ``graphnodetemplate`` |
|
2000 | 2007 | The template used to print changeset nodes in an ASCII revision graph. |
|
2001 | 2008 | (default: ``{graphnode}``) |
|
2002 | 2009 | |
|
2003 | 2010 | ``ignore`` |
|
2004 | 2011 | A file to read per-user ignore patterns from. This file should be |
|
2005 | 2012 | in the same format as a repository-wide .hgignore file. Filenames |
|
2006 | 2013 | are relative to the repository root. This option supports hook syntax, |
|
2007 | 2014 | so if you want to specify multiple ignore files, you can do so by |
|
2008 | 2015 | setting something like ``ignore.other = ~/.hgignore2``. For details |
|
2009 | 2016 | of the ignore file format, see the ``hgignore(5)`` man page. |
|
2010 | 2017 | |
|
2011 | 2018 | ``interactive`` |
|
2012 | 2019 | Allow to prompt the user. (default: True) |
|
2013 | 2020 | |
|
2014 | 2021 | ``interface`` |
|
2015 | 2022 | Select the default interface for interactive features (default: text). |
|
2016 | 2023 | Possible values are 'text' and 'curses'. |
|
2017 | 2024 | |
|
2018 | 2025 | ``interface.chunkselector`` |
|
2019 | 2026 | Select the interface for change recording (e.g. :hg:`commit -i`). |
|
2020 | 2027 | Possible values are 'text' and 'curses'. |
|
2021 | 2028 | This config overrides the interface specified by ui.interface. |
|
2022 | 2029 | |
|
2023 | 2030 | ``logtemplate`` |
|
2024 | 2031 | Template string for commands that print changesets. |
|
2025 | 2032 | |
|
2026 | 2033 | ``merge`` |
|
2027 | 2034 | The conflict resolution program to use during a manual merge. |
|
2028 | 2035 | For more information on merge tools see :hg:`help merge-tools`. |
|
2029 | 2036 | For configuring merge tools see the ``[merge-tools]`` section. |
|
2030 | 2037 | |
|
2031 | 2038 | ``mergemarkers`` |
|
2032 | 2039 | Sets the merge conflict marker label styling. The ``detailed`` |
|
2033 | 2040 | style uses the ``mergemarkertemplate`` setting to style the labels. |
|
2034 | 2041 | The ``basic`` style just uses 'local' and 'other' as the marker label. |
|
2035 | 2042 | One of ``basic`` or ``detailed``. |
|
2036 | 2043 | (default: ``basic``) |
|
2037 | 2044 | |
|
2038 | 2045 | ``mergemarkertemplate`` |
|
2039 | 2046 | The template used to print the commit description next to each conflict |
|
2040 | 2047 | marker during merge conflicts. See :hg:`help templates` for the template |
|
2041 | 2048 | format. |
|
2042 | 2049 | |
|
2043 | 2050 | Defaults to showing the hash, tags, branches, bookmarks, author, and |
|
2044 | 2051 | the first line of the commit description. |
|
2045 | 2052 | |
|
2046 | 2053 | If you use non-ASCII characters in names for tags, branches, bookmarks, |
|
2047 | 2054 | authors, and/or commit descriptions, you must pay attention to encodings of |
|
2048 | 2055 | managed files. At template expansion, non-ASCII characters use the encoding |
|
2049 | 2056 | specified by the ``--encoding`` global option, ``HGENCODING`` or other |
|
2050 | 2057 | environment variables that govern your locale. If the encoding of the merge |
|
2051 | 2058 | markers is different from the encoding of the merged files, |
|
2052 | 2059 | serious problems may occur. |
|
2053 | 2060 | |
|
2054 | 2061 | ``origbackuppath`` |
|
2055 | 2062 | The path to a directory used to store generated .orig files. If the path is |
|
2056 | 2063 | not a directory, one will be created. If set, files stored in this |
|
2057 | 2064 | directory have the same name as the original file and do not have a .orig |
|
2058 | 2065 | suffix. |
|
2059 | 2066 | |
|
2060 | 2067 | ``paginate`` |
|
2061 | 2068 | Control the pagination of command output (default: True). See :hg:`help pager` |
|
2062 | 2069 | for details. |
|
2063 | 2070 | |
|
2064 | 2071 | ``patch`` |
|
2065 | 2072 | An optional external tool that ``hg import`` and some extensions |
|
2066 | 2073 | will use for applying patches. By default Mercurial uses an |
|
2067 | 2074 | internal patch utility. The external tool must work as the common |
|
2068 | 2075 | Unix ``patch`` program. In particular, it must accept a ``-p`` |
|
2069 | 2076 | argument to strip patch headers, a ``-d`` argument to specify the |
|
2070 | 2077 | current directory, a file name to patch, and a patch file to take |
|
2071 | 2078 | from stdin. |
|
2072 | 2079 | |
|
2073 | 2080 | It is possible to specify a patch tool together with extra |
|
2074 | 2081 | arguments. For example, setting this option to ``patch --merge`` |
|
2075 | 2082 | will use the ``patch`` program with its 2-way merge option. |
|
2076 | 2083 | |
|
2077 | 2084 | ``portablefilenames`` |
|
2078 | 2085 | Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``. |
|
2079 | 2086 | (default: ``warn``) |
|
2080 | 2087 | |
|
2081 | 2088 | ``warn`` |
|
2082 | 2089 | Print a warning message on POSIX platforms, if a file with a non-portable |
|
2083 | 2090 | filename is added (e.g. a file with a name that can't be created on |
|
2084 | 2091 | Windows because it contains reserved parts like ``AUX``, reserved |
|
2085 | 2092 | characters like ``:``, or would cause a case collision with an existing |
|
2086 | 2093 | file). |
|
2087 | 2094 | |
|
2088 | 2095 | ``ignore`` |
|
2089 | 2096 | Don't print a warning. |
|
2090 | 2097 | |
|
2091 | 2098 | ``abort`` |
|
2092 | 2099 | The command is aborted. |
|
2093 | 2100 | |
|
2094 | 2101 | ``true`` |
|
2095 | 2102 | Alias for ``warn``. |
|
2096 | 2103 | |
|
2097 | 2104 | ``false`` |
|
2098 | 2105 | Alias for ``ignore``. |
|
2099 | 2106 | |
|
2100 | 2107 | .. container:: windows |
|
2101 | 2108 | |
|
2102 | 2109 | On Windows, this configuration option is ignored and the command aborted. |
|
2103 | 2110 | |
|
2104 | 2111 | ``quiet`` |
|
2105 | 2112 | Reduce the amount of output printed. |
|
2106 | 2113 | (default: False) |
|
2107 | 2114 | |
|
2108 | 2115 | ``remotecmd`` |
|
2109 | 2116 | Remote command to use for clone/push/pull operations. |
|
2110 | 2117 | (default: ``hg``) |
|
2111 | 2118 | |
|
2112 | 2119 | ``report_untrusted`` |
|
2113 | 2120 | Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a |
|
2114 | 2121 | trusted user or group. |
|
2115 | 2122 | (default: True) |
|
2116 | 2123 | |
|
2117 | 2124 | ``slash`` |
|
2118 | 2125 | Display paths using a slash (``/``) as the path separator. This |
|
2119 | 2126 | only makes a difference on systems where the default path |
|
2120 | 2127 | separator is not the slash character (e.g. Windows uses the |
|
2121 | 2128 | backslash character (``\``)). |
|
2122 | 2129 | (default: False) |
|
2123 | 2130 | |
|
2124 | 2131 | ``statuscopies`` |
|
2125 | 2132 | Display copies in the status command. |
|
2126 | 2133 | |
|
2127 | 2134 | ``ssh`` |
|
2128 | 2135 | Command to use for SSH connections. (default: ``ssh``) |
|
2129 | 2136 | |
|
2130 | 2137 | ``strict`` |
|
2131 | 2138 | Require exact command names, instead of allowing unambiguous |
|
2132 | 2139 | abbreviations. (default: False) |
|
2133 | 2140 | |
|
2134 | 2141 | ``style`` |
|
2135 | 2142 | Name of style to use for command output. |
|
2136 | 2143 | |
|
2137 | 2144 | ``supportcontact`` |
|
2138 | 2145 | A URL where users should report a Mercurial traceback. Use this if you are a |
|
2139 | 2146 | large organisation with its own Mercurial deployment process and crash |
|
2140 | 2147 | reports should be addressed to your internal support. |
|
2141 | 2148 | |
|
2142 | 2149 | ``textwidth`` |
|
2143 | 2150 | Maximum width of help text. A longer line generated by ``hg help`` or |
|
2144 | 2151 | ``hg subcommand --help`` will be broken after white space to get this |
|
2145 | 2152 | width or the terminal width, whichever comes first. |
|
2146 | 2153 | A non-positive value will disable this and the terminal width will be |
|
2147 | 2154 | used. (default: 78) |
|
2148 | 2155 | |
|
2149 | 2156 | ``timeout`` |
|
2150 | 2157 | The timeout used when a lock is held (in seconds), a negative value |
|
2151 | 2158 | means no timeout. (default: 600) |
|
2152 | 2159 | |
|
2153 | 2160 | ``traceback`` |
|
2154 | 2161 | Mercurial always prints a traceback when an unknown exception |
|
2155 | 2162 | occurs. Setting this to True will make Mercurial print a traceback |
|
2156 | 2163 | on all exceptions, even those recognized by Mercurial (such as |
|
2157 | 2164 | IOError or MemoryError). (default: False) |
|
2158 | 2165 | |
|
2159 | 2166 | ``tweakdefaults`` |
|
2160 | 2167 | |
|
2161 | 2168 | By default Mercurial's behavior changes very little from release |
|
2162 | 2169 | to release, but over time the recommended config settings |
|
2163 | 2170 | shift. Enable this config to opt in to get automatic tweaks to |
|
2164 | 2171 | Mercurial's behavior over time. This config setting will have no |
|
2165 | 2172 | effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does |
|
2166 | 2173 | not include ``tweakdefaults``. (default: False) |
|
2167 | 2174 | |
|
2168 | 2175 | ``username`` |
|
2169 | 2176 | The committer of a changeset created when running "commit". |
|
2170 | 2177 | Typically a person's name and email address, e.g. ``Fred Widget |
|
2171 | 2178 | <fred@example.com>``. Environment variables in the |
|
2172 | 2179 | username are expanded. |
|
2173 | 2180 | |
|
2174 | 2181 | (default: ``$EMAIL`` or ``username@hostname``. If the username in |
|
2175 | 2182 | hgrc is empty, e.g. if the system admin set ``username =`` in the |
|
2176 | 2183 | system hgrc, it has to be specified manually or in a different |
|
2177 | 2184 | hgrc file) |
|
2178 | 2185 | |
|
2179 | 2186 | ``verbose`` |
|
2180 | 2187 | Increase the amount of output printed. (default: False) |
|
2181 | 2188 | |
|
2182 | 2189 | |
|
2183 | 2190 | ``web`` |
|
2184 | 2191 | ------- |
|
2185 | 2192 | |
|
2186 | 2193 | Web interface configuration. The settings in this section apply to |
|
2187 | 2194 | both the builtin webserver (started by :hg:`serve`) and the script you |
|
2188 | 2195 | run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI |
|
2189 | 2196 | and WSGI). |
|
2190 | 2197 | |
|
2191 | 2198 | The Mercurial webserver does no authentication (it does not prompt for |
|
2192 | 2199 | usernames and passwords to validate *who* users are), but it does do |
|
2193 | 2200 | authorization (it grants or denies access for *authenticated users* |
|
2194 | 2201 | based on settings in this section). You must either configure your |
|
2195 | 2202 | webserver to do authentication for you, or disable the authorization |
|
2196 | 2203 | checks. |
|
2197 | 2204 | |
|
2198 | 2205 | For a quick setup in a trusted environment, e.g., a private LAN, where |
|
2199 | 2206 | you want it to accept pushes from anybody, you can use the following |
|
2200 | 2207 | command line:: |
|
2201 | 2208 | |
|
2202 | 2209 | $ hg --config web.allow_push=* --config web.push_ssl=False serve |
|
2203 | 2210 | |
|
2204 | 2211 | Note that this will allow anybody to push anything to the server and |
|
2205 | 2212 | that this should not be used for public servers. |
|
2206 | 2213 | |
|
2207 | 2214 | The full set of options is: |
|
2208 | 2215 | |
|
2209 | 2216 | ``accesslog`` |
|
2210 | 2217 | Where to output the access log. (default: stdout) |
|
2211 | 2218 | |
|
2212 | 2219 | ``address`` |
|
2213 | 2220 | Interface address to bind to. (default: all) |
|
2214 | 2221 | |
|
2215 | 2222 | ``allow_archive`` |
|
2216 | 2223 | List of archive format (bz2, gz, zip) allowed for downloading. |
|
2217 | 2224 | (default: empty) |
|
2218 | 2225 | |
|
2219 | 2226 | ``allowbz2`` |
|
2220 | 2227 | (DEPRECATED) Whether to allow .tar.bz2 downloading of repository |
|
2221 | 2228 | revisions. |
|
2222 | 2229 | (default: False) |
|
2223 | 2230 | |
|
2224 | 2231 | ``allowgz`` |
|
2225 | 2232 | (DEPRECATED) Whether to allow .tar.gz downloading of repository |
|
2226 | 2233 | revisions. |
|
2227 | 2234 | (default: False) |
|
2228 | 2235 | |
|
2229 | 2236 | ``allowpull`` |
|
2230 | 2237 | Whether to allow pulling from the repository. (default: True) |
|
2231 | 2238 | |
|
2232 | 2239 | ``allow_push`` |
|
2233 | 2240 | Whether to allow pushing to the repository. If empty or not set, |
|
2234 | 2241 | pushing is not allowed. If the special value ``*``, any remote |
|
2235 | 2242 | user can push, including unauthenticated users. Otherwise, the |
|
2236 | 2243 | remote user must have been authenticated, and the authenticated |
|
2237 | 2244 | user name must be present in this list. The contents of the |
|
2238 | 2245 | allow_push list are examined after the deny_push list. |
|
2239 | 2246 | |
|
2240 | 2247 | ``allow_read`` |
|
2241 | 2248 | If the user has not already been denied repository access due to |
|
2242 | 2249 | the contents of deny_read, this list determines whether to grant |
|
2243 | 2250 | repository access to the user. If this list is not empty, and the |
|
2244 | 2251 | user is unauthenticated or not present in the list, then access is |
|
2245 | 2252 | denied for the user. If the list is empty or not set, then access |
|
2246 | 2253 | is permitted to all users by default. Setting allow_read to the |
|
2247 | 2254 | special value ``*`` is equivalent to it not being set (i.e. access |
|
2248 | 2255 | is permitted to all users). The contents of the allow_read list are |
|
2249 | 2256 | examined after the deny_read list. |
|
2250 | 2257 | |
|
2251 | 2258 | ``allowzip`` |
|
2252 | 2259 | (DEPRECATED) Whether to allow .zip downloading of repository |
|
2253 | 2260 | revisions. This feature creates temporary files. |
|
2254 | 2261 | (default: False) |
|
2255 | 2262 | |
|
2256 | 2263 | ``archivesubrepos`` |
|
2257 | 2264 | Whether to recurse into subrepositories when archiving. |
|
2258 | 2265 | (default: False) |
|
2259 | 2266 | |
|
2260 | 2267 | ``baseurl`` |
|
2261 | 2268 | Base URL to use when publishing URLs in other locations, so |
|
2262 | 2269 | third-party tools like email notification hooks can construct |
|
2263 | 2270 | URLs. Example: ``http://hgserver/repos/``. |
|
2264 | 2271 | |
|
2265 | 2272 | ``cacerts`` |
|
2266 | 2273 | Path to file containing a list of PEM encoded certificate |
|
2267 | 2274 | authority certificates. Environment variables and ``~user`` |
|
2268 | 2275 | constructs are expanded in the filename. If specified on the |
|
2269 | 2276 | client, then it will verify the identity of remote HTTPS servers |
|
2270 | 2277 | with these certificates. |
|
2271 | 2278 | |
|
2272 | 2279 | To disable SSL verification temporarily, specify ``--insecure`` from |
|
2273 | 2280 | command line. |
|
2274 | 2281 | |
|
2275 | 2282 | You can use OpenSSL's CA certificate file if your platform has |
|
2276 | 2283 | one. On most Linux systems this will be |
|
2277 | 2284 | ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to |
|
2278 | 2285 | generate this file manually. The form must be as follows:: |
|
2279 | 2286 | |
|
2280 | 2287 | -----BEGIN CERTIFICATE----- |
|
2281 | 2288 | ... (certificate in base64 PEM encoding) ... |
|
2282 | 2289 | -----END CERTIFICATE----- |
|
2283 | 2290 | -----BEGIN CERTIFICATE----- |
|
2284 | 2291 | ... (certificate in base64 PEM encoding) ... |
|
2285 | 2292 | -----END CERTIFICATE----- |
|
2286 | 2293 | |
|
2287 | 2294 | ``cache`` |
|
2288 | 2295 | Whether to support caching in hgweb. (default: True) |
|
2289 | 2296 | |
|
2290 | 2297 | ``certificate`` |
|
2291 | 2298 | Certificate to use when running :hg:`serve`. |
|
2292 | 2299 | |
|
2293 | 2300 | ``collapse`` |
|
2294 | 2301 | With ``descend`` enabled, repositories in subdirectories are shown at |
|
2295 | 2302 | a single level alongside repositories in the current path. With |
|
2296 | 2303 | ``collapse`` also enabled, repositories residing at a deeper level than |
|
2297 | 2304 | the current path are grouped behind navigable directory entries that |
|
2298 | 2305 | lead to the locations of these repositories. In effect, this setting |
|
2299 | 2306 | collapses each collection of repositories found within a subdirectory |
|
2300 | 2307 | into a single entry for that subdirectory. (default: False) |
|
2301 | 2308 | |
|
2302 | 2309 | ``comparisoncontext`` |
|
2303 | 2310 | Number of lines of context to show in side-by-side file comparison. If |
|
2304 | 2311 | negative or the value ``full``, whole files are shown. (default: 5) |
|
2305 | 2312 | |
|
2306 | 2313 | This setting can be overridden by a ``context`` request parameter to the |
|
2307 | 2314 | ``comparison`` command, taking the same values. |
|
2308 | 2315 | |
|
2309 | 2316 | ``contact`` |
|
2310 | 2317 | Name or email address of the person in charge of the repository. |
|
2311 | 2318 | (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty) |
|
2312 | 2319 | |
|
2313 | 2320 | ``csp`` |
|
2314 | 2321 | Send a ``Content-Security-Policy`` HTTP header with this value. |
|
2315 | 2322 | |
|
2316 | 2323 | The value may contain a special string ``%nonce%``, which will be replaced |
|
2317 | 2324 | by a randomly-generated one-time use value. If the value contains |
|
2318 | 2325 | ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the |
|
2319 | 2326 | one-time property of the nonce. This nonce will also be inserted into |
|
2320 | 2327 | ``<script>`` elements containing inline JavaScript. |
|
2321 | 2328 | |
|
2322 | 2329 | Note: lots of HTML content sent by the server is derived from repository |
|
2323 | 2330 | data. Please consider the potential for malicious repository data to |
|
2324 | 2331 | "inject" itself into generated HTML content as part of your security |
|
2325 | 2332 | threat model. |
|
2326 | 2333 | |
|
2327 | 2334 | ``deny_push`` |
|
2328 | 2335 | Whether to deny pushing to the repository. If empty or not set, |
|
2329 | 2336 | push is not denied. If the special value ``*``, all remote users are |
|
2330 | 2337 | denied push. Otherwise, unauthenticated users are all denied, and |
|
2331 | 2338 | any authenticated user name present in this list is also denied. The |
|
2332 | 2339 | contents of the deny_push list are examined before the allow_push list. |
|
2333 | 2340 | |
|
2334 | 2341 | ``deny_read`` |
|
2335 | 2342 | Whether to deny reading/viewing of the repository. If this list is |
|
2336 | 2343 | not empty, unauthenticated users are all denied, and any |
|
2337 | 2344 | authenticated user name present in this list is also denied access to |
|
2338 | 2345 | the repository. If set to the special value ``*``, all remote users |
|
2339 | 2346 | are denied access (rarely needed ;). If deny_read is empty or not set, |
|
2340 | 2347 | the determination of repository access depends on the presence and |
|
2341 | 2348 | content of the allow_read list (see description). If both |
|
2342 | 2349 | deny_read and allow_read are empty or not set, then access is |
|
2343 | 2350 | permitted to all users by default. If the repository is being |
|
2344 | 2351 | served via hgwebdir, denied users will not be able to see it in |
|
2345 | 2352 | the list of repositories. The contents of the deny_read list have |
|
2346 | 2353 | priority over (are examined before) the contents of the allow_read |
|
2347 | 2354 | list. |
|
2348 | 2355 | |
|
2349 | 2356 | ``descend`` |
|
2350 | 2357 | hgwebdir indexes will not descend into subdirectories. Only repositories |
|
2351 | 2358 | directly in the current path will be shown (other repositories are still |
|
2352 | 2359 | available from the index corresponding to their containing path). |
|
2353 | 2360 | |
|
2354 | 2361 | ``description`` |
|
2355 | 2362 | Textual description of the repository's purpose or contents. |
|
2356 | 2363 | (default: "unknown") |
|
2357 | 2364 | |
|
2358 | 2365 | ``encoding`` |
|
2359 | 2366 | Character encoding name. (default: the current locale charset) |
|
2360 | 2367 | Example: "UTF-8". |
|
2361 | 2368 | |
|
2362 | 2369 | ``errorlog`` |
|
2363 | 2370 | Where to output the error log. (default: stderr) |
|
2364 | 2371 | |
|
2365 | 2372 | ``guessmime`` |
|
2366 | 2373 | Control MIME types for raw download of file content. |
|
2367 | 2374 | Set to True to let hgweb guess the content type from the file |
|
2368 | 2375 | extension. This will serve HTML files as ``text/html`` and might |
|
2369 | 2376 | allow cross-site scripting attacks when serving untrusted |
|
2370 | 2377 | repositories. (default: False) |
|
2371 | 2378 | |
|
2372 | 2379 | ``hidden`` |
|
2373 | 2380 | Whether to hide the repository in the hgwebdir index. |
|
2374 | 2381 | (default: False) |
|
2375 | 2382 | |
|
2376 | 2383 | ``ipv6`` |
|
2377 | 2384 | Whether to use IPv6. (default: False) |
|
2378 | 2385 | |
|
2379 | 2386 | ``labels`` |
|
2380 | 2387 | List of string *labels* associated with the repository. |
|
2381 | 2388 | |
|
2382 | 2389 | Labels are exposed as a template keyword and can be used to customize |
|
2383 | 2390 | output. e.g. the ``index`` template can group or filter repositories |
|
2384 | 2391 | by labels and the ``summary`` template can display additional content |
|
2385 | 2392 | if a specific label is present. |
|
2386 | 2393 | |
|
2387 | 2394 | ``logoimg`` |
|
2388 | 2395 | File name of the logo image that some templates display on each page. |
|
2389 | 2396 | The file name is relative to ``staticurl``. That is, the full path to |
|
2390 | 2397 | the logo image is "staticurl/logoimg". |
|
2391 | 2398 | If unset, ``hglogo.png`` will be used. |
|
2392 | 2399 | |
|
2393 | 2400 | ``logourl`` |
|
2394 | 2401 | Base URL to use for logos. If unset, ``https://mercurial-scm.org/`` |
|
2395 | 2402 | will be used. |
|
2396 | 2403 | |
|
2397 | 2404 | ``maxchanges`` |
|
2398 | 2405 | Maximum number of changes to list on the changelog. (default: 10) |
|
2399 | 2406 | |
|
2400 | 2407 | ``maxfiles`` |
|
2401 | 2408 | Maximum number of files to list per changeset. (default: 10) |
|
2402 | 2409 | |
|
2403 | 2410 | ``maxshortchanges`` |
|
2404 | 2411 | Maximum number of changes to list on the shortlog, graph or filelog |
|
2405 | 2412 | pages. (default: 60) |
|
2406 | 2413 | |
|
2407 | 2414 | ``name`` |
|
2408 | 2415 | Repository name to use in the web interface. |
|
2409 | 2416 | (default: current working directory) |
|
2410 | 2417 | |
|
2411 | 2418 | ``port`` |
|
2412 | 2419 | Port to listen on. (default: 8000) |
|
2413 | 2420 | |
|
2414 | 2421 | ``prefix`` |
|
2415 | 2422 | Prefix path to serve from. (default: '' (server root)) |
|
2416 | 2423 | |
|
2417 | 2424 | ``push_ssl`` |
|
2418 | 2425 | Whether to require that inbound pushes be transported over SSL to |
|
2419 | 2426 | prevent password sniffing. (default: True) |
|
2420 | 2427 | |
|
2421 | 2428 | ``refreshinterval`` |
|
2422 | 2429 | How frequently directory listings re-scan the filesystem for new |
|
2423 | 2430 | repositories, in seconds. This is relevant when wildcards are used |
|
2424 | 2431 | to define paths. Depending on how much filesystem traversal is |
|
2425 | 2432 | required, refreshing may negatively impact performance. |
|
2426 | 2433 | |
|
2427 | 2434 | Values less than or equal to 0 always refresh. |
|
2428 | 2435 | (default: 20) |
|
2429 | 2436 | |
|
2430 | 2437 | ``staticurl`` |
|
2431 | 2438 | Base URL to use for static files. If unset, static files (e.g. the |
|
2432 | 2439 | hgicon.png favicon) will be served by the CGI script itself. Use |
|
2433 | 2440 | this setting to serve them directly with the HTTP server. |
|
2434 | 2441 | Example: ``http://hgserver/static/``. |
|
2435 | 2442 | |
|
2436 | 2443 | ``stripes`` |
|
2437 | 2444 | How many lines a "zebra stripe" should span in multi-line output. |
|
2438 | 2445 | Set to 0 to disable. (default: 1) |
|
2439 | 2446 | |
|
2440 | 2447 | ``style`` |
|
2441 | 2448 | Which template map style to use. The available options are the names of |
|
2442 | 2449 | subdirectories in the HTML templates path. (default: ``paper``) |
|
2443 | 2450 | Example: ``monoblue``. |
|
2444 | 2451 | |
|
2445 | 2452 | ``templates`` |
|
2446 | 2453 | Where to find the HTML templates. The default path to the HTML templates |
|
2447 | 2454 | can be obtained from ``hg debuginstall``. |
|
2448 | 2455 | |
|
2449 | 2456 | ``websub`` |
|
2450 | 2457 | ---------- |
|
2451 | 2458 | |
|
2452 | 2459 | Web substitution filter definition. You can use this section to |
|
2453 | 2460 | define a set of regular expression substitution patterns which |
|
2454 | 2461 | let you automatically modify the hgweb server output. |
|
2455 | 2462 | |
|
2456 | 2463 | The default hgweb templates only apply these substitution patterns |
|
2457 | 2464 | on the revision description fields. You can apply them anywhere |
|
2458 | 2465 | you want when you create your own templates by adding calls to the |
|
2459 | 2466 | "websub" filter (usually after calling the "escape" filter). |
|
2460 | 2467 | |
|
2461 | 2468 | This can be used, for example, to convert issue references to links |
|
2462 | 2469 | to your issue tracker, or to convert "markdown-like" syntax into |
|
2463 | 2470 | HTML (see the examples below). |
|
2464 | 2471 | |
|
2465 | 2472 | Each entry in this section names a substitution filter. |
|
2466 | 2473 | The value of each entry defines the substitution expression itself. |
|
2467 | 2474 | The websub expressions follow the old interhg extension syntax, |
|
2468 | 2475 | which in turn imitates the Unix sed replacement syntax:: |
|
2469 | 2476 | |
|
2470 | 2477 | patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i] |
|
2471 | 2478 | |
|
2472 | 2479 | You can use any separator other than "/". The final "i" is optional |
|
2473 | 2480 | and indicates that the search must be case insensitive. |
|
2474 | 2481 | |
|
2475 | 2482 | Examples:: |
|
2476 | 2483 | |
|
2477 | 2484 | [websub] |
|
2478 | 2485 | issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i |
|
2479 | 2486 | italic = s/\b_(\S+)_\b/<i>\1<\/i>/ |
|
2480 | 2487 | bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/ |
|
2481 | 2488 | |
|
2482 | 2489 | ``worker`` |
|
2483 | 2490 | ---------- |
|
2484 | 2491 | |
|
2485 | 2492 | Parallel master/worker configuration. We currently perform working |
|
2486 | 2493 | directory updates in parallel on Unix-like systems, which greatly |
|
2487 | 2494 | helps performance. |
|
2488 | 2495 | |
|
2489 | 2496 | ``numcpus`` |
|
2490 | 2497 | Number of CPUs to use for parallel operations. A zero or |
|
2491 | 2498 | negative value is treated as ``use the default``. |
|
2492 | 2499 | (default: 4 or the number of CPUs on the system, whichever is larger) |
|
2493 | 2500 | |
|
2494 | 2501 | ``backgroundclose`` |
|
2495 | 2502 | Whether to enable closing file handles on background threads during certain |
|
2496 | 2503 | operations. Some platforms aren't very efficient at closing file |
|
2497 | 2504 | handles that have been written or appended to. By performing file closing |
|
2498 | 2505 | on background threads, file write rate can increase substantially. |
|
2499 | 2506 | (default: true on Windows, false elsewhere) |
|
2500 | 2507 | |
|
2501 | 2508 | ``backgroundcloseminfilecount`` |
|
2502 | 2509 | Minimum number of files required to trigger background file closing. |
|
2503 | 2510 | Operations not writing this many files won't start background close |
|
2504 | 2511 | threads. |
|
2505 | 2512 | (default: 2048) |
|
2506 | 2513 | |
|
2507 | 2514 | ``backgroundclosemaxqueue`` |
|
2508 | 2515 | The maximum number of opened file handles waiting to be closed in the |
|
2509 | 2516 | background. This option only has an effect if ``backgroundclose`` is |
|
2510 | 2517 | enabled. |
|
2511 | 2518 | (default: 384) |
|
2512 | 2519 | |
|
2513 | 2520 | ``backgroundclosethreadcount`` |
|
2514 | 2521 | Number of threads to process background file closes. Only relevant if |
|
2515 | 2522 | ``backgroundclose`` is enabled. |
|
2516 | 2523 | (default: 4) |
@@ -1,2330 +1,2338 | |||
|
1 | 1 | # localrepo.py - read/write repository class for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import errno |
|
11 | 11 | import hashlib |
|
12 | 12 | import inspect |
|
13 | 13 | import os |
|
14 | 14 | import random |
|
15 | 15 | import time |
|
16 | 16 | import weakref |
|
17 | 17 | |
|
18 | 18 | from .i18n import _ |
|
19 | 19 | from .node import ( |
|
20 | 20 | hex, |
|
21 | 21 | nullid, |
|
22 | 22 | short, |
|
23 | 23 | ) |
|
24 | 24 | from . import ( |
|
25 | 25 | bookmarks, |
|
26 | 26 | branchmap, |
|
27 | 27 | bundle2, |
|
28 | 28 | changegroup, |
|
29 | 29 | changelog, |
|
30 | 30 | color, |
|
31 | 31 | context, |
|
32 | 32 | dirstate, |
|
33 | 33 | dirstateguard, |
|
34 | 34 | discovery, |
|
35 | 35 | encoding, |
|
36 | 36 | error, |
|
37 | 37 | exchange, |
|
38 | 38 | extensions, |
|
39 | 39 | filelog, |
|
40 | 40 | hook, |
|
41 | 41 | lock as lockmod, |
|
42 | 42 | manifest, |
|
43 | 43 | match as matchmod, |
|
44 | 44 | merge as mergemod, |
|
45 | 45 | mergeutil, |
|
46 | 46 | namespaces, |
|
47 | 47 | obsolete, |
|
48 | 48 | pathutil, |
|
49 | 49 | peer, |
|
50 | 50 | phases, |
|
51 | 51 | pushkey, |
|
52 | 52 | pycompat, |
|
53 | 53 | repository, |
|
54 | 54 | repoview, |
|
55 | 55 | revset, |
|
56 | 56 | revsetlang, |
|
57 | 57 | scmutil, |
|
58 | 58 | sparse, |
|
59 | 59 | store, |
|
60 | 60 | subrepo, |
|
61 | 61 | tags as tagsmod, |
|
62 | 62 | transaction, |
|
63 | 63 | txnutil, |
|
64 | 64 | util, |
|
65 | 65 | vfs as vfsmod, |
|
66 | 66 | ) |
|
67 | 67 | |
|
68 | 68 | release = lockmod.release |
|
69 | 69 | urlerr = util.urlerr |
|
70 | 70 | urlreq = util.urlreq |
|
71 | 71 | |
|
72 | 72 | # set of (path, vfs-location) tuples. vfs-location is: |
|
73 | 73 | # - 'plain for vfs relative paths |
|
74 | 74 | # - '' for svfs relative paths |
|
75 | 75 | _cachedfiles = set() |
|
76 | 76 | |
|
77 | 77 | class _basefilecache(scmutil.filecache): |
|
78 | 78 | """All filecache usage on repo are done for logic that should be unfiltered |
|
79 | 79 | """ |
|
80 | 80 | def __get__(self, repo, type=None): |
|
81 | 81 | if repo is None: |
|
82 | 82 | return self |
|
83 | 83 | return super(_basefilecache, self).__get__(repo.unfiltered(), type) |
|
84 | 84 | def __set__(self, repo, value): |
|
85 | 85 | return super(_basefilecache, self).__set__(repo.unfiltered(), value) |
|
86 | 86 | def __delete__(self, repo): |
|
87 | 87 | return super(_basefilecache, self).__delete__(repo.unfiltered()) |
|
88 | 88 | |
|
89 | 89 | class repofilecache(_basefilecache): |
|
90 | 90 | """filecache for files in .hg but outside of .hg/store""" |
|
91 | 91 | def __init__(self, *paths): |
|
92 | 92 | super(repofilecache, self).__init__(*paths) |
|
93 | 93 | for path in paths: |
|
94 | 94 | _cachedfiles.add((path, 'plain')) |
|
95 | 95 | |
|
96 | 96 | def join(self, obj, fname): |
|
97 | 97 | return obj.vfs.join(fname) |
|
98 | 98 | |
|
99 | 99 | class storecache(_basefilecache): |
|
100 | 100 | """filecache for files in the store""" |
|
101 | 101 | def __init__(self, *paths): |
|
102 | 102 | super(storecache, self).__init__(*paths) |
|
103 | 103 | for path in paths: |
|
104 | 104 | _cachedfiles.add((path, '')) |
|
105 | 105 | |
|
106 | 106 | def join(self, obj, fname): |
|
107 | 107 | return obj.sjoin(fname) |
|
108 | 108 | |
|
109 | 109 | def isfilecached(repo, name): |
|
110 | 110 | """check if a repo has already cached "name" filecache-ed property |
|
111 | 111 | |
|
112 | 112 | This returns (cachedobj-or-None, iscached) tuple. |
|
113 | 113 | """ |
|
114 | 114 | cacheentry = repo.unfiltered()._filecache.get(name, None) |
|
115 | 115 | if not cacheentry: |
|
116 | 116 | return None, False |
|
117 | 117 | return cacheentry.obj, True |
|
118 | 118 | |
|
119 | 119 | class unfilteredpropertycache(util.propertycache): |
|
120 | 120 | """propertycache that apply to unfiltered repo only""" |
|
121 | 121 | |
|
122 | 122 | def __get__(self, repo, type=None): |
|
123 | 123 | unfi = repo.unfiltered() |
|
124 | 124 | if unfi is repo: |
|
125 | 125 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
126 | 126 | return getattr(unfi, self.name) |
|
127 | 127 | |
|
128 | 128 | class filteredpropertycache(util.propertycache): |
|
129 | 129 | """propertycache that must take filtering in account""" |
|
130 | 130 | |
|
131 | 131 | def cachevalue(self, obj, value): |
|
132 | 132 | object.__setattr__(obj, self.name, value) |
|
133 | 133 | |
|
134 | 134 | |
|
135 | 135 | def hasunfilteredcache(repo, name): |
|
136 | 136 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
137 | 137 | return name in vars(repo.unfiltered()) |
|
138 | 138 | |
|
139 | 139 | def unfilteredmethod(orig): |
|
140 | 140 | """decorate method that always need to be run on unfiltered version""" |
|
141 | 141 | def wrapper(repo, *args, **kwargs): |
|
142 | 142 | return orig(repo.unfiltered(), *args, **kwargs) |
|
143 | 143 | return wrapper |
|
144 | 144 | |
|
145 | 145 | moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', |
|
146 | 146 | 'unbundle'} |
|
147 | 147 | legacycaps = moderncaps.union({'changegroupsubset'}) |
|
148 | 148 | |
|
149 | 149 | class localpeer(repository.peer): |
|
150 | 150 | '''peer for a local repo; reflects only the most recent API''' |
|
151 | 151 | |
|
152 | 152 | def __init__(self, repo, caps=None): |
|
153 | 153 | super(localpeer, self).__init__() |
|
154 | 154 | |
|
155 | 155 | if caps is None: |
|
156 | 156 | caps = moderncaps.copy() |
|
157 | 157 | self._repo = repo.filtered('served') |
|
158 | 158 | self._ui = repo.ui |
|
159 | 159 | self._caps = repo._restrictcapabilities(caps) |
|
160 | 160 | |
|
161 | 161 | # Begin of _basepeer interface. |
|
162 | 162 | |
|
163 | 163 | @util.propertycache |
|
164 | 164 | def ui(self): |
|
165 | 165 | return self._ui |
|
166 | 166 | |
|
167 | 167 | def url(self): |
|
168 | 168 | return self._repo.url() |
|
169 | 169 | |
|
170 | 170 | def local(self): |
|
171 | 171 | return self._repo |
|
172 | 172 | |
|
173 | 173 | def peer(self): |
|
174 | 174 | return self |
|
175 | 175 | |
|
176 | 176 | def canpush(self): |
|
177 | 177 | return True |
|
178 | 178 | |
|
179 | 179 | def close(self): |
|
180 | 180 | self._repo.close() |
|
181 | 181 | |
|
182 | 182 | # End of _basepeer interface. |
|
183 | 183 | |
|
184 | 184 | # Begin of _basewirecommands interface. |
|
185 | 185 | |
|
186 | 186 | def branchmap(self): |
|
187 | 187 | return self._repo.branchmap() |
|
188 | 188 | |
|
189 | 189 | def capabilities(self): |
|
190 | 190 | return self._caps |
|
191 | 191 | |
|
192 | 192 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
193 | 193 | """Used to test argument passing over the wire""" |
|
194 | 194 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
195 | 195 | |
|
196 | 196 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, |
|
197 | 197 | **kwargs): |
|
198 | 198 | chunks = exchange.getbundlechunks(self._repo, source, heads=heads, |
|
199 | 199 | common=common, bundlecaps=bundlecaps, |
|
200 | 200 | **kwargs) |
|
201 | 201 | cb = util.chunkbuffer(chunks) |
|
202 | 202 | |
|
203 | 203 | if exchange.bundle2requested(bundlecaps): |
|
204 | 204 | # When requesting a bundle2, getbundle returns a stream to make the |
|
205 | 205 | # wire level function happier. We need to build a proper object |
|
206 | 206 | # from it in local peer. |
|
207 | 207 | return bundle2.getunbundler(self.ui, cb) |
|
208 | 208 | else: |
|
209 | 209 | return changegroup.getunbundler('01', cb, None) |
|
210 | 210 | |
|
211 | 211 | def heads(self): |
|
212 | 212 | return self._repo.heads() |
|
213 | 213 | |
|
214 | 214 | def known(self, nodes): |
|
215 | 215 | return self._repo.known(nodes) |
|
216 | 216 | |
|
217 | 217 | def listkeys(self, namespace): |
|
218 | 218 | return self._repo.listkeys(namespace) |
|
219 | 219 | |
|
220 | 220 | def lookup(self, key): |
|
221 | 221 | return self._repo.lookup(key) |
|
222 | 222 | |
|
223 | 223 | def pushkey(self, namespace, key, old, new): |
|
224 | 224 | return self._repo.pushkey(namespace, key, old, new) |
|
225 | 225 | |
|
226 | 226 | def stream_out(self): |
|
227 | 227 | raise error.Abort(_('cannot perform stream clone against local ' |
|
228 | 228 | 'peer')) |
|
229 | 229 | |
|
230 | 230 | def unbundle(self, cg, heads, url): |
|
231 | 231 | """apply a bundle on a repo |
|
232 | 232 | |
|
233 | 233 | This function handles the repo locking itself.""" |
|
234 | 234 | try: |
|
235 | 235 | try: |
|
236 | 236 | cg = exchange.readbundle(self.ui, cg, None) |
|
237 | 237 | ret = exchange.unbundle(self._repo, cg, heads, 'push', url) |
|
238 | 238 | if util.safehasattr(ret, 'getchunks'): |
|
239 | 239 | # This is a bundle20 object, turn it into an unbundler. |
|
240 | 240 | # This little dance should be dropped eventually when the |
|
241 | 241 | # API is finally improved. |
|
242 | 242 | stream = util.chunkbuffer(ret.getchunks()) |
|
243 | 243 | ret = bundle2.getunbundler(self.ui, stream) |
|
244 | 244 | return ret |
|
245 | 245 | except Exception as exc: |
|
246 | 246 | # If the exception contains output salvaged from a bundle2 |
|
247 | 247 | # reply, we need to make sure it is printed before continuing |
|
248 | 248 | # to fail. So we build a bundle2 with such output and consume |
|
249 | 249 | # it directly. |
|
250 | 250 | # |
|
251 | 251 | # This is not very elegant but allows a "simple" solution for |
|
252 | 252 | # issue4594 |
|
253 | 253 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
254 | 254 | if output: |
|
255 | 255 | bundler = bundle2.bundle20(self._repo.ui) |
|
256 | 256 | for out in output: |
|
257 | 257 | bundler.addpart(out) |
|
258 | 258 | stream = util.chunkbuffer(bundler.getchunks()) |
|
259 | 259 | b = bundle2.getunbundler(self.ui, stream) |
|
260 | 260 | bundle2.processbundle(self._repo, b) |
|
261 | 261 | raise |
|
262 | 262 | except error.PushRaced as exc: |
|
263 | 263 | raise error.ResponseError(_('push failed:'), str(exc)) |
|
264 | 264 | |
|
265 | 265 | # End of _basewirecommands interface. |
|
266 | 266 | |
|
267 | 267 | # Begin of peer interface. |
|
268 | 268 | |
|
269 | 269 | def iterbatch(self): |
|
270 | 270 | return peer.localiterbatcher(self) |
|
271 | 271 | |
|
272 | 272 | # End of peer interface. |
|
273 | 273 | |
|
274 | 274 | class locallegacypeer(repository.legacypeer, localpeer): |
|
275 | 275 | '''peer extension which implements legacy methods too; used for tests with |
|
276 | 276 | restricted capabilities''' |
|
277 | 277 | |
|
278 | 278 | def __init__(self, repo): |
|
279 | 279 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) |
|
280 | 280 | |
|
281 | 281 | # Begin of baselegacywirecommands interface. |
|
282 | 282 | |
|
283 | 283 | def between(self, pairs): |
|
284 | 284 | return self._repo.between(pairs) |
|
285 | 285 | |
|
286 | 286 | def branches(self, nodes): |
|
287 | 287 | return self._repo.branches(nodes) |
|
288 | 288 | |
|
289 | 289 | def changegroup(self, basenodes, source): |
|
290 | 290 | outgoing = discovery.outgoing(self._repo, missingroots=basenodes, |
|
291 | 291 | missingheads=self._repo.heads()) |
|
292 | 292 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
293 | 293 | |
|
294 | 294 | def changegroupsubset(self, bases, heads, source): |
|
295 | 295 | outgoing = discovery.outgoing(self._repo, missingroots=bases, |
|
296 | 296 | missingheads=heads) |
|
297 | 297 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
298 | 298 | |
|
299 | 299 | # End of baselegacywirecommands interface. |
|
300 | 300 | |
|
301 | 301 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
302 | 302 | # clients. |
|
303 | 303 | REVLOGV2_REQUIREMENT = 'exp-revlogv2.0' |
|
304 | 304 | |
|
305 | 305 | class localrepository(object): |
|
306 | 306 | |
|
307 | 307 | supportedformats = { |
|
308 | 308 | 'revlogv1', |
|
309 | 309 | 'generaldelta', |
|
310 | 310 | 'treemanifest', |
|
311 | 311 | 'manifestv2', |
|
312 | 312 | REVLOGV2_REQUIREMENT, |
|
313 | 313 | } |
|
314 | 314 | _basesupported = supportedformats | { |
|
315 | 315 | 'store', |
|
316 | 316 | 'fncache', |
|
317 | 317 | 'shared', |
|
318 | 318 | 'relshared', |
|
319 | 319 | 'dotencode', |
|
320 | 320 | 'exp-sparse', |
|
321 | 321 | } |
|
322 | 322 | openerreqs = { |
|
323 | 323 | 'revlogv1', |
|
324 | 324 | 'generaldelta', |
|
325 | 325 | 'treemanifest', |
|
326 | 326 | 'manifestv2', |
|
327 | 327 | } |
|
328 | 328 | |
|
329 | 329 | # a list of (ui, featureset) functions. |
|
330 | 330 | # only functions defined in module of enabled extensions are invoked |
|
331 | 331 | featuresetupfuncs = set() |
|
332 | 332 | |
|
333 | 333 | # list of prefix for file which can be written without 'wlock' |
|
334 | 334 | # Extensions should extend this list when needed |
|
335 | 335 | _wlockfreeprefix = { |
|
336 | 336 | # We migh consider requiring 'wlock' for the next |
|
337 | 337 | # two, but pretty much all the existing code assume |
|
338 | 338 | # wlock is not needed so we keep them excluded for |
|
339 | 339 | # now. |
|
340 | 340 | 'hgrc', |
|
341 | 341 | 'requires', |
|
342 | 342 | # XXX cache is a complicatged business someone |
|
343 | 343 | # should investigate this in depth at some point |
|
344 | 344 | 'cache/', |
|
345 | 345 | # XXX shouldn't be dirstate covered by the wlock? |
|
346 | 346 | 'dirstate', |
|
347 | 347 | # XXX bisect was still a bit too messy at the time |
|
348 | 348 | # this changeset was introduced. Someone should fix |
|
349 | 349 | # the remainig bit and drop this line |
|
350 | 350 | 'bisect.state', |
|
351 | 351 | } |
|
352 | 352 | |
|
353 | 353 | def __init__(self, baseui, path, create=False): |
|
354 | 354 | self.requirements = set() |
|
355 | 355 | self.filtername = None |
|
356 | 356 | # wvfs: rooted at the repository root, used to access the working copy |
|
357 | 357 | self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
358 | 358 | # vfs: rooted at .hg, used to access repo files outside of .hg/store |
|
359 | 359 | self.vfs = None |
|
360 | 360 | # svfs: usually rooted at .hg/store, used to access repository history |
|
361 | 361 | # If this is a shared repository, this vfs may point to another |
|
362 | 362 | # repository's .hg/store directory. |
|
363 | 363 | self.svfs = None |
|
364 | 364 | self.root = self.wvfs.base |
|
365 | 365 | self.path = self.wvfs.join(".hg") |
|
366 | 366 | self.origroot = path |
|
367 | 367 | # These auditor are not used by the vfs, |
|
368 | 368 | # only used when writing this comment: basectx.match |
|
369 | 369 | self.auditor = pathutil.pathauditor(self.root, self._checknested) |
|
370 | 370 | self.nofsauditor = pathutil.pathauditor(self.root, self._checknested, |
|
371 | 371 | realfs=False, cached=True) |
|
372 | 372 | self.baseui = baseui |
|
373 | 373 | self.ui = baseui.copy() |
|
374 | 374 | self.ui.copy = baseui.copy # prevent copying repo configuration |
|
375 | 375 | self.vfs = vfsmod.vfs(self.path, cacheaudited=True) |
|
376 | 376 | if (self.ui.configbool('devel', 'all-warnings') or |
|
377 | 377 | self.ui.configbool('devel', 'check-locks')): |
|
378 | 378 | self.vfs.audit = self._getvfsward(self.vfs.audit) |
|
379 | 379 | # A list of callback to shape the phase if no data were found. |
|
380 | 380 | # Callback are in the form: func(repo, roots) --> processed root. |
|
381 | 381 | # This list it to be filled by extension during repo setup |
|
382 | 382 | self._phasedefaults = [] |
|
383 | 383 | try: |
|
384 | 384 | self.ui.readconfig(self.vfs.join("hgrc"), self.root) |
|
385 | 385 | self._loadextensions() |
|
386 | 386 | except IOError: |
|
387 | 387 | pass |
|
388 | 388 | |
|
389 | 389 | if self.featuresetupfuncs: |
|
390 | 390 | self.supported = set(self._basesupported) # use private copy |
|
391 | 391 | extmods = set(m.__name__ for n, m |
|
392 | 392 | in extensions.extensions(self.ui)) |
|
393 | 393 | for setupfunc in self.featuresetupfuncs: |
|
394 | 394 | if setupfunc.__module__ in extmods: |
|
395 | 395 | setupfunc(self.ui, self.supported) |
|
396 | 396 | else: |
|
397 | 397 | self.supported = self._basesupported |
|
398 | 398 | color.setup(self.ui) |
|
399 | 399 | |
|
400 | 400 | # Add compression engines. |
|
401 | 401 | for name in util.compengines: |
|
402 | 402 | engine = util.compengines[name] |
|
403 | 403 | if engine.revlogheader(): |
|
404 | 404 | self.supported.add('exp-compression-%s' % name) |
|
405 | 405 | |
|
406 | 406 | if not self.vfs.isdir(): |
|
407 | 407 | if create: |
|
408 | 408 | self.requirements = newreporequirements(self) |
|
409 | 409 | |
|
410 | 410 | if not self.wvfs.exists(): |
|
411 | 411 | self.wvfs.makedirs() |
|
412 | 412 | self.vfs.makedir(notindexed=True) |
|
413 | 413 | |
|
414 | 414 | if 'store' in self.requirements: |
|
415 | 415 | self.vfs.mkdir("store") |
|
416 | 416 | |
|
417 | 417 | # create an invalid changelog |
|
418 | 418 | self.vfs.append( |
|
419 | 419 | "00changelog.i", |
|
420 | 420 | '\0\0\0\2' # represents revlogv2 |
|
421 | 421 | ' dummy changelog to prevent using the old repo layout' |
|
422 | 422 | ) |
|
423 | 423 | else: |
|
424 | 424 | raise error.RepoError(_("repository %s not found") % path) |
|
425 | 425 | elif create: |
|
426 | 426 | raise error.RepoError(_("repository %s already exists") % path) |
|
427 | 427 | else: |
|
428 | 428 | try: |
|
429 | 429 | self.requirements = scmutil.readrequires( |
|
430 | 430 | self.vfs, self.supported) |
|
431 | 431 | except IOError as inst: |
|
432 | 432 | if inst.errno != errno.ENOENT: |
|
433 | 433 | raise |
|
434 | 434 | |
|
435 | 435 | cachepath = self.vfs.join('cache') |
|
436 | 436 | self.sharedpath = self.path |
|
437 | 437 | try: |
|
438 | 438 | sharedpath = self.vfs.read("sharedpath").rstrip('\n') |
|
439 | 439 | if 'relshared' in self.requirements: |
|
440 | 440 | sharedpath = self.vfs.join(sharedpath) |
|
441 | 441 | vfs = vfsmod.vfs(sharedpath, realpath=True) |
|
442 | 442 | cachepath = vfs.join('cache') |
|
443 | 443 | s = vfs.base |
|
444 | 444 | if not vfs.exists(): |
|
445 | 445 | raise error.RepoError( |
|
446 | 446 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
447 | 447 | self.sharedpath = s |
|
448 | 448 | except IOError as inst: |
|
449 | 449 | if inst.errno != errno.ENOENT: |
|
450 | 450 | raise |
|
451 | 451 | |
|
452 | 452 | if 'exp-sparse' in self.requirements and not sparse.enabled: |
|
453 | 453 | raise error.RepoError(_('repository is using sparse feature but ' |
|
454 | 454 | 'sparse is not enabled; enable the ' |
|
455 | 455 | '"sparse" extensions to access')) |
|
456 | 456 | |
|
457 | 457 | self.store = store.store( |
|
458 | 458 | self.requirements, self.sharedpath, |
|
459 | 459 | lambda base: vfsmod.vfs(base, cacheaudited=True)) |
|
460 | 460 | self.spath = self.store.path |
|
461 | 461 | self.svfs = self.store.vfs |
|
462 | 462 | self.sjoin = self.store.join |
|
463 | 463 | self.vfs.createmode = self.store.createmode |
|
464 | 464 | self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) |
|
465 | 465 | self.cachevfs.createmode = self.store.createmode |
|
466 | 466 | if (self.ui.configbool('devel', 'all-warnings') or |
|
467 | 467 | self.ui.configbool('devel', 'check-locks')): |
|
468 | 468 | if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs |
|
469 | 469 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) |
|
470 | 470 | else: # standard vfs |
|
471 | 471 | self.svfs.audit = self._getsvfsward(self.svfs.audit) |
|
472 | 472 | self._applyopenerreqs() |
|
473 | 473 | if create: |
|
474 | 474 | self._writerequirements() |
|
475 | 475 | |
|
476 | 476 | self._dirstatevalidatewarned = False |
|
477 | 477 | |
|
478 | 478 | self._branchcaches = {} |
|
479 | 479 | self._revbranchcache = None |
|
480 | 480 | self.filterpats = {} |
|
481 | 481 | self._datafilters = {} |
|
482 | 482 | self._transref = self._lockref = self._wlockref = None |
|
483 | 483 | |
|
484 | 484 | # A cache for various files under .hg/ that tracks file changes, |
|
485 | 485 | # (used by the filecache decorator) |
|
486 | 486 | # |
|
487 | 487 | # Maps a property name to its util.filecacheentry |
|
488 | 488 | self._filecache = {} |
|
489 | 489 | |
|
490 | 490 | # hold sets of revision to be filtered |
|
491 | 491 | # should be cleared when something might have changed the filter value: |
|
492 | 492 | # - new changesets, |
|
493 | 493 | # - phase change, |
|
494 | 494 | # - new obsolescence marker, |
|
495 | 495 | # - working directory parent change, |
|
496 | 496 | # - bookmark changes |
|
497 | 497 | self.filteredrevcache = {} |
|
498 | 498 | |
|
499 | 499 | # post-dirstate-status hooks |
|
500 | 500 | self._postdsstatus = [] |
|
501 | 501 | |
|
502 | 502 | # Cache of types representing filtered repos. |
|
503 | 503 | self._filteredrepotypes = weakref.WeakKeyDictionary() |
|
504 | 504 | |
|
505 | 505 | # generic mapping between names and nodes |
|
506 | 506 | self.names = namespaces.namespaces() |
|
507 | 507 | |
|
508 | 508 | # Key to signature value. |
|
509 | 509 | self._sparsesignaturecache = {} |
|
510 | 510 | # Signature to cached matcher instance. |
|
511 | 511 | self._sparsematchercache = {} |
|
512 | 512 | |
|
513 | 513 | def _getvfsward(self, origfunc): |
|
514 | 514 | """build a ward for self.vfs""" |
|
515 | 515 | rref = weakref.ref(self) |
|
516 | 516 | def checkvfs(path, mode=None): |
|
517 | 517 | ret = origfunc(path, mode=mode) |
|
518 | 518 | repo = rref() |
|
519 | 519 | if (repo is None |
|
520 | 520 | or not util.safehasattr(repo, '_wlockref') |
|
521 | 521 | or not util.safehasattr(repo, '_lockref')): |
|
522 | 522 | return |
|
523 | 523 | if mode in (None, 'r', 'rb'): |
|
524 | 524 | return |
|
525 | 525 | if path.startswith(repo.path): |
|
526 | 526 | # truncate name relative to the repository (.hg) |
|
527 | 527 | path = path[len(repo.path) + 1:] |
|
528 | 528 | if path.startswith('cache/'): |
|
529 | 529 | msg = 'accessing cache with vfs instead of cachevfs: "%s"' |
|
530 | 530 | repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs") |
|
531 | 531 | if path.startswith('journal.'): |
|
532 | 532 | # journal is covered by 'lock' |
|
533 | 533 | if repo._currentlock(repo._lockref) is None: |
|
534 | 534 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
535 | 535 | stacklevel=2, config='check-locks') |
|
536 | 536 | elif repo._currentlock(repo._wlockref) is None: |
|
537 | 537 | # rest of vfs files are covered by 'wlock' |
|
538 | 538 | # |
|
539 | 539 | # exclude special files |
|
540 | 540 | for prefix in self._wlockfreeprefix: |
|
541 | 541 | if path.startswith(prefix): |
|
542 | 542 | return |
|
543 | 543 | repo.ui.develwarn('write with no wlock: "%s"' % path, |
|
544 | 544 | stacklevel=2, config='check-locks') |
|
545 | 545 | return ret |
|
546 | 546 | return checkvfs |
|
547 | 547 | |
|
548 | 548 | def _getsvfsward(self, origfunc): |
|
549 | 549 | """build a ward for self.svfs""" |
|
550 | 550 | rref = weakref.ref(self) |
|
551 | 551 | def checksvfs(path, mode=None): |
|
552 | 552 | ret = origfunc(path, mode=mode) |
|
553 | 553 | repo = rref() |
|
554 | 554 | if repo is None or not util.safehasattr(repo, '_lockref'): |
|
555 | 555 | return |
|
556 | 556 | if mode in (None, 'r', 'rb'): |
|
557 | 557 | return |
|
558 | 558 | if path.startswith(repo.sharedpath): |
|
559 | 559 | # truncate name relative to the repository (.hg) |
|
560 | 560 | path = path[len(repo.sharedpath) + 1:] |
|
561 | 561 | if repo._currentlock(repo._lockref) is None: |
|
562 | 562 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
563 | 563 | stacklevel=3) |
|
564 | 564 | return ret |
|
565 | 565 | return checksvfs |
|
566 | 566 | |
|
567 | 567 | def close(self): |
|
568 | 568 | self._writecaches() |
|
569 | 569 | |
|
570 | 570 | def _loadextensions(self): |
|
571 | 571 | extensions.loadall(self.ui) |
|
572 | 572 | |
|
573 | 573 | def _writecaches(self): |
|
574 | 574 | if self._revbranchcache: |
|
575 | 575 | self._revbranchcache.write() |
|
576 | 576 | |
|
577 | 577 | def _restrictcapabilities(self, caps): |
|
578 | 578 | if self.ui.configbool('experimental', 'bundle2-advertise'): |
|
579 | 579 | caps = set(caps) |
|
580 | 580 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self)) |
|
581 | 581 | caps.add('bundle2=' + urlreq.quote(capsblob)) |
|
582 | 582 | return caps |
|
583 | 583 | |
|
584 | 584 | def _applyopenerreqs(self): |
|
585 | 585 | self.svfs.options = dict((r, 1) for r in self.requirements |
|
586 | 586 | if r in self.openerreqs) |
|
587 | 587 | # experimental config: format.chunkcachesize |
|
588 | 588 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') |
|
589 | 589 | if chunkcachesize is not None: |
|
590 | 590 | self.svfs.options['chunkcachesize'] = chunkcachesize |
|
591 | 591 | # experimental config: format.maxchainlen |
|
592 | 592 | maxchainlen = self.ui.configint('format', 'maxchainlen') |
|
593 | 593 | if maxchainlen is not None: |
|
594 | 594 | self.svfs.options['maxchainlen'] = maxchainlen |
|
595 | 595 | # experimental config: format.manifestcachesize |
|
596 | 596 | manifestcachesize = self.ui.configint('format', 'manifestcachesize') |
|
597 | 597 | if manifestcachesize is not None: |
|
598 | 598 | self.svfs.options['manifestcachesize'] = manifestcachesize |
|
599 | 599 | # experimental config: format.aggressivemergedeltas |
|
600 | 600 | aggressivemergedeltas = self.ui.configbool('format', |
|
601 | 601 | 'aggressivemergedeltas') |
|
602 | 602 | self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas |
|
603 | 603 | self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) |
|
604 | 604 | chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan') |
|
605 | 605 | if 0 <= chainspan: |
|
606 | 606 | self.svfs.options['maxdeltachainspan'] = chainspan |
|
607 | 607 | mmapindexthreshold = self.ui.configbytes('experimental', |
|
608 | 608 | 'mmapindexthreshold') |
|
609 | 609 | if mmapindexthreshold is not None: |
|
610 | 610 | self.svfs.options['mmapindexthreshold'] = mmapindexthreshold |
|
611 | 611 | |
|
612 | 612 | for r in self.requirements: |
|
613 | 613 | if r.startswith('exp-compression-'): |
|
614 | 614 | self.svfs.options['compengine'] = r[len('exp-compression-'):] |
|
615 | 615 | |
|
616 | 616 | # TODO move "revlogv2" to openerreqs once finalized. |
|
617 | 617 | if REVLOGV2_REQUIREMENT in self.requirements: |
|
618 | 618 | self.svfs.options['revlogv2'] = True |
|
619 | 619 | |
|
620 | 620 | def _writerequirements(self): |
|
621 | 621 | scmutil.writerequires(self.vfs, self.requirements) |
|
622 | 622 | |
|
623 | 623 | def _checknested(self, path): |
|
624 | 624 | """Determine if path is a legal nested repository.""" |
|
625 | 625 | if not path.startswith(self.root): |
|
626 | 626 | return False |
|
627 | 627 | subpath = path[len(self.root) + 1:] |
|
628 | 628 | normsubpath = util.pconvert(subpath) |
|
629 | 629 | |
|
630 | 630 | # XXX: Checking against the current working copy is wrong in |
|
631 | 631 | # the sense that it can reject things like |
|
632 | 632 | # |
|
633 | 633 | # $ hg cat -r 10 sub/x.txt |
|
634 | 634 | # |
|
635 | 635 | # if sub/ is no longer a subrepository in the working copy |
|
636 | 636 | # parent revision. |
|
637 | 637 | # |
|
638 | 638 | # However, it can of course also allow things that would have |
|
639 | 639 | # been rejected before, such as the above cat command if sub/ |
|
640 | 640 | # is a subrepository now, but was a normal directory before. |
|
641 | 641 | # The old path auditor would have rejected by mistake since it |
|
642 | 642 | # panics when it sees sub/.hg/. |
|
643 | 643 | # |
|
644 | 644 | # All in all, checking against the working copy seems sensible |
|
645 | 645 | # since we want to prevent access to nested repositories on |
|
646 | 646 | # the filesystem *now*. |
|
647 | 647 | ctx = self[None] |
|
648 | 648 | parts = util.splitpath(subpath) |
|
649 | 649 | while parts: |
|
650 | 650 | prefix = '/'.join(parts) |
|
651 | 651 | if prefix in ctx.substate: |
|
652 | 652 | if prefix == normsubpath: |
|
653 | 653 | return True |
|
654 | 654 | else: |
|
655 | 655 | sub = ctx.sub(prefix) |
|
656 | 656 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
657 | 657 | else: |
|
658 | 658 | parts.pop() |
|
659 | 659 | return False |
|
660 | 660 | |
|
661 | 661 | def peer(self): |
|
662 | 662 | return localpeer(self) # not cached to avoid reference cycle |
|
663 | 663 | |
|
664 | 664 | def unfiltered(self): |
|
665 | 665 | """Return unfiltered version of the repository |
|
666 | 666 | |
|
667 | 667 | Intended to be overwritten by filtered repo.""" |
|
668 | 668 | return self |
|
669 | 669 | |
|
670 | 670 | def filtered(self, name): |
|
671 | 671 | """Return a filtered version of a repository""" |
|
672 | 672 | # Python <3.4 easily leaks types via __mro__. See |
|
673 | 673 | # https://bugs.python.org/issue17950. We cache dynamically |
|
674 | 674 | # created types so this method doesn't leak on every |
|
675 | 675 | # invocation. |
|
676 | 676 | |
|
677 | 677 | key = self.unfiltered().__class__ |
|
678 | 678 | if key not in self._filteredrepotypes: |
|
679 | 679 | # Build a new type with the repoview mixin and the base |
|
680 | 680 | # class of this repo. Give it a name containing the |
|
681 | 681 | # filter name to aid debugging. |
|
682 | 682 | bases = (repoview.repoview, key) |
|
683 | 683 | cls = type(r'%sfilteredrepo' % name, bases, {}) |
|
684 | 684 | self._filteredrepotypes[key] = cls |
|
685 | 685 | |
|
686 | 686 | return self._filteredrepotypes[key](self, name) |
|
687 | 687 | |
|
688 | 688 | @repofilecache('bookmarks', 'bookmarks.current') |
|
689 | 689 | def _bookmarks(self): |
|
690 | 690 | return bookmarks.bmstore(self) |
|
691 | 691 | |
|
692 | 692 | @property |
|
693 | 693 | def _activebookmark(self): |
|
694 | 694 | return self._bookmarks.active |
|
695 | 695 | |
|
696 | 696 | # _phaserevs and _phasesets depend on changelog. what we need is to |
|
697 | 697 | # call _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
698 | 698 | # can't be easily expressed in filecache mechanism. |
|
699 | 699 | @storecache('phaseroots', '00changelog.i') |
|
700 | 700 | def _phasecache(self): |
|
701 | 701 | return phases.phasecache(self, self._phasedefaults) |
|
702 | 702 | |
|
703 | 703 | @storecache('obsstore') |
|
704 | 704 | def obsstore(self): |
|
705 | 705 | return obsolete.makestore(self.ui, self) |
|
706 | 706 | |
|
707 | 707 | @storecache('00changelog.i') |
|
708 | 708 | def changelog(self): |
|
709 | 709 | return changelog.changelog(self.svfs, |
|
710 | 710 | trypending=txnutil.mayhavepending(self.root)) |
|
711 | 711 | |
|
712 | 712 | def _constructmanifest(self): |
|
713 | 713 | # This is a temporary function while we migrate from manifest to |
|
714 | 714 | # manifestlog. It allows bundlerepo and unionrepo to intercept the |
|
715 | 715 | # manifest creation. |
|
716 | 716 | return manifest.manifestrevlog(self.svfs) |
|
717 | 717 | |
|
718 | 718 | @storecache('00manifest.i') |
|
719 | 719 | def manifestlog(self): |
|
720 | 720 | return manifest.manifestlog(self.svfs, self) |
|
721 | 721 | |
|
722 | 722 | @repofilecache('dirstate') |
|
723 | 723 | def dirstate(self): |
|
724 | 724 | sparsematchfn = lambda: sparse.matcher(self) |
|
725 | 725 | |
|
726 | 726 | return dirstate.dirstate(self.vfs, self.ui, self.root, |
|
727 | 727 | self._dirstatevalidate, sparsematchfn) |
|
728 | 728 | |
|
729 | 729 | def _dirstatevalidate(self, node): |
|
730 | 730 | try: |
|
731 | 731 | self.changelog.rev(node) |
|
732 | 732 | return node |
|
733 | 733 | except error.LookupError: |
|
734 | 734 | if not self._dirstatevalidatewarned: |
|
735 | 735 | self._dirstatevalidatewarned = True |
|
736 | 736 | self.ui.warn(_("warning: ignoring unknown" |
|
737 | 737 | " working parent %s!\n") % short(node)) |
|
738 | 738 | return nullid |
|
739 | 739 | |
|
740 | 740 | def __getitem__(self, changeid): |
|
741 | 741 | if changeid is None: |
|
742 | 742 | return context.workingctx(self) |
|
743 | 743 | if isinstance(changeid, slice): |
|
744 | 744 | # wdirrev isn't contiguous so the slice shouldn't include it |
|
745 | 745 | return [context.changectx(self, i) |
|
746 | 746 | for i in xrange(*changeid.indices(len(self))) |
|
747 | 747 | if i not in self.changelog.filteredrevs] |
|
748 | 748 | try: |
|
749 | 749 | return context.changectx(self, changeid) |
|
750 | 750 | except error.WdirUnsupported: |
|
751 | 751 | return context.workingctx(self) |
|
752 | 752 | |
|
753 | 753 | def __contains__(self, changeid): |
|
754 | 754 | """True if the given changeid exists |
|
755 | 755 | |
|
756 | 756 | error.LookupError is raised if an ambiguous node specified. |
|
757 | 757 | """ |
|
758 | 758 | try: |
|
759 | 759 | self[changeid] |
|
760 | 760 | return True |
|
761 | 761 | except error.RepoLookupError: |
|
762 | 762 | return False |
|
763 | 763 | |
|
764 | 764 | def __nonzero__(self): |
|
765 | 765 | return True |
|
766 | 766 | |
|
767 | 767 | __bool__ = __nonzero__ |
|
768 | 768 | |
|
769 | 769 | def __len__(self): |
|
770 | 770 | return len(self.changelog) |
|
771 | 771 | |
|
772 | 772 | def __iter__(self): |
|
773 | 773 | return iter(self.changelog) |
|
774 | 774 | |
|
775 | 775 | def revs(self, expr, *args): |
|
776 | 776 | '''Find revisions matching a revset. |
|
777 | 777 | |
|
778 | 778 | The revset is specified as a string ``expr`` that may contain |
|
779 | 779 | %-formatting to escape certain types. See ``revsetlang.formatspec``. |
|
780 | 780 | |
|
781 | 781 | Revset aliases from the configuration are not expanded. To expand |
|
782 | 782 | user aliases, consider calling ``scmutil.revrange()`` or |
|
783 | 783 | ``repo.anyrevs([expr], user=True)``. |
|
784 | 784 | |
|
785 | 785 | Returns a revset.abstractsmartset, which is a list-like interface |
|
786 | 786 | that contains integer revisions. |
|
787 | 787 | ''' |
|
788 | 788 | expr = revsetlang.formatspec(expr, *args) |
|
789 | 789 | m = revset.match(None, expr) |
|
790 | 790 | return m(self) |
|
791 | 791 | |
|
792 | 792 | def set(self, expr, *args): |
|
793 | 793 | '''Find revisions matching a revset and emit changectx instances. |
|
794 | 794 | |
|
795 | 795 | This is a convenience wrapper around ``revs()`` that iterates the |
|
796 | 796 | result and is a generator of changectx instances. |
|
797 | 797 | |
|
798 | 798 | Revset aliases from the configuration are not expanded. To expand |
|
799 | 799 | user aliases, consider calling ``scmutil.revrange()``. |
|
800 | 800 | ''' |
|
801 | 801 | for r in self.revs(expr, *args): |
|
802 | 802 | yield self[r] |
|
803 | 803 | |
|
804 | 804 | def anyrevs(self, specs, user=False, localalias=None): |
|
805 | 805 | '''Find revisions matching one of the given revsets. |
|
806 | 806 | |
|
807 | 807 | Revset aliases from the configuration are not expanded by default. To |
|
808 | 808 | expand user aliases, specify ``user=True``. To provide some local |
|
809 | 809 | definitions overriding user aliases, set ``localalias`` to |
|
810 | 810 | ``{name: definitionstring}``. |
|
811 | 811 | ''' |
|
812 | 812 | if user: |
|
813 | 813 | m = revset.matchany(self.ui, specs, repo=self, |
|
814 | 814 | localalias=localalias) |
|
815 | 815 | else: |
|
816 | 816 | m = revset.matchany(None, specs, localalias=localalias) |
|
817 | 817 | return m(self) |
|
818 | 818 | |
|
819 | 819 | def url(self): |
|
820 | 820 | return 'file:' + self.root |
|
821 | 821 | |
|
822 | 822 | def hook(self, name, throw=False, **args): |
|
823 | 823 | """Call a hook, passing this repo instance. |
|
824 | 824 | |
|
825 | 825 | This a convenience method to aid invoking hooks. Extensions likely |
|
826 | 826 | won't call this unless they have registered a custom hook or are |
|
827 | 827 | replacing code that is expected to call a hook. |
|
828 | 828 | """ |
|
829 | 829 | return hook.hook(self.ui, self, name, throw, **args) |
|
830 | 830 | |
|
831 | 831 | @filteredpropertycache |
|
832 | 832 | def _tagscache(self): |
|
833 | 833 | '''Returns a tagscache object that contains various tags related |
|
834 | 834 | caches.''' |
|
835 | 835 | |
|
836 | 836 | # This simplifies its cache management by having one decorated |
|
837 | 837 | # function (this one) and the rest simply fetch things from it. |
|
838 | 838 | class tagscache(object): |
|
839 | 839 | def __init__(self): |
|
840 | 840 | # These two define the set of tags for this repository. tags |
|
841 | 841 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
842 | 842 | # 'local'. (Global tags are defined by .hgtags across all |
|
843 | 843 | # heads, and local tags are defined in .hg/localtags.) |
|
844 | 844 | # They constitute the in-memory cache of tags. |
|
845 | 845 | self.tags = self.tagtypes = None |
|
846 | 846 | |
|
847 | 847 | self.nodetagscache = self.tagslist = None |
|
848 | 848 | |
|
849 | 849 | cache = tagscache() |
|
850 | 850 | cache.tags, cache.tagtypes = self._findtags() |
|
851 | 851 | |
|
852 | 852 | return cache |
|
853 | 853 | |
|
854 | 854 | def tags(self): |
|
855 | 855 | '''return a mapping of tag to node''' |
|
856 | 856 | t = {} |
|
857 | 857 | if self.changelog.filteredrevs: |
|
858 | 858 | tags, tt = self._findtags() |
|
859 | 859 | else: |
|
860 | 860 | tags = self._tagscache.tags |
|
861 | 861 | for k, v in tags.iteritems(): |
|
862 | 862 | try: |
|
863 | 863 | # ignore tags to unknown nodes |
|
864 | 864 | self.changelog.rev(v) |
|
865 | 865 | t[k] = v |
|
866 | 866 | except (error.LookupError, ValueError): |
|
867 | 867 | pass |
|
868 | 868 | return t |
|
869 | 869 | |
|
870 | 870 | def _findtags(self): |
|
871 | 871 | '''Do the hard work of finding tags. Return a pair of dicts |
|
872 | 872 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
873 | 873 | maps tag name to a string like \'global\' or \'local\'. |
|
874 | 874 | Subclasses or extensions are free to add their own tags, but |
|
875 | 875 | should be aware that the returned dicts will be retained for the |
|
876 | 876 | duration of the localrepo object.''' |
|
877 | 877 | |
|
878 | 878 | # XXX what tagtype should subclasses/extensions use? Currently |
|
879 | 879 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
880 | 880 | # Should each extension invent its own tag type? Should there |
|
881 | 881 | # be one tagtype for all such "virtual" tags? Or is the status |
|
882 | 882 | # quo fine? |
|
883 | 883 | |
|
884 | 884 | |
|
885 | 885 | # map tag name to (node, hist) |
|
886 | 886 | alltags = tagsmod.findglobaltags(self.ui, self) |
|
887 | 887 | # map tag name to tag type |
|
888 | 888 | tagtypes = dict((tag, 'global') for tag in alltags) |
|
889 | 889 | |
|
890 | 890 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
891 | 891 | |
|
892 | 892 | # Build the return dicts. Have to re-encode tag names because |
|
893 | 893 | # the tags module always uses UTF-8 (in order not to lose info |
|
894 | 894 | # writing to the cache), but the rest of Mercurial wants them in |
|
895 | 895 | # local encoding. |
|
896 | 896 | tags = {} |
|
897 | 897 | for (name, (node, hist)) in alltags.iteritems(): |
|
898 | 898 | if node != nullid: |
|
899 | 899 | tags[encoding.tolocal(name)] = node |
|
900 | 900 | tags['tip'] = self.changelog.tip() |
|
901 | 901 | tagtypes = dict([(encoding.tolocal(name), value) |
|
902 | 902 | for (name, value) in tagtypes.iteritems()]) |
|
903 | 903 | return (tags, tagtypes) |
|
904 | 904 | |
|
905 | 905 | def tagtype(self, tagname): |
|
906 | 906 | ''' |
|
907 | 907 | return the type of the given tag. result can be: |
|
908 | 908 | |
|
909 | 909 | 'local' : a local tag |
|
910 | 910 | 'global' : a global tag |
|
911 | 911 | None : tag does not exist |
|
912 | 912 | ''' |
|
913 | 913 | |
|
914 | 914 | return self._tagscache.tagtypes.get(tagname) |
|
915 | 915 | |
|
916 | 916 | def tagslist(self): |
|
917 | 917 | '''return a list of tags ordered by revision''' |
|
918 | 918 | if not self._tagscache.tagslist: |
|
919 | 919 | l = [] |
|
920 | 920 | for t, n in self.tags().iteritems(): |
|
921 | 921 | l.append((self.changelog.rev(n), t, n)) |
|
922 | 922 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
923 | 923 | |
|
924 | 924 | return self._tagscache.tagslist |
|
925 | 925 | |
|
926 | 926 | def nodetags(self, node): |
|
927 | 927 | '''return the tags associated with a node''' |
|
928 | 928 | if not self._tagscache.nodetagscache: |
|
929 | 929 | nodetagscache = {} |
|
930 | 930 | for t, n in self._tagscache.tags.iteritems(): |
|
931 | 931 | nodetagscache.setdefault(n, []).append(t) |
|
932 | 932 | for tags in nodetagscache.itervalues(): |
|
933 | 933 | tags.sort() |
|
934 | 934 | self._tagscache.nodetagscache = nodetagscache |
|
935 | 935 | return self._tagscache.nodetagscache.get(node, []) |
|
936 | 936 | |
|
937 | 937 | def nodebookmarks(self, node): |
|
938 | 938 | """return the list of bookmarks pointing to the specified node""" |
|
939 | 939 | marks = [] |
|
940 | 940 | for bookmark, n in self._bookmarks.iteritems(): |
|
941 | 941 | if n == node: |
|
942 | 942 | marks.append(bookmark) |
|
943 | 943 | return sorted(marks) |
|
944 | 944 | |
|
945 | 945 | def branchmap(self): |
|
946 | 946 | '''returns a dictionary {branch: [branchheads]} with branchheads |
|
947 | 947 | ordered by increasing revision number''' |
|
948 | 948 | branchmap.updatecache(self) |
|
949 | 949 | return self._branchcaches[self.filtername] |
|
950 | 950 | |
|
951 | 951 | @unfilteredmethod |
|
952 | 952 | def revbranchcache(self): |
|
953 | 953 | if not self._revbranchcache: |
|
954 | 954 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
955 | 955 | return self._revbranchcache |
|
956 | 956 | |
|
957 | 957 | def branchtip(self, branch, ignoremissing=False): |
|
958 | 958 | '''return the tip node for a given branch |
|
959 | 959 | |
|
960 | 960 | If ignoremissing is True, then this method will not raise an error. |
|
961 | 961 | This is helpful for callers that only expect None for a missing branch |
|
962 | 962 | (e.g. namespace). |
|
963 | 963 | |
|
964 | 964 | ''' |
|
965 | 965 | try: |
|
966 | 966 | return self.branchmap().branchtip(branch) |
|
967 | 967 | except KeyError: |
|
968 | 968 | if not ignoremissing: |
|
969 | 969 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
970 | 970 | else: |
|
971 | 971 | pass |
|
972 | 972 | |
|
973 | 973 | def lookup(self, key): |
|
974 | 974 | return self[key].node() |
|
975 | 975 | |
|
976 | 976 | def lookupbranch(self, key, remote=None): |
|
977 | 977 | repo = remote or self |
|
978 | 978 | if key in repo.branchmap(): |
|
979 | 979 | return key |
|
980 | 980 | |
|
981 | 981 | repo = (remote and remote.local()) and remote or self |
|
982 | 982 | return repo[key].branch() |
|
983 | 983 | |
|
984 | 984 | def known(self, nodes): |
|
985 | 985 | cl = self.changelog |
|
986 | 986 | nm = cl.nodemap |
|
987 | 987 | filtered = cl.filteredrevs |
|
988 | 988 | result = [] |
|
989 | 989 | for n in nodes: |
|
990 | 990 | r = nm.get(n) |
|
991 | 991 | resp = not (r is None or r in filtered) |
|
992 | 992 | result.append(resp) |
|
993 | 993 | return result |
|
994 | 994 | |
|
995 | 995 | def local(self): |
|
996 | 996 | return self |
|
997 | 997 | |
|
998 | 998 | def publishing(self): |
|
999 | 999 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
1000 | 1000 | # so that we don't finalize changes shared between users via ssh or nfs |
|
1001 | 1001 | return self.ui.configbool('phases', 'publish', untrusted=True) |
|
1002 | 1002 | |
|
1003 | 1003 | def cancopy(self): |
|
1004 | 1004 | # so statichttprepo's override of local() works |
|
1005 | 1005 | if not self.local(): |
|
1006 | 1006 | return False |
|
1007 | 1007 | if not self.publishing(): |
|
1008 | 1008 | return True |
|
1009 | 1009 | # if publishing we can't copy if there is filtered content |
|
1010 | 1010 | return not self.filtered('visible').changelog.filteredrevs |
|
1011 | 1011 | |
|
1012 | 1012 | def shared(self): |
|
1013 | 1013 | '''the type of shared repository (None if not shared)''' |
|
1014 | 1014 | if self.sharedpath != self.path: |
|
1015 | 1015 | return 'store' |
|
1016 | 1016 | return None |
|
1017 | 1017 | |
|
1018 | 1018 | def wjoin(self, f, *insidef): |
|
1019 | 1019 | return self.vfs.reljoin(self.root, f, *insidef) |
|
1020 | 1020 | |
|
1021 | 1021 | def file(self, f): |
|
1022 | 1022 | if f[0] == '/': |
|
1023 | 1023 | f = f[1:] |
|
1024 | 1024 | return filelog.filelog(self.svfs, f) |
|
1025 | 1025 | |
|
1026 | 1026 | def changectx(self, changeid): |
|
1027 | 1027 | return self[changeid] |
|
1028 | 1028 | |
|
1029 | 1029 | def setparents(self, p1, p2=nullid): |
|
1030 | 1030 | with self.dirstate.parentchange(): |
|
1031 | 1031 | copies = self.dirstate.setparents(p1, p2) |
|
1032 | 1032 | pctx = self[p1] |
|
1033 | 1033 | if copies: |
|
1034 | 1034 | # Adjust copy records, the dirstate cannot do it, it |
|
1035 | 1035 | # requires access to parents manifests. Preserve them |
|
1036 | 1036 | # only for entries added to first parent. |
|
1037 | 1037 | for f in copies: |
|
1038 | 1038 | if f not in pctx and copies[f] in pctx: |
|
1039 | 1039 | self.dirstate.copy(copies[f], f) |
|
1040 | 1040 | if p2 == nullid: |
|
1041 | 1041 | for f, s in sorted(self.dirstate.copies().items()): |
|
1042 | 1042 | if f not in pctx and s not in pctx: |
|
1043 | 1043 | self.dirstate.copy(None, f) |
|
1044 | 1044 | |
|
1045 | 1045 | def filectx(self, path, changeid=None, fileid=None): |
|
1046 | 1046 | """changeid can be a changeset revision, node, or tag. |
|
1047 | 1047 | fileid can be a file revision or node.""" |
|
1048 | 1048 | return context.filectx(self, path, changeid, fileid) |
|
1049 | 1049 | |
|
1050 | 1050 | def getcwd(self): |
|
1051 | 1051 | return self.dirstate.getcwd() |
|
1052 | 1052 | |
|
1053 | 1053 | def pathto(self, f, cwd=None): |
|
1054 | 1054 | return self.dirstate.pathto(f, cwd) |
|
1055 | 1055 | |
|
1056 | 1056 | def _loadfilter(self, filter): |
|
1057 | 1057 | if filter not in self.filterpats: |
|
1058 | 1058 | l = [] |
|
1059 | 1059 | for pat, cmd in self.ui.configitems(filter): |
|
1060 | 1060 | if cmd == '!': |
|
1061 | 1061 | continue |
|
1062 | 1062 | mf = matchmod.match(self.root, '', [pat]) |
|
1063 | 1063 | fn = None |
|
1064 | 1064 | params = cmd |
|
1065 | 1065 | for name, filterfn in self._datafilters.iteritems(): |
|
1066 | 1066 | if cmd.startswith(name): |
|
1067 | 1067 | fn = filterfn |
|
1068 | 1068 | params = cmd[len(name):].lstrip() |
|
1069 | 1069 | break |
|
1070 | 1070 | if not fn: |
|
1071 | 1071 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
1072 | 1072 | # Wrap old filters not supporting keyword arguments |
|
1073 | 1073 | if not inspect.getargspec(fn)[2]: |
|
1074 | 1074 | oldfn = fn |
|
1075 | 1075 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
1076 | 1076 | l.append((mf, fn, params)) |
|
1077 | 1077 | self.filterpats[filter] = l |
|
1078 | 1078 | return self.filterpats[filter] |
|
1079 | 1079 | |
|
1080 | 1080 | def _filter(self, filterpats, filename, data): |
|
1081 | 1081 | for mf, fn, cmd in filterpats: |
|
1082 | 1082 | if mf(filename): |
|
1083 | 1083 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
1084 | 1084 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
1085 | 1085 | break |
|
1086 | 1086 | |
|
1087 | 1087 | return data |
|
1088 | 1088 | |
|
1089 | 1089 | @unfilteredpropertycache |
|
1090 | 1090 | def _encodefilterpats(self): |
|
1091 | 1091 | return self._loadfilter('encode') |
|
1092 | 1092 | |
|
1093 | 1093 | @unfilteredpropertycache |
|
1094 | 1094 | def _decodefilterpats(self): |
|
1095 | 1095 | return self._loadfilter('decode') |
|
1096 | 1096 | |
|
1097 | 1097 | def adddatafilter(self, name, filter): |
|
1098 | 1098 | self._datafilters[name] = filter |
|
1099 | 1099 | |
|
1100 | 1100 | def wread(self, filename): |
|
1101 | 1101 | if self.wvfs.islink(filename): |
|
1102 | 1102 | data = self.wvfs.readlink(filename) |
|
1103 | 1103 | else: |
|
1104 | 1104 | data = self.wvfs.read(filename) |
|
1105 | 1105 | return self._filter(self._encodefilterpats, filename, data) |
|
1106 | 1106 | |
|
1107 | 1107 | def wwrite(self, filename, data, flags, backgroundclose=False): |
|
1108 | 1108 | """write ``data`` into ``filename`` in the working directory |
|
1109 | 1109 | |
|
1110 | 1110 | This returns length of written (maybe decoded) data. |
|
1111 | 1111 | """ |
|
1112 | 1112 | data = self._filter(self._decodefilterpats, filename, data) |
|
1113 | 1113 | if 'l' in flags: |
|
1114 | 1114 | self.wvfs.symlink(data, filename) |
|
1115 | 1115 | else: |
|
1116 | 1116 | self.wvfs.write(filename, data, backgroundclose=backgroundclose) |
|
1117 | 1117 | if 'x' in flags: |
|
1118 | 1118 | self.wvfs.setflags(filename, False, True) |
|
1119 | 1119 | return len(data) |
|
1120 | 1120 | |
|
1121 | 1121 | def wwritedata(self, filename, data): |
|
1122 | 1122 | return self._filter(self._decodefilterpats, filename, data) |
|
1123 | 1123 | |
|
1124 | 1124 | def currenttransaction(self): |
|
1125 | 1125 | """return the current transaction or None if non exists""" |
|
1126 | 1126 | if self._transref: |
|
1127 | 1127 | tr = self._transref() |
|
1128 | 1128 | else: |
|
1129 | 1129 | tr = None |
|
1130 | 1130 | |
|
1131 | 1131 | if tr and tr.running(): |
|
1132 | 1132 | return tr |
|
1133 | 1133 | return None |
|
1134 | 1134 | |
|
1135 | 1135 | def transaction(self, desc, report=None): |
|
1136 | 1136 | if (self.ui.configbool('devel', 'all-warnings') |
|
1137 | 1137 | or self.ui.configbool('devel', 'check-locks')): |
|
1138 | 1138 | if self._currentlock(self._lockref) is None: |
|
1139 | 1139 | raise error.ProgrammingError('transaction requires locking') |
|
1140 | 1140 | tr = self.currenttransaction() |
|
1141 | 1141 | if tr is not None: |
|
1142 | 1142 | scmutil.registersummarycallback(self, tr, desc) |
|
1143 | 1143 | return tr.nest() |
|
1144 | 1144 | |
|
1145 | 1145 | # abort here if the journal already exists |
|
1146 | 1146 | if self.svfs.exists("journal"): |
|
1147 | 1147 | raise error.RepoError( |
|
1148 | 1148 | _("abandoned transaction found"), |
|
1149 | 1149 | hint=_("run 'hg recover' to clean up transaction")) |
|
1150 | 1150 | |
|
1151 | 1151 | idbase = "%.40f#%f" % (random.random(), time.time()) |
|
1152 | 1152 | ha = hex(hashlib.sha1(idbase).digest()) |
|
1153 | 1153 | txnid = 'TXN:' + ha |
|
1154 | 1154 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
1155 | 1155 | |
|
1156 | 1156 | self._writejournal(desc) |
|
1157 | 1157 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
1158 | 1158 | if report: |
|
1159 | 1159 | rp = report |
|
1160 | 1160 | else: |
|
1161 | 1161 | rp = self.ui.warn |
|
1162 | 1162 | vfsmap = {'plain': self.vfs} # root of .hg/ |
|
1163 | 1163 | # we must avoid cyclic reference between repo and transaction. |
|
1164 | 1164 | reporef = weakref.ref(self) |
|
1165 | 1165 | # Code to track tag movement |
|
1166 | 1166 | # |
|
1167 | 1167 | # Since tags are all handled as file content, it is actually quite hard |
|
1168 | 1168 | # to track these movement from a code perspective. So we fallback to a |
|
1169 | 1169 | # tracking at the repository level. One could envision to track changes |
|
1170 | 1170 | # to the '.hgtags' file through changegroup apply but that fails to |
|
1171 | 1171 | # cope with case where transaction expose new heads without changegroup |
|
1172 | 1172 | # being involved (eg: phase movement). |
|
1173 | 1173 | # |
|
1174 | 1174 | # For now, We gate the feature behind a flag since this likely comes |
|
1175 | 1175 | # with performance impacts. The current code run more often than needed |
|
1176 | 1176 | # and do not use caches as much as it could. The current focus is on |
|
1177 | 1177 | # the behavior of the feature so we disable it by default. The flag |
|
1178 | 1178 | # will be removed when we are happy with the performance impact. |
|
1179 | 1179 | # |
|
1180 | 1180 | # Once this feature is no longer experimental move the following |
|
1181 | 1181 | # documentation to the appropriate help section: |
|
1182 | 1182 | # |
|
1183 | 1183 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched |
|
1184 | 1184 | # tags (new or changed or deleted tags). In addition the details of |
|
1185 | 1185 | # these changes are made available in a file at: |
|
1186 | 1186 | # ``REPOROOT/.hg/changes/tags.changes``. |
|
1187 | 1187 | # Make sure you check for HG_TAG_MOVED before reading that file as it |
|
1188 | 1188 | # might exist from a previous transaction even if no tag were touched |
|
1189 | 1189 | # in this one. Changes are recorded in a line base format:: |
|
1190 | 1190 | # |
|
1191 | 1191 | # <action> <hex-node> <tag-name>\n |
|
1192 | 1192 | # |
|
1193 | 1193 | # Actions are defined as follow: |
|
1194 | 1194 | # "-R": tag is removed, |
|
1195 | 1195 | # "+A": tag is added, |
|
1196 | 1196 | # "-M": tag is moved (old value), |
|
1197 | 1197 | # "+M": tag is moved (new value), |
|
1198 | 1198 | tracktags = lambda x: None |
|
1199 | 1199 | # experimental config: experimental.hook-track-tags |
|
1200 | 1200 | shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags') |
|
1201 | 1201 | if desc != 'strip' and shouldtracktags: |
|
1202 | 1202 | oldheads = self.changelog.headrevs() |
|
1203 | 1203 | def tracktags(tr2): |
|
1204 | 1204 | repo = reporef() |
|
1205 | 1205 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) |
|
1206 | 1206 | newheads = repo.changelog.headrevs() |
|
1207 | 1207 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
1208 | 1208 | # notes: we compare lists here. |
|
1209 | 1209 | # As we do it only once buiding set would not be cheaper |
|
1210 | 1210 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) |
|
1211 | 1211 | if changes: |
|
1212 | 1212 | tr2.hookargs['tag_moved'] = '1' |
|
1213 | 1213 | with repo.vfs('changes/tags.changes', 'w', |
|
1214 | 1214 | atomictemp=True) as changesfile: |
|
1215 | 1215 | # note: we do not register the file to the transaction |
|
1216 | 1216 | # because we needs it to still exist on the transaction |
|
1217 | 1217 | # is close (for txnclose hooks) |
|
1218 | 1218 | tagsmod.writediff(changesfile, changes) |
|
1219 | 1219 | def validate(tr2): |
|
1220 | 1220 | """will run pre-closing hooks""" |
|
1221 | 1221 | # XXX the transaction API is a bit lacking here so we take a hacky |
|
1222 | 1222 | # path for now |
|
1223 | 1223 | # |
|
1224 | 1224 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' |
|
1225 | 1225 | # dict is copied before these run. In addition we needs the data |
|
1226 | 1226 | # available to in memory hooks too. |
|
1227 | 1227 | # |
|
1228 | 1228 | # Moreover, we also need to make sure this runs before txnclose |
|
1229 | 1229 | # hooks and there is no "pending" mechanism that would execute |
|
1230 | 1230 | # logic only if hooks are about to run. |
|
1231 | 1231 | # |
|
1232 | 1232 | # Fixing this limitation of the transaction is also needed to track |
|
1233 | 1233 | # other families of changes (bookmarks, phases, obsolescence). |
|
1234 | 1234 | # |
|
1235 | 1235 | # This will have to be fixed before we remove the experimental |
|
1236 | 1236 | # gating. |
|
1237 | 1237 | tracktags(tr2) |
|
1238 | 1238 | repo = reporef() |
|
1239 | 1239 | if hook.hashook(repo.ui, 'pretxnclose-bookmark'): |
|
1240 | 1240 | for name, (old, new) in sorted(tr.changes['bookmarks'].items()): |
|
1241 | 1241 | args = tr.hookargs.copy() |
|
1242 | 1242 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1243 | 1243 | repo.hook('pretxnclose-bookmark', throw=True, |
|
1244 | 1244 | txnname=desc, |
|
1245 | 1245 | **pycompat.strkwargs(args)) |
|
1246 | if hook.hashook(repo.ui, 'pretxnclose-phase'): | |
|
1247 | cl = repo.unfiltered().changelog | |
|
1248 | for rev, (old, new) in tr.changes['phases'].items(): | |
|
1249 | args = tr.hookargs.copy() | |
|
1250 | node = hex(cl.node(rev)) | |
|
1251 | args.update(phases.preparehookargs(node, old, new)) | |
|
1252 | repo.hook('pretxnclose-phase', throw=True, txnname=desc, | |
|
1253 | **pycompat.strkwargs(args)) | |
|
1246 | 1254 | |
|
1247 | 1255 | repo.hook('pretxnclose', throw=True, |
|
1248 | 1256 | txnname=desc, **pycompat.strkwargs(tr.hookargs)) |
|
1249 | 1257 | def releasefn(tr, success): |
|
1250 | 1258 | repo = reporef() |
|
1251 | 1259 | if success: |
|
1252 | 1260 | # this should be explicitly invoked here, because |
|
1253 | 1261 | # in-memory changes aren't written out at closing |
|
1254 | 1262 | # transaction, if tr.addfilegenerator (via |
|
1255 | 1263 | # dirstate.write or so) isn't invoked while |
|
1256 | 1264 | # transaction running |
|
1257 | 1265 | repo.dirstate.write(None) |
|
1258 | 1266 | else: |
|
1259 | 1267 | # discard all changes (including ones already written |
|
1260 | 1268 | # out) in this transaction |
|
1261 | 1269 | repo.dirstate.restorebackup(None, 'journal.dirstate') |
|
1262 | 1270 | |
|
1263 | 1271 | repo.invalidate(clearfilecache=True) |
|
1264 | 1272 | |
|
1265 | 1273 | tr = transaction.transaction(rp, self.svfs, vfsmap, |
|
1266 | 1274 | "journal", |
|
1267 | 1275 | "undo", |
|
1268 | 1276 | aftertrans(renames), |
|
1269 | 1277 | self.store.createmode, |
|
1270 | 1278 | validator=validate, |
|
1271 | 1279 | releasefn=releasefn, |
|
1272 | 1280 | checkambigfiles=_cachedfiles) |
|
1273 | 1281 | tr.changes['revs'] = set() |
|
1274 | 1282 | tr.changes['obsmarkers'] = set() |
|
1275 | 1283 | tr.changes['phases'] = {} |
|
1276 | 1284 | tr.changes['bookmarks'] = {} |
|
1277 | 1285 | |
|
1278 | 1286 | tr.hookargs['txnid'] = txnid |
|
1279 | 1287 | # note: writing the fncache only during finalize mean that the file is |
|
1280 | 1288 | # outdated when running hooks. As fncache is used for streaming clone, |
|
1281 | 1289 | # this is not expected to break anything that happen during the hooks. |
|
1282 | 1290 | tr.addfinalize('flush-fncache', self.store.write) |
|
1283 | 1291 | def txnclosehook(tr2): |
|
1284 | 1292 | """To be run if transaction is successful, will schedule a hook run |
|
1285 | 1293 | """ |
|
1286 | 1294 | # Don't reference tr2 in hook() so we don't hold a reference. |
|
1287 | 1295 | # This reduces memory consumption when there are multiple |
|
1288 | 1296 | # transactions per lock. This can likely go away if issue5045 |
|
1289 | 1297 | # fixes the function accumulation. |
|
1290 | 1298 | hookargs = tr2.hookargs |
|
1291 | 1299 | |
|
1292 | 1300 | def hookfunc(): |
|
1293 | 1301 | repo = reporef() |
|
1294 | 1302 | if hook.hashook(repo.ui, 'txnclose-bookmark'): |
|
1295 | 1303 | bmchanges = sorted(tr.changes['bookmarks'].items()) |
|
1296 | 1304 | for name, (old, new) in bmchanges: |
|
1297 | 1305 | args = tr.hookargs.copy() |
|
1298 | 1306 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1299 | 1307 | repo.hook('txnclose-bookmark', throw=False, |
|
1300 | 1308 | txnname=desc, **pycompat.strkwargs(args)) |
|
1301 | 1309 | |
|
1302 | 1310 | if hook.hashook(repo.ui, 'txnclose-phase'): |
|
1303 | 1311 | cl = repo.unfiltered().changelog |
|
1304 | 1312 | phasemv = sorted(tr.changes['phases'].items()) |
|
1305 | 1313 | for rev, (old, new) in phasemv: |
|
1306 | 1314 | args = tr.hookargs.copy() |
|
1307 | 1315 | node = hex(cl.node(rev)) |
|
1308 | 1316 | args.update(phases.preparehookargs(node, old, new)) |
|
1309 | 1317 | repo.hook('txnclose-phase', throw=False, txnname=desc, |
|
1310 | 1318 | **pycompat.strkwargs(args)) |
|
1311 | 1319 | |
|
1312 | 1320 | repo.hook('txnclose', throw=False, txnname=desc, |
|
1313 | 1321 | **pycompat.strkwargs(hookargs)) |
|
1314 | 1322 | reporef()._afterlock(hookfunc) |
|
1315 | 1323 | tr.addfinalize('txnclose-hook', txnclosehook) |
|
1316 | 1324 | tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) |
|
1317 | 1325 | def txnaborthook(tr2): |
|
1318 | 1326 | """To be run if transaction is aborted |
|
1319 | 1327 | """ |
|
1320 | 1328 | reporef().hook('txnabort', throw=False, txnname=desc, |
|
1321 | 1329 | **tr2.hookargs) |
|
1322 | 1330 | tr.addabort('txnabort-hook', txnaborthook) |
|
1323 | 1331 | # avoid eager cache invalidation. in-memory data should be identical |
|
1324 | 1332 | # to stored data if transaction has no error. |
|
1325 | 1333 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) |
|
1326 | 1334 | self._transref = weakref.ref(tr) |
|
1327 | 1335 | scmutil.registersummarycallback(self, tr, desc) |
|
1328 | 1336 | return tr |
|
1329 | 1337 | |
|
1330 | 1338 | def _journalfiles(self): |
|
1331 | 1339 | return ((self.svfs, 'journal'), |
|
1332 | 1340 | (self.vfs, 'journal.dirstate'), |
|
1333 | 1341 | (self.vfs, 'journal.branch'), |
|
1334 | 1342 | (self.vfs, 'journal.desc'), |
|
1335 | 1343 | (self.vfs, 'journal.bookmarks'), |
|
1336 | 1344 | (self.svfs, 'journal.phaseroots')) |
|
1337 | 1345 | |
|
1338 | 1346 | def undofiles(self): |
|
1339 | 1347 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
1340 | 1348 | |
|
1341 | 1349 | @unfilteredmethod |
|
1342 | 1350 | def _writejournal(self, desc): |
|
1343 | 1351 | self.dirstate.savebackup(None, 'journal.dirstate') |
|
1344 | 1352 | self.vfs.write("journal.branch", |
|
1345 | 1353 | encoding.fromlocal(self.dirstate.branch())) |
|
1346 | 1354 | self.vfs.write("journal.desc", |
|
1347 | 1355 | "%d\n%s\n" % (len(self), desc)) |
|
1348 | 1356 | self.vfs.write("journal.bookmarks", |
|
1349 | 1357 | self.vfs.tryread("bookmarks")) |
|
1350 | 1358 | self.svfs.write("journal.phaseroots", |
|
1351 | 1359 | self.svfs.tryread("phaseroots")) |
|
1352 | 1360 | |
|
1353 | 1361 | def recover(self): |
|
1354 | 1362 | with self.lock(): |
|
1355 | 1363 | if self.svfs.exists("journal"): |
|
1356 | 1364 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
1357 | 1365 | vfsmap = {'': self.svfs, |
|
1358 | 1366 | 'plain': self.vfs,} |
|
1359 | 1367 | transaction.rollback(self.svfs, vfsmap, "journal", |
|
1360 | 1368 | self.ui.warn, |
|
1361 | 1369 | checkambigfiles=_cachedfiles) |
|
1362 | 1370 | self.invalidate() |
|
1363 | 1371 | return True |
|
1364 | 1372 | else: |
|
1365 | 1373 | self.ui.warn(_("no interrupted transaction available\n")) |
|
1366 | 1374 | return False |
|
1367 | 1375 | |
|
1368 | 1376 | def rollback(self, dryrun=False, force=False): |
|
1369 | 1377 | wlock = lock = dsguard = None |
|
1370 | 1378 | try: |
|
1371 | 1379 | wlock = self.wlock() |
|
1372 | 1380 | lock = self.lock() |
|
1373 | 1381 | if self.svfs.exists("undo"): |
|
1374 | 1382 | dsguard = dirstateguard.dirstateguard(self, 'rollback') |
|
1375 | 1383 | |
|
1376 | 1384 | return self._rollback(dryrun, force, dsguard) |
|
1377 | 1385 | else: |
|
1378 | 1386 | self.ui.warn(_("no rollback information available\n")) |
|
1379 | 1387 | return 1 |
|
1380 | 1388 | finally: |
|
1381 | 1389 | release(dsguard, lock, wlock) |
|
1382 | 1390 | |
|
1383 | 1391 | @unfilteredmethod # Until we get smarter cache management |
|
1384 | 1392 | def _rollback(self, dryrun, force, dsguard): |
|
1385 | 1393 | ui = self.ui |
|
1386 | 1394 | try: |
|
1387 | 1395 | args = self.vfs.read('undo.desc').splitlines() |
|
1388 | 1396 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
1389 | 1397 | if len(args) >= 3: |
|
1390 | 1398 | detail = args[2] |
|
1391 | 1399 | oldtip = oldlen - 1 |
|
1392 | 1400 | |
|
1393 | 1401 | if detail and ui.verbose: |
|
1394 | 1402 | msg = (_('repository tip rolled back to revision %d' |
|
1395 | 1403 | ' (undo %s: %s)\n') |
|
1396 | 1404 | % (oldtip, desc, detail)) |
|
1397 | 1405 | else: |
|
1398 | 1406 | msg = (_('repository tip rolled back to revision %d' |
|
1399 | 1407 | ' (undo %s)\n') |
|
1400 | 1408 | % (oldtip, desc)) |
|
1401 | 1409 | except IOError: |
|
1402 | 1410 | msg = _('rolling back unknown transaction\n') |
|
1403 | 1411 | desc = None |
|
1404 | 1412 | |
|
1405 | 1413 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
1406 | 1414 | raise error.Abort( |
|
1407 | 1415 | _('rollback of last commit while not checked out ' |
|
1408 | 1416 | 'may lose data'), hint=_('use -f to force')) |
|
1409 | 1417 | |
|
1410 | 1418 | ui.status(msg) |
|
1411 | 1419 | if dryrun: |
|
1412 | 1420 | return 0 |
|
1413 | 1421 | |
|
1414 | 1422 | parents = self.dirstate.parents() |
|
1415 | 1423 | self.destroying() |
|
1416 | 1424 | vfsmap = {'plain': self.vfs, '': self.svfs} |
|
1417 | 1425 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn, |
|
1418 | 1426 | checkambigfiles=_cachedfiles) |
|
1419 | 1427 | if self.vfs.exists('undo.bookmarks'): |
|
1420 | 1428 | self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) |
|
1421 | 1429 | if self.svfs.exists('undo.phaseroots'): |
|
1422 | 1430 | self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True) |
|
1423 | 1431 | self.invalidate() |
|
1424 | 1432 | |
|
1425 | 1433 | parentgone = (parents[0] not in self.changelog.nodemap or |
|
1426 | 1434 | parents[1] not in self.changelog.nodemap) |
|
1427 | 1435 | if parentgone: |
|
1428 | 1436 | # prevent dirstateguard from overwriting already restored one |
|
1429 | 1437 | dsguard.close() |
|
1430 | 1438 | |
|
1431 | 1439 | self.dirstate.restorebackup(None, 'undo.dirstate') |
|
1432 | 1440 | try: |
|
1433 | 1441 | branch = self.vfs.read('undo.branch') |
|
1434 | 1442 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
1435 | 1443 | except IOError: |
|
1436 | 1444 | ui.warn(_('named branch could not be reset: ' |
|
1437 | 1445 | 'current branch is still \'%s\'\n') |
|
1438 | 1446 | % self.dirstate.branch()) |
|
1439 | 1447 | |
|
1440 | 1448 | parents = tuple([p.rev() for p in self[None].parents()]) |
|
1441 | 1449 | if len(parents) > 1: |
|
1442 | 1450 | ui.status(_('working directory now based on ' |
|
1443 | 1451 | 'revisions %d and %d\n') % parents) |
|
1444 | 1452 | else: |
|
1445 | 1453 | ui.status(_('working directory now based on ' |
|
1446 | 1454 | 'revision %d\n') % parents) |
|
1447 | 1455 | mergemod.mergestate.clean(self, self['.'].node()) |
|
1448 | 1456 | |
|
1449 | 1457 | # TODO: if we know which new heads may result from this rollback, pass |
|
1450 | 1458 | # them to destroy(), which will prevent the branchhead cache from being |
|
1451 | 1459 | # invalidated. |
|
1452 | 1460 | self.destroyed() |
|
1453 | 1461 | return 0 |
|
1454 | 1462 | |
|
1455 | 1463 | def _buildcacheupdater(self, newtransaction): |
|
1456 | 1464 | """called during transaction to build the callback updating cache |
|
1457 | 1465 | |
|
1458 | 1466 | Lives on the repository to help extension who might want to augment |
|
1459 | 1467 | this logic. For this purpose, the created transaction is passed to the |
|
1460 | 1468 | method. |
|
1461 | 1469 | """ |
|
1462 | 1470 | # we must avoid cyclic reference between repo and transaction. |
|
1463 | 1471 | reporef = weakref.ref(self) |
|
1464 | 1472 | def updater(tr): |
|
1465 | 1473 | repo = reporef() |
|
1466 | 1474 | repo.updatecaches(tr) |
|
1467 | 1475 | return updater |
|
1468 | 1476 | |
|
1469 | 1477 | @unfilteredmethod |
|
1470 | 1478 | def updatecaches(self, tr=None): |
|
1471 | 1479 | """warm appropriate caches |
|
1472 | 1480 | |
|
1473 | 1481 | If this function is called after a transaction closed. The transaction |
|
1474 | 1482 | will be available in the 'tr' argument. This can be used to selectively |
|
1475 | 1483 | update caches relevant to the changes in that transaction. |
|
1476 | 1484 | """ |
|
1477 | 1485 | if tr is not None and tr.hookargs.get('source') == 'strip': |
|
1478 | 1486 | # During strip, many caches are invalid but |
|
1479 | 1487 | # later call to `destroyed` will refresh them. |
|
1480 | 1488 | return |
|
1481 | 1489 | |
|
1482 | 1490 | if tr is None or tr.changes['revs']: |
|
1483 | 1491 | # updating the unfiltered branchmap should refresh all the others, |
|
1484 | 1492 | self.ui.debug('updating the branch cache\n') |
|
1485 | 1493 | branchmap.updatecache(self.filtered('served')) |
|
1486 | 1494 | |
|
1487 | 1495 | def invalidatecaches(self): |
|
1488 | 1496 | |
|
1489 | 1497 | if '_tagscache' in vars(self): |
|
1490 | 1498 | # can't use delattr on proxy |
|
1491 | 1499 | del self.__dict__['_tagscache'] |
|
1492 | 1500 | |
|
1493 | 1501 | self.unfiltered()._branchcaches.clear() |
|
1494 | 1502 | self.invalidatevolatilesets() |
|
1495 | 1503 | self._sparsesignaturecache.clear() |
|
1496 | 1504 | |
|
1497 | 1505 | def invalidatevolatilesets(self): |
|
1498 | 1506 | self.filteredrevcache.clear() |
|
1499 | 1507 | obsolete.clearobscaches(self) |
|
1500 | 1508 | |
|
1501 | 1509 | def invalidatedirstate(self): |
|
1502 | 1510 | '''Invalidates the dirstate, causing the next call to dirstate |
|
1503 | 1511 | to check if it was modified since the last time it was read, |
|
1504 | 1512 | rereading it if it has. |
|
1505 | 1513 | |
|
1506 | 1514 | This is different to dirstate.invalidate() that it doesn't always |
|
1507 | 1515 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
1508 | 1516 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
1509 | 1517 | known good state).''' |
|
1510 | 1518 | if hasunfilteredcache(self, 'dirstate'): |
|
1511 | 1519 | for k in self.dirstate._filecache: |
|
1512 | 1520 | try: |
|
1513 | 1521 | delattr(self.dirstate, k) |
|
1514 | 1522 | except AttributeError: |
|
1515 | 1523 | pass |
|
1516 | 1524 | delattr(self.unfiltered(), 'dirstate') |
|
1517 | 1525 | |
|
1518 | 1526 | def invalidate(self, clearfilecache=False): |
|
1519 | 1527 | '''Invalidates both store and non-store parts other than dirstate |
|
1520 | 1528 | |
|
1521 | 1529 | If a transaction is running, invalidation of store is omitted, |
|
1522 | 1530 | because discarding in-memory changes might cause inconsistency |
|
1523 | 1531 | (e.g. incomplete fncache causes unintentional failure, but |
|
1524 | 1532 | redundant one doesn't). |
|
1525 | 1533 | ''' |
|
1526 | 1534 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
1527 | 1535 | for k in list(self._filecache.keys()): |
|
1528 | 1536 | # dirstate is invalidated separately in invalidatedirstate() |
|
1529 | 1537 | if k == 'dirstate': |
|
1530 | 1538 | continue |
|
1531 | 1539 | if (k == 'changelog' and |
|
1532 | 1540 | self.currenttransaction() and |
|
1533 | 1541 | self.changelog._delayed): |
|
1534 | 1542 | # The changelog object may store unwritten revisions. We don't |
|
1535 | 1543 | # want to lose them. |
|
1536 | 1544 | # TODO: Solve the problem instead of working around it. |
|
1537 | 1545 | continue |
|
1538 | 1546 | |
|
1539 | 1547 | if clearfilecache: |
|
1540 | 1548 | del self._filecache[k] |
|
1541 | 1549 | try: |
|
1542 | 1550 | delattr(unfiltered, k) |
|
1543 | 1551 | except AttributeError: |
|
1544 | 1552 | pass |
|
1545 | 1553 | self.invalidatecaches() |
|
1546 | 1554 | if not self.currenttransaction(): |
|
1547 | 1555 | # TODO: Changing contents of store outside transaction |
|
1548 | 1556 | # causes inconsistency. We should make in-memory store |
|
1549 | 1557 | # changes detectable, and abort if changed. |
|
1550 | 1558 | self.store.invalidatecaches() |
|
1551 | 1559 | |
|
1552 | 1560 | def invalidateall(self): |
|
1553 | 1561 | '''Fully invalidates both store and non-store parts, causing the |
|
1554 | 1562 | subsequent operation to reread any outside changes.''' |
|
1555 | 1563 | # extension should hook this to invalidate its caches |
|
1556 | 1564 | self.invalidate() |
|
1557 | 1565 | self.invalidatedirstate() |
|
1558 | 1566 | |
|
1559 | 1567 | @unfilteredmethod |
|
1560 | 1568 | def _refreshfilecachestats(self, tr): |
|
1561 | 1569 | """Reload stats of cached files so that they are flagged as valid""" |
|
1562 | 1570 | for k, ce in self._filecache.items(): |
|
1563 | 1571 | if k == 'dirstate' or k not in self.__dict__: |
|
1564 | 1572 | continue |
|
1565 | 1573 | ce.refresh() |
|
1566 | 1574 | |
|
1567 | 1575 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, |
|
1568 | 1576 | inheritchecker=None, parentenvvar=None): |
|
1569 | 1577 | parentlock = None |
|
1570 | 1578 | # the contents of parentenvvar are used by the underlying lock to |
|
1571 | 1579 | # determine whether it can be inherited |
|
1572 | 1580 | if parentenvvar is not None: |
|
1573 | 1581 | parentlock = encoding.environ.get(parentenvvar) |
|
1574 | 1582 | try: |
|
1575 | 1583 | l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, |
|
1576 | 1584 | acquirefn=acquirefn, desc=desc, |
|
1577 | 1585 | inheritchecker=inheritchecker, |
|
1578 | 1586 | parentlock=parentlock) |
|
1579 | 1587 | except error.LockHeld as inst: |
|
1580 | 1588 | if not wait: |
|
1581 | 1589 | raise |
|
1582 | 1590 | # show more details for new-style locks |
|
1583 | 1591 | if ':' in inst.locker: |
|
1584 | 1592 | host, pid = inst.locker.split(":", 1) |
|
1585 | 1593 | self.ui.warn( |
|
1586 | 1594 | _("waiting for lock on %s held by process %r " |
|
1587 | 1595 | "on host %r\n") % (desc, pid, host)) |
|
1588 | 1596 | else: |
|
1589 | 1597 | self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
1590 | 1598 | (desc, inst.locker)) |
|
1591 | 1599 | # default to 600 seconds timeout |
|
1592 | 1600 | l = lockmod.lock(vfs, lockname, |
|
1593 | 1601 | int(self.ui.config("ui", "timeout")), |
|
1594 | 1602 | releasefn=releasefn, acquirefn=acquirefn, |
|
1595 | 1603 | desc=desc) |
|
1596 | 1604 | self.ui.warn(_("got lock after %s seconds\n") % l.delay) |
|
1597 | 1605 | return l |
|
1598 | 1606 | |
|
1599 | 1607 | def _afterlock(self, callback): |
|
1600 | 1608 | """add a callback to be run when the repository is fully unlocked |
|
1601 | 1609 | |
|
1602 | 1610 | The callback will be executed when the outermost lock is released |
|
1603 | 1611 | (with wlock being higher level than 'lock').""" |
|
1604 | 1612 | for ref in (self._wlockref, self._lockref): |
|
1605 | 1613 | l = ref and ref() |
|
1606 | 1614 | if l and l.held: |
|
1607 | 1615 | l.postrelease.append(callback) |
|
1608 | 1616 | break |
|
1609 | 1617 | else: # no lock have been found. |
|
1610 | 1618 | callback() |
|
1611 | 1619 | |
|
1612 | 1620 | def lock(self, wait=True): |
|
1613 | 1621 | '''Lock the repository store (.hg/store) and return a weak reference |
|
1614 | 1622 | to the lock. Use this before modifying the store (e.g. committing or |
|
1615 | 1623 | stripping). If you are opening a transaction, get a lock as well.) |
|
1616 | 1624 | |
|
1617 | 1625 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1618 | 1626 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1619 | 1627 | l = self._currentlock(self._lockref) |
|
1620 | 1628 | if l is not None: |
|
1621 | 1629 | l.lock() |
|
1622 | 1630 | return l |
|
1623 | 1631 | |
|
1624 | 1632 | l = self._lock(self.svfs, "lock", wait, None, |
|
1625 | 1633 | self.invalidate, _('repository %s') % self.origroot) |
|
1626 | 1634 | self._lockref = weakref.ref(l) |
|
1627 | 1635 | return l |
|
1628 | 1636 | |
|
1629 | 1637 | def _wlockchecktransaction(self): |
|
1630 | 1638 | if self.currenttransaction() is not None: |
|
1631 | 1639 | raise error.LockInheritanceContractViolation( |
|
1632 | 1640 | 'wlock cannot be inherited in the middle of a transaction') |
|
1633 | 1641 | |
|
1634 | 1642 | def wlock(self, wait=True): |
|
1635 | 1643 | '''Lock the non-store parts of the repository (everything under |
|
1636 | 1644 | .hg except .hg/store) and return a weak reference to the lock. |
|
1637 | 1645 | |
|
1638 | 1646 | Use this before modifying files in .hg. |
|
1639 | 1647 | |
|
1640 | 1648 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
1641 | 1649 | 'wlock' first to avoid a dead-lock hazard.''' |
|
1642 | 1650 | l = self._wlockref and self._wlockref() |
|
1643 | 1651 | if l is not None and l.held: |
|
1644 | 1652 | l.lock() |
|
1645 | 1653 | return l |
|
1646 | 1654 | |
|
1647 | 1655 | # We do not need to check for non-waiting lock acquisition. Such |
|
1648 | 1656 | # acquisition would not cause dead-lock as they would just fail. |
|
1649 | 1657 | if wait and (self.ui.configbool('devel', 'all-warnings') |
|
1650 | 1658 | or self.ui.configbool('devel', 'check-locks')): |
|
1651 | 1659 | if self._currentlock(self._lockref) is not None: |
|
1652 | 1660 | self.ui.develwarn('"wlock" acquired after "lock"') |
|
1653 | 1661 | |
|
1654 | 1662 | def unlock(): |
|
1655 | 1663 | if self.dirstate.pendingparentchange(): |
|
1656 | 1664 | self.dirstate.invalidate() |
|
1657 | 1665 | else: |
|
1658 | 1666 | self.dirstate.write(None) |
|
1659 | 1667 | |
|
1660 | 1668 | self._filecache['dirstate'].refresh() |
|
1661 | 1669 | |
|
1662 | 1670 | l = self._lock(self.vfs, "wlock", wait, unlock, |
|
1663 | 1671 | self.invalidatedirstate, _('working directory of %s') % |
|
1664 | 1672 | self.origroot, |
|
1665 | 1673 | inheritchecker=self._wlockchecktransaction, |
|
1666 | 1674 | parentenvvar='HG_WLOCK_LOCKER') |
|
1667 | 1675 | self._wlockref = weakref.ref(l) |
|
1668 | 1676 | return l |
|
1669 | 1677 | |
|
1670 | 1678 | def _currentlock(self, lockref): |
|
1671 | 1679 | """Returns the lock if it's held, or None if it's not.""" |
|
1672 | 1680 | if lockref is None: |
|
1673 | 1681 | return None |
|
1674 | 1682 | l = lockref() |
|
1675 | 1683 | if l is None or not l.held: |
|
1676 | 1684 | return None |
|
1677 | 1685 | return l |
|
1678 | 1686 | |
|
1679 | 1687 | def currentwlock(self): |
|
1680 | 1688 | """Returns the wlock if it's held, or None if it's not.""" |
|
1681 | 1689 | return self._currentlock(self._wlockref) |
|
1682 | 1690 | |
|
1683 | 1691 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
|
1684 | 1692 | """ |
|
1685 | 1693 | commit an individual file as part of a larger transaction |
|
1686 | 1694 | """ |
|
1687 | 1695 | |
|
1688 | 1696 | fname = fctx.path() |
|
1689 | 1697 | fparent1 = manifest1.get(fname, nullid) |
|
1690 | 1698 | fparent2 = manifest2.get(fname, nullid) |
|
1691 | 1699 | if isinstance(fctx, context.filectx): |
|
1692 | 1700 | node = fctx.filenode() |
|
1693 | 1701 | if node in [fparent1, fparent2]: |
|
1694 | 1702 | self.ui.debug('reusing %s filelog entry\n' % fname) |
|
1695 | 1703 | if manifest1.flags(fname) != fctx.flags(): |
|
1696 | 1704 | changelist.append(fname) |
|
1697 | 1705 | return node |
|
1698 | 1706 | |
|
1699 | 1707 | flog = self.file(fname) |
|
1700 | 1708 | meta = {} |
|
1701 | 1709 | copy = fctx.renamed() |
|
1702 | 1710 | if copy and copy[0] != fname: |
|
1703 | 1711 | # Mark the new revision of this file as a copy of another |
|
1704 | 1712 | # file. This copy data will effectively act as a parent |
|
1705 | 1713 | # of this new revision. If this is a merge, the first |
|
1706 | 1714 | # parent will be the nullid (meaning "look up the copy data") |
|
1707 | 1715 | # and the second one will be the other parent. For example: |
|
1708 | 1716 | # |
|
1709 | 1717 | # 0 --- 1 --- 3 rev1 changes file foo |
|
1710 | 1718 | # \ / rev2 renames foo to bar and changes it |
|
1711 | 1719 | # \- 2 -/ rev3 should have bar with all changes and |
|
1712 | 1720 | # should record that bar descends from |
|
1713 | 1721 | # bar in rev2 and foo in rev1 |
|
1714 | 1722 | # |
|
1715 | 1723 | # this allows this merge to succeed: |
|
1716 | 1724 | # |
|
1717 | 1725 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
1718 | 1726 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
1719 | 1727 | # \- 2 --- 4 as the merge base |
|
1720 | 1728 | # |
|
1721 | 1729 | |
|
1722 | 1730 | cfname = copy[0] |
|
1723 | 1731 | crev = manifest1.get(cfname) |
|
1724 | 1732 | newfparent = fparent2 |
|
1725 | 1733 | |
|
1726 | 1734 | if manifest2: # branch merge |
|
1727 | 1735 | if fparent2 == nullid or crev is None: # copied on remote side |
|
1728 | 1736 | if cfname in manifest2: |
|
1729 | 1737 | crev = manifest2[cfname] |
|
1730 | 1738 | newfparent = fparent1 |
|
1731 | 1739 | |
|
1732 | 1740 | # Here, we used to search backwards through history to try to find |
|
1733 | 1741 | # where the file copy came from if the source of a copy was not in |
|
1734 | 1742 | # the parent directory. However, this doesn't actually make sense to |
|
1735 | 1743 | # do (what does a copy from something not in your working copy even |
|
1736 | 1744 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn |
|
1737 | 1745 | # the user that copy information was dropped, so if they didn't |
|
1738 | 1746 | # expect this outcome it can be fixed, but this is the correct |
|
1739 | 1747 | # behavior in this circumstance. |
|
1740 | 1748 | |
|
1741 | 1749 | if crev: |
|
1742 | 1750 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) |
|
1743 | 1751 | meta["copy"] = cfname |
|
1744 | 1752 | meta["copyrev"] = hex(crev) |
|
1745 | 1753 | fparent1, fparent2 = nullid, newfparent |
|
1746 | 1754 | else: |
|
1747 | 1755 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
1748 | 1756 | "copied from '%s'!\n") % (fname, cfname)) |
|
1749 | 1757 | |
|
1750 | 1758 | elif fparent1 == nullid: |
|
1751 | 1759 | fparent1, fparent2 = fparent2, nullid |
|
1752 | 1760 | elif fparent2 != nullid: |
|
1753 | 1761 | # is one parent an ancestor of the other? |
|
1754 | 1762 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) |
|
1755 | 1763 | if fparent1 in fparentancestors: |
|
1756 | 1764 | fparent1, fparent2 = fparent2, nullid |
|
1757 | 1765 | elif fparent2 in fparentancestors: |
|
1758 | 1766 | fparent2 = nullid |
|
1759 | 1767 | |
|
1760 | 1768 | # is the file changed? |
|
1761 | 1769 | text = fctx.data() |
|
1762 | 1770 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
1763 | 1771 | changelist.append(fname) |
|
1764 | 1772 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
1765 | 1773 | # are just the flags changed during merge? |
|
1766 | 1774 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
|
1767 | 1775 | changelist.append(fname) |
|
1768 | 1776 | |
|
1769 | 1777 | return fparent1 |
|
1770 | 1778 | |
|
1771 | 1779 | def checkcommitpatterns(self, wctx, vdirs, match, status, fail): |
|
1772 | 1780 | """check for commit arguments that aren't committable""" |
|
1773 | 1781 | if match.isexact() or match.prefix(): |
|
1774 | 1782 | matched = set(status.modified + status.added + status.removed) |
|
1775 | 1783 | |
|
1776 | 1784 | for f in match.files(): |
|
1777 | 1785 | f = self.dirstate.normalize(f) |
|
1778 | 1786 | if f == '.' or f in matched or f in wctx.substate: |
|
1779 | 1787 | continue |
|
1780 | 1788 | if f in status.deleted: |
|
1781 | 1789 | fail(f, _('file not found!')) |
|
1782 | 1790 | if f in vdirs: # visited directory |
|
1783 | 1791 | d = f + '/' |
|
1784 | 1792 | for mf in matched: |
|
1785 | 1793 | if mf.startswith(d): |
|
1786 | 1794 | break |
|
1787 | 1795 | else: |
|
1788 | 1796 | fail(f, _("no match under directory!")) |
|
1789 | 1797 | elif f not in self.dirstate: |
|
1790 | 1798 | fail(f, _("file not tracked!")) |
|
1791 | 1799 | |
|
1792 | 1800 | @unfilteredmethod |
|
1793 | 1801 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
1794 | 1802 | editor=False, extra=None): |
|
1795 | 1803 | """Add a new revision to current repository. |
|
1796 | 1804 | |
|
1797 | 1805 | Revision information is gathered from the working directory, |
|
1798 | 1806 | match can be used to filter the committed files. If editor is |
|
1799 | 1807 | supplied, it is called to get a commit message. |
|
1800 | 1808 | """ |
|
1801 | 1809 | if extra is None: |
|
1802 | 1810 | extra = {} |
|
1803 | 1811 | |
|
1804 | 1812 | def fail(f, msg): |
|
1805 | 1813 | raise error.Abort('%s: %s' % (f, msg)) |
|
1806 | 1814 | |
|
1807 | 1815 | if not match: |
|
1808 | 1816 | match = matchmod.always(self.root, '') |
|
1809 | 1817 | |
|
1810 | 1818 | if not force: |
|
1811 | 1819 | vdirs = [] |
|
1812 | 1820 | match.explicitdir = vdirs.append |
|
1813 | 1821 | match.bad = fail |
|
1814 | 1822 | |
|
1815 | 1823 | wlock = lock = tr = None |
|
1816 | 1824 | try: |
|
1817 | 1825 | wlock = self.wlock() |
|
1818 | 1826 | lock = self.lock() # for recent changelog (see issue4368) |
|
1819 | 1827 | |
|
1820 | 1828 | wctx = self[None] |
|
1821 | 1829 | merge = len(wctx.parents()) > 1 |
|
1822 | 1830 | |
|
1823 | 1831 | if not force and merge and not match.always(): |
|
1824 | 1832 | raise error.Abort(_('cannot partially commit a merge ' |
|
1825 | 1833 | '(do not specify files or patterns)')) |
|
1826 | 1834 | |
|
1827 | 1835 | status = self.status(match=match, clean=force) |
|
1828 | 1836 | if force: |
|
1829 | 1837 | status.modified.extend(status.clean) # mq may commit clean files |
|
1830 | 1838 | |
|
1831 | 1839 | # check subrepos |
|
1832 | 1840 | subs = [] |
|
1833 | 1841 | commitsubs = set() |
|
1834 | 1842 | newstate = wctx.substate.copy() |
|
1835 | 1843 | # only manage subrepos and .hgsubstate if .hgsub is present |
|
1836 | 1844 | if '.hgsub' in wctx: |
|
1837 | 1845 | # we'll decide whether to track this ourselves, thanks |
|
1838 | 1846 | for c in status.modified, status.added, status.removed: |
|
1839 | 1847 | if '.hgsubstate' in c: |
|
1840 | 1848 | c.remove('.hgsubstate') |
|
1841 | 1849 | |
|
1842 | 1850 | # compare current state to last committed state |
|
1843 | 1851 | # build new substate based on last committed state |
|
1844 | 1852 | oldstate = wctx.p1().substate |
|
1845 | 1853 | for s in sorted(newstate.keys()): |
|
1846 | 1854 | if not match(s): |
|
1847 | 1855 | # ignore working copy, use old state if present |
|
1848 | 1856 | if s in oldstate: |
|
1849 | 1857 | newstate[s] = oldstate[s] |
|
1850 | 1858 | continue |
|
1851 | 1859 | if not force: |
|
1852 | 1860 | raise error.Abort( |
|
1853 | 1861 | _("commit with new subrepo %s excluded") % s) |
|
1854 | 1862 | dirtyreason = wctx.sub(s).dirtyreason(True) |
|
1855 | 1863 | if dirtyreason: |
|
1856 | 1864 | if not self.ui.configbool('ui', 'commitsubrepos'): |
|
1857 | 1865 | raise error.Abort(dirtyreason, |
|
1858 | 1866 | hint=_("use --subrepos for recursive commit")) |
|
1859 | 1867 | subs.append(s) |
|
1860 | 1868 | commitsubs.add(s) |
|
1861 | 1869 | else: |
|
1862 | 1870 | bs = wctx.sub(s).basestate() |
|
1863 | 1871 | newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
|
1864 | 1872 | if oldstate.get(s, (None, None, None))[1] != bs: |
|
1865 | 1873 | subs.append(s) |
|
1866 | 1874 | |
|
1867 | 1875 | # check for removed subrepos |
|
1868 | 1876 | for p in wctx.parents(): |
|
1869 | 1877 | r = [s for s in p.substate if s not in newstate] |
|
1870 | 1878 | subs += [s for s in r if match(s)] |
|
1871 | 1879 | if subs: |
|
1872 | 1880 | if (not match('.hgsub') and |
|
1873 | 1881 | '.hgsub' in (wctx.modified() + wctx.added())): |
|
1874 | 1882 | raise error.Abort( |
|
1875 | 1883 | _("can't commit subrepos without .hgsub")) |
|
1876 | 1884 | status.modified.insert(0, '.hgsubstate') |
|
1877 | 1885 | |
|
1878 | 1886 | elif '.hgsub' in status.removed: |
|
1879 | 1887 | # clean up .hgsubstate when .hgsub is removed |
|
1880 | 1888 | if ('.hgsubstate' in wctx and |
|
1881 | 1889 | '.hgsubstate' not in (status.modified + status.added + |
|
1882 | 1890 | status.removed)): |
|
1883 | 1891 | status.removed.insert(0, '.hgsubstate') |
|
1884 | 1892 | |
|
1885 | 1893 | # make sure all explicit patterns are matched |
|
1886 | 1894 | if not force: |
|
1887 | 1895 | self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
|
1888 | 1896 | |
|
1889 | 1897 | cctx = context.workingcommitctx(self, status, |
|
1890 | 1898 | text, user, date, extra) |
|
1891 | 1899 | |
|
1892 | 1900 | # internal config: ui.allowemptycommit |
|
1893 | 1901 | allowemptycommit = (wctx.branch() != wctx.p1().branch() |
|
1894 | 1902 | or extra.get('close') or merge or cctx.files() |
|
1895 | 1903 | or self.ui.configbool('ui', 'allowemptycommit')) |
|
1896 | 1904 | if not allowemptycommit: |
|
1897 | 1905 | return None |
|
1898 | 1906 | |
|
1899 | 1907 | if merge and cctx.deleted(): |
|
1900 | 1908 | raise error.Abort(_("cannot commit merge with missing files")) |
|
1901 | 1909 | |
|
1902 | 1910 | ms = mergemod.mergestate.read(self) |
|
1903 | 1911 | mergeutil.checkunresolved(ms) |
|
1904 | 1912 | |
|
1905 | 1913 | if editor: |
|
1906 | 1914 | cctx._text = editor(self, cctx, subs) |
|
1907 | 1915 | edited = (text != cctx._text) |
|
1908 | 1916 | |
|
1909 | 1917 | # Save commit message in case this transaction gets rolled back |
|
1910 | 1918 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
1911 | 1919 | # the assumption that the user will use the same editor again. |
|
1912 | 1920 | msgfn = self.savecommitmessage(cctx._text) |
|
1913 | 1921 | |
|
1914 | 1922 | # commit subs and write new state |
|
1915 | 1923 | if subs: |
|
1916 | 1924 | for s in sorted(commitsubs): |
|
1917 | 1925 | sub = wctx.sub(s) |
|
1918 | 1926 | self.ui.status(_('committing subrepository %s\n') % |
|
1919 | 1927 | subrepo.subrelpath(sub)) |
|
1920 | 1928 | sr = sub.commit(cctx._text, user, date) |
|
1921 | 1929 | newstate[s] = (newstate[s][0], sr) |
|
1922 | 1930 | subrepo.writestate(self, newstate) |
|
1923 | 1931 | |
|
1924 | 1932 | p1, p2 = self.dirstate.parents() |
|
1925 | 1933 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1926 | 1934 | try: |
|
1927 | 1935 | self.hook("precommit", throw=True, parent1=hookp1, |
|
1928 | 1936 | parent2=hookp2) |
|
1929 | 1937 | tr = self.transaction('commit') |
|
1930 | 1938 | ret = self.commitctx(cctx, True) |
|
1931 | 1939 | except: # re-raises |
|
1932 | 1940 | if edited: |
|
1933 | 1941 | self.ui.write( |
|
1934 | 1942 | _('note: commit message saved in %s\n') % msgfn) |
|
1935 | 1943 | raise |
|
1936 | 1944 | # update bookmarks, dirstate and mergestate |
|
1937 | 1945 | bookmarks.update(self, [p1, p2], ret) |
|
1938 | 1946 | cctx.markcommitted(ret) |
|
1939 | 1947 | ms.reset() |
|
1940 | 1948 | tr.close() |
|
1941 | 1949 | |
|
1942 | 1950 | finally: |
|
1943 | 1951 | lockmod.release(tr, lock, wlock) |
|
1944 | 1952 | |
|
1945 | 1953 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
|
1946 | 1954 | # hack for command that use a temporary commit (eg: histedit) |
|
1947 | 1955 | # temporary commit got stripped before hook release |
|
1948 | 1956 | if self.changelog.hasnode(ret): |
|
1949 | 1957 | self.hook("commit", node=node, parent1=parent1, |
|
1950 | 1958 | parent2=parent2) |
|
1951 | 1959 | self._afterlock(commithook) |
|
1952 | 1960 | return ret |
|
1953 | 1961 | |
|
1954 | 1962 | @unfilteredmethod |
|
1955 | 1963 | def commitctx(self, ctx, error=False): |
|
1956 | 1964 | """Add a new revision to current repository. |
|
1957 | 1965 | Revision information is passed via the context argument. |
|
1958 | 1966 | """ |
|
1959 | 1967 | |
|
1960 | 1968 | tr = None |
|
1961 | 1969 | p1, p2 = ctx.p1(), ctx.p2() |
|
1962 | 1970 | user = ctx.user() |
|
1963 | 1971 | |
|
1964 | 1972 | lock = self.lock() |
|
1965 | 1973 | try: |
|
1966 | 1974 | tr = self.transaction("commit") |
|
1967 | 1975 | trp = weakref.proxy(tr) |
|
1968 | 1976 | |
|
1969 | 1977 | if ctx.manifestnode(): |
|
1970 | 1978 | # reuse an existing manifest revision |
|
1971 | 1979 | mn = ctx.manifestnode() |
|
1972 | 1980 | files = ctx.files() |
|
1973 | 1981 | elif ctx.files(): |
|
1974 | 1982 | m1ctx = p1.manifestctx() |
|
1975 | 1983 | m2ctx = p2.manifestctx() |
|
1976 | 1984 | mctx = m1ctx.copy() |
|
1977 | 1985 | |
|
1978 | 1986 | m = mctx.read() |
|
1979 | 1987 | m1 = m1ctx.read() |
|
1980 | 1988 | m2 = m2ctx.read() |
|
1981 | 1989 | |
|
1982 | 1990 | # check in files |
|
1983 | 1991 | added = [] |
|
1984 | 1992 | changed = [] |
|
1985 | 1993 | removed = list(ctx.removed()) |
|
1986 | 1994 | linkrev = len(self) |
|
1987 | 1995 | self.ui.note(_("committing files:\n")) |
|
1988 | 1996 | for f in sorted(ctx.modified() + ctx.added()): |
|
1989 | 1997 | self.ui.note(f + "\n") |
|
1990 | 1998 | try: |
|
1991 | 1999 | fctx = ctx[f] |
|
1992 | 2000 | if fctx is None: |
|
1993 | 2001 | removed.append(f) |
|
1994 | 2002 | else: |
|
1995 | 2003 | added.append(f) |
|
1996 | 2004 | m[f] = self._filecommit(fctx, m1, m2, linkrev, |
|
1997 | 2005 | trp, changed) |
|
1998 | 2006 | m.setflag(f, fctx.flags()) |
|
1999 | 2007 | except OSError as inst: |
|
2000 | 2008 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
2001 | 2009 | raise |
|
2002 | 2010 | except IOError as inst: |
|
2003 | 2011 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
2004 | 2012 | if error or errcode and errcode != errno.ENOENT: |
|
2005 | 2013 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
2006 | 2014 | raise |
|
2007 | 2015 | |
|
2008 | 2016 | # update manifest |
|
2009 | 2017 | self.ui.note(_("committing manifest\n")) |
|
2010 | 2018 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
2011 | 2019 | drop = [f for f in removed if f in m] |
|
2012 | 2020 | for f in drop: |
|
2013 | 2021 | del m[f] |
|
2014 | 2022 | mn = mctx.write(trp, linkrev, |
|
2015 | 2023 | p1.manifestnode(), p2.manifestnode(), |
|
2016 | 2024 | added, drop) |
|
2017 | 2025 | files = changed + removed |
|
2018 | 2026 | else: |
|
2019 | 2027 | mn = p1.manifestnode() |
|
2020 | 2028 | files = [] |
|
2021 | 2029 | |
|
2022 | 2030 | # update changelog |
|
2023 | 2031 | self.ui.note(_("committing changelog\n")) |
|
2024 | 2032 | self.changelog.delayupdate(tr) |
|
2025 | 2033 | n = self.changelog.add(mn, files, ctx.description(), |
|
2026 | 2034 | trp, p1.node(), p2.node(), |
|
2027 | 2035 | user, ctx.date(), ctx.extra().copy()) |
|
2028 | 2036 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
2029 | 2037 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
2030 | 2038 | parent2=xp2) |
|
2031 | 2039 | # set the new commit is proper phase |
|
2032 | 2040 | targetphase = subrepo.newcommitphase(self.ui, ctx) |
|
2033 | 2041 | if targetphase: |
|
2034 | 2042 | # retract boundary do not alter parent changeset. |
|
2035 | 2043 | # if a parent have higher the resulting phase will |
|
2036 | 2044 | # be compliant anyway |
|
2037 | 2045 | # |
|
2038 | 2046 | # if minimal phase was 0 we don't need to retract anything |
|
2039 | 2047 | phases.registernew(self, tr, targetphase, [n]) |
|
2040 | 2048 | tr.close() |
|
2041 | 2049 | return n |
|
2042 | 2050 | finally: |
|
2043 | 2051 | if tr: |
|
2044 | 2052 | tr.release() |
|
2045 | 2053 | lock.release() |
|
2046 | 2054 | |
|
2047 | 2055 | @unfilteredmethod |
|
2048 | 2056 | def destroying(self): |
|
2049 | 2057 | '''Inform the repository that nodes are about to be destroyed. |
|
2050 | 2058 | Intended for use by strip and rollback, so there's a common |
|
2051 | 2059 | place for anything that has to be done before destroying history. |
|
2052 | 2060 | |
|
2053 | 2061 | This is mostly useful for saving state that is in memory and waiting |
|
2054 | 2062 | to be flushed when the current lock is released. Because a call to |
|
2055 | 2063 | destroyed is imminent, the repo will be invalidated causing those |
|
2056 | 2064 | changes to stay in memory (waiting for the next unlock), or vanish |
|
2057 | 2065 | completely. |
|
2058 | 2066 | ''' |
|
2059 | 2067 | # When using the same lock to commit and strip, the phasecache is left |
|
2060 | 2068 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
2061 | 2069 | # causing those changes to disappear. |
|
2062 | 2070 | if '_phasecache' in vars(self): |
|
2063 | 2071 | self._phasecache.write() |
|
2064 | 2072 | |
|
2065 | 2073 | @unfilteredmethod |
|
2066 | 2074 | def destroyed(self): |
|
2067 | 2075 | '''Inform the repository that nodes have been destroyed. |
|
2068 | 2076 | Intended for use by strip and rollback, so there's a common |
|
2069 | 2077 | place for anything that has to be done after destroying history. |
|
2070 | 2078 | ''' |
|
2071 | 2079 | # When one tries to: |
|
2072 | 2080 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
2073 | 2081 | # 2) use phasecache somewhere (e.g. commit) |
|
2074 | 2082 | # |
|
2075 | 2083 | # then 2) will fail because the phasecache contains nodes that were |
|
2076 | 2084 | # removed. We can either remove phasecache from the filecache, |
|
2077 | 2085 | # causing it to reload next time it is accessed, or simply filter |
|
2078 | 2086 | # the removed nodes now and write the updated cache. |
|
2079 | 2087 | self._phasecache.filterunknown(self) |
|
2080 | 2088 | self._phasecache.write() |
|
2081 | 2089 | |
|
2082 | 2090 | # refresh all repository caches |
|
2083 | 2091 | self.updatecaches() |
|
2084 | 2092 | |
|
2085 | 2093 | # Ensure the persistent tag cache is updated. Doing it now |
|
2086 | 2094 | # means that the tag cache only has to worry about destroyed |
|
2087 | 2095 | # heads immediately after a strip/rollback. That in turn |
|
2088 | 2096 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
2089 | 2097 | # and node) always means no nodes have been added or destroyed. |
|
2090 | 2098 | |
|
2091 | 2099 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
2092 | 2100 | # head, refresh the tag cache, then immediately add a new head. |
|
2093 | 2101 | # But I think doing it this way is necessary for the "instant |
|
2094 | 2102 | # tag cache retrieval" case to work. |
|
2095 | 2103 | self.invalidate() |
|
2096 | 2104 | |
|
2097 | 2105 | def walk(self, match, node=None): |
|
2098 | 2106 | ''' |
|
2099 | 2107 | walk recursively through the directory tree or a given |
|
2100 | 2108 | changeset, finding all files matched by the match |
|
2101 | 2109 | function |
|
2102 | 2110 | ''' |
|
2103 | 2111 | self.ui.deprecwarn('use repo[node].walk instead of repo.walk', '4.3') |
|
2104 | 2112 | return self[node].walk(match) |
|
2105 | 2113 | |
|
2106 | 2114 | def status(self, node1='.', node2=None, match=None, |
|
2107 | 2115 | ignored=False, clean=False, unknown=False, |
|
2108 | 2116 | listsubrepos=False): |
|
2109 | 2117 | '''a convenience method that calls node1.status(node2)''' |
|
2110 | 2118 | return self[node1].status(node2, match, ignored, clean, unknown, |
|
2111 | 2119 | listsubrepos) |
|
2112 | 2120 | |
|
2113 | 2121 | def addpostdsstatus(self, ps): |
|
2114 | 2122 | """Add a callback to run within the wlock, at the point at which status |
|
2115 | 2123 | fixups happen. |
|
2116 | 2124 | |
|
2117 | 2125 | On status completion, callback(wctx, status) will be called with the |
|
2118 | 2126 | wlock held, unless the dirstate has changed from underneath or the wlock |
|
2119 | 2127 | couldn't be grabbed. |
|
2120 | 2128 | |
|
2121 | 2129 | Callbacks should not capture and use a cached copy of the dirstate -- |
|
2122 | 2130 | it might change in the meanwhile. Instead, they should access the |
|
2123 | 2131 | dirstate via wctx.repo().dirstate. |
|
2124 | 2132 | |
|
2125 | 2133 | This list is emptied out after each status run -- extensions should |
|
2126 | 2134 | make sure it adds to this list each time dirstate.status is called. |
|
2127 | 2135 | Extensions should also make sure they don't call this for statuses |
|
2128 | 2136 | that don't involve the dirstate. |
|
2129 | 2137 | """ |
|
2130 | 2138 | |
|
2131 | 2139 | # The list is located here for uniqueness reasons -- it is actually |
|
2132 | 2140 | # managed by the workingctx, but that isn't unique per-repo. |
|
2133 | 2141 | self._postdsstatus.append(ps) |
|
2134 | 2142 | |
|
2135 | 2143 | def postdsstatus(self): |
|
2136 | 2144 | """Used by workingctx to get the list of post-dirstate-status hooks.""" |
|
2137 | 2145 | return self._postdsstatus |
|
2138 | 2146 | |
|
2139 | 2147 | def clearpostdsstatus(self): |
|
2140 | 2148 | """Used by workingctx to clear post-dirstate-status hooks.""" |
|
2141 | 2149 | del self._postdsstatus[:] |
|
2142 | 2150 | |
|
2143 | 2151 | def heads(self, start=None): |
|
2144 | 2152 | if start is None: |
|
2145 | 2153 | cl = self.changelog |
|
2146 | 2154 | headrevs = reversed(cl.headrevs()) |
|
2147 | 2155 | return [cl.node(rev) for rev in headrevs] |
|
2148 | 2156 | |
|
2149 | 2157 | heads = self.changelog.heads(start) |
|
2150 | 2158 | # sort the output in rev descending order |
|
2151 | 2159 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
2152 | 2160 | |
|
2153 | 2161 | def branchheads(self, branch=None, start=None, closed=False): |
|
2154 | 2162 | '''return a (possibly filtered) list of heads for the given branch |
|
2155 | 2163 | |
|
2156 | 2164 | Heads are returned in topological order, from newest to oldest. |
|
2157 | 2165 | If branch is None, use the dirstate branch. |
|
2158 | 2166 | If start is not None, return only heads reachable from start. |
|
2159 | 2167 | If closed is True, return heads that are marked as closed as well. |
|
2160 | 2168 | ''' |
|
2161 | 2169 | if branch is None: |
|
2162 | 2170 | branch = self[None].branch() |
|
2163 | 2171 | branches = self.branchmap() |
|
2164 | 2172 | if branch not in branches: |
|
2165 | 2173 | return [] |
|
2166 | 2174 | # the cache returns heads ordered lowest to highest |
|
2167 | 2175 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
2168 | 2176 | if start is not None: |
|
2169 | 2177 | # filter out the heads that cannot be reached from startrev |
|
2170 | 2178 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
2171 | 2179 | bheads = [h for h in bheads if h in fbheads] |
|
2172 | 2180 | return bheads |
|
2173 | 2181 | |
|
2174 | 2182 | def branches(self, nodes): |
|
2175 | 2183 | if not nodes: |
|
2176 | 2184 | nodes = [self.changelog.tip()] |
|
2177 | 2185 | b = [] |
|
2178 | 2186 | for n in nodes: |
|
2179 | 2187 | t = n |
|
2180 | 2188 | while True: |
|
2181 | 2189 | p = self.changelog.parents(n) |
|
2182 | 2190 | if p[1] != nullid or p[0] == nullid: |
|
2183 | 2191 | b.append((t, n, p[0], p[1])) |
|
2184 | 2192 | break |
|
2185 | 2193 | n = p[0] |
|
2186 | 2194 | return b |
|
2187 | 2195 | |
|
2188 | 2196 | def between(self, pairs): |
|
2189 | 2197 | r = [] |
|
2190 | 2198 | |
|
2191 | 2199 | for top, bottom in pairs: |
|
2192 | 2200 | n, l, i = top, [], 0 |
|
2193 | 2201 | f = 1 |
|
2194 | 2202 | |
|
2195 | 2203 | while n != bottom and n != nullid: |
|
2196 | 2204 | p = self.changelog.parents(n)[0] |
|
2197 | 2205 | if i == f: |
|
2198 | 2206 | l.append(n) |
|
2199 | 2207 | f = f * 2 |
|
2200 | 2208 | n = p |
|
2201 | 2209 | i += 1 |
|
2202 | 2210 | |
|
2203 | 2211 | r.append(l) |
|
2204 | 2212 | |
|
2205 | 2213 | return r |
|
2206 | 2214 | |
|
2207 | 2215 | def checkpush(self, pushop): |
|
2208 | 2216 | """Extensions can override this function if additional checks have |
|
2209 | 2217 | to be performed before pushing, or call it if they override push |
|
2210 | 2218 | command. |
|
2211 | 2219 | """ |
|
2212 | 2220 | |
|
2213 | 2221 | @unfilteredpropertycache |
|
2214 | 2222 | def prepushoutgoinghooks(self): |
|
2215 | 2223 | """Return util.hooks consists of a pushop with repo, remote, outgoing |
|
2216 | 2224 | methods, which are called before pushing changesets. |
|
2217 | 2225 | """ |
|
2218 | 2226 | return util.hooks() |
|
2219 | 2227 | |
|
2220 | 2228 | def pushkey(self, namespace, key, old, new): |
|
2221 | 2229 | try: |
|
2222 | 2230 | tr = self.currenttransaction() |
|
2223 | 2231 | hookargs = {} |
|
2224 | 2232 | if tr is not None: |
|
2225 | 2233 | hookargs.update(tr.hookargs) |
|
2226 | 2234 | hookargs['namespace'] = namespace |
|
2227 | 2235 | hookargs['key'] = key |
|
2228 | 2236 | hookargs['old'] = old |
|
2229 | 2237 | hookargs['new'] = new |
|
2230 | 2238 | self.hook('prepushkey', throw=True, **hookargs) |
|
2231 | 2239 | except error.HookAbort as exc: |
|
2232 | 2240 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) |
|
2233 | 2241 | if exc.hint: |
|
2234 | 2242 | self.ui.write_err(_("(%s)\n") % exc.hint) |
|
2235 | 2243 | return False |
|
2236 | 2244 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) |
|
2237 | 2245 | ret = pushkey.push(self, namespace, key, old, new) |
|
2238 | 2246 | def runhook(): |
|
2239 | 2247 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
2240 | 2248 | ret=ret) |
|
2241 | 2249 | self._afterlock(runhook) |
|
2242 | 2250 | return ret |
|
2243 | 2251 | |
|
2244 | 2252 | def listkeys(self, namespace): |
|
2245 | 2253 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
2246 | 2254 | self.ui.debug('listing keys for "%s"\n' % namespace) |
|
2247 | 2255 | values = pushkey.list(self, namespace) |
|
2248 | 2256 | self.hook('listkeys', namespace=namespace, values=values) |
|
2249 | 2257 | return values |
|
2250 | 2258 | |
|
2251 | 2259 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
2252 | 2260 | '''used to test argument passing over the wire''' |
|
2253 | 2261 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
2254 | 2262 | |
|
2255 | 2263 | def savecommitmessage(self, text): |
|
2256 | 2264 | fp = self.vfs('last-message.txt', 'wb') |
|
2257 | 2265 | try: |
|
2258 | 2266 | fp.write(text) |
|
2259 | 2267 | finally: |
|
2260 | 2268 | fp.close() |
|
2261 | 2269 | return self.pathto(fp.name[len(self.root) + 1:]) |
|
2262 | 2270 | |
|
2263 | 2271 | # used to avoid circular references so destructors work |
|
2264 | 2272 | def aftertrans(files): |
|
2265 | 2273 | renamefiles = [tuple(t) for t in files] |
|
2266 | 2274 | def a(): |
|
2267 | 2275 | for vfs, src, dest in renamefiles: |
|
2268 | 2276 | # if src and dest refer to a same file, vfs.rename is a no-op, |
|
2269 | 2277 | # leaving both src and dest on disk. delete dest to make sure |
|
2270 | 2278 | # the rename couldn't be such a no-op. |
|
2271 | 2279 | vfs.tryunlink(dest) |
|
2272 | 2280 | try: |
|
2273 | 2281 | vfs.rename(src, dest) |
|
2274 | 2282 | except OSError: # journal file does not yet exist |
|
2275 | 2283 | pass |
|
2276 | 2284 | return a |
|
2277 | 2285 | |
|
2278 | 2286 | def undoname(fn): |
|
2279 | 2287 | base, name = os.path.split(fn) |
|
2280 | 2288 | assert name.startswith('journal') |
|
2281 | 2289 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
2282 | 2290 | |
|
2283 | 2291 | def instance(ui, path, create): |
|
2284 | 2292 | return localrepository(ui, util.urllocalpath(path), create) |
|
2285 | 2293 | |
|
2286 | 2294 | def islocal(path): |
|
2287 | 2295 | return True |
|
2288 | 2296 | |
|
2289 | 2297 | def newreporequirements(repo): |
|
2290 | 2298 | """Determine the set of requirements for a new local repository. |
|
2291 | 2299 | |
|
2292 | 2300 | Extensions can wrap this function to specify custom requirements for |
|
2293 | 2301 | new repositories. |
|
2294 | 2302 | """ |
|
2295 | 2303 | ui = repo.ui |
|
2296 | 2304 | requirements = {'revlogv1'} |
|
2297 | 2305 | if ui.configbool('format', 'usestore'): |
|
2298 | 2306 | requirements.add('store') |
|
2299 | 2307 | if ui.configbool('format', 'usefncache'): |
|
2300 | 2308 | requirements.add('fncache') |
|
2301 | 2309 | if ui.configbool('format', 'dotencode'): |
|
2302 | 2310 | requirements.add('dotencode') |
|
2303 | 2311 | |
|
2304 | 2312 | compengine = ui.config('experimental', 'format.compression') |
|
2305 | 2313 | if compengine not in util.compengines: |
|
2306 | 2314 | raise error.Abort(_('compression engine %s defined by ' |
|
2307 | 2315 | 'experimental.format.compression not available') % |
|
2308 | 2316 | compengine, |
|
2309 | 2317 | hint=_('run "hg debuginstall" to list available ' |
|
2310 | 2318 | 'compression engines')) |
|
2311 | 2319 | |
|
2312 | 2320 | # zlib is the historical default and doesn't need an explicit requirement. |
|
2313 | 2321 | if compengine != 'zlib': |
|
2314 | 2322 | requirements.add('exp-compression-%s' % compengine) |
|
2315 | 2323 | |
|
2316 | 2324 | if scmutil.gdinitconfig(ui): |
|
2317 | 2325 | requirements.add('generaldelta') |
|
2318 | 2326 | if ui.configbool('experimental', 'treemanifest'): |
|
2319 | 2327 | requirements.add('treemanifest') |
|
2320 | 2328 | if ui.configbool('experimental', 'manifestv2'): |
|
2321 | 2329 | requirements.add('manifestv2') |
|
2322 | 2330 | |
|
2323 | 2331 | revlogv2 = ui.config('experimental', 'revlogv2') |
|
2324 | 2332 | if revlogv2 == 'enable-unstable-format-and-corrupt-my-data': |
|
2325 | 2333 | requirements.remove('revlogv1') |
|
2326 | 2334 | # generaldelta is implied by revlogv2. |
|
2327 | 2335 | requirements.discard('generaldelta') |
|
2328 | 2336 | requirements.add(REVLOGV2_REQUIREMENT) |
|
2329 | 2337 | |
|
2330 | 2338 | return requirements |
@@ -1,734 +1,825 | |||
|
1 | 1 | |
|
2 | 2 | $ cat >> $HGRCPATH << EOF |
|
3 | 3 | > [extensions] |
|
4 | 4 | > phasereport=$TESTDIR/testlib/ext-phase-report.py |
|
5 | 5 | > [hooks] |
|
6 | 6 | > txnclose-phase.test = echo "test-hook-close-phase: \$HG_NODE: \$HG_OLDPHASE -> \$HG_PHASE" |
|
7 | 7 | > EOF |
|
8 | 8 | |
|
9 | 9 | $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; } |
|
10 | 10 | $ mkcommit() { |
|
11 | 11 | > echo "$1" > "$1" |
|
12 | 12 | > hg add "$1" |
|
13 | 13 | > message="$1" |
|
14 | 14 | > shift |
|
15 | 15 | > hg ci -m "$message" $* |
|
16 | 16 | > } |
|
17 | 17 | |
|
18 | 18 | $ hg init initialrepo |
|
19 | 19 | $ cd initialrepo |
|
20 | 20 | |
|
21 | 21 | Cannot change null revision phase |
|
22 | 22 | |
|
23 | 23 | $ hg phase --force --secret null |
|
24 | 24 | abort: cannot change null revision phase |
|
25 | 25 | [255] |
|
26 | 26 | $ hg phase null |
|
27 | 27 | -1: public |
|
28 | 28 | |
|
29 | 29 | $ mkcommit A |
|
30 | 30 | test-debug-phase: new rev 0: x -> 1 |
|
31 | 31 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 1 |
|
32 | 32 | |
|
33 | 33 | New commit are draft by default |
|
34 | 34 | |
|
35 | 35 | $ hglog |
|
36 | 36 | 0 1 A |
|
37 | 37 | |
|
38 | 38 | Following commit are draft too |
|
39 | 39 | |
|
40 | 40 | $ mkcommit B |
|
41 | 41 | test-debug-phase: new rev 1: x -> 1 |
|
42 | 42 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 1 |
|
43 | 43 | |
|
44 | 44 | $ hglog |
|
45 | 45 | 1 1 B |
|
46 | 46 | 0 1 A |
|
47 | 47 | |
|
48 | 48 | Draft commit are properly created over public one: |
|
49 | 49 | |
|
50 | 50 | $ hg phase --public . |
|
51 | 51 | test-debug-phase: move rev 0: 1 -> 0 |
|
52 | 52 | test-debug-phase: move rev 1: 1 -> 0 |
|
53 | 53 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: 1 -> 0 |
|
54 | 54 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 1 -> 0 |
|
55 | 55 | $ hg phase |
|
56 | 56 | 1: public |
|
57 | 57 | $ hglog |
|
58 | 58 | 1 0 B |
|
59 | 59 | 0 0 A |
|
60 | 60 | |
|
61 | 61 | $ mkcommit C |
|
62 | 62 | test-debug-phase: new rev 2: x -> 1 |
|
63 | 63 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 1 |
|
64 | 64 | $ mkcommit D |
|
65 | 65 | test-debug-phase: new rev 3: x -> 1 |
|
66 | 66 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 1 |
|
67 | 67 | |
|
68 | 68 | $ hglog |
|
69 | 69 | 3 1 D |
|
70 | 70 | 2 1 C |
|
71 | 71 | 1 0 B |
|
72 | 72 | 0 0 A |
|
73 | 73 | |
|
74 | 74 | Test creating changeset as secret |
|
75 | 75 | |
|
76 | 76 | $ mkcommit E --config phases.new-commit='secret' |
|
77 | 77 | test-debug-phase: new rev 4: x -> 2 |
|
78 | 78 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> 2 |
|
79 | 79 | $ hglog |
|
80 | 80 | 4 2 E |
|
81 | 81 | 3 1 D |
|
82 | 82 | 2 1 C |
|
83 | 83 | 1 0 B |
|
84 | 84 | 0 0 A |
|
85 | 85 | |
|
86 | 86 | Test the secret property is inherited |
|
87 | 87 | |
|
88 | 88 | $ mkcommit H |
|
89 | 89 | test-debug-phase: new rev 5: x -> 2 |
|
90 | 90 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> 2 |
|
91 | 91 | $ hglog |
|
92 | 92 | 5 2 H |
|
93 | 93 | 4 2 E |
|
94 | 94 | 3 1 D |
|
95 | 95 | 2 1 C |
|
96 | 96 | 1 0 B |
|
97 | 97 | 0 0 A |
|
98 | 98 | |
|
99 | 99 | Even on merge |
|
100 | 100 | |
|
101 | 101 | $ hg up -q 1 |
|
102 | 102 | $ mkcommit "B'" |
|
103 | 103 | test-debug-phase: new rev 6: x -> 1 |
|
104 | 104 | created new head |
|
105 | 105 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 1 |
|
106 | 106 | $ hglog |
|
107 | 107 | 6 1 B' |
|
108 | 108 | 5 2 H |
|
109 | 109 | 4 2 E |
|
110 | 110 | 3 1 D |
|
111 | 111 | 2 1 C |
|
112 | 112 | 1 0 B |
|
113 | 113 | 0 0 A |
|
114 | 114 | $ hg merge 4 # E |
|
115 | 115 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
116 | 116 | (branch merge, don't forget to commit) |
|
117 | 117 | $ hg phase |
|
118 | 118 | 6: draft |
|
119 | 119 | 4: secret |
|
120 | 120 | $ hg ci -m "merge B' and E" |
|
121 | 121 | test-debug-phase: new rev 7: x -> 2 |
|
122 | 122 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> 2 |
|
123 | 123 | |
|
124 | 124 | $ hglog |
|
125 | 125 | 7 2 merge B' and E |
|
126 | 126 | 6 1 B' |
|
127 | 127 | 5 2 H |
|
128 | 128 | 4 2 E |
|
129 | 129 | 3 1 D |
|
130 | 130 | 2 1 C |
|
131 | 131 | 1 0 B |
|
132 | 132 | 0 0 A |
|
133 | 133 | |
|
134 | 134 | Test secret changeset are not pushed |
|
135 | 135 | |
|
136 | 136 | $ hg init ../push-dest |
|
137 | 137 | $ cat > ../push-dest/.hg/hgrc << EOF |
|
138 | 138 | > [phases] |
|
139 | 139 | > publish=False |
|
140 | 140 | > EOF |
|
141 | 141 | $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
142 | 142 | comparing with ../push-dest |
|
143 | 143 | searching for changes |
|
144 | 144 | 0 public A |
|
145 | 145 | 1 public B |
|
146 | 146 | 2 draft C |
|
147 | 147 | 3 draft D |
|
148 | 148 | 6 draft B' |
|
149 | 149 | $ hg outgoing -r 'branch(default)' ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
150 | 150 | comparing with ../push-dest |
|
151 | 151 | searching for changes |
|
152 | 152 | 0 public A |
|
153 | 153 | 1 public B |
|
154 | 154 | 2 draft C |
|
155 | 155 | 3 draft D |
|
156 | 156 | 6 draft B' |
|
157 | 157 | |
|
158 | 158 | $ hg push ../push-dest -f # force because we push multiple heads |
|
159 | 159 | pushing to ../push-dest |
|
160 | 160 | searching for changes |
|
161 | 161 | adding changesets |
|
162 | 162 | adding manifests |
|
163 | 163 | adding file changes |
|
164 | 164 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
165 | 165 | test-debug-phase: new rev 0: x -> 0 |
|
166 | 166 | test-debug-phase: new rev 1: x -> 0 |
|
167 | 167 | test-debug-phase: new rev 2: x -> 1 |
|
168 | 168 | test-debug-phase: new rev 3: x -> 1 |
|
169 | 169 | test-debug-phase: new rev 4: x -> 1 |
|
170 | 170 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0 |
|
171 | 171 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0 |
|
172 | 172 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 1 |
|
173 | 173 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 1 |
|
174 | 174 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 1 |
|
175 | 175 | $ hglog |
|
176 | 176 | 7 2 merge B' and E |
|
177 | 177 | 6 1 B' |
|
178 | 178 | 5 2 H |
|
179 | 179 | 4 2 E |
|
180 | 180 | 3 1 D |
|
181 | 181 | 2 1 C |
|
182 | 182 | 1 0 B |
|
183 | 183 | 0 0 A |
|
184 | 184 | $ cd ../push-dest |
|
185 | 185 | $ hglog |
|
186 | 186 | 4 1 B' |
|
187 | 187 | 3 1 D |
|
188 | 188 | 2 1 C |
|
189 | 189 | 1 0 B |
|
190 | 190 | 0 0 A |
|
191 | 191 | |
|
192 | 192 | (Issue3303) |
|
193 | 193 | Check that remote secret changeset are ignore when checking creation of remote heads |
|
194 | 194 | |
|
195 | 195 | We add a secret head into the push destination. This secret head shadows a |
|
196 | 196 | visible shared between the initial repo and the push destination. |
|
197 | 197 | |
|
198 | 198 | $ hg up -q 4 # B' |
|
199 | 199 | $ mkcommit Z --config phases.new-commit=secret |
|
200 | 200 | test-debug-phase: new rev 5: x -> 2 |
|
201 | 201 | test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a: -> 2 |
|
202 | 202 | $ hg phase . |
|
203 | 203 | 5: secret |
|
204 | 204 | |
|
205 | 205 | We now try to push a new public changeset that descend from the common public |
|
206 | 206 | head shadowed by the remote secret head. |
|
207 | 207 | |
|
208 | 208 | $ cd ../initialrepo |
|
209 | 209 | $ hg up -q 6 #B' |
|
210 | 210 | $ mkcommit I |
|
211 | 211 | test-debug-phase: new rev 8: x -> 1 |
|
212 | 212 | created new head |
|
213 | 213 | test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> 1 |
|
214 | 214 | $ hg push ../push-dest |
|
215 | 215 | pushing to ../push-dest |
|
216 | 216 | searching for changes |
|
217 | 217 | adding changesets |
|
218 | 218 | adding manifests |
|
219 | 219 | adding file changes |
|
220 | 220 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
221 | 221 | test-debug-phase: new rev 6: x -> 1 |
|
222 | 222 | test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> 1 |
|
223 | 223 | |
|
224 | 224 | :note: The "(+1 heads)" is wrong as we do not had any visible head |
|
225 | 225 | |
|
226 | 226 | check that branch cache with "served" filter are properly computed and stored |
|
227 | 227 | |
|
228 | 228 | $ ls ../push-dest/.hg/cache/branch2* |
|
229 | 229 | ../push-dest/.hg/cache/branch2-base |
|
230 | 230 | ../push-dest/.hg/cache/branch2-served |
|
231 | 231 | $ cat ../push-dest/.hg/cache/branch2-served |
|
232 | 232 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722 |
|
233 | 233 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
234 | 234 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
235 | 235 | $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n' #update visible cache too |
|
236 | 236 | 6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft |
|
237 | 237 | 5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret |
|
238 | 238 | 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft |
|
239 | 239 | $ ls ../push-dest/.hg/cache/branch2* |
|
240 | 240 | ../push-dest/.hg/cache/branch2-base |
|
241 | 241 | ../push-dest/.hg/cache/branch2-served |
|
242 | 242 | ../push-dest/.hg/cache/branch2-visible |
|
243 | 243 | $ cat ../push-dest/.hg/cache/branch2-served |
|
244 | 244 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722 |
|
245 | 245 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
246 | 246 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
247 | 247 | $ cat ../push-dest/.hg/cache/branch2-visible |
|
248 | 248 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 |
|
249 | 249 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
250 | 250 | 2713879da13d6eea1ff22b442a5a87cb31a7ce6a o default |
|
251 | 251 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
252 | 252 | |
|
253 | 253 | |
|
254 | 254 | Restore condition prior extra insertion. |
|
255 | 255 | $ hg -q --config extensions.mq= strip . |
|
256 | 256 | $ hg up -q 7 |
|
257 | 257 | $ cd .. |
|
258 | 258 | |
|
259 | 259 | Test secret changeset are not pull |
|
260 | 260 | |
|
261 | 261 | $ hg init pull-dest |
|
262 | 262 | $ cd pull-dest |
|
263 | 263 | $ hg pull ../initialrepo |
|
264 | 264 | pulling from ../initialrepo |
|
265 | 265 | requesting all changes |
|
266 | 266 | adding changesets |
|
267 | 267 | adding manifests |
|
268 | 268 | adding file changes |
|
269 | 269 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
270 | 270 | new changesets 4a2df7238c3b:cf9fe039dfd6 |
|
271 | 271 | test-debug-phase: new rev 0: x -> 0 |
|
272 | 272 | test-debug-phase: new rev 1: x -> 0 |
|
273 | 273 | test-debug-phase: new rev 2: x -> 0 |
|
274 | 274 | test-debug-phase: new rev 3: x -> 0 |
|
275 | 275 | test-debug-phase: new rev 4: x -> 0 |
|
276 | 276 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0 |
|
277 | 277 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0 |
|
278 | 278 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0 |
|
279 | 279 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0 |
|
280 | 280 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0 |
|
281 | 281 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
282 | 282 | $ hglog |
|
283 | 283 | 4 0 B' |
|
284 | 284 | 3 0 D |
|
285 | 285 | 2 0 C |
|
286 | 286 | 1 0 B |
|
287 | 287 | 0 0 A |
|
288 | 288 | $ cd .. |
|
289 | 289 | |
|
290 | 290 | But secret can still be bundled explicitly |
|
291 | 291 | |
|
292 | 292 | $ cd initialrepo |
|
293 | 293 | $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg |
|
294 | 294 | 4 changesets found |
|
295 | 295 | $ cd .. |
|
296 | 296 | |
|
297 | 297 | Test secret changeset are not cloned |
|
298 | 298 | (during local clone) |
|
299 | 299 | |
|
300 | 300 | $ hg clone -qU initialrepo clone-dest |
|
301 | 301 | test-debug-phase: new rev 0: x -> 0 |
|
302 | 302 | test-debug-phase: new rev 1: x -> 0 |
|
303 | 303 | test-debug-phase: new rev 2: x -> 0 |
|
304 | 304 | test-debug-phase: new rev 3: x -> 0 |
|
305 | 305 | test-debug-phase: new rev 4: x -> 0 |
|
306 | 306 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0 |
|
307 | 307 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0 |
|
308 | 308 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0 |
|
309 | 309 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0 |
|
310 | 310 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0 |
|
311 | 311 | $ hglog -R clone-dest |
|
312 | 312 | 4 0 B' |
|
313 | 313 | 3 0 D |
|
314 | 314 | 2 0 C |
|
315 | 315 | 1 0 B |
|
316 | 316 | 0 0 A |
|
317 | 317 | |
|
318 | 318 | Test summary |
|
319 | 319 | |
|
320 | 320 | $ hg summary -R clone-dest --verbose |
|
321 | 321 | parent: -1:000000000000 (no revision checked out) |
|
322 | 322 | branch: default |
|
323 | 323 | commit: (clean) |
|
324 | 324 | update: 5 new changesets (update) |
|
325 | 325 | $ hg summary -R initialrepo |
|
326 | 326 | parent: 7:17a481b3bccb tip |
|
327 | 327 | merge B' and E |
|
328 | 328 | branch: default |
|
329 | 329 | commit: (clean) (secret) |
|
330 | 330 | update: 1 new changesets, 2 branch heads (merge) |
|
331 | 331 | phases: 3 draft, 3 secret |
|
332 | 332 | $ hg summary -R initialrepo --quiet |
|
333 | 333 | parent: 7:17a481b3bccb tip |
|
334 | 334 | update: 1 new changesets, 2 branch heads (merge) |
|
335 | 335 | |
|
336 | 336 | Test revset |
|
337 | 337 | |
|
338 | 338 | $ cd initialrepo |
|
339 | 339 | $ hglog -r 'public()' |
|
340 | 340 | 0 0 A |
|
341 | 341 | 1 0 B |
|
342 | 342 | $ hglog -r 'draft()' |
|
343 | 343 | 2 1 C |
|
344 | 344 | 3 1 D |
|
345 | 345 | 6 1 B' |
|
346 | 346 | $ hglog -r 'secret()' |
|
347 | 347 | 4 2 E |
|
348 | 348 | 5 2 H |
|
349 | 349 | 7 2 merge B' and E |
|
350 | 350 | |
|
351 | 351 | test that phase are displayed in log at debug level |
|
352 | 352 | |
|
353 | 353 | $ hg log --debug |
|
354 | 354 | changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af |
|
355 | 355 | tag: tip |
|
356 | 356 | phase: secret |
|
357 | 357 | parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
358 | 358 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
359 | 359 | manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8 |
|
360 | 360 | user: test |
|
361 | 361 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
362 | 362 | files+: C D E |
|
363 | 363 | extra: branch=default |
|
364 | 364 | description: |
|
365 | 365 | merge B' and E |
|
366 | 366 | |
|
367 | 367 | |
|
368 | 368 | changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
369 | 369 | phase: draft |
|
370 | 370 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
371 | 371 | parent: -1:0000000000000000000000000000000000000000 |
|
372 | 372 | manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a |
|
373 | 373 | user: test |
|
374 | 374 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
375 | 375 | files+: B' |
|
376 | 376 | extra: branch=default |
|
377 | 377 | description: |
|
378 | 378 | B' |
|
379 | 379 | |
|
380 | 380 | |
|
381 | 381 | changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8 |
|
382 | 382 | phase: secret |
|
383 | 383 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
384 | 384 | parent: -1:0000000000000000000000000000000000000000 |
|
385 | 385 | manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a |
|
386 | 386 | user: test |
|
387 | 387 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
388 | 388 | files+: H |
|
389 | 389 | extra: branch=default |
|
390 | 390 | description: |
|
391 | 391 | H |
|
392 | 392 | |
|
393 | 393 | |
|
394 | 394 | changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
395 | 395 | phase: secret |
|
396 | 396 | parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
397 | 397 | parent: -1:0000000000000000000000000000000000000000 |
|
398 | 398 | manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc |
|
399 | 399 | user: test |
|
400 | 400 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
401 | 401 | files+: E |
|
402 | 402 | extra: branch=default |
|
403 | 403 | description: |
|
404 | 404 | E |
|
405 | 405 | |
|
406 | 406 | |
|
407 | 407 | changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
408 | 408 | phase: draft |
|
409 | 409 | parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
410 | 410 | parent: -1:0000000000000000000000000000000000000000 |
|
411 | 411 | manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c |
|
412 | 412 | user: test |
|
413 | 413 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
414 | 414 | files+: D |
|
415 | 415 | extra: branch=default |
|
416 | 416 | description: |
|
417 | 417 | D |
|
418 | 418 | |
|
419 | 419 | |
|
420 | 420 | changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
421 | 421 | phase: draft |
|
422 | 422 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
423 | 423 | parent: -1:0000000000000000000000000000000000000000 |
|
424 | 424 | manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4 |
|
425 | 425 | user: test |
|
426 | 426 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
427 | 427 | files+: C |
|
428 | 428 | extra: branch=default |
|
429 | 429 | description: |
|
430 | 430 | C |
|
431 | 431 | |
|
432 | 432 | |
|
433 | 433 | changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
434 | 434 | phase: public |
|
435 | 435 | parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
436 | 436 | parent: -1:0000000000000000000000000000000000000000 |
|
437 | 437 | manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd |
|
438 | 438 | user: test |
|
439 | 439 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
440 | 440 | files+: B |
|
441 | 441 | extra: branch=default |
|
442 | 442 | description: |
|
443 | 443 | B |
|
444 | 444 | |
|
445 | 445 | |
|
446 | 446 | changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
447 | 447 | phase: public |
|
448 | 448 | parent: -1:0000000000000000000000000000000000000000 |
|
449 | 449 | parent: -1:0000000000000000000000000000000000000000 |
|
450 | 450 | manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83 |
|
451 | 451 | user: test |
|
452 | 452 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
453 | 453 | files+: A |
|
454 | 454 | extra: branch=default |
|
455 | 455 | description: |
|
456 | 456 | A |
|
457 | 457 | |
|
458 | 458 | |
|
459 | 459 | |
|
460 | 460 | |
|
461 | 461 | (Issue3707) |
|
462 | 462 | test invalid phase name |
|
463 | 463 | |
|
464 | 464 | $ mkcommit I --config phases.new-commit='babar' |
|
465 | 465 | transaction abort! |
|
466 | 466 | rollback completed |
|
467 | 467 | abort: phases.new-commit: not a valid phase name ('babar') |
|
468 | 468 | [255] |
|
469 | 469 | Test phase command |
|
470 | 470 | =================== |
|
471 | 471 | |
|
472 | 472 | initial picture |
|
473 | 473 | |
|
474 | 474 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
475 | 475 | @ 7 secret merge B' and E |
|
476 | 476 | |\ |
|
477 | 477 | | o 6 draft B' |
|
478 | 478 | | | |
|
479 | 479 | +---o 5 secret H |
|
480 | 480 | | | |
|
481 | 481 | o | 4 secret E |
|
482 | 482 | | | |
|
483 | 483 | o | 3 draft D |
|
484 | 484 | | | |
|
485 | 485 | o | 2 draft C |
|
486 | 486 | |/ |
|
487 | 487 | o 1 public B |
|
488 | 488 | | |
|
489 | 489 | o 0 public A |
|
490 | 490 | |
|
491 | 491 | |
|
492 | 492 | display changesets phase |
|
493 | 493 | |
|
494 | 494 | (mixing -r and plain rev specification) |
|
495 | 495 | |
|
496 | 496 | $ hg phase 1::4 -r 7 |
|
497 | 497 | 1: public |
|
498 | 498 | 2: draft |
|
499 | 499 | 3: draft |
|
500 | 500 | 4: secret |
|
501 | 501 | 7: secret |
|
502 | 502 | |
|
503 | 503 | |
|
504 | 504 | move changeset forward |
|
505 | 505 | |
|
506 | 506 | (with -r option) |
|
507 | 507 | |
|
508 | 508 | $ hg phase --public -r 2 |
|
509 | 509 | test-debug-phase: move rev 2: 1 -> 0 |
|
510 | 510 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 1 -> 0 |
|
511 | 511 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
512 | 512 | @ 7 secret merge B' and E |
|
513 | 513 | |\ |
|
514 | 514 | | o 6 draft B' |
|
515 | 515 | | | |
|
516 | 516 | +---o 5 secret H |
|
517 | 517 | | | |
|
518 | 518 | o | 4 secret E |
|
519 | 519 | | | |
|
520 | 520 | o | 3 draft D |
|
521 | 521 | | | |
|
522 | 522 | o | 2 public C |
|
523 | 523 | |/ |
|
524 | 524 | o 1 public B |
|
525 | 525 | | |
|
526 | 526 | o 0 public A |
|
527 | 527 | |
|
528 | 528 | |
|
529 | 529 | move changeset backward |
|
530 | 530 | |
|
531 | 531 | (without -r option) |
|
532 | 532 | |
|
533 | 533 | $ hg phase --draft --force 2 |
|
534 | 534 | test-debug-phase: move rev 2: 0 -> 1 |
|
535 | 535 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 0 -> 1 |
|
536 | 536 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
537 | 537 | @ 7 secret merge B' and E |
|
538 | 538 | |\ |
|
539 | 539 | | o 6 draft B' |
|
540 | 540 | | | |
|
541 | 541 | +---o 5 secret H |
|
542 | 542 | | | |
|
543 | 543 | o | 4 secret E |
|
544 | 544 | | | |
|
545 | 545 | o | 3 draft D |
|
546 | 546 | | | |
|
547 | 547 | o | 2 draft C |
|
548 | 548 | |/ |
|
549 | 549 | o 1 public B |
|
550 | 550 | | |
|
551 | 551 | o 0 public A |
|
552 | 552 | |
|
553 | 553 | |
|
554 | 554 | move changeset forward and backward |
|
555 | 555 | |
|
556 | 556 | $ hg phase --draft --force 1::4 |
|
557 | 557 | test-debug-phase: move rev 1: 0 -> 1 |
|
558 | 558 | test-debug-phase: move rev 4: 2 -> 1 |
|
559 | 559 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 0 -> 1 |
|
560 | 560 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 2 -> 1 |
|
561 | 561 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
562 | 562 | @ 7 secret merge B' and E |
|
563 | 563 | |\ |
|
564 | 564 | | o 6 draft B' |
|
565 | 565 | | | |
|
566 | 566 | +---o 5 secret H |
|
567 | 567 | | | |
|
568 | 568 | o | 4 draft E |
|
569 | 569 | | | |
|
570 | 570 | o | 3 draft D |
|
571 | 571 | | | |
|
572 | 572 | o | 2 draft C |
|
573 | 573 | |/ |
|
574 | 574 | o 1 draft B |
|
575 | 575 | | |
|
576 | 576 | o 0 public A |
|
577 | 577 | |
|
578 | 578 | test partial failure |
|
579 | 579 | |
|
580 | 580 | $ hg phase --public 7 |
|
581 | 581 | test-debug-phase: move rev 1: 1 -> 0 |
|
582 | 582 | test-debug-phase: move rev 2: 1 -> 0 |
|
583 | 583 | test-debug-phase: move rev 3: 1 -> 0 |
|
584 | 584 | test-debug-phase: move rev 4: 1 -> 0 |
|
585 | 585 | test-debug-phase: move rev 6: 1 -> 0 |
|
586 | 586 | test-debug-phase: move rev 7: 2 -> 0 |
|
587 | 587 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 1 -> 0 |
|
588 | 588 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 1 -> 0 |
|
589 | 589 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: 1 -> 0 |
|
590 | 590 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 1 -> 0 |
|
591 | 591 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: 1 -> 0 |
|
592 | 592 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: 2 -> 0 |
|
593 | 593 | $ hg phase --draft '5 or 7' |
|
594 | 594 | test-debug-phase: move rev 5: 2 -> 1 |
|
595 | 595 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: 2 -> 1 |
|
596 | 596 | cannot move 1 changesets to a higher phase, use --force |
|
597 | 597 | phase changed for 1 changesets |
|
598 | 598 | [1] |
|
599 | 599 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
600 | 600 | @ 7 public merge B' and E |
|
601 | 601 | |\ |
|
602 | 602 | | o 6 public B' |
|
603 | 603 | | | |
|
604 | 604 | +---o 5 draft H |
|
605 | 605 | | | |
|
606 | 606 | o | 4 public E |
|
607 | 607 | | | |
|
608 | 608 | o | 3 public D |
|
609 | 609 | | | |
|
610 | 610 | o | 2 public C |
|
611 | 611 | |/ |
|
612 | 612 | o 1 public B |
|
613 | 613 | | |
|
614 | 614 | o 0 public A |
|
615 | 615 | |
|
616 | 616 | |
|
617 | 617 | test complete failure |
|
618 | 618 | |
|
619 | 619 | $ hg phase --draft 7 |
|
620 | 620 | cannot move 1 changesets to a higher phase, use --force |
|
621 | 621 | no phases changed |
|
622 | 622 | [1] |
|
623 | 623 | |
|
624 | 624 | $ cd .. |
|
625 | 625 | |
|
626 | 626 | test hidden changeset are not cloned as public (issue3935) |
|
627 | 627 | |
|
628 | 628 | $ cd initialrepo |
|
629 | 629 | |
|
630 | 630 | (enabling evolution) |
|
631 | 631 | $ cat >> $HGRCPATH << EOF |
|
632 | 632 | > [experimental] |
|
633 | 633 | > stabilization=createmarkers |
|
634 | 634 | > EOF |
|
635 | 635 | |
|
636 | 636 | (making a changeset hidden; H in that case) |
|
637 | 637 | $ hg debugobsolete `hg id --debug -r 5` |
|
638 | 638 | obsoleted 1 changesets |
|
639 | 639 | |
|
640 | 640 | $ cd .. |
|
641 | 641 | $ hg clone initialrepo clonewithobs |
|
642 | 642 | requesting all changes |
|
643 | 643 | adding changesets |
|
644 | 644 | adding manifests |
|
645 | 645 | adding file changes |
|
646 | 646 | added 7 changesets with 6 changes to 6 files |
|
647 | 647 | new changesets 4a2df7238c3b:17a481b3bccb |
|
648 | 648 | test-debug-phase: new rev 0: x -> 0 |
|
649 | 649 | test-debug-phase: new rev 1: x -> 0 |
|
650 | 650 | test-debug-phase: new rev 2: x -> 0 |
|
651 | 651 | test-debug-phase: new rev 3: x -> 0 |
|
652 | 652 | test-debug-phase: new rev 4: x -> 0 |
|
653 | 653 | test-debug-phase: new rev 5: x -> 0 |
|
654 | 654 | test-debug-phase: new rev 6: x -> 0 |
|
655 | 655 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0 |
|
656 | 656 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0 |
|
657 | 657 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0 |
|
658 | 658 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0 |
|
659 | 659 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> 0 |
|
660 | 660 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0 |
|
661 | 661 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> 0 |
|
662 | 662 | updating to branch default |
|
663 | 663 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
664 | 664 | $ cd clonewithobs |
|
665 | 665 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
666 | 666 | @ 6 public merge B' and E |
|
667 | 667 | |\ |
|
668 | 668 | | o 5 public B' |
|
669 | 669 | | | |
|
670 | 670 | o | 4 public E |
|
671 | 671 | | | |
|
672 | 672 | o | 3 public D |
|
673 | 673 | | | |
|
674 | 674 | o | 2 public C |
|
675 | 675 | |/ |
|
676 | 676 | o 1 public B |
|
677 | 677 | | |
|
678 | 678 | o 0 public A |
|
679 | 679 | |
|
680 | 680 | |
|
681 | 681 | test verify repo containing hidden changesets, which should not abort just |
|
682 | 682 | because repo.cancopy() is False |
|
683 | 683 | |
|
684 | 684 | $ cd ../initialrepo |
|
685 | 685 | $ hg verify |
|
686 | 686 | checking changesets |
|
687 | 687 | checking manifests |
|
688 | 688 | crosschecking files in changesets and manifests |
|
689 | 689 | checking files |
|
690 | 690 | 7 files, 8 changesets, 7 total revisions |
|
691 | 691 | |
|
692 | 692 | $ cd .. |
|
693 | 693 | |
|
694 | 694 | check whether HG_PENDING makes pending changes only in related |
|
695 | 695 | repositories visible to an external hook. |
|
696 | 696 | |
|
697 | 697 | (emulate a transaction running concurrently by copied |
|
698 | 698 | .hg/phaseroots.pending in subsequent test) |
|
699 | 699 | |
|
700 | 700 | $ cat > $TESTTMP/savepending.sh <<EOF |
|
701 | 701 | > cp .hg/store/phaseroots.pending .hg/store/phaseroots.pending.saved |
|
702 | 702 | > exit 1 # to avoid changing phase for subsequent tests |
|
703 | 703 | > EOF |
|
704 | 704 | $ cd push-dest |
|
705 | 705 | $ hg phase 6 |
|
706 | 706 | 6: draft |
|
707 | 707 | $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" phase -f -s 6 |
|
708 | 708 | transaction abort! |
|
709 | 709 | rollback completed |
|
710 | 710 | abort: pretxnclose hook exited with status 1 |
|
711 | 711 | [255] |
|
712 | 712 | $ cp .hg/store/phaseroots.pending.saved .hg/store/phaseroots.pending |
|
713 | 713 | |
|
714 | 714 | (check (in)visibility of phaseroot while transaction running in repo) |
|
715 | 715 | |
|
716 | 716 | $ cat > $TESTTMP/checkpending.sh <<EOF |
|
717 | 717 | > echo '@initialrepo' |
|
718 | 718 | > hg -R "$TESTTMP/initialrepo" phase 7 |
|
719 | 719 | > echo '@push-dest' |
|
720 | 720 | > hg -R "$TESTTMP/push-dest" phase 6 |
|
721 | 721 | > exit 1 # to avoid changing phase for subsequent tests |
|
722 | 722 | > EOF |
|
723 | 723 | $ cd ../initialrepo |
|
724 | 724 | $ hg phase 7 |
|
725 | 725 | 7: public |
|
726 | 726 | $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" phase -f -s 7 |
|
727 | 727 | @initialrepo |
|
728 | 728 | 7: secret |
|
729 | 729 | @push-dest |
|
730 | 730 | 6: draft |
|
731 | 731 | transaction abort! |
|
732 | 732 | rollback completed |
|
733 | 733 | abort: pretxnclose hook exited with status 1 |
|
734 | 734 | [255] |
|
735 | ||
|
736 | Check that pretxnclose-phase hook can control phase movement | |
|
737 | ||
|
738 | $ hg phase --force b3325c91a4d9 --secret | |
|
739 | test-debug-phase: move rev 3: 0 -> 2 | |
|
740 | test-debug-phase: move rev 4: 0 -> 2 | |
|
741 | test-debug-phase: move rev 5: 1 -> 2 | |
|
742 | test-debug-phase: move rev 7: 0 -> 2 | |
|
743 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: 0 -> 2 | |
|
744 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 0 -> 2 | |
|
745 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: 1 -> 2 | |
|
746 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: 0 -> 2 | |
|
747 | $ hg log -G -T phases | |
|
748 | @ changeset: 7:17a481b3bccb | |
|
749 | |\ tag: tip | |
|
750 | | | phase: secret | |
|
751 | | | parent: 6:cf9fe039dfd6 | |
|
752 | | | parent: 4:a603bfb5a83e | |
|
753 | | | user: test | |
|
754 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
755 | | | summary: merge B' and E | |
|
756 | | | | |
|
757 | | o changeset: 6:cf9fe039dfd6 | |
|
758 | | | phase: public | |
|
759 | | | parent: 1:27547f69f254 | |
|
760 | | | user: test | |
|
761 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
762 | | | summary: B' | |
|
763 | | | | |
|
764 | o | changeset: 4:a603bfb5a83e | |
|
765 | | | phase: secret | |
|
766 | | | user: test | |
|
767 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
768 | | | summary: E | |
|
769 | | | | |
|
770 | o | changeset: 3:b3325c91a4d9 | |
|
771 | | | phase: secret | |
|
772 | | | user: test | |
|
773 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
774 | | | summary: D | |
|
775 | | | | |
|
776 | o | changeset: 2:f838bfaca5c7 | |
|
777 | |/ phase: public | |
|
778 | | user: test | |
|
779 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
780 | | summary: C | |
|
781 | | | |
|
782 | o changeset: 1:27547f69f254 | |
|
783 | | phase: public | |
|
784 | | user: test | |
|
785 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
786 | | summary: B | |
|
787 | | | |
|
788 | o changeset: 0:4a2df7238c3b | |
|
789 | phase: public | |
|
790 | user: test | |
|
791 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
792 | summary: A | |
|
793 | ||
|
794 | ||
|
795 | Install a hook that prevent b3325c91a4d9 to become public | |
|
796 | ||
|
797 | $ cat >> .hg/hgrc << EOF | |
|
798 | > [hooks] | |
|
799 | > pretxnclose-phase.nopublish_D = (echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 0 -lt \$HG_PHASE ] | |
|
800 | > EOF | |
|
801 | ||
|
802 | Try various actions. only the draft move should succeed | |
|
803 | ||
|
804 | $ hg phase --public b3325c91a4d9 | |
|
805 | transaction abort! | |
|
806 | rollback completed | |
|
807 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 | |
|
808 | [255] | |
|
809 | $ hg phase --public a603bfb5a83e | |
|
810 | transaction abort! | |
|
811 | rollback completed | |
|
812 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 | |
|
813 | [255] | |
|
814 | $ hg phase --draft 17a481b3bccb | |
|
815 | test-debug-phase: move rev 3: 2 -> 1 | |
|
816 | test-debug-phase: move rev 4: 2 -> 1 | |
|
817 | test-debug-phase: move rev 7: 2 -> 1 | |
|
818 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: 2 -> 1 | |
|
819 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 2 -> 1 | |
|
820 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: 2 -> 1 | |
|
821 | $ hg phase --public 17a481b3bccb | |
|
822 | transaction abort! | |
|
823 | rollback completed | |
|
824 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 | |
|
825 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now