##// END OF EJS Templates
color: update main documentation...
Pierre-Yves David -
r31123:df0a0734 default
parent child Browse files
Show More
@@ -1,52 +1,53 b''
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3 3
4 4 <?include guids.wxi ?>
5 5 <?include defines.wxi ?>
6 6
7 7 <Fragment>
8 8 <ComponentGroup Id='helpFolder'>
9 9 <ComponentRef Id='help.root' />
10 10 <ComponentRef Id='help.internals' />
11 11 </ComponentGroup>
12 12 </Fragment>
13 13
14 14 <Fragment>
15 15 <DirectoryRef Id="INSTALLDIR">
16 16 <Directory Id="helpdir" Name="help" FileSource="$(var.SourceDir)">
17 17 <Component Id="help.root" Guid="$(var.help.root.guid)" Win64='$(var.IsX64)'>
18 <File Name="color.txt" />
18 19 <File Name="config.txt" KeyPath="yes" />
19 20 <File Name="dates.txt" />
20 21 <File Name="diffs.txt" />
21 22 <File Name="environment.txt" />
22 23 <File Name="extensions.txt" />
23 24 <File Name="filesets.txt" />
24 25 <File Name="glossary.txt" />
25 26 <File Name="hgignore.txt" />
26 27 <File Name="hgweb.txt" />
27 28 <File Name="merge-tools.txt" />
28 29 <File Name="pager.txt" />
29 30 <File Name="patterns.txt" />
30 31 <File Name="phases.txt" />
31 32 <File Name="revisions.txt" />
32 33 <File Name="scripting.txt" />
33 34 <File Name="subrepos.txt" />
34 35 <File Name="templates.txt" />
35 36 <File Name="urls.txt" />
36 37 </Component>
37 38
38 39 <Directory Id="help.internaldir" Name="internals">
39 40 <Component Id="help.internals" Guid="$(var.help.internals.guid)" Win64='$(var.IsX64)'>
40 41 <File Id="internals.bundles.txt" Name="bundles.txt" KeyPath="yes" />
41 42 <File Id="internals.changegroups.txt" Name="changegroups.txt" />
42 43 <File Id="internals.requirements.txt" Name="requirements.txt" />
43 44 <File Id="internals.revlogs.txt" Name="revlogs.txt" />
44 45 <File Id="internals.wireprotocol.txt" Name="wireprotocol.txt" />
45 46 </Component>
46 47 </Directory>
47 48
48 49 </Directory>
49 50 </DirectoryRef>
50 51 </Fragment>
51 52
52 53 </Wix>
@@ -1,186 +1,31 b''
1 1 # color.py color output for Mercurial commands
2 2 #
3 3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 '''colorize output from some commands
9
10 The color extension colorizes output from several Mercurial commands.
11 For example, the diff command shows additions in green and deletions
12 in red, while the status command shows modified files in magenta. Many
13 other commands have analogous colors. It is possible to customize
14 these colors.
15
16 Effects
17 -------
18
19 Other effects in addition to color, like bold and underlined text, are
20 also available. By default, the terminfo database is used to find the
21 terminal codes used to change color and effect. If terminfo is not
22 available, then effects are rendered with the ECMA-48 SGR control
23 function (aka ANSI escape codes).
24
25 The available effects in terminfo mode are 'blink', 'bold', 'dim',
26 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
27 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
28 'underline'. How each is rendered depends on the terminal emulator.
29 Some may not be available for a given terminal type, and will be
30 silently ignored.
31
32 If the terminfo entry for your terminal is missing codes for an effect
33 or has the wrong codes, you can add or override those codes in your
34 configuration::
35
36 [color]
37 terminfo.dim = \E[2m
38
39 where '\E' is substituted with an escape character.
8 '''enable Mercurial color mode (DEPRECATED)
40 9
41 Labels
42 ------
43
44 Text receives color effects depending on the labels that it has. Many
45 default Mercurial commands emit labelled text. You can also define
46 your own labels in templates using the label function, see :hg:`help
47 templates`. A single portion of text may have more than one label. In
48 that case, effects given to the last label will override any other
49 effects. This includes the special "none" effect, which nullifies
50 other effects.
51
52 Labels are normally invisible. In order to see these labels and their
53 position in the text, use the global --color=debug option. The same
54 anchor text may be associated to multiple labels, e.g.
55
56 [log.changeset changeset.secret|changeset: 22611:6f0a53c8f587]
57
58 The following are the default effects for some default labels. Default
59 effects may be overridden from your configuration file::
60
61 [color]
62 status.modified = blue bold underline red_background
63 status.added = green bold
64 status.removed = red bold blue_background
65 status.deleted = cyan bold underline
66 status.unknown = magenta bold underline
67 status.ignored = black bold
68
69 # 'none' turns off all effects
70 status.clean = none
71 status.copied = none
72
73 qseries.applied = blue bold underline
74 qseries.unapplied = black bold
75 qseries.missing = red bold
10 This extensions enable Mercurial color mode. The feature is now directly
11 available in Mercurial core. You can access it using::
76 12
77 diff.diffline = bold
78 diff.extended = cyan bold
79 diff.file_a = red bold
80 diff.file_b = green bold
81 diff.hunk = magenta
82 diff.deleted = red
83 diff.inserted = green
84 diff.changed = white
85 diff.tab =
86 diff.trailingwhitespace = bold red_background
87
88 # Blank so it inherits the style of the surrounding label
89 changeset.public =
90 changeset.draft =
91 changeset.secret =
92
93 resolve.unresolved = red bold
94 resolve.resolved = green bold
95
96 bookmarks.active = green
97
98 branches.active = none
99 branches.closed = black bold
100 branches.current = green
101 branches.inactive = none
102
103 tags.normal = green
104 tags.local = black bold
105
106 rebase.rebased = blue
107 rebase.remaining = red bold
108
109 shelve.age = cyan
110 shelve.newest = green bold
111 shelve.name = blue bold
112
113 histedit.remaining = red bold
114
115 Custom colors
116 -------------
13 [ui]
14 color = auto
117 15
118 Because there are only eight standard colors, this module allows you
119 to define color names for other color slots which might be available
120 for your terminal type, assuming terminfo mode. For instance::
121
122 color.brightblue = 12
123 color.pink = 207
124 color.orange = 202
125
126 to set 'brightblue' to color slot 12 (useful for 16 color terminals
127 that have brighter colors defined in the upper eight) and, 'pink' and
128 'orange' to colors in 256-color xterm's default color cube. These
129 defined colors may then be used as any of the pre-defined eight,
130 including appending '_background' to set the background to that color.
131
132 Modes
133 -----
134
135 By default, the color extension will use ANSI mode (or win32 mode on
136 Windows) if it detects a terminal. To override auto mode (to enable
137 terminfo mode, for example), set the following configuration option::
138
139 [color]
140 mode = terminfo
141
142 Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
143 disable color.
144
145 Note that on some systems, terminfo mode may cause problems when using
146 color with the pager extension and less -R. less with the -R option
147 will only display ECMA-48 color codes, and terminfo mode may sometimes
148 emit codes that less doesn't understand. You can work around this by
149 either using ansi mode (or auto mode), or by using less -r (which will
150 pass through all terminal control codes, not just color control
151 codes).
152
153 On some systems (such as MSYS in Windows), the terminal may support
154 a different color mode than the pager (activated via the "pager"
155 extension). It is possible to define separate modes depending on whether
156 the pager is active::
157
158 [color]
159 mode = auto
160 pagermode = ansi
161
162 If ``pagermode`` is not defined, the ``mode`` will be used.
16 See :hg:`help color` for details.
163 17 '''
164 18
165 19 from __future__ import absolute_import
166 20
167 from mercurial import (
168 color,
169 commands
170 )
21 from mercurial import color
171 22
172 23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
173 24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
174 25 # be specifying the version(s) of Mercurial they are tested with, or
175 26 # leave the attribute unspecified.
176 27 testedwith = 'ships-with-hg-core'
177 28
178 29 def extsetup(ui):
179 30 # change default color config
180 31 color._enabledbydefault = True
181 for idx, entry in enumerate(commands.globalopts):
182 if entry[1] == 'color':
183 patch = (entry[3].replace(' (EXPERIMENTAL)', ''),)
184 new = entry[:3] + patch + entry[4:]
185 commands.globalopts[idx] = new
186 break
@@ -1,472 +1,471 b''
1 1 # utility for color output for Mercurial commands
2 2 #
3 3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> and other
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 from .i18n import _
11 11
12 12 from . import (
13 13 encoding,
14 14 pycompat,
15 15 util
16 16 )
17 17
18 18 try:
19 19 import curses
20 20 # Mapping from effect name to terminfo attribute name (or raw code) or
21 21 # color number. This will also force-load the curses module.
22 22 _baseterminfoparams = {
23 23 'none': (True, 'sgr0', ''),
24 24 'standout': (True, 'smso', ''),
25 25 'underline': (True, 'smul', ''),
26 26 'reverse': (True, 'rev', ''),
27 27 'inverse': (True, 'rev', ''),
28 28 'blink': (True, 'blink', ''),
29 29 'dim': (True, 'dim', ''),
30 30 'bold': (True, 'bold', ''),
31 31 'invisible': (True, 'invis', ''),
32 32 'italic': (True, 'sitm', ''),
33 33 'black': (False, curses.COLOR_BLACK, ''),
34 34 'red': (False, curses.COLOR_RED, ''),
35 35 'green': (False, curses.COLOR_GREEN, ''),
36 36 'yellow': (False, curses.COLOR_YELLOW, ''),
37 37 'blue': (False, curses.COLOR_BLUE, ''),
38 38 'magenta': (False, curses.COLOR_MAGENTA, ''),
39 39 'cyan': (False, curses.COLOR_CYAN, ''),
40 40 'white': (False, curses.COLOR_WHITE, ''),
41 41 }
42 42 except ImportError:
43 43 curses = None
44 44 _baseterminfoparams = {}
45 45
46 46 # allow the extensions to change the default
47 47 _enabledbydefault = False
48 48
49 49 # start and stop parameters for effects
50 50 _effects = {
51 51 'none': 0,
52 52 'black': 30,
53 53 'red': 31,
54 54 'green': 32,
55 55 'yellow': 33,
56 56 'blue': 34,
57 57 'magenta': 35,
58 58 'cyan': 36,
59 59 'white': 37,
60 60 'bold': 1,
61 61 'italic': 3,
62 62 'underline': 4,
63 63 'inverse': 7,
64 64 'dim': 2,
65 65 'black_background': 40,
66 66 'red_background': 41,
67 67 'green_background': 42,
68 68 'yellow_background': 43,
69 69 'blue_background': 44,
70 70 'purple_background': 45,
71 71 'cyan_background': 46,
72 72 'white_background': 47,
73 73 }
74 74
75 75 _defaultstyles = {
76 76 'grep.match': 'red bold',
77 77 'grep.linenumber': 'green',
78 78 'grep.rev': 'green',
79 79 'grep.change': 'green',
80 80 'grep.sep': 'cyan',
81 81 'grep.filename': 'magenta',
82 82 'grep.user': 'magenta',
83 83 'grep.date': 'magenta',
84 84 'bookmarks.active': 'green',
85 85 'branches.active': 'none',
86 86 'branches.closed': 'black bold',
87 87 'branches.current': 'green',
88 88 'branches.inactive': 'none',
89 89 'diff.changed': 'white',
90 90 'diff.deleted': 'red',
91 91 'diff.diffline': 'bold',
92 92 'diff.extended': 'cyan bold',
93 93 'diff.file_a': 'red bold',
94 94 'diff.file_b': 'green bold',
95 95 'diff.hunk': 'magenta',
96 96 'diff.inserted': 'green',
97 97 'diff.tab': '',
98 98 'diff.trailingwhitespace': 'bold red_background',
99 99 'changeset.public' : '',
100 100 'changeset.draft' : '',
101 101 'changeset.secret' : '',
102 102 'diffstat.deleted': 'red',
103 103 'diffstat.inserted': 'green',
104 104 'histedit.remaining': 'red bold',
105 105 'ui.prompt': 'yellow',
106 106 'log.changeset': 'yellow',
107 107 'patchbomb.finalsummary': '',
108 108 'patchbomb.from': 'magenta',
109 109 'patchbomb.to': 'cyan',
110 110 'patchbomb.subject': 'green',
111 111 'patchbomb.diffstats': '',
112 112 'rebase.rebased': 'blue',
113 113 'rebase.remaining': 'red bold',
114 114 'resolve.resolved': 'green bold',
115 115 'resolve.unresolved': 'red bold',
116 116 'shelve.age': 'cyan',
117 117 'shelve.newest': 'green bold',
118 118 'shelve.name': 'blue bold',
119 119 'status.added': 'green bold',
120 120 'status.clean': 'none',
121 121 'status.copied': 'none',
122 122 'status.deleted': 'cyan bold underline',
123 123 'status.ignored': 'black bold',
124 124 'status.modified': 'blue bold',
125 125 'status.removed': 'red bold',
126 126 'status.unknown': 'magenta bold underline',
127 127 'tags.normal': 'green',
128 128 'tags.local': 'black bold',
129 129 }
130 130
131 131 def loadcolortable(ui, extname, colortable):
132 132 _defaultstyles.update(colortable)
133 133
134 134 def _terminfosetup(ui, mode):
135 135 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
136 136
137 137 # If we failed to load curses, we go ahead and return.
138 138 if curses is None:
139 139 return
140 140 # Otherwise, see what the config file says.
141 141 if mode not in ('auto', 'terminfo'):
142 142 return
143 143 ui._terminfoparams.update(_baseterminfoparams)
144 144
145 145 for key, val in ui.configitems('color'):
146 146 if key.startswith('color.'):
147 147 newval = (False, int(val), '')
148 148 ui._terminfoparams[key[6:]] = newval
149 149 elif key.startswith('terminfo.'):
150 150 newval = (True, '', val.replace('\\E', '\x1b'))
151 151 ui._terminfoparams[key[9:]] = newval
152 152 try:
153 153 curses.setupterm()
154 154 except curses.error as e:
155 155 ui._terminfoparams.clear()
156 156 return
157 157
158 158 for key, (b, e, c) in ui._terminfoparams.items():
159 159 if not b:
160 160 continue
161 161 if not c and not curses.tigetstr(e):
162 162 # Most terminals don't support dim, invis, etc, so don't be
163 163 # noisy and use ui.debug().
164 164 ui.debug("no terminfo entry for %s\n" % e)
165 165 del ui._terminfoparams[key]
166 166 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
167 167 # Only warn about missing terminfo entries if we explicitly asked for
168 168 # terminfo mode.
169 169 if mode == "terminfo":
170 170 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
171 171 "ECMA-48 color\n"))
172 172 ui._terminfoparams.clear()
173 173
174 174 def setup(ui):
175 175 """configure color on a ui
176 176
177 177 That function both set the colormode for the ui object and read
178 178 the configuration looking for custom colors and effect definitions."""
179 179 mode = _modesetup(ui)
180 180 ui._colormode = mode
181 181 if mode and mode != 'debug':
182 182 configstyles(ui)
183 183
184 184 def _modesetup(ui):
185 185 if ui.plain():
186 186 return None
187 187 default = 'never'
188 188 if _enabledbydefault:
189 189 default = 'auto'
190 # experimental config: ui.color
191 190 config = ui.config('ui', 'color', default)
192 191 if config == 'debug':
193 192 return 'debug'
194 193
195 194 auto = (config == 'auto')
196 195 always = not auto and util.parsebool(config)
197 196 if not always and not auto:
198 197 return None
199 198
200 199 formatted = (always or (encoding.environ.get('TERM') != 'dumb'
201 200 and ui.formatted()))
202 201
203 202 mode = ui.config('color', 'mode', 'auto')
204 203
205 204 # If pager is active, color.pagermode overrides color.mode.
206 205 if getattr(ui, 'pageractive', False):
207 206 mode = ui.config('color', 'pagermode', mode)
208 207
209 208 realmode = mode
210 209 if mode == 'auto':
211 210 if pycompat.osname == 'nt':
212 211 term = encoding.environ.get('TERM')
213 212 # TERM won't be defined in a vanilla cmd.exe environment.
214 213
215 214 # UNIX-like environments on Windows such as Cygwin and MSYS will
216 215 # set TERM. They appear to make a best effort attempt at setting it
217 216 # to something appropriate. However, not all environments with TERM
218 217 # defined support ANSI. Since "ansi" could result in terminal
219 218 # gibberish, we error on the side of selecting "win32". However, if
220 219 # w32effects is not defined, we almost certainly don't support
221 220 # "win32", so don't even try.
222 221 if (term and 'xterm' in term) or not w32effects:
223 222 realmode = 'ansi'
224 223 else:
225 224 realmode = 'win32'
226 225 else:
227 226 realmode = 'ansi'
228 227
229 228 def modewarn():
230 229 # only warn if color.mode was explicitly set and we're in
231 230 # a formatted terminal
232 231 if mode == realmode and ui.formatted():
233 232 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
234 233
235 234 if realmode == 'win32':
236 235 ui._terminfoparams.clear()
237 236 if not w32effects:
238 237 modewarn()
239 238 return None
240 239 _effects.update(w32effects)
241 240 elif realmode == 'ansi':
242 241 ui._terminfoparams.clear()
243 242 elif realmode == 'terminfo':
244 243 _terminfosetup(ui, mode)
245 244 if not ui._terminfoparams:
246 245 ## FIXME Shouldn't we return None in this case too?
247 246 modewarn()
248 247 realmode = 'ansi'
249 248 else:
250 249 return None
251 250
252 251 if always or (auto and formatted):
253 252 return realmode
254 253 return None
255 254
256 255 def configstyles(ui):
257 256 ui._styles.update(_defaultstyles)
258 257 for status, cfgeffects in ui.configitems('color'):
259 258 if '.' not in status or status.startswith(('color.', 'terminfo.')):
260 259 continue
261 260 cfgeffects = ui.configlist('color', status)
262 261 if cfgeffects:
263 262 good = []
264 263 for e in cfgeffects:
265 264 if valideffect(ui, e):
266 265 good.append(e)
267 266 else:
268 267 ui.warn(_("ignoring unknown color/effect %r "
269 268 "(configured in color.%s)\n")
270 269 % (e, status))
271 270 ui._styles[status] = ' '.join(good)
272 271
273 272 def valideffect(ui, effect):
274 273 'Determine if the effect is valid or not.'
275 274 return ((not ui._terminfoparams and effect in _effects)
276 275 or (effect in ui._terminfoparams
277 276 or effect[:-11] in ui._terminfoparams))
278 277
279 278 def _effect_str(ui, effect):
280 279 '''Helper function for render_effects().'''
281 280
282 281 bg = False
283 282 if effect.endswith('_background'):
284 283 bg = True
285 284 effect = effect[:-11]
286 285 try:
287 286 attr, val, termcode = ui._terminfoparams[effect]
288 287 except KeyError:
289 288 return ''
290 289 if attr:
291 290 if termcode:
292 291 return termcode
293 292 else:
294 293 return curses.tigetstr(val)
295 294 elif bg:
296 295 return curses.tparm(curses.tigetstr('setab'), val)
297 296 else:
298 297 return curses.tparm(curses.tigetstr('setaf'), val)
299 298
300 299 def _render_effects(ui, text, effects):
301 300 'Wrap text in commands to turn on each effect.'
302 301 if not text:
303 302 return text
304 303 if ui._terminfoparams:
305 304 start = ''.join(_effect_str(ui, effect)
306 305 for effect in ['none'] + effects.split())
307 306 stop = _effect_str(ui, 'none')
308 307 else:
309 308 start = [str(_effects[e]) for e in ['none'] + effects.split()]
310 309 start = '\033[' + ';'.join(start) + 'm'
311 310 stop = '\033[' + str(_effects['none']) + 'm'
312 311 return ''.join([start, text, stop])
313 312
314 313 def colorlabel(ui, msg, label):
315 314 """add color control code according to the mode"""
316 315 if ui._colormode == 'debug':
317 316 if label and msg:
318 317 if msg[-1] == '\n':
319 318 msg = "[%s|%s]\n" % (label, msg[:-1])
320 319 else:
321 320 msg = "[%s|%s]" % (label, msg)
322 321 elif ui._colormode is not None:
323 322 effects = []
324 323 for l in label.split():
325 324 s = ui._styles.get(l, '')
326 325 if s:
327 326 effects.append(s)
328 327 elif valideffect(ui, l):
329 328 effects.append(l)
330 329 effects = ' '.join(effects)
331 330 if effects:
332 331 msg = '\n'.join([_render_effects(ui, line, effects)
333 332 for line in msg.split('\n')])
334 333 return msg
335 334
336 335 w32effects = None
337 336 if pycompat.osname == 'nt':
338 337 import ctypes
339 338 import re
340 339
341 340 _kernel32 = ctypes.windll.kernel32
342 341
343 342 _WORD = ctypes.c_ushort
344 343
345 344 _INVALID_HANDLE_VALUE = -1
346 345
347 346 class _COORD(ctypes.Structure):
348 347 _fields_ = [('X', ctypes.c_short),
349 348 ('Y', ctypes.c_short)]
350 349
351 350 class _SMALL_RECT(ctypes.Structure):
352 351 _fields_ = [('Left', ctypes.c_short),
353 352 ('Top', ctypes.c_short),
354 353 ('Right', ctypes.c_short),
355 354 ('Bottom', ctypes.c_short)]
356 355
357 356 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
358 357 _fields_ = [('dwSize', _COORD),
359 358 ('dwCursorPosition', _COORD),
360 359 ('wAttributes', _WORD),
361 360 ('srWindow', _SMALL_RECT),
362 361 ('dwMaximumWindowSize', _COORD)]
363 362
364 363 _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11
365 364 _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12
366 365
367 366 _FOREGROUND_BLUE = 0x0001
368 367 _FOREGROUND_GREEN = 0x0002
369 368 _FOREGROUND_RED = 0x0004
370 369 _FOREGROUND_INTENSITY = 0x0008
371 370
372 371 _BACKGROUND_BLUE = 0x0010
373 372 _BACKGROUND_GREEN = 0x0020
374 373 _BACKGROUND_RED = 0x0040
375 374 _BACKGROUND_INTENSITY = 0x0080
376 375
377 376 _COMMON_LVB_REVERSE_VIDEO = 0x4000
378 377 _COMMON_LVB_UNDERSCORE = 0x8000
379 378
380 379 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
381 380 w32effects = {
382 381 'none': -1,
383 382 'black': 0,
384 383 'red': _FOREGROUND_RED,
385 384 'green': _FOREGROUND_GREEN,
386 385 'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
387 386 'blue': _FOREGROUND_BLUE,
388 387 'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
389 388 'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
390 389 'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
391 390 'bold': _FOREGROUND_INTENSITY,
392 391 'black_background': 0x100, # unused value > 0x0f
393 392 'red_background': _BACKGROUND_RED,
394 393 'green_background': _BACKGROUND_GREEN,
395 394 'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
396 395 'blue_background': _BACKGROUND_BLUE,
397 396 'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
398 397 'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
399 398 'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
400 399 _BACKGROUND_BLUE),
401 400 'bold_background': _BACKGROUND_INTENSITY,
402 401 'underline': _COMMON_LVB_UNDERSCORE, # double-byte charsets only
403 402 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only
404 403 }
405 404
406 405 passthrough = set([_FOREGROUND_INTENSITY,
407 406 _BACKGROUND_INTENSITY,
408 407 _COMMON_LVB_UNDERSCORE,
409 408 _COMMON_LVB_REVERSE_VIDEO])
410 409
411 410 stdout = _kernel32.GetStdHandle(
412 411 _STD_OUTPUT_HANDLE) # don't close the handle returned
413 412 if stdout is None or stdout == _INVALID_HANDLE_VALUE:
414 413 w32effects = None
415 414 else:
416 415 csbi = _CONSOLE_SCREEN_BUFFER_INFO()
417 416 if not _kernel32.GetConsoleScreenBufferInfo(
418 417 stdout, ctypes.byref(csbi)):
419 418 # stdout may not support GetConsoleScreenBufferInfo()
420 419 # when called from subprocess or redirected
421 420 w32effects = None
422 421 else:
423 422 origattr = csbi.wAttributes
424 423 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
425 424 re.MULTILINE | re.DOTALL)
426 425
427 426 def win32print(ui, writefunc, *msgs, **opts):
428 427 for text in msgs:
429 428 _win32print(ui, text, writefunc, **opts)
430 429
431 430 def _win32print(ui, text, writefunc, **opts):
432 431 label = opts.get('label', '')
433 432 attr = origattr
434 433
435 434 def mapcolor(val, attr):
436 435 if val == -1:
437 436 return origattr
438 437 elif val in passthrough:
439 438 return attr | val
440 439 elif val > 0x0f:
441 440 return (val & 0x70) | (attr & 0x8f)
442 441 else:
443 442 return (val & 0x07) | (attr & 0xf8)
444 443
445 444 # determine console attributes based on labels
446 445 for l in label.split():
447 446 style = ui._styles.get(l, '')
448 447 for effect in style.split():
449 448 try:
450 449 attr = mapcolor(w32effects[effect], attr)
451 450 except KeyError:
452 451 # w32effects could not have certain attributes so we skip
453 452 # them if not found
454 453 pass
455 454 # hack to ensure regexp finds data
456 455 if not text.startswith('\033['):
457 456 text = '\033[m' + text
458 457
459 458 # Look for ANSI-like codes embedded in text
460 459 m = re.match(ansire, text)
461 460
462 461 try:
463 462 while m:
464 463 for sattr in m.group(1).split(';'):
465 464 if sattr:
466 465 attr = mapcolor(int(sattr), attr)
467 466 _kernel32.SetConsoleTextAttribute(stdout, attr)
468 467 writefunc(m.group(2), **opts)
469 468 m = re.match(ansire, m.group(3))
470 469 finally:
471 470 # Explicitly reset original attributes
472 471 _kernel32.SetConsoleTextAttribute(stdout, origattr)
@@ -1,5435 +1,5434 b''
1 1 # commands.py - command processing for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import difflib
11 11 import errno
12 12 import os
13 13 import re
14 14
15 15 from .i18n import _
16 16 from .node import (
17 17 hex,
18 18 nullid,
19 19 nullrev,
20 20 short,
21 21 )
22 22 from . import (
23 23 archival,
24 24 bookmarks,
25 25 bundle2,
26 26 changegroup,
27 27 cmdutil,
28 28 copies,
29 29 destutil,
30 30 dirstateguard,
31 31 discovery,
32 32 encoding,
33 33 error,
34 34 exchange,
35 35 extensions,
36 36 graphmod,
37 37 hbisect,
38 38 help,
39 39 hg,
40 40 lock as lockmod,
41 41 merge as mergemod,
42 42 obsolete,
43 43 patch,
44 44 phases,
45 45 pycompat,
46 46 revsetlang,
47 47 scmutil,
48 48 server,
49 49 sshserver,
50 50 streamclone,
51 51 templatekw,
52 52 ui as uimod,
53 53 util,
54 54 )
55 55
56 56 release = lockmod.release
57 57
58 58 table = {}
59 59
60 60 command = cmdutil.command(table)
61 61
62 62 # label constants
63 63 # until 3.5, bookmarks.current was the advertised name, not
64 64 # bookmarks.active, so we must use both to avoid breaking old
65 65 # custom styles
66 66 activebookmarklabel = 'bookmarks.active bookmarks.current'
67 67
68 68 # common command options
69 69
70 70 globalopts = [
71 71 ('R', 'repository', '',
72 72 _('repository root directory or name of overlay bundle file'),
73 73 _('REPO')),
74 74 ('', 'cwd', '',
75 75 _('change working directory'), _('DIR')),
76 76 ('y', 'noninteractive', None,
77 77 _('do not prompt, automatically pick the first choice for all prompts')),
78 78 ('q', 'quiet', None, _('suppress output')),
79 79 ('v', 'verbose', None, _('enable additional output')),
80 80 ('', 'color', '',
81 81 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
82 82 # and should not be translated
83 _("when to colorize (boolean, always, auto, never, or debug)"
84 " (EXPERIMENTAL)"),
83 _("when to colorize (boolean, always, auto, never, or debug)"),
85 84 _('TYPE')),
86 85 ('', 'config', [],
87 86 _('set/override config option (use \'section.name=value\')'),
88 87 _('CONFIG')),
89 88 ('', 'debug', None, _('enable debugging output')),
90 89 ('', 'debugger', None, _('start debugger')),
91 90 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
92 91 _('ENCODE')),
93 92 ('', 'encodingmode', encoding.encodingmode,
94 93 _('set the charset encoding mode'), _('MODE')),
95 94 ('', 'traceback', None, _('always print a traceback on exception')),
96 95 ('', 'time', None, _('time how long the command takes')),
97 96 ('', 'profile', None, _('print command execution profile')),
98 97 ('', 'version', None, _('output version information and exit')),
99 98 ('h', 'help', None, _('display help and exit')),
100 99 ('', 'hidden', False, _('consider hidden changesets')),
101 100 ('', 'pager', 'auto',
102 101 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
103 102 ]
104 103
105 104 dryrunopts = [('n', 'dry-run', None,
106 105 _('do not perform actions, just print output'))]
107 106
108 107 remoteopts = [
109 108 ('e', 'ssh', '',
110 109 _('specify ssh command to use'), _('CMD')),
111 110 ('', 'remotecmd', '',
112 111 _('specify hg command to run on the remote side'), _('CMD')),
113 112 ('', 'insecure', None,
114 113 _('do not verify server certificate (ignoring web.cacerts config)')),
115 114 ]
116 115
117 116 walkopts = [
118 117 ('I', 'include', [],
119 118 _('include names matching the given patterns'), _('PATTERN')),
120 119 ('X', 'exclude', [],
121 120 _('exclude names matching the given patterns'), _('PATTERN')),
122 121 ]
123 122
124 123 commitopts = [
125 124 ('m', 'message', '',
126 125 _('use text as commit message'), _('TEXT')),
127 126 ('l', 'logfile', '',
128 127 _('read commit message from file'), _('FILE')),
129 128 ]
130 129
131 130 commitopts2 = [
132 131 ('d', 'date', '',
133 132 _('record the specified date as commit date'), _('DATE')),
134 133 ('u', 'user', '',
135 134 _('record the specified user as committer'), _('USER')),
136 135 ]
137 136
138 137 # hidden for now
139 138 formatteropts = [
140 139 ('T', 'template', '',
141 140 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
142 141 ]
143 142
144 143 templateopts = [
145 144 ('', 'style', '',
146 145 _('display using template map file (DEPRECATED)'), _('STYLE')),
147 146 ('T', 'template', '',
148 147 _('display with template'), _('TEMPLATE')),
149 148 ]
150 149
151 150 logopts = [
152 151 ('p', 'patch', None, _('show patch')),
153 152 ('g', 'git', None, _('use git extended diff format')),
154 153 ('l', 'limit', '',
155 154 _('limit number of changes displayed'), _('NUM')),
156 155 ('M', 'no-merges', None, _('do not show merges')),
157 156 ('', 'stat', None, _('output diffstat-style summary of changes')),
158 157 ('G', 'graph', None, _("show the revision DAG")),
159 158 ] + templateopts
160 159
161 160 diffopts = [
162 161 ('a', 'text', None, _('treat all files as text')),
163 162 ('g', 'git', None, _('use git extended diff format')),
164 163 ('', 'nodates', None, _('omit dates from diff headers'))
165 164 ]
166 165
167 166 diffwsopts = [
168 167 ('w', 'ignore-all-space', None,
169 168 _('ignore white space when comparing lines')),
170 169 ('b', 'ignore-space-change', None,
171 170 _('ignore changes in the amount of white space')),
172 171 ('B', 'ignore-blank-lines', None,
173 172 _('ignore changes whose lines are all blank')),
174 173 ]
175 174
176 175 diffopts2 = [
177 176 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
178 177 ('p', 'show-function', None, _('show which function each change is in')),
179 178 ('', 'reverse', None, _('produce a diff that undoes the changes')),
180 179 ] + diffwsopts + [
181 180 ('U', 'unified', '',
182 181 _('number of lines of context to show'), _('NUM')),
183 182 ('', 'stat', None, _('output diffstat-style summary of changes')),
184 183 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
185 184 ]
186 185
187 186 mergetoolopts = [
188 187 ('t', 'tool', '', _('specify merge tool')),
189 188 ]
190 189
191 190 similarityopts = [
192 191 ('s', 'similarity', '',
193 192 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
194 193 ]
195 194
196 195 subrepoopts = [
197 196 ('S', 'subrepos', None,
198 197 _('recurse into subrepositories'))
199 198 ]
200 199
201 200 debugrevlogopts = [
202 201 ('c', 'changelog', False, _('open changelog')),
203 202 ('m', 'manifest', False, _('open manifest')),
204 203 ('', 'dir', '', _('open directory manifest')),
205 204 ]
206 205
207 206 # Commands start here, listed alphabetically
208 207
209 208 @command('^add',
210 209 walkopts + subrepoopts + dryrunopts,
211 210 _('[OPTION]... [FILE]...'),
212 211 inferrepo=True)
213 212 def add(ui, repo, *pats, **opts):
214 213 """add the specified files on the next commit
215 214
216 215 Schedule files to be version controlled and added to the
217 216 repository.
218 217
219 218 The files will be added to the repository at the next commit. To
220 219 undo an add before that, see :hg:`forget`.
221 220
222 221 If no names are given, add all files to the repository (except
223 222 files matching ``.hgignore``).
224 223
225 224 .. container:: verbose
226 225
227 226 Examples:
228 227
229 228 - New (unknown) files are added
230 229 automatically by :hg:`add`::
231 230
232 231 $ ls
233 232 foo.c
234 233 $ hg status
235 234 ? foo.c
236 235 $ hg add
237 236 adding foo.c
238 237 $ hg status
239 238 A foo.c
240 239
241 240 - Specific files to be added can be specified::
242 241
243 242 $ ls
244 243 bar.c foo.c
245 244 $ hg status
246 245 ? bar.c
247 246 ? foo.c
248 247 $ hg add bar.c
249 248 $ hg status
250 249 A bar.c
251 250 ? foo.c
252 251
253 252 Returns 0 if all files are successfully added.
254 253 """
255 254
256 255 m = scmutil.match(repo[None], pats, opts)
257 256 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
258 257 return rejected and 1 or 0
259 258
260 259 @command('addremove',
261 260 similarityopts + subrepoopts + walkopts + dryrunopts,
262 261 _('[OPTION]... [FILE]...'),
263 262 inferrepo=True)
264 263 def addremove(ui, repo, *pats, **opts):
265 264 """add all new files, delete all missing files
266 265
267 266 Add all new files and remove all missing files from the
268 267 repository.
269 268
270 269 Unless names are given, new files are ignored if they match any of
271 270 the patterns in ``.hgignore``. As with add, these changes take
272 271 effect at the next commit.
273 272
274 273 Use the -s/--similarity option to detect renamed files. This
275 274 option takes a percentage between 0 (disabled) and 100 (files must
276 275 be identical) as its parameter. With a parameter greater than 0,
277 276 this compares every removed file with every added file and records
278 277 those similar enough as renames. Detecting renamed files this way
279 278 can be expensive. After using this option, :hg:`status -C` can be
280 279 used to check which files were identified as moved or renamed. If
281 280 not specified, -s/--similarity defaults to 100 and only renames of
282 281 identical files are detected.
283 282
284 283 .. container:: verbose
285 284
286 285 Examples:
287 286
288 287 - A number of files (bar.c and foo.c) are new,
289 288 while foobar.c has been removed (without using :hg:`remove`)
290 289 from the repository::
291 290
292 291 $ ls
293 292 bar.c foo.c
294 293 $ hg status
295 294 ! foobar.c
296 295 ? bar.c
297 296 ? foo.c
298 297 $ hg addremove
299 298 adding bar.c
300 299 adding foo.c
301 300 removing foobar.c
302 301 $ hg status
303 302 A bar.c
304 303 A foo.c
305 304 R foobar.c
306 305
307 306 - A file foobar.c was moved to foo.c without using :hg:`rename`.
308 307 Afterwards, it was edited slightly::
309 308
310 309 $ ls
311 310 foo.c
312 311 $ hg status
313 312 ! foobar.c
314 313 ? foo.c
315 314 $ hg addremove --similarity 90
316 315 removing foobar.c
317 316 adding foo.c
318 317 recording removal of foobar.c as rename to foo.c (94% similar)
319 318 $ hg status -C
320 319 A foo.c
321 320 foobar.c
322 321 R foobar.c
323 322
324 323 Returns 0 if all files are successfully added.
325 324 """
326 325 try:
327 326 sim = float(opts.get('similarity') or 100)
328 327 except ValueError:
329 328 raise error.Abort(_('similarity must be a number'))
330 329 if sim < 0 or sim > 100:
331 330 raise error.Abort(_('similarity must be between 0 and 100'))
332 331 matcher = scmutil.match(repo[None], pats, opts)
333 332 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
334 333
335 334 @command('^annotate|blame',
336 335 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
337 336 ('', 'follow', None,
338 337 _('follow copies/renames and list the filename (DEPRECATED)')),
339 338 ('', 'no-follow', None, _("don't follow copies and renames")),
340 339 ('a', 'text', None, _('treat all files as text')),
341 340 ('u', 'user', None, _('list the author (long with -v)')),
342 341 ('f', 'file', None, _('list the filename')),
343 342 ('d', 'date', None, _('list the date (short with -q)')),
344 343 ('n', 'number', None, _('list the revision number (default)')),
345 344 ('c', 'changeset', None, _('list the changeset')),
346 345 ('l', 'line-number', None, _('show line number at the first appearance'))
347 346 ] + diffwsopts + walkopts + formatteropts,
348 347 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
349 348 inferrepo=True)
350 349 def annotate(ui, repo, *pats, **opts):
351 350 """show changeset information by line for each file
352 351
353 352 List changes in files, showing the revision id responsible for
354 353 each line.
355 354
356 355 This command is useful for discovering when a change was made and
357 356 by whom.
358 357
359 358 If you include --file, --user, or --date, the revision number is
360 359 suppressed unless you also include --number.
361 360
362 361 Without the -a/--text option, annotate will avoid processing files
363 362 it detects as binary. With -a, annotate will annotate the file
364 363 anyway, although the results will probably be neither useful
365 364 nor desirable.
366 365
367 366 Returns 0 on success.
368 367 """
369 368 if not pats:
370 369 raise error.Abort(_('at least one filename or pattern is required'))
371 370
372 371 if opts.get('follow'):
373 372 # --follow is deprecated and now just an alias for -f/--file
374 373 # to mimic the behavior of Mercurial before version 1.5
375 374 opts['file'] = True
376 375
377 376 ctx = scmutil.revsingle(repo, opts.get('rev'))
378 377
379 378 fm = ui.formatter('annotate', opts)
380 379 if ui.quiet:
381 380 datefunc = util.shortdate
382 381 else:
383 382 datefunc = util.datestr
384 383 if ctx.rev() is None:
385 384 def hexfn(node):
386 385 if node is None:
387 386 return None
388 387 else:
389 388 return fm.hexfunc(node)
390 389 if opts.get('changeset'):
391 390 # omit "+" suffix which is appended to node hex
392 391 def formatrev(rev):
393 392 if rev is None:
394 393 return '%d' % ctx.p1().rev()
395 394 else:
396 395 return '%d' % rev
397 396 else:
398 397 def formatrev(rev):
399 398 if rev is None:
400 399 return '%d+' % ctx.p1().rev()
401 400 else:
402 401 return '%d ' % rev
403 402 def formathex(hex):
404 403 if hex is None:
405 404 return '%s+' % fm.hexfunc(ctx.p1().node())
406 405 else:
407 406 return '%s ' % hex
408 407 else:
409 408 hexfn = fm.hexfunc
410 409 formatrev = formathex = str
411 410
412 411 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
413 412 ('number', ' ', lambda x: x[0].rev(), formatrev),
414 413 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
415 414 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
416 415 ('file', ' ', lambda x: x[0].path(), str),
417 416 ('line_number', ':', lambda x: x[1], str),
418 417 ]
419 418 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
420 419
421 420 if (not opts.get('user') and not opts.get('changeset')
422 421 and not opts.get('date') and not opts.get('file')):
423 422 opts['number'] = True
424 423
425 424 linenumber = opts.get('line_number') is not None
426 425 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
427 426 raise error.Abort(_('at least one of -n/-c is required for -l'))
428 427
429 428 ui.pager('annotate')
430 429
431 430 if fm.isplain():
432 431 def makefunc(get, fmt):
433 432 return lambda x: fmt(get(x))
434 433 else:
435 434 def makefunc(get, fmt):
436 435 return get
437 436 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
438 437 if opts.get(op)]
439 438 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
440 439 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
441 440 if opts.get(op))
442 441
443 442 def bad(x, y):
444 443 raise error.Abort("%s: %s" % (x, y))
445 444
446 445 m = scmutil.match(ctx, pats, opts, badfn=bad)
447 446
448 447 follow = not opts.get('no_follow')
449 448 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
450 449 whitespace=True)
451 450 for abs in ctx.walk(m):
452 451 fctx = ctx[abs]
453 452 if not opts.get('text') and util.binary(fctx.data()):
454 453 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
455 454 continue
456 455
457 456 lines = fctx.annotate(follow=follow, linenumber=linenumber,
458 457 diffopts=diffopts)
459 458 if not lines:
460 459 continue
461 460 formats = []
462 461 pieces = []
463 462
464 463 for f, sep in funcmap:
465 464 l = [f(n) for n, dummy in lines]
466 465 if fm.isplain():
467 466 sizes = [encoding.colwidth(x) for x in l]
468 467 ml = max(sizes)
469 468 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
470 469 else:
471 470 formats.append(['%s' for x in l])
472 471 pieces.append(l)
473 472
474 473 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
475 474 fm.startitem()
476 475 fm.write(fields, "".join(f), *p)
477 476 fm.write('line', ": %s", l[1])
478 477
479 478 if not lines[-1][1].endswith('\n'):
480 479 fm.plain('\n')
481 480
482 481 fm.end()
483 482
484 483 @command('archive',
485 484 [('', 'no-decode', None, _('do not pass files through decoders')),
486 485 ('p', 'prefix', '', _('directory prefix for files in archive'),
487 486 _('PREFIX')),
488 487 ('r', 'rev', '', _('revision to distribute'), _('REV')),
489 488 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
490 489 ] + subrepoopts + walkopts,
491 490 _('[OPTION]... DEST'))
492 491 def archive(ui, repo, dest, **opts):
493 492 '''create an unversioned archive of a repository revision
494 493
495 494 By default, the revision used is the parent of the working
496 495 directory; use -r/--rev to specify a different revision.
497 496
498 497 The archive type is automatically detected based on file
499 498 extension (to override, use -t/--type).
500 499
501 500 .. container:: verbose
502 501
503 502 Examples:
504 503
505 504 - create a zip file containing the 1.0 release::
506 505
507 506 hg archive -r 1.0 project-1.0.zip
508 507
509 508 - create a tarball excluding .hg files::
510 509
511 510 hg archive project.tar.gz -X ".hg*"
512 511
513 512 Valid types are:
514 513
515 514 :``files``: a directory full of files (default)
516 515 :``tar``: tar archive, uncompressed
517 516 :``tbz2``: tar archive, compressed using bzip2
518 517 :``tgz``: tar archive, compressed using gzip
519 518 :``uzip``: zip archive, uncompressed
520 519 :``zip``: zip archive, compressed using deflate
521 520
522 521 The exact name of the destination archive or directory is given
523 522 using a format string; see :hg:`help export` for details.
524 523
525 524 Each member added to an archive file has a directory prefix
526 525 prepended. Use -p/--prefix to specify a format string for the
527 526 prefix. The default is the basename of the archive, with suffixes
528 527 removed.
529 528
530 529 Returns 0 on success.
531 530 '''
532 531
533 532 ctx = scmutil.revsingle(repo, opts.get('rev'))
534 533 if not ctx:
535 534 raise error.Abort(_('no working directory: please specify a revision'))
536 535 node = ctx.node()
537 536 dest = cmdutil.makefilename(repo, dest, node)
538 537 if os.path.realpath(dest) == repo.root:
539 538 raise error.Abort(_('repository root cannot be destination'))
540 539
541 540 kind = opts.get('type') or archival.guesskind(dest) or 'files'
542 541 prefix = opts.get('prefix')
543 542
544 543 if dest == '-':
545 544 if kind == 'files':
546 545 raise error.Abort(_('cannot archive plain files to stdout'))
547 546 dest = cmdutil.makefileobj(repo, dest)
548 547 if not prefix:
549 548 prefix = os.path.basename(repo.root) + '-%h'
550 549
551 550 prefix = cmdutil.makefilename(repo, prefix, node)
552 551 matchfn = scmutil.match(ctx, [], opts)
553 552 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
554 553 matchfn, prefix, subrepos=opts.get('subrepos'))
555 554
556 555 @command('backout',
557 556 [('', 'merge', None, _('merge with old dirstate parent after backout')),
558 557 ('', 'commit', None,
559 558 _('commit if no conflicts were encountered (DEPRECATED)')),
560 559 ('', 'no-commit', None, _('do not commit')),
561 560 ('', 'parent', '',
562 561 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
563 562 ('r', 'rev', '', _('revision to backout'), _('REV')),
564 563 ('e', 'edit', False, _('invoke editor on commit messages')),
565 564 ] + mergetoolopts + walkopts + commitopts + commitopts2,
566 565 _('[OPTION]... [-r] REV'))
567 566 def backout(ui, repo, node=None, rev=None, **opts):
568 567 '''reverse effect of earlier changeset
569 568
570 569 Prepare a new changeset with the effect of REV undone in the
571 570 current working directory. If no conflicts were encountered,
572 571 it will be committed immediately.
573 572
574 573 If REV is the parent of the working directory, then this new changeset
575 574 is committed automatically (unless --no-commit is specified).
576 575
577 576 .. note::
578 577
579 578 :hg:`backout` cannot be used to fix either an unwanted or
580 579 incorrect merge.
581 580
582 581 .. container:: verbose
583 582
584 583 Examples:
585 584
586 585 - Reverse the effect of the parent of the working directory.
587 586 This backout will be committed immediately::
588 587
589 588 hg backout -r .
590 589
591 590 - Reverse the effect of previous bad revision 23::
592 591
593 592 hg backout -r 23
594 593
595 594 - Reverse the effect of previous bad revision 23 and
596 595 leave changes uncommitted::
597 596
598 597 hg backout -r 23 --no-commit
599 598 hg commit -m "Backout revision 23"
600 599
601 600 By default, the pending changeset will have one parent,
602 601 maintaining a linear history. With --merge, the pending
603 602 changeset will instead have two parents: the old parent of the
604 603 working directory and a new child of REV that simply undoes REV.
605 604
606 605 Before version 1.7, the behavior without --merge was equivalent
607 606 to specifying --merge followed by :hg:`update --clean .` to
608 607 cancel the merge and leave the child of REV as a head to be
609 608 merged separately.
610 609
611 610 See :hg:`help dates` for a list of formats valid for -d/--date.
612 611
613 612 See :hg:`help revert` for a way to restore files to the state
614 613 of another revision.
615 614
616 615 Returns 0 on success, 1 if nothing to backout or there are unresolved
617 616 files.
618 617 '''
619 618 wlock = lock = None
620 619 try:
621 620 wlock = repo.wlock()
622 621 lock = repo.lock()
623 622 return _dobackout(ui, repo, node, rev, **opts)
624 623 finally:
625 624 release(lock, wlock)
626 625
627 626 def _dobackout(ui, repo, node=None, rev=None, **opts):
628 627 if opts.get('commit') and opts.get('no_commit'):
629 628 raise error.Abort(_("cannot use --commit with --no-commit"))
630 629 if opts.get('merge') and opts.get('no_commit'):
631 630 raise error.Abort(_("cannot use --merge with --no-commit"))
632 631
633 632 if rev and node:
634 633 raise error.Abort(_("please specify just one revision"))
635 634
636 635 if not rev:
637 636 rev = node
638 637
639 638 if not rev:
640 639 raise error.Abort(_("please specify a revision to backout"))
641 640
642 641 date = opts.get('date')
643 642 if date:
644 643 opts['date'] = util.parsedate(date)
645 644
646 645 cmdutil.checkunfinished(repo)
647 646 cmdutil.bailifchanged(repo)
648 647 node = scmutil.revsingle(repo, rev).node()
649 648
650 649 op1, op2 = repo.dirstate.parents()
651 650 if not repo.changelog.isancestor(node, op1):
652 651 raise error.Abort(_('cannot backout change that is not an ancestor'))
653 652
654 653 p1, p2 = repo.changelog.parents(node)
655 654 if p1 == nullid:
656 655 raise error.Abort(_('cannot backout a change with no parents'))
657 656 if p2 != nullid:
658 657 if not opts.get('parent'):
659 658 raise error.Abort(_('cannot backout a merge changeset'))
660 659 p = repo.lookup(opts['parent'])
661 660 if p not in (p1, p2):
662 661 raise error.Abort(_('%s is not a parent of %s') %
663 662 (short(p), short(node)))
664 663 parent = p
665 664 else:
666 665 if opts.get('parent'):
667 666 raise error.Abort(_('cannot use --parent on non-merge changeset'))
668 667 parent = p1
669 668
670 669 # the backout should appear on the same branch
671 670 branch = repo.dirstate.branch()
672 671 bheads = repo.branchheads(branch)
673 672 rctx = scmutil.revsingle(repo, hex(parent))
674 673 if not opts.get('merge') and op1 != node:
675 674 dsguard = dirstateguard.dirstateguard(repo, 'backout')
676 675 try:
677 676 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
678 677 'backout')
679 678 stats = mergemod.update(repo, parent, True, True, node, False)
680 679 repo.setparents(op1, op2)
681 680 dsguard.close()
682 681 hg._showstats(repo, stats)
683 682 if stats[3]:
684 683 repo.ui.status(_("use 'hg resolve' to retry unresolved "
685 684 "file merges\n"))
686 685 return 1
687 686 finally:
688 687 ui.setconfig('ui', 'forcemerge', '', '')
689 688 lockmod.release(dsguard)
690 689 else:
691 690 hg.clean(repo, node, show_stats=False)
692 691 repo.dirstate.setbranch(branch)
693 692 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
694 693
695 694 if opts.get('no_commit'):
696 695 msg = _("changeset %s backed out, "
697 696 "don't forget to commit.\n")
698 697 ui.status(msg % short(node))
699 698 return 0
700 699
701 700 def commitfunc(ui, repo, message, match, opts):
702 701 editform = 'backout'
703 702 e = cmdutil.getcommiteditor(editform=editform, **opts)
704 703 if not message:
705 704 # we don't translate commit messages
706 705 message = "Backed out changeset %s" % short(node)
707 706 e = cmdutil.getcommiteditor(edit=True, editform=editform)
708 707 return repo.commit(message, opts.get('user'), opts.get('date'),
709 708 match, editor=e)
710 709 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
711 710 if not newnode:
712 711 ui.status(_("nothing changed\n"))
713 712 return 1
714 713 cmdutil.commitstatus(repo, newnode, branch, bheads)
715 714
716 715 def nice(node):
717 716 return '%d:%s' % (repo.changelog.rev(node), short(node))
718 717 ui.status(_('changeset %s backs out changeset %s\n') %
719 718 (nice(repo.changelog.tip()), nice(node)))
720 719 if opts.get('merge') and op1 != node:
721 720 hg.clean(repo, op1, show_stats=False)
722 721 ui.status(_('merging with changeset %s\n')
723 722 % nice(repo.changelog.tip()))
724 723 try:
725 724 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
726 725 'backout')
727 726 return hg.merge(repo, hex(repo.changelog.tip()))
728 727 finally:
729 728 ui.setconfig('ui', 'forcemerge', '', '')
730 729 return 0
731 730
732 731 @command('bisect',
733 732 [('r', 'reset', False, _('reset bisect state')),
734 733 ('g', 'good', False, _('mark changeset good')),
735 734 ('b', 'bad', False, _('mark changeset bad')),
736 735 ('s', 'skip', False, _('skip testing changeset')),
737 736 ('e', 'extend', False, _('extend the bisect range')),
738 737 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
739 738 ('U', 'noupdate', False, _('do not update to target'))],
740 739 _("[-gbsr] [-U] [-c CMD] [REV]"))
741 740 def bisect(ui, repo, rev=None, extra=None, command=None,
742 741 reset=None, good=None, bad=None, skip=None, extend=None,
743 742 noupdate=None):
744 743 """subdivision search of changesets
745 744
746 745 This command helps to find changesets which introduce problems. To
747 746 use, mark the earliest changeset you know exhibits the problem as
748 747 bad, then mark the latest changeset which is free from the problem
749 748 as good. Bisect will update your working directory to a revision
750 749 for testing (unless the -U/--noupdate option is specified). Once
751 750 you have performed tests, mark the working directory as good or
752 751 bad, and bisect will either update to another candidate changeset
753 752 or announce that it has found the bad revision.
754 753
755 754 As a shortcut, you can also use the revision argument to mark a
756 755 revision as good or bad without checking it out first.
757 756
758 757 If you supply a command, it will be used for automatic bisection.
759 758 The environment variable HG_NODE will contain the ID of the
760 759 changeset being tested. The exit status of the command will be
761 760 used to mark revisions as good or bad: status 0 means good, 125
762 761 means to skip the revision, 127 (command not found) will abort the
763 762 bisection, and any other non-zero exit status means the revision
764 763 is bad.
765 764
766 765 .. container:: verbose
767 766
768 767 Some examples:
769 768
770 769 - start a bisection with known bad revision 34, and good revision 12::
771 770
772 771 hg bisect --bad 34
773 772 hg bisect --good 12
774 773
775 774 - advance the current bisection by marking current revision as good or
776 775 bad::
777 776
778 777 hg bisect --good
779 778 hg bisect --bad
780 779
781 780 - mark the current revision, or a known revision, to be skipped (e.g. if
782 781 that revision is not usable because of another issue)::
783 782
784 783 hg bisect --skip
785 784 hg bisect --skip 23
786 785
787 786 - skip all revisions that do not touch directories ``foo`` or ``bar``::
788 787
789 788 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
790 789
791 790 - forget the current bisection::
792 791
793 792 hg bisect --reset
794 793
795 794 - use 'make && make tests' to automatically find the first broken
796 795 revision::
797 796
798 797 hg bisect --reset
799 798 hg bisect --bad 34
800 799 hg bisect --good 12
801 800 hg bisect --command "make && make tests"
802 801
803 802 - see all changesets whose states are already known in the current
804 803 bisection::
805 804
806 805 hg log -r "bisect(pruned)"
807 806
808 807 - see the changeset currently being bisected (especially useful
809 808 if running with -U/--noupdate)::
810 809
811 810 hg log -r "bisect(current)"
812 811
813 812 - see all changesets that took part in the current bisection::
814 813
815 814 hg log -r "bisect(range)"
816 815
817 816 - you can even get a nice graph::
818 817
819 818 hg log --graph -r "bisect(range)"
820 819
821 820 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
822 821
823 822 Returns 0 on success.
824 823 """
825 824 # backward compatibility
826 825 if rev in "good bad reset init".split():
827 826 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
828 827 cmd, rev, extra = rev, extra, None
829 828 if cmd == "good":
830 829 good = True
831 830 elif cmd == "bad":
832 831 bad = True
833 832 else:
834 833 reset = True
835 834 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
836 835 raise error.Abort(_('incompatible arguments'))
837 836
838 837 cmdutil.checkunfinished(repo)
839 838
840 839 if reset:
841 840 hbisect.resetstate(repo)
842 841 return
843 842
844 843 state = hbisect.load_state(repo)
845 844
846 845 # update state
847 846 if good or bad or skip:
848 847 if rev:
849 848 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
850 849 else:
851 850 nodes = [repo.lookup('.')]
852 851 if good:
853 852 state['good'] += nodes
854 853 elif bad:
855 854 state['bad'] += nodes
856 855 elif skip:
857 856 state['skip'] += nodes
858 857 hbisect.save_state(repo, state)
859 858 if not (state['good'] and state['bad']):
860 859 return
861 860
862 861 def mayupdate(repo, node, show_stats=True):
863 862 """common used update sequence"""
864 863 if noupdate:
865 864 return
866 865 cmdutil.bailifchanged(repo)
867 866 return hg.clean(repo, node, show_stats=show_stats)
868 867
869 868 displayer = cmdutil.show_changeset(ui, repo, {})
870 869
871 870 if command:
872 871 changesets = 1
873 872 if noupdate:
874 873 try:
875 874 node = state['current'][0]
876 875 except LookupError:
877 876 raise error.Abort(_('current bisect revision is unknown - '
878 877 'start a new bisect to fix'))
879 878 else:
880 879 node, p2 = repo.dirstate.parents()
881 880 if p2 != nullid:
882 881 raise error.Abort(_('current bisect revision is a merge'))
883 882 if rev:
884 883 node = repo[scmutil.revsingle(repo, rev, node)].node()
885 884 try:
886 885 while changesets:
887 886 # update state
888 887 state['current'] = [node]
889 888 hbisect.save_state(repo, state)
890 889 status = ui.system(command, environ={'HG_NODE': hex(node)})
891 890 if status == 125:
892 891 transition = "skip"
893 892 elif status == 0:
894 893 transition = "good"
895 894 # status < 0 means process was killed
896 895 elif status == 127:
897 896 raise error.Abort(_("failed to execute %s") % command)
898 897 elif status < 0:
899 898 raise error.Abort(_("%s killed") % command)
900 899 else:
901 900 transition = "bad"
902 901 state[transition].append(node)
903 902 ctx = repo[node]
904 903 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
905 904 hbisect.checkstate(state)
906 905 # bisect
907 906 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
908 907 # update to next check
909 908 node = nodes[0]
910 909 mayupdate(repo, node, show_stats=False)
911 910 finally:
912 911 state['current'] = [node]
913 912 hbisect.save_state(repo, state)
914 913 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
915 914 return
916 915
917 916 hbisect.checkstate(state)
918 917
919 918 # actually bisect
920 919 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
921 920 if extend:
922 921 if not changesets:
923 922 extendnode = hbisect.extendrange(repo, state, nodes, good)
924 923 if extendnode is not None:
925 924 ui.write(_("Extending search to changeset %d:%s\n")
926 925 % (extendnode.rev(), extendnode))
927 926 state['current'] = [extendnode.node()]
928 927 hbisect.save_state(repo, state)
929 928 return mayupdate(repo, extendnode.node())
930 929 raise error.Abort(_("nothing to extend"))
931 930
932 931 if changesets == 0:
933 932 hbisect.printresult(ui, repo, state, displayer, nodes, good)
934 933 else:
935 934 assert len(nodes) == 1 # only a single node can be tested next
936 935 node = nodes[0]
937 936 # compute the approximate number of remaining tests
938 937 tests, size = 0, 2
939 938 while size <= changesets:
940 939 tests, size = tests + 1, size * 2
941 940 rev = repo.changelog.rev(node)
942 941 ui.write(_("Testing changeset %d:%s "
943 942 "(%d changesets remaining, ~%d tests)\n")
944 943 % (rev, short(node), changesets, tests))
945 944 state['current'] = [node]
946 945 hbisect.save_state(repo, state)
947 946 return mayupdate(repo, node)
948 947
949 948 @command('bookmarks|bookmark',
950 949 [('f', 'force', False, _('force')),
951 950 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
952 951 ('d', 'delete', False, _('delete a given bookmark')),
953 952 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
954 953 ('i', 'inactive', False, _('mark a bookmark inactive')),
955 954 ] + formatteropts,
956 955 _('hg bookmarks [OPTIONS]... [NAME]...'))
957 956 def bookmark(ui, repo, *names, **opts):
958 957 '''create a new bookmark or list existing bookmarks
959 958
960 959 Bookmarks are labels on changesets to help track lines of development.
961 960 Bookmarks are unversioned and can be moved, renamed and deleted.
962 961 Deleting or moving a bookmark has no effect on the associated changesets.
963 962
964 963 Creating or updating to a bookmark causes it to be marked as 'active'.
965 964 The active bookmark is indicated with a '*'.
966 965 When a commit is made, the active bookmark will advance to the new commit.
967 966 A plain :hg:`update` will also advance an active bookmark, if possible.
968 967 Updating away from a bookmark will cause it to be deactivated.
969 968
970 969 Bookmarks can be pushed and pulled between repositories (see
971 970 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
972 971 diverged, a new 'divergent bookmark' of the form 'name@path' will
973 972 be created. Using :hg:`merge` will resolve the divergence.
974 973
975 974 A bookmark named '@' has the special property that :hg:`clone` will
976 975 check it out by default if it exists.
977 976
978 977 .. container:: verbose
979 978
980 979 Examples:
981 980
982 981 - create an active bookmark for a new line of development::
983 982
984 983 hg book new-feature
985 984
986 985 - create an inactive bookmark as a place marker::
987 986
988 987 hg book -i reviewed
989 988
990 989 - create an inactive bookmark on another changeset::
991 990
992 991 hg book -r .^ tested
993 992
994 993 - rename bookmark turkey to dinner::
995 994
996 995 hg book -m turkey dinner
997 996
998 997 - move the '@' bookmark from another branch::
999 998
1000 999 hg book -f @
1001 1000 '''
1002 1001 force = opts.get('force')
1003 1002 rev = opts.get('rev')
1004 1003 delete = opts.get('delete')
1005 1004 rename = opts.get('rename')
1006 1005 inactive = opts.get('inactive')
1007 1006
1008 1007 def checkformat(mark):
1009 1008 mark = mark.strip()
1010 1009 if not mark:
1011 1010 raise error.Abort(_("bookmark names cannot consist entirely of "
1012 1011 "whitespace"))
1013 1012 scmutil.checknewlabel(repo, mark, 'bookmark')
1014 1013 return mark
1015 1014
1016 1015 def checkconflict(repo, mark, cur, force=False, target=None):
1017 1016 if mark in marks and not force:
1018 1017 if target:
1019 1018 if marks[mark] == target and target == cur:
1020 1019 # re-activating a bookmark
1021 1020 return
1022 1021 anc = repo.changelog.ancestors([repo[target].rev()])
1023 1022 bmctx = repo[marks[mark]]
1024 1023 divs = [repo[b].node() for b in marks
1025 1024 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
1026 1025
1027 1026 # allow resolving a single divergent bookmark even if moving
1028 1027 # the bookmark across branches when a revision is specified
1029 1028 # that contains a divergent bookmark
1030 1029 if bmctx.rev() not in anc and target in divs:
1031 1030 bookmarks.deletedivergent(repo, [target], mark)
1032 1031 return
1033 1032
1034 1033 deletefrom = [b for b in divs
1035 1034 if repo[b].rev() in anc or b == target]
1036 1035 bookmarks.deletedivergent(repo, deletefrom, mark)
1037 1036 if bookmarks.validdest(repo, bmctx, repo[target]):
1038 1037 ui.status(_("moving bookmark '%s' forward from %s\n") %
1039 1038 (mark, short(bmctx.node())))
1040 1039 return
1041 1040 raise error.Abort(_("bookmark '%s' already exists "
1042 1041 "(use -f to force)") % mark)
1043 1042 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1044 1043 and not force):
1045 1044 raise error.Abort(
1046 1045 _("a bookmark cannot have the name of an existing branch"))
1047 1046
1048 1047 if delete and rename:
1049 1048 raise error.Abort(_("--delete and --rename are incompatible"))
1050 1049 if delete and rev:
1051 1050 raise error.Abort(_("--rev is incompatible with --delete"))
1052 1051 if rename and rev:
1053 1052 raise error.Abort(_("--rev is incompatible with --rename"))
1054 1053 if not names and (delete or rev):
1055 1054 raise error.Abort(_("bookmark name required"))
1056 1055
1057 1056 if delete or rename or names or inactive:
1058 1057 wlock = lock = tr = None
1059 1058 try:
1060 1059 wlock = repo.wlock()
1061 1060 lock = repo.lock()
1062 1061 cur = repo.changectx('.').node()
1063 1062 marks = repo._bookmarks
1064 1063 if delete:
1065 1064 tr = repo.transaction('bookmark')
1066 1065 for mark in names:
1067 1066 if mark not in marks:
1068 1067 raise error.Abort(_("bookmark '%s' does not exist") %
1069 1068 mark)
1070 1069 if mark == repo._activebookmark:
1071 1070 bookmarks.deactivate(repo)
1072 1071 del marks[mark]
1073 1072
1074 1073 elif rename:
1075 1074 tr = repo.transaction('bookmark')
1076 1075 if not names:
1077 1076 raise error.Abort(_("new bookmark name required"))
1078 1077 elif len(names) > 1:
1079 1078 raise error.Abort(_("only one new bookmark name allowed"))
1080 1079 mark = checkformat(names[0])
1081 1080 if rename not in marks:
1082 1081 raise error.Abort(_("bookmark '%s' does not exist")
1083 1082 % rename)
1084 1083 checkconflict(repo, mark, cur, force)
1085 1084 marks[mark] = marks[rename]
1086 1085 if repo._activebookmark == rename and not inactive:
1087 1086 bookmarks.activate(repo, mark)
1088 1087 del marks[rename]
1089 1088 elif names:
1090 1089 tr = repo.transaction('bookmark')
1091 1090 newact = None
1092 1091 for mark in names:
1093 1092 mark = checkformat(mark)
1094 1093 if newact is None:
1095 1094 newact = mark
1096 1095 if inactive and mark == repo._activebookmark:
1097 1096 bookmarks.deactivate(repo)
1098 1097 return
1099 1098 tgt = cur
1100 1099 if rev:
1101 1100 tgt = scmutil.revsingle(repo, rev).node()
1102 1101 checkconflict(repo, mark, cur, force, tgt)
1103 1102 marks[mark] = tgt
1104 1103 if not inactive and cur == marks[newact] and not rev:
1105 1104 bookmarks.activate(repo, newact)
1106 1105 elif cur != tgt and newact == repo._activebookmark:
1107 1106 bookmarks.deactivate(repo)
1108 1107 elif inactive:
1109 1108 if len(marks) == 0:
1110 1109 ui.status(_("no bookmarks set\n"))
1111 1110 elif not repo._activebookmark:
1112 1111 ui.status(_("no active bookmark\n"))
1113 1112 else:
1114 1113 bookmarks.deactivate(repo)
1115 1114 if tr is not None:
1116 1115 marks.recordchange(tr)
1117 1116 tr.close()
1118 1117 finally:
1119 1118 lockmod.release(tr, lock, wlock)
1120 1119 else: # show bookmarks
1121 1120 fm = ui.formatter('bookmarks', opts)
1122 1121 hexfn = fm.hexfunc
1123 1122 marks = repo._bookmarks
1124 1123 if len(marks) == 0 and fm.isplain():
1125 1124 ui.status(_("no bookmarks set\n"))
1126 1125 for bmark, n in sorted(marks.iteritems()):
1127 1126 active = repo._activebookmark
1128 1127 if bmark == active:
1129 1128 prefix, label = '*', activebookmarklabel
1130 1129 else:
1131 1130 prefix, label = ' ', ''
1132 1131
1133 1132 fm.startitem()
1134 1133 if not ui.quiet:
1135 1134 fm.plain(' %s ' % prefix, label=label)
1136 1135 fm.write('bookmark', '%s', bmark, label=label)
1137 1136 pad = " " * (25 - encoding.colwidth(bmark))
1138 1137 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1139 1138 repo.changelog.rev(n), hexfn(n), label=label)
1140 1139 fm.data(active=(bmark == active))
1141 1140 fm.plain('\n')
1142 1141 fm.end()
1143 1142
1144 1143 @command('branch',
1145 1144 [('f', 'force', None,
1146 1145 _('set branch name even if it shadows an existing branch')),
1147 1146 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1148 1147 _('[-fC] [NAME]'))
1149 1148 def branch(ui, repo, label=None, **opts):
1150 1149 """set or show the current branch name
1151 1150
1152 1151 .. note::
1153 1152
1154 1153 Branch names are permanent and global. Use :hg:`bookmark` to create a
1155 1154 light-weight bookmark instead. See :hg:`help glossary` for more
1156 1155 information about named branches and bookmarks.
1157 1156
1158 1157 With no argument, show the current branch name. With one argument,
1159 1158 set the working directory branch name (the branch will not exist
1160 1159 in the repository until the next commit). Standard practice
1161 1160 recommends that primary development take place on the 'default'
1162 1161 branch.
1163 1162
1164 1163 Unless -f/--force is specified, branch will not let you set a
1165 1164 branch name that already exists.
1166 1165
1167 1166 Use -C/--clean to reset the working directory branch to that of
1168 1167 the parent of the working directory, negating a previous branch
1169 1168 change.
1170 1169
1171 1170 Use the command :hg:`update` to switch to an existing branch. Use
1172 1171 :hg:`commit --close-branch` to mark this branch head as closed.
1173 1172 When all heads of a branch are closed, the branch will be
1174 1173 considered closed.
1175 1174
1176 1175 Returns 0 on success.
1177 1176 """
1178 1177 if label:
1179 1178 label = label.strip()
1180 1179
1181 1180 if not opts.get('clean') and not label:
1182 1181 ui.write("%s\n" % repo.dirstate.branch())
1183 1182 return
1184 1183
1185 1184 with repo.wlock():
1186 1185 if opts.get('clean'):
1187 1186 label = repo[None].p1().branch()
1188 1187 repo.dirstate.setbranch(label)
1189 1188 ui.status(_('reset working directory to branch %s\n') % label)
1190 1189 elif label:
1191 1190 if not opts.get('force') and label in repo.branchmap():
1192 1191 if label not in [p.branch() for p in repo[None].parents()]:
1193 1192 raise error.Abort(_('a branch of the same name already'
1194 1193 ' exists'),
1195 1194 # i18n: "it" refers to an existing branch
1196 1195 hint=_("use 'hg update' to switch to it"))
1197 1196 scmutil.checknewlabel(repo, label, 'branch')
1198 1197 repo.dirstate.setbranch(label)
1199 1198 ui.status(_('marked working directory as branch %s\n') % label)
1200 1199
1201 1200 # find any open named branches aside from default
1202 1201 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1203 1202 if n != "default" and not c]
1204 1203 if not others:
1205 1204 ui.status(_('(branches are permanent and global, '
1206 1205 'did you want a bookmark?)\n'))
1207 1206
1208 1207 @command('branches',
1209 1208 [('a', 'active', False,
1210 1209 _('show only branches that have unmerged heads (DEPRECATED)')),
1211 1210 ('c', 'closed', False, _('show normal and closed branches')),
1212 1211 ] + formatteropts,
1213 1212 _('[-c]'))
1214 1213 def branches(ui, repo, active=False, closed=False, **opts):
1215 1214 """list repository named branches
1216 1215
1217 1216 List the repository's named branches, indicating which ones are
1218 1217 inactive. If -c/--closed is specified, also list branches which have
1219 1218 been marked closed (see :hg:`commit --close-branch`).
1220 1219
1221 1220 Use the command :hg:`update` to switch to an existing branch.
1222 1221
1223 1222 Returns 0.
1224 1223 """
1225 1224
1226 1225 fm = ui.formatter('branches', opts)
1227 1226 hexfunc = fm.hexfunc
1228 1227
1229 1228 allheads = set(repo.heads())
1230 1229 branches = []
1231 1230 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1232 1231 isactive = not isclosed and bool(set(heads) & allheads)
1233 1232 branches.append((tag, repo[tip], isactive, not isclosed))
1234 1233 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1235 1234 reverse=True)
1236 1235
1237 1236 for tag, ctx, isactive, isopen in branches:
1238 1237 if active and not isactive:
1239 1238 continue
1240 1239 if isactive:
1241 1240 label = 'branches.active'
1242 1241 notice = ''
1243 1242 elif not isopen:
1244 1243 if not closed:
1245 1244 continue
1246 1245 label = 'branches.closed'
1247 1246 notice = _(' (closed)')
1248 1247 else:
1249 1248 label = 'branches.inactive'
1250 1249 notice = _(' (inactive)')
1251 1250 current = (tag == repo.dirstate.branch())
1252 1251 if current:
1253 1252 label = 'branches.current'
1254 1253
1255 1254 fm.startitem()
1256 1255 fm.write('branch', '%s', tag, label=label)
1257 1256 rev = ctx.rev()
1258 1257 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1259 1258 fmt = ' ' * padsize + ' %d:%s'
1260 1259 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1261 1260 label='log.changeset changeset.%s' % ctx.phasestr())
1262 1261 fm.data(active=isactive, closed=not isopen, current=current)
1263 1262 if not ui.quiet:
1264 1263 fm.plain(notice)
1265 1264 fm.plain('\n')
1266 1265 fm.end()
1267 1266
1268 1267 @command('bundle',
1269 1268 [('f', 'force', None, _('run even when the destination is unrelated')),
1270 1269 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1271 1270 _('REV')),
1272 1271 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1273 1272 _('BRANCH')),
1274 1273 ('', 'base', [],
1275 1274 _('a base changeset assumed to be available at the destination'),
1276 1275 _('REV')),
1277 1276 ('a', 'all', None, _('bundle all changesets in the repository')),
1278 1277 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1279 1278 ] + remoteopts,
1280 1279 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1281 1280 def bundle(ui, repo, fname, dest=None, **opts):
1282 1281 """create a changegroup file
1283 1282
1284 1283 Generate a changegroup file collecting changesets to be added
1285 1284 to a repository.
1286 1285
1287 1286 To create a bundle containing all changesets, use -a/--all
1288 1287 (or --base null). Otherwise, hg assumes the destination will have
1289 1288 all the nodes you specify with --base parameters. Otherwise, hg
1290 1289 will assume the repository has all the nodes in destination, or
1291 1290 default-push/default if no destination is specified.
1292 1291
1293 1292 You can change bundle format with the -t/--type option. You can
1294 1293 specify a compression, a bundle version or both using a dash
1295 1294 (comp-version). The available compression methods are: none, bzip2,
1296 1295 and gzip (by default, bundles are compressed using bzip2). The
1297 1296 available formats are: v1, v2 (default to most suitable).
1298 1297
1299 1298 The bundle file can then be transferred using conventional means
1300 1299 and applied to another repository with the unbundle or pull
1301 1300 command. This is useful when direct push and pull are not
1302 1301 available or when exporting an entire repository is undesirable.
1303 1302
1304 1303 Applying bundles preserves all changeset contents including
1305 1304 permissions, copy/rename information, and revision history.
1306 1305
1307 1306 Returns 0 on success, 1 if no changes found.
1308 1307 """
1309 1308 revs = None
1310 1309 if 'rev' in opts:
1311 1310 revstrings = opts['rev']
1312 1311 revs = scmutil.revrange(repo, revstrings)
1313 1312 if revstrings and not revs:
1314 1313 raise error.Abort(_('no commits to bundle'))
1315 1314
1316 1315 bundletype = opts.get('type', 'bzip2').lower()
1317 1316 try:
1318 1317 bcompression, cgversion, params = exchange.parsebundlespec(
1319 1318 repo, bundletype, strict=False)
1320 1319 except error.UnsupportedBundleSpecification as e:
1321 1320 raise error.Abort(str(e),
1322 1321 hint=_("see 'hg help bundle' for supported "
1323 1322 "values for --type"))
1324 1323
1325 1324 # Packed bundles are a pseudo bundle format for now.
1326 1325 if cgversion == 's1':
1327 1326 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1328 1327 hint=_("use 'hg debugcreatestreamclonebundle'"))
1329 1328
1330 1329 if opts.get('all'):
1331 1330 if dest:
1332 1331 raise error.Abort(_("--all is incompatible with specifying "
1333 1332 "a destination"))
1334 1333 if opts.get('base'):
1335 1334 ui.warn(_("ignoring --base because --all was specified\n"))
1336 1335 base = ['null']
1337 1336 else:
1338 1337 base = scmutil.revrange(repo, opts.get('base'))
1339 1338 # TODO: get desired bundlecaps from command line.
1340 1339 bundlecaps = None
1341 1340 if cgversion not in changegroup.supportedoutgoingversions(repo):
1342 1341 raise error.Abort(_("repository does not support bundle version %s") %
1343 1342 cgversion)
1344 1343
1345 1344 if base:
1346 1345 if dest:
1347 1346 raise error.Abort(_("--base is incompatible with specifying "
1348 1347 "a destination"))
1349 1348 common = [repo.lookup(rev) for rev in base]
1350 1349 heads = revs and map(repo.lookup, revs) or None
1351 1350 outgoing = discovery.outgoing(repo, common, heads)
1352 1351 cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
1353 1352 bundlecaps=bundlecaps,
1354 1353 version=cgversion)
1355 1354 outgoing = None
1356 1355 else:
1357 1356 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1358 1357 dest, branches = hg.parseurl(dest, opts.get('branch'))
1359 1358 other = hg.peer(repo, opts, dest)
1360 1359 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1361 1360 heads = revs and map(repo.lookup, revs) or revs
1362 1361 outgoing = discovery.findcommonoutgoing(repo, other,
1363 1362 onlyheads=heads,
1364 1363 force=opts.get('force'),
1365 1364 portable=True)
1366 1365 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1367 1366 bundlecaps, version=cgversion)
1368 1367 if not cg:
1369 1368 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1370 1369 return 1
1371 1370
1372 1371 if cgversion == '01': #bundle1
1373 1372 if bcompression is None:
1374 1373 bcompression = 'UN'
1375 1374 bversion = 'HG10' + bcompression
1376 1375 bcompression = None
1377 1376 else:
1378 1377 assert cgversion == '02'
1379 1378 bversion = 'HG20'
1380 1379
1381 1380 # TODO compression options should be derived from bundlespec parsing.
1382 1381 # This is a temporary hack to allow adjusting bundle compression
1383 1382 # level without a) formalizing the bundlespec changes to declare it
1384 1383 # b) introducing a command flag.
1385 1384 compopts = {}
1386 1385 complevel = ui.configint('experimental', 'bundlecomplevel')
1387 1386 if complevel is not None:
1388 1387 compopts['level'] = complevel
1389 1388
1390 1389 bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression,
1391 1390 compopts=compopts)
1392 1391
1393 1392 @command('cat',
1394 1393 [('o', 'output', '',
1395 1394 _('print output to file with formatted name'), _('FORMAT')),
1396 1395 ('r', 'rev', '', _('print the given revision'), _('REV')),
1397 1396 ('', 'decode', None, _('apply any matching decode filter')),
1398 1397 ] + walkopts,
1399 1398 _('[OPTION]... FILE...'),
1400 1399 inferrepo=True)
1401 1400 def cat(ui, repo, file1, *pats, **opts):
1402 1401 """output the current or given revision of files
1403 1402
1404 1403 Print the specified files as they were at the given revision. If
1405 1404 no revision is given, the parent of the working directory is used.
1406 1405
1407 1406 Output may be to a file, in which case the name of the file is
1408 1407 given using a format string. The formatting rules as follows:
1409 1408
1410 1409 :``%%``: literal "%" character
1411 1410 :``%s``: basename of file being printed
1412 1411 :``%d``: dirname of file being printed, or '.' if in repository root
1413 1412 :``%p``: root-relative path name of file being printed
1414 1413 :``%H``: changeset hash (40 hexadecimal digits)
1415 1414 :``%R``: changeset revision number
1416 1415 :``%h``: short-form changeset hash (12 hexadecimal digits)
1417 1416 :``%r``: zero-padded changeset revision number
1418 1417 :``%b``: basename of the exporting repository
1419 1418
1420 1419 Returns 0 on success.
1421 1420 """
1422 1421 ctx = scmutil.revsingle(repo, opts.get('rev'))
1423 1422 m = scmutil.match(ctx, (file1,) + pats, opts)
1424 1423
1425 1424 ui.pager('cat')
1426 1425 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1427 1426
1428 1427 @command('^clone',
1429 1428 [('U', 'noupdate', None, _('the clone will include an empty working '
1430 1429 'directory (only a repository)')),
1431 1430 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1432 1431 _('REV')),
1433 1432 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1434 1433 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1435 1434 ('', 'pull', None, _('use pull protocol to copy metadata')),
1436 1435 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1437 1436 ] + remoteopts,
1438 1437 _('[OPTION]... SOURCE [DEST]'),
1439 1438 norepo=True)
1440 1439 def clone(ui, source, dest=None, **opts):
1441 1440 """make a copy of an existing repository
1442 1441
1443 1442 Create a copy of an existing repository in a new directory.
1444 1443
1445 1444 If no destination directory name is specified, it defaults to the
1446 1445 basename of the source.
1447 1446
1448 1447 The location of the source is added to the new repository's
1449 1448 ``.hg/hgrc`` file, as the default to be used for future pulls.
1450 1449
1451 1450 Only local paths and ``ssh://`` URLs are supported as
1452 1451 destinations. For ``ssh://`` destinations, no working directory or
1453 1452 ``.hg/hgrc`` will be created on the remote side.
1454 1453
1455 1454 If the source repository has a bookmark called '@' set, that
1456 1455 revision will be checked out in the new repository by default.
1457 1456
1458 1457 To check out a particular version, use -u/--update, or
1459 1458 -U/--noupdate to create a clone with no working directory.
1460 1459
1461 1460 To pull only a subset of changesets, specify one or more revisions
1462 1461 identifiers with -r/--rev or branches with -b/--branch. The
1463 1462 resulting clone will contain only the specified changesets and
1464 1463 their ancestors. These options (or 'clone src#rev dest') imply
1465 1464 --pull, even for local source repositories.
1466 1465
1467 1466 .. note::
1468 1467
1469 1468 Specifying a tag will include the tagged changeset but not the
1470 1469 changeset containing the tag.
1471 1470
1472 1471 .. container:: verbose
1473 1472
1474 1473 For efficiency, hardlinks are used for cloning whenever the
1475 1474 source and destination are on the same filesystem (note this
1476 1475 applies only to the repository data, not to the working
1477 1476 directory). Some filesystems, such as AFS, implement hardlinking
1478 1477 incorrectly, but do not report errors. In these cases, use the
1479 1478 --pull option to avoid hardlinking.
1480 1479
1481 1480 In some cases, you can clone repositories and the working
1482 1481 directory using full hardlinks with ::
1483 1482
1484 1483 $ cp -al REPO REPOCLONE
1485 1484
1486 1485 This is the fastest way to clone, but it is not always safe. The
1487 1486 operation is not atomic (making sure REPO is not modified during
1488 1487 the operation is up to you) and you have to make sure your
1489 1488 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1490 1489 so). Also, this is not compatible with certain extensions that
1491 1490 place their metadata under the .hg directory, such as mq.
1492 1491
1493 1492 Mercurial will update the working directory to the first applicable
1494 1493 revision from this list:
1495 1494
1496 1495 a) null if -U or the source repository has no changesets
1497 1496 b) if -u . and the source repository is local, the first parent of
1498 1497 the source repository's working directory
1499 1498 c) the changeset specified with -u (if a branch name, this means the
1500 1499 latest head of that branch)
1501 1500 d) the changeset specified with -r
1502 1501 e) the tipmost head specified with -b
1503 1502 f) the tipmost head specified with the url#branch source syntax
1504 1503 g) the revision marked with the '@' bookmark, if present
1505 1504 h) the tipmost head of the default branch
1506 1505 i) tip
1507 1506
1508 1507 When cloning from servers that support it, Mercurial may fetch
1509 1508 pre-generated data from a server-advertised URL. When this is done,
1510 1509 hooks operating on incoming changesets and changegroups may fire twice,
1511 1510 once for the bundle fetched from the URL and another for any additional
1512 1511 data not fetched from this URL. In addition, if an error occurs, the
1513 1512 repository may be rolled back to a partial clone. This behavior may
1514 1513 change in future releases. See :hg:`help -e clonebundles` for more.
1515 1514
1516 1515 Examples:
1517 1516
1518 1517 - clone a remote repository to a new directory named hg/::
1519 1518
1520 1519 hg clone https://www.mercurial-scm.org/repo/hg/
1521 1520
1522 1521 - create a lightweight local clone::
1523 1522
1524 1523 hg clone project/ project-feature/
1525 1524
1526 1525 - clone from an absolute path on an ssh server (note double-slash)::
1527 1526
1528 1527 hg clone ssh://user@server//home/projects/alpha/
1529 1528
1530 1529 - do a high-speed clone over a LAN while checking out a
1531 1530 specified version::
1532 1531
1533 1532 hg clone --uncompressed http://server/repo -u 1.5
1534 1533
1535 1534 - create a repository without changesets after a particular revision::
1536 1535
1537 1536 hg clone -r 04e544 experimental/ good/
1538 1537
1539 1538 - clone (and track) a particular named branch::
1540 1539
1541 1540 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1542 1541
1543 1542 See :hg:`help urls` for details on specifying URLs.
1544 1543
1545 1544 Returns 0 on success.
1546 1545 """
1547 1546 if opts.get('noupdate') and opts.get('updaterev'):
1548 1547 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1549 1548
1550 1549 r = hg.clone(ui, opts, source, dest,
1551 1550 pull=opts.get('pull'),
1552 1551 stream=opts.get('uncompressed'),
1553 1552 rev=opts.get('rev'),
1554 1553 update=opts.get('updaterev') or not opts.get('noupdate'),
1555 1554 branch=opts.get('branch'),
1556 1555 shareopts=opts.get('shareopts'))
1557 1556
1558 1557 return r is None
1559 1558
1560 1559 @command('^commit|ci',
1561 1560 [('A', 'addremove', None,
1562 1561 _('mark new/missing files as added/removed before committing')),
1563 1562 ('', 'close-branch', None,
1564 1563 _('mark a branch head as closed')),
1565 1564 ('', 'amend', None, _('amend the parent of the working directory')),
1566 1565 ('s', 'secret', None, _('use the secret phase for committing')),
1567 1566 ('e', 'edit', None, _('invoke editor on commit messages')),
1568 1567 ('i', 'interactive', None, _('use interactive mode')),
1569 1568 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1570 1569 _('[OPTION]... [FILE]...'),
1571 1570 inferrepo=True)
1572 1571 def commit(ui, repo, *pats, **opts):
1573 1572 """commit the specified files or all outstanding changes
1574 1573
1575 1574 Commit changes to the given files into the repository. Unlike a
1576 1575 centralized SCM, this operation is a local operation. See
1577 1576 :hg:`push` for a way to actively distribute your changes.
1578 1577
1579 1578 If a list of files is omitted, all changes reported by :hg:`status`
1580 1579 will be committed.
1581 1580
1582 1581 If you are committing the result of a merge, do not provide any
1583 1582 filenames or -I/-X filters.
1584 1583
1585 1584 If no commit message is specified, Mercurial starts your
1586 1585 configured editor where you can enter a message. In case your
1587 1586 commit fails, you will find a backup of your message in
1588 1587 ``.hg/last-message.txt``.
1589 1588
1590 1589 The --close-branch flag can be used to mark the current branch
1591 1590 head closed. When all heads of a branch are closed, the branch
1592 1591 will be considered closed and no longer listed.
1593 1592
1594 1593 The --amend flag can be used to amend the parent of the
1595 1594 working directory with a new commit that contains the changes
1596 1595 in the parent in addition to those currently reported by :hg:`status`,
1597 1596 if there are any. The old commit is stored in a backup bundle in
1598 1597 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1599 1598 on how to restore it).
1600 1599
1601 1600 Message, user and date are taken from the amended commit unless
1602 1601 specified. When a message isn't specified on the command line,
1603 1602 the editor will open with the message of the amended commit.
1604 1603
1605 1604 It is not possible to amend public changesets (see :hg:`help phases`)
1606 1605 or changesets that have children.
1607 1606
1608 1607 See :hg:`help dates` for a list of formats valid for -d/--date.
1609 1608
1610 1609 Returns 0 on success, 1 if nothing changed.
1611 1610
1612 1611 .. container:: verbose
1613 1612
1614 1613 Examples:
1615 1614
1616 1615 - commit all files ending in .py::
1617 1616
1618 1617 hg commit --include "set:**.py"
1619 1618
1620 1619 - commit all non-binary files::
1621 1620
1622 1621 hg commit --exclude "set:binary()"
1623 1622
1624 1623 - amend the current commit and set the date to now::
1625 1624
1626 1625 hg commit --amend --date now
1627 1626 """
1628 1627 wlock = lock = None
1629 1628 try:
1630 1629 wlock = repo.wlock()
1631 1630 lock = repo.lock()
1632 1631 return _docommit(ui, repo, *pats, **opts)
1633 1632 finally:
1634 1633 release(lock, wlock)
1635 1634
1636 1635 def _docommit(ui, repo, *pats, **opts):
1637 1636 if opts.get('interactive'):
1638 1637 opts.pop('interactive')
1639 1638 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1640 1639 cmdutil.recordfilter, *pats, **opts)
1641 1640 # ret can be 0 (no changes to record) or the value returned by
1642 1641 # commit(), 1 if nothing changed or None on success.
1643 1642 return 1 if ret == 0 else ret
1644 1643
1645 1644 if opts.get('subrepos'):
1646 1645 if opts.get('amend'):
1647 1646 raise error.Abort(_('cannot amend with --subrepos'))
1648 1647 # Let --subrepos on the command line override config setting.
1649 1648 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1650 1649
1651 1650 cmdutil.checkunfinished(repo, commit=True)
1652 1651
1653 1652 branch = repo[None].branch()
1654 1653 bheads = repo.branchheads(branch)
1655 1654
1656 1655 extra = {}
1657 1656 if opts.get('close_branch'):
1658 1657 extra['close'] = 1
1659 1658
1660 1659 if not bheads:
1661 1660 raise error.Abort(_('can only close branch heads'))
1662 1661 elif opts.get('amend'):
1663 1662 if repo[None].parents()[0].p1().branch() != branch and \
1664 1663 repo[None].parents()[0].p2().branch() != branch:
1665 1664 raise error.Abort(_('can only close branch heads'))
1666 1665
1667 1666 if opts.get('amend'):
1668 1667 if ui.configbool('ui', 'commitsubrepos'):
1669 1668 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1670 1669
1671 1670 old = repo['.']
1672 1671 if not old.mutable():
1673 1672 raise error.Abort(_('cannot amend public changesets'))
1674 1673 if len(repo[None].parents()) > 1:
1675 1674 raise error.Abort(_('cannot amend while merging'))
1676 1675 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1677 1676 if not allowunstable and old.children():
1678 1677 raise error.Abort(_('cannot amend changeset with children'))
1679 1678
1680 1679 # Currently histedit gets confused if an amend happens while histedit
1681 1680 # is in progress. Since we have a checkunfinished command, we are
1682 1681 # temporarily honoring it.
1683 1682 #
1684 1683 # Note: eventually this guard will be removed. Please do not expect
1685 1684 # this behavior to remain.
1686 1685 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1687 1686 cmdutil.checkunfinished(repo)
1688 1687
1689 1688 # commitfunc is used only for temporary amend commit by cmdutil.amend
1690 1689 def commitfunc(ui, repo, message, match, opts):
1691 1690 return repo.commit(message,
1692 1691 opts.get('user') or old.user(),
1693 1692 opts.get('date') or old.date(),
1694 1693 match,
1695 1694 extra=extra)
1696 1695
1697 1696 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1698 1697 if node == old.node():
1699 1698 ui.status(_("nothing changed\n"))
1700 1699 return 1
1701 1700 else:
1702 1701 def commitfunc(ui, repo, message, match, opts):
1703 1702 backup = ui.backupconfig('phases', 'new-commit')
1704 1703 baseui = repo.baseui
1705 1704 basebackup = baseui.backupconfig('phases', 'new-commit')
1706 1705 try:
1707 1706 if opts.get('secret'):
1708 1707 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1709 1708 # Propagate to subrepos
1710 1709 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1711 1710
1712 1711 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1713 1712 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1714 1713 return repo.commit(message, opts.get('user'), opts.get('date'),
1715 1714 match,
1716 1715 editor=editor,
1717 1716 extra=extra)
1718 1717 finally:
1719 1718 ui.restoreconfig(backup)
1720 1719 repo.baseui.restoreconfig(basebackup)
1721 1720
1722 1721
1723 1722 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1724 1723
1725 1724 if not node:
1726 1725 stat = cmdutil.postcommitstatus(repo, pats, opts)
1727 1726 if stat[3]:
1728 1727 ui.status(_("nothing changed (%d missing files, see "
1729 1728 "'hg status')\n") % len(stat[3]))
1730 1729 else:
1731 1730 ui.status(_("nothing changed\n"))
1732 1731 return 1
1733 1732
1734 1733 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1735 1734
1736 1735 @command('config|showconfig|debugconfig',
1737 1736 [('u', 'untrusted', None, _('show untrusted configuration options')),
1738 1737 ('e', 'edit', None, _('edit user config')),
1739 1738 ('l', 'local', None, _('edit repository config')),
1740 1739 ('g', 'global', None, _('edit global config'))] + formatteropts,
1741 1740 _('[-u] [NAME]...'),
1742 1741 optionalrepo=True)
1743 1742 def config(ui, repo, *values, **opts):
1744 1743 """show combined config settings from all hgrc files
1745 1744
1746 1745 With no arguments, print names and values of all config items.
1747 1746
1748 1747 With one argument of the form section.name, print just the value
1749 1748 of that config item.
1750 1749
1751 1750 With multiple arguments, print names and values of all config
1752 1751 items with matching section names.
1753 1752
1754 1753 With --edit, start an editor on the user-level config file. With
1755 1754 --global, edit the system-wide config file. With --local, edit the
1756 1755 repository-level config file.
1757 1756
1758 1757 With --debug, the source (filename and line number) is printed
1759 1758 for each config item.
1760 1759
1761 1760 See :hg:`help config` for more information about config files.
1762 1761
1763 1762 Returns 0 on success, 1 if NAME does not exist.
1764 1763
1765 1764 """
1766 1765
1767 1766 if opts.get('edit') or opts.get('local') or opts.get('global'):
1768 1767 if opts.get('local') and opts.get('global'):
1769 1768 raise error.Abort(_("can't use --local and --global together"))
1770 1769
1771 1770 if opts.get('local'):
1772 1771 if not repo:
1773 1772 raise error.Abort(_("can't use --local outside a repository"))
1774 1773 paths = [repo.join('hgrc')]
1775 1774 elif opts.get('global'):
1776 1775 paths = scmutil.systemrcpath()
1777 1776 else:
1778 1777 paths = scmutil.userrcpath()
1779 1778
1780 1779 for f in paths:
1781 1780 if os.path.exists(f):
1782 1781 break
1783 1782 else:
1784 1783 if opts.get('global'):
1785 1784 samplehgrc = uimod.samplehgrcs['global']
1786 1785 elif opts.get('local'):
1787 1786 samplehgrc = uimod.samplehgrcs['local']
1788 1787 else:
1789 1788 samplehgrc = uimod.samplehgrcs['user']
1790 1789
1791 1790 f = paths[0]
1792 1791 fp = open(f, "w")
1793 1792 fp.write(samplehgrc)
1794 1793 fp.close()
1795 1794
1796 1795 editor = ui.geteditor()
1797 1796 ui.system("%s \"%s\"" % (editor, f),
1798 1797 onerr=error.Abort, errprefix=_("edit failed"))
1799 1798 return
1800 1799 ui.pager('config')
1801 1800 fm = ui.formatter('config', opts)
1802 1801 for f in scmutil.rcpath():
1803 1802 ui.debug('read config from: %s\n' % f)
1804 1803 untrusted = bool(opts.get('untrusted'))
1805 1804 if values:
1806 1805 sections = [v for v in values if '.' not in v]
1807 1806 items = [v for v in values if '.' in v]
1808 1807 if len(items) > 1 or items and sections:
1809 1808 raise error.Abort(_('only one config item permitted'))
1810 1809 matched = False
1811 1810 for section, name, value in ui.walkconfig(untrusted=untrusted):
1812 1811 source = ui.configsource(section, name, untrusted)
1813 1812 value = str(value)
1814 1813 if fm.isplain():
1815 1814 source = source or 'none'
1816 1815 value = value.replace('\n', '\\n')
1817 1816 entryname = section + '.' + name
1818 1817 if values:
1819 1818 for v in values:
1820 1819 if v == section:
1821 1820 fm.startitem()
1822 1821 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1823 1822 fm.write('name value', '%s=%s\n', entryname, value)
1824 1823 matched = True
1825 1824 elif v == entryname:
1826 1825 fm.startitem()
1827 1826 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1828 1827 fm.write('value', '%s\n', value)
1829 1828 fm.data(name=entryname)
1830 1829 matched = True
1831 1830 else:
1832 1831 fm.startitem()
1833 1832 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1834 1833 fm.write('name value', '%s=%s\n', entryname, value)
1835 1834 matched = True
1836 1835 fm.end()
1837 1836 if matched:
1838 1837 return 0
1839 1838 return 1
1840 1839
1841 1840 @command('copy|cp',
1842 1841 [('A', 'after', None, _('record a copy that has already occurred')),
1843 1842 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1844 1843 ] + walkopts + dryrunopts,
1845 1844 _('[OPTION]... [SOURCE]... DEST'))
1846 1845 def copy(ui, repo, *pats, **opts):
1847 1846 """mark files as copied for the next commit
1848 1847
1849 1848 Mark dest as having copies of source files. If dest is a
1850 1849 directory, copies are put in that directory. If dest is a file,
1851 1850 the source must be a single file.
1852 1851
1853 1852 By default, this command copies the contents of files as they
1854 1853 exist in the working directory. If invoked with -A/--after, the
1855 1854 operation is recorded, but no copying is performed.
1856 1855
1857 1856 This command takes effect with the next commit. To undo a copy
1858 1857 before that, see :hg:`revert`.
1859 1858
1860 1859 Returns 0 on success, 1 if errors are encountered.
1861 1860 """
1862 1861 with repo.wlock(False):
1863 1862 return cmdutil.copy(ui, repo, pats, opts)
1864 1863
1865 1864 @command('^diff',
1866 1865 [('r', 'rev', [], _('revision'), _('REV')),
1867 1866 ('c', 'change', '', _('change made by revision'), _('REV'))
1868 1867 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1869 1868 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1870 1869 inferrepo=True)
1871 1870 def diff(ui, repo, *pats, **opts):
1872 1871 """diff repository (or selected files)
1873 1872
1874 1873 Show differences between revisions for the specified files.
1875 1874
1876 1875 Differences between files are shown using the unified diff format.
1877 1876
1878 1877 .. note::
1879 1878
1880 1879 :hg:`diff` may generate unexpected results for merges, as it will
1881 1880 default to comparing against the working directory's first
1882 1881 parent changeset if no revisions are specified.
1883 1882
1884 1883 When two revision arguments are given, then changes are shown
1885 1884 between those revisions. If only one revision is specified then
1886 1885 that revision is compared to the working directory, and, when no
1887 1886 revisions are specified, the working directory files are compared
1888 1887 to its first parent.
1889 1888
1890 1889 Alternatively you can specify -c/--change with a revision to see
1891 1890 the changes in that changeset relative to its first parent.
1892 1891
1893 1892 Without the -a/--text option, diff will avoid generating diffs of
1894 1893 files it detects as binary. With -a, diff will generate a diff
1895 1894 anyway, probably with undesirable results.
1896 1895
1897 1896 Use the -g/--git option to generate diffs in the git extended diff
1898 1897 format. For more information, read :hg:`help diffs`.
1899 1898
1900 1899 .. container:: verbose
1901 1900
1902 1901 Examples:
1903 1902
1904 1903 - compare a file in the current working directory to its parent::
1905 1904
1906 1905 hg diff foo.c
1907 1906
1908 1907 - compare two historical versions of a directory, with rename info::
1909 1908
1910 1909 hg diff --git -r 1.0:1.2 lib/
1911 1910
1912 1911 - get change stats relative to the last change on some date::
1913 1912
1914 1913 hg diff --stat -r "date('may 2')"
1915 1914
1916 1915 - diff all newly-added files that contain a keyword::
1917 1916
1918 1917 hg diff "set:added() and grep(GNU)"
1919 1918
1920 1919 - compare a revision and its parents::
1921 1920
1922 1921 hg diff -c 9353 # compare against first parent
1923 1922 hg diff -r 9353^:9353 # same using revset syntax
1924 1923 hg diff -r 9353^2:9353 # compare against the second parent
1925 1924
1926 1925 Returns 0 on success.
1927 1926 """
1928 1927
1929 1928 revs = opts.get('rev')
1930 1929 change = opts.get('change')
1931 1930 stat = opts.get('stat')
1932 1931 reverse = opts.get('reverse')
1933 1932
1934 1933 if revs and change:
1935 1934 msg = _('cannot specify --rev and --change at the same time')
1936 1935 raise error.Abort(msg)
1937 1936 elif change:
1938 1937 node2 = scmutil.revsingle(repo, change, None).node()
1939 1938 node1 = repo[node2].p1().node()
1940 1939 else:
1941 1940 node1, node2 = scmutil.revpair(repo, revs)
1942 1941
1943 1942 if reverse:
1944 1943 node1, node2 = node2, node1
1945 1944
1946 1945 diffopts = patch.diffallopts(ui, opts)
1947 1946 m = scmutil.match(repo[node2], pats, opts)
1948 1947 ui.pager('diff')
1949 1948 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1950 1949 listsubrepos=opts.get('subrepos'),
1951 1950 root=opts.get('root'))
1952 1951
1953 1952 @command('^export',
1954 1953 [('o', 'output', '',
1955 1954 _('print output to file with formatted name'), _('FORMAT')),
1956 1955 ('', 'switch-parent', None, _('diff against the second parent')),
1957 1956 ('r', 'rev', [], _('revisions to export'), _('REV')),
1958 1957 ] + diffopts,
1959 1958 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
1960 1959 def export(ui, repo, *changesets, **opts):
1961 1960 """dump the header and diffs for one or more changesets
1962 1961
1963 1962 Print the changeset header and diffs for one or more revisions.
1964 1963 If no revision is given, the parent of the working directory is used.
1965 1964
1966 1965 The information shown in the changeset header is: author, date,
1967 1966 branch name (if non-default), changeset hash, parent(s) and commit
1968 1967 comment.
1969 1968
1970 1969 .. note::
1971 1970
1972 1971 :hg:`export` may generate unexpected diff output for merge
1973 1972 changesets, as it will compare the merge changeset against its
1974 1973 first parent only.
1975 1974
1976 1975 Output may be to a file, in which case the name of the file is
1977 1976 given using a format string. The formatting rules are as follows:
1978 1977
1979 1978 :``%%``: literal "%" character
1980 1979 :``%H``: changeset hash (40 hexadecimal digits)
1981 1980 :``%N``: number of patches being generated
1982 1981 :``%R``: changeset revision number
1983 1982 :``%b``: basename of the exporting repository
1984 1983 :``%h``: short-form changeset hash (12 hexadecimal digits)
1985 1984 :``%m``: first line of the commit message (only alphanumeric characters)
1986 1985 :``%n``: zero-padded sequence number, starting at 1
1987 1986 :``%r``: zero-padded changeset revision number
1988 1987
1989 1988 Without the -a/--text option, export will avoid generating diffs
1990 1989 of files it detects as binary. With -a, export will generate a
1991 1990 diff anyway, probably with undesirable results.
1992 1991
1993 1992 Use the -g/--git option to generate diffs in the git extended diff
1994 1993 format. See :hg:`help diffs` for more information.
1995 1994
1996 1995 With the --switch-parent option, the diff will be against the
1997 1996 second parent. It can be useful to review a merge.
1998 1997
1999 1998 .. container:: verbose
2000 1999
2001 2000 Examples:
2002 2001
2003 2002 - use export and import to transplant a bugfix to the current
2004 2003 branch::
2005 2004
2006 2005 hg export -r 9353 | hg import -
2007 2006
2008 2007 - export all the changesets between two revisions to a file with
2009 2008 rename information::
2010 2009
2011 2010 hg export --git -r 123:150 > changes.txt
2012 2011
2013 2012 - split outgoing changes into a series of patches with
2014 2013 descriptive names::
2015 2014
2016 2015 hg export -r "outgoing()" -o "%n-%m.patch"
2017 2016
2018 2017 Returns 0 on success.
2019 2018 """
2020 2019 changesets += tuple(opts.get('rev', []))
2021 2020 if not changesets:
2022 2021 changesets = ['.']
2023 2022 revs = scmutil.revrange(repo, changesets)
2024 2023 if not revs:
2025 2024 raise error.Abort(_("export requires at least one changeset"))
2026 2025 if len(revs) > 1:
2027 2026 ui.note(_('exporting patches:\n'))
2028 2027 else:
2029 2028 ui.note(_('exporting patch:\n'))
2030 2029 ui.pager('export')
2031 2030 cmdutil.export(repo, revs, template=opts.get('output'),
2032 2031 switch_parent=opts.get('switch_parent'),
2033 2032 opts=patch.diffallopts(ui, opts))
2034 2033
2035 2034 @command('files',
2036 2035 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2037 2036 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2038 2037 ] + walkopts + formatteropts + subrepoopts,
2039 2038 _('[OPTION]... [FILE]...'))
2040 2039 def files(ui, repo, *pats, **opts):
2041 2040 """list tracked files
2042 2041
2043 2042 Print files under Mercurial control in the working directory or
2044 2043 specified revision for given files (excluding removed files).
2045 2044 Files can be specified as filenames or filesets.
2046 2045
2047 2046 If no files are given to match, this command prints the names
2048 2047 of all files under Mercurial control.
2049 2048
2050 2049 .. container:: verbose
2051 2050
2052 2051 Examples:
2053 2052
2054 2053 - list all files under the current directory::
2055 2054
2056 2055 hg files .
2057 2056
2058 2057 - shows sizes and flags for current revision::
2059 2058
2060 2059 hg files -vr .
2061 2060
2062 2061 - list all files named README::
2063 2062
2064 2063 hg files -I "**/README"
2065 2064
2066 2065 - list all binary files::
2067 2066
2068 2067 hg files "set:binary()"
2069 2068
2070 2069 - find files containing a regular expression::
2071 2070
2072 2071 hg files "set:grep('bob')"
2073 2072
2074 2073 - search tracked file contents with xargs and grep::
2075 2074
2076 2075 hg files -0 | xargs -0 grep foo
2077 2076
2078 2077 See :hg:`help patterns` and :hg:`help filesets` for more information
2079 2078 on specifying file patterns.
2080 2079
2081 2080 Returns 0 if a match is found, 1 otherwise.
2082 2081
2083 2082 """
2084 2083 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2085 2084
2086 2085 end = '\n'
2087 2086 if opts.get('print0'):
2088 2087 end = '\0'
2089 2088 fmt = '%s' + end
2090 2089
2091 2090 m = scmutil.match(ctx, pats, opts)
2092 2091 ui.pager('files')
2093 2092 with ui.formatter('files', opts) as fm:
2094 2093 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2095 2094
2096 2095 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
2097 2096 def forget(ui, repo, *pats, **opts):
2098 2097 """forget the specified files on the next commit
2099 2098
2100 2099 Mark the specified files so they will no longer be tracked
2101 2100 after the next commit.
2102 2101
2103 2102 This only removes files from the current branch, not from the
2104 2103 entire project history, and it does not delete them from the
2105 2104 working directory.
2106 2105
2107 2106 To delete the file from the working directory, see :hg:`remove`.
2108 2107
2109 2108 To undo a forget before the next commit, see :hg:`add`.
2110 2109
2111 2110 .. container:: verbose
2112 2111
2113 2112 Examples:
2114 2113
2115 2114 - forget newly-added binary files::
2116 2115
2117 2116 hg forget "set:added() and binary()"
2118 2117
2119 2118 - forget files that would be excluded by .hgignore::
2120 2119
2121 2120 hg forget "set:hgignore()"
2122 2121
2123 2122 Returns 0 on success.
2124 2123 """
2125 2124
2126 2125 if not pats:
2127 2126 raise error.Abort(_('no files specified'))
2128 2127
2129 2128 m = scmutil.match(repo[None], pats, opts)
2130 2129 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2131 2130 return rejected and 1 or 0
2132 2131
2133 2132 @command(
2134 2133 'graft',
2135 2134 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2136 2135 ('c', 'continue', False, _('resume interrupted graft')),
2137 2136 ('e', 'edit', False, _('invoke editor on commit messages')),
2138 2137 ('', 'log', None, _('append graft info to log message')),
2139 2138 ('f', 'force', False, _('force graft')),
2140 2139 ('D', 'currentdate', False,
2141 2140 _('record the current date as commit date')),
2142 2141 ('U', 'currentuser', False,
2143 2142 _('record the current user as committer'), _('DATE'))]
2144 2143 + commitopts2 + mergetoolopts + dryrunopts,
2145 2144 _('[OPTION]... [-r REV]... REV...'))
2146 2145 def graft(ui, repo, *revs, **opts):
2147 2146 '''copy changes from other branches onto the current branch
2148 2147
2149 2148 This command uses Mercurial's merge logic to copy individual
2150 2149 changes from other branches without merging branches in the
2151 2150 history graph. This is sometimes known as 'backporting' or
2152 2151 'cherry-picking'. By default, graft will copy user, date, and
2153 2152 description from the source changesets.
2154 2153
2155 2154 Changesets that are ancestors of the current revision, that have
2156 2155 already been grafted, or that are merges will be skipped.
2157 2156
2158 2157 If --log is specified, log messages will have a comment appended
2159 2158 of the form::
2160 2159
2161 2160 (grafted from CHANGESETHASH)
2162 2161
2163 2162 If --force is specified, revisions will be grafted even if they
2164 2163 are already ancestors of or have been grafted to the destination.
2165 2164 This is useful when the revisions have since been backed out.
2166 2165
2167 2166 If a graft merge results in conflicts, the graft process is
2168 2167 interrupted so that the current merge can be manually resolved.
2169 2168 Once all conflicts are addressed, the graft process can be
2170 2169 continued with the -c/--continue option.
2171 2170
2172 2171 .. note::
2173 2172
2174 2173 The -c/--continue option does not reapply earlier options, except
2175 2174 for --force.
2176 2175
2177 2176 .. container:: verbose
2178 2177
2179 2178 Examples:
2180 2179
2181 2180 - copy a single change to the stable branch and edit its description::
2182 2181
2183 2182 hg update stable
2184 2183 hg graft --edit 9393
2185 2184
2186 2185 - graft a range of changesets with one exception, updating dates::
2187 2186
2188 2187 hg graft -D "2085::2093 and not 2091"
2189 2188
2190 2189 - continue a graft after resolving conflicts::
2191 2190
2192 2191 hg graft -c
2193 2192
2194 2193 - show the source of a grafted changeset::
2195 2194
2196 2195 hg log --debug -r .
2197 2196
2198 2197 - show revisions sorted by date::
2199 2198
2200 2199 hg log -r "sort(all(), date)"
2201 2200
2202 2201 See :hg:`help revisions` for more about specifying revisions.
2203 2202
2204 2203 Returns 0 on successful completion.
2205 2204 '''
2206 2205 with repo.wlock():
2207 2206 return _dograft(ui, repo, *revs, **opts)
2208 2207
2209 2208 def _dograft(ui, repo, *revs, **opts):
2210 2209 if revs and opts.get('rev'):
2211 2210 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2212 2211 'revision ordering!\n'))
2213 2212
2214 2213 revs = list(revs)
2215 2214 revs.extend(opts.get('rev'))
2216 2215
2217 2216 if not opts.get('user') and opts.get('currentuser'):
2218 2217 opts['user'] = ui.username()
2219 2218 if not opts.get('date') and opts.get('currentdate'):
2220 2219 opts['date'] = "%d %d" % util.makedate()
2221 2220
2222 2221 editor = cmdutil.getcommiteditor(editform='graft', **opts)
2223 2222
2224 2223 cont = False
2225 2224 if opts.get('continue'):
2226 2225 cont = True
2227 2226 if revs:
2228 2227 raise error.Abort(_("can't specify --continue and revisions"))
2229 2228 # read in unfinished revisions
2230 2229 try:
2231 2230 nodes = repo.vfs.read('graftstate').splitlines()
2232 2231 revs = [repo[node].rev() for node in nodes]
2233 2232 except IOError as inst:
2234 2233 if inst.errno != errno.ENOENT:
2235 2234 raise
2236 2235 cmdutil.wrongtooltocontinue(repo, _('graft'))
2237 2236 else:
2238 2237 cmdutil.checkunfinished(repo)
2239 2238 cmdutil.bailifchanged(repo)
2240 2239 if not revs:
2241 2240 raise error.Abort(_('no revisions specified'))
2242 2241 revs = scmutil.revrange(repo, revs)
2243 2242
2244 2243 skipped = set()
2245 2244 # check for merges
2246 2245 for rev in repo.revs('%ld and merge()', revs):
2247 2246 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2248 2247 skipped.add(rev)
2249 2248 revs = [r for r in revs if r not in skipped]
2250 2249 if not revs:
2251 2250 return -1
2252 2251
2253 2252 # Don't check in the --continue case, in effect retaining --force across
2254 2253 # --continues. That's because without --force, any revisions we decided to
2255 2254 # skip would have been filtered out here, so they wouldn't have made their
2256 2255 # way to the graftstate. With --force, any revisions we would have otherwise
2257 2256 # skipped would not have been filtered out, and if they hadn't been applied
2258 2257 # already, they'd have been in the graftstate.
2259 2258 if not (cont or opts.get('force')):
2260 2259 # check for ancestors of dest branch
2261 2260 crev = repo['.'].rev()
2262 2261 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2263 2262 # XXX make this lazy in the future
2264 2263 # don't mutate while iterating, create a copy
2265 2264 for rev in list(revs):
2266 2265 if rev in ancestors:
2267 2266 ui.warn(_('skipping ancestor revision %d:%s\n') %
2268 2267 (rev, repo[rev]))
2269 2268 # XXX remove on list is slow
2270 2269 revs.remove(rev)
2271 2270 if not revs:
2272 2271 return -1
2273 2272
2274 2273 # analyze revs for earlier grafts
2275 2274 ids = {}
2276 2275 for ctx in repo.set("%ld", revs):
2277 2276 ids[ctx.hex()] = ctx.rev()
2278 2277 n = ctx.extra().get('source')
2279 2278 if n:
2280 2279 ids[n] = ctx.rev()
2281 2280
2282 2281 # check ancestors for earlier grafts
2283 2282 ui.debug('scanning for duplicate grafts\n')
2284 2283
2285 2284 for rev in repo.changelog.findmissingrevs(revs, [crev]):
2286 2285 ctx = repo[rev]
2287 2286 n = ctx.extra().get('source')
2288 2287 if n in ids:
2289 2288 try:
2290 2289 r = repo[n].rev()
2291 2290 except error.RepoLookupError:
2292 2291 r = None
2293 2292 if r in revs:
2294 2293 ui.warn(_('skipping revision %d:%s '
2295 2294 '(already grafted to %d:%s)\n')
2296 2295 % (r, repo[r], rev, ctx))
2297 2296 revs.remove(r)
2298 2297 elif ids[n] in revs:
2299 2298 if r is None:
2300 2299 ui.warn(_('skipping already grafted revision %d:%s '
2301 2300 '(%d:%s also has unknown origin %s)\n')
2302 2301 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2303 2302 else:
2304 2303 ui.warn(_('skipping already grafted revision %d:%s '
2305 2304 '(%d:%s also has origin %d:%s)\n')
2306 2305 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2307 2306 revs.remove(ids[n])
2308 2307 elif ctx.hex() in ids:
2309 2308 r = ids[ctx.hex()]
2310 2309 ui.warn(_('skipping already grafted revision %d:%s '
2311 2310 '(was grafted from %d:%s)\n') %
2312 2311 (r, repo[r], rev, ctx))
2313 2312 revs.remove(r)
2314 2313 if not revs:
2315 2314 return -1
2316 2315
2317 2316 for pos, ctx in enumerate(repo.set("%ld", revs)):
2318 2317 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2319 2318 ctx.description().split('\n', 1)[0])
2320 2319 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2321 2320 if names:
2322 2321 desc += ' (%s)' % ' '.join(names)
2323 2322 ui.status(_('grafting %s\n') % desc)
2324 2323 if opts.get('dry_run'):
2325 2324 continue
2326 2325
2327 2326 source = ctx.extra().get('source')
2328 2327 extra = {}
2329 2328 if source:
2330 2329 extra['source'] = source
2331 2330 extra['intermediate-source'] = ctx.hex()
2332 2331 else:
2333 2332 extra['source'] = ctx.hex()
2334 2333 user = ctx.user()
2335 2334 if opts.get('user'):
2336 2335 user = opts['user']
2337 2336 date = ctx.date()
2338 2337 if opts.get('date'):
2339 2338 date = opts['date']
2340 2339 message = ctx.description()
2341 2340 if opts.get('log'):
2342 2341 message += '\n(grafted from %s)' % ctx.hex()
2343 2342
2344 2343 # we don't merge the first commit when continuing
2345 2344 if not cont:
2346 2345 # perform the graft merge with p1(rev) as 'ancestor'
2347 2346 try:
2348 2347 # ui.forcemerge is an internal variable, do not document
2349 2348 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2350 2349 'graft')
2351 2350 stats = mergemod.graft(repo, ctx, ctx.p1(),
2352 2351 ['local', 'graft'])
2353 2352 finally:
2354 2353 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2355 2354 # report any conflicts
2356 2355 if stats and stats[3] > 0:
2357 2356 # write out state for --continue
2358 2357 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2359 2358 repo.vfs.write('graftstate', ''.join(nodelines))
2360 2359 extra = ''
2361 2360 if opts.get('user'):
2362 2361 extra += ' --user %s' % util.shellquote(opts['user'])
2363 2362 if opts.get('date'):
2364 2363 extra += ' --date %s' % util.shellquote(opts['date'])
2365 2364 if opts.get('log'):
2366 2365 extra += ' --log'
2367 2366 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2368 2367 raise error.Abort(
2369 2368 _("unresolved conflicts, can't continue"),
2370 2369 hint=hint)
2371 2370 else:
2372 2371 cont = False
2373 2372
2374 2373 # commit
2375 2374 node = repo.commit(text=message, user=user,
2376 2375 date=date, extra=extra, editor=editor)
2377 2376 if node is None:
2378 2377 ui.warn(
2379 2378 _('note: graft of %d:%s created no changes to commit\n') %
2380 2379 (ctx.rev(), ctx))
2381 2380
2382 2381 # remove state when we complete successfully
2383 2382 if not opts.get('dry_run'):
2384 2383 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
2385 2384
2386 2385 return 0
2387 2386
2388 2387 @command('grep',
2389 2388 [('0', 'print0', None, _('end fields with NUL')),
2390 2389 ('', 'all', None, _('print all revisions that match')),
2391 2390 ('a', 'text', None, _('treat all files as text')),
2392 2391 ('f', 'follow', None,
2393 2392 _('follow changeset history,'
2394 2393 ' or file history across copies and renames')),
2395 2394 ('i', 'ignore-case', None, _('ignore case when matching')),
2396 2395 ('l', 'files-with-matches', None,
2397 2396 _('print only filenames and revisions that match')),
2398 2397 ('n', 'line-number', None, _('print matching line numbers')),
2399 2398 ('r', 'rev', [],
2400 2399 _('only search files changed within revision range'), _('REV')),
2401 2400 ('u', 'user', None, _('list the author (long with -v)')),
2402 2401 ('d', 'date', None, _('list the date (short with -q)')),
2403 2402 ] + formatteropts + walkopts,
2404 2403 _('[OPTION]... PATTERN [FILE]...'),
2405 2404 inferrepo=True)
2406 2405 def grep(ui, repo, pattern, *pats, **opts):
2407 2406 """search revision history for a pattern in specified files
2408 2407
2409 2408 Search revision history for a regular expression in the specified
2410 2409 files or the entire project.
2411 2410
2412 2411 By default, grep prints the most recent revision number for each
2413 2412 file in which it finds a match. To get it to print every revision
2414 2413 that contains a change in match status ("-" for a match that becomes
2415 2414 a non-match, or "+" for a non-match that becomes a match), use the
2416 2415 --all flag.
2417 2416
2418 2417 PATTERN can be any Python (roughly Perl-compatible) regular
2419 2418 expression.
2420 2419
2421 2420 If no FILEs are specified (and -f/--follow isn't set), all files in
2422 2421 the repository are searched, including those that don't exist in the
2423 2422 current branch or have been deleted in a prior changeset.
2424 2423
2425 2424 Returns 0 if a match is found, 1 otherwise.
2426 2425 """
2427 2426 reflags = re.M
2428 2427 if opts.get('ignore_case'):
2429 2428 reflags |= re.I
2430 2429 try:
2431 2430 regexp = util.re.compile(pattern, reflags)
2432 2431 except re.error as inst:
2433 2432 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
2434 2433 return 1
2435 2434 sep, eol = ':', '\n'
2436 2435 if opts.get('print0'):
2437 2436 sep = eol = '\0'
2438 2437
2439 2438 getfile = util.lrucachefunc(repo.file)
2440 2439
2441 2440 def matchlines(body):
2442 2441 begin = 0
2443 2442 linenum = 0
2444 2443 while begin < len(body):
2445 2444 match = regexp.search(body, begin)
2446 2445 if not match:
2447 2446 break
2448 2447 mstart, mend = match.span()
2449 2448 linenum += body.count('\n', begin, mstart) + 1
2450 2449 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2451 2450 begin = body.find('\n', mend) + 1 or len(body) + 1
2452 2451 lend = begin - 1
2453 2452 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2454 2453
2455 2454 class linestate(object):
2456 2455 def __init__(self, line, linenum, colstart, colend):
2457 2456 self.line = line
2458 2457 self.linenum = linenum
2459 2458 self.colstart = colstart
2460 2459 self.colend = colend
2461 2460
2462 2461 def __hash__(self):
2463 2462 return hash((self.linenum, self.line))
2464 2463
2465 2464 def __eq__(self, other):
2466 2465 return self.line == other.line
2467 2466
2468 2467 def findpos(self):
2469 2468 """Iterate all (start, end) indices of matches"""
2470 2469 yield self.colstart, self.colend
2471 2470 p = self.colend
2472 2471 while p < len(self.line):
2473 2472 m = regexp.search(self.line, p)
2474 2473 if not m:
2475 2474 break
2476 2475 yield m.span()
2477 2476 p = m.end()
2478 2477
2479 2478 matches = {}
2480 2479 copies = {}
2481 2480 def grepbody(fn, rev, body):
2482 2481 matches[rev].setdefault(fn, [])
2483 2482 m = matches[rev][fn]
2484 2483 for lnum, cstart, cend, line in matchlines(body):
2485 2484 s = linestate(line, lnum, cstart, cend)
2486 2485 m.append(s)
2487 2486
2488 2487 def difflinestates(a, b):
2489 2488 sm = difflib.SequenceMatcher(None, a, b)
2490 2489 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2491 2490 if tag == 'insert':
2492 2491 for i in xrange(blo, bhi):
2493 2492 yield ('+', b[i])
2494 2493 elif tag == 'delete':
2495 2494 for i in xrange(alo, ahi):
2496 2495 yield ('-', a[i])
2497 2496 elif tag == 'replace':
2498 2497 for i in xrange(alo, ahi):
2499 2498 yield ('-', a[i])
2500 2499 for i in xrange(blo, bhi):
2501 2500 yield ('+', b[i])
2502 2501
2503 2502 def display(fm, fn, ctx, pstates, states):
2504 2503 rev = ctx.rev()
2505 2504 if fm.isplain():
2506 2505 formatuser = ui.shortuser
2507 2506 else:
2508 2507 formatuser = str
2509 2508 if ui.quiet:
2510 2509 datefmt = '%Y-%m-%d'
2511 2510 else:
2512 2511 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2513 2512 found = False
2514 2513 @util.cachefunc
2515 2514 def binary():
2516 2515 flog = getfile(fn)
2517 2516 return util.binary(flog.read(ctx.filenode(fn)))
2518 2517
2519 2518 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2520 2519 if opts.get('all'):
2521 2520 iter = difflinestates(pstates, states)
2522 2521 else:
2523 2522 iter = [('', l) for l in states]
2524 2523 for change, l in iter:
2525 2524 fm.startitem()
2526 2525 fm.data(node=fm.hexfunc(ctx.node()))
2527 2526 cols = [
2528 2527 ('filename', fn, True),
2529 2528 ('rev', rev, True),
2530 2529 ('linenumber', l.linenum, opts.get('line_number')),
2531 2530 ]
2532 2531 if opts.get('all'):
2533 2532 cols.append(('change', change, True))
2534 2533 cols.extend([
2535 2534 ('user', formatuser(ctx.user()), opts.get('user')),
2536 2535 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2537 2536 ])
2538 2537 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2539 2538 for name, data, cond in cols:
2540 2539 field = fieldnamemap.get(name, name)
2541 2540 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2542 2541 if cond and name != lastcol:
2543 2542 fm.plain(sep, label='grep.sep')
2544 2543 if not opts.get('files_with_matches'):
2545 2544 fm.plain(sep, label='grep.sep')
2546 2545 if not opts.get('text') and binary():
2547 2546 fm.plain(_(" Binary file matches"))
2548 2547 else:
2549 2548 displaymatches(fm.nested('texts'), l)
2550 2549 fm.plain(eol)
2551 2550 found = True
2552 2551 if opts.get('files_with_matches'):
2553 2552 break
2554 2553 return found
2555 2554
2556 2555 def displaymatches(fm, l):
2557 2556 p = 0
2558 2557 for s, e in l.findpos():
2559 2558 if p < s:
2560 2559 fm.startitem()
2561 2560 fm.write('text', '%s', l.line[p:s])
2562 2561 fm.data(matched=False)
2563 2562 fm.startitem()
2564 2563 fm.write('text', '%s', l.line[s:e], label='grep.match')
2565 2564 fm.data(matched=True)
2566 2565 p = e
2567 2566 if p < len(l.line):
2568 2567 fm.startitem()
2569 2568 fm.write('text', '%s', l.line[p:])
2570 2569 fm.data(matched=False)
2571 2570 fm.end()
2572 2571
2573 2572 skip = {}
2574 2573 revfiles = {}
2575 2574 matchfn = scmutil.match(repo[None], pats, opts)
2576 2575 found = False
2577 2576 follow = opts.get('follow')
2578 2577
2579 2578 def prep(ctx, fns):
2580 2579 rev = ctx.rev()
2581 2580 pctx = ctx.p1()
2582 2581 parent = pctx.rev()
2583 2582 matches.setdefault(rev, {})
2584 2583 matches.setdefault(parent, {})
2585 2584 files = revfiles.setdefault(rev, [])
2586 2585 for fn in fns:
2587 2586 flog = getfile(fn)
2588 2587 try:
2589 2588 fnode = ctx.filenode(fn)
2590 2589 except error.LookupError:
2591 2590 continue
2592 2591
2593 2592 copied = flog.renamed(fnode)
2594 2593 copy = follow and copied and copied[0]
2595 2594 if copy:
2596 2595 copies.setdefault(rev, {})[fn] = copy
2597 2596 if fn in skip:
2598 2597 if copy:
2599 2598 skip[copy] = True
2600 2599 continue
2601 2600 files.append(fn)
2602 2601
2603 2602 if fn not in matches[rev]:
2604 2603 grepbody(fn, rev, flog.read(fnode))
2605 2604
2606 2605 pfn = copy or fn
2607 2606 if pfn not in matches[parent]:
2608 2607 try:
2609 2608 fnode = pctx.filenode(pfn)
2610 2609 grepbody(pfn, parent, flog.read(fnode))
2611 2610 except error.LookupError:
2612 2611 pass
2613 2612
2614 2613 ui.pager('grep')
2615 2614 fm = ui.formatter('grep', opts)
2616 2615 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2617 2616 rev = ctx.rev()
2618 2617 parent = ctx.p1().rev()
2619 2618 for fn in sorted(revfiles.get(rev, [])):
2620 2619 states = matches[rev][fn]
2621 2620 copy = copies.get(rev, {}).get(fn)
2622 2621 if fn in skip:
2623 2622 if copy:
2624 2623 skip[copy] = True
2625 2624 continue
2626 2625 pstates = matches.get(parent, {}).get(copy or fn, [])
2627 2626 if pstates or states:
2628 2627 r = display(fm, fn, ctx, pstates, states)
2629 2628 found = found or r
2630 2629 if r and not opts.get('all'):
2631 2630 skip[fn] = True
2632 2631 if copy:
2633 2632 skip[copy] = True
2634 2633 del matches[rev]
2635 2634 del revfiles[rev]
2636 2635 fm.end()
2637 2636
2638 2637 return not found
2639 2638
2640 2639 @command('heads',
2641 2640 [('r', 'rev', '',
2642 2641 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2643 2642 ('t', 'topo', False, _('show topological heads only')),
2644 2643 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2645 2644 ('c', 'closed', False, _('show normal and closed branch heads')),
2646 2645 ] + templateopts,
2647 2646 _('[-ct] [-r STARTREV] [REV]...'))
2648 2647 def heads(ui, repo, *branchrevs, **opts):
2649 2648 """show branch heads
2650 2649
2651 2650 With no arguments, show all open branch heads in the repository.
2652 2651 Branch heads are changesets that have no descendants on the
2653 2652 same branch. They are where development generally takes place and
2654 2653 are the usual targets for update and merge operations.
2655 2654
2656 2655 If one or more REVs are given, only open branch heads on the
2657 2656 branches associated with the specified changesets are shown. This
2658 2657 means that you can use :hg:`heads .` to see the heads on the
2659 2658 currently checked-out branch.
2660 2659
2661 2660 If -c/--closed is specified, also show branch heads marked closed
2662 2661 (see :hg:`commit --close-branch`).
2663 2662
2664 2663 If STARTREV is specified, only those heads that are descendants of
2665 2664 STARTREV will be displayed.
2666 2665
2667 2666 If -t/--topo is specified, named branch mechanics will be ignored and only
2668 2667 topological heads (changesets with no children) will be shown.
2669 2668
2670 2669 Returns 0 if matching heads are found, 1 if not.
2671 2670 """
2672 2671
2673 2672 start = None
2674 2673 if 'rev' in opts:
2675 2674 start = scmutil.revsingle(repo, opts['rev'], None).node()
2676 2675
2677 2676 if opts.get('topo'):
2678 2677 heads = [repo[h] for h in repo.heads(start)]
2679 2678 else:
2680 2679 heads = []
2681 2680 for branch in repo.branchmap():
2682 2681 heads += repo.branchheads(branch, start, opts.get('closed'))
2683 2682 heads = [repo[h] for h in heads]
2684 2683
2685 2684 if branchrevs:
2686 2685 branches = set(repo[br].branch() for br in branchrevs)
2687 2686 heads = [h for h in heads if h.branch() in branches]
2688 2687
2689 2688 if opts.get('active') and branchrevs:
2690 2689 dagheads = repo.heads(start)
2691 2690 heads = [h for h in heads if h.node() in dagheads]
2692 2691
2693 2692 if branchrevs:
2694 2693 haveheads = set(h.branch() for h in heads)
2695 2694 if branches - haveheads:
2696 2695 headless = ', '.join(b for b in branches - haveheads)
2697 2696 msg = _('no open branch heads found on branches %s')
2698 2697 if opts.get('rev'):
2699 2698 msg += _(' (started at %s)') % opts['rev']
2700 2699 ui.warn((msg + '\n') % headless)
2701 2700
2702 2701 if not heads:
2703 2702 return 1
2704 2703
2705 2704 heads = sorted(heads, key=lambda x: -x.rev())
2706 2705 displayer = cmdutil.show_changeset(ui, repo, opts)
2707 2706 for ctx in heads:
2708 2707 displayer.show(ctx)
2709 2708 displayer.close()
2710 2709
2711 2710 @command('help',
2712 2711 [('e', 'extension', None, _('show only help for extensions')),
2713 2712 ('c', 'command', None, _('show only help for commands')),
2714 2713 ('k', 'keyword', None, _('show topics matching keyword')),
2715 2714 ('s', 'system', [], _('show help for specific platform(s)')),
2716 2715 ],
2717 2716 _('[-ecks] [TOPIC]'),
2718 2717 norepo=True)
2719 2718 def help_(ui, name=None, **opts):
2720 2719 """show help for a given topic or a help overview
2721 2720
2722 2721 With no arguments, print a list of commands with short help messages.
2723 2722
2724 2723 Given a topic, extension, or command name, print help for that
2725 2724 topic.
2726 2725
2727 2726 Returns 0 if successful.
2728 2727 """
2729 2728
2730 2729 keep = opts.get('system') or []
2731 2730 if len(keep) == 0:
2732 2731 if pycompat.sysplatform.startswith('win'):
2733 2732 keep.append('windows')
2734 2733 elif pycompat.sysplatform == 'OpenVMS':
2735 2734 keep.append('vms')
2736 2735 elif pycompat.sysplatform == 'plan9':
2737 2736 keep.append('plan9')
2738 2737 else:
2739 2738 keep.append('unix')
2740 2739 keep.append(pycompat.sysplatform.lower())
2741 2740 if ui.verbose:
2742 2741 keep.append('verbose')
2743 2742
2744 2743 formatted = help.formattedhelp(ui, name, keep=keep, **opts)
2745 2744 ui.pager('help')
2746 2745 ui.write(formatted)
2747 2746
2748 2747
2749 2748 @command('identify|id',
2750 2749 [('r', 'rev', '',
2751 2750 _('identify the specified revision'), _('REV')),
2752 2751 ('n', 'num', None, _('show local revision number')),
2753 2752 ('i', 'id', None, _('show global revision id')),
2754 2753 ('b', 'branch', None, _('show branch')),
2755 2754 ('t', 'tags', None, _('show tags')),
2756 2755 ('B', 'bookmarks', None, _('show bookmarks')),
2757 2756 ] + remoteopts,
2758 2757 _('[-nibtB] [-r REV] [SOURCE]'),
2759 2758 optionalrepo=True)
2760 2759 def identify(ui, repo, source=None, rev=None,
2761 2760 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2762 2761 """identify the working directory or specified revision
2763 2762
2764 2763 Print a summary identifying the repository state at REV using one or
2765 2764 two parent hash identifiers, followed by a "+" if the working
2766 2765 directory has uncommitted changes, the branch name (if not default),
2767 2766 a list of tags, and a list of bookmarks.
2768 2767
2769 2768 When REV is not given, print a summary of the current state of the
2770 2769 repository.
2771 2770
2772 2771 Specifying a path to a repository root or Mercurial bundle will
2773 2772 cause lookup to operate on that repository/bundle.
2774 2773
2775 2774 .. container:: verbose
2776 2775
2777 2776 Examples:
2778 2777
2779 2778 - generate a build identifier for the working directory::
2780 2779
2781 2780 hg id --id > build-id.dat
2782 2781
2783 2782 - find the revision corresponding to a tag::
2784 2783
2785 2784 hg id -n -r 1.3
2786 2785
2787 2786 - check the most recent revision of a remote repository::
2788 2787
2789 2788 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2790 2789
2791 2790 See :hg:`log` for generating more information about specific revisions,
2792 2791 including full hash identifiers.
2793 2792
2794 2793 Returns 0 if successful.
2795 2794 """
2796 2795
2797 2796 if not repo and not source:
2798 2797 raise error.Abort(_("there is no Mercurial repository here "
2799 2798 "(.hg not found)"))
2800 2799
2801 2800 if ui.debugflag:
2802 2801 hexfunc = hex
2803 2802 else:
2804 2803 hexfunc = short
2805 2804 default = not (num or id or branch or tags or bookmarks)
2806 2805 output = []
2807 2806 revs = []
2808 2807
2809 2808 if source:
2810 2809 source, branches = hg.parseurl(ui.expandpath(source))
2811 2810 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2812 2811 repo = peer.local()
2813 2812 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2814 2813
2815 2814 if not repo:
2816 2815 if num or branch or tags:
2817 2816 raise error.Abort(
2818 2817 _("can't query remote revision number, branch, or tags"))
2819 2818 if not rev and revs:
2820 2819 rev = revs[0]
2821 2820 if not rev:
2822 2821 rev = "tip"
2823 2822
2824 2823 remoterev = peer.lookup(rev)
2825 2824 if default or id:
2826 2825 output = [hexfunc(remoterev)]
2827 2826
2828 2827 def getbms():
2829 2828 bms = []
2830 2829
2831 2830 if 'bookmarks' in peer.listkeys('namespaces'):
2832 2831 hexremoterev = hex(remoterev)
2833 2832 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2834 2833 if bmr == hexremoterev]
2835 2834
2836 2835 return sorted(bms)
2837 2836
2838 2837 if bookmarks:
2839 2838 output.extend(getbms())
2840 2839 elif default and not ui.quiet:
2841 2840 # multiple bookmarks for a single parent separated by '/'
2842 2841 bm = '/'.join(getbms())
2843 2842 if bm:
2844 2843 output.append(bm)
2845 2844 else:
2846 2845 ctx = scmutil.revsingle(repo, rev, None)
2847 2846
2848 2847 if ctx.rev() is None:
2849 2848 ctx = repo[None]
2850 2849 parents = ctx.parents()
2851 2850 taglist = []
2852 2851 for p in parents:
2853 2852 taglist.extend(p.tags())
2854 2853
2855 2854 changed = ""
2856 2855 if default or id or num:
2857 2856 if (any(repo.status())
2858 2857 or any(ctx.sub(s).dirty() for s in ctx.substate)):
2859 2858 changed = '+'
2860 2859 if default or id:
2861 2860 output = ["%s%s" %
2862 2861 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
2863 2862 if num:
2864 2863 output.append("%s%s" %
2865 2864 ('+'.join([str(p.rev()) for p in parents]), changed))
2866 2865 else:
2867 2866 if default or id:
2868 2867 output = [hexfunc(ctx.node())]
2869 2868 if num:
2870 2869 output.append(str(ctx.rev()))
2871 2870 taglist = ctx.tags()
2872 2871
2873 2872 if default and not ui.quiet:
2874 2873 b = ctx.branch()
2875 2874 if b != 'default':
2876 2875 output.append("(%s)" % b)
2877 2876
2878 2877 # multiple tags for a single parent separated by '/'
2879 2878 t = '/'.join(taglist)
2880 2879 if t:
2881 2880 output.append(t)
2882 2881
2883 2882 # multiple bookmarks for a single parent separated by '/'
2884 2883 bm = '/'.join(ctx.bookmarks())
2885 2884 if bm:
2886 2885 output.append(bm)
2887 2886 else:
2888 2887 if branch:
2889 2888 output.append(ctx.branch())
2890 2889
2891 2890 if tags:
2892 2891 output.extend(taglist)
2893 2892
2894 2893 if bookmarks:
2895 2894 output.extend(ctx.bookmarks())
2896 2895
2897 2896 ui.write("%s\n" % ' '.join(output))
2898 2897
2899 2898 @command('import|patch',
2900 2899 [('p', 'strip', 1,
2901 2900 _('directory strip option for patch. This has the same '
2902 2901 'meaning as the corresponding patch option'), _('NUM')),
2903 2902 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2904 2903 ('e', 'edit', False, _('invoke editor on commit messages')),
2905 2904 ('f', 'force', None,
2906 2905 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2907 2906 ('', 'no-commit', None,
2908 2907 _("don't commit, just update the working directory")),
2909 2908 ('', 'bypass', None,
2910 2909 _("apply patch without touching the working directory")),
2911 2910 ('', 'partial', None,
2912 2911 _('commit even if some hunks fail')),
2913 2912 ('', 'exact', None,
2914 2913 _('abort if patch would apply lossily')),
2915 2914 ('', 'prefix', '',
2916 2915 _('apply patch to subdirectory'), _('DIR')),
2917 2916 ('', 'import-branch', None,
2918 2917 _('use any branch information in patch (implied by --exact)'))] +
2919 2918 commitopts + commitopts2 + similarityopts,
2920 2919 _('[OPTION]... PATCH...'))
2921 2920 def import_(ui, repo, patch1=None, *patches, **opts):
2922 2921 """import an ordered set of patches
2923 2922
2924 2923 Import a list of patches and commit them individually (unless
2925 2924 --no-commit is specified).
2926 2925
2927 2926 To read a patch from standard input (stdin), use "-" as the patch
2928 2927 name. If a URL is specified, the patch will be downloaded from
2929 2928 there.
2930 2929
2931 2930 Import first applies changes to the working directory (unless
2932 2931 --bypass is specified), import will abort if there are outstanding
2933 2932 changes.
2934 2933
2935 2934 Use --bypass to apply and commit patches directly to the
2936 2935 repository, without affecting the working directory. Without
2937 2936 --exact, patches will be applied on top of the working directory
2938 2937 parent revision.
2939 2938
2940 2939 You can import a patch straight from a mail message. Even patches
2941 2940 as attachments work (to use the body part, it must have type
2942 2941 text/plain or text/x-patch). From and Subject headers of email
2943 2942 message are used as default committer and commit message. All
2944 2943 text/plain body parts before first diff are added to the commit
2945 2944 message.
2946 2945
2947 2946 If the imported patch was generated by :hg:`export`, user and
2948 2947 description from patch override values from message headers and
2949 2948 body. Values given on command line with -m/--message and -u/--user
2950 2949 override these.
2951 2950
2952 2951 If --exact is specified, import will set the working directory to
2953 2952 the parent of each patch before applying it, and will abort if the
2954 2953 resulting changeset has a different ID than the one recorded in
2955 2954 the patch. This will guard against various ways that portable
2956 2955 patch formats and mail systems might fail to transfer Mercurial
2957 2956 data or metadata. See :hg:`bundle` for lossless transmission.
2958 2957
2959 2958 Use --partial to ensure a changeset will be created from the patch
2960 2959 even if some hunks fail to apply. Hunks that fail to apply will be
2961 2960 written to a <target-file>.rej file. Conflicts can then be resolved
2962 2961 by hand before :hg:`commit --amend` is run to update the created
2963 2962 changeset. This flag exists to let people import patches that
2964 2963 partially apply without losing the associated metadata (author,
2965 2964 date, description, ...).
2966 2965
2967 2966 .. note::
2968 2967
2969 2968 When no hunks apply cleanly, :hg:`import --partial` will create
2970 2969 an empty changeset, importing only the patch metadata.
2971 2970
2972 2971 With -s/--similarity, hg will attempt to discover renames and
2973 2972 copies in the patch in the same way as :hg:`addremove`.
2974 2973
2975 2974 It is possible to use external patch programs to perform the patch
2976 2975 by setting the ``ui.patch`` configuration option. For the default
2977 2976 internal tool, the fuzz can also be configured via ``patch.fuzz``.
2978 2977 See :hg:`help config` for more information about configuration
2979 2978 files and how to use these options.
2980 2979
2981 2980 See :hg:`help dates` for a list of formats valid for -d/--date.
2982 2981
2983 2982 .. container:: verbose
2984 2983
2985 2984 Examples:
2986 2985
2987 2986 - import a traditional patch from a website and detect renames::
2988 2987
2989 2988 hg import -s 80 http://example.com/bugfix.patch
2990 2989
2991 2990 - import a changeset from an hgweb server::
2992 2991
2993 2992 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
2994 2993
2995 2994 - import all the patches in an Unix-style mbox::
2996 2995
2997 2996 hg import incoming-patches.mbox
2998 2997
2999 2998 - import patches from stdin::
3000 2999
3001 3000 hg import -
3002 3001
3003 3002 - attempt to exactly restore an exported changeset (not always
3004 3003 possible)::
3005 3004
3006 3005 hg import --exact proposed-fix.patch
3007 3006
3008 3007 - use an external tool to apply a patch which is too fuzzy for
3009 3008 the default internal tool.
3010 3009
3011 3010 hg import --config ui.patch="patch --merge" fuzzy.patch
3012 3011
3013 3012 - change the default fuzzing from 2 to a less strict 7
3014 3013
3015 3014 hg import --config ui.fuzz=7 fuzz.patch
3016 3015
3017 3016 Returns 0 on success, 1 on partial success (see --partial).
3018 3017 """
3019 3018
3020 3019 if not patch1:
3021 3020 raise error.Abort(_('need at least one patch to import'))
3022 3021
3023 3022 patches = (patch1,) + patches
3024 3023
3025 3024 date = opts.get('date')
3026 3025 if date:
3027 3026 opts['date'] = util.parsedate(date)
3028 3027
3029 3028 exact = opts.get('exact')
3030 3029 update = not opts.get('bypass')
3031 3030 if not update and opts.get('no_commit'):
3032 3031 raise error.Abort(_('cannot use --no-commit with --bypass'))
3033 3032 try:
3034 3033 sim = float(opts.get('similarity') or 0)
3035 3034 except ValueError:
3036 3035 raise error.Abort(_('similarity must be a number'))
3037 3036 if sim < 0 or sim > 100:
3038 3037 raise error.Abort(_('similarity must be between 0 and 100'))
3039 3038 if sim and not update:
3040 3039 raise error.Abort(_('cannot use --similarity with --bypass'))
3041 3040 if exact:
3042 3041 if opts.get('edit'):
3043 3042 raise error.Abort(_('cannot use --exact with --edit'))
3044 3043 if opts.get('prefix'):
3045 3044 raise error.Abort(_('cannot use --exact with --prefix'))
3046 3045
3047 3046 base = opts["base"]
3048 3047 wlock = dsguard = lock = tr = None
3049 3048 msgs = []
3050 3049 ret = 0
3051 3050
3052 3051
3053 3052 try:
3054 3053 wlock = repo.wlock()
3055 3054
3056 3055 if update:
3057 3056 cmdutil.checkunfinished(repo)
3058 3057 if (exact or not opts.get('force')):
3059 3058 cmdutil.bailifchanged(repo)
3060 3059
3061 3060 if not opts.get('no_commit'):
3062 3061 lock = repo.lock()
3063 3062 tr = repo.transaction('import')
3064 3063 else:
3065 3064 dsguard = dirstateguard.dirstateguard(repo, 'import')
3066 3065 parents = repo[None].parents()
3067 3066 for patchurl in patches:
3068 3067 if patchurl == '-':
3069 3068 ui.status(_('applying patch from stdin\n'))
3070 3069 patchfile = ui.fin
3071 3070 patchurl = 'stdin' # for error message
3072 3071 else:
3073 3072 patchurl = os.path.join(base, patchurl)
3074 3073 ui.status(_('applying %s\n') % patchurl)
3075 3074 patchfile = hg.openpath(ui, patchurl)
3076 3075
3077 3076 haspatch = False
3078 3077 for hunk in patch.split(patchfile):
3079 3078 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
3080 3079 parents, opts,
3081 3080 msgs, hg.clean)
3082 3081 if msg:
3083 3082 haspatch = True
3084 3083 ui.note(msg + '\n')
3085 3084 if update or exact:
3086 3085 parents = repo[None].parents()
3087 3086 else:
3088 3087 parents = [repo[node]]
3089 3088 if rej:
3090 3089 ui.write_err(_("patch applied partially\n"))
3091 3090 ui.write_err(_("(fix the .rej files and run "
3092 3091 "`hg commit --amend`)\n"))
3093 3092 ret = 1
3094 3093 break
3095 3094
3096 3095 if not haspatch:
3097 3096 raise error.Abort(_('%s: no diffs found') % patchurl)
3098 3097
3099 3098 if tr:
3100 3099 tr.close()
3101 3100 if msgs:
3102 3101 repo.savecommitmessage('\n* * *\n'.join(msgs))
3103 3102 if dsguard:
3104 3103 dsguard.close()
3105 3104 return ret
3106 3105 finally:
3107 3106 if tr:
3108 3107 tr.release()
3109 3108 release(lock, dsguard, wlock)
3110 3109
3111 3110 @command('incoming|in',
3112 3111 [('f', 'force', None,
3113 3112 _('run even if remote repository is unrelated')),
3114 3113 ('n', 'newest-first', None, _('show newest record first')),
3115 3114 ('', 'bundle', '',
3116 3115 _('file to store the bundles into'), _('FILE')),
3117 3116 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3118 3117 ('B', 'bookmarks', False, _("compare bookmarks")),
3119 3118 ('b', 'branch', [],
3120 3119 _('a specific branch you would like to pull'), _('BRANCH')),
3121 3120 ] + logopts + remoteopts + subrepoopts,
3122 3121 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3123 3122 def incoming(ui, repo, source="default", **opts):
3124 3123 """show new changesets found in source
3125 3124
3126 3125 Show new changesets found in the specified path/URL or the default
3127 3126 pull location. These are the changesets that would have been pulled
3128 3127 if a pull at the time you issued this command.
3129 3128
3130 3129 See pull for valid source format details.
3131 3130
3132 3131 .. container:: verbose
3133 3132
3134 3133 With -B/--bookmarks, the result of bookmark comparison between
3135 3134 local and remote repositories is displayed. With -v/--verbose,
3136 3135 status is also displayed for each bookmark like below::
3137 3136
3138 3137 BM1 01234567890a added
3139 3138 BM2 1234567890ab advanced
3140 3139 BM3 234567890abc diverged
3141 3140 BM4 34567890abcd changed
3142 3141
3143 3142 The action taken locally when pulling depends on the
3144 3143 status of each bookmark:
3145 3144
3146 3145 :``added``: pull will create it
3147 3146 :``advanced``: pull will update it
3148 3147 :``diverged``: pull will create a divergent bookmark
3149 3148 :``changed``: result depends on remote changesets
3150 3149
3151 3150 From the point of view of pulling behavior, bookmark
3152 3151 existing only in the remote repository are treated as ``added``,
3153 3152 even if it is in fact locally deleted.
3154 3153
3155 3154 .. container:: verbose
3156 3155
3157 3156 For remote repository, using --bundle avoids downloading the
3158 3157 changesets twice if the incoming is followed by a pull.
3159 3158
3160 3159 Examples:
3161 3160
3162 3161 - show incoming changes with patches and full description::
3163 3162
3164 3163 hg incoming -vp
3165 3164
3166 3165 - show incoming changes excluding merges, store a bundle::
3167 3166
3168 3167 hg in -vpM --bundle incoming.hg
3169 3168 hg pull incoming.hg
3170 3169
3171 3170 - briefly list changes inside a bundle::
3172 3171
3173 3172 hg in changes.hg -T "{desc|firstline}\\n"
3174 3173
3175 3174 Returns 0 if there are incoming changes, 1 otherwise.
3176 3175 """
3177 3176 if opts.get('graph'):
3178 3177 cmdutil.checkunsupportedgraphflags([], opts)
3179 3178 def display(other, chlist, displayer):
3180 3179 revdag = cmdutil.graphrevs(other, chlist, opts)
3181 3180 cmdutil.displaygraph(ui, repo, revdag, displayer,
3182 3181 graphmod.asciiedges)
3183 3182
3184 3183 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3185 3184 return 0
3186 3185
3187 3186 if opts.get('bundle') and opts.get('subrepos'):
3188 3187 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3189 3188
3190 3189 if opts.get('bookmarks'):
3191 3190 source, branches = hg.parseurl(ui.expandpath(source),
3192 3191 opts.get('branch'))
3193 3192 other = hg.peer(repo, opts, source)
3194 3193 if 'bookmarks' not in other.listkeys('namespaces'):
3195 3194 ui.warn(_("remote doesn't support bookmarks\n"))
3196 3195 return 0
3197 3196 ui.pager('incoming')
3198 3197 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3199 3198 return bookmarks.incoming(ui, repo, other)
3200 3199
3201 3200 repo._subtoppath = ui.expandpath(source)
3202 3201 try:
3203 3202 return hg.incoming(ui, repo, source, opts)
3204 3203 finally:
3205 3204 del repo._subtoppath
3206 3205
3207 3206
3208 3207 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3209 3208 norepo=True)
3210 3209 def init(ui, dest=".", **opts):
3211 3210 """create a new repository in the given directory
3212 3211
3213 3212 Initialize a new repository in the given directory. If the given
3214 3213 directory does not exist, it will be created.
3215 3214
3216 3215 If no directory is given, the current directory is used.
3217 3216
3218 3217 It is possible to specify an ``ssh://`` URL as the destination.
3219 3218 See :hg:`help urls` for more information.
3220 3219
3221 3220 Returns 0 on success.
3222 3221 """
3223 3222 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3224 3223
3225 3224 @command('locate',
3226 3225 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3227 3226 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3228 3227 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3229 3228 ] + walkopts,
3230 3229 _('[OPTION]... [PATTERN]...'))
3231 3230 def locate(ui, repo, *pats, **opts):
3232 3231 """locate files matching specific patterns (DEPRECATED)
3233 3232
3234 3233 Print files under Mercurial control in the working directory whose
3235 3234 names match the given patterns.
3236 3235
3237 3236 By default, this command searches all directories in the working
3238 3237 directory. To search just the current directory and its
3239 3238 subdirectories, use "--include .".
3240 3239
3241 3240 If no patterns are given to match, this command prints the names
3242 3241 of all files under Mercurial control in the working directory.
3243 3242
3244 3243 If you want to feed the output of this command into the "xargs"
3245 3244 command, use the -0 option to both this command and "xargs". This
3246 3245 will avoid the problem of "xargs" treating single filenames that
3247 3246 contain whitespace as multiple filenames.
3248 3247
3249 3248 See :hg:`help files` for a more versatile command.
3250 3249
3251 3250 Returns 0 if a match is found, 1 otherwise.
3252 3251 """
3253 3252 if opts.get('print0'):
3254 3253 end = '\0'
3255 3254 else:
3256 3255 end = '\n'
3257 3256 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3258 3257
3259 3258 ret = 1
3260 3259 ctx = repo[rev]
3261 3260 m = scmutil.match(ctx, pats, opts, default='relglob',
3262 3261 badfn=lambda x, y: False)
3263 3262
3264 3263 ui.pager('locate')
3265 3264 for abs in ctx.matches(m):
3266 3265 if opts.get('fullpath'):
3267 3266 ui.write(repo.wjoin(abs), end)
3268 3267 else:
3269 3268 ui.write(((pats and m.rel(abs)) or abs), end)
3270 3269 ret = 0
3271 3270
3272 3271 return ret
3273 3272
3274 3273 @command('^log|history',
3275 3274 [('f', 'follow', None,
3276 3275 _('follow changeset history, or file history across copies and renames')),
3277 3276 ('', 'follow-first', None,
3278 3277 _('only follow the first parent of merge changesets (DEPRECATED)')),
3279 3278 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3280 3279 ('C', 'copies', None, _('show copied files')),
3281 3280 ('k', 'keyword', [],
3282 3281 _('do case-insensitive search for a given text'), _('TEXT')),
3283 3282 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3284 3283 ('', 'removed', None, _('include revisions where files were removed')),
3285 3284 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3286 3285 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3287 3286 ('', 'only-branch', [],
3288 3287 _('show only changesets within the given named branch (DEPRECATED)'),
3289 3288 _('BRANCH')),
3290 3289 ('b', 'branch', [],
3291 3290 _('show changesets within the given named branch'), _('BRANCH')),
3292 3291 ('P', 'prune', [],
3293 3292 _('do not display revision or any of its ancestors'), _('REV')),
3294 3293 ] + logopts + walkopts,
3295 3294 _('[OPTION]... [FILE]'),
3296 3295 inferrepo=True)
3297 3296 def log(ui, repo, *pats, **opts):
3298 3297 """show revision history of entire repository or files
3299 3298
3300 3299 Print the revision history of the specified files or the entire
3301 3300 project.
3302 3301
3303 3302 If no revision range is specified, the default is ``tip:0`` unless
3304 3303 --follow is set, in which case the working directory parent is
3305 3304 used as the starting revision.
3306 3305
3307 3306 File history is shown without following rename or copy history of
3308 3307 files. Use -f/--follow with a filename to follow history across
3309 3308 renames and copies. --follow without a filename will only show
3310 3309 ancestors or descendants of the starting revision.
3311 3310
3312 3311 By default this command prints revision number and changeset id,
3313 3312 tags, non-trivial parents, user, date and time, and a summary for
3314 3313 each commit. When the -v/--verbose switch is used, the list of
3315 3314 changed files and full commit message are shown.
3316 3315
3317 3316 With --graph the revisions are shown as an ASCII art DAG with the most
3318 3317 recent changeset at the top.
3319 3318 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
3320 3319 and '+' represents a fork where the changeset from the lines below is a
3321 3320 parent of the 'o' merge on the same line.
3322 3321
3323 3322 .. note::
3324 3323
3325 3324 :hg:`log --patch` may generate unexpected diff output for merge
3326 3325 changesets, as it will only compare the merge changeset against
3327 3326 its first parent. Also, only files different from BOTH parents
3328 3327 will appear in files:.
3329 3328
3330 3329 .. note::
3331 3330
3332 3331 For performance reasons, :hg:`log FILE` may omit duplicate changes
3333 3332 made on branches and will not show removals or mode changes. To
3334 3333 see all such changes, use the --removed switch.
3335 3334
3336 3335 .. container:: verbose
3337 3336
3338 3337 Some examples:
3339 3338
3340 3339 - changesets with full descriptions and file lists::
3341 3340
3342 3341 hg log -v
3343 3342
3344 3343 - changesets ancestral to the working directory::
3345 3344
3346 3345 hg log -f
3347 3346
3348 3347 - last 10 commits on the current branch::
3349 3348
3350 3349 hg log -l 10 -b .
3351 3350
3352 3351 - changesets showing all modifications of a file, including removals::
3353 3352
3354 3353 hg log --removed file.c
3355 3354
3356 3355 - all changesets that touch a directory, with diffs, excluding merges::
3357 3356
3358 3357 hg log -Mp lib/
3359 3358
3360 3359 - all revision numbers that match a keyword::
3361 3360
3362 3361 hg log -k bug --template "{rev}\\n"
3363 3362
3364 3363 - the full hash identifier of the working directory parent::
3365 3364
3366 3365 hg log -r . --template "{node}\\n"
3367 3366
3368 3367 - list available log templates::
3369 3368
3370 3369 hg log -T list
3371 3370
3372 3371 - check if a given changeset is included in a tagged release::
3373 3372
3374 3373 hg log -r "a21ccf and ancestor(1.9)"
3375 3374
3376 3375 - find all changesets by some user in a date range::
3377 3376
3378 3377 hg log -k alice -d "may 2008 to jul 2008"
3379 3378
3380 3379 - summary of all changesets after the last tag::
3381 3380
3382 3381 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3383 3382
3384 3383 See :hg:`help dates` for a list of formats valid for -d/--date.
3385 3384
3386 3385 See :hg:`help revisions` for more about specifying and ordering
3387 3386 revisions.
3388 3387
3389 3388 See :hg:`help templates` for more about pre-packaged styles and
3390 3389 specifying custom templates.
3391 3390
3392 3391 Returns 0 on success.
3393 3392
3394 3393 """
3395 3394 if opts.get('follow') and opts.get('rev'):
3396 3395 opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', opts.get('rev'))]
3397 3396 del opts['follow']
3398 3397
3399 3398 if opts.get('graph'):
3400 3399 return cmdutil.graphlog(ui, repo, *pats, **opts)
3401 3400
3402 3401 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
3403 3402 limit = cmdutil.loglimit(opts)
3404 3403 count = 0
3405 3404
3406 3405 getrenamed = None
3407 3406 if opts.get('copies'):
3408 3407 endrev = None
3409 3408 if opts.get('rev'):
3410 3409 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
3411 3410 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3412 3411
3413 3412 ui.pager('log')
3414 3413 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3415 3414 for rev in revs:
3416 3415 if count == limit:
3417 3416 break
3418 3417 ctx = repo[rev]
3419 3418 copies = None
3420 3419 if getrenamed is not None and rev:
3421 3420 copies = []
3422 3421 for fn in ctx.files():
3423 3422 rename = getrenamed(fn, rev)
3424 3423 if rename:
3425 3424 copies.append((fn, rename[0]))
3426 3425 if filematcher:
3427 3426 revmatchfn = filematcher(ctx.rev())
3428 3427 else:
3429 3428 revmatchfn = None
3430 3429 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
3431 3430 if displayer.flush(ctx):
3432 3431 count += 1
3433 3432
3434 3433 displayer.close()
3435 3434
3436 3435 @command('manifest',
3437 3436 [('r', 'rev', '', _('revision to display'), _('REV')),
3438 3437 ('', 'all', False, _("list files from all revisions"))]
3439 3438 + formatteropts,
3440 3439 _('[-r REV]'))
3441 3440 def manifest(ui, repo, node=None, rev=None, **opts):
3442 3441 """output the current or given revision of the project manifest
3443 3442
3444 3443 Print a list of version controlled files for the given revision.
3445 3444 If no revision is given, the first parent of the working directory
3446 3445 is used, or the null revision if no revision is checked out.
3447 3446
3448 3447 With -v, print file permissions, symlink and executable bits.
3449 3448 With --debug, print file revision hashes.
3450 3449
3451 3450 If option --all is specified, the list of all files from all revisions
3452 3451 is printed. This includes deleted and renamed files.
3453 3452
3454 3453 Returns 0 on success.
3455 3454 """
3456 3455 fm = ui.formatter('manifest', opts)
3457 3456
3458 3457 if opts.get('all'):
3459 3458 if rev or node:
3460 3459 raise error.Abort(_("can't specify a revision with --all"))
3461 3460
3462 3461 res = []
3463 3462 prefix = "data/"
3464 3463 suffix = ".i"
3465 3464 plen = len(prefix)
3466 3465 slen = len(suffix)
3467 3466 with repo.lock():
3468 3467 for fn, b, size in repo.store.datafiles():
3469 3468 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
3470 3469 res.append(fn[plen:-slen])
3471 3470 ui.pager('manifest')
3472 3471 for f in res:
3473 3472 fm.startitem()
3474 3473 fm.write("path", '%s\n', f)
3475 3474 fm.end()
3476 3475 return
3477 3476
3478 3477 if rev and node:
3479 3478 raise error.Abort(_("please specify just one revision"))
3480 3479
3481 3480 if not node:
3482 3481 node = rev
3483 3482
3484 3483 char = {'l': '@', 'x': '*', '': ''}
3485 3484 mode = {'l': '644', 'x': '755', '': '644'}
3486 3485 ctx = scmutil.revsingle(repo, node)
3487 3486 mf = ctx.manifest()
3488 3487 ui.pager('manifest')
3489 3488 for f in ctx:
3490 3489 fm.startitem()
3491 3490 fl = ctx[f].flags()
3492 3491 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3493 3492 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3494 3493 fm.write('path', '%s\n', f)
3495 3494 fm.end()
3496 3495
3497 3496 @command('^merge',
3498 3497 [('f', 'force', None,
3499 3498 _('force a merge including outstanding changes (DEPRECATED)')),
3500 3499 ('r', 'rev', '', _('revision to merge'), _('REV')),
3501 3500 ('P', 'preview', None,
3502 3501 _('review revisions to merge (no merge is performed)'))
3503 3502 ] + mergetoolopts,
3504 3503 _('[-P] [[-r] REV]'))
3505 3504 def merge(ui, repo, node=None, **opts):
3506 3505 """merge another revision into working directory
3507 3506
3508 3507 The current working directory is updated with all changes made in
3509 3508 the requested revision since the last common predecessor revision.
3510 3509
3511 3510 Files that changed between either parent are marked as changed for
3512 3511 the next commit and a commit must be performed before any further
3513 3512 updates to the repository are allowed. The next commit will have
3514 3513 two parents.
3515 3514
3516 3515 ``--tool`` can be used to specify the merge tool used for file
3517 3516 merges. It overrides the HGMERGE environment variable and your
3518 3517 configuration files. See :hg:`help merge-tools` for options.
3519 3518
3520 3519 If no revision is specified, the working directory's parent is a
3521 3520 head revision, and the current branch contains exactly one other
3522 3521 head, the other head is merged with by default. Otherwise, an
3523 3522 explicit revision with which to merge with must be provided.
3524 3523
3525 3524 See :hg:`help resolve` for information on handling file conflicts.
3526 3525
3527 3526 To undo an uncommitted merge, use :hg:`update --clean .` which
3528 3527 will check out a clean copy of the original merge parent, losing
3529 3528 all changes.
3530 3529
3531 3530 Returns 0 on success, 1 if there are unresolved files.
3532 3531 """
3533 3532
3534 3533 if opts.get('rev') and node:
3535 3534 raise error.Abort(_("please specify just one revision"))
3536 3535 if not node:
3537 3536 node = opts.get('rev')
3538 3537
3539 3538 if node:
3540 3539 node = scmutil.revsingle(repo, node).node()
3541 3540
3542 3541 if not node:
3543 3542 node = repo[destutil.destmerge(repo)].node()
3544 3543
3545 3544 if opts.get('preview'):
3546 3545 # find nodes that are ancestors of p2 but not of p1
3547 3546 p1 = repo.lookup('.')
3548 3547 p2 = repo.lookup(node)
3549 3548 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3550 3549
3551 3550 displayer = cmdutil.show_changeset(ui, repo, opts)
3552 3551 for node in nodes:
3553 3552 displayer.show(repo[node])
3554 3553 displayer.close()
3555 3554 return 0
3556 3555
3557 3556 try:
3558 3557 # ui.forcemerge is an internal variable, do not document
3559 3558 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3560 3559 force = opts.get('force')
3561 3560 labels = ['working copy', 'merge rev']
3562 3561 return hg.merge(repo, node, force=force, mergeforce=force,
3563 3562 labels=labels)
3564 3563 finally:
3565 3564 ui.setconfig('ui', 'forcemerge', '', 'merge')
3566 3565
3567 3566 @command('outgoing|out',
3568 3567 [('f', 'force', None, _('run even when the destination is unrelated')),
3569 3568 ('r', 'rev', [],
3570 3569 _('a changeset intended to be included in the destination'), _('REV')),
3571 3570 ('n', 'newest-first', None, _('show newest record first')),
3572 3571 ('B', 'bookmarks', False, _('compare bookmarks')),
3573 3572 ('b', 'branch', [], _('a specific branch you would like to push'),
3574 3573 _('BRANCH')),
3575 3574 ] + logopts + remoteopts + subrepoopts,
3576 3575 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3577 3576 def outgoing(ui, repo, dest=None, **opts):
3578 3577 """show changesets not found in the destination
3579 3578
3580 3579 Show changesets not found in the specified destination repository
3581 3580 or the default push location. These are the changesets that would
3582 3581 be pushed if a push was requested.
3583 3582
3584 3583 See pull for details of valid destination formats.
3585 3584
3586 3585 .. container:: verbose
3587 3586
3588 3587 With -B/--bookmarks, the result of bookmark comparison between
3589 3588 local and remote repositories is displayed. With -v/--verbose,
3590 3589 status is also displayed for each bookmark like below::
3591 3590
3592 3591 BM1 01234567890a added
3593 3592 BM2 deleted
3594 3593 BM3 234567890abc advanced
3595 3594 BM4 34567890abcd diverged
3596 3595 BM5 4567890abcde changed
3597 3596
3598 3597 The action taken when pushing depends on the
3599 3598 status of each bookmark:
3600 3599
3601 3600 :``added``: push with ``-B`` will create it
3602 3601 :``deleted``: push with ``-B`` will delete it
3603 3602 :``advanced``: push will update it
3604 3603 :``diverged``: push with ``-B`` will update it
3605 3604 :``changed``: push with ``-B`` will update it
3606 3605
3607 3606 From the point of view of pushing behavior, bookmarks
3608 3607 existing only in the remote repository are treated as
3609 3608 ``deleted``, even if it is in fact added remotely.
3610 3609
3611 3610 Returns 0 if there are outgoing changes, 1 otherwise.
3612 3611 """
3613 3612 if opts.get('graph'):
3614 3613 cmdutil.checkunsupportedgraphflags([], opts)
3615 3614 o, other = hg._outgoing(ui, repo, dest, opts)
3616 3615 if not o:
3617 3616 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3618 3617 return
3619 3618
3620 3619 revdag = cmdutil.graphrevs(repo, o, opts)
3621 3620 ui.pager('outgoing')
3622 3621 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3623 3622 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
3624 3623 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3625 3624 return 0
3626 3625
3627 3626 if opts.get('bookmarks'):
3628 3627 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3629 3628 dest, branches = hg.parseurl(dest, opts.get('branch'))
3630 3629 other = hg.peer(repo, opts, dest)
3631 3630 if 'bookmarks' not in other.listkeys('namespaces'):
3632 3631 ui.warn(_("remote doesn't support bookmarks\n"))
3633 3632 return 0
3634 3633 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3635 3634 ui.pager('outgoing')
3636 3635 return bookmarks.outgoing(ui, repo, other)
3637 3636
3638 3637 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3639 3638 try:
3640 3639 return hg.outgoing(ui, repo, dest, opts)
3641 3640 finally:
3642 3641 del repo._subtoppath
3643 3642
3644 3643 @command('parents',
3645 3644 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3646 3645 ] + templateopts,
3647 3646 _('[-r REV] [FILE]'),
3648 3647 inferrepo=True)
3649 3648 def parents(ui, repo, file_=None, **opts):
3650 3649 """show the parents of the working directory or revision (DEPRECATED)
3651 3650
3652 3651 Print the working directory's parent revisions. If a revision is
3653 3652 given via -r/--rev, the parent of that revision will be printed.
3654 3653 If a file argument is given, the revision in which the file was
3655 3654 last changed (before the working directory revision or the
3656 3655 argument to --rev if given) is printed.
3657 3656
3658 3657 This command is equivalent to::
3659 3658
3660 3659 hg log -r "p1()+p2()" or
3661 3660 hg log -r "p1(REV)+p2(REV)" or
3662 3661 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3663 3662 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3664 3663
3665 3664 See :hg:`summary` and :hg:`help revsets` for related information.
3666 3665
3667 3666 Returns 0 on success.
3668 3667 """
3669 3668
3670 3669 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3671 3670
3672 3671 if file_:
3673 3672 m = scmutil.match(ctx, (file_,), opts)
3674 3673 if m.anypats() or len(m.files()) != 1:
3675 3674 raise error.Abort(_('can only specify an explicit filename'))
3676 3675 file_ = m.files()[0]
3677 3676 filenodes = []
3678 3677 for cp in ctx.parents():
3679 3678 if not cp:
3680 3679 continue
3681 3680 try:
3682 3681 filenodes.append(cp.filenode(file_))
3683 3682 except error.LookupError:
3684 3683 pass
3685 3684 if not filenodes:
3686 3685 raise error.Abort(_("'%s' not found in manifest!") % file_)
3687 3686 p = []
3688 3687 for fn in filenodes:
3689 3688 fctx = repo.filectx(file_, fileid=fn)
3690 3689 p.append(fctx.node())
3691 3690 else:
3692 3691 p = [cp.node() for cp in ctx.parents()]
3693 3692
3694 3693 displayer = cmdutil.show_changeset(ui, repo, opts)
3695 3694 for n in p:
3696 3695 if n != nullid:
3697 3696 displayer.show(repo[n])
3698 3697 displayer.close()
3699 3698
3700 3699 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True)
3701 3700 def paths(ui, repo, search=None, **opts):
3702 3701 """show aliases for remote repositories
3703 3702
3704 3703 Show definition of symbolic path name NAME. If no name is given,
3705 3704 show definition of all available names.
3706 3705
3707 3706 Option -q/--quiet suppresses all output when searching for NAME
3708 3707 and shows only the path names when listing all definitions.
3709 3708
3710 3709 Path names are defined in the [paths] section of your
3711 3710 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3712 3711 repository, ``.hg/hgrc`` is used, too.
3713 3712
3714 3713 The path names ``default`` and ``default-push`` have a special
3715 3714 meaning. When performing a push or pull operation, they are used
3716 3715 as fallbacks if no location is specified on the command-line.
3717 3716 When ``default-push`` is set, it will be used for push and
3718 3717 ``default`` will be used for pull; otherwise ``default`` is used
3719 3718 as the fallback for both. When cloning a repository, the clone
3720 3719 source is written as ``default`` in ``.hg/hgrc``.
3721 3720
3722 3721 .. note::
3723 3722
3724 3723 ``default`` and ``default-push`` apply to all inbound (e.g.
3725 3724 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3726 3725 and :hg:`bundle`) operations.
3727 3726
3728 3727 See :hg:`help urls` for more information.
3729 3728
3730 3729 Returns 0 on success.
3731 3730 """
3732 3731 ui.pager('paths')
3733 3732 if search:
3734 3733 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3735 3734 if name == search]
3736 3735 else:
3737 3736 pathitems = sorted(ui.paths.iteritems())
3738 3737
3739 3738 fm = ui.formatter('paths', opts)
3740 3739 if fm.isplain():
3741 3740 hidepassword = util.hidepassword
3742 3741 else:
3743 3742 hidepassword = str
3744 3743 if ui.quiet:
3745 3744 namefmt = '%s\n'
3746 3745 else:
3747 3746 namefmt = '%s = '
3748 3747 showsubopts = not search and not ui.quiet
3749 3748
3750 3749 for name, path in pathitems:
3751 3750 fm.startitem()
3752 3751 fm.condwrite(not search, 'name', namefmt, name)
3753 3752 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3754 3753 for subopt, value in sorted(path.suboptions.items()):
3755 3754 assert subopt not in ('name', 'url')
3756 3755 if showsubopts:
3757 3756 fm.plain('%s:%s = ' % (name, subopt))
3758 3757 fm.condwrite(showsubopts, subopt, '%s\n', value)
3759 3758
3760 3759 fm.end()
3761 3760
3762 3761 if search and not pathitems:
3763 3762 if not ui.quiet:
3764 3763 ui.warn(_("not found!\n"))
3765 3764 return 1
3766 3765 else:
3767 3766 return 0
3768 3767
3769 3768 @command('phase',
3770 3769 [('p', 'public', False, _('set changeset phase to public')),
3771 3770 ('d', 'draft', False, _('set changeset phase to draft')),
3772 3771 ('s', 'secret', False, _('set changeset phase to secret')),
3773 3772 ('f', 'force', False, _('allow to move boundary backward')),
3774 3773 ('r', 'rev', [], _('target revision'), _('REV')),
3775 3774 ],
3776 3775 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3777 3776 def phase(ui, repo, *revs, **opts):
3778 3777 """set or show the current phase name
3779 3778
3780 3779 With no argument, show the phase name of the current revision(s).
3781 3780
3782 3781 With one of -p/--public, -d/--draft or -s/--secret, change the
3783 3782 phase value of the specified revisions.
3784 3783
3785 3784 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
3786 3785 lower phase to an higher phase. Phases are ordered as follows::
3787 3786
3788 3787 public < draft < secret
3789 3788
3790 3789 Returns 0 on success, 1 if some phases could not be changed.
3791 3790
3792 3791 (For more information about the phases concept, see :hg:`help phases`.)
3793 3792 """
3794 3793 # search for a unique phase argument
3795 3794 targetphase = None
3796 3795 for idx, name in enumerate(phases.phasenames):
3797 3796 if opts[name]:
3798 3797 if targetphase is not None:
3799 3798 raise error.Abort(_('only one phase can be specified'))
3800 3799 targetphase = idx
3801 3800
3802 3801 # look for specified revision
3803 3802 revs = list(revs)
3804 3803 revs.extend(opts['rev'])
3805 3804 if not revs:
3806 3805 # display both parents as the second parent phase can influence
3807 3806 # the phase of a merge commit
3808 3807 revs = [c.rev() for c in repo[None].parents()]
3809 3808
3810 3809 revs = scmutil.revrange(repo, revs)
3811 3810
3812 3811 lock = None
3813 3812 ret = 0
3814 3813 if targetphase is None:
3815 3814 # display
3816 3815 for r in revs:
3817 3816 ctx = repo[r]
3818 3817 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3819 3818 else:
3820 3819 tr = None
3821 3820 lock = repo.lock()
3822 3821 try:
3823 3822 tr = repo.transaction("phase")
3824 3823 # set phase
3825 3824 if not revs:
3826 3825 raise error.Abort(_('empty revision set'))
3827 3826 nodes = [repo[r].node() for r in revs]
3828 3827 # moving revision from public to draft may hide them
3829 3828 # We have to check result on an unfiltered repository
3830 3829 unfi = repo.unfiltered()
3831 3830 getphase = unfi._phasecache.phase
3832 3831 olddata = [getphase(unfi, r) for r in unfi]
3833 3832 phases.advanceboundary(repo, tr, targetphase, nodes)
3834 3833 if opts['force']:
3835 3834 phases.retractboundary(repo, tr, targetphase, nodes)
3836 3835 tr.close()
3837 3836 finally:
3838 3837 if tr is not None:
3839 3838 tr.release()
3840 3839 lock.release()
3841 3840 getphase = unfi._phasecache.phase
3842 3841 newdata = [getphase(unfi, r) for r in unfi]
3843 3842 changes = sum(newdata[r] != olddata[r] for r in unfi)
3844 3843 cl = unfi.changelog
3845 3844 rejected = [n for n in nodes
3846 3845 if newdata[cl.rev(n)] < targetphase]
3847 3846 if rejected:
3848 3847 ui.warn(_('cannot move %i changesets to a higher '
3849 3848 'phase, use --force\n') % len(rejected))
3850 3849 ret = 1
3851 3850 if changes:
3852 3851 msg = _('phase changed for %i changesets\n') % changes
3853 3852 if ret:
3854 3853 ui.status(msg)
3855 3854 else:
3856 3855 ui.note(msg)
3857 3856 else:
3858 3857 ui.warn(_('no phases changed\n'))
3859 3858 return ret
3860 3859
3861 3860 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3862 3861 """Run after a changegroup has been added via pull/unbundle
3863 3862
3864 3863 This takes arguments below:
3865 3864
3866 3865 :modheads: change of heads by pull/unbundle
3867 3866 :optupdate: updating working directory is needed or not
3868 3867 :checkout: update destination revision (or None to default destination)
3869 3868 :brev: a name, which might be a bookmark to be activated after updating
3870 3869 """
3871 3870 if modheads == 0:
3872 3871 return
3873 3872 if optupdate:
3874 3873 try:
3875 3874 return hg.updatetotally(ui, repo, checkout, brev)
3876 3875 except error.UpdateAbort as inst:
3877 3876 msg = _("not updating: %s") % str(inst)
3878 3877 hint = inst.hint
3879 3878 raise error.UpdateAbort(msg, hint=hint)
3880 3879 if modheads > 1:
3881 3880 currentbranchheads = len(repo.branchheads())
3882 3881 if currentbranchheads == modheads:
3883 3882 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3884 3883 elif currentbranchheads > 1:
3885 3884 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3886 3885 "merge)\n"))
3887 3886 else:
3888 3887 ui.status(_("(run 'hg heads' to see heads)\n"))
3889 3888 else:
3890 3889 ui.status(_("(run 'hg update' to get a working copy)\n"))
3891 3890
3892 3891 @command('^pull',
3893 3892 [('u', 'update', None,
3894 3893 _('update to new branch head if changesets were pulled')),
3895 3894 ('f', 'force', None, _('run even when remote repository is unrelated')),
3896 3895 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3897 3896 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3898 3897 ('b', 'branch', [], _('a specific branch you would like to pull'),
3899 3898 _('BRANCH')),
3900 3899 ] + remoteopts,
3901 3900 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3902 3901 def pull(ui, repo, source="default", **opts):
3903 3902 """pull changes from the specified source
3904 3903
3905 3904 Pull changes from a remote repository to a local one.
3906 3905
3907 3906 This finds all changes from the repository at the specified path
3908 3907 or URL and adds them to a local repository (the current one unless
3909 3908 -R is specified). By default, this does not update the copy of the
3910 3909 project in the working directory.
3911 3910
3912 3911 Use :hg:`incoming` if you want to see what would have been added
3913 3912 by a pull at the time you issued this command. If you then decide
3914 3913 to add those changes to the repository, you should use :hg:`pull
3915 3914 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
3916 3915
3917 3916 If SOURCE is omitted, the 'default' path will be used.
3918 3917 See :hg:`help urls` for more information.
3919 3918
3920 3919 Specifying bookmark as ``.`` is equivalent to specifying the active
3921 3920 bookmark's name.
3922 3921
3923 3922 Returns 0 on success, 1 if an update had unresolved files.
3924 3923 """
3925 3924 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
3926 3925 ui.status(_('pulling from %s\n') % util.hidepassword(source))
3927 3926 other = hg.peer(repo, opts, source)
3928 3927 try:
3929 3928 revs, checkout = hg.addbranchrevs(repo, other, branches,
3930 3929 opts.get('rev'))
3931 3930
3932 3931
3933 3932 pullopargs = {}
3934 3933 if opts.get('bookmark'):
3935 3934 if not revs:
3936 3935 revs = []
3937 3936 # The list of bookmark used here is not the one used to actually
3938 3937 # update the bookmark name. This can result in the revision pulled
3939 3938 # not ending up with the name of the bookmark because of a race
3940 3939 # condition on the server. (See issue 4689 for details)
3941 3940 remotebookmarks = other.listkeys('bookmarks')
3942 3941 pullopargs['remotebookmarks'] = remotebookmarks
3943 3942 for b in opts['bookmark']:
3944 3943 b = repo._bookmarks.expandname(b)
3945 3944 if b not in remotebookmarks:
3946 3945 raise error.Abort(_('remote bookmark %s not found!') % b)
3947 3946 revs.append(remotebookmarks[b])
3948 3947
3949 3948 if revs:
3950 3949 try:
3951 3950 # When 'rev' is a bookmark name, we cannot guarantee that it
3952 3951 # will be updated with that name because of a race condition
3953 3952 # server side. (See issue 4689 for details)
3954 3953 oldrevs = revs
3955 3954 revs = [] # actually, nodes
3956 3955 for r in oldrevs:
3957 3956 node = other.lookup(r)
3958 3957 revs.append(node)
3959 3958 if r == checkout:
3960 3959 checkout = node
3961 3960 except error.CapabilityError:
3962 3961 err = _("other repository doesn't support revision lookup, "
3963 3962 "so a rev cannot be specified.")
3964 3963 raise error.Abort(err)
3965 3964
3966 3965 pullopargs.update(opts.get('opargs', {}))
3967 3966 modheads = exchange.pull(repo, other, heads=revs,
3968 3967 force=opts.get('force'),
3969 3968 bookmarks=opts.get('bookmark', ()),
3970 3969 opargs=pullopargs).cgresult
3971 3970
3972 3971 # brev is a name, which might be a bookmark to be activated at
3973 3972 # the end of the update. In other words, it is an explicit
3974 3973 # destination of the update
3975 3974 brev = None
3976 3975
3977 3976 if checkout:
3978 3977 checkout = str(repo.changelog.rev(checkout))
3979 3978
3980 3979 # order below depends on implementation of
3981 3980 # hg.addbranchrevs(). opts['bookmark'] is ignored,
3982 3981 # because 'checkout' is determined without it.
3983 3982 if opts.get('rev'):
3984 3983 brev = opts['rev'][0]
3985 3984 elif opts.get('branch'):
3986 3985 brev = opts['branch'][0]
3987 3986 else:
3988 3987 brev = branches[0]
3989 3988 repo._subtoppath = source
3990 3989 try:
3991 3990 ret = postincoming(ui, repo, modheads, opts.get('update'),
3992 3991 checkout, brev)
3993 3992
3994 3993 finally:
3995 3994 del repo._subtoppath
3996 3995
3997 3996 finally:
3998 3997 other.close()
3999 3998 return ret
4000 3999
4001 4000 @command('^push',
4002 4001 [('f', 'force', None, _('force push')),
4003 4002 ('r', 'rev', [],
4004 4003 _('a changeset intended to be included in the destination'),
4005 4004 _('REV')),
4006 4005 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4007 4006 ('b', 'branch', [],
4008 4007 _('a specific branch you would like to push'), _('BRANCH')),
4009 4008 ('', 'new-branch', False, _('allow pushing a new branch')),
4010 4009 ] + remoteopts,
4011 4010 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4012 4011 def push(ui, repo, dest=None, **opts):
4013 4012 """push changes to the specified destination
4014 4013
4015 4014 Push changesets from the local repository to the specified
4016 4015 destination.
4017 4016
4018 4017 This operation is symmetrical to pull: it is identical to a pull
4019 4018 in the destination repository from the current one.
4020 4019
4021 4020 By default, push will not allow creation of new heads at the
4022 4021 destination, since multiple heads would make it unclear which head
4023 4022 to use. In this situation, it is recommended to pull and merge
4024 4023 before pushing.
4025 4024
4026 4025 Use --new-branch if you want to allow push to create a new named
4027 4026 branch that is not present at the destination. This allows you to
4028 4027 only create a new branch without forcing other changes.
4029 4028
4030 4029 .. note::
4031 4030
4032 4031 Extra care should be taken with the -f/--force option,
4033 4032 which will push all new heads on all branches, an action which will
4034 4033 almost always cause confusion for collaborators.
4035 4034
4036 4035 If -r/--rev is used, the specified revision and all its ancestors
4037 4036 will be pushed to the remote repository.
4038 4037
4039 4038 If -B/--bookmark is used, the specified bookmarked revision, its
4040 4039 ancestors, and the bookmark will be pushed to the remote
4041 4040 repository. Specifying ``.`` is equivalent to specifying the active
4042 4041 bookmark's name.
4043 4042
4044 4043 Please see :hg:`help urls` for important details about ``ssh://``
4045 4044 URLs. If DESTINATION is omitted, a default path will be used.
4046 4045
4047 4046 Returns 0 if push was successful, 1 if nothing to push.
4048 4047 """
4049 4048
4050 4049 if opts.get('bookmark'):
4051 4050 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4052 4051 for b in opts['bookmark']:
4053 4052 # translate -B options to -r so changesets get pushed
4054 4053 b = repo._bookmarks.expandname(b)
4055 4054 if b in repo._bookmarks:
4056 4055 opts.setdefault('rev', []).append(b)
4057 4056 else:
4058 4057 # if we try to push a deleted bookmark, translate it to null
4059 4058 # this lets simultaneous -r, -b options continue working
4060 4059 opts.setdefault('rev', []).append("null")
4061 4060
4062 4061 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4063 4062 if not path:
4064 4063 raise error.Abort(_('default repository not configured!'),
4065 4064 hint=_("see 'hg help config.paths'"))
4066 4065 dest = path.pushloc or path.loc
4067 4066 branches = (path.branch, opts.get('branch') or [])
4068 4067 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4069 4068 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4070 4069 other = hg.peer(repo, opts, dest)
4071 4070
4072 4071 if revs:
4073 4072 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4074 4073 if not revs:
4075 4074 raise error.Abort(_("specified revisions evaluate to an empty set"),
4076 4075 hint=_("use different revision arguments"))
4077 4076 elif path.pushrev:
4078 4077 # It doesn't make any sense to specify ancestor revisions. So limit
4079 4078 # to DAG heads to make discovery simpler.
4080 4079 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4081 4080 revs = scmutil.revrange(repo, [expr])
4082 4081 revs = [repo[rev].node() for rev in revs]
4083 4082 if not revs:
4084 4083 raise error.Abort(_('default push revset for path evaluates to an '
4085 4084 'empty set'))
4086 4085
4087 4086 repo._subtoppath = dest
4088 4087 try:
4089 4088 # push subrepos depth-first for coherent ordering
4090 4089 c = repo['']
4091 4090 subs = c.substate # only repos that are committed
4092 4091 for s in sorted(subs):
4093 4092 result = c.sub(s).push(opts)
4094 4093 if result == 0:
4095 4094 return not result
4096 4095 finally:
4097 4096 del repo._subtoppath
4098 4097 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4099 4098 newbranch=opts.get('new_branch'),
4100 4099 bookmarks=opts.get('bookmark', ()),
4101 4100 opargs=opts.get('opargs'))
4102 4101
4103 4102 result = not pushop.cgresult
4104 4103
4105 4104 if pushop.bkresult is not None:
4106 4105 if pushop.bkresult == 2:
4107 4106 result = 2
4108 4107 elif not result and pushop.bkresult:
4109 4108 result = 2
4110 4109
4111 4110 return result
4112 4111
4113 4112 @command('recover', [])
4114 4113 def recover(ui, repo):
4115 4114 """roll back an interrupted transaction
4116 4115
4117 4116 Recover from an interrupted commit or pull.
4118 4117
4119 4118 This command tries to fix the repository status after an
4120 4119 interrupted operation. It should only be necessary when Mercurial
4121 4120 suggests it.
4122 4121
4123 4122 Returns 0 if successful, 1 if nothing to recover or verify fails.
4124 4123 """
4125 4124 if repo.recover():
4126 4125 return hg.verify(repo)
4127 4126 return 1
4128 4127
4129 4128 @command('^remove|rm',
4130 4129 [('A', 'after', None, _('record delete for missing files')),
4131 4130 ('f', 'force', None,
4132 4131 _('forget added files, delete modified files')),
4133 4132 ] + subrepoopts + walkopts,
4134 4133 _('[OPTION]... FILE...'),
4135 4134 inferrepo=True)
4136 4135 def remove(ui, repo, *pats, **opts):
4137 4136 """remove the specified files on the next commit
4138 4137
4139 4138 Schedule the indicated files for removal from the current branch.
4140 4139
4141 4140 This command schedules the files to be removed at the next commit.
4142 4141 To undo a remove before that, see :hg:`revert`. To undo added
4143 4142 files, see :hg:`forget`.
4144 4143
4145 4144 .. container:: verbose
4146 4145
4147 4146 -A/--after can be used to remove only files that have already
4148 4147 been deleted, -f/--force can be used to force deletion, and -Af
4149 4148 can be used to remove files from the next revision without
4150 4149 deleting them from the working directory.
4151 4150
4152 4151 The following table details the behavior of remove for different
4153 4152 file states (columns) and option combinations (rows). The file
4154 4153 states are Added [A], Clean [C], Modified [M] and Missing [!]
4155 4154 (as reported by :hg:`status`). The actions are Warn, Remove
4156 4155 (from branch) and Delete (from disk):
4157 4156
4158 4157 ========= == == == ==
4159 4158 opt/state A C M !
4160 4159 ========= == == == ==
4161 4160 none W RD W R
4162 4161 -f R RD RD R
4163 4162 -A W W W R
4164 4163 -Af R R R R
4165 4164 ========= == == == ==
4166 4165
4167 4166 .. note::
4168 4167
4169 4168 :hg:`remove` never deletes files in Added [A] state from the
4170 4169 working directory, not even if ``--force`` is specified.
4171 4170
4172 4171 Returns 0 on success, 1 if any warnings encountered.
4173 4172 """
4174 4173
4175 4174 after, force = opts.get('after'), opts.get('force')
4176 4175 if not pats and not after:
4177 4176 raise error.Abort(_('no files specified'))
4178 4177
4179 4178 m = scmutil.match(repo[None], pats, opts)
4180 4179 subrepos = opts.get('subrepos')
4181 4180 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
4182 4181
4183 4182 @command('rename|move|mv',
4184 4183 [('A', 'after', None, _('record a rename that has already occurred')),
4185 4184 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4186 4185 ] + walkopts + dryrunopts,
4187 4186 _('[OPTION]... SOURCE... DEST'))
4188 4187 def rename(ui, repo, *pats, **opts):
4189 4188 """rename files; equivalent of copy + remove
4190 4189
4191 4190 Mark dest as copies of sources; mark sources for deletion. If dest
4192 4191 is a directory, copies are put in that directory. If dest is a
4193 4192 file, there can only be one source.
4194 4193
4195 4194 By default, this command copies the contents of files as they
4196 4195 exist in the working directory. If invoked with -A/--after, the
4197 4196 operation is recorded, but no copying is performed.
4198 4197
4199 4198 This command takes effect at the next commit. To undo a rename
4200 4199 before that, see :hg:`revert`.
4201 4200
4202 4201 Returns 0 on success, 1 if errors are encountered.
4203 4202 """
4204 4203 with repo.wlock(False):
4205 4204 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4206 4205
4207 4206 @command('resolve',
4208 4207 [('a', 'all', None, _('select all unresolved files')),
4209 4208 ('l', 'list', None, _('list state of files needing merge')),
4210 4209 ('m', 'mark', None, _('mark files as resolved')),
4211 4210 ('u', 'unmark', None, _('mark files as unresolved')),
4212 4211 ('n', 'no-status', None, _('hide status prefix'))]
4213 4212 + mergetoolopts + walkopts + formatteropts,
4214 4213 _('[OPTION]... [FILE]...'),
4215 4214 inferrepo=True)
4216 4215 def resolve(ui, repo, *pats, **opts):
4217 4216 """redo merges or set/view the merge status of files
4218 4217
4219 4218 Merges with unresolved conflicts are often the result of
4220 4219 non-interactive merging using the ``internal:merge`` configuration
4221 4220 setting, or a command-line merge tool like ``diff3``. The resolve
4222 4221 command is used to manage the files involved in a merge, after
4223 4222 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4224 4223 working directory must have two parents). See :hg:`help
4225 4224 merge-tools` for information on configuring merge tools.
4226 4225
4227 4226 The resolve command can be used in the following ways:
4228 4227
4229 4228 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4230 4229 files, discarding any previous merge attempts. Re-merging is not
4231 4230 performed for files already marked as resolved. Use ``--all/-a``
4232 4231 to select all unresolved files. ``--tool`` can be used to specify
4233 4232 the merge tool used for the given files. It overrides the HGMERGE
4234 4233 environment variable and your configuration files. Previous file
4235 4234 contents are saved with a ``.orig`` suffix.
4236 4235
4237 4236 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4238 4237 (e.g. after having manually fixed-up the files). The default is
4239 4238 to mark all unresolved files.
4240 4239
4241 4240 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4242 4241 default is to mark all resolved files.
4243 4242
4244 4243 - :hg:`resolve -l`: list files which had or still have conflicts.
4245 4244 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4246 4245 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4247 4246 the list. See :hg:`help filesets` for details.
4248 4247
4249 4248 .. note::
4250 4249
4251 4250 Mercurial will not let you commit files with unresolved merge
4252 4251 conflicts. You must use :hg:`resolve -m ...` before you can
4253 4252 commit after a conflicting merge.
4254 4253
4255 4254 Returns 0 on success, 1 if any files fail a resolve attempt.
4256 4255 """
4257 4256
4258 4257 flaglist = 'all mark unmark list no_status'.split()
4259 4258 all, mark, unmark, show, nostatus = \
4260 4259 [opts.get(o) for o in flaglist]
4261 4260
4262 4261 if (show and (mark or unmark)) or (mark and unmark):
4263 4262 raise error.Abort(_("too many options specified"))
4264 4263 if pats and all:
4265 4264 raise error.Abort(_("can't specify --all and patterns"))
4266 4265 if not (all or pats or show or mark or unmark):
4267 4266 raise error.Abort(_('no files or directories specified'),
4268 4267 hint=('use --all to re-merge all unresolved files'))
4269 4268
4270 4269 if show:
4271 4270 ui.pager('resolve')
4272 4271 fm = ui.formatter('resolve', opts)
4273 4272 ms = mergemod.mergestate.read(repo)
4274 4273 m = scmutil.match(repo[None], pats, opts)
4275 4274 for f in ms:
4276 4275 if not m(f):
4277 4276 continue
4278 4277 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
4279 4278 'd': 'driverresolved'}[ms[f]]
4280 4279 fm.startitem()
4281 4280 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
4282 4281 fm.write('path', '%s\n', f, label=l)
4283 4282 fm.end()
4284 4283 return 0
4285 4284
4286 4285 with repo.wlock():
4287 4286 ms = mergemod.mergestate.read(repo)
4288 4287
4289 4288 if not (ms.active() or repo.dirstate.p2() != nullid):
4290 4289 raise error.Abort(
4291 4290 _('resolve command not applicable when not merging'))
4292 4291
4293 4292 wctx = repo[None]
4294 4293
4295 4294 if ms.mergedriver and ms.mdstate() == 'u':
4296 4295 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4297 4296 ms.commit()
4298 4297 # allow mark and unmark to go through
4299 4298 if not mark and not unmark and not proceed:
4300 4299 return 1
4301 4300
4302 4301 m = scmutil.match(wctx, pats, opts)
4303 4302 ret = 0
4304 4303 didwork = False
4305 4304 runconclude = False
4306 4305
4307 4306 tocomplete = []
4308 4307 for f in ms:
4309 4308 if not m(f):
4310 4309 continue
4311 4310
4312 4311 didwork = True
4313 4312
4314 4313 # don't let driver-resolved files be marked, and run the conclude
4315 4314 # step if asked to resolve
4316 4315 if ms[f] == "d":
4317 4316 exact = m.exact(f)
4318 4317 if mark:
4319 4318 if exact:
4320 4319 ui.warn(_('not marking %s as it is driver-resolved\n')
4321 4320 % f)
4322 4321 elif unmark:
4323 4322 if exact:
4324 4323 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4325 4324 % f)
4326 4325 else:
4327 4326 runconclude = True
4328 4327 continue
4329 4328
4330 4329 if mark:
4331 4330 ms.mark(f, "r")
4332 4331 elif unmark:
4333 4332 ms.mark(f, "u")
4334 4333 else:
4335 4334 # backup pre-resolve (merge uses .orig for its own purposes)
4336 4335 a = repo.wjoin(f)
4337 4336 try:
4338 4337 util.copyfile(a, a + ".resolve")
4339 4338 except (IOError, OSError) as inst:
4340 4339 if inst.errno != errno.ENOENT:
4341 4340 raise
4342 4341
4343 4342 try:
4344 4343 # preresolve file
4345 4344 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4346 4345 'resolve')
4347 4346 complete, r = ms.preresolve(f, wctx)
4348 4347 if not complete:
4349 4348 tocomplete.append(f)
4350 4349 elif r:
4351 4350 ret = 1
4352 4351 finally:
4353 4352 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4354 4353 ms.commit()
4355 4354
4356 4355 # replace filemerge's .orig file with our resolve file, but only
4357 4356 # for merges that are complete
4358 4357 if complete:
4359 4358 try:
4360 4359 util.rename(a + ".resolve",
4361 4360 scmutil.origpath(ui, repo, a))
4362 4361 except OSError as inst:
4363 4362 if inst.errno != errno.ENOENT:
4364 4363 raise
4365 4364
4366 4365 for f in tocomplete:
4367 4366 try:
4368 4367 # resolve file
4369 4368 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4370 4369 'resolve')
4371 4370 r = ms.resolve(f, wctx)
4372 4371 if r:
4373 4372 ret = 1
4374 4373 finally:
4375 4374 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4376 4375 ms.commit()
4377 4376
4378 4377 # replace filemerge's .orig file with our resolve file
4379 4378 a = repo.wjoin(f)
4380 4379 try:
4381 4380 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4382 4381 except OSError as inst:
4383 4382 if inst.errno != errno.ENOENT:
4384 4383 raise
4385 4384
4386 4385 ms.commit()
4387 4386 ms.recordactions()
4388 4387
4389 4388 if not didwork and pats:
4390 4389 hint = None
4391 4390 if not any([p for p in pats if p.find(':') >= 0]):
4392 4391 pats = ['path:%s' % p for p in pats]
4393 4392 m = scmutil.match(wctx, pats, opts)
4394 4393 for f in ms:
4395 4394 if not m(f):
4396 4395 continue
4397 4396 flags = ''.join(['-%s ' % o[0] for o in flaglist
4398 4397 if opts.get(o)])
4399 4398 hint = _("(try: hg resolve %s%s)\n") % (
4400 4399 flags,
4401 4400 ' '.join(pats))
4402 4401 break
4403 4402 ui.warn(_("arguments do not match paths that need resolving\n"))
4404 4403 if hint:
4405 4404 ui.warn(hint)
4406 4405 elif ms.mergedriver and ms.mdstate() != 's':
4407 4406 # run conclude step when either a driver-resolved file is requested
4408 4407 # or there are no driver-resolved files
4409 4408 # we can't use 'ret' to determine whether any files are unresolved
4410 4409 # because we might not have tried to resolve some
4411 4410 if ((runconclude or not list(ms.driverresolved()))
4412 4411 and not list(ms.unresolved())):
4413 4412 proceed = mergemod.driverconclude(repo, ms, wctx)
4414 4413 ms.commit()
4415 4414 if not proceed:
4416 4415 return 1
4417 4416
4418 4417 # Nudge users into finishing an unfinished operation
4419 4418 unresolvedf = list(ms.unresolved())
4420 4419 driverresolvedf = list(ms.driverresolved())
4421 4420 if not unresolvedf and not driverresolvedf:
4422 4421 ui.status(_('(no more unresolved files)\n'))
4423 4422 cmdutil.checkafterresolved(repo)
4424 4423 elif not unresolvedf:
4425 4424 ui.status(_('(no more unresolved files -- '
4426 4425 'run "hg resolve --all" to conclude)\n'))
4427 4426
4428 4427 return ret
4429 4428
4430 4429 @command('revert',
4431 4430 [('a', 'all', None, _('revert all changes when no arguments given')),
4432 4431 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4433 4432 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4434 4433 ('C', 'no-backup', None, _('do not save backup copies of files')),
4435 4434 ('i', 'interactive', None,
4436 4435 _('interactively select the changes (EXPERIMENTAL)')),
4437 4436 ] + walkopts + dryrunopts,
4438 4437 _('[OPTION]... [-r REV] [NAME]...'))
4439 4438 def revert(ui, repo, *pats, **opts):
4440 4439 """restore files to their checkout state
4441 4440
4442 4441 .. note::
4443 4442
4444 4443 To check out earlier revisions, you should use :hg:`update REV`.
4445 4444 To cancel an uncommitted merge (and lose your changes),
4446 4445 use :hg:`update --clean .`.
4447 4446
4448 4447 With no revision specified, revert the specified files or directories
4449 4448 to the contents they had in the parent of the working directory.
4450 4449 This restores the contents of files to an unmodified
4451 4450 state and unschedules adds, removes, copies, and renames. If the
4452 4451 working directory has two parents, you must explicitly specify a
4453 4452 revision.
4454 4453
4455 4454 Using the -r/--rev or -d/--date options, revert the given files or
4456 4455 directories to their states as of a specific revision. Because
4457 4456 revert does not change the working directory parents, this will
4458 4457 cause these files to appear modified. This can be helpful to "back
4459 4458 out" some or all of an earlier change. See :hg:`backout` for a
4460 4459 related method.
4461 4460
4462 4461 Modified files are saved with a .orig suffix before reverting.
4463 4462 To disable these backups, use --no-backup. It is possible to store
4464 4463 the backup files in a custom directory relative to the root of the
4465 4464 repository by setting the ``ui.origbackuppath`` configuration
4466 4465 option.
4467 4466
4468 4467 See :hg:`help dates` for a list of formats valid for -d/--date.
4469 4468
4470 4469 See :hg:`help backout` for a way to reverse the effect of an
4471 4470 earlier changeset.
4472 4471
4473 4472 Returns 0 on success.
4474 4473 """
4475 4474
4476 4475 if opts.get("date"):
4477 4476 if opts.get("rev"):
4478 4477 raise error.Abort(_("you can't specify a revision and a date"))
4479 4478 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4480 4479
4481 4480 parent, p2 = repo.dirstate.parents()
4482 4481 if not opts.get('rev') and p2 != nullid:
4483 4482 # revert after merge is a trap for new users (issue2915)
4484 4483 raise error.Abort(_('uncommitted merge with no revision specified'),
4485 4484 hint=_("use 'hg update' or see 'hg help revert'"))
4486 4485
4487 4486 ctx = scmutil.revsingle(repo, opts.get('rev'))
4488 4487
4489 4488 if (not (pats or opts.get('include') or opts.get('exclude') or
4490 4489 opts.get('all') or opts.get('interactive'))):
4491 4490 msg = _("no files or directories specified")
4492 4491 if p2 != nullid:
4493 4492 hint = _("uncommitted merge, use --all to discard all changes,"
4494 4493 " or 'hg update -C .' to abort the merge")
4495 4494 raise error.Abort(msg, hint=hint)
4496 4495 dirty = any(repo.status())
4497 4496 node = ctx.node()
4498 4497 if node != parent:
4499 4498 if dirty:
4500 4499 hint = _("uncommitted changes, use --all to discard all"
4501 4500 " changes, or 'hg update %s' to update") % ctx.rev()
4502 4501 else:
4503 4502 hint = _("use --all to revert all files,"
4504 4503 " or 'hg update %s' to update") % ctx.rev()
4505 4504 elif dirty:
4506 4505 hint = _("uncommitted changes, use --all to discard all changes")
4507 4506 else:
4508 4507 hint = _("use --all to revert all files")
4509 4508 raise error.Abort(msg, hint=hint)
4510 4509
4511 4510 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
4512 4511
4513 4512 @command('rollback', dryrunopts +
4514 4513 [('f', 'force', False, _('ignore safety measures'))])
4515 4514 def rollback(ui, repo, **opts):
4516 4515 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4517 4516
4518 4517 Please use :hg:`commit --amend` instead of rollback to correct
4519 4518 mistakes in the last commit.
4520 4519
4521 4520 This command should be used with care. There is only one level of
4522 4521 rollback, and there is no way to undo a rollback. It will also
4523 4522 restore the dirstate at the time of the last transaction, losing
4524 4523 any dirstate changes since that time. This command does not alter
4525 4524 the working directory.
4526 4525
4527 4526 Transactions are used to encapsulate the effects of all commands
4528 4527 that create new changesets or propagate existing changesets into a
4529 4528 repository.
4530 4529
4531 4530 .. container:: verbose
4532 4531
4533 4532 For example, the following commands are transactional, and their
4534 4533 effects can be rolled back:
4535 4534
4536 4535 - commit
4537 4536 - import
4538 4537 - pull
4539 4538 - push (with this repository as the destination)
4540 4539 - unbundle
4541 4540
4542 4541 To avoid permanent data loss, rollback will refuse to rollback a
4543 4542 commit transaction if it isn't checked out. Use --force to
4544 4543 override this protection.
4545 4544
4546 4545 The rollback command can be entirely disabled by setting the
4547 4546 ``ui.rollback`` configuration setting to false. If you're here
4548 4547 because you want to use rollback and it's disabled, you can
4549 4548 re-enable the command by setting ``ui.rollback`` to true.
4550 4549
4551 4550 This command is not intended for use on public repositories. Once
4552 4551 changes are visible for pull by other users, rolling a transaction
4553 4552 back locally is ineffective (someone else may already have pulled
4554 4553 the changes). Furthermore, a race is possible with readers of the
4555 4554 repository; for example an in-progress pull from the repository
4556 4555 may fail if a rollback is performed.
4557 4556
4558 4557 Returns 0 on success, 1 if no rollback data is available.
4559 4558 """
4560 4559 if not ui.configbool('ui', 'rollback', True):
4561 4560 raise error.Abort(_('rollback is disabled because it is unsafe'),
4562 4561 hint=('see `hg help -v rollback` for information'))
4563 4562 return repo.rollback(dryrun=opts.get('dry_run'),
4564 4563 force=opts.get('force'))
4565 4564
4566 4565 @command('root', [])
4567 4566 def root(ui, repo):
4568 4567 """print the root (top) of the current working directory
4569 4568
4570 4569 Print the root directory of the current repository.
4571 4570
4572 4571 Returns 0 on success.
4573 4572 """
4574 4573 ui.write(repo.root + "\n")
4575 4574
4576 4575 @command('^serve',
4577 4576 [('A', 'accesslog', '', _('name of access log file to write to'),
4578 4577 _('FILE')),
4579 4578 ('d', 'daemon', None, _('run server in background')),
4580 4579 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4581 4580 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4582 4581 # use string type, then we can check if something was passed
4583 4582 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4584 4583 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4585 4584 _('ADDR')),
4586 4585 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4587 4586 _('PREFIX')),
4588 4587 ('n', 'name', '',
4589 4588 _('name to show in web pages (default: working directory)'), _('NAME')),
4590 4589 ('', 'web-conf', '',
4591 4590 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4592 4591 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4593 4592 _('FILE')),
4594 4593 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4595 4594 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4596 4595 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4597 4596 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4598 4597 ('', 'style', '', _('template style to use'), _('STYLE')),
4599 4598 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4600 4599 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
4601 4600 _('[OPTION]...'),
4602 4601 optionalrepo=True)
4603 4602 def serve(ui, repo, **opts):
4604 4603 """start stand-alone webserver
4605 4604
4606 4605 Start a local HTTP repository browser and pull server. You can use
4607 4606 this for ad-hoc sharing and browsing of repositories. It is
4608 4607 recommended to use a real web server to serve a repository for
4609 4608 longer periods of time.
4610 4609
4611 4610 Please note that the server does not implement access control.
4612 4611 This means that, by default, anybody can read from the server and
4613 4612 nobody can write to it by default. Set the ``web.allow_push``
4614 4613 option to ``*`` to allow everybody to push to the server. You
4615 4614 should use a real web server if you need to authenticate users.
4616 4615
4617 4616 By default, the server logs accesses to stdout and errors to
4618 4617 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4619 4618 files.
4620 4619
4621 4620 To have the server choose a free port number to listen on, specify
4622 4621 a port number of 0; in this case, the server will print the port
4623 4622 number it uses.
4624 4623
4625 4624 Returns 0 on success.
4626 4625 """
4627 4626
4628 4627 if opts["stdio"] and opts["cmdserver"]:
4629 4628 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4630 4629
4631 4630 if opts["stdio"]:
4632 4631 if repo is None:
4633 4632 raise error.RepoError(_("there is no Mercurial repository here"
4634 4633 " (.hg not found)"))
4635 4634 s = sshserver.sshserver(ui, repo)
4636 4635 s.serve_forever()
4637 4636
4638 4637 service = server.createservice(ui, repo, opts)
4639 4638 return server.runservice(opts, initfn=service.init, runfn=service.run)
4640 4639
4641 4640 @command('^status|st',
4642 4641 [('A', 'all', None, _('show status of all files')),
4643 4642 ('m', 'modified', None, _('show only modified files')),
4644 4643 ('a', 'added', None, _('show only added files')),
4645 4644 ('r', 'removed', None, _('show only removed files')),
4646 4645 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4647 4646 ('c', 'clean', None, _('show only files without changes')),
4648 4647 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4649 4648 ('i', 'ignored', None, _('show only ignored files')),
4650 4649 ('n', 'no-status', None, _('hide status prefix')),
4651 4650 ('C', 'copies', None, _('show source of copied files')),
4652 4651 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4653 4652 ('', 'rev', [], _('show difference from revision'), _('REV')),
4654 4653 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4655 4654 ] + walkopts + subrepoopts + formatteropts,
4656 4655 _('[OPTION]... [FILE]...'),
4657 4656 inferrepo=True)
4658 4657 def status(ui, repo, *pats, **opts):
4659 4658 """show changed files in the working directory
4660 4659
4661 4660 Show status of files in the repository. If names are given, only
4662 4661 files that match are shown. Files that are clean or ignored or
4663 4662 the source of a copy/move operation, are not listed unless
4664 4663 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4665 4664 Unless options described with "show only ..." are given, the
4666 4665 options -mardu are used.
4667 4666
4668 4667 Option -q/--quiet hides untracked (unknown and ignored) files
4669 4668 unless explicitly requested with -u/--unknown or -i/--ignored.
4670 4669
4671 4670 .. note::
4672 4671
4673 4672 :hg:`status` may appear to disagree with diff if permissions have
4674 4673 changed or a merge has occurred. The standard diff format does
4675 4674 not report permission changes and diff only reports changes
4676 4675 relative to one merge parent.
4677 4676
4678 4677 If one revision is given, it is used as the base revision.
4679 4678 If two revisions are given, the differences between them are
4680 4679 shown. The --change option can also be used as a shortcut to list
4681 4680 the changed files of a revision from its first parent.
4682 4681
4683 4682 The codes used to show the status of files are::
4684 4683
4685 4684 M = modified
4686 4685 A = added
4687 4686 R = removed
4688 4687 C = clean
4689 4688 ! = missing (deleted by non-hg command, but still tracked)
4690 4689 ? = not tracked
4691 4690 I = ignored
4692 4691 = origin of the previous file (with --copies)
4693 4692
4694 4693 .. container:: verbose
4695 4694
4696 4695 Examples:
4697 4696
4698 4697 - show changes in the working directory relative to a
4699 4698 changeset::
4700 4699
4701 4700 hg status --rev 9353
4702 4701
4703 4702 - show changes in the working directory relative to the
4704 4703 current directory (see :hg:`help patterns` for more information)::
4705 4704
4706 4705 hg status re:
4707 4706
4708 4707 - show all changes including copies in an existing changeset::
4709 4708
4710 4709 hg status --copies --change 9353
4711 4710
4712 4711 - get a NUL separated list of added files, suitable for xargs::
4713 4712
4714 4713 hg status -an0
4715 4714
4716 4715 Returns 0 on success.
4717 4716 """
4718 4717
4719 4718 revs = opts.get('rev')
4720 4719 change = opts.get('change')
4721 4720
4722 4721 if revs and change:
4723 4722 msg = _('cannot specify --rev and --change at the same time')
4724 4723 raise error.Abort(msg)
4725 4724 elif change:
4726 4725 node2 = scmutil.revsingle(repo, change, None).node()
4727 4726 node1 = repo[node2].p1().node()
4728 4727 else:
4729 4728 node1, node2 = scmutil.revpair(repo, revs)
4730 4729
4731 4730 if pats:
4732 4731 cwd = repo.getcwd()
4733 4732 else:
4734 4733 cwd = ''
4735 4734
4736 4735 if opts.get('print0'):
4737 4736 end = '\0'
4738 4737 else:
4739 4738 end = '\n'
4740 4739 copy = {}
4741 4740 states = 'modified added removed deleted unknown ignored clean'.split()
4742 4741 show = [k for k in states if opts.get(k)]
4743 4742 if opts.get('all'):
4744 4743 show += ui.quiet and (states[:4] + ['clean']) or states
4745 4744 if not show:
4746 4745 if ui.quiet:
4747 4746 show = states[:4]
4748 4747 else:
4749 4748 show = states[:5]
4750 4749
4751 4750 m = scmutil.match(repo[node2], pats, opts)
4752 4751 stat = repo.status(node1, node2, m,
4753 4752 'ignored' in show, 'clean' in show, 'unknown' in show,
4754 4753 opts.get('subrepos'))
4755 4754 changestates = zip(states, 'MAR!?IC', stat)
4756 4755
4757 4756 if (opts.get('all') or opts.get('copies')
4758 4757 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4759 4758 copy = copies.pathcopies(repo[node1], repo[node2], m)
4760 4759
4761 4760 ui.pager('status')
4762 4761 fm = ui.formatter('status', opts)
4763 4762 fmt = '%s' + end
4764 4763 showchar = not opts.get('no_status')
4765 4764
4766 4765 for state, char, files in changestates:
4767 4766 if state in show:
4768 4767 label = 'status.' + state
4769 4768 for f in files:
4770 4769 fm.startitem()
4771 4770 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4772 4771 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4773 4772 if f in copy:
4774 4773 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4775 4774 label='status.copied')
4776 4775 fm.end()
4777 4776
4778 4777 @command('^summary|sum',
4779 4778 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
4780 4779 def summary(ui, repo, **opts):
4781 4780 """summarize working directory state
4782 4781
4783 4782 This generates a brief summary of the working directory state,
4784 4783 including parents, branch, commit status, phase and available updates.
4785 4784
4786 4785 With the --remote option, this will check the default paths for
4787 4786 incoming and outgoing changes. This can be time-consuming.
4788 4787
4789 4788 Returns 0 on success.
4790 4789 """
4791 4790
4792 4791 ui.pager('summary')
4793 4792 ctx = repo[None]
4794 4793 parents = ctx.parents()
4795 4794 pnode = parents[0].node()
4796 4795 marks = []
4797 4796
4798 4797 ms = None
4799 4798 try:
4800 4799 ms = mergemod.mergestate.read(repo)
4801 4800 except error.UnsupportedMergeRecords as e:
4802 4801 s = ' '.join(e.recordtypes)
4803 4802 ui.warn(
4804 4803 _('warning: merge state has unsupported record types: %s\n') % s)
4805 4804 unresolved = 0
4806 4805 else:
4807 4806 unresolved = [f for f in ms if ms[f] == 'u']
4808 4807
4809 4808 for p in parents:
4810 4809 # label with log.changeset (instead of log.parent) since this
4811 4810 # shows a working directory parent *changeset*:
4812 4811 # i18n: column positioning for "hg summary"
4813 4812 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
4814 4813 label=cmdutil._changesetlabels(p))
4815 4814 ui.write(' '.join(p.tags()), label='log.tag')
4816 4815 if p.bookmarks():
4817 4816 marks.extend(p.bookmarks())
4818 4817 if p.rev() == -1:
4819 4818 if not len(repo):
4820 4819 ui.write(_(' (empty repository)'))
4821 4820 else:
4822 4821 ui.write(_(' (no revision checked out)'))
4823 4822 if p.troubled():
4824 4823 ui.write(' ('
4825 4824 + ', '.join(ui.label(trouble, 'trouble.%s' % trouble)
4826 4825 for trouble in p.troubles())
4827 4826 + ')')
4828 4827 ui.write('\n')
4829 4828 if p.description():
4830 4829 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
4831 4830 label='log.summary')
4832 4831
4833 4832 branch = ctx.branch()
4834 4833 bheads = repo.branchheads(branch)
4835 4834 # i18n: column positioning for "hg summary"
4836 4835 m = _('branch: %s\n') % branch
4837 4836 if branch != 'default':
4838 4837 ui.write(m, label='log.branch')
4839 4838 else:
4840 4839 ui.status(m, label='log.branch')
4841 4840
4842 4841 if marks:
4843 4842 active = repo._activebookmark
4844 4843 # i18n: column positioning for "hg summary"
4845 4844 ui.write(_('bookmarks:'), label='log.bookmark')
4846 4845 if active is not None:
4847 4846 if active in marks:
4848 4847 ui.write(' *' + active, label=activebookmarklabel)
4849 4848 marks.remove(active)
4850 4849 else:
4851 4850 ui.write(' [%s]' % active, label=activebookmarklabel)
4852 4851 for m in marks:
4853 4852 ui.write(' ' + m, label='log.bookmark')
4854 4853 ui.write('\n', label='log.bookmark')
4855 4854
4856 4855 status = repo.status(unknown=True)
4857 4856
4858 4857 c = repo.dirstate.copies()
4859 4858 copied, renamed = [], []
4860 4859 for d, s in c.iteritems():
4861 4860 if s in status.removed:
4862 4861 status.removed.remove(s)
4863 4862 renamed.append(d)
4864 4863 else:
4865 4864 copied.append(d)
4866 4865 if d in status.added:
4867 4866 status.added.remove(d)
4868 4867
4869 4868 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
4870 4869
4871 4870 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
4872 4871 (ui.label(_('%d added'), 'status.added'), status.added),
4873 4872 (ui.label(_('%d removed'), 'status.removed'), status.removed),
4874 4873 (ui.label(_('%d renamed'), 'status.copied'), renamed),
4875 4874 (ui.label(_('%d copied'), 'status.copied'), copied),
4876 4875 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
4877 4876 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
4878 4877 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
4879 4878 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
4880 4879 t = []
4881 4880 for l, s in labels:
4882 4881 if s:
4883 4882 t.append(l % len(s))
4884 4883
4885 4884 t = ', '.join(t)
4886 4885 cleanworkdir = False
4887 4886
4888 4887 if repo.vfs.exists('graftstate'):
4889 4888 t += _(' (graft in progress)')
4890 4889 if repo.vfs.exists('updatestate'):
4891 4890 t += _(' (interrupted update)')
4892 4891 elif len(parents) > 1:
4893 4892 t += _(' (merge)')
4894 4893 elif branch != parents[0].branch():
4895 4894 t += _(' (new branch)')
4896 4895 elif (parents[0].closesbranch() and
4897 4896 pnode in repo.branchheads(branch, closed=True)):
4898 4897 t += _(' (head closed)')
4899 4898 elif not (status.modified or status.added or status.removed or renamed or
4900 4899 copied or subs):
4901 4900 t += _(' (clean)')
4902 4901 cleanworkdir = True
4903 4902 elif pnode not in bheads:
4904 4903 t += _(' (new branch head)')
4905 4904
4906 4905 if parents:
4907 4906 pendingphase = max(p.phase() for p in parents)
4908 4907 else:
4909 4908 pendingphase = phases.public
4910 4909
4911 4910 if pendingphase > phases.newcommitphase(ui):
4912 4911 t += ' (%s)' % phases.phasenames[pendingphase]
4913 4912
4914 4913 if cleanworkdir:
4915 4914 # i18n: column positioning for "hg summary"
4916 4915 ui.status(_('commit: %s\n') % t.strip())
4917 4916 else:
4918 4917 # i18n: column positioning for "hg summary"
4919 4918 ui.write(_('commit: %s\n') % t.strip())
4920 4919
4921 4920 # all ancestors of branch heads - all ancestors of parent = new csets
4922 4921 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
4923 4922 bheads))
4924 4923
4925 4924 if new == 0:
4926 4925 # i18n: column positioning for "hg summary"
4927 4926 ui.status(_('update: (current)\n'))
4928 4927 elif pnode not in bheads:
4929 4928 # i18n: column positioning for "hg summary"
4930 4929 ui.write(_('update: %d new changesets (update)\n') % new)
4931 4930 else:
4932 4931 # i18n: column positioning for "hg summary"
4933 4932 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
4934 4933 (new, len(bheads)))
4935 4934
4936 4935 t = []
4937 4936 draft = len(repo.revs('draft()'))
4938 4937 if draft:
4939 4938 t.append(_('%d draft') % draft)
4940 4939 secret = len(repo.revs('secret()'))
4941 4940 if secret:
4942 4941 t.append(_('%d secret') % secret)
4943 4942
4944 4943 if draft or secret:
4945 4944 ui.status(_('phases: %s\n') % ', '.join(t))
4946 4945
4947 4946 if obsolete.isenabled(repo, obsolete.createmarkersopt):
4948 4947 for trouble in ("unstable", "divergent", "bumped"):
4949 4948 numtrouble = len(repo.revs(trouble + "()"))
4950 4949 # We write all the possibilities to ease translation
4951 4950 troublemsg = {
4952 4951 "unstable": _("unstable: %d changesets"),
4953 4952 "divergent": _("divergent: %d changesets"),
4954 4953 "bumped": _("bumped: %d changesets"),
4955 4954 }
4956 4955 if numtrouble > 0:
4957 4956 ui.status(troublemsg[trouble] % numtrouble + "\n")
4958 4957
4959 4958 cmdutil.summaryhooks(ui, repo)
4960 4959
4961 4960 if opts.get('remote'):
4962 4961 needsincoming, needsoutgoing = True, True
4963 4962 else:
4964 4963 needsincoming, needsoutgoing = False, False
4965 4964 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
4966 4965 if i:
4967 4966 needsincoming = True
4968 4967 if o:
4969 4968 needsoutgoing = True
4970 4969 if not needsincoming and not needsoutgoing:
4971 4970 return
4972 4971
4973 4972 def getincoming():
4974 4973 source, branches = hg.parseurl(ui.expandpath('default'))
4975 4974 sbranch = branches[0]
4976 4975 try:
4977 4976 other = hg.peer(repo, {}, source)
4978 4977 except error.RepoError:
4979 4978 if opts.get('remote'):
4980 4979 raise
4981 4980 return source, sbranch, None, None, None
4982 4981 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
4983 4982 if revs:
4984 4983 revs = [other.lookup(rev) for rev in revs]
4985 4984 ui.debug('comparing with %s\n' % util.hidepassword(source))
4986 4985 repo.ui.pushbuffer()
4987 4986 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
4988 4987 repo.ui.popbuffer()
4989 4988 return source, sbranch, other, commoninc, commoninc[1]
4990 4989
4991 4990 if needsincoming:
4992 4991 source, sbranch, sother, commoninc, incoming = getincoming()
4993 4992 else:
4994 4993 source = sbranch = sother = commoninc = incoming = None
4995 4994
4996 4995 def getoutgoing():
4997 4996 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
4998 4997 dbranch = branches[0]
4999 4998 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5000 4999 if source != dest:
5001 5000 try:
5002 5001 dother = hg.peer(repo, {}, dest)
5003 5002 except error.RepoError:
5004 5003 if opts.get('remote'):
5005 5004 raise
5006 5005 return dest, dbranch, None, None
5007 5006 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5008 5007 elif sother is None:
5009 5008 # there is no explicit destination peer, but source one is invalid
5010 5009 return dest, dbranch, None, None
5011 5010 else:
5012 5011 dother = sother
5013 5012 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5014 5013 common = None
5015 5014 else:
5016 5015 common = commoninc
5017 5016 if revs:
5018 5017 revs = [repo.lookup(rev) for rev in revs]
5019 5018 repo.ui.pushbuffer()
5020 5019 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5021 5020 commoninc=common)
5022 5021 repo.ui.popbuffer()
5023 5022 return dest, dbranch, dother, outgoing
5024 5023
5025 5024 if needsoutgoing:
5026 5025 dest, dbranch, dother, outgoing = getoutgoing()
5027 5026 else:
5028 5027 dest = dbranch = dother = outgoing = None
5029 5028
5030 5029 if opts.get('remote'):
5031 5030 t = []
5032 5031 if incoming:
5033 5032 t.append(_('1 or more incoming'))
5034 5033 o = outgoing.missing
5035 5034 if o:
5036 5035 t.append(_('%d outgoing') % len(o))
5037 5036 other = dother or sother
5038 5037 if 'bookmarks' in other.listkeys('namespaces'):
5039 5038 counts = bookmarks.summary(repo, other)
5040 5039 if counts[0] > 0:
5041 5040 t.append(_('%d incoming bookmarks') % counts[0])
5042 5041 if counts[1] > 0:
5043 5042 t.append(_('%d outgoing bookmarks') % counts[1])
5044 5043
5045 5044 if t:
5046 5045 # i18n: column positioning for "hg summary"
5047 5046 ui.write(_('remote: %s\n') % (', '.join(t)))
5048 5047 else:
5049 5048 # i18n: column positioning for "hg summary"
5050 5049 ui.status(_('remote: (synced)\n'))
5051 5050
5052 5051 cmdutil.summaryremotehooks(ui, repo, opts,
5053 5052 ((source, sbranch, sother, commoninc),
5054 5053 (dest, dbranch, dother, outgoing)))
5055 5054
5056 5055 @command('tag',
5057 5056 [('f', 'force', None, _('force tag')),
5058 5057 ('l', 'local', None, _('make the tag local')),
5059 5058 ('r', 'rev', '', _('revision to tag'), _('REV')),
5060 5059 ('', 'remove', None, _('remove a tag')),
5061 5060 # -l/--local is already there, commitopts cannot be used
5062 5061 ('e', 'edit', None, _('invoke editor on commit messages')),
5063 5062 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5064 5063 ] + commitopts2,
5065 5064 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5066 5065 def tag(ui, repo, name1, *names, **opts):
5067 5066 """add one or more tags for the current or given revision
5068 5067
5069 5068 Name a particular revision using <name>.
5070 5069
5071 5070 Tags are used to name particular revisions of the repository and are
5072 5071 very useful to compare different revisions, to go back to significant
5073 5072 earlier versions or to mark branch points as releases, etc. Changing
5074 5073 an existing tag is normally disallowed; use -f/--force to override.
5075 5074
5076 5075 If no revision is given, the parent of the working directory is
5077 5076 used.
5078 5077
5079 5078 To facilitate version control, distribution, and merging of tags,
5080 5079 they are stored as a file named ".hgtags" which is managed similarly
5081 5080 to other project files and can be hand-edited if necessary. This
5082 5081 also means that tagging creates a new commit. The file
5083 5082 ".hg/localtags" is used for local tags (not shared among
5084 5083 repositories).
5085 5084
5086 5085 Tag commits are usually made at the head of a branch. If the parent
5087 5086 of the working directory is not a branch head, :hg:`tag` aborts; use
5088 5087 -f/--force to force the tag commit to be based on a non-head
5089 5088 changeset.
5090 5089
5091 5090 See :hg:`help dates` for a list of formats valid for -d/--date.
5092 5091
5093 5092 Since tag names have priority over branch names during revision
5094 5093 lookup, using an existing branch name as a tag name is discouraged.
5095 5094
5096 5095 Returns 0 on success.
5097 5096 """
5098 5097 wlock = lock = None
5099 5098 try:
5100 5099 wlock = repo.wlock()
5101 5100 lock = repo.lock()
5102 5101 rev_ = "."
5103 5102 names = [t.strip() for t in (name1,) + names]
5104 5103 if len(names) != len(set(names)):
5105 5104 raise error.Abort(_('tag names must be unique'))
5106 5105 for n in names:
5107 5106 scmutil.checknewlabel(repo, n, 'tag')
5108 5107 if not n:
5109 5108 raise error.Abort(_('tag names cannot consist entirely of '
5110 5109 'whitespace'))
5111 5110 if opts.get('rev') and opts.get('remove'):
5112 5111 raise error.Abort(_("--rev and --remove are incompatible"))
5113 5112 if opts.get('rev'):
5114 5113 rev_ = opts['rev']
5115 5114 message = opts.get('message')
5116 5115 if opts.get('remove'):
5117 5116 if opts.get('local'):
5118 5117 expectedtype = 'local'
5119 5118 else:
5120 5119 expectedtype = 'global'
5121 5120
5122 5121 for n in names:
5123 5122 if not repo.tagtype(n):
5124 5123 raise error.Abort(_("tag '%s' does not exist") % n)
5125 5124 if repo.tagtype(n) != expectedtype:
5126 5125 if expectedtype == 'global':
5127 5126 raise error.Abort(_("tag '%s' is not a global tag") % n)
5128 5127 else:
5129 5128 raise error.Abort(_("tag '%s' is not a local tag") % n)
5130 5129 rev_ = 'null'
5131 5130 if not message:
5132 5131 # we don't translate commit messages
5133 5132 message = 'Removed tag %s' % ', '.join(names)
5134 5133 elif not opts.get('force'):
5135 5134 for n in names:
5136 5135 if n in repo.tags():
5137 5136 raise error.Abort(_("tag '%s' already exists "
5138 5137 "(use -f to force)") % n)
5139 5138 if not opts.get('local'):
5140 5139 p1, p2 = repo.dirstate.parents()
5141 5140 if p2 != nullid:
5142 5141 raise error.Abort(_('uncommitted merge'))
5143 5142 bheads = repo.branchheads()
5144 5143 if not opts.get('force') and bheads and p1 not in bheads:
5145 5144 raise error.Abort(_('working directory is not at a branch head '
5146 5145 '(use -f to force)'))
5147 5146 r = scmutil.revsingle(repo, rev_).node()
5148 5147
5149 5148 if not message:
5150 5149 # we don't translate commit messages
5151 5150 message = ('Added tag %s for changeset %s' %
5152 5151 (', '.join(names), short(r)))
5153 5152
5154 5153 date = opts.get('date')
5155 5154 if date:
5156 5155 date = util.parsedate(date)
5157 5156
5158 5157 if opts.get('remove'):
5159 5158 editform = 'tag.remove'
5160 5159 else:
5161 5160 editform = 'tag.add'
5162 5161 editor = cmdutil.getcommiteditor(editform=editform, **opts)
5163 5162
5164 5163 # don't allow tagging the null rev
5165 5164 if (not opts.get('remove') and
5166 5165 scmutil.revsingle(repo, rev_).rev() == nullrev):
5167 5166 raise error.Abort(_("cannot tag null revision"))
5168 5167
5169 5168 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
5170 5169 editor=editor)
5171 5170 finally:
5172 5171 release(lock, wlock)
5173 5172
5174 5173 @command('tags', formatteropts, '')
5175 5174 def tags(ui, repo, **opts):
5176 5175 """list repository tags
5177 5176
5178 5177 This lists both regular and local tags. When the -v/--verbose
5179 5178 switch is used, a third column "local" is printed for local tags.
5180 5179 When the -q/--quiet switch is used, only the tag name is printed.
5181 5180
5182 5181 Returns 0 on success.
5183 5182 """
5184 5183
5185 5184 ui.pager('tags')
5186 5185 fm = ui.formatter('tags', opts)
5187 5186 hexfunc = fm.hexfunc
5188 5187 tagtype = ""
5189 5188
5190 5189 for t, n in reversed(repo.tagslist()):
5191 5190 hn = hexfunc(n)
5192 5191 label = 'tags.normal'
5193 5192 tagtype = ''
5194 5193 if repo.tagtype(t) == 'local':
5195 5194 label = 'tags.local'
5196 5195 tagtype = 'local'
5197 5196
5198 5197 fm.startitem()
5199 5198 fm.write('tag', '%s', t, label=label)
5200 5199 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5201 5200 fm.condwrite(not ui.quiet, 'rev node', fmt,
5202 5201 repo.changelog.rev(n), hn, label=label)
5203 5202 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5204 5203 tagtype, label=label)
5205 5204 fm.plain('\n')
5206 5205 fm.end()
5207 5206
5208 5207 @command('tip',
5209 5208 [('p', 'patch', None, _('show patch')),
5210 5209 ('g', 'git', None, _('use git extended diff format')),
5211 5210 ] + templateopts,
5212 5211 _('[-p] [-g]'))
5213 5212 def tip(ui, repo, **opts):
5214 5213 """show the tip revision (DEPRECATED)
5215 5214
5216 5215 The tip revision (usually just called the tip) is the changeset
5217 5216 most recently added to the repository (and therefore the most
5218 5217 recently changed head).
5219 5218
5220 5219 If you have just made a commit, that commit will be the tip. If
5221 5220 you have just pulled changes from another repository, the tip of
5222 5221 that repository becomes the current tip. The "tip" tag is special
5223 5222 and cannot be renamed or assigned to a different changeset.
5224 5223
5225 5224 This command is deprecated, please use :hg:`heads` instead.
5226 5225
5227 5226 Returns 0 on success.
5228 5227 """
5229 5228 displayer = cmdutil.show_changeset(ui, repo, opts)
5230 5229 displayer.show(repo['tip'])
5231 5230 displayer.close()
5232 5231
5233 5232 @command('unbundle',
5234 5233 [('u', 'update', None,
5235 5234 _('update to new branch head if changesets were unbundled'))],
5236 5235 _('[-u] FILE...'))
5237 5236 def unbundle(ui, repo, fname1, *fnames, **opts):
5238 5237 """apply one or more changegroup files
5239 5238
5240 5239 Apply one or more compressed changegroup files generated by the
5241 5240 bundle command.
5242 5241
5243 5242 Returns 0 on success, 1 if an update has unresolved files.
5244 5243 """
5245 5244 fnames = (fname1,) + fnames
5246 5245
5247 5246 with repo.lock():
5248 5247 for fname in fnames:
5249 5248 f = hg.openpath(ui, fname)
5250 5249 gen = exchange.readbundle(ui, f, fname)
5251 5250 if isinstance(gen, bundle2.unbundle20):
5252 5251 tr = repo.transaction('unbundle')
5253 5252 try:
5254 5253 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5255 5254 url='bundle:' + fname)
5256 5255 tr.close()
5257 5256 except error.BundleUnknownFeatureError as exc:
5258 5257 raise error.Abort(_('%s: unknown bundle feature, %s')
5259 5258 % (fname, exc),
5260 5259 hint=_("see https://mercurial-scm.org/"
5261 5260 "wiki/BundleFeature for more "
5262 5261 "information"))
5263 5262 finally:
5264 5263 if tr:
5265 5264 tr.release()
5266 5265 changes = [r.get('return', 0)
5267 5266 for r in op.records['changegroup']]
5268 5267 modheads = changegroup.combineresults(changes)
5269 5268 elif isinstance(gen, streamclone.streamcloneapplier):
5270 5269 raise error.Abort(
5271 5270 _('packed bundles cannot be applied with '
5272 5271 '"hg unbundle"'),
5273 5272 hint=_('use "hg debugapplystreamclonebundle"'))
5274 5273 else:
5275 5274 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
5276 5275
5277 5276 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
5278 5277
5279 5278 @command('^update|up|checkout|co',
5280 5279 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5281 5280 ('c', 'check', None, _('require clean working directory')),
5282 5281 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5283 5282 ('r', 'rev', '', _('revision'), _('REV'))
5284 5283 ] + mergetoolopts,
5285 5284 _('[-C|-c] [-d DATE] [[-r] REV]'))
5286 5285 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
5287 5286 tool=None):
5288 5287 """update working directory (or switch revisions)
5289 5288
5290 5289 Update the repository's working directory to the specified
5291 5290 changeset. If no changeset is specified, update to the tip of the
5292 5291 current named branch and move the active bookmark (see :hg:`help
5293 5292 bookmarks`).
5294 5293
5295 5294 Update sets the working directory's parent revision to the specified
5296 5295 changeset (see :hg:`help parents`).
5297 5296
5298 5297 If the changeset is not a descendant or ancestor of the working
5299 5298 directory's parent and there are uncommitted changes, the update is
5300 5299 aborted. With the -c/--check option, the working directory is checked
5301 5300 for uncommitted changes; if none are found, the working directory is
5302 5301 updated to the specified changeset.
5303 5302
5304 5303 .. container:: verbose
5305 5304
5306 5305 The -C/--clean and -c/--check options control what happens if the
5307 5306 working directory contains uncommitted changes.
5308 5307 At most of one of them can be specified.
5309 5308
5310 5309 1. If no option is specified, and if
5311 5310 the requested changeset is an ancestor or descendant of
5312 5311 the working directory's parent, the uncommitted changes
5313 5312 are merged into the requested changeset and the merged
5314 5313 result is left uncommitted. If the requested changeset is
5315 5314 not an ancestor or descendant (that is, it is on another
5316 5315 branch), the update is aborted and the uncommitted changes
5317 5316 are preserved.
5318 5317
5319 5318 2. With the -c/--check option, the update is aborted and the
5320 5319 uncommitted changes are preserved.
5321 5320
5322 5321 3. With the -C/--clean option, uncommitted changes are discarded and
5323 5322 the working directory is updated to the requested changeset.
5324 5323
5325 5324 To cancel an uncommitted merge (and lose your changes), use
5326 5325 :hg:`update --clean .`.
5327 5326
5328 5327 Use null as the changeset to remove the working directory (like
5329 5328 :hg:`clone -U`).
5330 5329
5331 5330 If you want to revert just one file to an older revision, use
5332 5331 :hg:`revert [-r REV] NAME`.
5333 5332
5334 5333 See :hg:`help dates` for a list of formats valid for -d/--date.
5335 5334
5336 5335 Returns 0 on success, 1 if there are unresolved files.
5337 5336 """
5338 5337 if rev and node:
5339 5338 raise error.Abort(_("please specify just one revision"))
5340 5339
5341 5340 if rev is None or rev == '':
5342 5341 rev = node
5343 5342
5344 5343 if date and rev is not None:
5345 5344 raise error.Abort(_("you can't specify a revision and a date"))
5346 5345
5347 5346 if check and clean:
5348 5347 raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
5349 5348
5350 5349 with repo.wlock():
5351 5350 cmdutil.clearunfinished(repo)
5352 5351
5353 5352 if date:
5354 5353 rev = cmdutil.finddate(ui, repo, date)
5355 5354
5356 5355 # if we defined a bookmark, we have to remember the original name
5357 5356 brev = rev
5358 5357 rev = scmutil.revsingle(repo, rev, rev).rev()
5359 5358
5360 5359 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
5361 5360
5362 5361 return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check)
5363 5362
5364 5363 @command('verify', [])
5365 5364 def verify(ui, repo):
5366 5365 """verify the integrity of the repository
5367 5366
5368 5367 Verify the integrity of the current repository.
5369 5368
5370 5369 This will perform an extensive check of the repository's
5371 5370 integrity, validating the hashes and checksums of each entry in
5372 5371 the changelog, manifest, and tracked files, as well as the
5373 5372 integrity of their crosslinks and indices.
5374 5373
5375 5374 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5376 5375 for more information about recovery from corruption of the
5377 5376 repository.
5378 5377
5379 5378 Returns 0 on success, 1 if errors are encountered.
5380 5379 """
5381 5380 return hg.verify(repo)
5382 5381
5383 5382 @command('version', [] + formatteropts, norepo=True)
5384 5383 def version_(ui, **opts):
5385 5384 """output version and copyright information"""
5386 5385 if ui.verbose:
5387 5386 ui.pager('version')
5388 5387 fm = ui.formatter("version", opts)
5389 5388 fm.startitem()
5390 5389 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5391 5390 util.version())
5392 5391 license = _(
5393 5392 "(see https://mercurial-scm.org for more information)\n"
5394 5393 "\nCopyright (C) 2005-2017 Matt Mackall and others\n"
5395 5394 "This is free software; see the source for copying conditions. "
5396 5395 "There is NO\nwarranty; "
5397 5396 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5398 5397 )
5399 5398 if not ui.quiet:
5400 5399 fm.plain(license)
5401 5400
5402 5401 if ui.verbose:
5403 5402 fm.plain(_("\nEnabled extensions:\n\n"))
5404 5403 # format names and versions into columns
5405 5404 names = []
5406 5405 vers = []
5407 5406 isinternals = []
5408 5407 for name, module in extensions.extensions():
5409 5408 names.append(name)
5410 5409 vers.append(extensions.moduleversion(module) or None)
5411 5410 isinternals.append(extensions.ismoduleinternal(module))
5412 5411 fn = fm.nested("extensions")
5413 5412 if names:
5414 5413 namefmt = " %%-%ds " % max(len(n) for n in names)
5415 5414 places = [_("external"), _("internal")]
5416 5415 for n, v, p in zip(names, vers, isinternals):
5417 5416 fn.startitem()
5418 5417 fn.condwrite(ui.verbose, "name", namefmt, n)
5419 5418 if ui.verbose:
5420 5419 fn.plain("%s " % places[p])
5421 5420 fn.data(bundled=p)
5422 5421 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5423 5422 if ui.verbose:
5424 5423 fn.plain("\n")
5425 5424 fn.end()
5426 5425 fm.end()
5427 5426
5428 5427 def loadcmdtable(ui, name, cmdtable):
5429 5428 """Load command functions from specified cmdtable
5430 5429 """
5431 5430 overrides = [cmd for cmd in cmdtable if cmd in table]
5432 5431 if overrides:
5433 5432 ui.warn(_("extension '%s' overrides commands: %s\n")
5434 5433 % (name, " ".join(overrides)))
5435 5434 table.update(cmdtable)
@@ -1,186 +1,134 b''
1 # color.py color output for Mercurial commands
2 #
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
4 #
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.
1 Mercurial can colorizes output from several commands.
7 2
8 '''colorize output from some commands
9
10 The color extension colorizes output from several Mercurial commands.
11 3 For example, the diff command shows additions in green and deletions
12 4 in red, while the status command shows modified files in magenta. Many
13 5 other commands have analogous colors. It is possible to customize
14 6 these colors.
15 7
8 To enable color use::
9
10 [ui]
11 color = auto
12
13 Mode
14 ====
15
16 Mercurial can use various system to display color. The supported modes are
17 ``ansi``, ``win32``, and ``terminfo``. See :hg:`help config.color` for details
18 about how to control the mode
19
16 20 Effects
17 -------
21 =======
18 22
19 23 Other effects in addition to color, like bold and underlined text, are
20 24 also available. By default, the terminfo database is used to find the
21 25 terminal codes used to change color and effect. If terminfo is not
22 26 available, then effects are rendered with the ECMA-48 SGR control
23 27 function (aka ANSI escape codes).
24 28
25 29 The available effects in terminfo mode are 'blink', 'bold', 'dim',
26 30 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
27 31 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
28 32 'underline'. How each is rendered depends on the terminal emulator.
29 33 Some may not be available for a given terminal type, and will be
30 34 silently ignored.
31 35
32 36 If the terminfo entry for your terminal is missing codes for an effect
33 37 or has the wrong codes, you can add or override those codes in your
34 38 configuration::
35 39
36 40 [color]
37 41 terminfo.dim = \E[2m
38 42
39 43 where '\E' is substituted with an escape character.
40 44
41 45 Labels
42 ------
46 ======
43 47
44 48 Text receives color effects depending on the labels that it has. Many
45 49 default Mercurial commands emit labelled text. You can also define
46 50 your own labels in templates using the label function, see :hg:`help
47 51 templates`. A single portion of text may have more than one label. In
48 52 that case, effects given to the last label will override any other
49 53 effects. This includes the special "none" effect, which nullifies
50 54 other effects.
51 55
52 56 Labels are normally invisible. In order to see these labels and their
53 57 position in the text, use the global --color=debug option. The same
54 58 anchor text may be associated to multiple labels, e.g.
55 59
56 60 [log.changeset changeset.secret|changeset: 22611:6f0a53c8f587]
57 61
58 62 The following are the default effects for some default labels. Default
59 63 effects may be overridden from your configuration file::
60 64
61 65 [color]
62 66 status.modified = blue bold underline red_background
63 67 status.added = green bold
64 68 status.removed = red bold blue_background
65 69 status.deleted = cyan bold underline
66 70 status.unknown = magenta bold underline
67 71 status.ignored = black bold
68 72
69 73 # 'none' turns off all effects
70 74 status.clean = none
71 75 status.copied = none
72 76
73 77 qseries.applied = blue bold underline
74 78 qseries.unapplied = black bold
75 79 qseries.missing = red bold
76 80
77 81 diff.diffline = bold
78 82 diff.extended = cyan bold
79 83 diff.file_a = red bold
80 84 diff.file_b = green bold
81 85 diff.hunk = magenta
82 86 diff.deleted = red
83 87 diff.inserted = green
84 88 diff.changed = white
85 89 diff.tab =
86 90 diff.trailingwhitespace = bold red_background
87 91
88 92 # Blank so it inherits the style of the surrounding label
89 93 changeset.public =
90 94 changeset.draft =
91 95 changeset.secret =
92 96
93 97 resolve.unresolved = red bold
94 98 resolve.resolved = green bold
95 99
96 100 bookmarks.active = green
97 101
98 102 branches.active = none
99 103 branches.closed = black bold
100 104 branches.current = green
101 105 branches.inactive = none
102 106
103 107 tags.normal = green
104 108 tags.local = black bold
105 109
106 110 rebase.rebased = blue
107 111 rebase.remaining = red bold
108 112
109 113 shelve.age = cyan
110 114 shelve.newest = green bold
111 115 shelve.name = blue bold
112 116
113 117 histedit.remaining = red bold
114 118
115 119 Custom colors
116 -------------
120 =============
117 121
118 122 Because there are only eight standard colors, this module allows you
119 123 to define color names for other color slots which might be available
120 124 for your terminal type, assuming terminfo mode. For instance::
121 125
122 126 color.brightblue = 12
123 127 color.pink = 207
124 128 color.orange = 202
125 129
126 130 to set 'brightblue' to color slot 12 (useful for 16 color terminals
127 131 that have brighter colors defined in the upper eight) and, 'pink' and
128 132 'orange' to colors in 256-color xterm's default color cube. These
129 133 defined colors may then be used as any of the pre-defined eight,
130 134 including appending '_background' to set the background to that color.
131
132 Modes
133 -----
134
135 By default, the color extension will use ANSI mode (or win32 mode on
136 Windows) if it detects a terminal. To override auto mode (to enable
137 terminfo mode, for example), set the following configuration option::
138
139 [color]
140 mode = terminfo
141
142 Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
143 disable color.
144
145 Note that on some systems, terminfo mode may cause problems when using
146 color with the pager extension and less -R. less with the -R option
147 will only display ECMA-48 color codes, and terminfo mode may sometimes
148 emit codes that less doesn't understand. You can work around this by
149 either using ansi mode (or auto mode), or by using less -r (which will
150 pass through all terminal control codes, not just color control
151 codes).
152
153 On some systems (such as MSYS in Windows), the terminal may support
154 a different color mode than the pager (activated via the "pager"
155 extension). It is possible to define separate modes depending on whether
156 the pager is active::
157
158 [color]
159 mode = auto
160 pagermode = ansi
161
162 If ``pagermode`` is not defined, the ``mode`` will be used.
163 '''
164
165 from __future__ import absolute_import
166
167 from mercurial import (
168 color,
169 commands
170 )
171
172 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
173 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
174 # be specifying the version(s) of Mercurial they are tested with, or
175 # leave the attribute unspecified.
176 testedwith = 'ships-with-hg-core'
177
178 def extsetup(ui):
179 # change default color config
180 color._enabledbydefault = True
181 for idx, entry in enumerate(commands.globalopts):
182 if entry[1] == 'color':
183 patch = (entry[3].replace(' (EXPERIMENTAL)', ''),)
184 new = entry[:3] + patch + entry[4:]
185 commands.globalopts[idx] = new
186 break
@@ -1,2318 +1,2352 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself:
34 34
35 35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36 36
37 37 Global configuration like the username setting is typically put into:
38 38
39 39 .. container:: windows
40 40
41 41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 42
43 43 .. container:: unix.plan9
44 44
45 45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46 46
47 47 The names of these files depend on the system on which Mercurial is
48 48 installed. ``*.rc`` files from a single directory are read in
49 49 alphabetical order, later ones overriding earlier ones. Where multiple
50 50 paths are given below, settings from earlier paths override later
51 51 ones.
52 52
53 53 .. container:: verbose.unix
54 54
55 55 On Unix, the following files are consulted:
56 56
57 57 - ``<repo>/.hg/hgrc`` (per-repository)
58 58 - ``$HOME/.hgrc`` (per-user)
59 59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 62 - ``/etc/mercurial/hgrc`` (per-system)
63 63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 64 - ``<internal>/default.d/*.rc`` (defaults)
65 65
66 66 .. container:: verbose.windows
67 67
68 68 On Windows, the following files are consulted:
69 69
70 70 - ``<repo>/.hg/hgrc`` (per-repository)
71 71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 73 - ``%HOME%\.hgrc`` (per-user)
74 74 - ``%HOME%\Mercurial.ini`` (per-user)
75 75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 78 - ``<internal>/default.d/*.rc`` (defaults)
79 79
80 80 .. note::
81 81
82 82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 83 is used when running 32-bit Python on 64-bit Windows.
84 84
85 85 .. container:: windows
86 86
87 87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88 88
89 89 .. container:: verbose.plan9
90 90
91 91 On Plan9, the following files are consulted:
92 92
93 93 - ``<repo>/.hg/hgrc`` (per-repository)
94 94 - ``$home/lib/hgrc`` (per-user)
95 95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 97 - ``/lib/mercurial/hgrc`` (per-system)
98 98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 99 - ``<internal>/default.d/*.rc`` (defaults)
100 100
101 101 Per-repository configuration options only apply in a
102 102 particular repository. This file is not version-controlled, and
103 103 will not get transferred during a "clone" operation. Options in
104 104 this file override options in all other configuration files.
105 105
106 106 .. container:: unix.plan9
107 107
108 108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 109 belong to a trusted user or to a trusted group. See
110 110 :hg:`help config.trusted` for more details.
111 111
112 112 Per-user configuration file(s) are for the user running Mercurial. Options
113 113 in these files apply to all Mercurial commands executed by this user in any
114 114 directory. Options in these files override per-system and per-installation
115 115 options.
116 116
117 117 Per-installation configuration files are searched for in the
118 118 directory where Mercurial is installed. ``<install-root>`` is the
119 119 parent directory of the **hg** executable (or symlink) being run.
120 120
121 121 .. container:: unix.plan9
122 122
123 123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 125 files apply to all Mercurial commands executed by any user in any
126 126 directory.
127 127
128 128 Per-installation configuration files are for the system on
129 129 which Mercurial is running. Options in these files apply to all
130 130 Mercurial commands executed by any user in any directory. Registry
131 131 keys contain PATH-like strings, every part of which must reference
132 132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 133 be read. Mercurial checks each of these locations in the specified
134 134 order until one or more configuration files are detected.
135 135
136 136 Per-system configuration files are for the system on which Mercurial
137 137 is running. Options in these files apply to all Mercurial commands
138 138 executed by any user in any directory. Options in these files
139 139 override per-installation options.
140 140
141 141 Mercurial comes with some default configuration. The default configuration
142 142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 143 configuration files should never be edited by users or administrators but can
144 144 be overridden in other configuration files. So far the directory only contains
145 145 merge tool configuration but packagers can also put other default configuration
146 146 there.
147 147
148 148 Syntax
149 149 ======
150 150
151 151 A configuration file consists of sections, led by a ``[section]`` header
152 152 and followed by ``name = value`` entries (sometimes called
153 153 ``configuration keys``)::
154 154
155 155 [spam]
156 156 eggs=ham
157 157 green=
158 158 eggs
159 159
160 160 Each line contains one entry. If the lines that follow are indented,
161 161 they are treated as continuations of that entry. Leading whitespace is
162 162 removed from values. Empty lines are skipped. Lines beginning with
163 163 ``#`` or ``;`` are ignored and may be used to provide comments.
164 164
165 165 Configuration keys can be set multiple times, in which case Mercurial
166 166 will use the value that was configured last. As an example::
167 167
168 168 [spam]
169 169 eggs=large
170 170 ham=serrano
171 171 eggs=small
172 172
173 173 This would set the configuration key named ``eggs`` to ``small``.
174 174
175 175 It is also possible to define a section multiple times. A section can
176 176 be redefined on the same and/or on different configuration files. For
177 177 example::
178 178
179 179 [foo]
180 180 eggs=large
181 181 ham=serrano
182 182 eggs=small
183 183
184 184 [bar]
185 185 eggs=ham
186 186 green=
187 187 eggs
188 188
189 189 [foo]
190 190 ham=prosciutto
191 191 eggs=medium
192 192 bread=toasted
193 193
194 194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 196 respectively. As you can see there only thing that matters is the last
197 197 value that was set for each of the configuration keys.
198 198
199 199 If a configuration key is set multiple times in different
200 200 configuration files the final value will depend on the order in which
201 201 the different configuration files are read, with settings from earlier
202 202 paths overriding later ones as described on the ``Files`` section
203 203 above.
204 204
205 205 A line of the form ``%include file`` will include ``file`` into the
206 206 current configuration file. The inclusion is recursive, which means
207 207 that included files can include other files. Filenames are relative to
208 208 the configuration file in which the ``%include`` directive is found.
209 209 Environment variables and ``~user`` constructs are expanded in
210 210 ``file``. This lets you do something like::
211 211
212 212 %include ~/.hgrc.d/$HOST.rc
213 213
214 214 to include a different configuration file on each computer you use.
215 215
216 216 A line with ``%unset name`` will remove ``name`` from the current
217 217 section, if it has been set previously.
218 218
219 219 The values are either free-form text strings, lists of text strings,
220 220 or Boolean values. Boolean values can be set to true using any of "1",
221 221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 222 (all case insensitive).
223 223
224 224 List values are separated by whitespace or comma, except when values are
225 225 placed in double quotation marks::
226 226
227 227 allow_read = "John Doe, PhD", brian, betty
228 228
229 229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 230 quotation marks at the beginning of a word is counted as a quotation
231 231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232 232
233 233 Sections
234 234 ========
235 235
236 236 This section describes the different sections that may appear in a
237 237 Mercurial configuration file, the purpose of each section, its possible
238 238 keys, and their possible values.
239 239
240 240 ``alias``
241 241 ---------
242 242
243 243 Defines command aliases.
244 244
245 245 Aliases allow you to define your own commands in terms of other
246 246 commands (or aliases), optionally including arguments. Positional
247 247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 248 are expanded by Mercurial before execution. Positional arguments not
249 249 already used by ``$N`` in the definition are put at the end of the
250 250 command to be executed.
251 251
252 252 Alias definitions consist of lines of the form::
253 253
254 254 <alias> = <command> [<argument>]...
255 255
256 256 For example, this definition::
257 257
258 258 latest = log --limit 5
259 259
260 260 creates a new command ``latest`` that shows only the five most recent
261 261 changesets. You can define subsequent aliases using earlier ones::
262 262
263 263 stable5 = latest -b stable
264 264
265 265 .. note::
266 266
267 267 It is possible to create aliases with the same names as
268 268 existing commands, which will then override the original
269 269 definitions. This is almost always a bad idea!
270 270
271 271 An alias can start with an exclamation point (``!``) to make it a
272 272 shell alias. A shell alias is executed with the shell and will let you
273 273 run arbitrary commands. As an example, ::
274 274
275 275 echo = !echo $@
276 276
277 277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 278 terminal. A better example might be::
279 279
280 280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281 281
282 282 which will make ``hg purge`` delete all unknown files in the
283 283 repository in the same manner as the purge extension.
284 284
285 285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 286 expand to the command arguments. Unmatched arguments are
287 287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 289 arguments quoted individually and separated by a space. These expansions
290 290 happen before the command is passed to the shell.
291 291
292 292 Shell aliases are executed in an environment where ``$HG`` expands to
293 293 the path of the Mercurial that was used to execute the alias. This is
294 294 useful when you want to call further Mercurial commands in a shell
295 295 alias, as was done above for the purge alias. In addition,
296 296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298 298
299 299 .. note::
300 300
301 301 Some global configuration options such as ``-R`` are
302 302 processed before shell aliases and will thus not be passed to
303 303 aliases.
304 304
305 305
306 306 ``annotate``
307 307 ------------
308 308
309 309 Settings used when displaying file annotations. All values are
310 310 Booleans and default to False. See :hg:`help config.diff` for
311 311 related options for the diff command.
312 312
313 313 ``ignorews``
314 314 Ignore white space when comparing lines.
315 315
316 316 ``ignorewsamount``
317 317 Ignore changes in the amount of white space.
318 318
319 319 ``ignoreblanklines``
320 320 Ignore changes whose lines are all blank.
321 321
322 322
323 323 ``auth``
324 324 --------
325 325
326 326 Authentication credentials for HTTP authentication. This section
327 327 allows you to store usernames and passwords for use when logging
328 328 *into* HTTP servers. See :hg:`help config.web` if
329 329 you want to configure *who* can login to your HTTP server.
330 330
331 331 Each line has the following format::
332 332
333 333 <name>.<argument> = <value>
334 334
335 335 where ``<name>`` is used to group arguments into authentication
336 336 entries. Example::
337 337
338 338 foo.prefix = hg.intevation.de/mercurial
339 339 foo.username = foo
340 340 foo.password = bar
341 341 foo.schemes = http https
342 342
343 343 bar.prefix = secure.example.org
344 344 bar.key = path/to/file.key
345 345 bar.cert = path/to/file.cert
346 346 bar.schemes = https
347 347
348 348 Supported arguments:
349 349
350 350 ``prefix``
351 351 Either ``*`` or a URI prefix with or without the scheme part.
352 352 The authentication entry with the longest matching prefix is used
353 353 (where ``*`` matches everything and counts as a match of length
354 354 1). If the prefix doesn't include a scheme, the match is performed
355 355 against the URI with its scheme stripped as well, and the schemes
356 356 argument, q.v., is then subsequently consulted.
357 357
358 358 ``username``
359 359 Optional. Username to authenticate with. If not given, and the
360 360 remote site requires basic or digest authentication, the user will
361 361 be prompted for it. Environment variables are expanded in the
362 362 username letting you do ``foo.username = $USER``. If the URI
363 363 includes a username, only ``[auth]`` entries with a matching
364 364 username or without a username will be considered.
365 365
366 366 ``password``
367 367 Optional. Password to authenticate with. If not given, and the
368 368 remote site requires basic or digest authentication, the user
369 369 will be prompted for it.
370 370
371 371 ``key``
372 372 Optional. PEM encoded client certificate key file. Environment
373 373 variables are expanded in the filename.
374 374
375 375 ``cert``
376 376 Optional. PEM encoded client certificate chain file. Environment
377 377 variables are expanded in the filename.
378 378
379 379 ``schemes``
380 380 Optional. Space separated list of URI schemes to use this
381 381 authentication entry with. Only used if the prefix doesn't include
382 382 a scheme. Supported schemes are http and https. They will match
383 383 static-http and static-https respectively, as well.
384 384 (default: https)
385 385
386 386 If no suitable authentication entry is found, the user is prompted
387 387 for credentials as usual if required by the remote.
388 388
389 ``color``
390 ---------
391
392 Configure the Mercurial color mode. For details about how to define your custom
393 effect and style see :hg:`help color`.
394
395 ``mode``
396 String: control the method used to output color. One of ``auto``, ``ansi``,
397 ``win32``, ``terminfo`` or ``debug``. In auto mode the color extension will
398 use ANSI mode by default (or win32 mode on Windows) if it detects a
399 terminal. Any invalid value will disable color.
400
401 ``pagermode``
402 String: optinal override of ``color.mode`` used with pager (from the pager
403 extensions).
404
405 On some systems, terminfo mode may cause problems when using
406 color with the pager extension and less -R. less with the -R option
407 will only display ECMA-48 color codes, and terminfo mode may sometimes
408 emit codes that less doesn't understand. You can work around this by
409 either using ansi mode (or auto mode), or by using less -r (which will
410 pass through all terminal control codes, not just color control
411 codes).
412
413 On some systems (such as MSYS in Windows), the terminal may support
414 a different color mode than the pager (activated via the "pager"
415 extension).
389 416
390 417 ``committemplate``
391 418 ------------------
392 419
393 420 ``changeset``
394 421 String: configuration in this section is used as the template to
395 422 customize the text shown in the editor when committing.
396 423
397 424 In addition to pre-defined template keywords, commit log specific one
398 425 below can be used for customization:
399 426
400 427 ``extramsg``
401 428 String: Extra message (typically 'Leave message empty to abort
402 429 commit.'). This may be changed by some commands or extensions.
403 430
404 431 For example, the template configuration below shows as same text as
405 432 one shown by default::
406 433
407 434 [committemplate]
408 435 changeset = {desc}\n\n
409 436 HG: Enter commit message. Lines beginning with 'HG:' are removed.
410 437 HG: {extramsg}
411 438 HG: --
412 439 HG: user: {author}\n{ifeq(p2rev, "-1", "",
413 440 "HG: branch merge\n")
414 441 }HG: branch '{branch}'\n{if(activebookmark,
415 442 "HG: bookmark '{activebookmark}'\n") }{subrepos %
416 443 "HG: subrepo {subrepo}\n" }{file_adds %
417 444 "HG: added {file}\n" }{file_mods %
418 445 "HG: changed {file}\n" }{file_dels %
419 446 "HG: removed {file}\n" }{if(files, "",
420 447 "HG: no files changed\n")}
421 448
422 449 ``diff()``
423 450 String: show the diff (see :hg:`help templates` for detail)
424 451
425 452 Sometimes it is helpful to show the diff of the changeset in the editor without
426 453 having to prefix 'HG: ' to each line so that highlighting works correctly. For
427 454 this, Mercurial provides a special string which will ignore everything below
428 455 it::
429 456
430 457 HG: ------------------------ >8 ------------------------
431 458
432 459 For example, the template configuration below will show the diff below the
433 460 extra message::
434 461
435 462 [committemplate]
436 463 changeset = {desc}\n\n
437 464 HG: Enter commit message. Lines beginning with 'HG:' are removed.
438 465 HG: {extramsg}
439 466 HG: ------------------------ >8 ------------------------
440 467 HG: Do not touch the line above.
441 468 HG: Everything below will be removed.
442 469 {diff()}
443 470
444 471 .. note::
445 472
446 473 For some problematic encodings (see :hg:`help win32mbcs` for
447 474 detail), this customization should be configured carefully, to
448 475 avoid showing broken characters.
449 476
450 477 For example, if a multibyte character ending with backslash (0x5c) is
451 478 followed by the ASCII character 'n' in the customized template,
452 479 the sequence of backslash and 'n' is treated as line-feed unexpectedly
453 480 (and the multibyte character is broken, too).
454 481
455 482 Customized template is used for commands below (``--edit`` may be
456 483 required):
457 484
458 485 - :hg:`backout`
459 486 - :hg:`commit`
460 487 - :hg:`fetch` (for merge commit only)
461 488 - :hg:`graft`
462 489 - :hg:`histedit`
463 490 - :hg:`import`
464 491 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
465 492 - :hg:`rebase`
466 493 - :hg:`shelve`
467 494 - :hg:`sign`
468 495 - :hg:`tag`
469 496 - :hg:`transplant`
470 497
471 498 Configuring items below instead of ``changeset`` allows showing
472 499 customized message only for specific actions, or showing different
473 500 messages for each action.
474 501
475 502 - ``changeset.backout`` for :hg:`backout`
476 503 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
477 504 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
478 505 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
479 506 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
480 507 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
481 508 - ``changeset.gpg.sign`` for :hg:`sign`
482 509 - ``changeset.graft`` for :hg:`graft`
483 510 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
484 511 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
485 512 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
486 513 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
487 514 - ``changeset.import.bypass`` for :hg:`import --bypass`
488 515 - ``changeset.import.normal.merge`` for :hg:`import` on merges
489 516 - ``changeset.import.normal.normal`` for :hg:`import` on other
490 517 - ``changeset.mq.qnew`` for :hg:`qnew`
491 518 - ``changeset.mq.qfold`` for :hg:`qfold`
492 519 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
493 520 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
494 521 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
495 522 - ``changeset.rebase.normal`` for :hg:`rebase` on other
496 523 - ``changeset.shelve.shelve`` for :hg:`shelve`
497 524 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
498 525 - ``changeset.tag.remove`` for :hg:`tag --remove`
499 526 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
500 527 - ``changeset.transplant.normal`` for :hg:`transplant` on other
501 528
502 529 These dot-separated lists of names are treated as hierarchical ones.
503 530 For example, ``changeset.tag.remove`` customizes the commit message
504 531 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
505 532 commit message for :hg:`tag` regardless of ``--remove`` option.
506 533
507 534 When the external editor is invoked for a commit, the corresponding
508 535 dot-separated list of names without the ``changeset.`` prefix
509 536 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
510 537 variable.
511 538
512 539 In this section, items other than ``changeset`` can be referred from
513 540 others. For example, the configuration to list committed files up
514 541 below can be referred as ``{listupfiles}``::
515 542
516 543 [committemplate]
517 544 listupfiles = {file_adds %
518 545 "HG: added {file}\n" }{file_mods %
519 546 "HG: changed {file}\n" }{file_dels %
520 547 "HG: removed {file}\n" }{if(files, "",
521 548 "HG: no files changed\n")}
522 549
523 550 ``decode/encode``
524 551 -----------------
525 552
526 553 Filters for transforming files on checkout/checkin. This would
527 554 typically be used for newline processing or other
528 555 localization/canonicalization of files.
529 556
530 557 Filters consist of a filter pattern followed by a filter command.
531 558 Filter patterns are globs by default, rooted at the repository root.
532 559 For example, to match any file ending in ``.txt`` in the root
533 560 directory only, use the pattern ``*.txt``. To match any file ending
534 561 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
535 562 For each file only the first matching filter applies.
536 563
537 564 The filter command can start with a specifier, either ``pipe:`` or
538 565 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
539 566
540 567 A ``pipe:`` command must accept data on stdin and return the transformed
541 568 data on stdout.
542 569
543 570 Pipe example::
544 571
545 572 [encode]
546 573 # uncompress gzip files on checkin to improve delta compression
547 574 # note: not necessarily a good idea, just an example
548 575 *.gz = pipe: gunzip
549 576
550 577 [decode]
551 578 # recompress gzip files when writing them to the working dir (we
552 579 # can safely omit "pipe:", because it's the default)
553 580 *.gz = gzip
554 581
555 582 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
556 583 with the name of a temporary file that contains the data to be
557 584 filtered by the command. The string ``OUTFILE`` is replaced with the name
558 585 of an empty temporary file, where the filtered data must be written by
559 586 the command.
560 587
561 588 .. container:: windows
562 589
563 590 .. note::
564 591
565 592 The tempfile mechanism is recommended for Windows systems,
566 593 where the standard shell I/O redirection operators often have
567 594 strange effects and may corrupt the contents of your files.
568 595
569 596 This filter mechanism is used internally by the ``eol`` extension to
570 597 translate line ending characters between Windows (CRLF) and Unix (LF)
571 598 format. We suggest you use the ``eol`` extension for convenience.
572 599
573 600
574 601 ``defaults``
575 602 ------------
576 603
577 604 (defaults are deprecated. Don't use them. Use aliases instead.)
578 605
579 606 Use the ``[defaults]`` section to define command defaults, i.e. the
580 607 default options/arguments to pass to the specified commands.
581 608
582 609 The following example makes :hg:`log` run in verbose mode, and
583 610 :hg:`status` show only the modified files, by default::
584 611
585 612 [defaults]
586 613 log = -v
587 614 status = -m
588 615
589 616 The actual commands, instead of their aliases, must be used when
590 617 defining command defaults. The command defaults will also be applied
591 618 to the aliases of the commands defined.
592 619
593 620
594 621 ``diff``
595 622 --------
596 623
597 624 Settings used when displaying diffs. Everything except for ``unified``
598 625 is a Boolean and defaults to False. See :hg:`help config.annotate`
599 626 for related options for the annotate command.
600 627
601 628 ``git``
602 629 Use git extended diff format.
603 630
604 631 ``nobinary``
605 632 Omit git binary patches.
606 633
607 634 ``nodates``
608 635 Don't include dates in diff headers.
609 636
610 637 ``noprefix``
611 638 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
612 639
613 640 ``showfunc``
614 641 Show which function each change is in.
615 642
616 643 ``ignorews``
617 644 Ignore white space when comparing lines.
618 645
619 646 ``ignorewsamount``
620 647 Ignore changes in the amount of white space.
621 648
622 649 ``ignoreblanklines``
623 650 Ignore changes whose lines are all blank.
624 651
625 652 ``unified``
626 653 Number of lines of context to show.
627 654
628 655 ``email``
629 656 ---------
630 657
631 658 Settings for extensions that send email messages.
632 659
633 660 ``from``
634 661 Optional. Email address to use in "From" header and SMTP envelope
635 662 of outgoing messages.
636 663
637 664 ``to``
638 665 Optional. Comma-separated list of recipients' email addresses.
639 666
640 667 ``cc``
641 668 Optional. Comma-separated list of carbon copy recipients'
642 669 email addresses.
643 670
644 671 ``bcc``
645 672 Optional. Comma-separated list of blind carbon copy recipients'
646 673 email addresses.
647 674
648 675 ``method``
649 676 Optional. Method to use to send email messages. If value is ``smtp``
650 677 (default), use SMTP (see the ``[smtp]`` section for configuration).
651 678 Otherwise, use as name of program to run that acts like sendmail
652 679 (takes ``-f`` option for sender, list of recipients on command line,
653 680 message on stdin). Normally, setting this to ``sendmail`` or
654 681 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
655 682
656 683 ``charsets``
657 684 Optional. Comma-separated list of character sets considered
658 685 convenient for recipients. Addresses, headers, and parts not
659 686 containing patches of outgoing messages will be encoded in the
660 687 first character set to which conversion from local encoding
661 688 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
662 689 conversion fails, the text in question is sent as is.
663 690 (default: '')
664 691
665 692 Order of outgoing email character sets:
666 693
667 694 1. ``us-ascii``: always first, regardless of settings
668 695 2. ``email.charsets``: in order given by user
669 696 3. ``ui.fallbackencoding``: if not in email.charsets
670 697 4. ``$HGENCODING``: if not in email.charsets
671 698 5. ``utf-8``: always last, regardless of settings
672 699
673 700 Email example::
674 701
675 702 [email]
676 703 from = Joseph User <joe.user@example.com>
677 704 method = /usr/sbin/sendmail
678 705 # charsets for western Europeans
679 706 # us-ascii, utf-8 omitted, as they are tried first and last
680 707 charsets = iso-8859-1, iso-8859-15, windows-1252
681 708
682 709
683 710 ``extensions``
684 711 --------------
685 712
686 713 Mercurial has an extension mechanism for adding new features. To
687 714 enable an extension, create an entry for it in this section.
688 715
689 716 If you know that the extension is already in Python's search path,
690 717 you can give the name of the module, followed by ``=``, with nothing
691 718 after the ``=``.
692 719
693 720 Otherwise, give a name that you choose, followed by ``=``, followed by
694 721 the path to the ``.py`` file (including the file name extension) that
695 722 defines the extension.
696 723
697 724 To explicitly disable an extension that is enabled in an hgrc of
698 725 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
699 726 or ``foo = !`` when path is not supplied.
700 727
701 728 Example for ``~/.hgrc``::
702 729
703 730 [extensions]
704 731 # (the color extension will get loaded from Mercurial's path)
705 732 color =
706 733 # (this extension will get loaded from the file specified)
707 734 myfeature = ~/.hgext/myfeature.py
708 735
709 736
710 737 ``format``
711 738 ----------
712 739
713 740 ``usegeneraldelta``
714 741 Enable or disable the "generaldelta" repository format which improves
715 742 repository compression by allowing "revlog" to store delta against arbitrary
716 743 revision instead of the previous stored one. This provides significant
717 744 improvement for repositories with branches.
718 745
719 746 Repositories with this on-disk format require Mercurial version 1.9.
720 747
721 748 Enabled by default.
722 749
723 750 ``dotencode``
724 751 Enable or disable the "dotencode" repository format which enhances
725 752 the "fncache" repository format (which has to be enabled to use
726 753 dotencode) to avoid issues with filenames starting with ._ on
727 754 Mac OS X and spaces on Windows.
728 755
729 756 Repositories with this on-disk format require Mercurial version 1.7.
730 757
731 758 Enabled by default.
732 759
733 760 ``usefncache``
734 761 Enable or disable the "fncache" repository format which enhances
735 762 the "store" repository format (which has to be enabled to use
736 763 fncache) to allow longer filenames and avoids using Windows
737 764 reserved names, e.g. "nul".
738 765
739 766 Repositories with this on-disk format require Mercurial version 1.1.
740 767
741 768 Enabled by default.
742 769
743 770 ``usestore``
744 771 Enable or disable the "store" repository format which improves
745 772 compatibility with systems that fold case or otherwise mangle
746 773 filenames. Disabling this option will allow you to store longer filenames
747 774 in some situations at the expense of compatibility.
748 775
749 776 Repositories with this on-disk format require Mercurial version 0.9.4.
750 777
751 778 Enabled by default.
752 779
753 780 ``graph``
754 781 ---------
755 782
756 783 Web graph view configuration. This section let you change graph
757 784 elements display properties by branches, for instance to make the
758 785 ``default`` branch stand out.
759 786
760 787 Each line has the following format::
761 788
762 789 <branch>.<argument> = <value>
763 790
764 791 where ``<branch>`` is the name of the branch being
765 792 customized. Example::
766 793
767 794 [graph]
768 795 # 2px width
769 796 default.width = 2
770 797 # red color
771 798 default.color = FF0000
772 799
773 800 Supported arguments:
774 801
775 802 ``width``
776 803 Set branch edges width in pixels.
777 804
778 805 ``color``
779 806 Set branch edges color in hexadecimal RGB notation.
780 807
781 808 ``hooks``
782 809 ---------
783 810
784 811 Commands or Python functions that get automatically executed by
785 812 various actions such as starting or finishing a commit. Multiple
786 813 hooks can be run for the same action by appending a suffix to the
787 814 action. Overriding a site-wide hook can be done by changing its
788 815 value or setting it to an empty string. Hooks can be prioritized
789 816 by adding a prefix of ``priority.`` to the hook name on a new line
790 817 and setting the priority. The default priority is 0.
791 818
792 819 Example ``.hg/hgrc``::
793 820
794 821 [hooks]
795 822 # update working directory after adding changesets
796 823 changegroup.update = hg update
797 824 # do not use the site-wide hook
798 825 incoming =
799 826 incoming.email = /my/email/hook
800 827 incoming.autobuild = /my/build/hook
801 828 # force autobuild hook to run before other incoming hooks
802 829 priority.incoming.autobuild = 1
803 830
804 831 Most hooks are run with environment variables set that give useful
805 832 additional information. For each hook below, the environment
806 833 variables it is passed are listed with names of the form ``$HG_foo``.
807 834
808 835 ``changegroup``
809 836 Run after a changegroup has been added via push, pull or unbundle. ID of the
810 837 first new changeset is in ``$HG_NODE`` and last in ``$HG_NODE_LAST``. URL
811 838 from which changes came is in ``$HG_URL``.
812 839
813 840 ``commit``
814 841 Run after a changeset has been created in the local repository. ID
815 842 of the newly created changeset is in ``$HG_NODE``. Parent changeset
816 843 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
817 844
818 845 ``incoming``
819 846 Run after a changeset has been pulled, pushed, or unbundled into
820 847 the local repository. The ID of the newly arrived changeset is in
821 848 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
822 849
823 850 ``outgoing``
824 851 Run after sending changes from local repository to another. ID of
825 852 first changeset sent is in ``$HG_NODE``. Source of operation is in
826 853 ``$HG_SOURCE``; Also see :hg:`help config.hooks.preoutgoing` hook.
827 854
828 855 ``post-<command>``
829 856 Run after successful invocations of the associated command. The
830 857 contents of the command line are passed as ``$HG_ARGS`` and the result
831 858 code in ``$HG_RESULT``. Parsed command line arguments are passed as
832 859 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
833 860 the python data internally passed to <command>. ``$HG_OPTS`` is a
834 861 dictionary of options (with unspecified options set to their defaults).
835 862 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
836 863
837 864 ``fail-<command>``
838 865 Run after a failed invocation of an associated command. The contents
839 866 of the command line are passed as ``$HG_ARGS``. Parsed command line
840 867 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
841 868 string representations of the python data internally passed to
842 869 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
843 870 options set to their defaults). ``$HG_PATS`` is a list of arguments.
844 871 Hook failure is ignored.
845 872
846 873 ``pre-<command>``
847 874 Run before executing the associated command. The contents of the
848 875 command line are passed as ``$HG_ARGS``. Parsed command line arguments
849 876 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
850 877 representations of the data internally passed to <command>. ``$HG_OPTS``
851 878 is a dictionary of options (with unspecified options set to their
852 879 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
853 880 failure, the command doesn't execute and Mercurial returns the failure
854 881 code.
855 882
856 883 ``prechangegroup``
857 884 Run before a changegroup is added via push, pull or unbundle. Exit
858 885 status 0 allows the changegroup to proceed. Non-zero status will
859 886 cause the push, pull or unbundle to fail. URL from which changes
860 887 will come is in ``$HG_URL``.
861 888
862 889 ``precommit``
863 890 Run before starting a local commit. Exit status 0 allows the
864 891 commit to proceed. Non-zero status will cause the commit to fail.
865 892 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
866 893
867 894 ``prelistkeys``
868 895 Run before listing pushkeys (like bookmarks) in the
869 896 repository. Non-zero status will cause failure. The key namespace is
870 897 in ``$HG_NAMESPACE``.
871 898
872 899 ``preoutgoing``
873 900 Run before collecting changes to send from the local repository to
874 901 another. Non-zero status will cause failure. This lets you prevent
875 902 pull over HTTP or SSH. Also prevents against local pull, push
876 903 (outbound) or bundle commands, but not effective, since you can
877 904 just copy files instead then. Source of operation is in
878 905 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
879 906 SSH or HTTP repository. If "push", "pull" or "bundle", operation
880 907 is happening on behalf of repository on same system.
881 908
882 909 ``prepushkey``
883 910 Run before a pushkey (like a bookmark) is added to the
884 911 repository. Non-zero status will cause the key to be rejected. The
885 912 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
886 913 the old value (if any) is in ``$HG_OLD``, and the new value is in
887 914 ``$HG_NEW``.
888 915
889 916 ``pretag``
890 917 Run before creating a tag. Exit status 0 allows the tag to be
891 918 created. Non-zero status will cause the tag to fail. ID of
892 919 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
893 920 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
894 921
895 922 ``pretxnopen``
896 923 Run before any new repository transaction is open. The reason for the
897 924 transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
898 925 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
899 926 transaction from being opened.
900 927
901 928 ``pretxnclose``
902 929 Run right before the transaction is actually finalized. Any repository change
903 930 will be visible to the hook program. This lets you validate the transaction
904 931 content or change it. Exit status 0 allows the commit to proceed. Non-zero
905 932 status will cause the transaction to be rolled back. The reason for the
906 933 transaction opening will be in ``$HG_TXNNAME`` and a unique identifier for
907 934 the transaction will be in ``HG_TXNID``. The rest of the available data will
908 935 vary according the transaction type. New changesets will add ``$HG_NODE`` (id
909 936 of the first added changeset), ``$HG_NODE_LAST`` (id of the last added
910 937 changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables, bookmarks and phases
911 938 changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``, etc.
912 939
913 940 ``txnclose``
914 941 Run after any repository transaction has been committed. At this
915 942 point, the transaction can no longer be rolled back. The hook will run
916 943 after the lock is released. See :hg:`help config.hooks.pretxnclose` docs for
917 944 details about available variables.
918 945
919 946 ``txnabort``
920 947 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
921 948 docs for details about available variables.
922 949
923 950 ``pretxnchangegroup``
924 951 Run after a changegroup has been added via push, pull or unbundle, but before
925 952 the transaction has been committed. Changegroup is visible to hook program.
926 953 This lets you validate incoming changes before accepting them. Passed the ID
927 954 of the first new changeset in ``$HG_NODE`` and last in ``$HG_NODE_LAST``.
928 955 Exit status 0 allows the transaction to commit. Non-zero status will cause
929 956 the transaction to be rolled back and the push, pull or unbundle will fail.
930 957 URL that was source of changes is in ``$HG_URL``.
931 958
932 959 ``pretxncommit``
933 960 Run after a changeset has been created but the transaction not yet
934 961 committed. Changeset is visible to hook program. This lets you
935 962 validate commit message and changes. Exit status 0 allows the
936 963 commit to proceed. Non-zero status will cause the transaction to
937 964 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
938 965 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
939 966
940 967 ``preupdate``
941 968 Run before updating the working directory. Exit status 0 allows
942 969 the update to proceed. Non-zero status will prevent the update.
943 970 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
944 971 of second new parent is in ``$HG_PARENT2``.
945 972
946 973 ``listkeys``
947 974 Run after listing pushkeys (like bookmarks) in the repository. The
948 975 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
949 976 dictionary containing the keys and values.
950 977
951 978 ``pushkey``
952 979 Run after a pushkey (like a bookmark) is added to the
953 980 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
954 981 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
955 982 value is in ``$HG_NEW``.
956 983
957 984 ``tag``
958 985 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
959 986 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
960 987 repository if ``$HG_LOCAL=0``.
961 988
962 989 ``update``
963 990 Run after updating the working directory. Changeset ID of first
964 991 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
965 992 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
966 993 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
967 994
968 995 .. note::
969 996
970 997 It is generally better to use standard hooks rather than the
971 998 generic pre- and post- command hooks as they are guaranteed to be
972 999 called in the appropriate contexts for influencing transactions.
973 1000 Also, hooks like "commit" will be called in all contexts that
974 1001 generate a commit (e.g. tag) and not just the commit command.
975 1002
976 1003 .. note::
977 1004
978 1005 Environment variables with empty values may not be passed to
979 1006 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
980 1007 will have an empty value under Unix-like platforms for non-merge
981 1008 changesets, while it will not be available at all under Windows.
982 1009
983 1010 The syntax for Python hooks is as follows::
984 1011
985 1012 hookname = python:modulename.submodule.callable
986 1013 hookname = python:/path/to/python/module.py:callable
987 1014
988 1015 Python hooks are run within the Mercurial process. Each hook is
989 1016 called with at least three keyword arguments: a ui object (keyword
990 1017 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
991 1018 keyword that tells what kind of hook is used. Arguments listed as
992 1019 environment variables above are passed as keyword arguments, with no
993 1020 ``HG_`` prefix, and names in lower case.
994 1021
995 1022 If a Python hook returns a "true" value or raises an exception, this
996 1023 is treated as a failure.
997 1024
998 1025
999 1026 ``hostfingerprints``
1000 1027 --------------------
1001 1028
1002 1029 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1003 1030
1004 1031 Fingerprints of the certificates of known HTTPS servers.
1005 1032
1006 1033 A HTTPS connection to a server with a fingerprint configured here will
1007 1034 only succeed if the servers certificate matches the fingerprint.
1008 1035 This is very similar to how ssh known hosts works.
1009 1036
1010 1037 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1011 1038 Multiple values can be specified (separated by spaces or commas). This can
1012 1039 be used to define both old and new fingerprints while a host transitions
1013 1040 to a new certificate.
1014 1041
1015 1042 The CA chain and web.cacerts is not used for servers with a fingerprint.
1016 1043
1017 1044 For example::
1018 1045
1019 1046 [hostfingerprints]
1020 1047 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1021 1048 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1022 1049
1023 1050 ``hostsecurity``
1024 1051 ----------------
1025 1052
1026 1053 Used to specify global and per-host security settings for connecting to
1027 1054 other machines.
1028 1055
1029 1056 The following options control default behavior for all hosts.
1030 1057
1031 1058 ``ciphers``
1032 1059 Defines the cryptographic ciphers to use for connections.
1033 1060
1034 1061 Value must be a valid OpenSSL Cipher List Format as documented at
1035 1062 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1036 1063
1037 1064 This setting is for advanced users only. Setting to incorrect values
1038 1065 can significantly lower connection security or decrease performance.
1039 1066 You have been warned.
1040 1067
1041 1068 This option requires Python 2.7.
1042 1069
1043 1070 ``minimumprotocol``
1044 1071 Defines the minimum channel encryption protocol to use.
1045 1072
1046 1073 By default, the highest version of TLS supported by both client and server
1047 1074 is used.
1048 1075
1049 1076 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1050 1077
1051 1078 When running on an old Python version, only ``tls1.0`` is allowed since
1052 1079 old versions of Python only support up to TLS 1.0.
1053 1080
1054 1081 When running a Python that supports modern TLS versions, the default is
1055 1082 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1056 1083 weakens security and should only be used as a feature of last resort if
1057 1084 a server does not support TLS 1.1+.
1058 1085
1059 1086 Options in the ``[hostsecurity]`` section can have the form
1060 1087 ``hostname``:``setting``. This allows multiple settings to be defined on a
1061 1088 per-host basis.
1062 1089
1063 1090 The following per-host settings can be defined.
1064 1091
1065 1092 ``ciphers``
1066 1093 This behaves like ``ciphers`` as described above except it only applies
1067 1094 to the host on which it is defined.
1068 1095
1069 1096 ``fingerprints``
1070 1097 A list of hashes of the DER encoded peer/remote certificate. Values have
1071 1098 the form ``algorithm``:``fingerprint``. e.g.
1072 1099 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1073 1100
1074 1101 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1075 1102 ``sha512``.
1076 1103
1077 1104 Use of ``sha256`` or ``sha512`` is preferred.
1078 1105
1079 1106 If a fingerprint is specified, the CA chain is not validated for this
1080 1107 host and Mercurial will require the remote certificate to match one
1081 1108 of the fingerprints specified. This means if the server updates its
1082 1109 certificate, Mercurial will abort until a new fingerprint is defined.
1083 1110 This can provide stronger security than traditional CA-based validation
1084 1111 at the expense of convenience.
1085 1112
1086 1113 This option takes precedence over ``verifycertsfile``.
1087 1114
1088 1115 ``minimumprotocol``
1089 1116 This behaves like ``minimumprotocol`` as described above except it
1090 1117 only applies to the host on which it is defined.
1091 1118
1092 1119 ``verifycertsfile``
1093 1120 Path to file a containing a list of PEM encoded certificates used to
1094 1121 verify the server certificate. Environment variables and ``~user``
1095 1122 constructs are expanded in the filename.
1096 1123
1097 1124 The server certificate or the certificate's certificate authority (CA)
1098 1125 must match a certificate from this file or certificate verification
1099 1126 will fail and connections to the server will be refused.
1100 1127
1101 1128 If defined, only certificates provided by this file will be used:
1102 1129 ``web.cacerts`` and any system/default certificates will not be
1103 1130 used.
1104 1131
1105 1132 This option has no effect if the per-host ``fingerprints`` option
1106 1133 is set.
1107 1134
1108 1135 The format of the file is as follows::
1109 1136
1110 1137 -----BEGIN CERTIFICATE-----
1111 1138 ... (certificate in base64 PEM encoding) ...
1112 1139 -----END CERTIFICATE-----
1113 1140 -----BEGIN CERTIFICATE-----
1114 1141 ... (certificate in base64 PEM encoding) ...
1115 1142 -----END CERTIFICATE-----
1116 1143
1117 1144 For example::
1118 1145
1119 1146 [hostsecurity]
1120 1147 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1121 1148 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
1122 1149 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1123 1150
1124 1151 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1125 1152 when connecting to ``hg.example.com``::
1126 1153
1127 1154 [hostsecurity]
1128 1155 minimumprotocol = tls1.2
1129 1156 hg.example.com:minimumprotocol = tls1.1
1130 1157
1131 1158 ``http_proxy``
1132 1159 --------------
1133 1160
1134 1161 Used to access web-based Mercurial repositories through a HTTP
1135 1162 proxy.
1136 1163
1137 1164 ``host``
1138 1165 Host name and (optional) port of the proxy server, for example
1139 1166 "myproxy:8000".
1140 1167
1141 1168 ``no``
1142 1169 Optional. Comma-separated list of host names that should bypass
1143 1170 the proxy.
1144 1171
1145 1172 ``passwd``
1146 1173 Optional. Password to authenticate with at the proxy server.
1147 1174
1148 1175 ``user``
1149 1176 Optional. User name to authenticate with at the proxy server.
1150 1177
1151 1178 ``always``
1152 1179 Optional. Always use the proxy, even for localhost and any entries
1153 1180 in ``http_proxy.no``. (default: False)
1154 1181
1155 1182 ``merge``
1156 1183 ---------
1157 1184
1158 1185 This section specifies behavior during merges and updates.
1159 1186
1160 1187 ``checkignored``
1161 1188 Controls behavior when an ignored file on disk has the same name as a tracked
1162 1189 file in the changeset being merged or updated to, and has different
1163 1190 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1164 1191 abort on such files. With ``warn``, warn on such files and back them up as
1165 1192 ``.orig``. With ``ignore``, don't print a warning and back them up as
1166 1193 ``.orig``. (default: ``abort``)
1167 1194
1168 1195 ``checkunknown``
1169 1196 Controls behavior when an unknown file that isn't ignored has the same name
1170 1197 as a tracked file in the changeset being merged or updated to, and has
1171 1198 different contents. Similar to ``merge.checkignored``, except for files that
1172 1199 are not ignored. (default: ``abort``)
1173 1200
1174 1201 ``merge-patterns``
1175 1202 ------------------
1176 1203
1177 1204 This section specifies merge tools to associate with particular file
1178 1205 patterns. Tools matched here will take precedence over the default
1179 1206 merge tool. Patterns are globs by default, rooted at the repository
1180 1207 root.
1181 1208
1182 1209 Example::
1183 1210
1184 1211 [merge-patterns]
1185 1212 **.c = kdiff3
1186 1213 **.jpg = myimgmerge
1187 1214
1188 1215 ``merge-tools``
1189 1216 ---------------
1190 1217
1191 1218 This section configures external merge tools to use for file-level
1192 1219 merges. This section has likely been preconfigured at install time.
1193 1220 Use :hg:`config merge-tools` to check the existing configuration.
1194 1221 Also see :hg:`help merge-tools` for more details.
1195 1222
1196 1223 Example ``~/.hgrc``::
1197 1224
1198 1225 [merge-tools]
1199 1226 # Override stock tool location
1200 1227 kdiff3.executable = ~/bin/kdiff3
1201 1228 # Specify command line
1202 1229 kdiff3.args = $base $local $other -o $output
1203 1230 # Give higher priority
1204 1231 kdiff3.priority = 1
1205 1232
1206 1233 # Changing the priority of preconfigured tool
1207 1234 meld.priority = 0
1208 1235
1209 1236 # Disable a preconfigured tool
1210 1237 vimdiff.disabled = yes
1211 1238
1212 1239 # Define new tool
1213 1240 myHtmlTool.args = -m $local $other $base $output
1214 1241 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1215 1242 myHtmlTool.priority = 1
1216 1243
1217 1244 Supported arguments:
1218 1245
1219 1246 ``priority``
1220 1247 The priority in which to evaluate this tool.
1221 1248 (default: 0)
1222 1249
1223 1250 ``executable``
1224 1251 Either just the name of the executable or its pathname.
1225 1252
1226 1253 .. container:: windows
1227 1254
1228 1255 On Windows, the path can use environment variables with ${ProgramFiles}
1229 1256 syntax.
1230 1257
1231 1258 (default: the tool name)
1232 1259
1233 1260 ``args``
1234 1261 The arguments to pass to the tool executable. You can refer to the
1235 1262 files being merged as well as the output file through these
1236 1263 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1237 1264 of ``$local`` and ``$other`` can vary depending on which action is being
1238 1265 performed. During and update or merge, ``$local`` represents the original
1239 1266 state of the file, while ``$other`` represents the commit you are updating
1240 1267 to or the commit you are merging with. During a rebase ``$local``
1241 1268 represents the destination of the rebase, and ``$other`` represents the
1242 1269 commit being rebased.
1243 1270 (default: ``$local $base $other``)
1244 1271
1245 1272 ``premerge``
1246 1273 Attempt to run internal non-interactive 3-way merge tool before
1247 1274 launching external tool. Options are ``true``, ``false``, ``keep`` or
1248 1275 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1249 1276 premerge fails. The ``keep-merge3`` will do the same but include information
1250 1277 about the base of the merge in the marker (see internal :merge3 in
1251 1278 :hg:`help merge-tools`).
1252 1279 (default: True)
1253 1280
1254 1281 ``binary``
1255 1282 This tool can merge binary files. (default: False, unless tool
1256 1283 was selected by file pattern match)
1257 1284
1258 1285 ``symlink``
1259 1286 This tool can merge symlinks. (default: False)
1260 1287
1261 1288 ``check``
1262 1289 A list of merge success-checking options:
1263 1290
1264 1291 ``changed``
1265 1292 Ask whether merge was successful when the merged file shows no changes.
1266 1293 ``conflicts``
1267 1294 Check whether there are conflicts even though the tool reported success.
1268 1295 ``prompt``
1269 1296 Always prompt for merge success, regardless of success reported by tool.
1270 1297
1271 1298 ``fixeol``
1272 1299 Attempt to fix up EOL changes caused by the merge tool.
1273 1300 (default: False)
1274 1301
1275 1302 ``gui``
1276 1303 This tool requires a graphical interface to run. (default: False)
1277 1304
1278 1305 .. container:: windows
1279 1306
1280 1307 ``regkey``
1281 1308 Windows registry key which describes install location of this
1282 1309 tool. Mercurial will search for this key first under
1283 1310 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1284 1311 (default: None)
1285 1312
1286 1313 ``regkeyalt``
1287 1314 An alternate Windows registry key to try if the first key is not
1288 1315 found. The alternate key uses the same ``regname`` and ``regappend``
1289 1316 semantics of the primary key. The most common use for this key
1290 1317 is to search for 32bit applications on 64bit operating systems.
1291 1318 (default: None)
1292 1319
1293 1320 ``regname``
1294 1321 Name of value to read from specified registry key.
1295 1322 (default: the unnamed (default) value)
1296 1323
1297 1324 ``regappend``
1298 1325 String to append to the value read from the registry, typically
1299 1326 the executable name of the tool.
1300 1327 (default: None)
1301 1328
1302 1329
1303 1330 ``patch``
1304 1331 ---------
1305 1332
1306 1333 Settings used when applying patches, for instance through the 'import'
1307 1334 command or with Mercurial Queues extension.
1308 1335
1309 1336 ``eol``
1310 1337 When set to 'strict' patch content and patched files end of lines
1311 1338 are preserved. When set to ``lf`` or ``crlf``, both files end of
1312 1339 lines are ignored when patching and the result line endings are
1313 1340 normalized to either LF (Unix) or CRLF (Windows). When set to
1314 1341 ``auto``, end of lines are again ignored while patching but line
1315 1342 endings in patched files are normalized to their original setting
1316 1343 on a per-file basis. If target file does not exist or has no end
1317 1344 of line, patch line endings are preserved.
1318 1345 (default: strict)
1319 1346
1320 1347 ``fuzz``
1321 1348 The number of lines of 'fuzz' to allow when applying patches. This
1322 1349 controls how much context the patcher is allowed to ignore when
1323 1350 trying to apply a patch.
1324 1351 (default: 2)
1325 1352
1326 1353 ``paths``
1327 1354 ---------
1328 1355
1329 1356 Assigns symbolic names and behavior to repositories.
1330 1357
1331 1358 Options are symbolic names defining the URL or directory that is the
1332 1359 location of the repository. Example::
1333 1360
1334 1361 [paths]
1335 1362 my_server = https://example.com/my_repo
1336 1363 local_path = /home/me/repo
1337 1364
1338 1365 These symbolic names can be used from the command line. To pull
1339 1366 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1340 1367 :hg:`push local_path`.
1341 1368
1342 1369 Options containing colons (``:``) denote sub-options that can influence
1343 1370 behavior for that specific path. Example::
1344 1371
1345 1372 [paths]
1346 1373 my_server = https://example.com/my_path
1347 1374 my_server:pushurl = ssh://example.com/my_path
1348 1375
1349 1376 The following sub-options can be defined:
1350 1377
1351 1378 ``pushurl``
1352 1379 The URL to use for push operations. If not defined, the location
1353 1380 defined by the path's main entry is used.
1354 1381
1355 1382 ``pushrev``
1356 1383 A revset defining which revisions to push by default.
1357 1384
1358 1385 When :hg:`push` is executed without a ``-r`` argument, the revset
1359 1386 defined by this sub-option is evaluated to determine what to push.
1360 1387
1361 1388 For example, a value of ``.`` will push the working directory's
1362 1389 revision by default.
1363 1390
1364 1391 Revsets specifying bookmarks will not result in the bookmark being
1365 1392 pushed.
1366 1393
1367 1394 The following special named paths exist:
1368 1395
1369 1396 ``default``
1370 1397 The URL or directory to use when no source or remote is specified.
1371 1398
1372 1399 :hg:`clone` will automatically define this path to the location the
1373 1400 repository was cloned from.
1374 1401
1375 1402 ``default-push``
1376 1403 (deprecated) The URL or directory for the default :hg:`push` location.
1377 1404 ``default:pushurl`` should be used instead.
1378 1405
1379 1406 ``phases``
1380 1407 ----------
1381 1408
1382 1409 Specifies default handling of phases. See :hg:`help phases` for more
1383 1410 information about working with phases.
1384 1411
1385 1412 ``publish``
1386 1413 Controls draft phase behavior when working as a server. When true,
1387 1414 pushed changesets are set to public in both client and server and
1388 1415 pulled or cloned changesets are set to public in the client.
1389 1416 (default: True)
1390 1417
1391 1418 ``new-commit``
1392 1419 Phase of newly-created commits.
1393 1420 (default: draft)
1394 1421
1395 1422 ``checksubrepos``
1396 1423 Check the phase of the current revision of each subrepository. Allowed
1397 1424 values are "ignore", "follow" and "abort". For settings other than
1398 1425 "ignore", the phase of the current revision of each subrepository is
1399 1426 checked before committing the parent repository. If any of those phases is
1400 1427 greater than the phase of the parent repository (e.g. if a subrepo is in a
1401 1428 "secret" phase while the parent repo is in "draft" phase), the commit is
1402 1429 either aborted (if checksubrepos is set to "abort") or the higher phase is
1403 1430 used for the parent repository commit (if set to "follow").
1404 1431 (default: follow)
1405 1432
1406 1433
1407 1434 ``profiling``
1408 1435 -------------
1409 1436
1410 1437 Specifies profiling type, format, and file output. Two profilers are
1411 1438 supported: an instrumenting profiler (named ``ls``), and a sampling
1412 1439 profiler (named ``stat``).
1413 1440
1414 1441 In this section description, 'profiling data' stands for the raw data
1415 1442 collected during profiling, while 'profiling report' stands for a
1416 1443 statistical text report generated from the profiling data. The
1417 1444 profiling is done using lsprof.
1418 1445
1419 1446 ``enabled``
1420 1447 Enable the profiler.
1421 1448 (default: false)
1422 1449
1423 1450 This is equivalent to passing ``--profile`` on the command line.
1424 1451
1425 1452 ``type``
1426 1453 The type of profiler to use.
1427 1454 (default: stat)
1428 1455
1429 1456 ``ls``
1430 1457 Use Python's built-in instrumenting profiler. This profiler
1431 1458 works on all platforms, but each line number it reports is the
1432 1459 first line of a function. This restriction makes it difficult to
1433 1460 identify the expensive parts of a non-trivial function.
1434 1461 ``stat``
1435 1462 Use a statistical profiler, statprof. This profiler is most
1436 1463 useful for profiling commands that run for longer than about 0.1
1437 1464 seconds.
1438 1465
1439 1466 ``format``
1440 1467 Profiling format. Specific to the ``ls`` instrumenting profiler.
1441 1468 (default: text)
1442 1469
1443 1470 ``text``
1444 1471 Generate a profiling report. When saving to a file, it should be
1445 1472 noted that only the report is saved, and the profiling data is
1446 1473 not kept.
1447 1474 ``kcachegrind``
1448 1475 Format profiling data for kcachegrind use: when saving to a
1449 1476 file, the generated file can directly be loaded into
1450 1477 kcachegrind.
1451 1478
1452 1479 ``statformat``
1453 1480 Profiling format for the ``stat`` profiler.
1454 1481 (default: hotpath)
1455 1482
1456 1483 ``hotpath``
1457 1484 Show a tree-based display containing the hot path of execution (where
1458 1485 most time was spent).
1459 1486 ``bymethod``
1460 1487 Show a table of methods ordered by how frequently they are active.
1461 1488 ``byline``
1462 1489 Show a table of lines in files ordered by how frequently they are active.
1463 1490 ``json``
1464 1491 Render profiling data as JSON.
1465 1492
1466 1493 ``frequency``
1467 1494 Sampling frequency. Specific to the ``stat`` sampling profiler.
1468 1495 (default: 1000)
1469 1496
1470 1497 ``output``
1471 1498 File path where profiling data or report should be saved. If the
1472 1499 file exists, it is replaced. (default: None, data is printed on
1473 1500 stderr)
1474 1501
1475 1502 ``sort``
1476 1503 Sort field. Specific to the ``ls`` instrumenting profiler.
1477 1504 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1478 1505 ``inlinetime``.
1479 1506 (default: inlinetime)
1480 1507
1481 1508 ``limit``
1482 1509 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1483 1510 (default: 30)
1484 1511
1485 1512 ``nested``
1486 1513 Show at most this number of lines of drill-down info after each main entry.
1487 1514 This can help explain the difference between Total and Inline.
1488 1515 Specific to the ``ls`` instrumenting profiler.
1489 1516 (default: 5)
1490 1517
1491 1518 ``progress``
1492 1519 ------------
1493 1520
1494 1521 Mercurial commands can draw progress bars that are as informative as
1495 1522 possible. Some progress bars only offer indeterminate information, while others
1496 1523 have a definite end point.
1497 1524
1498 1525 ``delay``
1499 1526 Number of seconds (float) before showing the progress bar. (default: 3)
1500 1527
1501 1528 ``changedelay``
1502 1529 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1503 1530 that value will be used instead. (default: 1)
1504 1531
1505 1532 ``refresh``
1506 1533 Time in seconds between refreshes of the progress bar. (default: 0.1)
1507 1534
1508 1535 ``format``
1509 1536 Format of the progress bar.
1510 1537
1511 1538 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1512 1539 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1513 1540 last 20 characters of the item, but this can be changed by adding either
1514 1541 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1515 1542 first num characters.
1516 1543
1517 1544 (default: topic bar number estimate)
1518 1545
1519 1546 ``width``
1520 1547 If set, the maximum width of the progress information (that is, min(width,
1521 1548 term width) will be used).
1522 1549
1523 1550 ``clear-complete``
1524 1551 Clear the progress bar after it's done. (default: True)
1525 1552
1526 1553 ``disable``
1527 1554 If true, don't show a progress bar.
1528 1555
1529 1556 ``assume-tty``
1530 1557 If true, ALWAYS show a progress bar, unless disable is given.
1531 1558
1532 1559 ``rebase``
1533 1560 ----------
1534 1561
1535 1562 ``allowdivergence``
1536 1563 Default to False, when True allow creating divergence when performing
1537 1564 rebase of obsolete changesets.
1538 1565
1539 1566 ``revsetalias``
1540 1567 ---------------
1541 1568
1542 1569 Alias definitions for revsets. See :hg:`help revsets` for details.
1543 1570
1544 1571 ``server``
1545 1572 ----------
1546 1573
1547 1574 Controls generic server settings.
1548 1575
1549 1576 ``compressionengines``
1550 1577 List of compression engines and their relative priority to advertise
1551 1578 to clients.
1552 1579
1553 1580 The order of compression engines determines their priority, the first
1554 1581 having the highest priority. If a compression engine is not listed
1555 1582 here, it won't be advertised to clients.
1556 1583
1557 1584 If not set (the default), built-in defaults are used. Run
1558 1585 :hg:`debuginstall` to list available compression engines and their
1559 1586 default wire protocol priority.
1560 1587
1561 1588 Older Mercurial clients only support zlib compression and this setting
1562 1589 has no effect for legacy clients.
1563 1590
1564 1591 ``uncompressed``
1565 1592 Whether to allow clients to clone a repository using the
1566 1593 uncompressed streaming protocol. This transfers about 40% more
1567 1594 data than a regular clone, but uses less memory and CPU on both
1568 1595 server and client. Over a LAN (100 Mbps or better) or a very fast
1569 1596 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1570 1597 regular clone. Over most WAN connections (anything slower than
1571 1598 about 6 Mbps), uncompressed streaming is slower, because of the
1572 1599 extra data transfer overhead. This mode will also temporarily hold
1573 1600 the write lock while determining what data to transfer.
1574 1601 (default: True)
1575 1602
1576 1603 ``preferuncompressed``
1577 1604 When set, clients will try to use the uncompressed streaming
1578 1605 protocol. (default: False)
1579 1606
1580 1607 ``validate``
1581 1608 Whether to validate the completeness of pushed changesets by
1582 1609 checking that all new file revisions specified in manifests are
1583 1610 present. (default: False)
1584 1611
1585 1612 ``maxhttpheaderlen``
1586 1613 Instruct HTTP clients not to send request headers longer than this
1587 1614 many bytes. (default: 1024)
1588 1615
1589 1616 ``bundle1``
1590 1617 Whether to allow clients to push and pull using the legacy bundle1
1591 1618 exchange format. (default: True)
1592 1619
1593 1620 ``bundle1gd``
1594 1621 Like ``bundle1`` but only used if the repository is using the
1595 1622 *generaldelta* storage format. (default: True)
1596 1623
1597 1624 ``bundle1.push``
1598 1625 Whether to allow clients to push using the legacy bundle1 exchange
1599 1626 format. (default: True)
1600 1627
1601 1628 ``bundle1gd.push``
1602 1629 Like ``bundle1.push`` but only used if the repository is using the
1603 1630 *generaldelta* storage format. (default: True)
1604 1631
1605 1632 ``bundle1.pull``
1606 1633 Whether to allow clients to pull using the legacy bundle1 exchange
1607 1634 format. (default: True)
1608 1635
1609 1636 ``bundle1gd.pull``
1610 1637 Like ``bundle1.pull`` but only used if the repository is using the
1611 1638 *generaldelta* storage format. (default: True)
1612 1639
1613 1640 Large repositories using the *generaldelta* storage format should
1614 1641 consider setting this option because converting *generaldelta*
1615 1642 repositories to the exchange format required by the bundle1 data
1616 1643 format can consume a lot of CPU.
1617 1644
1618 1645 ``zliblevel``
1619 1646 Integer between ``-1`` and ``9`` that controls the zlib compression level
1620 1647 for wire protocol commands that send zlib compressed output (notably the
1621 1648 commands that send repository history data).
1622 1649
1623 1650 The default (``-1``) uses the default zlib compression level, which is
1624 1651 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1625 1652 maximum compression.
1626 1653
1627 1654 Setting this option allows server operators to make trade-offs between
1628 1655 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1629 1656 but sends more bytes to clients.
1630 1657
1631 1658 This option only impacts the HTTP server.
1632 1659
1633 1660 ``zstdlevel``
1634 1661 Integer between ``1`` and ``22`` that controls the zstd compression level
1635 1662 for wire protocol commands. ``1`` is the minimal amount of compression and
1636 1663 ``22`` is the highest amount of compression.
1637 1664
1638 1665 The default (``3``) should be significantly faster than zlib while likely
1639 1666 delivering better compression ratios.
1640 1667
1641 1668 This option only impacts the HTTP server.
1642 1669
1643 1670 See also ``server.zliblevel``.
1644 1671
1645 1672 ``smtp``
1646 1673 --------
1647 1674
1648 1675 Configuration for extensions that need to send email messages.
1649 1676
1650 1677 ``host``
1651 1678 Host name of mail server, e.g. "mail.example.com".
1652 1679
1653 1680 ``port``
1654 1681 Optional. Port to connect to on mail server. (default: 465 if
1655 1682 ``tls`` is smtps; 25 otherwise)
1656 1683
1657 1684 ``tls``
1658 1685 Optional. Method to enable TLS when connecting to mail server: starttls,
1659 1686 smtps or none. (default: none)
1660 1687
1661 1688 ``username``
1662 1689 Optional. User name for authenticating with the SMTP server.
1663 1690 (default: None)
1664 1691
1665 1692 ``password``
1666 1693 Optional. Password for authenticating with the SMTP server. If not
1667 1694 specified, interactive sessions will prompt the user for a
1668 1695 password; non-interactive sessions will fail. (default: None)
1669 1696
1670 1697 ``local_hostname``
1671 1698 Optional. The hostname that the sender can use to identify
1672 1699 itself to the MTA.
1673 1700
1674 1701
1675 1702 ``subpaths``
1676 1703 ------------
1677 1704
1678 1705 Subrepository source URLs can go stale if a remote server changes name
1679 1706 or becomes temporarily unavailable. This section lets you define
1680 1707 rewrite rules of the form::
1681 1708
1682 1709 <pattern> = <replacement>
1683 1710
1684 1711 where ``pattern`` is a regular expression matching a subrepository
1685 1712 source URL and ``replacement`` is the replacement string used to
1686 1713 rewrite it. Groups can be matched in ``pattern`` and referenced in
1687 1714 ``replacements``. For instance::
1688 1715
1689 1716 http://server/(.*)-hg/ = http://hg.server/\1/
1690 1717
1691 1718 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1692 1719
1693 1720 Relative subrepository paths are first made absolute, and the
1694 1721 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1695 1722 doesn't match the full path, an attempt is made to apply it on the
1696 1723 relative path alone. The rules are applied in definition order.
1697 1724
1698 1725 ``templatealias``
1699 1726 -----------------
1700 1727
1701 1728 Alias definitions for templates. See :hg:`help templates` for details.
1702 1729
1703 1730 ``templates``
1704 1731 -------------
1705 1732
1706 1733 Use the ``[templates]`` section to define template strings.
1707 1734 See :hg:`help templates` for details.
1708 1735
1709 1736 ``trusted``
1710 1737 -----------
1711 1738
1712 1739 Mercurial will not use the settings in the
1713 1740 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1714 1741 user or to a trusted group, as various hgrc features allow arbitrary
1715 1742 commands to be run. This issue is often encountered when configuring
1716 1743 hooks or extensions for shared repositories or servers. However,
1717 1744 the web interface will use some safe settings from the ``[web]``
1718 1745 section.
1719 1746
1720 1747 This section specifies what users and groups are trusted. The
1721 1748 current user is always trusted. To trust everybody, list a user or a
1722 1749 group with name ``*``. These settings must be placed in an
1723 1750 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1724 1751 user or service running Mercurial.
1725 1752
1726 1753 ``users``
1727 1754 Comma-separated list of trusted users.
1728 1755
1729 1756 ``groups``
1730 1757 Comma-separated list of trusted groups.
1731 1758
1732 1759
1733 1760 ``ui``
1734 1761 ------
1735 1762
1736 1763 User interface controls.
1737 1764
1738 1765 ``archivemeta``
1739 1766 Whether to include the .hg_archival.txt file containing meta data
1740 1767 (hashes for the repository base and for tip) in archives created
1741 1768 by the :hg:`archive` command or downloaded via hgweb.
1742 1769 (default: True)
1743 1770
1744 1771 ``askusername``
1745 1772 Whether to prompt for a username when committing. If True, and
1746 1773 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1747 1774 be prompted to enter a username. If no username is entered, the
1748 1775 default ``USER@HOST`` is used instead.
1749 1776 (default: False)
1750 1777
1751 1778 ``clonebundles``
1752 1779 Whether the "clone bundles" feature is enabled.
1753 1780
1754 1781 When enabled, :hg:`clone` may download and apply a server-advertised
1755 1782 bundle file from a URL instead of using the normal exchange mechanism.
1756 1783
1757 1784 This can likely result in faster and more reliable clones.
1758 1785
1759 1786 (default: True)
1760 1787
1761 1788 ``clonebundlefallback``
1762 1789 Whether failure to apply an advertised "clone bundle" from a server
1763 1790 should result in fallback to a regular clone.
1764 1791
1765 1792 This is disabled by default because servers advertising "clone
1766 1793 bundles" often do so to reduce server load. If advertised bundles
1767 1794 start mass failing and clients automatically fall back to a regular
1768 1795 clone, this would add significant and unexpected load to the server
1769 1796 since the server is expecting clone operations to be offloaded to
1770 1797 pre-generated bundles. Failing fast (the default behavior) ensures
1771 1798 clients don't overwhelm the server when "clone bundle" application
1772 1799 fails.
1773 1800
1774 1801 (default: False)
1775 1802
1776 1803 ``clonebundleprefers``
1777 1804 Defines preferences for which "clone bundles" to use.
1778 1805
1779 1806 Servers advertising "clone bundles" may advertise multiple available
1780 1807 bundles. Each bundle may have different attributes, such as the bundle
1781 1808 type and compression format. This option is used to prefer a particular
1782 1809 bundle over another.
1783 1810
1784 1811 The following keys are defined by Mercurial:
1785 1812
1786 1813 BUNDLESPEC
1787 1814 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
1788 1815 e.g. ``gzip-v2`` or ``bzip2-v1``.
1789 1816
1790 1817 COMPRESSION
1791 1818 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
1792 1819
1793 1820 Server operators may define custom keys.
1794 1821
1795 1822 Example values: ``COMPRESSION=bzip2``,
1796 1823 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
1797 1824
1798 1825 By default, the first bundle advertised by the server is used.
1799 1826
1827 ``color``
1828 String: when to use to colorize output. possible value are auto, always,
1829 never, or debug (default: never). 'auto' will use color whenever it seems
1830 possible. See :hg:`help color` for details.
1831
1832 (in addition a boolean can be used in place always/never)
1833
1800 1834 ``commitsubrepos``
1801 1835 Whether to commit modified subrepositories when committing the
1802 1836 parent repository. If False and one subrepository has uncommitted
1803 1837 changes, abort the commit.
1804 1838 (default: False)
1805 1839
1806 1840 ``debug``
1807 1841 Print debugging information. (default: False)
1808 1842
1809 1843 ``editor``
1810 1844 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
1811 1845
1812 1846 ``fallbackencoding``
1813 1847 Encoding to try if it's not possible to decode the changelog using
1814 1848 UTF-8. (default: ISO-8859-1)
1815 1849
1816 1850 ``graphnodetemplate``
1817 1851 The template used to print changeset nodes in an ASCII revision graph.
1818 1852 (default: ``{graphnode}``)
1819 1853
1820 1854 ``ignore``
1821 1855 A file to read per-user ignore patterns from. This file should be
1822 1856 in the same format as a repository-wide .hgignore file. Filenames
1823 1857 are relative to the repository root. This option supports hook syntax,
1824 1858 so if you want to specify multiple ignore files, you can do so by
1825 1859 setting something like ``ignore.other = ~/.hgignore2``. For details
1826 1860 of the ignore file format, see the ``hgignore(5)`` man page.
1827 1861
1828 1862 ``interactive``
1829 1863 Allow to prompt the user. (default: True)
1830 1864
1831 1865 ``interface``
1832 1866 Select the default interface for interactive features (default: text).
1833 1867 Possible values are 'text' and 'curses'.
1834 1868
1835 1869 ``interface.chunkselector``
1836 1870 Select the interface for change recording (e.g. :hg:`commit -i`).
1837 1871 Possible values are 'text' and 'curses'.
1838 1872 This config overrides the interface specified by ui.interface.
1839 1873
1840 1874 ``logtemplate``
1841 1875 Template string for commands that print changesets.
1842 1876
1843 1877 ``merge``
1844 1878 The conflict resolution program to use during a manual merge.
1845 1879 For more information on merge tools see :hg:`help merge-tools`.
1846 1880 For configuring merge tools see the ``[merge-tools]`` section.
1847 1881
1848 1882 ``mergemarkers``
1849 1883 Sets the merge conflict marker label styling. The ``detailed``
1850 1884 style uses the ``mergemarkertemplate`` setting to style the labels.
1851 1885 The ``basic`` style just uses 'local' and 'other' as the marker label.
1852 1886 One of ``basic`` or ``detailed``.
1853 1887 (default: ``basic``)
1854 1888
1855 1889 ``mergemarkertemplate``
1856 1890 The template used to print the commit description next to each conflict
1857 1891 marker during merge conflicts. See :hg:`help templates` for the template
1858 1892 format.
1859 1893
1860 1894 Defaults to showing the hash, tags, branches, bookmarks, author, and
1861 1895 the first line of the commit description.
1862 1896
1863 1897 If you use non-ASCII characters in names for tags, branches, bookmarks,
1864 1898 authors, and/or commit descriptions, you must pay attention to encodings of
1865 1899 managed files. At template expansion, non-ASCII characters use the encoding
1866 1900 specified by the ``--encoding`` global option, ``HGENCODING`` or other
1867 1901 environment variables that govern your locale. If the encoding of the merge
1868 1902 markers is different from the encoding of the merged files,
1869 1903 serious problems may occur.
1870 1904
1871 1905 ``origbackuppath``
1872 1906 The path to a directory used to store generated .orig files. If the path is
1873 1907 not a directory, one will be created.
1874 1908
1875 1909 ``patch``
1876 1910 An optional external tool that ``hg import`` and some extensions
1877 1911 will use for applying patches. By default Mercurial uses an
1878 1912 internal patch utility. The external tool must work as the common
1879 1913 Unix ``patch`` program. In particular, it must accept a ``-p``
1880 1914 argument to strip patch headers, a ``-d`` argument to specify the
1881 1915 current directory, a file name to patch, and a patch file to take
1882 1916 from stdin.
1883 1917
1884 1918 It is possible to specify a patch tool together with extra
1885 1919 arguments. For example, setting this option to ``patch --merge``
1886 1920 will use the ``patch`` program with its 2-way merge option.
1887 1921
1888 1922 ``portablefilenames``
1889 1923 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1890 1924 (default: ``warn``)
1891 1925
1892 1926 ``warn``
1893 1927 Print a warning message on POSIX platforms, if a file with a non-portable
1894 1928 filename is added (e.g. a file with a name that can't be created on
1895 1929 Windows because it contains reserved parts like ``AUX``, reserved
1896 1930 characters like ``:``, or would cause a case collision with an existing
1897 1931 file).
1898 1932
1899 1933 ``ignore``
1900 1934 Don't print a warning.
1901 1935
1902 1936 ``abort``
1903 1937 The command is aborted.
1904 1938
1905 1939 ``true``
1906 1940 Alias for ``warn``.
1907 1941
1908 1942 ``false``
1909 1943 Alias for ``ignore``.
1910 1944
1911 1945 .. container:: windows
1912 1946
1913 1947 On Windows, this configuration option is ignored and the command aborted.
1914 1948
1915 1949 ``quiet``
1916 1950 Reduce the amount of output printed.
1917 1951 (default: False)
1918 1952
1919 1953 ``remotecmd``
1920 1954 Remote command to use for clone/push/pull operations.
1921 1955 (default: ``hg``)
1922 1956
1923 1957 ``report_untrusted``
1924 1958 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1925 1959 trusted user or group.
1926 1960 (default: True)
1927 1961
1928 1962 ``slash``
1929 1963 Display paths using a slash (``/``) as the path separator. This
1930 1964 only makes a difference on systems where the default path
1931 1965 separator is not the slash character (e.g. Windows uses the
1932 1966 backslash character (``\``)).
1933 1967 (default: False)
1934 1968
1935 1969 ``statuscopies``
1936 1970 Display copies in the status command.
1937 1971
1938 1972 ``ssh``
1939 1973 Command to use for SSH connections. (default: ``ssh``)
1940 1974
1941 1975 ``strict``
1942 1976 Require exact command names, instead of allowing unambiguous
1943 1977 abbreviations. (default: False)
1944 1978
1945 1979 ``style``
1946 1980 Name of style to use for command output.
1947 1981
1948 1982 ``supportcontact``
1949 1983 A URL where users should report a Mercurial traceback. Use this if you are a
1950 1984 large organisation with its own Mercurial deployment process and crash
1951 1985 reports should be addressed to your internal support.
1952 1986
1953 1987 ``textwidth``
1954 1988 Maximum width of help text. A longer line generated by ``hg help`` or
1955 1989 ``hg subcommand --help`` will be broken after white space to get this
1956 1990 width or the terminal width, whichever comes first.
1957 1991 A non-positive value will disable this and the terminal width will be
1958 1992 used. (default: 78)
1959 1993
1960 1994 ``timeout``
1961 1995 The timeout used when a lock is held (in seconds), a negative value
1962 1996 means no timeout. (default: 600)
1963 1997
1964 1998 ``traceback``
1965 1999 Mercurial always prints a traceback when an unknown exception
1966 2000 occurs. Setting this to True will make Mercurial print a traceback
1967 2001 on all exceptions, even those recognized by Mercurial (such as
1968 2002 IOError or MemoryError). (default: False)
1969 2003
1970 2004 ``username``
1971 2005 The committer of a changeset created when running "commit".
1972 2006 Typically a person's name and email address, e.g. ``Fred Widget
1973 2007 <fred@example.com>``. Environment variables in the
1974 2008 username are expanded.
1975 2009
1976 2010 (default: ``$EMAIL`` or ``username@hostname``. If the username in
1977 2011 hgrc is empty, e.g. if the system admin set ``username =`` in the
1978 2012 system hgrc, it has to be specified manually or in a different
1979 2013 hgrc file)
1980 2014
1981 2015 ``verbose``
1982 2016 Increase the amount of output printed. (default: False)
1983 2017
1984 2018
1985 2019 ``web``
1986 2020 -------
1987 2021
1988 2022 Web interface configuration. The settings in this section apply to
1989 2023 both the builtin webserver (started by :hg:`serve`) and the script you
1990 2024 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1991 2025 and WSGI).
1992 2026
1993 2027 The Mercurial webserver does no authentication (it does not prompt for
1994 2028 usernames and passwords to validate *who* users are), but it does do
1995 2029 authorization (it grants or denies access for *authenticated users*
1996 2030 based on settings in this section). You must either configure your
1997 2031 webserver to do authentication for you, or disable the authorization
1998 2032 checks.
1999 2033
2000 2034 For a quick setup in a trusted environment, e.g., a private LAN, where
2001 2035 you want it to accept pushes from anybody, you can use the following
2002 2036 command line::
2003 2037
2004 2038 $ hg --config web.allow_push=* --config web.push_ssl=False serve
2005 2039
2006 2040 Note that this will allow anybody to push anything to the server and
2007 2041 that this should not be used for public servers.
2008 2042
2009 2043 The full set of options is:
2010 2044
2011 2045 ``accesslog``
2012 2046 Where to output the access log. (default: stdout)
2013 2047
2014 2048 ``address``
2015 2049 Interface address to bind to. (default: all)
2016 2050
2017 2051 ``allow_archive``
2018 2052 List of archive format (bz2, gz, zip) allowed for downloading.
2019 2053 (default: empty)
2020 2054
2021 2055 ``allowbz2``
2022 2056 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2023 2057 revisions.
2024 2058 (default: False)
2025 2059
2026 2060 ``allowgz``
2027 2061 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2028 2062 revisions.
2029 2063 (default: False)
2030 2064
2031 2065 ``allowpull``
2032 2066 Whether to allow pulling from the repository. (default: True)
2033 2067
2034 2068 ``allow_push``
2035 2069 Whether to allow pushing to the repository. If empty or not set,
2036 2070 pushing is not allowed. If the special value ``*``, any remote
2037 2071 user can push, including unauthenticated users. Otherwise, the
2038 2072 remote user must have been authenticated, and the authenticated
2039 2073 user name must be present in this list. The contents of the
2040 2074 allow_push list are examined after the deny_push list.
2041 2075
2042 2076 ``allow_read``
2043 2077 If the user has not already been denied repository access due to
2044 2078 the contents of deny_read, this list determines whether to grant
2045 2079 repository access to the user. If this list is not empty, and the
2046 2080 user is unauthenticated or not present in the list, then access is
2047 2081 denied for the user. If the list is empty or not set, then access
2048 2082 is permitted to all users by default. Setting allow_read to the
2049 2083 special value ``*`` is equivalent to it not being set (i.e. access
2050 2084 is permitted to all users). The contents of the allow_read list are
2051 2085 examined after the deny_read list.
2052 2086
2053 2087 ``allowzip``
2054 2088 (DEPRECATED) Whether to allow .zip downloading of repository
2055 2089 revisions. This feature creates temporary files.
2056 2090 (default: False)
2057 2091
2058 2092 ``archivesubrepos``
2059 2093 Whether to recurse into subrepositories when archiving.
2060 2094 (default: False)
2061 2095
2062 2096 ``baseurl``
2063 2097 Base URL to use when publishing URLs in other locations, so
2064 2098 third-party tools like email notification hooks can construct
2065 2099 URLs. Example: ``http://hgserver/repos/``.
2066 2100
2067 2101 ``cacerts``
2068 2102 Path to file containing a list of PEM encoded certificate
2069 2103 authority certificates. Environment variables and ``~user``
2070 2104 constructs are expanded in the filename. If specified on the
2071 2105 client, then it will verify the identity of remote HTTPS servers
2072 2106 with these certificates.
2073 2107
2074 2108 To disable SSL verification temporarily, specify ``--insecure`` from
2075 2109 command line.
2076 2110
2077 2111 You can use OpenSSL's CA certificate file if your platform has
2078 2112 one. On most Linux systems this will be
2079 2113 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2080 2114 generate this file manually. The form must be as follows::
2081 2115
2082 2116 -----BEGIN CERTIFICATE-----
2083 2117 ... (certificate in base64 PEM encoding) ...
2084 2118 -----END CERTIFICATE-----
2085 2119 -----BEGIN CERTIFICATE-----
2086 2120 ... (certificate in base64 PEM encoding) ...
2087 2121 -----END CERTIFICATE-----
2088 2122
2089 2123 ``cache``
2090 2124 Whether to support caching in hgweb. (default: True)
2091 2125
2092 2126 ``certificate``
2093 2127 Certificate to use when running :hg:`serve`.
2094 2128
2095 2129 ``collapse``
2096 2130 With ``descend`` enabled, repositories in subdirectories are shown at
2097 2131 a single level alongside repositories in the current path. With
2098 2132 ``collapse`` also enabled, repositories residing at a deeper level than
2099 2133 the current path are grouped behind navigable directory entries that
2100 2134 lead to the locations of these repositories. In effect, this setting
2101 2135 collapses each collection of repositories found within a subdirectory
2102 2136 into a single entry for that subdirectory. (default: False)
2103 2137
2104 2138 ``comparisoncontext``
2105 2139 Number of lines of context to show in side-by-side file comparison. If
2106 2140 negative or the value ``full``, whole files are shown. (default: 5)
2107 2141
2108 2142 This setting can be overridden by a ``context`` request parameter to the
2109 2143 ``comparison`` command, taking the same values.
2110 2144
2111 2145 ``contact``
2112 2146 Name or email address of the person in charge of the repository.
2113 2147 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2114 2148
2115 2149 ``csp``
2116 2150 Send a ``Content-Security-Policy`` HTTP header with this value.
2117 2151
2118 2152 The value may contain a special string ``%nonce%``, which will be replaced
2119 2153 by a randomly-generated one-time use value. If the value contains
2120 2154 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2121 2155 one-time property of the nonce. This nonce will also be inserted into
2122 2156 ``<script>`` elements containing inline JavaScript.
2123 2157
2124 2158 Note: lots of HTML content sent by the server is derived from repository
2125 2159 data. Please consider the potential for malicious repository data to
2126 2160 "inject" itself into generated HTML content as part of your security
2127 2161 threat model.
2128 2162
2129 2163 ``deny_push``
2130 2164 Whether to deny pushing to the repository. If empty or not set,
2131 2165 push is not denied. If the special value ``*``, all remote users are
2132 2166 denied push. Otherwise, unauthenticated users are all denied, and
2133 2167 any authenticated user name present in this list is also denied. The
2134 2168 contents of the deny_push list are examined before the allow_push list.
2135 2169
2136 2170 ``deny_read``
2137 2171 Whether to deny reading/viewing of the repository. If this list is
2138 2172 not empty, unauthenticated users are all denied, and any
2139 2173 authenticated user name present in this list is also denied access to
2140 2174 the repository. If set to the special value ``*``, all remote users
2141 2175 are denied access (rarely needed ;). If deny_read is empty or not set,
2142 2176 the determination of repository access depends on the presence and
2143 2177 content of the allow_read list (see description). If both
2144 2178 deny_read and allow_read are empty or not set, then access is
2145 2179 permitted to all users by default. If the repository is being
2146 2180 served via hgwebdir, denied users will not be able to see it in
2147 2181 the list of repositories. The contents of the deny_read list have
2148 2182 priority over (are examined before) the contents of the allow_read
2149 2183 list.
2150 2184
2151 2185 ``descend``
2152 2186 hgwebdir indexes will not descend into subdirectories. Only repositories
2153 2187 directly in the current path will be shown (other repositories are still
2154 2188 available from the index corresponding to their containing path).
2155 2189
2156 2190 ``description``
2157 2191 Textual description of the repository's purpose or contents.
2158 2192 (default: "unknown")
2159 2193
2160 2194 ``encoding``
2161 2195 Character encoding name. (default: the current locale charset)
2162 2196 Example: "UTF-8".
2163 2197
2164 2198 ``errorlog``
2165 2199 Where to output the error log. (default: stderr)
2166 2200
2167 2201 ``guessmime``
2168 2202 Control MIME types for raw download of file content.
2169 2203 Set to True to let hgweb guess the content type from the file
2170 2204 extension. This will serve HTML files as ``text/html`` and might
2171 2205 allow cross-site scripting attacks when serving untrusted
2172 2206 repositories. (default: False)
2173 2207
2174 2208 ``hidden``
2175 2209 Whether to hide the repository in the hgwebdir index.
2176 2210 (default: False)
2177 2211
2178 2212 ``ipv6``
2179 2213 Whether to use IPv6. (default: False)
2180 2214
2181 2215 ``labels``
2182 2216 List of string *labels* associated with the repository.
2183 2217
2184 2218 Labels are exposed as a template keyword and can be used to customize
2185 2219 output. e.g. the ``index`` template can group or filter repositories
2186 2220 by labels and the ``summary`` template can display additional content
2187 2221 if a specific label is present.
2188 2222
2189 2223 ``logoimg``
2190 2224 File name of the logo image that some templates display on each page.
2191 2225 The file name is relative to ``staticurl``. That is, the full path to
2192 2226 the logo image is "staticurl/logoimg".
2193 2227 If unset, ``hglogo.png`` will be used.
2194 2228
2195 2229 ``logourl``
2196 2230 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2197 2231 will be used.
2198 2232
2199 2233 ``maxchanges``
2200 2234 Maximum number of changes to list on the changelog. (default: 10)
2201 2235
2202 2236 ``maxfiles``
2203 2237 Maximum number of files to list per changeset. (default: 10)
2204 2238
2205 2239 ``maxshortchanges``
2206 2240 Maximum number of changes to list on the shortlog, graph or filelog
2207 2241 pages. (default: 60)
2208 2242
2209 2243 ``name``
2210 2244 Repository name to use in the web interface.
2211 2245 (default: current working directory)
2212 2246
2213 2247 ``port``
2214 2248 Port to listen on. (default: 8000)
2215 2249
2216 2250 ``prefix``
2217 2251 Prefix path to serve from. (default: '' (server root))
2218 2252
2219 2253 ``push_ssl``
2220 2254 Whether to require that inbound pushes be transported over SSL to
2221 2255 prevent password sniffing. (default: True)
2222 2256
2223 2257 ``refreshinterval``
2224 2258 How frequently directory listings re-scan the filesystem for new
2225 2259 repositories, in seconds. This is relevant when wildcards are used
2226 2260 to define paths. Depending on how much filesystem traversal is
2227 2261 required, refreshing may negatively impact performance.
2228 2262
2229 2263 Values less than or equal to 0 always refresh.
2230 2264 (default: 20)
2231 2265
2232 2266 ``staticurl``
2233 2267 Base URL to use for static files. If unset, static files (e.g. the
2234 2268 hgicon.png favicon) will be served by the CGI script itself. Use
2235 2269 this setting to serve them directly with the HTTP server.
2236 2270 Example: ``http://hgserver/static/``.
2237 2271
2238 2272 ``stripes``
2239 2273 How many lines a "zebra stripe" should span in multi-line output.
2240 2274 Set to 0 to disable. (default: 1)
2241 2275
2242 2276 ``style``
2243 2277 Which template map style to use. The available options are the names of
2244 2278 subdirectories in the HTML templates path. (default: ``paper``)
2245 2279 Example: ``monoblue``.
2246 2280
2247 2281 ``templates``
2248 2282 Where to find the HTML templates. The default path to the HTML templates
2249 2283 can be obtained from ``hg debuginstall``.
2250 2284
2251 2285 ``websub``
2252 2286 ----------
2253 2287
2254 2288 Web substitution filter definition. You can use this section to
2255 2289 define a set of regular expression substitution patterns which
2256 2290 let you automatically modify the hgweb server output.
2257 2291
2258 2292 The default hgweb templates only apply these substitution patterns
2259 2293 on the revision description fields. You can apply them anywhere
2260 2294 you want when you create your own templates by adding calls to the
2261 2295 "websub" filter (usually after calling the "escape" filter).
2262 2296
2263 2297 This can be used, for example, to convert issue references to links
2264 2298 to your issue tracker, or to convert "markdown-like" syntax into
2265 2299 HTML (see the examples below).
2266 2300
2267 2301 Each entry in this section names a substitution filter.
2268 2302 The value of each entry defines the substitution expression itself.
2269 2303 The websub expressions follow the old interhg extension syntax,
2270 2304 which in turn imitates the Unix sed replacement syntax::
2271 2305
2272 2306 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2273 2307
2274 2308 You can use any separator other than "/". The final "i" is optional
2275 2309 and indicates that the search must be case insensitive.
2276 2310
2277 2311 Examples::
2278 2312
2279 2313 [websub]
2280 2314 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2281 2315 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2282 2316 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2283 2317
2284 2318 ``worker``
2285 2319 ----------
2286 2320
2287 2321 Parallel master/worker configuration. We currently perform working
2288 2322 directory updates in parallel on Unix-like systems, which greatly
2289 2323 helps performance.
2290 2324
2291 2325 ``numcpus``
2292 2326 Number of CPUs to use for parallel operations. A zero or
2293 2327 negative value is treated as ``use the default``.
2294 2328 (default: 4 or the number of CPUs on the system, whichever is larger)
2295 2329
2296 2330 ``backgroundclose``
2297 2331 Whether to enable closing file handles on background threads during certain
2298 2332 operations. Some platforms aren't very efficient at closing file
2299 2333 handles that have been written or appended to. By performing file closing
2300 2334 on background threads, file write rate can increase substantially.
2301 2335 (default: true on Windows, false elsewhere)
2302 2336
2303 2337 ``backgroundcloseminfilecount``
2304 2338 Minimum number of files required to trigger background file closing.
2305 2339 Operations not writing this many files won't start background close
2306 2340 threads.
2307 2341 (default: 2048)
2308 2342
2309 2343 ``backgroundclosemaxqueue``
2310 2344 The maximum number of opened file handles waiting to be closed in the
2311 2345 background. This option only has an effect if ``backgroundclose`` is
2312 2346 enabled.
2313 2347 (default: 384)
2314 2348
2315 2349 ``backgroundclosethreadcount``
2316 2350 Number of threads to process background file closes. Only relevant if
2317 2351 ``backgroundclose`` is enabled.
2318 2352 (default: 4)
@@ -1,1551 +1,1551 b''
1 1 Test basic extension support
2 2
3 3 $ cat > foobar.py <<EOF
4 4 > import os
5 5 > from mercurial import cmdutil, commands
6 6 > cmdtable = {}
7 7 > command = cmdutil.command(cmdtable)
8 8 > def uisetup(ui):
9 9 > ui.write("uisetup called\\n")
10 10 > ui.flush()
11 11 > def reposetup(ui, repo):
12 12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
13 13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
14 14 > ui.flush()
15 15 > @command('foo', [], 'hg foo')
16 16 > def foo(ui, *args, **kwargs):
17 17 > ui.write("Foo\\n")
18 18 > @command('bar', [], 'hg bar', norepo=True)
19 19 > def bar(ui, *args, **kwargs):
20 20 > ui.write("Bar\\n")
21 21 > EOF
22 22 $ abspath=`pwd`/foobar.py
23 23
24 24 $ mkdir barfoo
25 25 $ cp foobar.py barfoo/__init__.py
26 26 $ barfoopath=`pwd`/barfoo
27 27
28 28 $ hg init a
29 29 $ cd a
30 30 $ echo foo > file
31 31 $ hg add file
32 32 $ hg commit -m 'add file'
33 33
34 34 $ echo '[extensions]' >> $HGRCPATH
35 35 $ echo "foobar = $abspath" >> $HGRCPATH
36 36 $ hg foo
37 37 uisetup called
38 38 reposetup called for a
39 39 ui == repo.ui
40 40 Foo
41 41
42 42 $ cd ..
43 43 $ hg clone a b
44 44 uisetup called
45 45 reposetup called for a
46 46 ui == repo.ui
47 47 reposetup called for b
48 48 ui == repo.ui
49 49 updating to branch default
50 50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 51
52 52 $ hg bar
53 53 uisetup called
54 54 Bar
55 55 $ echo 'foobar = !' >> $HGRCPATH
56 56
57 57 module/__init__.py-style
58 58
59 59 $ echo "barfoo = $barfoopath" >> $HGRCPATH
60 60 $ cd a
61 61 $ hg foo
62 62 uisetup called
63 63 reposetup called for a
64 64 ui == repo.ui
65 65 Foo
66 66 $ echo 'barfoo = !' >> $HGRCPATH
67 67
68 68 Check that extensions are loaded in phases:
69 69
70 70 $ cat > foo.py <<EOF
71 71 > import os
72 72 > name = os.path.basename(__file__).rsplit('.', 1)[0]
73 73 > print "1) %s imported" % name
74 74 > def uisetup(ui):
75 75 > print "2) %s uisetup" % name
76 76 > def extsetup():
77 77 > print "3) %s extsetup" % name
78 78 > def reposetup(ui, repo):
79 79 > print "4) %s reposetup" % name
80 80 > EOF
81 81
82 82 $ cp foo.py bar.py
83 83 $ echo 'foo = foo.py' >> $HGRCPATH
84 84 $ echo 'bar = bar.py' >> $HGRCPATH
85 85
86 86 Command with no output, we just want to see the extensions loaded:
87 87
88 88 $ hg paths
89 89 1) foo imported
90 90 1) bar imported
91 91 2) foo uisetup
92 92 2) bar uisetup
93 93 3) foo extsetup
94 94 3) bar extsetup
95 95 4) foo reposetup
96 96 4) bar reposetup
97 97
98 98 Check hgweb's load order:
99 99
100 100 $ cat > hgweb.cgi <<EOF
101 101 > #!/usr/bin/env python
102 102 > from mercurial import demandimport; demandimport.enable()
103 103 > from mercurial.hgweb import hgweb
104 104 > from mercurial.hgweb import wsgicgi
105 105 > application = hgweb('.', 'test repo')
106 106 > wsgicgi.launch(application)
107 107 > EOF
108 108
109 109 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
110 110 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
111 111 > | grep '^[0-9]) ' # ignores HTML output
112 112 1) foo imported
113 113 1) bar imported
114 114 2) foo uisetup
115 115 2) bar uisetup
116 116 3) foo extsetup
117 117 3) bar extsetup
118 118 4) foo reposetup
119 119 4) bar reposetup
120 120
121 121 $ echo 'foo = !' >> $HGRCPATH
122 122 $ echo 'bar = !' >> $HGRCPATH
123 123
124 124 Check "from __future__ import absolute_import" support for external libraries
125 125
126 126 #if windows
127 127 $ PATHSEP=";"
128 128 #else
129 129 $ PATHSEP=":"
130 130 #endif
131 131 $ export PATHSEP
132 132
133 133 $ mkdir $TESTTMP/libroot
134 134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
135 135 $ mkdir $TESTTMP/libroot/mod
136 136 $ touch $TESTTMP/libroot/mod/__init__.py
137 137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
138 138
139 139 #if absimport
140 140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
141 141 > from __future__ import absolute_import
142 142 > import ambig # should load "libroot/ambig.py"
143 143 > s = ambig.s
144 144 > EOF
145 145 $ cat > loadabs.py <<EOF
146 146 > import mod.ambigabs as ambigabs
147 147 > def extsetup():
148 148 > print 'ambigabs.s=%s' % ambigabs.s
149 149 > EOF
150 150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
151 151 ambigabs.s=libroot/ambig.py
152 152 $TESTTMP/a (glob)
153 153 #endif
154 154
155 155 #if no-py3k
156 156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
157 157 > import ambig # should load "libroot/mod/ambig.py"
158 158 > s = ambig.s
159 159 > EOF
160 160 $ cat > loadrel.py <<EOF
161 161 > import mod.ambigrel as ambigrel
162 162 > def extsetup():
163 163 > print 'ambigrel.s=%s' % ambigrel.s
164 164 > EOF
165 165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
166 166 ambigrel.s=libroot/mod/ambig.py
167 167 $TESTTMP/a (glob)
168 168 #endif
169 169
170 170 Check absolute/relative import of extension specific modules
171 171
172 172 $ mkdir $TESTTMP/extroot
173 173 $ cat > $TESTTMP/extroot/bar.py <<EOF
174 174 > s = 'this is extroot.bar'
175 175 > EOF
176 176 $ mkdir $TESTTMP/extroot/sub1
177 177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
178 178 > s = 'this is extroot.sub1.__init__'
179 179 > EOF
180 180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
181 181 > s = 'this is extroot.sub1.baz'
182 182 > EOF
183 183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
184 184 > s = 'this is extroot.__init__'
185 185 > import foo
186 186 > def extsetup(ui):
187 187 > ui.write('(extroot) ', foo.func(), '\n')
188 188 > ui.flush()
189 189 > EOF
190 190
191 191 $ cat > $TESTTMP/extroot/foo.py <<EOF
192 192 > # test absolute import
193 193 > buf = []
194 194 > def func():
195 195 > # "not locals" case
196 196 > import extroot.bar
197 197 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
198 198 > return '\n(extroot) '.join(buf)
199 199 > # "fromlist == ('*',)" case
200 200 > from extroot.bar import *
201 201 > buf.append('from extroot.bar import *: %s' % s)
202 202 > # "not fromlist" and "if '.' in name" case
203 203 > import extroot.sub1.baz
204 204 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
205 205 > # "not fromlist" and NOT "if '.' in name" case
206 206 > import extroot
207 207 > buf.append('import extroot: %s' % extroot.s)
208 208 > # NOT "not fromlist" and NOT "level != -1" case
209 209 > from extroot.bar import s
210 210 > buf.append('from extroot.bar import s: %s' % s)
211 211 > EOF
212 212 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
213 213 (extroot) from extroot.bar import *: this is extroot.bar
214 214 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
215 215 (extroot) import extroot: this is extroot.__init__
216 216 (extroot) from extroot.bar import s: this is extroot.bar
217 217 (extroot) import extroot.bar in func(): this is extroot.bar
218 218 $TESTTMP/a (glob)
219 219
220 220 #if no-py3k
221 221 $ rm "$TESTTMP"/extroot/foo.*
222 222 $ cat > $TESTTMP/extroot/foo.py <<EOF
223 223 > # test relative import
224 224 > buf = []
225 225 > def func():
226 226 > # "not locals" case
227 227 > import bar
228 228 > buf.append('import bar in func(): %s' % bar.s)
229 229 > return '\n(extroot) '.join(buf)
230 230 > # "fromlist == ('*',)" case
231 231 > from bar import *
232 232 > buf.append('from bar import *: %s' % s)
233 233 > # "not fromlist" and "if '.' in name" case
234 234 > import sub1.baz
235 235 > buf.append('import sub1.baz: %s' % sub1.baz.s)
236 236 > # "not fromlist" and NOT "if '.' in name" case
237 237 > import sub1
238 238 > buf.append('import sub1: %s' % sub1.s)
239 239 > # NOT "not fromlist" and NOT "level != -1" case
240 240 > from bar import s
241 241 > buf.append('from bar import s: %s' % s)
242 242 > EOF
243 243 $ hg --config extensions.extroot=$TESTTMP/extroot root
244 244 (extroot) from bar import *: this is extroot.bar
245 245 (extroot) import sub1.baz: this is extroot.sub1.baz
246 246 (extroot) import sub1: this is extroot.sub1.__init__
247 247 (extroot) from bar import s: this is extroot.bar
248 248 (extroot) import bar in func(): this is extroot.bar
249 249 $TESTTMP/a (glob)
250 250 #endif
251 251
252 252 #if demandimport absimport
253 253
254 254 Examine whether module loading is delayed until actual referring, even
255 255 though module is imported with "absolute_import" feature.
256 256
257 257 Files below in each packages are used for described purpose:
258 258
259 259 - "called": examine whether "from MODULE import ATTR" works correctly
260 260 - "unused": examine whether loading is delayed correctly
261 261 - "used": examine whether "from PACKAGE import MODULE" works correctly
262 262
263 263 Package hierarchy is needed to examine whether demand importing works
264 264 as expected for "from SUB.PACK.AGE import MODULE".
265 265
266 266 Setup "external library" to be imported with "absolute_import"
267 267 feature.
268 268
269 269 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
270 270 $ touch $TESTTMP/extlibroot/__init__.py
271 271 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
272 272 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
273 273
274 274 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<EOF
275 275 > def func():
276 276 > return "this is extlibroot.lsub1.lsub2.called.func()"
277 277 > EOF
278 278 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<EOF
279 279 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
280 280 > EOF
281 281 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<EOF
282 282 > detail = "this is extlibroot.lsub1.lsub2.used"
283 283 > EOF
284 284
285 285 Setup sub-package of "external library", which causes instantiation of
286 286 demandmod in "recurse down the module chain" code path. Relative
287 287 importing with "absolute_import" feature isn't tested, because "level
288 288 >=1 " doesn't cause instantiation of demandmod.
289 289
290 290 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
291 291 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<EOF
292 292 > detail = "this is extlibroot.recursedown.abs.used"
293 293 > EOF
294 294 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<EOF
295 295 > from __future__ import absolute_import
296 296 > from extlibroot.recursedown.abs.used import detail
297 297 > EOF
298 298
299 299 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
300 300 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<EOF
301 301 > detail = "this is extlibroot.recursedown.legacy.used"
302 302 > EOF
303 303 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<EOF
304 304 > # legacy style (level == -1) import
305 305 > from extlibroot.recursedown.legacy.used import detail
306 306 > EOF
307 307
308 308 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<EOF
309 309 > from __future__ import absolute_import
310 310 > from extlibroot.recursedown.abs import detail as absdetail
311 311 > from .legacy import detail as legacydetail
312 312 > EOF
313 313
314 314 Setup extension local modules to be imported with "absolute_import"
315 315 feature.
316 316
317 317 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
318 318 $ touch $TESTTMP/absextroot/xsub1/__init__.py
319 319 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
320 320
321 321 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<EOF
322 322 > def func():
323 323 > return "this is absextroot.xsub1.xsub2.called.func()"
324 324 > EOF
325 325 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<EOF
326 326 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
327 327 > EOF
328 328 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<EOF
329 329 > detail = "this is absextroot.xsub1.xsub2.used"
330 330 > EOF
331 331
332 332 Setup extension local modules to examine whether demand importing
333 333 works as expected in "level > 1" case.
334 334
335 335 $ cat > $TESTTMP/absextroot/relimportee.py <<EOF
336 336 > detail = "this is absextroot.relimportee"
337 337 > EOF
338 338 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<EOF
339 339 > from __future__ import absolute_import
340 340 > from ... import relimportee
341 341 > detail = "this relimporter imports %r" % (relimportee.detail)
342 342 > EOF
343 343
344 344 Setup modules, which actually import extension local modules at
345 345 runtime.
346 346
347 347 $ cat > $TESTTMP/absextroot/absolute.py << EOF
348 348 > from __future__ import absolute_import
349 349 >
350 350 > # import extension local modules absolutely (level = 0)
351 351 > from absextroot.xsub1.xsub2 import used, unused
352 352 > from absextroot.xsub1.xsub2.called import func
353 353 >
354 354 > def getresult():
355 355 > result = []
356 356 > result.append(used.detail)
357 357 > result.append(func())
358 358 > return result
359 359 > EOF
360 360
361 361 $ cat > $TESTTMP/absextroot/relative.py << EOF
362 362 > from __future__ import absolute_import
363 363 >
364 364 > # import extension local modules relatively (level == 1)
365 365 > from .xsub1.xsub2 import used, unused
366 366 > from .xsub1.xsub2.called import func
367 367 >
368 368 > # import a module, which implies "importing with level > 1"
369 369 > from .xsub1.xsub2 import relimporter
370 370 >
371 371 > def getresult():
372 372 > result = []
373 373 > result.append(used.detail)
374 374 > result.append(func())
375 375 > result.append(relimporter.detail)
376 376 > return result
377 377 > EOF
378 378
379 379 Setup main procedure of extension.
380 380
381 381 $ cat > $TESTTMP/absextroot/__init__.py <<EOF
382 382 > from __future__ import absolute_import
383 383 > from mercurial import cmdutil
384 384 > cmdtable = {}
385 385 > command = cmdutil.command(cmdtable)
386 386 >
387 387 > # "absolute" and "relative" shouldn't be imported before actual
388 388 > # command execution, because (1) they import same modules, and (2)
389 389 > # preceding import (= instantiate "demandmod" object instead of
390 390 > # real "module" object) might hide problem of succeeding import.
391 391 >
392 392 > @command('showabsolute', [], norepo=True)
393 393 > def showabsolute(ui, *args, **opts):
394 394 > from absextroot import absolute
395 395 > ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult()))
396 396 >
397 397 > @command('showrelative', [], norepo=True)
398 398 > def showrelative(ui, *args, **opts):
399 399 > from . import relative
400 400 > ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult()))
401 401 >
402 402 > # import modules from external library
403 403 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
404 404 > from extlibroot.lsub1.lsub2.called import func as lfunc
405 405 > from extlibroot.recursedown import absdetail, legacydetail
406 406 >
407 407 > def uisetup(ui):
408 408 > result = []
409 409 > result.append(lused.detail)
410 410 > result.append(lfunc())
411 411 > result.append(absdetail)
412 412 > result.append(legacydetail)
413 413 > ui.write('LIB: %s\n' % '\nLIB: '.join(result))
414 414 > EOF
415 415
416 416 Examine module importing.
417 417
418 418 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
419 419 LIB: this is extlibroot.lsub1.lsub2.used
420 420 LIB: this is extlibroot.lsub1.lsub2.called.func()
421 421 LIB: this is extlibroot.recursedown.abs.used
422 422 LIB: this is extlibroot.recursedown.legacy.used
423 423 ABS: this is absextroot.xsub1.xsub2.used
424 424 ABS: this is absextroot.xsub1.xsub2.called.func()
425 425
426 426 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
427 427 LIB: this is extlibroot.lsub1.lsub2.used
428 428 LIB: this is extlibroot.lsub1.lsub2.called.func()
429 429 LIB: this is extlibroot.recursedown.abs.used
430 430 LIB: this is extlibroot.recursedown.legacy.used
431 431 REL: this is absextroot.xsub1.xsub2.used
432 432 REL: this is absextroot.xsub1.xsub2.called.func()
433 433 REL: this relimporter imports 'this is absextroot.relimportee'
434 434
435 435 Examine whether sub-module is imported relatively as expected.
436 436
437 437 See also issue5208 for detail about example case on Python 3.x.
438 438
439 439 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
440 440 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
441 441
442 442 $ cat > $TESTTMP/notexist.py <<EOF
443 443 > text = 'notexist.py at root is loaded unintentionally\n'
444 444 > EOF
445 445
446 446 $ cat > $TESTTMP/checkrelativity.py <<EOF
447 447 > from mercurial import cmdutil
448 448 > cmdtable = {}
449 449 > command = cmdutil.command(cmdtable)
450 450 >
451 451 > # demand import avoids failure of importing notexist here
452 452 > import extlibroot.lsub1.lsub2.notexist
453 453 >
454 454 > @command('checkrelativity', [], norepo=True)
455 455 > def checkrelativity(ui, *args, **opts):
456 456 > try:
457 457 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
458 458 > return 1 # unintentional success
459 459 > except ImportError:
460 460 > pass # intentional failure
461 461 > EOF
462 462
463 463 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
464 464
465 465 #endif
466 466
467 467 $ cd ..
468 468
469 469 hide outer repo
470 470 $ hg init
471 471
472 472 $ cat > empty.py <<EOF
473 473 > '''empty cmdtable
474 474 > '''
475 475 > cmdtable = {}
476 476 > EOF
477 477 $ emptypath=`pwd`/empty.py
478 478 $ echo "empty = $emptypath" >> $HGRCPATH
479 479 $ hg help empty
480 480 empty extension - empty cmdtable
481 481
482 482 no commands defined
483 483
484 484
485 485 $ echo 'empty = !' >> $HGRCPATH
486 486
487 487 $ cat > debugextension.py <<EOF
488 488 > '''only debugcommands
489 489 > '''
490 490 > from mercurial import cmdutil
491 491 > cmdtable = {}
492 492 > command = cmdutil.command(cmdtable)
493 493 > @command('debugfoobar', [], 'hg debugfoobar')
494 494 > def debugfoobar(ui, repo, *args, **opts):
495 495 > "yet another debug command"
496 496 > pass
497 497 > @command('foo', [], 'hg foo')
498 498 > def foo(ui, repo, *args, **opts):
499 499 > """yet another foo command
500 500 > This command has been DEPRECATED since forever.
501 501 > """
502 502 > pass
503 503 > EOF
504 504 $ debugpath=`pwd`/debugextension.py
505 505 $ echo "debugextension = $debugpath" >> $HGRCPATH
506 506
507 507 $ hg help debugextension
508 508 hg debugextensions
509 509
510 510 show information about active extensions
511 511
512 512 options:
513 513
514 514 (some details hidden, use --verbose to show complete help)
515 515
516 516
517 517 $ hg --verbose help debugextension
518 518 hg debugextensions
519 519
520 520 show information about active extensions
521 521
522 522 options:
523 523
524 524 -T --template TEMPLATE display with template (EXPERIMENTAL)
525 525
526 526 global options ([+] can be repeated):
527 527
528 528 -R --repository REPO repository root directory or name of overlay bundle
529 529 file
530 530 --cwd DIR change working directory
531 531 -y --noninteractive do not prompt, automatically pick the first choice for
532 532 all prompts
533 533 -q --quiet suppress output
534 534 -v --verbose enable additional output
535 535 --color TYPE when to colorize (boolean, always, auto, never, or
536 debug) (EXPERIMENTAL)
536 debug)
537 537 --config CONFIG [+] set/override config option (use 'section.name=value')
538 538 --debug enable debugging output
539 539 --debugger start debugger
540 540 --encoding ENCODE set the charset encoding (default: ascii)
541 541 --encodingmode MODE set the charset encoding mode (default: strict)
542 542 --traceback always print a traceback on exception
543 543 --time time how long the command takes
544 544 --profile print command execution profile
545 545 --version output version information and exit
546 546 -h --help display help and exit
547 547 --hidden consider hidden changesets
548 548 --pager TYPE when to paginate (boolean, always, auto, or never)
549 549 (default: auto)
550 550
551 551
552 552
553 553
554 554
555 555
556 556 $ hg --debug help debugextension
557 557 hg debugextensions
558 558
559 559 show information about active extensions
560 560
561 561 options:
562 562
563 563 -T --template TEMPLATE display with template (EXPERIMENTAL)
564 564
565 565 global options ([+] can be repeated):
566 566
567 567 -R --repository REPO repository root directory or name of overlay bundle
568 568 file
569 569 --cwd DIR change working directory
570 570 -y --noninteractive do not prompt, automatically pick the first choice for
571 571 all prompts
572 572 -q --quiet suppress output
573 573 -v --verbose enable additional output
574 574 --color TYPE when to colorize (boolean, always, auto, never, or
575 debug) (EXPERIMENTAL)
575 debug)
576 576 --config CONFIG [+] set/override config option (use 'section.name=value')
577 577 --debug enable debugging output
578 578 --debugger start debugger
579 579 --encoding ENCODE set the charset encoding (default: ascii)
580 580 --encodingmode MODE set the charset encoding mode (default: strict)
581 581 --traceback always print a traceback on exception
582 582 --time time how long the command takes
583 583 --profile print command execution profile
584 584 --version output version information and exit
585 585 -h --help display help and exit
586 586 --hidden consider hidden changesets
587 587 --pager TYPE when to paginate (boolean, always, auto, or never)
588 588 (default: auto)
589 589
590 590
591 591
592 592
593 593
594 594 $ echo 'debugextension = !' >> $HGRCPATH
595 595
596 596 Asking for help about a deprecated extension should do something useful:
597 597
598 598 $ hg help glog
599 599 'glog' is provided by the following extension:
600 600
601 601 graphlog command to view revision graphs from a shell (DEPRECATED)
602 602
603 603 (use 'hg help extensions' for information on enabling extensions)
604 604
605 605 Extension module help vs command help:
606 606
607 607 $ echo 'extdiff =' >> $HGRCPATH
608 608 $ hg help extdiff
609 609 hg extdiff [OPT]... [FILE]...
610 610
611 611 use external program to diff repository (or selected files)
612 612
613 613 Show differences between revisions for the specified files, using an
614 614 external program. The default program used is diff, with default options
615 615 "-Npru".
616 616
617 617 To select a different program, use the -p/--program option. The program
618 618 will be passed the names of two directories to compare. To pass additional
619 619 options to the program, use -o/--option. These will be passed before the
620 620 names of the directories to compare.
621 621
622 622 When two revision arguments are given, then changes are shown between
623 623 those revisions. If only one revision is specified then that revision is
624 624 compared to the working directory, and, when no revisions are specified,
625 625 the working directory files are compared to its parent.
626 626
627 627 (use 'hg help -e extdiff' to show help for the extdiff extension)
628 628
629 629 options ([+] can be repeated):
630 630
631 631 -p --program CMD comparison program to run
632 632 -o --option OPT [+] pass option to comparison program
633 633 -r --rev REV [+] revision
634 634 -c --change REV change made by revision
635 635 --patch compare patches for two revisions
636 636 -I --include PATTERN [+] include names matching the given patterns
637 637 -X --exclude PATTERN [+] exclude names matching the given patterns
638 638 -S --subrepos recurse into subrepositories
639 639
640 640 (some details hidden, use --verbose to show complete help)
641 641
642 642
643 643
644 644
645 645
646 646
647 647
648 648
649 649
650 650
651 651 $ hg help --extension extdiff
652 652 extdiff extension - command to allow external programs to compare revisions
653 653
654 654 The extdiff Mercurial extension allows you to use external programs to compare
655 655 revisions, or revision with working directory. The external diff programs are
656 656 called with a configurable set of options and two non-option arguments: paths
657 657 to directories containing snapshots of files to compare.
658 658
659 659 The extdiff extension also allows you to configure new diff commands, so you
660 660 do not need to type 'hg extdiff -p kdiff3' always.
661 661
662 662 [extdiff]
663 663 # add new command that runs GNU diff(1) in 'context diff' mode
664 664 cdiff = gdiff -Nprc5
665 665 ## or the old way:
666 666 #cmd.cdiff = gdiff
667 667 #opts.cdiff = -Nprc5
668 668
669 669 # add new command called meld, runs meld (no need to name twice). If
670 670 # the meld executable is not available, the meld tool in [merge-tools]
671 671 # will be used, if available
672 672 meld =
673 673
674 674 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
675 675 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
676 676 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
677 677 # your .vimrc
678 678 vimdiff = gvim -f "+next" \
679 679 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
680 680
681 681 Tool arguments can include variables that are expanded at runtime:
682 682
683 683 $parent1, $plabel1 - filename, descriptive label of first parent
684 684 $child, $clabel - filename, descriptive label of child revision
685 685 $parent2, $plabel2 - filename, descriptive label of second parent
686 686 $root - repository root
687 687 $parent is an alias for $parent1.
688 688
689 689 The extdiff extension will look in your [diff-tools] and [merge-tools]
690 690 sections for diff tool arguments, when none are specified in [extdiff].
691 691
692 692 [extdiff]
693 693 kdiff3 =
694 694
695 695 [diff-tools]
696 696 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
697 697
698 698 You can use -I/-X and list of file or directory names like normal 'hg diff'
699 699 command. The extdiff extension makes snapshots of only needed files, so
700 700 running the external diff program will actually be pretty fast (at least
701 701 faster than having to compare the entire tree).
702 702
703 703 list of commands:
704 704
705 705 extdiff use external program to diff repository (or selected files)
706 706
707 707 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
708 708
709 709
710 710
711 711
712 712
713 713
714 714
715 715
716 716
717 717
718 718
719 719
720 720
721 721
722 722
723 723
724 724 $ echo 'extdiff = !' >> $HGRCPATH
725 725
726 726 Test help topic with same name as extension
727 727
728 728 $ cat > multirevs.py <<EOF
729 729 > from mercurial import cmdutil, commands
730 730 > cmdtable = {}
731 731 > command = cmdutil.command(cmdtable)
732 732 > """multirevs extension
733 733 > Big multi-line module docstring."""
734 734 > @command('multirevs', [], 'ARG', norepo=True)
735 735 > def multirevs(ui, repo, arg, *args, **opts):
736 736 > """multirevs command"""
737 737 > pass
738 738 > EOF
739 739 $ echo "multirevs = multirevs.py" >> $HGRCPATH
740 740
741 741 $ hg help multirevs | tail
742 742 bookmark (this works because the last revision of the revset is used):
743 743
744 744 hg update :@
745 745
746 746 - Show diff between tags 1.3 and 1.5 (this works because the first and the
747 747 last revisions of the revset are used):
748 748
749 749 hg diff -r 1.3::1.5
750 750
751 751 use 'hg help -c multirevs' to see help for the multirevs command
752 752
753 753
754 754
755 755
756 756
757 757
758 758 $ hg help -c multirevs
759 759 hg multirevs ARG
760 760
761 761 multirevs command
762 762
763 763 (some details hidden, use --verbose to show complete help)
764 764
765 765
766 766
767 767 $ hg multirevs
768 768 hg multirevs: invalid arguments
769 769 hg multirevs ARG
770 770
771 771 multirevs command
772 772
773 773 (use 'hg multirevs -h' to show more help)
774 774 [255]
775 775
776 776
777 777
778 778 $ echo "multirevs = !" >> $HGRCPATH
779 779
780 780 Issue811: Problem loading extensions twice (by site and by user)
781 781
782 782 $ cat <<EOF >> $HGRCPATH
783 783 > mq =
784 784 > strip =
785 785 > hgext.mq =
786 786 > hgext/mq =
787 787 > EOF
788 788
789 789 Show extensions:
790 790 (note that mq force load strip, also checking it's not loaded twice)
791 791
792 792 $ hg debugextensions
793 793 mq
794 794 strip
795 795
796 796 For extensions, which name matches one of its commands, help
797 797 message should ask '-v -e' to get list of built-in aliases
798 798 along with extension help itself
799 799
800 800 $ mkdir $TESTTMP/d
801 801 $ cat > $TESTTMP/d/dodo.py <<EOF
802 802 > """
803 803 > This is an awesome 'dodo' extension. It does nothing and
804 804 > writes 'Foo foo'
805 805 > """
806 806 > from mercurial import cmdutil, commands
807 807 > cmdtable = {}
808 808 > command = cmdutil.command(cmdtable)
809 809 > @command('dodo', [], 'hg dodo')
810 810 > def dodo(ui, *args, **kwargs):
811 811 > """Does nothing"""
812 812 > ui.write("I do nothing. Yay\\n")
813 813 > @command('foofoo', [], 'hg foofoo')
814 814 > def foofoo(ui, *args, **kwargs):
815 815 > """Writes 'Foo foo'"""
816 816 > ui.write("Foo foo\\n")
817 817 > EOF
818 818 $ dodopath=$TESTTMP/d/dodo.py
819 819
820 820 $ echo "dodo = $dodopath" >> $HGRCPATH
821 821
822 822 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
823 823 $ hg help -e dodo
824 824 dodo extension -
825 825
826 826 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
827 827
828 828 list of commands:
829 829
830 830 dodo Does nothing
831 831 foofoo Writes 'Foo foo'
832 832
833 833 (use 'hg help -v -e dodo' to show built-in aliases and global options)
834 834
835 835 Make sure that '-v -e' prints list of built-in aliases along with
836 836 extension help itself
837 837 $ hg help -v -e dodo
838 838 dodo extension -
839 839
840 840 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
841 841
842 842 list of commands:
843 843
844 844 dodo Does nothing
845 845 foofoo Writes 'Foo foo'
846 846
847 847 global options ([+] can be repeated):
848 848
849 849 -R --repository REPO repository root directory or name of overlay bundle
850 850 file
851 851 --cwd DIR change working directory
852 852 -y --noninteractive do not prompt, automatically pick the first choice for
853 853 all prompts
854 854 -q --quiet suppress output
855 855 -v --verbose enable additional output
856 856 --color TYPE when to colorize (boolean, always, auto, never, or
857 debug) (EXPERIMENTAL)
857 debug)
858 858 --config CONFIG [+] set/override config option (use 'section.name=value')
859 859 --debug enable debugging output
860 860 --debugger start debugger
861 861 --encoding ENCODE set the charset encoding (default: ascii)
862 862 --encodingmode MODE set the charset encoding mode (default: strict)
863 863 --traceback always print a traceback on exception
864 864 --time time how long the command takes
865 865 --profile print command execution profile
866 866 --version output version information and exit
867 867 -h --help display help and exit
868 868 --hidden consider hidden changesets
869 869 --pager TYPE when to paginate (boolean, always, auto, or never)
870 870 (default: auto)
871 871
872 872 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
873 873 $ hg help -v dodo
874 874 hg dodo
875 875
876 876 Does nothing
877 877
878 878 (use 'hg help -e dodo' to show help for the dodo extension)
879 879
880 880 options:
881 881
882 882 --mq operate on patch repository
883 883
884 884 global options ([+] can be repeated):
885 885
886 886 -R --repository REPO repository root directory or name of overlay bundle
887 887 file
888 888 --cwd DIR change working directory
889 889 -y --noninteractive do not prompt, automatically pick the first choice for
890 890 all prompts
891 891 -q --quiet suppress output
892 892 -v --verbose enable additional output
893 893 --color TYPE when to colorize (boolean, always, auto, never, or
894 debug) (EXPERIMENTAL)
894 debug)
895 895 --config CONFIG [+] set/override config option (use 'section.name=value')
896 896 --debug enable debugging output
897 897 --debugger start debugger
898 898 --encoding ENCODE set the charset encoding (default: ascii)
899 899 --encodingmode MODE set the charset encoding mode (default: strict)
900 900 --traceback always print a traceback on exception
901 901 --time time how long the command takes
902 902 --profile print command execution profile
903 903 --version output version information and exit
904 904 -h --help display help and exit
905 905 --hidden consider hidden changesets
906 906 --pager TYPE when to paginate (boolean, always, auto, or never)
907 907 (default: auto)
908 908
909 909 In case when extension name doesn't match any of its commands,
910 910 help message should ask for '-v' to get list of built-in aliases
911 911 along with extension help
912 912 $ cat > $TESTTMP/d/dudu.py <<EOF
913 913 > """
914 914 > This is an awesome 'dudu' extension. It does something and
915 915 > also writes 'Beep beep'
916 916 > """
917 917 > from mercurial import cmdutil, commands
918 918 > cmdtable = {}
919 919 > command = cmdutil.command(cmdtable)
920 920 > @command('something', [], 'hg something')
921 921 > def something(ui, *args, **kwargs):
922 922 > """Does something"""
923 923 > ui.write("I do something. Yaaay\\n")
924 924 > @command('beep', [], 'hg beep')
925 925 > def beep(ui, *args, **kwargs):
926 926 > """Writes 'Beep beep'"""
927 927 > ui.write("Beep beep\\n")
928 928 > EOF
929 929 $ dudupath=$TESTTMP/d/dudu.py
930 930
931 931 $ echo "dudu = $dudupath" >> $HGRCPATH
932 932
933 933 $ hg help -e dudu
934 934 dudu extension -
935 935
936 936 This is an awesome 'dudu' extension. It does something and also writes 'Beep
937 937 beep'
938 938
939 939 list of commands:
940 940
941 941 beep Writes 'Beep beep'
942 942 something Does something
943 943
944 944 (use 'hg help -v dudu' to show built-in aliases and global options)
945 945
946 946 In case when extension name doesn't match any of its commands,
947 947 help options '-v' and '-v -e' should be equivalent
948 948 $ hg help -v dudu
949 949 dudu extension -
950 950
951 951 This is an awesome 'dudu' extension. It does something and also writes 'Beep
952 952 beep'
953 953
954 954 list of commands:
955 955
956 956 beep Writes 'Beep beep'
957 957 something Does something
958 958
959 959 global options ([+] can be repeated):
960 960
961 961 -R --repository REPO repository root directory or name of overlay bundle
962 962 file
963 963 --cwd DIR change working directory
964 964 -y --noninteractive do not prompt, automatically pick the first choice for
965 965 all prompts
966 966 -q --quiet suppress output
967 967 -v --verbose enable additional output
968 968 --color TYPE when to colorize (boolean, always, auto, never, or
969 debug) (EXPERIMENTAL)
969 debug)
970 970 --config CONFIG [+] set/override config option (use 'section.name=value')
971 971 --debug enable debugging output
972 972 --debugger start debugger
973 973 --encoding ENCODE set the charset encoding (default: ascii)
974 974 --encodingmode MODE set the charset encoding mode (default: strict)
975 975 --traceback always print a traceback on exception
976 976 --time time how long the command takes
977 977 --profile print command execution profile
978 978 --version output version information and exit
979 979 -h --help display help and exit
980 980 --hidden consider hidden changesets
981 981 --pager TYPE when to paginate (boolean, always, auto, or never)
982 982 (default: auto)
983 983
984 984 $ hg help -v -e dudu
985 985 dudu extension -
986 986
987 987 This is an awesome 'dudu' extension. It does something and also writes 'Beep
988 988 beep'
989 989
990 990 list of commands:
991 991
992 992 beep Writes 'Beep beep'
993 993 something Does something
994 994
995 995 global options ([+] can be repeated):
996 996
997 997 -R --repository REPO repository root directory or name of overlay bundle
998 998 file
999 999 --cwd DIR change working directory
1000 1000 -y --noninteractive do not prompt, automatically pick the first choice for
1001 1001 all prompts
1002 1002 -q --quiet suppress output
1003 1003 -v --verbose enable additional output
1004 1004 --color TYPE when to colorize (boolean, always, auto, never, or
1005 debug) (EXPERIMENTAL)
1005 debug)
1006 1006 --config CONFIG [+] set/override config option (use 'section.name=value')
1007 1007 --debug enable debugging output
1008 1008 --debugger start debugger
1009 1009 --encoding ENCODE set the charset encoding (default: ascii)
1010 1010 --encodingmode MODE set the charset encoding mode (default: strict)
1011 1011 --traceback always print a traceback on exception
1012 1012 --time time how long the command takes
1013 1013 --profile print command execution profile
1014 1014 --version output version information and exit
1015 1015 -h --help display help and exit
1016 1016 --hidden consider hidden changesets
1017 1017 --pager TYPE when to paginate (boolean, always, auto, or never)
1018 1018 (default: auto)
1019 1019
1020 1020 Disabled extension commands:
1021 1021
1022 1022 $ ORGHGRCPATH=$HGRCPATH
1023 1023 $ HGRCPATH=
1024 1024 $ export HGRCPATH
1025 1025 $ hg help email
1026 1026 'email' is provided by the following extension:
1027 1027
1028 1028 patchbomb command to send changesets as (a series of) patch emails
1029 1029
1030 1030 (use 'hg help extensions' for information on enabling extensions)
1031 1031
1032 1032
1033 1033 $ hg qdel
1034 1034 hg: unknown command 'qdel'
1035 1035 'qdelete' is provided by the following extension:
1036 1036
1037 1037 mq manage a stack of patches
1038 1038
1039 1039 (use 'hg help extensions' for information on enabling extensions)
1040 1040 [255]
1041 1041
1042 1042
1043 1043 $ hg churn
1044 1044 hg: unknown command 'churn'
1045 1045 'churn' is provided by the following extension:
1046 1046
1047 1047 churn command to display statistics about repository history
1048 1048
1049 1049 (use 'hg help extensions' for information on enabling extensions)
1050 1050 [255]
1051 1051
1052 1052
1053 1053
1054 1054 Disabled extensions:
1055 1055
1056 1056 $ hg help churn
1057 1057 churn extension - command to display statistics about repository history
1058 1058
1059 1059 (use 'hg help extensions' for information on enabling extensions)
1060 1060
1061 1061 $ hg help patchbomb
1062 1062 patchbomb extension - command to send changesets as (a series of) patch emails
1063 1063
1064 1064 The series is started off with a "[PATCH 0 of N]" introduction, which
1065 1065 describes the series as a whole.
1066 1066
1067 1067 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1068 1068 line of the changeset description as the subject text. The message contains
1069 1069 two or three body parts:
1070 1070
1071 1071 - The changeset description.
1072 1072 - [Optional] The result of running diffstat on the patch.
1073 1073 - The patch itself, as generated by 'hg export'.
1074 1074
1075 1075 Each message refers to the first in the series using the In-Reply-To and
1076 1076 References headers, so they will show up as a sequence in threaded mail and
1077 1077 news readers, and in mail archives.
1078 1078
1079 1079 To configure other defaults, add a section like this to your configuration
1080 1080 file:
1081 1081
1082 1082 [email]
1083 1083 from = My Name <my@email>
1084 1084 to = recipient1, recipient2, ...
1085 1085 cc = cc1, cc2, ...
1086 1086 bcc = bcc1, bcc2, ...
1087 1087 reply-to = address1, address2, ...
1088 1088
1089 1089 Use "[patchbomb]" as configuration section name if you need to override global
1090 1090 "[email]" address settings.
1091 1091
1092 1092 Then you can use the 'hg email' command to mail a series of changesets as a
1093 1093 patchbomb.
1094 1094
1095 1095 You can also either configure the method option in the email section to be a
1096 1096 sendmail compatible mailer or fill out the [smtp] section so that the
1097 1097 patchbomb extension can automatically send patchbombs directly from the
1098 1098 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1099 1099
1100 1100 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1101 1101 supply one via configuration or the command line. You can override this to
1102 1102 never prompt by configuring an empty value:
1103 1103
1104 1104 [email]
1105 1105 cc =
1106 1106
1107 1107 You can control the default inclusion of an introduction message with the
1108 1108 "patchbomb.intro" configuration option. The configuration is always
1109 1109 overwritten by command line flags like --intro and --desc:
1110 1110
1111 1111 [patchbomb]
1112 1112 intro=auto # include introduction message if more than 1 patch (default)
1113 1113 intro=never # never include an introduction message
1114 1114 intro=always # always include an introduction message
1115 1115
1116 1116 You can set patchbomb to always ask for confirmation by setting
1117 1117 "patchbomb.confirm" to true.
1118 1118
1119 1119 (use 'hg help extensions' for information on enabling extensions)
1120 1120
1121 1121
1122 1122 Broken disabled extension and command:
1123 1123
1124 1124 $ mkdir hgext
1125 1125 $ echo > hgext/__init__.py
1126 1126 $ cat > hgext/broken.py <<EOF
1127 1127 > "broken extension'
1128 1128 > EOF
1129 1129 $ cat > path.py <<EOF
1130 1130 > import os, sys
1131 1131 > sys.path.insert(0, os.environ['HGEXTPATH'])
1132 1132 > EOF
1133 1133 $ HGEXTPATH=`pwd`
1134 1134 $ export HGEXTPATH
1135 1135
1136 1136 $ hg --config extensions.path=./path.py help broken
1137 1137 broken extension - (no help text available)
1138 1138
1139 1139 (use 'hg help extensions' for information on enabling extensions)
1140 1140
1141 1141
1142 1142 $ cat > hgext/forest.py <<EOF
1143 1143 > cmdtable = None
1144 1144 > EOF
1145 1145 $ hg --config extensions.path=./path.py help foo > /dev/null
1146 1146 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
1147 1147 abort: no such help topic: foo
1148 1148 (try 'hg help --keyword foo')
1149 1149 [255]
1150 1150
1151 1151 $ cat > throw.py <<EOF
1152 1152 > from mercurial import cmdutil, commands, util
1153 1153 > cmdtable = {}
1154 1154 > command = cmdutil.command(cmdtable)
1155 1155 > class Bogon(Exception): pass
1156 1156 > @command('throw', [], 'hg throw', norepo=True)
1157 1157 > def throw(ui, **opts):
1158 1158 > """throws an exception"""
1159 1159 > raise Bogon()
1160 1160 > EOF
1161 1161
1162 1162 No declared supported version, extension complains:
1163 1163 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1164 1164 ** Unknown exception encountered with possibly-broken third-party extension throw
1165 1165 ** which supports versions unknown of Mercurial.
1166 1166 ** Please disable throw and try your action again.
1167 1167 ** If that fixes the bug please report it to the extension author.
1168 1168 ** Python * (glob)
1169 1169 ** Mercurial Distributed SCM * (glob)
1170 1170 ** Extensions loaded: throw
1171 1171
1172 1172 empty declaration of supported version, extension complains:
1173 1173 $ echo "testedwith = ''" >> throw.py
1174 1174 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1175 1175 ** Unknown exception encountered with possibly-broken third-party extension throw
1176 1176 ** which supports versions unknown of Mercurial.
1177 1177 ** Please disable throw and try your action again.
1178 1178 ** If that fixes the bug please report it to the extension author.
1179 1179 ** Python * (glob)
1180 1180 ** Mercurial Distributed SCM (*) (glob)
1181 1181 ** Extensions loaded: throw
1182 1182
1183 1183 If the extension specifies a buglink, show that:
1184 1184 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1185 1185 $ rm -f throw.pyc throw.pyo
1186 1186 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1187 1187 ** Unknown exception encountered with possibly-broken third-party extension throw
1188 1188 ** which supports versions unknown of Mercurial.
1189 1189 ** Please disable throw and try your action again.
1190 1190 ** If that fixes the bug please report it to http://example.com/bts
1191 1191 ** Python * (glob)
1192 1192 ** Mercurial Distributed SCM (*) (glob)
1193 1193 ** Extensions loaded: throw
1194 1194
1195 1195 If the extensions declare outdated versions, accuse the older extension first:
1196 1196 $ echo "from mercurial import util" >> older.py
1197 1197 $ echo "util.version = lambda:'2.2'" >> older.py
1198 1198 $ echo "testedwith = '1.9.3'" >> older.py
1199 1199 $ echo "testedwith = '2.1.1'" >> throw.py
1200 1200 $ rm -f throw.pyc throw.pyo
1201 1201 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1202 1202 > throw 2>&1 | egrep '^\*\*'
1203 1203 ** Unknown exception encountered with possibly-broken third-party extension older
1204 1204 ** which supports versions 1.9 of Mercurial.
1205 1205 ** Please disable older and try your action again.
1206 1206 ** If that fixes the bug please report it to the extension author.
1207 1207 ** Python * (glob)
1208 1208 ** Mercurial Distributed SCM (version 2.2)
1209 1209 ** Extensions loaded: throw, older
1210 1210
1211 1211 One extension only tested with older, one only with newer versions:
1212 1212 $ echo "util.version = lambda:'2.1'" >> older.py
1213 1213 $ rm -f older.pyc older.pyo
1214 1214 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1215 1215 > throw 2>&1 | egrep '^\*\*'
1216 1216 ** Unknown exception encountered with possibly-broken third-party extension older
1217 1217 ** which supports versions 1.9 of Mercurial.
1218 1218 ** Please disable older and try your action again.
1219 1219 ** If that fixes the bug please report it to the extension author.
1220 1220 ** Python * (glob)
1221 1221 ** Mercurial Distributed SCM (version 2.1)
1222 1222 ** Extensions loaded: throw, older
1223 1223
1224 1224 Older extension is tested with current version, the other only with newer:
1225 1225 $ echo "util.version = lambda:'1.9.3'" >> older.py
1226 1226 $ rm -f older.pyc older.pyo
1227 1227 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1228 1228 > throw 2>&1 | egrep '^\*\*'
1229 1229 ** Unknown exception encountered with possibly-broken third-party extension throw
1230 1230 ** which supports versions 2.1 of Mercurial.
1231 1231 ** Please disable throw and try your action again.
1232 1232 ** If that fixes the bug please report it to http://example.com/bts
1233 1233 ** Python * (glob)
1234 1234 ** Mercurial Distributed SCM (version 1.9.3)
1235 1235 ** Extensions loaded: throw, older
1236 1236
1237 1237 Ability to point to a different point
1238 1238 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1239 1239 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1240 1240 ** unknown exception encountered, please report by visiting
1241 1241 ** Your Local Goat Lenders
1242 1242 ** Python * (glob)
1243 1243 ** Mercurial Distributed SCM (*) (glob)
1244 1244 ** Extensions loaded: throw, older
1245 1245
1246 1246 Declare the version as supporting this hg version, show regular bts link:
1247 1247 $ hgver=`hg debuginstall -T '{hgver}'`
1248 1248 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1249 1249 $ if [ -z "$hgver" ]; then
1250 1250 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1251 1251 > fi
1252 1252 $ rm -f throw.pyc throw.pyo
1253 1253 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1254 1254 ** unknown exception encountered, please report by visiting
1255 1255 ** https://mercurial-scm.org/wiki/BugTracker
1256 1256 ** Python * (glob)
1257 1257 ** Mercurial Distributed SCM (*) (glob)
1258 1258 ** Extensions loaded: throw
1259 1259
1260 1260 Patch version is ignored during compatibility check
1261 1261 $ echo "testedwith = '3.2'" >> throw.py
1262 1262 $ echo "util.version = lambda:'3.2.2'" >> throw.py
1263 1263 $ rm -f throw.pyc throw.pyo
1264 1264 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1265 1265 ** unknown exception encountered, please report by visiting
1266 1266 ** https://mercurial-scm.org/wiki/BugTracker
1267 1267 ** Python * (glob)
1268 1268 ** Mercurial Distributed SCM (*) (glob)
1269 1269 ** Extensions loaded: throw
1270 1270
1271 1271 Test version number support in 'hg version':
1272 1272 $ echo '__version__ = (1, 2, 3)' >> throw.py
1273 1273 $ rm -f throw.pyc throw.pyo
1274 1274 $ hg version -v
1275 1275 Mercurial Distributed SCM (version *) (glob)
1276 1276 (see https://mercurial-scm.org for more information)
1277 1277
1278 1278 Copyright (C) 2005-* Matt Mackall and others (glob)
1279 1279 This is free software; see the source for copying conditions. There is NO
1280 1280 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1281 1281
1282 1282 Enabled extensions:
1283 1283
1284 1284
1285 1285 $ hg version -v --config extensions.throw=throw.py
1286 1286 Mercurial Distributed SCM (version *) (glob)
1287 1287 (see https://mercurial-scm.org for more information)
1288 1288
1289 1289 Copyright (C) 2005-* Matt Mackall and others (glob)
1290 1290 This is free software; see the source for copying conditions. There is NO
1291 1291 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1292 1292
1293 1293 Enabled extensions:
1294 1294
1295 1295 throw external 1.2.3
1296 1296 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
1297 1297 $ rm -f throw.pyc throw.pyo
1298 1298 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1299 1299 Mercurial Distributed SCM (version *) (glob)
1300 1300 (see https://mercurial-scm.org for more information)
1301 1301
1302 1302 Copyright (C) 2005-* Matt Mackall and others (glob)
1303 1303 This is free software; see the source for copying conditions. There is NO
1304 1304 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1305 1305
1306 1306 Enabled extensions:
1307 1307
1308 1308 throw external 1.twentythree
1309 1309 strip internal
1310 1310
1311 1311 $ hg version -q --config extensions.throw=throw.py
1312 1312 Mercurial Distributed SCM (version *) (glob)
1313 1313
1314 1314 Test JSON output of version:
1315 1315
1316 1316 $ hg version -Tjson
1317 1317 [
1318 1318 {
1319 1319 "extensions": [],
1320 1320 "ver": "*" (glob)
1321 1321 }
1322 1322 ]
1323 1323
1324 1324 $ hg version --config extensions.throw=throw.py -Tjson
1325 1325 [
1326 1326 {
1327 1327 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1328 1328 "ver": "3.2.2"
1329 1329 }
1330 1330 ]
1331 1331
1332 1332 $ hg version --config extensions.strip= -Tjson
1333 1333 [
1334 1334 {
1335 1335 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1336 1336 "ver": "*" (glob)
1337 1337 }
1338 1338 ]
1339 1339
1340 1340 Test template output of version:
1341 1341
1342 1342 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1343 1343 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1344 1344 throw 1.twentythree (external)
1345 1345 strip (internal)
1346 1346
1347 1347 Refuse to load extensions with minimum version requirements
1348 1348
1349 1349 $ cat > minversion1.py << EOF
1350 1350 > from mercurial import util
1351 1351 > util.version = lambda: '3.5.2'
1352 1352 > minimumhgversion = '3.6'
1353 1353 > EOF
1354 1354 $ hg --config extensions.minversion=minversion1.py version
1355 1355 (third party extension minversion requires version 3.6 or newer of Mercurial; disabling)
1356 1356 Mercurial Distributed SCM (version 3.5.2)
1357 1357 (see https://mercurial-scm.org for more information)
1358 1358
1359 1359 Copyright (C) 2005-* Matt Mackall and others (glob)
1360 1360 This is free software; see the source for copying conditions. There is NO
1361 1361 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1362 1362
1363 1363 $ cat > minversion2.py << EOF
1364 1364 > from mercurial import util
1365 1365 > util.version = lambda: '3.6'
1366 1366 > minimumhgversion = '3.7'
1367 1367 > EOF
1368 1368 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1369 1369 (third party extension minversion requires version 3.7 or newer of Mercurial; disabling)
1370 1370
1371 1371 Can load version that is only off by point release
1372 1372
1373 1373 $ cat > minversion2.py << EOF
1374 1374 > from mercurial import util
1375 1375 > util.version = lambda: '3.6.1'
1376 1376 > minimumhgversion = '3.6'
1377 1377 > EOF
1378 1378 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1379 1379 [1]
1380 1380
1381 1381 Can load minimum version identical to current
1382 1382
1383 1383 $ cat > minversion3.py << EOF
1384 1384 > from mercurial import util
1385 1385 > util.version = lambda: '3.5'
1386 1386 > minimumhgversion = '3.5'
1387 1387 > EOF
1388 1388 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1389 1389 [1]
1390 1390
1391 1391 Restore HGRCPATH
1392 1392
1393 1393 $ HGRCPATH=$ORGHGRCPATH
1394 1394 $ export HGRCPATH
1395 1395
1396 1396 Commands handling multiple repositories at a time should invoke only
1397 1397 "reposetup()" of extensions enabling in the target repository.
1398 1398
1399 1399 $ mkdir reposetup-test
1400 1400 $ cd reposetup-test
1401 1401
1402 1402 $ cat > $TESTTMP/reposetuptest.py <<EOF
1403 1403 > from mercurial import extensions
1404 1404 > def reposetup(ui, repo):
1405 1405 > ui.write('reposetup() for %s\n' % (repo.root))
1406 1406 > ui.flush()
1407 1407 > EOF
1408 1408 $ hg init src
1409 1409 $ echo a > src/a
1410 1410 $ hg -R src commit -Am '#0 at src/a'
1411 1411 adding a
1412 1412 $ echo '[extensions]' >> src/.hg/hgrc
1413 1413 $ echo '# enable extension locally' >> src/.hg/hgrc
1414 1414 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1415 1415 $ hg -R src status
1416 1416 reposetup() for $TESTTMP/reposetup-test/src (glob)
1417 1417
1418 1418 $ hg clone -U src clone-dst1
1419 1419 reposetup() for $TESTTMP/reposetup-test/src (glob)
1420 1420 $ hg init push-dst1
1421 1421 $ hg -q -R src push push-dst1
1422 1422 reposetup() for $TESTTMP/reposetup-test/src (glob)
1423 1423 $ hg init pull-src1
1424 1424 $ hg -q -R pull-src1 pull src
1425 1425 reposetup() for $TESTTMP/reposetup-test/src (glob)
1426 1426
1427 1427 $ cat <<EOF >> $HGRCPATH
1428 1428 > [extensions]
1429 1429 > # disable extension globally and explicitly
1430 1430 > reposetuptest = !
1431 1431 > EOF
1432 1432 $ hg clone -U src clone-dst2
1433 1433 reposetup() for $TESTTMP/reposetup-test/src (glob)
1434 1434 $ hg init push-dst2
1435 1435 $ hg -q -R src push push-dst2
1436 1436 reposetup() for $TESTTMP/reposetup-test/src (glob)
1437 1437 $ hg init pull-src2
1438 1438 $ hg -q -R pull-src2 pull src
1439 1439 reposetup() for $TESTTMP/reposetup-test/src (glob)
1440 1440
1441 1441 $ cat <<EOF >> $HGRCPATH
1442 1442 > [extensions]
1443 1443 > # enable extension globally
1444 1444 > reposetuptest = $TESTTMP/reposetuptest.py
1445 1445 > EOF
1446 1446 $ hg clone -U src clone-dst3
1447 1447 reposetup() for $TESTTMP/reposetup-test/src (glob)
1448 1448 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1449 1449 $ hg init push-dst3
1450 1450 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1451 1451 $ hg -q -R src push push-dst3
1452 1452 reposetup() for $TESTTMP/reposetup-test/src (glob)
1453 1453 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1454 1454 $ hg init pull-src3
1455 1455 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1456 1456 $ hg -q -R pull-src3 pull src
1457 1457 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1458 1458 reposetup() for $TESTTMP/reposetup-test/src (glob)
1459 1459
1460 1460 $ echo '[extensions]' >> src/.hg/hgrc
1461 1461 $ echo '# disable extension locally' >> src/.hg/hgrc
1462 1462 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1463 1463 $ hg clone -U src clone-dst4
1464 1464 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1465 1465 $ hg init push-dst4
1466 1466 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1467 1467 $ hg -q -R src push push-dst4
1468 1468 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1469 1469 $ hg init pull-src4
1470 1470 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1471 1471 $ hg -q -R pull-src4 pull src
1472 1472 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1473 1473
1474 1474 disabling in command line overlays with all configuration
1475 1475 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1476 1476 $ hg --config extensions.reposetuptest=! init push-dst5
1477 1477 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1478 1478 $ hg --config extensions.reposetuptest=! init pull-src5
1479 1479 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1480 1480
1481 1481 $ cat <<EOF >> $HGRCPATH
1482 1482 > [extensions]
1483 1483 > # disable extension globally and explicitly
1484 1484 > reposetuptest = !
1485 1485 > EOF
1486 1486 $ hg init parent
1487 1487 $ hg init parent/sub1
1488 1488 $ echo 1 > parent/sub1/1
1489 1489 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1490 1490 adding 1
1491 1491 $ hg init parent/sub2
1492 1492 $ hg init parent/sub2/sub21
1493 1493 $ echo 21 > parent/sub2/sub21/21
1494 1494 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1495 1495 adding 21
1496 1496 $ cat > parent/sub2/.hgsub <<EOF
1497 1497 > sub21 = sub21
1498 1498 > EOF
1499 1499 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1500 1500 adding .hgsub
1501 1501 $ hg init parent/sub3
1502 1502 $ echo 3 > parent/sub3/3
1503 1503 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1504 1504 adding 3
1505 1505 $ cat > parent/.hgsub <<EOF
1506 1506 > sub1 = sub1
1507 1507 > sub2 = sub2
1508 1508 > sub3 = sub3
1509 1509 > EOF
1510 1510 $ hg -R parent commit -Am '#0 at parent'
1511 1511 adding .hgsub
1512 1512 $ echo '[extensions]' >> parent/.hg/hgrc
1513 1513 $ echo '# enable extension locally' >> parent/.hg/hgrc
1514 1514 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1515 1515 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1516 1516 $ hg -R parent status -S -A
1517 1517 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1518 1518 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1519 1519 C .hgsub
1520 1520 C .hgsubstate
1521 1521 C sub1/1
1522 1522 C sub2/.hgsub
1523 1523 C sub2/.hgsubstate
1524 1524 C sub2/sub21/21
1525 1525 C sub3/3
1526 1526
1527 1527 $ cd ..
1528 1528
1529 1529 Test synopsis and docstring extending
1530 1530
1531 1531 $ hg init exthelp
1532 1532 $ cat > exthelp.py <<EOF
1533 1533 > from mercurial import commands, extensions
1534 1534 > def exbookmarks(orig, *args, **opts):
1535 1535 > return orig(*args, **opts)
1536 1536 > def uisetup(ui):
1537 1537 > synopsis = ' GREPME [--foo] [-x]'
1538 1538 > docstring = '''
1539 1539 > GREPME make sure that this is in the help!
1540 1540 > '''
1541 1541 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1542 1542 > synopsis, docstring)
1543 1543 > EOF
1544 1544 $ abspath=`pwd`/exthelp.py
1545 1545 $ echo '[extensions]' >> $HGRCPATH
1546 1546 $ echo "exthelp = $abspath" >> $HGRCPATH
1547 1547 $ cd exthelp
1548 1548 $ hg help bookmarks | grep GREPME
1549 1549 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1550 1550 GREPME make sure that this is in the help!
1551 1551
@@ -1,3216 +1,3215 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge another revision into working directory
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge another revision into working directory
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 $ hg help
48 48 Mercurial Distributed SCM
49 49
50 50 list of commands:
51 51
52 52 add add the specified files on the next commit
53 53 addremove add all new files, delete all missing files
54 54 annotate show changeset information by line for each file
55 55 archive create an unversioned archive of a repository revision
56 56 backout reverse effect of earlier changeset
57 57 bisect subdivision search of changesets
58 58 bookmarks create a new bookmark or list existing bookmarks
59 59 branch set or show the current branch name
60 60 branches list repository named branches
61 61 bundle create a changegroup file
62 62 cat output the current or given revision of files
63 63 clone make a copy of an existing repository
64 64 commit commit the specified files or all outstanding changes
65 65 config show combined config settings from all hgrc files
66 66 copy mark files as copied for the next commit
67 67 diff diff repository (or selected files)
68 68 export dump the header and diffs for one or more changesets
69 69 files list tracked files
70 70 forget forget the specified files on the next commit
71 71 graft copy changes from other branches onto the current branch
72 72 grep search revision history for a pattern in specified files
73 73 heads show branch heads
74 74 help show help for a given topic or a help overview
75 75 identify identify the working directory or specified revision
76 76 import import an ordered set of patches
77 77 incoming show new changesets found in source
78 78 init create a new repository in the given directory
79 79 log show revision history of entire repository or files
80 80 manifest output the current or given revision of the project manifest
81 81 merge merge another revision into working directory
82 82 outgoing show changesets not found in the destination
83 83 paths show aliases for remote repositories
84 84 phase set or show the current phase name
85 85 pull pull changes from the specified source
86 86 push push changes to the specified destination
87 87 recover roll back an interrupted transaction
88 88 remove remove the specified files on the next commit
89 89 rename rename files; equivalent of copy + remove
90 90 resolve redo merges or set/view the merge status of files
91 91 revert restore files to their checkout state
92 92 root print the root (top) of the current working directory
93 93 serve start stand-alone webserver
94 94 status show changed files in the working directory
95 95 summary summarize working directory state
96 96 tag add one or more tags for the current or given revision
97 97 tags list repository tags
98 98 unbundle apply one or more changegroup files
99 99 update update working directory (or switch revisions)
100 100 verify verify the integrity of the repository
101 101 version output version and copyright information
102 102
103 103 additional help topics:
104 104
105 105 config Configuration Files
106 106 dates Date Formats
107 107 diffs Diff Formats
108 108 environment Environment Variables
109 109 extensions Using Additional Features
110 110 filesets Specifying File Sets
111 111 glossary Glossary
112 112 hgignore Syntax for Mercurial Ignore Files
113 113 hgweb Configuring hgweb
114 114 internals Technical implementation topics
115 115 merge-tools Merge Tools
116 116 pager Pager Support
117 117 patterns File Name Patterns
118 118 phases Working with Phases
119 119 revisions Specifying Revisions
120 120 scripting Using Mercurial from scripts and automation
121 121 subrepos Subrepositories
122 122 templating Template Usage
123 123 urls URL Paths
124 124
125 125 (use 'hg help -v' to show built-in aliases and global options)
126 126
127 127 $ hg -q help
128 128 add add the specified files on the next commit
129 129 addremove add all new files, delete all missing files
130 130 annotate show changeset information by line for each file
131 131 archive create an unversioned archive of a repository revision
132 132 backout reverse effect of earlier changeset
133 133 bisect subdivision search of changesets
134 134 bookmarks create a new bookmark or list existing bookmarks
135 135 branch set or show the current branch name
136 136 branches list repository named branches
137 137 bundle create a changegroup file
138 138 cat output the current or given revision of files
139 139 clone make a copy of an existing repository
140 140 commit commit the specified files or all outstanding changes
141 141 config show combined config settings from all hgrc files
142 142 copy mark files as copied for the next commit
143 143 diff diff repository (or selected files)
144 144 export dump the header and diffs for one or more changesets
145 145 files list tracked files
146 146 forget forget the specified files on the next commit
147 147 graft copy changes from other branches onto the current branch
148 148 grep search revision history for a pattern in specified files
149 149 heads show branch heads
150 150 help show help for a given topic or a help overview
151 151 identify identify the working directory or specified revision
152 152 import import an ordered set of patches
153 153 incoming show new changesets found in source
154 154 init create a new repository in the given directory
155 155 log show revision history of entire repository or files
156 156 manifest output the current or given revision of the project manifest
157 157 merge merge another revision into working directory
158 158 outgoing show changesets not found in the destination
159 159 paths show aliases for remote repositories
160 160 phase set or show the current phase name
161 161 pull pull changes from the specified source
162 162 push push changes to the specified destination
163 163 recover roll back an interrupted transaction
164 164 remove remove the specified files on the next commit
165 165 rename rename files; equivalent of copy + remove
166 166 resolve redo merges or set/view the merge status of files
167 167 revert restore files to their checkout state
168 168 root print the root (top) of the current working directory
169 169 serve start stand-alone webserver
170 170 status show changed files in the working directory
171 171 summary summarize working directory state
172 172 tag add one or more tags for the current or given revision
173 173 tags list repository tags
174 174 unbundle apply one or more changegroup files
175 175 update update working directory (or switch revisions)
176 176 verify verify the integrity of the repository
177 177 version output version and copyright information
178 178
179 179 additional help topics:
180 180
181 181 config Configuration Files
182 182 dates Date Formats
183 183 diffs Diff Formats
184 184 environment Environment Variables
185 185 extensions Using Additional Features
186 186 filesets Specifying File Sets
187 187 glossary Glossary
188 188 hgignore Syntax for Mercurial Ignore Files
189 189 hgweb Configuring hgweb
190 190 internals Technical implementation topics
191 191 merge-tools Merge Tools
192 192 pager Pager Support
193 193 patterns File Name Patterns
194 194 phases Working with Phases
195 195 revisions Specifying Revisions
196 196 scripting Using Mercurial from scripts and automation
197 197 subrepos Subrepositories
198 198 templating Template Usage
199 199 urls URL Paths
200 200
201 201 Test extension help:
202 202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 203 Using Additional Features
204 204 """""""""""""""""""""""""
205 205
206 206 Mercurial has the ability to add new features through the use of
207 207 extensions. Extensions may add new commands, add options to existing
208 208 commands, change the default behavior of commands, or implement hooks.
209 209
210 210 To enable the "foo" extension, either shipped with Mercurial or in the
211 211 Python search path, create an entry for it in your configuration file,
212 212 like this:
213 213
214 214 [extensions]
215 215 foo =
216 216
217 217 You may also specify the full path to an extension:
218 218
219 219 [extensions]
220 220 myfeature = ~/.hgext/myfeature.py
221 221
222 222 See 'hg help config' for more information on configuration files.
223 223
224 224 Extensions are not loaded by default for a variety of reasons: they can
225 225 increase startup overhead; they may be meant for advanced usage only; they
226 226 may provide potentially dangerous abilities (such as letting you destroy
227 227 or modify history); they might not be ready for prime time; or they may
228 228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 229 to activate extensions as needed.
230 230
231 231 To explicitly disable an extension enabled in a configuration file of
232 232 broader scope, prepend its path with !:
233 233
234 234 [extensions]
235 235 # disabling extension bar residing in /path/to/extension/bar.py
236 236 bar = !/path/to/extension/bar.py
237 237 # ditto, but no path was supplied for extension baz
238 238 baz = !
239 239
240 240 enabled extensions:
241 241
242 242 children command to display child changesets (DEPRECATED)
243 243 rebase command to move sets of revisions to a different ancestor
244 244
245 245 disabled extensions:
246 246
247 247 acl hooks for controlling repository access
248 248 blackbox log repository events to a blackbox for debugging
249 249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 250 censor erase file content at a given revision
251 251 churn command to display statistics about repository history
252 252 clonebundles advertise pre-generated bundles to seed clones
253 color colorize output from some commands
254 253 convert import revisions from foreign VCS repositories into
255 254 Mercurial
256 255 eol automatically manage newlines in repository files
257 256 extdiff command to allow external programs to compare revisions
258 257 factotum http authentication with factotum
259 258 gpg commands to sign and verify changesets
260 259 hgk browse the repository in a graphical way
261 260 highlight syntax highlighting for hgweb (requires Pygments)
262 261 histedit interactive history editing
263 262 keyword expand keywords in tracked files
264 263 largefiles track large binary files
265 264 mq manage a stack of patches
266 265 notify hooks for sending email push notifications
267 266 patchbomb command to send changesets as (a series of) patch emails
268 267 purge command to delete untracked files from the working
269 268 directory
270 269 relink recreates hardlinks between repository clones
271 270 schemes extend schemes with shortcuts to repository swarms
272 271 share share a common history between several working directories
273 272 shelve save and restore changes to the working directory
274 273 strip strip changesets and their descendants from history
275 274 transplant command to transplant changesets from another branch
276 275 win32mbcs allow the use of MBCS paths with problematic encodings
277 276 zeroconf discover and advertise repositories on the local network
278 277
279 278 Verify that extension keywords appear in help templates
280 279
281 280 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
282 281
283 282 Test short command list with verbose option
284 283
285 284 $ hg -v help shortlist
286 285 Mercurial Distributed SCM
287 286
288 287 basic commands:
289 288
290 289 add add the specified files on the next commit
291 290 annotate, blame
292 291 show changeset information by line for each file
293 292 clone make a copy of an existing repository
294 293 commit, ci commit the specified files or all outstanding changes
295 294 diff diff repository (or selected files)
296 295 export dump the header and diffs for one or more changesets
297 296 forget forget the specified files on the next commit
298 297 init create a new repository in the given directory
299 298 log, history show revision history of entire repository or files
300 299 merge merge another revision into working directory
301 300 pull pull changes from the specified source
302 301 push push changes to the specified destination
303 302 remove, rm remove the specified files on the next commit
304 303 serve start stand-alone webserver
305 304 status, st show changed files in the working directory
306 305 summary, sum summarize working directory state
307 306 update, up, checkout, co
308 307 update working directory (or switch revisions)
309 308
310 309 global options ([+] can be repeated):
311 310
312 311 -R --repository REPO repository root directory or name of overlay bundle
313 312 file
314 313 --cwd DIR change working directory
315 314 -y --noninteractive do not prompt, automatically pick the first choice for
316 315 all prompts
317 316 -q --quiet suppress output
318 317 -v --verbose enable additional output
319 318 --color TYPE when to colorize (boolean, always, auto, never, or
320 debug) (EXPERIMENTAL)
319 debug)
321 320 --config CONFIG [+] set/override config option (use 'section.name=value')
322 321 --debug enable debugging output
323 322 --debugger start debugger
324 323 --encoding ENCODE set the charset encoding (default: ascii)
325 324 --encodingmode MODE set the charset encoding mode (default: strict)
326 325 --traceback always print a traceback on exception
327 326 --time time how long the command takes
328 327 --profile print command execution profile
329 328 --version output version information and exit
330 329 -h --help display help and exit
331 330 --hidden consider hidden changesets
332 331 --pager TYPE when to paginate (boolean, always, auto, or never)
333 332 (default: auto)
334 333
335 334 (use 'hg help' for the full list of commands)
336 335
337 336 $ hg add -h
338 337 hg add [OPTION]... [FILE]...
339 338
340 339 add the specified files on the next commit
341 340
342 341 Schedule files to be version controlled and added to the repository.
343 342
344 343 The files will be added to the repository at the next commit. To undo an
345 344 add before that, see 'hg forget'.
346 345
347 346 If no names are given, add all files to the repository (except files
348 347 matching ".hgignore").
349 348
350 349 Returns 0 if all files are successfully added.
351 350
352 351 options ([+] can be repeated):
353 352
354 353 -I --include PATTERN [+] include names matching the given patterns
355 354 -X --exclude PATTERN [+] exclude names matching the given patterns
356 355 -S --subrepos recurse into subrepositories
357 356 -n --dry-run do not perform actions, just print output
358 357
359 358 (some details hidden, use --verbose to show complete help)
360 359
361 360 Verbose help for add
362 361
363 362 $ hg add -hv
364 363 hg add [OPTION]... [FILE]...
365 364
366 365 add the specified files on the next commit
367 366
368 367 Schedule files to be version controlled and added to the repository.
369 368
370 369 The files will be added to the repository at the next commit. To undo an
371 370 add before that, see 'hg forget'.
372 371
373 372 If no names are given, add all files to the repository (except files
374 373 matching ".hgignore").
375 374
376 375 Examples:
377 376
378 377 - New (unknown) files are added automatically by 'hg add':
379 378
380 379 $ ls
381 380 foo.c
382 381 $ hg status
383 382 ? foo.c
384 383 $ hg add
385 384 adding foo.c
386 385 $ hg status
387 386 A foo.c
388 387
389 388 - Specific files to be added can be specified:
390 389
391 390 $ ls
392 391 bar.c foo.c
393 392 $ hg status
394 393 ? bar.c
395 394 ? foo.c
396 395 $ hg add bar.c
397 396 $ hg status
398 397 A bar.c
399 398 ? foo.c
400 399
401 400 Returns 0 if all files are successfully added.
402 401
403 402 options ([+] can be repeated):
404 403
405 404 -I --include PATTERN [+] include names matching the given patterns
406 405 -X --exclude PATTERN [+] exclude names matching the given patterns
407 406 -S --subrepos recurse into subrepositories
408 407 -n --dry-run do not perform actions, just print output
409 408
410 409 global options ([+] can be repeated):
411 410
412 411 -R --repository REPO repository root directory or name of overlay bundle
413 412 file
414 413 --cwd DIR change working directory
415 414 -y --noninteractive do not prompt, automatically pick the first choice for
416 415 all prompts
417 416 -q --quiet suppress output
418 417 -v --verbose enable additional output
419 418 --color TYPE when to colorize (boolean, always, auto, never, or
420 debug) (EXPERIMENTAL)
419 debug)
421 420 --config CONFIG [+] set/override config option (use 'section.name=value')
422 421 --debug enable debugging output
423 422 --debugger start debugger
424 423 --encoding ENCODE set the charset encoding (default: ascii)
425 424 --encodingmode MODE set the charset encoding mode (default: strict)
426 425 --traceback always print a traceback on exception
427 426 --time time how long the command takes
428 427 --profile print command execution profile
429 428 --version output version information and exit
430 429 -h --help display help and exit
431 430 --hidden consider hidden changesets
432 431 --pager TYPE when to paginate (boolean, always, auto, or never)
433 432 (default: auto)
434 433
435 434 Test the textwidth config option
436 435
437 436 $ hg root -h --config ui.textwidth=50
438 437 hg root
439 438
440 439 print the root (top) of the current working
441 440 directory
442 441
443 442 Print the root directory of the current
444 443 repository.
445 444
446 445 Returns 0 on success.
447 446
448 447 (some details hidden, use --verbose to show
449 448 complete help)
450 449
451 450 Test help option with version option
452 451
453 452 $ hg add -h --version
454 453 Mercurial Distributed SCM (version *) (glob)
455 454 (see https://mercurial-scm.org for more information)
456 455
457 456 Copyright (C) 2005-* Matt Mackall and others (glob)
458 457 This is free software; see the source for copying conditions. There is NO
459 458 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
460 459
461 460 $ hg add --skjdfks
462 461 hg add: option --skjdfks not recognized
463 462 hg add [OPTION]... [FILE]...
464 463
465 464 add the specified files on the next commit
466 465
467 466 options ([+] can be repeated):
468 467
469 468 -I --include PATTERN [+] include names matching the given patterns
470 469 -X --exclude PATTERN [+] exclude names matching the given patterns
471 470 -S --subrepos recurse into subrepositories
472 471 -n --dry-run do not perform actions, just print output
473 472
474 473 (use 'hg add -h' to show more help)
475 474 [255]
476 475
477 476 Test ambiguous command help
478 477
479 478 $ hg help ad
480 479 list of commands:
481 480
482 481 add add the specified files on the next commit
483 482 addremove add all new files, delete all missing files
484 483
485 484 (use 'hg help -v ad' to show built-in aliases and global options)
486 485
487 486 Test command without options
488 487
489 488 $ hg help verify
490 489 hg verify
491 490
492 491 verify the integrity of the repository
493 492
494 493 Verify the integrity of the current repository.
495 494
496 495 This will perform an extensive check of the repository's integrity,
497 496 validating the hashes and checksums of each entry in the changelog,
498 497 manifest, and tracked files, as well as the integrity of their crosslinks
499 498 and indices.
500 499
501 500 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
502 501 information about recovery from corruption of the repository.
503 502
504 503 Returns 0 on success, 1 if errors are encountered.
505 504
506 505 (some details hidden, use --verbose to show complete help)
507 506
508 507 $ hg help diff
509 508 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
510 509
511 510 diff repository (or selected files)
512 511
513 512 Show differences between revisions for the specified files.
514 513
515 514 Differences between files are shown using the unified diff format.
516 515
517 516 Note:
518 517 'hg diff' may generate unexpected results for merges, as it will
519 518 default to comparing against the working directory's first parent
520 519 changeset if no revisions are specified.
521 520
522 521 When two revision arguments are given, then changes are shown between
523 522 those revisions. If only one revision is specified then that revision is
524 523 compared to the working directory, and, when no revisions are specified,
525 524 the working directory files are compared to its first parent.
526 525
527 526 Alternatively you can specify -c/--change with a revision to see the
528 527 changes in that changeset relative to its first parent.
529 528
530 529 Without the -a/--text option, diff will avoid generating diffs of files it
531 530 detects as binary. With -a, diff will generate a diff anyway, probably
532 531 with undesirable results.
533 532
534 533 Use the -g/--git option to generate diffs in the git extended diff format.
535 534 For more information, read 'hg help diffs'.
536 535
537 536 Returns 0 on success.
538 537
539 538 options ([+] can be repeated):
540 539
541 540 -r --rev REV [+] revision
542 541 -c --change REV change made by revision
543 542 -a --text treat all files as text
544 543 -g --git use git extended diff format
545 544 --nodates omit dates from diff headers
546 545 --noprefix omit a/ and b/ prefixes from filenames
547 546 -p --show-function show which function each change is in
548 547 --reverse produce a diff that undoes the changes
549 548 -w --ignore-all-space ignore white space when comparing lines
550 549 -b --ignore-space-change ignore changes in the amount of white space
551 550 -B --ignore-blank-lines ignore changes whose lines are all blank
552 551 -U --unified NUM number of lines of context to show
553 552 --stat output diffstat-style summary of changes
554 553 --root DIR produce diffs relative to subdirectory
555 554 -I --include PATTERN [+] include names matching the given patterns
556 555 -X --exclude PATTERN [+] exclude names matching the given patterns
557 556 -S --subrepos recurse into subrepositories
558 557
559 558 (some details hidden, use --verbose to show complete help)
560 559
561 560 $ hg help status
562 561 hg status [OPTION]... [FILE]...
563 562
564 563 aliases: st
565 564
566 565 show changed files in the working directory
567 566
568 567 Show status of files in the repository. If names are given, only files
569 568 that match are shown. Files that are clean or ignored or the source of a
570 569 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
571 570 -C/--copies or -A/--all are given. Unless options described with "show
572 571 only ..." are given, the options -mardu are used.
573 572
574 573 Option -q/--quiet hides untracked (unknown and ignored) files unless
575 574 explicitly requested with -u/--unknown or -i/--ignored.
576 575
577 576 Note:
578 577 'hg status' may appear to disagree with diff if permissions have
579 578 changed or a merge has occurred. The standard diff format does not
580 579 report permission changes and diff only reports changes relative to one
581 580 merge parent.
582 581
583 582 If one revision is given, it is used as the base revision. If two
584 583 revisions are given, the differences between them are shown. The --change
585 584 option can also be used as a shortcut to list the changed files of a
586 585 revision from its first parent.
587 586
588 587 The codes used to show the status of files are:
589 588
590 589 M = modified
591 590 A = added
592 591 R = removed
593 592 C = clean
594 593 ! = missing (deleted by non-hg command, but still tracked)
595 594 ? = not tracked
596 595 I = ignored
597 596 = origin of the previous file (with --copies)
598 597
599 598 Returns 0 on success.
600 599
601 600 options ([+] can be repeated):
602 601
603 602 -A --all show status of all files
604 603 -m --modified show only modified files
605 604 -a --added show only added files
606 605 -r --removed show only removed files
607 606 -d --deleted show only deleted (but tracked) files
608 607 -c --clean show only files without changes
609 608 -u --unknown show only unknown (not tracked) files
610 609 -i --ignored show only ignored files
611 610 -n --no-status hide status prefix
612 611 -C --copies show source of copied files
613 612 -0 --print0 end filenames with NUL, for use with xargs
614 613 --rev REV [+] show difference from revision
615 614 --change REV list the changed files of a revision
616 615 -I --include PATTERN [+] include names matching the given patterns
617 616 -X --exclude PATTERN [+] exclude names matching the given patterns
618 617 -S --subrepos recurse into subrepositories
619 618
620 619 (some details hidden, use --verbose to show complete help)
621 620
622 621 $ hg -q help status
623 622 hg status [OPTION]... [FILE]...
624 623
625 624 show changed files in the working directory
626 625
627 626 $ hg help foo
628 627 abort: no such help topic: foo
629 628 (try 'hg help --keyword foo')
630 629 [255]
631 630
632 631 $ hg skjdfks
633 632 hg: unknown command 'skjdfks'
634 633 Mercurial Distributed SCM
635 634
636 635 basic commands:
637 636
638 637 add add the specified files on the next commit
639 638 annotate show changeset information by line for each file
640 639 clone make a copy of an existing repository
641 640 commit commit the specified files or all outstanding changes
642 641 diff diff repository (or selected files)
643 642 export dump the header and diffs for one or more changesets
644 643 forget forget the specified files on the next commit
645 644 init create a new repository in the given directory
646 645 log show revision history of entire repository or files
647 646 merge merge another revision into working directory
648 647 pull pull changes from the specified source
649 648 push push changes to the specified destination
650 649 remove remove the specified files on the next commit
651 650 serve start stand-alone webserver
652 651 status show changed files in the working directory
653 652 summary summarize working directory state
654 653 update update working directory (or switch revisions)
655 654
656 655 (use 'hg help' for the full list of commands or 'hg -v' for details)
657 656 [255]
658 657
659 658
660 659 Make sure that we don't run afoul of the help system thinking that
661 660 this is a section and erroring out weirdly.
662 661
663 662 $ hg .log
664 663 hg: unknown command '.log'
665 664 (did you mean log?)
666 665 [255]
667 666
668 667 $ hg log.
669 668 hg: unknown command 'log.'
670 669 (did you mean log?)
671 670 [255]
672 671 $ hg pu.lh
673 672 hg: unknown command 'pu.lh'
674 673 (did you mean one of pull, push?)
675 674 [255]
676 675
677 676 $ cat > helpext.py <<EOF
678 677 > import os
679 678 > from mercurial import cmdutil, commands
680 679 >
681 680 > cmdtable = {}
682 681 > command = cmdutil.command(cmdtable)
683 682 >
684 683 > @command('nohelp',
685 684 > [('', 'longdesc', 3, 'x'*90),
686 685 > ('n', '', None, 'normal desc'),
687 686 > ('', 'newline', '', 'line1\nline2')],
688 687 > 'hg nohelp',
689 688 > norepo=True)
690 689 > @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
691 690 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
692 691 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
693 692 > def nohelp(ui, *args, **kwargs):
694 693 > pass
695 694 >
696 695 > def uisetup(ui):
697 696 > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext')
698 697 > ui.setconfig('alias', 'hgalias', 'summary', 'helpext')
699 698 >
700 699 > EOF
701 700 $ echo '[extensions]' >> $HGRCPATH
702 701 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
703 702
704 703 Test for aliases
705 704
706 705 $ hg help hgalias
707 706 hg hgalias [--remote]
708 707
709 708 alias for: hg summary
710 709
711 710 summarize working directory state
712 711
713 712 This generates a brief summary of the working directory state, including
714 713 parents, branch, commit status, phase and available updates.
715 714
716 715 With the --remote option, this will check the default paths for incoming
717 716 and outgoing changes. This can be time-consuming.
718 717
719 718 Returns 0 on success.
720 719
721 720 defined by: helpext
722 721
723 722 options:
724 723
725 724 --remote check for push and pull
726 725
727 726 (some details hidden, use --verbose to show complete help)
728 727
729 728 $ hg help shellalias
730 729 hg shellalias
731 730
732 731 shell alias for:
733 732
734 733 echo hi
735 734
736 735 defined by: helpext
737 736
738 737 (some details hidden, use --verbose to show complete help)
739 738
740 739 Test command with no help text
741 740
742 741 $ hg help nohelp
743 742 hg nohelp
744 743
745 744 (no help text available)
746 745
747 746 options:
748 747
749 748 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
750 749 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
751 750 -n -- normal desc
752 751 --newline VALUE line1 line2
753 752
754 753 (some details hidden, use --verbose to show complete help)
755 754
756 755 $ hg help -k nohelp
757 756 Commands:
758 757
759 758 nohelp hg nohelp
760 759
761 760 Extension Commands:
762 761
763 762 nohelp (no help text available)
764 763
765 764 Test that default list of commands omits extension commands
766 765
767 766 $ hg help
768 767 Mercurial Distributed SCM
769 768
770 769 list of commands:
771 770
772 771 add add the specified files on the next commit
773 772 addremove add all new files, delete all missing files
774 773 annotate show changeset information by line for each file
775 774 archive create an unversioned archive of a repository revision
776 775 backout reverse effect of earlier changeset
777 776 bisect subdivision search of changesets
778 777 bookmarks create a new bookmark or list existing bookmarks
779 778 branch set or show the current branch name
780 779 branches list repository named branches
781 780 bundle create a changegroup file
782 781 cat output the current or given revision of files
783 782 clone make a copy of an existing repository
784 783 commit commit the specified files or all outstanding changes
785 784 config show combined config settings from all hgrc files
786 785 copy mark files as copied for the next commit
787 786 diff diff repository (or selected files)
788 787 export dump the header and diffs for one or more changesets
789 788 files list tracked files
790 789 forget forget the specified files on the next commit
791 790 graft copy changes from other branches onto the current branch
792 791 grep search revision history for a pattern in specified files
793 792 heads show branch heads
794 793 help show help for a given topic or a help overview
795 794 identify identify the working directory or specified revision
796 795 import import an ordered set of patches
797 796 incoming show new changesets found in source
798 797 init create a new repository in the given directory
799 798 log show revision history of entire repository or files
800 799 manifest output the current or given revision of the project manifest
801 800 merge merge another revision into working directory
802 801 outgoing show changesets not found in the destination
803 802 paths show aliases for remote repositories
804 803 phase set or show the current phase name
805 804 pull pull changes from the specified source
806 805 push push changes to the specified destination
807 806 recover roll back an interrupted transaction
808 807 remove remove the specified files on the next commit
809 808 rename rename files; equivalent of copy + remove
810 809 resolve redo merges or set/view the merge status of files
811 810 revert restore files to their checkout state
812 811 root print the root (top) of the current working directory
813 812 serve start stand-alone webserver
814 813 status show changed files in the working directory
815 814 summary summarize working directory state
816 815 tag add one or more tags for the current or given revision
817 816 tags list repository tags
818 817 unbundle apply one or more changegroup files
819 818 update update working directory (or switch revisions)
820 819 verify verify the integrity of the repository
821 820 version output version and copyright information
822 821
823 822 enabled extensions:
824 823
825 824 helpext (no help text available)
826 825
827 826 additional help topics:
828 827
829 828 config Configuration Files
830 829 dates Date Formats
831 830 diffs Diff Formats
832 831 environment Environment Variables
833 832 extensions Using Additional Features
834 833 filesets Specifying File Sets
835 834 glossary Glossary
836 835 hgignore Syntax for Mercurial Ignore Files
837 836 hgweb Configuring hgweb
838 837 internals Technical implementation topics
839 838 merge-tools Merge Tools
840 839 pager Pager Support
841 840 patterns File Name Patterns
842 841 phases Working with Phases
843 842 revisions Specifying Revisions
844 843 scripting Using Mercurial from scripts and automation
845 844 subrepos Subrepositories
846 845 templating Template Usage
847 846 urls URL Paths
848 847
849 848 (use 'hg help -v' to show built-in aliases and global options)
850 849
851 850
852 851 Test list of internal help commands
853 852
854 853 $ hg help debug
855 854 debug commands (internal and unsupported):
856 855
857 856 debugancestor
858 857 find the ancestor revision of two revisions in a given index
859 858 debugapplystreamclonebundle
860 859 apply a stream clone bundle file
861 860 debugbuilddag
862 861 builds a repo with a given DAG from scratch in the current
863 862 empty repo
864 863 debugbundle lists the contents of a bundle
865 864 debugcheckstate
866 865 validate the correctness of the current dirstate
867 866 debugcolor show available color, effects or style
868 867 debugcommands
869 868 list all available commands and options
870 869 debugcomplete
871 870 returns the completion list associated with the given command
872 871 debugcreatestreamclonebundle
873 872 create a stream clone bundle file
874 873 debugdag format the changelog or an index DAG as a concise textual
875 874 description
876 875 debugdata dump the contents of a data file revision
877 876 debugdate parse and display a date
878 877 debugdeltachain
879 878 dump information about delta chains in a revlog
880 879 debugdirstate
881 880 show the contents of the current dirstate
882 881 debugdiscovery
883 882 runs the changeset discovery protocol in isolation
884 883 debugextensions
885 884 show information about active extensions
886 885 debugfileset parse and apply a fileset specification
887 886 debugfsinfo show information detected about current filesystem
888 887 debuggetbundle
889 888 retrieves a bundle from a repo
890 889 debugignore display the combined ignore pattern and information about
891 890 ignored files
892 891 debugindex dump the contents of an index file
893 892 debugindexdot
894 893 dump an index DAG as a graphviz dot file
895 894 debuginstall test Mercurial installation
896 895 debugknown test whether node ids are known to a repo
897 896 debuglocks show or modify state of locks
898 897 debugmergestate
899 898 print merge state
900 899 debugnamecomplete
901 900 complete "names" - tags, open branch names, bookmark names
902 901 debugobsolete
903 902 create arbitrary obsolete marker
904 903 debugoptADV (no help text available)
905 904 debugoptDEP (no help text available)
906 905 debugoptEXP (no help text available)
907 906 debugpathcomplete
908 907 complete part or all of a tracked path
909 908 debugpushkey access the pushkey key/value protocol
910 909 debugpvec (no help text available)
911 910 debugrebuilddirstate
912 911 rebuild the dirstate as it would look like for the given
913 912 revision
914 913 debugrebuildfncache
915 914 rebuild the fncache file
916 915 debugrename dump rename information
917 916 debugrevlog show data and statistics about a revlog
918 917 debugrevspec parse and apply a revision specification
919 918 debugsetparents
920 919 manually set the parents of the current working directory
921 920 debugsub (no help text available)
922 921 debugsuccessorssets
923 922 show set of successors for revision
924 923 debugtemplate
925 924 parse and apply a template
926 925 debugupgraderepo
927 926 upgrade a repository to use different features
928 927 debugwalk show how files match on given patterns
929 928 debugwireargs
930 929 (no help text available)
931 930
932 931 (use 'hg help -v debug' to show built-in aliases and global options)
933 932
934 933 internals topic renders index of available sub-topics
935 934
936 935 $ hg help internals
937 936 Technical implementation topics
938 937 """""""""""""""""""""""""""""""
939 938
940 939 bundles Bundles
941 940 changegroups Changegroups
942 941 requirements Repository Requirements
943 942 revlogs Revision Logs
944 943 wireprotocol Wire Protocol
945 944
946 945 sub-topics can be accessed
947 946
948 947 $ hg help internals.changegroups
949 948 Changegroups
950 949 """"""""""""
951 950
952 951 Changegroups are representations of repository revlog data, specifically
953 952 the changelog, manifest, and filelogs.
954 953
955 954 There are 3 versions of changegroups: "1", "2", and "3". From a high-
956 955 level, versions "1" and "2" are almost exactly the same, with the only
957 956 difference being a header on entries in the changeset segment. Version "3"
958 957 adds support for exchanging treemanifests and includes revlog flags in the
959 958 delta header.
960 959
961 960 Changegroups consists of 3 logical segments:
962 961
963 962 +---------------------------------+
964 963 | | | |
965 964 | changeset | manifest | filelogs |
966 965 | | | |
967 966 +---------------------------------+
968 967
969 968 The principle building block of each segment is a *chunk*. A *chunk* is a
970 969 framed piece of data:
971 970
972 971 +---------------------------------------+
973 972 | | |
974 973 | length | data |
975 974 | (32 bits) | <length> bytes |
976 975 | | |
977 976 +---------------------------------------+
978 977
979 978 Each chunk starts with a 32-bit big-endian signed integer indicating the
980 979 length of the raw data that follows.
981 980
982 981 There is a special case chunk that has 0 length ("0x00000000"). We call
983 982 this an *empty chunk*.
984 983
985 984 Delta Groups
986 985 ============
987 986
988 987 A *delta group* expresses the content of a revlog as a series of deltas,
989 988 or patches against previous revisions.
990 989
991 990 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
992 991 to signal the end of the delta group:
993 992
994 993 +------------------------------------------------------------------------+
995 994 | | | | | |
996 995 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
997 996 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
998 997 | | | | | |
999 998 +------------------------------------------------------------+-----------+
1000 999
1001 1000 Each *chunk*'s data consists of the following:
1002 1001
1003 1002 +-----------------------------------------+
1004 1003 | | | |
1005 1004 | delta header | mdiff header | delta |
1006 1005 | (various) | (12 bytes) | (various) |
1007 1006 | | | |
1008 1007 +-----------------------------------------+
1009 1008
1010 1009 The *length* field is the byte length of the remaining 3 logical pieces of
1011 1010 data. The *delta* is a diff from an existing entry in the changelog.
1012 1011
1013 1012 The *delta header* is different between versions "1", "2", and "3" of the
1014 1013 changegroup format.
1015 1014
1016 1015 Version 1:
1017 1016
1018 1017 +------------------------------------------------------+
1019 1018 | | | | |
1020 1019 | node | p1 node | p2 node | link node |
1021 1020 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1022 1021 | | | | |
1023 1022 +------------------------------------------------------+
1024 1023
1025 1024 Version 2:
1026 1025
1027 1026 +------------------------------------------------------------------+
1028 1027 | | | | | |
1029 1028 | node | p1 node | p2 node | base node | link node |
1030 1029 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1031 1030 | | | | | |
1032 1031 +------------------------------------------------------------------+
1033 1032
1034 1033 Version 3:
1035 1034
1036 1035 +------------------------------------------------------------------------------+
1037 1036 | | | | | | |
1038 1037 | node | p1 node | p2 node | base node | link node | flags |
1039 1038 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1040 1039 | | | | | | |
1041 1040 +------------------------------------------------------------------------------+
1042 1041
1043 1042 The *mdiff header* consists of 3 32-bit big-endian signed integers
1044 1043 describing offsets at which to apply the following delta content:
1045 1044
1046 1045 +-------------------------------------+
1047 1046 | | | |
1048 1047 | offset | old length | new length |
1049 1048 | (32 bits) | (32 bits) | (32 bits) |
1050 1049 | | | |
1051 1050 +-------------------------------------+
1052 1051
1053 1052 In version 1, the delta is always applied against the previous node from
1054 1053 the changegroup or the first parent if this is the first entry in the
1055 1054 changegroup.
1056 1055
1057 1056 In version 2, the delta base node is encoded in the entry in the
1058 1057 changegroup. This allows the delta to be expressed against any parent,
1059 1058 which can result in smaller deltas and more efficient encoding of data.
1060 1059
1061 1060 Changeset Segment
1062 1061 =================
1063 1062
1064 1063 The *changeset segment* consists of a single *delta group* holding
1065 1064 changelog data. It is followed by an *empty chunk* to denote the boundary
1066 1065 to the *manifests segment*.
1067 1066
1068 1067 Manifest Segment
1069 1068 ================
1070 1069
1071 1070 The *manifest segment* consists of a single *delta group* holding manifest
1072 1071 data. It is followed by an *empty chunk* to denote the boundary to the
1073 1072 *filelogs segment*.
1074 1073
1075 1074 Filelogs Segment
1076 1075 ================
1077 1076
1078 1077 The *filelogs* segment consists of multiple sub-segments, each
1079 1078 corresponding to an individual file whose data is being described:
1080 1079
1081 1080 +--------------------------------------+
1082 1081 | | | | |
1083 1082 | filelog0 | filelog1 | filelog2 | ... |
1084 1083 | | | | |
1085 1084 +--------------------------------------+
1086 1085
1087 1086 In version "3" of the changegroup format, filelogs may include directory
1088 1087 logs when treemanifests are in use. directory logs are identified by
1089 1088 having a trailing '/' on their filename (see below).
1090 1089
1091 1090 The final filelog sub-segment is followed by an *empty chunk* to denote
1092 1091 the end of the segment and the overall changegroup.
1093 1092
1094 1093 Each filelog sub-segment consists of the following:
1095 1094
1096 1095 +------------------------------------------+
1097 1096 | | | |
1098 1097 | filename size | filename | delta group |
1099 1098 | (32 bits) | (various) | (various) |
1100 1099 | | | |
1101 1100 +------------------------------------------+
1102 1101
1103 1102 That is, a *chunk* consisting of the filename (not terminated or padded)
1104 1103 followed by N chunks constituting the *delta group* for this file.
1105 1104
1106 1105 Test list of commands with command with no help text
1107 1106
1108 1107 $ hg help helpext
1109 1108 helpext extension - no help text available
1110 1109
1111 1110 list of commands:
1112 1111
1113 1112 nohelp (no help text available)
1114 1113
1115 1114 (use 'hg help -v helpext' to show built-in aliases and global options)
1116 1115
1117 1116
1118 1117 test advanced, deprecated and experimental options are hidden in command help
1119 1118 $ hg help debugoptADV
1120 1119 hg debugoptADV
1121 1120
1122 1121 (no help text available)
1123 1122
1124 1123 options:
1125 1124
1126 1125 (some details hidden, use --verbose to show complete help)
1127 1126 $ hg help debugoptDEP
1128 1127 hg debugoptDEP
1129 1128
1130 1129 (no help text available)
1131 1130
1132 1131 options:
1133 1132
1134 1133 (some details hidden, use --verbose to show complete help)
1135 1134
1136 1135 $ hg help debugoptEXP
1137 1136 hg debugoptEXP
1138 1137
1139 1138 (no help text available)
1140 1139
1141 1140 options:
1142 1141
1143 1142 (some details hidden, use --verbose to show complete help)
1144 1143
1145 1144 test advanced, deprecated and experimental options are shown with -v
1146 1145 $ hg help -v debugoptADV | grep aopt
1147 1146 --aopt option is (ADVANCED)
1148 1147 $ hg help -v debugoptDEP | grep dopt
1149 1148 --dopt option is (DEPRECATED)
1150 1149 $ hg help -v debugoptEXP | grep eopt
1151 1150 --eopt option is (EXPERIMENTAL)
1152 1151
1153 1152 #if gettext
1154 1153 test deprecated option is hidden with translation with untranslated description
1155 1154 (use many globy for not failing on changed transaction)
1156 1155 $ LANGUAGE=sv hg help debugoptDEP
1157 1156 hg debugoptDEP
1158 1157
1159 1158 (*) (glob)
1160 1159
1161 1160 options:
1162 1161
1163 1162 (some details hidden, use --verbose to show complete help)
1164 1163 #endif
1165 1164
1166 1165 Test commands that collide with topics (issue4240)
1167 1166
1168 1167 $ hg config -hq
1169 1168 hg config [-u] [NAME]...
1170 1169
1171 1170 show combined config settings from all hgrc files
1172 1171 $ hg showconfig -hq
1173 1172 hg config [-u] [NAME]...
1174 1173
1175 1174 show combined config settings from all hgrc files
1176 1175
1177 1176 Test a help topic
1178 1177
1179 1178 $ hg help dates
1180 1179 Date Formats
1181 1180 """"""""""""
1182 1181
1183 1182 Some commands allow the user to specify a date, e.g.:
1184 1183
1185 1184 - backout, commit, import, tag: Specify the commit date.
1186 1185 - log, revert, update: Select revision(s) by date.
1187 1186
1188 1187 Many date formats are valid. Here are some examples:
1189 1188
1190 1189 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1191 1190 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1192 1191 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1193 1192 - "Dec 6" (midnight)
1194 1193 - "13:18" (today assumed)
1195 1194 - "3:39" (3:39AM assumed)
1196 1195 - "3:39pm" (15:39)
1197 1196 - "2006-12-06 13:18:29" (ISO 8601 format)
1198 1197 - "2006-12-6 13:18"
1199 1198 - "2006-12-6"
1200 1199 - "12-6"
1201 1200 - "12/6"
1202 1201 - "12/6/6" (Dec 6 2006)
1203 1202 - "today" (midnight)
1204 1203 - "yesterday" (midnight)
1205 1204 - "now" - right now
1206 1205
1207 1206 Lastly, there is Mercurial's internal format:
1208 1207
1209 1208 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1210 1209
1211 1210 This is the internal representation format for dates. The first number is
1212 1211 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1213 1212 is the offset of the local timezone, in seconds west of UTC (negative if
1214 1213 the timezone is east of UTC).
1215 1214
1216 1215 The log command also accepts date ranges:
1217 1216
1218 1217 - "<DATE" - at or before a given date/time
1219 1218 - ">DATE" - on or after a given date/time
1220 1219 - "DATE to DATE" - a date range, inclusive
1221 1220 - "-DAYS" - within a given number of days of today
1222 1221
1223 1222 Test repeated config section name
1224 1223
1225 1224 $ hg help config.host
1226 1225 "http_proxy.host"
1227 1226 Host name and (optional) port of the proxy server, for example
1228 1227 "myproxy:8000".
1229 1228
1230 1229 "smtp.host"
1231 1230 Host name of mail server, e.g. "mail.example.com".
1232 1231
1233 1232 Unrelated trailing paragraphs shouldn't be included
1234 1233
1235 1234 $ hg help config.extramsg | grep '^$'
1236 1235
1237 1236
1238 1237 Test capitalized section name
1239 1238
1240 1239 $ hg help scripting.HGPLAIN > /dev/null
1241 1240
1242 1241 Help subsection:
1243 1242
1244 1243 $ hg help config.charsets |grep "Email example:" > /dev/null
1245 1244 [1]
1246 1245
1247 1246 Show nested definitions
1248 1247 ("profiling.type"[break]"ls"[break]"stat"[break])
1249 1248
1250 1249 $ hg help config.type | egrep '^$'|wc -l
1251 1250 \s*3 (re)
1252 1251
1253 1252 Separate sections from subsections
1254 1253
1255 1254 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1256 1255 "format"
1257 1256 --------
1258 1257
1259 1258 "usegeneraldelta"
1260 1259
1261 1260 "dotencode"
1262 1261
1263 1262 "usefncache"
1264 1263
1265 1264 "usestore"
1266 1265
1267 1266 "profiling"
1268 1267 -----------
1269 1268
1270 1269 "format"
1271 1270
1272 1271 "progress"
1273 1272 ----------
1274 1273
1275 1274 "format"
1276 1275
1277 1276
1278 1277 Last item in help config.*:
1279 1278
1280 1279 $ hg help config.`hg help config|grep '^ "'| \
1281 1280 > tail -1|sed 's![ "]*!!g'`| \
1282 1281 > grep 'hg help -c config' > /dev/null
1283 1282 [1]
1284 1283
1285 1284 note to use help -c for general hg help config:
1286 1285
1287 1286 $ hg help config |grep 'hg help -c config' > /dev/null
1288 1287
1289 1288 Test templating help
1290 1289
1291 1290 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1292 1291 desc String. The text of the changeset description.
1293 1292 diffstat String. Statistics of changes with the following format:
1294 1293 firstline Any text. Returns the first line of text.
1295 1294 nonempty Any text. Returns '(none)' if the string is empty.
1296 1295
1297 1296 Test deprecated items
1298 1297
1299 1298 $ hg help -v templating | grep currentbookmark
1300 1299 currentbookmark
1301 1300 $ hg help templating | (grep currentbookmark || true)
1302 1301
1303 1302 Test help hooks
1304 1303
1305 1304 $ cat > helphook1.py <<EOF
1306 1305 > from mercurial import help
1307 1306 >
1308 1307 > def rewrite(ui, topic, doc):
1309 1308 > return doc + '\nhelphook1\n'
1310 1309 >
1311 1310 > def extsetup(ui):
1312 1311 > help.addtopichook('revisions', rewrite)
1313 1312 > EOF
1314 1313 $ cat > helphook2.py <<EOF
1315 1314 > from mercurial import help
1316 1315 >
1317 1316 > def rewrite(ui, topic, doc):
1318 1317 > return doc + '\nhelphook2\n'
1319 1318 >
1320 1319 > def extsetup(ui):
1321 1320 > help.addtopichook('revisions', rewrite)
1322 1321 > EOF
1323 1322 $ echo '[extensions]' >> $HGRCPATH
1324 1323 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1325 1324 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1326 1325 $ hg help revsets | grep helphook
1327 1326 helphook1
1328 1327 helphook2
1329 1328
1330 1329 help -c should only show debug --debug
1331 1330
1332 1331 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1333 1332 [1]
1334 1333
1335 1334 help -c should only show deprecated for -v
1336 1335
1337 1336 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1338 1337 [1]
1339 1338
1340 1339 Test -s / --system
1341 1340
1342 1341 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1343 1342 > wc -l | sed -e 's/ //g'
1344 1343 0
1345 1344 $ hg help config.files --system unix | grep 'USER' | \
1346 1345 > wc -l | sed -e 's/ //g'
1347 1346 0
1348 1347
1349 1348 Test -e / -c / -k combinations
1350 1349
1351 1350 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1352 1351 Commands:
1353 1352 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1354 1353 Extensions:
1355 1354 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1356 1355 Topics:
1357 1356 Commands:
1358 1357 Extensions:
1359 1358 Extension Commands:
1360 1359 $ hg help -c schemes
1361 1360 abort: no such help topic: schemes
1362 1361 (try 'hg help --keyword schemes')
1363 1362 [255]
1364 1363 $ hg help -e schemes |head -1
1365 1364 schemes extension - extend schemes with shortcuts to repository swarms
1366 1365 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1367 1366 Commands:
1368 1367 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1369 1368 Extensions:
1370 1369 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1371 1370 Extensions:
1372 1371 Commands:
1373 1372 $ hg help -c commit > /dev/null
1374 1373 $ hg help -e -c commit > /dev/null
1375 1374 $ hg help -e commit > /dev/null
1376 1375 abort: no such help topic: commit
1377 1376 (try 'hg help --keyword commit')
1378 1377 [255]
1379 1378
1380 1379 Test keyword search help
1381 1380
1382 1381 $ cat > prefixedname.py <<EOF
1383 1382 > '''matched against word "clone"
1384 1383 > '''
1385 1384 > EOF
1386 1385 $ echo '[extensions]' >> $HGRCPATH
1387 1386 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1388 1387 $ hg help -k clone
1389 1388 Topics:
1390 1389
1391 1390 config Configuration Files
1392 1391 extensions Using Additional Features
1393 1392 glossary Glossary
1394 1393 phases Working with Phases
1395 1394 subrepos Subrepositories
1396 1395 urls URL Paths
1397 1396
1398 1397 Commands:
1399 1398
1400 1399 bookmarks create a new bookmark or list existing bookmarks
1401 1400 clone make a copy of an existing repository
1402 1401 paths show aliases for remote repositories
1403 1402 update update working directory (or switch revisions)
1404 1403
1405 1404 Extensions:
1406 1405
1407 1406 clonebundles advertise pre-generated bundles to seed clones
1408 1407 prefixedname matched against word "clone"
1409 1408 relink recreates hardlinks between repository clones
1410 1409
1411 1410 Extension Commands:
1412 1411
1413 1412 qclone clone main and patch repository at same time
1414 1413
1415 1414 Test unfound topic
1416 1415
1417 1416 $ hg help nonexistingtopicthatwillneverexisteverever
1418 1417 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1419 1418 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1420 1419 [255]
1421 1420
1422 1421 Test unfound keyword
1423 1422
1424 1423 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1425 1424 abort: no matches
1426 1425 (try 'hg help' for a list of topics)
1427 1426 [255]
1428 1427
1429 1428 Test omit indicating for help
1430 1429
1431 1430 $ cat > addverboseitems.py <<EOF
1432 1431 > '''extension to test omit indicating.
1433 1432 >
1434 1433 > This paragraph is never omitted (for extension)
1435 1434 >
1436 1435 > .. container:: verbose
1437 1436 >
1438 1437 > This paragraph is omitted,
1439 1438 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1440 1439 >
1441 1440 > This paragraph is never omitted, too (for extension)
1442 1441 > '''
1443 1442 >
1444 1443 > from mercurial import help, commands
1445 1444 > testtopic = """This paragraph is never omitted (for topic).
1446 1445 >
1447 1446 > .. container:: verbose
1448 1447 >
1449 1448 > This paragraph is omitted,
1450 1449 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1451 1450 >
1452 1451 > This paragraph is never omitted, too (for topic)
1453 1452 > """
1454 1453 > def extsetup(ui):
1455 1454 > help.helptable.append((["topic-containing-verbose"],
1456 1455 > "This is the topic to test omit indicating.",
1457 1456 > lambda ui: testtopic))
1458 1457 > EOF
1459 1458 $ echo '[extensions]' >> $HGRCPATH
1460 1459 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1461 1460 $ hg help addverboseitems
1462 1461 addverboseitems extension - extension to test omit indicating.
1463 1462
1464 1463 This paragraph is never omitted (for extension)
1465 1464
1466 1465 This paragraph is never omitted, too (for extension)
1467 1466
1468 1467 (some details hidden, use --verbose to show complete help)
1469 1468
1470 1469 no commands defined
1471 1470 $ hg help -v addverboseitems
1472 1471 addverboseitems extension - extension to test omit indicating.
1473 1472
1474 1473 This paragraph is never omitted (for extension)
1475 1474
1476 1475 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1477 1476 extension)
1478 1477
1479 1478 This paragraph is never omitted, too (for extension)
1480 1479
1481 1480 no commands defined
1482 1481 $ hg help topic-containing-verbose
1483 1482 This is the topic to test omit indicating.
1484 1483 """"""""""""""""""""""""""""""""""""""""""
1485 1484
1486 1485 This paragraph is never omitted (for topic).
1487 1486
1488 1487 This paragraph is never omitted, too (for topic)
1489 1488
1490 1489 (some details hidden, use --verbose to show complete help)
1491 1490 $ hg help -v topic-containing-verbose
1492 1491 This is the topic to test omit indicating.
1493 1492 """"""""""""""""""""""""""""""""""""""""""
1494 1493
1495 1494 This paragraph is never omitted (for topic).
1496 1495
1497 1496 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1498 1497 topic)
1499 1498
1500 1499 This paragraph is never omitted, too (for topic)
1501 1500
1502 1501 Test section lookup
1503 1502
1504 1503 $ hg help revset.merge
1505 1504 "merge()"
1506 1505 Changeset is a merge changeset.
1507 1506
1508 1507 $ hg help glossary.dag
1509 1508 DAG
1510 1509 The repository of changesets of a distributed version control system
1511 1510 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1512 1511 of nodes and edges, where nodes correspond to changesets and edges
1513 1512 imply a parent -> child relation. This graph can be visualized by
1514 1513 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1515 1514 limited by the requirement for children to have at most two parents.
1516 1515
1517 1516
1518 1517 $ hg help hgrc.paths
1519 1518 "paths"
1520 1519 -------
1521 1520
1522 1521 Assigns symbolic names and behavior to repositories.
1523 1522
1524 1523 Options are symbolic names defining the URL or directory that is the
1525 1524 location of the repository. Example:
1526 1525
1527 1526 [paths]
1528 1527 my_server = https://example.com/my_repo
1529 1528 local_path = /home/me/repo
1530 1529
1531 1530 These symbolic names can be used from the command line. To pull from
1532 1531 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1533 1532 local_path'.
1534 1533
1535 1534 Options containing colons (":") denote sub-options that can influence
1536 1535 behavior for that specific path. Example:
1537 1536
1538 1537 [paths]
1539 1538 my_server = https://example.com/my_path
1540 1539 my_server:pushurl = ssh://example.com/my_path
1541 1540
1542 1541 The following sub-options can be defined:
1543 1542
1544 1543 "pushurl"
1545 1544 The URL to use for push operations. If not defined, the location
1546 1545 defined by the path's main entry is used.
1547 1546
1548 1547 "pushrev"
1549 1548 A revset defining which revisions to push by default.
1550 1549
1551 1550 When 'hg push' is executed without a "-r" argument, the revset defined
1552 1551 by this sub-option is evaluated to determine what to push.
1553 1552
1554 1553 For example, a value of "." will push the working directory's revision
1555 1554 by default.
1556 1555
1557 1556 Revsets specifying bookmarks will not result in the bookmark being
1558 1557 pushed.
1559 1558
1560 1559 The following special named paths exist:
1561 1560
1562 1561 "default"
1563 1562 The URL or directory to use when no source or remote is specified.
1564 1563
1565 1564 'hg clone' will automatically define this path to the location the
1566 1565 repository was cloned from.
1567 1566
1568 1567 "default-push"
1569 1568 (deprecated) The URL or directory for the default 'hg push' location.
1570 1569 "default:pushurl" should be used instead.
1571 1570
1572 1571 $ hg help glossary.mcguffin
1573 1572 abort: help section not found: glossary.mcguffin
1574 1573 [255]
1575 1574
1576 1575 $ hg help glossary.mc.guffin
1577 1576 abort: help section not found: glossary.mc.guffin
1578 1577 [255]
1579 1578
1580 1579 $ hg help template.files
1581 1580 files List of strings. All files modified, added, or removed by
1582 1581 this changeset.
1583 1582 files(pattern)
1584 1583 All files of the current changeset matching the pattern. See
1585 1584 'hg help patterns'.
1586 1585
1587 1586 Test section lookup by translated message
1588 1587
1589 1588 str.lower() instead of encoding.lower(str) on translated message might
1590 1589 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1591 1590 as the second or later byte of multi-byte character.
1592 1591
1593 1592 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1594 1593 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1595 1594 replacement makes message meaningless.
1596 1595
1597 1596 This tests that section lookup by translated string isn't broken by
1598 1597 such str.lower().
1599 1598
1600 1599 $ python <<EOF
1601 1600 > def escape(s):
1602 1601 > return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
1603 1602 > # translation of "record" in ja_JP.cp932
1604 1603 > upper = "\x8bL\x98^"
1605 1604 > # str.lower()-ed section name should be treated as different one
1606 1605 > lower = "\x8bl\x98^"
1607 1606 > with open('ambiguous.py', 'w') as fp:
1608 1607 > fp.write("""# ambiguous section names in ja_JP.cp932
1609 1608 > u'''summary of extension
1610 1609 >
1611 1610 > %s
1612 1611 > ----
1613 1612 >
1614 1613 > Upper name should show only this message
1615 1614 >
1616 1615 > %s
1617 1616 > ----
1618 1617 >
1619 1618 > Lower name should show only this message
1620 1619 >
1621 1620 > subsequent section
1622 1621 > ------------------
1623 1622 >
1624 1623 > This should be hidden at 'hg help ambiguous' with section name.
1625 1624 > '''
1626 1625 > """ % (escape(upper), escape(lower)))
1627 1626 > EOF
1628 1627
1629 1628 $ cat >> $HGRCPATH <<EOF
1630 1629 > [extensions]
1631 1630 > ambiguous = ./ambiguous.py
1632 1631 > EOF
1633 1632
1634 1633 $ python <<EOF | sh
1635 1634 > upper = "\x8bL\x98^"
1636 1635 > print "hg --encoding cp932 help -e ambiguous.%s" % upper
1637 1636 > EOF
1638 1637 \x8bL\x98^ (esc)
1639 1638 ----
1640 1639
1641 1640 Upper name should show only this message
1642 1641
1643 1642
1644 1643 $ python <<EOF | sh
1645 1644 > lower = "\x8bl\x98^"
1646 1645 > print "hg --encoding cp932 help -e ambiguous.%s" % lower
1647 1646 > EOF
1648 1647 \x8bl\x98^ (esc)
1649 1648 ----
1650 1649
1651 1650 Lower name should show only this message
1652 1651
1653 1652
1654 1653 $ cat >> $HGRCPATH <<EOF
1655 1654 > [extensions]
1656 1655 > ambiguous = !
1657 1656 > EOF
1658 1657
1659 1658 Show help content of disabled extensions
1660 1659
1661 1660 $ cat >> $HGRCPATH <<EOF
1662 1661 > [extensions]
1663 1662 > ambiguous = !./ambiguous.py
1664 1663 > EOF
1665 1664 $ hg help -e ambiguous
1666 1665 ambiguous extension - (no help text available)
1667 1666
1668 1667 (use 'hg help extensions' for information on enabling extensions)
1669 1668
1670 1669 Test dynamic list of merge tools only shows up once
1671 1670 $ hg help merge-tools
1672 1671 Merge Tools
1673 1672 """""""""""
1674 1673
1675 1674 To merge files Mercurial uses merge tools.
1676 1675
1677 1676 A merge tool combines two different versions of a file into a merged file.
1678 1677 Merge tools are given the two files and the greatest common ancestor of
1679 1678 the two file versions, so they can determine the changes made on both
1680 1679 branches.
1681 1680
1682 1681 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1683 1682 backout' and in several extensions.
1684 1683
1685 1684 Usually, the merge tool tries to automatically reconcile the files by
1686 1685 combining all non-overlapping changes that occurred separately in the two
1687 1686 different evolutions of the same initial base file. Furthermore, some
1688 1687 interactive merge programs make it easier to manually resolve conflicting
1689 1688 merges, either in a graphical way, or by inserting some conflict markers.
1690 1689 Mercurial does not include any interactive merge programs but relies on
1691 1690 external tools for that.
1692 1691
1693 1692 Available merge tools
1694 1693 =====================
1695 1694
1696 1695 External merge tools and their properties are configured in the merge-
1697 1696 tools configuration section - see hgrc(5) - but they can often just be
1698 1697 named by their executable.
1699 1698
1700 1699 A merge tool is generally usable if its executable can be found on the
1701 1700 system and if it can handle the merge. The executable is found if it is an
1702 1701 absolute or relative executable path or the name of an application in the
1703 1702 executable search path. The tool is assumed to be able to handle the merge
1704 1703 if it can handle symlinks if the file is a symlink, if it can handle
1705 1704 binary files if the file is binary, and if a GUI is available if the tool
1706 1705 requires a GUI.
1707 1706
1708 1707 There are some internal merge tools which can be used. The internal merge
1709 1708 tools are:
1710 1709
1711 1710 ":dump"
1712 1711 Creates three versions of the files to merge, containing the contents of
1713 1712 local, other and base. These files can then be used to perform a merge
1714 1713 manually. If the file to be merged is named "a.txt", these files will
1715 1714 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1716 1715 they will be placed in the same directory as "a.txt".
1717 1716
1718 1717 ":fail"
1719 1718 Rather than attempting to merge files that were modified on both
1720 1719 branches, it marks them as unresolved. The resolve command must be used
1721 1720 to resolve these conflicts.
1722 1721
1723 1722 ":local"
1724 1723 Uses the local 'p1()' version of files as the merged version.
1725 1724
1726 1725 ":merge"
1727 1726 Uses the internal non-interactive simple merge algorithm for merging
1728 1727 files. It will fail if there are any conflicts and leave markers in the
1729 1728 partially merged file. Markers will have two sections, one for each side
1730 1729 of merge.
1731 1730
1732 1731 ":merge-local"
1733 1732 Like :merge, but resolve all conflicts non-interactively in favor of the
1734 1733 local 'p1()' changes.
1735 1734
1736 1735 ":merge-other"
1737 1736 Like :merge, but resolve all conflicts non-interactively in favor of the
1738 1737 other 'p2()' changes.
1739 1738
1740 1739 ":merge3"
1741 1740 Uses the internal non-interactive simple merge algorithm for merging
1742 1741 files. It will fail if there are any conflicts and leave markers in the
1743 1742 partially merged file. Marker will have three sections, one from each
1744 1743 side of the merge and one for the base content.
1745 1744
1746 1745 ":other"
1747 1746 Uses the other 'p2()' version of files as the merged version.
1748 1747
1749 1748 ":prompt"
1750 1749 Asks the user which of the local 'p1()' or the other 'p2()' version to
1751 1750 keep as the merged version.
1752 1751
1753 1752 ":tagmerge"
1754 1753 Uses the internal tag merge algorithm (experimental).
1755 1754
1756 1755 ":union"
1757 1756 Uses the internal non-interactive simple merge algorithm for merging
1758 1757 files. It will use both left and right sides for conflict regions. No
1759 1758 markers are inserted.
1760 1759
1761 1760 Internal tools are always available and do not require a GUI but will by
1762 1761 default not handle symlinks or binary files.
1763 1762
1764 1763 Choosing a merge tool
1765 1764 =====================
1766 1765
1767 1766 Mercurial uses these rules when deciding which merge tool to use:
1768 1767
1769 1768 1. If a tool has been specified with the --tool option to merge or
1770 1769 resolve, it is used. If it is the name of a tool in the merge-tools
1771 1770 configuration, its configuration is used. Otherwise the specified tool
1772 1771 must be executable by the shell.
1773 1772 2. If the "HGMERGE" environment variable is present, its value is used and
1774 1773 must be executable by the shell.
1775 1774 3. If the filename of the file to be merged matches any of the patterns in
1776 1775 the merge-patterns configuration section, the first usable merge tool
1777 1776 corresponding to a matching pattern is used. Here, binary capabilities
1778 1777 of the merge tool are not considered.
1779 1778 4. If ui.merge is set it will be considered next. If the value is not the
1780 1779 name of a configured tool, the specified value is used and must be
1781 1780 executable by the shell. Otherwise the named tool is used if it is
1782 1781 usable.
1783 1782 5. If any usable merge tools are present in the merge-tools configuration
1784 1783 section, the one with the highest priority is used.
1785 1784 6. If a program named "hgmerge" can be found on the system, it is used -
1786 1785 but it will by default not be used for symlinks and binary files.
1787 1786 7. If the file to be merged is not binary and is not a symlink, then
1788 1787 internal ":merge" is used.
1789 1788 8. The merge of the file fails and must be resolved before commit.
1790 1789
1791 1790 Note:
1792 1791 After selecting a merge program, Mercurial will by default attempt to
1793 1792 merge the files using a simple merge algorithm first. Only if it
1794 1793 doesn't succeed because of conflicting changes Mercurial will actually
1795 1794 execute the merge program. Whether to use the simple merge algorithm
1796 1795 first can be controlled by the premerge setting of the merge tool.
1797 1796 Premerge is enabled by default unless the file is binary or a symlink.
1798 1797
1799 1798 See the merge-tools and ui sections of hgrc(5) for details on the
1800 1799 configuration of merge tools.
1801 1800
1802 1801 Test usage of section marks in help documents
1803 1802
1804 1803 $ cd "$TESTDIR"/../doc
1805 1804 $ python check-seclevel.py
1806 1805 $ cd $TESTTMP
1807 1806
1808 1807 #if serve
1809 1808
1810 1809 Test the help pages in hgweb.
1811 1810
1812 1811 Dish up an empty repo; serve it cold.
1813 1812
1814 1813 $ hg init "$TESTTMP/test"
1815 1814 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1816 1815 $ cat hg.pid >> $DAEMON_PIDS
1817 1816
1818 1817 $ get-with-headers.py $LOCALIP:$HGPORT "help"
1819 1818 200 Script output follows
1820 1819
1821 1820 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1822 1821 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1823 1822 <head>
1824 1823 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1825 1824 <meta name="robots" content="index, nofollow" />
1826 1825 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1827 1826 <script type="text/javascript" src="/static/mercurial.js"></script>
1828 1827
1829 1828 <title>Help: Index</title>
1830 1829 </head>
1831 1830 <body>
1832 1831
1833 1832 <div class="container">
1834 1833 <div class="menu">
1835 1834 <div class="logo">
1836 1835 <a href="https://mercurial-scm.org/">
1837 1836 <img src="/static/hglogo.png" alt="mercurial" /></a>
1838 1837 </div>
1839 1838 <ul>
1840 1839 <li><a href="/shortlog">log</a></li>
1841 1840 <li><a href="/graph">graph</a></li>
1842 1841 <li><a href="/tags">tags</a></li>
1843 1842 <li><a href="/bookmarks">bookmarks</a></li>
1844 1843 <li><a href="/branches">branches</a></li>
1845 1844 </ul>
1846 1845 <ul>
1847 1846 <li class="active">help</li>
1848 1847 </ul>
1849 1848 </div>
1850 1849
1851 1850 <div class="main">
1852 1851 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1853 1852 <form class="search" action="/log">
1854 1853
1855 1854 <p><input name="rev" id="search1" type="text" size="30" /></p>
1856 1855 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1857 1856 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1858 1857 </form>
1859 1858 <table class="bigtable">
1860 1859 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
1861 1860
1862 1861 <tr><td>
1863 1862 <a href="/help/config">
1864 1863 config
1865 1864 </a>
1866 1865 </td><td>
1867 1866 Configuration Files
1868 1867 </td></tr>
1869 1868 <tr><td>
1870 1869 <a href="/help/dates">
1871 1870 dates
1872 1871 </a>
1873 1872 </td><td>
1874 1873 Date Formats
1875 1874 </td></tr>
1876 1875 <tr><td>
1877 1876 <a href="/help/diffs">
1878 1877 diffs
1879 1878 </a>
1880 1879 </td><td>
1881 1880 Diff Formats
1882 1881 </td></tr>
1883 1882 <tr><td>
1884 1883 <a href="/help/environment">
1885 1884 environment
1886 1885 </a>
1887 1886 </td><td>
1888 1887 Environment Variables
1889 1888 </td></tr>
1890 1889 <tr><td>
1891 1890 <a href="/help/extensions">
1892 1891 extensions
1893 1892 </a>
1894 1893 </td><td>
1895 1894 Using Additional Features
1896 1895 </td></tr>
1897 1896 <tr><td>
1898 1897 <a href="/help/filesets">
1899 1898 filesets
1900 1899 </a>
1901 1900 </td><td>
1902 1901 Specifying File Sets
1903 1902 </td></tr>
1904 1903 <tr><td>
1905 1904 <a href="/help/glossary">
1906 1905 glossary
1907 1906 </a>
1908 1907 </td><td>
1909 1908 Glossary
1910 1909 </td></tr>
1911 1910 <tr><td>
1912 1911 <a href="/help/hgignore">
1913 1912 hgignore
1914 1913 </a>
1915 1914 </td><td>
1916 1915 Syntax for Mercurial Ignore Files
1917 1916 </td></tr>
1918 1917 <tr><td>
1919 1918 <a href="/help/hgweb">
1920 1919 hgweb
1921 1920 </a>
1922 1921 </td><td>
1923 1922 Configuring hgweb
1924 1923 </td></tr>
1925 1924 <tr><td>
1926 1925 <a href="/help/internals">
1927 1926 internals
1928 1927 </a>
1929 1928 </td><td>
1930 1929 Technical implementation topics
1931 1930 </td></tr>
1932 1931 <tr><td>
1933 1932 <a href="/help/merge-tools">
1934 1933 merge-tools
1935 1934 </a>
1936 1935 </td><td>
1937 1936 Merge Tools
1938 1937 </td></tr>
1939 1938 <tr><td>
1940 1939 <a href="/help/pager">
1941 1940 pager
1942 1941 </a>
1943 1942 </td><td>
1944 1943 Pager Support
1945 1944 </td></tr>
1946 1945 <tr><td>
1947 1946 <a href="/help/patterns">
1948 1947 patterns
1949 1948 </a>
1950 1949 </td><td>
1951 1950 File Name Patterns
1952 1951 </td></tr>
1953 1952 <tr><td>
1954 1953 <a href="/help/phases">
1955 1954 phases
1956 1955 </a>
1957 1956 </td><td>
1958 1957 Working with Phases
1959 1958 </td></tr>
1960 1959 <tr><td>
1961 1960 <a href="/help/revisions">
1962 1961 revisions
1963 1962 </a>
1964 1963 </td><td>
1965 1964 Specifying Revisions
1966 1965 </td></tr>
1967 1966 <tr><td>
1968 1967 <a href="/help/scripting">
1969 1968 scripting
1970 1969 </a>
1971 1970 </td><td>
1972 1971 Using Mercurial from scripts and automation
1973 1972 </td></tr>
1974 1973 <tr><td>
1975 1974 <a href="/help/subrepos">
1976 1975 subrepos
1977 1976 </a>
1978 1977 </td><td>
1979 1978 Subrepositories
1980 1979 </td></tr>
1981 1980 <tr><td>
1982 1981 <a href="/help/templating">
1983 1982 templating
1984 1983 </a>
1985 1984 </td><td>
1986 1985 Template Usage
1987 1986 </td></tr>
1988 1987 <tr><td>
1989 1988 <a href="/help/urls">
1990 1989 urls
1991 1990 </a>
1992 1991 </td><td>
1993 1992 URL Paths
1994 1993 </td></tr>
1995 1994 <tr><td>
1996 1995 <a href="/help/topic-containing-verbose">
1997 1996 topic-containing-verbose
1998 1997 </a>
1999 1998 </td><td>
2000 1999 This is the topic to test omit indicating.
2001 2000 </td></tr>
2002 2001
2003 2002
2004 2003 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2005 2004
2006 2005 <tr><td>
2007 2006 <a href="/help/add">
2008 2007 add
2009 2008 </a>
2010 2009 </td><td>
2011 2010 add the specified files on the next commit
2012 2011 </td></tr>
2013 2012 <tr><td>
2014 2013 <a href="/help/annotate">
2015 2014 annotate
2016 2015 </a>
2017 2016 </td><td>
2018 2017 show changeset information by line for each file
2019 2018 </td></tr>
2020 2019 <tr><td>
2021 2020 <a href="/help/clone">
2022 2021 clone
2023 2022 </a>
2024 2023 </td><td>
2025 2024 make a copy of an existing repository
2026 2025 </td></tr>
2027 2026 <tr><td>
2028 2027 <a href="/help/commit">
2029 2028 commit
2030 2029 </a>
2031 2030 </td><td>
2032 2031 commit the specified files or all outstanding changes
2033 2032 </td></tr>
2034 2033 <tr><td>
2035 2034 <a href="/help/diff">
2036 2035 diff
2037 2036 </a>
2038 2037 </td><td>
2039 2038 diff repository (or selected files)
2040 2039 </td></tr>
2041 2040 <tr><td>
2042 2041 <a href="/help/export">
2043 2042 export
2044 2043 </a>
2045 2044 </td><td>
2046 2045 dump the header and diffs for one or more changesets
2047 2046 </td></tr>
2048 2047 <tr><td>
2049 2048 <a href="/help/forget">
2050 2049 forget
2051 2050 </a>
2052 2051 </td><td>
2053 2052 forget the specified files on the next commit
2054 2053 </td></tr>
2055 2054 <tr><td>
2056 2055 <a href="/help/init">
2057 2056 init
2058 2057 </a>
2059 2058 </td><td>
2060 2059 create a new repository in the given directory
2061 2060 </td></tr>
2062 2061 <tr><td>
2063 2062 <a href="/help/log">
2064 2063 log
2065 2064 </a>
2066 2065 </td><td>
2067 2066 show revision history of entire repository or files
2068 2067 </td></tr>
2069 2068 <tr><td>
2070 2069 <a href="/help/merge">
2071 2070 merge
2072 2071 </a>
2073 2072 </td><td>
2074 2073 merge another revision into working directory
2075 2074 </td></tr>
2076 2075 <tr><td>
2077 2076 <a href="/help/pull">
2078 2077 pull
2079 2078 </a>
2080 2079 </td><td>
2081 2080 pull changes from the specified source
2082 2081 </td></tr>
2083 2082 <tr><td>
2084 2083 <a href="/help/push">
2085 2084 push
2086 2085 </a>
2087 2086 </td><td>
2088 2087 push changes to the specified destination
2089 2088 </td></tr>
2090 2089 <tr><td>
2091 2090 <a href="/help/remove">
2092 2091 remove
2093 2092 </a>
2094 2093 </td><td>
2095 2094 remove the specified files on the next commit
2096 2095 </td></tr>
2097 2096 <tr><td>
2098 2097 <a href="/help/serve">
2099 2098 serve
2100 2099 </a>
2101 2100 </td><td>
2102 2101 start stand-alone webserver
2103 2102 </td></tr>
2104 2103 <tr><td>
2105 2104 <a href="/help/status">
2106 2105 status
2107 2106 </a>
2108 2107 </td><td>
2109 2108 show changed files in the working directory
2110 2109 </td></tr>
2111 2110 <tr><td>
2112 2111 <a href="/help/summary">
2113 2112 summary
2114 2113 </a>
2115 2114 </td><td>
2116 2115 summarize working directory state
2117 2116 </td></tr>
2118 2117 <tr><td>
2119 2118 <a href="/help/update">
2120 2119 update
2121 2120 </a>
2122 2121 </td><td>
2123 2122 update working directory (or switch revisions)
2124 2123 </td></tr>
2125 2124
2126 2125
2127 2126
2128 2127 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2129 2128
2130 2129 <tr><td>
2131 2130 <a href="/help/addremove">
2132 2131 addremove
2133 2132 </a>
2134 2133 </td><td>
2135 2134 add all new files, delete all missing files
2136 2135 </td></tr>
2137 2136 <tr><td>
2138 2137 <a href="/help/archive">
2139 2138 archive
2140 2139 </a>
2141 2140 </td><td>
2142 2141 create an unversioned archive of a repository revision
2143 2142 </td></tr>
2144 2143 <tr><td>
2145 2144 <a href="/help/backout">
2146 2145 backout
2147 2146 </a>
2148 2147 </td><td>
2149 2148 reverse effect of earlier changeset
2150 2149 </td></tr>
2151 2150 <tr><td>
2152 2151 <a href="/help/bisect">
2153 2152 bisect
2154 2153 </a>
2155 2154 </td><td>
2156 2155 subdivision search of changesets
2157 2156 </td></tr>
2158 2157 <tr><td>
2159 2158 <a href="/help/bookmarks">
2160 2159 bookmarks
2161 2160 </a>
2162 2161 </td><td>
2163 2162 create a new bookmark or list existing bookmarks
2164 2163 </td></tr>
2165 2164 <tr><td>
2166 2165 <a href="/help/branch">
2167 2166 branch
2168 2167 </a>
2169 2168 </td><td>
2170 2169 set or show the current branch name
2171 2170 </td></tr>
2172 2171 <tr><td>
2173 2172 <a href="/help/branches">
2174 2173 branches
2175 2174 </a>
2176 2175 </td><td>
2177 2176 list repository named branches
2178 2177 </td></tr>
2179 2178 <tr><td>
2180 2179 <a href="/help/bundle">
2181 2180 bundle
2182 2181 </a>
2183 2182 </td><td>
2184 2183 create a changegroup file
2185 2184 </td></tr>
2186 2185 <tr><td>
2187 2186 <a href="/help/cat">
2188 2187 cat
2189 2188 </a>
2190 2189 </td><td>
2191 2190 output the current or given revision of files
2192 2191 </td></tr>
2193 2192 <tr><td>
2194 2193 <a href="/help/config">
2195 2194 config
2196 2195 </a>
2197 2196 </td><td>
2198 2197 show combined config settings from all hgrc files
2199 2198 </td></tr>
2200 2199 <tr><td>
2201 2200 <a href="/help/copy">
2202 2201 copy
2203 2202 </a>
2204 2203 </td><td>
2205 2204 mark files as copied for the next commit
2206 2205 </td></tr>
2207 2206 <tr><td>
2208 2207 <a href="/help/files">
2209 2208 files
2210 2209 </a>
2211 2210 </td><td>
2212 2211 list tracked files
2213 2212 </td></tr>
2214 2213 <tr><td>
2215 2214 <a href="/help/graft">
2216 2215 graft
2217 2216 </a>
2218 2217 </td><td>
2219 2218 copy changes from other branches onto the current branch
2220 2219 </td></tr>
2221 2220 <tr><td>
2222 2221 <a href="/help/grep">
2223 2222 grep
2224 2223 </a>
2225 2224 </td><td>
2226 2225 search revision history for a pattern in specified files
2227 2226 </td></tr>
2228 2227 <tr><td>
2229 2228 <a href="/help/heads">
2230 2229 heads
2231 2230 </a>
2232 2231 </td><td>
2233 2232 show branch heads
2234 2233 </td></tr>
2235 2234 <tr><td>
2236 2235 <a href="/help/help">
2237 2236 help
2238 2237 </a>
2239 2238 </td><td>
2240 2239 show help for a given topic or a help overview
2241 2240 </td></tr>
2242 2241 <tr><td>
2243 2242 <a href="/help/hgalias">
2244 2243 hgalias
2245 2244 </a>
2246 2245 </td><td>
2247 2246 summarize working directory state
2248 2247 </td></tr>
2249 2248 <tr><td>
2250 2249 <a href="/help/identify">
2251 2250 identify
2252 2251 </a>
2253 2252 </td><td>
2254 2253 identify the working directory or specified revision
2255 2254 </td></tr>
2256 2255 <tr><td>
2257 2256 <a href="/help/import">
2258 2257 import
2259 2258 </a>
2260 2259 </td><td>
2261 2260 import an ordered set of patches
2262 2261 </td></tr>
2263 2262 <tr><td>
2264 2263 <a href="/help/incoming">
2265 2264 incoming
2266 2265 </a>
2267 2266 </td><td>
2268 2267 show new changesets found in source
2269 2268 </td></tr>
2270 2269 <tr><td>
2271 2270 <a href="/help/manifest">
2272 2271 manifest
2273 2272 </a>
2274 2273 </td><td>
2275 2274 output the current or given revision of the project manifest
2276 2275 </td></tr>
2277 2276 <tr><td>
2278 2277 <a href="/help/nohelp">
2279 2278 nohelp
2280 2279 </a>
2281 2280 </td><td>
2282 2281 (no help text available)
2283 2282 </td></tr>
2284 2283 <tr><td>
2285 2284 <a href="/help/outgoing">
2286 2285 outgoing
2287 2286 </a>
2288 2287 </td><td>
2289 2288 show changesets not found in the destination
2290 2289 </td></tr>
2291 2290 <tr><td>
2292 2291 <a href="/help/paths">
2293 2292 paths
2294 2293 </a>
2295 2294 </td><td>
2296 2295 show aliases for remote repositories
2297 2296 </td></tr>
2298 2297 <tr><td>
2299 2298 <a href="/help/phase">
2300 2299 phase
2301 2300 </a>
2302 2301 </td><td>
2303 2302 set or show the current phase name
2304 2303 </td></tr>
2305 2304 <tr><td>
2306 2305 <a href="/help/recover">
2307 2306 recover
2308 2307 </a>
2309 2308 </td><td>
2310 2309 roll back an interrupted transaction
2311 2310 </td></tr>
2312 2311 <tr><td>
2313 2312 <a href="/help/rename">
2314 2313 rename
2315 2314 </a>
2316 2315 </td><td>
2317 2316 rename files; equivalent of copy + remove
2318 2317 </td></tr>
2319 2318 <tr><td>
2320 2319 <a href="/help/resolve">
2321 2320 resolve
2322 2321 </a>
2323 2322 </td><td>
2324 2323 redo merges or set/view the merge status of files
2325 2324 </td></tr>
2326 2325 <tr><td>
2327 2326 <a href="/help/revert">
2328 2327 revert
2329 2328 </a>
2330 2329 </td><td>
2331 2330 restore files to their checkout state
2332 2331 </td></tr>
2333 2332 <tr><td>
2334 2333 <a href="/help/root">
2335 2334 root
2336 2335 </a>
2337 2336 </td><td>
2338 2337 print the root (top) of the current working directory
2339 2338 </td></tr>
2340 2339 <tr><td>
2341 2340 <a href="/help/shellalias">
2342 2341 shellalias
2343 2342 </a>
2344 2343 </td><td>
2345 2344 (no help text available)
2346 2345 </td></tr>
2347 2346 <tr><td>
2348 2347 <a href="/help/tag">
2349 2348 tag
2350 2349 </a>
2351 2350 </td><td>
2352 2351 add one or more tags for the current or given revision
2353 2352 </td></tr>
2354 2353 <tr><td>
2355 2354 <a href="/help/tags">
2356 2355 tags
2357 2356 </a>
2358 2357 </td><td>
2359 2358 list repository tags
2360 2359 </td></tr>
2361 2360 <tr><td>
2362 2361 <a href="/help/unbundle">
2363 2362 unbundle
2364 2363 </a>
2365 2364 </td><td>
2366 2365 apply one or more changegroup files
2367 2366 </td></tr>
2368 2367 <tr><td>
2369 2368 <a href="/help/verify">
2370 2369 verify
2371 2370 </a>
2372 2371 </td><td>
2373 2372 verify the integrity of the repository
2374 2373 </td></tr>
2375 2374 <tr><td>
2376 2375 <a href="/help/version">
2377 2376 version
2378 2377 </a>
2379 2378 </td><td>
2380 2379 output version and copyright information
2381 2380 </td></tr>
2382 2381
2383 2382
2384 2383 </table>
2385 2384 </div>
2386 2385 </div>
2387 2386
2388 2387
2389 2388
2390 2389 </body>
2391 2390 </html>
2392 2391
2393 2392
2394 2393 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2395 2394 200 Script output follows
2396 2395
2397 2396 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2398 2397 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2399 2398 <head>
2400 2399 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2401 2400 <meta name="robots" content="index, nofollow" />
2402 2401 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2403 2402 <script type="text/javascript" src="/static/mercurial.js"></script>
2404 2403
2405 2404 <title>Help: add</title>
2406 2405 </head>
2407 2406 <body>
2408 2407
2409 2408 <div class="container">
2410 2409 <div class="menu">
2411 2410 <div class="logo">
2412 2411 <a href="https://mercurial-scm.org/">
2413 2412 <img src="/static/hglogo.png" alt="mercurial" /></a>
2414 2413 </div>
2415 2414 <ul>
2416 2415 <li><a href="/shortlog">log</a></li>
2417 2416 <li><a href="/graph">graph</a></li>
2418 2417 <li><a href="/tags">tags</a></li>
2419 2418 <li><a href="/bookmarks">bookmarks</a></li>
2420 2419 <li><a href="/branches">branches</a></li>
2421 2420 </ul>
2422 2421 <ul>
2423 2422 <li class="active"><a href="/help">help</a></li>
2424 2423 </ul>
2425 2424 </div>
2426 2425
2427 2426 <div class="main">
2428 2427 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2429 2428 <h3>Help: add</h3>
2430 2429
2431 2430 <form class="search" action="/log">
2432 2431
2433 2432 <p><input name="rev" id="search1" type="text" size="30" /></p>
2434 2433 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2435 2434 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2436 2435 </form>
2437 2436 <div id="doc">
2438 2437 <p>
2439 2438 hg add [OPTION]... [FILE]...
2440 2439 </p>
2441 2440 <p>
2442 2441 add the specified files on the next commit
2443 2442 </p>
2444 2443 <p>
2445 2444 Schedule files to be version controlled and added to the
2446 2445 repository.
2447 2446 </p>
2448 2447 <p>
2449 2448 The files will be added to the repository at the next commit. To
2450 2449 undo an add before that, see 'hg forget'.
2451 2450 </p>
2452 2451 <p>
2453 2452 If no names are given, add all files to the repository (except
2454 2453 files matching &quot;.hgignore&quot;).
2455 2454 </p>
2456 2455 <p>
2457 2456 Examples:
2458 2457 </p>
2459 2458 <ul>
2460 2459 <li> New (unknown) files are added automatically by 'hg add':
2461 2460 <pre>
2462 2461 \$ ls (re)
2463 2462 foo.c
2464 2463 \$ hg status (re)
2465 2464 ? foo.c
2466 2465 \$ hg add (re)
2467 2466 adding foo.c
2468 2467 \$ hg status (re)
2469 2468 A foo.c
2470 2469 </pre>
2471 2470 <li> Specific files to be added can be specified:
2472 2471 <pre>
2473 2472 \$ ls (re)
2474 2473 bar.c foo.c
2475 2474 \$ hg status (re)
2476 2475 ? bar.c
2477 2476 ? foo.c
2478 2477 \$ hg add bar.c (re)
2479 2478 \$ hg status (re)
2480 2479 A bar.c
2481 2480 ? foo.c
2482 2481 </pre>
2483 2482 </ul>
2484 2483 <p>
2485 2484 Returns 0 if all files are successfully added.
2486 2485 </p>
2487 2486 <p>
2488 2487 options ([+] can be repeated):
2489 2488 </p>
2490 2489 <table>
2491 2490 <tr><td>-I</td>
2492 2491 <td>--include PATTERN [+]</td>
2493 2492 <td>include names matching the given patterns</td></tr>
2494 2493 <tr><td>-X</td>
2495 2494 <td>--exclude PATTERN [+]</td>
2496 2495 <td>exclude names matching the given patterns</td></tr>
2497 2496 <tr><td>-S</td>
2498 2497 <td>--subrepos</td>
2499 2498 <td>recurse into subrepositories</td></tr>
2500 2499 <tr><td>-n</td>
2501 2500 <td>--dry-run</td>
2502 2501 <td>do not perform actions, just print output</td></tr>
2503 2502 </table>
2504 2503 <p>
2505 2504 global options ([+] can be repeated):
2506 2505 </p>
2507 2506 <table>
2508 2507 <tr><td>-R</td>
2509 2508 <td>--repository REPO</td>
2510 2509 <td>repository root directory or name of overlay bundle file</td></tr>
2511 2510 <tr><td></td>
2512 2511 <td>--cwd DIR</td>
2513 2512 <td>change working directory</td></tr>
2514 2513 <tr><td>-y</td>
2515 2514 <td>--noninteractive</td>
2516 2515 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2517 2516 <tr><td>-q</td>
2518 2517 <td>--quiet</td>
2519 2518 <td>suppress output</td></tr>
2520 2519 <tr><td>-v</td>
2521 2520 <td>--verbose</td>
2522 2521 <td>enable additional output</td></tr>
2523 2522 <tr><td></td>
2524 2523 <td>--color TYPE</td>
2525 <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL)</td></tr>
2524 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2526 2525 <tr><td></td>
2527 2526 <td>--config CONFIG [+]</td>
2528 2527 <td>set/override config option (use 'section.name=value')</td></tr>
2529 2528 <tr><td></td>
2530 2529 <td>--debug</td>
2531 2530 <td>enable debugging output</td></tr>
2532 2531 <tr><td></td>
2533 2532 <td>--debugger</td>
2534 2533 <td>start debugger</td></tr>
2535 2534 <tr><td></td>
2536 2535 <td>--encoding ENCODE</td>
2537 2536 <td>set the charset encoding (default: ascii)</td></tr>
2538 2537 <tr><td></td>
2539 2538 <td>--encodingmode MODE</td>
2540 2539 <td>set the charset encoding mode (default: strict)</td></tr>
2541 2540 <tr><td></td>
2542 2541 <td>--traceback</td>
2543 2542 <td>always print a traceback on exception</td></tr>
2544 2543 <tr><td></td>
2545 2544 <td>--time</td>
2546 2545 <td>time how long the command takes</td></tr>
2547 2546 <tr><td></td>
2548 2547 <td>--profile</td>
2549 2548 <td>print command execution profile</td></tr>
2550 2549 <tr><td></td>
2551 2550 <td>--version</td>
2552 2551 <td>output version information and exit</td></tr>
2553 2552 <tr><td>-h</td>
2554 2553 <td>--help</td>
2555 2554 <td>display help and exit</td></tr>
2556 2555 <tr><td></td>
2557 2556 <td>--hidden</td>
2558 2557 <td>consider hidden changesets</td></tr>
2559 2558 <tr><td></td>
2560 2559 <td>--pager TYPE</td>
2561 2560 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2562 2561 </table>
2563 2562
2564 2563 </div>
2565 2564 </div>
2566 2565 </div>
2567 2566
2568 2567
2569 2568
2570 2569 </body>
2571 2570 </html>
2572 2571
2573 2572
2574 2573 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2575 2574 200 Script output follows
2576 2575
2577 2576 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2578 2577 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2579 2578 <head>
2580 2579 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2581 2580 <meta name="robots" content="index, nofollow" />
2582 2581 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2583 2582 <script type="text/javascript" src="/static/mercurial.js"></script>
2584 2583
2585 2584 <title>Help: remove</title>
2586 2585 </head>
2587 2586 <body>
2588 2587
2589 2588 <div class="container">
2590 2589 <div class="menu">
2591 2590 <div class="logo">
2592 2591 <a href="https://mercurial-scm.org/">
2593 2592 <img src="/static/hglogo.png" alt="mercurial" /></a>
2594 2593 </div>
2595 2594 <ul>
2596 2595 <li><a href="/shortlog">log</a></li>
2597 2596 <li><a href="/graph">graph</a></li>
2598 2597 <li><a href="/tags">tags</a></li>
2599 2598 <li><a href="/bookmarks">bookmarks</a></li>
2600 2599 <li><a href="/branches">branches</a></li>
2601 2600 </ul>
2602 2601 <ul>
2603 2602 <li class="active"><a href="/help">help</a></li>
2604 2603 </ul>
2605 2604 </div>
2606 2605
2607 2606 <div class="main">
2608 2607 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2609 2608 <h3>Help: remove</h3>
2610 2609
2611 2610 <form class="search" action="/log">
2612 2611
2613 2612 <p><input name="rev" id="search1" type="text" size="30" /></p>
2614 2613 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2615 2614 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2616 2615 </form>
2617 2616 <div id="doc">
2618 2617 <p>
2619 2618 hg remove [OPTION]... FILE...
2620 2619 </p>
2621 2620 <p>
2622 2621 aliases: rm
2623 2622 </p>
2624 2623 <p>
2625 2624 remove the specified files on the next commit
2626 2625 </p>
2627 2626 <p>
2628 2627 Schedule the indicated files for removal from the current branch.
2629 2628 </p>
2630 2629 <p>
2631 2630 This command schedules the files to be removed at the next commit.
2632 2631 To undo a remove before that, see 'hg revert'. To undo added
2633 2632 files, see 'hg forget'.
2634 2633 </p>
2635 2634 <p>
2636 2635 -A/--after can be used to remove only files that have already
2637 2636 been deleted, -f/--force can be used to force deletion, and -Af
2638 2637 can be used to remove files from the next revision without
2639 2638 deleting them from the working directory.
2640 2639 </p>
2641 2640 <p>
2642 2641 The following table details the behavior of remove for different
2643 2642 file states (columns) and option combinations (rows). The file
2644 2643 states are Added [A], Clean [C], Modified [M] and Missing [!]
2645 2644 (as reported by 'hg status'). The actions are Warn, Remove
2646 2645 (from branch) and Delete (from disk):
2647 2646 </p>
2648 2647 <table>
2649 2648 <tr><td>opt/state</td>
2650 2649 <td>A</td>
2651 2650 <td>C</td>
2652 2651 <td>M</td>
2653 2652 <td>!</td></tr>
2654 2653 <tr><td>none</td>
2655 2654 <td>W</td>
2656 2655 <td>RD</td>
2657 2656 <td>W</td>
2658 2657 <td>R</td></tr>
2659 2658 <tr><td>-f</td>
2660 2659 <td>R</td>
2661 2660 <td>RD</td>
2662 2661 <td>RD</td>
2663 2662 <td>R</td></tr>
2664 2663 <tr><td>-A</td>
2665 2664 <td>W</td>
2666 2665 <td>W</td>
2667 2666 <td>W</td>
2668 2667 <td>R</td></tr>
2669 2668 <tr><td>-Af</td>
2670 2669 <td>R</td>
2671 2670 <td>R</td>
2672 2671 <td>R</td>
2673 2672 <td>R</td></tr>
2674 2673 </table>
2675 2674 <p>
2676 2675 <b>Note:</b>
2677 2676 </p>
2678 2677 <p>
2679 2678 'hg remove' never deletes files in Added [A] state from the
2680 2679 working directory, not even if &quot;--force&quot; is specified.
2681 2680 </p>
2682 2681 <p>
2683 2682 Returns 0 on success, 1 if any warnings encountered.
2684 2683 </p>
2685 2684 <p>
2686 2685 options ([+] can be repeated):
2687 2686 </p>
2688 2687 <table>
2689 2688 <tr><td>-A</td>
2690 2689 <td>--after</td>
2691 2690 <td>record delete for missing files</td></tr>
2692 2691 <tr><td>-f</td>
2693 2692 <td>--force</td>
2694 2693 <td>forget added files, delete modified files</td></tr>
2695 2694 <tr><td>-S</td>
2696 2695 <td>--subrepos</td>
2697 2696 <td>recurse into subrepositories</td></tr>
2698 2697 <tr><td>-I</td>
2699 2698 <td>--include PATTERN [+]</td>
2700 2699 <td>include names matching the given patterns</td></tr>
2701 2700 <tr><td>-X</td>
2702 2701 <td>--exclude PATTERN [+]</td>
2703 2702 <td>exclude names matching the given patterns</td></tr>
2704 2703 </table>
2705 2704 <p>
2706 2705 global options ([+] can be repeated):
2707 2706 </p>
2708 2707 <table>
2709 2708 <tr><td>-R</td>
2710 2709 <td>--repository REPO</td>
2711 2710 <td>repository root directory or name of overlay bundle file</td></tr>
2712 2711 <tr><td></td>
2713 2712 <td>--cwd DIR</td>
2714 2713 <td>change working directory</td></tr>
2715 2714 <tr><td>-y</td>
2716 2715 <td>--noninteractive</td>
2717 2716 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2718 2717 <tr><td>-q</td>
2719 2718 <td>--quiet</td>
2720 2719 <td>suppress output</td></tr>
2721 2720 <tr><td>-v</td>
2722 2721 <td>--verbose</td>
2723 2722 <td>enable additional output</td></tr>
2724 2723 <tr><td></td>
2725 2724 <td>--color TYPE</td>
2726 <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL)</td></tr>
2725 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2727 2726 <tr><td></td>
2728 2727 <td>--config CONFIG [+]</td>
2729 2728 <td>set/override config option (use 'section.name=value')</td></tr>
2730 2729 <tr><td></td>
2731 2730 <td>--debug</td>
2732 2731 <td>enable debugging output</td></tr>
2733 2732 <tr><td></td>
2734 2733 <td>--debugger</td>
2735 2734 <td>start debugger</td></tr>
2736 2735 <tr><td></td>
2737 2736 <td>--encoding ENCODE</td>
2738 2737 <td>set the charset encoding (default: ascii)</td></tr>
2739 2738 <tr><td></td>
2740 2739 <td>--encodingmode MODE</td>
2741 2740 <td>set the charset encoding mode (default: strict)</td></tr>
2742 2741 <tr><td></td>
2743 2742 <td>--traceback</td>
2744 2743 <td>always print a traceback on exception</td></tr>
2745 2744 <tr><td></td>
2746 2745 <td>--time</td>
2747 2746 <td>time how long the command takes</td></tr>
2748 2747 <tr><td></td>
2749 2748 <td>--profile</td>
2750 2749 <td>print command execution profile</td></tr>
2751 2750 <tr><td></td>
2752 2751 <td>--version</td>
2753 2752 <td>output version information and exit</td></tr>
2754 2753 <tr><td>-h</td>
2755 2754 <td>--help</td>
2756 2755 <td>display help and exit</td></tr>
2757 2756 <tr><td></td>
2758 2757 <td>--hidden</td>
2759 2758 <td>consider hidden changesets</td></tr>
2760 2759 <tr><td></td>
2761 2760 <td>--pager TYPE</td>
2762 2761 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2763 2762 </table>
2764 2763
2765 2764 </div>
2766 2765 </div>
2767 2766 </div>
2768 2767
2769 2768
2770 2769
2771 2770 </body>
2772 2771 </html>
2773 2772
2774 2773
2775 2774 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
2776 2775 200 Script output follows
2777 2776
2778 2777 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2779 2778 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2780 2779 <head>
2781 2780 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2782 2781 <meta name="robots" content="index, nofollow" />
2783 2782 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2784 2783 <script type="text/javascript" src="/static/mercurial.js"></script>
2785 2784
2786 2785 <title>Help: dates</title>
2787 2786 </head>
2788 2787 <body>
2789 2788
2790 2789 <div class="container">
2791 2790 <div class="menu">
2792 2791 <div class="logo">
2793 2792 <a href="https://mercurial-scm.org/">
2794 2793 <img src="/static/hglogo.png" alt="mercurial" /></a>
2795 2794 </div>
2796 2795 <ul>
2797 2796 <li><a href="/shortlog">log</a></li>
2798 2797 <li><a href="/graph">graph</a></li>
2799 2798 <li><a href="/tags">tags</a></li>
2800 2799 <li><a href="/bookmarks">bookmarks</a></li>
2801 2800 <li><a href="/branches">branches</a></li>
2802 2801 </ul>
2803 2802 <ul>
2804 2803 <li class="active"><a href="/help">help</a></li>
2805 2804 </ul>
2806 2805 </div>
2807 2806
2808 2807 <div class="main">
2809 2808 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2810 2809 <h3>Help: dates</h3>
2811 2810
2812 2811 <form class="search" action="/log">
2813 2812
2814 2813 <p><input name="rev" id="search1" type="text" size="30" /></p>
2815 2814 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2816 2815 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2817 2816 </form>
2818 2817 <div id="doc">
2819 2818 <h1>Date Formats</h1>
2820 2819 <p>
2821 2820 Some commands allow the user to specify a date, e.g.:
2822 2821 </p>
2823 2822 <ul>
2824 2823 <li> backout, commit, import, tag: Specify the commit date.
2825 2824 <li> log, revert, update: Select revision(s) by date.
2826 2825 </ul>
2827 2826 <p>
2828 2827 Many date formats are valid. Here are some examples:
2829 2828 </p>
2830 2829 <ul>
2831 2830 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
2832 2831 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
2833 2832 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
2834 2833 <li> &quot;Dec 6&quot; (midnight)
2835 2834 <li> &quot;13:18&quot; (today assumed)
2836 2835 <li> &quot;3:39&quot; (3:39AM assumed)
2837 2836 <li> &quot;3:39pm&quot; (15:39)
2838 2837 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
2839 2838 <li> &quot;2006-12-6 13:18&quot;
2840 2839 <li> &quot;2006-12-6&quot;
2841 2840 <li> &quot;12-6&quot;
2842 2841 <li> &quot;12/6&quot;
2843 2842 <li> &quot;12/6/6&quot; (Dec 6 2006)
2844 2843 <li> &quot;today&quot; (midnight)
2845 2844 <li> &quot;yesterday&quot; (midnight)
2846 2845 <li> &quot;now&quot; - right now
2847 2846 </ul>
2848 2847 <p>
2849 2848 Lastly, there is Mercurial's internal format:
2850 2849 </p>
2851 2850 <ul>
2852 2851 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
2853 2852 </ul>
2854 2853 <p>
2855 2854 This is the internal representation format for dates. The first number
2856 2855 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
2857 2856 second is the offset of the local timezone, in seconds west of UTC
2858 2857 (negative if the timezone is east of UTC).
2859 2858 </p>
2860 2859 <p>
2861 2860 The log command also accepts date ranges:
2862 2861 </p>
2863 2862 <ul>
2864 2863 <li> &quot;&lt;DATE&quot; - at or before a given date/time
2865 2864 <li> &quot;&gt;DATE&quot; - on or after a given date/time
2866 2865 <li> &quot;DATE to DATE&quot; - a date range, inclusive
2867 2866 <li> &quot;-DAYS&quot; - within a given number of days of today
2868 2867 </ul>
2869 2868
2870 2869 </div>
2871 2870 </div>
2872 2871 </div>
2873 2872
2874 2873
2875 2874
2876 2875 </body>
2877 2876 </html>
2878 2877
2879 2878
2880 2879 Sub-topic indexes rendered properly
2881 2880
2882 2881 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
2883 2882 200 Script output follows
2884 2883
2885 2884 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2886 2885 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2887 2886 <head>
2888 2887 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2889 2888 <meta name="robots" content="index, nofollow" />
2890 2889 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2891 2890 <script type="text/javascript" src="/static/mercurial.js"></script>
2892 2891
2893 2892 <title>Help: internals</title>
2894 2893 </head>
2895 2894 <body>
2896 2895
2897 2896 <div class="container">
2898 2897 <div class="menu">
2899 2898 <div class="logo">
2900 2899 <a href="https://mercurial-scm.org/">
2901 2900 <img src="/static/hglogo.png" alt="mercurial" /></a>
2902 2901 </div>
2903 2902 <ul>
2904 2903 <li><a href="/shortlog">log</a></li>
2905 2904 <li><a href="/graph">graph</a></li>
2906 2905 <li><a href="/tags">tags</a></li>
2907 2906 <li><a href="/bookmarks">bookmarks</a></li>
2908 2907 <li><a href="/branches">branches</a></li>
2909 2908 </ul>
2910 2909 <ul>
2911 2910 <li><a href="/help">help</a></li>
2912 2911 </ul>
2913 2912 </div>
2914 2913
2915 2914 <div class="main">
2916 2915 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2917 2916 <form class="search" action="/log">
2918 2917
2919 2918 <p><input name="rev" id="search1" type="text" size="30" /></p>
2920 2919 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2921 2920 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2922 2921 </form>
2923 2922 <table class="bigtable">
2924 2923 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2925 2924
2926 2925 <tr><td>
2927 2926 <a href="/help/internals.bundles">
2928 2927 bundles
2929 2928 </a>
2930 2929 </td><td>
2931 2930 Bundles
2932 2931 </td></tr>
2933 2932 <tr><td>
2934 2933 <a href="/help/internals.changegroups">
2935 2934 changegroups
2936 2935 </a>
2937 2936 </td><td>
2938 2937 Changegroups
2939 2938 </td></tr>
2940 2939 <tr><td>
2941 2940 <a href="/help/internals.requirements">
2942 2941 requirements
2943 2942 </a>
2944 2943 </td><td>
2945 2944 Repository Requirements
2946 2945 </td></tr>
2947 2946 <tr><td>
2948 2947 <a href="/help/internals.revlogs">
2949 2948 revlogs
2950 2949 </a>
2951 2950 </td><td>
2952 2951 Revision Logs
2953 2952 </td></tr>
2954 2953 <tr><td>
2955 2954 <a href="/help/internals.wireprotocol">
2956 2955 wireprotocol
2957 2956 </a>
2958 2957 </td><td>
2959 2958 Wire Protocol
2960 2959 </td></tr>
2961 2960
2962 2961
2963 2962
2964 2963
2965 2964
2966 2965 </table>
2967 2966 </div>
2968 2967 </div>
2969 2968
2970 2969
2971 2970
2972 2971 </body>
2973 2972 </html>
2974 2973
2975 2974
2976 2975 Sub-topic topics rendered properly
2977 2976
2978 2977 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
2979 2978 200 Script output follows
2980 2979
2981 2980 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2982 2981 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2983 2982 <head>
2984 2983 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2985 2984 <meta name="robots" content="index, nofollow" />
2986 2985 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2987 2986 <script type="text/javascript" src="/static/mercurial.js"></script>
2988 2987
2989 2988 <title>Help: internals.changegroups</title>
2990 2989 </head>
2991 2990 <body>
2992 2991
2993 2992 <div class="container">
2994 2993 <div class="menu">
2995 2994 <div class="logo">
2996 2995 <a href="https://mercurial-scm.org/">
2997 2996 <img src="/static/hglogo.png" alt="mercurial" /></a>
2998 2997 </div>
2999 2998 <ul>
3000 2999 <li><a href="/shortlog">log</a></li>
3001 3000 <li><a href="/graph">graph</a></li>
3002 3001 <li><a href="/tags">tags</a></li>
3003 3002 <li><a href="/bookmarks">bookmarks</a></li>
3004 3003 <li><a href="/branches">branches</a></li>
3005 3004 </ul>
3006 3005 <ul>
3007 3006 <li class="active"><a href="/help">help</a></li>
3008 3007 </ul>
3009 3008 </div>
3010 3009
3011 3010 <div class="main">
3012 3011 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3013 3012 <h3>Help: internals.changegroups</h3>
3014 3013
3015 3014 <form class="search" action="/log">
3016 3015
3017 3016 <p><input name="rev" id="search1" type="text" size="30" /></p>
3018 3017 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3019 3018 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3020 3019 </form>
3021 3020 <div id="doc">
3022 3021 <h1>Changegroups</h1>
3023 3022 <p>
3024 3023 Changegroups are representations of repository revlog data, specifically
3025 3024 the changelog, manifest, and filelogs.
3026 3025 </p>
3027 3026 <p>
3028 3027 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3029 3028 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with
3030 3029 the only difference being a header on entries in the changeset
3031 3030 segment. Version &quot;3&quot; adds support for exchanging treemanifests and
3032 3031 includes revlog flags in the delta header.
3033 3032 </p>
3034 3033 <p>
3035 3034 Changegroups consists of 3 logical segments:
3036 3035 </p>
3037 3036 <pre>
3038 3037 +---------------------------------+
3039 3038 | | | |
3040 3039 | changeset | manifest | filelogs |
3041 3040 | | | |
3042 3041 +---------------------------------+
3043 3042 </pre>
3044 3043 <p>
3045 3044 The principle building block of each segment is a *chunk*. A *chunk*
3046 3045 is a framed piece of data:
3047 3046 </p>
3048 3047 <pre>
3049 3048 +---------------------------------------+
3050 3049 | | |
3051 3050 | length | data |
3052 3051 | (32 bits) | &lt;length&gt; bytes |
3053 3052 | | |
3054 3053 +---------------------------------------+
3055 3054 </pre>
3056 3055 <p>
3057 3056 Each chunk starts with a 32-bit big-endian signed integer indicating
3058 3057 the length of the raw data that follows.
3059 3058 </p>
3060 3059 <p>
3061 3060 There is a special case chunk that has 0 length (&quot;0x00000000&quot;). We
3062 3061 call this an *empty chunk*.
3063 3062 </p>
3064 3063 <h2>Delta Groups</h2>
3065 3064 <p>
3066 3065 A *delta group* expresses the content of a revlog as a series of deltas,
3067 3066 or patches against previous revisions.
3068 3067 </p>
3069 3068 <p>
3070 3069 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3071 3070 to signal the end of the delta group:
3072 3071 </p>
3073 3072 <pre>
3074 3073 +------------------------------------------------------------------------+
3075 3074 | | | | | |
3076 3075 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3077 3076 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
3078 3077 | | | | | |
3079 3078 +------------------------------------------------------------+-----------+
3080 3079 </pre>
3081 3080 <p>
3082 3081 Each *chunk*'s data consists of the following:
3083 3082 </p>
3084 3083 <pre>
3085 3084 +-----------------------------------------+
3086 3085 | | | |
3087 3086 | delta header | mdiff header | delta |
3088 3087 | (various) | (12 bytes) | (various) |
3089 3088 | | | |
3090 3089 +-----------------------------------------+
3091 3090 </pre>
3092 3091 <p>
3093 3092 The *length* field is the byte length of the remaining 3 logical pieces
3094 3093 of data. The *delta* is a diff from an existing entry in the changelog.
3095 3094 </p>
3096 3095 <p>
3097 3096 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3098 3097 &quot;3&quot; of the changegroup format.
3099 3098 </p>
3100 3099 <p>
3101 3100 Version 1:
3102 3101 </p>
3103 3102 <pre>
3104 3103 +------------------------------------------------------+
3105 3104 | | | | |
3106 3105 | node | p1 node | p2 node | link node |
3107 3106 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3108 3107 | | | | |
3109 3108 +------------------------------------------------------+
3110 3109 </pre>
3111 3110 <p>
3112 3111 Version 2:
3113 3112 </p>
3114 3113 <pre>
3115 3114 +------------------------------------------------------------------+
3116 3115 | | | | | |
3117 3116 | node | p1 node | p2 node | base node | link node |
3118 3117 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3119 3118 | | | | | |
3120 3119 +------------------------------------------------------------------+
3121 3120 </pre>
3122 3121 <p>
3123 3122 Version 3:
3124 3123 </p>
3125 3124 <pre>
3126 3125 +------------------------------------------------------------------------------+
3127 3126 | | | | | | |
3128 3127 | node | p1 node | p2 node | base node | link node | flags |
3129 3128 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3130 3129 | | | | | | |
3131 3130 +------------------------------------------------------------------------------+
3132 3131 </pre>
3133 3132 <p>
3134 3133 The *mdiff header* consists of 3 32-bit big-endian signed integers
3135 3134 describing offsets at which to apply the following delta content:
3136 3135 </p>
3137 3136 <pre>
3138 3137 +-------------------------------------+
3139 3138 | | | |
3140 3139 | offset | old length | new length |
3141 3140 | (32 bits) | (32 bits) | (32 bits) |
3142 3141 | | | |
3143 3142 +-------------------------------------+
3144 3143 </pre>
3145 3144 <p>
3146 3145 In version 1, the delta is always applied against the previous node from
3147 3146 the changegroup or the first parent if this is the first entry in the
3148 3147 changegroup.
3149 3148 </p>
3150 3149 <p>
3151 3150 In version 2, the delta base node is encoded in the entry in the
3152 3151 changegroup. This allows the delta to be expressed against any parent,
3153 3152 which can result in smaller deltas and more efficient encoding of data.
3154 3153 </p>
3155 3154 <h2>Changeset Segment</h2>
3156 3155 <p>
3157 3156 The *changeset segment* consists of a single *delta group* holding
3158 3157 changelog data. It is followed by an *empty chunk* to denote the
3159 3158 boundary to the *manifests segment*.
3160 3159 </p>
3161 3160 <h2>Manifest Segment</h2>
3162 3161 <p>
3163 3162 The *manifest segment* consists of a single *delta group* holding
3164 3163 manifest data. It is followed by an *empty chunk* to denote the boundary
3165 3164 to the *filelogs segment*.
3166 3165 </p>
3167 3166 <h2>Filelogs Segment</h2>
3168 3167 <p>
3169 3168 The *filelogs* segment consists of multiple sub-segments, each
3170 3169 corresponding to an individual file whose data is being described:
3171 3170 </p>
3172 3171 <pre>
3173 3172 +--------------------------------------+
3174 3173 | | | | |
3175 3174 | filelog0 | filelog1 | filelog2 | ... |
3176 3175 | | | | |
3177 3176 +--------------------------------------+
3178 3177 </pre>
3179 3178 <p>
3180 3179 In version &quot;3&quot; of the changegroup format, filelogs may include
3181 3180 directory logs when treemanifests are in use. directory logs are
3182 3181 identified by having a trailing '/' on their filename (see below).
3183 3182 </p>
3184 3183 <p>
3185 3184 The final filelog sub-segment is followed by an *empty chunk* to denote
3186 3185 the end of the segment and the overall changegroup.
3187 3186 </p>
3188 3187 <p>
3189 3188 Each filelog sub-segment consists of the following:
3190 3189 </p>
3191 3190 <pre>
3192 3191 +------------------------------------------+
3193 3192 | | | |
3194 3193 | filename size | filename | delta group |
3195 3194 | (32 bits) | (various) | (various) |
3196 3195 | | | |
3197 3196 +------------------------------------------+
3198 3197 </pre>
3199 3198 <p>
3200 3199 That is, a *chunk* consisting of the filename (not terminated or padded)
3201 3200 followed by N chunks constituting the *delta group* for this file.
3202 3201 </p>
3203 3202
3204 3203 </div>
3205 3204 </div>
3206 3205 </div>
3207 3206
3208 3207
3209 3208
3210 3209 </body>
3211 3210 </html>
3212 3211
3213 3212
3214 3213 $ killdaemons.py
3215 3214
3216 3215 #endif
General Comments 0
You need to be logged in to leave comments. Login now