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