##// 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 <?xml version="1.0" encoding="utf-8"?>
1 <?xml version="1.0" encoding="utf-8"?>
2 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
2 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3
3
4 <?include guids.wxi ?>
4 <?include guids.wxi ?>
5 <?include defines.wxi ?>
5 <?include defines.wxi ?>
6
6
7 <Fragment>
7 <Fragment>
8 <ComponentGroup Id='helpFolder'>
8 <ComponentGroup Id='helpFolder'>
9 <ComponentRef Id='help.root' />
9 <ComponentRef Id='help.root' />
10 <ComponentRef Id='help.internals' />
10 <ComponentRef Id='help.internals' />
11 </ComponentGroup>
11 </ComponentGroup>
12 </Fragment>
12 </Fragment>
13
13
14 <Fragment>
14 <Fragment>
15 <DirectoryRef Id="INSTALLDIR">
15 <DirectoryRef Id="INSTALLDIR">
16 <Directory Id="helpdir" Name="help" FileSource="$(var.SourceDir)">
16 <Directory Id="helpdir" Name="help" FileSource="$(var.SourceDir)">
17 <Component Id="help.root" Guid="$(var.help.root.guid)" Win64='$(var.IsX64)'>
17 <Component Id="help.root" Guid="$(var.help.root.guid)" Win64='$(var.IsX64)'>
18 <File Name="color.txt" />
18 <File Name="config.txt" KeyPath="yes" />
19 <File Name="config.txt" KeyPath="yes" />
19 <File Name="dates.txt" />
20 <File Name="dates.txt" />
20 <File Name="diffs.txt" />
21 <File Name="diffs.txt" />
21 <File Name="environment.txt" />
22 <File Name="environment.txt" />
22 <File Name="extensions.txt" />
23 <File Name="extensions.txt" />
23 <File Name="filesets.txt" />
24 <File Name="filesets.txt" />
24 <File Name="glossary.txt" />
25 <File Name="glossary.txt" />
25 <File Name="hgignore.txt" />
26 <File Name="hgignore.txt" />
26 <File Name="hgweb.txt" />
27 <File Name="hgweb.txt" />
27 <File Name="merge-tools.txt" />
28 <File Name="merge-tools.txt" />
28 <File Name="pager.txt" />
29 <File Name="pager.txt" />
29 <File Name="patterns.txt" />
30 <File Name="patterns.txt" />
30 <File Name="phases.txt" />
31 <File Name="phases.txt" />
31 <File Name="revisions.txt" />
32 <File Name="revisions.txt" />
32 <File Name="scripting.txt" />
33 <File Name="scripting.txt" />
33 <File Name="subrepos.txt" />
34 <File Name="subrepos.txt" />
34 <File Name="templates.txt" />
35 <File Name="templates.txt" />
35 <File Name="urls.txt" />
36 <File Name="urls.txt" />
36 </Component>
37 </Component>
37
38
38 <Directory Id="help.internaldir" Name="internals">
39 <Directory Id="help.internaldir" Name="internals">
39 <Component Id="help.internals" Guid="$(var.help.internals.guid)" Win64='$(var.IsX64)'>
40 <Component Id="help.internals" Guid="$(var.help.internals.guid)" Win64='$(var.IsX64)'>
40 <File Id="internals.bundles.txt" Name="bundles.txt" KeyPath="yes" />
41 <File Id="internals.bundles.txt" Name="bundles.txt" KeyPath="yes" />
41 <File Id="internals.changegroups.txt" Name="changegroups.txt" />
42 <File Id="internals.changegroups.txt" Name="changegroups.txt" />
42 <File Id="internals.requirements.txt" Name="requirements.txt" />
43 <File Id="internals.requirements.txt" Name="requirements.txt" />
43 <File Id="internals.revlogs.txt" Name="revlogs.txt" />
44 <File Id="internals.revlogs.txt" Name="revlogs.txt" />
44 <File Id="internals.wireprotocol.txt" Name="wireprotocol.txt" />
45 <File Id="internals.wireprotocol.txt" Name="wireprotocol.txt" />
45 </Component>
46 </Component>
46 </Directory>
47 </Directory>
47
48
48 </Directory>
49 </Directory>
49 </DirectoryRef>
50 </DirectoryRef>
50 </Fragment>
51 </Fragment>
51
52
52 </Wix>
53 </Wix>
@@ -1,186 +1,31 b''
1 # color.py color output for Mercurial commands
1 # color.py color output for Mercurial commands
2 #
2 #
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''colorize output from some commands
8 '''enable Mercurial color mode (DEPRECATED)
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.
40
9
41 Labels
10 This extensions enable Mercurial color mode. The feature is now directly
42 ------
11 available in Mercurial core. You can access it using::
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
76
12
77 diff.diffline = bold
13 [ui]
78 diff.extended = cyan bold
14 color = auto
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 -------------
117
15
118 Because there are only eight standard colors, this module allows you
16 See :hg:`help color` for details.
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.
163 '''
17 '''
164
18
165 from __future__ import absolute_import
19 from __future__ import absolute_import
166
20
167 from mercurial import (
21 from mercurial import color
168 color,
169 commands
170 )
171
22
172 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
173 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
174 # be specifying the version(s) of Mercurial they are tested with, or
25 # be specifying the version(s) of Mercurial they are tested with, or
175 # leave the attribute unspecified.
26 # leave the attribute unspecified.
176 testedwith = 'ships-with-hg-core'
27 testedwith = 'ships-with-hg-core'
177
28
178 def extsetup(ui):
29 def extsetup(ui):
179 # change default color config
30 # change default color config
180 color._enabledbydefault = True
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 # utility for color output for Mercurial commands
1 # utility for color output for Mercurial commands
2 #
2 #
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> and other
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> and other
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from .i18n import _
10 from .i18n import _
11
11
12 from . import (
12 from . import (
13 encoding,
13 encoding,
14 pycompat,
14 pycompat,
15 util
15 util
16 )
16 )
17
17
18 try:
18 try:
19 import curses
19 import curses
20 # Mapping from effect name to terminfo attribute name (or raw code) or
20 # Mapping from effect name to terminfo attribute name (or raw code) or
21 # color number. This will also force-load the curses module.
21 # color number. This will also force-load the curses module.
22 _baseterminfoparams = {
22 _baseterminfoparams = {
23 'none': (True, 'sgr0', ''),
23 'none': (True, 'sgr0', ''),
24 'standout': (True, 'smso', ''),
24 'standout': (True, 'smso', ''),
25 'underline': (True, 'smul', ''),
25 'underline': (True, 'smul', ''),
26 'reverse': (True, 'rev', ''),
26 'reverse': (True, 'rev', ''),
27 'inverse': (True, 'rev', ''),
27 'inverse': (True, 'rev', ''),
28 'blink': (True, 'blink', ''),
28 'blink': (True, 'blink', ''),
29 'dim': (True, 'dim', ''),
29 'dim': (True, 'dim', ''),
30 'bold': (True, 'bold', ''),
30 'bold': (True, 'bold', ''),
31 'invisible': (True, 'invis', ''),
31 'invisible': (True, 'invis', ''),
32 'italic': (True, 'sitm', ''),
32 'italic': (True, 'sitm', ''),
33 'black': (False, curses.COLOR_BLACK, ''),
33 'black': (False, curses.COLOR_BLACK, ''),
34 'red': (False, curses.COLOR_RED, ''),
34 'red': (False, curses.COLOR_RED, ''),
35 'green': (False, curses.COLOR_GREEN, ''),
35 'green': (False, curses.COLOR_GREEN, ''),
36 'yellow': (False, curses.COLOR_YELLOW, ''),
36 'yellow': (False, curses.COLOR_YELLOW, ''),
37 'blue': (False, curses.COLOR_BLUE, ''),
37 'blue': (False, curses.COLOR_BLUE, ''),
38 'magenta': (False, curses.COLOR_MAGENTA, ''),
38 'magenta': (False, curses.COLOR_MAGENTA, ''),
39 'cyan': (False, curses.COLOR_CYAN, ''),
39 'cyan': (False, curses.COLOR_CYAN, ''),
40 'white': (False, curses.COLOR_WHITE, ''),
40 'white': (False, curses.COLOR_WHITE, ''),
41 }
41 }
42 except ImportError:
42 except ImportError:
43 curses = None
43 curses = None
44 _baseterminfoparams = {}
44 _baseterminfoparams = {}
45
45
46 # allow the extensions to change the default
46 # allow the extensions to change the default
47 _enabledbydefault = False
47 _enabledbydefault = False
48
48
49 # start and stop parameters for effects
49 # start and stop parameters for effects
50 _effects = {
50 _effects = {
51 'none': 0,
51 'none': 0,
52 'black': 30,
52 'black': 30,
53 'red': 31,
53 'red': 31,
54 'green': 32,
54 'green': 32,
55 'yellow': 33,
55 'yellow': 33,
56 'blue': 34,
56 'blue': 34,
57 'magenta': 35,
57 'magenta': 35,
58 'cyan': 36,
58 'cyan': 36,
59 'white': 37,
59 'white': 37,
60 'bold': 1,
60 'bold': 1,
61 'italic': 3,
61 'italic': 3,
62 'underline': 4,
62 'underline': 4,
63 'inverse': 7,
63 'inverse': 7,
64 'dim': 2,
64 'dim': 2,
65 'black_background': 40,
65 'black_background': 40,
66 'red_background': 41,
66 'red_background': 41,
67 'green_background': 42,
67 'green_background': 42,
68 'yellow_background': 43,
68 'yellow_background': 43,
69 'blue_background': 44,
69 'blue_background': 44,
70 'purple_background': 45,
70 'purple_background': 45,
71 'cyan_background': 46,
71 'cyan_background': 46,
72 'white_background': 47,
72 'white_background': 47,
73 }
73 }
74
74
75 _defaultstyles = {
75 _defaultstyles = {
76 'grep.match': 'red bold',
76 'grep.match': 'red bold',
77 'grep.linenumber': 'green',
77 'grep.linenumber': 'green',
78 'grep.rev': 'green',
78 'grep.rev': 'green',
79 'grep.change': 'green',
79 'grep.change': 'green',
80 'grep.sep': 'cyan',
80 'grep.sep': 'cyan',
81 'grep.filename': 'magenta',
81 'grep.filename': 'magenta',
82 'grep.user': 'magenta',
82 'grep.user': 'magenta',
83 'grep.date': 'magenta',
83 'grep.date': 'magenta',
84 'bookmarks.active': 'green',
84 'bookmarks.active': 'green',
85 'branches.active': 'none',
85 'branches.active': 'none',
86 'branches.closed': 'black bold',
86 'branches.closed': 'black bold',
87 'branches.current': 'green',
87 'branches.current': 'green',
88 'branches.inactive': 'none',
88 'branches.inactive': 'none',
89 'diff.changed': 'white',
89 'diff.changed': 'white',
90 'diff.deleted': 'red',
90 'diff.deleted': 'red',
91 'diff.diffline': 'bold',
91 'diff.diffline': 'bold',
92 'diff.extended': 'cyan bold',
92 'diff.extended': 'cyan bold',
93 'diff.file_a': 'red bold',
93 'diff.file_a': 'red bold',
94 'diff.file_b': 'green bold',
94 'diff.file_b': 'green bold',
95 'diff.hunk': 'magenta',
95 'diff.hunk': 'magenta',
96 'diff.inserted': 'green',
96 'diff.inserted': 'green',
97 'diff.tab': '',
97 'diff.tab': '',
98 'diff.trailingwhitespace': 'bold red_background',
98 'diff.trailingwhitespace': 'bold red_background',
99 'changeset.public' : '',
99 'changeset.public' : '',
100 'changeset.draft' : '',
100 'changeset.draft' : '',
101 'changeset.secret' : '',
101 'changeset.secret' : '',
102 'diffstat.deleted': 'red',
102 'diffstat.deleted': 'red',
103 'diffstat.inserted': 'green',
103 'diffstat.inserted': 'green',
104 'histedit.remaining': 'red bold',
104 'histedit.remaining': 'red bold',
105 'ui.prompt': 'yellow',
105 'ui.prompt': 'yellow',
106 'log.changeset': 'yellow',
106 'log.changeset': 'yellow',
107 'patchbomb.finalsummary': '',
107 'patchbomb.finalsummary': '',
108 'patchbomb.from': 'magenta',
108 'patchbomb.from': 'magenta',
109 'patchbomb.to': 'cyan',
109 'patchbomb.to': 'cyan',
110 'patchbomb.subject': 'green',
110 'patchbomb.subject': 'green',
111 'patchbomb.diffstats': '',
111 'patchbomb.diffstats': '',
112 'rebase.rebased': 'blue',
112 'rebase.rebased': 'blue',
113 'rebase.remaining': 'red bold',
113 'rebase.remaining': 'red bold',
114 'resolve.resolved': 'green bold',
114 'resolve.resolved': 'green bold',
115 'resolve.unresolved': 'red bold',
115 'resolve.unresolved': 'red bold',
116 'shelve.age': 'cyan',
116 'shelve.age': 'cyan',
117 'shelve.newest': 'green bold',
117 'shelve.newest': 'green bold',
118 'shelve.name': 'blue bold',
118 'shelve.name': 'blue bold',
119 'status.added': 'green bold',
119 'status.added': 'green bold',
120 'status.clean': 'none',
120 'status.clean': 'none',
121 'status.copied': 'none',
121 'status.copied': 'none',
122 'status.deleted': 'cyan bold underline',
122 'status.deleted': 'cyan bold underline',
123 'status.ignored': 'black bold',
123 'status.ignored': 'black bold',
124 'status.modified': 'blue bold',
124 'status.modified': 'blue bold',
125 'status.removed': 'red bold',
125 'status.removed': 'red bold',
126 'status.unknown': 'magenta bold underline',
126 'status.unknown': 'magenta bold underline',
127 'tags.normal': 'green',
127 'tags.normal': 'green',
128 'tags.local': 'black bold',
128 'tags.local': 'black bold',
129 }
129 }
130
130
131 def loadcolortable(ui, extname, colortable):
131 def loadcolortable(ui, extname, colortable):
132 _defaultstyles.update(colortable)
132 _defaultstyles.update(colortable)
133
133
134 def _terminfosetup(ui, mode):
134 def _terminfosetup(ui, mode):
135 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
135 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
136
136
137 # If we failed to load curses, we go ahead and return.
137 # If we failed to load curses, we go ahead and return.
138 if curses is None:
138 if curses is None:
139 return
139 return
140 # Otherwise, see what the config file says.
140 # Otherwise, see what the config file says.
141 if mode not in ('auto', 'terminfo'):
141 if mode not in ('auto', 'terminfo'):
142 return
142 return
143 ui._terminfoparams.update(_baseterminfoparams)
143 ui._terminfoparams.update(_baseterminfoparams)
144
144
145 for key, val in ui.configitems('color'):
145 for key, val in ui.configitems('color'):
146 if key.startswith('color.'):
146 if key.startswith('color.'):
147 newval = (False, int(val), '')
147 newval = (False, int(val), '')
148 ui._terminfoparams[key[6:]] = newval
148 ui._terminfoparams[key[6:]] = newval
149 elif key.startswith('terminfo.'):
149 elif key.startswith('terminfo.'):
150 newval = (True, '', val.replace('\\E', '\x1b'))
150 newval = (True, '', val.replace('\\E', '\x1b'))
151 ui._terminfoparams[key[9:]] = newval
151 ui._terminfoparams[key[9:]] = newval
152 try:
152 try:
153 curses.setupterm()
153 curses.setupterm()
154 except curses.error as e:
154 except curses.error as e:
155 ui._terminfoparams.clear()
155 ui._terminfoparams.clear()
156 return
156 return
157
157
158 for key, (b, e, c) in ui._terminfoparams.items():
158 for key, (b, e, c) in ui._terminfoparams.items():
159 if not b:
159 if not b:
160 continue
160 continue
161 if not c and not curses.tigetstr(e):
161 if not c and not curses.tigetstr(e):
162 # Most terminals don't support dim, invis, etc, so don't be
162 # Most terminals don't support dim, invis, etc, so don't be
163 # noisy and use ui.debug().
163 # noisy and use ui.debug().
164 ui.debug("no terminfo entry for %s\n" % e)
164 ui.debug("no terminfo entry for %s\n" % e)
165 del ui._terminfoparams[key]
165 del ui._terminfoparams[key]
166 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
166 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
167 # Only warn about missing terminfo entries if we explicitly asked for
167 # Only warn about missing terminfo entries if we explicitly asked for
168 # terminfo mode.
168 # terminfo mode.
169 if mode == "terminfo":
169 if mode == "terminfo":
170 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
170 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
171 "ECMA-48 color\n"))
171 "ECMA-48 color\n"))
172 ui._terminfoparams.clear()
172 ui._terminfoparams.clear()
173
173
174 def setup(ui):
174 def setup(ui):
175 """configure color on a ui
175 """configure color on a ui
176
176
177 That function both set the colormode for the ui object and read
177 That function both set the colormode for the ui object and read
178 the configuration looking for custom colors and effect definitions."""
178 the configuration looking for custom colors and effect definitions."""
179 mode = _modesetup(ui)
179 mode = _modesetup(ui)
180 ui._colormode = mode
180 ui._colormode = mode
181 if mode and mode != 'debug':
181 if mode and mode != 'debug':
182 configstyles(ui)
182 configstyles(ui)
183
183
184 def _modesetup(ui):
184 def _modesetup(ui):
185 if ui.plain():
185 if ui.plain():
186 return None
186 return None
187 default = 'never'
187 default = 'never'
188 if _enabledbydefault:
188 if _enabledbydefault:
189 default = 'auto'
189 default = 'auto'
190 # experimental config: ui.color
191 config = ui.config('ui', 'color', default)
190 config = ui.config('ui', 'color', default)
192 if config == 'debug':
191 if config == 'debug':
193 return 'debug'
192 return 'debug'
194
193
195 auto = (config == 'auto')
194 auto = (config == 'auto')
196 always = not auto and util.parsebool(config)
195 always = not auto and util.parsebool(config)
197 if not always and not auto:
196 if not always and not auto:
198 return None
197 return None
199
198
200 formatted = (always or (encoding.environ.get('TERM') != 'dumb'
199 formatted = (always or (encoding.environ.get('TERM') != 'dumb'
201 and ui.formatted()))
200 and ui.formatted()))
202
201
203 mode = ui.config('color', 'mode', 'auto')
202 mode = ui.config('color', 'mode', 'auto')
204
203
205 # If pager is active, color.pagermode overrides color.mode.
204 # If pager is active, color.pagermode overrides color.mode.
206 if getattr(ui, 'pageractive', False):
205 if getattr(ui, 'pageractive', False):
207 mode = ui.config('color', 'pagermode', mode)
206 mode = ui.config('color', 'pagermode', mode)
208
207
209 realmode = mode
208 realmode = mode
210 if mode == 'auto':
209 if mode == 'auto':
211 if pycompat.osname == 'nt':
210 if pycompat.osname == 'nt':
212 term = encoding.environ.get('TERM')
211 term = encoding.environ.get('TERM')
213 # TERM won't be defined in a vanilla cmd.exe environment.
212 # TERM won't be defined in a vanilla cmd.exe environment.
214
213
215 # UNIX-like environments on Windows such as Cygwin and MSYS will
214 # UNIX-like environments on Windows such as Cygwin and MSYS will
216 # set TERM. They appear to make a best effort attempt at setting it
215 # set TERM. They appear to make a best effort attempt at setting it
217 # to something appropriate. However, not all environments with TERM
216 # to something appropriate. However, not all environments with TERM
218 # defined support ANSI. Since "ansi" could result in terminal
217 # defined support ANSI. Since "ansi" could result in terminal
219 # gibberish, we error on the side of selecting "win32". However, if
218 # gibberish, we error on the side of selecting "win32". However, if
220 # w32effects is not defined, we almost certainly don't support
219 # w32effects is not defined, we almost certainly don't support
221 # "win32", so don't even try.
220 # "win32", so don't even try.
222 if (term and 'xterm' in term) or not w32effects:
221 if (term and 'xterm' in term) or not w32effects:
223 realmode = 'ansi'
222 realmode = 'ansi'
224 else:
223 else:
225 realmode = 'win32'
224 realmode = 'win32'
226 else:
225 else:
227 realmode = 'ansi'
226 realmode = 'ansi'
228
227
229 def modewarn():
228 def modewarn():
230 # only warn if color.mode was explicitly set and we're in
229 # only warn if color.mode was explicitly set and we're in
231 # a formatted terminal
230 # a formatted terminal
232 if mode == realmode and ui.formatted():
231 if mode == realmode and ui.formatted():
233 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
232 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
234
233
235 if realmode == 'win32':
234 if realmode == 'win32':
236 ui._terminfoparams.clear()
235 ui._terminfoparams.clear()
237 if not w32effects:
236 if not w32effects:
238 modewarn()
237 modewarn()
239 return None
238 return None
240 _effects.update(w32effects)
239 _effects.update(w32effects)
241 elif realmode == 'ansi':
240 elif realmode == 'ansi':
242 ui._terminfoparams.clear()
241 ui._terminfoparams.clear()
243 elif realmode == 'terminfo':
242 elif realmode == 'terminfo':
244 _terminfosetup(ui, mode)
243 _terminfosetup(ui, mode)
245 if not ui._terminfoparams:
244 if not ui._terminfoparams:
246 ## FIXME Shouldn't we return None in this case too?
245 ## FIXME Shouldn't we return None in this case too?
247 modewarn()
246 modewarn()
248 realmode = 'ansi'
247 realmode = 'ansi'
249 else:
248 else:
250 return None
249 return None
251
250
252 if always or (auto and formatted):
251 if always or (auto and formatted):
253 return realmode
252 return realmode
254 return None
253 return None
255
254
256 def configstyles(ui):
255 def configstyles(ui):
257 ui._styles.update(_defaultstyles)
256 ui._styles.update(_defaultstyles)
258 for status, cfgeffects in ui.configitems('color'):
257 for status, cfgeffects in ui.configitems('color'):
259 if '.' not in status or status.startswith(('color.', 'terminfo.')):
258 if '.' not in status or status.startswith(('color.', 'terminfo.')):
260 continue
259 continue
261 cfgeffects = ui.configlist('color', status)
260 cfgeffects = ui.configlist('color', status)
262 if cfgeffects:
261 if cfgeffects:
263 good = []
262 good = []
264 for e in cfgeffects:
263 for e in cfgeffects:
265 if valideffect(ui, e):
264 if valideffect(ui, e):
266 good.append(e)
265 good.append(e)
267 else:
266 else:
268 ui.warn(_("ignoring unknown color/effect %r "
267 ui.warn(_("ignoring unknown color/effect %r "
269 "(configured in color.%s)\n")
268 "(configured in color.%s)\n")
270 % (e, status))
269 % (e, status))
271 ui._styles[status] = ' '.join(good)
270 ui._styles[status] = ' '.join(good)
272
271
273 def valideffect(ui, effect):
272 def valideffect(ui, effect):
274 'Determine if the effect is valid or not.'
273 'Determine if the effect is valid or not.'
275 return ((not ui._terminfoparams and effect in _effects)
274 return ((not ui._terminfoparams and effect in _effects)
276 or (effect in ui._terminfoparams
275 or (effect in ui._terminfoparams
277 or effect[:-11] in ui._terminfoparams))
276 or effect[:-11] in ui._terminfoparams))
278
277
279 def _effect_str(ui, effect):
278 def _effect_str(ui, effect):
280 '''Helper function for render_effects().'''
279 '''Helper function for render_effects().'''
281
280
282 bg = False
281 bg = False
283 if effect.endswith('_background'):
282 if effect.endswith('_background'):
284 bg = True
283 bg = True
285 effect = effect[:-11]
284 effect = effect[:-11]
286 try:
285 try:
287 attr, val, termcode = ui._terminfoparams[effect]
286 attr, val, termcode = ui._terminfoparams[effect]
288 except KeyError:
287 except KeyError:
289 return ''
288 return ''
290 if attr:
289 if attr:
291 if termcode:
290 if termcode:
292 return termcode
291 return termcode
293 else:
292 else:
294 return curses.tigetstr(val)
293 return curses.tigetstr(val)
295 elif bg:
294 elif bg:
296 return curses.tparm(curses.tigetstr('setab'), val)
295 return curses.tparm(curses.tigetstr('setab'), val)
297 else:
296 else:
298 return curses.tparm(curses.tigetstr('setaf'), val)
297 return curses.tparm(curses.tigetstr('setaf'), val)
299
298
300 def _render_effects(ui, text, effects):
299 def _render_effects(ui, text, effects):
301 'Wrap text in commands to turn on each effect.'
300 'Wrap text in commands to turn on each effect.'
302 if not text:
301 if not text:
303 return text
302 return text
304 if ui._terminfoparams:
303 if ui._terminfoparams:
305 start = ''.join(_effect_str(ui, effect)
304 start = ''.join(_effect_str(ui, effect)
306 for effect in ['none'] + effects.split())
305 for effect in ['none'] + effects.split())
307 stop = _effect_str(ui, 'none')
306 stop = _effect_str(ui, 'none')
308 else:
307 else:
309 start = [str(_effects[e]) for e in ['none'] + effects.split()]
308 start = [str(_effects[e]) for e in ['none'] + effects.split()]
310 start = '\033[' + ';'.join(start) + 'm'
309 start = '\033[' + ';'.join(start) + 'm'
311 stop = '\033[' + str(_effects['none']) + 'm'
310 stop = '\033[' + str(_effects['none']) + 'm'
312 return ''.join([start, text, stop])
311 return ''.join([start, text, stop])
313
312
314 def colorlabel(ui, msg, label):
313 def colorlabel(ui, msg, label):
315 """add color control code according to the mode"""
314 """add color control code according to the mode"""
316 if ui._colormode == 'debug':
315 if ui._colormode == 'debug':
317 if label and msg:
316 if label and msg:
318 if msg[-1] == '\n':
317 if msg[-1] == '\n':
319 msg = "[%s|%s]\n" % (label, msg[:-1])
318 msg = "[%s|%s]\n" % (label, msg[:-1])
320 else:
319 else:
321 msg = "[%s|%s]" % (label, msg)
320 msg = "[%s|%s]" % (label, msg)
322 elif ui._colormode is not None:
321 elif ui._colormode is not None:
323 effects = []
322 effects = []
324 for l in label.split():
323 for l in label.split():
325 s = ui._styles.get(l, '')
324 s = ui._styles.get(l, '')
326 if s:
325 if s:
327 effects.append(s)
326 effects.append(s)
328 elif valideffect(ui, l):
327 elif valideffect(ui, l):
329 effects.append(l)
328 effects.append(l)
330 effects = ' '.join(effects)
329 effects = ' '.join(effects)
331 if effects:
330 if effects:
332 msg = '\n'.join([_render_effects(ui, line, effects)
331 msg = '\n'.join([_render_effects(ui, line, effects)
333 for line in msg.split('\n')])
332 for line in msg.split('\n')])
334 return msg
333 return msg
335
334
336 w32effects = None
335 w32effects = None
337 if pycompat.osname == 'nt':
336 if pycompat.osname == 'nt':
338 import ctypes
337 import ctypes
339 import re
338 import re
340
339
341 _kernel32 = ctypes.windll.kernel32
340 _kernel32 = ctypes.windll.kernel32
342
341
343 _WORD = ctypes.c_ushort
342 _WORD = ctypes.c_ushort
344
343
345 _INVALID_HANDLE_VALUE = -1
344 _INVALID_HANDLE_VALUE = -1
346
345
347 class _COORD(ctypes.Structure):
346 class _COORD(ctypes.Structure):
348 _fields_ = [('X', ctypes.c_short),
347 _fields_ = [('X', ctypes.c_short),
349 ('Y', ctypes.c_short)]
348 ('Y', ctypes.c_short)]
350
349
351 class _SMALL_RECT(ctypes.Structure):
350 class _SMALL_RECT(ctypes.Structure):
352 _fields_ = [('Left', ctypes.c_short),
351 _fields_ = [('Left', ctypes.c_short),
353 ('Top', ctypes.c_short),
352 ('Top', ctypes.c_short),
354 ('Right', ctypes.c_short),
353 ('Right', ctypes.c_short),
355 ('Bottom', ctypes.c_short)]
354 ('Bottom', ctypes.c_short)]
356
355
357 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
356 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
358 _fields_ = [('dwSize', _COORD),
357 _fields_ = [('dwSize', _COORD),
359 ('dwCursorPosition', _COORD),
358 ('dwCursorPosition', _COORD),
360 ('wAttributes', _WORD),
359 ('wAttributes', _WORD),
361 ('srWindow', _SMALL_RECT),
360 ('srWindow', _SMALL_RECT),
362 ('dwMaximumWindowSize', _COORD)]
361 ('dwMaximumWindowSize', _COORD)]
363
362
364 _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11
363 _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11
365 _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12
364 _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12
366
365
367 _FOREGROUND_BLUE = 0x0001
366 _FOREGROUND_BLUE = 0x0001
368 _FOREGROUND_GREEN = 0x0002
367 _FOREGROUND_GREEN = 0x0002
369 _FOREGROUND_RED = 0x0004
368 _FOREGROUND_RED = 0x0004
370 _FOREGROUND_INTENSITY = 0x0008
369 _FOREGROUND_INTENSITY = 0x0008
371
370
372 _BACKGROUND_BLUE = 0x0010
371 _BACKGROUND_BLUE = 0x0010
373 _BACKGROUND_GREEN = 0x0020
372 _BACKGROUND_GREEN = 0x0020
374 _BACKGROUND_RED = 0x0040
373 _BACKGROUND_RED = 0x0040
375 _BACKGROUND_INTENSITY = 0x0080
374 _BACKGROUND_INTENSITY = 0x0080
376
375
377 _COMMON_LVB_REVERSE_VIDEO = 0x4000
376 _COMMON_LVB_REVERSE_VIDEO = 0x4000
378 _COMMON_LVB_UNDERSCORE = 0x8000
377 _COMMON_LVB_UNDERSCORE = 0x8000
379
378
380 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
379 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
381 w32effects = {
380 w32effects = {
382 'none': -1,
381 'none': -1,
383 'black': 0,
382 'black': 0,
384 'red': _FOREGROUND_RED,
383 'red': _FOREGROUND_RED,
385 'green': _FOREGROUND_GREEN,
384 'green': _FOREGROUND_GREEN,
386 'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
385 'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
387 'blue': _FOREGROUND_BLUE,
386 'blue': _FOREGROUND_BLUE,
388 'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
387 'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
389 'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
388 'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
390 'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
389 'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
391 'bold': _FOREGROUND_INTENSITY,
390 'bold': _FOREGROUND_INTENSITY,
392 'black_background': 0x100, # unused value > 0x0f
391 'black_background': 0x100, # unused value > 0x0f
393 'red_background': _BACKGROUND_RED,
392 'red_background': _BACKGROUND_RED,
394 'green_background': _BACKGROUND_GREEN,
393 'green_background': _BACKGROUND_GREEN,
395 'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
394 'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
396 'blue_background': _BACKGROUND_BLUE,
395 'blue_background': _BACKGROUND_BLUE,
397 'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
396 'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
398 'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
397 'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
399 'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
398 'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
400 _BACKGROUND_BLUE),
399 _BACKGROUND_BLUE),
401 'bold_background': _BACKGROUND_INTENSITY,
400 'bold_background': _BACKGROUND_INTENSITY,
402 'underline': _COMMON_LVB_UNDERSCORE, # double-byte charsets only
401 'underline': _COMMON_LVB_UNDERSCORE, # double-byte charsets only
403 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only
402 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only
404 }
403 }
405
404
406 passthrough = set([_FOREGROUND_INTENSITY,
405 passthrough = set([_FOREGROUND_INTENSITY,
407 _BACKGROUND_INTENSITY,
406 _BACKGROUND_INTENSITY,
408 _COMMON_LVB_UNDERSCORE,
407 _COMMON_LVB_UNDERSCORE,
409 _COMMON_LVB_REVERSE_VIDEO])
408 _COMMON_LVB_REVERSE_VIDEO])
410
409
411 stdout = _kernel32.GetStdHandle(
410 stdout = _kernel32.GetStdHandle(
412 _STD_OUTPUT_HANDLE) # don't close the handle returned
411 _STD_OUTPUT_HANDLE) # don't close the handle returned
413 if stdout is None or stdout == _INVALID_HANDLE_VALUE:
412 if stdout is None or stdout == _INVALID_HANDLE_VALUE:
414 w32effects = None
413 w32effects = None
415 else:
414 else:
416 csbi = _CONSOLE_SCREEN_BUFFER_INFO()
415 csbi = _CONSOLE_SCREEN_BUFFER_INFO()
417 if not _kernel32.GetConsoleScreenBufferInfo(
416 if not _kernel32.GetConsoleScreenBufferInfo(
418 stdout, ctypes.byref(csbi)):
417 stdout, ctypes.byref(csbi)):
419 # stdout may not support GetConsoleScreenBufferInfo()
418 # stdout may not support GetConsoleScreenBufferInfo()
420 # when called from subprocess or redirected
419 # when called from subprocess or redirected
421 w32effects = None
420 w32effects = None
422 else:
421 else:
423 origattr = csbi.wAttributes
422 origattr = csbi.wAttributes
424 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
423 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
425 re.MULTILINE | re.DOTALL)
424 re.MULTILINE | re.DOTALL)
426
425
427 def win32print(ui, writefunc, *msgs, **opts):
426 def win32print(ui, writefunc, *msgs, **opts):
428 for text in msgs:
427 for text in msgs:
429 _win32print(ui, text, writefunc, **opts)
428 _win32print(ui, text, writefunc, **opts)
430
429
431 def _win32print(ui, text, writefunc, **opts):
430 def _win32print(ui, text, writefunc, **opts):
432 label = opts.get('label', '')
431 label = opts.get('label', '')
433 attr = origattr
432 attr = origattr
434
433
435 def mapcolor(val, attr):
434 def mapcolor(val, attr):
436 if val == -1:
435 if val == -1:
437 return origattr
436 return origattr
438 elif val in passthrough:
437 elif val in passthrough:
439 return attr | val
438 return attr | val
440 elif val > 0x0f:
439 elif val > 0x0f:
441 return (val & 0x70) | (attr & 0x8f)
440 return (val & 0x70) | (attr & 0x8f)
442 else:
441 else:
443 return (val & 0x07) | (attr & 0xf8)
442 return (val & 0x07) | (attr & 0xf8)
444
443
445 # determine console attributes based on labels
444 # determine console attributes based on labels
446 for l in label.split():
445 for l in label.split():
447 style = ui._styles.get(l, '')
446 style = ui._styles.get(l, '')
448 for effect in style.split():
447 for effect in style.split():
449 try:
448 try:
450 attr = mapcolor(w32effects[effect], attr)
449 attr = mapcolor(w32effects[effect], attr)
451 except KeyError:
450 except KeyError:
452 # w32effects could not have certain attributes so we skip
451 # w32effects could not have certain attributes so we skip
453 # them if not found
452 # them if not found
454 pass
453 pass
455 # hack to ensure regexp finds data
454 # hack to ensure regexp finds data
456 if not text.startswith('\033['):
455 if not text.startswith('\033['):
457 text = '\033[m' + text
456 text = '\033[m' + text
458
457
459 # Look for ANSI-like codes embedded in text
458 # Look for ANSI-like codes embedded in text
460 m = re.match(ansire, text)
459 m = re.match(ansire, text)
461
460
462 try:
461 try:
463 while m:
462 while m:
464 for sattr in m.group(1).split(';'):
463 for sattr in m.group(1).split(';'):
465 if sattr:
464 if sattr:
466 attr = mapcolor(int(sattr), attr)
465 attr = mapcolor(int(sattr), attr)
467 _kernel32.SetConsoleTextAttribute(stdout, attr)
466 _kernel32.SetConsoleTextAttribute(stdout, attr)
468 writefunc(m.group(2), **opts)
467 writefunc(m.group(2), **opts)
469 m = re.match(ansire, m.group(3))
468 m = re.match(ansire, m.group(3))
470 finally:
469 finally:
471 # Explicitly reset original attributes
470 # Explicitly reset original attributes
472 _kernel32.SetConsoleTextAttribute(stdout, origattr)
471 _kernel32.SetConsoleTextAttribute(stdout, origattr)
@@ -1,5435 +1,5434 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import difflib
10 import difflib
11 import errno
11 import errno
12 import os
12 import os
13 import re
13 import re
14
14
15 from .i18n import _
15 from .i18n import _
16 from .node import (
16 from .node import (
17 hex,
17 hex,
18 nullid,
18 nullid,
19 nullrev,
19 nullrev,
20 short,
20 short,
21 )
21 )
22 from . import (
22 from . import (
23 archival,
23 archival,
24 bookmarks,
24 bookmarks,
25 bundle2,
25 bundle2,
26 changegroup,
26 changegroup,
27 cmdutil,
27 cmdutil,
28 copies,
28 copies,
29 destutil,
29 destutil,
30 dirstateguard,
30 dirstateguard,
31 discovery,
31 discovery,
32 encoding,
32 encoding,
33 error,
33 error,
34 exchange,
34 exchange,
35 extensions,
35 extensions,
36 graphmod,
36 graphmod,
37 hbisect,
37 hbisect,
38 help,
38 help,
39 hg,
39 hg,
40 lock as lockmod,
40 lock as lockmod,
41 merge as mergemod,
41 merge as mergemod,
42 obsolete,
42 obsolete,
43 patch,
43 patch,
44 phases,
44 phases,
45 pycompat,
45 pycompat,
46 revsetlang,
46 revsetlang,
47 scmutil,
47 scmutil,
48 server,
48 server,
49 sshserver,
49 sshserver,
50 streamclone,
50 streamclone,
51 templatekw,
51 templatekw,
52 ui as uimod,
52 ui as uimod,
53 util,
53 util,
54 )
54 )
55
55
56 release = lockmod.release
56 release = lockmod.release
57
57
58 table = {}
58 table = {}
59
59
60 command = cmdutil.command(table)
60 command = cmdutil.command(table)
61
61
62 # label constants
62 # label constants
63 # until 3.5, bookmarks.current was the advertised name, not
63 # until 3.5, bookmarks.current was the advertised name, not
64 # bookmarks.active, so we must use both to avoid breaking old
64 # bookmarks.active, so we must use both to avoid breaking old
65 # custom styles
65 # custom styles
66 activebookmarklabel = 'bookmarks.active bookmarks.current'
66 activebookmarklabel = 'bookmarks.active bookmarks.current'
67
67
68 # common command options
68 # common command options
69
69
70 globalopts = [
70 globalopts = [
71 ('R', 'repository', '',
71 ('R', 'repository', '',
72 _('repository root directory or name of overlay bundle file'),
72 _('repository root directory or name of overlay bundle file'),
73 _('REPO')),
73 _('REPO')),
74 ('', 'cwd', '',
74 ('', 'cwd', '',
75 _('change working directory'), _('DIR')),
75 _('change working directory'), _('DIR')),
76 ('y', 'noninteractive', None,
76 ('y', 'noninteractive', None,
77 _('do not prompt, automatically pick the first choice for all prompts')),
77 _('do not prompt, automatically pick the first choice for all prompts')),
78 ('q', 'quiet', None, _('suppress output')),
78 ('q', 'quiet', None, _('suppress output')),
79 ('v', 'verbose', None, _('enable additional output')),
79 ('v', 'verbose', None, _('enable additional output')),
80 ('', 'color', '',
80 ('', 'color', '',
81 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
81 # i18n: 'always', 'auto', 'never', and 'debug' are keywords
82 # and should not be translated
82 # and should not be translated
83 _("when to colorize (boolean, always, auto, never, or debug)"
83 _("when to colorize (boolean, always, auto, never, or debug)"),
84 " (EXPERIMENTAL)"),
85 _('TYPE')),
84 _('TYPE')),
86 ('', 'config', [],
85 ('', 'config', [],
87 _('set/override config option (use \'section.name=value\')'),
86 _('set/override config option (use \'section.name=value\')'),
88 _('CONFIG')),
87 _('CONFIG')),
89 ('', 'debug', None, _('enable debugging output')),
88 ('', 'debug', None, _('enable debugging output')),
90 ('', 'debugger', None, _('start debugger')),
89 ('', 'debugger', None, _('start debugger')),
91 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
90 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
92 _('ENCODE')),
91 _('ENCODE')),
93 ('', 'encodingmode', encoding.encodingmode,
92 ('', 'encodingmode', encoding.encodingmode,
94 _('set the charset encoding mode'), _('MODE')),
93 _('set the charset encoding mode'), _('MODE')),
95 ('', 'traceback', None, _('always print a traceback on exception')),
94 ('', 'traceback', None, _('always print a traceback on exception')),
96 ('', 'time', None, _('time how long the command takes')),
95 ('', 'time', None, _('time how long the command takes')),
97 ('', 'profile', None, _('print command execution profile')),
96 ('', 'profile', None, _('print command execution profile')),
98 ('', 'version', None, _('output version information and exit')),
97 ('', 'version', None, _('output version information and exit')),
99 ('h', 'help', None, _('display help and exit')),
98 ('h', 'help', None, _('display help and exit')),
100 ('', 'hidden', False, _('consider hidden changesets')),
99 ('', 'hidden', False, _('consider hidden changesets')),
101 ('', 'pager', 'auto',
100 ('', 'pager', 'auto',
102 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
101 _("when to paginate (boolean, always, auto, or never)"), _('TYPE')),
103 ]
102 ]
104
103
105 dryrunopts = [('n', 'dry-run', None,
104 dryrunopts = [('n', 'dry-run', None,
106 _('do not perform actions, just print output'))]
105 _('do not perform actions, just print output'))]
107
106
108 remoteopts = [
107 remoteopts = [
109 ('e', 'ssh', '',
108 ('e', 'ssh', '',
110 _('specify ssh command to use'), _('CMD')),
109 _('specify ssh command to use'), _('CMD')),
111 ('', 'remotecmd', '',
110 ('', 'remotecmd', '',
112 _('specify hg command to run on the remote side'), _('CMD')),
111 _('specify hg command to run on the remote side'), _('CMD')),
113 ('', 'insecure', None,
112 ('', 'insecure', None,
114 _('do not verify server certificate (ignoring web.cacerts config)')),
113 _('do not verify server certificate (ignoring web.cacerts config)')),
115 ]
114 ]
116
115
117 walkopts = [
116 walkopts = [
118 ('I', 'include', [],
117 ('I', 'include', [],
119 _('include names matching the given patterns'), _('PATTERN')),
118 _('include names matching the given patterns'), _('PATTERN')),
120 ('X', 'exclude', [],
119 ('X', 'exclude', [],
121 _('exclude names matching the given patterns'), _('PATTERN')),
120 _('exclude names matching the given patterns'), _('PATTERN')),
122 ]
121 ]
123
122
124 commitopts = [
123 commitopts = [
125 ('m', 'message', '',
124 ('m', 'message', '',
126 _('use text as commit message'), _('TEXT')),
125 _('use text as commit message'), _('TEXT')),
127 ('l', 'logfile', '',
126 ('l', 'logfile', '',
128 _('read commit message from file'), _('FILE')),
127 _('read commit message from file'), _('FILE')),
129 ]
128 ]
130
129
131 commitopts2 = [
130 commitopts2 = [
132 ('d', 'date', '',
131 ('d', 'date', '',
133 _('record the specified date as commit date'), _('DATE')),
132 _('record the specified date as commit date'), _('DATE')),
134 ('u', 'user', '',
133 ('u', 'user', '',
135 _('record the specified user as committer'), _('USER')),
134 _('record the specified user as committer'), _('USER')),
136 ]
135 ]
137
136
138 # hidden for now
137 # hidden for now
139 formatteropts = [
138 formatteropts = [
140 ('T', 'template', '',
139 ('T', 'template', '',
141 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
140 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
142 ]
141 ]
143
142
144 templateopts = [
143 templateopts = [
145 ('', 'style', '',
144 ('', 'style', '',
146 _('display using template map file (DEPRECATED)'), _('STYLE')),
145 _('display using template map file (DEPRECATED)'), _('STYLE')),
147 ('T', 'template', '',
146 ('T', 'template', '',
148 _('display with template'), _('TEMPLATE')),
147 _('display with template'), _('TEMPLATE')),
149 ]
148 ]
150
149
151 logopts = [
150 logopts = [
152 ('p', 'patch', None, _('show patch')),
151 ('p', 'patch', None, _('show patch')),
153 ('g', 'git', None, _('use git extended diff format')),
152 ('g', 'git', None, _('use git extended diff format')),
154 ('l', 'limit', '',
153 ('l', 'limit', '',
155 _('limit number of changes displayed'), _('NUM')),
154 _('limit number of changes displayed'), _('NUM')),
156 ('M', 'no-merges', None, _('do not show merges')),
155 ('M', 'no-merges', None, _('do not show merges')),
157 ('', 'stat', None, _('output diffstat-style summary of changes')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
158 ('G', 'graph', None, _("show the revision DAG")),
157 ('G', 'graph', None, _("show the revision DAG")),
159 ] + templateopts
158 ] + templateopts
160
159
161 diffopts = [
160 diffopts = [
162 ('a', 'text', None, _('treat all files as text')),
161 ('a', 'text', None, _('treat all files as text')),
163 ('g', 'git', None, _('use git extended diff format')),
162 ('g', 'git', None, _('use git extended diff format')),
164 ('', 'nodates', None, _('omit dates from diff headers'))
163 ('', 'nodates', None, _('omit dates from diff headers'))
165 ]
164 ]
166
165
167 diffwsopts = [
166 diffwsopts = [
168 ('w', 'ignore-all-space', None,
167 ('w', 'ignore-all-space', None,
169 _('ignore white space when comparing lines')),
168 _('ignore white space when comparing lines')),
170 ('b', 'ignore-space-change', None,
169 ('b', 'ignore-space-change', None,
171 _('ignore changes in the amount of white space')),
170 _('ignore changes in the amount of white space')),
172 ('B', 'ignore-blank-lines', None,
171 ('B', 'ignore-blank-lines', None,
173 _('ignore changes whose lines are all blank')),
172 _('ignore changes whose lines are all blank')),
174 ]
173 ]
175
174
176 diffopts2 = [
175 diffopts2 = [
177 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
176 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
178 ('p', 'show-function', None, _('show which function each change is in')),
177 ('p', 'show-function', None, _('show which function each change is in')),
179 ('', 'reverse', None, _('produce a diff that undoes the changes')),
178 ('', 'reverse', None, _('produce a diff that undoes the changes')),
180 ] + diffwsopts + [
179 ] + diffwsopts + [
181 ('U', 'unified', '',
180 ('U', 'unified', '',
182 _('number of lines of context to show'), _('NUM')),
181 _('number of lines of context to show'), _('NUM')),
183 ('', 'stat', None, _('output diffstat-style summary of changes')),
182 ('', 'stat', None, _('output diffstat-style summary of changes')),
184 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
183 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
185 ]
184 ]
186
185
187 mergetoolopts = [
186 mergetoolopts = [
188 ('t', 'tool', '', _('specify merge tool')),
187 ('t', 'tool', '', _('specify merge tool')),
189 ]
188 ]
190
189
191 similarityopts = [
190 similarityopts = [
192 ('s', 'similarity', '',
191 ('s', 'similarity', '',
193 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
192 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
194 ]
193 ]
195
194
196 subrepoopts = [
195 subrepoopts = [
197 ('S', 'subrepos', None,
196 ('S', 'subrepos', None,
198 _('recurse into subrepositories'))
197 _('recurse into subrepositories'))
199 ]
198 ]
200
199
201 debugrevlogopts = [
200 debugrevlogopts = [
202 ('c', 'changelog', False, _('open changelog')),
201 ('c', 'changelog', False, _('open changelog')),
203 ('m', 'manifest', False, _('open manifest')),
202 ('m', 'manifest', False, _('open manifest')),
204 ('', 'dir', '', _('open directory manifest')),
203 ('', 'dir', '', _('open directory manifest')),
205 ]
204 ]
206
205
207 # Commands start here, listed alphabetically
206 # Commands start here, listed alphabetically
208
207
209 @command('^add',
208 @command('^add',
210 walkopts + subrepoopts + dryrunopts,
209 walkopts + subrepoopts + dryrunopts,
211 _('[OPTION]... [FILE]...'),
210 _('[OPTION]... [FILE]...'),
212 inferrepo=True)
211 inferrepo=True)
213 def add(ui, repo, *pats, **opts):
212 def add(ui, repo, *pats, **opts):
214 """add the specified files on the next commit
213 """add the specified files on the next commit
215
214
216 Schedule files to be version controlled and added to the
215 Schedule files to be version controlled and added to the
217 repository.
216 repository.
218
217
219 The files will be added to the repository at the next commit. To
218 The files will be added to the repository at the next commit. To
220 undo an add before that, see :hg:`forget`.
219 undo an add before that, see :hg:`forget`.
221
220
222 If no names are given, add all files to the repository (except
221 If no names are given, add all files to the repository (except
223 files matching ``.hgignore``).
222 files matching ``.hgignore``).
224
223
225 .. container:: verbose
224 .. container:: verbose
226
225
227 Examples:
226 Examples:
228
227
229 - New (unknown) files are added
228 - New (unknown) files are added
230 automatically by :hg:`add`::
229 automatically by :hg:`add`::
231
230
232 $ ls
231 $ ls
233 foo.c
232 foo.c
234 $ hg status
233 $ hg status
235 ? foo.c
234 ? foo.c
236 $ hg add
235 $ hg add
237 adding foo.c
236 adding foo.c
238 $ hg status
237 $ hg status
239 A foo.c
238 A foo.c
240
239
241 - Specific files to be added can be specified::
240 - Specific files to be added can be specified::
242
241
243 $ ls
242 $ ls
244 bar.c foo.c
243 bar.c foo.c
245 $ hg status
244 $ hg status
246 ? bar.c
245 ? bar.c
247 ? foo.c
246 ? foo.c
248 $ hg add bar.c
247 $ hg add bar.c
249 $ hg status
248 $ hg status
250 A bar.c
249 A bar.c
251 ? foo.c
250 ? foo.c
252
251
253 Returns 0 if all files are successfully added.
252 Returns 0 if all files are successfully added.
254 """
253 """
255
254
256 m = scmutil.match(repo[None], pats, opts)
255 m = scmutil.match(repo[None], pats, opts)
257 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
256 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
258 return rejected and 1 or 0
257 return rejected and 1 or 0
259
258
260 @command('addremove',
259 @command('addremove',
261 similarityopts + subrepoopts + walkopts + dryrunopts,
260 similarityopts + subrepoopts + walkopts + dryrunopts,
262 _('[OPTION]... [FILE]...'),
261 _('[OPTION]... [FILE]...'),
263 inferrepo=True)
262 inferrepo=True)
264 def addremove(ui, repo, *pats, **opts):
263 def addremove(ui, repo, *pats, **opts):
265 """add all new files, delete all missing files
264 """add all new files, delete all missing files
266
265
267 Add all new files and remove all missing files from the
266 Add all new files and remove all missing files from the
268 repository.
267 repository.
269
268
270 Unless names are given, new files are ignored if they match any of
269 Unless names are given, new files are ignored if they match any of
271 the patterns in ``.hgignore``. As with add, these changes take
270 the patterns in ``.hgignore``. As with add, these changes take
272 effect at the next commit.
271 effect at the next commit.
273
272
274 Use the -s/--similarity option to detect renamed files. This
273 Use the -s/--similarity option to detect renamed files. This
275 option takes a percentage between 0 (disabled) and 100 (files must
274 option takes a percentage between 0 (disabled) and 100 (files must
276 be identical) as its parameter. With a parameter greater than 0,
275 be identical) as its parameter. With a parameter greater than 0,
277 this compares every removed file with every added file and records
276 this compares every removed file with every added file and records
278 those similar enough as renames. Detecting renamed files this way
277 those similar enough as renames. Detecting renamed files this way
279 can be expensive. After using this option, :hg:`status -C` can be
278 can be expensive. After using this option, :hg:`status -C` can be
280 used to check which files were identified as moved or renamed. If
279 used to check which files were identified as moved or renamed. If
281 not specified, -s/--similarity defaults to 100 and only renames of
280 not specified, -s/--similarity defaults to 100 and only renames of
282 identical files are detected.
281 identical files are detected.
283
282
284 .. container:: verbose
283 .. container:: verbose
285
284
286 Examples:
285 Examples:
287
286
288 - A number of files (bar.c and foo.c) are new,
287 - A number of files (bar.c and foo.c) are new,
289 while foobar.c has been removed (without using :hg:`remove`)
288 while foobar.c has been removed (without using :hg:`remove`)
290 from the repository::
289 from the repository::
291
290
292 $ ls
291 $ ls
293 bar.c foo.c
292 bar.c foo.c
294 $ hg status
293 $ hg status
295 ! foobar.c
294 ! foobar.c
296 ? bar.c
295 ? bar.c
297 ? foo.c
296 ? foo.c
298 $ hg addremove
297 $ hg addremove
299 adding bar.c
298 adding bar.c
300 adding foo.c
299 adding foo.c
301 removing foobar.c
300 removing foobar.c
302 $ hg status
301 $ hg status
303 A bar.c
302 A bar.c
304 A foo.c
303 A foo.c
305 R foobar.c
304 R foobar.c
306
305
307 - A file foobar.c was moved to foo.c without using :hg:`rename`.
306 - A file foobar.c was moved to foo.c without using :hg:`rename`.
308 Afterwards, it was edited slightly::
307 Afterwards, it was edited slightly::
309
308
310 $ ls
309 $ ls
311 foo.c
310 foo.c
312 $ hg status
311 $ hg status
313 ! foobar.c
312 ! foobar.c
314 ? foo.c
313 ? foo.c
315 $ hg addremove --similarity 90
314 $ hg addremove --similarity 90
316 removing foobar.c
315 removing foobar.c
317 adding foo.c
316 adding foo.c
318 recording removal of foobar.c as rename to foo.c (94% similar)
317 recording removal of foobar.c as rename to foo.c (94% similar)
319 $ hg status -C
318 $ hg status -C
320 A foo.c
319 A foo.c
321 foobar.c
320 foobar.c
322 R foobar.c
321 R foobar.c
323
322
324 Returns 0 if all files are successfully added.
323 Returns 0 if all files are successfully added.
325 """
324 """
326 try:
325 try:
327 sim = float(opts.get('similarity') or 100)
326 sim = float(opts.get('similarity') or 100)
328 except ValueError:
327 except ValueError:
329 raise error.Abort(_('similarity must be a number'))
328 raise error.Abort(_('similarity must be a number'))
330 if sim < 0 or sim > 100:
329 if sim < 0 or sim > 100:
331 raise error.Abort(_('similarity must be between 0 and 100'))
330 raise error.Abort(_('similarity must be between 0 and 100'))
332 matcher = scmutil.match(repo[None], pats, opts)
331 matcher = scmutil.match(repo[None], pats, opts)
333 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
332 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
334
333
335 @command('^annotate|blame',
334 @command('^annotate|blame',
336 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
335 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
337 ('', 'follow', None,
336 ('', 'follow', None,
338 _('follow copies/renames and list the filename (DEPRECATED)')),
337 _('follow copies/renames and list the filename (DEPRECATED)')),
339 ('', 'no-follow', None, _("don't follow copies and renames")),
338 ('', 'no-follow', None, _("don't follow copies and renames")),
340 ('a', 'text', None, _('treat all files as text')),
339 ('a', 'text', None, _('treat all files as text')),
341 ('u', 'user', None, _('list the author (long with -v)')),
340 ('u', 'user', None, _('list the author (long with -v)')),
342 ('f', 'file', None, _('list the filename')),
341 ('f', 'file', None, _('list the filename')),
343 ('d', 'date', None, _('list the date (short with -q)')),
342 ('d', 'date', None, _('list the date (short with -q)')),
344 ('n', 'number', None, _('list the revision number (default)')),
343 ('n', 'number', None, _('list the revision number (default)')),
345 ('c', 'changeset', None, _('list the changeset')),
344 ('c', 'changeset', None, _('list the changeset')),
346 ('l', 'line-number', None, _('show line number at the first appearance'))
345 ('l', 'line-number', None, _('show line number at the first appearance'))
347 ] + diffwsopts + walkopts + formatteropts,
346 ] + diffwsopts + walkopts + formatteropts,
348 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
347 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
349 inferrepo=True)
348 inferrepo=True)
350 def annotate(ui, repo, *pats, **opts):
349 def annotate(ui, repo, *pats, **opts):
351 """show changeset information by line for each file
350 """show changeset information by line for each file
352
351
353 List changes in files, showing the revision id responsible for
352 List changes in files, showing the revision id responsible for
354 each line.
353 each line.
355
354
356 This command is useful for discovering when a change was made and
355 This command is useful for discovering when a change was made and
357 by whom.
356 by whom.
358
357
359 If you include --file, --user, or --date, the revision number is
358 If you include --file, --user, or --date, the revision number is
360 suppressed unless you also include --number.
359 suppressed unless you also include --number.
361
360
362 Without the -a/--text option, annotate will avoid processing files
361 Without the -a/--text option, annotate will avoid processing files
363 it detects as binary. With -a, annotate will annotate the file
362 it detects as binary. With -a, annotate will annotate the file
364 anyway, although the results will probably be neither useful
363 anyway, although the results will probably be neither useful
365 nor desirable.
364 nor desirable.
366
365
367 Returns 0 on success.
366 Returns 0 on success.
368 """
367 """
369 if not pats:
368 if not pats:
370 raise error.Abort(_('at least one filename or pattern is required'))
369 raise error.Abort(_('at least one filename or pattern is required'))
371
370
372 if opts.get('follow'):
371 if opts.get('follow'):
373 # --follow is deprecated and now just an alias for -f/--file
372 # --follow is deprecated and now just an alias for -f/--file
374 # to mimic the behavior of Mercurial before version 1.5
373 # to mimic the behavior of Mercurial before version 1.5
375 opts['file'] = True
374 opts['file'] = True
376
375
377 ctx = scmutil.revsingle(repo, opts.get('rev'))
376 ctx = scmutil.revsingle(repo, opts.get('rev'))
378
377
379 fm = ui.formatter('annotate', opts)
378 fm = ui.formatter('annotate', opts)
380 if ui.quiet:
379 if ui.quiet:
381 datefunc = util.shortdate
380 datefunc = util.shortdate
382 else:
381 else:
383 datefunc = util.datestr
382 datefunc = util.datestr
384 if ctx.rev() is None:
383 if ctx.rev() is None:
385 def hexfn(node):
384 def hexfn(node):
386 if node is None:
385 if node is None:
387 return None
386 return None
388 else:
387 else:
389 return fm.hexfunc(node)
388 return fm.hexfunc(node)
390 if opts.get('changeset'):
389 if opts.get('changeset'):
391 # omit "+" suffix which is appended to node hex
390 # omit "+" suffix which is appended to node hex
392 def formatrev(rev):
391 def formatrev(rev):
393 if rev is None:
392 if rev is None:
394 return '%d' % ctx.p1().rev()
393 return '%d' % ctx.p1().rev()
395 else:
394 else:
396 return '%d' % rev
395 return '%d' % rev
397 else:
396 else:
398 def formatrev(rev):
397 def formatrev(rev):
399 if rev is None:
398 if rev is None:
400 return '%d+' % ctx.p1().rev()
399 return '%d+' % ctx.p1().rev()
401 else:
400 else:
402 return '%d ' % rev
401 return '%d ' % rev
403 def formathex(hex):
402 def formathex(hex):
404 if hex is None:
403 if hex is None:
405 return '%s+' % fm.hexfunc(ctx.p1().node())
404 return '%s+' % fm.hexfunc(ctx.p1().node())
406 else:
405 else:
407 return '%s ' % hex
406 return '%s ' % hex
408 else:
407 else:
409 hexfn = fm.hexfunc
408 hexfn = fm.hexfunc
410 formatrev = formathex = str
409 formatrev = formathex = str
411
410
412 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
411 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
413 ('number', ' ', lambda x: x[0].rev(), formatrev),
412 ('number', ' ', lambda x: x[0].rev(), formatrev),
414 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
413 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
415 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
414 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
416 ('file', ' ', lambda x: x[0].path(), str),
415 ('file', ' ', lambda x: x[0].path(), str),
417 ('line_number', ':', lambda x: x[1], str),
416 ('line_number', ':', lambda x: x[1], str),
418 ]
417 ]
419 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
418 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
420
419
421 if (not opts.get('user') and not opts.get('changeset')
420 if (not opts.get('user') and not opts.get('changeset')
422 and not opts.get('date') and not opts.get('file')):
421 and not opts.get('date') and not opts.get('file')):
423 opts['number'] = True
422 opts['number'] = True
424
423
425 linenumber = opts.get('line_number') is not None
424 linenumber = opts.get('line_number') is not None
426 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
425 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
427 raise error.Abort(_('at least one of -n/-c is required for -l'))
426 raise error.Abort(_('at least one of -n/-c is required for -l'))
428
427
429 ui.pager('annotate')
428 ui.pager('annotate')
430
429
431 if fm.isplain():
430 if fm.isplain():
432 def makefunc(get, fmt):
431 def makefunc(get, fmt):
433 return lambda x: fmt(get(x))
432 return lambda x: fmt(get(x))
434 else:
433 else:
435 def makefunc(get, fmt):
434 def makefunc(get, fmt):
436 return get
435 return get
437 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
436 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
438 if opts.get(op)]
437 if opts.get(op)]
439 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
438 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
440 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
439 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
441 if opts.get(op))
440 if opts.get(op))
442
441
443 def bad(x, y):
442 def bad(x, y):
444 raise error.Abort("%s: %s" % (x, y))
443 raise error.Abort("%s: %s" % (x, y))
445
444
446 m = scmutil.match(ctx, pats, opts, badfn=bad)
445 m = scmutil.match(ctx, pats, opts, badfn=bad)
447
446
448 follow = not opts.get('no_follow')
447 follow = not opts.get('no_follow')
449 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
448 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
450 whitespace=True)
449 whitespace=True)
451 for abs in ctx.walk(m):
450 for abs in ctx.walk(m):
452 fctx = ctx[abs]
451 fctx = ctx[abs]
453 if not opts.get('text') and util.binary(fctx.data()):
452 if not opts.get('text') and util.binary(fctx.data()):
454 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
453 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
455 continue
454 continue
456
455
457 lines = fctx.annotate(follow=follow, linenumber=linenumber,
456 lines = fctx.annotate(follow=follow, linenumber=linenumber,
458 diffopts=diffopts)
457 diffopts=diffopts)
459 if not lines:
458 if not lines:
460 continue
459 continue
461 formats = []
460 formats = []
462 pieces = []
461 pieces = []
463
462
464 for f, sep in funcmap:
463 for f, sep in funcmap:
465 l = [f(n) for n, dummy in lines]
464 l = [f(n) for n, dummy in lines]
466 if fm.isplain():
465 if fm.isplain():
467 sizes = [encoding.colwidth(x) for x in l]
466 sizes = [encoding.colwidth(x) for x in l]
468 ml = max(sizes)
467 ml = max(sizes)
469 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
468 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
470 else:
469 else:
471 formats.append(['%s' for x in l])
470 formats.append(['%s' for x in l])
472 pieces.append(l)
471 pieces.append(l)
473
472
474 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
473 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
475 fm.startitem()
474 fm.startitem()
476 fm.write(fields, "".join(f), *p)
475 fm.write(fields, "".join(f), *p)
477 fm.write('line', ": %s", l[1])
476 fm.write('line', ": %s", l[1])
478
477
479 if not lines[-1][1].endswith('\n'):
478 if not lines[-1][1].endswith('\n'):
480 fm.plain('\n')
479 fm.plain('\n')
481
480
482 fm.end()
481 fm.end()
483
482
484 @command('archive',
483 @command('archive',
485 [('', 'no-decode', None, _('do not pass files through decoders')),
484 [('', 'no-decode', None, _('do not pass files through decoders')),
486 ('p', 'prefix', '', _('directory prefix for files in archive'),
485 ('p', 'prefix', '', _('directory prefix for files in archive'),
487 _('PREFIX')),
486 _('PREFIX')),
488 ('r', 'rev', '', _('revision to distribute'), _('REV')),
487 ('r', 'rev', '', _('revision to distribute'), _('REV')),
489 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
488 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
490 ] + subrepoopts + walkopts,
489 ] + subrepoopts + walkopts,
491 _('[OPTION]... DEST'))
490 _('[OPTION]... DEST'))
492 def archive(ui, repo, dest, **opts):
491 def archive(ui, repo, dest, **opts):
493 '''create an unversioned archive of a repository revision
492 '''create an unversioned archive of a repository revision
494
493
495 By default, the revision used is the parent of the working
494 By default, the revision used is the parent of the working
496 directory; use -r/--rev to specify a different revision.
495 directory; use -r/--rev to specify a different revision.
497
496
498 The archive type is automatically detected based on file
497 The archive type is automatically detected based on file
499 extension (to override, use -t/--type).
498 extension (to override, use -t/--type).
500
499
501 .. container:: verbose
500 .. container:: verbose
502
501
503 Examples:
502 Examples:
504
503
505 - create a zip file containing the 1.0 release::
504 - create a zip file containing the 1.0 release::
506
505
507 hg archive -r 1.0 project-1.0.zip
506 hg archive -r 1.0 project-1.0.zip
508
507
509 - create a tarball excluding .hg files::
508 - create a tarball excluding .hg files::
510
509
511 hg archive project.tar.gz -X ".hg*"
510 hg archive project.tar.gz -X ".hg*"
512
511
513 Valid types are:
512 Valid types are:
514
513
515 :``files``: a directory full of files (default)
514 :``files``: a directory full of files (default)
516 :``tar``: tar archive, uncompressed
515 :``tar``: tar archive, uncompressed
517 :``tbz2``: tar archive, compressed using bzip2
516 :``tbz2``: tar archive, compressed using bzip2
518 :``tgz``: tar archive, compressed using gzip
517 :``tgz``: tar archive, compressed using gzip
519 :``uzip``: zip archive, uncompressed
518 :``uzip``: zip archive, uncompressed
520 :``zip``: zip archive, compressed using deflate
519 :``zip``: zip archive, compressed using deflate
521
520
522 The exact name of the destination archive or directory is given
521 The exact name of the destination archive or directory is given
523 using a format string; see :hg:`help export` for details.
522 using a format string; see :hg:`help export` for details.
524
523
525 Each member added to an archive file has a directory prefix
524 Each member added to an archive file has a directory prefix
526 prepended. Use -p/--prefix to specify a format string for the
525 prepended. Use -p/--prefix to specify a format string for the
527 prefix. The default is the basename of the archive, with suffixes
526 prefix. The default is the basename of the archive, with suffixes
528 removed.
527 removed.
529
528
530 Returns 0 on success.
529 Returns 0 on success.
531 '''
530 '''
532
531
533 ctx = scmutil.revsingle(repo, opts.get('rev'))
532 ctx = scmutil.revsingle(repo, opts.get('rev'))
534 if not ctx:
533 if not ctx:
535 raise error.Abort(_('no working directory: please specify a revision'))
534 raise error.Abort(_('no working directory: please specify a revision'))
536 node = ctx.node()
535 node = ctx.node()
537 dest = cmdutil.makefilename(repo, dest, node)
536 dest = cmdutil.makefilename(repo, dest, node)
538 if os.path.realpath(dest) == repo.root:
537 if os.path.realpath(dest) == repo.root:
539 raise error.Abort(_('repository root cannot be destination'))
538 raise error.Abort(_('repository root cannot be destination'))
540
539
541 kind = opts.get('type') or archival.guesskind(dest) or 'files'
540 kind = opts.get('type') or archival.guesskind(dest) or 'files'
542 prefix = opts.get('prefix')
541 prefix = opts.get('prefix')
543
542
544 if dest == '-':
543 if dest == '-':
545 if kind == 'files':
544 if kind == 'files':
546 raise error.Abort(_('cannot archive plain files to stdout'))
545 raise error.Abort(_('cannot archive plain files to stdout'))
547 dest = cmdutil.makefileobj(repo, dest)
546 dest = cmdutil.makefileobj(repo, dest)
548 if not prefix:
547 if not prefix:
549 prefix = os.path.basename(repo.root) + '-%h'
548 prefix = os.path.basename(repo.root) + '-%h'
550
549
551 prefix = cmdutil.makefilename(repo, prefix, node)
550 prefix = cmdutil.makefilename(repo, prefix, node)
552 matchfn = scmutil.match(ctx, [], opts)
551 matchfn = scmutil.match(ctx, [], opts)
553 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
552 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
554 matchfn, prefix, subrepos=opts.get('subrepos'))
553 matchfn, prefix, subrepos=opts.get('subrepos'))
555
554
556 @command('backout',
555 @command('backout',
557 [('', 'merge', None, _('merge with old dirstate parent after backout')),
556 [('', 'merge', None, _('merge with old dirstate parent after backout')),
558 ('', 'commit', None,
557 ('', 'commit', None,
559 _('commit if no conflicts were encountered (DEPRECATED)')),
558 _('commit if no conflicts were encountered (DEPRECATED)')),
560 ('', 'no-commit', None, _('do not commit')),
559 ('', 'no-commit', None, _('do not commit')),
561 ('', 'parent', '',
560 ('', 'parent', '',
562 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
561 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
563 ('r', 'rev', '', _('revision to backout'), _('REV')),
562 ('r', 'rev', '', _('revision to backout'), _('REV')),
564 ('e', 'edit', False, _('invoke editor on commit messages')),
563 ('e', 'edit', False, _('invoke editor on commit messages')),
565 ] + mergetoolopts + walkopts + commitopts + commitopts2,
564 ] + mergetoolopts + walkopts + commitopts + commitopts2,
566 _('[OPTION]... [-r] REV'))
565 _('[OPTION]... [-r] REV'))
567 def backout(ui, repo, node=None, rev=None, **opts):
566 def backout(ui, repo, node=None, rev=None, **opts):
568 '''reverse effect of earlier changeset
567 '''reverse effect of earlier changeset
569
568
570 Prepare a new changeset with the effect of REV undone in the
569 Prepare a new changeset with the effect of REV undone in the
571 current working directory. If no conflicts were encountered,
570 current working directory. If no conflicts were encountered,
572 it will be committed immediately.
571 it will be committed immediately.
573
572
574 If REV is the parent of the working directory, then this new changeset
573 If REV is the parent of the working directory, then this new changeset
575 is committed automatically (unless --no-commit is specified).
574 is committed automatically (unless --no-commit is specified).
576
575
577 .. note::
576 .. note::
578
577
579 :hg:`backout` cannot be used to fix either an unwanted or
578 :hg:`backout` cannot be used to fix either an unwanted or
580 incorrect merge.
579 incorrect merge.
581
580
582 .. container:: verbose
581 .. container:: verbose
583
582
584 Examples:
583 Examples:
585
584
586 - Reverse the effect of the parent of the working directory.
585 - Reverse the effect of the parent of the working directory.
587 This backout will be committed immediately::
586 This backout will be committed immediately::
588
587
589 hg backout -r .
588 hg backout -r .
590
589
591 - Reverse the effect of previous bad revision 23::
590 - Reverse the effect of previous bad revision 23::
592
591
593 hg backout -r 23
592 hg backout -r 23
594
593
595 - Reverse the effect of previous bad revision 23 and
594 - Reverse the effect of previous bad revision 23 and
596 leave changes uncommitted::
595 leave changes uncommitted::
597
596
598 hg backout -r 23 --no-commit
597 hg backout -r 23 --no-commit
599 hg commit -m "Backout revision 23"
598 hg commit -m "Backout revision 23"
600
599
601 By default, the pending changeset will have one parent,
600 By default, the pending changeset will have one parent,
602 maintaining a linear history. With --merge, the pending
601 maintaining a linear history. With --merge, the pending
603 changeset will instead have two parents: the old parent of the
602 changeset will instead have two parents: the old parent of the
604 working directory and a new child of REV that simply undoes REV.
603 working directory and a new child of REV that simply undoes REV.
605
604
606 Before version 1.7, the behavior without --merge was equivalent
605 Before version 1.7, the behavior without --merge was equivalent
607 to specifying --merge followed by :hg:`update --clean .` to
606 to specifying --merge followed by :hg:`update --clean .` to
608 cancel the merge and leave the child of REV as a head to be
607 cancel the merge and leave the child of REV as a head to be
609 merged separately.
608 merged separately.
610
609
611 See :hg:`help dates` for a list of formats valid for -d/--date.
610 See :hg:`help dates` for a list of formats valid for -d/--date.
612
611
613 See :hg:`help revert` for a way to restore files to the state
612 See :hg:`help revert` for a way to restore files to the state
614 of another revision.
613 of another revision.
615
614
616 Returns 0 on success, 1 if nothing to backout or there are unresolved
615 Returns 0 on success, 1 if nothing to backout or there are unresolved
617 files.
616 files.
618 '''
617 '''
619 wlock = lock = None
618 wlock = lock = None
620 try:
619 try:
621 wlock = repo.wlock()
620 wlock = repo.wlock()
622 lock = repo.lock()
621 lock = repo.lock()
623 return _dobackout(ui, repo, node, rev, **opts)
622 return _dobackout(ui, repo, node, rev, **opts)
624 finally:
623 finally:
625 release(lock, wlock)
624 release(lock, wlock)
626
625
627 def _dobackout(ui, repo, node=None, rev=None, **opts):
626 def _dobackout(ui, repo, node=None, rev=None, **opts):
628 if opts.get('commit') and opts.get('no_commit'):
627 if opts.get('commit') and opts.get('no_commit'):
629 raise error.Abort(_("cannot use --commit with --no-commit"))
628 raise error.Abort(_("cannot use --commit with --no-commit"))
630 if opts.get('merge') and opts.get('no_commit'):
629 if opts.get('merge') and opts.get('no_commit'):
631 raise error.Abort(_("cannot use --merge with --no-commit"))
630 raise error.Abort(_("cannot use --merge with --no-commit"))
632
631
633 if rev and node:
632 if rev and node:
634 raise error.Abort(_("please specify just one revision"))
633 raise error.Abort(_("please specify just one revision"))
635
634
636 if not rev:
635 if not rev:
637 rev = node
636 rev = node
638
637
639 if not rev:
638 if not rev:
640 raise error.Abort(_("please specify a revision to backout"))
639 raise error.Abort(_("please specify a revision to backout"))
641
640
642 date = opts.get('date')
641 date = opts.get('date')
643 if date:
642 if date:
644 opts['date'] = util.parsedate(date)
643 opts['date'] = util.parsedate(date)
645
644
646 cmdutil.checkunfinished(repo)
645 cmdutil.checkunfinished(repo)
647 cmdutil.bailifchanged(repo)
646 cmdutil.bailifchanged(repo)
648 node = scmutil.revsingle(repo, rev).node()
647 node = scmutil.revsingle(repo, rev).node()
649
648
650 op1, op2 = repo.dirstate.parents()
649 op1, op2 = repo.dirstate.parents()
651 if not repo.changelog.isancestor(node, op1):
650 if not repo.changelog.isancestor(node, op1):
652 raise error.Abort(_('cannot backout change that is not an ancestor'))
651 raise error.Abort(_('cannot backout change that is not an ancestor'))
653
652
654 p1, p2 = repo.changelog.parents(node)
653 p1, p2 = repo.changelog.parents(node)
655 if p1 == nullid:
654 if p1 == nullid:
656 raise error.Abort(_('cannot backout a change with no parents'))
655 raise error.Abort(_('cannot backout a change with no parents'))
657 if p2 != nullid:
656 if p2 != nullid:
658 if not opts.get('parent'):
657 if not opts.get('parent'):
659 raise error.Abort(_('cannot backout a merge changeset'))
658 raise error.Abort(_('cannot backout a merge changeset'))
660 p = repo.lookup(opts['parent'])
659 p = repo.lookup(opts['parent'])
661 if p not in (p1, p2):
660 if p not in (p1, p2):
662 raise error.Abort(_('%s is not a parent of %s') %
661 raise error.Abort(_('%s is not a parent of %s') %
663 (short(p), short(node)))
662 (short(p), short(node)))
664 parent = p
663 parent = p
665 else:
664 else:
666 if opts.get('parent'):
665 if opts.get('parent'):
667 raise error.Abort(_('cannot use --parent on non-merge changeset'))
666 raise error.Abort(_('cannot use --parent on non-merge changeset'))
668 parent = p1
667 parent = p1
669
668
670 # the backout should appear on the same branch
669 # the backout should appear on the same branch
671 branch = repo.dirstate.branch()
670 branch = repo.dirstate.branch()
672 bheads = repo.branchheads(branch)
671 bheads = repo.branchheads(branch)
673 rctx = scmutil.revsingle(repo, hex(parent))
672 rctx = scmutil.revsingle(repo, hex(parent))
674 if not opts.get('merge') and op1 != node:
673 if not opts.get('merge') and op1 != node:
675 dsguard = dirstateguard.dirstateguard(repo, 'backout')
674 dsguard = dirstateguard.dirstateguard(repo, 'backout')
676 try:
675 try:
677 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
676 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
678 'backout')
677 'backout')
679 stats = mergemod.update(repo, parent, True, True, node, False)
678 stats = mergemod.update(repo, parent, True, True, node, False)
680 repo.setparents(op1, op2)
679 repo.setparents(op1, op2)
681 dsguard.close()
680 dsguard.close()
682 hg._showstats(repo, stats)
681 hg._showstats(repo, stats)
683 if stats[3]:
682 if stats[3]:
684 repo.ui.status(_("use 'hg resolve' to retry unresolved "
683 repo.ui.status(_("use 'hg resolve' to retry unresolved "
685 "file merges\n"))
684 "file merges\n"))
686 return 1
685 return 1
687 finally:
686 finally:
688 ui.setconfig('ui', 'forcemerge', '', '')
687 ui.setconfig('ui', 'forcemerge', '', '')
689 lockmod.release(dsguard)
688 lockmod.release(dsguard)
690 else:
689 else:
691 hg.clean(repo, node, show_stats=False)
690 hg.clean(repo, node, show_stats=False)
692 repo.dirstate.setbranch(branch)
691 repo.dirstate.setbranch(branch)
693 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
692 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
694
693
695 if opts.get('no_commit'):
694 if opts.get('no_commit'):
696 msg = _("changeset %s backed out, "
695 msg = _("changeset %s backed out, "
697 "don't forget to commit.\n")
696 "don't forget to commit.\n")
698 ui.status(msg % short(node))
697 ui.status(msg % short(node))
699 return 0
698 return 0
700
699
701 def commitfunc(ui, repo, message, match, opts):
700 def commitfunc(ui, repo, message, match, opts):
702 editform = 'backout'
701 editform = 'backout'
703 e = cmdutil.getcommiteditor(editform=editform, **opts)
702 e = cmdutil.getcommiteditor(editform=editform, **opts)
704 if not message:
703 if not message:
705 # we don't translate commit messages
704 # we don't translate commit messages
706 message = "Backed out changeset %s" % short(node)
705 message = "Backed out changeset %s" % short(node)
707 e = cmdutil.getcommiteditor(edit=True, editform=editform)
706 e = cmdutil.getcommiteditor(edit=True, editform=editform)
708 return repo.commit(message, opts.get('user'), opts.get('date'),
707 return repo.commit(message, opts.get('user'), opts.get('date'),
709 match, editor=e)
708 match, editor=e)
710 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
709 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
711 if not newnode:
710 if not newnode:
712 ui.status(_("nothing changed\n"))
711 ui.status(_("nothing changed\n"))
713 return 1
712 return 1
714 cmdutil.commitstatus(repo, newnode, branch, bheads)
713 cmdutil.commitstatus(repo, newnode, branch, bheads)
715
714
716 def nice(node):
715 def nice(node):
717 return '%d:%s' % (repo.changelog.rev(node), short(node))
716 return '%d:%s' % (repo.changelog.rev(node), short(node))
718 ui.status(_('changeset %s backs out changeset %s\n') %
717 ui.status(_('changeset %s backs out changeset %s\n') %
719 (nice(repo.changelog.tip()), nice(node)))
718 (nice(repo.changelog.tip()), nice(node)))
720 if opts.get('merge') and op1 != node:
719 if opts.get('merge') and op1 != node:
721 hg.clean(repo, op1, show_stats=False)
720 hg.clean(repo, op1, show_stats=False)
722 ui.status(_('merging with changeset %s\n')
721 ui.status(_('merging with changeset %s\n')
723 % nice(repo.changelog.tip()))
722 % nice(repo.changelog.tip()))
724 try:
723 try:
725 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
724 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
726 'backout')
725 'backout')
727 return hg.merge(repo, hex(repo.changelog.tip()))
726 return hg.merge(repo, hex(repo.changelog.tip()))
728 finally:
727 finally:
729 ui.setconfig('ui', 'forcemerge', '', '')
728 ui.setconfig('ui', 'forcemerge', '', '')
730 return 0
729 return 0
731
730
732 @command('bisect',
731 @command('bisect',
733 [('r', 'reset', False, _('reset bisect state')),
732 [('r', 'reset', False, _('reset bisect state')),
734 ('g', 'good', False, _('mark changeset good')),
733 ('g', 'good', False, _('mark changeset good')),
735 ('b', 'bad', False, _('mark changeset bad')),
734 ('b', 'bad', False, _('mark changeset bad')),
736 ('s', 'skip', False, _('skip testing changeset')),
735 ('s', 'skip', False, _('skip testing changeset')),
737 ('e', 'extend', False, _('extend the bisect range')),
736 ('e', 'extend', False, _('extend the bisect range')),
738 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
737 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
739 ('U', 'noupdate', False, _('do not update to target'))],
738 ('U', 'noupdate', False, _('do not update to target'))],
740 _("[-gbsr] [-U] [-c CMD] [REV]"))
739 _("[-gbsr] [-U] [-c CMD] [REV]"))
741 def bisect(ui, repo, rev=None, extra=None, command=None,
740 def bisect(ui, repo, rev=None, extra=None, command=None,
742 reset=None, good=None, bad=None, skip=None, extend=None,
741 reset=None, good=None, bad=None, skip=None, extend=None,
743 noupdate=None):
742 noupdate=None):
744 """subdivision search of changesets
743 """subdivision search of changesets
745
744
746 This command helps to find changesets which introduce problems. To
745 This command helps to find changesets which introduce problems. To
747 use, mark the earliest changeset you know exhibits the problem as
746 use, mark the earliest changeset you know exhibits the problem as
748 bad, then mark the latest changeset which is free from the problem
747 bad, then mark the latest changeset which is free from the problem
749 as good. Bisect will update your working directory to a revision
748 as good. Bisect will update your working directory to a revision
750 for testing (unless the -U/--noupdate option is specified). Once
749 for testing (unless the -U/--noupdate option is specified). Once
751 you have performed tests, mark the working directory as good or
750 you have performed tests, mark the working directory as good or
752 bad, and bisect will either update to another candidate changeset
751 bad, and bisect will either update to another candidate changeset
753 or announce that it has found the bad revision.
752 or announce that it has found the bad revision.
754
753
755 As a shortcut, you can also use the revision argument to mark a
754 As a shortcut, you can also use the revision argument to mark a
756 revision as good or bad without checking it out first.
755 revision as good or bad without checking it out first.
757
756
758 If you supply a command, it will be used for automatic bisection.
757 If you supply a command, it will be used for automatic bisection.
759 The environment variable HG_NODE will contain the ID of the
758 The environment variable HG_NODE will contain the ID of the
760 changeset being tested. The exit status of the command will be
759 changeset being tested. The exit status of the command will be
761 used to mark revisions as good or bad: status 0 means good, 125
760 used to mark revisions as good or bad: status 0 means good, 125
762 means to skip the revision, 127 (command not found) will abort the
761 means to skip the revision, 127 (command not found) will abort the
763 bisection, and any other non-zero exit status means the revision
762 bisection, and any other non-zero exit status means the revision
764 is bad.
763 is bad.
765
764
766 .. container:: verbose
765 .. container:: verbose
767
766
768 Some examples:
767 Some examples:
769
768
770 - start a bisection with known bad revision 34, and good revision 12::
769 - start a bisection with known bad revision 34, and good revision 12::
771
770
772 hg bisect --bad 34
771 hg bisect --bad 34
773 hg bisect --good 12
772 hg bisect --good 12
774
773
775 - advance the current bisection by marking current revision as good or
774 - advance the current bisection by marking current revision as good or
776 bad::
775 bad::
777
776
778 hg bisect --good
777 hg bisect --good
779 hg bisect --bad
778 hg bisect --bad
780
779
781 - mark the current revision, or a known revision, to be skipped (e.g. if
780 - mark the current revision, or a known revision, to be skipped (e.g. if
782 that revision is not usable because of another issue)::
781 that revision is not usable because of another issue)::
783
782
784 hg bisect --skip
783 hg bisect --skip
785 hg bisect --skip 23
784 hg bisect --skip 23
786
785
787 - skip all revisions that do not touch directories ``foo`` or ``bar``::
786 - skip all revisions that do not touch directories ``foo`` or ``bar``::
788
787
789 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
788 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
790
789
791 - forget the current bisection::
790 - forget the current bisection::
792
791
793 hg bisect --reset
792 hg bisect --reset
794
793
795 - use 'make && make tests' to automatically find the first broken
794 - use 'make && make tests' to automatically find the first broken
796 revision::
795 revision::
797
796
798 hg bisect --reset
797 hg bisect --reset
799 hg bisect --bad 34
798 hg bisect --bad 34
800 hg bisect --good 12
799 hg bisect --good 12
801 hg bisect --command "make && make tests"
800 hg bisect --command "make && make tests"
802
801
803 - see all changesets whose states are already known in the current
802 - see all changesets whose states are already known in the current
804 bisection::
803 bisection::
805
804
806 hg log -r "bisect(pruned)"
805 hg log -r "bisect(pruned)"
807
806
808 - see the changeset currently being bisected (especially useful
807 - see the changeset currently being bisected (especially useful
809 if running with -U/--noupdate)::
808 if running with -U/--noupdate)::
810
809
811 hg log -r "bisect(current)"
810 hg log -r "bisect(current)"
812
811
813 - see all changesets that took part in the current bisection::
812 - see all changesets that took part in the current bisection::
814
813
815 hg log -r "bisect(range)"
814 hg log -r "bisect(range)"
816
815
817 - you can even get a nice graph::
816 - you can even get a nice graph::
818
817
819 hg log --graph -r "bisect(range)"
818 hg log --graph -r "bisect(range)"
820
819
821 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
820 See :hg:`help revisions.bisect` for more about the `bisect()` predicate.
822
821
823 Returns 0 on success.
822 Returns 0 on success.
824 """
823 """
825 # backward compatibility
824 # backward compatibility
826 if rev in "good bad reset init".split():
825 if rev in "good bad reset init".split():
827 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
826 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
828 cmd, rev, extra = rev, extra, None
827 cmd, rev, extra = rev, extra, None
829 if cmd == "good":
828 if cmd == "good":
830 good = True
829 good = True
831 elif cmd == "bad":
830 elif cmd == "bad":
832 bad = True
831 bad = True
833 else:
832 else:
834 reset = True
833 reset = True
835 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
834 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
836 raise error.Abort(_('incompatible arguments'))
835 raise error.Abort(_('incompatible arguments'))
837
836
838 cmdutil.checkunfinished(repo)
837 cmdutil.checkunfinished(repo)
839
838
840 if reset:
839 if reset:
841 hbisect.resetstate(repo)
840 hbisect.resetstate(repo)
842 return
841 return
843
842
844 state = hbisect.load_state(repo)
843 state = hbisect.load_state(repo)
845
844
846 # update state
845 # update state
847 if good or bad or skip:
846 if good or bad or skip:
848 if rev:
847 if rev:
849 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
848 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
850 else:
849 else:
851 nodes = [repo.lookup('.')]
850 nodes = [repo.lookup('.')]
852 if good:
851 if good:
853 state['good'] += nodes
852 state['good'] += nodes
854 elif bad:
853 elif bad:
855 state['bad'] += nodes
854 state['bad'] += nodes
856 elif skip:
855 elif skip:
857 state['skip'] += nodes
856 state['skip'] += nodes
858 hbisect.save_state(repo, state)
857 hbisect.save_state(repo, state)
859 if not (state['good'] and state['bad']):
858 if not (state['good'] and state['bad']):
860 return
859 return
861
860
862 def mayupdate(repo, node, show_stats=True):
861 def mayupdate(repo, node, show_stats=True):
863 """common used update sequence"""
862 """common used update sequence"""
864 if noupdate:
863 if noupdate:
865 return
864 return
866 cmdutil.bailifchanged(repo)
865 cmdutil.bailifchanged(repo)
867 return hg.clean(repo, node, show_stats=show_stats)
866 return hg.clean(repo, node, show_stats=show_stats)
868
867
869 displayer = cmdutil.show_changeset(ui, repo, {})
868 displayer = cmdutil.show_changeset(ui, repo, {})
870
869
871 if command:
870 if command:
872 changesets = 1
871 changesets = 1
873 if noupdate:
872 if noupdate:
874 try:
873 try:
875 node = state['current'][0]
874 node = state['current'][0]
876 except LookupError:
875 except LookupError:
877 raise error.Abort(_('current bisect revision is unknown - '
876 raise error.Abort(_('current bisect revision is unknown - '
878 'start a new bisect to fix'))
877 'start a new bisect to fix'))
879 else:
878 else:
880 node, p2 = repo.dirstate.parents()
879 node, p2 = repo.dirstate.parents()
881 if p2 != nullid:
880 if p2 != nullid:
882 raise error.Abort(_('current bisect revision is a merge'))
881 raise error.Abort(_('current bisect revision is a merge'))
883 if rev:
882 if rev:
884 node = repo[scmutil.revsingle(repo, rev, node)].node()
883 node = repo[scmutil.revsingle(repo, rev, node)].node()
885 try:
884 try:
886 while changesets:
885 while changesets:
887 # update state
886 # update state
888 state['current'] = [node]
887 state['current'] = [node]
889 hbisect.save_state(repo, state)
888 hbisect.save_state(repo, state)
890 status = ui.system(command, environ={'HG_NODE': hex(node)})
889 status = ui.system(command, environ={'HG_NODE': hex(node)})
891 if status == 125:
890 if status == 125:
892 transition = "skip"
891 transition = "skip"
893 elif status == 0:
892 elif status == 0:
894 transition = "good"
893 transition = "good"
895 # status < 0 means process was killed
894 # status < 0 means process was killed
896 elif status == 127:
895 elif status == 127:
897 raise error.Abort(_("failed to execute %s") % command)
896 raise error.Abort(_("failed to execute %s") % command)
898 elif status < 0:
897 elif status < 0:
899 raise error.Abort(_("%s killed") % command)
898 raise error.Abort(_("%s killed") % command)
900 else:
899 else:
901 transition = "bad"
900 transition = "bad"
902 state[transition].append(node)
901 state[transition].append(node)
903 ctx = repo[node]
902 ctx = repo[node]
904 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
903 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
905 hbisect.checkstate(state)
904 hbisect.checkstate(state)
906 # bisect
905 # bisect
907 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
906 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
908 # update to next check
907 # update to next check
909 node = nodes[0]
908 node = nodes[0]
910 mayupdate(repo, node, show_stats=False)
909 mayupdate(repo, node, show_stats=False)
911 finally:
910 finally:
912 state['current'] = [node]
911 state['current'] = [node]
913 hbisect.save_state(repo, state)
912 hbisect.save_state(repo, state)
914 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
913 hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
915 return
914 return
916
915
917 hbisect.checkstate(state)
916 hbisect.checkstate(state)
918
917
919 # actually bisect
918 # actually bisect
920 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
919 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
921 if extend:
920 if extend:
922 if not changesets:
921 if not changesets:
923 extendnode = hbisect.extendrange(repo, state, nodes, good)
922 extendnode = hbisect.extendrange(repo, state, nodes, good)
924 if extendnode is not None:
923 if extendnode is not None:
925 ui.write(_("Extending search to changeset %d:%s\n")
924 ui.write(_("Extending search to changeset %d:%s\n")
926 % (extendnode.rev(), extendnode))
925 % (extendnode.rev(), extendnode))
927 state['current'] = [extendnode.node()]
926 state['current'] = [extendnode.node()]
928 hbisect.save_state(repo, state)
927 hbisect.save_state(repo, state)
929 return mayupdate(repo, extendnode.node())
928 return mayupdate(repo, extendnode.node())
930 raise error.Abort(_("nothing to extend"))
929 raise error.Abort(_("nothing to extend"))
931
930
932 if changesets == 0:
931 if changesets == 0:
933 hbisect.printresult(ui, repo, state, displayer, nodes, good)
932 hbisect.printresult(ui, repo, state, displayer, nodes, good)
934 else:
933 else:
935 assert len(nodes) == 1 # only a single node can be tested next
934 assert len(nodes) == 1 # only a single node can be tested next
936 node = nodes[0]
935 node = nodes[0]
937 # compute the approximate number of remaining tests
936 # compute the approximate number of remaining tests
938 tests, size = 0, 2
937 tests, size = 0, 2
939 while size <= changesets:
938 while size <= changesets:
940 tests, size = tests + 1, size * 2
939 tests, size = tests + 1, size * 2
941 rev = repo.changelog.rev(node)
940 rev = repo.changelog.rev(node)
942 ui.write(_("Testing changeset %d:%s "
941 ui.write(_("Testing changeset %d:%s "
943 "(%d changesets remaining, ~%d tests)\n")
942 "(%d changesets remaining, ~%d tests)\n")
944 % (rev, short(node), changesets, tests))
943 % (rev, short(node), changesets, tests))
945 state['current'] = [node]
944 state['current'] = [node]
946 hbisect.save_state(repo, state)
945 hbisect.save_state(repo, state)
947 return mayupdate(repo, node)
946 return mayupdate(repo, node)
948
947
949 @command('bookmarks|bookmark',
948 @command('bookmarks|bookmark',
950 [('f', 'force', False, _('force')),
949 [('f', 'force', False, _('force')),
951 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
950 ('r', 'rev', '', _('revision for bookmark action'), _('REV')),
952 ('d', 'delete', False, _('delete a given bookmark')),
951 ('d', 'delete', False, _('delete a given bookmark')),
953 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
952 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
954 ('i', 'inactive', False, _('mark a bookmark inactive')),
953 ('i', 'inactive', False, _('mark a bookmark inactive')),
955 ] + formatteropts,
954 ] + formatteropts,
956 _('hg bookmarks [OPTIONS]... [NAME]...'))
955 _('hg bookmarks [OPTIONS]... [NAME]...'))
957 def bookmark(ui, repo, *names, **opts):
956 def bookmark(ui, repo, *names, **opts):
958 '''create a new bookmark or list existing bookmarks
957 '''create a new bookmark or list existing bookmarks
959
958
960 Bookmarks are labels on changesets to help track lines of development.
959 Bookmarks are labels on changesets to help track lines of development.
961 Bookmarks are unversioned and can be moved, renamed and deleted.
960 Bookmarks are unversioned and can be moved, renamed and deleted.
962 Deleting or moving a bookmark has no effect on the associated changesets.
961 Deleting or moving a bookmark has no effect on the associated changesets.
963
962
964 Creating or updating to a bookmark causes it to be marked as 'active'.
963 Creating or updating to a bookmark causes it to be marked as 'active'.
965 The active bookmark is indicated with a '*'.
964 The active bookmark is indicated with a '*'.
966 When a commit is made, the active bookmark will advance to the new commit.
965 When a commit is made, the active bookmark will advance to the new commit.
967 A plain :hg:`update` will also advance an active bookmark, if possible.
966 A plain :hg:`update` will also advance an active bookmark, if possible.
968 Updating away from a bookmark will cause it to be deactivated.
967 Updating away from a bookmark will cause it to be deactivated.
969
968
970 Bookmarks can be pushed and pulled between repositories (see
969 Bookmarks can be pushed and pulled between repositories (see
971 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
970 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
972 diverged, a new 'divergent bookmark' of the form 'name@path' will
971 diverged, a new 'divergent bookmark' of the form 'name@path' will
973 be created. Using :hg:`merge` will resolve the divergence.
972 be created. Using :hg:`merge` will resolve the divergence.
974
973
975 A bookmark named '@' has the special property that :hg:`clone` will
974 A bookmark named '@' has the special property that :hg:`clone` will
976 check it out by default if it exists.
975 check it out by default if it exists.
977
976
978 .. container:: verbose
977 .. container:: verbose
979
978
980 Examples:
979 Examples:
981
980
982 - create an active bookmark for a new line of development::
981 - create an active bookmark for a new line of development::
983
982
984 hg book new-feature
983 hg book new-feature
985
984
986 - create an inactive bookmark as a place marker::
985 - create an inactive bookmark as a place marker::
987
986
988 hg book -i reviewed
987 hg book -i reviewed
989
988
990 - create an inactive bookmark on another changeset::
989 - create an inactive bookmark on another changeset::
991
990
992 hg book -r .^ tested
991 hg book -r .^ tested
993
992
994 - rename bookmark turkey to dinner::
993 - rename bookmark turkey to dinner::
995
994
996 hg book -m turkey dinner
995 hg book -m turkey dinner
997
996
998 - move the '@' bookmark from another branch::
997 - move the '@' bookmark from another branch::
999
998
1000 hg book -f @
999 hg book -f @
1001 '''
1000 '''
1002 force = opts.get('force')
1001 force = opts.get('force')
1003 rev = opts.get('rev')
1002 rev = opts.get('rev')
1004 delete = opts.get('delete')
1003 delete = opts.get('delete')
1005 rename = opts.get('rename')
1004 rename = opts.get('rename')
1006 inactive = opts.get('inactive')
1005 inactive = opts.get('inactive')
1007
1006
1008 def checkformat(mark):
1007 def checkformat(mark):
1009 mark = mark.strip()
1008 mark = mark.strip()
1010 if not mark:
1009 if not mark:
1011 raise error.Abort(_("bookmark names cannot consist entirely of "
1010 raise error.Abort(_("bookmark names cannot consist entirely of "
1012 "whitespace"))
1011 "whitespace"))
1013 scmutil.checknewlabel(repo, mark, 'bookmark')
1012 scmutil.checknewlabel(repo, mark, 'bookmark')
1014 return mark
1013 return mark
1015
1014
1016 def checkconflict(repo, mark, cur, force=False, target=None):
1015 def checkconflict(repo, mark, cur, force=False, target=None):
1017 if mark in marks and not force:
1016 if mark in marks and not force:
1018 if target:
1017 if target:
1019 if marks[mark] == target and target == cur:
1018 if marks[mark] == target and target == cur:
1020 # re-activating a bookmark
1019 # re-activating a bookmark
1021 return
1020 return
1022 anc = repo.changelog.ancestors([repo[target].rev()])
1021 anc = repo.changelog.ancestors([repo[target].rev()])
1023 bmctx = repo[marks[mark]]
1022 bmctx = repo[marks[mark]]
1024 divs = [repo[b].node() for b in marks
1023 divs = [repo[b].node() for b in marks
1025 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
1024 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
1026
1025
1027 # allow resolving a single divergent bookmark even if moving
1026 # allow resolving a single divergent bookmark even if moving
1028 # the bookmark across branches when a revision is specified
1027 # the bookmark across branches when a revision is specified
1029 # that contains a divergent bookmark
1028 # that contains a divergent bookmark
1030 if bmctx.rev() not in anc and target in divs:
1029 if bmctx.rev() not in anc and target in divs:
1031 bookmarks.deletedivergent(repo, [target], mark)
1030 bookmarks.deletedivergent(repo, [target], mark)
1032 return
1031 return
1033
1032
1034 deletefrom = [b for b in divs
1033 deletefrom = [b for b in divs
1035 if repo[b].rev() in anc or b == target]
1034 if repo[b].rev() in anc or b == target]
1036 bookmarks.deletedivergent(repo, deletefrom, mark)
1035 bookmarks.deletedivergent(repo, deletefrom, mark)
1037 if bookmarks.validdest(repo, bmctx, repo[target]):
1036 if bookmarks.validdest(repo, bmctx, repo[target]):
1038 ui.status(_("moving bookmark '%s' forward from %s\n") %
1037 ui.status(_("moving bookmark '%s' forward from %s\n") %
1039 (mark, short(bmctx.node())))
1038 (mark, short(bmctx.node())))
1040 return
1039 return
1041 raise error.Abort(_("bookmark '%s' already exists "
1040 raise error.Abort(_("bookmark '%s' already exists "
1042 "(use -f to force)") % mark)
1041 "(use -f to force)") % mark)
1043 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1042 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1044 and not force):
1043 and not force):
1045 raise error.Abort(
1044 raise error.Abort(
1046 _("a bookmark cannot have the name of an existing branch"))
1045 _("a bookmark cannot have the name of an existing branch"))
1047
1046
1048 if delete and rename:
1047 if delete and rename:
1049 raise error.Abort(_("--delete and --rename are incompatible"))
1048 raise error.Abort(_("--delete and --rename are incompatible"))
1050 if delete and rev:
1049 if delete and rev:
1051 raise error.Abort(_("--rev is incompatible with --delete"))
1050 raise error.Abort(_("--rev is incompatible with --delete"))
1052 if rename and rev:
1051 if rename and rev:
1053 raise error.Abort(_("--rev is incompatible with --rename"))
1052 raise error.Abort(_("--rev is incompatible with --rename"))
1054 if not names and (delete or rev):
1053 if not names and (delete or rev):
1055 raise error.Abort(_("bookmark name required"))
1054 raise error.Abort(_("bookmark name required"))
1056
1055
1057 if delete or rename or names or inactive:
1056 if delete or rename or names or inactive:
1058 wlock = lock = tr = None
1057 wlock = lock = tr = None
1059 try:
1058 try:
1060 wlock = repo.wlock()
1059 wlock = repo.wlock()
1061 lock = repo.lock()
1060 lock = repo.lock()
1062 cur = repo.changectx('.').node()
1061 cur = repo.changectx('.').node()
1063 marks = repo._bookmarks
1062 marks = repo._bookmarks
1064 if delete:
1063 if delete:
1065 tr = repo.transaction('bookmark')
1064 tr = repo.transaction('bookmark')
1066 for mark in names:
1065 for mark in names:
1067 if mark not in marks:
1066 if mark not in marks:
1068 raise error.Abort(_("bookmark '%s' does not exist") %
1067 raise error.Abort(_("bookmark '%s' does not exist") %
1069 mark)
1068 mark)
1070 if mark == repo._activebookmark:
1069 if mark == repo._activebookmark:
1071 bookmarks.deactivate(repo)
1070 bookmarks.deactivate(repo)
1072 del marks[mark]
1071 del marks[mark]
1073
1072
1074 elif rename:
1073 elif rename:
1075 tr = repo.transaction('bookmark')
1074 tr = repo.transaction('bookmark')
1076 if not names:
1075 if not names:
1077 raise error.Abort(_("new bookmark name required"))
1076 raise error.Abort(_("new bookmark name required"))
1078 elif len(names) > 1:
1077 elif len(names) > 1:
1079 raise error.Abort(_("only one new bookmark name allowed"))
1078 raise error.Abort(_("only one new bookmark name allowed"))
1080 mark = checkformat(names[0])
1079 mark = checkformat(names[0])
1081 if rename not in marks:
1080 if rename not in marks:
1082 raise error.Abort(_("bookmark '%s' does not exist")
1081 raise error.Abort(_("bookmark '%s' does not exist")
1083 % rename)
1082 % rename)
1084 checkconflict(repo, mark, cur, force)
1083 checkconflict(repo, mark, cur, force)
1085 marks[mark] = marks[rename]
1084 marks[mark] = marks[rename]
1086 if repo._activebookmark == rename and not inactive:
1085 if repo._activebookmark == rename and not inactive:
1087 bookmarks.activate(repo, mark)
1086 bookmarks.activate(repo, mark)
1088 del marks[rename]
1087 del marks[rename]
1089 elif names:
1088 elif names:
1090 tr = repo.transaction('bookmark')
1089 tr = repo.transaction('bookmark')
1091 newact = None
1090 newact = None
1092 for mark in names:
1091 for mark in names:
1093 mark = checkformat(mark)
1092 mark = checkformat(mark)
1094 if newact is None:
1093 if newact is None:
1095 newact = mark
1094 newact = mark
1096 if inactive and mark == repo._activebookmark:
1095 if inactive and mark == repo._activebookmark:
1097 bookmarks.deactivate(repo)
1096 bookmarks.deactivate(repo)
1098 return
1097 return
1099 tgt = cur
1098 tgt = cur
1100 if rev:
1099 if rev:
1101 tgt = scmutil.revsingle(repo, rev).node()
1100 tgt = scmutil.revsingle(repo, rev).node()
1102 checkconflict(repo, mark, cur, force, tgt)
1101 checkconflict(repo, mark, cur, force, tgt)
1103 marks[mark] = tgt
1102 marks[mark] = tgt
1104 if not inactive and cur == marks[newact] and not rev:
1103 if not inactive and cur == marks[newact] and not rev:
1105 bookmarks.activate(repo, newact)
1104 bookmarks.activate(repo, newact)
1106 elif cur != tgt and newact == repo._activebookmark:
1105 elif cur != tgt and newact == repo._activebookmark:
1107 bookmarks.deactivate(repo)
1106 bookmarks.deactivate(repo)
1108 elif inactive:
1107 elif inactive:
1109 if len(marks) == 0:
1108 if len(marks) == 0:
1110 ui.status(_("no bookmarks set\n"))
1109 ui.status(_("no bookmarks set\n"))
1111 elif not repo._activebookmark:
1110 elif not repo._activebookmark:
1112 ui.status(_("no active bookmark\n"))
1111 ui.status(_("no active bookmark\n"))
1113 else:
1112 else:
1114 bookmarks.deactivate(repo)
1113 bookmarks.deactivate(repo)
1115 if tr is not None:
1114 if tr is not None:
1116 marks.recordchange(tr)
1115 marks.recordchange(tr)
1117 tr.close()
1116 tr.close()
1118 finally:
1117 finally:
1119 lockmod.release(tr, lock, wlock)
1118 lockmod.release(tr, lock, wlock)
1120 else: # show bookmarks
1119 else: # show bookmarks
1121 fm = ui.formatter('bookmarks', opts)
1120 fm = ui.formatter('bookmarks', opts)
1122 hexfn = fm.hexfunc
1121 hexfn = fm.hexfunc
1123 marks = repo._bookmarks
1122 marks = repo._bookmarks
1124 if len(marks) == 0 and fm.isplain():
1123 if len(marks) == 0 and fm.isplain():
1125 ui.status(_("no bookmarks set\n"))
1124 ui.status(_("no bookmarks set\n"))
1126 for bmark, n in sorted(marks.iteritems()):
1125 for bmark, n in sorted(marks.iteritems()):
1127 active = repo._activebookmark
1126 active = repo._activebookmark
1128 if bmark == active:
1127 if bmark == active:
1129 prefix, label = '*', activebookmarklabel
1128 prefix, label = '*', activebookmarklabel
1130 else:
1129 else:
1131 prefix, label = ' ', ''
1130 prefix, label = ' ', ''
1132
1131
1133 fm.startitem()
1132 fm.startitem()
1134 if not ui.quiet:
1133 if not ui.quiet:
1135 fm.plain(' %s ' % prefix, label=label)
1134 fm.plain(' %s ' % prefix, label=label)
1136 fm.write('bookmark', '%s', bmark, label=label)
1135 fm.write('bookmark', '%s', bmark, label=label)
1137 pad = " " * (25 - encoding.colwidth(bmark))
1136 pad = " " * (25 - encoding.colwidth(bmark))
1138 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1137 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1139 repo.changelog.rev(n), hexfn(n), label=label)
1138 repo.changelog.rev(n), hexfn(n), label=label)
1140 fm.data(active=(bmark == active))
1139 fm.data(active=(bmark == active))
1141 fm.plain('\n')
1140 fm.plain('\n')
1142 fm.end()
1141 fm.end()
1143
1142
1144 @command('branch',
1143 @command('branch',
1145 [('f', 'force', None,
1144 [('f', 'force', None,
1146 _('set branch name even if it shadows an existing branch')),
1145 _('set branch name even if it shadows an existing branch')),
1147 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1146 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1148 _('[-fC] [NAME]'))
1147 _('[-fC] [NAME]'))
1149 def branch(ui, repo, label=None, **opts):
1148 def branch(ui, repo, label=None, **opts):
1150 """set or show the current branch name
1149 """set or show the current branch name
1151
1150
1152 .. note::
1151 .. note::
1153
1152
1154 Branch names are permanent and global. Use :hg:`bookmark` to create a
1153 Branch names are permanent and global. Use :hg:`bookmark` to create a
1155 light-weight bookmark instead. See :hg:`help glossary` for more
1154 light-weight bookmark instead. See :hg:`help glossary` for more
1156 information about named branches and bookmarks.
1155 information about named branches and bookmarks.
1157
1156
1158 With no argument, show the current branch name. With one argument,
1157 With no argument, show the current branch name. With one argument,
1159 set the working directory branch name (the branch will not exist
1158 set the working directory branch name (the branch will not exist
1160 in the repository until the next commit). Standard practice
1159 in the repository until the next commit). Standard practice
1161 recommends that primary development take place on the 'default'
1160 recommends that primary development take place on the 'default'
1162 branch.
1161 branch.
1163
1162
1164 Unless -f/--force is specified, branch will not let you set a
1163 Unless -f/--force is specified, branch will not let you set a
1165 branch name that already exists.
1164 branch name that already exists.
1166
1165
1167 Use -C/--clean to reset the working directory branch to that of
1166 Use -C/--clean to reset the working directory branch to that of
1168 the parent of the working directory, negating a previous branch
1167 the parent of the working directory, negating a previous branch
1169 change.
1168 change.
1170
1169
1171 Use the command :hg:`update` to switch to an existing branch. Use
1170 Use the command :hg:`update` to switch to an existing branch. Use
1172 :hg:`commit --close-branch` to mark this branch head as closed.
1171 :hg:`commit --close-branch` to mark this branch head as closed.
1173 When all heads of a branch are closed, the branch will be
1172 When all heads of a branch are closed, the branch will be
1174 considered closed.
1173 considered closed.
1175
1174
1176 Returns 0 on success.
1175 Returns 0 on success.
1177 """
1176 """
1178 if label:
1177 if label:
1179 label = label.strip()
1178 label = label.strip()
1180
1179
1181 if not opts.get('clean') and not label:
1180 if not opts.get('clean') and not label:
1182 ui.write("%s\n" % repo.dirstate.branch())
1181 ui.write("%s\n" % repo.dirstate.branch())
1183 return
1182 return
1184
1183
1185 with repo.wlock():
1184 with repo.wlock():
1186 if opts.get('clean'):
1185 if opts.get('clean'):
1187 label = repo[None].p1().branch()
1186 label = repo[None].p1().branch()
1188 repo.dirstate.setbranch(label)
1187 repo.dirstate.setbranch(label)
1189 ui.status(_('reset working directory to branch %s\n') % label)
1188 ui.status(_('reset working directory to branch %s\n') % label)
1190 elif label:
1189 elif label:
1191 if not opts.get('force') and label in repo.branchmap():
1190 if not opts.get('force') and label in repo.branchmap():
1192 if label not in [p.branch() for p in repo[None].parents()]:
1191 if label not in [p.branch() for p in repo[None].parents()]:
1193 raise error.Abort(_('a branch of the same name already'
1192 raise error.Abort(_('a branch of the same name already'
1194 ' exists'),
1193 ' exists'),
1195 # i18n: "it" refers to an existing branch
1194 # i18n: "it" refers to an existing branch
1196 hint=_("use 'hg update' to switch to it"))
1195 hint=_("use 'hg update' to switch to it"))
1197 scmutil.checknewlabel(repo, label, 'branch')
1196 scmutil.checknewlabel(repo, label, 'branch')
1198 repo.dirstate.setbranch(label)
1197 repo.dirstate.setbranch(label)
1199 ui.status(_('marked working directory as branch %s\n') % label)
1198 ui.status(_('marked working directory as branch %s\n') % label)
1200
1199
1201 # find any open named branches aside from default
1200 # find any open named branches aside from default
1202 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1201 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1203 if n != "default" and not c]
1202 if n != "default" and not c]
1204 if not others:
1203 if not others:
1205 ui.status(_('(branches are permanent and global, '
1204 ui.status(_('(branches are permanent and global, '
1206 'did you want a bookmark?)\n'))
1205 'did you want a bookmark?)\n'))
1207
1206
1208 @command('branches',
1207 @command('branches',
1209 [('a', 'active', False,
1208 [('a', 'active', False,
1210 _('show only branches that have unmerged heads (DEPRECATED)')),
1209 _('show only branches that have unmerged heads (DEPRECATED)')),
1211 ('c', 'closed', False, _('show normal and closed branches')),
1210 ('c', 'closed', False, _('show normal and closed branches')),
1212 ] + formatteropts,
1211 ] + formatteropts,
1213 _('[-c]'))
1212 _('[-c]'))
1214 def branches(ui, repo, active=False, closed=False, **opts):
1213 def branches(ui, repo, active=False, closed=False, **opts):
1215 """list repository named branches
1214 """list repository named branches
1216
1215
1217 List the repository's named branches, indicating which ones are
1216 List the repository's named branches, indicating which ones are
1218 inactive. If -c/--closed is specified, also list branches which have
1217 inactive. If -c/--closed is specified, also list branches which have
1219 been marked closed (see :hg:`commit --close-branch`).
1218 been marked closed (see :hg:`commit --close-branch`).
1220
1219
1221 Use the command :hg:`update` to switch to an existing branch.
1220 Use the command :hg:`update` to switch to an existing branch.
1222
1221
1223 Returns 0.
1222 Returns 0.
1224 """
1223 """
1225
1224
1226 fm = ui.formatter('branches', opts)
1225 fm = ui.formatter('branches', opts)
1227 hexfunc = fm.hexfunc
1226 hexfunc = fm.hexfunc
1228
1227
1229 allheads = set(repo.heads())
1228 allheads = set(repo.heads())
1230 branches = []
1229 branches = []
1231 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1230 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1232 isactive = not isclosed and bool(set(heads) & allheads)
1231 isactive = not isclosed and bool(set(heads) & allheads)
1233 branches.append((tag, repo[tip], isactive, not isclosed))
1232 branches.append((tag, repo[tip], isactive, not isclosed))
1234 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1233 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1235 reverse=True)
1234 reverse=True)
1236
1235
1237 for tag, ctx, isactive, isopen in branches:
1236 for tag, ctx, isactive, isopen in branches:
1238 if active and not isactive:
1237 if active and not isactive:
1239 continue
1238 continue
1240 if isactive:
1239 if isactive:
1241 label = 'branches.active'
1240 label = 'branches.active'
1242 notice = ''
1241 notice = ''
1243 elif not isopen:
1242 elif not isopen:
1244 if not closed:
1243 if not closed:
1245 continue
1244 continue
1246 label = 'branches.closed'
1245 label = 'branches.closed'
1247 notice = _(' (closed)')
1246 notice = _(' (closed)')
1248 else:
1247 else:
1249 label = 'branches.inactive'
1248 label = 'branches.inactive'
1250 notice = _(' (inactive)')
1249 notice = _(' (inactive)')
1251 current = (tag == repo.dirstate.branch())
1250 current = (tag == repo.dirstate.branch())
1252 if current:
1251 if current:
1253 label = 'branches.current'
1252 label = 'branches.current'
1254
1253
1255 fm.startitem()
1254 fm.startitem()
1256 fm.write('branch', '%s', tag, label=label)
1255 fm.write('branch', '%s', tag, label=label)
1257 rev = ctx.rev()
1256 rev = ctx.rev()
1258 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1257 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1259 fmt = ' ' * padsize + ' %d:%s'
1258 fmt = ' ' * padsize + ' %d:%s'
1260 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1259 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1261 label='log.changeset changeset.%s' % ctx.phasestr())
1260 label='log.changeset changeset.%s' % ctx.phasestr())
1262 fm.data(active=isactive, closed=not isopen, current=current)
1261 fm.data(active=isactive, closed=not isopen, current=current)
1263 if not ui.quiet:
1262 if not ui.quiet:
1264 fm.plain(notice)
1263 fm.plain(notice)
1265 fm.plain('\n')
1264 fm.plain('\n')
1266 fm.end()
1265 fm.end()
1267
1266
1268 @command('bundle',
1267 @command('bundle',
1269 [('f', 'force', None, _('run even when the destination is unrelated')),
1268 [('f', 'force', None, _('run even when the destination is unrelated')),
1270 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1269 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1271 _('REV')),
1270 _('REV')),
1272 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1271 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1273 _('BRANCH')),
1272 _('BRANCH')),
1274 ('', 'base', [],
1273 ('', 'base', [],
1275 _('a base changeset assumed to be available at the destination'),
1274 _('a base changeset assumed to be available at the destination'),
1276 _('REV')),
1275 _('REV')),
1277 ('a', 'all', None, _('bundle all changesets in the repository')),
1276 ('a', 'all', None, _('bundle all changesets in the repository')),
1278 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1277 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1279 ] + remoteopts,
1278 ] + remoteopts,
1280 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1279 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1281 def bundle(ui, repo, fname, dest=None, **opts):
1280 def bundle(ui, repo, fname, dest=None, **opts):
1282 """create a changegroup file
1281 """create a changegroup file
1283
1282
1284 Generate a changegroup file collecting changesets to be added
1283 Generate a changegroup file collecting changesets to be added
1285 to a repository.
1284 to a repository.
1286
1285
1287 To create a bundle containing all changesets, use -a/--all
1286 To create a bundle containing all changesets, use -a/--all
1288 (or --base null). Otherwise, hg assumes the destination will have
1287 (or --base null). Otherwise, hg assumes the destination will have
1289 all the nodes you specify with --base parameters. Otherwise, hg
1288 all the nodes you specify with --base parameters. Otherwise, hg
1290 will assume the repository has all the nodes in destination, or
1289 will assume the repository has all the nodes in destination, or
1291 default-push/default if no destination is specified.
1290 default-push/default if no destination is specified.
1292
1291
1293 You can change bundle format with the -t/--type option. You can
1292 You can change bundle format with the -t/--type option. You can
1294 specify a compression, a bundle version or both using a dash
1293 specify a compression, a bundle version or both using a dash
1295 (comp-version). The available compression methods are: none, bzip2,
1294 (comp-version). The available compression methods are: none, bzip2,
1296 and gzip (by default, bundles are compressed using bzip2). The
1295 and gzip (by default, bundles are compressed using bzip2). The
1297 available formats are: v1, v2 (default to most suitable).
1296 available formats are: v1, v2 (default to most suitable).
1298
1297
1299 The bundle file can then be transferred using conventional means
1298 The bundle file can then be transferred using conventional means
1300 and applied to another repository with the unbundle or pull
1299 and applied to another repository with the unbundle or pull
1301 command. This is useful when direct push and pull are not
1300 command. This is useful when direct push and pull are not
1302 available or when exporting an entire repository is undesirable.
1301 available or when exporting an entire repository is undesirable.
1303
1302
1304 Applying bundles preserves all changeset contents including
1303 Applying bundles preserves all changeset contents including
1305 permissions, copy/rename information, and revision history.
1304 permissions, copy/rename information, and revision history.
1306
1305
1307 Returns 0 on success, 1 if no changes found.
1306 Returns 0 on success, 1 if no changes found.
1308 """
1307 """
1309 revs = None
1308 revs = None
1310 if 'rev' in opts:
1309 if 'rev' in opts:
1311 revstrings = opts['rev']
1310 revstrings = opts['rev']
1312 revs = scmutil.revrange(repo, revstrings)
1311 revs = scmutil.revrange(repo, revstrings)
1313 if revstrings and not revs:
1312 if revstrings and not revs:
1314 raise error.Abort(_('no commits to bundle'))
1313 raise error.Abort(_('no commits to bundle'))
1315
1314
1316 bundletype = opts.get('type', 'bzip2').lower()
1315 bundletype = opts.get('type', 'bzip2').lower()
1317 try:
1316 try:
1318 bcompression, cgversion, params = exchange.parsebundlespec(
1317 bcompression, cgversion, params = exchange.parsebundlespec(
1319 repo, bundletype, strict=False)
1318 repo, bundletype, strict=False)
1320 except error.UnsupportedBundleSpecification as e:
1319 except error.UnsupportedBundleSpecification as e:
1321 raise error.Abort(str(e),
1320 raise error.Abort(str(e),
1322 hint=_("see 'hg help bundle' for supported "
1321 hint=_("see 'hg help bundle' for supported "
1323 "values for --type"))
1322 "values for --type"))
1324
1323
1325 # Packed bundles are a pseudo bundle format for now.
1324 # Packed bundles are a pseudo bundle format for now.
1326 if cgversion == 's1':
1325 if cgversion == 's1':
1327 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1326 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1328 hint=_("use 'hg debugcreatestreamclonebundle'"))
1327 hint=_("use 'hg debugcreatestreamclonebundle'"))
1329
1328
1330 if opts.get('all'):
1329 if opts.get('all'):
1331 if dest:
1330 if dest:
1332 raise error.Abort(_("--all is incompatible with specifying "
1331 raise error.Abort(_("--all is incompatible with specifying "
1333 "a destination"))
1332 "a destination"))
1334 if opts.get('base'):
1333 if opts.get('base'):
1335 ui.warn(_("ignoring --base because --all was specified\n"))
1334 ui.warn(_("ignoring --base because --all was specified\n"))
1336 base = ['null']
1335 base = ['null']
1337 else:
1336 else:
1338 base = scmutil.revrange(repo, opts.get('base'))
1337 base = scmutil.revrange(repo, opts.get('base'))
1339 # TODO: get desired bundlecaps from command line.
1338 # TODO: get desired bundlecaps from command line.
1340 bundlecaps = None
1339 bundlecaps = None
1341 if cgversion not in changegroup.supportedoutgoingversions(repo):
1340 if cgversion not in changegroup.supportedoutgoingversions(repo):
1342 raise error.Abort(_("repository does not support bundle version %s") %
1341 raise error.Abort(_("repository does not support bundle version %s") %
1343 cgversion)
1342 cgversion)
1344
1343
1345 if base:
1344 if base:
1346 if dest:
1345 if dest:
1347 raise error.Abort(_("--base is incompatible with specifying "
1346 raise error.Abort(_("--base is incompatible with specifying "
1348 "a destination"))
1347 "a destination"))
1349 common = [repo.lookup(rev) for rev in base]
1348 common = [repo.lookup(rev) for rev in base]
1350 heads = revs and map(repo.lookup, revs) or None
1349 heads = revs and map(repo.lookup, revs) or None
1351 outgoing = discovery.outgoing(repo, common, heads)
1350 outgoing = discovery.outgoing(repo, common, heads)
1352 cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
1351 cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
1353 bundlecaps=bundlecaps,
1352 bundlecaps=bundlecaps,
1354 version=cgversion)
1353 version=cgversion)
1355 outgoing = None
1354 outgoing = None
1356 else:
1355 else:
1357 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1356 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1358 dest, branches = hg.parseurl(dest, opts.get('branch'))
1357 dest, branches = hg.parseurl(dest, opts.get('branch'))
1359 other = hg.peer(repo, opts, dest)
1358 other = hg.peer(repo, opts, dest)
1360 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1359 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1361 heads = revs and map(repo.lookup, revs) or revs
1360 heads = revs and map(repo.lookup, revs) or revs
1362 outgoing = discovery.findcommonoutgoing(repo, other,
1361 outgoing = discovery.findcommonoutgoing(repo, other,
1363 onlyheads=heads,
1362 onlyheads=heads,
1364 force=opts.get('force'),
1363 force=opts.get('force'),
1365 portable=True)
1364 portable=True)
1366 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1365 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1367 bundlecaps, version=cgversion)
1366 bundlecaps, version=cgversion)
1368 if not cg:
1367 if not cg:
1369 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1368 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1370 return 1
1369 return 1
1371
1370
1372 if cgversion == '01': #bundle1
1371 if cgversion == '01': #bundle1
1373 if bcompression is None:
1372 if bcompression is None:
1374 bcompression = 'UN'
1373 bcompression = 'UN'
1375 bversion = 'HG10' + bcompression
1374 bversion = 'HG10' + bcompression
1376 bcompression = None
1375 bcompression = None
1377 else:
1376 else:
1378 assert cgversion == '02'
1377 assert cgversion == '02'
1379 bversion = 'HG20'
1378 bversion = 'HG20'
1380
1379
1381 # TODO compression options should be derived from bundlespec parsing.
1380 # TODO compression options should be derived from bundlespec parsing.
1382 # This is a temporary hack to allow adjusting bundle compression
1381 # This is a temporary hack to allow adjusting bundle compression
1383 # level without a) formalizing the bundlespec changes to declare it
1382 # level without a) formalizing the bundlespec changes to declare it
1384 # b) introducing a command flag.
1383 # b) introducing a command flag.
1385 compopts = {}
1384 compopts = {}
1386 complevel = ui.configint('experimental', 'bundlecomplevel')
1385 complevel = ui.configint('experimental', 'bundlecomplevel')
1387 if complevel is not None:
1386 if complevel is not None:
1388 compopts['level'] = complevel
1387 compopts['level'] = complevel
1389
1388
1390 bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression,
1389 bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression,
1391 compopts=compopts)
1390 compopts=compopts)
1392
1391
1393 @command('cat',
1392 @command('cat',
1394 [('o', 'output', '',
1393 [('o', 'output', '',
1395 _('print output to file with formatted name'), _('FORMAT')),
1394 _('print output to file with formatted name'), _('FORMAT')),
1396 ('r', 'rev', '', _('print the given revision'), _('REV')),
1395 ('r', 'rev', '', _('print the given revision'), _('REV')),
1397 ('', 'decode', None, _('apply any matching decode filter')),
1396 ('', 'decode', None, _('apply any matching decode filter')),
1398 ] + walkopts,
1397 ] + walkopts,
1399 _('[OPTION]... FILE...'),
1398 _('[OPTION]... FILE...'),
1400 inferrepo=True)
1399 inferrepo=True)
1401 def cat(ui, repo, file1, *pats, **opts):
1400 def cat(ui, repo, file1, *pats, **opts):
1402 """output the current or given revision of files
1401 """output the current or given revision of files
1403
1402
1404 Print the specified files as they were at the given revision. If
1403 Print the specified files as they were at the given revision. If
1405 no revision is given, the parent of the working directory is used.
1404 no revision is given, the parent of the working directory is used.
1406
1405
1407 Output may be to a file, in which case the name of the file is
1406 Output may be to a file, in which case the name of the file is
1408 given using a format string. The formatting rules as follows:
1407 given using a format string. The formatting rules as follows:
1409
1408
1410 :``%%``: literal "%" character
1409 :``%%``: literal "%" character
1411 :``%s``: basename of file being printed
1410 :``%s``: basename of file being printed
1412 :``%d``: dirname of file being printed, or '.' if in repository root
1411 :``%d``: dirname of file being printed, or '.' if in repository root
1413 :``%p``: root-relative path name of file being printed
1412 :``%p``: root-relative path name of file being printed
1414 :``%H``: changeset hash (40 hexadecimal digits)
1413 :``%H``: changeset hash (40 hexadecimal digits)
1415 :``%R``: changeset revision number
1414 :``%R``: changeset revision number
1416 :``%h``: short-form changeset hash (12 hexadecimal digits)
1415 :``%h``: short-form changeset hash (12 hexadecimal digits)
1417 :``%r``: zero-padded changeset revision number
1416 :``%r``: zero-padded changeset revision number
1418 :``%b``: basename of the exporting repository
1417 :``%b``: basename of the exporting repository
1419
1418
1420 Returns 0 on success.
1419 Returns 0 on success.
1421 """
1420 """
1422 ctx = scmutil.revsingle(repo, opts.get('rev'))
1421 ctx = scmutil.revsingle(repo, opts.get('rev'))
1423 m = scmutil.match(ctx, (file1,) + pats, opts)
1422 m = scmutil.match(ctx, (file1,) + pats, opts)
1424
1423
1425 ui.pager('cat')
1424 ui.pager('cat')
1426 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1425 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1427
1426
1428 @command('^clone',
1427 @command('^clone',
1429 [('U', 'noupdate', None, _('the clone will include an empty working '
1428 [('U', 'noupdate', None, _('the clone will include an empty working '
1430 'directory (only a repository)')),
1429 'directory (only a repository)')),
1431 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1430 ('u', 'updaterev', '', _('revision, tag, or branch to check out'),
1432 _('REV')),
1431 _('REV')),
1433 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1432 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1434 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1433 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1435 ('', 'pull', None, _('use pull protocol to copy metadata')),
1434 ('', 'pull', None, _('use pull protocol to copy metadata')),
1436 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1435 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1437 ] + remoteopts,
1436 ] + remoteopts,
1438 _('[OPTION]... SOURCE [DEST]'),
1437 _('[OPTION]... SOURCE [DEST]'),
1439 norepo=True)
1438 norepo=True)
1440 def clone(ui, source, dest=None, **opts):
1439 def clone(ui, source, dest=None, **opts):
1441 """make a copy of an existing repository
1440 """make a copy of an existing repository
1442
1441
1443 Create a copy of an existing repository in a new directory.
1442 Create a copy of an existing repository in a new directory.
1444
1443
1445 If no destination directory name is specified, it defaults to the
1444 If no destination directory name is specified, it defaults to the
1446 basename of the source.
1445 basename of the source.
1447
1446
1448 The location of the source is added to the new repository's
1447 The location of the source is added to the new repository's
1449 ``.hg/hgrc`` file, as the default to be used for future pulls.
1448 ``.hg/hgrc`` file, as the default to be used for future pulls.
1450
1449
1451 Only local paths and ``ssh://`` URLs are supported as
1450 Only local paths and ``ssh://`` URLs are supported as
1452 destinations. For ``ssh://`` destinations, no working directory or
1451 destinations. For ``ssh://`` destinations, no working directory or
1453 ``.hg/hgrc`` will be created on the remote side.
1452 ``.hg/hgrc`` will be created on the remote side.
1454
1453
1455 If the source repository has a bookmark called '@' set, that
1454 If the source repository has a bookmark called '@' set, that
1456 revision will be checked out in the new repository by default.
1455 revision will be checked out in the new repository by default.
1457
1456
1458 To check out a particular version, use -u/--update, or
1457 To check out a particular version, use -u/--update, or
1459 -U/--noupdate to create a clone with no working directory.
1458 -U/--noupdate to create a clone with no working directory.
1460
1459
1461 To pull only a subset of changesets, specify one or more revisions
1460 To pull only a subset of changesets, specify one or more revisions
1462 identifiers with -r/--rev or branches with -b/--branch. The
1461 identifiers with -r/--rev or branches with -b/--branch. The
1463 resulting clone will contain only the specified changesets and
1462 resulting clone will contain only the specified changesets and
1464 their ancestors. These options (or 'clone src#rev dest') imply
1463 their ancestors. These options (or 'clone src#rev dest') imply
1465 --pull, even for local source repositories.
1464 --pull, even for local source repositories.
1466
1465
1467 .. note::
1466 .. note::
1468
1467
1469 Specifying a tag will include the tagged changeset but not the
1468 Specifying a tag will include the tagged changeset but not the
1470 changeset containing the tag.
1469 changeset containing the tag.
1471
1470
1472 .. container:: verbose
1471 .. container:: verbose
1473
1472
1474 For efficiency, hardlinks are used for cloning whenever the
1473 For efficiency, hardlinks are used for cloning whenever the
1475 source and destination are on the same filesystem (note this
1474 source and destination are on the same filesystem (note this
1476 applies only to the repository data, not to the working
1475 applies only to the repository data, not to the working
1477 directory). Some filesystems, such as AFS, implement hardlinking
1476 directory). Some filesystems, such as AFS, implement hardlinking
1478 incorrectly, but do not report errors. In these cases, use the
1477 incorrectly, but do not report errors. In these cases, use the
1479 --pull option to avoid hardlinking.
1478 --pull option to avoid hardlinking.
1480
1479
1481 In some cases, you can clone repositories and the working
1480 In some cases, you can clone repositories and the working
1482 directory using full hardlinks with ::
1481 directory using full hardlinks with ::
1483
1482
1484 $ cp -al REPO REPOCLONE
1483 $ cp -al REPO REPOCLONE
1485
1484
1486 This is the fastest way to clone, but it is not always safe. The
1485 This is the fastest way to clone, but it is not always safe. The
1487 operation is not atomic (making sure REPO is not modified during
1486 operation is not atomic (making sure REPO is not modified during
1488 the operation is up to you) and you have to make sure your
1487 the operation is up to you) and you have to make sure your
1489 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1488 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1490 so). Also, this is not compatible with certain extensions that
1489 so). Also, this is not compatible with certain extensions that
1491 place their metadata under the .hg directory, such as mq.
1490 place their metadata under the .hg directory, such as mq.
1492
1491
1493 Mercurial will update the working directory to the first applicable
1492 Mercurial will update the working directory to the first applicable
1494 revision from this list:
1493 revision from this list:
1495
1494
1496 a) null if -U or the source repository has no changesets
1495 a) null if -U or the source repository has no changesets
1497 b) if -u . and the source repository is local, the first parent of
1496 b) if -u . and the source repository is local, the first parent of
1498 the source repository's working directory
1497 the source repository's working directory
1499 c) the changeset specified with -u (if a branch name, this means the
1498 c) the changeset specified with -u (if a branch name, this means the
1500 latest head of that branch)
1499 latest head of that branch)
1501 d) the changeset specified with -r
1500 d) the changeset specified with -r
1502 e) the tipmost head specified with -b
1501 e) the tipmost head specified with -b
1503 f) the tipmost head specified with the url#branch source syntax
1502 f) the tipmost head specified with the url#branch source syntax
1504 g) the revision marked with the '@' bookmark, if present
1503 g) the revision marked with the '@' bookmark, if present
1505 h) the tipmost head of the default branch
1504 h) the tipmost head of the default branch
1506 i) tip
1505 i) tip
1507
1506
1508 When cloning from servers that support it, Mercurial may fetch
1507 When cloning from servers that support it, Mercurial may fetch
1509 pre-generated data from a server-advertised URL. When this is done,
1508 pre-generated data from a server-advertised URL. When this is done,
1510 hooks operating on incoming changesets and changegroups may fire twice,
1509 hooks operating on incoming changesets and changegroups may fire twice,
1511 once for the bundle fetched from the URL and another for any additional
1510 once for the bundle fetched from the URL and another for any additional
1512 data not fetched from this URL. In addition, if an error occurs, the
1511 data not fetched from this URL. In addition, if an error occurs, the
1513 repository may be rolled back to a partial clone. This behavior may
1512 repository may be rolled back to a partial clone. This behavior may
1514 change in future releases. See :hg:`help -e clonebundles` for more.
1513 change in future releases. See :hg:`help -e clonebundles` for more.
1515
1514
1516 Examples:
1515 Examples:
1517
1516
1518 - clone a remote repository to a new directory named hg/::
1517 - clone a remote repository to a new directory named hg/::
1519
1518
1520 hg clone https://www.mercurial-scm.org/repo/hg/
1519 hg clone https://www.mercurial-scm.org/repo/hg/
1521
1520
1522 - create a lightweight local clone::
1521 - create a lightweight local clone::
1523
1522
1524 hg clone project/ project-feature/
1523 hg clone project/ project-feature/
1525
1524
1526 - clone from an absolute path on an ssh server (note double-slash)::
1525 - clone from an absolute path on an ssh server (note double-slash)::
1527
1526
1528 hg clone ssh://user@server//home/projects/alpha/
1527 hg clone ssh://user@server//home/projects/alpha/
1529
1528
1530 - do a high-speed clone over a LAN while checking out a
1529 - do a high-speed clone over a LAN while checking out a
1531 specified version::
1530 specified version::
1532
1531
1533 hg clone --uncompressed http://server/repo -u 1.5
1532 hg clone --uncompressed http://server/repo -u 1.5
1534
1533
1535 - create a repository without changesets after a particular revision::
1534 - create a repository without changesets after a particular revision::
1536
1535
1537 hg clone -r 04e544 experimental/ good/
1536 hg clone -r 04e544 experimental/ good/
1538
1537
1539 - clone (and track) a particular named branch::
1538 - clone (and track) a particular named branch::
1540
1539
1541 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1540 hg clone https://www.mercurial-scm.org/repo/hg/#stable
1542
1541
1543 See :hg:`help urls` for details on specifying URLs.
1542 See :hg:`help urls` for details on specifying URLs.
1544
1543
1545 Returns 0 on success.
1544 Returns 0 on success.
1546 """
1545 """
1547 if opts.get('noupdate') and opts.get('updaterev'):
1546 if opts.get('noupdate') and opts.get('updaterev'):
1548 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1547 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1549
1548
1550 r = hg.clone(ui, opts, source, dest,
1549 r = hg.clone(ui, opts, source, dest,
1551 pull=opts.get('pull'),
1550 pull=opts.get('pull'),
1552 stream=opts.get('uncompressed'),
1551 stream=opts.get('uncompressed'),
1553 rev=opts.get('rev'),
1552 rev=opts.get('rev'),
1554 update=opts.get('updaterev') or not opts.get('noupdate'),
1553 update=opts.get('updaterev') or not opts.get('noupdate'),
1555 branch=opts.get('branch'),
1554 branch=opts.get('branch'),
1556 shareopts=opts.get('shareopts'))
1555 shareopts=opts.get('shareopts'))
1557
1556
1558 return r is None
1557 return r is None
1559
1558
1560 @command('^commit|ci',
1559 @command('^commit|ci',
1561 [('A', 'addremove', None,
1560 [('A', 'addremove', None,
1562 _('mark new/missing files as added/removed before committing')),
1561 _('mark new/missing files as added/removed before committing')),
1563 ('', 'close-branch', None,
1562 ('', 'close-branch', None,
1564 _('mark a branch head as closed')),
1563 _('mark a branch head as closed')),
1565 ('', 'amend', None, _('amend the parent of the working directory')),
1564 ('', 'amend', None, _('amend the parent of the working directory')),
1566 ('s', 'secret', None, _('use the secret phase for committing')),
1565 ('s', 'secret', None, _('use the secret phase for committing')),
1567 ('e', 'edit', None, _('invoke editor on commit messages')),
1566 ('e', 'edit', None, _('invoke editor on commit messages')),
1568 ('i', 'interactive', None, _('use interactive mode')),
1567 ('i', 'interactive', None, _('use interactive mode')),
1569 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1568 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1570 _('[OPTION]... [FILE]...'),
1569 _('[OPTION]... [FILE]...'),
1571 inferrepo=True)
1570 inferrepo=True)
1572 def commit(ui, repo, *pats, **opts):
1571 def commit(ui, repo, *pats, **opts):
1573 """commit the specified files or all outstanding changes
1572 """commit the specified files or all outstanding changes
1574
1573
1575 Commit changes to the given files into the repository. Unlike a
1574 Commit changes to the given files into the repository. Unlike a
1576 centralized SCM, this operation is a local operation. See
1575 centralized SCM, this operation is a local operation. See
1577 :hg:`push` for a way to actively distribute your changes.
1576 :hg:`push` for a way to actively distribute your changes.
1578
1577
1579 If a list of files is omitted, all changes reported by :hg:`status`
1578 If a list of files is omitted, all changes reported by :hg:`status`
1580 will be committed.
1579 will be committed.
1581
1580
1582 If you are committing the result of a merge, do not provide any
1581 If you are committing the result of a merge, do not provide any
1583 filenames or -I/-X filters.
1582 filenames or -I/-X filters.
1584
1583
1585 If no commit message is specified, Mercurial starts your
1584 If no commit message is specified, Mercurial starts your
1586 configured editor where you can enter a message. In case your
1585 configured editor where you can enter a message. In case your
1587 commit fails, you will find a backup of your message in
1586 commit fails, you will find a backup of your message in
1588 ``.hg/last-message.txt``.
1587 ``.hg/last-message.txt``.
1589
1588
1590 The --close-branch flag can be used to mark the current branch
1589 The --close-branch flag can be used to mark the current branch
1591 head closed. When all heads of a branch are closed, the branch
1590 head closed. When all heads of a branch are closed, the branch
1592 will be considered closed and no longer listed.
1591 will be considered closed and no longer listed.
1593
1592
1594 The --amend flag can be used to amend the parent of the
1593 The --amend flag can be used to amend the parent of the
1595 working directory with a new commit that contains the changes
1594 working directory with a new commit that contains the changes
1596 in the parent in addition to those currently reported by :hg:`status`,
1595 in the parent in addition to those currently reported by :hg:`status`,
1597 if there are any. The old commit is stored in a backup bundle in
1596 if there are any. The old commit is stored in a backup bundle in
1598 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1597 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1599 on how to restore it).
1598 on how to restore it).
1600
1599
1601 Message, user and date are taken from the amended commit unless
1600 Message, user and date are taken from the amended commit unless
1602 specified. When a message isn't specified on the command line,
1601 specified. When a message isn't specified on the command line,
1603 the editor will open with the message of the amended commit.
1602 the editor will open with the message of the amended commit.
1604
1603
1605 It is not possible to amend public changesets (see :hg:`help phases`)
1604 It is not possible to amend public changesets (see :hg:`help phases`)
1606 or changesets that have children.
1605 or changesets that have children.
1607
1606
1608 See :hg:`help dates` for a list of formats valid for -d/--date.
1607 See :hg:`help dates` for a list of formats valid for -d/--date.
1609
1608
1610 Returns 0 on success, 1 if nothing changed.
1609 Returns 0 on success, 1 if nothing changed.
1611
1610
1612 .. container:: verbose
1611 .. container:: verbose
1613
1612
1614 Examples:
1613 Examples:
1615
1614
1616 - commit all files ending in .py::
1615 - commit all files ending in .py::
1617
1616
1618 hg commit --include "set:**.py"
1617 hg commit --include "set:**.py"
1619
1618
1620 - commit all non-binary files::
1619 - commit all non-binary files::
1621
1620
1622 hg commit --exclude "set:binary()"
1621 hg commit --exclude "set:binary()"
1623
1622
1624 - amend the current commit and set the date to now::
1623 - amend the current commit and set the date to now::
1625
1624
1626 hg commit --amend --date now
1625 hg commit --amend --date now
1627 """
1626 """
1628 wlock = lock = None
1627 wlock = lock = None
1629 try:
1628 try:
1630 wlock = repo.wlock()
1629 wlock = repo.wlock()
1631 lock = repo.lock()
1630 lock = repo.lock()
1632 return _docommit(ui, repo, *pats, **opts)
1631 return _docommit(ui, repo, *pats, **opts)
1633 finally:
1632 finally:
1634 release(lock, wlock)
1633 release(lock, wlock)
1635
1634
1636 def _docommit(ui, repo, *pats, **opts):
1635 def _docommit(ui, repo, *pats, **opts):
1637 if opts.get('interactive'):
1636 if opts.get('interactive'):
1638 opts.pop('interactive')
1637 opts.pop('interactive')
1639 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1638 ret = cmdutil.dorecord(ui, repo, commit, None, False,
1640 cmdutil.recordfilter, *pats, **opts)
1639 cmdutil.recordfilter, *pats, **opts)
1641 # ret can be 0 (no changes to record) or the value returned by
1640 # ret can be 0 (no changes to record) or the value returned by
1642 # commit(), 1 if nothing changed or None on success.
1641 # commit(), 1 if nothing changed or None on success.
1643 return 1 if ret == 0 else ret
1642 return 1 if ret == 0 else ret
1644
1643
1645 if opts.get('subrepos'):
1644 if opts.get('subrepos'):
1646 if opts.get('amend'):
1645 if opts.get('amend'):
1647 raise error.Abort(_('cannot amend with --subrepos'))
1646 raise error.Abort(_('cannot amend with --subrepos'))
1648 # Let --subrepos on the command line override config setting.
1647 # Let --subrepos on the command line override config setting.
1649 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1648 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1650
1649
1651 cmdutil.checkunfinished(repo, commit=True)
1650 cmdutil.checkunfinished(repo, commit=True)
1652
1651
1653 branch = repo[None].branch()
1652 branch = repo[None].branch()
1654 bheads = repo.branchheads(branch)
1653 bheads = repo.branchheads(branch)
1655
1654
1656 extra = {}
1655 extra = {}
1657 if opts.get('close_branch'):
1656 if opts.get('close_branch'):
1658 extra['close'] = 1
1657 extra['close'] = 1
1659
1658
1660 if not bheads:
1659 if not bheads:
1661 raise error.Abort(_('can only close branch heads'))
1660 raise error.Abort(_('can only close branch heads'))
1662 elif opts.get('amend'):
1661 elif opts.get('amend'):
1663 if repo[None].parents()[0].p1().branch() != branch and \
1662 if repo[None].parents()[0].p1().branch() != branch and \
1664 repo[None].parents()[0].p2().branch() != branch:
1663 repo[None].parents()[0].p2().branch() != branch:
1665 raise error.Abort(_('can only close branch heads'))
1664 raise error.Abort(_('can only close branch heads'))
1666
1665
1667 if opts.get('amend'):
1666 if opts.get('amend'):
1668 if ui.configbool('ui', 'commitsubrepos'):
1667 if ui.configbool('ui', 'commitsubrepos'):
1669 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1668 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1670
1669
1671 old = repo['.']
1670 old = repo['.']
1672 if not old.mutable():
1671 if not old.mutable():
1673 raise error.Abort(_('cannot amend public changesets'))
1672 raise error.Abort(_('cannot amend public changesets'))
1674 if len(repo[None].parents()) > 1:
1673 if len(repo[None].parents()) > 1:
1675 raise error.Abort(_('cannot amend while merging'))
1674 raise error.Abort(_('cannot amend while merging'))
1676 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1675 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1677 if not allowunstable and old.children():
1676 if not allowunstable and old.children():
1678 raise error.Abort(_('cannot amend changeset with children'))
1677 raise error.Abort(_('cannot amend changeset with children'))
1679
1678
1680 # Currently histedit gets confused if an amend happens while histedit
1679 # Currently histedit gets confused if an amend happens while histedit
1681 # is in progress. Since we have a checkunfinished command, we are
1680 # is in progress. Since we have a checkunfinished command, we are
1682 # temporarily honoring it.
1681 # temporarily honoring it.
1683 #
1682 #
1684 # Note: eventually this guard will be removed. Please do not expect
1683 # Note: eventually this guard will be removed. Please do not expect
1685 # this behavior to remain.
1684 # this behavior to remain.
1686 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1685 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1687 cmdutil.checkunfinished(repo)
1686 cmdutil.checkunfinished(repo)
1688
1687
1689 # commitfunc is used only for temporary amend commit by cmdutil.amend
1688 # commitfunc is used only for temporary amend commit by cmdutil.amend
1690 def commitfunc(ui, repo, message, match, opts):
1689 def commitfunc(ui, repo, message, match, opts):
1691 return repo.commit(message,
1690 return repo.commit(message,
1692 opts.get('user') or old.user(),
1691 opts.get('user') or old.user(),
1693 opts.get('date') or old.date(),
1692 opts.get('date') or old.date(),
1694 match,
1693 match,
1695 extra=extra)
1694 extra=extra)
1696
1695
1697 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1696 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1698 if node == old.node():
1697 if node == old.node():
1699 ui.status(_("nothing changed\n"))
1698 ui.status(_("nothing changed\n"))
1700 return 1
1699 return 1
1701 else:
1700 else:
1702 def commitfunc(ui, repo, message, match, opts):
1701 def commitfunc(ui, repo, message, match, opts):
1703 backup = ui.backupconfig('phases', 'new-commit')
1702 backup = ui.backupconfig('phases', 'new-commit')
1704 baseui = repo.baseui
1703 baseui = repo.baseui
1705 basebackup = baseui.backupconfig('phases', 'new-commit')
1704 basebackup = baseui.backupconfig('phases', 'new-commit')
1706 try:
1705 try:
1707 if opts.get('secret'):
1706 if opts.get('secret'):
1708 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1707 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1709 # Propagate to subrepos
1708 # Propagate to subrepos
1710 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1709 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1711
1710
1712 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1711 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1713 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1712 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1714 return repo.commit(message, opts.get('user'), opts.get('date'),
1713 return repo.commit(message, opts.get('user'), opts.get('date'),
1715 match,
1714 match,
1716 editor=editor,
1715 editor=editor,
1717 extra=extra)
1716 extra=extra)
1718 finally:
1717 finally:
1719 ui.restoreconfig(backup)
1718 ui.restoreconfig(backup)
1720 repo.baseui.restoreconfig(basebackup)
1719 repo.baseui.restoreconfig(basebackup)
1721
1720
1722
1721
1723 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1722 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1724
1723
1725 if not node:
1724 if not node:
1726 stat = cmdutil.postcommitstatus(repo, pats, opts)
1725 stat = cmdutil.postcommitstatus(repo, pats, opts)
1727 if stat[3]:
1726 if stat[3]:
1728 ui.status(_("nothing changed (%d missing files, see "
1727 ui.status(_("nothing changed (%d missing files, see "
1729 "'hg status')\n") % len(stat[3]))
1728 "'hg status')\n") % len(stat[3]))
1730 else:
1729 else:
1731 ui.status(_("nothing changed\n"))
1730 ui.status(_("nothing changed\n"))
1732 return 1
1731 return 1
1733
1732
1734 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1733 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1735
1734
1736 @command('config|showconfig|debugconfig',
1735 @command('config|showconfig|debugconfig',
1737 [('u', 'untrusted', None, _('show untrusted configuration options')),
1736 [('u', 'untrusted', None, _('show untrusted configuration options')),
1738 ('e', 'edit', None, _('edit user config')),
1737 ('e', 'edit', None, _('edit user config')),
1739 ('l', 'local', None, _('edit repository config')),
1738 ('l', 'local', None, _('edit repository config')),
1740 ('g', 'global', None, _('edit global config'))] + formatteropts,
1739 ('g', 'global', None, _('edit global config'))] + formatteropts,
1741 _('[-u] [NAME]...'),
1740 _('[-u] [NAME]...'),
1742 optionalrepo=True)
1741 optionalrepo=True)
1743 def config(ui, repo, *values, **opts):
1742 def config(ui, repo, *values, **opts):
1744 """show combined config settings from all hgrc files
1743 """show combined config settings from all hgrc files
1745
1744
1746 With no arguments, print names and values of all config items.
1745 With no arguments, print names and values of all config items.
1747
1746
1748 With one argument of the form section.name, print just the value
1747 With one argument of the form section.name, print just the value
1749 of that config item.
1748 of that config item.
1750
1749
1751 With multiple arguments, print names and values of all config
1750 With multiple arguments, print names and values of all config
1752 items with matching section names.
1751 items with matching section names.
1753
1752
1754 With --edit, start an editor on the user-level config file. With
1753 With --edit, start an editor on the user-level config file. With
1755 --global, edit the system-wide config file. With --local, edit the
1754 --global, edit the system-wide config file. With --local, edit the
1756 repository-level config file.
1755 repository-level config file.
1757
1756
1758 With --debug, the source (filename and line number) is printed
1757 With --debug, the source (filename and line number) is printed
1759 for each config item.
1758 for each config item.
1760
1759
1761 See :hg:`help config` for more information about config files.
1760 See :hg:`help config` for more information about config files.
1762
1761
1763 Returns 0 on success, 1 if NAME does not exist.
1762 Returns 0 on success, 1 if NAME does not exist.
1764
1763
1765 """
1764 """
1766
1765
1767 if opts.get('edit') or opts.get('local') or opts.get('global'):
1766 if opts.get('edit') or opts.get('local') or opts.get('global'):
1768 if opts.get('local') and opts.get('global'):
1767 if opts.get('local') and opts.get('global'):
1769 raise error.Abort(_("can't use --local and --global together"))
1768 raise error.Abort(_("can't use --local and --global together"))
1770
1769
1771 if opts.get('local'):
1770 if opts.get('local'):
1772 if not repo:
1771 if not repo:
1773 raise error.Abort(_("can't use --local outside a repository"))
1772 raise error.Abort(_("can't use --local outside a repository"))
1774 paths = [repo.join('hgrc')]
1773 paths = [repo.join('hgrc')]
1775 elif opts.get('global'):
1774 elif opts.get('global'):
1776 paths = scmutil.systemrcpath()
1775 paths = scmutil.systemrcpath()
1777 else:
1776 else:
1778 paths = scmutil.userrcpath()
1777 paths = scmutil.userrcpath()
1779
1778
1780 for f in paths:
1779 for f in paths:
1781 if os.path.exists(f):
1780 if os.path.exists(f):
1782 break
1781 break
1783 else:
1782 else:
1784 if opts.get('global'):
1783 if opts.get('global'):
1785 samplehgrc = uimod.samplehgrcs['global']
1784 samplehgrc = uimod.samplehgrcs['global']
1786 elif opts.get('local'):
1785 elif opts.get('local'):
1787 samplehgrc = uimod.samplehgrcs['local']
1786 samplehgrc = uimod.samplehgrcs['local']
1788 else:
1787 else:
1789 samplehgrc = uimod.samplehgrcs['user']
1788 samplehgrc = uimod.samplehgrcs['user']
1790
1789
1791 f = paths[0]
1790 f = paths[0]
1792 fp = open(f, "w")
1791 fp = open(f, "w")
1793 fp.write(samplehgrc)
1792 fp.write(samplehgrc)
1794 fp.close()
1793 fp.close()
1795
1794
1796 editor = ui.geteditor()
1795 editor = ui.geteditor()
1797 ui.system("%s \"%s\"" % (editor, f),
1796 ui.system("%s \"%s\"" % (editor, f),
1798 onerr=error.Abort, errprefix=_("edit failed"))
1797 onerr=error.Abort, errprefix=_("edit failed"))
1799 return
1798 return
1800 ui.pager('config')
1799 ui.pager('config')
1801 fm = ui.formatter('config', opts)
1800 fm = ui.formatter('config', opts)
1802 for f in scmutil.rcpath():
1801 for f in scmutil.rcpath():
1803 ui.debug('read config from: %s\n' % f)
1802 ui.debug('read config from: %s\n' % f)
1804 untrusted = bool(opts.get('untrusted'))
1803 untrusted = bool(opts.get('untrusted'))
1805 if values:
1804 if values:
1806 sections = [v for v in values if '.' not in v]
1805 sections = [v for v in values if '.' not in v]
1807 items = [v for v in values if '.' in v]
1806 items = [v for v in values if '.' in v]
1808 if len(items) > 1 or items and sections:
1807 if len(items) > 1 or items and sections:
1809 raise error.Abort(_('only one config item permitted'))
1808 raise error.Abort(_('only one config item permitted'))
1810 matched = False
1809 matched = False
1811 for section, name, value in ui.walkconfig(untrusted=untrusted):
1810 for section, name, value in ui.walkconfig(untrusted=untrusted):
1812 source = ui.configsource(section, name, untrusted)
1811 source = ui.configsource(section, name, untrusted)
1813 value = str(value)
1812 value = str(value)
1814 if fm.isplain():
1813 if fm.isplain():
1815 source = source or 'none'
1814 source = source or 'none'
1816 value = value.replace('\n', '\\n')
1815 value = value.replace('\n', '\\n')
1817 entryname = section + '.' + name
1816 entryname = section + '.' + name
1818 if values:
1817 if values:
1819 for v in values:
1818 for v in values:
1820 if v == section:
1819 if v == section:
1821 fm.startitem()
1820 fm.startitem()
1822 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1821 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1823 fm.write('name value', '%s=%s\n', entryname, value)
1822 fm.write('name value', '%s=%s\n', entryname, value)
1824 matched = True
1823 matched = True
1825 elif v == entryname:
1824 elif v == entryname:
1826 fm.startitem()
1825 fm.startitem()
1827 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1826 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1828 fm.write('value', '%s\n', value)
1827 fm.write('value', '%s\n', value)
1829 fm.data(name=entryname)
1828 fm.data(name=entryname)
1830 matched = True
1829 matched = True
1831 else:
1830 else:
1832 fm.startitem()
1831 fm.startitem()
1833 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1832 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
1834 fm.write('name value', '%s=%s\n', entryname, value)
1833 fm.write('name value', '%s=%s\n', entryname, value)
1835 matched = True
1834 matched = True
1836 fm.end()
1835 fm.end()
1837 if matched:
1836 if matched:
1838 return 0
1837 return 0
1839 return 1
1838 return 1
1840
1839
1841 @command('copy|cp',
1840 @command('copy|cp',
1842 [('A', 'after', None, _('record a copy that has already occurred')),
1841 [('A', 'after', None, _('record a copy that has already occurred')),
1843 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1842 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1844 ] + walkopts + dryrunopts,
1843 ] + walkopts + dryrunopts,
1845 _('[OPTION]... [SOURCE]... DEST'))
1844 _('[OPTION]... [SOURCE]... DEST'))
1846 def copy(ui, repo, *pats, **opts):
1845 def copy(ui, repo, *pats, **opts):
1847 """mark files as copied for the next commit
1846 """mark files as copied for the next commit
1848
1847
1849 Mark dest as having copies of source files. If dest is a
1848 Mark dest as having copies of source files. If dest is a
1850 directory, copies are put in that directory. If dest is a file,
1849 directory, copies are put in that directory. If dest is a file,
1851 the source must be a single file.
1850 the source must be a single file.
1852
1851
1853 By default, this command copies the contents of files as they
1852 By default, this command copies the contents of files as they
1854 exist in the working directory. If invoked with -A/--after, the
1853 exist in the working directory. If invoked with -A/--after, the
1855 operation is recorded, but no copying is performed.
1854 operation is recorded, but no copying is performed.
1856
1855
1857 This command takes effect with the next commit. To undo a copy
1856 This command takes effect with the next commit. To undo a copy
1858 before that, see :hg:`revert`.
1857 before that, see :hg:`revert`.
1859
1858
1860 Returns 0 on success, 1 if errors are encountered.
1859 Returns 0 on success, 1 if errors are encountered.
1861 """
1860 """
1862 with repo.wlock(False):
1861 with repo.wlock(False):
1863 return cmdutil.copy(ui, repo, pats, opts)
1862 return cmdutil.copy(ui, repo, pats, opts)
1864
1863
1865 @command('^diff',
1864 @command('^diff',
1866 [('r', 'rev', [], _('revision'), _('REV')),
1865 [('r', 'rev', [], _('revision'), _('REV')),
1867 ('c', 'change', '', _('change made by revision'), _('REV'))
1866 ('c', 'change', '', _('change made by revision'), _('REV'))
1868 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1867 ] + diffopts + diffopts2 + walkopts + subrepoopts,
1869 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1868 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
1870 inferrepo=True)
1869 inferrepo=True)
1871 def diff(ui, repo, *pats, **opts):
1870 def diff(ui, repo, *pats, **opts):
1872 """diff repository (or selected files)
1871 """diff repository (or selected files)
1873
1872
1874 Show differences between revisions for the specified files.
1873 Show differences between revisions for the specified files.
1875
1874
1876 Differences between files are shown using the unified diff format.
1875 Differences between files are shown using the unified diff format.
1877
1876
1878 .. note::
1877 .. note::
1879
1878
1880 :hg:`diff` may generate unexpected results for merges, as it will
1879 :hg:`diff` may generate unexpected results for merges, as it will
1881 default to comparing against the working directory's first
1880 default to comparing against the working directory's first
1882 parent changeset if no revisions are specified.
1881 parent changeset if no revisions are specified.
1883
1882
1884 When two revision arguments are given, then changes are shown
1883 When two revision arguments are given, then changes are shown
1885 between those revisions. If only one revision is specified then
1884 between those revisions. If only one revision is specified then
1886 that revision is compared to the working directory, and, when no
1885 that revision is compared to the working directory, and, when no
1887 revisions are specified, the working directory files are compared
1886 revisions are specified, the working directory files are compared
1888 to its first parent.
1887 to its first parent.
1889
1888
1890 Alternatively you can specify -c/--change with a revision to see
1889 Alternatively you can specify -c/--change with a revision to see
1891 the changes in that changeset relative to its first parent.
1890 the changes in that changeset relative to its first parent.
1892
1891
1893 Without the -a/--text option, diff will avoid generating diffs of
1892 Without the -a/--text option, diff will avoid generating diffs of
1894 files it detects as binary. With -a, diff will generate a diff
1893 files it detects as binary. With -a, diff will generate a diff
1895 anyway, probably with undesirable results.
1894 anyway, probably with undesirable results.
1896
1895
1897 Use the -g/--git option to generate diffs in the git extended diff
1896 Use the -g/--git option to generate diffs in the git extended diff
1898 format. For more information, read :hg:`help diffs`.
1897 format. For more information, read :hg:`help diffs`.
1899
1898
1900 .. container:: verbose
1899 .. container:: verbose
1901
1900
1902 Examples:
1901 Examples:
1903
1902
1904 - compare a file in the current working directory to its parent::
1903 - compare a file in the current working directory to its parent::
1905
1904
1906 hg diff foo.c
1905 hg diff foo.c
1907
1906
1908 - compare two historical versions of a directory, with rename info::
1907 - compare two historical versions of a directory, with rename info::
1909
1908
1910 hg diff --git -r 1.0:1.2 lib/
1909 hg diff --git -r 1.0:1.2 lib/
1911
1910
1912 - get change stats relative to the last change on some date::
1911 - get change stats relative to the last change on some date::
1913
1912
1914 hg diff --stat -r "date('may 2')"
1913 hg diff --stat -r "date('may 2')"
1915
1914
1916 - diff all newly-added files that contain a keyword::
1915 - diff all newly-added files that contain a keyword::
1917
1916
1918 hg diff "set:added() and grep(GNU)"
1917 hg diff "set:added() and grep(GNU)"
1919
1918
1920 - compare a revision and its parents::
1919 - compare a revision and its parents::
1921
1920
1922 hg diff -c 9353 # compare against first parent
1921 hg diff -c 9353 # compare against first parent
1923 hg diff -r 9353^:9353 # same using revset syntax
1922 hg diff -r 9353^:9353 # same using revset syntax
1924 hg diff -r 9353^2:9353 # compare against the second parent
1923 hg diff -r 9353^2:9353 # compare against the second parent
1925
1924
1926 Returns 0 on success.
1925 Returns 0 on success.
1927 """
1926 """
1928
1927
1929 revs = opts.get('rev')
1928 revs = opts.get('rev')
1930 change = opts.get('change')
1929 change = opts.get('change')
1931 stat = opts.get('stat')
1930 stat = opts.get('stat')
1932 reverse = opts.get('reverse')
1931 reverse = opts.get('reverse')
1933
1932
1934 if revs and change:
1933 if revs and change:
1935 msg = _('cannot specify --rev and --change at the same time')
1934 msg = _('cannot specify --rev and --change at the same time')
1936 raise error.Abort(msg)
1935 raise error.Abort(msg)
1937 elif change:
1936 elif change:
1938 node2 = scmutil.revsingle(repo, change, None).node()
1937 node2 = scmutil.revsingle(repo, change, None).node()
1939 node1 = repo[node2].p1().node()
1938 node1 = repo[node2].p1().node()
1940 else:
1939 else:
1941 node1, node2 = scmutil.revpair(repo, revs)
1940 node1, node2 = scmutil.revpair(repo, revs)
1942
1941
1943 if reverse:
1942 if reverse:
1944 node1, node2 = node2, node1
1943 node1, node2 = node2, node1
1945
1944
1946 diffopts = patch.diffallopts(ui, opts)
1945 diffopts = patch.diffallopts(ui, opts)
1947 m = scmutil.match(repo[node2], pats, opts)
1946 m = scmutil.match(repo[node2], pats, opts)
1948 ui.pager('diff')
1947 ui.pager('diff')
1949 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1948 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1950 listsubrepos=opts.get('subrepos'),
1949 listsubrepos=opts.get('subrepos'),
1951 root=opts.get('root'))
1950 root=opts.get('root'))
1952
1951
1953 @command('^export',
1952 @command('^export',
1954 [('o', 'output', '',
1953 [('o', 'output', '',
1955 _('print output to file with formatted name'), _('FORMAT')),
1954 _('print output to file with formatted name'), _('FORMAT')),
1956 ('', 'switch-parent', None, _('diff against the second parent')),
1955 ('', 'switch-parent', None, _('diff against the second parent')),
1957 ('r', 'rev', [], _('revisions to export'), _('REV')),
1956 ('r', 'rev', [], _('revisions to export'), _('REV')),
1958 ] + diffopts,
1957 ] + diffopts,
1959 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
1958 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
1960 def export(ui, repo, *changesets, **opts):
1959 def export(ui, repo, *changesets, **opts):
1961 """dump the header and diffs for one or more changesets
1960 """dump the header and diffs for one or more changesets
1962
1961
1963 Print the changeset header and diffs for one or more revisions.
1962 Print the changeset header and diffs for one or more revisions.
1964 If no revision is given, the parent of the working directory is used.
1963 If no revision is given, the parent of the working directory is used.
1965
1964
1966 The information shown in the changeset header is: author, date,
1965 The information shown in the changeset header is: author, date,
1967 branch name (if non-default), changeset hash, parent(s) and commit
1966 branch name (if non-default), changeset hash, parent(s) and commit
1968 comment.
1967 comment.
1969
1968
1970 .. note::
1969 .. note::
1971
1970
1972 :hg:`export` may generate unexpected diff output for merge
1971 :hg:`export` may generate unexpected diff output for merge
1973 changesets, as it will compare the merge changeset against its
1972 changesets, as it will compare the merge changeset against its
1974 first parent only.
1973 first parent only.
1975
1974
1976 Output may be to a file, in which case the name of the file is
1975 Output may be to a file, in which case the name of the file is
1977 given using a format string. The formatting rules are as follows:
1976 given using a format string. The formatting rules are as follows:
1978
1977
1979 :``%%``: literal "%" character
1978 :``%%``: literal "%" character
1980 :``%H``: changeset hash (40 hexadecimal digits)
1979 :``%H``: changeset hash (40 hexadecimal digits)
1981 :``%N``: number of patches being generated
1980 :``%N``: number of patches being generated
1982 :``%R``: changeset revision number
1981 :``%R``: changeset revision number
1983 :``%b``: basename of the exporting repository
1982 :``%b``: basename of the exporting repository
1984 :``%h``: short-form changeset hash (12 hexadecimal digits)
1983 :``%h``: short-form changeset hash (12 hexadecimal digits)
1985 :``%m``: first line of the commit message (only alphanumeric characters)
1984 :``%m``: first line of the commit message (only alphanumeric characters)
1986 :``%n``: zero-padded sequence number, starting at 1
1985 :``%n``: zero-padded sequence number, starting at 1
1987 :``%r``: zero-padded changeset revision number
1986 :``%r``: zero-padded changeset revision number
1988
1987
1989 Without the -a/--text option, export will avoid generating diffs
1988 Without the -a/--text option, export will avoid generating diffs
1990 of files it detects as binary. With -a, export will generate a
1989 of files it detects as binary. With -a, export will generate a
1991 diff anyway, probably with undesirable results.
1990 diff anyway, probably with undesirable results.
1992
1991
1993 Use the -g/--git option to generate diffs in the git extended diff
1992 Use the -g/--git option to generate diffs in the git extended diff
1994 format. See :hg:`help diffs` for more information.
1993 format. See :hg:`help diffs` for more information.
1995
1994
1996 With the --switch-parent option, the diff will be against the
1995 With the --switch-parent option, the diff will be against the
1997 second parent. It can be useful to review a merge.
1996 second parent. It can be useful to review a merge.
1998
1997
1999 .. container:: verbose
1998 .. container:: verbose
2000
1999
2001 Examples:
2000 Examples:
2002
2001
2003 - use export and import to transplant a bugfix to the current
2002 - use export and import to transplant a bugfix to the current
2004 branch::
2003 branch::
2005
2004
2006 hg export -r 9353 | hg import -
2005 hg export -r 9353 | hg import -
2007
2006
2008 - export all the changesets between two revisions to a file with
2007 - export all the changesets between two revisions to a file with
2009 rename information::
2008 rename information::
2010
2009
2011 hg export --git -r 123:150 > changes.txt
2010 hg export --git -r 123:150 > changes.txt
2012
2011
2013 - split outgoing changes into a series of patches with
2012 - split outgoing changes into a series of patches with
2014 descriptive names::
2013 descriptive names::
2015
2014
2016 hg export -r "outgoing()" -o "%n-%m.patch"
2015 hg export -r "outgoing()" -o "%n-%m.patch"
2017
2016
2018 Returns 0 on success.
2017 Returns 0 on success.
2019 """
2018 """
2020 changesets += tuple(opts.get('rev', []))
2019 changesets += tuple(opts.get('rev', []))
2021 if not changesets:
2020 if not changesets:
2022 changesets = ['.']
2021 changesets = ['.']
2023 revs = scmutil.revrange(repo, changesets)
2022 revs = scmutil.revrange(repo, changesets)
2024 if not revs:
2023 if not revs:
2025 raise error.Abort(_("export requires at least one changeset"))
2024 raise error.Abort(_("export requires at least one changeset"))
2026 if len(revs) > 1:
2025 if len(revs) > 1:
2027 ui.note(_('exporting patches:\n'))
2026 ui.note(_('exporting patches:\n'))
2028 else:
2027 else:
2029 ui.note(_('exporting patch:\n'))
2028 ui.note(_('exporting patch:\n'))
2030 ui.pager('export')
2029 ui.pager('export')
2031 cmdutil.export(repo, revs, template=opts.get('output'),
2030 cmdutil.export(repo, revs, template=opts.get('output'),
2032 switch_parent=opts.get('switch_parent'),
2031 switch_parent=opts.get('switch_parent'),
2033 opts=patch.diffallopts(ui, opts))
2032 opts=patch.diffallopts(ui, opts))
2034
2033
2035 @command('files',
2034 @command('files',
2036 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2035 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
2037 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2036 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
2038 ] + walkopts + formatteropts + subrepoopts,
2037 ] + walkopts + formatteropts + subrepoopts,
2039 _('[OPTION]... [FILE]...'))
2038 _('[OPTION]... [FILE]...'))
2040 def files(ui, repo, *pats, **opts):
2039 def files(ui, repo, *pats, **opts):
2041 """list tracked files
2040 """list tracked files
2042
2041
2043 Print files under Mercurial control in the working directory or
2042 Print files under Mercurial control in the working directory or
2044 specified revision for given files (excluding removed files).
2043 specified revision for given files (excluding removed files).
2045 Files can be specified as filenames or filesets.
2044 Files can be specified as filenames or filesets.
2046
2045
2047 If no files are given to match, this command prints the names
2046 If no files are given to match, this command prints the names
2048 of all files under Mercurial control.
2047 of all files under Mercurial control.
2049
2048
2050 .. container:: verbose
2049 .. container:: verbose
2051
2050
2052 Examples:
2051 Examples:
2053
2052
2054 - list all files under the current directory::
2053 - list all files under the current directory::
2055
2054
2056 hg files .
2055 hg files .
2057
2056
2058 - shows sizes and flags for current revision::
2057 - shows sizes and flags for current revision::
2059
2058
2060 hg files -vr .
2059 hg files -vr .
2061
2060
2062 - list all files named README::
2061 - list all files named README::
2063
2062
2064 hg files -I "**/README"
2063 hg files -I "**/README"
2065
2064
2066 - list all binary files::
2065 - list all binary files::
2067
2066
2068 hg files "set:binary()"
2067 hg files "set:binary()"
2069
2068
2070 - find files containing a regular expression::
2069 - find files containing a regular expression::
2071
2070
2072 hg files "set:grep('bob')"
2071 hg files "set:grep('bob')"
2073
2072
2074 - search tracked file contents with xargs and grep::
2073 - search tracked file contents with xargs and grep::
2075
2074
2076 hg files -0 | xargs -0 grep foo
2075 hg files -0 | xargs -0 grep foo
2077
2076
2078 See :hg:`help patterns` and :hg:`help filesets` for more information
2077 See :hg:`help patterns` and :hg:`help filesets` for more information
2079 on specifying file patterns.
2078 on specifying file patterns.
2080
2079
2081 Returns 0 if a match is found, 1 otherwise.
2080 Returns 0 if a match is found, 1 otherwise.
2082
2081
2083 """
2082 """
2084 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2083 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2085
2084
2086 end = '\n'
2085 end = '\n'
2087 if opts.get('print0'):
2086 if opts.get('print0'):
2088 end = '\0'
2087 end = '\0'
2089 fmt = '%s' + end
2088 fmt = '%s' + end
2090
2089
2091 m = scmutil.match(ctx, pats, opts)
2090 m = scmutil.match(ctx, pats, opts)
2092 ui.pager('files')
2091 ui.pager('files')
2093 with ui.formatter('files', opts) as fm:
2092 with ui.formatter('files', opts) as fm:
2094 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2093 return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
2095
2094
2096 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
2095 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
2097 def forget(ui, repo, *pats, **opts):
2096 def forget(ui, repo, *pats, **opts):
2098 """forget the specified files on the next commit
2097 """forget the specified files on the next commit
2099
2098
2100 Mark the specified files so they will no longer be tracked
2099 Mark the specified files so they will no longer be tracked
2101 after the next commit.
2100 after the next commit.
2102
2101
2103 This only removes files from the current branch, not from the
2102 This only removes files from the current branch, not from the
2104 entire project history, and it does not delete them from the
2103 entire project history, and it does not delete them from the
2105 working directory.
2104 working directory.
2106
2105
2107 To delete the file from the working directory, see :hg:`remove`.
2106 To delete the file from the working directory, see :hg:`remove`.
2108
2107
2109 To undo a forget before the next commit, see :hg:`add`.
2108 To undo a forget before the next commit, see :hg:`add`.
2110
2109
2111 .. container:: verbose
2110 .. container:: verbose
2112
2111
2113 Examples:
2112 Examples:
2114
2113
2115 - forget newly-added binary files::
2114 - forget newly-added binary files::
2116
2115
2117 hg forget "set:added() and binary()"
2116 hg forget "set:added() and binary()"
2118
2117
2119 - forget files that would be excluded by .hgignore::
2118 - forget files that would be excluded by .hgignore::
2120
2119
2121 hg forget "set:hgignore()"
2120 hg forget "set:hgignore()"
2122
2121
2123 Returns 0 on success.
2122 Returns 0 on success.
2124 """
2123 """
2125
2124
2126 if not pats:
2125 if not pats:
2127 raise error.Abort(_('no files specified'))
2126 raise error.Abort(_('no files specified'))
2128
2127
2129 m = scmutil.match(repo[None], pats, opts)
2128 m = scmutil.match(repo[None], pats, opts)
2130 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2129 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2131 return rejected and 1 or 0
2130 return rejected and 1 or 0
2132
2131
2133 @command(
2132 @command(
2134 'graft',
2133 'graft',
2135 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2134 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2136 ('c', 'continue', False, _('resume interrupted graft')),
2135 ('c', 'continue', False, _('resume interrupted graft')),
2137 ('e', 'edit', False, _('invoke editor on commit messages')),
2136 ('e', 'edit', False, _('invoke editor on commit messages')),
2138 ('', 'log', None, _('append graft info to log message')),
2137 ('', 'log', None, _('append graft info to log message')),
2139 ('f', 'force', False, _('force graft')),
2138 ('f', 'force', False, _('force graft')),
2140 ('D', 'currentdate', False,
2139 ('D', 'currentdate', False,
2141 _('record the current date as commit date')),
2140 _('record the current date as commit date')),
2142 ('U', 'currentuser', False,
2141 ('U', 'currentuser', False,
2143 _('record the current user as committer'), _('DATE'))]
2142 _('record the current user as committer'), _('DATE'))]
2144 + commitopts2 + mergetoolopts + dryrunopts,
2143 + commitopts2 + mergetoolopts + dryrunopts,
2145 _('[OPTION]... [-r REV]... REV...'))
2144 _('[OPTION]... [-r REV]... REV...'))
2146 def graft(ui, repo, *revs, **opts):
2145 def graft(ui, repo, *revs, **opts):
2147 '''copy changes from other branches onto the current branch
2146 '''copy changes from other branches onto the current branch
2148
2147
2149 This command uses Mercurial's merge logic to copy individual
2148 This command uses Mercurial's merge logic to copy individual
2150 changes from other branches without merging branches in the
2149 changes from other branches without merging branches in the
2151 history graph. This is sometimes known as 'backporting' or
2150 history graph. This is sometimes known as 'backporting' or
2152 'cherry-picking'. By default, graft will copy user, date, and
2151 'cherry-picking'. By default, graft will copy user, date, and
2153 description from the source changesets.
2152 description from the source changesets.
2154
2153
2155 Changesets that are ancestors of the current revision, that have
2154 Changesets that are ancestors of the current revision, that have
2156 already been grafted, or that are merges will be skipped.
2155 already been grafted, or that are merges will be skipped.
2157
2156
2158 If --log is specified, log messages will have a comment appended
2157 If --log is specified, log messages will have a comment appended
2159 of the form::
2158 of the form::
2160
2159
2161 (grafted from CHANGESETHASH)
2160 (grafted from CHANGESETHASH)
2162
2161
2163 If --force is specified, revisions will be grafted even if they
2162 If --force is specified, revisions will be grafted even if they
2164 are already ancestors of or have been grafted to the destination.
2163 are already ancestors of or have been grafted to the destination.
2165 This is useful when the revisions have since been backed out.
2164 This is useful when the revisions have since been backed out.
2166
2165
2167 If a graft merge results in conflicts, the graft process is
2166 If a graft merge results in conflicts, the graft process is
2168 interrupted so that the current merge can be manually resolved.
2167 interrupted so that the current merge can be manually resolved.
2169 Once all conflicts are addressed, the graft process can be
2168 Once all conflicts are addressed, the graft process can be
2170 continued with the -c/--continue option.
2169 continued with the -c/--continue option.
2171
2170
2172 .. note::
2171 .. note::
2173
2172
2174 The -c/--continue option does not reapply earlier options, except
2173 The -c/--continue option does not reapply earlier options, except
2175 for --force.
2174 for --force.
2176
2175
2177 .. container:: verbose
2176 .. container:: verbose
2178
2177
2179 Examples:
2178 Examples:
2180
2179
2181 - copy a single change to the stable branch and edit its description::
2180 - copy a single change to the stable branch and edit its description::
2182
2181
2183 hg update stable
2182 hg update stable
2184 hg graft --edit 9393
2183 hg graft --edit 9393
2185
2184
2186 - graft a range of changesets with one exception, updating dates::
2185 - graft a range of changesets with one exception, updating dates::
2187
2186
2188 hg graft -D "2085::2093 and not 2091"
2187 hg graft -D "2085::2093 and not 2091"
2189
2188
2190 - continue a graft after resolving conflicts::
2189 - continue a graft after resolving conflicts::
2191
2190
2192 hg graft -c
2191 hg graft -c
2193
2192
2194 - show the source of a grafted changeset::
2193 - show the source of a grafted changeset::
2195
2194
2196 hg log --debug -r .
2195 hg log --debug -r .
2197
2196
2198 - show revisions sorted by date::
2197 - show revisions sorted by date::
2199
2198
2200 hg log -r "sort(all(), date)"
2199 hg log -r "sort(all(), date)"
2201
2200
2202 See :hg:`help revisions` for more about specifying revisions.
2201 See :hg:`help revisions` for more about specifying revisions.
2203
2202
2204 Returns 0 on successful completion.
2203 Returns 0 on successful completion.
2205 '''
2204 '''
2206 with repo.wlock():
2205 with repo.wlock():
2207 return _dograft(ui, repo, *revs, **opts)
2206 return _dograft(ui, repo, *revs, **opts)
2208
2207
2209 def _dograft(ui, repo, *revs, **opts):
2208 def _dograft(ui, repo, *revs, **opts):
2210 if revs and opts.get('rev'):
2209 if revs and opts.get('rev'):
2211 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2210 ui.warn(_('warning: inconsistent use of --rev might give unexpected '
2212 'revision ordering!\n'))
2211 'revision ordering!\n'))
2213
2212
2214 revs = list(revs)
2213 revs = list(revs)
2215 revs.extend(opts.get('rev'))
2214 revs.extend(opts.get('rev'))
2216
2215
2217 if not opts.get('user') and opts.get('currentuser'):
2216 if not opts.get('user') and opts.get('currentuser'):
2218 opts['user'] = ui.username()
2217 opts['user'] = ui.username()
2219 if not opts.get('date') and opts.get('currentdate'):
2218 if not opts.get('date') and opts.get('currentdate'):
2220 opts['date'] = "%d %d" % util.makedate()
2219 opts['date'] = "%d %d" % util.makedate()
2221
2220
2222 editor = cmdutil.getcommiteditor(editform='graft', **opts)
2221 editor = cmdutil.getcommiteditor(editform='graft', **opts)
2223
2222
2224 cont = False
2223 cont = False
2225 if opts.get('continue'):
2224 if opts.get('continue'):
2226 cont = True
2225 cont = True
2227 if revs:
2226 if revs:
2228 raise error.Abort(_("can't specify --continue and revisions"))
2227 raise error.Abort(_("can't specify --continue and revisions"))
2229 # read in unfinished revisions
2228 # read in unfinished revisions
2230 try:
2229 try:
2231 nodes = repo.vfs.read('graftstate').splitlines()
2230 nodes = repo.vfs.read('graftstate').splitlines()
2232 revs = [repo[node].rev() for node in nodes]
2231 revs = [repo[node].rev() for node in nodes]
2233 except IOError as inst:
2232 except IOError as inst:
2234 if inst.errno != errno.ENOENT:
2233 if inst.errno != errno.ENOENT:
2235 raise
2234 raise
2236 cmdutil.wrongtooltocontinue(repo, _('graft'))
2235 cmdutil.wrongtooltocontinue(repo, _('graft'))
2237 else:
2236 else:
2238 cmdutil.checkunfinished(repo)
2237 cmdutil.checkunfinished(repo)
2239 cmdutil.bailifchanged(repo)
2238 cmdutil.bailifchanged(repo)
2240 if not revs:
2239 if not revs:
2241 raise error.Abort(_('no revisions specified'))
2240 raise error.Abort(_('no revisions specified'))
2242 revs = scmutil.revrange(repo, revs)
2241 revs = scmutil.revrange(repo, revs)
2243
2242
2244 skipped = set()
2243 skipped = set()
2245 # check for merges
2244 # check for merges
2246 for rev in repo.revs('%ld and merge()', revs):
2245 for rev in repo.revs('%ld and merge()', revs):
2247 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2246 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2248 skipped.add(rev)
2247 skipped.add(rev)
2249 revs = [r for r in revs if r not in skipped]
2248 revs = [r for r in revs if r not in skipped]
2250 if not revs:
2249 if not revs:
2251 return -1
2250 return -1
2252
2251
2253 # Don't check in the --continue case, in effect retaining --force across
2252 # Don't check in the --continue case, in effect retaining --force across
2254 # --continues. That's because without --force, any revisions we decided to
2253 # --continues. That's because without --force, any revisions we decided to
2255 # skip would have been filtered out here, so they wouldn't have made their
2254 # skip would have been filtered out here, so they wouldn't have made their
2256 # way to the graftstate. With --force, any revisions we would have otherwise
2255 # way to the graftstate. With --force, any revisions we would have otherwise
2257 # skipped would not have been filtered out, and if they hadn't been applied
2256 # skipped would not have been filtered out, and if they hadn't been applied
2258 # already, they'd have been in the graftstate.
2257 # already, they'd have been in the graftstate.
2259 if not (cont or opts.get('force')):
2258 if not (cont or opts.get('force')):
2260 # check for ancestors of dest branch
2259 # check for ancestors of dest branch
2261 crev = repo['.'].rev()
2260 crev = repo['.'].rev()
2262 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2261 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2263 # XXX make this lazy in the future
2262 # XXX make this lazy in the future
2264 # don't mutate while iterating, create a copy
2263 # don't mutate while iterating, create a copy
2265 for rev in list(revs):
2264 for rev in list(revs):
2266 if rev in ancestors:
2265 if rev in ancestors:
2267 ui.warn(_('skipping ancestor revision %d:%s\n') %
2266 ui.warn(_('skipping ancestor revision %d:%s\n') %
2268 (rev, repo[rev]))
2267 (rev, repo[rev]))
2269 # XXX remove on list is slow
2268 # XXX remove on list is slow
2270 revs.remove(rev)
2269 revs.remove(rev)
2271 if not revs:
2270 if not revs:
2272 return -1
2271 return -1
2273
2272
2274 # analyze revs for earlier grafts
2273 # analyze revs for earlier grafts
2275 ids = {}
2274 ids = {}
2276 for ctx in repo.set("%ld", revs):
2275 for ctx in repo.set("%ld", revs):
2277 ids[ctx.hex()] = ctx.rev()
2276 ids[ctx.hex()] = ctx.rev()
2278 n = ctx.extra().get('source')
2277 n = ctx.extra().get('source')
2279 if n:
2278 if n:
2280 ids[n] = ctx.rev()
2279 ids[n] = ctx.rev()
2281
2280
2282 # check ancestors for earlier grafts
2281 # check ancestors for earlier grafts
2283 ui.debug('scanning for duplicate grafts\n')
2282 ui.debug('scanning for duplicate grafts\n')
2284
2283
2285 for rev in repo.changelog.findmissingrevs(revs, [crev]):
2284 for rev in repo.changelog.findmissingrevs(revs, [crev]):
2286 ctx = repo[rev]
2285 ctx = repo[rev]
2287 n = ctx.extra().get('source')
2286 n = ctx.extra().get('source')
2288 if n in ids:
2287 if n in ids:
2289 try:
2288 try:
2290 r = repo[n].rev()
2289 r = repo[n].rev()
2291 except error.RepoLookupError:
2290 except error.RepoLookupError:
2292 r = None
2291 r = None
2293 if r in revs:
2292 if r in revs:
2294 ui.warn(_('skipping revision %d:%s '
2293 ui.warn(_('skipping revision %d:%s '
2295 '(already grafted to %d:%s)\n')
2294 '(already grafted to %d:%s)\n')
2296 % (r, repo[r], rev, ctx))
2295 % (r, repo[r], rev, ctx))
2297 revs.remove(r)
2296 revs.remove(r)
2298 elif ids[n] in revs:
2297 elif ids[n] in revs:
2299 if r is None:
2298 if r is None:
2300 ui.warn(_('skipping already grafted revision %d:%s '
2299 ui.warn(_('skipping already grafted revision %d:%s '
2301 '(%d:%s also has unknown origin %s)\n')
2300 '(%d:%s also has unknown origin %s)\n')
2302 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2301 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
2303 else:
2302 else:
2304 ui.warn(_('skipping already grafted revision %d:%s '
2303 ui.warn(_('skipping already grafted revision %d:%s '
2305 '(%d:%s also has origin %d:%s)\n')
2304 '(%d:%s also has origin %d:%s)\n')
2306 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2305 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
2307 revs.remove(ids[n])
2306 revs.remove(ids[n])
2308 elif ctx.hex() in ids:
2307 elif ctx.hex() in ids:
2309 r = ids[ctx.hex()]
2308 r = ids[ctx.hex()]
2310 ui.warn(_('skipping already grafted revision %d:%s '
2309 ui.warn(_('skipping already grafted revision %d:%s '
2311 '(was grafted from %d:%s)\n') %
2310 '(was grafted from %d:%s)\n') %
2312 (r, repo[r], rev, ctx))
2311 (r, repo[r], rev, ctx))
2313 revs.remove(r)
2312 revs.remove(r)
2314 if not revs:
2313 if not revs:
2315 return -1
2314 return -1
2316
2315
2317 for pos, ctx in enumerate(repo.set("%ld", revs)):
2316 for pos, ctx in enumerate(repo.set("%ld", revs)):
2318 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2317 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2319 ctx.description().split('\n', 1)[0])
2318 ctx.description().split('\n', 1)[0])
2320 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2319 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
2321 if names:
2320 if names:
2322 desc += ' (%s)' % ' '.join(names)
2321 desc += ' (%s)' % ' '.join(names)
2323 ui.status(_('grafting %s\n') % desc)
2322 ui.status(_('grafting %s\n') % desc)
2324 if opts.get('dry_run'):
2323 if opts.get('dry_run'):
2325 continue
2324 continue
2326
2325
2327 source = ctx.extra().get('source')
2326 source = ctx.extra().get('source')
2328 extra = {}
2327 extra = {}
2329 if source:
2328 if source:
2330 extra['source'] = source
2329 extra['source'] = source
2331 extra['intermediate-source'] = ctx.hex()
2330 extra['intermediate-source'] = ctx.hex()
2332 else:
2331 else:
2333 extra['source'] = ctx.hex()
2332 extra['source'] = ctx.hex()
2334 user = ctx.user()
2333 user = ctx.user()
2335 if opts.get('user'):
2334 if opts.get('user'):
2336 user = opts['user']
2335 user = opts['user']
2337 date = ctx.date()
2336 date = ctx.date()
2338 if opts.get('date'):
2337 if opts.get('date'):
2339 date = opts['date']
2338 date = opts['date']
2340 message = ctx.description()
2339 message = ctx.description()
2341 if opts.get('log'):
2340 if opts.get('log'):
2342 message += '\n(grafted from %s)' % ctx.hex()
2341 message += '\n(grafted from %s)' % ctx.hex()
2343
2342
2344 # we don't merge the first commit when continuing
2343 # we don't merge the first commit when continuing
2345 if not cont:
2344 if not cont:
2346 # perform the graft merge with p1(rev) as 'ancestor'
2345 # perform the graft merge with p1(rev) as 'ancestor'
2347 try:
2346 try:
2348 # ui.forcemerge is an internal variable, do not document
2347 # ui.forcemerge is an internal variable, do not document
2349 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2348 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
2350 'graft')
2349 'graft')
2351 stats = mergemod.graft(repo, ctx, ctx.p1(),
2350 stats = mergemod.graft(repo, ctx, ctx.p1(),
2352 ['local', 'graft'])
2351 ['local', 'graft'])
2353 finally:
2352 finally:
2354 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2353 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
2355 # report any conflicts
2354 # report any conflicts
2356 if stats and stats[3] > 0:
2355 if stats and stats[3] > 0:
2357 # write out state for --continue
2356 # write out state for --continue
2358 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2357 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
2359 repo.vfs.write('graftstate', ''.join(nodelines))
2358 repo.vfs.write('graftstate', ''.join(nodelines))
2360 extra = ''
2359 extra = ''
2361 if opts.get('user'):
2360 if opts.get('user'):
2362 extra += ' --user %s' % util.shellquote(opts['user'])
2361 extra += ' --user %s' % util.shellquote(opts['user'])
2363 if opts.get('date'):
2362 if opts.get('date'):
2364 extra += ' --date %s' % util.shellquote(opts['date'])
2363 extra += ' --date %s' % util.shellquote(opts['date'])
2365 if opts.get('log'):
2364 if opts.get('log'):
2366 extra += ' --log'
2365 extra += ' --log'
2367 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2366 hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
2368 raise error.Abort(
2367 raise error.Abort(
2369 _("unresolved conflicts, can't continue"),
2368 _("unresolved conflicts, can't continue"),
2370 hint=hint)
2369 hint=hint)
2371 else:
2370 else:
2372 cont = False
2371 cont = False
2373
2372
2374 # commit
2373 # commit
2375 node = repo.commit(text=message, user=user,
2374 node = repo.commit(text=message, user=user,
2376 date=date, extra=extra, editor=editor)
2375 date=date, extra=extra, editor=editor)
2377 if node is None:
2376 if node is None:
2378 ui.warn(
2377 ui.warn(
2379 _('note: graft of %d:%s created no changes to commit\n') %
2378 _('note: graft of %d:%s created no changes to commit\n') %
2380 (ctx.rev(), ctx))
2379 (ctx.rev(), ctx))
2381
2380
2382 # remove state when we complete successfully
2381 # remove state when we complete successfully
2383 if not opts.get('dry_run'):
2382 if not opts.get('dry_run'):
2384 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
2383 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
2385
2384
2386 return 0
2385 return 0
2387
2386
2388 @command('grep',
2387 @command('grep',
2389 [('0', 'print0', None, _('end fields with NUL')),
2388 [('0', 'print0', None, _('end fields with NUL')),
2390 ('', 'all', None, _('print all revisions that match')),
2389 ('', 'all', None, _('print all revisions that match')),
2391 ('a', 'text', None, _('treat all files as text')),
2390 ('a', 'text', None, _('treat all files as text')),
2392 ('f', 'follow', None,
2391 ('f', 'follow', None,
2393 _('follow changeset history,'
2392 _('follow changeset history,'
2394 ' or file history across copies and renames')),
2393 ' or file history across copies and renames')),
2395 ('i', 'ignore-case', None, _('ignore case when matching')),
2394 ('i', 'ignore-case', None, _('ignore case when matching')),
2396 ('l', 'files-with-matches', None,
2395 ('l', 'files-with-matches', None,
2397 _('print only filenames and revisions that match')),
2396 _('print only filenames and revisions that match')),
2398 ('n', 'line-number', None, _('print matching line numbers')),
2397 ('n', 'line-number', None, _('print matching line numbers')),
2399 ('r', 'rev', [],
2398 ('r', 'rev', [],
2400 _('only search files changed within revision range'), _('REV')),
2399 _('only search files changed within revision range'), _('REV')),
2401 ('u', 'user', None, _('list the author (long with -v)')),
2400 ('u', 'user', None, _('list the author (long with -v)')),
2402 ('d', 'date', None, _('list the date (short with -q)')),
2401 ('d', 'date', None, _('list the date (short with -q)')),
2403 ] + formatteropts + walkopts,
2402 ] + formatteropts + walkopts,
2404 _('[OPTION]... PATTERN [FILE]...'),
2403 _('[OPTION]... PATTERN [FILE]...'),
2405 inferrepo=True)
2404 inferrepo=True)
2406 def grep(ui, repo, pattern, *pats, **opts):
2405 def grep(ui, repo, pattern, *pats, **opts):
2407 """search revision history for a pattern in specified files
2406 """search revision history for a pattern in specified files
2408
2407
2409 Search revision history for a regular expression in the specified
2408 Search revision history for a regular expression in the specified
2410 files or the entire project.
2409 files or the entire project.
2411
2410
2412 By default, grep prints the most recent revision number for each
2411 By default, grep prints the most recent revision number for each
2413 file in which it finds a match. To get it to print every revision
2412 file in which it finds a match. To get it to print every revision
2414 that contains a change in match status ("-" for a match that becomes
2413 that contains a change in match status ("-" for a match that becomes
2415 a non-match, or "+" for a non-match that becomes a match), use the
2414 a non-match, or "+" for a non-match that becomes a match), use the
2416 --all flag.
2415 --all flag.
2417
2416
2418 PATTERN can be any Python (roughly Perl-compatible) regular
2417 PATTERN can be any Python (roughly Perl-compatible) regular
2419 expression.
2418 expression.
2420
2419
2421 If no FILEs are specified (and -f/--follow isn't set), all files in
2420 If no FILEs are specified (and -f/--follow isn't set), all files in
2422 the repository are searched, including those that don't exist in the
2421 the repository are searched, including those that don't exist in the
2423 current branch or have been deleted in a prior changeset.
2422 current branch or have been deleted in a prior changeset.
2424
2423
2425 Returns 0 if a match is found, 1 otherwise.
2424 Returns 0 if a match is found, 1 otherwise.
2426 """
2425 """
2427 reflags = re.M
2426 reflags = re.M
2428 if opts.get('ignore_case'):
2427 if opts.get('ignore_case'):
2429 reflags |= re.I
2428 reflags |= re.I
2430 try:
2429 try:
2431 regexp = util.re.compile(pattern, reflags)
2430 regexp = util.re.compile(pattern, reflags)
2432 except re.error as inst:
2431 except re.error as inst:
2433 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
2432 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
2434 return 1
2433 return 1
2435 sep, eol = ':', '\n'
2434 sep, eol = ':', '\n'
2436 if opts.get('print0'):
2435 if opts.get('print0'):
2437 sep = eol = '\0'
2436 sep = eol = '\0'
2438
2437
2439 getfile = util.lrucachefunc(repo.file)
2438 getfile = util.lrucachefunc(repo.file)
2440
2439
2441 def matchlines(body):
2440 def matchlines(body):
2442 begin = 0
2441 begin = 0
2443 linenum = 0
2442 linenum = 0
2444 while begin < len(body):
2443 while begin < len(body):
2445 match = regexp.search(body, begin)
2444 match = regexp.search(body, begin)
2446 if not match:
2445 if not match:
2447 break
2446 break
2448 mstart, mend = match.span()
2447 mstart, mend = match.span()
2449 linenum += body.count('\n', begin, mstart) + 1
2448 linenum += body.count('\n', begin, mstart) + 1
2450 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2449 lstart = body.rfind('\n', begin, mstart) + 1 or begin
2451 begin = body.find('\n', mend) + 1 or len(body) + 1
2450 begin = body.find('\n', mend) + 1 or len(body) + 1
2452 lend = begin - 1
2451 lend = begin - 1
2453 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2452 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
2454
2453
2455 class linestate(object):
2454 class linestate(object):
2456 def __init__(self, line, linenum, colstart, colend):
2455 def __init__(self, line, linenum, colstart, colend):
2457 self.line = line
2456 self.line = line
2458 self.linenum = linenum
2457 self.linenum = linenum
2459 self.colstart = colstart
2458 self.colstart = colstart
2460 self.colend = colend
2459 self.colend = colend
2461
2460
2462 def __hash__(self):
2461 def __hash__(self):
2463 return hash((self.linenum, self.line))
2462 return hash((self.linenum, self.line))
2464
2463
2465 def __eq__(self, other):
2464 def __eq__(self, other):
2466 return self.line == other.line
2465 return self.line == other.line
2467
2466
2468 def findpos(self):
2467 def findpos(self):
2469 """Iterate all (start, end) indices of matches"""
2468 """Iterate all (start, end) indices of matches"""
2470 yield self.colstart, self.colend
2469 yield self.colstart, self.colend
2471 p = self.colend
2470 p = self.colend
2472 while p < len(self.line):
2471 while p < len(self.line):
2473 m = regexp.search(self.line, p)
2472 m = regexp.search(self.line, p)
2474 if not m:
2473 if not m:
2475 break
2474 break
2476 yield m.span()
2475 yield m.span()
2477 p = m.end()
2476 p = m.end()
2478
2477
2479 matches = {}
2478 matches = {}
2480 copies = {}
2479 copies = {}
2481 def grepbody(fn, rev, body):
2480 def grepbody(fn, rev, body):
2482 matches[rev].setdefault(fn, [])
2481 matches[rev].setdefault(fn, [])
2483 m = matches[rev][fn]
2482 m = matches[rev][fn]
2484 for lnum, cstart, cend, line in matchlines(body):
2483 for lnum, cstart, cend, line in matchlines(body):
2485 s = linestate(line, lnum, cstart, cend)
2484 s = linestate(line, lnum, cstart, cend)
2486 m.append(s)
2485 m.append(s)
2487
2486
2488 def difflinestates(a, b):
2487 def difflinestates(a, b):
2489 sm = difflib.SequenceMatcher(None, a, b)
2488 sm = difflib.SequenceMatcher(None, a, b)
2490 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2489 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2491 if tag == 'insert':
2490 if tag == 'insert':
2492 for i in xrange(blo, bhi):
2491 for i in xrange(blo, bhi):
2493 yield ('+', b[i])
2492 yield ('+', b[i])
2494 elif tag == 'delete':
2493 elif tag == 'delete':
2495 for i in xrange(alo, ahi):
2494 for i in xrange(alo, ahi):
2496 yield ('-', a[i])
2495 yield ('-', a[i])
2497 elif tag == 'replace':
2496 elif tag == 'replace':
2498 for i in xrange(alo, ahi):
2497 for i in xrange(alo, ahi):
2499 yield ('-', a[i])
2498 yield ('-', a[i])
2500 for i in xrange(blo, bhi):
2499 for i in xrange(blo, bhi):
2501 yield ('+', b[i])
2500 yield ('+', b[i])
2502
2501
2503 def display(fm, fn, ctx, pstates, states):
2502 def display(fm, fn, ctx, pstates, states):
2504 rev = ctx.rev()
2503 rev = ctx.rev()
2505 if fm.isplain():
2504 if fm.isplain():
2506 formatuser = ui.shortuser
2505 formatuser = ui.shortuser
2507 else:
2506 else:
2508 formatuser = str
2507 formatuser = str
2509 if ui.quiet:
2508 if ui.quiet:
2510 datefmt = '%Y-%m-%d'
2509 datefmt = '%Y-%m-%d'
2511 else:
2510 else:
2512 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2511 datefmt = '%a %b %d %H:%M:%S %Y %1%2'
2513 found = False
2512 found = False
2514 @util.cachefunc
2513 @util.cachefunc
2515 def binary():
2514 def binary():
2516 flog = getfile(fn)
2515 flog = getfile(fn)
2517 return util.binary(flog.read(ctx.filenode(fn)))
2516 return util.binary(flog.read(ctx.filenode(fn)))
2518
2517
2519 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2518 fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
2520 if opts.get('all'):
2519 if opts.get('all'):
2521 iter = difflinestates(pstates, states)
2520 iter = difflinestates(pstates, states)
2522 else:
2521 else:
2523 iter = [('', l) for l in states]
2522 iter = [('', l) for l in states]
2524 for change, l in iter:
2523 for change, l in iter:
2525 fm.startitem()
2524 fm.startitem()
2526 fm.data(node=fm.hexfunc(ctx.node()))
2525 fm.data(node=fm.hexfunc(ctx.node()))
2527 cols = [
2526 cols = [
2528 ('filename', fn, True),
2527 ('filename', fn, True),
2529 ('rev', rev, True),
2528 ('rev', rev, True),
2530 ('linenumber', l.linenum, opts.get('line_number')),
2529 ('linenumber', l.linenum, opts.get('line_number')),
2531 ]
2530 ]
2532 if opts.get('all'):
2531 if opts.get('all'):
2533 cols.append(('change', change, True))
2532 cols.append(('change', change, True))
2534 cols.extend([
2533 cols.extend([
2535 ('user', formatuser(ctx.user()), opts.get('user')),
2534 ('user', formatuser(ctx.user()), opts.get('user')),
2536 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2535 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')),
2537 ])
2536 ])
2538 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2537 lastcol = next(name for name, data, cond in reversed(cols) if cond)
2539 for name, data, cond in cols:
2538 for name, data, cond in cols:
2540 field = fieldnamemap.get(name, name)
2539 field = fieldnamemap.get(name, name)
2541 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2540 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name)
2542 if cond and name != lastcol:
2541 if cond and name != lastcol:
2543 fm.plain(sep, label='grep.sep')
2542 fm.plain(sep, label='grep.sep')
2544 if not opts.get('files_with_matches'):
2543 if not opts.get('files_with_matches'):
2545 fm.plain(sep, label='grep.sep')
2544 fm.plain(sep, label='grep.sep')
2546 if not opts.get('text') and binary():
2545 if not opts.get('text') and binary():
2547 fm.plain(_(" Binary file matches"))
2546 fm.plain(_(" Binary file matches"))
2548 else:
2547 else:
2549 displaymatches(fm.nested('texts'), l)
2548 displaymatches(fm.nested('texts'), l)
2550 fm.plain(eol)
2549 fm.plain(eol)
2551 found = True
2550 found = True
2552 if opts.get('files_with_matches'):
2551 if opts.get('files_with_matches'):
2553 break
2552 break
2554 return found
2553 return found
2555
2554
2556 def displaymatches(fm, l):
2555 def displaymatches(fm, l):
2557 p = 0
2556 p = 0
2558 for s, e in l.findpos():
2557 for s, e in l.findpos():
2559 if p < s:
2558 if p < s:
2560 fm.startitem()
2559 fm.startitem()
2561 fm.write('text', '%s', l.line[p:s])
2560 fm.write('text', '%s', l.line[p:s])
2562 fm.data(matched=False)
2561 fm.data(matched=False)
2563 fm.startitem()
2562 fm.startitem()
2564 fm.write('text', '%s', l.line[s:e], label='grep.match')
2563 fm.write('text', '%s', l.line[s:e], label='grep.match')
2565 fm.data(matched=True)
2564 fm.data(matched=True)
2566 p = e
2565 p = e
2567 if p < len(l.line):
2566 if p < len(l.line):
2568 fm.startitem()
2567 fm.startitem()
2569 fm.write('text', '%s', l.line[p:])
2568 fm.write('text', '%s', l.line[p:])
2570 fm.data(matched=False)
2569 fm.data(matched=False)
2571 fm.end()
2570 fm.end()
2572
2571
2573 skip = {}
2572 skip = {}
2574 revfiles = {}
2573 revfiles = {}
2575 matchfn = scmutil.match(repo[None], pats, opts)
2574 matchfn = scmutil.match(repo[None], pats, opts)
2576 found = False
2575 found = False
2577 follow = opts.get('follow')
2576 follow = opts.get('follow')
2578
2577
2579 def prep(ctx, fns):
2578 def prep(ctx, fns):
2580 rev = ctx.rev()
2579 rev = ctx.rev()
2581 pctx = ctx.p1()
2580 pctx = ctx.p1()
2582 parent = pctx.rev()
2581 parent = pctx.rev()
2583 matches.setdefault(rev, {})
2582 matches.setdefault(rev, {})
2584 matches.setdefault(parent, {})
2583 matches.setdefault(parent, {})
2585 files = revfiles.setdefault(rev, [])
2584 files = revfiles.setdefault(rev, [])
2586 for fn in fns:
2585 for fn in fns:
2587 flog = getfile(fn)
2586 flog = getfile(fn)
2588 try:
2587 try:
2589 fnode = ctx.filenode(fn)
2588 fnode = ctx.filenode(fn)
2590 except error.LookupError:
2589 except error.LookupError:
2591 continue
2590 continue
2592
2591
2593 copied = flog.renamed(fnode)
2592 copied = flog.renamed(fnode)
2594 copy = follow and copied and copied[0]
2593 copy = follow and copied and copied[0]
2595 if copy:
2594 if copy:
2596 copies.setdefault(rev, {})[fn] = copy
2595 copies.setdefault(rev, {})[fn] = copy
2597 if fn in skip:
2596 if fn in skip:
2598 if copy:
2597 if copy:
2599 skip[copy] = True
2598 skip[copy] = True
2600 continue
2599 continue
2601 files.append(fn)
2600 files.append(fn)
2602
2601
2603 if fn not in matches[rev]:
2602 if fn not in matches[rev]:
2604 grepbody(fn, rev, flog.read(fnode))
2603 grepbody(fn, rev, flog.read(fnode))
2605
2604
2606 pfn = copy or fn
2605 pfn = copy or fn
2607 if pfn not in matches[parent]:
2606 if pfn not in matches[parent]:
2608 try:
2607 try:
2609 fnode = pctx.filenode(pfn)
2608 fnode = pctx.filenode(pfn)
2610 grepbody(pfn, parent, flog.read(fnode))
2609 grepbody(pfn, parent, flog.read(fnode))
2611 except error.LookupError:
2610 except error.LookupError:
2612 pass
2611 pass
2613
2612
2614 ui.pager('grep')
2613 ui.pager('grep')
2615 fm = ui.formatter('grep', opts)
2614 fm = ui.formatter('grep', opts)
2616 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2615 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2617 rev = ctx.rev()
2616 rev = ctx.rev()
2618 parent = ctx.p1().rev()
2617 parent = ctx.p1().rev()
2619 for fn in sorted(revfiles.get(rev, [])):
2618 for fn in sorted(revfiles.get(rev, [])):
2620 states = matches[rev][fn]
2619 states = matches[rev][fn]
2621 copy = copies.get(rev, {}).get(fn)
2620 copy = copies.get(rev, {}).get(fn)
2622 if fn in skip:
2621 if fn in skip:
2623 if copy:
2622 if copy:
2624 skip[copy] = True
2623 skip[copy] = True
2625 continue
2624 continue
2626 pstates = matches.get(parent, {}).get(copy or fn, [])
2625 pstates = matches.get(parent, {}).get(copy or fn, [])
2627 if pstates or states:
2626 if pstates or states:
2628 r = display(fm, fn, ctx, pstates, states)
2627 r = display(fm, fn, ctx, pstates, states)
2629 found = found or r
2628 found = found or r
2630 if r and not opts.get('all'):
2629 if r and not opts.get('all'):
2631 skip[fn] = True
2630 skip[fn] = True
2632 if copy:
2631 if copy:
2633 skip[copy] = True
2632 skip[copy] = True
2634 del matches[rev]
2633 del matches[rev]
2635 del revfiles[rev]
2634 del revfiles[rev]
2636 fm.end()
2635 fm.end()
2637
2636
2638 return not found
2637 return not found
2639
2638
2640 @command('heads',
2639 @command('heads',
2641 [('r', 'rev', '',
2640 [('r', 'rev', '',
2642 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2641 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
2643 ('t', 'topo', False, _('show topological heads only')),
2642 ('t', 'topo', False, _('show topological heads only')),
2644 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2643 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
2645 ('c', 'closed', False, _('show normal and closed branch heads')),
2644 ('c', 'closed', False, _('show normal and closed branch heads')),
2646 ] + templateopts,
2645 ] + templateopts,
2647 _('[-ct] [-r STARTREV] [REV]...'))
2646 _('[-ct] [-r STARTREV] [REV]...'))
2648 def heads(ui, repo, *branchrevs, **opts):
2647 def heads(ui, repo, *branchrevs, **opts):
2649 """show branch heads
2648 """show branch heads
2650
2649
2651 With no arguments, show all open branch heads in the repository.
2650 With no arguments, show all open branch heads in the repository.
2652 Branch heads are changesets that have no descendants on the
2651 Branch heads are changesets that have no descendants on the
2653 same branch. They are where development generally takes place and
2652 same branch. They are where development generally takes place and
2654 are the usual targets for update and merge operations.
2653 are the usual targets for update and merge operations.
2655
2654
2656 If one or more REVs are given, only open branch heads on the
2655 If one or more REVs are given, only open branch heads on the
2657 branches associated with the specified changesets are shown. This
2656 branches associated with the specified changesets are shown. This
2658 means that you can use :hg:`heads .` to see the heads on the
2657 means that you can use :hg:`heads .` to see the heads on the
2659 currently checked-out branch.
2658 currently checked-out branch.
2660
2659
2661 If -c/--closed is specified, also show branch heads marked closed
2660 If -c/--closed is specified, also show branch heads marked closed
2662 (see :hg:`commit --close-branch`).
2661 (see :hg:`commit --close-branch`).
2663
2662
2664 If STARTREV is specified, only those heads that are descendants of
2663 If STARTREV is specified, only those heads that are descendants of
2665 STARTREV will be displayed.
2664 STARTREV will be displayed.
2666
2665
2667 If -t/--topo is specified, named branch mechanics will be ignored and only
2666 If -t/--topo is specified, named branch mechanics will be ignored and only
2668 topological heads (changesets with no children) will be shown.
2667 topological heads (changesets with no children) will be shown.
2669
2668
2670 Returns 0 if matching heads are found, 1 if not.
2669 Returns 0 if matching heads are found, 1 if not.
2671 """
2670 """
2672
2671
2673 start = None
2672 start = None
2674 if 'rev' in opts:
2673 if 'rev' in opts:
2675 start = scmutil.revsingle(repo, opts['rev'], None).node()
2674 start = scmutil.revsingle(repo, opts['rev'], None).node()
2676
2675
2677 if opts.get('topo'):
2676 if opts.get('topo'):
2678 heads = [repo[h] for h in repo.heads(start)]
2677 heads = [repo[h] for h in repo.heads(start)]
2679 else:
2678 else:
2680 heads = []
2679 heads = []
2681 for branch in repo.branchmap():
2680 for branch in repo.branchmap():
2682 heads += repo.branchheads(branch, start, opts.get('closed'))
2681 heads += repo.branchheads(branch, start, opts.get('closed'))
2683 heads = [repo[h] for h in heads]
2682 heads = [repo[h] for h in heads]
2684
2683
2685 if branchrevs:
2684 if branchrevs:
2686 branches = set(repo[br].branch() for br in branchrevs)
2685 branches = set(repo[br].branch() for br in branchrevs)
2687 heads = [h for h in heads if h.branch() in branches]
2686 heads = [h for h in heads if h.branch() in branches]
2688
2687
2689 if opts.get('active') and branchrevs:
2688 if opts.get('active') and branchrevs:
2690 dagheads = repo.heads(start)
2689 dagheads = repo.heads(start)
2691 heads = [h for h in heads if h.node() in dagheads]
2690 heads = [h for h in heads if h.node() in dagheads]
2692
2691
2693 if branchrevs:
2692 if branchrevs:
2694 haveheads = set(h.branch() for h in heads)
2693 haveheads = set(h.branch() for h in heads)
2695 if branches - haveheads:
2694 if branches - haveheads:
2696 headless = ', '.join(b for b in branches - haveheads)
2695 headless = ', '.join(b for b in branches - haveheads)
2697 msg = _('no open branch heads found on branches %s')
2696 msg = _('no open branch heads found on branches %s')
2698 if opts.get('rev'):
2697 if opts.get('rev'):
2699 msg += _(' (started at %s)') % opts['rev']
2698 msg += _(' (started at %s)') % opts['rev']
2700 ui.warn((msg + '\n') % headless)
2699 ui.warn((msg + '\n') % headless)
2701
2700
2702 if not heads:
2701 if not heads:
2703 return 1
2702 return 1
2704
2703
2705 heads = sorted(heads, key=lambda x: -x.rev())
2704 heads = sorted(heads, key=lambda x: -x.rev())
2706 displayer = cmdutil.show_changeset(ui, repo, opts)
2705 displayer = cmdutil.show_changeset(ui, repo, opts)
2707 for ctx in heads:
2706 for ctx in heads:
2708 displayer.show(ctx)
2707 displayer.show(ctx)
2709 displayer.close()
2708 displayer.close()
2710
2709
2711 @command('help',
2710 @command('help',
2712 [('e', 'extension', None, _('show only help for extensions')),
2711 [('e', 'extension', None, _('show only help for extensions')),
2713 ('c', 'command', None, _('show only help for commands')),
2712 ('c', 'command', None, _('show only help for commands')),
2714 ('k', 'keyword', None, _('show topics matching keyword')),
2713 ('k', 'keyword', None, _('show topics matching keyword')),
2715 ('s', 'system', [], _('show help for specific platform(s)')),
2714 ('s', 'system', [], _('show help for specific platform(s)')),
2716 ],
2715 ],
2717 _('[-ecks] [TOPIC]'),
2716 _('[-ecks] [TOPIC]'),
2718 norepo=True)
2717 norepo=True)
2719 def help_(ui, name=None, **opts):
2718 def help_(ui, name=None, **opts):
2720 """show help for a given topic or a help overview
2719 """show help for a given topic or a help overview
2721
2720
2722 With no arguments, print a list of commands with short help messages.
2721 With no arguments, print a list of commands with short help messages.
2723
2722
2724 Given a topic, extension, or command name, print help for that
2723 Given a topic, extension, or command name, print help for that
2725 topic.
2724 topic.
2726
2725
2727 Returns 0 if successful.
2726 Returns 0 if successful.
2728 """
2727 """
2729
2728
2730 keep = opts.get('system') or []
2729 keep = opts.get('system') or []
2731 if len(keep) == 0:
2730 if len(keep) == 0:
2732 if pycompat.sysplatform.startswith('win'):
2731 if pycompat.sysplatform.startswith('win'):
2733 keep.append('windows')
2732 keep.append('windows')
2734 elif pycompat.sysplatform == 'OpenVMS':
2733 elif pycompat.sysplatform == 'OpenVMS':
2735 keep.append('vms')
2734 keep.append('vms')
2736 elif pycompat.sysplatform == 'plan9':
2735 elif pycompat.sysplatform == 'plan9':
2737 keep.append('plan9')
2736 keep.append('plan9')
2738 else:
2737 else:
2739 keep.append('unix')
2738 keep.append('unix')
2740 keep.append(pycompat.sysplatform.lower())
2739 keep.append(pycompat.sysplatform.lower())
2741 if ui.verbose:
2740 if ui.verbose:
2742 keep.append('verbose')
2741 keep.append('verbose')
2743
2742
2744 formatted = help.formattedhelp(ui, name, keep=keep, **opts)
2743 formatted = help.formattedhelp(ui, name, keep=keep, **opts)
2745 ui.pager('help')
2744 ui.pager('help')
2746 ui.write(formatted)
2745 ui.write(formatted)
2747
2746
2748
2747
2749 @command('identify|id',
2748 @command('identify|id',
2750 [('r', 'rev', '',
2749 [('r', 'rev', '',
2751 _('identify the specified revision'), _('REV')),
2750 _('identify the specified revision'), _('REV')),
2752 ('n', 'num', None, _('show local revision number')),
2751 ('n', 'num', None, _('show local revision number')),
2753 ('i', 'id', None, _('show global revision id')),
2752 ('i', 'id', None, _('show global revision id')),
2754 ('b', 'branch', None, _('show branch')),
2753 ('b', 'branch', None, _('show branch')),
2755 ('t', 'tags', None, _('show tags')),
2754 ('t', 'tags', None, _('show tags')),
2756 ('B', 'bookmarks', None, _('show bookmarks')),
2755 ('B', 'bookmarks', None, _('show bookmarks')),
2757 ] + remoteopts,
2756 ] + remoteopts,
2758 _('[-nibtB] [-r REV] [SOURCE]'),
2757 _('[-nibtB] [-r REV] [SOURCE]'),
2759 optionalrepo=True)
2758 optionalrepo=True)
2760 def identify(ui, repo, source=None, rev=None,
2759 def identify(ui, repo, source=None, rev=None,
2761 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2760 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
2762 """identify the working directory or specified revision
2761 """identify the working directory or specified revision
2763
2762
2764 Print a summary identifying the repository state at REV using one or
2763 Print a summary identifying the repository state at REV using one or
2765 two parent hash identifiers, followed by a "+" if the working
2764 two parent hash identifiers, followed by a "+" if the working
2766 directory has uncommitted changes, the branch name (if not default),
2765 directory has uncommitted changes, the branch name (if not default),
2767 a list of tags, and a list of bookmarks.
2766 a list of tags, and a list of bookmarks.
2768
2767
2769 When REV is not given, print a summary of the current state of the
2768 When REV is not given, print a summary of the current state of the
2770 repository.
2769 repository.
2771
2770
2772 Specifying a path to a repository root or Mercurial bundle will
2771 Specifying a path to a repository root or Mercurial bundle will
2773 cause lookup to operate on that repository/bundle.
2772 cause lookup to operate on that repository/bundle.
2774
2773
2775 .. container:: verbose
2774 .. container:: verbose
2776
2775
2777 Examples:
2776 Examples:
2778
2777
2779 - generate a build identifier for the working directory::
2778 - generate a build identifier for the working directory::
2780
2779
2781 hg id --id > build-id.dat
2780 hg id --id > build-id.dat
2782
2781
2783 - find the revision corresponding to a tag::
2782 - find the revision corresponding to a tag::
2784
2783
2785 hg id -n -r 1.3
2784 hg id -n -r 1.3
2786
2785
2787 - check the most recent revision of a remote repository::
2786 - check the most recent revision of a remote repository::
2788
2787
2789 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2788 hg id -r tip https://www.mercurial-scm.org/repo/hg/
2790
2789
2791 See :hg:`log` for generating more information about specific revisions,
2790 See :hg:`log` for generating more information about specific revisions,
2792 including full hash identifiers.
2791 including full hash identifiers.
2793
2792
2794 Returns 0 if successful.
2793 Returns 0 if successful.
2795 """
2794 """
2796
2795
2797 if not repo and not source:
2796 if not repo and not source:
2798 raise error.Abort(_("there is no Mercurial repository here "
2797 raise error.Abort(_("there is no Mercurial repository here "
2799 "(.hg not found)"))
2798 "(.hg not found)"))
2800
2799
2801 if ui.debugflag:
2800 if ui.debugflag:
2802 hexfunc = hex
2801 hexfunc = hex
2803 else:
2802 else:
2804 hexfunc = short
2803 hexfunc = short
2805 default = not (num or id or branch or tags or bookmarks)
2804 default = not (num or id or branch or tags or bookmarks)
2806 output = []
2805 output = []
2807 revs = []
2806 revs = []
2808
2807
2809 if source:
2808 if source:
2810 source, branches = hg.parseurl(ui.expandpath(source))
2809 source, branches = hg.parseurl(ui.expandpath(source))
2811 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2810 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
2812 repo = peer.local()
2811 repo = peer.local()
2813 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2812 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
2814
2813
2815 if not repo:
2814 if not repo:
2816 if num or branch or tags:
2815 if num or branch or tags:
2817 raise error.Abort(
2816 raise error.Abort(
2818 _("can't query remote revision number, branch, or tags"))
2817 _("can't query remote revision number, branch, or tags"))
2819 if not rev and revs:
2818 if not rev and revs:
2820 rev = revs[0]
2819 rev = revs[0]
2821 if not rev:
2820 if not rev:
2822 rev = "tip"
2821 rev = "tip"
2823
2822
2824 remoterev = peer.lookup(rev)
2823 remoterev = peer.lookup(rev)
2825 if default or id:
2824 if default or id:
2826 output = [hexfunc(remoterev)]
2825 output = [hexfunc(remoterev)]
2827
2826
2828 def getbms():
2827 def getbms():
2829 bms = []
2828 bms = []
2830
2829
2831 if 'bookmarks' in peer.listkeys('namespaces'):
2830 if 'bookmarks' in peer.listkeys('namespaces'):
2832 hexremoterev = hex(remoterev)
2831 hexremoterev = hex(remoterev)
2833 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2832 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
2834 if bmr == hexremoterev]
2833 if bmr == hexremoterev]
2835
2834
2836 return sorted(bms)
2835 return sorted(bms)
2837
2836
2838 if bookmarks:
2837 if bookmarks:
2839 output.extend(getbms())
2838 output.extend(getbms())
2840 elif default and not ui.quiet:
2839 elif default and not ui.quiet:
2841 # multiple bookmarks for a single parent separated by '/'
2840 # multiple bookmarks for a single parent separated by '/'
2842 bm = '/'.join(getbms())
2841 bm = '/'.join(getbms())
2843 if bm:
2842 if bm:
2844 output.append(bm)
2843 output.append(bm)
2845 else:
2844 else:
2846 ctx = scmutil.revsingle(repo, rev, None)
2845 ctx = scmutil.revsingle(repo, rev, None)
2847
2846
2848 if ctx.rev() is None:
2847 if ctx.rev() is None:
2849 ctx = repo[None]
2848 ctx = repo[None]
2850 parents = ctx.parents()
2849 parents = ctx.parents()
2851 taglist = []
2850 taglist = []
2852 for p in parents:
2851 for p in parents:
2853 taglist.extend(p.tags())
2852 taglist.extend(p.tags())
2854
2853
2855 changed = ""
2854 changed = ""
2856 if default or id or num:
2855 if default or id or num:
2857 if (any(repo.status())
2856 if (any(repo.status())
2858 or any(ctx.sub(s).dirty() for s in ctx.substate)):
2857 or any(ctx.sub(s).dirty() for s in ctx.substate)):
2859 changed = '+'
2858 changed = '+'
2860 if default or id:
2859 if default or id:
2861 output = ["%s%s" %
2860 output = ["%s%s" %
2862 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
2861 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
2863 if num:
2862 if num:
2864 output.append("%s%s" %
2863 output.append("%s%s" %
2865 ('+'.join([str(p.rev()) for p in parents]), changed))
2864 ('+'.join([str(p.rev()) for p in parents]), changed))
2866 else:
2865 else:
2867 if default or id:
2866 if default or id:
2868 output = [hexfunc(ctx.node())]
2867 output = [hexfunc(ctx.node())]
2869 if num:
2868 if num:
2870 output.append(str(ctx.rev()))
2869 output.append(str(ctx.rev()))
2871 taglist = ctx.tags()
2870 taglist = ctx.tags()
2872
2871
2873 if default and not ui.quiet:
2872 if default and not ui.quiet:
2874 b = ctx.branch()
2873 b = ctx.branch()
2875 if b != 'default':
2874 if b != 'default':
2876 output.append("(%s)" % b)
2875 output.append("(%s)" % b)
2877
2876
2878 # multiple tags for a single parent separated by '/'
2877 # multiple tags for a single parent separated by '/'
2879 t = '/'.join(taglist)
2878 t = '/'.join(taglist)
2880 if t:
2879 if t:
2881 output.append(t)
2880 output.append(t)
2882
2881
2883 # multiple bookmarks for a single parent separated by '/'
2882 # multiple bookmarks for a single parent separated by '/'
2884 bm = '/'.join(ctx.bookmarks())
2883 bm = '/'.join(ctx.bookmarks())
2885 if bm:
2884 if bm:
2886 output.append(bm)
2885 output.append(bm)
2887 else:
2886 else:
2888 if branch:
2887 if branch:
2889 output.append(ctx.branch())
2888 output.append(ctx.branch())
2890
2889
2891 if tags:
2890 if tags:
2892 output.extend(taglist)
2891 output.extend(taglist)
2893
2892
2894 if bookmarks:
2893 if bookmarks:
2895 output.extend(ctx.bookmarks())
2894 output.extend(ctx.bookmarks())
2896
2895
2897 ui.write("%s\n" % ' '.join(output))
2896 ui.write("%s\n" % ' '.join(output))
2898
2897
2899 @command('import|patch',
2898 @command('import|patch',
2900 [('p', 'strip', 1,
2899 [('p', 'strip', 1,
2901 _('directory strip option for patch. This has the same '
2900 _('directory strip option for patch. This has the same '
2902 'meaning as the corresponding patch option'), _('NUM')),
2901 'meaning as the corresponding patch option'), _('NUM')),
2903 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2902 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
2904 ('e', 'edit', False, _('invoke editor on commit messages')),
2903 ('e', 'edit', False, _('invoke editor on commit messages')),
2905 ('f', 'force', None,
2904 ('f', 'force', None,
2906 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2905 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
2907 ('', 'no-commit', None,
2906 ('', 'no-commit', None,
2908 _("don't commit, just update the working directory")),
2907 _("don't commit, just update the working directory")),
2909 ('', 'bypass', None,
2908 ('', 'bypass', None,
2910 _("apply patch without touching the working directory")),
2909 _("apply patch without touching the working directory")),
2911 ('', 'partial', None,
2910 ('', 'partial', None,
2912 _('commit even if some hunks fail')),
2911 _('commit even if some hunks fail')),
2913 ('', 'exact', None,
2912 ('', 'exact', None,
2914 _('abort if patch would apply lossily')),
2913 _('abort if patch would apply lossily')),
2915 ('', 'prefix', '',
2914 ('', 'prefix', '',
2916 _('apply patch to subdirectory'), _('DIR')),
2915 _('apply patch to subdirectory'), _('DIR')),
2917 ('', 'import-branch', None,
2916 ('', 'import-branch', None,
2918 _('use any branch information in patch (implied by --exact)'))] +
2917 _('use any branch information in patch (implied by --exact)'))] +
2919 commitopts + commitopts2 + similarityopts,
2918 commitopts + commitopts2 + similarityopts,
2920 _('[OPTION]... PATCH...'))
2919 _('[OPTION]... PATCH...'))
2921 def import_(ui, repo, patch1=None, *patches, **opts):
2920 def import_(ui, repo, patch1=None, *patches, **opts):
2922 """import an ordered set of patches
2921 """import an ordered set of patches
2923
2922
2924 Import a list of patches and commit them individually (unless
2923 Import a list of patches and commit them individually (unless
2925 --no-commit is specified).
2924 --no-commit is specified).
2926
2925
2927 To read a patch from standard input (stdin), use "-" as the patch
2926 To read a patch from standard input (stdin), use "-" as the patch
2928 name. If a URL is specified, the patch will be downloaded from
2927 name. If a URL is specified, the patch will be downloaded from
2929 there.
2928 there.
2930
2929
2931 Import first applies changes to the working directory (unless
2930 Import first applies changes to the working directory (unless
2932 --bypass is specified), import will abort if there are outstanding
2931 --bypass is specified), import will abort if there are outstanding
2933 changes.
2932 changes.
2934
2933
2935 Use --bypass to apply and commit patches directly to the
2934 Use --bypass to apply and commit patches directly to the
2936 repository, without affecting the working directory. Without
2935 repository, without affecting the working directory. Without
2937 --exact, patches will be applied on top of the working directory
2936 --exact, patches will be applied on top of the working directory
2938 parent revision.
2937 parent revision.
2939
2938
2940 You can import a patch straight from a mail message. Even patches
2939 You can import a patch straight from a mail message. Even patches
2941 as attachments work (to use the body part, it must have type
2940 as attachments work (to use the body part, it must have type
2942 text/plain or text/x-patch). From and Subject headers of email
2941 text/plain or text/x-patch). From and Subject headers of email
2943 message are used as default committer and commit message. All
2942 message are used as default committer and commit message. All
2944 text/plain body parts before first diff are added to the commit
2943 text/plain body parts before first diff are added to the commit
2945 message.
2944 message.
2946
2945
2947 If the imported patch was generated by :hg:`export`, user and
2946 If the imported patch was generated by :hg:`export`, user and
2948 description from patch override values from message headers and
2947 description from patch override values from message headers and
2949 body. Values given on command line with -m/--message and -u/--user
2948 body. Values given on command line with -m/--message and -u/--user
2950 override these.
2949 override these.
2951
2950
2952 If --exact is specified, import will set the working directory to
2951 If --exact is specified, import will set the working directory to
2953 the parent of each patch before applying it, and will abort if the
2952 the parent of each patch before applying it, and will abort if the
2954 resulting changeset has a different ID than the one recorded in
2953 resulting changeset has a different ID than the one recorded in
2955 the patch. This will guard against various ways that portable
2954 the patch. This will guard against various ways that portable
2956 patch formats and mail systems might fail to transfer Mercurial
2955 patch formats and mail systems might fail to transfer Mercurial
2957 data or metadata. See :hg:`bundle` for lossless transmission.
2956 data or metadata. See :hg:`bundle` for lossless transmission.
2958
2957
2959 Use --partial to ensure a changeset will be created from the patch
2958 Use --partial to ensure a changeset will be created from the patch
2960 even if some hunks fail to apply. Hunks that fail to apply will be
2959 even if some hunks fail to apply. Hunks that fail to apply will be
2961 written to a <target-file>.rej file. Conflicts can then be resolved
2960 written to a <target-file>.rej file. Conflicts can then be resolved
2962 by hand before :hg:`commit --amend` is run to update the created
2961 by hand before :hg:`commit --amend` is run to update the created
2963 changeset. This flag exists to let people import patches that
2962 changeset. This flag exists to let people import patches that
2964 partially apply without losing the associated metadata (author,
2963 partially apply without losing the associated metadata (author,
2965 date, description, ...).
2964 date, description, ...).
2966
2965
2967 .. note::
2966 .. note::
2968
2967
2969 When no hunks apply cleanly, :hg:`import --partial` will create
2968 When no hunks apply cleanly, :hg:`import --partial` will create
2970 an empty changeset, importing only the patch metadata.
2969 an empty changeset, importing only the patch metadata.
2971
2970
2972 With -s/--similarity, hg will attempt to discover renames and
2971 With -s/--similarity, hg will attempt to discover renames and
2973 copies in the patch in the same way as :hg:`addremove`.
2972 copies in the patch in the same way as :hg:`addremove`.
2974
2973
2975 It is possible to use external patch programs to perform the patch
2974 It is possible to use external patch programs to perform the patch
2976 by setting the ``ui.patch`` configuration option. For the default
2975 by setting the ``ui.patch`` configuration option. For the default
2977 internal tool, the fuzz can also be configured via ``patch.fuzz``.
2976 internal tool, the fuzz can also be configured via ``patch.fuzz``.
2978 See :hg:`help config` for more information about configuration
2977 See :hg:`help config` for more information about configuration
2979 files and how to use these options.
2978 files and how to use these options.
2980
2979
2981 See :hg:`help dates` for a list of formats valid for -d/--date.
2980 See :hg:`help dates` for a list of formats valid for -d/--date.
2982
2981
2983 .. container:: verbose
2982 .. container:: verbose
2984
2983
2985 Examples:
2984 Examples:
2986
2985
2987 - import a traditional patch from a website and detect renames::
2986 - import a traditional patch from a website and detect renames::
2988
2987
2989 hg import -s 80 http://example.com/bugfix.patch
2988 hg import -s 80 http://example.com/bugfix.patch
2990
2989
2991 - import a changeset from an hgweb server::
2990 - import a changeset from an hgweb server::
2992
2991
2993 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
2992 hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
2994
2993
2995 - import all the patches in an Unix-style mbox::
2994 - import all the patches in an Unix-style mbox::
2996
2995
2997 hg import incoming-patches.mbox
2996 hg import incoming-patches.mbox
2998
2997
2999 - import patches from stdin::
2998 - import patches from stdin::
3000
2999
3001 hg import -
3000 hg import -
3002
3001
3003 - attempt to exactly restore an exported changeset (not always
3002 - attempt to exactly restore an exported changeset (not always
3004 possible)::
3003 possible)::
3005
3004
3006 hg import --exact proposed-fix.patch
3005 hg import --exact proposed-fix.patch
3007
3006
3008 - use an external tool to apply a patch which is too fuzzy for
3007 - use an external tool to apply a patch which is too fuzzy for
3009 the default internal tool.
3008 the default internal tool.
3010
3009
3011 hg import --config ui.patch="patch --merge" fuzzy.patch
3010 hg import --config ui.patch="patch --merge" fuzzy.patch
3012
3011
3013 - change the default fuzzing from 2 to a less strict 7
3012 - change the default fuzzing from 2 to a less strict 7
3014
3013
3015 hg import --config ui.fuzz=7 fuzz.patch
3014 hg import --config ui.fuzz=7 fuzz.patch
3016
3015
3017 Returns 0 on success, 1 on partial success (see --partial).
3016 Returns 0 on success, 1 on partial success (see --partial).
3018 """
3017 """
3019
3018
3020 if not patch1:
3019 if not patch1:
3021 raise error.Abort(_('need at least one patch to import'))
3020 raise error.Abort(_('need at least one patch to import'))
3022
3021
3023 patches = (patch1,) + patches
3022 patches = (patch1,) + patches
3024
3023
3025 date = opts.get('date')
3024 date = opts.get('date')
3026 if date:
3025 if date:
3027 opts['date'] = util.parsedate(date)
3026 opts['date'] = util.parsedate(date)
3028
3027
3029 exact = opts.get('exact')
3028 exact = opts.get('exact')
3030 update = not opts.get('bypass')
3029 update = not opts.get('bypass')
3031 if not update and opts.get('no_commit'):
3030 if not update and opts.get('no_commit'):
3032 raise error.Abort(_('cannot use --no-commit with --bypass'))
3031 raise error.Abort(_('cannot use --no-commit with --bypass'))
3033 try:
3032 try:
3034 sim = float(opts.get('similarity') or 0)
3033 sim = float(opts.get('similarity') or 0)
3035 except ValueError:
3034 except ValueError:
3036 raise error.Abort(_('similarity must be a number'))
3035 raise error.Abort(_('similarity must be a number'))
3037 if sim < 0 or sim > 100:
3036 if sim < 0 or sim > 100:
3038 raise error.Abort(_('similarity must be between 0 and 100'))
3037 raise error.Abort(_('similarity must be between 0 and 100'))
3039 if sim and not update:
3038 if sim and not update:
3040 raise error.Abort(_('cannot use --similarity with --bypass'))
3039 raise error.Abort(_('cannot use --similarity with --bypass'))
3041 if exact:
3040 if exact:
3042 if opts.get('edit'):
3041 if opts.get('edit'):
3043 raise error.Abort(_('cannot use --exact with --edit'))
3042 raise error.Abort(_('cannot use --exact with --edit'))
3044 if opts.get('prefix'):
3043 if opts.get('prefix'):
3045 raise error.Abort(_('cannot use --exact with --prefix'))
3044 raise error.Abort(_('cannot use --exact with --prefix'))
3046
3045
3047 base = opts["base"]
3046 base = opts["base"]
3048 wlock = dsguard = lock = tr = None
3047 wlock = dsguard = lock = tr = None
3049 msgs = []
3048 msgs = []
3050 ret = 0
3049 ret = 0
3051
3050
3052
3051
3053 try:
3052 try:
3054 wlock = repo.wlock()
3053 wlock = repo.wlock()
3055
3054
3056 if update:
3055 if update:
3057 cmdutil.checkunfinished(repo)
3056 cmdutil.checkunfinished(repo)
3058 if (exact or not opts.get('force')):
3057 if (exact or not opts.get('force')):
3059 cmdutil.bailifchanged(repo)
3058 cmdutil.bailifchanged(repo)
3060
3059
3061 if not opts.get('no_commit'):
3060 if not opts.get('no_commit'):
3062 lock = repo.lock()
3061 lock = repo.lock()
3063 tr = repo.transaction('import')
3062 tr = repo.transaction('import')
3064 else:
3063 else:
3065 dsguard = dirstateguard.dirstateguard(repo, 'import')
3064 dsguard = dirstateguard.dirstateguard(repo, 'import')
3066 parents = repo[None].parents()
3065 parents = repo[None].parents()
3067 for patchurl in patches:
3066 for patchurl in patches:
3068 if patchurl == '-':
3067 if patchurl == '-':
3069 ui.status(_('applying patch from stdin\n'))
3068 ui.status(_('applying patch from stdin\n'))
3070 patchfile = ui.fin
3069 patchfile = ui.fin
3071 patchurl = 'stdin' # for error message
3070 patchurl = 'stdin' # for error message
3072 else:
3071 else:
3073 patchurl = os.path.join(base, patchurl)
3072 patchurl = os.path.join(base, patchurl)
3074 ui.status(_('applying %s\n') % patchurl)
3073 ui.status(_('applying %s\n') % patchurl)
3075 patchfile = hg.openpath(ui, patchurl)
3074 patchfile = hg.openpath(ui, patchurl)
3076
3075
3077 haspatch = False
3076 haspatch = False
3078 for hunk in patch.split(patchfile):
3077 for hunk in patch.split(patchfile):
3079 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
3078 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
3080 parents, opts,
3079 parents, opts,
3081 msgs, hg.clean)
3080 msgs, hg.clean)
3082 if msg:
3081 if msg:
3083 haspatch = True
3082 haspatch = True
3084 ui.note(msg + '\n')
3083 ui.note(msg + '\n')
3085 if update or exact:
3084 if update or exact:
3086 parents = repo[None].parents()
3085 parents = repo[None].parents()
3087 else:
3086 else:
3088 parents = [repo[node]]
3087 parents = [repo[node]]
3089 if rej:
3088 if rej:
3090 ui.write_err(_("patch applied partially\n"))
3089 ui.write_err(_("patch applied partially\n"))
3091 ui.write_err(_("(fix the .rej files and run "
3090 ui.write_err(_("(fix the .rej files and run "
3092 "`hg commit --amend`)\n"))
3091 "`hg commit --amend`)\n"))
3093 ret = 1
3092 ret = 1
3094 break
3093 break
3095
3094
3096 if not haspatch:
3095 if not haspatch:
3097 raise error.Abort(_('%s: no diffs found') % patchurl)
3096 raise error.Abort(_('%s: no diffs found') % patchurl)
3098
3097
3099 if tr:
3098 if tr:
3100 tr.close()
3099 tr.close()
3101 if msgs:
3100 if msgs:
3102 repo.savecommitmessage('\n* * *\n'.join(msgs))
3101 repo.savecommitmessage('\n* * *\n'.join(msgs))
3103 if dsguard:
3102 if dsguard:
3104 dsguard.close()
3103 dsguard.close()
3105 return ret
3104 return ret
3106 finally:
3105 finally:
3107 if tr:
3106 if tr:
3108 tr.release()
3107 tr.release()
3109 release(lock, dsguard, wlock)
3108 release(lock, dsguard, wlock)
3110
3109
3111 @command('incoming|in',
3110 @command('incoming|in',
3112 [('f', 'force', None,
3111 [('f', 'force', None,
3113 _('run even if remote repository is unrelated')),
3112 _('run even if remote repository is unrelated')),
3114 ('n', 'newest-first', None, _('show newest record first')),
3113 ('n', 'newest-first', None, _('show newest record first')),
3115 ('', 'bundle', '',
3114 ('', 'bundle', '',
3116 _('file to store the bundles into'), _('FILE')),
3115 _('file to store the bundles into'), _('FILE')),
3117 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3116 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3118 ('B', 'bookmarks', False, _("compare bookmarks")),
3117 ('B', 'bookmarks', False, _("compare bookmarks")),
3119 ('b', 'branch', [],
3118 ('b', 'branch', [],
3120 _('a specific branch you would like to pull'), _('BRANCH')),
3119 _('a specific branch you would like to pull'), _('BRANCH')),
3121 ] + logopts + remoteopts + subrepoopts,
3120 ] + logopts + remoteopts + subrepoopts,
3122 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3121 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3123 def incoming(ui, repo, source="default", **opts):
3122 def incoming(ui, repo, source="default", **opts):
3124 """show new changesets found in source
3123 """show new changesets found in source
3125
3124
3126 Show new changesets found in the specified path/URL or the default
3125 Show new changesets found in the specified path/URL or the default
3127 pull location. These are the changesets that would have been pulled
3126 pull location. These are the changesets that would have been pulled
3128 if a pull at the time you issued this command.
3127 if a pull at the time you issued this command.
3129
3128
3130 See pull for valid source format details.
3129 See pull for valid source format details.
3131
3130
3132 .. container:: verbose
3131 .. container:: verbose
3133
3132
3134 With -B/--bookmarks, the result of bookmark comparison between
3133 With -B/--bookmarks, the result of bookmark comparison between
3135 local and remote repositories is displayed. With -v/--verbose,
3134 local and remote repositories is displayed. With -v/--verbose,
3136 status is also displayed for each bookmark like below::
3135 status is also displayed for each bookmark like below::
3137
3136
3138 BM1 01234567890a added
3137 BM1 01234567890a added
3139 BM2 1234567890ab advanced
3138 BM2 1234567890ab advanced
3140 BM3 234567890abc diverged
3139 BM3 234567890abc diverged
3141 BM4 34567890abcd changed
3140 BM4 34567890abcd changed
3142
3141
3143 The action taken locally when pulling depends on the
3142 The action taken locally when pulling depends on the
3144 status of each bookmark:
3143 status of each bookmark:
3145
3144
3146 :``added``: pull will create it
3145 :``added``: pull will create it
3147 :``advanced``: pull will update it
3146 :``advanced``: pull will update it
3148 :``diverged``: pull will create a divergent bookmark
3147 :``diverged``: pull will create a divergent bookmark
3149 :``changed``: result depends on remote changesets
3148 :``changed``: result depends on remote changesets
3150
3149
3151 From the point of view of pulling behavior, bookmark
3150 From the point of view of pulling behavior, bookmark
3152 existing only in the remote repository are treated as ``added``,
3151 existing only in the remote repository are treated as ``added``,
3153 even if it is in fact locally deleted.
3152 even if it is in fact locally deleted.
3154
3153
3155 .. container:: verbose
3154 .. container:: verbose
3156
3155
3157 For remote repository, using --bundle avoids downloading the
3156 For remote repository, using --bundle avoids downloading the
3158 changesets twice if the incoming is followed by a pull.
3157 changesets twice if the incoming is followed by a pull.
3159
3158
3160 Examples:
3159 Examples:
3161
3160
3162 - show incoming changes with patches and full description::
3161 - show incoming changes with patches and full description::
3163
3162
3164 hg incoming -vp
3163 hg incoming -vp
3165
3164
3166 - show incoming changes excluding merges, store a bundle::
3165 - show incoming changes excluding merges, store a bundle::
3167
3166
3168 hg in -vpM --bundle incoming.hg
3167 hg in -vpM --bundle incoming.hg
3169 hg pull incoming.hg
3168 hg pull incoming.hg
3170
3169
3171 - briefly list changes inside a bundle::
3170 - briefly list changes inside a bundle::
3172
3171
3173 hg in changes.hg -T "{desc|firstline}\\n"
3172 hg in changes.hg -T "{desc|firstline}\\n"
3174
3173
3175 Returns 0 if there are incoming changes, 1 otherwise.
3174 Returns 0 if there are incoming changes, 1 otherwise.
3176 """
3175 """
3177 if opts.get('graph'):
3176 if opts.get('graph'):
3178 cmdutil.checkunsupportedgraphflags([], opts)
3177 cmdutil.checkunsupportedgraphflags([], opts)
3179 def display(other, chlist, displayer):
3178 def display(other, chlist, displayer):
3180 revdag = cmdutil.graphrevs(other, chlist, opts)
3179 revdag = cmdutil.graphrevs(other, chlist, opts)
3181 cmdutil.displaygraph(ui, repo, revdag, displayer,
3180 cmdutil.displaygraph(ui, repo, revdag, displayer,
3182 graphmod.asciiedges)
3181 graphmod.asciiedges)
3183
3182
3184 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3183 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3185 return 0
3184 return 0
3186
3185
3187 if opts.get('bundle') and opts.get('subrepos'):
3186 if opts.get('bundle') and opts.get('subrepos'):
3188 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3187 raise error.Abort(_('cannot combine --bundle and --subrepos'))
3189
3188
3190 if opts.get('bookmarks'):
3189 if opts.get('bookmarks'):
3191 source, branches = hg.parseurl(ui.expandpath(source),
3190 source, branches = hg.parseurl(ui.expandpath(source),
3192 opts.get('branch'))
3191 opts.get('branch'))
3193 other = hg.peer(repo, opts, source)
3192 other = hg.peer(repo, opts, source)
3194 if 'bookmarks' not in other.listkeys('namespaces'):
3193 if 'bookmarks' not in other.listkeys('namespaces'):
3195 ui.warn(_("remote doesn't support bookmarks\n"))
3194 ui.warn(_("remote doesn't support bookmarks\n"))
3196 return 0
3195 return 0
3197 ui.pager('incoming')
3196 ui.pager('incoming')
3198 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3197 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3199 return bookmarks.incoming(ui, repo, other)
3198 return bookmarks.incoming(ui, repo, other)
3200
3199
3201 repo._subtoppath = ui.expandpath(source)
3200 repo._subtoppath = ui.expandpath(source)
3202 try:
3201 try:
3203 return hg.incoming(ui, repo, source, opts)
3202 return hg.incoming(ui, repo, source, opts)
3204 finally:
3203 finally:
3205 del repo._subtoppath
3204 del repo._subtoppath
3206
3205
3207
3206
3208 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3207 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
3209 norepo=True)
3208 norepo=True)
3210 def init(ui, dest=".", **opts):
3209 def init(ui, dest=".", **opts):
3211 """create a new repository in the given directory
3210 """create a new repository in the given directory
3212
3211
3213 Initialize a new repository in the given directory. If the given
3212 Initialize a new repository in the given directory. If the given
3214 directory does not exist, it will be created.
3213 directory does not exist, it will be created.
3215
3214
3216 If no directory is given, the current directory is used.
3215 If no directory is given, the current directory is used.
3217
3216
3218 It is possible to specify an ``ssh://`` URL as the destination.
3217 It is possible to specify an ``ssh://`` URL as the destination.
3219 See :hg:`help urls` for more information.
3218 See :hg:`help urls` for more information.
3220
3219
3221 Returns 0 on success.
3220 Returns 0 on success.
3222 """
3221 """
3223 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3222 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3224
3223
3225 @command('locate',
3224 @command('locate',
3226 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3225 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3227 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3226 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3228 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3227 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3229 ] + walkopts,
3228 ] + walkopts,
3230 _('[OPTION]... [PATTERN]...'))
3229 _('[OPTION]... [PATTERN]...'))
3231 def locate(ui, repo, *pats, **opts):
3230 def locate(ui, repo, *pats, **opts):
3232 """locate files matching specific patterns (DEPRECATED)
3231 """locate files matching specific patterns (DEPRECATED)
3233
3232
3234 Print files under Mercurial control in the working directory whose
3233 Print files under Mercurial control in the working directory whose
3235 names match the given patterns.
3234 names match the given patterns.
3236
3235
3237 By default, this command searches all directories in the working
3236 By default, this command searches all directories in the working
3238 directory. To search just the current directory and its
3237 directory. To search just the current directory and its
3239 subdirectories, use "--include .".
3238 subdirectories, use "--include .".
3240
3239
3241 If no patterns are given to match, this command prints the names
3240 If no patterns are given to match, this command prints the names
3242 of all files under Mercurial control in the working directory.
3241 of all files under Mercurial control in the working directory.
3243
3242
3244 If you want to feed the output of this command into the "xargs"
3243 If you want to feed the output of this command into the "xargs"
3245 command, use the -0 option to both this command and "xargs". This
3244 command, use the -0 option to both this command and "xargs". This
3246 will avoid the problem of "xargs" treating single filenames that
3245 will avoid the problem of "xargs" treating single filenames that
3247 contain whitespace as multiple filenames.
3246 contain whitespace as multiple filenames.
3248
3247
3249 See :hg:`help files` for a more versatile command.
3248 See :hg:`help files` for a more versatile command.
3250
3249
3251 Returns 0 if a match is found, 1 otherwise.
3250 Returns 0 if a match is found, 1 otherwise.
3252 """
3251 """
3253 if opts.get('print0'):
3252 if opts.get('print0'):
3254 end = '\0'
3253 end = '\0'
3255 else:
3254 else:
3256 end = '\n'
3255 end = '\n'
3257 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3256 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3258
3257
3259 ret = 1
3258 ret = 1
3260 ctx = repo[rev]
3259 ctx = repo[rev]
3261 m = scmutil.match(ctx, pats, opts, default='relglob',
3260 m = scmutil.match(ctx, pats, opts, default='relglob',
3262 badfn=lambda x, y: False)
3261 badfn=lambda x, y: False)
3263
3262
3264 ui.pager('locate')
3263 ui.pager('locate')
3265 for abs in ctx.matches(m):
3264 for abs in ctx.matches(m):
3266 if opts.get('fullpath'):
3265 if opts.get('fullpath'):
3267 ui.write(repo.wjoin(abs), end)
3266 ui.write(repo.wjoin(abs), end)
3268 else:
3267 else:
3269 ui.write(((pats and m.rel(abs)) or abs), end)
3268 ui.write(((pats and m.rel(abs)) or abs), end)
3270 ret = 0
3269 ret = 0
3271
3270
3272 return ret
3271 return ret
3273
3272
3274 @command('^log|history',
3273 @command('^log|history',
3275 [('f', 'follow', None,
3274 [('f', 'follow', None,
3276 _('follow changeset history, or file history across copies and renames')),
3275 _('follow changeset history, or file history across copies and renames')),
3277 ('', 'follow-first', None,
3276 ('', 'follow-first', None,
3278 _('only follow the first parent of merge changesets (DEPRECATED)')),
3277 _('only follow the first parent of merge changesets (DEPRECATED)')),
3279 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3278 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3280 ('C', 'copies', None, _('show copied files')),
3279 ('C', 'copies', None, _('show copied files')),
3281 ('k', 'keyword', [],
3280 ('k', 'keyword', [],
3282 _('do case-insensitive search for a given text'), _('TEXT')),
3281 _('do case-insensitive search for a given text'), _('TEXT')),
3283 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3282 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
3284 ('', 'removed', None, _('include revisions where files were removed')),
3283 ('', 'removed', None, _('include revisions where files were removed')),
3285 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3284 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3286 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3285 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3287 ('', 'only-branch', [],
3286 ('', 'only-branch', [],
3288 _('show only changesets within the given named branch (DEPRECATED)'),
3287 _('show only changesets within the given named branch (DEPRECATED)'),
3289 _('BRANCH')),
3288 _('BRANCH')),
3290 ('b', 'branch', [],
3289 ('b', 'branch', [],
3291 _('show changesets within the given named branch'), _('BRANCH')),
3290 _('show changesets within the given named branch'), _('BRANCH')),
3292 ('P', 'prune', [],
3291 ('P', 'prune', [],
3293 _('do not display revision or any of its ancestors'), _('REV')),
3292 _('do not display revision or any of its ancestors'), _('REV')),
3294 ] + logopts + walkopts,
3293 ] + logopts + walkopts,
3295 _('[OPTION]... [FILE]'),
3294 _('[OPTION]... [FILE]'),
3296 inferrepo=True)
3295 inferrepo=True)
3297 def log(ui, repo, *pats, **opts):
3296 def log(ui, repo, *pats, **opts):
3298 """show revision history of entire repository or files
3297 """show revision history of entire repository or files
3299
3298
3300 Print the revision history of the specified files or the entire
3299 Print the revision history of the specified files or the entire
3301 project.
3300 project.
3302
3301
3303 If no revision range is specified, the default is ``tip:0`` unless
3302 If no revision range is specified, the default is ``tip:0`` unless
3304 --follow is set, in which case the working directory parent is
3303 --follow is set, in which case the working directory parent is
3305 used as the starting revision.
3304 used as the starting revision.
3306
3305
3307 File history is shown without following rename or copy history of
3306 File history is shown without following rename or copy history of
3308 files. Use -f/--follow with a filename to follow history across
3307 files. Use -f/--follow with a filename to follow history across
3309 renames and copies. --follow without a filename will only show
3308 renames and copies. --follow without a filename will only show
3310 ancestors or descendants of the starting revision.
3309 ancestors or descendants of the starting revision.
3311
3310
3312 By default this command prints revision number and changeset id,
3311 By default this command prints revision number and changeset id,
3313 tags, non-trivial parents, user, date and time, and a summary for
3312 tags, non-trivial parents, user, date and time, and a summary for
3314 each commit. When the -v/--verbose switch is used, the list of
3313 each commit. When the -v/--verbose switch is used, the list of
3315 changed files and full commit message are shown.
3314 changed files and full commit message are shown.
3316
3315
3317 With --graph the revisions are shown as an ASCII art DAG with the most
3316 With --graph the revisions are shown as an ASCII art DAG with the most
3318 recent changeset at the top.
3317 recent changeset at the top.
3319 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
3318 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
3320 and '+' represents a fork where the changeset from the lines below is a
3319 and '+' represents a fork where the changeset from the lines below is a
3321 parent of the 'o' merge on the same line.
3320 parent of the 'o' merge on the same line.
3322
3321
3323 .. note::
3322 .. note::
3324
3323
3325 :hg:`log --patch` may generate unexpected diff output for merge
3324 :hg:`log --patch` may generate unexpected diff output for merge
3326 changesets, as it will only compare the merge changeset against
3325 changesets, as it will only compare the merge changeset against
3327 its first parent. Also, only files different from BOTH parents
3326 its first parent. Also, only files different from BOTH parents
3328 will appear in files:.
3327 will appear in files:.
3329
3328
3330 .. note::
3329 .. note::
3331
3330
3332 For performance reasons, :hg:`log FILE` may omit duplicate changes
3331 For performance reasons, :hg:`log FILE` may omit duplicate changes
3333 made on branches and will not show removals or mode changes. To
3332 made on branches and will not show removals or mode changes. To
3334 see all such changes, use the --removed switch.
3333 see all such changes, use the --removed switch.
3335
3334
3336 .. container:: verbose
3335 .. container:: verbose
3337
3336
3338 Some examples:
3337 Some examples:
3339
3338
3340 - changesets with full descriptions and file lists::
3339 - changesets with full descriptions and file lists::
3341
3340
3342 hg log -v
3341 hg log -v
3343
3342
3344 - changesets ancestral to the working directory::
3343 - changesets ancestral to the working directory::
3345
3344
3346 hg log -f
3345 hg log -f
3347
3346
3348 - last 10 commits on the current branch::
3347 - last 10 commits on the current branch::
3349
3348
3350 hg log -l 10 -b .
3349 hg log -l 10 -b .
3351
3350
3352 - changesets showing all modifications of a file, including removals::
3351 - changesets showing all modifications of a file, including removals::
3353
3352
3354 hg log --removed file.c
3353 hg log --removed file.c
3355
3354
3356 - all changesets that touch a directory, with diffs, excluding merges::
3355 - all changesets that touch a directory, with diffs, excluding merges::
3357
3356
3358 hg log -Mp lib/
3357 hg log -Mp lib/
3359
3358
3360 - all revision numbers that match a keyword::
3359 - all revision numbers that match a keyword::
3361
3360
3362 hg log -k bug --template "{rev}\\n"
3361 hg log -k bug --template "{rev}\\n"
3363
3362
3364 - the full hash identifier of the working directory parent::
3363 - the full hash identifier of the working directory parent::
3365
3364
3366 hg log -r . --template "{node}\\n"
3365 hg log -r . --template "{node}\\n"
3367
3366
3368 - list available log templates::
3367 - list available log templates::
3369
3368
3370 hg log -T list
3369 hg log -T list
3371
3370
3372 - check if a given changeset is included in a tagged release::
3371 - check if a given changeset is included in a tagged release::
3373
3372
3374 hg log -r "a21ccf and ancestor(1.9)"
3373 hg log -r "a21ccf and ancestor(1.9)"
3375
3374
3376 - find all changesets by some user in a date range::
3375 - find all changesets by some user in a date range::
3377
3376
3378 hg log -k alice -d "may 2008 to jul 2008"
3377 hg log -k alice -d "may 2008 to jul 2008"
3379
3378
3380 - summary of all changesets after the last tag::
3379 - summary of all changesets after the last tag::
3381
3380
3382 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3381 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
3383
3382
3384 See :hg:`help dates` for a list of formats valid for -d/--date.
3383 See :hg:`help dates` for a list of formats valid for -d/--date.
3385
3384
3386 See :hg:`help revisions` for more about specifying and ordering
3385 See :hg:`help revisions` for more about specifying and ordering
3387 revisions.
3386 revisions.
3388
3387
3389 See :hg:`help templates` for more about pre-packaged styles and
3388 See :hg:`help templates` for more about pre-packaged styles and
3390 specifying custom templates.
3389 specifying custom templates.
3391
3390
3392 Returns 0 on success.
3391 Returns 0 on success.
3393
3392
3394 """
3393 """
3395 if opts.get('follow') and opts.get('rev'):
3394 if opts.get('follow') and opts.get('rev'):
3396 opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', opts.get('rev'))]
3395 opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', opts.get('rev'))]
3397 del opts['follow']
3396 del opts['follow']
3398
3397
3399 if opts.get('graph'):
3398 if opts.get('graph'):
3400 return cmdutil.graphlog(ui, repo, *pats, **opts)
3399 return cmdutil.graphlog(ui, repo, *pats, **opts)
3401
3400
3402 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
3401 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
3403 limit = cmdutil.loglimit(opts)
3402 limit = cmdutil.loglimit(opts)
3404 count = 0
3403 count = 0
3405
3404
3406 getrenamed = None
3405 getrenamed = None
3407 if opts.get('copies'):
3406 if opts.get('copies'):
3408 endrev = None
3407 endrev = None
3409 if opts.get('rev'):
3408 if opts.get('rev'):
3410 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
3409 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
3411 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3410 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
3412
3411
3413 ui.pager('log')
3412 ui.pager('log')
3414 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3413 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3415 for rev in revs:
3414 for rev in revs:
3416 if count == limit:
3415 if count == limit:
3417 break
3416 break
3418 ctx = repo[rev]
3417 ctx = repo[rev]
3419 copies = None
3418 copies = None
3420 if getrenamed is not None and rev:
3419 if getrenamed is not None and rev:
3421 copies = []
3420 copies = []
3422 for fn in ctx.files():
3421 for fn in ctx.files():
3423 rename = getrenamed(fn, rev)
3422 rename = getrenamed(fn, rev)
3424 if rename:
3423 if rename:
3425 copies.append((fn, rename[0]))
3424 copies.append((fn, rename[0]))
3426 if filematcher:
3425 if filematcher:
3427 revmatchfn = filematcher(ctx.rev())
3426 revmatchfn = filematcher(ctx.rev())
3428 else:
3427 else:
3429 revmatchfn = None
3428 revmatchfn = None
3430 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
3429 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
3431 if displayer.flush(ctx):
3430 if displayer.flush(ctx):
3432 count += 1
3431 count += 1
3433
3432
3434 displayer.close()
3433 displayer.close()
3435
3434
3436 @command('manifest',
3435 @command('manifest',
3437 [('r', 'rev', '', _('revision to display'), _('REV')),
3436 [('r', 'rev', '', _('revision to display'), _('REV')),
3438 ('', 'all', False, _("list files from all revisions"))]
3437 ('', 'all', False, _("list files from all revisions"))]
3439 + formatteropts,
3438 + formatteropts,
3440 _('[-r REV]'))
3439 _('[-r REV]'))
3441 def manifest(ui, repo, node=None, rev=None, **opts):
3440 def manifest(ui, repo, node=None, rev=None, **opts):
3442 """output the current or given revision of the project manifest
3441 """output the current or given revision of the project manifest
3443
3442
3444 Print a list of version controlled files for the given revision.
3443 Print a list of version controlled files for the given revision.
3445 If no revision is given, the first parent of the working directory
3444 If no revision is given, the first parent of the working directory
3446 is used, or the null revision if no revision is checked out.
3445 is used, or the null revision if no revision is checked out.
3447
3446
3448 With -v, print file permissions, symlink and executable bits.
3447 With -v, print file permissions, symlink and executable bits.
3449 With --debug, print file revision hashes.
3448 With --debug, print file revision hashes.
3450
3449
3451 If option --all is specified, the list of all files from all revisions
3450 If option --all is specified, the list of all files from all revisions
3452 is printed. This includes deleted and renamed files.
3451 is printed. This includes deleted and renamed files.
3453
3452
3454 Returns 0 on success.
3453 Returns 0 on success.
3455 """
3454 """
3456 fm = ui.formatter('manifest', opts)
3455 fm = ui.formatter('manifest', opts)
3457
3456
3458 if opts.get('all'):
3457 if opts.get('all'):
3459 if rev or node:
3458 if rev or node:
3460 raise error.Abort(_("can't specify a revision with --all"))
3459 raise error.Abort(_("can't specify a revision with --all"))
3461
3460
3462 res = []
3461 res = []
3463 prefix = "data/"
3462 prefix = "data/"
3464 suffix = ".i"
3463 suffix = ".i"
3465 plen = len(prefix)
3464 plen = len(prefix)
3466 slen = len(suffix)
3465 slen = len(suffix)
3467 with repo.lock():
3466 with repo.lock():
3468 for fn, b, size in repo.store.datafiles():
3467 for fn, b, size in repo.store.datafiles():
3469 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
3468 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
3470 res.append(fn[plen:-slen])
3469 res.append(fn[plen:-slen])
3471 ui.pager('manifest')
3470 ui.pager('manifest')
3472 for f in res:
3471 for f in res:
3473 fm.startitem()
3472 fm.startitem()
3474 fm.write("path", '%s\n', f)
3473 fm.write("path", '%s\n', f)
3475 fm.end()
3474 fm.end()
3476 return
3475 return
3477
3476
3478 if rev and node:
3477 if rev and node:
3479 raise error.Abort(_("please specify just one revision"))
3478 raise error.Abort(_("please specify just one revision"))
3480
3479
3481 if not node:
3480 if not node:
3482 node = rev
3481 node = rev
3483
3482
3484 char = {'l': '@', 'x': '*', '': ''}
3483 char = {'l': '@', 'x': '*', '': ''}
3485 mode = {'l': '644', 'x': '755', '': '644'}
3484 mode = {'l': '644', 'x': '755', '': '644'}
3486 ctx = scmutil.revsingle(repo, node)
3485 ctx = scmutil.revsingle(repo, node)
3487 mf = ctx.manifest()
3486 mf = ctx.manifest()
3488 ui.pager('manifest')
3487 ui.pager('manifest')
3489 for f in ctx:
3488 for f in ctx:
3490 fm.startitem()
3489 fm.startitem()
3491 fl = ctx[f].flags()
3490 fl = ctx[f].flags()
3492 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3491 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
3493 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3492 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
3494 fm.write('path', '%s\n', f)
3493 fm.write('path', '%s\n', f)
3495 fm.end()
3494 fm.end()
3496
3495
3497 @command('^merge',
3496 @command('^merge',
3498 [('f', 'force', None,
3497 [('f', 'force', None,
3499 _('force a merge including outstanding changes (DEPRECATED)')),
3498 _('force a merge including outstanding changes (DEPRECATED)')),
3500 ('r', 'rev', '', _('revision to merge'), _('REV')),
3499 ('r', 'rev', '', _('revision to merge'), _('REV')),
3501 ('P', 'preview', None,
3500 ('P', 'preview', None,
3502 _('review revisions to merge (no merge is performed)'))
3501 _('review revisions to merge (no merge is performed)'))
3503 ] + mergetoolopts,
3502 ] + mergetoolopts,
3504 _('[-P] [[-r] REV]'))
3503 _('[-P] [[-r] REV]'))
3505 def merge(ui, repo, node=None, **opts):
3504 def merge(ui, repo, node=None, **opts):
3506 """merge another revision into working directory
3505 """merge another revision into working directory
3507
3506
3508 The current working directory is updated with all changes made in
3507 The current working directory is updated with all changes made in
3509 the requested revision since the last common predecessor revision.
3508 the requested revision since the last common predecessor revision.
3510
3509
3511 Files that changed between either parent are marked as changed for
3510 Files that changed between either parent are marked as changed for
3512 the next commit and a commit must be performed before any further
3511 the next commit and a commit must be performed before any further
3513 updates to the repository are allowed. The next commit will have
3512 updates to the repository are allowed. The next commit will have
3514 two parents.
3513 two parents.
3515
3514
3516 ``--tool`` can be used to specify the merge tool used for file
3515 ``--tool`` can be used to specify the merge tool used for file
3517 merges. It overrides the HGMERGE environment variable and your
3516 merges. It overrides the HGMERGE environment variable and your
3518 configuration files. See :hg:`help merge-tools` for options.
3517 configuration files. See :hg:`help merge-tools` for options.
3519
3518
3520 If no revision is specified, the working directory's parent is a
3519 If no revision is specified, the working directory's parent is a
3521 head revision, and the current branch contains exactly one other
3520 head revision, and the current branch contains exactly one other
3522 head, the other head is merged with by default. Otherwise, an
3521 head, the other head is merged with by default. Otherwise, an
3523 explicit revision with which to merge with must be provided.
3522 explicit revision with which to merge with must be provided.
3524
3523
3525 See :hg:`help resolve` for information on handling file conflicts.
3524 See :hg:`help resolve` for information on handling file conflicts.
3526
3525
3527 To undo an uncommitted merge, use :hg:`update --clean .` which
3526 To undo an uncommitted merge, use :hg:`update --clean .` which
3528 will check out a clean copy of the original merge parent, losing
3527 will check out a clean copy of the original merge parent, losing
3529 all changes.
3528 all changes.
3530
3529
3531 Returns 0 on success, 1 if there are unresolved files.
3530 Returns 0 on success, 1 if there are unresolved files.
3532 """
3531 """
3533
3532
3534 if opts.get('rev') and node:
3533 if opts.get('rev') and node:
3535 raise error.Abort(_("please specify just one revision"))
3534 raise error.Abort(_("please specify just one revision"))
3536 if not node:
3535 if not node:
3537 node = opts.get('rev')
3536 node = opts.get('rev')
3538
3537
3539 if node:
3538 if node:
3540 node = scmutil.revsingle(repo, node).node()
3539 node = scmutil.revsingle(repo, node).node()
3541
3540
3542 if not node:
3541 if not node:
3543 node = repo[destutil.destmerge(repo)].node()
3542 node = repo[destutil.destmerge(repo)].node()
3544
3543
3545 if opts.get('preview'):
3544 if opts.get('preview'):
3546 # find nodes that are ancestors of p2 but not of p1
3545 # find nodes that are ancestors of p2 but not of p1
3547 p1 = repo.lookup('.')
3546 p1 = repo.lookup('.')
3548 p2 = repo.lookup(node)
3547 p2 = repo.lookup(node)
3549 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3548 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
3550
3549
3551 displayer = cmdutil.show_changeset(ui, repo, opts)
3550 displayer = cmdutil.show_changeset(ui, repo, opts)
3552 for node in nodes:
3551 for node in nodes:
3553 displayer.show(repo[node])
3552 displayer.show(repo[node])
3554 displayer.close()
3553 displayer.close()
3555 return 0
3554 return 0
3556
3555
3557 try:
3556 try:
3558 # ui.forcemerge is an internal variable, do not document
3557 # ui.forcemerge is an internal variable, do not document
3559 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3558 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
3560 force = opts.get('force')
3559 force = opts.get('force')
3561 labels = ['working copy', 'merge rev']
3560 labels = ['working copy', 'merge rev']
3562 return hg.merge(repo, node, force=force, mergeforce=force,
3561 return hg.merge(repo, node, force=force, mergeforce=force,
3563 labels=labels)
3562 labels=labels)
3564 finally:
3563 finally:
3565 ui.setconfig('ui', 'forcemerge', '', 'merge')
3564 ui.setconfig('ui', 'forcemerge', '', 'merge')
3566
3565
3567 @command('outgoing|out',
3566 @command('outgoing|out',
3568 [('f', 'force', None, _('run even when the destination is unrelated')),
3567 [('f', 'force', None, _('run even when the destination is unrelated')),
3569 ('r', 'rev', [],
3568 ('r', 'rev', [],
3570 _('a changeset intended to be included in the destination'), _('REV')),
3569 _('a changeset intended to be included in the destination'), _('REV')),
3571 ('n', 'newest-first', None, _('show newest record first')),
3570 ('n', 'newest-first', None, _('show newest record first')),
3572 ('B', 'bookmarks', False, _('compare bookmarks')),
3571 ('B', 'bookmarks', False, _('compare bookmarks')),
3573 ('b', 'branch', [], _('a specific branch you would like to push'),
3572 ('b', 'branch', [], _('a specific branch you would like to push'),
3574 _('BRANCH')),
3573 _('BRANCH')),
3575 ] + logopts + remoteopts + subrepoopts,
3574 ] + logopts + remoteopts + subrepoopts,
3576 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3575 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
3577 def outgoing(ui, repo, dest=None, **opts):
3576 def outgoing(ui, repo, dest=None, **opts):
3578 """show changesets not found in the destination
3577 """show changesets not found in the destination
3579
3578
3580 Show changesets not found in the specified destination repository
3579 Show changesets not found in the specified destination repository
3581 or the default push location. These are the changesets that would
3580 or the default push location. These are the changesets that would
3582 be pushed if a push was requested.
3581 be pushed if a push was requested.
3583
3582
3584 See pull for details of valid destination formats.
3583 See pull for details of valid destination formats.
3585
3584
3586 .. container:: verbose
3585 .. container:: verbose
3587
3586
3588 With -B/--bookmarks, the result of bookmark comparison between
3587 With -B/--bookmarks, the result of bookmark comparison between
3589 local and remote repositories is displayed. With -v/--verbose,
3588 local and remote repositories is displayed. With -v/--verbose,
3590 status is also displayed for each bookmark like below::
3589 status is also displayed for each bookmark like below::
3591
3590
3592 BM1 01234567890a added
3591 BM1 01234567890a added
3593 BM2 deleted
3592 BM2 deleted
3594 BM3 234567890abc advanced
3593 BM3 234567890abc advanced
3595 BM4 34567890abcd diverged
3594 BM4 34567890abcd diverged
3596 BM5 4567890abcde changed
3595 BM5 4567890abcde changed
3597
3596
3598 The action taken when pushing depends on the
3597 The action taken when pushing depends on the
3599 status of each bookmark:
3598 status of each bookmark:
3600
3599
3601 :``added``: push with ``-B`` will create it
3600 :``added``: push with ``-B`` will create it
3602 :``deleted``: push with ``-B`` will delete it
3601 :``deleted``: push with ``-B`` will delete it
3603 :``advanced``: push will update it
3602 :``advanced``: push will update it
3604 :``diverged``: push with ``-B`` will update it
3603 :``diverged``: push with ``-B`` will update it
3605 :``changed``: push with ``-B`` will update it
3604 :``changed``: push with ``-B`` will update it
3606
3605
3607 From the point of view of pushing behavior, bookmarks
3606 From the point of view of pushing behavior, bookmarks
3608 existing only in the remote repository are treated as
3607 existing only in the remote repository are treated as
3609 ``deleted``, even if it is in fact added remotely.
3608 ``deleted``, even if it is in fact added remotely.
3610
3609
3611 Returns 0 if there are outgoing changes, 1 otherwise.
3610 Returns 0 if there are outgoing changes, 1 otherwise.
3612 """
3611 """
3613 if opts.get('graph'):
3612 if opts.get('graph'):
3614 cmdutil.checkunsupportedgraphflags([], opts)
3613 cmdutil.checkunsupportedgraphflags([], opts)
3615 o, other = hg._outgoing(ui, repo, dest, opts)
3614 o, other = hg._outgoing(ui, repo, dest, opts)
3616 if not o:
3615 if not o:
3617 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3616 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3618 return
3617 return
3619
3618
3620 revdag = cmdutil.graphrevs(repo, o, opts)
3619 revdag = cmdutil.graphrevs(repo, o, opts)
3621 ui.pager('outgoing')
3620 ui.pager('outgoing')
3622 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3621 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
3623 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
3622 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
3624 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3623 cmdutil.outgoinghooks(ui, repo, other, opts, o)
3625 return 0
3624 return 0
3626
3625
3627 if opts.get('bookmarks'):
3626 if opts.get('bookmarks'):
3628 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3627 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3629 dest, branches = hg.parseurl(dest, opts.get('branch'))
3628 dest, branches = hg.parseurl(dest, opts.get('branch'))
3630 other = hg.peer(repo, opts, dest)
3629 other = hg.peer(repo, opts, dest)
3631 if 'bookmarks' not in other.listkeys('namespaces'):
3630 if 'bookmarks' not in other.listkeys('namespaces'):
3632 ui.warn(_("remote doesn't support bookmarks\n"))
3631 ui.warn(_("remote doesn't support bookmarks\n"))
3633 return 0
3632 return 0
3634 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3633 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
3635 ui.pager('outgoing')
3634 ui.pager('outgoing')
3636 return bookmarks.outgoing(ui, repo, other)
3635 return bookmarks.outgoing(ui, repo, other)
3637
3636
3638 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3637 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
3639 try:
3638 try:
3640 return hg.outgoing(ui, repo, dest, opts)
3639 return hg.outgoing(ui, repo, dest, opts)
3641 finally:
3640 finally:
3642 del repo._subtoppath
3641 del repo._subtoppath
3643
3642
3644 @command('parents',
3643 @command('parents',
3645 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3644 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
3646 ] + templateopts,
3645 ] + templateopts,
3647 _('[-r REV] [FILE]'),
3646 _('[-r REV] [FILE]'),
3648 inferrepo=True)
3647 inferrepo=True)
3649 def parents(ui, repo, file_=None, **opts):
3648 def parents(ui, repo, file_=None, **opts):
3650 """show the parents of the working directory or revision (DEPRECATED)
3649 """show the parents of the working directory or revision (DEPRECATED)
3651
3650
3652 Print the working directory's parent revisions. If a revision is
3651 Print the working directory's parent revisions. If a revision is
3653 given via -r/--rev, the parent of that revision will be printed.
3652 given via -r/--rev, the parent of that revision will be printed.
3654 If a file argument is given, the revision in which the file was
3653 If a file argument is given, the revision in which the file was
3655 last changed (before the working directory revision or the
3654 last changed (before the working directory revision or the
3656 argument to --rev if given) is printed.
3655 argument to --rev if given) is printed.
3657
3656
3658 This command is equivalent to::
3657 This command is equivalent to::
3659
3658
3660 hg log -r "p1()+p2()" or
3659 hg log -r "p1()+p2()" or
3661 hg log -r "p1(REV)+p2(REV)" or
3660 hg log -r "p1(REV)+p2(REV)" or
3662 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3661 hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or
3663 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3662 hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))"
3664
3663
3665 See :hg:`summary` and :hg:`help revsets` for related information.
3664 See :hg:`summary` and :hg:`help revsets` for related information.
3666
3665
3667 Returns 0 on success.
3666 Returns 0 on success.
3668 """
3667 """
3669
3668
3670 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3669 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3671
3670
3672 if file_:
3671 if file_:
3673 m = scmutil.match(ctx, (file_,), opts)
3672 m = scmutil.match(ctx, (file_,), opts)
3674 if m.anypats() or len(m.files()) != 1:
3673 if m.anypats() or len(m.files()) != 1:
3675 raise error.Abort(_('can only specify an explicit filename'))
3674 raise error.Abort(_('can only specify an explicit filename'))
3676 file_ = m.files()[0]
3675 file_ = m.files()[0]
3677 filenodes = []
3676 filenodes = []
3678 for cp in ctx.parents():
3677 for cp in ctx.parents():
3679 if not cp:
3678 if not cp:
3680 continue
3679 continue
3681 try:
3680 try:
3682 filenodes.append(cp.filenode(file_))
3681 filenodes.append(cp.filenode(file_))
3683 except error.LookupError:
3682 except error.LookupError:
3684 pass
3683 pass
3685 if not filenodes:
3684 if not filenodes:
3686 raise error.Abort(_("'%s' not found in manifest!") % file_)
3685 raise error.Abort(_("'%s' not found in manifest!") % file_)
3687 p = []
3686 p = []
3688 for fn in filenodes:
3687 for fn in filenodes:
3689 fctx = repo.filectx(file_, fileid=fn)
3688 fctx = repo.filectx(file_, fileid=fn)
3690 p.append(fctx.node())
3689 p.append(fctx.node())
3691 else:
3690 else:
3692 p = [cp.node() for cp in ctx.parents()]
3691 p = [cp.node() for cp in ctx.parents()]
3693
3692
3694 displayer = cmdutil.show_changeset(ui, repo, opts)
3693 displayer = cmdutil.show_changeset(ui, repo, opts)
3695 for n in p:
3694 for n in p:
3696 if n != nullid:
3695 if n != nullid:
3697 displayer.show(repo[n])
3696 displayer.show(repo[n])
3698 displayer.close()
3697 displayer.close()
3699
3698
3700 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True)
3699 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True)
3701 def paths(ui, repo, search=None, **opts):
3700 def paths(ui, repo, search=None, **opts):
3702 """show aliases for remote repositories
3701 """show aliases for remote repositories
3703
3702
3704 Show definition of symbolic path name NAME. If no name is given,
3703 Show definition of symbolic path name NAME. If no name is given,
3705 show definition of all available names.
3704 show definition of all available names.
3706
3705
3707 Option -q/--quiet suppresses all output when searching for NAME
3706 Option -q/--quiet suppresses all output when searching for NAME
3708 and shows only the path names when listing all definitions.
3707 and shows only the path names when listing all definitions.
3709
3708
3710 Path names are defined in the [paths] section of your
3709 Path names are defined in the [paths] section of your
3711 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3710 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
3712 repository, ``.hg/hgrc`` is used, too.
3711 repository, ``.hg/hgrc`` is used, too.
3713
3712
3714 The path names ``default`` and ``default-push`` have a special
3713 The path names ``default`` and ``default-push`` have a special
3715 meaning. When performing a push or pull operation, they are used
3714 meaning. When performing a push or pull operation, they are used
3716 as fallbacks if no location is specified on the command-line.
3715 as fallbacks if no location is specified on the command-line.
3717 When ``default-push`` is set, it will be used for push and
3716 When ``default-push`` is set, it will be used for push and
3718 ``default`` will be used for pull; otherwise ``default`` is used
3717 ``default`` will be used for pull; otherwise ``default`` is used
3719 as the fallback for both. When cloning a repository, the clone
3718 as the fallback for both. When cloning a repository, the clone
3720 source is written as ``default`` in ``.hg/hgrc``.
3719 source is written as ``default`` in ``.hg/hgrc``.
3721
3720
3722 .. note::
3721 .. note::
3723
3722
3724 ``default`` and ``default-push`` apply to all inbound (e.g.
3723 ``default`` and ``default-push`` apply to all inbound (e.g.
3725 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3724 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email`
3726 and :hg:`bundle`) operations.
3725 and :hg:`bundle`) operations.
3727
3726
3728 See :hg:`help urls` for more information.
3727 See :hg:`help urls` for more information.
3729
3728
3730 Returns 0 on success.
3729 Returns 0 on success.
3731 """
3730 """
3732 ui.pager('paths')
3731 ui.pager('paths')
3733 if search:
3732 if search:
3734 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3733 pathitems = [(name, path) for name, path in ui.paths.iteritems()
3735 if name == search]
3734 if name == search]
3736 else:
3735 else:
3737 pathitems = sorted(ui.paths.iteritems())
3736 pathitems = sorted(ui.paths.iteritems())
3738
3737
3739 fm = ui.formatter('paths', opts)
3738 fm = ui.formatter('paths', opts)
3740 if fm.isplain():
3739 if fm.isplain():
3741 hidepassword = util.hidepassword
3740 hidepassword = util.hidepassword
3742 else:
3741 else:
3743 hidepassword = str
3742 hidepassword = str
3744 if ui.quiet:
3743 if ui.quiet:
3745 namefmt = '%s\n'
3744 namefmt = '%s\n'
3746 else:
3745 else:
3747 namefmt = '%s = '
3746 namefmt = '%s = '
3748 showsubopts = not search and not ui.quiet
3747 showsubopts = not search and not ui.quiet
3749
3748
3750 for name, path in pathitems:
3749 for name, path in pathitems:
3751 fm.startitem()
3750 fm.startitem()
3752 fm.condwrite(not search, 'name', namefmt, name)
3751 fm.condwrite(not search, 'name', namefmt, name)
3753 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3752 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc))
3754 for subopt, value in sorted(path.suboptions.items()):
3753 for subopt, value in sorted(path.suboptions.items()):
3755 assert subopt not in ('name', 'url')
3754 assert subopt not in ('name', 'url')
3756 if showsubopts:
3755 if showsubopts:
3757 fm.plain('%s:%s = ' % (name, subopt))
3756 fm.plain('%s:%s = ' % (name, subopt))
3758 fm.condwrite(showsubopts, subopt, '%s\n', value)
3757 fm.condwrite(showsubopts, subopt, '%s\n', value)
3759
3758
3760 fm.end()
3759 fm.end()
3761
3760
3762 if search and not pathitems:
3761 if search and not pathitems:
3763 if not ui.quiet:
3762 if not ui.quiet:
3764 ui.warn(_("not found!\n"))
3763 ui.warn(_("not found!\n"))
3765 return 1
3764 return 1
3766 else:
3765 else:
3767 return 0
3766 return 0
3768
3767
3769 @command('phase',
3768 @command('phase',
3770 [('p', 'public', False, _('set changeset phase to public')),
3769 [('p', 'public', False, _('set changeset phase to public')),
3771 ('d', 'draft', False, _('set changeset phase to draft')),
3770 ('d', 'draft', False, _('set changeset phase to draft')),
3772 ('s', 'secret', False, _('set changeset phase to secret')),
3771 ('s', 'secret', False, _('set changeset phase to secret')),
3773 ('f', 'force', False, _('allow to move boundary backward')),
3772 ('f', 'force', False, _('allow to move boundary backward')),
3774 ('r', 'rev', [], _('target revision'), _('REV')),
3773 ('r', 'rev', [], _('target revision'), _('REV')),
3775 ],
3774 ],
3776 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3775 _('[-p|-d|-s] [-f] [-r] [REV...]'))
3777 def phase(ui, repo, *revs, **opts):
3776 def phase(ui, repo, *revs, **opts):
3778 """set or show the current phase name
3777 """set or show the current phase name
3779
3778
3780 With no argument, show the phase name of the current revision(s).
3779 With no argument, show the phase name of the current revision(s).
3781
3780
3782 With one of -p/--public, -d/--draft or -s/--secret, change the
3781 With one of -p/--public, -d/--draft or -s/--secret, change the
3783 phase value of the specified revisions.
3782 phase value of the specified revisions.
3784
3783
3785 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
3784 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
3786 lower phase to an higher phase. Phases are ordered as follows::
3785 lower phase to an higher phase. Phases are ordered as follows::
3787
3786
3788 public < draft < secret
3787 public < draft < secret
3789
3788
3790 Returns 0 on success, 1 if some phases could not be changed.
3789 Returns 0 on success, 1 if some phases could not be changed.
3791
3790
3792 (For more information about the phases concept, see :hg:`help phases`.)
3791 (For more information about the phases concept, see :hg:`help phases`.)
3793 """
3792 """
3794 # search for a unique phase argument
3793 # search for a unique phase argument
3795 targetphase = None
3794 targetphase = None
3796 for idx, name in enumerate(phases.phasenames):
3795 for idx, name in enumerate(phases.phasenames):
3797 if opts[name]:
3796 if opts[name]:
3798 if targetphase is not None:
3797 if targetphase is not None:
3799 raise error.Abort(_('only one phase can be specified'))
3798 raise error.Abort(_('only one phase can be specified'))
3800 targetphase = idx
3799 targetphase = idx
3801
3800
3802 # look for specified revision
3801 # look for specified revision
3803 revs = list(revs)
3802 revs = list(revs)
3804 revs.extend(opts['rev'])
3803 revs.extend(opts['rev'])
3805 if not revs:
3804 if not revs:
3806 # display both parents as the second parent phase can influence
3805 # display both parents as the second parent phase can influence
3807 # the phase of a merge commit
3806 # the phase of a merge commit
3808 revs = [c.rev() for c in repo[None].parents()]
3807 revs = [c.rev() for c in repo[None].parents()]
3809
3808
3810 revs = scmutil.revrange(repo, revs)
3809 revs = scmutil.revrange(repo, revs)
3811
3810
3812 lock = None
3811 lock = None
3813 ret = 0
3812 ret = 0
3814 if targetphase is None:
3813 if targetphase is None:
3815 # display
3814 # display
3816 for r in revs:
3815 for r in revs:
3817 ctx = repo[r]
3816 ctx = repo[r]
3818 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3817 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
3819 else:
3818 else:
3820 tr = None
3819 tr = None
3821 lock = repo.lock()
3820 lock = repo.lock()
3822 try:
3821 try:
3823 tr = repo.transaction("phase")
3822 tr = repo.transaction("phase")
3824 # set phase
3823 # set phase
3825 if not revs:
3824 if not revs:
3826 raise error.Abort(_('empty revision set'))
3825 raise error.Abort(_('empty revision set'))
3827 nodes = [repo[r].node() for r in revs]
3826 nodes = [repo[r].node() for r in revs]
3828 # moving revision from public to draft may hide them
3827 # moving revision from public to draft may hide them
3829 # We have to check result on an unfiltered repository
3828 # We have to check result on an unfiltered repository
3830 unfi = repo.unfiltered()
3829 unfi = repo.unfiltered()
3831 getphase = unfi._phasecache.phase
3830 getphase = unfi._phasecache.phase
3832 olddata = [getphase(unfi, r) for r in unfi]
3831 olddata = [getphase(unfi, r) for r in unfi]
3833 phases.advanceboundary(repo, tr, targetphase, nodes)
3832 phases.advanceboundary(repo, tr, targetphase, nodes)
3834 if opts['force']:
3833 if opts['force']:
3835 phases.retractboundary(repo, tr, targetphase, nodes)
3834 phases.retractboundary(repo, tr, targetphase, nodes)
3836 tr.close()
3835 tr.close()
3837 finally:
3836 finally:
3838 if tr is not None:
3837 if tr is not None:
3839 tr.release()
3838 tr.release()
3840 lock.release()
3839 lock.release()
3841 getphase = unfi._phasecache.phase
3840 getphase = unfi._phasecache.phase
3842 newdata = [getphase(unfi, r) for r in unfi]
3841 newdata = [getphase(unfi, r) for r in unfi]
3843 changes = sum(newdata[r] != olddata[r] for r in unfi)
3842 changes = sum(newdata[r] != olddata[r] for r in unfi)
3844 cl = unfi.changelog
3843 cl = unfi.changelog
3845 rejected = [n for n in nodes
3844 rejected = [n for n in nodes
3846 if newdata[cl.rev(n)] < targetphase]
3845 if newdata[cl.rev(n)] < targetphase]
3847 if rejected:
3846 if rejected:
3848 ui.warn(_('cannot move %i changesets to a higher '
3847 ui.warn(_('cannot move %i changesets to a higher '
3849 'phase, use --force\n') % len(rejected))
3848 'phase, use --force\n') % len(rejected))
3850 ret = 1
3849 ret = 1
3851 if changes:
3850 if changes:
3852 msg = _('phase changed for %i changesets\n') % changes
3851 msg = _('phase changed for %i changesets\n') % changes
3853 if ret:
3852 if ret:
3854 ui.status(msg)
3853 ui.status(msg)
3855 else:
3854 else:
3856 ui.note(msg)
3855 ui.note(msg)
3857 else:
3856 else:
3858 ui.warn(_('no phases changed\n'))
3857 ui.warn(_('no phases changed\n'))
3859 return ret
3858 return ret
3860
3859
3861 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3860 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
3862 """Run after a changegroup has been added via pull/unbundle
3861 """Run after a changegroup has been added via pull/unbundle
3863
3862
3864 This takes arguments below:
3863 This takes arguments below:
3865
3864
3866 :modheads: change of heads by pull/unbundle
3865 :modheads: change of heads by pull/unbundle
3867 :optupdate: updating working directory is needed or not
3866 :optupdate: updating working directory is needed or not
3868 :checkout: update destination revision (or None to default destination)
3867 :checkout: update destination revision (or None to default destination)
3869 :brev: a name, which might be a bookmark to be activated after updating
3868 :brev: a name, which might be a bookmark to be activated after updating
3870 """
3869 """
3871 if modheads == 0:
3870 if modheads == 0:
3872 return
3871 return
3873 if optupdate:
3872 if optupdate:
3874 try:
3873 try:
3875 return hg.updatetotally(ui, repo, checkout, brev)
3874 return hg.updatetotally(ui, repo, checkout, brev)
3876 except error.UpdateAbort as inst:
3875 except error.UpdateAbort as inst:
3877 msg = _("not updating: %s") % str(inst)
3876 msg = _("not updating: %s") % str(inst)
3878 hint = inst.hint
3877 hint = inst.hint
3879 raise error.UpdateAbort(msg, hint=hint)
3878 raise error.UpdateAbort(msg, hint=hint)
3880 if modheads > 1:
3879 if modheads > 1:
3881 currentbranchheads = len(repo.branchheads())
3880 currentbranchheads = len(repo.branchheads())
3882 if currentbranchheads == modheads:
3881 if currentbranchheads == modheads:
3883 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3882 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3884 elif currentbranchheads > 1:
3883 elif currentbranchheads > 1:
3885 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3884 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
3886 "merge)\n"))
3885 "merge)\n"))
3887 else:
3886 else:
3888 ui.status(_("(run 'hg heads' to see heads)\n"))
3887 ui.status(_("(run 'hg heads' to see heads)\n"))
3889 else:
3888 else:
3890 ui.status(_("(run 'hg update' to get a working copy)\n"))
3889 ui.status(_("(run 'hg update' to get a working copy)\n"))
3891
3890
3892 @command('^pull',
3891 @command('^pull',
3893 [('u', 'update', None,
3892 [('u', 'update', None,
3894 _('update to new branch head if changesets were pulled')),
3893 _('update to new branch head if changesets were pulled')),
3895 ('f', 'force', None, _('run even when remote repository is unrelated')),
3894 ('f', 'force', None, _('run even when remote repository is unrelated')),
3896 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3895 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3897 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3896 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
3898 ('b', 'branch', [], _('a specific branch you would like to pull'),
3897 ('b', 'branch', [], _('a specific branch you would like to pull'),
3899 _('BRANCH')),
3898 _('BRANCH')),
3900 ] + remoteopts,
3899 ] + remoteopts,
3901 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3900 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
3902 def pull(ui, repo, source="default", **opts):
3901 def pull(ui, repo, source="default", **opts):
3903 """pull changes from the specified source
3902 """pull changes from the specified source
3904
3903
3905 Pull changes from a remote repository to a local one.
3904 Pull changes from a remote repository to a local one.
3906
3905
3907 This finds all changes from the repository at the specified path
3906 This finds all changes from the repository at the specified path
3908 or URL and adds them to a local repository (the current one unless
3907 or URL and adds them to a local repository (the current one unless
3909 -R is specified). By default, this does not update the copy of the
3908 -R is specified). By default, this does not update the copy of the
3910 project in the working directory.
3909 project in the working directory.
3911
3910
3912 Use :hg:`incoming` if you want to see what would have been added
3911 Use :hg:`incoming` if you want to see what would have been added
3913 by a pull at the time you issued this command. If you then decide
3912 by a pull at the time you issued this command. If you then decide
3914 to add those changes to the repository, you should use :hg:`pull
3913 to add those changes to the repository, you should use :hg:`pull
3915 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
3914 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
3916
3915
3917 If SOURCE is omitted, the 'default' path will be used.
3916 If SOURCE is omitted, the 'default' path will be used.
3918 See :hg:`help urls` for more information.
3917 See :hg:`help urls` for more information.
3919
3918
3920 Specifying bookmark as ``.`` is equivalent to specifying the active
3919 Specifying bookmark as ``.`` is equivalent to specifying the active
3921 bookmark's name.
3920 bookmark's name.
3922
3921
3923 Returns 0 on success, 1 if an update had unresolved files.
3922 Returns 0 on success, 1 if an update had unresolved files.
3924 """
3923 """
3925 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
3924 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
3926 ui.status(_('pulling from %s\n') % util.hidepassword(source))
3925 ui.status(_('pulling from %s\n') % util.hidepassword(source))
3927 other = hg.peer(repo, opts, source)
3926 other = hg.peer(repo, opts, source)
3928 try:
3927 try:
3929 revs, checkout = hg.addbranchrevs(repo, other, branches,
3928 revs, checkout = hg.addbranchrevs(repo, other, branches,
3930 opts.get('rev'))
3929 opts.get('rev'))
3931
3930
3932
3931
3933 pullopargs = {}
3932 pullopargs = {}
3934 if opts.get('bookmark'):
3933 if opts.get('bookmark'):
3935 if not revs:
3934 if not revs:
3936 revs = []
3935 revs = []
3937 # The list of bookmark used here is not the one used to actually
3936 # The list of bookmark used here is not the one used to actually
3938 # update the bookmark name. This can result in the revision pulled
3937 # update the bookmark name. This can result in the revision pulled
3939 # not ending up with the name of the bookmark because of a race
3938 # not ending up with the name of the bookmark because of a race
3940 # condition on the server. (See issue 4689 for details)
3939 # condition on the server. (See issue 4689 for details)
3941 remotebookmarks = other.listkeys('bookmarks')
3940 remotebookmarks = other.listkeys('bookmarks')
3942 pullopargs['remotebookmarks'] = remotebookmarks
3941 pullopargs['remotebookmarks'] = remotebookmarks
3943 for b in opts['bookmark']:
3942 for b in opts['bookmark']:
3944 b = repo._bookmarks.expandname(b)
3943 b = repo._bookmarks.expandname(b)
3945 if b not in remotebookmarks:
3944 if b not in remotebookmarks:
3946 raise error.Abort(_('remote bookmark %s not found!') % b)
3945 raise error.Abort(_('remote bookmark %s not found!') % b)
3947 revs.append(remotebookmarks[b])
3946 revs.append(remotebookmarks[b])
3948
3947
3949 if revs:
3948 if revs:
3950 try:
3949 try:
3951 # When 'rev' is a bookmark name, we cannot guarantee that it
3950 # When 'rev' is a bookmark name, we cannot guarantee that it
3952 # will be updated with that name because of a race condition
3951 # will be updated with that name because of a race condition
3953 # server side. (See issue 4689 for details)
3952 # server side. (See issue 4689 for details)
3954 oldrevs = revs
3953 oldrevs = revs
3955 revs = [] # actually, nodes
3954 revs = [] # actually, nodes
3956 for r in oldrevs:
3955 for r in oldrevs:
3957 node = other.lookup(r)
3956 node = other.lookup(r)
3958 revs.append(node)
3957 revs.append(node)
3959 if r == checkout:
3958 if r == checkout:
3960 checkout = node
3959 checkout = node
3961 except error.CapabilityError:
3960 except error.CapabilityError:
3962 err = _("other repository doesn't support revision lookup, "
3961 err = _("other repository doesn't support revision lookup, "
3963 "so a rev cannot be specified.")
3962 "so a rev cannot be specified.")
3964 raise error.Abort(err)
3963 raise error.Abort(err)
3965
3964
3966 pullopargs.update(opts.get('opargs', {}))
3965 pullopargs.update(opts.get('opargs', {}))
3967 modheads = exchange.pull(repo, other, heads=revs,
3966 modheads = exchange.pull(repo, other, heads=revs,
3968 force=opts.get('force'),
3967 force=opts.get('force'),
3969 bookmarks=opts.get('bookmark', ()),
3968 bookmarks=opts.get('bookmark', ()),
3970 opargs=pullopargs).cgresult
3969 opargs=pullopargs).cgresult
3971
3970
3972 # brev is a name, which might be a bookmark to be activated at
3971 # brev is a name, which might be a bookmark to be activated at
3973 # the end of the update. In other words, it is an explicit
3972 # the end of the update. In other words, it is an explicit
3974 # destination of the update
3973 # destination of the update
3975 brev = None
3974 brev = None
3976
3975
3977 if checkout:
3976 if checkout:
3978 checkout = str(repo.changelog.rev(checkout))
3977 checkout = str(repo.changelog.rev(checkout))
3979
3978
3980 # order below depends on implementation of
3979 # order below depends on implementation of
3981 # hg.addbranchrevs(). opts['bookmark'] is ignored,
3980 # hg.addbranchrevs(). opts['bookmark'] is ignored,
3982 # because 'checkout' is determined without it.
3981 # because 'checkout' is determined without it.
3983 if opts.get('rev'):
3982 if opts.get('rev'):
3984 brev = opts['rev'][0]
3983 brev = opts['rev'][0]
3985 elif opts.get('branch'):
3984 elif opts.get('branch'):
3986 brev = opts['branch'][0]
3985 brev = opts['branch'][0]
3987 else:
3986 else:
3988 brev = branches[0]
3987 brev = branches[0]
3989 repo._subtoppath = source
3988 repo._subtoppath = source
3990 try:
3989 try:
3991 ret = postincoming(ui, repo, modheads, opts.get('update'),
3990 ret = postincoming(ui, repo, modheads, opts.get('update'),
3992 checkout, brev)
3991 checkout, brev)
3993
3992
3994 finally:
3993 finally:
3995 del repo._subtoppath
3994 del repo._subtoppath
3996
3995
3997 finally:
3996 finally:
3998 other.close()
3997 other.close()
3999 return ret
3998 return ret
4000
3999
4001 @command('^push',
4000 @command('^push',
4002 [('f', 'force', None, _('force push')),
4001 [('f', 'force', None, _('force push')),
4003 ('r', 'rev', [],
4002 ('r', 'rev', [],
4004 _('a changeset intended to be included in the destination'),
4003 _('a changeset intended to be included in the destination'),
4005 _('REV')),
4004 _('REV')),
4006 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4005 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4007 ('b', 'branch', [],
4006 ('b', 'branch', [],
4008 _('a specific branch you would like to push'), _('BRANCH')),
4007 _('a specific branch you would like to push'), _('BRANCH')),
4009 ('', 'new-branch', False, _('allow pushing a new branch')),
4008 ('', 'new-branch', False, _('allow pushing a new branch')),
4010 ] + remoteopts,
4009 ] + remoteopts,
4011 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4010 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4012 def push(ui, repo, dest=None, **opts):
4011 def push(ui, repo, dest=None, **opts):
4013 """push changes to the specified destination
4012 """push changes to the specified destination
4014
4013
4015 Push changesets from the local repository to the specified
4014 Push changesets from the local repository to the specified
4016 destination.
4015 destination.
4017
4016
4018 This operation is symmetrical to pull: it is identical to a pull
4017 This operation is symmetrical to pull: it is identical to a pull
4019 in the destination repository from the current one.
4018 in the destination repository from the current one.
4020
4019
4021 By default, push will not allow creation of new heads at the
4020 By default, push will not allow creation of new heads at the
4022 destination, since multiple heads would make it unclear which head
4021 destination, since multiple heads would make it unclear which head
4023 to use. In this situation, it is recommended to pull and merge
4022 to use. In this situation, it is recommended to pull and merge
4024 before pushing.
4023 before pushing.
4025
4024
4026 Use --new-branch if you want to allow push to create a new named
4025 Use --new-branch if you want to allow push to create a new named
4027 branch that is not present at the destination. This allows you to
4026 branch that is not present at the destination. This allows you to
4028 only create a new branch without forcing other changes.
4027 only create a new branch without forcing other changes.
4029
4028
4030 .. note::
4029 .. note::
4031
4030
4032 Extra care should be taken with the -f/--force option,
4031 Extra care should be taken with the -f/--force option,
4033 which will push all new heads on all branches, an action which will
4032 which will push all new heads on all branches, an action which will
4034 almost always cause confusion for collaborators.
4033 almost always cause confusion for collaborators.
4035
4034
4036 If -r/--rev is used, the specified revision and all its ancestors
4035 If -r/--rev is used, the specified revision and all its ancestors
4037 will be pushed to the remote repository.
4036 will be pushed to the remote repository.
4038
4037
4039 If -B/--bookmark is used, the specified bookmarked revision, its
4038 If -B/--bookmark is used, the specified bookmarked revision, its
4040 ancestors, and the bookmark will be pushed to the remote
4039 ancestors, and the bookmark will be pushed to the remote
4041 repository. Specifying ``.`` is equivalent to specifying the active
4040 repository. Specifying ``.`` is equivalent to specifying the active
4042 bookmark's name.
4041 bookmark's name.
4043
4042
4044 Please see :hg:`help urls` for important details about ``ssh://``
4043 Please see :hg:`help urls` for important details about ``ssh://``
4045 URLs. If DESTINATION is omitted, a default path will be used.
4044 URLs. If DESTINATION is omitted, a default path will be used.
4046
4045
4047 Returns 0 if push was successful, 1 if nothing to push.
4046 Returns 0 if push was successful, 1 if nothing to push.
4048 """
4047 """
4049
4048
4050 if opts.get('bookmark'):
4049 if opts.get('bookmark'):
4051 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4050 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4052 for b in opts['bookmark']:
4051 for b in opts['bookmark']:
4053 # translate -B options to -r so changesets get pushed
4052 # translate -B options to -r so changesets get pushed
4054 b = repo._bookmarks.expandname(b)
4053 b = repo._bookmarks.expandname(b)
4055 if b in repo._bookmarks:
4054 if b in repo._bookmarks:
4056 opts.setdefault('rev', []).append(b)
4055 opts.setdefault('rev', []).append(b)
4057 else:
4056 else:
4058 # if we try to push a deleted bookmark, translate it to null
4057 # if we try to push a deleted bookmark, translate it to null
4059 # this lets simultaneous -r, -b options continue working
4058 # this lets simultaneous -r, -b options continue working
4060 opts.setdefault('rev', []).append("null")
4059 opts.setdefault('rev', []).append("null")
4061
4060
4062 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4061 path = ui.paths.getpath(dest, default=('default-push', 'default'))
4063 if not path:
4062 if not path:
4064 raise error.Abort(_('default repository not configured!'),
4063 raise error.Abort(_('default repository not configured!'),
4065 hint=_("see 'hg help config.paths'"))
4064 hint=_("see 'hg help config.paths'"))
4066 dest = path.pushloc or path.loc
4065 dest = path.pushloc or path.loc
4067 branches = (path.branch, opts.get('branch') or [])
4066 branches = (path.branch, opts.get('branch') or [])
4068 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4067 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4069 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4068 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4070 other = hg.peer(repo, opts, dest)
4069 other = hg.peer(repo, opts, dest)
4071
4070
4072 if revs:
4071 if revs:
4073 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4072 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4074 if not revs:
4073 if not revs:
4075 raise error.Abort(_("specified revisions evaluate to an empty set"),
4074 raise error.Abort(_("specified revisions evaluate to an empty set"),
4076 hint=_("use different revision arguments"))
4075 hint=_("use different revision arguments"))
4077 elif path.pushrev:
4076 elif path.pushrev:
4078 # It doesn't make any sense to specify ancestor revisions. So limit
4077 # It doesn't make any sense to specify ancestor revisions. So limit
4079 # to DAG heads to make discovery simpler.
4078 # to DAG heads to make discovery simpler.
4080 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4079 expr = revsetlang.formatspec('heads(%r)', path.pushrev)
4081 revs = scmutil.revrange(repo, [expr])
4080 revs = scmutil.revrange(repo, [expr])
4082 revs = [repo[rev].node() for rev in revs]
4081 revs = [repo[rev].node() for rev in revs]
4083 if not revs:
4082 if not revs:
4084 raise error.Abort(_('default push revset for path evaluates to an '
4083 raise error.Abort(_('default push revset for path evaluates to an '
4085 'empty set'))
4084 'empty set'))
4086
4085
4087 repo._subtoppath = dest
4086 repo._subtoppath = dest
4088 try:
4087 try:
4089 # push subrepos depth-first for coherent ordering
4088 # push subrepos depth-first for coherent ordering
4090 c = repo['']
4089 c = repo['']
4091 subs = c.substate # only repos that are committed
4090 subs = c.substate # only repos that are committed
4092 for s in sorted(subs):
4091 for s in sorted(subs):
4093 result = c.sub(s).push(opts)
4092 result = c.sub(s).push(opts)
4094 if result == 0:
4093 if result == 0:
4095 return not result
4094 return not result
4096 finally:
4095 finally:
4097 del repo._subtoppath
4096 del repo._subtoppath
4098 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4097 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4099 newbranch=opts.get('new_branch'),
4098 newbranch=opts.get('new_branch'),
4100 bookmarks=opts.get('bookmark', ()),
4099 bookmarks=opts.get('bookmark', ()),
4101 opargs=opts.get('opargs'))
4100 opargs=opts.get('opargs'))
4102
4101
4103 result = not pushop.cgresult
4102 result = not pushop.cgresult
4104
4103
4105 if pushop.bkresult is not None:
4104 if pushop.bkresult is not None:
4106 if pushop.bkresult == 2:
4105 if pushop.bkresult == 2:
4107 result = 2
4106 result = 2
4108 elif not result and pushop.bkresult:
4107 elif not result and pushop.bkresult:
4109 result = 2
4108 result = 2
4110
4109
4111 return result
4110 return result
4112
4111
4113 @command('recover', [])
4112 @command('recover', [])
4114 def recover(ui, repo):
4113 def recover(ui, repo):
4115 """roll back an interrupted transaction
4114 """roll back an interrupted transaction
4116
4115
4117 Recover from an interrupted commit or pull.
4116 Recover from an interrupted commit or pull.
4118
4117
4119 This command tries to fix the repository status after an
4118 This command tries to fix the repository status after an
4120 interrupted operation. It should only be necessary when Mercurial
4119 interrupted operation. It should only be necessary when Mercurial
4121 suggests it.
4120 suggests it.
4122
4121
4123 Returns 0 if successful, 1 if nothing to recover or verify fails.
4122 Returns 0 if successful, 1 if nothing to recover or verify fails.
4124 """
4123 """
4125 if repo.recover():
4124 if repo.recover():
4126 return hg.verify(repo)
4125 return hg.verify(repo)
4127 return 1
4126 return 1
4128
4127
4129 @command('^remove|rm',
4128 @command('^remove|rm',
4130 [('A', 'after', None, _('record delete for missing files')),
4129 [('A', 'after', None, _('record delete for missing files')),
4131 ('f', 'force', None,
4130 ('f', 'force', None,
4132 _('forget added files, delete modified files')),
4131 _('forget added files, delete modified files')),
4133 ] + subrepoopts + walkopts,
4132 ] + subrepoopts + walkopts,
4134 _('[OPTION]... FILE...'),
4133 _('[OPTION]... FILE...'),
4135 inferrepo=True)
4134 inferrepo=True)
4136 def remove(ui, repo, *pats, **opts):
4135 def remove(ui, repo, *pats, **opts):
4137 """remove the specified files on the next commit
4136 """remove the specified files on the next commit
4138
4137
4139 Schedule the indicated files for removal from the current branch.
4138 Schedule the indicated files for removal from the current branch.
4140
4139
4141 This command schedules the files to be removed at the next commit.
4140 This command schedules the files to be removed at the next commit.
4142 To undo a remove before that, see :hg:`revert`. To undo added
4141 To undo a remove before that, see :hg:`revert`. To undo added
4143 files, see :hg:`forget`.
4142 files, see :hg:`forget`.
4144
4143
4145 .. container:: verbose
4144 .. container:: verbose
4146
4145
4147 -A/--after can be used to remove only files that have already
4146 -A/--after can be used to remove only files that have already
4148 been deleted, -f/--force can be used to force deletion, and -Af
4147 been deleted, -f/--force can be used to force deletion, and -Af
4149 can be used to remove files from the next revision without
4148 can be used to remove files from the next revision without
4150 deleting them from the working directory.
4149 deleting them from the working directory.
4151
4150
4152 The following table details the behavior of remove for different
4151 The following table details the behavior of remove for different
4153 file states (columns) and option combinations (rows). The file
4152 file states (columns) and option combinations (rows). The file
4154 states are Added [A], Clean [C], Modified [M] and Missing [!]
4153 states are Added [A], Clean [C], Modified [M] and Missing [!]
4155 (as reported by :hg:`status`). The actions are Warn, Remove
4154 (as reported by :hg:`status`). The actions are Warn, Remove
4156 (from branch) and Delete (from disk):
4155 (from branch) and Delete (from disk):
4157
4156
4158 ========= == == == ==
4157 ========= == == == ==
4159 opt/state A C M !
4158 opt/state A C M !
4160 ========= == == == ==
4159 ========= == == == ==
4161 none W RD W R
4160 none W RD W R
4162 -f R RD RD R
4161 -f R RD RD R
4163 -A W W W R
4162 -A W W W R
4164 -Af R R R R
4163 -Af R R R R
4165 ========= == == == ==
4164 ========= == == == ==
4166
4165
4167 .. note::
4166 .. note::
4168
4167
4169 :hg:`remove` never deletes files in Added [A] state from the
4168 :hg:`remove` never deletes files in Added [A] state from the
4170 working directory, not even if ``--force`` is specified.
4169 working directory, not even if ``--force`` is specified.
4171
4170
4172 Returns 0 on success, 1 if any warnings encountered.
4171 Returns 0 on success, 1 if any warnings encountered.
4173 """
4172 """
4174
4173
4175 after, force = opts.get('after'), opts.get('force')
4174 after, force = opts.get('after'), opts.get('force')
4176 if not pats and not after:
4175 if not pats and not after:
4177 raise error.Abort(_('no files specified'))
4176 raise error.Abort(_('no files specified'))
4178
4177
4179 m = scmutil.match(repo[None], pats, opts)
4178 m = scmutil.match(repo[None], pats, opts)
4180 subrepos = opts.get('subrepos')
4179 subrepos = opts.get('subrepos')
4181 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
4180 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
4182
4181
4183 @command('rename|move|mv',
4182 @command('rename|move|mv',
4184 [('A', 'after', None, _('record a rename that has already occurred')),
4183 [('A', 'after', None, _('record a rename that has already occurred')),
4185 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4184 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4186 ] + walkopts + dryrunopts,
4185 ] + walkopts + dryrunopts,
4187 _('[OPTION]... SOURCE... DEST'))
4186 _('[OPTION]... SOURCE... DEST'))
4188 def rename(ui, repo, *pats, **opts):
4187 def rename(ui, repo, *pats, **opts):
4189 """rename files; equivalent of copy + remove
4188 """rename files; equivalent of copy + remove
4190
4189
4191 Mark dest as copies of sources; mark sources for deletion. If dest
4190 Mark dest as copies of sources; mark sources for deletion. If dest
4192 is a directory, copies are put in that directory. If dest is a
4191 is a directory, copies are put in that directory. If dest is a
4193 file, there can only be one source.
4192 file, there can only be one source.
4194
4193
4195 By default, this command copies the contents of files as they
4194 By default, this command copies the contents of files as they
4196 exist in the working directory. If invoked with -A/--after, the
4195 exist in the working directory. If invoked with -A/--after, the
4197 operation is recorded, but no copying is performed.
4196 operation is recorded, but no copying is performed.
4198
4197
4199 This command takes effect at the next commit. To undo a rename
4198 This command takes effect at the next commit. To undo a rename
4200 before that, see :hg:`revert`.
4199 before that, see :hg:`revert`.
4201
4200
4202 Returns 0 on success, 1 if errors are encountered.
4201 Returns 0 on success, 1 if errors are encountered.
4203 """
4202 """
4204 with repo.wlock(False):
4203 with repo.wlock(False):
4205 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4204 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4206
4205
4207 @command('resolve',
4206 @command('resolve',
4208 [('a', 'all', None, _('select all unresolved files')),
4207 [('a', 'all', None, _('select all unresolved files')),
4209 ('l', 'list', None, _('list state of files needing merge')),
4208 ('l', 'list', None, _('list state of files needing merge')),
4210 ('m', 'mark', None, _('mark files as resolved')),
4209 ('m', 'mark', None, _('mark files as resolved')),
4211 ('u', 'unmark', None, _('mark files as unresolved')),
4210 ('u', 'unmark', None, _('mark files as unresolved')),
4212 ('n', 'no-status', None, _('hide status prefix'))]
4211 ('n', 'no-status', None, _('hide status prefix'))]
4213 + mergetoolopts + walkopts + formatteropts,
4212 + mergetoolopts + walkopts + formatteropts,
4214 _('[OPTION]... [FILE]...'),
4213 _('[OPTION]... [FILE]...'),
4215 inferrepo=True)
4214 inferrepo=True)
4216 def resolve(ui, repo, *pats, **opts):
4215 def resolve(ui, repo, *pats, **opts):
4217 """redo merges or set/view the merge status of files
4216 """redo merges or set/view the merge status of files
4218
4217
4219 Merges with unresolved conflicts are often the result of
4218 Merges with unresolved conflicts are often the result of
4220 non-interactive merging using the ``internal:merge`` configuration
4219 non-interactive merging using the ``internal:merge`` configuration
4221 setting, or a command-line merge tool like ``diff3``. The resolve
4220 setting, or a command-line merge tool like ``diff3``. The resolve
4222 command is used to manage the files involved in a merge, after
4221 command is used to manage the files involved in a merge, after
4223 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4222 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4224 working directory must have two parents). See :hg:`help
4223 working directory must have two parents). See :hg:`help
4225 merge-tools` for information on configuring merge tools.
4224 merge-tools` for information on configuring merge tools.
4226
4225
4227 The resolve command can be used in the following ways:
4226 The resolve command can be used in the following ways:
4228
4227
4229 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4228 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4230 files, discarding any previous merge attempts. Re-merging is not
4229 files, discarding any previous merge attempts. Re-merging is not
4231 performed for files already marked as resolved. Use ``--all/-a``
4230 performed for files already marked as resolved. Use ``--all/-a``
4232 to select all unresolved files. ``--tool`` can be used to specify
4231 to select all unresolved files. ``--tool`` can be used to specify
4233 the merge tool used for the given files. It overrides the HGMERGE
4232 the merge tool used for the given files. It overrides the HGMERGE
4234 environment variable and your configuration files. Previous file
4233 environment variable and your configuration files. Previous file
4235 contents are saved with a ``.orig`` suffix.
4234 contents are saved with a ``.orig`` suffix.
4236
4235
4237 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4236 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4238 (e.g. after having manually fixed-up the files). The default is
4237 (e.g. after having manually fixed-up the files). The default is
4239 to mark all unresolved files.
4238 to mark all unresolved files.
4240
4239
4241 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4240 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4242 default is to mark all resolved files.
4241 default is to mark all resolved files.
4243
4242
4244 - :hg:`resolve -l`: list files which had or still have conflicts.
4243 - :hg:`resolve -l`: list files which had or still have conflicts.
4245 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4244 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4246 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4245 You can use ``set:unresolved()`` or ``set:resolved()`` to filter
4247 the list. See :hg:`help filesets` for details.
4246 the list. See :hg:`help filesets` for details.
4248
4247
4249 .. note::
4248 .. note::
4250
4249
4251 Mercurial will not let you commit files with unresolved merge
4250 Mercurial will not let you commit files with unresolved merge
4252 conflicts. You must use :hg:`resolve -m ...` before you can
4251 conflicts. You must use :hg:`resolve -m ...` before you can
4253 commit after a conflicting merge.
4252 commit after a conflicting merge.
4254
4253
4255 Returns 0 on success, 1 if any files fail a resolve attempt.
4254 Returns 0 on success, 1 if any files fail a resolve attempt.
4256 """
4255 """
4257
4256
4258 flaglist = 'all mark unmark list no_status'.split()
4257 flaglist = 'all mark unmark list no_status'.split()
4259 all, mark, unmark, show, nostatus = \
4258 all, mark, unmark, show, nostatus = \
4260 [opts.get(o) for o in flaglist]
4259 [opts.get(o) for o in flaglist]
4261
4260
4262 if (show and (mark or unmark)) or (mark and unmark):
4261 if (show and (mark or unmark)) or (mark and unmark):
4263 raise error.Abort(_("too many options specified"))
4262 raise error.Abort(_("too many options specified"))
4264 if pats and all:
4263 if pats and all:
4265 raise error.Abort(_("can't specify --all and patterns"))
4264 raise error.Abort(_("can't specify --all and patterns"))
4266 if not (all or pats or show or mark or unmark):
4265 if not (all or pats or show or mark or unmark):
4267 raise error.Abort(_('no files or directories specified'),
4266 raise error.Abort(_('no files or directories specified'),
4268 hint=('use --all to re-merge all unresolved files'))
4267 hint=('use --all to re-merge all unresolved files'))
4269
4268
4270 if show:
4269 if show:
4271 ui.pager('resolve')
4270 ui.pager('resolve')
4272 fm = ui.formatter('resolve', opts)
4271 fm = ui.formatter('resolve', opts)
4273 ms = mergemod.mergestate.read(repo)
4272 ms = mergemod.mergestate.read(repo)
4274 m = scmutil.match(repo[None], pats, opts)
4273 m = scmutil.match(repo[None], pats, opts)
4275 for f in ms:
4274 for f in ms:
4276 if not m(f):
4275 if not m(f):
4277 continue
4276 continue
4278 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
4277 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
4279 'd': 'driverresolved'}[ms[f]]
4278 'd': 'driverresolved'}[ms[f]]
4280 fm.startitem()
4279 fm.startitem()
4281 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
4280 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
4282 fm.write('path', '%s\n', f, label=l)
4281 fm.write('path', '%s\n', f, label=l)
4283 fm.end()
4282 fm.end()
4284 return 0
4283 return 0
4285
4284
4286 with repo.wlock():
4285 with repo.wlock():
4287 ms = mergemod.mergestate.read(repo)
4286 ms = mergemod.mergestate.read(repo)
4288
4287
4289 if not (ms.active() or repo.dirstate.p2() != nullid):
4288 if not (ms.active() or repo.dirstate.p2() != nullid):
4290 raise error.Abort(
4289 raise error.Abort(
4291 _('resolve command not applicable when not merging'))
4290 _('resolve command not applicable when not merging'))
4292
4291
4293 wctx = repo[None]
4292 wctx = repo[None]
4294
4293
4295 if ms.mergedriver and ms.mdstate() == 'u':
4294 if ms.mergedriver and ms.mdstate() == 'u':
4296 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4295 proceed = mergemod.driverpreprocess(repo, ms, wctx)
4297 ms.commit()
4296 ms.commit()
4298 # allow mark and unmark to go through
4297 # allow mark and unmark to go through
4299 if not mark and not unmark and not proceed:
4298 if not mark and not unmark and not proceed:
4300 return 1
4299 return 1
4301
4300
4302 m = scmutil.match(wctx, pats, opts)
4301 m = scmutil.match(wctx, pats, opts)
4303 ret = 0
4302 ret = 0
4304 didwork = False
4303 didwork = False
4305 runconclude = False
4304 runconclude = False
4306
4305
4307 tocomplete = []
4306 tocomplete = []
4308 for f in ms:
4307 for f in ms:
4309 if not m(f):
4308 if not m(f):
4310 continue
4309 continue
4311
4310
4312 didwork = True
4311 didwork = True
4313
4312
4314 # don't let driver-resolved files be marked, and run the conclude
4313 # don't let driver-resolved files be marked, and run the conclude
4315 # step if asked to resolve
4314 # step if asked to resolve
4316 if ms[f] == "d":
4315 if ms[f] == "d":
4317 exact = m.exact(f)
4316 exact = m.exact(f)
4318 if mark:
4317 if mark:
4319 if exact:
4318 if exact:
4320 ui.warn(_('not marking %s as it is driver-resolved\n')
4319 ui.warn(_('not marking %s as it is driver-resolved\n')
4321 % f)
4320 % f)
4322 elif unmark:
4321 elif unmark:
4323 if exact:
4322 if exact:
4324 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4323 ui.warn(_('not unmarking %s as it is driver-resolved\n')
4325 % f)
4324 % f)
4326 else:
4325 else:
4327 runconclude = True
4326 runconclude = True
4328 continue
4327 continue
4329
4328
4330 if mark:
4329 if mark:
4331 ms.mark(f, "r")
4330 ms.mark(f, "r")
4332 elif unmark:
4331 elif unmark:
4333 ms.mark(f, "u")
4332 ms.mark(f, "u")
4334 else:
4333 else:
4335 # backup pre-resolve (merge uses .orig for its own purposes)
4334 # backup pre-resolve (merge uses .orig for its own purposes)
4336 a = repo.wjoin(f)
4335 a = repo.wjoin(f)
4337 try:
4336 try:
4338 util.copyfile(a, a + ".resolve")
4337 util.copyfile(a, a + ".resolve")
4339 except (IOError, OSError) as inst:
4338 except (IOError, OSError) as inst:
4340 if inst.errno != errno.ENOENT:
4339 if inst.errno != errno.ENOENT:
4341 raise
4340 raise
4342
4341
4343 try:
4342 try:
4344 # preresolve file
4343 # preresolve file
4345 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4344 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4346 'resolve')
4345 'resolve')
4347 complete, r = ms.preresolve(f, wctx)
4346 complete, r = ms.preresolve(f, wctx)
4348 if not complete:
4347 if not complete:
4349 tocomplete.append(f)
4348 tocomplete.append(f)
4350 elif r:
4349 elif r:
4351 ret = 1
4350 ret = 1
4352 finally:
4351 finally:
4353 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4352 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4354 ms.commit()
4353 ms.commit()
4355
4354
4356 # replace filemerge's .orig file with our resolve file, but only
4355 # replace filemerge's .orig file with our resolve file, but only
4357 # for merges that are complete
4356 # for merges that are complete
4358 if complete:
4357 if complete:
4359 try:
4358 try:
4360 util.rename(a + ".resolve",
4359 util.rename(a + ".resolve",
4361 scmutil.origpath(ui, repo, a))
4360 scmutil.origpath(ui, repo, a))
4362 except OSError as inst:
4361 except OSError as inst:
4363 if inst.errno != errno.ENOENT:
4362 if inst.errno != errno.ENOENT:
4364 raise
4363 raise
4365
4364
4366 for f in tocomplete:
4365 for f in tocomplete:
4367 try:
4366 try:
4368 # resolve file
4367 # resolve file
4369 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4368 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4370 'resolve')
4369 'resolve')
4371 r = ms.resolve(f, wctx)
4370 r = ms.resolve(f, wctx)
4372 if r:
4371 if r:
4373 ret = 1
4372 ret = 1
4374 finally:
4373 finally:
4375 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4374 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4376 ms.commit()
4375 ms.commit()
4377
4376
4378 # replace filemerge's .orig file with our resolve file
4377 # replace filemerge's .orig file with our resolve file
4379 a = repo.wjoin(f)
4378 a = repo.wjoin(f)
4380 try:
4379 try:
4381 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4380 util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
4382 except OSError as inst:
4381 except OSError as inst:
4383 if inst.errno != errno.ENOENT:
4382 if inst.errno != errno.ENOENT:
4384 raise
4383 raise
4385
4384
4386 ms.commit()
4385 ms.commit()
4387 ms.recordactions()
4386 ms.recordactions()
4388
4387
4389 if not didwork and pats:
4388 if not didwork and pats:
4390 hint = None
4389 hint = None
4391 if not any([p for p in pats if p.find(':') >= 0]):
4390 if not any([p for p in pats if p.find(':') >= 0]):
4392 pats = ['path:%s' % p for p in pats]
4391 pats = ['path:%s' % p for p in pats]
4393 m = scmutil.match(wctx, pats, opts)
4392 m = scmutil.match(wctx, pats, opts)
4394 for f in ms:
4393 for f in ms:
4395 if not m(f):
4394 if not m(f):
4396 continue
4395 continue
4397 flags = ''.join(['-%s ' % o[0] for o in flaglist
4396 flags = ''.join(['-%s ' % o[0] for o in flaglist
4398 if opts.get(o)])
4397 if opts.get(o)])
4399 hint = _("(try: hg resolve %s%s)\n") % (
4398 hint = _("(try: hg resolve %s%s)\n") % (
4400 flags,
4399 flags,
4401 ' '.join(pats))
4400 ' '.join(pats))
4402 break
4401 break
4403 ui.warn(_("arguments do not match paths that need resolving\n"))
4402 ui.warn(_("arguments do not match paths that need resolving\n"))
4404 if hint:
4403 if hint:
4405 ui.warn(hint)
4404 ui.warn(hint)
4406 elif ms.mergedriver and ms.mdstate() != 's':
4405 elif ms.mergedriver and ms.mdstate() != 's':
4407 # run conclude step when either a driver-resolved file is requested
4406 # run conclude step when either a driver-resolved file is requested
4408 # or there are no driver-resolved files
4407 # or there are no driver-resolved files
4409 # we can't use 'ret' to determine whether any files are unresolved
4408 # we can't use 'ret' to determine whether any files are unresolved
4410 # because we might not have tried to resolve some
4409 # because we might not have tried to resolve some
4411 if ((runconclude or not list(ms.driverresolved()))
4410 if ((runconclude or not list(ms.driverresolved()))
4412 and not list(ms.unresolved())):
4411 and not list(ms.unresolved())):
4413 proceed = mergemod.driverconclude(repo, ms, wctx)
4412 proceed = mergemod.driverconclude(repo, ms, wctx)
4414 ms.commit()
4413 ms.commit()
4415 if not proceed:
4414 if not proceed:
4416 return 1
4415 return 1
4417
4416
4418 # Nudge users into finishing an unfinished operation
4417 # Nudge users into finishing an unfinished operation
4419 unresolvedf = list(ms.unresolved())
4418 unresolvedf = list(ms.unresolved())
4420 driverresolvedf = list(ms.driverresolved())
4419 driverresolvedf = list(ms.driverresolved())
4421 if not unresolvedf and not driverresolvedf:
4420 if not unresolvedf and not driverresolvedf:
4422 ui.status(_('(no more unresolved files)\n'))
4421 ui.status(_('(no more unresolved files)\n'))
4423 cmdutil.checkafterresolved(repo)
4422 cmdutil.checkafterresolved(repo)
4424 elif not unresolvedf:
4423 elif not unresolvedf:
4425 ui.status(_('(no more unresolved files -- '
4424 ui.status(_('(no more unresolved files -- '
4426 'run "hg resolve --all" to conclude)\n'))
4425 'run "hg resolve --all" to conclude)\n'))
4427
4426
4428 return ret
4427 return ret
4429
4428
4430 @command('revert',
4429 @command('revert',
4431 [('a', 'all', None, _('revert all changes when no arguments given')),
4430 [('a', 'all', None, _('revert all changes when no arguments given')),
4432 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4431 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4433 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4432 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4434 ('C', 'no-backup', None, _('do not save backup copies of files')),
4433 ('C', 'no-backup', None, _('do not save backup copies of files')),
4435 ('i', 'interactive', None,
4434 ('i', 'interactive', None,
4436 _('interactively select the changes (EXPERIMENTAL)')),
4435 _('interactively select the changes (EXPERIMENTAL)')),
4437 ] + walkopts + dryrunopts,
4436 ] + walkopts + dryrunopts,
4438 _('[OPTION]... [-r REV] [NAME]...'))
4437 _('[OPTION]... [-r REV] [NAME]...'))
4439 def revert(ui, repo, *pats, **opts):
4438 def revert(ui, repo, *pats, **opts):
4440 """restore files to their checkout state
4439 """restore files to their checkout state
4441
4440
4442 .. note::
4441 .. note::
4443
4442
4444 To check out earlier revisions, you should use :hg:`update REV`.
4443 To check out earlier revisions, you should use :hg:`update REV`.
4445 To cancel an uncommitted merge (and lose your changes),
4444 To cancel an uncommitted merge (and lose your changes),
4446 use :hg:`update --clean .`.
4445 use :hg:`update --clean .`.
4447
4446
4448 With no revision specified, revert the specified files or directories
4447 With no revision specified, revert the specified files or directories
4449 to the contents they had in the parent of the working directory.
4448 to the contents they had in the parent of the working directory.
4450 This restores the contents of files to an unmodified
4449 This restores the contents of files to an unmodified
4451 state and unschedules adds, removes, copies, and renames. If the
4450 state and unschedules adds, removes, copies, and renames. If the
4452 working directory has two parents, you must explicitly specify a
4451 working directory has two parents, you must explicitly specify a
4453 revision.
4452 revision.
4454
4453
4455 Using the -r/--rev or -d/--date options, revert the given files or
4454 Using the -r/--rev or -d/--date options, revert the given files or
4456 directories to their states as of a specific revision. Because
4455 directories to their states as of a specific revision. Because
4457 revert does not change the working directory parents, this will
4456 revert does not change the working directory parents, this will
4458 cause these files to appear modified. This can be helpful to "back
4457 cause these files to appear modified. This can be helpful to "back
4459 out" some or all of an earlier change. See :hg:`backout` for a
4458 out" some or all of an earlier change. See :hg:`backout` for a
4460 related method.
4459 related method.
4461
4460
4462 Modified files are saved with a .orig suffix before reverting.
4461 Modified files are saved with a .orig suffix before reverting.
4463 To disable these backups, use --no-backup. It is possible to store
4462 To disable these backups, use --no-backup. It is possible to store
4464 the backup files in a custom directory relative to the root of the
4463 the backup files in a custom directory relative to the root of the
4465 repository by setting the ``ui.origbackuppath`` configuration
4464 repository by setting the ``ui.origbackuppath`` configuration
4466 option.
4465 option.
4467
4466
4468 See :hg:`help dates` for a list of formats valid for -d/--date.
4467 See :hg:`help dates` for a list of formats valid for -d/--date.
4469
4468
4470 See :hg:`help backout` for a way to reverse the effect of an
4469 See :hg:`help backout` for a way to reverse the effect of an
4471 earlier changeset.
4470 earlier changeset.
4472
4471
4473 Returns 0 on success.
4472 Returns 0 on success.
4474 """
4473 """
4475
4474
4476 if opts.get("date"):
4475 if opts.get("date"):
4477 if opts.get("rev"):
4476 if opts.get("rev"):
4478 raise error.Abort(_("you can't specify a revision and a date"))
4477 raise error.Abort(_("you can't specify a revision and a date"))
4479 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4478 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4480
4479
4481 parent, p2 = repo.dirstate.parents()
4480 parent, p2 = repo.dirstate.parents()
4482 if not opts.get('rev') and p2 != nullid:
4481 if not opts.get('rev') and p2 != nullid:
4483 # revert after merge is a trap for new users (issue2915)
4482 # revert after merge is a trap for new users (issue2915)
4484 raise error.Abort(_('uncommitted merge with no revision specified'),
4483 raise error.Abort(_('uncommitted merge with no revision specified'),
4485 hint=_("use 'hg update' or see 'hg help revert'"))
4484 hint=_("use 'hg update' or see 'hg help revert'"))
4486
4485
4487 ctx = scmutil.revsingle(repo, opts.get('rev'))
4486 ctx = scmutil.revsingle(repo, opts.get('rev'))
4488
4487
4489 if (not (pats or opts.get('include') or opts.get('exclude') or
4488 if (not (pats or opts.get('include') or opts.get('exclude') or
4490 opts.get('all') or opts.get('interactive'))):
4489 opts.get('all') or opts.get('interactive'))):
4491 msg = _("no files or directories specified")
4490 msg = _("no files or directories specified")
4492 if p2 != nullid:
4491 if p2 != nullid:
4493 hint = _("uncommitted merge, use --all to discard all changes,"
4492 hint = _("uncommitted merge, use --all to discard all changes,"
4494 " or 'hg update -C .' to abort the merge")
4493 " or 'hg update -C .' to abort the merge")
4495 raise error.Abort(msg, hint=hint)
4494 raise error.Abort(msg, hint=hint)
4496 dirty = any(repo.status())
4495 dirty = any(repo.status())
4497 node = ctx.node()
4496 node = ctx.node()
4498 if node != parent:
4497 if node != parent:
4499 if dirty:
4498 if dirty:
4500 hint = _("uncommitted changes, use --all to discard all"
4499 hint = _("uncommitted changes, use --all to discard all"
4501 " changes, or 'hg update %s' to update") % ctx.rev()
4500 " changes, or 'hg update %s' to update") % ctx.rev()
4502 else:
4501 else:
4503 hint = _("use --all to revert all files,"
4502 hint = _("use --all to revert all files,"
4504 " or 'hg update %s' to update") % ctx.rev()
4503 " or 'hg update %s' to update") % ctx.rev()
4505 elif dirty:
4504 elif dirty:
4506 hint = _("uncommitted changes, use --all to discard all changes")
4505 hint = _("uncommitted changes, use --all to discard all changes")
4507 else:
4506 else:
4508 hint = _("use --all to revert all files")
4507 hint = _("use --all to revert all files")
4509 raise error.Abort(msg, hint=hint)
4508 raise error.Abort(msg, hint=hint)
4510
4509
4511 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
4510 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
4512
4511
4513 @command('rollback', dryrunopts +
4512 @command('rollback', dryrunopts +
4514 [('f', 'force', False, _('ignore safety measures'))])
4513 [('f', 'force', False, _('ignore safety measures'))])
4515 def rollback(ui, repo, **opts):
4514 def rollback(ui, repo, **opts):
4516 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4515 """roll back the last transaction (DANGEROUS) (DEPRECATED)
4517
4516
4518 Please use :hg:`commit --amend` instead of rollback to correct
4517 Please use :hg:`commit --amend` instead of rollback to correct
4519 mistakes in the last commit.
4518 mistakes in the last commit.
4520
4519
4521 This command should be used with care. There is only one level of
4520 This command should be used with care. There is only one level of
4522 rollback, and there is no way to undo a rollback. It will also
4521 rollback, and there is no way to undo a rollback. It will also
4523 restore the dirstate at the time of the last transaction, losing
4522 restore the dirstate at the time of the last transaction, losing
4524 any dirstate changes since that time. This command does not alter
4523 any dirstate changes since that time. This command does not alter
4525 the working directory.
4524 the working directory.
4526
4525
4527 Transactions are used to encapsulate the effects of all commands
4526 Transactions are used to encapsulate the effects of all commands
4528 that create new changesets or propagate existing changesets into a
4527 that create new changesets or propagate existing changesets into a
4529 repository.
4528 repository.
4530
4529
4531 .. container:: verbose
4530 .. container:: verbose
4532
4531
4533 For example, the following commands are transactional, and their
4532 For example, the following commands are transactional, and their
4534 effects can be rolled back:
4533 effects can be rolled back:
4535
4534
4536 - commit
4535 - commit
4537 - import
4536 - import
4538 - pull
4537 - pull
4539 - push (with this repository as the destination)
4538 - push (with this repository as the destination)
4540 - unbundle
4539 - unbundle
4541
4540
4542 To avoid permanent data loss, rollback will refuse to rollback a
4541 To avoid permanent data loss, rollback will refuse to rollback a
4543 commit transaction if it isn't checked out. Use --force to
4542 commit transaction if it isn't checked out. Use --force to
4544 override this protection.
4543 override this protection.
4545
4544
4546 The rollback command can be entirely disabled by setting the
4545 The rollback command can be entirely disabled by setting the
4547 ``ui.rollback`` configuration setting to false. If you're here
4546 ``ui.rollback`` configuration setting to false. If you're here
4548 because you want to use rollback and it's disabled, you can
4547 because you want to use rollback and it's disabled, you can
4549 re-enable the command by setting ``ui.rollback`` to true.
4548 re-enable the command by setting ``ui.rollback`` to true.
4550
4549
4551 This command is not intended for use on public repositories. Once
4550 This command is not intended for use on public repositories. Once
4552 changes are visible for pull by other users, rolling a transaction
4551 changes are visible for pull by other users, rolling a transaction
4553 back locally is ineffective (someone else may already have pulled
4552 back locally is ineffective (someone else may already have pulled
4554 the changes). Furthermore, a race is possible with readers of the
4553 the changes). Furthermore, a race is possible with readers of the
4555 repository; for example an in-progress pull from the repository
4554 repository; for example an in-progress pull from the repository
4556 may fail if a rollback is performed.
4555 may fail if a rollback is performed.
4557
4556
4558 Returns 0 on success, 1 if no rollback data is available.
4557 Returns 0 on success, 1 if no rollback data is available.
4559 """
4558 """
4560 if not ui.configbool('ui', 'rollback', True):
4559 if not ui.configbool('ui', 'rollback', True):
4561 raise error.Abort(_('rollback is disabled because it is unsafe'),
4560 raise error.Abort(_('rollback is disabled because it is unsafe'),
4562 hint=('see `hg help -v rollback` for information'))
4561 hint=('see `hg help -v rollback` for information'))
4563 return repo.rollback(dryrun=opts.get('dry_run'),
4562 return repo.rollback(dryrun=opts.get('dry_run'),
4564 force=opts.get('force'))
4563 force=opts.get('force'))
4565
4564
4566 @command('root', [])
4565 @command('root', [])
4567 def root(ui, repo):
4566 def root(ui, repo):
4568 """print the root (top) of the current working directory
4567 """print the root (top) of the current working directory
4569
4568
4570 Print the root directory of the current repository.
4569 Print the root directory of the current repository.
4571
4570
4572 Returns 0 on success.
4571 Returns 0 on success.
4573 """
4572 """
4574 ui.write(repo.root + "\n")
4573 ui.write(repo.root + "\n")
4575
4574
4576 @command('^serve',
4575 @command('^serve',
4577 [('A', 'accesslog', '', _('name of access log file to write to'),
4576 [('A', 'accesslog', '', _('name of access log file to write to'),
4578 _('FILE')),
4577 _('FILE')),
4579 ('d', 'daemon', None, _('run server in background')),
4578 ('d', 'daemon', None, _('run server in background')),
4580 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4579 ('', 'daemon-postexec', [], _('used internally by daemon mode')),
4581 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4580 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
4582 # use string type, then we can check if something was passed
4581 # use string type, then we can check if something was passed
4583 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4582 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
4584 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4583 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
4585 _('ADDR')),
4584 _('ADDR')),
4586 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4585 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
4587 _('PREFIX')),
4586 _('PREFIX')),
4588 ('n', 'name', '',
4587 ('n', 'name', '',
4589 _('name to show in web pages (default: working directory)'), _('NAME')),
4588 _('name to show in web pages (default: working directory)'), _('NAME')),
4590 ('', 'web-conf', '',
4589 ('', 'web-conf', '',
4591 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4590 _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')),
4592 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4591 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
4593 _('FILE')),
4592 _('FILE')),
4594 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4593 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
4595 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4594 ('', 'stdio', None, _('for remote clients (ADVANCED)')),
4596 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4595 ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')),
4597 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4596 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4598 ('', 'style', '', _('template style to use'), _('STYLE')),
4597 ('', 'style', '', _('template style to use'), _('STYLE')),
4599 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4598 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4600 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
4599 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
4601 _('[OPTION]...'),
4600 _('[OPTION]...'),
4602 optionalrepo=True)
4601 optionalrepo=True)
4603 def serve(ui, repo, **opts):
4602 def serve(ui, repo, **opts):
4604 """start stand-alone webserver
4603 """start stand-alone webserver
4605
4604
4606 Start a local HTTP repository browser and pull server. You can use
4605 Start a local HTTP repository browser and pull server. You can use
4607 this for ad-hoc sharing and browsing of repositories. It is
4606 this for ad-hoc sharing and browsing of repositories. It is
4608 recommended to use a real web server to serve a repository for
4607 recommended to use a real web server to serve a repository for
4609 longer periods of time.
4608 longer periods of time.
4610
4609
4611 Please note that the server does not implement access control.
4610 Please note that the server does not implement access control.
4612 This means that, by default, anybody can read from the server and
4611 This means that, by default, anybody can read from the server and
4613 nobody can write to it by default. Set the ``web.allow_push``
4612 nobody can write to it by default. Set the ``web.allow_push``
4614 option to ``*`` to allow everybody to push to the server. You
4613 option to ``*`` to allow everybody to push to the server. You
4615 should use a real web server if you need to authenticate users.
4614 should use a real web server if you need to authenticate users.
4616
4615
4617 By default, the server logs accesses to stdout and errors to
4616 By default, the server logs accesses to stdout and errors to
4618 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4617 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
4619 files.
4618 files.
4620
4619
4621 To have the server choose a free port number to listen on, specify
4620 To have the server choose a free port number to listen on, specify
4622 a port number of 0; in this case, the server will print the port
4621 a port number of 0; in this case, the server will print the port
4623 number it uses.
4622 number it uses.
4624
4623
4625 Returns 0 on success.
4624 Returns 0 on success.
4626 """
4625 """
4627
4626
4628 if opts["stdio"] and opts["cmdserver"]:
4627 if opts["stdio"] and opts["cmdserver"]:
4629 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4628 raise error.Abort(_("cannot use --stdio with --cmdserver"))
4630
4629
4631 if opts["stdio"]:
4630 if opts["stdio"]:
4632 if repo is None:
4631 if repo is None:
4633 raise error.RepoError(_("there is no Mercurial repository here"
4632 raise error.RepoError(_("there is no Mercurial repository here"
4634 " (.hg not found)"))
4633 " (.hg not found)"))
4635 s = sshserver.sshserver(ui, repo)
4634 s = sshserver.sshserver(ui, repo)
4636 s.serve_forever()
4635 s.serve_forever()
4637
4636
4638 service = server.createservice(ui, repo, opts)
4637 service = server.createservice(ui, repo, opts)
4639 return server.runservice(opts, initfn=service.init, runfn=service.run)
4638 return server.runservice(opts, initfn=service.init, runfn=service.run)
4640
4639
4641 @command('^status|st',
4640 @command('^status|st',
4642 [('A', 'all', None, _('show status of all files')),
4641 [('A', 'all', None, _('show status of all files')),
4643 ('m', 'modified', None, _('show only modified files')),
4642 ('m', 'modified', None, _('show only modified files')),
4644 ('a', 'added', None, _('show only added files')),
4643 ('a', 'added', None, _('show only added files')),
4645 ('r', 'removed', None, _('show only removed files')),
4644 ('r', 'removed', None, _('show only removed files')),
4646 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4645 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4647 ('c', 'clean', None, _('show only files without changes')),
4646 ('c', 'clean', None, _('show only files without changes')),
4648 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4647 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4649 ('i', 'ignored', None, _('show only ignored files')),
4648 ('i', 'ignored', None, _('show only ignored files')),
4650 ('n', 'no-status', None, _('hide status prefix')),
4649 ('n', 'no-status', None, _('hide status prefix')),
4651 ('C', 'copies', None, _('show source of copied files')),
4650 ('C', 'copies', None, _('show source of copied files')),
4652 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4651 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4653 ('', 'rev', [], _('show difference from revision'), _('REV')),
4652 ('', 'rev', [], _('show difference from revision'), _('REV')),
4654 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4653 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
4655 ] + walkopts + subrepoopts + formatteropts,
4654 ] + walkopts + subrepoopts + formatteropts,
4656 _('[OPTION]... [FILE]...'),
4655 _('[OPTION]... [FILE]...'),
4657 inferrepo=True)
4656 inferrepo=True)
4658 def status(ui, repo, *pats, **opts):
4657 def status(ui, repo, *pats, **opts):
4659 """show changed files in the working directory
4658 """show changed files in the working directory
4660
4659
4661 Show status of files in the repository. If names are given, only
4660 Show status of files in the repository. If names are given, only
4662 files that match are shown. Files that are clean or ignored or
4661 files that match are shown. Files that are clean or ignored or
4663 the source of a copy/move operation, are not listed unless
4662 the source of a copy/move operation, are not listed unless
4664 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4663 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
4665 Unless options described with "show only ..." are given, the
4664 Unless options described with "show only ..." are given, the
4666 options -mardu are used.
4665 options -mardu are used.
4667
4666
4668 Option -q/--quiet hides untracked (unknown and ignored) files
4667 Option -q/--quiet hides untracked (unknown and ignored) files
4669 unless explicitly requested with -u/--unknown or -i/--ignored.
4668 unless explicitly requested with -u/--unknown or -i/--ignored.
4670
4669
4671 .. note::
4670 .. note::
4672
4671
4673 :hg:`status` may appear to disagree with diff if permissions have
4672 :hg:`status` may appear to disagree with diff if permissions have
4674 changed or a merge has occurred. The standard diff format does
4673 changed or a merge has occurred. The standard diff format does
4675 not report permission changes and diff only reports changes
4674 not report permission changes and diff only reports changes
4676 relative to one merge parent.
4675 relative to one merge parent.
4677
4676
4678 If one revision is given, it is used as the base revision.
4677 If one revision is given, it is used as the base revision.
4679 If two revisions are given, the differences between them are
4678 If two revisions are given, the differences between them are
4680 shown. The --change option can also be used as a shortcut to list
4679 shown. The --change option can also be used as a shortcut to list
4681 the changed files of a revision from its first parent.
4680 the changed files of a revision from its first parent.
4682
4681
4683 The codes used to show the status of files are::
4682 The codes used to show the status of files are::
4684
4683
4685 M = modified
4684 M = modified
4686 A = added
4685 A = added
4687 R = removed
4686 R = removed
4688 C = clean
4687 C = clean
4689 ! = missing (deleted by non-hg command, but still tracked)
4688 ! = missing (deleted by non-hg command, but still tracked)
4690 ? = not tracked
4689 ? = not tracked
4691 I = ignored
4690 I = ignored
4692 = origin of the previous file (with --copies)
4691 = origin of the previous file (with --copies)
4693
4692
4694 .. container:: verbose
4693 .. container:: verbose
4695
4694
4696 Examples:
4695 Examples:
4697
4696
4698 - show changes in the working directory relative to a
4697 - show changes in the working directory relative to a
4699 changeset::
4698 changeset::
4700
4699
4701 hg status --rev 9353
4700 hg status --rev 9353
4702
4701
4703 - show changes in the working directory relative to the
4702 - show changes in the working directory relative to the
4704 current directory (see :hg:`help patterns` for more information)::
4703 current directory (see :hg:`help patterns` for more information)::
4705
4704
4706 hg status re:
4705 hg status re:
4707
4706
4708 - show all changes including copies in an existing changeset::
4707 - show all changes including copies in an existing changeset::
4709
4708
4710 hg status --copies --change 9353
4709 hg status --copies --change 9353
4711
4710
4712 - get a NUL separated list of added files, suitable for xargs::
4711 - get a NUL separated list of added files, suitable for xargs::
4713
4712
4714 hg status -an0
4713 hg status -an0
4715
4714
4716 Returns 0 on success.
4715 Returns 0 on success.
4717 """
4716 """
4718
4717
4719 revs = opts.get('rev')
4718 revs = opts.get('rev')
4720 change = opts.get('change')
4719 change = opts.get('change')
4721
4720
4722 if revs and change:
4721 if revs and change:
4723 msg = _('cannot specify --rev and --change at the same time')
4722 msg = _('cannot specify --rev and --change at the same time')
4724 raise error.Abort(msg)
4723 raise error.Abort(msg)
4725 elif change:
4724 elif change:
4726 node2 = scmutil.revsingle(repo, change, None).node()
4725 node2 = scmutil.revsingle(repo, change, None).node()
4727 node1 = repo[node2].p1().node()
4726 node1 = repo[node2].p1().node()
4728 else:
4727 else:
4729 node1, node2 = scmutil.revpair(repo, revs)
4728 node1, node2 = scmutil.revpair(repo, revs)
4730
4729
4731 if pats:
4730 if pats:
4732 cwd = repo.getcwd()
4731 cwd = repo.getcwd()
4733 else:
4732 else:
4734 cwd = ''
4733 cwd = ''
4735
4734
4736 if opts.get('print0'):
4735 if opts.get('print0'):
4737 end = '\0'
4736 end = '\0'
4738 else:
4737 else:
4739 end = '\n'
4738 end = '\n'
4740 copy = {}
4739 copy = {}
4741 states = 'modified added removed deleted unknown ignored clean'.split()
4740 states = 'modified added removed deleted unknown ignored clean'.split()
4742 show = [k for k in states if opts.get(k)]
4741 show = [k for k in states if opts.get(k)]
4743 if opts.get('all'):
4742 if opts.get('all'):
4744 show += ui.quiet and (states[:4] + ['clean']) or states
4743 show += ui.quiet and (states[:4] + ['clean']) or states
4745 if not show:
4744 if not show:
4746 if ui.quiet:
4745 if ui.quiet:
4747 show = states[:4]
4746 show = states[:4]
4748 else:
4747 else:
4749 show = states[:5]
4748 show = states[:5]
4750
4749
4751 m = scmutil.match(repo[node2], pats, opts)
4750 m = scmutil.match(repo[node2], pats, opts)
4752 stat = repo.status(node1, node2, m,
4751 stat = repo.status(node1, node2, m,
4753 'ignored' in show, 'clean' in show, 'unknown' in show,
4752 'ignored' in show, 'clean' in show, 'unknown' in show,
4754 opts.get('subrepos'))
4753 opts.get('subrepos'))
4755 changestates = zip(states, 'MAR!?IC', stat)
4754 changestates = zip(states, 'MAR!?IC', stat)
4756
4755
4757 if (opts.get('all') or opts.get('copies')
4756 if (opts.get('all') or opts.get('copies')
4758 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4757 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
4759 copy = copies.pathcopies(repo[node1], repo[node2], m)
4758 copy = copies.pathcopies(repo[node1], repo[node2], m)
4760
4759
4761 ui.pager('status')
4760 ui.pager('status')
4762 fm = ui.formatter('status', opts)
4761 fm = ui.formatter('status', opts)
4763 fmt = '%s' + end
4762 fmt = '%s' + end
4764 showchar = not opts.get('no_status')
4763 showchar = not opts.get('no_status')
4765
4764
4766 for state, char, files in changestates:
4765 for state, char, files in changestates:
4767 if state in show:
4766 if state in show:
4768 label = 'status.' + state
4767 label = 'status.' + state
4769 for f in files:
4768 for f in files:
4770 fm.startitem()
4769 fm.startitem()
4771 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4770 fm.condwrite(showchar, 'status', '%s ', char, label=label)
4772 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4771 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
4773 if f in copy:
4772 if f in copy:
4774 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4773 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
4775 label='status.copied')
4774 label='status.copied')
4776 fm.end()
4775 fm.end()
4777
4776
4778 @command('^summary|sum',
4777 @command('^summary|sum',
4779 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
4778 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
4780 def summary(ui, repo, **opts):
4779 def summary(ui, repo, **opts):
4781 """summarize working directory state
4780 """summarize working directory state
4782
4781
4783 This generates a brief summary of the working directory state,
4782 This generates a brief summary of the working directory state,
4784 including parents, branch, commit status, phase and available updates.
4783 including parents, branch, commit status, phase and available updates.
4785
4784
4786 With the --remote option, this will check the default paths for
4785 With the --remote option, this will check the default paths for
4787 incoming and outgoing changes. This can be time-consuming.
4786 incoming and outgoing changes. This can be time-consuming.
4788
4787
4789 Returns 0 on success.
4788 Returns 0 on success.
4790 """
4789 """
4791
4790
4792 ui.pager('summary')
4791 ui.pager('summary')
4793 ctx = repo[None]
4792 ctx = repo[None]
4794 parents = ctx.parents()
4793 parents = ctx.parents()
4795 pnode = parents[0].node()
4794 pnode = parents[0].node()
4796 marks = []
4795 marks = []
4797
4796
4798 ms = None
4797 ms = None
4799 try:
4798 try:
4800 ms = mergemod.mergestate.read(repo)
4799 ms = mergemod.mergestate.read(repo)
4801 except error.UnsupportedMergeRecords as e:
4800 except error.UnsupportedMergeRecords as e:
4802 s = ' '.join(e.recordtypes)
4801 s = ' '.join(e.recordtypes)
4803 ui.warn(
4802 ui.warn(
4804 _('warning: merge state has unsupported record types: %s\n') % s)
4803 _('warning: merge state has unsupported record types: %s\n') % s)
4805 unresolved = 0
4804 unresolved = 0
4806 else:
4805 else:
4807 unresolved = [f for f in ms if ms[f] == 'u']
4806 unresolved = [f for f in ms if ms[f] == 'u']
4808
4807
4809 for p in parents:
4808 for p in parents:
4810 # label with log.changeset (instead of log.parent) since this
4809 # label with log.changeset (instead of log.parent) since this
4811 # shows a working directory parent *changeset*:
4810 # shows a working directory parent *changeset*:
4812 # i18n: column positioning for "hg summary"
4811 # i18n: column positioning for "hg summary"
4813 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
4812 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
4814 label=cmdutil._changesetlabels(p))
4813 label=cmdutil._changesetlabels(p))
4815 ui.write(' '.join(p.tags()), label='log.tag')
4814 ui.write(' '.join(p.tags()), label='log.tag')
4816 if p.bookmarks():
4815 if p.bookmarks():
4817 marks.extend(p.bookmarks())
4816 marks.extend(p.bookmarks())
4818 if p.rev() == -1:
4817 if p.rev() == -1:
4819 if not len(repo):
4818 if not len(repo):
4820 ui.write(_(' (empty repository)'))
4819 ui.write(_(' (empty repository)'))
4821 else:
4820 else:
4822 ui.write(_(' (no revision checked out)'))
4821 ui.write(_(' (no revision checked out)'))
4823 if p.troubled():
4822 if p.troubled():
4824 ui.write(' ('
4823 ui.write(' ('
4825 + ', '.join(ui.label(trouble, 'trouble.%s' % trouble)
4824 + ', '.join(ui.label(trouble, 'trouble.%s' % trouble)
4826 for trouble in p.troubles())
4825 for trouble in p.troubles())
4827 + ')')
4826 + ')')
4828 ui.write('\n')
4827 ui.write('\n')
4829 if p.description():
4828 if p.description():
4830 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
4829 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
4831 label='log.summary')
4830 label='log.summary')
4832
4831
4833 branch = ctx.branch()
4832 branch = ctx.branch()
4834 bheads = repo.branchheads(branch)
4833 bheads = repo.branchheads(branch)
4835 # i18n: column positioning for "hg summary"
4834 # i18n: column positioning for "hg summary"
4836 m = _('branch: %s\n') % branch
4835 m = _('branch: %s\n') % branch
4837 if branch != 'default':
4836 if branch != 'default':
4838 ui.write(m, label='log.branch')
4837 ui.write(m, label='log.branch')
4839 else:
4838 else:
4840 ui.status(m, label='log.branch')
4839 ui.status(m, label='log.branch')
4841
4840
4842 if marks:
4841 if marks:
4843 active = repo._activebookmark
4842 active = repo._activebookmark
4844 # i18n: column positioning for "hg summary"
4843 # i18n: column positioning for "hg summary"
4845 ui.write(_('bookmarks:'), label='log.bookmark')
4844 ui.write(_('bookmarks:'), label='log.bookmark')
4846 if active is not None:
4845 if active is not None:
4847 if active in marks:
4846 if active in marks:
4848 ui.write(' *' + active, label=activebookmarklabel)
4847 ui.write(' *' + active, label=activebookmarklabel)
4849 marks.remove(active)
4848 marks.remove(active)
4850 else:
4849 else:
4851 ui.write(' [%s]' % active, label=activebookmarklabel)
4850 ui.write(' [%s]' % active, label=activebookmarklabel)
4852 for m in marks:
4851 for m in marks:
4853 ui.write(' ' + m, label='log.bookmark')
4852 ui.write(' ' + m, label='log.bookmark')
4854 ui.write('\n', label='log.bookmark')
4853 ui.write('\n', label='log.bookmark')
4855
4854
4856 status = repo.status(unknown=True)
4855 status = repo.status(unknown=True)
4857
4856
4858 c = repo.dirstate.copies()
4857 c = repo.dirstate.copies()
4859 copied, renamed = [], []
4858 copied, renamed = [], []
4860 for d, s in c.iteritems():
4859 for d, s in c.iteritems():
4861 if s in status.removed:
4860 if s in status.removed:
4862 status.removed.remove(s)
4861 status.removed.remove(s)
4863 renamed.append(d)
4862 renamed.append(d)
4864 else:
4863 else:
4865 copied.append(d)
4864 copied.append(d)
4866 if d in status.added:
4865 if d in status.added:
4867 status.added.remove(d)
4866 status.added.remove(d)
4868
4867
4869 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
4868 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
4870
4869
4871 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
4870 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
4872 (ui.label(_('%d added'), 'status.added'), status.added),
4871 (ui.label(_('%d added'), 'status.added'), status.added),
4873 (ui.label(_('%d removed'), 'status.removed'), status.removed),
4872 (ui.label(_('%d removed'), 'status.removed'), status.removed),
4874 (ui.label(_('%d renamed'), 'status.copied'), renamed),
4873 (ui.label(_('%d renamed'), 'status.copied'), renamed),
4875 (ui.label(_('%d copied'), 'status.copied'), copied),
4874 (ui.label(_('%d copied'), 'status.copied'), copied),
4876 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
4875 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
4877 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
4876 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
4878 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
4877 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
4879 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
4878 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
4880 t = []
4879 t = []
4881 for l, s in labels:
4880 for l, s in labels:
4882 if s:
4881 if s:
4883 t.append(l % len(s))
4882 t.append(l % len(s))
4884
4883
4885 t = ', '.join(t)
4884 t = ', '.join(t)
4886 cleanworkdir = False
4885 cleanworkdir = False
4887
4886
4888 if repo.vfs.exists('graftstate'):
4887 if repo.vfs.exists('graftstate'):
4889 t += _(' (graft in progress)')
4888 t += _(' (graft in progress)')
4890 if repo.vfs.exists('updatestate'):
4889 if repo.vfs.exists('updatestate'):
4891 t += _(' (interrupted update)')
4890 t += _(' (interrupted update)')
4892 elif len(parents) > 1:
4891 elif len(parents) > 1:
4893 t += _(' (merge)')
4892 t += _(' (merge)')
4894 elif branch != parents[0].branch():
4893 elif branch != parents[0].branch():
4895 t += _(' (new branch)')
4894 t += _(' (new branch)')
4896 elif (parents[0].closesbranch() and
4895 elif (parents[0].closesbranch() and
4897 pnode in repo.branchheads(branch, closed=True)):
4896 pnode in repo.branchheads(branch, closed=True)):
4898 t += _(' (head closed)')
4897 t += _(' (head closed)')
4899 elif not (status.modified or status.added or status.removed or renamed or
4898 elif not (status.modified or status.added or status.removed or renamed or
4900 copied or subs):
4899 copied or subs):
4901 t += _(' (clean)')
4900 t += _(' (clean)')
4902 cleanworkdir = True
4901 cleanworkdir = True
4903 elif pnode not in bheads:
4902 elif pnode not in bheads:
4904 t += _(' (new branch head)')
4903 t += _(' (new branch head)')
4905
4904
4906 if parents:
4905 if parents:
4907 pendingphase = max(p.phase() for p in parents)
4906 pendingphase = max(p.phase() for p in parents)
4908 else:
4907 else:
4909 pendingphase = phases.public
4908 pendingphase = phases.public
4910
4909
4911 if pendingphase > phases.newcommitphase(ui):
4910 if pendingphase > phases.newcommitphase(ui):
4912 t += ' (%s)' % phases.phasenames[pendingphase]
4911 t += ' (%s)' % phases.phasenames[pendingphase]
4913
4912
4914 if cleanworkdir:
4913 if cleanworkdir:
4915 # i18n: column positioning for "hg summary"
4914 # i18n: column positioning for "hg summary"
4916 ui.status(_('commit: %s\n') % t.strip())
4915 ui.status(_('commit: %s\n') % t.strip())
4917 else:
4916 else:
4918 # i18n: column positioning for "hg summary"
4917 # i18n: column positioning for "hg summary"
4919 ui.write(_('commit: %s\n') % t.strip())
4918 ui.write(_('commit: %s\n') % t.strip())
4920
4919
4921 # all ancestors of branch heads - all ancestors of parent = new csets
4920 # all ancestors of branch heads - all ancestors of parent = new csets
4922 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
4921 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
4923 bheads))
4922 bheads))
4924
4923
4925 if new == 0:
4924 if new == 0:
4926 # i18n: column positioning for "hg summary"
4925 # i18n: column positioning for "hg summary"
4927 ui.status(_('update: (current)\n'))
4926 ui.status(_('update: (current)\n'))
4928 elif pnode not in bheads:
4927 elif pnode not in bheads:
4929 # i18n: column positioning for "hg summary"
4928 # i18n: column positioning for "hg summary"
4930 ui.write(_('update: %d new changesets (update)\n') % new)
4929 ui.write(_('update: %d new changesets (update)\n') % new)
4931 else:
4930 else:
4932 # i18n: column positioning for "hg summary"
4931 # i18n: column positioning for "hg summary"
4933 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
4932 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
4934 (new, len(bheads)))
4933 (new, len(bheads)))
4935
4934
4936 t = []
4935 t = []
4937 draft = len(repo.revs('draft()'))
4936 draft = len(repo.revs('draft()'))
4938 if draft:
4937 if draft:
4939 t.append(_('%d draft') % draft)
4938 t.append(_('%d draft') % draft)
4940 secret = len(repo.revs('secret()'))
4939 secret = len(repo.revs('secret()'))
4941 if secret:
4940 if secret:
4942 t.append(_('%d secret') % secret)
4941 t.append(_('%d secret') % secret)
4943
4942
4944 if draft or secret:
4943 if draft or secret:
4945 ui.status(_('phases: %s\n') % ', '.join(t))
4944 ui.status(_('phases: %s\n') % ', '.join(t))
4946
4945
4947 if obsolete.isenabled(repo, obsolete.createmarkersopt):
4946 if obsolete.isenabled(repo, obsolete.createmarkersopt):
4948 for trouble in ("unstable", "divergent", "bumped"):
4947 for trouble in ("unstable", "divergent", "bumped"):
4949 numtrouble = len(repo.revs(trouble + "()"))
4948 numtrouble = len(repo.revs(trouble + "()"))
4950 # We write all the possibilities to ease translation
4949 # We write all the possibilities to ease translation
4951 troublemsg = {
4950 troublemsg = {
4952 "unstable": _("unstable: %d changesets"),
4951 "unstable": _("unstable: %d changesets"),
4953 "divergent": _("divergent: %d changesets"),
4952 "divergent": _("divergent: %d changesets"),
4954 "bumped": _("bumped: %d changesets"),
4953 "bumped": _("bumped: %d changesets"),
4955 }
4954 }
4956 if numtrouble > 0:
4955 if numtrouble > 0:
4957 ui.status(troublemsg[trouble] % numtrouble + "\n")
4956 ui.status(troublemsg[trouble] % numtrouble + "\n")
4958
4957
4959 cmdutil.summaryhooks(ui, repo)
4958 cmdutil.summaryhooks(ui, repo)
4960
4959
4961 if opts.get('remote'):
4960 if opts.get('remote'):
4962 needsincoming, needsoutgoing = True, True
4961 needsincoming, needsoutgoing = True, True
4963 else:
4962 else:
4964 needsincoming, needsoutgoing = False, False
4963 needsincoming, needsoutgoing = False, False
4965 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
4964 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
4966 if i:
4965 if i:
4967 needsincoming = True
4966 needsincoming = True
4968 if o:
4967 if o:
4969 needsoutgoing = True
4968 needsoutgoing = True
4970 if not needsincoming and not needsoutgoing:
4969 if not needsincoming and not needsoutgoing:
4971 return
4970 return
4972
4971
4973 def getincoming():
4972 def getincoming():
4974 source, branches = hg.parseurl(ui.expandpath('default'))
4973 source, branches = hg.parseurl(ui.expandpath('default'))
4975 sbranch = branches[0]
4974 sbranch = branches[0]
4976 try:
4975 try:
4977 other = hg.peer(repo, {}, source)
4976 other = hg.peer(repo, {}, source)
4978 except error.RepoError:
4977 except error.RepoError:
4979 if opts.get('remote'):
4978 if opts.get('remote'):
4980 raise
4979 raise
4981 return source, sbranch, None, None, None
4980 return source, sbranch, None, None, None
4982 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
4981 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
4983 if revs:
4982 if revs:
4984 revs = [other.lookup(rev) for rev in revs]
4983 revs = [other.lookup(rev) for rev in revs]
4985 ui.debug('comparing with %s\n' % util.hidepassword(source))
4984 ui.debug('comparing with %s\n' % util.hidepassword(source))
4986 repo.ui.pushbuffer()
4985 repo.ui.pushbuffer()
4987 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
4986 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
4988 repo.ui.popbuffer()
4987 repo.ui.popbuffer()
4989 return source, sbranch, other, commoninc, commoninc[1]
4988 return source, sbranch, other, commoninc, commoninc[1]
4990
4989
4991 if needsincoming:
4990 if needsincoming:
4992 source, sbranch, sother, commoninc, incoming = getincoming()
4991 source, sbranch, sother, commoninc, incoming = getincoming()
4993 else:
4992 else:
4994 source = sbranch = sother = commoninc = incoming = None
4993 source = sbranch = sother = commoninc = incoming = None
4995
4994
4996 def getoutgoing():
4995 def getoutgoing():
4997 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
4996 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
4998 dbranch = branches[0]
4997 dbranch = branches[0]
4999 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
4998 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5000 if source != dest:
4999 if source != dest:
5001 try:
5000 try:
5002 dother = hg.peer(repo, {}, dest)
5001 dother = hg.peer(repo, {}, dest)
5003 except error.RepoError:
5002 except error.RepoError:
5004 if opts.get('remote'):
5003 if opts.get('remote'):
5005 raise
5004 raise
5006 return dest, dbranch, None, None
5005 return dest, dbranch, None, None
5007 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5006 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5008 elif sother is None:
5007 elif sother is None:
5009 # there is no explicit destination peer, but source one is invalid
5008 # there is no explicit destination peer, but source one is invalid
5010 return dest, dbranch, None, None
5009 return dest, dbranch, None, None
5011 else:
5010 else:
5012 dother = sother
5011 dother = sother
5013 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5012 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5014 common = None
5013 common = None
5015 else:
5014 else:
5016 common = commoninc
5015 common = commoninc
5017 if revs:
5016 if revs:
5018 revs = [repo.lookup(rev) for rev in revs]
5017 revs = [repo.lookup(rev) for rev in revs]
5019 repo.ui.pushbuffer()
5018 repo.ui.pushbuffer()
5020 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5019 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5021 commoninc=common)
5020 commoninc=common)
5022 repo.ui.popbuffer()
5021 repo.ui.popbuffer()
5023 return dest, dbranch, dother, outgoing
5022 return dest, dbranch, dother, outgoing
5024
5023
5025 if needsoutgoing:
5024 if needsoutgoing:
5026 dest, dbranch, dother, outgoing = getoutgoing()
5025 dest, dbranch, dother, outgoing = getoutgoing()
5027 else:
5026 else:
5028 dest = dbranch = dother = outgoing = None
5027 dest = dbranch = dother = outgoing = None
5029
5028
5030 if opts.get('remote'):
5029 if opts.get('remote'):
5031 t = []
5030 t = []
5032 if incoming:
5031 if incoming:
5033 t.append(_('1 or more incoming'))
5032 t.append(_('1 or more incoming'))
5034 o = outgoing.missing
5033 o = outgoing.missing
5035 if o:
5034 if o:
5036 t.append(_('%d outgoing') % len(o))
5035 t.append(_('%d outgoing') % len(o))
5037 other = dother or sother
5036 other = dother or sother
5038 if 'bookmarks' in other.listkeys('namespaces'):
5037 if 'bookmarks' in other.listkeys('namespaces'):
5039 counts = bookmarks.summary(repo, other)
5038 counts = bookmarks.summary(repo, other)
5040 if counts[0] > 0:
5039 if counts[0] > 0:
5041 t.append(_('%d incoming bookmarks') % counts[0])
5040 t.append(_('%d incoming bookmarks') % counts[0])
5042 if counts[1] > 0:
5041 if counts[1] > 0:
5043 t.append(_('%d outgoing bookmarks') % counts[1])
5042 t.append(_('%d outgoing bookmarks') % counts[1])
5044
5043
5045 if t:
5044 if t:
5046 # i18n: column positioning for "hg summary"
5045 # i18n: column positioning for "hg summary"
5047 ui.write(_('remote: %s\n') % (', '.join(t)))
5046 ui.write(_('remote: %s\n') % (', '.join(t)))
5048 else:
5047 else:
5049 # i18n: column positioning for "hg summary"
5048 # i18n: column positioning for "hg summary"
5050 ui.status(_('remote: (synced)\n'))
5049 ui.status(_('remote: (synced)\n'))
5051
5050
5052 cmdutil.summaryremotehooks(ui, repo, opts,
5051 cmdutil.summaryremotehooks(ui, repo, opts,
5053 ((source, sbranch, sother, commoninc),
5052 ((source, sbranch, sother, commoninc),
5054 (dest, dbranch, dother, outgoing)))
5053 (dest, dbranch, dother, outgoing)))
5055
5054
5056 @command('tag',
5055 @command('tag',
5057 [('f', 'force', None, _('force tag')),
5056 [('f', 'force', None, _('force tag')),
5058 ('l', 'local', None, _('make the tag local')),
5057 ('l', 'local', None, _('make the tag local')),
5059 ('r', 'rev', '', _('revision to tag'), _('REV')),
5058 ('r', 'rev', '', _('revision to tag'), _('REV')),
5060 ('', 'remove', None, _('remove a tag')),
5059 ('', 'remove', None, _('remove a tag')),
5061 # -l/--local is already there, commitopts cannot be used
5060 # -l/--local is already there, commitopts cannot be used
5062 ('e', 'edit', None, _('invoke editor on commit messages')),
5061 ('e', 'edit', None, _('invoke editor on commit messages')),
5063 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5062 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
5064 ] + commitopts2,
5063 ] + commitopts2,
5065 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5064 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5066 def tag(ui, repo, name1, *names, **opts):
5065 def tag(ui, repo, name1, *names, **opts):
5067 """add one or more tags for the current or given revision
5066 """add one or more tags for the current or given revision
5068
5067
5069 Name a particular revision using <name>.
5068 Name a particular revision using <name>.
5070
5069
5071 Tags are used to name particular revisions of the repository and are
5070 Tags are used to name particular revisions of the repository and are
5072 very useful to compare different revisions, to go back to significant
5071 very useful to compare different revisions, to go back to significant
5073 earlier versions or to mark branch points as releases, etc. Changing
5072 earlier versions or to mark branch points as releases, etc. Changing
5074 an existing tag is normally disallowed; use -f/--force to override.
5073 an existing tag is normally disallowed; use -f/--force to override.
5075
5074
5076 If no revision is given, the parent of the working directory is
5075 If no revision is given, the parent of the working directory is
5077 used.
5076 used.
5078
5077
5079 To facilitate version control, distribution, and merging of tags,
5078 To facilitate version control, distribution, and merging of tags,
5080 they are stored as a file named ".hgtags" which is managed similarly
5079 they are stored as a file named ".hgtags" which is managed similarly
5081 to other project files and can be hand-edited if necessary. This
5080 to other project files and can be hand-edited if necessary. This
5082 also means that tagging creates a new commit. The file
5081 also means that tagging creates a new commit. The file
5083 ".hg/localtags" is used for local tags (not shared among
5082 ".hg/localtags" is used for local tags (not shared among
5084 repositories).
5083 repositories).
5085
5084
5086 Tag commits are usually made at the head of a branch. If the parent
5085 Tag commits are usually made at the head of a branch. If the parent
5087 of the working directory is not a branch head, :hg:`tag` aborts; use
5086 of the working directory is not a branch head, :hg:`tag` aborts; use
5088 -f/--force to force the tag commit to be based on a non-head
5087 -f/--force to force the tag commit to be based on a non-head
5089 changeset.
5088 changeset.
5090
5089
5091 See :hg:`help dates` for a list of formats valid for -d/--date.
5090 See :hg:`help dates` for a list of formats valid for -d/--date.
5092
5091
5093 Since tag names have priority over branch names during revision
5092 Since tag names have priority over branch names during revision
5094 lookup, using an existing branch name as a tag name is discouraged.
5093 lookup, using an existing branch name as a tag name is discouraged.
5095
5094
5096 Returns 0 on success.
5095 Returns 0 on success.
5097 """
5096 """
5098 wlock = lock = None
5097 wlock = lock = None
5099 try:
5098 try:
5100 wlock = repo.wlock()
5099 wlock = repo.wlock()
5101 lock = repo.lock()
5100 lock = repo.lock()
5102 rev_ = "."
5101 rev_ = "."
5103 names = [t.strip() for t in (name1,) + names]
5102 names = [t.strip() for t in (name1,) + names]
5104 if len(names) != len(set(names)):
5103 if len(names) != len(set(names)):
5105 raise error.Abort(_('tag names must be unique'))
5104 raise error.Abort(_('tag names must be unique'))
5106 for n in names:
5105 for n in names:
5107 scmutil.checknewlabel(repo, n, 'tag')
5106 scmutil.checknewlabel(repo, n, 'tag')
5108 if not n:
5107 if not n:
5109 raise error.Abort(_('tag names cannot consist entirely of '
5108 raise error.Abort(_('tag names cannot consist entirely of '
5110 'whitespace'))
5109 'whitespace'))
5111 if opts.get('rev') and opts.get('remove'):
5110 if opts.get('rev') and opts.get('remove'):
5112 raise error.Abort(_("--rev and --remove are incompatible"))
5111 raise error.Abort(_("--rev and --remove are incompatible"))
5113 if opts.get('rev'):
5112 if opts.get('rev'):
5114 rev_ = opts['rev']
5113 rev_ = opts['rev']
5115 message = opts.get('message')
5114 message = opts.get('message')
5116 if opts.get('remove'):
5115 if opts.get('remove'):
5117 if opts.get('local'):
5116 if opts.get('local'):
5118 expectedtype = 'local'
5117 expectedtype = 'local'
5119 else:
5118 else:
5120 expectedtype = 'global'
5119 expectedtype = 'global'
5121
5120
5122 for n in names:
5121 for n in names:
5123 if not repo.tagtype(n):
5122 if not repo.tagtype(n):
5124 raise error.Abort(_("tag '%s' does not exist") % n)
5123 raise error.Abort(_("tag '%s' does not exist") % n)
5125 if repo.tagtype(n) != expectedtype:
5124 if repo.tagtype(n) != expectedtype:
5126 if expectedtype == 'global':
5125 if expectedtype == 'global':
5127 raise error.Abort(_("tag '%s' is not a global tag") % n)
5126 raise error.Abort(_("tag '%s' is not a global tag") % n)
5128 else:
5127 else:
5129 raise error.Abort(_("tag '%s' is not a local tag") % n)
5128 raise error.Abort(_("tag '%s' is not a local tag") % n)
5130 rev_ = 'null'
5129 rev_ = 'null'
5131 if not message:
5130 if not message:
5132 # we don't translate commit messages
5131 # we don't translate commit messages
5133 message = 'Removed tag %s' % ', '.join(names)
5132 message = 'Removed tag %s' % ', '.join(names)
5134 elif not opts.get('force'):
5133 elif not opts.get('force'):
5135 for n in names:
5134 for n in names:
5136 if n in repo.tags():
5135 if n in repo.tags():
5137 raise error.Abort(_("tag '%s' already exists "
5136 raise error.Abort(_("tag '%s' already exists "
5138 "(use -f to force)") % n)
5137 "(use -f to force)") % n)
5139 if not opts.get('local'):
5138 if not opts.get('local'):
5140 p1, p2 = repo.dirstate.parents()
5139 p1, p2 = repo.dirstate.parents()
5141 if p2 != nullid:
5140 if p2 != nullid:
5142 raise error.Abort(_('uncommitted merge'))
5141 raise error.Abort(_('uncommitted merge'))
5143 bheads = repo.branchheads()
5142 bheads = repo.branchheads()
5144 if not opts.get('force') and bheads and p1 not in bheads:
5143 if not opts.get('force') and bheads and p1 not in bheads:
5145 raise error.Abort(_('working directory is not at a branch head '
5144 raise error.Abort(_('working directory is not at a branch head '
5146 '(use -f to force)'))
5145 '(use -f to force)'))
5147 r = scmutil.revsingle(repo, rev_).node()
5146 r = scmutil.revsingle(repo, rev_).node()
5148
5147
5149 if not message:
5148 if not message:
5150 # we don't translate commit messages
5149 # we don't translate commit messages
5151 message = ('Added tag %s for changeset %s' %
5150 message = ('Added tag %s for changeset %s' %
5152 (', '.join(names), short(r)))
5151 (', '.join(names), short(r)))
5153
5152
5154 date = opts.get('date')
5153 date = opts.get('date')
5155 if date:
5154 if date:
5156 date = util.parsedate(date)
5155 date = util.parsedate(date)
5157
5156
5158 if opts.get('remove'):
5157 if opts.get('remove'):
5159 editform = 'tag.remove'
5158 editform = 'tag.remove'
5160 else:
5159 else:
5161 editform = 'tag.add'
5160 editform = 'tag.add'
5162 editor = cmdutil.getcommiteditor(editform=editform, **opts)
5161 editor = cmdutil.getcommiteditor(editform=editform, **opts)
5163
5162
5164 # don't allow tagging the null rev
5163 # don't allow tagging the null rev
5165 if (not opts.get('remove') and
5164 if (not opts.get('remove') and
5166 scmutil.revsingle(repo, rev_).rev() == nullrev):
5165 scmutil.revsingle(repo, rev_).rev() == nullrev):
5167 raise error.Abort(_("cannot tag null revision"))
5166 raise error.Abort(_("cannot tag null revision"))
5168
5167
5169 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
5168 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
5170 editor=editor)
5169 editor=editor)
5171 finally:
5170 finally:
5172 release(lock, wlock)
5171 release(lock, wlock)
5173
5172
5174 @command('tags', formatteropts, '')
5173 @command('tags', formatteropts, '')
5175 def tags(ui, repo, **opts):
5174 def tags(ui, repo, **opts):
5176 """list repository tags
5175 """list repository tags
5177
5176
5178 This lists both regular and local tags. When the -v/--verbose
5177 This lists both regular and local tags. When the -v/--verbose
5179 switch is used, a third column "local" is printed for local tags.
5178 switch is used, a third column "local" is printed for local tags.
5180 When the -q/--quiet switch is used, only the tag name is printed.
5179 When the -q/--quiet switch is used, only the tag name is printed.
5181
5180
5182 Returns 0 on success.
5181 Returns 0 on success.
5183 """
5182 """
5184
5183
5185 ui.pager('tags')
5184 ui.pager('tags')
5186 fm = ui.formatter('tags', opts)
5185 fm = ui.formatter('tags', opts)
5187 hexfunc = fm.hexfunc
5186 hexfunc = fm.hexfunc
5188 tagtype = ""
5187 tagtype = ""
5189
5188
5190 for t, n in reversed(repo.tagslist()):
5189 for t, n in reversed(repo.tagslist()):
5191 hn = hexfunc(n)
5190 hn = hexfunc(n)
5192 label = 'tags.normal'
5191 label = 'tags.normal'
5193 tagtype = ''
5192 tagtype = ''
5194 if repo.tagtype(t) == 'local':
5193 if repo.tagtype(t) == 'local':
5195 label = 'tags.local'
5194 label = 'tags.local'
5196 tagtype = 'local'
5195 tagtype = 'local'
5197
5196
5198 fm.startitem()
5197 fm.startitem()
5199 fm.write('tag', '%s', t, label=label)
5198 fm.write('tag', '%s', t, label=label)
5200 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5199 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5201 fm.condwrite(not ui.quiet, 'rev node', fmt,
5200 fm.condwrite(not ui.quiet, 'rev node', fmt,
5202 repo.changelog.rev(n), hn, label=label)
5201 repo.changelog.rev(n), hn, label=label)
5203 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5202 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5204 tagtype, label=label)
5203 tagtype, label=label)
5205 fm.plain('\n')
5204 fm.plain('\n')
5206 fm.end()
5205 fm.end()
5207
5206
5208 @command('tip',
5207 @command('tip',
5209 [('p', 'patch', None, _('show patch')),
5208 [('p', 'patch', None, _('show patch')),
5210 ('g', 'git', None, _('use git extended diff format')),
5209 ('g', 'git', None, _('use git extended diff format')),
5211 ] + templateopts,
5210 ] + templateopts,
5212 _('[-p] [-g]'))
5211 _('[-p] [-g]'))
5213 def tip(ui, repo, **opts):
5212 def tip(ui, repo, **opts):
5214 """show the tip revision (DEPRECATED)
5213 """show the tip revision (DEPRECATED)
5215
5214
5216 The tip revision (usually just called the tip) is the changeset
5215 The tip revision (usually just called the tip) is the changeset
5217 most recently added to the repository (and therefore the most
5216 most recently added to the repository (and therefore the most
5218 recently changed head).
5217 recently changed head).
5219
5218
5220 If you have just made a commit, that commit will be the tip. If
5219 If you have just made a commit, that commit will be the tip. If
5221 you have just pulled changes from another repository, the tip of
5220 you have just pulled changes from another repository, the tip of
5222 that repository becomes the current tip. The "tip" tag is special
5221 that repository becomes the current tip. The "tip" tag is special
5223 and cannot be renamed or assigned to a different changeset.
5222 and cannot be renamed or assigned to a different changeset.
5224
5223
5225 This command is deprecated, please use :hg:`heads` instead.
5224 This command is deprecated, please use :hg:`heads` instead.
5226
5225
5227 Returns 0 on success.
5226 Returns 0 on success.
5228 """
5227 """
5229 displayer = cmdutil.show_changeset(ui, repo, opts)
5228 displayer = cmdutil.show_changeset(ui, repo, opts)
5230 displayer.show(repo['tip'])
5229 displayer.show(repo['tip'])
5231 displayer.close()
5230 displayer.close()
5232
5231
5233 @command('unbundle',
5232 @command('unbundle',
5234 [('u', 'update', None,
5233 [('u', 'update', None,
5235 _('update to new branch head if changesets were unbundled'))],
5234 _('update to new branch head if changesets were unbundled'))],
5236 _('[-u] FILE...'))
5235 _('[-u] FILE...'))
5237 def unbundle(ui, repo, fname1, *fnames, **opts):
5236 def unbundle(ui, repo, fname1, *fnames, **opts):
5238 """apply one or more changegroup files
5237 """apply one or more changegroup files
5239
5238
5240 Apply one or more compressed changegroup files generated by the
5239 Apply one or more compressed changegroup files generated by the
5241 bundle command.
5240 bundle command.
5242
5241
5243 Returns 0 on success, 1 if an update has unresolved files.
5242 Returns 0 on success, 1 if an update has unresolved files.
5244 """
5243 """
5245 fnames = (fname1,) + fnames
5244 fnames = (fname1,) + fnames
5246
5245
5247 with repo.lock():
5246 with repo.lock():
5248 for fname in fnames:
5247 for fname in fnames:
5249 f = hg.openpath(ui, fname)
5248 f = hg.openpath(ui, fname)
5250 gen = exchange.readbundle(ui, f, fname)
5249 gen = exchange.readbundle(ui, f, fname)
5251 if isinstance(gen, bundle2.unbundle20):
5250 if isinstance(gen, bundle2.unbundle20):
5252 tr = repo.transaction('unbundle')
5251 tr = repo.transaction('unbundle')
5253 try:
5252 try:
5254 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5253 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
5255 url='bundle:' + fname)
5254 url='bundle:' + fname)
5256 tr.close()
5255 tr.close()
5257 except error.BundleUnknownFeatureError as exc:
5256 except error.BundleUnknownFeatureError as exc:
5258 raise error.Abort(_('%s: unknown bundle feature, %s')
5257 raise error.Abort(_('%s: unknown bundle feature, %s')
5259 % (fname, exc),
5258 % (fname, exc),
5260 hint=_("see https://mercurial-scm.org/"
5259 hint=_("see https://mercurial-scm.org/"
5261 "wiki/BundleFeature for more "
5260 "wiki/BundleFeature for more "
5262 "information"))
5261 "information"))
5263 finally:
5262 finally:
5264 if tr:
5263 if tr:
5265 tr.release()
5264 tr.release()
5266 changes = [r.get('return', 0)
5265 changes = [r.get('return', 0)
5267 for r in op.records['changegroup']]
5266 for r in op.records['changegroup']]
5268 modheads = changegroup.combineresults(changes)
5267 modheads = changegroup.combineresults(changes)
5269 elif isinstance(gen, streamclone.streamcloneapplier):
5268 elif isinstance(gen, streamclone.streamcloneapplier):
5270 raise error.Abort(
5269 raise error.Abort(
5271 _('packed bundles cannot be applied with '
5270 _('packed bundles cannot be applied with '
5272 '"hg unbundle"'),
5271 '"hg unbundle"'),
5273 hint=_('use "hg debugapplystreamclonebundle"'))
5272 hint=_('use "hg debugapplystreamclonebundle"'))
5274 else:
5273 else:
5275 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
5274 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
5276
5275
5277 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
5276 return postincoming(ui, repo, modheads, opts.get('update'), None, None)
5278
5277
5279 @command('^update|up|checkout|co',
5278 @command('^update|up|checkout|co',
5280 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5279 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5281 ('c', 'check', None, _('require clean working directory')),
5280 ('c', 'check', None, _('require clean working directory')),
5282 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5281 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5283 ('r', 'rev', '', _('revision'), _('REV'))
5282 ('r', 'rev', '', _('revision'), _('REV'))
5284 ] + mergetoolopts,
5283 ] + mergetoolopts,
5285 _('[-C|-c] [-d DATE] [[-r] REV]'))
5284 _('[-C|-c] [-d DATE] [[-r] REV]'))
5286 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
5285 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
5287 tool=None):
5286 tool=None):
5288 """update working directory (or switch revisions)
5287 """update working directory (or switch revisions)
5289
5288
5290 Update the repository's working directory to the specified
5289 Update the repository's working directory to the specified
5291 changeset. If no changeset is specified, update to the tip of the
5290 changeset. If no changeset is specified, update to the tip of the
5292 current named branch and move the active bookmark (see :hg:`help
5291 current named branch and move the active bookmark (see :hg:`help
5293 bookmarks`).
5292 bookmarks`).
5294
5293
5295 Update sets the working directory's parent revision to the specified
5294 Update sets the working directory's parent revision to the specified
5296 changeset (see :hg:`help parents`).
5295 changeset (see :hg:`help parents`).
5297
5296
5298 If the changeset is not a descendant or ancestor of the working
5297 If the changeset is not a descendant or ancestor of the working
5299 directory's parent and there are uncommitted changes, the update is
5298 directory's parent and there are uncommitted changes, the update is
5300 aborted. With the -c/--check option, the working directory is checked
5299 aborted. With the -c/--check option, the working directory is checked
5301 for uncommitted changes; if none are found, the working directory is
5300 for uncommitted changes; if none are found, the working directory is
5302 updated to the specified changeset.
5301 updated to the specified changeset.
5303
5302
5304 .. container:: verbose
5303 .. container:: verbose
5305
5304
5306 The -C/--clean and -c/--check options control what happens if the
5305 The -C/--clean and -c/--check options control what happens if the
5307 working directory contains uncommitted changes.
5306 working directory contains uncommitted changes.
5308 At most of one of them can be specified.
5307 At most of one of them can be specified.
5309
5308
5310 1. If no option is specified, and if
5309 1. If no option is specified, and if
5311 the requested changeset is an ancestor or descendant of
5310 the requested changeset is an ancestor or descendant of
5312 the working directory's parent, the uncommitted changes
5311 the working directory's parent, the uncommitted changes
5313 are merged into the requested changeset and the merged
5312 are merged into the requested changeset and the merged
5314 result is left uncommitted. If the requested changeset is
5313 result is left uncommitted. If the requested changeset is
5315 not an ancestor or descendant (that is, it is on another
5314 not an ancestor or descendant (that is, it is on another
5316 branch), the update is aborted and the uncommitted changes
5315 branch), the update is aborted and the uncommitted changes
5317 are preserved.
5316 are preserved.
5318
5317
5319 2. With the -c/--check option, the update is aborted and the
5318 2. With the -c/--check option, the update is aborted and the
5320 uncommitted changes are preserved.
5319 uncommitted changes are preserved.
5321
5320
5322 3. With the -C/--clean option, uncommitted changes are discarded and
5321 3. With the -C/--clean option, uncommitted changes are discarded and
5323 the working directory is updated to the requested changeset.
5322 the working directory is updated to the requested changeset.
5324
5323
5325 To cancel an uncommitted merge (and lose your changes), use
5324 To cancel an uncommitted merge (and lose your changes), use
5326 :hg:`update --clean .`.
5325 :hg:`update --clean .`.
5327
5326
5328 Use null as the changeset to remove the working directory (like
5327 Use null as the changeset to remove the working directory (like
5329 :hg:`clone -U`).
5328 :hg:`clone -U`).
5330
5329
5331 If you want to revert just one file to an older revision, use
5330 If you want to revert just one file to an older revision, use
5332 :hg:`revert [-r REV] NAME`.
5331 :hg:`revert [-r REV] NAME`.
5333
5332
5334 See :hg:`help dates` for a list of formats valid for -d/--date.
5333 See :hg:`help dates` for a list of formats valid for -d/--date.
5335
5334
5336 Returns 0 on success, 1 if there are unresolved files.
5335 Returns 0 on success, 1 if there are unresolved files.
5337 """
5336 """
5338 if rev and node:
5337 if rev and node:
5339 raise error.Abort(_("please specify just one revision"))
5338 raise error.Abort(_("please specify just one revision"))
5340
5339
5341 if rev is None or rev == '':
5340 if rev is None or rev == '':
5342 rev = node
5341 rev = node
5343
5342
5344 if date and rev is not None:
5343 if date and rev is not None:
5345 raise error.Abort(_("you can't specify a revision and a date"))
5344 raise error.Abort(_("you can't specify a revision and a date"))
5346
5345
5347 if check and clean:
5346 if check and clean:
5348 raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
5347 raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
5349
5348
5350 with repo.wlock():
5349 with repo.wlock():
5351 cmdutil.clearunfinished(repo)
5350 cmdutil.clearunfinished(repo)
5352
5351
5353 if date:
5352 if date:
5354 rev = cmdutil.finddate(ui, repo, date)
5353 rev = cmdutil.finddate(ui, repo, date)
5355
5354
5356 # if we defined a bookmark, we have to remember the original name
5355 # if we defined a bookmark, we have to remember the original name
5357 brev = rev
5356 brev = rev
5358 rev = scmutil.revsingle(repo, rev, rev).rev()
5357 rev = scmutil.revsingle(repo, rev, rev).rev()
5359
5358
5360 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
5359 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
5361
5360
5362 return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check)
5361 return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check)
5363
5362
5364 @command('verify', [])
5363 @command('verify', [])
5365 def verify(ui, repo):
5364 def verify(ui, repo):
5366 """verify the integrity of the repository
5365 """verify the integrity of the repository
5367
5366
5368 Verify the integrity of the current repository.
5367 Verify the integrity of the current repository.
5369
5368
5370 This will perform an extensive check of the repository's
5369 This will perform an extensive check of the repository's
5371 integrity, validating the hashes and checksums of each entry in
5370 integrity, validating the hashes and checksums of each entry in
5372 the changelog, manifest, and tracked files, as well as the
5371 the changelog, manifest, and tracked files, as well as the
5373 integrity of their crosslinks and indices.
5372 integrity of their crosslinks and indices.
5374
5373
5375 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5374 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
5376 for more information about recovery from corruption of the
5375 for more information about recovery from corruption of the
5377 repository.
5376 repository.
5378
5377
5379 Returns 0 on success, 1 if errors are encountered.
5378 Returns 0 on success, 1 if errors are encountered.
5380 """
5379 """
5381 return hg.verify(repo)
5380 return hg.verify(repo)
5382
5381
5383 @command('version', [] + formatteropts, norepo=True)
5382 @command('version', [] + formatteropts, norepo=True)
5384 def version_(ui, **opts):
5383 def version_(ui, **opts):
5385 """output version and copyright information"""
5384 """output version and copyright information"""
5386 if ui.verbose:
5385 if ui.verbose:
5387 ui.pager('version')
5386 ui.pager('version')
5388 fm = ui.formatter("version", opts)
5387 fm = ui.formatter("version", opts)
5389 fm.startitem()
5388 fm.startitem()
5390 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5389 fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
5391 util.version())
5390 util.version())
5392 license = _(
5391 license = _(
5393 "(see https://mercurial-scm.org for more information)\n"
5392 "(see https://mercurial-scm.org for more information)\n"
5394 "\nCopyright (C) 2005-2017 Matt Mackall and others\n"
5393 "\nCopyright (C) 2005-2017 Matt Mackall and others\n"
5395 "This is free software; see the source for copying conditions. "
5394 "This is free software; see the source for copying conditions. "
5396 "There is NO\nwarranty; "
5395 "There is NO\nwarranty; "
5397 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5396 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5398 )
5397 )
5399 if not ui.quiet:
5398 if not ui.quiet:
5400 fm.plain(license)
5399 fm.plain(license)
5401
5400
5402 if ui.verbose:
5401 if ui.verbose:
5403 fm.plain(_("\nEnabled extensions:\n\n"))
5402 fm.plain(_("\nEnabled extensions:\n\n"))
5404 # format names and versions into columns
5403 # format names and versions into columns
5405 names = []
5404 names = []
5406 vers = []
5405 vers = []
5407 isinternals = []
5406 isinternals = []
5408 for name, module in extensions.extensions():
5407 for name, module in extensions.extensions():
5409 names.append(name)
5408 names.append(name)
5410 vers.append(extensions.moduleversion(module) or None)
5409 vers.append(extensions.moduleversion(module) or None)
5411 isinternals.append(extensions.ismoduleinternal(module))
5410 isinternals.append(extensions.ismoduleinternal(module))
5412 fn = fm.nested("extensions")
5411 fn = fm.nested("extensions")
5413 if names:
5412 if names:
5414 namefmt = " %%-%ds " % max(len(n) for n in names)
5413 namefmt = " %%-%ds " % max(len(n) for n in names)
5415 places = [_("external"), _("internal")]
5414 places = [_("external"), _("internal")]
5416 for n, v, p in zip(names, vers, isinternals):
5415 for n, v, p in zip(names, vers, isinternals):
5417 fn.startitem()
5416 fn.startitem()
5418 fn.condwrite(ui.verbose, "name", namefmt, n)
5417 fn.condwrite(ui.verbose, "name", namefmt, n)
5419 if ui.verbose:
5418 if ui.verbose:
5420 fn.plain("%s " % places[p])
5419 fn.plain("%s " % places[p])
5421 fn.data(bundled=p)
5420 fn.data(bundled=p)
5422 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5421 fn.condwrite(ui.verbose and v, "ver", "%s", v)
5423 if ui.verbose:
5422 if ui.verbose:
5424 fn.plain("\n")
5423 fn.plain("\n")
5425 fn.end()
5424 fn.end()
5426 fm.end()
5425 fm.end()
5427
5426
5428 def loadcmdtable(ui, name, cmdtable):
5427 def loadcmdtable(ui, name, cmdtable):
5429 """Load command functions from specified cmdtable
5428 """Load command functions from specified cmdtable
5430 """
5429 """
5431 overrides = [cmd for cmd in cmdtable if cmd in table]
5430 overrides = [cmd for cmd in cmdtable if cmd in table]
5432 if overrides:
5431 if overrides:
5433 ui.warn(_("extension '%s' overrides commands: %s\n")
5432 ui.warn(_("extension '%s' overrides commands: %s\n")
5434 % (name, " ".join(overrides)))
5433 % (name, " ".join(overrides)))
5435 table.update(cmdtable)
5434 table.update(cmdtable)
@@ -1,186 +1,134 b''
1 # color.py color output for Mercurial commands
1 Mercurial can colorizes output from several 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.
7
2
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
3 For example, the diff command shows additions in green and deletions
12 in red, while the status command shows modified files in magenta. Many
4 in red, while the status command shows modified files in magenta. Many
13 other commands have analogous colors. It is possible to customize
5 other commands have analogous colors. It is possible to customize
14 these colors.
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 Effects
20 Effects
17 -------
21 =======
18
22
19 Other effects in addition to color, like bold and underlined text, are
23 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
24 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
25 terminal codes used to change color and effect. If terminfo is not
22 available, then effects are rendered with the ECMA-48 SGR control
26 available, then effects are rendered with the ECMA-48 SGR control
23 function (aka ANSI escape codes).
27 function (aka ANSI escape codes).
24
28
25 The available effects in terminfo mode are 'blink', 'bold', 'dim',
29 The available effects in terminfo mode are 'blink', 'bold', 'dim',
26 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
30 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
27 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
31 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
28 'underline'. How each is rendered depends on the terminal emulator.
32 'underline'. How each is rendered depends on the terminal emulator.
29 Some may not be available for a given terminal type, and will be
33 Some may not be available for a given terminal type, and will be
30 silently ignored.
34 silently ignored.
31
35
32 If the terminfo entry for your terminal is missing codes for an effect
36 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
37 or has the wrong codes, you can add or override those codes in your
34 configuration::
38 configuration::
35
39
36 [color]
40 [color]
37 terminfo.dim = \E[2m
41 terminfo.dim = \E[2m
38
42
39 where '\E' is substituted with an escape character.
43 where '\E' is substituted with an escape character.
40
44
41 Labels
45 Labels
42 ------
46 ======
43
47
44 Text receives color effects depending on the labels that it has. Many
48 Text receives color effects depending on the labels that it has. Many
45 default Mercurial commands emit labelled text. You can also define
49 default Mercurial commands emit labelled text. You can also define
46 your own labels in templates using the label function, see :hg:`help
50 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
51 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
52 that case, effects given to the last label will override any other
49 effects. This includes the special "none" effect, which nullifies
53 effects. This includes the special "none" effect, which nullifies
50 other effects.
54 other effects.
51
55
52 Labels are normally invisible. In order to see these labels and their
56 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
57 position in the text, use the global --color=debug option. The same
54 anchor text may be associated to multiple labels, e.g.
58 anchor text may be associated to multiple labels, e.g.
55
59
56 [log.changeset changeset.secret|changeset: 22611:6f0a53c8f587]
60 [log.changeset changeset.secret|changeset: 22611:6f0a53c8f587]
57
61
58 The following are the default effects for some default labels. Default
62 The following are the default effects for some default labels. Default
59 effects may be overridden from your configuration file::
63 effects may be overridden from your configuration file::
60
64
61 [color]
65 [color]
62 status.modified = blue bold underline red_background
66 status.modified = blue bold underline red_background
63 status.added = green bold
67 status.added = green bold
64 status.removed = red bold blue_background
68 status.removed = red bold blue_background
65 status.deleted = cyan bold underline
69 status.deleted = cyan bold underline
66 status.unknown = magenta bold underline
70 status.unknown = magenta bold underline
67 status.ignored = black bold
71 status.ignored = black bold
68
72
69 # 'none' turns off all effects
73 # 'none' turns off all effects
70 status.clean = none
74 status.clean = none
71 status.copied = none
75 status.copied = none
72
76
73 qseries.applied = blue bold underline
77 qseries.applied = blue bold underline
74 qseries.unapplied = black bold
78 qseries.unapplied = black bold
75 qseries.missing = red bold
79 qseries.missing = red bold
76
80
77 diff.diffline = bold
81 diff.diffline = bold
78 diff.extended = cyan bold
82 diff.extended = cyan bold
79 diff.file_a = red bold
83 diff.file_a = red bold
80 diff.file_b = green bold
84 diff.file_b = green bold
81 diff.hunk = magenta
85 diff.hunk = magenta
82 diff.deleted = red
86 diff.deleted = red
83 diff.inserted = green
87 diff.inserted = green
84 diff.changed = white
88 diff.changed = white
85 diff.tab =
89 diff.tab =
86 diff.trailingwhitespace = bold red_background
90 diff.trailingwhitespace = bold red_background
87
91
88 # Blank so it inherits the style of the surrounding label
92 # Blank so it inherits the style of the surrounding label
89 changeset.public =
93 changeset.public =
90 changeset.draft =
94 changeset.draft =
91 changeset.secret =
95 changeset.secret =
92
96
93 resolve.unresolved = red bold
97 resolve.unresolved = red bold
94 resolve.resolved = green bold
98 resolve.resolved = green bold
95
99
96 bookmarks.active = green
100 bookmarks.active = green
97
101
98 branches.active = none
102 branches.active = none
99 branches.closed = black bold
103 branches.closed = black bold
100 branches.current = green
104 branches.current = green
101 branches.inactive = none
105 branches.inactive = none
102
106
103 tags.normal = green
107 tags.normal = green
104 tags.local = black bold
108 tags.local = black bold
105
109
106 rebase.rebased = blue
110 rebase.rebased = blue
107 rebase.remaining = red bold
111 rebase.remaining = red bold
108
112
109 shelve.age = cyan
113 shelve.age = cyan
110 shelve.newest = green bold
114 shelve.newest = green bold
111 shelve.name = blue bold
115 shelve.name = blue bold
112
116
113 histedit.remaining = red bold
117 histedit.remaining = red bold
114
118
115 Custom colors
119 Custom colors
116 -------------
120 =============
117
121
118 Because there are only eight standard colors, this module allows you
122 Because there are only eight standard colors, this module allows you
119 to define color names for other color slots which might be available
123 to define color names for other color slots which might be available
120 for your terminal type, assuming terminfo mode. For instance::
124 for your terminal type, assuming terminfo mode. For instance::
121
125
122 color.brightblue = 12
126 color.brightblue = 12
123 color.pink = 207
127 color.pink = 207
124 color.orange = 202
128 color.orange = 202
125
129
126 to set 'brightblue' to color slot 12 (useful for 16 color terminals
130 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
131 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
132 '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,
133 defined colors may then be used as any of the pre-defined eight,
130 including appending '_background' to set the background to that color.
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 The Mercurial system uses a set of configuration files to control
1 The Mercurial system uses a set of configuration files to control
2 aspects of its behavior.
2 aspects of its behavior.
3
3
4 Troubleshooting
4 Troubleshooting
5 ===============
5 ===============
6
6
7 If you're having problems with your configuration,
7 If you're having problems with your configuration,
8 :hg:`config --debug` can help you understand what is introducing
8 :hg:`config --debug` can help you understand what is introducing
9 a setting into your environment.
9 a setting into your environment.
10
10
11 See :hg:`help config.syntax` and :hg:`help config.files`
11 See :hg:`help config.syntax` and :hg:`help config.files`
12 for information about how and where to override things.
12 for information about how and where to override things.
13
13
14 Structure
14 Structure
15 =========
15 =========
16
16
17 The configuration files use a simple ini-file format. A configuration
17 The configuration files use a simple ini-file format. A configuration
18 file consists of sections, led by a ``[section]`` header and followed
18 file consists of sections, led by a ``[section]`` header and followed
19 by ``name = value`` entries::
19 by ``name = value`` entries::
20
20
21 [ui]
21 [ui]
22 username = Firstname Lastname <firstname.lastname@example.net>
22 username = Firstname Lastname <firstname.lastname@example.net>
23 verbose = True
23 verbose = True
24
24
25 The above entries will be referred to as ``ui.username`` and
25 The above entries will be referred to as ``ui.username`` and
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27
27
28 Files
28 Files
29 =====
29 =====
30
30
31 Mercurial reads configuration data from several files, if they exist.
31 Mercurial reads configuration data from several files, if they exist.
32 These files do not exist by default and you will have to create the
32 These files do not exist by default and you will have to create the
33 appropriate configuration files yourself:
33 appropriate configuration files yourself:
34
34
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36
36
37 Global configuration like the username setting is typically put into:
37 Global configuration like the username setting is typically put into:
38
38
39 .. container:: windows
39 .. container:: windows
40
40
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42
42
43 .. container:: unix.plan9
43 .. container:: unix.plan9
44
44
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46
46
47 The names of these files depend on the system on which Mercurial is
47 The names of these files depend on the system on which Mercurial is
48 installed. ``*.rc`` files from a single directory are read in
48 installed. ``*.rc`` files from a single directory are read in
49 alphabetical order, later ones overriding earlier ones. Where multiple
49 alphabetical order, later ones overriding earlier ones. Where multiple
50 paths are given below, settings from earlier paths override later
50 paths are given below, settings from earlier paths override later
51 ones.
51 ones.
52
52
53 .. container:: verbose.unix
53 .. container:: verbose.unix
54
54
55 On Unix, the following files are consulted:
55 On Unix, the following files are consulted:
56
56
57 - ``<repo>/.hg/hgrc`` (per-repository)
57 - ``<repo>/.hg/hgrc`` (per-repository)
58 - ``$HOME/.hgrc`` (per-user)
58 - ``$HOME/.hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 - ``/etc/mercurial/hgrc`` (per-system)
62 - ``/etc/mercurial/hgrc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 - ``<internal>/default.d/*.rc`` (defaults)
64 - ``<internal>/default.d/*.rc`` (defaults)
65
65
66 .. container:: verbose.windows
66 .. container:: verbose.windows
67
67
68 On Windows, the following files are consulted:
68 On Windows, the following files are consulted:
69
69
70 - ``<repo>/.hg/hgrc`` (per-repository)
70 - ``<repo>/.hg/hgrc`` (per-repository)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 - ``<internal>/default.d/*.rc`` (defaults)
78 - ``<internal>/default.d/*.rc`` (defaults)
79
79
80 .. note::
80 .. note::
81
81
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 is used when running 32-bit Python on 64-bit Windows.
83 is used when running 32-bit Python on 64-bit Windows.
84
84
85 .. container:: windows
85 .. container:: windows
86
86
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88
88
89 .. container:: verbose.plan9
89 .. container:: verbose.plan9
90
90
91 On Plan9, the following files are consulted:
91 On Plan9, the following files are consulted:
92
92
93 - ``<repo>/.hg/hgrc`` (per-repository)
93 - ``<repo>/.hg/hgrc`` (per-repository)
94 - ``$home/lib/hgrc`` (per-user)
94 - ``$home/lib/hgrc`` (per-user)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 - ``/lib/mercurial/hgrc`` (per-system)
97 - ``/lib/mercurial/hgrc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 - ``<internal>/default.d/*.rc`` (defaults)
99 - ``<internal>/default.d/*.rc`` (defaults)
100
100
101 Per-repository configuration options only apply in a
101 Per-repository configuration options only apply in a
102 particular repository. This file is not version-controlled, and
102 particular repository. This file is not version-controlled, and
103 will not get transferred during a "clone" operation. Options in
103 will not get transferred during a "clone" operation. Options in
104 this file override options in all other configuration files.
104 this file override options in all other configuration files.
105
105
106 .. container:: unix.plan9
106 .. container:: unix.plan9
107
107
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 belong to a trusted user or to a trusted group. See
109 belong to a trusted user or to a trusted group. See
110 :hg:`help config.trusted` for more details.
110 :hg:`help config.trusted` for more details.
111
111
112 Per-user configuration file(s) are for the user running Mercurial. Options
112 Per-user configuration file(s) are for the user running Mercurial. Options
113 in these files apply to all Mercurial commands executed by this user in any
113 in these files apply to all Mercurial commands executed by this user in any
114 directory. Options in these files override per-system and per-installation
114 directory. Options in these files override per-system and per-installation
115 options.
115 options.
116
116
117 Per-installation configuration files are searched for in the
117 Per-installation configuration files are searched for in the
118 directory where Mercurial is installed. ``<install-root>`` is the
118 directory where Mercurial is installed. ``<install-root>`` is the
119 parent directory of the **hg** executable (or symlink) being run.
119 parent directory of the **hg** executable (or symlink) being run.
120
120
121 .. container:: unix.plan9
121 .. container:: unix.plan9
122
122
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 files apply to all Mercurial commands executed by any user in any
125 files apply to all Mercurial commands executed by any user in any
126 directory.
126 directory.
127
127
128 Per-installation configuration files are for the system on
128 Per-installation configuration files are for the system on
129 which Mercurial is running. Options in these files apply to all
129 which Mercurial is running. Options in these files apply to all
130 Mercurial commands executed by any user in any directory. Registry
130 Mercurial commands executed by any user in any directory. Registry
131 keys contain PATH-like strings, every part of which must reference
131 keys contain PATH-like strings, every part of which must reference
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 be read. Mercurial checks each of these locations in the specified
133 be read. Mercurial checks each of these locations in the specified
134 order until one or more configuration files are detected.
134 order until one or more configuration files are detected.
135
135
136 Per-system configuration files are for the system on which Mercurial
136 Per-system configuration files are for the system on which Mercurial
137 is running. Options in these files apply to all Mercurial commands
137 is running. Options in these files apply to all Mercurial commands
138 executed by any user in any directory. Options in these files
138 executed by any user in any directory. Options in these files
139 override per-installation options.
139 override per-installation options.
140
140
141 Mercurial comes with some default configuration. The default configuration
141 Mercurial comes with some default configuration. The default configuration
142 files are installed with Mercurial and will be overwritten on upgrades. Default
142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 configuration files should never be edited by users or administrators but can
143 configuration files should never be edited by users or administrators but can
144 be overridden in other configuration files. So far the directory only contains
144 be overridden in other configuration files. So far the directory only contains
145 merge tool configuration but packagers can also put other default configuration
145 merge tool configuration but packagers can also put other default configuration
146 there.
146 there.
147
147
148 Syntax
148 Syntax
149 ======
149 ======
150
150
151 A configuration file consists of sections, led by a ``[section]`` header
151 A configuration file consists of sections, led by a ``[section]`` header
152 and followed by ``name = value`` entries (sometimes called
152 and followed by ``name = value`` entries (sometimes called
153 ``configuration keys``)::
153 ``configuration keys``)::
154
154
155 [spam]
155 [spam]
156 eggs=ham
156 eggs=ham
157 green=
157 green=
158 eggs
158 eggs
159
159
160 Each line contains one entry. If the lines that follow are indented,
160 Each line contains one entry. If the lines that follow are indented,
161 they are treated as continuations of that entry. Leading whitespace is
161 they are treated as continuations of that entry. Leading whitespace is
162 removed from values. Empty lines are skipped. Lines beginning with
162 removed from values. Empty lines are skipped. Lines beginning with
163 ``#`` or ``;`` are ignored and may be used to provide comments.
163 ``#`` or ``;`` are ignored and may be used to provide comments.
164
164
165 Configuration keys can be set multiple times, in which case Mercurial
165 Configuration keys can be set multiple times, in which case Mercurial
166 will use the value that was configured last. As an example::
166 will use the value that was configured last. As an example::
167
167
168 [spam]
168 [spam]
169 eggs=large
169 eggs=large
170 ham=serrano
170 ham=serrano
171 eggs=small
171 eggs=small
172
172
173 This would set the configuration key named ``eggs`` to ``small``.
173 This would set the configuration key named ``eggs`` to ``small``.
174
174
175 It is also possible to define a section multiple times. A section can
175 It is also possible to define a section multiple times. A section can
176 be redefined on the same and/or on different configuration files. For
176 be redefined on the same and/or on different configuration files. For
177 example::
177 example::
178
178
179 [foo]
179 [foo]
180 eggs=large
180 eggs=large
181 ham=serrano
181 ham=serrano
182 eggs=small
182 eggs=small
183
183
184 [bar]
184 [bar]
185 eggs=ham
185 eggs=ham
186 green=
186 green=
187 eggs
187 eggs
188
188
189 [foo]
189 [foo]
190 ham=prosciutto
190 ham=prosciutto
191 eggs=medium
191 eggs=medium
192 bread=toasted
192 bread=toasted
193
193
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 respectively. As you can see there only thing that matters is the last
196 respectively. As you can see there only thing that matters is the last
197 value that was set for each of the configuration keys.
197 value that was set for each of the configuration keys.
198
198
199 If a configuration key is set multiple times in different
199 If a configuration key is set multiple times in different
200 configuration files the final value will depend on the order in which
200 configuration files the final value will depend on the order in which
201 the different configuration files are read, with settings from earlier
201 the different configuration files are read, with settings from earlier
202 paths overriding later ones as described on the ``Files`` section
202 paths overriding later ones as described on the ``Files`` section
203 above.
203 above.
204
204
205 A line of the form ``%include file`` will include ``file`` into the
205 A line of the form ``%include file`` will include ``file`` into the
206 current configuration file. The inclusion is recursive, which means
206 current configuration file. The inclusion is recursive, which means
207 that included files can include other files. Filenames are relative to
207 that included files can include other files. Filenames are relative to
208 the configuration file in which the ``%include`` directive is found.
208 the configuration file in which the ``%include`` directive is found.
209 Environment variables and ``~user`` constructs are expanded in
209 Environment variables and ``~user`` constructs are expanded in
210 ``file``. This lets you do something like::
210 ``file``. This lets you do something like::
211
211
212 %include ~/.hgrc.d/$HOST.rc
212 %include ~/.hgrc.d/$HOST.rc
213
213
214 to include a different configuration file on each computer you use.
214 to include a different configuration file on each computer you use.
215
215
216 A line with ``%unset name`` will remove ``name`` from the current
216 A line with ``%unset name`` will remove ``name`` from the current
217 section, if it has been set previously.
217 section, if it has been set previously.
218
218
219 The values are either free-form text strings, lists of text strings,
219 The values are either free-form text strings, lists of text strings,
220 or Boolean values. Boolean values can be set to true using any of "1",
220 or Boolean values. Boolean values can be set to true using any of "1",
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 (all case insensitive).
222 (all case insensitive).
223
223
224 List values are separated by whitespace or comma, except when values are
224 List values are separated by whitespace or comma, except when values are
225 placed in double quotation marks::
225 placed in double quotation marks::
226
226
227 allow_read = "John Doe, PhD", brian, betty
227 allow_read = "John Doe, PhD", brian, betty
228
228
229 Quotation marks can be escaped by prefixing them with a backslash. Only
229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 quotation marks at the beginning of a word is counted as a quotation
230 quotation marks at the beginning of a word is counted as a quotation
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232
232
233 Sections
233 Sections
234 ========
234 ========
235
235
236 This section describes the different sections that may appear in a
236 This section describes the different sections that may appear in a
237 Mercurial configuration file, the purpose of each section, its possible
237 Mercurial configuration file, the purpose of each section, its possible
238 keys, and their possible values.
238 keys, and their possible values.
239
239
240 ``alias``
240 ``alias``
241 ---------
241 ---------
242
242
243 Defines command aliases.
243 Defines command aliases.
244
244
245 Aliases allow you to define your own commands in terms of other
245 Aliases allow you to define your own commands in terms of other
246 commands (or aliases), optionally including arguments. Positional
246 commands (or aliases), optionally including arguments. Positional
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 are expanded by Mercurial before execution. Positional arguments not
248 are expanded by Mercurial before execution. Positional arguments not
249 already used by ``$N`` in the definition are put at the end of the
249 already used by ``$N`` in the definition are put at the end of the
250 command to be executed.
250 command to be executed.
251
251
252 Alias definitions consist of lines of the form::
252 Alias definitions consist of lines of the form::
253
253
254 <alias> = <command> [<argument>]...
254 <alias> = <command> [<argument>]...
255
255
256 For example, this definition::
256 For example, this definition::
257
257
258 latest = log --limit 5
258 latest = log --limit 5
259
259
260 creates a new command ``latest`` that shows only the five most recent
260 creates a new command ``latest`` that shows only the five most recent
261 changesets. You can define subsequent aliases using earlier ones::
261 changesets. You can define subsequent aliases using earlier ones::
262
262
263 stable5 = latest -b stable
263 stable5 = latest -b stable
264
264
265 .. note::
265 .. note::
266
266
267 It is possible to create aliases with the same names as
267 It is possible to create aliases with the same names as
268 existing commands, which will then override the original
268 existing commands, which will then override the original
269 definitions. This is almost always a bad idea!
269 definitions. This is almost always a bad idea!
270
270
271 An alias can start with an exclamation point (``!``) to make it a
271 An alias can start with an exclamation point (``!``) to make it a
272 shell alias. A shell alias is executed with the shell and will let you
272 shell alias. A shell alias is executed with the shell and will let you
273 run arbitrary commands. As an example, ::
273 run arbitrary commands. As an example, ::
274
274
275 echo = !echo $@
275 echo = !echo $@
276
276
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 terminal. A better example might be::
278 terminal. A better example might be::
279
279
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281
281
282 which will make ``hg purge`` delete all unknown files in the
282 which will make ``hg purge`` delete all unknown files in the
283 repository in the same manner as the purge extension.
283 repository in the same manner as the purge extension.
284
284
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 expand to the command arguments. Unmatched arguments are
286 expand to the command arguments. Unmatched arguments are
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 arguments quoted individually and separated by a space. These expansions
289 arguments quoted individually and separated by a space. These expansions
290 happen before the command is passed to the shell.
290 happen before the command is passed to the shell.
291
291
292 Shell aliases are executed in an environment where ``$HG`` expands to
292 Shell aliases are executed in an environment where ``$HG`` expands to
293 the path of the Mercurial that was used to execute the alias. This is
293 the path of the Mercurial that was used to execute the alias. This is
294 useful when you want to call further Mercurial commands in a shell
294 useful when you want to call further Mercurial commands in a shell
295 alias, as was done above for the purge alias. In addition,
295 alias, as was done above for the purge alias. In addition,
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298
298
299 .. note::
299 .. note::
300
300
301 Some global configuration options such as ``-R`` are
301 Some global configuration options such as ``-R`` are
302 processed before shell aliases and will thus not be passed to
302 processed before shell aliases and will thus not be passed to
303 aliases.
303 aliases.
304
304
305
305
306 ``annotate``
306 ``annotate``
307 ------------
307 ------------
308
308
309 Settings used when displaying file annotations. All values are
309 Settings used when displaying file annotations. All values are
310 Booleans and default to False. See :hg:`help config.diff` for
310 Booleans and default to False. See :hg:`help config.diff` for
311 related options for the diff command.
311 related options for the diff command.
312
312
313 ``ignorews``
313 ``ignorews``
314 Ignore white space when comparing lines.
314 Ignore white space when comparing lines.
315
315
316 ``ignorewsamount``
316 ``ignorewsamount``
317 Ignore changes in the amount of white space.
317 Ignore changes in the amount of white space.
318
318
319 ``ignoreblanklines``
319 ``ignoreblanklines``
320 Ignore changes whose lines are all blank.
320 Ignore changes whose lines are all blank.
321
321
322
322
323 ``auth``
323 ``auth``
324 --------
324 --------
325
325
326 Authentication credentials for HTTP authentication. This section
326 Authentication credentials for HTTP authentication. This section
327 allows you to store usernames and passwords for use when logging
327 allows you to store usernames and passwords for use when logging
328 *into* HTTP servers. See :hg:`help config.web` if
328 *into* HTTP servers. See :hg:`help config.web` if
329 you want to configure *who* can login to your HTTP server.
329 you want to configure *who* can login to your HTTP server.
330
330
331 Each line has the following format::
331 Each line has the following format::
332
332
333 <name>.<argument> = <value>
333 <name>.<argument> = <value>
334
334
335 where ``<name>`` is used to group arguments into authentication
335 where ``<name>`` is used to group arguments into authentication
336 entries. Example::
336 entries. Example::
337
337
338 foo.prefix = hg.intevation.de/mercurial
338 foo.prefix = hg.intevation.de/mercurial
339 foo.username = foo
339 foo.username = foo
340 foo.password = bar
340 foo.password = bar
341 foo.schemes = http https
341 foo.schemes = http https
342
342
343 bar.prefix = secure.example.org
343 bar.prefix = secure.example.org
344 bar.key = path/to/file.key
344 bar.key = path/to/file.key
345 bar.cert = path/to/file.cert
345 bar.cert = path/to/file.cert
346 bar.schemes = https
346 bar.schemes = https
347
347
348 Supported arguments:
348 Supported arguments:
349
349
350 ``prefix``
350 ``prefix``
351 Either ``*`` or a URI prefix with or without the scheme part.
351 Either ``*`` or a URI prefix with or without the scheme part.
352 The authentication entry with the longest matching prefix is used
352 The authentication entry with the longest matching prefix is used
353 (where ``*`` matches everything and counts as a match of length
353 (where ``*`` matches everything and counts as a match of length
354 1). If the prefix doesn't include a scheme, the match is performed
354 1). If the prefix doesn't include a scheme, the match is performed
355 against the URI with its scheme stripped as well, and the schemes
355 against the URI with its scheme stripped as well, and the schemes
356 argument, q.v., is then subsequently consulted.
356 argument, q.v., is then subsequently consulted.
357
357
358 ``username``
358 ``username``
359 Optional. Username to authenticate with. If not given, and the
359 Optional. Username to authenticate with. If not given, and the
360 remote site requires basic or digest authentication, the user will
360 remote site requires basic or digest authentication, the user will
361 be prompted for it. Environment variables are expanded in the
361 be prompted for it. Environment variables are expanded in the
362 username letting you do ``foo.username = $USER``. If the URI
362 username letting you do ``foo.username = $USER``. If the URI
363 includes a username, only ``[auth]`` entries with a matching
363 includes a username, only ``[auth]`` entries with a matching
364 username or without a username will be considered.
364 username or without a username will be considered.
365
365
366 ``password``
366 ``password``
367 Optional. Password to authenticate with. If not given, and the
367 Optional. Password to authenticate with. If not given, and the
368 remote site requires basic or digest authentication, the user
368 remote site requires basic or digest authentication, the user
369 will be prompted for it.
369 will be prompted for it.
370
370
371 ``key``
371 ``key``
372 Optional. PEM encoded client certificate key file. Environment
372 Optional. PEM encoded client certificate key file. Environment
373 variables are expanded in the filename.
373 variables are expanded in the filename.
374
374
375 ``cert``
375 ``cert``
376 Optional. PEM encoded client certificate chain file. Environment
376 Optional. PEM encoded client certificate chain file. Environment
377 variables are expanded in the filename.
377 variables are expanded in the filename.
378
378
379 ``schemes``
379 ``schemes``
380 Optional. Space separated list of URI schemes to use this
380 Optional. Space separated list of URI schemes to use this
381 authentication entry with. Only used if the prefix doesn't include
381 authentication entry with. Only used if the prefix doesn't include
382 a scheme. Supported schemes are http and https. They will match
382 a scheme. Supported schemes are http and https. They will match
383 static-http and static-https respectively, as well.
383 static-http and static-https respectively, as well.
384 (default: https)
384 (default: https)
385
385
386 If no suitable authentication entry is found, the user is prompted
386 If no suitable authentication entry is found, the user is prompted
387 for credentials as usual if required by the remote.
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 ``committemplate``
417 ``committemplate``
391 ------------------
418 ------------------
392
419
393 ``changeset``
420 ``changeset``
394 String: configuration in this section is used as the template to
421 String: configuration in this section is used as the template to
395 customize the text shown in the editor when committing.
422 customize the text shown in the editor when committing.
396
423
397 In addition to pre-defined template keywords, commit log specific one
424 In addition to pre-defined template keywords, commit log specific one
398 below can be used for customization:
425 below can be used for customization:
399
426
400 ``extramsg``
427 ``extramsg``
401 String: Extra message (typically 'Leave message empty to abort
428 String: Extra message (typically 'Leave message empty to abort
402 commit.'). This may be changed by some commands or extensions.
429 commit.'). This may be changed by some commands or extensions.
403
430
404 For example, the template configuration below shows as same text as
431 For example, the template configuration below shows as same text as
405 one shown by default::
432 one shown by default::
406
433
407 [committemplate]
434 [committemplate]
408 changeset = {desc}\n\n
435 changeset = {desc}\n\n
409 HG: Enter commit message. Lines beginning with 'HG:' are removed.
436 HG: Enter commit message. Lines beginning with 'HG:' are removed.
410 HG: {extramsg}
437 HG: {extramsg}
411 HG: --
438 HG: --
412 HG: user: {author}\n{ifeq(p2rev, "-1", "",
439 HG: user: {author}\n{ifeq(p2rev, "-1", "",
413 "HG: branch merge\n")
440 "HG: branch merge\n")
414 }HG: branch '{branch}'\n{if(activebookmark,
441 }HG: branch '{branch}'\n{if(activebookmark,
415 "HG: bookmark '{activebookmark}'\n") }{subrepos %
442 "HG: bookmark '{activebookmark}'\n") }{subrepos %
416 "HG: subrepo {subrepo}\n" }{file_adds %
443 "HG: subrepo {subrepo}\n" }{file_adds %
417 "HG: added {file}\n" }{file_mods %
444 "HG: added {file}\n" }{file_mods %
418 "HG: changed {file}\n" }{file_dels %
445 "HG: changed {file}\n" }{file_dels %
419 "HG: removed {file}\n" }{if(files, "",
446 "HG: removed {file}\n" }{if(files, "",
420 "HG: no files changed\n")}
447 "HG: no files changed\n")}
421
448
422 ``diff()``
449 ``diff()``
423 String: show the diff (see :hg:`help templates` for detail)
450 String: show the diff (see :hg:`help templates` for detail)
424
451
425 Sometimes it is helpful to show the diff of the changeset in the editor without
452 Sometimes it is helpful to show the diff of the changeset in the editor without
426 having to prefix 'HG: ' to each line so that highlighting works correctly. For
453 having to prefix 'HG: ' to each line so that highlighting works correctly. For
427 this, Mercurial provides a special string which will ignore everything below
454 this, Mercurial provides a special string which will ignore everything below
428 it::
455 it::
429
456
430 HG: ------------------------ >8 ------------------------
457 HG: ------------------------ >8 ------------------------
431
458
432 For example, the template configuration below will show the diff below the
459 For example, the template configuration below will show the diff below the
433 extra message::
460 extra message::
434
461
435 [committemplate]
462 [committemplate]
436 changeset = {desc}\n\n
463 changeset = {desc}\n\n
437 HG: Enter commit message. Lines beginning with 'HG:' are removed.
464 HG: Enter commit message. Lines beginning with 'HG:' are removed.
438 HG: {extramsg}
465 HG: {extramsg}
439 HG: ------------------------ >8 ------------------------
466 HG: ------------------------ >8 ------------------------
440 HG: Do not touch the line above.
467 HG: Do not touch the line above.
441 HG: Everything below will be removed.
468 HG: Everything below will be removed.
442 {diff()}
469 {diff()}
443
470
444 .. note::
471 .. note::
445
472
446 For some problematic encodings (see :hg:`help win32mbcs` for
473 For some problematic encodings (see :hg:`help win32mbcs` for
447 detail), this customization should be configured carefully, to
474 detail), this customization should be configured carefully, to
448 avoid showing broken characters.
475 avoid showing broken characters.
449
476
450 For example, if a multibyte character ending with backslash (0x5c) is
477 For example, if a multibyte character ending with backslash (0x5c) is
451 followed by the ASCII character 'n' in the customized template,
478 followed by the ASCII character 'n' in the customized template,
452 the sequence of backslash and 'n' is treated as line-feed unexpectedly
479 the sequence of backslash and 'n' is treated as line-feed unexpectedly
453 (and the multibyte character is broken, too).
480 (and the multibyte character is broken, too).
454
481
455 Customized template is used for commands below (``--edit`` may be
482 Customized template is used for commands below (``--edit`` may be
456 required):
483 required):
457
484
458 - :hg:`backout`
485 - :hg:`backout`
459 - :hg:`commit`
486 - :hg:`commit`
460 - :hg:`fetch` (for merge commit only)
487 - :hg:`fetch` (for merge commit only)
461 - :hg:`graft`
488 - :hg:`graft`
462 - :hg:`histedit`
489 - :hg:`histedit`
463 - :hg:`import`
490 - :hg:`import`
464 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
491 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
465 - :hg:`rebase`
492 - :hg:`rebase`
466 - :hg:`shelve`
493 - :hg:`shelve`
467 - :hg:`sign`
494 - :hg:`sign`
468 - :hg:`tag`
495 - :hg:`tag`
469 - :hg:`transplant`
496 - :hg:`transplant`
470
497
471 Configuring items below instead of ``changeset`` allows showing
498 Configuring items below instead of ``changeset`` allows showing
472 customized message only for specific actions, or showing different
499 customized message only for specific actions, or showing different
473 messages for each action.
500 messages for each action.
474
501
475 - ``changeset.backout`` for :hg:`backout`
502 - ``changeset.backout`` for :hg:`backout`
476 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
503 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
477 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
504 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
478 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
505 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
479 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
506 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
480 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
507 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
481 - ``changeset.gpg.sign`` for :hg:`sign`
508 - ``changeset.gpg.sign`` for :hg:`sign`
482 - ``changeset.graft`` for :hg:`graft`
509 - ``changeset.graft`` for :hg:`graft`
483 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
510 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
484 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
511 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
485 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
512 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
486 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
513 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
487 - ``changeset.import.bypass`` for :hg:`import --bypass`
514 - ``changeset.import.bypass`` for :hg:`import --bypass`
488 - ``changeset.import.normal.merge`` for :hg:`import` on merges
515 - ``changeset.import.normal.merge`` for :hg:`import` on merges
489 - ``changeset.import.normal.normal`` for :hg:`import` on other
516 - ``changeset.import.normal.normal`` for :hg:`import` on other
490 - ``changeset.mq.qnew`` for :hg:`qnew`
517 - ``changeset.mq.qnew`` for :hg:`qnew`
491 - ``changeset.mq.qfold`` for :hg:`qfold`
518 - ``changeset.mq.qfold`` for :hg:`qfold`
492 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
519 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
493 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
520 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
494 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
521 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
495 - ``changeset.rebase.normal`` for :hg:`rebase` on other
522 - ``changeset.rebase.normal`` for :hg:`rebase` on other
496 - ``changeset.shelve.shelve`` for :hg:`shelve`
523 - ``changeset.shelve.shelve`` for :hg:`shelve`
497 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
524 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
498 - ``changeset.tag.remove`` for :hg:`tag --remove`
525 - ``changeset.tag.remove`` for :hg:`tag --remove`
499 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
526 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
500 - ``changeset.transplant.normal`` for :hg:`transplant` on other
527 - ``changeset.transplant.normal`` for :hg:`transplant` on other
501
528
502 These dot-separated lists of names are treated as hierarchical ones.
529 These dot-separated lists of names are treated as hierarchical ones.
503 For example, ``changeset.tag.remove`` customizes the commit message
530 For example, ``changeset.tag.remove`` customizes the commit message
504 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
531 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
505 commit message for :hg:`tag` regardless of ``--remove`` option.
532 commit message for :hg:`tag` regardless of ``--remove`` option.
506
533
507 When the external editor is invoked for a commit, the corresponding
534 When the external editor is invoked for a commit, the corresponding
508 dot-separated list of names without the ``changeset.`` prefix
535 dot-separated list of names without the ``changeset.`` prefix
509 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
536 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
510 variable.
537 variable.
511
538
512 In this section, items other than ``changeset`` can be referred from
539 In this section, items other than ``changeset`` can be referred from
513 others. For example, the configuration to list committed files up
540 others. For example, the configuration to list committed files up
514 below can be referred as ``{listupfiles}``::
541 below can be referred as ``{listupfiles}``::
515
542
516 [committemplate]
543 [committemplate]
517 listupfiles = {file_adds %
544 listupfiles = {file_adds %
518 "HG: added {file}\n" }{file_mods %
545 "HG: added {file}\n" }{file_mods %
519 "HG: changed {file}\n" }{file_dels %
546 "HG: changed {file}\n" }{file_dels %
520 "HG: removed {file}\n" }{if(files, "",
547 "HG: removed {file}\n" }{if(files, "",
521 "HG: no files changed\n")}
548 "HG: no files changed\n")}
522
549
523 ``decode/encode``
550 ``decode/encode``
524 -----------------
551 -----------------
525
552
526 Filters for transforming files on checkout/checkin. This would
553 Filters for transforming files on checkout/checkin. This would
527 typically be used for newline processing or other
554 typically be used for newline processing or other
528 localization/canonicalization of files.
555 localization/canonicalization of files.
529
556
530 Filters consist of a filter pattern followed by a filter command.
557 Filters consist of a filter pattern followed by a filter command.
531 Filter patterns are globs by default, rooted at the repository root.
558 Filter patterns are globs by default, rooted at the repository root.
532 For example, to match any file ending in ``.txt`` in the root
559 For example, to match any file ending in ``.txt`` in the root
533 directory only, use the pattern ``*.txt``. To match any file ending
560 directory only, use the pattern ``*.txt``. To match any file ending
534 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
561 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
535 For each file only the first matching filter applies.
562 For each file only the first matching filter applies.
536
563
537 The filter command can start with a specifier, either ``pipe:`` or
564 The filter command can start with a specifier, either ``pipe:`` or
538 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
565 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
539
566
540 A ``pipe:`` command must accept data on stdin and return the transformed
567 A ``pipe:`` command must accept data on stdin and return the transformed
541 data on stdout.
568 data on stdout.
542
569
543 Pipe example::
570 Pipe example::
544
571
545 [encode]
572 [encode]
546 # uncompress gzip files on checkin to improve delta compression
573 # uncompress gzip files on checkin to improve delta compression
547 # note: not necessarily a good idea, just an example
574 # note: not necessarily a good idea, just an example
548 *.gz = pipe: gunzip
575 *.gz = pipe: gunzip
549
576
550 [decode]
577 [decode]
551 # recompress gzip files when writing them to the working dir (we
578 # recompress gzip files when writing them to the working dir (we
552 # can safely omit "pipe:", because it's the default)
579 # can safely omit "pipe:", because it's the default)
553 *.gz = gzip
580 *.gz = gzip
554
581
555 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
582 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
556 with the name of a temporary file that contains the data to be
583 with the name of a temporary file that contains the data to be
557 filtered by the command. The string ``OUTFILE`` is replaced with the name
584 filtered by the command. The string ``OUTFILE`` is replaced with the name
558 of an empty temporary file, where the filtered data must be written by
585 of an empty temporary file, where the filtered data must be written by
559 the command.
586 the command.
560
587
561 .. container:: windows
588 .. container:: windows
562
589
563 .. note::
590 .. note::
564
591
565 The tempfile mechanism is recommended for Windows systems,
592 The tempfile mechanism is recommended for Windows systems,
566 where the standard shell I/O redirection operators often have
593 where the standard shell I/O redirection operators often have
567 strange effects and may corrupt the contents of your files.
594 strange effects and may corrupt the contents of your files.
568
595
569 This filter mechanism is used internally by the ``eol`` extension to
596 This filter mechanism is used internally by the ``eol`` extension to
570 translate line ending characters between Windows (CRLF) and Unix (LF)
597 translate line ending characters between Windows (CRLF) and Unix (LF)
571 format. We suggest you use the ``eol`` extension for convenience.
598 format. We suggest you use the ``eol`` extension for convenience.
572
599
573
600
574 ``defaults``
601 ``defaults``
575 ------------
602 ------------
576
603
577 (defaults are deprecated. Don't use them. Use aliases instead.)
604 (defaults are deprecated. Don't use them. Use aliases instead.)
578
605
579 Use the ``[defaults]`` section to define command defaults, i.e. the
606 Use the ``[defaults]`` section to define command defaults, i.e. the
580 default options/arguments to pass to the specified commands.
607 default options/arguments to pass to the specified commands.
581
608
582 The following example makes :hg:`log` run in verbose mode, and
609 The following example makes :hg:`log` run in verbose mode, and
583 :hg:`status` show only the modified files, by default::
610 :hg:`status` show only the modified files, by default::
584
611
585 [defaults]
612 [defaults]
586 log = -v
613 log = -v
587 status = -m
614 status = -m
588
615
589 The actual commands, instead of their aliases, must be used when
616 The actual commands, instead of their aliases, must be used when
590 defining command defaults. The command defaults will also be applied
617 defining command defaults. The command defaults will also be applied
591 to the aliases of the commands defined.
618 to the aliases of the commands defined.
592
619
593
620
594 ``diff``
621 ``diff``
595 --------
622 --------
596
623
597 Settings used when displaying diffs. Everything except for ``unified``
624 Settings used when displaying diffs. Everything except for ``unified``
598 is a Boolean and defaults to False. See :hg:`help config.annotate`
625 is a Boolean and defaults to False. See :hg:`help config.annotate`
599 for related options for the annotate command.
626 for related options for the annotate command.
600
627
601 ``git``
628 ``git``
602 Use git extended diff format.
629 Use git extended diff format.
603
630
604 ``nobinary``
631 ``nobinary``
605 Omit git binary patches.
632 Omit git binary patches.
606
633
607 ``nodates``
634 ``nodates``
608 Don't include dates in diff headers.
635 Don't include dates in diff headers.
609
636
610 ``noprefix``
637 ``noprefix``
611 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
638 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
612
639
613 ``showfunc``
640 ``showfunc``
614 Show which function each change is in.
641 Show which function each change is in.
615
642
616 ``ignorews``
643 ``ignorews``
617 Ignore white space when comparing lines.
644 Ignore white space when comparing lines.
618
645
619 ``ignorewsamount``
646 ``ignorewsamount``
620 Ignore changes in the amount of white space.
647 Ignore changes in the amount of white space.
621
648
622 ``ignoreblanklines``
649 ``ignoreblanklines``
623 Ignore changes whose lines are all blank.
650 Ignore changes whose lines are all blank.
624
651
625 ``unified``
652 ``unified``
626 Number of lines of context to show.
653 Number of lines of context to show.
627
654
628 ``email``
655 ``email``
629 ---------
656 ---------
630
657
631 Settings for extensions that send email messages.
658 Settings for extensions that send email messages.
632
659
633 ``from``
660 ``from``
634 Optional. Email address to use in "From" header and SMTP envelope
661 Optional. Email address to use in "From" header and SMTP envelope
635 of outgoing messages.
662 of outgoing messages.
636
663
637 ``to``
664 ``to``
638 Optional. Comma-separated list of recipients' email addresses.
665 Optional. Comma-separated list of recipients' email addresses.
639
666
640 ``cc``
667 ``cc``
641 Optional. Comma-separated list of carbon copy recipients'
668 Optional. Comma-separated list of carbon copy recipients'
642 email addresses.
669 email addresses.
643
670
644 ``bcc``
671 ``bcc``
645 Optional. Comma-separated list of blind carbon copy recipients'
672 Optional. Comma-separated list of blind carbon copy recipients'
646 email addresses.
673 email addresses.
647
674
648 ``method``
675 ``method``
649 Optional. Method to use to send email messages. If value is ``smtp``
676 Optional. Method to use to send email messages. If value is ``smtp``
650 (default), use SMTP (see the ``[smtp]`` section for configuration).
677 (default), use SMTP (see the ``[smtp]`` section for configuration).
651 Otherwise, use as name of program to run that acts like sendmail
678 Otherwise, use as name of program to run that acts like sendmail
652 (takes ``-f`` option for sender, list of recipients on command line,
679 (takes ``-f`` option for sender, list of recipients on command line,
653 message on stdin). Normally, setting this to ``sendmail`` or
680 message on stdin). Normally, setting this to ``sendmail`` or
654 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
681 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
655
682
656 ``charsets``
683 ``charsets``
657 Optional. Comma-separated list of character sets considered
684 Optional. Comma-separated list of character sets considered
658 convenient for recipients. Addresses, headers, and parts not
685 convenient for recipients. Addresses, headers, and parts not
659 containing patches of outgoing messages will be encoded in the
686 containing patches of outgoing messages will be encoded in the
660 first character set to which conversion from local encoding
687 first character set to which conversion from local encoding
661 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
688 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
662 conversion fails, the text in question is sent as is.
689 conversion fails, the text in question is sent as is.
663 (default: '')
690 (default: '')
664
691
665 Order of outgoing email character sets:
692 Order of outgoing email character sets:
666
693
667 1. ``us-ascii``: always first, regardless of settings
694 1. ``us-ascii``: always first, regardless of settings
668 2. ``email.charsets``: in order given by user
695 2. ``email.charsets``: in order given by user
669 3. ``ui.fallbackencoding``: if not in email.charsets
696 3. ``ui.fallbackencoding``: if not in email.charsets
670 4. ``$HGENCODING``: if not in email.charsets
697 4. ``$HGENCODING``: if not in email.charsets
671 5. ``utf-8``: always last, regardless of settings
698 5. ``utf-8``: always last, regardless of settings
672
699
673 Email example::
700 Email example::
674
701
675 [email]
702 [email]
676 from = Joseph User <joe.user@example.com>
703 from = Joseph User <joe.user@example.com>
677 method = /usr/sbin/sendmail
704 method = /usr/sbin/sendmail
678 # charsets for western Europeans
705 # charsets for western Europeans
679 # us-ascii, utf-8 omitted, as they are tried first and last
706 # us-ascii, utf-8 omitted, as they are tried first and last
680 charsets = iso-8859-1, iso-8859-15, windows-1252
707 charsets = iso-8859-1, iso-8859-15, windows-1252
681
708
682
709
683 ``extensions``
710 ``extensions``
684 --------------
711 --------------
685
712
686 Mercurial has an extension mechanism for adding new features. To
713 Mercurial has an extension mechanism for adding new features. To
687 enable an extension, create an entry for it in this section.
714 enable an extension, create an entry for it in this section.
688
715
689 If you know that the extension is already in Python's search path,
716 If you know that the extension is already in Python's search path,
690 you can give the name of the module, followed by ``=``, with nothing
717 you can give the name of the module, followed by ``=``, with nothing
691 after the ``=``.
718 after the ``=``.
692
719
693 Otherwise, give a name that you choose, followed by ``=``, followed by
720 Otherwise, give a name that you choose, followed by ``=``, followed by
694 the path to the ``.py`` file (including the file name extension) that
721 the path to the ``.py`` file (including the file name extension) that
695 defines the extension.
722 defines the extension.
696
723
697 To explicitly disable an extension that is enabled in an hgrc of
724 To explicitly disable an extension that is enabled in an hgrc of
698 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
725 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
699 or ``foo = !`` when path is not supplied.
726 or ``foo = !`` when path is not supplied.
700
727
701 Example for ``~/.hgrc``::
728 Example for ``~/.hgrc``::
702
729
703 [extensions]
730 [extensions]
704 # (the color extension will get loaded from Mercurial's path)
731 # (the color extension will get loaded from Mercurial's path)
705 color =
732 color =
706 # (this extension will get loaded from the file specified)
733 # (this extension will get loaded from the file specified)
707 myfeature = ~/.hgext/myfeature.py
734 myfeature = ~/.hgext/myfeature.py
708
735
709
736
710 ``format``
737 ``format``
711 ----------
738 ----------
712
739
713 ``usegeneraldelta``
740 ``usegeneraldelta``
714 Enable or disable the "generaldelta" repository format which improves
741 Enable or disable the "generaldelta" repository format which improves
715 repository compression by allowing "revlog" to store delta against arbitrary
742 repository compression by allowing "revlog" to store delta against arbitrary
716 revision instead of the previous stored one. This provides significant
743 revision instead of the previous stored one. This provides significant
717 improvement for repositories with branches.
744 improvement for repositories with branches.
718
745
719 Repositories with this on-disk format require Mercurial version 1.9.
746 Repositories with this on-disk format require Mercurial version 1.9.
720
747
721 Enabled by default.
748 Enabled by default.
722
749
723 ``dotencode``
750 ``dotencode``
724 Enable or disable the "dotencode" repository format which enhances
751 Enable or disable the "dotencode" repository format which enhances
725 the "fncache" repository format (which has to be enabled to use
752 the "fncache" repository format (which has to be enabled to use
726 dotencode) to avoid issues with filenames starting with ._ on
753 dotencode) to avoid issues with filenames starting with ._ on
727 Mac OS X and spaces on Windows.
754 Mac OS X and spaces on Windows.
728
755
729 Repositories with this on-disk format require Mercurial version 1.7.
756 Repositories with this on-disk format require Mercurial version 1.7.
730
757
731 Enabled by default.
758 Enabled by default.
732
759
733 ``usefncache``
760 ``usefncache``
734 Enable or disable the "fncache" repository format which enhances
761 Enable or disable the "fncache" repository format which enhances
735 the "store" repository format (which has to be enabled to use
762 the "store" repository format (which has to be enabled to use
736 fncache) to allow longer filenames and avoids using Windows
763 fncache) to allow longer filenames and avoids using Windows
737 reserved names, e.g. "nul".
764 reserved names, e.g. "nul".
738
765
739 Repositories with this on-disk format require Mercurial version 1.1.
766 Repositories with this on-disk format require Mercurial version 1.1.
740
767
741 Enabled by default.
768 Enabled by default.
742
769
743 ``usestore``
770 ``usestore``
744 Enable or disable the "store" repository format which improves
771 Enable or disable the "store" repository format which improves
745 compatibility with systems that fold case or otherwise mangle
772 compatibility with systems that fold case or otherwise mangle
746 filenames. Disabling this option will allow you to store longer filenames
773 filenames. Disabling this option will allow you to store longer filenames
747 in some situations at the expense of compatibility.
774 in some situations at the expense of compatibility.
748
775
749 Repositories with this on-disk format require Mercurial version 0.9.4.
776 Repositories with this on-disk format require Mercurial version 0.9.4.
750
777
751 Enabled by default.
778 Enabled by default.
752
779
753 ``graph``
780 ``graph``
754 ---------
781 ---------
755
782
756 Web graph view configuration. This section let you change graph
783 Web graph view configuration. This section let you change graph
757 elements display properties by branches, for instance to make the
784 elements display properties by branches, for instance to make the
758 ``default`` branch stand out.
785 ``default`` branch stand out.
759
786
760 Each line has the following format::
787 Each line has the following format::
761
788
762 <branch>.<argument> = <value>
789 <branch>.<argument> = <value>
763
790
764 where ``<branch>`` is the name of the branch being
791 where ``<branch>`` is the name of the branch being
765 customized. Example::
792 customized. Example::
766
793
767 [graph]
794 [graph]
768 # 2px width
795 # 2px width
769 default.width = 2
796 default.width = 2
770 # red color
797 # red color
771 default.color = FF0000
798 default.color = FF0000
772
799
773 Supported arguments:
800 Supported arguments:
774
801
775 ``width``
802 ``width``
776 Set branch edges width in pixels.
803 Set branch edges width in pixels.
777
804
778 ``color``
805 ``color``
779 Set branch edges color in hexadecimal RGB notation.
806 Set branch edges color in hexadecimal RGB notation.
780
807
781 ``hooks``
808 ``hooks``
782 ---------
809 ---------
783
810
784 Commands or Python functions that get automatically executed by
811 Commands or Python functions that get automatically executed by
785 various actions such as starting or finishing a commit. Multiple
812 various actions such as starting or finishing a commit. Multiple
786 hooks can be run for the same action by appending a suffix to the
813 hooks can be run for the same action by appending a suffix to the
787 action. Overriding a site-wide hook can be done by changing its
814 action. Overriding a site-wide hook can be done by changing its
788 value or setting it to an empty string. Hooks can be prioritized
815 value or setting it to an empty string. Hooks can be prioritized
789 by adding a prefix of ``priority.`` to the hook name on a new line
816 by adding a prefix of ``priority.`` to the hook name on a new line
790 and setting the priority. The default priority is 0.
817 and setting the priority. The default priority is 0.
791
818
792 Example ``.hg/hgrc``::
819 Example ``.hg/hgrc``::
793
820
794 [hooks]
821 [hooks]
795 # update working directory after adding changesets
822 # update working directory after adding changesets
796 changegroup.update = hg update
823 changegroup.update = hg update
797 # do not use the site-wide hook
824 # do not use the site-wide hook
798 incoming =
825 incoming =
799 incoming.email = /my/email/hook
826 incoming.email = /my/email/hook
800 incoming.autobuild = /my/build/hook
827 incoming.autobuild = /my/build/hook
801 # force autobuild hook to run before other incoming hooks
828 # force autobuild hook to run before other incoming hooks
802 priority.incoming.autobuild = 1
829 priority.incoming.autobuild = 1
803
830
804 Most hooks are run with environment variables set that give useful
831 Most hooks are run with environment variables set that give useful
805 additional information. For each hook below, the environment
832 additional information. For each hook below, the environment
806 variables it is passed are listed with names of the form ``$HG_foo``.
833 variables it is passed are listed with names of the form ``$HG_foo``.
807
834
808 ``changegroup``
835 ``changegroup``
809 Run after a changegroup has been added via push, pull or unbundle. ID of the
836 Run after a changegroup has been added via push, pull or unbundle. ID of the
810 first new changeset is in ``$HG_NODE`` and last in ``$HG_NODE_LAST``. URL
837 first new changeset is in ``$HG_NODE`` and last in ``$HG_NODE_LAST``. URL
811 from which changes came is in ``$HG_URL``.
838 from which changes came is in ``$HG_URL``.
812
839
813 ``commit``
840 ``commit``
814 Run after a changeset has been created in the local repository. ID
841 Run after a changeset has been created in the local repository. ID
815 of the newly created changeset is in ``$HG_NODE``. Parent changeset
842 of the newly created changeset is in ``$HG_NODE``. Parent changeset
816 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
843 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
817
844
818 ``incoming``
845 ``incoming``
819 Run after a changeset has been pulled, pushed, or unbundled into
846 Run after a changeset has been pulled, pushed, or unbundled into
820 the local repository. The ID of the newly arrived changeset is in
847 the local repository. The ID of the newly arrived changeset is in
821 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
848 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
822
849
823 ``outgoing``
850 ``outgoing``
824 Run after sending changes from local repository to another. ID of
851 Run after sending changes from local repository to another. ID of
825 first changeset sent is in ``$HG_NODE``. Source of operation is in
852 first changeset sent is in ``$HG_NODE``. Source of operation is in
826 ``$HG_SOURCE``; Also see :hg:`help config.hooks.preoutgoing` hook.
853 ``$HG_SOURCE``; Also see :hg:`help config.hooks.preoutgoing` hook.
827
854
828 ``post-<command>``
855 ``post-<command>``
829 Run after successful invocations of the associated command. The
856 Run after successful invocations of the associated command. The
830 contents of the command line are passed as ``$HG_ARGS`` and the result
857 contents of the command line are passed as ``$HG_ARGS`` and the result
831 code in ``$HG_RESULT``. Parsed command line arguments are passed as
858 code in ``$HG_RESULT``. Parsed command line arguments are passed as
832 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
859 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
833 the python data internally passed to <command>. ``$HG_OPTS`` is a
860 the python data internally passed to <command>. ``$HG_OPTS`` is a
834 dictionary of options (with unspecified options set to their defaults).
861 dictionary of options (with unspecified options set to their defaults).
835 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
862 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
836
863
837 ``fail-<command>``
864 ``fail-<command>``
838 Run after a failed invocation of an associated command. The contents
865 Run after a failed invocation of an associated command. The contents
839 of the command line are passed as ``$HG_ARGS``. Parsed command line
866 of the command line are passed as ``$HG_ARGS``. Parsed command line
840 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
867 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
841 string representations of the python data internally passed to
868 string representations of the python data internally passed to
842 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
869 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
843 options set to their defaults). ``$HG_PATS`` is a list of arguments.
870 options set to their defaults). ``$HG_PATS`` is a list of arguments.
844 Hook failure is ignored.
871 Hook failure is ignored.
845
872
846 ``pre-<command>``
873 ``pre-<command>``
847 Run before executing the associated command. The contents of the
874 Run before executing the associated command. The contents of the
848 command line are passed as ``$HG_ARGS``. Parsed command line arguments
875 command line are passed as ``$HG_ARGS``. Parsed command line arguments
849 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
876 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
850 representations of the data internally passed to <command>. ``$HG_OPTS``
877 representations of the data internally passed to <command>. ``$HG_OPTS``
851 is a dictionary of options (with unspecified options set to their
878 is a dictionary of options (with unspecified options set to their
852 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
879 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
853 failure, the command doesn't execute and Mercurial returns the failure
880 failure, the command doesn't execute and Mercurial returns the failure
854 code.
881 code.
855
882
856 ``prechangegroup``
883 ``prechangegroup``
857 Run before a changegroup is added via push, pull or unbundle. Exit
884 Run before a changegroup is added via push, pull or unbundle. Exit
858 status 0 allows the changegroup to proceed. Non-zero status will
885 status 0 allows the changegroup to proceed. Non-zero status will
859 cause the push, pull or unbundle to fail. URL from which changes
886 cause the push, pull or unbundle to fail. URL from which changes
860 will come is in ``$HG_URL``.
887 will come is in ``$HG_URL``.
861
888
862 ``precommit``
889 ``precommit``
863 Run before starting a local commit. Exit status 0 allows the
890 Run before starting a local commit. Exit status 0 allows the
864 commit to proceed. Non-zero status will cause the commit to fail.
891 commit to proceed. Non-zero status will cause the commit to fail.
865 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
892 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
866
893
867 ``prelistkeys``
894 ``prelistkeys``
868 Run before listing pushkeys (like bookmarks) in the
895 Run before listing pushkeys (like bookmarks) in the
869 repository. Non-zero status will cause failure. The key namespace is
896 repository. Non-zero status will cause failure. The key namespace is
870 in ``$HG_NAMESPACE``.
897 in ``$HG_NAMESPACE``.
871
898
872 ``preoutgoing``
899 ``preoutgoing``
873 Run before collecting changes to send from the local repository to
900 Run before collecting changes to send from the local repository to
874 another. Non-zero status will cause failure. This lets you prevent
901 another. Non-zero status will cause failure. This lets you prevent
875 pull over HTTP or SSH. Also prevents against local pull, push
902 pull over HTTP or SSH. Also prevents against local pull, push
876 (outbound) or bundle commands, but not effective, since you can
903 (outbound) or bundle commands, but not effective, since you can
877 just copy files instead then. Source of operation is in
904 just copy files instead then. Source of operation is in
878 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
905 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
879 SSH or HTTP repository. If "push", "pull" or "bundle", operation
906 SSH or HTTP repository. If "push", "pull" or "bundle", operation
880 is happening on behalf of repository on same system.
907 is happening on behalf of repository on same system.
881
908
882 ``prepushkey``
909 ``prepushkey``
883 Run before a pushkey (like a bookmark) is added to the
910 Run before a pushkey (like a bookmark) is added to the
884 repository. Non-zero status will cause the key to be rejected. The
911 repository. Non-zero status will cause the key to be rejected. The
885 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
912 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
886 the old value (if any) is in ``$HG_OLD``, and the new value is in
913 the old value (if any) is in ``$HG_OLD``, and the new value is in
887 ``$HG_NEW``.
914 ``$HG_NEW``.
888
915
889 ``pretag``
916 ``pretag``
890 Run before creating a tag. Exit status 0 allows the tag to be
917 Run before creating a tag. Exit status 0 allows the tag to be
891 created. Non-zero status will cause the tag to fail. ID of
918 created. Non-zero status will cause the tag to fail. ID of
892 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
919 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
893 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
920 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
894
921
895 ``pretxnopen``
922 ``pretxnopen``
896 Run before any new repository transaction is open. The reason for the
923 Run before any new repository transaction is open. The reason for the
897 transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
924 transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
898 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
925 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
899 transaction from being opened.
926 transaction from being opened.
900
927
901 ``pretxnclose``
928 ``pretxnclose``
902 Run right before the transaction is actually finalized. Any repository change
929 Run right before the transaction is actually finalized. Any repository change
903 will be visible to the hook program. This lets you validate the transaction
930 will be visible to the hook program. This lets you validate the transaction
904 content or change it. Exit status 0 allows the commit to proceed. Non-zero
931 content or change it. Exit status 0 allows the commit to proceed. Non-zero
905 status will cause the transaction to be rolled back. The reason for the
932 status will cause the transaction to be rolled back. The reason for the
906 transaction opening will be in ``$HG_TXNNAME`` and a unique identifier for
933 transaction opening will be in ``$HG_TXNNAME`` and a unique identifier for
907 the transaction will be in ``HG_TXNID``. The rest of the available data will
934 the transaction will be in ``HG_TXNID``. The rest of the available data will
908 vary according the transaction type. New changesets will add ``$HG_NODE`` (id
935 vary according the transaction type. New changesets will add ``$HG_NODE`` (id
909 of the first added changeset), ``$HG_NODE_LAST`` (id of the last added
936 of the first added changeset), ``$HG_NODE_LAST`` (id of the last added
910 changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables, bookmarks and phases
937 changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables, bookmarks and phases
911 changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``, etc.
938 changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``, etc.
912
939
913 ``txnclose``
940 ``txnclose``
914 Run after any repository transaction has been committed. At this
941 Run after any repository transaction has been committed. At this
915 point, the transaction can no longer be rolled back. The hook will run
942 point, the transaction can no longer be rolled back. The hook will run
916 after the lock is released. See :hg:`help config.hooks.pretxnclose` docs for
943 after the lock is released. See :hg:`help config.hooks.pretxnclose` docs for
917 details about available variables.
944 details about available variables.
918
945
919 ``txnabort``
946 ``txnabort``
920 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
947 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
921 docs for details about available variables.
948 docs for details about available variables.
922
949
923 ``pretxnchangegroup``
950 ``pretxnchangegroup``
924 Run after a changegroup has been added via push, pull or unbundle, but before
951 Run after a changegroup has been added via push, pull or unbundle, but before
925 the transaction has been committed. Changegroup is visible to hook program.
952 the transaction has been committed. Changegroup is visible to hook program.
926 This lets you validate incoming changes before accepting them. Passed the ID
953 This lets you validate incoming changes before accepting them. Passed the ID
927 of the first new changeset in ``$HG_NODE`` and last in ``$HG_NODE_LAST``.
954 of the first new changeset in ``$HG_NODE`` and last in ``$HG_NODE_LAST``.
928 Exit status 0 allows the transaction to commit. Non-zero status will cause
955 Exit status 0 allows the transaction to commit. Non-zero status will cause
929 the transaction to be rolled back and the push, pull or unbundle will fail.
956 the transaction to be rolled back and the push, pull or unbundle will fail.
930 URL that was source of changes is in ``$HG_URL``.
957 URL that was source of changes is in ``$HG_URL``.
931
958
932 ``pretxncommit``
959 ``pretxncommit``
933 Run after a changeset has been created but the transaction not yet
960 Run after a changeset has been created but the transaction not yet
934 committed. Changeset is visible to hook program. This lets you
961 committed. Changeset is visible to hook program. This lets you
935 validate commit message and changes. Exit status 0 allows the
962 validate commit message and changes. Exit status 0 allows the
936 commit to proceed. Non-zero status will cause the transaction to
963 commit to proceed. Non-zero status will cause the transaction to
937 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
964 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
938 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
965 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
939
966
940 ``preupdate``
967 ``preupdate``
941 Run before updating the working directory. Exit status 0 allows
968 Run before updating the working directory. Exit status 0 allows
942 the update to proceed. Non-zero status will prevent the update.
969 the update to proceed. Non-zero status will prevent the update.
943 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
970 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
944 of second new parent is in ``$HG_PARENT2``.
971 of second new parent is in ``$HG_PARENT2``.
945
972
946 ``listkeys``
973 ``listkeys``
947 Run after listing pushkeys (like bookmarks) in the repository. The
974 Run after listing pushkeys (like bookmarks) in the repository. The
948 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
975 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
949 dictionary containing the keys and values.
976 dictionary containing the keys and values.
950
977
951 ``pushkey``
978 ``pushkey``
952 Run after a pushkey (like a bookmark) is added to the
979 Run after a pushkey (like a bookmark) is added to the
953 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
980 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
954 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
981 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
955 value is in ``$HG_NEW``.
982 value is in ``$HG_NEW``.
956
983
957 ``tag``
984 ``tag``
958 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
985 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
959 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
986 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
960 repository if ``$HG_LOCAL=0``.
987 repository if ``$HG_LOCAL=0``.
961
988
962 ``update``
989 ``update``
963 Run after updating the working directory. Changeset ID of first
990 Run after updating the working directory. Changeset ID of first
964 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
991 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
965 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
992 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
966 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
993 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
967
994
968 .. note::
995 .. note::
969
996
970 It is generally better to use standard hooks rather than the
997 It is generally better to use standard hooks rather than the
971 generic pre- and post- command hooks as they are guaranteed to be
998 generic pre- and post- command hooks as they are guaranteed to be
972 called in the appropriate contexts for influencing transactions.
999 called in the appropriate contexts for influencing transactions.
973 Also, hooks like "commit" will be called in all contexts that
1000 Also, hooks like "commit" will be called in all contexts that
974 generate a commit (e.g. tag) and not just the commit command.
1001 generate a commit (e.g. tag) and not just the commit command.
975
1002
976 .. note::
1003 .. note::
977
1004
978 Environment variables with empty values may not be passed to
1005 Environment variables with empty values may not be passed to
979 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1006 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
980 will have an empty value under Unix-like platforms for non-merge
1007 will have an empty value under Unix-like platforms for non-merge
981 changesets, while it will not be available at all under Windows.
1008 changesets, while it will not be available at all under Windows.
982
1009
983 The syntax for Python hooks is as follows::
1010 The syntax for Python hooks is as follows::
984
1011
985 hookname = python:modulename.submodule.callable
1012 hookname = python:modulename.submodule.callable
986 hookname = python:/path/to/python/module.py:callable
1013 hookname = python:/path/to/python/module.py:callable
987
1014
988 Python hooks are run within the Mercurial process. Each hook is
1015 Python hooks are run within the Mercurial process. Each hook is
989 called with at least three keyword arguments: a ui object (keyword
1016 called with at least three keyword arguments: a ui object (keyword
990 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1017 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
991 keyword that tells what kind of hook is used. Arguments listed as
1018 keyword that tells what kind of hook is used. Arguments listed as
992 environment variables above are passed as keyword arguments, with no
1019 environment variables above are passed as keyword arguments, with no
993 ``HG_`` prefix, and names in lower case.
1020 ``HG_`` prefix, and names in lower case.
994
1021
995 If a Python hook returns a "true" value or raises an exception, this
1022 If a Python hook returns a "true" value or raises an exception, this
996 is treated as a failure.
1023 is treated as a failure.
997
1024
998
1025
999 ``hostfingerprints``
1026 ``hostfingerprints``
1000 --------------------
1027 --------------------
1001
1028
1002 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1029 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1003
1030
1004 Fingerprints of the certificates of known HTTPS servers.
1031 Fingerprints of the certificates of known HTTPS servers.
1005
1032
1006 A HTTPS connection to a server with a fingerprint configured here will
1033 A HTTPS connection to a server with a fingerprint configured here will
1007 only succeed if the servers certificate matches the fingerprint.
1034 only succeed if the servers certificate matches the fingerprint.
1008 This is very similar to how ssh known hosts works.
1035 This is very similar to how ssh known hosts works.
1009
1036
1010 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1037 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1011 Multiple values can be specified (separated by spaces or commas). This can
1038 Multiple values can be specified (separated by spaces or commas). This can
1012 be used to define both old and new fingerprints while a host transitions
1039 be used to define both old and new fingerprints while a host transitions
1013 to a new certificate.
1040 to a new certificate.
1014
1041
1015 The CA chain and web.cacerts is not used for servers with a fingerprint.
1042 The CA chain and web.cacerts is not used for servers with a fingerprint.
1016
1043
1017 For example::
1044 For example::
1018
1045
1019 [hostfingerprints]
1046 [hostfingerprints]
1020 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
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 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
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 ``hostsecurity``
1050 ``hostsecurity``
1024 ----------------
1051 ----------------
1025
1052
1026 Used to specify global and per-host security settings for connecting to
1053 Used to specify global and per-host security settings for connecting to
1027 other machines.
1054 other machines.
1028
1055
1029 The following options control default behavior for all hosts.
1056 The following options control default behavior for all hosts.
1030
1057
1031 ``ciphers``
1058 ``ciphers``
1032 Defines the cryptographic ciphers to use for connections.
1059 Defines the cryptographic ciphers to use for connections.
1033
1060
1034 Value must be a valid OpenSSL Cipher List Format as documented at
1061 Value must be a valid OpenSSL Cipher List Format as documented at
1035 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1062 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1036
1063
1037 This setting is for advanced users only. Setting to incorrect values
1064 This setting is for advanced users only. Setting to incorrect values
1038 can significantly lower connection security or decrease performance.
1065 can significantly lower connection security or decrease performance.
1039 You have been warned.
1066 You have been warned.
1040
1067
1041 This option requires Python 2.7.
1068 This option requires Python 2.7.
1042
1069
1043 ``minimumprotocol``
1070 ``minimumprotocol``
1044 Defines the minimum channel encryption protocol to use.
1071 Defines the minimum channel encryption protocol to use.
1045
1072
1046 By default, the highest version of TLS supported by both client and server
1073 By default, the highest version of TLS supported by both client and server
1047 is used.
1074 is used.
1048
1075
1049 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1076 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1050
1077
1051 When running on an old Python version, only ``tls1.0`` is allowed since
1078 When running on an old Python version, only ``tls1.0`` is allowed since
1052 old versions of Python only support up to TLS 1.0.
1079 old versions of Python only support up to TLS 1.0.
1053
1080
1054 When running a Python that supports modern TLS versions, the default is
1081 When running a Python that supports modern TLS versions, the default is
1055 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1082 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1056 weakens security and should only be used as a feature of last resort if
1083 weakens security and should only be used as a feature of last resort if
1057 a server does not support TLS 1.1+.
1084 a server does not support TLS 1.1+.
1058
1085
1059 Options in the ``[hostsecurity]`` section can have the form
1086 Options in the ``[hostsecurity]`` section can have the form
1060 ``hostname``:``setting``. This allows multiple settings to be defined on a
1087 ``hostname``:``setting``. This allows multiple settings to be defined on a
1061 per-host basis.
1088 per-host basis.
1062
1089
1063 The following per-host settings can be defined.
1090 The following per-host settings can be defined.
1064
1091
1065 ``ciphers``
1092 ``ciphers``
1066 This behaves like ``ciphers`` as described above except it only applies
1093 This behaves like ``ciphers`` as described above except it only applies
1067 to the host on which it is defined.
1094 to the host on which it is defined.
1068
1095
1069 ``fingerprints``
1096 ``fingerprints``
1070 A list of hashes of the DER encoded peer/remote certificate. Values have
1097 A list of hashes of the DER encoded peer/remote certificate. Values have
1071 the form ``algorithm``:``fingerprint``. e.g.
1098 the form ``algorithm``:``fingerprint``. e.g.
1072 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1099 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1073
1100
1074 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1101 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1075 ``sha512``.
1102 ``sha512``.
1076
1103
1077 Use of ``sha256`` or ``sha512`` is preferred.
1104 Use of ``sha256`` or ``sha512`` is preferred.
1078
1105
1079 If a fingerprint is specified, the CA chain is not validated for this
1106 If a fingerprint is specified, the CA chain is not validated for this
1080 host and Mercurial will require the remote certificate to match one
1107 host and Mercurial will require the remote certificate to match one
1081 of the fingerprints specified. This means if the server updates its
1108 of the fingerprints specified. This means if the server updates its
1082 certificate, Mercurial will abort until a new fingerprint is defined.
1109 certificate, Mercurial will abort until a new fingerprint is defined.
1083 This can provide stronger security than traditional CA-based validation
1110 This can provide stronger security than traditional CA-based validation
1084 at the expense of convenience.
1111 at the expense of convenience.
1085
1112
1086 This option takes precedence over ``verifycertsfile``.
1113 This option takes precedence over ``verifycertsfile``.
1087
1114
1088 ``minimumprotocol``
1115 ``minimumprotocol``
1089 This behaves like ``minimumprotocol`` as described above except it
1116 This behaves like ``minimumprotocol`` as described above except it
1090 only applies to the host on which it is defined.
1117 only applies to the host on which it is defined.
1091
1118
1092 ``verifycertsfile``
1119 ``verifycertsfile``
1093 Path to file a containing a list of PEM encoded certificates used to
1120 Path to file a containing a list of PEM encoded certificates used to
1094 verify the server certificate. Environment variables and ``~user``
1121 verify the server certificate. Environment variables and ``~user``
1095 constructs are expanded in the filename.
1122 constructs are expanded in the filename.
1096
1123
1097 The server certificate or the certificate's certificate authority (CA)
1124 The server certificate or the certificate's certificate authority (CA)
1098 must match a certificate from this file or certificate verification
1125 must match a certificate from this file or certificate verification
1099 will fail and connections to the server will be refused.
1126 will fail and connections to the server will be refused.
1100
1127
1101 If defined, only certificates provided by this file will be used:
1128 If defined, only certificates provided by this file will be used:
1102 ``web.cacerts`` and any system/default certificates will not be
1129 ``web.cacerts`` and any system/default certificates will not be
1103 used.
1130 used.
1104
1131
1105 This option has no effect if the per-host ``fingerprints`` option
1132 This option has no effect if the per-host ``fingerprints`` option
1106 is set.
1133 is set.
1107
1134
1108 The format of the file is as follows::
1135 The format of the file is as follows::
1109
1136
1110 -----BEGIN CERTIFICATE-----
1137 -----BEGIN CERTIFICATE-----
1111 ... (certificate in base64 PEM encoding) ...
1138 ... (certificate in base64 PEM encoding) ...
1112 -----END CERTIFICATE-----
1139 -----END CERTIFICATE-----
1113 -----BEGIN CERTIFICATE-----
1140 -----BEGIN CERTIFICATE-----
1114 ... (certificate in base64 PEM encoding) ...
1141 ... (certificate in base64 PEM encoding) ...
1115 -----END CERTIFICATE-----
1142 -----END CERTIFICATE-----
1116
1143
1117 For example::
1144 For example::
1118
1145
1119 [hostsecurity]
1146 [hostsecurity]
1120 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1147 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1121 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
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 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1149 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1123
1150
1124 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1151 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1125 when connecting to ``hg.example.com``::
1152 when connecting to ``hg.example.com``::
1126
1153
1127 [hostsecurity]
1154 [hostsecurity]
1128 minimumprotocol = tls1.2
1155 minimumprotocol = tls1.2
1129 hg.example.com:minimumprotocol = tls1.1
1156 hg.example.com:minimumprotocol = tls1.1
1130
1157
1131 ``http_proxy``
1158 ``http_proxy``
1132 --------------
1159 --------------
1133
1160
1134 Used to access web-based Mercurial repositories through a HTTP
1161 Used to access web-based Mercurial repositories through a HTTP
1135 proxy.
1162 proxy.
1136
1163
1137 ``host``
1164 ``host``
1138 Host name and (optional) port of the proxy server, for example
1165 Host name and (optional) port of the proxy server, for example
1139 "myproxy:8000".
1166 "myproxy:8000".
1140
1167
1141 ``no``
1168 ``no``
1142 Optional. Comma-separated list of host names that should bypass
1169 Optional. Comma-separated list of host names that should bypass
1143 the proxy.
1170 the proxy.
1144
1171
1145 ``passwd``
1172 ``passwd``
1146 Optional. Password to authenticate with at the proxy server.
1173 Optional. Password to authenticate with at the proxy server.
1147
1174
1148 ``user``
1175 ``user``
1149 Optional. User name to authenticate with at the proxy server.
1176 Optional. User name to authenticate with at the proxy server.
1150
1177
1151 ``always``
1178 ``always``
1152 Optional. Always use the proxy, even for localhost and any entries
1179 Optional. Always use the proxy, even for localhost and any entries
1153 in ``http_proxy.no``. (default: False)
1180 in ``http_proxy.no``. (default: False)
1154
1181
1155 ``merge``
1182 ``merge``
1156 ---------
1183 ---------
1157
1184
1158 This section specifies behavior during merges and updates.
1185 This section specifies behavior during merges and updates.
1159
1186
1160 ``checkignored``
1187 ``checkignored``
1161 Controls behavior when an ignored file on disk has the same name as a tracked
1188 Controls behavior when an ignored file on disk has the same name as a tracked
1162 file in the changeset being merged or updated to, and has different
1189 file in the changeset being merged or updated to, and has different
1163 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1190 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1164 abort on such files. With ``warn``, warn on such files and back them up as
1191 abort on such files. With ``warn``, warn on such files and back them up as
1165 ``.orig``. With ``ignore``, don't print a warning and back them up as
1192 ``.orig``. With ``ignore``, don't print a warning and back them up as
1166 ``.orig``. (default: ``abort``)
1193 ``.orig``. (default: ``abort``)
1167
1194
1168 ``checkunknown``
1195 ``checkunknown``
1169 Controls behavior when an unknown file that isn't ignored has the same name
1196 Controls behavior when an unknown file that isn't ignored has the same name
1170 as a tracked file in the changeset being merged or updated to, and has
1197 as a tracked file in the changeset being merged or updated to, and has
1171 different contents. Similar to ``merge.checkignored``, except for files that
1198 different contents. Similar to ``merge.checkignored``, except for files that
1172 are not ignored. (default: ``abort``)
1199 are not ignored. (default: ``abort``)
1173
1200
1174 ``merge-patterns``
1201 ``merge-patterns``
1175 ------------------
1202 ------------------
1176
1203
1177 This section specifies merge tools to associate with particular file
1204 This section specifies merge tools to associate with particular file
1178 patterns. Tools matched here will take precedence over the default
1205 patterns. Tools matched here will take precedence over the default
1179 merge tool. Patterns are globs by default, rooted at the repository
1206 merge tool. Patterns are globs by default, rooted at the repository
1180 root.
1207 root.
1181
1208
1182 Example::
1209 Example::
1183
1210
1184 [merge-patterns]
1211 [merge-patterns]
1185 **.c = kdiff3
1212 **.c = kdiff3
1186 **.jpg = myimgmerge
1213 **.jpg = myimgmerge
1187
1214
1188 ``merge-tools``
1215 ``merge-tools``
1189 ---------------
1216 ---------------
1190
1217
1191 This section configures external merge tools to use for file-level
1218 This section configures external merge tools to use for file-level
1192 merges. This section has likely been preconfigured at install time.
1219 merges. This section has likely been preconfigured at install time.
1193 Use :hg:`config merge-tools` to check the existing configuration.
1220 Use :hg:`config merge-tools` to check the existing configuration.
1194 Also see :hg:`help merge-tools` for more details.
1221 Also see :hg:`help merge-tools` for more details.
1195
1222
1196 Example ``~/.hgrc``::
1223 Example ``~/.hgrc``::
1197
1224
1198 [merge-tools]
1225 [merge-tools]
1199 # Override stock tool location
1226 # Override stock tool location
1200 kdiff3.executable = ~/bin/kdiff3
1227 kdiff3.executable = ~/bin/kdiff3
1201 # Specify command line
1228 # Specify command line
1202 kdiff3.args = $base $local $other -o $output
1229 kdiff3.args = $base $local $other -o $output
1203 # Give higher priority
1230 # Give higher priority
1204 kdiff3.priority = 1
1231 kdiff3.priority = 1
1205
1232
1206 # Changing the priority of preconfigured tool
1233 # Changing the priority of preconfigured tool
1207 meld.priority = 0
1234 meld.priority = 0
1208
1235
1209 # Disable a preconfigured tool
1236 # Disable a preconfigured tool
1210 vimdiff.disabled = yes
1237 vimdiff.disabled = yes
1211
1238
1212 # Define new tool
1239 # Define new tool
1213 myHtmlTool.args = -m $local $other $base $output
1240 myHtmlTool.args = -m $local $other $base $output
1214 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1241 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1215 myHtmlTool.priority = 1
1242 myHtmlTool.priority = 1
1216
1243
1217 Supported arguments:
1244 Supported arguments:
1218
1245
1219 ``priority``
1246 ``priority``
1220 The priority in which to evaluate this tool.
1247 The priority in which to evaluate this tool.
1221 (default: 0)
1248 (default: 0)
1222
1249
1223 ``executable``
1250 ``executable``
1224 Either just the name of the executable or its pathname.
1251 Either just the name of the executable or its pathname.
1225
1252
1226 .. container:: windows
1253 .. container:: windows
1227
1254
1228 On Windows, the path can use environment variables with ${ProgramFiles}
1255 On Windows, the path can use environment variables with ${ProgramFiles}
1229 syntax.
1256 syntax.
1230
1257
1231 (default: the tool name)
1258 (default: the tool name)
1232
1259
1233 ``args``
1260 ``args``
1234 The arguments to pass to the tool executable. You can refer to the
1261 The arguments to pass to the tool executable. You can refer to the
1235 files being merged as well as the output file through these
1262 files being merged as well as the output file through these
1236 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1263 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1237 of ``$local`` and ``$other`` can vary depending on which action is being
1264 of ``$local`` and ``$other`` can vary depending on which action is being
1238 performed. During and update or merge, ``$local`` represents the original
1265 performed. During and update or merge, ``$local`` represents the original
1239 state of the file, while ``$other`` represents the commit you are updating
1266 state of the file, while ``$other`` represents the commit you are updating
1240 to or the commit you are merging with. During a rebase ``$local``
1267 to or the commit you are merging with. During a rebase ``$local``
1241 represents the destination of the rebase, and ``$other`` represents the
1268 represents the destination of the rebase, and ``$other`` represents the
1242 commit being rebased.
1269 commit being rebased.
1243 (default: ``$local $base $other``)
1270 (default: ``$local $base $other``)
1244
1271
1245 ``premerge``
1272 ``premerge``
1246 Attempt to run internal non-interactive 3-way merge tool before
1273 Attempt to run internal non-interactive 3-way merge tool before
1247 launching external tool. Options are ``true``, ``false``, ``keep`` or
1274 launching external tool. Options are ``true``, ``false``, ``keep`` or
1248 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1275 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1249 premerge fails. The ``keep-merge3`` will do the same but include information
1276 premerge fails. The ``keep-merge3`` will do the same but include information
1250 about the base of the merge in the marker (see internal :merge3 in
1277 about the base of the merge in the marker (see internal :merge3 in
1251 :hg:`help merge-tools`).
1278 :hg:`help merge-tools`).
1252 (default: True)
1279 (default: True)
1253
1280
1254 ``binary``
1281 ``binary``
1255 This tool can merge binary files. (default: False, unless tool
1282 This tool can merge binary files. (default: False, unless tool
1256 was selected by file pattern match)
1283 was selected by file pattern match)
1257
1284
1258 ``symlink``
1285 ``symlink``
1259 This tool can merge symlinks. (default: False)
1286 This tool can merge symlinks. (default: False)
1260
1287
1261 ``check``
1288 ``check``
1262 A list of merge success-checking options:
1289 A list of merge success-checking options:
1263
1290
1264 ``changed``
1291 ``changed``
1265 Ask whether merge was successful when the merged file shows no changes.
1292 Ask whether merge was successful when the merged file shows no changes.
1266 ``conflicts``
1293 ``conflicts``
1267 Check whether there are conflicts even though the tool reported success.
1294 Check whether there are conflicts even though the tool reported success.
1268 ``prompt``
1295 ``prompt``
1269 Always prompt for merge success, regardless of success reported by tool.
1296 Always prompt for merge success, regardless of success reported by tool.
1270
1297
1271 ``fixeol``
1298 ``fixeol``
1272 Attempt to fix up EOL changes caused by the merge tool.
1299 Attempt to fix up EOL changes caused by the merge tool.
1273 (default: False)
1300 (default: False)
1274
1301
1275 ``gui``
1302 ``gui``
1276 This tool requires a graphical interface to run. (default: False)
1303 This tool requires a graphical interface to run. (default: False)
1277
1304
1278 .. container:: windows
1305 .. container:: windows
1279
1306
1280 ``regkey``
1307 ``regkey``
1281 Windows registry key which describes install location of this
1308 Windows registry key which describes install location of this
1282 tool. Mercurial will search for this key first under
1309 tool. Mercurial will search for this key first under
1283 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1310 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1284 (default: None)
1311 (default: None)
1285
1312
1286 ``regkeyalt``
1313 ``regkeyalt``
1287 An alternate Windows registry key to try if the first key is not
1314 An alternate Windows registry key to try if the first key is not
1288 found. The alternate key uses the same ``regname`` and ``regappend``
1315 found. The alternate key uses the same ``regname`` and ``regappend``
1289 semantics of the primary key. The most common use for this key
1316 semantics of the primary key. The most common use for this key
1290 is to search for 32bit applications on 64bit operating systems.
1317 is to search for 32bit applications on 64bit operating systems.
1291 (default: None)
1318 (default: None)
1292
1319
1293 ``regname``
1320 ``regname``
1294 Name of value to read from specified registry key.
1321 Name of value to read from specified registry key.
1295 (default: the unnamed (default) value)
1322 (default: the unnamed (default) value)
1296
1323
1297 ``regappend``
1324 ``regappend``
1298 String to append to the value read from the registry, typically
1325 String to append to the value read from the registry, typically
1299 the executable name of the tool.
1326 the executable name of the tool.
1300 (default: None)
1327 (default: None)
1301
1328
1302
1329
1303 ``patch``
1330 ``patch``
1304 ---------
1331 ---------
1305
1332
1306 Settings used when applying patches, for instance through the 'import'
1333 Settings used when applying patches, for instance through the 'import'
1307 command or with Mercurial Queues extension.
1334 command or with Mercurial Queues extension.
1308
1335
1309 ``eol``
1336 ``eol``
1310 When set to 'strict' patch content and patched files end of lines
1337 When set to 'strict' patch content and patched files end of lines
1311 are preserved. When set to ``lf`` or ``crlf``, both files end of
1338 are preserved. When set to ``lf`` or ``crlf``, both files end of
1312 lines are ignored when patching and the result line endings are
1339 lines are ignored when patching and the result line endings are
1313 normalized to either LF (Unix) or CRLF (Windows). When set to
1340 normalized to either LF (Unix) or CRLF (Windows). When set to
1314 ``auto``, end of lines are again ignored while patching but line
1341 ``auto``, end of lines are again ignored while patching but line
1315 endings in patched files are normalized to their original setting
1342 endings in patched files are normalized to their original setting
1316 on a per-file basis. If target file does not exist or has no end
1343 on a per-file basis. If target file does not exist or has no end
1317 of line, patch line endings are preserved.
1344 of line, patch line endings are preserved.
1318 (default: strict)
1345 (default: strict)
1319
1346
1320 ``fuzz``
1347 ``fuzz``
1321 The number of lines of 'fuzz' to allow when applying patches. This
1348 The number of lines of 'fuzz' to allow when applying patches. This
1322 controls how much context the patcher is allowed to ignore when
1349 controls how much context the patcher is allowed to ignore when
1323 trying to apply a patch.
1350 trying to apply a patch.
1324 (default: 2)
1351 (default: 2)
1325
1352
1326 ``paths``
1353 ``paths``
1327 ---------
1354 ---------
1328
1355
1329 Assigns symbolic names and behavior to repositories.
1356 Assigns symbolic names and behavior to repositories.
1330
1357
1331 Options are symbolic names defining the URL or directory that is the
1358 Options are symbolic names defining the URL or directory that is the
1332 location of the repository. Example::
1359 location of the repository. Example::
1333
1360
1334 [paths]
1361 [paths]
1335 my_server = https://example.com/my_repo
1362 my_server = https://example.com/my_repo
1336 local_path = /home/me/repo
1363 local_path = /home/me/repo
1337
1364
1338 These symbolic names can be used from the command line. To pull
1365 These symbolic names can be used from the command line. To pull
1339 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1366 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1340 :hg:`push local_path`.
1367 :hg:`push local_path`.
1341
1368
1342 Options containing colons (``:``) denote sub-options that can influence
1369 Options containing colons (``:``) denote sub-options that can influence
1343 behavior for that specific path. Example::
1370 behavior for that specific path. Example::
1344
1371
1345 [paths]
1372 [paths]
1346 my_server = https://example.com/my_path
1373 my_server = https://example.com/my_path
1347 my_server:pushurl = ssh://example.com/my_path
1374 my_server:pushurl = ssh://example.com/my_path
1348
1375
1349 The following sub-options can be defined:
1376 The following sub-options can be defined:
1350
1377
1351 ``pushurl``
1378 ``pushurl``
1352 The URL to use for push operations. If not defined, the location
1379 The URL to use for push operations. If not defined, the location
1353 defined by the path's main entry is used.
1380 defined by the path's main entry is used.
1354
1381
1355 ``pushrev``
1382 ``pushrev``
1356 A revset defining which revisions to push by default.
1383 A revset defining which revisions to push by default.
1357
1384
1358 When :hg:`push` is executed without a ``-r`` argument, the revset
1385 When :hg:`push` is executed without a ``-r`` argument, the revset
1359 defined by this sub-option is evaluated to determine what to push.
1386 defined by this sub-option is evaluated to determine what to push.
1360
1387
1361 For example, a value of ``.`` will push the working directory's
1388 For example, a value of ``.`` will push the working directory's
1362 revision by default.
1389 revision by default.
1363
1390
1364 Revsets specifying bookmarks will not result in the bookmark being
1391 Revsets specifying bookmarks will not result in the bookmark being
1365 pushed.
1392 pushed.
1366
1393
1367 The following special named paths exist:
1394 The following special named paths exist:
1368
1395
1369 ``default``
1396 ``default``
1370 The URL or directory to use when no source or remote is specified.
1397 The URL or directory to use when no source or remote is specified.
1371
1398
1372 :hg:`clone` will automatically define this path to the location the
1399 :hg:`clone` will automatically define this path to the location the
1373 repository was cloned from.
1400 repository was cloned from.
1374
1401
1375 ``default-push``
1402 ``default-push``
1376 (deprecated) The URL or directory for the default :hg:`push` location.
1403 (deprecated) The URL or directory for the default :hg:`push` location.
1377 ``default:pushurl`` should be used instead.
1404 ``default:pushurl`` should be used instead.
1378
1405
1379 ``phases``
1406 ``phases``
1380 ----------
1407 ----------
1381
1408
1382 Specifies default handling of phases. See :hg:`help phases` for more
1409 Specifies default handling of phases. See :hg:`help phases` for more
1383 information about working with phases.
1410 information about working with phases.
1384
1411
1385 ``publish``
1412 ``publish``
1386 Controls draft phase behavior when working as a server. When true,
1413 Controls draft phase behavior when working as a server. When true,
1387 pushed changesets are set to public in both client and server and
1414 pushed changesets are set to public in both client and server and
1388 pulled or cloned changesets are set to public in the client.
1415 pulled or cloned changesets are set to public in the client.
1389 (default: True)
1416 (default: True)
1390
1417
1391 ``new-commit``
1418 ``new-commit``
1392 Phase of newly-created commits.
1419 Phase of newly-created commits.
1393 (default: draft)
1420 (default: draft)
1394
1421
1395 ``checksubrepos``
1422 ``checksubrepos``
1396 Check the phase of the current revision of each subrepository. Allowed
1423 Check the phase of the current revision of each subrepository. Allowed
1397 values are "ignore", "follow" and "abort". For settings other than
1424 values are "ignore", "follow" and "abort". For settings other than
1398 "ignore", the phase of the current revision of each subrepository is
1425 "ignore", the phase of the current revision of each subrepository is
1399 checked before committing the parent repository. If any of those phases is
1426 checked before committing the parent repository. If any of those phases is
1400 greater than the phase of the parent repository (e.g. if a subrepo is in a
1427 greater than the phase of the parent repository (e.g. if a subrepo is in a
1401 "secret" phase while the parent repo is in "draft" phase), the commit is
1428 "secret" phase while the parent repo is in "draft" phase), the commit is
1402 either aborted (if checksubrepos is set to "abort") or the higher phase is
1429 either aborted (if checksubrepos is set to "abort") or the higher phase is
1403 used for the parent repository commit (if set to "follow").
1430 used for the parent repository commit (if set to "follow").
1404 (default: follow)
1431 (default: follow)
1405
1432
1406
1433
1407 ``profiling``
1434 ``profiling``
1408 -------------
1435 -------------
1409
1436
1410 Specifies profiling type, format, and file output. Two profilers are
1437 Specifies profiling type, format, and file output. Two profilers are
1411 supported: an instrumenting profiler (named ``ls``), and a sampling
1438 supported: an instrumenting profiler (named ``ls``), and a sampling
1412 profiler (named ``stat``).
1439 profiler (named ``stat``).
1413
1440
1414 In this section description, 'profiling data' stands for the raw data
1441 In this section description, 'profiling data' stands for the raw data
1415 collected during profiling, while 'profiling report' stands for a
1442 collected during profiling, while 'profiling report' stands for a
1416 statistical text report generated from the profiling data. The
1443 statistical text report generated from the profiling data. The
1417 profiling is done using lsprof.
1444 profiling is done using lsprof.
1418
1445
1419 ``enabled``
1446 ``enabled``
1420 Enable the profiler.
1447 Enable the profiler.
1421 (default: false)
1448 (default: false)
1422
1449
1423 This is equivalent to passing ``--profile`` on the command line.
1450 This is equivalent to passing ``--profile`` on the command line.
1424
1451
1425 ``type``
1452 ``type``
1426 The type of profiler to use.
1453 The type of profiler to use.
1427 (default: stat)
1454 (default: stat)
1428
1455
1429 ``ls``
1456 ``ls``
1430 Use Python's built-in instrumenting profiler. This profiler
1457 Use Python's built-in instrumenting profiler. This profiler
1431 works on all platforms, but each line number it reports is the
1458 works on all platforms, but each line number it reports is the
1432 first line of a function. This restriction makes it difficult to
1459 first line of a function. This restriction makes it difficult to
1433 identify the expensive parts of a non-trivial function.
1460 identify the expensive parts of a non-trivial function.
1434 ``stat``
1461 ``stat``
1435 Use a statistical profiler, statprof. This profiler is most
1462 Use a statistical profiler, statprof. This profiler is most
1436 useful for profiling commands that run for longer than about 0.1
1463 useful for profiling commands that run for longer than about 0.1
1437 seconds.
1464 seconds.
1438
1465
1439 ``format``
1466 ``format``
1440 Profiling format. Specific to the ``ls`` instrumenting profiler.
1467 Profiling format. Specific to the ``ls`` instrumenting profiler.
1441 (default: text)
1468 (default: text)
1442
1469
1443 ``text``
1470 ``text``
1444 Generate a profiling report. When saving to a file, it should be
1471 Generate a profiling report. When saving to a file, it should be
1445 noted that only the report is saved, and the profiling data is
1472 noted that only the report is saved, and the profiling data is
1446 not kept.
1473 not kept.
1447 ``kcachegrind``
1474 ``kcachegrind``
1448 Format profiling data for kcachegrind use: when saving to a
1475 Format profiling data for kcachegrind use: when saving to a
1449 file, the generated file can directly be loaded into
1476 file, the generated file can directly be loaded into
1450 kcachegrind.
1477 kcachegrind.
1451
1478
1452 ``statformat``
1479 ``statformat``
1453 Profiling format for the ``stat`` profiler.
1480 Profiling format for the ``stat`` profiler.
1454 (default: hotpath)
1481 (default: hotpath)
1455
1482
1456 ``hotpath``
1483 ``hotpath``
1457 Show a tree-based display containing the hot path of execution (where
1484 Show a tree-based display containing the hot path of execution (where
1458 most time was spent).
1485 most time was spent).
1459 ``bymethod``
1486 ``bymethod``
1460 Show a table of methods ordered by how frequently they are active.
1487 Show a table of methods ordered by how frequently they are active.
1461 ``byline``
1488 ``byline``
1462 Show a table of lines in files ordered by how frequently they are active.
1489 Show a table of lines in files ordered by how frequently they are active.
1463 ``json``
1490 ``json``
1464 Render profiling data as JSON.
1491 Render profiling data as JSON.
1465
1492
1466 ``frequency``
1493 ``frequency``
1467 Sampling frequency. Specific to the ``stat`` sampling profiler.
1494 Sampling frequency. Specific to the ``stat`` sampling profiler.
1468 (default: 1000)
1495 (default: 1000)
1469
1496
1470 ``output``
1497 ``output``
1471 File path where profiling data or report should be saved. If the
1498 File path where profiling data or report should be saved. If the
1472 file exists, it is replaced. (default: None, data is printed on
1499 file exists, it is replaced. (default: None, data is printed on
1473 stderr)
1500 stderr)
1474
1501
1475 ``sort``
1502 ``sort``
1476 Sort field. Specific to the ``ls`` instrumenting profiler.
1503 Sort field. Specific to the ``ls`` instrumenting profiler.
1477 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1504 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1478 ``inlinetime``.
1505 ``inlinetime``.
1479 (default: inlinetime)
1506 (default: inlinetime)
1480
1507
1481 ``limit``
1508 ``limit``
1482 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1509 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1483 (default: 30)
1510 (default: 30)
1484
1511
1485 ``nested``
1512 ``nested``
1486 Show at most this number of lines of drill-down info after each main entry.
1513 Show at most this number of lines of drill-down info after each main entry.
1487 This can help explain the difference between Total and Inline.
1514 This can help explain the difference between Total and Inline.
1488 Specific to the ``ls`` instrumenting profiler.
1515 Specific to the ``ls`` instrumenting profiler.
1489 (default: 5)
1516 (default: 5)
1490
1517
1491 ``progress``
1518 ``progress``
1492 ------------
1519 ------------
1493
1520
1494 Mercurial commands can draw progress bars that are as informative as
1521 Mercurial commands can draw progress bars that are as informative as
1495 possible. Some progress bars only offer indeterminate information, while others
1522 possible. Some progress bars only offer indeterminate information, while others
1496 have a definite end point.
1523 have a definite end point.
1497
1524
1498 ``delay``
1525 ``delay``
1499 Number of seconds (float) before showing the progress bar. (default: 3)
1526 Number of seconds (float) before showing the progress bar. (default: 3)
1500
1527
1501 ``changedelay``
1528 ``changedelay``
1502 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1529 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1503 that value will be used instead. (default: 1)
1530 that value will be used instead. (default: 1)
1504
1531
1505 ``refresh``
1532 ``refresh``
1506 Time in seconds between refreshes of the progress bar. (default: 0.1)
1533 Time in seconds between refreshes of the progress bar. (default: 0.1)
1507
1534
1508 ``format``
1535 ``format``
1509 Format of the progress bar.
1536 Format of the progress bar.
1510
1537
1511 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1538 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1512 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1539 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1513 last 20 characters of the item, but this can be changed by adding either
1540 last 20 characters of the item, but this can be changed by adding either
1514 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1541 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1515 first num characters.
1542 first num characters.
1516
1543
1517 (default: topic bar number estimate)
1544 (default: topic bar number estimate)
1518
1545
1519 ``width``
1546 ``width``
1520 If set, the maximum width of the progress information (that is, min(width,
1547 If set, the maximum width of the progress information (that is, min(width,
1521 term width) will be used).
1548 term width) will be used).
1522
1549
1523 ``clear-complete``
1550 ``clear-complete``
1524 Clear the progress bar after it's done. (default: True)
1551 Clear the progress bar after it's done. (default: True)
1525
1552
1526 ``disable``
1553 ``disable``
1527 If true, don't show a progress bar.
1554 If true, don't show a progress bar.
1528
1555
1529 ``assume-tty``
1556 ``assume-tty``
1530 If true, ALWAYS show a progress bar, unless disable is given.
1557 If true, ALWAYS show a progress bar, unless disable is given.
1531
1558
1532 ``rebase``
1559 ``rebase``
1533 ----------
1560 ----------
1534
1561
1535 ``allowdivergence``
1562 ``allowdivergence``
1536 Default to False, when True allow creating divergence when performing
1563 Default to False, when True allow creating divergence when performing
1537 rebase of obsolete changesets.
1564 rebase of obsolete changesets.
1538
1565
1539 ``revsetalias``
1566 ``revsetalias``
1540 ---------------
1567 ---------------
1541
1568
1542 Alias definitions for revsets. See :hg:`help revsets` for details.
1569 Alias definitions for revsets. See :hg:`help revsets` for details.
1543
1570
1544 ``server``
1571 ``server``
1545 ----------
1572 ----------
1546
1573
1547 Controls generic server settings.
1574 Controls generic server settings.
1548
1575
1549 ``compressionengines``
1576 ``compressionengines``
1550 List of compression engines and their relative priority to advertise
1577 List of compression engines and their relative priority to advertise
1551 to clients.
1578 to clients.
1552
1579
1553 The order of compression engines determines their priority, the first
1580 The order of compression engines determines their priority, the first
1554 having the highest priority. If a compression engine is not listed
1581 having the highest priority. If a compression engine is not listed
1555 here, it won't be advertised to clients.
1582 here, it won't be advertised to clients.
1556
1583
1557 If not set (the default), built-in defaults are used. Run
1584 If not set (the default), built-in defaults are used. Run
1558 :hg:`debuginstall` to list available compression engines and their
1585 :hg:`debuginstall` to list available compression engines and their
1559 default wire protocol priority.
1586 default wire protocol priority.
1560
1587
1561 Older Mercurial clients only support zlib compression and this setting
1588 Older Mercurial clients only support zlib compression and this setting
1562 has no effect for legacy clients.
1589 has no effect for legacy clients.
1563
1590
1564 ``uncompressed``
1591 ``uncompressed``
1565 Whether to allow clients to clone a repository using the
1592 Whether to allow clients to clone a repository using the
1566 uncompressed streaming protocol. This transfers about 40% more
1593 uncompressed streaming protocol. This transfers about 40% more
1567 data than a regular clone, but uses less memory and CPU on both
1594 data than a regular clone, but uses less memory and CPU on both
1568 server and client. Over a LAN (100 Mbps or better) or a very fast
1595 server and client. Over a LAN (100 Mbps or better) or a very fast
1569 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1596 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1570 regular clone. Over most WAN connections (anything slower than
1597 regular clone. Over most WAN connections (anything slower than
1571 about 6 Mbps), uncompressed streaming is slower, because of the
1598 about 6 Mbps), uncompressed streaming is slower, because of the
1572 extra data transfer overhead. This mode will also temporarily hold
1599 extra data transfer overhead. This mode will also temporarily hold
1573 the write lock while determining what data to transfer.
1600 the write lock while determining what data to transfer.
1574 (default: True)
1601 (default: True)
1575
1602
1576 ``preferuncompressed``
1603 ``preferuncompressed``
1577 When set, clients will try to use the uncompressed streaming
1604 When set, clients will try to use the uncompressed streaming
1578 protocol. (default: False)
1605 protocol. (default: False)
1579
1606
1580 ``validate``
1607 ``validate``
1581 Whether to validate the completeness of pushed changesets by
1608 Whether to validate the completeness of pushed changesets by
1582 checking that all new file revisions specified in manifests are
1609 checking that all new file revisions specified in manifests are
1583 present. (default: False)
1610 present. (default: False)
1584
1611
1585 ``maxhttpheaderlen``
1612 ``maxhttpheaderlen``
1586 Instruct HTTP clients not to send request headers longer than this
1613 Instruct HTTP clients not to send request headers longer than this
1587 many bytes. (default: 1024)
1614 many bytes. (default: 1024)
1588
1615
1589 ``bundle1``
1616 ``bundle1``
1590 Whether to allow clients to push and pull using the legacy bundle1
1617 Whether to allow clients to push and pull using the legacy bundle1
1591 exchange format. (default: True)
1618 exchange format. (default: True)
1592
1619
1593 ``bundle1gd``
1620 ``bundle1gd``
1594 Like ``bundle1`` but only used if the repository is using the
1621 Like ``bundle1`` but only used if the repository is using the
1595 *generaldelta* storage format. (default: True)
1622 *generaldelta* storage format. (default: True)
1596
1623
1597 ``bundle1.push``
1624 ``bundle1.push``
1598 Whether to allow clients to push using the legacy bundle1 exchange
1625 Whether to allow clients to push using the legacy bundle1 exchange
1599 format. (default: True)
1626 format. (default: True)
1600
1627
1601 ``bundle1gd.push``
1628 ``bundle1gd.push``
1602 Like ``bundle1.push`` but only used if the repository is using the
1629 Like ``bundle1.push`` but only used if the repository is using the
1603 *generaldelta* storage format. (default: True)
1630 *generaldelta* storage format. (default: True)
1604
1631
1605 ``bundle1.pull``
1632 ``bundle1.pull``
1606 Whether to allow clients to pull using the legacy bundle1 exchange
1633 Whether to allow clients to pull using the legacy bundle1 exchange
1607 format. (default: True)
1634 format. (default: True)
1608
1635
1609 ``bundle1gd.pull``
1636 ``bundle1gd.pull``
1610 Like ``bundle1.pull`` but only used if the repository is using the
1637 Like ``bundle1.pull`` but only used if the repository is using the
1611 *generaldelta* storage format. (default: True)
1638 *generaldelta* storage format. (default: True)
1612
1639
1613 Large repositories using the *generaldelta* storage format should
1640 Large repositories using the *generaldelta* storage format should
1614 consider setting this option because converting *generaldelta*
1641 consider setting this option because converting *generaldelta*
1615 repositories to the exchange format required by the bundle1 data
1642 repositories to the exchange format required by the bundle1 data
1616 format can consume a lot of CPU.
1643 format can consume a lot of CPU.
1617
1644
1618 ``zliblevel``
1645 ``zliblevel``
1619 Integer between ``-1`` and ``9`` that controls the zlib compression level
1646 Integer between ``-1`` and ``9`` that controls the zlib compression level
1620 for wire protocol commands that send zlib compressed output (notably the
1647 for wire protocol commands that send zlib compressed output (notably the
1621 commands that send repository history data).
1648 commands that send repository history data).
1622
1649
1623 The default (``-1``) uses the default zlib compression level, which is
1650 The default (``-1``) uses the default zlib compression level, which is
1624 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1651 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1625 maximum compression.
1652 maximum compression.
1626
1653
1627 Setting this option allows server operators to make trade-offs between
1654 Setting this option allows server operators to make trade-offs between
1628 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1655 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1629 but sends more bytes to clients.
1656 but sends more bytes to clients.
1630
1657
1631 This option only impacts the HTTP server.
1658 This option only impacts the HTTP server.
1632
1659
1633 ``zstdlevel``
1660 ``zstdlevel``
1634 Integer between ``1`` and ``22`` that controls the zstd compression level
1661 Integer between ``1`` and ``22`` that controls the zstd compression level
1635 for wire protocol commands. ``1`` is the minimal amount of compression and
1662 for wire protocol commands. ``1`` is the minimal amount of compression and
1636 ``22`` is the highest amount of compression.
1663 ``22`` is the highest amount of compression.
1637
1664
1638 The default (``3``) should be significantly faster than zlib while likely
1665 The default (``3``) should be significantly faster than zlib while likely
1639 delivering better compression ratios.
1666 delivering better compression ratios.
1640
1667
1641 This option only impacts the HTTP server.
1668 This option only impacts the HTTP server.
1642
1669
1643 See also ``server.zliblevel``.
1670 See also ``server.zliblevel``.
1644
1671
1645 ``smtp``
1672 ``smtp``
1646 --------
1673 --------
1647
1674
1648 Configuration for extensions that need to send email messages.
1675 Configuration for extensions that need to send email messages.
1649
1676
1650 ``host``
1677 ``host``
1651 Host name of mail server, e.g. "mail.example.com".
1678 Host name of mail server, e.g. "mail.example.com".
1652
1679
1653 ``port``
1680 ``port``
1654 Optional. Port to connect to on mail server. (default: 465 if
1681 Optional. Port to connect to on mail server. (default: 465 if
1655 ``tls`` is smtps; 25 otherwise)
1682 ``tls`` is smtps; 25 otherwise)
1656
1683
1657 ``tls``
1684 ``tls``
1658 Optional. Method to enable TLS when connecting to mail server: starttls,
1685 Optional. Method to enable TLS when connecting to mail server: starttls,
1659 smtps or none. (default: none)
1686 smtps or none. (default: none)
1660
1687
1661 ``username``
1688 ``username``
1662 Optional. User name for authenticating with the SMTP server.
1689 Optional. User name for authenticating with the SMTP server.
1663 (default: None)
1690 (default: None)
1664
1691
1665 ``password``
1692 ``password``
1666 Optional. Password for authenticating with the SMTP server. If not
1693 Optional. Password for authenticating with the SMTP server. If not
1667 specified, interactive sessions will prompt the user for a
1694 specified, interactive sessions will prompt the user for a
1668 password; non-interactive sessions will fail. (default: None)
1695 password; non-interactive sessions will fail. (default: None)
1669
1696
1670 ``local_hostname``
1697 ``local_hostname``
1671 Optional. The hostname that the sender can use to identify
1698 Optional. The hostname that the sender can use to identify
1672 itself to the MTA.
1699 itself to the MTA.
1673
1700
1674
1701
1675 ``subpaths``
1702 ``subpaths``
1676 ------------
1703 ------------
1677
1704
1678 Subrepository source URLs can go stale if a remote server changes name
1705 Subrepository source URLs can go stale if a remote server changes name
1679 or becomes temporarily unavailable. This section lets you define
1706 or becomes temporarily unavailable. This section lets you define
1680 rewrite rules of the form::
1707 rewrite rules of the form::
1681
1708
1682 <pattern> = <replacement>
1709 <pattern> = <replacement>
1683
1710
1684 where ``pattern`` is a regular expression matching a subrepository
1711 where ``pattern`` is a regular expression matching a subrepository
1685 source URL and ``replacement`` is the replacement string used to
1712 source URL and ``replacement`` is the replacement string used to
1686 rewrite it. Groups can be matched in ``pattern`` and referenced in
1713 rewrite it. Groups can be matched in ``pattern`` and referenced in
1687 ``replacements``. For instance::
1714 ``replacements``. For instance::
1688
1715
1689 http://server/(.*)-hg/ = http://hg.server/\1/
1716 http://server/(.*)-hg/ = http://hg.server/\1/
1690
1717
1691 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1718 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1692
1719
1693 Relative subrepository paths are first made absolute, and the
1720 Relative subrepository paths are first made absolute, and the
1694 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1721 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1695 doesn't match the full path, an attempt is made to apply it on the
1722 doesn't match the full path, an attempt is made to apply it on the
1696 relative path alone. The rules are applied in definition order.
1723 relative path alone. The rules are applied in definition order.
1697
1724
1698 ``templatealias``
1725 ``templatealias``
1699 -----------------
1726 -----------------
1700
1727
1701 Alias definitions for templates. See :hg:`help templates` for details.
1728 Alias definitions for templates. See :hg:`help templates` for details.
1702
1729
1703 ``templates``
1730 ``templates``
1704 -------------
1731 -------------
1705
1732
1706 Use the ``[templates]`` section to define template strings.
1733 Use the ``[templates]`` section to define template strings.
1707 See :hg:`help templates` for details.
1734 See :hg:`help templates` for details.
1708
1735
1709 ``trusted``
1736 ``trusted``
1710 -----------
1737 -----------
1711
1738
1712 Mercurial will not use the settings in the
1739 Mercurial will not use the settings in the
1713 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1740 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1714 user or to a trusted group, as various hgrc features allow arbitrary
1741 user or to a trusted group, as various hgrc features allow arbitrary
1715 commands to be run. This issue is often encountered when configuring
1742 commands to be run. This issue is often encountered when configuring
1716 hooks or extensions for shared repositories or servers. However,
1743 hooks or extensions for shared repositories or servers. However,
1717 the web interface will use some safe settings from the ``[web]``
1744 the web interface will use some safe settings from the ``[web]``
1718 section.
1745 section.
1719
1746
1720 This section specifies what users and groups are trusted. The
1747 This section specifies what users and groups are trusted. The
1721 current user is always trusted. To trust everybody, list a user or a
1748 current user is always trusted. To trust everybody, list a user or a
1722 group with name ``*``. These settings must be placed in an
1749 group with name ``*``. These settings must be placed in an
1723 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1750 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1724 user or service running Mercurial.
1751 user or service running Mercurial.
1725
1752
1726 ``users``
1753 ``users``
1727 Comma-separated list of trusted users.
1754 Comma-separated list of trusted users.
1728
1755
1729 ``groups``
1756 ``groups``
1730 Comma-separated list of trusted groups.
1757 Comma-separated list of trusted groups.
1731
1758
1732
1759
1733 ``ui``
1760 ``ui``
1734 ------
1761 ------
1735
1762
1736 User interface controls.
1763 User interface controls.
1737
1764
1738 ``archivemeta``
1765 ``archivemeta``
1739 Whether to include the .hg_archival.txt file containing meta data
1766 Whether to include the .hg_archival.txt file containing meta data
1740 (hashes for the repository base and for tip) in archives created
1767 (hashes for the repository base and for tip) in archives created
1741 by the :hg:`archive` command or downloaded via hgweb.
1768 by the :hg:`archive` command or downloaded via hgweb.
1742 (default: True)
1769 (default: True)
1743
1770
1744 ``askusername``
1771 ``askusername``
1745 Whether to prompt for a username when committing. If True, and
1772 Whether to prompt for a username when committing. If True, and
1746 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1773 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1747 be prompted to enter a username. If no username is entered, the
1774 be prompted to enter a username. If no username is entered, the
1748 default ``USER@HOST`` is used instead.
1775 default ``USER@HOST`` is used instead.
1749 (default: False)
1776 (default: False)
1750
1777
1751 ``clonebundles``
1778 ``clonebundles``
1752 Whether the "clone bundles" feature is enabled.
1779 Whether the "clone bundles" feature is enabled.
1753
1780
1754 When enabled, :hg:`clone` may download and apply a server-advertised
1781 When enabled, :hg:`clone` may download and apply a server-advertised
1755 bundle file from a URL instead of using the normal exchange mechanism.
1782 bundle file from a URL instead of using the normal exchange mechanism.
1756
1783
1757 This can likely result in faster and more reliable clones.
1784 This can likely result in faster and more reliable clones.
1758
1785
1759 (default: True)
1786 (default: True)
1760
1787
1761 ``clonebundlefallback``
1788 ``clonebundlefallback``
1762 Whether failure to apply an advertised "clone bundle" from a server
1789 Whether failure to apply an advertised "clone bundle" from a server
1763 should result in fallback to a regular clone.
1790 should result in fallback to a regular clone.
1764
1791
1765 This is disabled by default because servers advertising "clone
1792 This is disabled by default because servers advertising "clone
1766 bundles" often do so to reduce server load. If advertised bundles
1793 bundles" often do so to reduce server load. If advertised bundles
1767 start mass failing and clients automatically fall back to a regular
1794 start mass failing and clients automatically fall back to a regular
1768 clone, this would add significant and unexpected load to the server
1795 clone, this would add significant and unexpected load to the server
1769 since the server is expecting clone operations to be offloaded to
1796 since the server is expecting clone operations to be offloaded to
1770 pre-generated bundles. Failing fast (the default behavior) ensures
1797 pre-generated bundles. Failing fast (the default behavior) ensures
1771 clients don't overwhelm the server when "clone bundle" application
1798 clients don't overwhelm the server when "clone bundle" application
1772 fails.
1799 fails.
1773
1800
1774 (default: False)
1801 (default: False)
1775
1802
1776 ``clonebundleprefers``
1803 ``clonebundleprefers``
1777 Defines preferences for which "clone bundles" to use.
1804 Defines preferences for which "clone bundles" to use.
1778
1805
1779 Servers advertising "clone bundles" may advertise multiple available
1806 Servers advertising "clone bundles" may advertise multiple available
1780 bundles. Each bundle may have different attributes, such as the bundle
1807 bundles. Each bundle may have different attributes, such as the bundle
1781 type and compression format. This option is used to prefer a particular
1808 type and compression format. This option is used to prefer a particular
1782 bundle over another.
1809 bundle over another.
1783
1810
1784 The following keys are defined by Mercurial:
1811 The following keys are defined by Mercurial:
1785
1812
1786 BUNDLESPEC
1813 BUNDLESPEC
1787 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
1814 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
1788 e.g. ``gzip-v2`` or ``bzip2-v1``.
1815 e.g. ``gzip-v2`` or ``bzip2-v1``.
1789
1816
1790 COMPRESSION
1817 COMPRESSION
1791 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
1818 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
1792
1819
1793 Server operators may define custom keys.
1820 Server operators may define custom keys.
1794
1821
1795 Example values: ``COMPRESSION=bzip2``,
1822 Example values: ``COMPRESSION=bzip2``,
1796 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
1823 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
1797
1824
1798 By default, the first bundle advertised by the server is used.
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 ``commitsubrepos``
1834 ``commitsubrepos``
1801 Whether to commit modified subrepositories when committing the
1835 Whether to commit modified subrepositories when committing the
1802 parent repository. If False and one subrepository has uncommitted
1836 parent repository. If False and one subrepository has uncommitted
1803 changes, abort the commit.
1837 changes, abort the commit.
1804 (default: False)
1838 (default: False)
1805
1839
1806 ``debug``
1840 ``debug``
1807 Print debugging information. (default: False)
1841 Print debugging information. (default: False)
1808
1842
1809 ``editor``
1843 ``editor``
1810 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
1844 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
1811
1845
1812 ``fallbackencoding``
1846 ``fallbackencoding``
1813 Encoding to try if it's not possible to decode the changelog using
1847 Encoding to try if it's not possible to decode the changelog using
1814 UTF-8. (default: ISO-8859-1)
1848 UTF-8. (default: ISO-8859-1)
1815
1849
1816 ``graphnodetemplate``
1850 ``graphnodetemplate``
1817 The template used to print changeset nodes in an ASCII revision graph.
1851 The template used to print changeset nodes in an ASCII revision graph.
1818 (default: ``{graphnode}``)
1852 (default: ``{graphnode}``)
1819
1853
1820 ``ignore``
1854 ``ignore``
1821 A file to read per-user ignore patterns from. This file should be
1855 A file to read per-user ignore patterns from. This file should be
1822 in the same format as a repository-wide .hgignore file. Filenames
1856 in the same format as a repository-wide .hgignore file. Filenames
1823 are relative to the repository root. This option supports hook syntax,
1857 are relative to the repository root. This option supports hook syntax,
1824 so if you want to specify multiple ignore files, you can do so by
1858 so if you want to specify multiple ignore files, you can do so by
1825 setting something like ``ignore.other = ~/.hgignore2``. For details
1859 setting something like ``ignore.other = ~/.hgignore2``. For details
1826 of the ignore file format, see the ``hgignore(5)`` man page.
1860 of the ignore file format, see the ``hgignore(5)`` man page.
1827
1861
1828 ``interactive``
1862 ``interactive``
1829 Allow to prompt the user. (default: True)
1863 Allow to prompt the user. (default: True)
1830
1864
1831 ``interface``
1865 ``interface``
1832 Select the default interface for interactive features (default: text).
1866 Select the default interface for interactive features (default: text).
1833 Possible values are 'text' and 'curses'.
1867 Possible values are 'text' and 'curses'.
1834
1868
1835 ``interface.chunkselector``
1869 ``interface.chunkselector``
1836 Select the interface for change recording (e.g. :hg:`commit -i`).
1870 Select the interface for change recording (e.g. :hg:`commit -i`).
1837 Possible values are 'text' and 'curses'.
1871 Possible values are 'text' and 'curses'.
1838 This config overrides the interface specified by ui.interface.
1872 This config overrides the interface specified by ui.interface.
1839
1873
1840 ``logtemplate``
1874 ``logtemplate``
1841 Template string for commands that print changesets.
1875 Template string for commands that print changesets.
1842
1876
1843 ``merge``
1877 ``merge``
1844 The conflict resolution program to use during a manual merge.
1878 The conflict resolution program to use during a manual merge.
1845 For more information on merge tools see :hg:`help merge-tools`.
1879 For more information on merge tools see :hg:`help merge-tools`.
1846 For configuring merge tools see the ``[merge-tools]`` section.
1880 For configuring merge tools see the ``[merge-tools]`` section.
1847
1881
1848 ``mergemarkers``
1882 ``mergemarkers``
1849 Sets the merge conflict marker label styling. The ``detailed``
1883 Sets the merge conflict marker label styling. The ``detailed``
1850 style uses the ``mergemarkertemplate`` setting to style the labels.
1884 style uses the ``mergemarkertemplate`` setting to style the labels.
1851 The ``basic`` style just uses 'local' and 'other' as the marker label.
1885 The ``basic`` style just uses 'local' and 'other' as the marker label.
1852 One of ``basic`` or ``detailed``.
1886 One of ``basic`` or ``detailed``.
1853 (default: ``basic``)
1887 (default: ``basic``)
1854
1888
1855 ``mergemarkertemplate``
1889 ``mergemarkertemplate``
1856 The template used to print the commit description next to each conflict
1890 The template used to print the commit description next to each conflict
1857 marker during merge conflicts. See :hg:`help templates` for the template
1891 marker during merge conflicts. See :hg:`help templates` for the template
1858 format.
1892 format.
1859
1893
1860 Defaults to showing the hash, tags, branches, bookmarks, author, and
1894 Defaults to showing the hash, tags, branches, bookmarks, author, and
1861 the first line of the commit description.
1895 the first line of the commit description.
1862
1896
1863 If you use non-ASCII characters in names for tags, branches, bookmarks,
1897 If you use non-ASCII characters in names for tags, branches, bookmarks,
1864 authors, and/or commit descriptions, you must pay attention to encodings of
1898 authors, and/or commit descriptions, you must pay attention to encodings of
1865 managed files. At template expansion, non-ASCII characters use the encoding
1899 managed files. At template expansion, non-ASCII characters use the encoding
1866 specified by the ``--encoding`` global option, ``HGENCODING`` or other
1900 specified by the ``--encoding`` global option, ``HGENCODING`` or other
1867 environment variables that govern your locale. If the encoding of the merge
1901 environment variables that govern your locale. If the encoding of the merge
1868 markers is different from the encoding of the merged files,
1902 markers is different from the encoding of the merged files,
1869 serious problems may occur.
1903 serious problems may occur.
1870
1904
1871 ``origbackuppath``
1905 ``origbackuppath``
1872 The path to a directory used to store generated .orig files. If the path is
1906 The path to a directory used to store generated .orig files. If the path is
1873 not a directory, one will be created.
1907 not a directory, one will be created.
1874
1908
1875 ``patch``
1909 ``patch``
1876 An optional external tool that ``hg import`` and some extensions
1910 An optional external tool that ``hg import`` and some extensions
1877 will use for applying patches. By default Mercurial uses an
1911 will use for applying patches. By default Mercurial uses an
1878 internal patch utility. The external tool must work as the common
1912 internal patch utility. The external tool must work as the common
1879 Unix ``patch`` program. In particular, it must accept a ``-p``
1913 Unix ``patch`` program. In particular, it must accept a ``-p``
1880 argument to strip patch headers, a ``-d`` argument to specify the
1914 argument to strip patch headers, a ``-d`` argument to specify the
1881 current directory, a file name to patch, and a patch file to take
1915 current directory, a file name to patch, and a patch file to take
1882 from stdin.
1916 from stdin.
1883
1917
1884 It is possible to specify a patch tool together with extra
1918 It is possible to specify a patch tool together with extra
1885 arguments. For example, setting this option to ``patch --merge``
1919 arguments. For example, setting this option to ``patch --merge``
1886 will use the ``patch`` program with its 2-way merge option.
1920 will use the ``patch`` program with its 2-way merge option.
1887
1921
1888 ``portablefilenames``
1922 ``portablefilenames``
1889 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1923 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1890 (default: ``warn``)
1924 (default: ``warn``)
1891
1925
1892 ``warn``
1926 ``warn``
1893 Print a warning message on POSIX platforms, if a file with a non-portable
1927 Print a warning message on POSIX platforms, if a file with a non-portable
1894 filename is added (e.g. a file with a name that can't be created on
1928 filename is added (e.g. a file with a name that can't be created on
1895 Windows because it contains reserved parts like ``AUX``, reserved
1929 Windows because it contains reserved parts like ``AUX``, reserved
1896 characters like ``:``, or would cause a case collision with an existing
1930 characters like ``:``, or would cause a case collision with an existing
1897 file).
1931 file).
1898
1932
1899 ``ignore``
1933 ``ignore``
1900 Don't print a warning.
1934 Don't print a warning.
1901
1935
1902 ``abort``
1936 ``abort``
1903 The command is aborted.
1937 The command is aborted.
1904
1938
1905 ``true``
1939 ``true``
1906 Alias for ``warn``.
1940 Alias for ``warn``.
1907
1941
1908 ``false``
1942 ``false``
1909 Alias for ``ignore``.
1943 Alias for ``ignore``.
1910
1944
1911 .. container:: windows
1945 .. container:: windows
1912
1946
1913 On Windows, this configuration option is ignored and the command aborted.
1947 On Windows, this configuration option is ignored and the command aborted.
1914
1948
1915 ``quiet``
1949 ``quiet``
1916 Reduce the amount of output printed.
1950 Reduce the amount of output printed.
1917 (default: False)
1951 (default: False)
1918
1952
1919 ``remotecmd``
1953 ``remotecmd``
1920 Remote command to use for clone/push/pull operations.
1954 Remote command to use for clone/push/pull operations.
1921 (default: ``hg``)
1955 (default: ``hg``)
1922
1956
1923 ``report_untrusted``
1957 ``report_untrusted``
1924 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1958 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1925 trusted user or group.
1959 trusted user or group.
1926 (default: True)
1960 (default: True)
1927
1961
1928 ``slash``
1962 ``slash``
1929 Display paths using a slash (``/``) as the path separator. This
1963 Display paths using a slash (``/``) as the path separator. This
1930 only makes a difference on systems where the default path
1964 only makes a difference on systems where the default path
1931 separator is not the slash character (e.g. Windows uses the
1965 separator is not the slash character (e.g. Windows uses the
1932 backslash character (``\``)).
1966 backslash character (``\``)).
1933 (default: False)
1967 (default: False)
1934
1968
1935 ``statuscopies``
1969 ``statuscopies``
1936 Display copies in the status command.
1970 Display copies in the status command.
1937
1971
1938 ``ssh``
1972 ``ssh``
1939 Command to use for SSH connections. (default: ``ssh``)
1973 Command to use for SSH connections. (default: ``ssh``)
1940
1974
1941 ``strict``
1975 ``strict``
1942 Require exact command names, instead of allowing unambiguous
1976 Require exact command names, instead of allowing unambiguous
1943 abbreviations. (default: False)
1977 abbreviations. (default: False)
1944
1978
1945 ``style``
1979 ``style``
1946 Name of style to use for command output.
1980 Name of style to use for command output.
1947
1981
1948 ``supportcontact``
1982 ``supportcontact``
1949 A URL where users should report a Mercurial traceback. Use this if you are a
1983 A URL where users should report a Mercurial traceback. Use this if you are a
1950 large organisation with its own Mercurial deployment process and crash
1984 large organisation with its own Mercurial deployment process and crash
1951 reports should be addressed to your internal support.
1985 reports should be addressed to your internal support.
1952
1986
1953 ``textwidth``
1987 ``textwidth``
1954 Maximum width of help text. A longer line generated by ``hg help`` or
1988 Maximum width of help text. A longer line generated by ``hg help`` or
1955 ``hg subcommand --help`` will be broken after white space to get this
1989 ``hg subcommand --help`` will be broken after white space to get this
1956 width or the terminal width, whichever comes first.
1990 width or the terminal width, whichever comes first.
1957 A non-positive value will disable this and the terminal width will be
1991 A non-positive value will disable this and the terminal width will be
1958 used. (default: 78)
1992 used. (default: 78)
1959
1993
1960 ``timeout``
1994 ``timeout``
1961 The timeout used when a lock is held (in seconds), a negative value
1995 The timeout used when a lock is held (in seconds), a negative value
1962 means no timeout. (default: 600)
1996 means no timeout. (default: 600)
1963
1997
1964 ``traceback``
1998 ``traceback``
1965 Mercurial always prints a traceback when an unknown exception
1999 Mercurial always prints a traceback when an unknown exception
1966 occurs. Setting this to True will make Mercurial print a traceback
2000 occurs. Setting this to True will make Mercurial print a traceback
1967 on all exceptions, even those recognized by Mercurial (such as
2001 on all exceptions, even those recognized by Mercurial (such as
1968 IOError or MemoryError). (default: False)
2002 IOError or MemoryError). (default: False)
1969
2003
1970 ``username``
2004 ``username``
1971 The committer of a changeset created when running "commit".
2005 The committer of a changeset created when running "commit".
1972 Typically a person's name and email address, e.g. ``Fred Widget
2006 Typically a person's name and email address, e.g. ``Fred Widget
1973 <fred@example.com>``. Environment variables in the
2007 <fred@example.com>``. Environment variables in the
1974 username are expanded.
2008 username are expanded.
1975
2009
1976 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2010 (default: ``$EMAIL`` or ``username@hostname``. If the username in
1977 hgrc is empty, e.g. if the system admin set ``username =`` in the
2011 hgrc is empty, e.g. if the system admin set ``username =`` in the
1978 system hgrc, it has to be specified manually or in a different
2012 system hgrc, it has to be specified manually or in a different
1979 hgrc file)
2013 hgrc file)
1980
2014
1981 ``verbose``
2015 ``verbose``
1982 Increase the amount of output printed. (default: False)
2016 Increase the amount of output printed. (default: False)
1983
2017
1984
2018
1985 ``web``
2019 ``web``
1986 -------
2020 -------
1987
2021
1988 Web interface configuration. The settings in this section apply to
2022 Web interface configuration. The settings in this section apply to
1989 both the builtin webserver (started by :hg:`serve`) and the script you
2023 both the builtin webserver (started by :hg:`serve`) and the script you
1990 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2024 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1991 and WSGI).
2025 and WSGI).
1992
2026
1993 The Mercurial webserver does no authentication (it does not prompt for
2027 The Mercurial webserver does no authentication (it does not prompt for
1994 usernames and passwords to validate *who* users are), but it does do
2028 usernames and passwords to validate *who* users are), but it does do
1995 authorization (it grants or denies access for *authenticated users*
2029 authorization (it grants or denies access for *authenticated users*
1996 based on settings in this section). You must either configure your
2030 based on settings in this section). You must either configure your
1997 webserver to do authentication for you, or disable the authorization
2031 webserver to do authentication for you, or disable the authorization
1998 checks.
2032 checks.
1999
2033
2000 For a quick setup in a trusted environment, e.g., a private LAN, where
2034 For a quick setup in a trusted environment, e.g., a private LAN, where
2001 you want it to accept pushes from anybody, you can use the following
2035 you want it to accept pushes from anybody, you can use the following
2002 command line::
2036 command line::
2003
2037
2004 $ hg --config web.allow_push=* --config web.push_ssl=False serve
2038 $ hg --config web.allow_push=* --config web.push_ssl=False serve
2005
2039
2006 Note that this will allow anybody to push anything to the server and
2040 Note that this will allow anybody to push anything to the server and
2007 that this should not be used for public servers.
2041 that this should not be used for public servers.
2008
2042
2009 The full set of options is:
2043 The full set of options is:
2010
2044
2011 ``accesslog``
2045 ``accesslog``
2012 Where to output the access log. (default: stdout)
2046 Where to output the access log. (default: stdout)
2013
2047
2014 ``address``
2048 ``address``
2015 Interface address to bind to. (default: all)
2049 Interface address to bind to. (default: all)
2016
2050
2017 ``allow_archive``
2051 ``allow_archive``
2018 List of archive format (bz2, gz, zip) allowed for downloading.
2052 List of archive format (bz2, gz, zip) allowed for downloading.
2019 (default: empty)
2053 (default: empty)
2020
2054
2021 ``allowbz2``
2055 ``allowbz2``
2022 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2056 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2023 revisions.
2057 revisions.
2024 (default: False)
2058 (default: False)
2025
2059
2026 ``allowgz``
2060 ``allowgz``
2027 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2061 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2028 revisions.
2062 revisions.
2029 (default: False)
2063 (default: False)
2030
2064
2031 ``allowpull``
2065 ``allowpull``
2032 Whether to allow pulling from the repository. (default: True)
2066 Whether to allow pulling from the repository. (default: True)
2033
2067
2034 ``allow_push``
2068 ``allow_push``
2035 Whether to allow pushing to the repository. If empty or not set,
2069 Whether to allow pushing to the repository. If empty or not set,
2036 pushing is not allowed. If the special value ``*``, any remote
2070 pushing is not allowed. If the special value ``*``, any remote
2037 user can push, including unauthenticated users. Otherwise, the
2071 user can push, including unauthenticated users. Otherwise, the
2038 remote user must have been authenticated, and the authenticated
2072 remote user must have been authenticated, and the authenticated
2039 user name must be present in this list. The contents of the
2073 user name must be present in this list. The contents of the
2040 allow_push list are examined after the deny_push list.
2074 allow_push list are examined after the deny_push list.
2041
2075
2042 ``allow_read``
2076 ``allow_read``
2043 If the user has not already been denied repository access due to
2077 If the user has not already been denied repository access due to
2044 the contents of deny_read, this list determines whether to grant
2078 the contents of deny_read, this list determines whether to grant
2045 repository access to the user. If this list is not empty, and the
2079 repository access to the user. If this list is not empty, and the
2046 user is unauthenticated or not present in the list, then access is
2080 user is unauthenticated or not present in the list, then access is
2047 denied for the user. If the list is empty or not set, then access
2081 denied for the user. If the list is empty or not set, then access
2048 is permitted to all users by default. Setting allow_read to the
2082 is permitted to all users by default. Setting allow_read to the
2049 special value ``*`` is equivalent to it not being set (i.e. access
2083 special value ``*`` is equivalent to it not being set (i.e. access
2050 is permitted to all users). The contents of the allow_read list are
2084 is permitted to all users). The contents of the allow_read list are
2051 examined after the deny_read list.
2085 examined after the deny_read list.
2052
2086
2053 ``allowzip``
2087 ``allowzip``
2054 (DEPRECATED) Whether to allow .zip downloading of repository
2088 (DEPRECATED) Whether to allow .zip downloading of repository
2055 revisions. This feature creates temporary files.
2089 revisions. This feature creates temporary files.
2056 (default: False)
2090 (default: False)
2057
2091
2058 ``archivesubrepos``
2092 ``archivesubrepos``
2059 Whether to recurse into subrepositories when archiving.
2093 Whether to recurse into subrepositories when archiving.
2060 (default: False)
2094 (default: False)
2061
2095
2062 ``baseurl``
2096 ``baseurl``
2063 Base URL to use when publishing URLs in other locations, so
2097 Base URL to use when publishing URLs in other locations, so
2064 third-party tools like email notification hooks can construct
2098 third-party tools like email notification hooks can construct
2065 URLs. Example: ``http://hgserver/repos/``.
2099 URLs. Example: ``http://hgserver/repos/``.
2066
2100
2067 ``cacerts``
2101 ``cacerts``
2068 Path to file containing a list of PEM encoded certificate
2102 Path to file containing a list of PEM encoded certificate
2069 authority certificates. Environment variables and ``~user``
2103 authority certificates. Environment variables and ``~user``
2070 constructs are expanded in the filename. If specified on the
2104 constructs are expanded in the filename. If specified on the
2071 client, then it will verify the identity of remote HTTPS servers
2105 client, then it will verify the identity of remote HTTPS servers
2072 with these certificates.
2106 with these certificates.
2073
2107
2074 To disable SSL verification temporarily, specify ``--insecure`` from
2108 To disable SSL verification temporarily, specify ``--insecure`` from
2075 command line.
2109 command line.
2076
2110
2077 You can use OpenSSL's CA certificate file if your platform has
2111 You can use OpenSSL's CA certificate file if your platform has
2078 one. On most Linux systems this will be
2112 one. On most Linux systems this will be
2079 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2113 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2080 generate this file manually. The form must be as follows::
2114 generate this file manually. The form must be as follows::
2081
2115
2082 -----BEGIN CERTIFICATE-----
2116 -----BEGIN CERTIFICATE-----
2083 ... (certificate in base64 PEM encoding) ...
2117 ... (certificate in base64 PEM encoding) ...
2084 -----END CERTIFICATE-----
2118 -----END CERTIFICATE-----
2085 -----BEGIN CERTIFICATE-----
2119 -----BEGIN CERTIFICATE-----
2086 ... (certificate in base64 PEM encoding) ...
2120 ... (certificate in base64 PEM encoding) ...
2087 -----END CERTIFICATE-----
2121 -----END CERTIFICATE-----
2088
2122
2089 ``cache``
2123 ``cache``
2090 Whether to support caching in hgweb. (default: True)
2124 Whether to support caching in hgweb. (default: True)
2091
2125
2092 ``certificate``
2126 ``certificate``
2093 Certificate to use when running :hg:`serve`.
2127 Certificate to use when running :hg:`serve`.
2094
2128
2095 ``collapse``
2129 ``collapse``
2096 With ``descend`` enabled, repositories in subdirectories are shown at
2130 With ``descend`` enabled, repositories in subdirectories are shown at
2097 a single level alongside repositories in the current path. With
2131 a single level alongside repositories in the current path. With
2098 ``collapse`` also enabled, repositories residing at a deeper level than
2132 ``collapse`` also enabled, repositories residing at a deeper level than
2099 the current path are grouped behind navigable directory entries that
2133 the current path are grouped behind navigable directory entries that
2100 lead to the locations of these repositories. In effect, this setting
2134 lead to the locations of these repositories. In effect, this setting
2101 collapses each collection of repositories found within a subdirectory
2135 collapses each collection of repositories found within a subdirectory
2102 into a single entry for that subdirectory. (default: False)
2136 into a single entry for that subdirectory. (default: False)
2103
2137
2104 ``comparisoncontext``
2138 ``comparisoncontext``
2105 Number of lines of context to show in side-by-side file comparison. If
2139 Number of lines of context to show in side-by-side file comparison. If
2106 negative or the value ``full``, whole files are shown. (default: 5)
2140 negative or the value ``full``, whole files are shown. (default: 5)
2107
2141
2108 This setting can be overridden by a ``context`` request parameter to the
2142 This setting can be overridden by a ``context`` request parameter to the
2109 ``comparison`` command, taking the same values.
2143 ``comparison`` command, taking the same values.
2110
2144
2111 ``contact``
2145 ``contact``
2112 Name or email address of the person in charge of the repository.
2146 Name or email address of the person in charge of the repository.
2113 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2147 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2114
2148
2115 ``csp``
2149 ``csp``
2116 Send a ``Content-Security-Policy`` HTTP header with this value.
2150 Send a ``Content-Security-Policy`` HTTP header with this value.
2117
2151
2118 The value may contain a special string ``%nonce%``, which will be replaced
2152 The value may contain a special string ``%nonce%``, which will be replaced
2119 by a randomly-generated one-time use value. If the value contains
2153 by a randomly-generated one-time use value. If the value contains
2120 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2154 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2121 one-time property of the nonce. This nonce will also be inserted into
2155 one-time property of the nonce. This nonce will also be inserted into
2122 ``<script>`` elements containing inline JavaScript.
2156 ``<script>`` elements containing inline JavaScript.
2123
2157
2124 Note: lots of HTML content sent by the server is derived from repository
2158 Note: lots of HTML content sent by the server is derived from repository
2125 data. Please consider the potential for malicious repository data to
2159 data. Please consider the potential for malicious repository data to
2126 "inject" itself into generated HTML content as part of your security
2160 "inject" itself into generated HTML content as part of your security
2127 threat model.
2161 threat model.
2128
2162
2129 ``deny_push``
2163 ``deny_push``
2130 Whether to deny pushing to the repository. If empty or not set,
2164 Whether to deny pushing to the repository. If empty or not set,
2131 push is not denied. If the special value ``*``, all remote users are
2165 push is not denied. If the special value ``*``, all remote users are
2132 denied push. Otherwise, unauthenticated users are all denied, and
2166 denied push. Otherwise, unauthenticated users are all denied, and
2133 any authenticated user name present in this list is also denied. The
2167 any authenticated user name present in this list is also denied. The
2134 contents of the deny_push list are examined before the allow_push list.
2168 contents of the deny_push list are examined before the allow_push list.
2135
2169
2136 ``deny_read``
2170 ``deny_read``
2137 Whether to deny reading/viewing of the repository. If this list is
2171 Whether to deny reading/viewing of the repository. If this list is
2138 not empty, unauthenticated users are all denied, and any
2172 not empty, unauthenticated users are all denied, and any
2139 authenticated user name present in this list is also denied access to
2173 authenticated user name present in this list is also denied access to
2140 the repository. If set to the special value ``*``, all remote users
2174 the repository. If set to the special value ``*``, all remote users
2141 are denied access (rarely needed ;). If deny_read is empty or not set,
2175 are denied access (rarely needed ;). If deny_read is empty or not set,
2142 the determination of repository access depends on the presence and
2176 the determination of repository access depends on the presence and
2143 content of the allow_read list (see description). If both
2177 content of the allow_read list (see description). If both
2144 deny_read and allow_read are empty or not set, then access is
2178 deny_read and allow_read are empty or not set, then access is
2145 permitted to all users by default. If the repository is being
2179 permitted to all users by default. If the repository is being
2146 served via hgwebdir, denied users will not be able to see it in
2180 served via hgwebdir, denied users will not be able to see it in
2147 the list of repositories. The contents of the deny_read list have
2181 the list of repositories. The contents of the deny_read list have
2148 priority over (are examined before) the contents of the allow_read
2182 priority over (are examined before) the contents of the allow_read
2149 list.
2183 list.
2150
2184
2151 ``descend``
2185 ``descend``
2152 hgwebdir indexes will not descend into subdirectories. Only repositories
2186 hgwebdir indexes will not descend into subdirectories. Only repositories
2153 directly in the current path will be shown (other repositories are still
2187 directly in the current path will be shown (other repositories are still
2154 available from the index corresponding to their containing path).
2188 available from the index corresponding to their containing path).
2155
2189
2156 ``description``
2190 ``description``
2157 Textual description of the repository's purpose or contents.
2191 Textual description of the repository's purpose or contents.
2158 (default: "unknown")
2192 (default: "unknown")
2159
2193
2160 ``encoding``
2194 ``encoding``
2161 Character encoding name. (default: the current locale charset)
2195 Character encoding name. (default: the current locale charset)
2162 Example: "UTF-8".
2196 Example: "UTF-8".
2163
2197
2164 ``errorlog``
2198 ``errorlog``
2165 Where to output the error log. (default: stderr)
2199 Where to output the error log. (default: stderr)
2166
2200
2167 ``guessmime``
2201 ``guessmime``
2168 Control MIME types for raw download of file content.
2202 Control MIME types for raw download of file content.
2169 Set to True to let hgweb guess the content type from the file
2203 Set to True to let hgweb guess the content type from the file
2170 extension. This will serve HTML files as ``text/html`` and might
2204 extension. This will serve HTML files as ``text/html`` and might
2171 allow cross-site scripting attacks when serving untrusted
2205 allow cross-site scripting attacks when serving untrusted
2172 repositories. (default: False)
2206 repositories. (default: False)
2173
2207
2174 ``hidden``
2208 ``hidden``
2175 Whether to hide the repository in the hgwebdir index.
2209 Whether to hide the repository in the hgwebdir index.
2176 (default: False)
2210 (default: False)
2177
2211
2178 ``ipv6``
2212 ``ipv6``
2179 Whether to use IPv6. (default: False)
2213 Whether to use IPv6. (default: False)
2180
2214
2181 ``labels``
2215 ``labels``
2182 List of string *labels* associated with the repository.
2216 List of string *labels* associated with the repository.
2183
2217
2184 Labels are exposed as a template keyword and can be used to customize
2218 Labels are exposed as a template keyword and can be used to customize
2185 output. e.g. the ``index`` template can group or filter repositories
2219 output. e.g. the ``index`` template can group or filter repositories
2186 by labels and the ``summary`` template can display additional content
2220 by labels and the ``summary`` template can display additional content
2187 if a specific label is present.
2221 if a specific label is present.
2188
2222
2189 ``logoimg``
2223 ``logoimg``
2190 File name of the logo image that some templates display on each page.
2224 File name of the logo image that some templates display on each page.
2191 The file name is relative to ``staticurl``. That is, the full path to
2225 The file name is relative to ``staticurl``. That is, the full path to
2192 the logo image is "staticurl/logoimg".
2226 the logo image is "staticurl/logoimg".
2193 If unset, ``hglogo.png`` will be used.
2227 If unset, ``hglogo.png`` will be used.
2194
2228
2195 ``logourl``
2229 ``logourl``
2196 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2230 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2197 will be used.
2231 will be used.
2198
2232
2199 ``maxchanges``
2233 ``maxchanges``
2200 Maximum number of changes to list on the changelog. (default: 10)
2234 Maximum number of changes to list on the changelog. (default: 10)
2201
2235
2202 ``maxfiles``
2236 ``maxfiles``
2203 Maximum number of files to list per changeset. (default: 10)
2237 Maximum number of files to list per changeset. (default: 10)
2204
2238
2205 ``maxshortchanges``
2239 ``maxshortchanges``
2206 Maximum number of changes to list on the shortlog, graph or filelog
2240 Maximum number of changes to list on the shortlog, graph or filelog
2207 pages. (default: 60)
2241 pages. (default: 60)
2208
2242
2209 ``name``
2243 ``name``
2210 Repository name to use in the web interface.
2244 Repository name to use in the web interface.
2211 (default: current working directory)
2245 (default: current working directory)
2212
2246
2213 ``port``
2247 ``port``
2214 Port to listen on. (default: 8000)
2248 Port to listen on. (default: 8000)
2215
2249
2216 ``prefix``
2250 ``prefix``
2217 Prefix path to serve from. (default: '' (server root))
2251 Prefix path to serve from. (default: '' (server root))
2218
2252
2219 ``push_ssl``
2253 ``push_ssl``
2220 Whether to require that inbound pushes be transported over SSL to
2254 Whether to require that inbound pushes be transported over SSL to
2221 prevent password sniffing. (default: True)
2255 prevent password sniffing. (default: True)
2222
2256
2223 ``refreshinterval``
2257 ``refreshinterval``
2224 How frequently directory listings re-scan the filesystem for new
2258 How frequently directory listings re-scan the filesystem for new
2225 repositories, in seconds. This is relevant when wildcards are used
2259 repositories, in seconds. This is relevant when wildcards are used
2226 to define paths. Depending on how much filesystem traversal is
2260 to define paths. Depending on how much filesystem traversal is
2227 required, refreshing may negatively impact performance.
2261 required, refreshing may negatively impact performance.
2228
2262
2229 Values less than or equal to 0 always refresh.
2263 Values less than or equal to 0 always refresh.
2230 (default: 20)
2264 (default: 20)
2231
2265
2232 ``staticurl``
2266 ``staticurl``
2233 Base URL to use for static files. If unset, static files (e.g. the
2267 Base URL to use for static files. If unset, static files (e.g. the
2234 hgicon.png favicon) will be served by the CGI script itself. Use
2268 hgicon.png favicon) will be served by the CGI script itself. Use
2235 this setting to serve them directly with the HTTP server.
2269 this setting to serve them directly with the HTTP server.
2236 Example: ``http://hgserver/static/``.
2270 Example: ``http://hgserver/static/``.
2237
2271
2238 ``stripes``
2272 ``stripes``
2239 How many lines a "zebra stripe" should span in multi-line output.
2273 How many lines a "zebra stripe" should span in multi-line output.
2240 Set to 0 to disable. (default: 1)
2274 Set to 0 to disable. (default: 1)
2241
2275
2242 ``style``
2276 ``style``
2243 Which template map style to use. The available options are the names of
2277 Which template map style to use. The available options are the names of
2244 subdirectories in the HTML templates path. (default: ``paper``)
2278 subdirectories in the HTML templates path. (default: ``paper``)
2245 Example: ``monoblue``.
2279 Example: ``monoblue``.
2246
2280
2247 ``templates``
2281 ``templates``
2248 Where to find the HTML templates. The default path to the HTML templates
2282 Where to find the HTML templates. The default path to the HTML templates
2249 can be obtained from ``hg debuginstall``.
2283 can be obtained from ``hg debuginstall``.
2250
2284
2251 ``websub``
2285 ``websub``
2252 ----------
2286 ----------
2253
2287
2254 Web substitution filter definition. You can use this section to
2288 Web substitution filter definition. You can use this section to
2255 define a set of regular expression substitution patterns which
2289 define a set of regular expression substitution patterns which
2256 let you automatically modify the hgweb server output.
2290 let you automatically modify the hgweb server output.
2257
2291
2258 The default hgweb templates only apply these substitution patterns
2292 The default hgweb templates only apply these substitution patterns
2259 on the revision description fields. You can apply them anywhere
2293 on the revision description fields. You can apply them anywhere
2260 you want when you create your own templates by adding calls to the
2294 you want when you create your own templates by adding calls to the
2261 "websub" filter (usually after calling the "escape" filter).
2295 "websub" filter (usually after calling the "escape" filter).
2262
2296
2263 This can be used, for example, to convert issue references to links
2297 This can be used, for example, to convert issue references to links
2264 to your issue tracker, or to convert "markdown-like" syntax into
2298 to your issue tracker, or to convert "markdown-like" syntax into
2265 HTML (see the examples below).
2299 HTML (see the examples below).
2266
2300
2267 Each entry in this section names a substitution filter.
2301 Each entry in this section names a substitution filter.
2268 The value of each entry defines the substitution expression itself.
2302 The value of each entry defines the substitution expression itself.
2269 The websub expressions follow the old interhg extension syntax,
2303 The websub expressions follow the old interhg extension syntax,
2270 which in turn imitates the Unix sed replacement syntax::
2304 which in turn imitates the Unix sed replacement syntax::
2271
2305
2272 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2306 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2273
2307
2274 You can use any separator other than "/". The final "i" is optional
2308 You can use any separator other than "/". The final "i" is optional
2275 and indicates that the search must be case insensitive.
2309 and indicates that the search must be case insensitive.
2276
2310
2277 Examples::
2311 Examples::
2278
2312
2279 [websub]
2313 [websub]
2280 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2314 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2281 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2315 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2282 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2316 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2283
2317
2284 ``worker``
2318 ``worker``
2285 ----------
2319 ----------
2286
2320
2287 Parallel master/worker configuration. We currently perform working
2321 Parallel master/worker configuration. We currently perform working
2288 directory updates in parallel on Unix-like systems, which greatly
2322 directory updates in parallel on Unix-like systems, which greatly
2289 helps performance.
2323 helps performance.
2290
2324
2291 ``numcpus``
2325 ``numcpus``
2292 Number of CPUs to use for parallel operations. A zero or
2326 Number of CPUs to use for parallel operations. A zero or
2293 negative value is treated as ``use the default``.
2327 negative value is treated as ``use the default``.
2294 (default: 4 or the number of CPUs on the system, whichever is larger)
2328 (default: 4 or the number of CPUs on the system, whichever is larger)
2295
2329
2296 ``backgroundclose``
2330 ``backgroundclose``
2297 Whether to enable closing file handles on background threads during certain
2331 Whether to enable closing file handles on background threads during certain
2298 operations. Some platforms aren't very efficient at closing file
2332 operations. Some platforms aren't very efficient at closing file
2299 handles that have been written or appended to. By performing file closing
2333 handles that have been written or appended to. By performing file closing
2300 on background threads, file write rate can increase substantially.
2334 on background threads, file write rate can increase substantially.
2301 (default: true on Windows, false elsewhere)
2335 (default: true on Windows, false elsewhere)
2302
2336
2303 ``backgroundcloseminfilecount``
2337 ``backgroundcloseminfilecount``
2304 Minimum number of files required to trigger background file closing.
2338 Minimum number of files required to trigger background file closing.
2305 Operations not writing this many files won't start background close
2339 Operations not writing this many files won't start background close
2306 threads.
2340 threads.
2307 (default: 2048)
2341 (default: 2048)
2308
2342
2309 ``backgroundclosemaxqueue``
2343 ``backgroundclosemaxqueue``
2310 The maximum number of opened file handles waiting to be closed in the
2344 The maximum number of opened file handles waiting to be closed in the
2311 background. This option only has an effect if ``backgroundclose`` is
2345 background. This option only has an effect if ``backgroundclose`` is
2312 enabled.
2346 enabled.
2313 (default: 384)
2347 (default: 384)
2314
2348
2315 ``backgroundclosethreadcount``
2349 ``backgroundclosethreadcount``
2316 Number of threads to process background file closes. Only relevant if
2350 Number of threads to process background file closes. Only relevant if
2317 ``backgroundclose`` is enabled.
2351 ``backgroundclose`` is enabled.
2318 (default: 4)
2352 (default: 4)
@@ -1,1551 +1,1551 b''
1 Test basic extension support
1 Test basic extension support
2
2
3 $ cat > foobar.py <<EOF
3 $ cat > foobar.py <<EOF
4 > import os
4 > import os
5 > from mercurial import cmdutil, commands
5 > from mercurial import cmdutil, commands
6 > cmdtable = {}
6 > cmdtable = {}
7 > command = cmdutil.command(cmdtable)
7 > command = cmdutil.command(cmdtable)
8 > def uisetup(ui):
8 > def uisetup(ui):
9 > ui.write("uisetup called\\n")
9 > ui.write("uisetup called\\n")
10 > ui.flush()
10 > ui.flush()
11 > def reposetup(ui, repo):
11 > def reposetup(ui, repo):
12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
14 > ui.flush()
14 > ui.flush()
15 > @command('foo', [], 'hg foo')
15 > @command('foo', [], 'hg foo')
16 > def foo(ui, *args, **kwargs):
16 > def foo(ui, *args, **kwargs):
17 > ui.write("Foo\\n")
17 > ui.write("Foo\\n")
18 > @command('bar', [], 'hg bar', norepo=True)
18 > @command('bar', [], 'hg bar', norepo=True)
19 > def bar(ui, *args, **kwargs):
19 > def bar(ui, *args, **kwargs):
20 > ui.write("Bar\\n")
20 > ui.write("Bar\\n")
21 > EOF
21 > EOF
22 $ abspath=`pwd`/foobar.py
22 $ abspath=`pwd`/foobar.py
23
23
24 $ mkdir barfoo
24 $ mkdir barfoo
25 $ cp foobar.py barfoo/__init__.py
25 $ cp foobar.py barfoo/__init__.py
26 $ barfoopath=`pwd`/barfoo
26 $ barfoopath=`pwd`/barfoo
27
27
28 $ hg init a
28 $ hg init a
29 $ cd a
29 $ cd a
30 $ echo foo > file
30 $ echo foo > file
31 $ hg add file
31 $ hg add file
32 $ hg commit -m 'add file'
32 $ hg commit -m 'add file'
33
33
34 $ echo '[extensions]' >> $HGRCPATH
34 $ echo '[extensions]' >> $HGRCPATH
35 $ echo "foobar = $abspath" >> $HGRCPATH
35 $ echo "foobar = $abspath" >> $HGRCPATH
36 $ hg foo
36 $ hg foo
37 uisetup called
37 uisetup called
38 reposetup called for a
38 reposetup called for a
39 ui == repo.ui
39 ui == repo.ui
40 Foo
40 Foo
41
41
42 $ cd ..
42 $ cd ..
43 $ hg clone a b
43 $ hg clone a b
44 uisetup called
44 uisetup called
45 reposetup called for a
45 reposetup called for a
46 ui == repo.ui
46 ui == repo.ui
47 reposetup called for b
47 reposetup called for b
48 ui == repo.ui
48 ui == repo.ui
49 updating to branch default
49 updating to branch default
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51
51
52 $ hg bar
52 $ hg bar
53 uisetup called
53 uisetup called
54 Bar
54 Bar
55 $ echo 'foobar = !' >> $HGRCPATH
55 $ echo 'foobar = !' >> $HGRCPATH
56
56
57 module/__init__.py-style
57 module/__init__.py-style
58
58
59 $ echo "barfoo = $barfoopath" >> $HGRCPATH
59 $ echo "barfoo = $barfoopath" >> $HGRCPATH
60 $ cd a
60 $ cd a
61 $ hg foo
61 $ hg foo
62 uisetup called
62 uisetup called
63 reposetup called for a
63 reposetup called for a
64 ui == repo.ui
64 ui == repo.ui
65 Foo
65 Foo
66 $ echo 'barfoo = !' >> $HGRCPATH
66 $ echo 'barfoo = !' >> $HGRCPATH
67
67
68 Check that extensions are loaded in phases:
68 Check that extensions are loaded in phases:
69
69
70 $ cat > foo.py <<EOF
70 $ cat > foo.py <<EOF
71 > import os
71 > import os
72 > name = os.path.basename(__file__).rsplit('.', 1)[0]
72 > name = os.path.basename(__file__).rsplit('.', 1)[0]
73 > print "1) %s imported" % name
73 > print "1) %s imported" % name
74 > def uisetup(ui):
74 > def uisetup(ui):
75 > print "2) %s uisetup" % name
75 > print "2) %s uisetup" % name
76 > def extsetup():
76 > def extsetup():
77 > print "3) %s extsetup" % name
77 > print "3) %s extsetup" % name
78 > def reposetup(ui, repo):
78 > def reposetup(ui, repo):
79 > print "4) %s reposetup" % name
79 > print "4) %s reposetup" % name
80 > EOF
80 > EOF
81
81
82 $ cp foo.py bar.py
82 $ cp foo.py bar.py
83 $ echo 'foo = foo.py' >> $HGRCPATH
83 $ echo 'foo = foo.py' >> $HGRCPATH
84 $ echo 'bar = bar.py' >> $HGRCPATH
84 $ echo 'bar = bar.py' >> $HGRCPATH
85
85
86 Command with no output, we just want to see the extensions loaded:
86 Command with no output, we just want to see the extensions loaded:
87
87
88 $ hg paths
88 $ hg paths
89 1) foo imported
89 1) foo imported
90 1) bar imported
90 1) bar imported
91 2) foo uisetup
91 2) foo uisetup
92 2) bar uisetup
92 2) bar uisetup
93 3) foo extsetup
93 3) foo extsetup
94 3) bar extsetup
94 3) bar extsetup
95 4) foo reposetup
95 4) foo reposetup
96 4) bar reposetup
96 4) bar reposetup
97
97
98 Check hgweb's load order:
98 Check hgweb's load order:
99
99
100 $ cat > hgweb.cgi <<EOF
100 $ cat > hgweb.cgi <<EOF
101 > #!/usr/bin/env python
101 > #!/usr/bin/env python
102 > from mercurial import demandimport; demandimport.enable()
102 > from mercurial import demandimport; demandimport.enable()
103 > from mercurial.hgweb import hgweb
103 > from mercurial.hgweb import hgweb
104 > from mercurial.hgweb import wsgicgi
104 > from mercurial.hgweb import wsgicgi
105 > application = hgweb('.', 'test repo')
105 > application = hgweb('.', 'test repo')
106 > wsgicgi.launch(application)
106 > wsgicgi.launch(application)
107 > EOF
107 > EOF
108
108
109 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
109 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
110 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
110 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
111 > | grep '^[0-9]) ' # ignores HTML output
111 > | grep '^[0-9]) ' # ignores HTML output
112 1) foo imported
112 1) foo imported
113 1) bar imported
113 1) bar imported
114 2) foo uisetup
114 2) foo uisetup
115 2) bar uisetup
115 2) bar uisetup
116 3) foo extsetup
116 3) foo extsetup
117 3) bar extsetup
117 3) bar extsetup
118 4) foo reposetup
118 4) foo reposetup
119 4) bar reposetup
119 4) bar reposetup
120
120
121 $ echo 'foo = !' >> $HGRCPATH
121 $ echo 'foo = !' >> $HGRCPATH
122 $ echo 'bar = !' >> $HGRCPATH
122 $ echo 'bar = !' >> $HGRCPATH
123
123
124 Check "from __future__ import absolute_import" support for external libraries
124 Check "from __future__ import absolute_import" support for external libraries
125
125
126 #if windows
126 #if windows
127 $ PATHSEP=";"
127 $ PATHSEP=";"
128 #else
128 #else
129 $ PATHSEP=":"
129 $ PATHSEP=":"
130 #endif
130 #endif
131 $ export PATHSEP
131 $ export PATHSEP
132
132
133 $ mkdir $TESTTMP/libroot
133 $ mkdir $TESTTMP/libroot
134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
135 $ mkdir $TESTTMP/libroot/mod
135 $ mkdir $TESTTMP/libroot/mod
136 $ touch $TESTTMP/libroot/mod/__init__.py
136 $ touch $TESTTMP/libroot/mod/__init__.py
137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
138
138
139 #if absimport
139 #if absimport
140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
141 > from __future__ import absolute_import
141 > from __future__ import absolute_import
142 > import ambig # should load "libroot/ambig.py"
142 > import ambig # should load "libroot/ambig.py"
143 > s = ambig.s
143 > s = ambig.s
144 > EOF
144 > EOF
145 $ cat > loadabs.py <<EOF
145 $ cat > loadabs.py <<EOF
146 > import mod.ambigabs as ambigabs
146 > import mod.ambigabs as ambigabs
147 > def extsetup():
147 > def extsetup():
148 > print 'ambigabs.s=%s' % ambigabs.s
148 > print 'ambigabs.s=%s' % ambigabs.s
149 > EOF
149 > EOF
150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
151 ambigabs.s=libroot/ambig.py
151 ambigabs.s=libroot/ambig.py
152 $TESTTMP/a (glob)
152 $TESTTMP/a (glob)
153 #endif
153 #endif
154
154
155 #if no-py3k
155 #if no-py3k
156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
157 > import ambig # should load "libroot/mod/ambig.py"
157 > import ambig # should load "libroot/mod/ambig.py"
158 > s = ambig.s
158 > s = ambig.s
159 > EOF
159 > EOF
160 $ cat > loadrel.py <<EOF
160 $ cat > loadrel.py <<EOF
161 > import mod.ambigrel as ambigrel
161 > import mod.ambigrel as ambigrel
162 > def extsetup():
162 > def extsetup():
163 > print 'ambigrel.s=%s' % ambigrel.s
163 > print 'ambigrel.s=%s' % ambigrel.s
164 > EOF
164 > EOF
165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
166 ambigrel.s=libroot/mod/ambig.py
166 ambigrel.s=libroot/mod/ambig.py
167 $TESTTMP/a (glob)
167 $TESTTMP/a (glob)
168 #endif
168 #endif
169
169
170 Check absolute/relative import of extension specific modules
170 Check absolute/relative import of extension specific modules
171
171
172 $ mkdir $TESTTMP/extroot
172 $ mkdir $TESTTMP/extroot
173 $ cat > $TESTTMP/extroot/bar.py <<EOF
173 $ cat > $TESTTMP/extroot/bar.py <<EOF
174 > s = 'this is extroot.bar'
174 > s = 'this is extroot.bar'
175 > EOF
175 > EOF
176 $ mkdir $TESTTMP/extroot/sub1
176 $ mkdir $TESTTMP/extroot/sub1
177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
178 > s = 'this is extroot.sub1.__init__'
178 > s = 'this is extroot.sub1.__init__'
179 > EOF
179 > EOF
180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
181 > s = 'this is extroot.sub1.baz'
181 > s = 'this is extroot.sub1.baz'
182 > EOF
182 > EOF
183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
184 > s = 'this is extroot.__init__'
184 > s = 'this is extroot.__init__'
185 > import foo
185 > import foo
186 > def extsetup(ui):
186 > def extsetup(ui):
187 > ui.write('(extroot) ', foo.func(), '\n')
187 > ui.write('(extroot) ', foo.func(), '\n')
188 > ui.flush()
188 > ui.flush()
189 > EOF
189 > EOF
190
190
191 $ cat > $TESTTMP/extroot/foo.py <<EOF
191 $ cat > $TESTTMP/extroot/foo.py <<EOF
192 > # test absolute import
192 > # test absolute import
193 > buf = []
193 > buf = []
194 > def func():
194 > def func():
195 > # "not locals" case
195 > # "not locals" case
196 > import extroot.bar
196 > import extroot.bar
197 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
197 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
198 > return '\n(extroot) '.join(buf)
198 > return '\n(extroot) '.join(buf)
199 > # "fromlist == ('*',)" case
199 > # "fromlist == ('*',)" case
200 > from extroot.bar import *
200 > from extroot.bar import *
201 > buf.append('from extroot.bar import *: %s' % s)
201 > buf.append('from extroot.bar import *: %s' % s)
202 > # "not fromlist" and "if '.' in name" case
202 > # "not fromlist" and "if '.' in name" case
203 > import extroot.sub1.baz
203 > import extroot.sub1.baz
204 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
204 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
205 > # "not fromlist" and NOT "if '.' in name" case
205 > # "not fromlist" and NOT "if '.' in name" case
206 > import extroot
206 > import extroot
207 > buf.append('import extroot: %s' % extroot.s)
207 > buf.append('import extroot: %s' % extroot.s)
208 > # NOT "not fromlist" and NOT "level != -1" case
208 > # NOT "not fromlist" and NOT "level != -1" case
209 > from extroot.bar import s
209 > from extroot.bar import s
210 > buf.append('from extroot.bar import s: %s' % s)
210 > buf.append('from extroot.bar import s: %s' % s)
211 > EOF
211 > EOF
212 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
212 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
213 (extroot) from extroot.bar import *: this is extroot.bar
213 (extroot) from extroot.bar import *: this is extroot.bar
214 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
214 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
215 (extroot) import extroot: this is extroot.__init__
215 (extroot) import extroot: this is extroot.__init__
216 (extroot) from extroot.bar import s: this is extroot.bar
216 (extroot) from extroot.bar import s: this is extroot.bar
217 (extroot) import extroot.bar in func(): this is extroot.bar
217 (extroot) import extroot.bar in func(): this is extroot.bar
218 $TESTTMP/a (glob)
218 $TESTTMP/a (glob)
219
219
220 #if no-py3k
220 #if no-py3k
221 $ rm "$TESTTMP"/extroot/foo.*
221 $ rm "$TESTTMP"/extroot/foo.*
222 $ cat > $TESTTMP/extroot/foo.py <<EOF
222 $ cat > $TESTTMP/extroot/foo.py <<EOF
223 > # test relative import
223 > # test relative import
224 > buf = []
224 > buf = []
225 > def func():
225 > def func():
226 > # "not locals" case
226 > # "not locals" case
227 > import bar
227 > import bar
228 > buf.append('import bar in func(): %s' % bar.s)
228 > buf.append('import bar in func(): %s' % bar.s)
229 > return '\n(extroot) '.join(buf)
229 > return '\n(extroot) '.join(buf)
230 > # "fromlist == ('*',)" case
230 > # "fromlist == ('*',)" case
231 > from bar import *
231 > from bar import *
232 > buf.append('from bar import *: %s' % s)
232 > buf.append('from bar import *: %s' % s)
233 > # "not fromlist" and "if '.' in name" case
233 > # "not fromlist" and "if '.' in name" case
234 > import sub1.baz
234 > import sub1.baz
235 > buf.append('import sub1.baz: %s' % sub1.baz.s)
235 > buf.append('import sub1.baz: %s' % sub1.baz.s)
236 > # "not fromlist" and NOT "if '.' in name" case
236 > # "not fromlist" and NOT "if '.' in name" case
237 > import sub1
237 > import sub1
238 > buf.append('import sub1: %s' % sub1.s)
238 > buf.append('import sub1: %s' % sub1.s)
239 > # NOT "not fromlist" and NOT "level != -1" case
239 > # NOT "not fromlist" and NOT "level != -1" case
240 > from bar import s
240 > from bar import s
241 > buf.append('from bar import s: %s' % s)
241 > buf.append('from bar import s: %s' % s)
242 > EOF
242 > EOF
243 $ hg --config extensions.extroot=$TESTTMP/extroot root
243 $ hg --config extensions.extroot=$TESTTMP/extroot root
244 (extroot) from bar import *: this is extroot.bar
244 (extroot) from bar import *: this is extroot.bar
245 (extroot) import sub1.baz: this is extroot.sub1.baz
245 (extroot) import sub1.baz: this is extroot.sub1.baz
246 (extroot) import sub1: this is extroot.sub1.__init__
246 (extroot) import sub1: this is extroot.sub1.__init__
247 (extroot) from bar import s: this is extroot.bar
247 (extroot) from bar import s: this is extroot.bar
248 (extroot) import bar in func(): this is extroot.bar
248 (extroot) import bar in func(): this is extroot.bar
249 $TESTTMP/a (glob)
249 $TESTTMP/a (glob)
250 #endif
250 #endif
251
251
252 #if demandimport absimport
252 #if demandimport absimport
253
253
254 Examine whether module loading is delayed until actual referring, even
254 Examine whether module loading is delayed until actual referring, even
255 though module is imported with "absolute_import" feature.
255 though module is imported with "absolute_import" feature.
256
256
257 Files below in each packages are used for described purpose:
257 Files below in each packages are used for described purpose:
258
258
259 - "called": examine whether "from MODULE import ATTR" works correctly
259 - "called": examine whether "from MODULE import ATTR" works correctly
260 - "unused": examine whether loading is delayed correctly
260 - "unused": examine whether loading is delayed correctly
261 - "used": examine whether "from PACKAGE import MODULE" works correctly
261 - "used": examine whether "from PACKAGE import MODULE" works correctly
262
262
263 Package hierarchy is needed to examine whether demand importing works
263 Package hierarchy is needed to examine whether demand importing works
264 as expected for "from SUB.PACK.AGE import MODULE".
264 as expected for "from SUB.PACK.AGE import MODULE".
265
265
266 Setup "external library" to be imported with "absolute_import"
266 Setup "external library" to be imported with "absolute_import"
267 feature.
267 feature.
268
268
269 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
269 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
270 $ touch $TESTTMP/extlibroot/__init__.py
270 $ touch $TESTTMP/extlibroot/__init__.py
271 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
271 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
272 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
272 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
273
273
274 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<EOF
274 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<EOF
275 > def func():
275 > def func():
276 > return "this is extlibroot.lsub1.lsub2.called.func()"
276 > return "this is extlibroot.lsub1.lsub2.called.func()"
277 > EOF
277 > EOF
278 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<EOF
278 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<EOF
279 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
279 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
280 > EOF
280 > EOF
281 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<EOF
281 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<EOF
282 > detail = "this is extlibroot.lsub1.lsub2.used"
282 > detail = "this is extlibroot.lsub1.lsub2.used"
283 > EOF
283 > EOF
284
284
285 Setup sub-package of "external library", which causes instantiation of
285 Setup sub-package of "external library", which causes instantiation of
286 demandmod in "recurse down the module chain" code path. Relative
286 demandmod in "recurse down the module chain" code path. Relative
287 importing with "absolute_import" feature isn't tested, because "level
287 importing with "absolute_import" feature isn't tested, because "level
288 >=1 " doesn't cause instantiation of demandmod.
288 >=1 " doesn't cause instantiation of demandmod.
289
289
290 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
290 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
291 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<EOF
291 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<EOF
292 > detail = "this is extlibroot.recursedown.abs.used"
292 > detail = "this is extlibroot.recursedown.abs.used"
293 > EOF
293 > EOF
294 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<EOF
294 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<EOF
295 > from __future__ import absolute_import
295 > from __future__ import absolute_import
296 > from extlibroot.recursedown.abs.used import detail
296 > from extlibroot.recursedown.abs.used import detail
297 > EOF
297 > EOF
298
298
299 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
299 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
300 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<EOF
300 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<EOF
301 > detail = "this is extlibroot.recursedown.legacy.used"
301 > detail = "this is extlibroot.recursedown.legacy.used"
302 > EOF
302 > EOF
303 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<EOF
303 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<EOF
304 > # legacy style (level == -1) import
304 > # legacy style (level == -1) import
305 > from extlibroot.recursedown.legacy.used import detail
305 > from extlibroot.recursedown.legacy.used import detail
306 > EOF
306 > EOF
307
307
308 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<EOF
308 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<EOF
309 > from __future__ import absolute_import
309 > from __future__ import absolute_import
310 > from extlibroot.recursedown.abs import detail as absdetail
310 > from extlibroot.recursedown.abs import detail as absdetail
311 > from .legacy import detail as legacydetail
311 > from .legacy import detail as legacydetail
312 > EOF
312 > EOF
313
313
314 Setup extension local modules to be imported with "absolute_import"
314 Setup extension local modules to be imported with "absolute_import"
315 feature.
315 feature.
316
316
317 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
317 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
318 $ touch $TESTTMP/absextroot/xsub1/__init__.py
318 $ touch $TESTTMP/absextroot/xsub1/__init__.py
319 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
319 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
320
320
321 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<EOF
321 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<EOF
322 > def func():
322 > def func():
323 > return "this is absextroot.xsub1.xsub2.called.func()"
323 > return "this is absextroot.xsub1.xsub2.called.func()"
324 > EOF
324 > EOF
325 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<EOF
325 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<EOF
326 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
326 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
327 > EOF
327 > EOF
328 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<EOF
328 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<EOF
329 > detail = "this is absextroot.xsub1.xsub2.used"
329 > detail = "this is absextroot.xsub1.xsub2.used"
330 > EOF
330 > EOF
331
331
332 Setup extension local modules to examine whether demand importing
332 Setup extension local modules to examine whether demand importing
333 works as expected in "level > 1" case.
333 works as expected in "level > 1" case.
334
334
335 $ cat > $TESTTMP/absextroot/relimportee.py <<EOF
335 $ cat > $TESTTMP/absextroot/relimportee.py <<EOF
336 > detail = "this is absextroot.relimportee"
336 > detail = "this is absextroot.relimportee"
337 > EOF
337 > EOF
338 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<EOF
338 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<EOF
339 > from __future__ import absolute_import
339 > from __future__ import absolute_import
340 > from ... import relimportee
340 > from ... import relimportee
341 > detail = "this relimporter imports %r" % (relimportee.detail)
341 > detail = "this relimporter imports %r" % (relimportee.detail)
342 > EOF
342 > EOF
343
343
344 Setup modules, which actually import extension local modules at
344 Setup modules, which actually import extension local modules at
345 runtime.
345 runtime.
346
346
347 $ cat > $TESTTMP/absextroot/absolute.py << EOF
347 $ cat > $TESTTMP/absextroot/absolute.py << EOF
348 > from __future__ import absolute_import
348 > from __future__ import absolute_import
349 >
349 >
350 > # import extension local modules absolutely (level = 0)
350 > # import extension local modules absolutely (level = 0)
351 > from absextroot.xsub1.xsub2 import used, unused
351 > from absextroot.xsub1.xsub2 import used, unused
352 > from absextroot.xsub1.xsub2.called import func
352 > from absextroot.xsub1.xsub2.called import func
353 >
353 >
354 > def getresult():
354 > def getresult():
355 > result = []
355 > result = []
356 > result.append(used.detail)
356 > result.append(used.detail)
357 > result.append(func())
357 > result.append(func())
358 > return result
358 > return result
359 > EOF
359 > EOF
360
360
361 $ cat > $TESTTMP/absextroot/relative.py << EOF
361 $ cat > $TESTTMP/absextroot/relative.py << EOF
362 > from __future__ import absolute_import
362 > from __future__ import absolute_import
363 >
363 >
364 > # import extension local modules relatively (level == 1)
364 > # import extension local modules relatively (level == 1)
365 > from .xsub1.xsub2 import used, unused
365 > from .xsub1.xsub2 import used, unused
366 > from .xsub1.xsub2.called import func
366 > from .xsub1.xsub2.called import func
367 >
367 >
368 > # import a module, which implies "importing with level > 1"
368 > # import a module, which implies "importing with level > 1"
369 > from .xsub1.xsub2 import relimporter
369 > from .xsub1.xsub2 import relimporter
370 >
370 >
371 > def getresult():
371 > def getresult():
372 > result = []
372 > result = []
373 > result.append(used.detail)
373 > result.append(used.detail)
374 > result.append(func())
374 > result.append(func())
375 > result.append(relimporter.detail)
375 > result.append(relimporter.detail)
376 > return result
376 > return result
377 > EOF
377 > EOF
378
378
379 Setup main procedure of extension.
379 Setup main procedure of extension.
380
380
381 $ cat > $TESTTMP/absextroot/__init__.py <<EOF
381 $ cat > $TESTTMP/absextroot/__init__.py <<EOF
382 > from __future__ import absolute_import
382 > from __future__ import absolute_import
383 > from mercurial import cmdutil
383 > from mercurial import cmdutil
384 > cmdtable = {}
384 > cmdtable = {}
385 > command = cmdutil.command(cmdtable)
385 > command = cmdutil.command(cmdtable)
386 >
386 >
387 > # "absolute" and "relative" shouldn't be imported before actual
387 > # "absolute" and "relative" shouldn't be imported before actual
388 > # command execution, because (1) they import same modules, and (2)
388 > # command execution, because (1) they import same modules, and (2)
389 > # preceding import (= instantiate "demandmod" object instead of
389 > # preceding import (= instantiate "demandmod" object instead of
390 > # real "module" object) might hide problem of succeeding import.
390 > # real "module" object) might hide problem of succeeding import.
391 >
391 >
392 > @command('showabsolute', [], norepo=True)
392 > @command('showabsolute', [], norepo=True)
393 > def showabsolute(ui, *args, **opts):
393 > def showabsolute(ui, *args, **opts):
394 > from absextroot import absolute
394 > from absextroot import absolute
395 > ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult()))
395 > ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult()))
396 >
396 >
397 > @command('showrelative', [], norepo=True)
397 > @command('showrelative', [], norepo=True)
398 > def showrelative(ui, *args, **opts):
398 > def showrelative(ui, *args, **opts):
399 > from . import relative
399 > from . import relative
400 > ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult()))
400 > ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult()))
401 >
401 >
402 > # import modules from external library
402 > # import modules from external library
403 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
403 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
404 > from extlibroot.lsub1.lsub2.called import func as lfunc
404 > from extlibroot.lsub1.lsub2.called import func as lfunc
405 > from extlibroot.recursedown import absdetail, legacydetail
405 > from extlibroot.recursedown import absdetail, legacydetail
406 >
406 >
407 > def uisetup(ui):
407 > def uisetup(ui):
408 > result = []
408 > result = []
409 > result.append(lused.detail)
409 > result.append(lused.detail)
410 > result.append(lfunc())
410 > result.append(lfunc())
411 > result.append(absdetail)
411 > result.append(absdetail)
412 > result.append(legacydetail)
412 > result.append(legacydetail)
413 > ui.write('LIB: %s\n' % '\nLIB: '.join(result))
413 > ui.write('LIB: %s\n' % '\nLIB: '.join(result))
414 > EOF
414 > EOF
415
415
416 Examine module importing.
416 Examine module importing.
417
417
418 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
418 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
419 LIB: this is extlibroot.lsub1.lsub2.used
419 LIB: this is extlibroot.lsub1.lsub2.used
420 LIB: this is extlibroot.lsub1.lsub2.called.func()
420 LIB: this is extlibroot.lsub1.lsub2.called.func()
421 LIB: this is extlibroot.recursedown.abs.used
421 LIB: this is extlibroot.recursedown.abs.used
422 LIB: this is extlibroot.recursedown.legacy.used
422 LIB: this is extlibroot.recursedown.legacy.used
423 ABS: this is absextroot.xsub1.xsub2.used
423 ABS: this is absextroot.xsub1.xsub2.used
424 ABS: this is absextroot.xsub1.xsub2.called.func()
424 ABS: this is absextroot.xsub1.xsub2.called.func()
425
425
426 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
426 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
427 LIB: this is extlibroot.lsub1.lsub2.used
427 LIB: this is extlibroot.lsub1.lsub2.used
428 LIB: this is extlibroot.lsub1.lsub2.called.func()
428 LIB: this is extlibroot.lsub1.lsub2.called.func()
429 LIB: this is extlibroot.recursedown.abs.used
429 LIB: this is extlibroot.recursedown.abs.used
430 LIB: this is extlibroot.recursedown.legacy.used
430 LIB: this is extlibroot.recursedown.legacy.used
431 REL: this is absextroot.xsub1.xsub2.used
431 REL: this is absextroot.xsub1.xsub2.used
432 REL: this is absextroot.xsub1.xsub2.called.func()
432 REL: this is absextroot.xsub1.xsub2.called.func()
433 REL: this relimporter imports 'this is absextroot.relimportee'
433 REL: this relimporter imports 'this is absextroot.relimportee'
434
434
435 Examine whether sub-module is imported relatively as expected.
435 Examine whether sub-module is imported relatively as expected.
436
436
437 See also issue5208 for detail about example case on Python 3.x.
437 See also issue5208 for detail about example case on Python 3.x.
438
438
439 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
439 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
440 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
440 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
441
441
442 $ cat > $TESTTMP/notexist.py <<EOF
442 $ cat > $TESTTMP/notexist.py <<EOF
443 > text = 'notexist.py at root is loaded unintentionally\n'
443 > text = 'notexist.py at root is loaded unintentionally\n'
444 > EOF
444 > EOF
445
445
446 $ cat > $TESTTMP/checkrelativity.py <<EOF
446 $ cat > $TESTTMP/checkrelativity.py <<EOF
447 > from mercurial import cmdutil
447 > from mercurial import cmdutil
448 > cmdtable = {}
448 > cmdtable = {}
449 > command = cmdutil.command(cmdtable)
449 > command = cmdutil.command(cmdtable)
450 >
450 >
451 > # demand import avoids failure of importing notexist here
451 > # demand import avoids failure of importing notexist here
452 > import extlibroot.lsub1.lsub2.notexist
452 > import extlibroot.lsub1.lsub2.notexist
453 >
453 >
454 > @command('checkrelativity', [], norepo=True)
454 > @command('checkrelativity', [], norepo=True)
455 > def checkrelativity(ui, *args, **opts):
455 > def checkrelativity(ui, *args, **opts):
456 > try:
456 > try:
457 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
457 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
458 > return 1 # unintentional success
458 > return 1 # unintentional success
459 > except ImportError:
459 > except ImportError:
460 > pass # intentional failure
460 > pass # intentional failure
461 > EOF
461 > EOF
462
462
463 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
463 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
464
464
465 #endif
465 #endif
466
466
467 $ cd ..
467 $ cd ..
468
468
469 hide outer repo
469 hide outer repo
470 $ hg init
470 $ hg init
471
471
472 $ cat > empty.py <<EOF
472 $ cat > empty.py <<EOF
473 > '''empty cmdtable
473 > '''empty cmdtable
474 > '''
474 > '''
475 > cmdtable = {}
475 > cmdtable = {}
476 > EOF
476 > EOF
477 $ emptypath=`pwd`/empty.py
477 $ emptypath=`pwd`/empty.py
478 $ echo "empty = $emptypath" >> $HGRCPATH
478 $ echo "empty = $emptypath" >> $HGRCPATH
479 $ hg help empty
479 $ hg help empty
480 empty extension - empty cmdtable
480 empty extension - empty cmdtable
481
481
482 no commands defined
482 no commands defined
483
483
484
484
485 $ echo 'empty = !' >> $HGRCPATH
485 $ echo 'empty = !' >> $HGRCPATH
486
486
487 $ cat > debugextension.py <<EOF
487 $ cat > debugextension.py <<EOF
488 > '''only debugcommands
488 > '''only debugcommands
489 > '''
489 > '''
490 > from mercurial import cmdutil
490 > from mercurial import cmdutil
491 > cmdtable = {}
491 > cmdtable = {}
492 > command = cmdutil.command(cmdtable)
492 > command = cmdutil.command(cmdtable)
493 > @command('debugfoobar', [], 'hg debugfoobar')
493 > @command('debugfoobar', [], 'hg debugfoobar')
494 > def debugfoobar(ui, repo, *args, **opts):
494 > def debugfoobar(ui, repo, *args, **opts):
495 > "yet another debug command"
495 > "yet another debug command"
496 > pass
496 > pass
497 > @command('foo', [], 'hg foo')
497 > @command('foo', [], 'hg foo')
498 > def foo(ui, repo, *args, **opts):
498 > def foo(ui, repo, *args, **opts):
499 > """yet another foo command
499 > """yet another foo command
500 > This command has been DEPRECATED since forever.
500 > This command has been DEPRECATED since forever.
501 > """
501 > """
502 > pass
502 > pass
503 > EOF
503 > EOF
504 $ debugpath=`pwd`/debugextension.py
504 $ debugpath=`pwd`/debugextension.py
505 $ echo "debugextension = $debugpath" >> $HGRCPATH
505 $ echo "debugextension = $debugpath" >> $HGRCPATH
506
506
507 $ hg help debugextension
507 $ hg help debugextension
508 hg debugextensions
508 hg debugextensions
509
509
510 show information about active extensions
510 show information about active extensions
511
511
512 options:
512 options:
513
513
514 (some details hidden, use --verbose to show complete help)
514 (some details hidden, use --verbose to show complete help)
515
515
516
516
517 $ hg --verbose help debugextension
517 $ hg --verbose help debugextension
518 hg debugextensions
518 hg debugextensions
519
519
520 show information about active extensions
520 show information about active extensions
521
521
522 options:
522 options:
523
523
524 -T --template TEMPLATE display with template (EXPERIMENTAL)
524 -T --template TEMPLATE display with template (EXPERIMENTAL)
525
525
526 global options ([+] can be repeated):
526 global options ([+] can be repeated):
527
527
528 -R --repository REPO repository root directory or name of overlay bundle
528 -R --repository REPO repository root directory or name of overlay bundle
529 file
529 file
530 --cwd DIR change working directory
530 --cwd DIR change working directory
531 -y --noninteractive do not prompt, automatically pick the first choice for
531 -y --noninteractive do not prompt, automatically pick the first choice for
532 all prompts
532 all prompts
533 -q --quiet suppress output
533 -q --quiet suppress output
534 -v --verbose enable additional output
534 -v --verbose enable additional output
535 --color TYPE when to colorize (boolean, always, auto, never, or
535 --color TYPE when to colorize (boolean, always, auto, never, or
536 debug) (EXPERIMENTAL)
536 debug)
537 --config CONFIG [+] set/override config option (use 'section.name=value')
537 --config CONFIG [+] set/override config option (use 'section.name=value')
538 --debug enable debugging output
538 --debug enable debugging output
539 --debugger start debugger
539 --debugger start debugger
540 --encoding ENCODE set the charset encoding (default: ascii)
540 --encoding ENCODE set the charset encoding (default: ascii)
541 --encodingmode MODE set the charset encoding mode (default: strict)
541 --encodingmode MODE set the charset encoding mode (default: strict)
542 --traceback always print a traceback on exception
542 --traceback always print a traceback on exception
543 --time time how long the command takes
543 --time time how long the command takes
544 --profile print command execution profile
544 --profile print command execution profile
545 --version output version information and exit
545 --version output version information and exit
546 -h --help display help and exit
546 -h --help display help and exit
547 --hidden consider hidden changesets
547 --hidden consider hidden changesets
548 --pager TYPE when to paginate (boolean, always, auto, or never)
548 --pager TYPE when to paginate (boolean, always, auto, or never)
549 (default: auto)
549 (default: auto)
550
550
551
551
552
552
553
553
554
554
555
555
556 $ hg --debug help debugextension
556 $ hg --debug help debugextension
557 hg debugextensions
557 hg debugextensions
558
558
559 show information about active extensions
559 show information about active extensions
560
560
561 options:
561 options:
562
562
563 -T --template TEMPLATE display with template (EXPERIMENTAL)
563 -T --template TEMPLATE display with template (EXPERIMENTAL)
564
564
565 global options ([+] can be repeated):
565 global options ([+] can be repeated):
566
566
567 -R --repository REPO repository root directory or name of overlay bundle
567 -R --repository REPO repository root directory or name of overlay bundle
568 file
568 file
569 --cwd DIR change working directory
569 --cwd DIR change working directory
570 -y --noninteractive do not prompt, automatically pick the first choice for
570 -y --noninteractive do not prompt, automatically pick the first choice for
571 all prompts
571 all prompts
572 -q --quiet suppress output
572 -q --quiet suppress output
573 -v --verbose enable additional output
573 -v --verbose enable additional output
574 --color TYPE when to colorize (boolean, always, auto, never, or
574 --color TYPE when to colorize (boolean, always, auto, never, or
575 debug) (EXPERIMENTAL)
575 debug)
576 --config CONFIG [+] set/override config option (use 'section.name=value')
576 --config CONFIG [+] set/override config option (use 'section.name=value')
577 --debug enable debugging output
577 --debug enable debugging output
578 --debugger start debugger
578 --debugger start debugger
579 --encoding ENCODE set the charset encoding (default: ascii)
579 --encoding ENCODE set the charset encoding (default: ascii)
580 --encodingmode MODE set the charset encoding mode (default: strict)
580 --encodingmode MODE set the charset encoding mode (default: strict)
581 --traceback always print a traceback on exception
581 --traceback always print a traceback on exception
582 --time time how long the command takes
582 --time time how long the command takes
583 --profile print command execution profile
583 --profile print command execution profile
584 --version output version information and exit
584 --version output version information and exit
585 -h --help display help and exit
585 -h --help display help and exit
586 --hidden consider hidden changesets
586 --hidden consider hidden changesets
587 --pager TYPE when to paginate (boolean, always, auto, or never)
587 --pager TYPE when to paginate (boolean, always, auto, or never)
588 (default: auto)
588 (default: auto)
589
589
590
590
591
591
592
592
593
593
594 $ echo 'debugextension = !' >> $HGRCPATH
594 $ echo 'debugextension = !' >> $HGRCPATH
595
595
596 Asking for help about a deprecated extension should do something useful:
596 Asking for help about a deprecated extension should do something useful:
597
597
598 $ hg help glog
598 $ hg help glog
599 'glog' is provided by the following extension:
599 'glog' is provided by the following extension:
600
600
601 graphlog command to view revision graphs from a shell (DEPRECATED)
601 graphlog command to view revision graphs from a shell (DEPRECATED)
602
602
603 (use 'hg help extensions' for information on enabling extensions)
603 (use 'hg help extensions' for information on enabling extensions)
604
604
605 Extension module help vs command help:
605 Extension module help vs command help:
606
606
607 $ echo 'extdiff =' >> $HGRCPATH
607 $ echo 'extdiff =' >> $HGRCPATH
608 $ hg help extdiff
608 $ hg help extdiff
609 hg extdiff [OPT]... [FILE]...
609 hg extdiff [OPT]... [FILE]...
610
610
611 use external program to diff repository (or selected files)
611 use external program to diff repository (or selected files)
612
612
613 Show differences between revisions for the specified files, using an
613 Show differences between revisions for the specified files, using an
614 external program. The default program used is diff, with default options
614 external program. The default program used is diff, with default options
615 "-Npru".
615 "-Npru".
616
616
617 To select a different program, use the -p/--program option. The program
617 To select a different program, use the -p/--program option. The program
618 will be passed the names of two directories to compare. To pass additional
618 will be passed the names of two directories to compare. To pass additional
619 options to the program, use -o/--option. These will be passed before the
619 options to the program, use -o/--option. These will be passed before the
620 names of the directories to compare.
620 names of the directories to compare.
621
621
622 When two revision arguments are given, then changes are shown between
622 When two revision arguments are given, then changes are shown between
623 those revisions. If only one revision is specified then that revision is
623 those revisions. If only one revision is specified then that revision is
624 compared to the working directory, and, when no revisions are specified,
624 compared to the working directory, and, when no revisions are specified,
625 the working directory files are compared to its parent.
625 the working directory files are compared to its parent.
626
626
627 (use 'hg help -e extdiff' to show help for the extdiff extension)
627 (use 'hg help -e extdiff' to show help for the extdiff extension)
628
628
629 options ([+] can be repeated):
629 options ([+] can be repeated):
630
630
631 -p --program CMD comparison program to run
631 -p --program CMD comparison program to run
632 -o --option OPT [+] pass option to comparison program
632 -o --option OPT [+] pass option to comparison program
633 -r --rev REV [+] revision
633 -r --rev REV [+] revision
634 -c --change REV change made by revision
634 -c --change REV change made by revision
635 --patch compare patches for two revisions
635 --patch compare patches for two revisions
636 -I --include PATTERN [+] include names matching the given patterns
636 -I --include PATTERN [+] include names matching the given patterns
637 -X --exclude PATTERN [+] exclude names matching the given patterns
637 -X --exclude PATTERN [+] exclude names matching the given patterns
638 -S --subrepos recurse into subrepositories
638 -S --subrepos recurse into subrepositories
639
639
640 (some details hidden, use --verbose to show complete help)
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 $ hg help --extension extdiff
651 $ hg help --extension extdiff
652 extdiff extension - command to allow external programs to compare revisions
652 extdiff extension - command to allow external programs to compare revisions
653
653
654 The extdiff Mercurial extension allows you to use external programs to compare
654 The extdiff Mercurial extension allows you to use external programs to compare
655 revisions, or revision with working directory. The external diff programs are
655 revisions, or revision with working directory. The external diff programs are
656 called with a configurable set of options and two non-option arguments: paths
656 called with a configurable set of options and two non-option arguments: paths
657 to directories containing snapshots of files to compare.
657 to directories containing snapshots of files to compare.
658
658
659 The extdiff extension also allows you to configure new diff commands, so you
659 The extdiff extension also allows you to configure new diff commands, so you
660 do not need to type 'hg extdiff -p kdiff3' always.
660 do not need to type 'hg extdiff -p kdiff3' always.
661
661
662 [extdiff]
662 [extdiff]
663 # add new command that runs GNU diff(1) in 'context diff' mode
663 # add new command that runs GNU diff(1) in 'context diff' mode
664 cdiff = gdiff -Nprc5
664 cdiff = gdiff -Nprc5
665 ## or the old way:
665 ## or the old way:
666 #cmd.cdiff = gdiff
666 #cmd.cdiff = gdiff
667 #opts.cdiff = -Nprc5
667 #opts.cdiff = -Nprc5
668
668
669 # add new command called meld, runs meld (no need to name twice). If
669 # add new command called meld, runs meld (no need to name twice). If
670 # the meld executable is not available, the meld tool in [merge-tools]
670 # the meld executable is not available, the meld tool in [merge-tools]
671 # will be used, if available
671 # will be used, if available
672 meld =
672 meld =
673
673
674 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
674 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
675 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
675 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
676 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
676 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
677 # your .vimrc
677 # your .vimrc
678 vimdiff = gvim -f "+next" \
678 vimdiff = gvim -f "+next" \
679 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
679 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
680
680
681 Tool arguments can include variables that are expanded at runtime:
681 Tool arguments can include variables that are expanded at runtime:
682
682
683 $parent1, $plabel1 - filename, descriptive label of first parent
683 $parent1, $plabel1 - filename, descriptive label of first parent
684 $child, $clabel - filename, descriptive label of child revision
684 $child, $clabel - filename, descriptive label of child revision
685 $parent2, $plabel2 - filename, descriptive label of second parent
685 $parent2, $plabel2 - filename, descriptive label of second parent
686 $root - repository root
686 $root - repository root
687 $parent is an alias for $parent1.
687 $parent is an alias for $parent1.
688
688
689 The extdiff extension will look in your [diff-tools] and [merge-tools]
689 The extdiff extension will look in your [diff-tools] and [merge-tools]
690 sections for diff tool arguments, when none are specified in [extdiff].
690 sections for diff tool arguments, when none are specified in [extdiff].
691
691
692 [extdiff]
692 [extdiff]
693 kdiff3 =
693 kdiff3 =
694
694
695 [diff-tools]
695 [diff-tools]
696 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
696 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
697
697
698 You can use -I/-X and list of file or directory names like normal 'hg diff'
698 You can use -I/-X and list of file or directory names like normal 'hg diff'
699 command. The extdiff extension makes snapshots of only needed files, so
699 command. The extdiff extension makes snapshots of only needed files, so
700 running the external diff program will actually be pretty fast (at least
700 running the external diff program will actually be pretty fast (at least
701 faster than having to compare the entire tree).
701 faster than having to compare the entire tree).
702
702
703 list of commands:
703 list of commands:
704
704
705 extdiff use external program to diff repository (or selected files)
705 extdiff use external program to diff repository (or selected files)
706
706
707 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
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 $ echo 'extdiff = !' >> $HGRCPATH
724 $ echo 'extdiff = !' >> $HGRCPATH
725
725
726 Test help topic with same name as extension
726 Test help topic with same name as extension
727
727
728 $ cat > multirevs.py <<EOF
728 $ cat > multirevs.py <<EOF
729 > from mercurial import cmdutil, commands
729 > from mercurial import cmdutil, commands
730 > cmdtable = {}
730 > cmdtable = {}
731 > command = cmdutil.command(cmdtable)
731 > command = cmdutil.command(cmdtable)
732 > """multirevs extension
732 > """multirevs extension
733 > Big multi-line module docstring."""
733 > Big multi-line module docstring."""
734 > @command('multirevs', [], 'ARG', norepo=True)
734 > @command('multirevs', [], 'ARG', norepo=True)
735 > def multirevs(ui, repo, arg, *args, **opts):
735 > def multirevs(ui, repo, arg, *args, **opts):
736 > """multirevs command"""
736 > """multirevs command"""
737 > pass
737 > pass
738 > EOF
738 > EOF
739 $ echo "multirevs = multirevs.py" >> $HGRCPATH
739 $ echo "multirevs = multirevs.py" >> $HGRCPATH
740
740
741 $ hg help multirevs | tail
741 $ hg help multirevs | tail
742 bookmark (this works because the last revision of the revset is used):
742 bookmark (this works because the last revision of the revset is used):
743
743
744 hg update :@
744 hg update :@
745
745
746 - Show diff between tags 1.3 and 1.5 (this works because the first and the
746 - Show diff between tags 1.3 and 1.5 (this works because the first and the
747 last revisions of the revset are used):
747 last revisions of the revset are used):
748
748
749 hg diff -r 1.3::1.5
749 hg diff -r 1.3::1.5
750
750
751 use 'hg help -c multirevs' to see help for the multirevs command
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 $ hg help -c multirevs
758 $ hg help -c multirevs
759 hg multirevs ARG
759 hg multirevs ARG
760
760
761 multirevs command
761 multirevs command
762
762
763 (some details hidden, use --verbose to show complete help)
763 (some details hidden, use --verbose to show complete help)
764
764
765
765
766
766
767 $ hg multirevs
767 $ hg multirevs
768 hg multirevs: invalid arguments
768 hg multirevs: invalid arguments
769 hg multirevs ARG
769 hg multirevs ARG
770
770
771 multirevs command
771 multirevs command
772
772
773 (use 'hg multirevs -h' to show more help)
773 (use 'hg multirevs -h' to show more help)
774 [255]
774 [255]
775
775
776
776
777
777
778 $ echo "multirevs = !" >> $HGRCPATH
778 $ echo "multirevs = !" >> $HGRCPATH
779
779
780 Issue811: Problem loading extensions twice (by site and by user)
780 Issue811: Problem loading extensions twice (by site and by user)
781
781
782 $ cat <<EOF >> $HGRCPATH
782 $ cat <<EOF >> $HGRCPATH
783 > mq =
783 > mq =
784 > strip =
784 > strip =
785 > hgext.mq =
785 > hgext.mq =
786 > hgext/mq =
786 > hgext/mq =
787 > EOF
787 > EOF
788
788
789 Show extensions:
789 Show extensions:
790 (note that mq force load strip, also checking it's not loaded twice)
790 (note that mq force load strip, also checking it's not loaded twice)
791
791
792 $ hg debugextensions
792 $ hg debugextensions
793 mq
793 mq
794 strip
794 strip
795
795
796 For extensions, which name matches one of its commands, help
796 For extensions, which name matches one of its commands, help
797 message should ask '-v -e' to get list of built-in aliases
797 message should ask '-v -e' to get list of built-in aliases
798 along with extension help itself
798 along with extension help itself
799
799
800 $ mkdir $TESTTMP/d
800 $ mkdir $TESTTMP/d
801 $ cat > $TESTTMP/d/dodo.py <<EOF
801 $ cat > $TESTTMP/d/dodo.py <<EOF
802 > """
802 > """
803 > This is an awesome 'dodo' extension. It does nothing and
803 > This is an awesome 'dodo' extension. It does nothing and
804 > writes 'Foo foo'
804 > writes 'Foo foo'
805 > """
805 > """
806 > from mercurial import cmdutil, commands
806 > from mercurial import cmdutil, commands
807 > cmdtable = {}
807 > cmdtable = {}
808 > command = cmdutil.command(cmdtable)
808 > command = cmdutil.command(cmdtable)
809 > @command('dodo', [], 'hg dodo')
809 > @command('dodo', [], 'hg dodo')
810 > def dodo(ui, *args, **kwargs):
810 > def dodo(ui, *args, **kwargs):
811 > """Does nothing"""
811 > """Does nothing"""
812 > ui.write("I do nothing. Yay\\n")
812 > ui.write("I do nothing. Yay\\n")
813 > @command('foofoo', [], 'hg foofoo')
813 > @command('foofoo', [], 'hg foofoo')
814 > def foofoo(ui, *args, **kwargs):
814 > def foofoo(ui, *args, **kwargs):
815 > """Writes 'Foo foo'"""
815 > """Writes 'Foo foo'"""
816 > ui.write("Foo foo\\n")
816 > ui.write("Foo foo\\n")
817 > EOF
817 > EOF
818 $ dodopath=$TESTTMP/d/dodo.py
818 $ dodopath=$TESTTMP/d/dodo.py
819
819
820 $ echo "dodo = $dodopath" >> $HGRCPATH
820 $ echo "dodo = $dodopath" >> $HGRCPATH
821
821
822 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
822 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
823 $ hg help -e dodo
823 $ hg help -e dodo
824 dodo extension -
824 dodo extension -
825
825
826 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
826 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
827
827
828 list of commands:
828 list of commands:
829
829
830 dodo Does nothing
830 dodo Does nothing
831 foofoo Writes 'Foo foo'
831 foofoo Writes 'Foo foo'
832
832
833 (use 'hg help -v -e dodo' to show built-in aliases and global options)
833 (use 'hg help -v -e dodo' to show built-in aliases and global options)
834
834
835 Make sure that '-v -e' prints list of built-in aliases along with
835 Make sure that '-v -e' prints list of built-in aliases along with
836 extension help itself
836 extension help itself
837 $ hg help -v -e dodo
837 $ hg help -v -e dodo
838 dodo extension -
838 dodo extension -
839
839
840 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
840 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
841
841
842 list of commands:
842 list of commands:
843
843
844 dodo Does nothing
844 dodo Does nothing
845 foofoo Writes 'Foo foo'
845 foofoo Writes 'Foo foo'
846
846
847 global options ([+] can be repeated):
847 global options ([+] can be repeated):
848
848
849 -R --repository REPO repository root directory or name of overlay bundle
849 -R --repository REPO repository root directory or name of overlay bundle
850 file
850 file
851 --cwd DIR change working directory
851 --cwd DIR change working directory
852 -y --noninteractive do not prompt, automatically pick the first choice for
852 -y --noninteractive do not prompt, automatically pick the first choice for
853 all prompts
853 all prompts
854 -q --quiet suppress output
854 -q --quiet suppress output
855 -v --verbose enable additional output
855 -v --verbose enable additional output
856 --color TYPE when to colorize (boolean, always, auto, never, or
856 --color TYPE when to colorize (boolean, always, auto, never, or
857 debug) (EXPERIMENTAL)
857 debug)
858 --config CONFIG [+] set/override config option (use 'section.name=value')
858 --config CONFIG [+] set/override config option (use 'section.name=value')
859 --debug enable debugging output
859 --debug enable debugging output
860 --debugger start debugger
860 --debugger start debugger
861 --encoding ENCODE set the charset encoding (default: ascii)
861 --encoding ENCODE set the charset encoding (default: ascii)
862 --encodingmode MODE set the charset encoding mode (default: strict)
862 --encodingmode MODE set the charset encoding mode (default: strict)
863 --traceback always print a traceback on exception
863 --traceback always print a traceback on exception
864 --time time how long the command takes
864 --time time how long the command takes
865 --profile print command execution profile
865 --profile print command execution profile
866 --version output version information and exit
866 --version output version information and exit
867 -h --help display help and exit
867 -h --help display help and exit
868 --hidden consider hidden changesets
868 --hidden consider hidden changesets
869 --pager TYPE when to paginate (boolean, always, auto, or never)
869 --pager TYPE when to paginate (boolean, always, auto, or never)
870 (default: auto)
870 (default: auto)
871
871
872 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
872 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
873 $ hg help -v dodo
873 $ hg help -v dodo
874 hg dodo
874 hg dodo
875
875
876 Does nothing
876 Does nothing
877
877
878 (use 'hg help -e dodo' to show help for the dodo extension)
878 (use 'hg help -e dodo' to show help for the dodo extension)
879
879
880 options:
880 options:
881
881
882 --mq operate on patch repository
882 --mq operate on patch repository
883
883
884 global options ([+] can be repeated):
884 global options ([+] can be repeated):
885
885
886 -R --repository REPO repository root directory or name of overlay bundle
886 -R --repository REPO repository root directory or name of overlay bundle
887 file
887 file
888 --cwd DIR change working directory
888 --cwd DIR change working directory
889 -y --noninteractive do not prompt, automatically pick the first choice for
889 -y --noninteractive do not prompt, automatically pick the first choice for
890 all prompts
890 all prompts
891 -q --quiet suppress output
891 -q --quiet suppress output
892 -v --verbose enable additional output
892 -v --verbose enable additional output
893 --color TYPE when to colorize (boolean, always, auto, never, or
893 --color TYPE when to colorize (boolean, always, auto, never, or
894 debug) (EXPERIMENTAL)
894 debug)
895 --config CONFIG [+] set/override config option (use 'section.name=value')
895 --config CONFIG [+] set/override config option (use 'section.name=value')
896 --debug enable debugging output
896 --debug enable debugging output
897 --debugger start debugger
897 --debugger start debugger
898 --encoding ENCODE set the charset encoding (default: ascii)
898 --encoding ENCODE set the charset encoding (default: ascii)
899 --encodingmode MODE set the charset encoding mode (default: strict)
899 --encodingmode MODE set the charset encoding mode (default: strict)
900 --traceback always print a traceback on exception
900 --traceback always print a traceback on exception
901 --time time how long the command takes
901 --time time how long the command takes
902 --profile print command execution profile
902 --profile print command execution profile
903 --version output version information and exit
903 --version output version information and exit
904 -h --help display help and exit
904 -h --help display help and exit
905 --hidden consider hidden changesets
905 --hidden consider hidden changesets
906 --pager TYPE when to paginate (boolean, always, auto, or never)
906 --pager TYPE when to paginate (boolean, always, auto, or never)
907 (default: auto)
907 (default: auto)
908
908
909 In case when extension name doesn't match any of its commands,
909 In case when extension name doesn't match any of its commands,
910 help message should ask for '-v' to get list of built-in aliases
910 help message should ask for '-v' to get list of built-in aliases
911 along with extension help
911 along with extension help
912 $ cat > $TESTTMP/d/dudu.py <<EOF
912 $ cat > $TESTTMP/d/dudu.py <<EOF
913 > """
913 > """
914 > This is an awesome 'dudu' extension. It does something and
914 > This is an awesome 'dudu' extension. It does something and
915 > also writes 'Beep beep'
915 > also writes 'Beep beep'
916 > """
916 > """
917 > from mercurial import cmdutil, commands
917 > from mercurial import cmdutil, commands
918 > cmdtable = {}
918 > cmdtable = {}
919 > command = cmdutil.command(cmdtable)
919 > command = cmdutil.command(cmdtable)
920 > @command('something', [], 'hg something')
920 > @command('something', [], 'hg something')
921 > def something(ui, *args, **kwargs):
921 > def something(ui, *args, **kwargs):
922 > """Does something"""
922 > """Does something"""
923 > ui.write("I do something. Yaaay\\n")
923 > ui.write("I do something. Yaaay\\n")
924 > @command('beep', [], 'hg beep')
924 > @command('beep', [], 'hg beep')
925 > def beep(ui, *args, **kwargs):
925 > def beep(ui, *args, **kwargs):
926 > """Writes 'Beep beep'"""
926 > """Writes 'Beep beep'"""
927 > ui.write("Beep beep\\n")
927 > ui.write("Beep beep\\n")
928 > EOF
928 > EOF
929 $ dudupath=$TESTTMP/d/dudu.py
929 $ dudupath=$TESTTMP/d/dudu.py
930
930
931 $ echo "dudu = $dudupath" >> $HGRCPATH
931 $ echo "dudu = $dudupath" >> $HGRCPATH
932
932
933 $ hg help -e dudu
933 $ hg help -e dudu
934 dudu extension -
934 dudu extension -
935
935
936 This is an awesome 'dudu' extension. It does something and also writes 'Beep
936 This is an awesome 'dudu' extension. It does something and also writes 'Beep
937 beep'
937 beep'
938
938
939 list of commands:
939 list of commands:
940
940
941 beep Writes 'Beep beep'
941 beep Writes 'Beep beep'
942 something Does something
942 something Does something
943
943
944 (use 'hg help -v dudu' to show built-in aliases and global options)
944 (use 'hg help -v dudu' to show built-in aliases and global options)
945
945
946 In case when extension name doesn't match any of its commands,
946 In case when extension name doesn't match any of its commands,
947 help options '-v' and '-v -e' should be equivalent
947 help options '-v' and '-v -e' should be equivalent
948 $ hg help -v dudu
948 $ hg help -v dudu
949 dudu extension -
949 dudu extension -
950
950
951 This is an awesome 'dudu' extension. It does something and also writes 'Beep
951 This is an awesome 'dudu' extension. It does something and also writes 'Beep
952 beep'
952 beep'
953
953
954 list of commands:
954 list of commands:
955
955
956 beep Writes 'Beep beep'
956 beep Writes 'Beep beep'
957 something Does something
957 something Does something
958
958
959 global options ([+] can be repeated):
959 global options ([+] can be repeated):
960
960
961 -R --repository REPO repository root directory or name of overlay bundle
961 -R --repository REPO repository root directory or name of overlay bundle
962 file
962 file
963 --cwd DIR change working directory
963 --cwd DIR change working directory
964 -y --noninteractive do not prompt, automatically pick the first choice for
964 -y --noninteractive do not prompt, automatically pick the first choice for
965 all prompts
965 all prompts
966 -q --quiet suppress output
966 -q --quiet suppress output
967 -v --verbose enable additional output
967 -v --verbose enable additional output
968 --color TYPE when to colorize (boolean, always, auto, never, or
968 --color TYPE when to colorize (boolean, always, auto, never, or
969 debug) (EXPERIMENTAL)
969 debug)
970 --config CONFIG [+] set/override config option (use 'section.name=value')
970 --config CONFIG [+] set/override config option (use 'section.name=value')
971 --debug enable debugging output
971 --debug enable debugging output
972 --debugger start debugger
972 --debugger start debugger
973 --encoding ENCODE set the charset encoding (default: ascii)
973 --encoding ENCODE set the charset encoding (default: ascii)
974 --encodingmode MODE set the charset encoding mode (default: strict)
974 --encodingmode MODE set the charset encoding mode (default: strict)
975 --traceback always print a traceback on exception
975 --traceback always print a traceback on exception
976 --time time how long the command takes
976 --time time how long the command takes
977 --profile print command execution profile
977 --profile print command execution profile
978 --version output version information and exit
978 --version output version information and exit
979 -h --help display help and exit
979 -h --help display help and exit
980 --hidden consider hidden changesets
980 --hidden consider hidden changesets
981 --pager TYPE when to paginate (boolean, always, auto, or never)
981 --pager TYPE when to paginate (boolean, always, auto, or never)
982 (default: auto)
982 (default: auto)
983
983
984 $ hg help -v -e dudu
984 $ hg help -v -e dudu
985 dudu extension -
985 dudu extension -
986
986
987 This is an awesome 'dudu' extension. It does something and also writes 'Beep
987 This is an awesome 'dudu' extension. It does something and also writes 'Beep
988 beep'
988 beep'
989
989
990 list of commands:
990 list of commands:
991
991
992 beep Writes 'Beep beep'
992 beep Writes 'Beep beep'
993 something Does something
993 something Does something
994
994
995 global options ([+] can be repeated):
995 global options ([+] can be repeated):
996
996
997 -R --repository REPO repository root directory or name of overlay bundle
997 -R --repository REPO repository root directory or name of overlay bundle
998 file
998 file
999 --cwd DIR change working directory
999 --cwd DIR change working directory
1000 -y --noninteractive do not prompt, automatically pick the first choice for
1000 -y --noninteractive do not prompt, automatically pick the first choice for
1001 all prompts
1001 all prompts
1002 -q --quiet suppress output
1002 -q --quiet suppress output
1003 -v --verbose enable additional output
1003 -v --verbose enable additional output
1004 --color TYPE when to colorize (boolean, always, auto, never, or
1004 --color TYPE when to colorize (boolean, always, auto, never, or
1005 debug) (EXPERIMENTAL)
1005 debug)
1006 --config CONFIG [+] set/override config option (use 'section.name=value')
1006 --config CONFIG [+] set/override config option (use 'section.name=value')
1007 --debug enable debugging output
1007 --debug enable debugging output
1008 --debugger start debugger
1008 --debugger start debugger
1009 --encoding ENCODE set the charset encoding (default: ascii)
1009 --encoding ENCODE set the charset encoding (default: ascii)
1010 --encodingmode MODE set the charset encoding mode (default: strict)
1010 --encodingmode MODE set the charset encoding mode (default: strict)
1011 --traceback always print a traceback on exception
1011 --traceback always print a traceback on exception
1012 --time time how long the command takes
1012 --time time how long the command takes
1013 --profile print command execution profile
1013 --profile print command execution profile
1014 --version output version information and exit
1014 --version output version information and exit
1015 -h --help display help and exit
1015 -h --help display help and exit
1016 --hidden consider hidden changesets
1016 --hidden consider hidden changesets
1017 --pager TYPE when to paginate (boolean, always, auto, or never)
1017 --pager TYPE when to paginate (boolean, always, auto, or never)
1018 (default: auto)
1018 (default: auto)
1019
1019
1020 Disabled extension commands:
1020 Disabled extension commands:
1021
1021
1022 $ ORGHGRCPATH=$HGRCPATH
1022 $ ORGHGRCPATH=$HGRCPATH
1023 $ HGRCPATH=
1023 $ HGRCPATH=
1024 $ export HGRCPATH
1024 $ export HGRCPATH
1025 $ hg help email
1025 $ hg help email
1026 'email' is provided by the following extension:
1026 'email' is provided by the following extension:
1027
1027
1028 patchbomb command to send changesets as (a series of) patch emails
1028 patchbomb command to send changesets as (a series of) patch emails
1029
1029
1030 (use 'hg help extensions' for information on enabling extensions)
1030 (use 'hg help extensions' for information on enabling extensions)
1031
1031
1032
1032
1033 $ hg qdel
1033 $ hg qdel
1034 hg: unknown command 'qdel'
1034 hg: unknown command 'qdel'
1035 'qdelete' is provided by the following extension:
1035 'qdelete' is provided by the following extension:
1036
1036
1037 mq manage a stack of patches
1037 mq manage a stack of patches
1038
1038
1039 (use 'hg help extensions' for information on enabling extensions)
1039 (use 'hg help extensions' for information on enabling extensions)
1040 [255]
1040 [255]
1041
1041
1042
1042
1043 $ hg churn
1043 $ hg churn
1044 hg: unknown command 'churn'
1044 hg: unknown command 'churn'
1045 'churn' is provided by the following extension:
1045 'churn' is provided by the following extension:
1046
1046
1047 churn command to display statistics about repository history
1047 churn command to display statistics about repository history
1048
1048
1049 (use 'hg help extensions' for information on enabling extensions)
1049 (use 'hg help extensions' for information on enabling extensions)
1050 [255]
1050 [255]
1051
1051
1052
1052
1053
1053
1054 Disabled extensions:
1054 Disabled extensions:
1055
1055
1056 $ hg help churn
1056 $ hg help churn
1057 churn extension - command to display statistics about repository history
1057 churn extension - command to display statistics about repository history
1058
1058
1059 (use 'hg help extensions' for information on enabling extensions)
1059 (use 'hg help extensions' for information on enabling extensions)
1060
1060
1061 $ hg help patchbomb
1061 $ hg help patchbomb
1062 patchbomb extension - command to send changesets as (a series of) patch emails
1062 patchbomb extension - command to send changesets as (a series of) patch emails
1063
1063
1064 The series is started off with a "[PATCH 0 of N]" introduction, which
1064 The series is started off with a "[PATCH 0 of N]" introduction, which
1065 describes the series as a whole.
1065 describes the series as a whole.
1066
1066
1067 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1067 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1068 line of the changeset description as the subject text. The message contains
1068 line of the changeset description as the subject text. The message contains
1069 two or three body parts:
1069 two or three body parts:
1070
1070
1071 - The changeset description.
1071 - The changeset description.
1072 - [Optional] The result of running diffstat on the patch.
1072 - [Optional] The result of running diffstat on the patch.
1073 - The patch itself, as generated by 'hg export'.
1073 - The patch itself, as generated by 'hg export'.
1074
1074
1075 Each message refers to the first in the series using the In-Reply-To and
1075 Each message refers to the first in the series using the In-Reply-To and
1076 References headers, so they will show up as a sequence in threaded mail and
1076 References headers, so they will show up as a sequence in threaded mail and
1077 news readers, and in mail archives.
1077 news readers, and in mail archives.
1078
1078
1079 To configure other defaults, add a section like this to your configuration
1079 To configure other defaults, add a section like this to your configuration
1080 file:
1080 file:
1081
1081
1082 [email]
1082 [email]
1083 from = My Name <my@email>
1083 from = My Name <my@email>
1084 to = recipient1, recipient2, ...
1084 to = recipient1, recipient2, ...
1085 cc = cc1, cc2, ...
1085 cc = cc1, cc2, ...
1086 bcc = bcc1, bcc2, ...
1086 bcc = bcc1, bcc2, ...
1087 reply-to = address1, address2, ...
1087 reply-to = address1, address2, ...
1088
1088
1089 Use "[patchbomb]" as configuration section name if you need to override global
1089 Use "[patchbomb]" as configuration section name if you need to override global
1090 "[email]" address settings.
1090 "[email]" address settings.
1091
1091
1092 Then you can use the 'hg email' command to mail a series of changesets as a
1092 Then you can use the 'hg email' command to mail a series of changesets as a
1093 patchbomb.
1093 patchbomb.
1094
1094
1095 You can also either configure the method option in the email section to be a
1095 You can also either configure the method option in the email section to be a
1096 sendmail compatible mailer or fill out the [smtp] section so that the
1096 sendmail compatible mailer or fill out the [smtp] section so that the
1097 patchbomb extension can automatically send patchbombs directly from the
1097 patchbomb extension can automatically send patchbombs directly from the
1098 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1098 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1099
1099
1100 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1100 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1101 supply one via configuration or the command line. You can override this to
1101 supply one via configuration or the command line. You can override this to
1102 never prompt by configuring an empty value:
1102 never prompt by configuring an empty value:
1103
1103
1104 [email]
1104 [email]
1105 cc =
1105 cc =
1106
1106
1107 You can control the default inclusion of an introduction message with the
1107 You can control the default inclusion of an introduction message with the
1108 "patchbomb.intro" configuration option. The configuration is always
1108 "patchbomb.intro" configuration option. The configuration is always
1109 overwritten by command line flags like --intro and --desc:
1109 overwritten by command line flags like --intro and --desc:
1110
1110
1111 [patchbomb]
1111 [patchbomb]
1112 intro=auto # include introduction message if more than 1 patch (default)
1112 intro=auto # include introduction message if more than 1 patch (default)
1113 intro=never # never include an introduction message
1113 intro=never # never include an introduction message
1114 intro=always # always include an introduction message
1114 intro=always # always include an introduction message
1115
1115
1116 You can set patchbomb to always ask for confirmation by setting
1116 You can set patchbomb to always ask for confirmation by setting
1117 "patchbomb.confirm" to true.
1117 "patchbomb.confirm" to true.
1118
1118
1119 (use 'hg help extensions' for information on enabling extensions)
1119 (use 'hg help extensions' for information on enabling extensions)
1120
1120
1121
1121
1122 Broken disabled extension and command:
1122 Broken disabled extension and command:
1123
1123
1124 $ mkdir hgext
1124 $ mkdir hgext
1125 $ echo > hgext/__init__.py
1125 $ echo > hgext/__init__.py
1126 $ cat > hgext/broken.py <<EOF
1126 $ cat > hgext/broken.py <<EOF
1127 > "broken extension'
1127 > "broken extension'
1128 > EOF
1128 > EOF
1129 $ cat > path.py <<EOF
1129 $ cat > path.py <<EOF
1130 > import os, sys
1130 > import os, sys
1131 > sys.path.insert(0, os.environ['HGEXTPATH'])
1131 > sys.path.insert(0, os.environ['HGEXTPATH'])
1132 > EOF
1132 > EOF
1133 $ HGEXTPATH=`pwd`
1133 $ HGEXTPATH=`pwd`
1134 $ export HGEXTPATH
1134 $ export HGEXTPATH
1135
1135
1136 $ hg --config extensions.path=./path.py help broken
1136 $ hg --config extensions.path=./path.py help broken
1137 broken extension - (no help text available)
1137 broken extension - (no help text available)
1138
1138
1139 (use 'hg help extensions' for information on enabling extensions)
1139 (use 'hg help extensions' for information on enabling extensions)
1140
1140
1141
1141
1142 $ cat > hgext/forest.py <<EOF
1142 $ cat > hgext/forest.py <<EOF
1143 > cmdtable = None
1143 > cmdtable = None
1144 > EOF
1144 > EOF
1145 $ hg --config extensions.path=./path.py help foo > /dev/null
1145 $ hg --config extensions.path=./path.py help foo > /dev/null
1146 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
1146 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
1147 abort: no such help topic: foo
1147 abort: no such help topic: foo
1148 (try 'hg help --keyword foo')
1148 (try 'hg help --keyword foo')
1149 [255]
1149 [255]
1150
1150
1151 $ cat > throw.py <<EOF
1151 $ cat > throw.py <<EOF
1152 > from mercurial import cmdutil, commands, util
1152 > from mercurial import cmdutil, commands, util
1153 > cmdtable = {}
1153 > cmdtable = {}
1154 > command = cmdutil.command(cmdtable)
1154 > command = cmdutil.command(cmdtable)
1155 > class Bogon(Exception): pass
1155 > class Bogon(Exception): pass
1156 > @command('throw', [], 'hg throw', norepo=True)
1156 > @command('throw', [], 'hg throw', norepo=True)
1157 > def throw(ui, **opts):
1157 > def throw(ui, **opts):
1158 > """throws an exception"""
1158 > """throws an exception"""
1159 > raise Bogon()
1159 > raise Bogon()
1160 > EOF
1160 > EOF
1161
1161
1162 No declared supported version, extension complains:
1162 No declared supported version, extension complains:
1163 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1163 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1164 ** Unknown exception encountered with possibly-broken third-party extension throw
1164 ** Unknown exception encountered with possibly-broken third-party extension throw
1165 ** which supports versions unknown of Mercurial.
1165 ** which supports versions unknown of Mercurial.
1166 ** Please disable throw and try your action again.
1166 ** Please disable throw and try your action again.
1167 ** If that fixes the bug please report it to the extension author.
1167 ** If that fixes the bug please report it to the extension author.
1168 ** Python * (glob)
1168 ** Python * (glob)
1169 ** Mercurial Distributed SCM * (glob)
1169 ** Mercurial Distributed SCM * (glob)
1170 ** Extensions loaded: throw
1170 ** Extensions loaded: throw
1171
1171
1172 empty declaration of supported version, extension complains:
1172 empty declaration of supported version, extension complains:
1173 $ echo "testedwith = ''" >> throw.py
1173 $ echo "testedwith = ''" >> throw.py
1174 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1174 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1175 ** Unknown exception encountered with possibly-broken third-party extension throw
1175 ** Unknown exception encountered with possibly-broken third-party extension throw
1176 ** which supports versions unknown of Mercurial.
1176 ** which supports versions unknown of Mercurial.
1177 ** Please disable throw and try your action again.
1177 ** Please disable throw and try your action again.
1178 ** If that fixes the bug please report it to the extension author.
1178 ** If that fixes the bug please report it to the extension author.
1179 ** Python * (glob)
1179 ** Python * (glob)
1180 ** Mercurial Distributed SCM (*) (glob)
1180 ** Mercurial Distributed SCM (*) (glob)
1181 ** Extensions loaded: throw
1181 ** Extensions loaded: throw
1182
1182
1183 If the extension specifies a buglink, show that:
1183 If the extension specifies a buglink, show that:
1184 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1184 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1185 $ rm -f throw.pyc throw.pyo
1185 $ rm -f throw.pyc throw.pyo
1186 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1186 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1187 ** Unknown exception encountered with possibly-broken third-party extension throw
1187 ** Unknown exception encountered with possibly-broken third-party extension throw
1188 ** which supports versions unknown of Mercurial.
1188 ** which supports versions unknown of Mercurial.
1189 ** Please disable throw and try your action again.
1189 ** Please disable throw and try your action again.
1190 ** If that fixes the bug please report it to http://example.com/bts
1190 ** If that fixes the bug please report it to http://example.com/bts
1191 ** Python * (glob)
1191 ** Python * (glob)
1192 ** Mercurial Distributed SCM (*) (glob)
1192 ** Mercurial Distributed SCM (*) (glob)
1193 ** Extensions loaded: throw
1193 ** Extensions loaded: throw
1194
1194
1195 If the extensions declare outdated versions, accuse the older extension first:
1195 If the extensions declare outdated versions, accuse the older extension first:
1196 $ echo "from mercurial import util" >> older.py
1196 $ echo "from mercurial import util" >> older.py
1197 $ echo "util.version = lambda:'2.2'" >> older.py
1197 $ echo "util.version = lambda:'2.2'" >> older.py
1198 $ echo "testedwith = '1.9.3'" >> older.py
1198 $ echo "testedwith = '1.9.3'" >> older.py
1199 $ echo "testedwith = '2.1.1'" >> throw.py
1199 $ echo "testedwith = '2.1.1'" >> throw.py
1200 $ rm -f throw.pyc throw.pyo
1200 $ rm -f throw.pyc throw.pyo
1201 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1201 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1202 > throw 2>&1 | egrep '^\*\*'
1202 > throw 2>&1 | egrep '^\*\*'
1203 ** Unknown exception encountered with possibly-broken third-party extension older
1203 ** Unknown exception encountered with possibly-broken third-party extension older
1204 ** which supports versions 1.9 of Mercurial.
1204 ** which supports versions 1.9 of Mercurial.
1205 ** Please disable older and try your action again.
1205 ** Please disable older and try your action again.
1206 ** If that fixes the bug please report it to the extension author.
1206 ** If that fixes the bug please report it to the extension author.
1207 ** Python * (glob)
1207 ** Python * (glob)
1208 ** Mercurial Distributed SCM (version 2.2)
1208 ** Mercurial Distributed SCM (version 2.2)
1209 ** Extensions loaded: throw, older
1209 ** Extensions loaded: throw, older
1210
1210
1211 One extension only tested with older, one only with newer versions:
1211 One extension only tested with older, one only with newer versions:
1212 $ echo "util.version = lambda:'2.1'" >> older.py
1212 $ echo "util.version = lambda:'2.1'" >> older.py
1213 $ rm -f older.pyc older.pyo
1213 $ rm -f older.pyc older.pyo
1214 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1214 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1215 > throw 2>&1 | egrep '^\*\*'
1215 > throw 2>&1 | egrep '^\*\*'
1216 ** Unknown exception encountered with possibly-broken third-party extension older
1216 ** Unknown exception encountered with possibly-broken third-party extension older
1217 ** which supports versions 1.9 of Mercurial.
1217 ** which supports versions 1.9 of Mercurial.
1218 ** Please disable older and try your action again.
1218 ** Please disable older and try your action again.
1219 ** If that fixes the bug please report it to the extension author.
1219 ** If that fixes the bug please report it to the extension author.
1220 ** Python * (glob)
1220 ** Python * (glob)
1221 ** Mercurial Distributed SCM (version 2.1)
1221 ** Mercurial Distributed SCM (version 2.1)
1222 ** Extensions loaded: throw, older
1222 ** Extensions loaded: throw, older
1223
1223
1224 Older extension is tested with current version, the other only with newer:
1224 Older extension is tested with current version, the other only with newer:
1225 $ echo "util.version = lambda:'1.9.3'" >> older.py
1225 $ echo "util.version = lambda:'1.9.3'" >> older.py
1226 $ rm -f older.pyc older.pyo
1226 $ rm -f older.pyc older.pyo
1227 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1227 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1228 > throw 2>&1 | egrep '^\*\*'
1228 > throw 2>&1 | egrep '^\*\*'
1229 ** Unknown exception encountered with possibly-broken third-party extension throw
1229 ** Unknown exception encountered with possibly-broken third-party extension throw
1230 ** which supports versions 2.1 of Mercurial.
1230 ** which supports versions 2.1 of Mercurial.
1231 ** Please disable throw and try your action again.
1231 ** Please disable throw and try your action again.
1232 ** If that fixes the bug please report it to http://example.com/bts
1232 ** If that fixes the bug please report it to http://example.com/bts
1233 ** Python * (glob)
1233 ** Python * (glob)
1234 ** Mercurial Distributed SCM (version 1.9.3)
1234 ** Mercurial Distributed SCM (version 1.9.3)
1235 ** Extensions loaded: throw, older
1235 ** Extensions loaded: throw, older
1236
1236
1237 Ability to point to a different point
1237 Ability to point to a different point
1238 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1238 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1239 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1239 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1240 ** unknown exception encountered, please report by visiting
1240 ** unknown exception encountered, please report by visiting
1241 ** Your Local Goat Lenders
1241 ** Your Local Goat Lenders
1242 ** Python * (glob)
1242 ** Python * (glob)
1243 ** Mercurial Distributed SCM (*) (glob)
1243 ** Mercurial Distributed SCM (*) (glob)
1244 ** Extensions loaded: throw, older
1244 ** Extensions loaded: throw, older
1245
1245
1246 Declare the version as supporting this hg version, show regular bts link:
1246 Declare the version as supporting this hg version, show regular bts link:
1247 $ hgver=`hg debuginstall -T '{hgver}'`
1247 $ hgver=`hg debuginstall -T '{hgver}'`
1248 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1248 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1249 $ if [ -z "$hgver" ]; then
1249 $ if [ -z "$hgver" ]; then
1250 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1250 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1251 > fi
1251 > fi
1252 $ rm -f throw.pyc throw.pyo
1252 $ rm -f throw.pyc throw.pyo
1253 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1253 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1254 ** unknown exception encountered, please report by visiting
1254 ** unknown exception encountered, please report by visiting
1255 ** https://mercurial-scm.org/wiki/BugTracker
1255 ** https://mercurial-scm.org/wiki/BugTracker
1256 ** Python * (glob)
1256 ** Python * (glob)
1257 ** Mercurial Distributed SCM (*) (glob)
1257 ** Mercurial Distributed SCM (*) (glob)
1258 ** Extensions loaded: throw
1258 ** Extensions loaded: throw
1259
1259
1260 Patch version is ignored during compatibility check
1260 Patch version is ignored during compatibility check
1261 $ echo "testedwith = '3.2'" >> throw.py
1261 $ echo "testedwith = '3.2'" >> throw.py
1262 $ echo "util.version = lambda:'3.2.2'" >> throw.py
1262 $ echo "util.version = lambda:'3.2.2'" >> throw.py
1263 $ rm -f throw.pyc throw.pyo
1263 $ rm -f throw.pyc throw.pyo
1264 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1264 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1265 ** unknown exception encountered, please report by visiting
1265 ** unknown exception encountered, please report by visiting
1266 ** https://mercurial-scm.org/wiki/BugTracker
1266 ** https://mercurial-scm.org/wiki/BugTracker
1267 ** Python * (glob)
1267 ** Python * (glob)
1268 ** Mercurial Distributed SCM (*) (glob)
1268 ** Mercurial Distributed SCM (*) (glob)
1269 ** Extensions loaded: throw
1269 ** Extensions loaded: throw
1270
1270
1271 Test version number support in 'hg version':
1271 Test version number support in 'hg version':
1272 $ echo '__version__ = (1, 2, 3)' >> throw.py
1272 $ echo '__version__ = (1, 2, 3)' >> throw.py
1273 $ rm -f throw.pyc throw.pyo
1273 $ rm -f throw.pyc throw.pyo
1274 $ hg version -v
1274 $ hg version -v
1275 Mercurial Distributed SCM (version *) (glob)
1275 Mercurial Distributed SCM (version *) (glob)
1276 (see https://mercurial-scm.org for more information)
1276 (see https://mercurial-scm.org for more information)
1277
1277
1278 Copyright (C) 2005-* Matt Mackall and others (glob)
1278 Copyright (C) 2005-* Matt Mackall and others (glob)
1279 This is free software; see the source for copying conditions. There is NO
1279 This is free software; see the source for copying conditions. There is NO
1280 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1280 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1281
1281
1282 Enabled extensions:
1282 Enabled extensions:
1283
1283
1284
1284
1285 $ hg version -v --config extensions.throw=throw.py
1285 $ hg version -v --config extensions.throw=throw.py
1286 Mercurial Distributed SCM (version *) (glob)
1286 Mercurial Distributed SCM (version *) (glob)
1287 (see https://mercurial-scm.org for more information)
1287 (see https://mercurial-scm.org for more information)
1288
1288
1289 Copyright (C) 2005-* Matt Mackall and others (glob)
1289 Copyright (C) 2005-* Matt Mackall and others (glob)
1290 This is free software; see the source for copying conditions. There is NO
1290 This is free software; see the source for copying conditions. There is NO
1291 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1291 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1292
1292
1293 Enabled extensions:
1293 Enabled extensions:
1294
1294
1295 throw external 1.2.3
1295 throw external 1.2.3
1296 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
1296 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
1297 $ rm -f throw.pyc throw.pyo
1297 $ rm -f throw.pyc throw.pyo
1298 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1298 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1299 Mercurial Distributed SCM (version *) (glob)
1299 Mercurial Distributed SCM (version *) (glob)
1300 (see https://mercurial-scm.org for more information)
1300 (see https://mercurial-scm.org for more information)
1301
1301
1302 Copyright (C) 2005-* Matt Mackall and others (glob)
1302 Copyright (C) 2005-* Matt Mackall and others (glob)
1303 This is free software; see the source for copying conditions. There is NO
1303 This is free software; see the source for copying conditions. There is NO
1304 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1304 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1305
1305
1306 Enabled extensions:
1306 Enabled extensions:
1307
1307
1308 throw external 1.twentythree
1308 throw external 1.twentythree
1309 strip internal
1309 strip internal
1310
1310
1311 $ hg version -q --config extensions.throw=throw.py
1311 $ hg version -q --config extensions.throw=throw.py
1312 Mercurial Distributed SCM (version *) (glob)
1312 Mercurial Distributed SCM (version *) (glob)
1313
1313
1314 Test JSON output of version:
1314 Test JSON output of version:
1315
1315
1316 $ hg version -Tjson
1316 $ hg version -Tjson
1317 [
1317 [
1318 {
1318 {
1319 "extensions": [],
1319 "extensions": [],
1320 "ver": "*" (glob)
1320 "ver": "*" (glob)
1321 }
1321 }
1322 ]
1322 ]
1323
1323
1324 $ hg version --config extensions.throw=throw.py -Tjson
1324 $ hg version --config extensions.throw=throw.py -Tjson
1325 [
1325 [
1326 {
1326 {
1327 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1327 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1328 "ver": "3.2.2"
1328 "ver": "3.2.2"
1329 }
1329 }
1330 ]
1330 ]
1331
1331
1332 $ hg version --config extensions.strip= -Tjson
1332 $ hg version --config extensions.strip= -Tjson
1333 [
1333 [
1334 {
1334 {
1335 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1335 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1336 "ver": "*" (glob)
1336 "ver": "*" (glob)
1337 }
1337 }
1338 ]
1338 ]
1339
1339
1340 Test template output of version:
1340 Test template output of version:
1341
1341
1342 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1342 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1343 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1343 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1344 throw 1.twentythree (external)
1344 throw 1.twentythree (external)
1345 strip (internal)
1345 strip (internal)
1346
1346
1347 Refuse to load extensions with minimum version requirements
1347 Refuse to load extensions with minimum version requirements
1348
1348
1349 $ cat > minversion1.py << EOF
1349 $ cat > minversion1.py << EOF
1350 > from mercurial import util
1350 > from mercurial import util
1351 > util.version = lambda: '3.5.2'
1351 > util.version = lambda: '3.5.2'
1352 > minimumhgversion = '3.6'
1352 > minimumhgversion = '3.6'
1353 > EOF
1353 > EOF
1354 $ hg --config extensions.minversion=minversion1.py version
1354 $ hg --config extensions.minversion=minversion1.py version
1355 (third party extension minversion requires version 3.6 or newer of Mercurial; disabling)
1355 (third party extension minversion requires version 3.6 or newer of Mercurial; disabling)
1356 Mercurial Distributed SCM (version 3.5.2)
1356 Mercurial Distributed SCM (version 3.5.2)
1357 (see https://mercurial-scm.org for more information)
1357 (see https://mercurial-scm.org for more information)
1358
1358
1359 Copyright (C) 2005-* Matt Mackall and others (glob)
1359 Copyright (C) 2005-* Matt Mackall and others (glob)
1360 This is free software; see the source for copying conditions. There is NO
1360 This is free software; see the source for copying conditions. There is NO
1361 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1361 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1362
1362
1363 $ cat > minversion2.py << EOF
1363 $ cat > minversion2.py << EOF
1364 > from mercurial import util
1364 > from mercurial import util
1365 > util.version = lambda: '3.6'
1365 > util.version = lambda: '3.6'
1366 > minimumhgversion = '3.7'
1366 > minimumhgversion = '3.7'
1367 > EOF
1367 > EOF
1368 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1368 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1369 (third party extension minversion requires version 3.7 or newer of Mercurial; disabling)
1369 (third party extension minversion requires version 3.7 or newer of Mercurial; disabling)
1370
1370
1371 Can load version that is only off by point release
1371 Can load version that is only off by point release
1372
1372
1373 $ cat > minversion2.py << EOF
1373 $ cat > minversion2.py << EOF
1374 > from mercurial import util
1374 > from mercurial import util
1375 > util.version = lambda: '3.6.1'
1375 > util.version = lambda: '3.6.1'
1376 > minimumhgversion = '3.6'
1376 > minimumhgversion = '3.6'
1377 > EOF
1377 > EOF
1378 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1378 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1379 [1]
1379 [1]
1380
1380
1381 Can load minimum version identical to current
1381 Can load minimum version identical to current
1382
1382
1383 $ cat > minversion3.py << EOF
1383 $ cat > minversion3.py << EOF
1384 > from mercurial import util
1384 > from mercurial import util
1385 > util.version = lambda: '3.5'
1385 > util.version = lambda: '3.5'
1386 > minimumhgversion = '3.5'
1386 > minimumhgversion = '3.5'
1387 > EOF
1387 > EOF
1388 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1388 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1389 [1]
1389 [1]
1390
1390
1391 Restore HGRCPATH
1391 Restore HGRCPATH
1392
1392
1393 $ HGRCPATH=$ORGHGRCPATH
1393 $ HGRCPATH=$ORGHGRCPATH
1394 $ export HGRCPATH
1394 $ export HGRCPATH
1395
1395
1396 Commands handling multiple repositories at a time should invoke only
1396 Commands handling multiple repositories at a time should invoke only
1397 "reposetup()" of extensions enabling in the target repository.
1397 "reposetup()" of extensions enabling in the target repository.
1398
1398
1399 $ mkdir reposetup-test
1399 $ mkdir reposetup-test
1400 $ cd reposetup-test
1400 $ cd reposetup-test
1401
1401
1402 $ cat > $TESTTMP/reposetuptest.py <<EOF
1402 $ cat > $TESTTMP/reposetuptest.py <<EOF
1403 > from mercurial import extensions
1403 > from mercurial import extensions
1404 > def reposetup(ui, repo):
1404 > def reposetup(ui, repo):
1405 > ui.write('reposetup() for %s\n' % (repo.root))
1405 > ui.write('reposetup() for %s\n' % (repo.root))
1406 > ui.flush()
1406 > ui.flush()
1407 > EOF
1407 > EOF
1408 $ hg init src
1408 $ hg init src
1409 $ echo a > src/a
1409 $ echo a > src/a
1410 $ hg -R src commit -Am '#0 at src/a'
1410 $ hg -R src commit -Am '#0 at src/a'
1411 adding a
1411 adding a
1412 $ echo '[extensions]' >> src/.hg/hgrc
1412 $ echo '[extensions]' >> src/.hg/hgrc
1413 $ echo '# enable extension locally' >> src/.hg/hgrc
1413 $ echo '# enable extension locally' >> src/.hg/hgrc
1414 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1414 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1415 $ hg -R src status
1415 $ hg -R src status
1416 reposetup() for $TESTTMP/reposetup-test/src (glob)
1416 reposetup() for $TESTTMP/reposetup-test/src (glob)
1417
1417
1418 $ hg clone -U src clone-dst1
1418 $ hg clone -U src clone-dst1
1419 reposetup() for $TESTTMP/reposetup-test/src (glob)
1419 reposetup() for $TESTTMP/reposetup-test/src (glob)
1420 $ hg init push-dst1
1420 $ hg init push-dst1
1421 $ hg -q -R src push push-dst1
1421 $ hg -q -R src push push-dst1
1422 reposetup() for $TESTTMP/reposetup-test/src (glob)
1422 reposetup() for $TESTTMP/reposetup-test/src (glob)
1423 $ hg init pull-src1
1423 $ hg init pull-src1
1424 $ hg -q -R pull-src1 pull src
1424 $ hg -q -R pull-src1 pull src
1425 reposetup() for $TESTTMP/reposetup-test/src (glob)
1425 reposetup() for $TESTTMP/reposetup-test/src (glob)
1426
1426
1427 $ cat <<EOF >> $HGRCPATH
1427 $ cat <<EOF >> $HGRCPATH
1428 > [extensions]
1428 > [extensions]
1429 > # disable extension globally and explicitly
1429 > # disable extension globally and explicitly
1430 > reposetuptest = !
1430 > reposetuptest = !
1431 > EOF
1431 > EOF
1432 $ hg clone -U src clone-dst2
1432 $ hg clone -U src clone-dst2
1433 reposetup() for $TESTTMP/reposetup-test/src (glob)
1433 reposetup() for $TESTTMP/reposetup-test/src (glob)
1434 $ hg init push-dst2
1434 $ hg init push-dst2
1435 $ hg -q -R src push push-dst2
1435 $ hg -q -R src push push-dst2
1436 reposetup() for $TESTTMP/reposetup-test/src (glob)
1436 reposetup() for $TESTTMP/reposetup-test/src (glob)
1437 $ hg init pull-src2
1437 $ hg init pull-src2
1438 $ hg -q -R pull-src2 pull src
1438 $ hg -q -R pull-src2 pull src
1439 reposetup() for $TESTTMP/reposetup-test/src (glob)
1439 reposetup() for $TESTTMP/reposetup-test/src (glob)
1440
1440
1441 $ cat <<EOF >> $HGRCPATH
1441 $ cat <<EOF >> $HGRCPATH
1442 > [extensions]
1442 > [extensions]
1443 > # enable extension globally
1443 > # enable extension globally
1444 > reposetuptest = $TESTTMP/reposetuptest.py
1444 > reposetuptest = $TESTTMP/reposetuptest.py
1445 > EOF
1445 > EOF
1446 $ hg clone -U src clone-dst3
1446 $ hg clone -U src clone-dst3
1447 reposetup() for $TESTTMP/reposetup-test/src (glob)
1447 reposetup() for $TESTTMP/reposetup-test/src (glob)
1448 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1448 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1449 $ hg init push-dst3
1449 $ hg init push-dst3
1450 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1450 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1451 $ hg -q -R src push push-dst3
1451 $ hg -q -R src push push-dst3
1452 reposetup() for $TESTTMP/reposetup-test/src (glob)
1452 reposetup() for $TESTTMP/reposetup-test/src (glob)
1453 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1453 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1454 $ hg init pull-src3
1454 $ hg init pull-src3
1455 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1455 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1456 $ hg -q -R pull-src3 pull src
1456 $ hg -q -R pull-src3 pull src
1457 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1457 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1458 reposetup() for $TESTTMP/reposetup-test/src (glob)
1458 reposetup() for $TESTTMP/reposetup-test/src (glob)
1459
1459
1460 $ echo '[extensions]' >> src/.hg/hgrc
1460 $ echo '[extensions]' >> src/.hg/hgrc
1461 $ echo '# disable extension locally' >> src/.hg/hgrc
1461 $ echo '# disable extension locally' >> src/.hg/hgrc
1462 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1462 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1463 $ hg clone -U src clone-dst4
1463 $ hg clone -U src clone-dst4
1464 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1464 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1465 $ hg init push-dst4
1465 $ hg init push-dst4
1466 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1466 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1467 $ hg -q -R src push push-dst4
1467 $ hg -q -R src push push-dst4
1468 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1468 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1469 $ hg init pull-src4
1469 $ hg init pull-src4
1470 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1470 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1471 $ hg -q -R pull-src4 pull src
1471 $ hg -q -R pull-src4 pull src
1472 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1472 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1473
1473
1474 disabling in command line overlays with all configuration
1474 disabling in command line overlays with all configuration
1475 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1475 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1476 $ hg --config extensions.reposetuptest=! init push-dst5
1476 $ hg --config extensions.reposetuptest=! init push-dst5
1477 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1477 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1478 $ hg --config extensions.reposetuptest=! init pull-src5
1478 $ hg --config extensions.reposetuptest=! init pull-src5
1479 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1479 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1480
1480
1481 $ cat <<EOF >> $HGRCPATH
1481 $ cat <<EOF >> $HGRCPATH
1482 > [extensions]
1482 > [extensions]
1483 > # disable extension globally and explicitly
1483 > # disable extension globally and explicitly
1484 > reposetuptest = !
1484 > reposetuptest = !
1485 > EOF
1485 > EOF
1486 $ hg init parent
1486 $ hg init parent
1487 $ hg init parent/sub1
1487 $ hg init parent/sub1
1488 $ echo 1 > parent/sub1/1
1488 $ echo 1 > parent/sub1/1
1489 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1489 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1490 adding 1
1490 adding 1
1491 $ hg init parent/sub2
1491 $ hg init parent/sub2
1492 $ hg init parent/sub2/sub21
1492 $ hg init parent/sub2/sub21
1493 $ echo 21 > parent/sub2/sub21/21
1493 $ echo 21 > parent/sub2/sub21/21
1494 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1494 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1495 adding 21
1495 adding 21
1496 $ cat > parent/sub2/.hgsub <<EOF
1496 $ cat > parent/sub2/.hgsub <<EOF
1497 > sub21 = sub21
1497 > sub21 = sub21
1498 > EOF
1498 > EOF
1499 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1499 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1500 adding .hgsub
1500 adding .hgsub
1501 $ hg init parent/sub3
1501 $ hg init parent/sub3
1502 $ echo 3 > parent/sub3/3
1502 $ echo 3 > parent/sub3/3
1503 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1503 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1504 adding 3
1504 adding 3
1505 $ cat > parent/.hgsub <<EOF
1505 $ cat > parent/.hgsub <<EOF
1506 > sub1 = sub1
1506 > sub1 = sub1
1507 > sub2 = sub2
1507 > sub2 = sub2
1508 > sub3 = sub3
1508 > sub3 = sub3
1509 > EOF
1509 > EOF
1510 $ hg -R parent commit -Am '#0 at parent'
1510 $ hg -R parent commit -Am '#0 at parent'
1511 adding .hgsub
1511 adding .hgsub
1512 $ echo '[extensions]' >> parent/.hg/hgrc
1512 $ echo '[extensions]' >> parent/.hg/hgrc
1513 $ echo '# enable extension locally' >> parent/.hg/hgrc
1513 $ echo '# enable extension locally' >> parent/.hg/hgrc
1514 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1514 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1515 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1515 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1516 $ hg -R parent status -S -A
1516 $ hg -R parent status -S -A
1517 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1517 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1518 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1518 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1519 C .hgsub
1519 C .hgsub
1520 C .hgsubstate
1520 C .hgsubstate
1521 C sub1/1
1521 C sub1/1
1522 C sub2/.hgsub
1522 C sub2/.hgsub
1523 C sub2/.hgsubstate
1523 C sub2/.hgsubstate
1524 C sub2/sub21/21
1524 C sub2/sub21/21
1525 C sub3/3
1525 C sub3/3
1526
1526
1527 $ cd ..
1527 $ cd ..
1528
1528
1529 Test synopsis and docstring extending
1529 Test synopsis and docstring extending
1530
1530
1531 $ hg init exthelp
1531 $ hg init exthelp
1532 $ cat > exthelp.py <<EOF
1532 $ cat > exthelp.py <<EOF
1533 > from mercurial import commands, extensions
1533 > from mercurial import commands, extensions
1534 > def exbookmarks(orig, *args, **opts):
1534 > def exbookmarks(orig, *args, **opts):
1535 > return orig(*args, **opts)
1535 > return orig(*args, **opts)
1536 > def uisetup(ui):
1536 > def uisetup(ui):
1537 > synopsis = ' GREPME [--foo] [-x]'
1537 > synopsis = ' GREPME [--foo] [-x]'
1538 > docstring = '''
1538 > docstring = '''
1539 > GREPME make sure that this is in the help!
1539 > GREPME make sure that this is in the help!
1540 > '''
1540 > '''
1541 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1541 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1542 > synopsis, docstring)
1542 > synopsis, docstring)
1543 > EOF
1543 > EOF
1544 $ abspath=`pwd`/exthelp.py
1544 $ abspath=`pwd`/exthelp.py
1545 $ echo '[extensions]' >> $HGRCPATH
1545 $ echo '[extensions]' >> $HGRCPATH
1546 $ echo "exthelp = $abspath" >> $HGRCPATH
1546 $ echo "exthelp = $abspath" >> $HGRCPATH
1547 $ cd exthelp
1547 $ cd exthelp
1548 $ hg help bookmarks | grep GREPME
1548 $ hg help bookmarks | grep GREPME
1549 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1549 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1550 GREPME make sure that this is in the help!
1550 GREPME make sure that this is in the help!
1551
1551
@@ -1,3216 +1,3215 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge another revision into working directory
17 merge merge another revision into working directory
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use 'hg help' for the full list of commands or 'hg -v' for details)
26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge another revision into working directory
38 merge merge another revision into working directory
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search revision history for a pattern in specified files
72 grep search revision history for a pattern in specified files
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working directory or specified revision
75 identify identify the working directory or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge another revision into working directory
81 merge merge another revision into working directory
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 internals Technical implementation topics
114 internals Technical implementation topics
115 merge-tools Merge Tools
115 merge-tools Merge Tools
116 pager Pager Support
116 pager Pager Support
117 patterns File Name Patterns
117 patterns File Name Patterns
118 phases Working with Phases
118 phases Working with Phases
119 revisions Specifying Revisions
119 revisions Specifying Revisions
120 scripting Using Mercurial from scripts and automation
120 scripting Using Mercurial from scripts and automation
121 subrepos Subrepositories
121 subrepos Subrepositories
122 templating Template Usage
122 templating Template Usage
123 urls URL Paths
123 urls URL Paths
124
124
125 (use 'hg help -v' to show built-in aliases and global options)
125 (use 'hg help -v' to show built-in aliases and global options)
126
126
127 $ hg -q help
127 $ hg -q help
128 add add the specified files on the next commit
128 add add the specified files on the next commit
129 addremove add all new files, delete all missing files
129 addremove add all new files, delete all missing files
130 annotate show changeset information by line for each file
130 annotate show changeset information by line for each file
131 archive create an unversioned archive of a repository revision
131 archive create an unversioned archive of a repository revision
132 backout reverse effect of earlier changeset
132 backout reverse effect of earlier changeset
133 bisect subdivision search of changesets
133 bisect subdivision search of changesets
134 bookmarks create a new bookmark or list existing bookmarks
134 bookmarks create a new bookmark or list existing bookmarks
135 branch set or show the current branch name
135 branch set or show the current branch name
136 branches list repository named branches
136 branches list repository named branches
137 bundle create a changegroup file
137 bundle create a changegroup file
138 cat output the current or given revision of files
138 cat output the current or given revision of files
139 clone make a copy of an existing repository
139 clone make a copy of an existing repository
140 commit commit the specified files or all outstanding changes
140 commit commit the specified files or all outstanding changes
141 config show combined config settings from all hgrc files
141 config show combined config settings from all hgrc files
142 copy mark files as copied for the next commit
142 copy mark files as copied for the next commit
143 diff diff repository (or selected files)
143 diff diff repository (or selected files)
144 export dump the header and diffs for one or more changesets
144 export dump the header and diffs for one or more changesets
145 files list tracked files
145 files list tracked files
146 forget forget the specified files on the next commit
146 forget forget the specified files on the next commit
147 graft copy changes from other branches onto the current branch
147 graft copy changes from other branches onto the current branch
148 grep search revision history for a pattern in specified files
148 grep search revision history for a pattern in specified files
149 heads show branch heads
149 heads show branch heads
150 help show help for a given topic or a help overview
150 help show help for a given topic or a help overview
151 identify identify the working directory or specified revision
151 identify identify the working directory or specified revision
152 import import an ordered set of patches
152 import import an ordered set of patches
153 incoming show new changesets found in source
153 incoming show new changesets found in source
154 init create a new repository in the given directory
154 init create a new repository in the given directory
155 log show revision history of entire repository or files
155 log show revision history of entire repository or files
156 manifest output the current or given revision of the project manifest
156 manifest output the current or given revision of the project manifest
157 merge merge another revision into working directory
157 merge merge another revision into working directory
158 outgoing show changesets not found in the destination
158 outgoing show changesets not found in the destination
159 paths show aliases for remote repositories
159 paths show aliases for remote repositories
160 phase set or show the current phase name
160 phase set or show the current phase name
161 pull pull changes from the specified source
161 pull pull changes from the specified source
162 push push changes to the specified destination
162 push push changes to the specified destination
163 recover roll back an interrupted transaction
163 recover roll back an interrupted transaction
164 remove remove the specified files on the next commit
164 remove remove the specified files on the next commit
165 rename rename files; equivalent of copy + remove
165 rename rename files; equivalent of copy + remove
166 resolve redo merges or set/view the merge status of files
166 resolve redo merges or set/view the merge status of files
167 revert restore files to their checkout state
167 revert restore files to their checkout state
168 root print the root (top) of the current working directory
168 root print the root (top) of the current working directory
169 serve start stand-alone webserver
169 serve start stand-alone webserver
170 status show changed files in the working directory
170 status show changed files in the working directory
171 summary summarize working directory state
171 summary summarize working directory state
172 tag add one or more tags for the current or given revision
172 tag add one or more tags for the current or given revision
173 tags list repository tags
173 tags list repository tags
174 unbundle apply one or more changegroup files
174 unbundle apply one or more changegroup files
175 update update working directory (or switch revisions)
175 update update working directory (or switch revisions)
176 verify verify the integrity of the repository
176 verify verify the integrity of the repository
177 version output version and copyright information
177 version output version and copyright information
178
178
179 additional help topics:
179 additional help topics:
180
180
181 config Configuration Files
181 config Configuration Files
182 dates Date Formats
182 dates Date Formats
183 diffs Diff Formats
183 diffs Diff Formats
184 environment Environment Variables
184 environment Environment Variables
185 extensions Using Additional Features
185 extensions Using Additional Features
186 filesets Specifying File Sets
186 filesets Specifying File Sets
187 glossary Glossary
187 glossary Glossary
188 hgignore Syntax for Mercurial Ignore Files
188 hgignore Syntax for Mercurial Ignore Files
189 hgweb Configuring hgweb
189 hgweb Configuring hgweb
190 internals Technical implementation topics
190 internals Technical implementation topics
191 merge-tools Merge Tools
191 merge-tools Merge Tools
192 pager Pager Support
192 pager Pager Support
193 patterns File Name Patterns
193 patterns File Name Patterns
194 phases Working with Phases
194 phases Working with Phases
195 revisions Specifying Revisions
195 revisions Specifying Revisions
196 scripting Using Mercurial from scripts and automation
196 scripting Using Mercurial from scripts and automation
197 subrepos Subrepositories
197 subrepos Subrepositories
198 templating Template Usage
198 templating Template Usage
199 urls URL Paths
199 urls URL Paths
200
200
201 Test extension help:
201 Test extension help:
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 Using Additional Features
203 Using Additional Features
204 """""""""""""""""""""""""
204 """""""""""""""""""""""""
205
205
206 Mercurial has the ability to add new features through the use of
206 Mercurial has the ability to add new features through the use of
207 extensions. Extensions may add new commands, add options to existing
207 extensions. Extensions may add new commands, add options to existing
208 commands, change the default behavior of commands, or implement hooks.
208 commands, change the default behavior of commands, or implement hooks.
209
209
210 To enable the "foo" extension, either shipped with Mercurial or in the
210 To enable the "foo" extension, either shipped with Mercurial or in the
211 Python search path, create an entry for it in your configuration file,
211 Python search path, create an entry for it in your configuration file,
212 like this:
212 like this:
213
213
214 [extensions]
214 [extensions]
215 foo =
215 foo =
216
216
217 You may also specify the full path to an extension:
217 You may also specify the full path to an extension:
218
218
219 [extensions]
219 [extensions]
220 myfeature = ~/.hgext/myfeature.py
220 myfeature = ~/.hgext/myfeature.py
221
221
222 See 'hg help config' for more information on configuration files.
222 See 'hg help config' for more information on configuration files.
223
223
224 Extensions are not loaded by default for a variety of reasons: they can
224 Extensions are not loaded by default for a variety of reasons: they can
225 increase startup overhead; they may be meant for advanced usage only; they
225 increase startup overhead; they may be meant for advanced usage only; they
226 may provide potentially dangerous abilities (such as letting you destroy
226 may provide potentially dangerous abilities (such as letting you destroy
227 or modify history); they might not be ready for prime time; or they may
227 or modify history); they might not be ready for prime time; or they may
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 to activate extensions as needed.
229 to activate extensions as needed.
230
230
231 To explicitly disable an extension enabled in a configuration file of
231 To explicitly disable an extension enabled in a configuration file of
232 broader scope, prepend its path with !:
232 broader scope, prepend its path with !:
233
233
234 [extensions]
234 [extensions]
235 # disabling extension bar residing in /path/to/extension/bar.py
235 # disabling extension bar residing in /path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
237 # ditto, but no path was supplied for extension baz
237 # ditto, but no path was supplied for extension baz
238 baz = !
238 baz = !
239
239
240 enabled extensions:
240 enabled extensions:
241
241
242 children command to display child changesets (DEPRECATED)
242 children command to display child changesets (DEPRECATED)
243 rebase command to move sets of revisions to a different ancestor
243 rebase command to move sets of revisions to a different ancestor
244
244
245 disabled extensions:
245 disabled extensions:
246
246
247 acl hooks for controlling repository access
247 acl hooks for controlling repository access
248 blackbox log repository events to a blackbox for debugging
248 blackbox log repository events to a blackbox for debugging
249 bugzilla hooks for integrating with the Bugzilla bug tracker
249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 censor erase file content at a given revision
250 censor erase file content at a given revision
251 churn command to display statistics about repository history
251 churn command to display statistics about repository history
252 clonebundles advertise pre-generated bundles to seed clones
252 clonebundles advertise pre-generated bundles to seed clones
253 color colorize output from some commands
254 convert import revisions from foreign VCS repositories into
253 convert import revisions from foreign VCS repositories into
255 Mercurial
254 Mercurial
256 eol automatically manage newlines in repository files
255 eol automatically manage newlines in repository files
257 extdiff command to allow external programs to compare revisions
256 extdiff command to allow external programs to compare revisions
258 factotum http authentication with factotum
257 factotum http authentication with factotum
259 gpg commands to sign and verify changesets
258 gpg commands to sign and verify changesets
260 hgk browse the repository in a graphical way
259 hgk browse the repository in a graphical way
261 highlight syntax highlighting for hgweb (requires Pygments)
260 highlight syntax highlighting for hgweb (requires Pygments)
262 histedit interactive history editing
261 histedit interactive history editing
263 keyword expand keywords in tracked files
262 keyword expand keywords in tracked files
264 largefiles track large binary files
263 largefiles track large binary files
265 mq manage a stack of patches
264 mq manage a stack of patches
266 notify hooks for sending email push notifications
265 notify hooks for sending email push notifications
267 patchbomb command to send changesets as (a series of) patch emails
266 patchbomb command to send changesets as (a series of) patch emails
268 purge command to delete untracked files from the working
267 purge command to delete untracked files from the working
269 directory
268 directory
270 relink recreates hardlinks between repository clones
269 relink recreates hardlinks between repository clones
271 schemes extend schemes with shortcuts to repository swarms
270 schemes extend schemes with shortcuts to repository swarms
272 share share a common history between several working directories
271 share share a common history between several working directories
273 shelve save and restore changes to the working directory
272 shelve save and restore changes to the working directory
274 strip strip changesets and their descendants from history
273 strip strip changesets and their descendants from history
275 transplant command to transplant changesets from another branch
274 transplant command to transplant changesets from another branch
276 win32mbcs allow the use of MBCS paths with problematic encodings
275 win32mbcs allow the use of MBCS paths with problematic encodings
277 zeroconf discover and advertise repositories on the local network
276 zeroconf discover and advertise repositories on the local network
278
277
279 Verify that extension keywords appear in help templates
278 Verify that extension keywords appear in help templates
280
279
281 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
280 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
282
281
283 Test short command list with verbose option
282 Test short command list with verbose option
284
283
285 $ hg -v help shortlist
284 $ hg -v help shortlist
286 Mercurial Distributed SCM
285 Mercurial Distributed SCM
287
286
288 basic commands:
287 basic commands:
289
288
290 add add the specified files on the next commit
289 add add the specified files on the next commit
291 annotate, blame
290 annotate, blame
292 show changeset information by line for each file
291 show changeset information by line for each file
293 clone make a copy of an existing repository
292 clone make a copy of an existing repository
294 commit, ci commit the specified files or all outstanding changes
293 commit, ci commit the specified files or all outstanding changes
295 diff diff repository (or selected files)
294 diff diff repository (or selected files)
296 export dump the header and diffs for one or more changesets
295 export dump the header and diffs for one or more changesets
297 forget forget the specified files on the next commit
296 forget forget the specified files on the next commit
298 init create a new repository in the given directory
297 init create a new repository in the given directory
299 log, history show revision history of entire repository or files
298 log, history show revision history of entire repository or files
300 merge merge another revision into working directory
299 merge merge another revision into working directory
301 pull pull changes from the specified source
300 pull pull changes from the specified source
302 push push changes to the specified destination
301 push push changes to the specified destination
303 remove, rm remove the specified files on the next commit
302 remove, rm remove the specified files on the next commit
304 serve start stand-alone webserver
303 serve start stand-alone webserver
305 status, st show changed files in the working directory
304 status, st show changed files in the working directory
306 summary, sum summarize working directory state
305 summary, sum summarize working directory state
307 update, up, checkout, co
306 update, up, checkout, co
308 update working directory (or switch revisions)
307 update working directory (or switch revisions)
309
308
310 global options ([+] can be repeated):
309 global options ([+] can be repeated):
311
310
312 -R --repository REPO repository root directory or name of overlay bundle
311 -R --repository REPO repository root directory or name of overlay bundle
313 file
312 file
314 --cwd DIR change working directory
313 --cwd DIR change working directory
315 -y --noninteractive do not prompt, automatically pick the first choice for
314 -y --noninteractive do not prompt, automatically pick the first choice for
316 all prompts
315 all prompts
317 -q --quiet suppress output
316 -q --quiet suppress output
318 -v --verbose enable additional output
317 -v --verbose enable additional output
319 --color TYPE when to colorize (boolean, always, auto, never, or
318 --color TYPE when to colorize (boolean, always, auto, never, or
320 debug) (EXPERIMENTAL)
319 debug)
321 --config CONFIG [+] set/override config option (use 'section.name=value')
320 --config CONFIG [+] set/override config option (use 'section.name=value')
322 --debug enable debugging output
321 --debug enable debugging output
323 --debugger start debugger
322 --debugger start debugger
324 --encoding ENCODE set the charset encoding (default: ascii)
323 --encoding ENCODE set the charset encoding (default: ascii)
325 --encodingmode MODE set the charset encoding mode (default: strict)
324 --encodingmode MODE set the charset encoding mode (default: strict)
326 --traceback always print a traceback on exception
325 --traceback always print a traceback on exception
327 --time time how long the command takes
326 --time time how long the command takes
328 --profile print command execution profile
327 --profile print command execution profile
329 --version output version information and exit
328 --version output version information and exit
330 -h --help display help and exit
329 -h --help display help and exit
331 --hidden consider hidden changesets
330 --hidden consider hidden changesets
332 --pager TYPE when to paginate (boolean, always, auto, or never)
331 --pager TYPE when to paginate (boolean, always, auto, or never)
333 (default: auto)
332 (default: auto)
334
333
335 (use 'hg help' for the full list of commands)
334 (use 'hg help' for the full list of commands)
336
335
337 $ hg add -h
336 $ hg add -h
338 hg add [OPTION]... [FILE]...
337 hg add [OPTION]... [FILE]...
339
338
340 add the specified files on the next commit
339 add the specified files on the next commit
341
340
342 Schedule files to be version controlled and added to the repository.
341 Schedule files to be version controlled and added to the repository.
343
342
344 The files will be added to the repository at the next commit. To undo an
343 The files will be added to the repository at the next commit. To undo an
345 add before that, see 'hg forget'.
344 add before that, see 'hg forget'.
346
345
347 If no names are given, add all files to the repository (except files
346 If no names are given, add all files to the repository (except files
348 matching ".hgignore").
347 matching ".hgignore").
349
348
350 Returns 0 if all files are successfully added.
349 Returns 0 if all files are successfully added.
351
350
352 options ([+] can be repeated):
351 options ([+] can be repeated):
353
352
354 -I --include PATTERN [+] include names matching the given patterns
353 -I --include PATTERN [+] include names matching the given patterns
355 -X --exclude PATTERN [+] exclude names matching the given patterns
354 -X --exclude PATTERN [+] exclude names matching the given patterns
356 -S --subrepos recurse into subrepositories
355 -S --subrepos recurse into subrepositories
357 -n --dry-run do not perform actions, just print output
356 -n --dry-run do not perform actions, just print output
358
357
359 (some details hidden, use --verbose to show complete help)
358 (some details hidden, use --verbose to show complete help)
360
359
361 Verbose help for add
360 Verbose help for add
362
361
363 $ hg add -hv
362 $ hg add -hv
364 hg add [OPTION]... [FILE]...
363 hg add [OPTION]... [FILE]...
365
364
366 add the specified files on the next commit
365 add the specified files on the next commit
367
366
368 Schedule files to be version controlled and added to the repository.
367 Schedule files to be version controlled and added to the repository.
369
368
370 The files will be added to the repository at the next commit. To undo an
369 The files will be added to the repository at the next commit. To undo an
371 add before that, see 'hg forget'.
370 add before that, see 'hg forget'.
372
371
373 If no names are given, add all files to the repository (except files
372 If no names are given, add all files to the repository (except files
374 matching ".hgignore").
373 matching ".hgignore").
375
374
376 Examples:
375 Examples:
377
376
378 - New (unknown) files are added automatically by 'hg add':
377 - New (unknown) files are added automatically by 'hg add':
379
378
380 $ ls
379 $ ls
381 foo.c
380 foo.c
382 $ hg status
381 $ hg status
383 ? foo.c
382 ? foo.c
384 $ hg add
383 $ hg add
385 adding foo.c
384 adding foo.c
386 $ hg status
385 $ hg status
387 A foo.c
386 A foo.c
388
387
389 - Specific files to be added can be specified:
388 - Specific files to be added can be specified:
390
389
391 $ ls
390 $ ls
392 bar.c foo.c
391 bar.c foo.c
393 $ hg status
392 $ hg status
394 ? bar.c
393 ? bar.c
395 ? foo.c
394 ? foo.c
396 $ hg add bar.c
395 $ hg add bar.c
397 $ hg status
396 $ hg status
398 A bar.c
397 A bar.c
399 ? foo.c
398 ? foo.c
400
399
401 Returns 0 if all files are successfully added.
400 Returns 0 if all files are successfully added.
402
401
403 options ([+] can be repeated):
402 options ([+] can be repeated):
404
403
405 -I --include PATTERN [+] include names matching the given patterns
404 -I --include PATTERN [+] include names matching the given patterns
406 -X --exclude PATTERN [+] exclude names matching the given patterns
405 -X --exclude PATTERN [+] exclude names matching the given patterns
407 -S --subrepos recurse into subrepositories
406 -S --subrepos recurse into subrepositories
408 -n --dry-run do not perform actions, just print output
407 -n --dry-run do not perform actions, just print output
409
408
410 global options ([+] can be repeated):
409 global options ([+] can be repeated):
411
410
412 -R --repository REPO repository root directory or name of overlay bundle
411 -R --repository REPO repository root directory or name of overlay bundle
413 file
412 file
414 --cwd DIR change working directory
413 --cwd DIR change working directory
415 -y --noninteractive do not prompt, automatically pick the first choice for
414 -y --noninteractive do not prompt, automatically pick the first choice for
416 all prompts
415 all prompts
417 -q --quiet suppress output
416 -q --quiet suppress output
418 -v --verbose enable additional output
417 -v --verbose enable additional output
419 --color TYPE when to colorize (boolean, always, auto, never, or
418 --color TYPE when to colorize (boolean, always, auto, never, or
420 debug) (EXPERIMENTAL)
419 debug)
421 --config CONFIG [+] set/override config option (use 'section.name=value')
420 --config CONFIG [+] set/override config option (use 'section.name=value')
422 --debug enable debugging output
421 --debug enable debugging output
423 --debugger start debugger
422 --debugger start debugger
424 --encoding ENCODE set the charset encoding (default: ascii)
423 --encoding ENCODE set the charset encoding (default: ascii)
425 --encodingmode MODE set the charset encoding mode (default: strict)
424 --encodingmode MODE set the charset encoding mode (default: strict)
426 --traceback always print a traceback on exception
425 --traceback always print a traceback on exception
427 --time time how long the command takes
426 --time time how long the command takes
428 --profile print command execution profile
427 --profile print command execution profile
429 --version output version information and exit
428 --version output version information and exit
430 -h --help display help and exit
429 -h --help display help and exit
431 --hidden consider hidden changesets
430 --hidden consider hidden changesets
432 --pager TYPE when to paginate (boolean, always, auto, or never)
431 --pager TYPE when to paginate (boolean, always, auto, or never)
433 (default: auto)
432 (default: auto)
434
433
435 Test the textwidth config option
434 Test the textwidth config option
436
435
437 $ hg root -h --config ui.textwidth=50
436 $ hg root -h --config ui.textwidth=50
438 hg root
437 hg root
439
438
440 print the root (top) of the current working
439 print the root (top) of the current working
441 directory
440 directory
442
441
443 Print the root directory of the current
442 Print the root directory of the current
444 repository.
443 repository.
445
444
446 Returns 0 on success.
445 Returns 0 on success.
447
446
448 (some details hidden, use --verbose to show
447 (some details hidden, use --verbose to show
449 complete help)
448 complete help)
450
449
451 Test help option with version option
450 Test help option with version option
452
451
453 $ hg add -h --version
452 $ hg add -h --version
454 Mercurial Distributed SCM (version *) (glob)
453 Mercurial Distributed SCM (version *) (glob)
455 (see https://mercurial-scm.org for more information)
454 (see https://mercurial-scm.org for more information)
456
455
457 Copyright (C) 2005-* Matt Mackall and others (glob)
456 Copyright (C) 2005-* Matt Mackall and others (glob)
458 This is free software; see the source for copying conditions. There is NO
457 This is free software; see the source for copying conditions. There is NO
459 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
458 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
460
459
461 $ hg add --skjdfks
460 $ hg add --skjdfks
462 hg add: option --skjdfks not recognized
461 hg add: option --skjdfks not recognized
463 hg add [OPTION]... [FILE]...
462 hg add [OPTION]... [FILE]...
464
463
465 add the specified files on the next commit
464 add the specified files on the next commit
466
465
467 options ([+] can be repeated):
466 options ([+] can be repeated):
468
467
469 -I --include PATTERN [+] include names matching the given patterns
468 -I --include PATTERN [+] include names matching the given patterns
470 -X --exclude PATTERN [+] exclude names matching the given patterns
469 -X --exclude PATTERN [+] exclude names matching the given patterns
471 -S --subrepos recurse into subrepositories
470 -S --subrepos recurse into subrepositories
472 -n --dry-run do not perform actions, just print output
471 -n --dry-run do not perform actions, just print output
473
472
474 (use 'hg add -h' to show more help)
473 (use 'hg add -h' to show more help)
475 [255]
474 [255]
476
475
477 Test ambiguous command help
476 Test ambiguous command help
478
477
479 $ hg help ad
478 $ hg help ad
480 list of commands:
479 list of commands:
481
480
482 add add the specified files on the next commit
481 add add the specified files on the next commit
483 addremove add all new files, delete all missing files
482 addremove add all new files, delete all missing files
484
483
485 (use 'hg help -v ad' to show built-in aliases and global options)
484 (use 'hg help -v ad' to show built-in aliases and global options)
486
485
487 Test command without options
486 Test command without options
488
487
489 $ hg help verify
488 $ hg help verify
490 hg verify
489 hg verify
491
490
492 verify the integrity of the repository
491 verify the integrity of the repository
493
492
494 Verify the integrity of the current repository.
493 Verify the integrity of the current repository.
495
494
496 This will perform an extensive check of the repository's integrity,
495 This will perform an extensive check of the repository's integrity,
497 validating the hashes and checksums of each entry in the changelog,
496 validating the hashes and checksums of each entry in the changelog,
498 manifest, and tracked files, as well as the integrity of their crosslinks
497 manifest, and tracked files, as well as the integrity of their crosslinks
499 and indices.
498 and indices.
500
499
501 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
500 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
502 information about recovery from corruption of the repository.
501 information about recovery from corruption of the repository.
503
502
504 Returns 0 on success, 1 if errors are encountered.
503 Returns 0 on success, 1 if errors are encountered.
505
504
506 (some details hidden, use --verbose to show complete help)
505 (some details hidden, use --verbose to show complete help)
507
506
508 $ hg help diff
507 $ hg help diff
509 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
508 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
510
509
511 diff repository (or selected files)
510 diff repository (or selected files)
512
511
513 Show differences between revisions for the specified files.
512 Show differences between revisions for the specified files.
514
513
515 Differences between files are shown using the unified diff format.
514 Differences between files are shown using the unified diff format.
516
515
517 Note:
516 Note:
518 'hg diff' may generate unexpected results for merges, as it will
517 'hg diff' may generate unexpected results for merges, as it will
519 default to comparing against the working directory's first parent
518 default to comparing against the working directory's first parent
520 changeset if no revisions are specified.
519 changeset if no revisions are specified.
521
520
522 When two revision arguments are given, then changes are shown between
521 When two revision arguments are given, then changes are shown between
523 those revisions. If only one revision is specified then that revision is
522 those revisions. If only one revision is specified then that revision is
524 compared to the working directory, and, when no revisions are specified,
523 compared to the working directory, and, when no revisions are specified,
525 the working directory files are compared to its first parent.
524 the working directory files are compared to its first parent.
526
525
527 Alternatively you can specify -c/--change with a revision to see the
526 Alternatively you can specify -c/--change with a revision to see the
528 changes in that changeset relative to its first parent.
527 changes in that changeset relative to its first parent.
529
528
530 Without the -a/--text option, diff will avoid generating diffs of files it
529 Without the -a/--text option, diff will avoid generating diffs of files it
531 detects as binary. With -a, diff will generate a diff anyway, probably
530 detects as binary. With -a, diff will generate a diff anyway, probably
532 with undesirable results.
531 with undesirable results.
533
532
534 Use the -g/--git option to generate diffs in the git extended diff format.
533 Use the -g/--git option to generate diffs in the git extended diff format.
535 For more information, read 'hg help diffs'.
534 For more information, read 'hg help diffs'.
536
535
537 Returns 0 on success.
536 Returns 0 on success.
538
537
539 options ([+] can be repeated):
538 options ([+] can be repeated):
540
539
541 -r --rev REV [+] revision
540 -r --rev REV [+] revision
542 -c --change REV change made by revision
541 -c --change REV change made by revision
543 -a --text treat all files as text
542 -a --text treat all files as text
544 -g --git use git extended diff format
543 -g --git use git extended diff format
545 --nodates omit dates from diff headers
544 --nodates omit dates from diff headers
546 --noprefix omit a/ and b/ prefixes from filenames
545 --noprefix omit a/ and b/ prefixes from filenames
547 -p --show-function show which function each change is in
546 -p --show-function show which function each change is in
548 --reverse produce a diff that undoes the changes
547 --reverse produce a diff that undoes the changes
549 -w --ignore-all-space ignore white space when comparing lines
548 -w --ignore-all-space ignore white space when comparing lines
550 -b --ignore-space-change ignore changes in the amount of white space
549 -b --ignore-space-change ignore changes in the amount of white space
551 -B --ignore-blank-lines ignore changes whose lines are all blank
550 -B --ignore-blank-lines ignore changes whose lines are all blank
552 -U --unified NUM number of lines of context to show
551 -U --unified NUM number of lines of context to show
553 --stat output diffstat-style summary of changes
552 --stat output diffstat-style summary of changes
554 --root DIR produce diffs relative to subdirectory
553 --root DIR produce diffs relative to subdirectory
555 -I --include PATTERN [+] include names matching the given patterns
554 -I --include PATTERN [+] include names matching the given patterns
556 -X --exclude PATTERN [+] exclude names matching the given patterns
555 -X --exclude PATTERN [+] exclude names matching the given patterns
557 -S --subrepos recurse into subrepositories
556 -S --subrepos recurse into subrepositories
558
557
559 (some details hidden, use --verbose to show complete help)
558 (some details hidden, use --verbose to show complete help)
560
559
561 $ hg help status
560 $ hg help status
562 hg status [OPTION]... [FILE]...
561 hg status [OPTION]... [FILE]...
563
562
564 aliases: st
563 aliases: st
565
564
566 show changed files in the working directory
565 show changed files in the working directory
567
566
568 Show status of files in the repository. If names are given, only files
567 Show status of files in the repository. If names are given, only files
569 that match are shown. Files that are clean or ignored or the source of a
568 that match are shown. Files that are clean or ignored or the source of a
570 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
569 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
571 -C/--copies or -A/--all are given. Unless options described with "show
570 -C/--copies or -A/--all are given. Unless options described with "show
572 only ..." are given, the options -mardu are used.
571 only ..." are given, the options -mardu are used.
573
572
574 Option -q/--quiet hides untracked (unknown and ignored) files unless
573 Option -q/--quiet hides untracked (unknown and ignored) files unless
575 explicitly requested with -u/--unknown or -i/--ignored.
574 explicitly requested with -u/--unknown or -i/--ignored.
576
575
577 Note:
576 Note:
578 'hg status' may appear to disagree with diff if permissions have
577 'hg status' may appear to disagree with diff if permissions have
579 changed or a merge has occurred. The standard diff format does not
578 changed or a merge has occurred. The standard diff format does not
580 report permission changes and diff only reports changes relative to one
579 report permission changes and diff only reports changes relative to one
581 merge parent.
580 merge parent.
582
581
583 If one revision is given, it is used as the base revision. If two
582 If one revision is given, it is used as the base revision. If two
584 revisions are given, the differences between them are shown. The --change
583 revisions are given, the differences between them are shown. The --change
585 option can also be used as a shortcut to list the changed files of a
584 option can also be used as a shortcut to list the changed files of a
586 revision from its first parent.
585 revision from its first parent.
587
586
588 The codes used to show the status of files are:
587 The codes used to show the status of files are:
589
588
590 M = modified
589 M = modified
591 A = added
590 A = added
592 R = removed
591 R = removed
593 C = clean
592 C = clean
594 ! = missing (deleted by non-hg command, but still tracked)
593 ! = missing (deleted by non-hg command, but still tracked)
595 ? = not tracked
594 ? = not tracked
596 I = ignored
595 I = ignored
597 = origin of the previous file (with --copies)
596 = origin of the previous file (with --copies)
598
597
599 Returns 0 on success.
598 Returns 0 on success.
600
599
601 options ([+] can be repeated):
600 options ([+] can be repeated):
602
601
603 -A --all show status of all files
602 -A --all show status of all files
604 -m --modified show only modified files
603 -m --modified show only modified files
605 -a --added show only added files
604 -a --added show only added files
606 -r --removed show only removed files
605 -r --removed show only removed files
607 -d --deleted show only deleted (but tracked) files
606 -d --deleted show only deleted (but tracked) files
608 -c --clean show only files without changes
607 -c --clean show only files without changes
609 -u --unknown show only unknown (not tracked) files
608 -u --unknown show only unknown (not tracked) files
610 -i --ignored show only ignored files
609 -i --ignored show only ignored files
611 -n --no-status hide status prefix
610 -n --no-status hide status prefix
612 -C --copies show source of copied files
611 -C --copies show source of copied files
613 -0 --print0 end filenames with NUL, for use with xargs
612 -0 --print0 end filenames with NUL, for use with xargs
614 --rev REV [+] show difference from revision
613 --rev REV [+] show difference from revision
615 --change REV list the changed files of a revision
614 --change REV list the changed files of a revision
616 -I --include PATTERN [+] include names matching the given patterns
615 -I --include PATTERN [+] include names matching the given patterns
617 -X --exclude PATTERN [+] exclude names matching the given patterns
616 -X --exclude PATTERN [+] exclude names matching the given patterns
618 -S --subrepos recurse into subrepositories
617 -S --subrepos recurse into subrepositories
619
618
620 (some details hidden, use --verbose to show complete help)
619 (some details hidden, use --verbose to show complete help)
621
620
622 $ hg -q help status
621 $ hg -q help status
623 hg status [OPTION]... [FILE]...
622 hg status [OPTION]... [FILE]...
624
623
625 show changed files in the working directory
624 show changed files in the working directory
626
625
627 $ hg help foo
626 $ hg help foo
628 abort: no such help topic: foo
627 abort: no such help topic: foo
629 (try 'hg help --keyword foo')
628 (try 'hg help --keyword foo')
630 [255]
629 [255]
631
630
632 $ hg skjdfks
631 $ hg skjdfks
633 hg: unknown command 'skjdfks'
632 hg: unknown command 'skjdfks'
634 Mercurial Distributed SCM
633 Mercurial Distributed SCM
635
634
636 basic commands:
635 basic commands:
637
636
638 add add the specified files on the next commit
637 add add the specified files on the next commit
639 annotate show changeset information by line for each file
638 annotate show changeset information by line for each file
640 clone make a copy of an existing repository
639 clone make a copy of an existing repository
641 commit commit the specified files or all outstanding changes
640 commit commit the specified files or all outstanding changes
642 diff diff repository (or selected files)
641 diff diff repository (or selected files)
643 export dump the header and diffs for one or more changesets
642 export dump the header and diffs for one or more changesets
644 forget forget the specified files on the next commit
643 forget forget the specified files on the next commit
645 init create a new repository in the given directory
644 init create a new repository in the given directory
646 log show revision history of entire repository or files
645 log show revision history of entire repository or files
647 merge merge another revision into working directory
646 merge merge another revision into working directory
648 pull pull changes from the specified source
647 pull pull changes from the specified source
649 push push changes to the specified destination
648 push push changes to the specified destination
650 remove remove the specified files on the next commit
649 remove remove the specified files on the next commit
651 serve start stand-alone webserver
650 serve start stand-alone webserver
652 status show changed files in the working directory
651 status show changed files in the working directory
653 summary summarize working directory state
652 summary summarize working directory state
654 update update working directory (or switch revisions)
653 update update working directory (or switch revisions)
655
654
656 (use 'hg help' for the full list of commands or 'hg -v' for details)
655 (use 'hg help' for the full list of commands or 'hg -v' for details)
657 [255]
656 [255]
658
657
659
658
660 Make sure that we don't run afoul of the help system thinking that
659 Make sure that we don't run afoul of the help system thinking that
661 this is a section and erroring out weirdly.
660 this is a section and erroring out weirdly.
662
661
663 $ hg .log
662 $ hg .log
664 hg: unknown command '.log'
663 hg: unknown command '.log'
665 (did you mean log?)
664 (did you mean log?)
666 [255]
665 [255]
667
666
668 $ hg log.
667 $ hg log.
669 hg: unknown command 'log.'
668 hg: unknown command 'log.'
670 (did you mean log?)
669 (did you mean log?)
671 [255]
670 [255]
672 $ hg pu.lh
671 $ hg pu.lh
673 hg: unknown command 'pu.lh'
672 hg: unknown command 'pu.lh'
674 (did you mean one of pull, push?)
673 (did you mean one of pull, push?)
675 [255]
674 [255]
676
675
677 $ cat > helpext.py <<EOF
676 $ cat > helpext.py <<EOF
678 > import os
677 > import os
679 > from mercurial import cmdutil, commands
678 > from mercurial import cmdutil, commands
680 >
679 >
681 > cmdtable = {}
680 > cmdtable = {}
682 > command = cmdutil.command(cmdtable)
681 > command = cmdutil.command(cmdtable)
683 >
682 >
684 > @command('nohelp',
683 > @command('nohelp',
685 > [('', 'longdesc', 3, 'x'*90),
684 > [('', 'longdesc', 3, 'x'*90),
686 > ('n', '', None, 'normal desc'),
685 > ('n', '', None, 'normal desc'),
687 > ('', 'newline', '', 'line1\nline2')],
686 > ('', 'newline', '', 'line1\nline2')],
688 > 'hg nohelp',
687 > 'hg nohelp',
689 > norepo=True)
688 > norepo=True)
690 > @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
689 > @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
691 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
690 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
692 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
691 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
693 > def nohelp(ui, *args, **kwargs):
692 > def nohelp(ui, *args, **kwargs):
694 > pass
693 > pass
695 >
694 >
696 > def uisetup(ui):
695 > def uisetup(ui):
697 > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext')
696 > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext')
698 > ui.setconfig('alias', 'hgalias', 'summary', 'helpext')
697 > ui.setconfig('alias', 'hgalias', 'summary', 'helpext')
699 >
698 >
700 > EOF
699 > EOF
701 $ echo '[extensions]' >> $HGRCPATH
700 $ echo '[extensions]' >> $HGRCPATH
702 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
701 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
703
702
704 Test for aliases
703 Test for aliases
705
704
706 $ hg help hgalias
705 $ hg help hgalias
707 hg hgalias [--remote]
706 hg hgalias [--remote]
708
707
709 alias for: hg summary
708 alias for: hg summary
710
709
711 summarize working directory state
710 summarize working directory state
712
711
713 This generates a brief summary of the working directory state, including
712 This generates a brief summary of the working directory state, including
714 parents, branch, commit status, phase and available updates.
713 parents, branch, commit status, phase and available updates.
715
714
716 With the --remote option, this will check the default paths for incoming
715 With the --remote option, this will check the default paths for incoming
717 and outgoing changes. This can be time-consuming.
716 and outgoing changes. This can be time-consuming.
718
717
719 Returns 0 on success.
718 Returns 0 on success.
720
719
721 defined by: helpext
720 defined by: helpext
722
721
723 options:
722 options:
724
723
725 --remote check for push and pull
724 --remote check for push and pull
726
725
727 (some details hidden, use --verbose to show complete help)
726 (some details hidden, use --verbose to show complete help)
728
727
729 $ hg help shellalias
728 $ hg help shellalias
730 hg shellalias
729 hg shellalias
731
730
732 shell alias for:
731 shell alias for:
733
732
734 echo hi
733 echo hi
735
734
736 defined by: helpext
735 defined by: helpext
737
736
738 (some details hidden, use --verbose to show complete help)
737 (some details hidden, use --verbose to show complete help)
739
738
740 Test command with no help text
739 Test command with no help text
741
740
742 $ hg help nohelp
741 $ hg help nohelp
743 hg nohelp
742 hg nohelp
744
743
745 (no help text available)
744 (no help text available)
746
745
747 options:
746 options:
748
747
749 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
748 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
750 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
749 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
751 -n -- normal desc
750 -n -- normal desc
752 --newline VALUE line1 line2
751 --newline VALUE line1 line2
753
752
754 (some details hidden, use --verbose to show complete help)
753 (some details hidden, use --verbose to show complete help)
755
754
756 $ hg help -k nohelp
755 $ hg help -k nohelp
757 Commands:
756 Commands:
758
757
759 nohelp hg nohelp
758 nohelp hg nohelp
760
759
761 Extension Commands:
760 Extension Commands:
762
761
763 nohelp (no help text available)
762 nohelp (no help text available)
764
763
765 Test that default list of commands omits extension commands
764 Test that default list of commands omits extension commands
766
765
767 $ hg help
766 $ hg help
768 Mercurial Distributed SCM
767 Mercurial Distributed SCM
769
768
770 list of commands:
769 list of commands:
771
770
772 add add the specified files on the next commit
771 add add the specified files on the next commit
773 addremove add all new files, delete all missing files
772 addremove add all new files, delete all missing files
774 annotate show changeset information by line for each file
773 annotate show changeset information by line for each file
775 archive create an unversioned archive of a repository revision
774 archive create an unversioned archive of a repository revision
776 backout reverse effect of earlier changeset
775 backout reverse effect of earlier changeset
777 bisect subdivision search of changesets
776 bisect subdivision search of changesets
778 bookmarks create a new bookmark or list existing bookmarks
777 bookmarks create a new bookmark or list existing bookmarks
779 branch set or show the current branch name
778 branch set or show the current branch name
780 branches list repository named branches
779 branches list repository named branches
781 bundle create a changegroup file
780 bundle create a changegroup file
782 cat output the current or given revision of files
781 cat output the current or given revision of files
783 clone make a copy of an existing repository
782 clone make a copy of an existing repository
784 commit commit the specified files or all outstanding changes
783 commit commit the specified files or all outstanding changes
785 config show combined config settings from all hgrc files
784 config show combined config settings from all hgrc files
786 copy mark files as copied for the next commit
785 copy mark files as copied for the next commit
787 diff diff repository (or selected files)
786 diff diff repository (or selected files)
788 export dump the header and diffs for one or more changesets
787 export dump the header and diffs for one or more changesets
789 files list tracked files
788 files list tracked files
790 forget forget the specified files on the next commit
789 forget forget the specified files on the next commit
791 graft copy changes from other branches onto the current branch
790 graft copy changes from other branches onto the current branch
792 grep search revision history for a pattern in specified files
791 grep search revision history for a pattern in specified files
793 heads show branch heads
792 heads show branch heads
794 help show help for a given topic or a help overview
793 help show help for a given topic or a help overview
795 identify identify the working directory or specified revision
794 identify identify the working directory or specified revision
796 import import an ordered set of patches
795 import import an ordered set of patches
797 incoming show new changesets found in source
796 incoming show new changesets found in source
798 init create a new repository in the given directory
797 init create a new repository in the given directory
799 log show revision history of entire repository or files
798 log show revision history of entire repository or files
800 manifest output the current or given revision of the project manifest
799 manifest output the current or given revision of the project manifest
801 merge merge another revision into working directory
800 merge merge another revision into working directory
802 outgoing show changesets not found in the destination
801 outgoing show changesets not found in the destination
803 paths show aliases for remote repositories
802 paths show aliases for remote repositories
804 phase set or show the current phase name
803 phase set or show the current phase name
805 pull pull changes from the specified source
804 pull pull changes from the specified source
806 push push changes to the specified destination
805 push push changes to the specified destination
807 recover roll back an interrupted transaction
806 recover roll back an interrupted transaction
808 remove remove the specified files on the next commit
807 remove remove the specified files on the next commit
809 rename rename files; equivalent of copy + remove
808 rename rename files; equivalent of copy + remove
810 resolve redo merges or set/view the merge status of files
809 resolve redo merges or set/view the merge status of files
811 revert restore files to their checkout state
810 revert restore files to their checkout state
812 root print the root (top) of the current working directory
811 root print the root (top) of the current working directory
813 serve start stand-alone webserver
812 serve start stand-alone webserver
814 status show changed files in the working directory
813 status show changed files in the working directory
815 summary summarize working directory state
814 summary summarize working directory state
816 tag add one or more tags for the current or given revision
815 tag add one or more tags for the current or given revision
817 tags list repository tags
816 tags list repository tags
818 unbundle apply one or more changegroup files
817 unbundle apply one or more changegroup files
819 update update working directory (or switch revisions)
818 update update working directory (or switch revisions)
820 verify verify the integrity of the repository
819 verify verify the integrity of the repository
821 version output version and copyright information
820 version output version and copyright information
822
821
823 enabled extensions:
822 enabled extensions:
824
823
825 helpext (no help text available)
824 helpext (no help text available)
826
825
827 additional help topics:
826 additional help topics:
828
827
829 config Configuration Files
828 config Configuration Files
830 dates Date Formats
829 dates Date Formats
831 diffs Diff Formats
830 diffs Diff Formats
832 environment Environment Variables
831 environment Environment Variables
833 extensions Using Additional Features
832 extensions Using Additional Features
834 filesets Specifying File Sets
833 filesets Specifying File Sets
835 glossary Glossary
834 glossary Glossary
836 hgignore Syntax for Mercurial Ignore Files
835 hgignore Syntax for Mercurial Ignore Files
837 hgweb Configuring hgweb
836 hgweb Configuring hgweb
838 internals Technical implementation topics
837 internals Technical implementation topics
839 merge-tools Merge Tools
838 merge-tools Merge Tools
840 pager Pager Support
839 pager Pager Support
841 patterns File Name Patterns
840 patterns File Name Patterns
842 phases Working with Phases
841 phases Working with Phases
843 revisions Specifying Revisions
842 revisions Specifying Revisions
844 scripting Using Mercurial from scripts and automation
843 scripting Using Mercurial from scripts and automation
845 subrepos Subrepositories
844 subrepos Subrepositories
846 templating Template Usage
845 templating Template Usage
847 urls URL Paths
846 urls URL Paths
848
847
849 (use 'hg help -v' to show built-in aliases and global options)
848 (use 'hg help -v' to show built-in aliases and global options)
850
849
851
850
852 Test list of internal help commands
851 Test list of internal help commands
853
852
854 $ hg help debug
853 $ hg help debug
855 debug commands (internal and unsupported):
854 debug commands (internal and unsupported):
856
855
857 debugancestor
856 debugancestor
858 find the ancestor revision of two revisions in a given index
857 find the ancestor revision of two revisions in a given index
859 debugapplystreamclonebundle
858 debugapplystreamclonebundle
860 apply a stream clone bundle file
859 apply a stream clone bundle file
861 debugbuilddag
860 debugbuilddag
862 builds a repo with a given DAG from scratch in the current
861 builds a repo with a given DAG from scratch in the current
863 empty repo
862 empty repo
864 debugbundle lists the contents of a bundle
863 debugbundle lists the contents of a bundle
865 debugcheckstate
864 debugcheckstate
866 validate the correctness of the current dirstate
865 validate the correctness of the current dirstate
867 debugcolor show available color, effects or style
866 debugcolor show available color, effects or style
868 debugcommands
867 debugcommands
869 list all available commands and options
868 list all available commands and options
870 debugcomplete
869 debugcomplete
871 returns the completion list associated with the given command
870 returns the completion list associated with the given command
872 debugcreatestreamclonebundle
871 debugcreatestreamclonebundle
873 create a stream clone bundle file
872 create a stream clone bundle file
874 debugdag format the changelog or an index DAG as a concise textual
873 debugdag format the changelog or an index DAG as a concise textual
875 description
874 description
876 debugdata dump the contents of a data file revision
875 debugdata dump the contents of a data file revision
877 debugdate parse and display a date
876 debugdate parse and display a date
878 debugdeltachain
877 debugdeltachain
879 dump information about delta chains in a revlog
878 dump information about delta chains in a revlog
880 debugdirstate
879 debugdirstate
881 show the contents of the current dirstate
880 show the contents of the current dirstate
882 debugdiscovery
881 debugdiscovery
883 runs the changeset discovery protocol in isolation
882 runs the changeset discovery protocol in isolation
884 debugextensions
883 debugextensions
885 show information about active extensions
884 show information about active extensions
886 debugfileset parse and apply a fileset specification
885 debugfileset parse and apply a fileset specification
887 debugfsinfo show information detected about current filesystem
886 debugfsinfo show information detected about current filesystem
888 debuggetbundle
887 debuggetbundle
889 retrieves a bundle from a repo
888 retrieves a bundle from a repo
890 debugignore display the combined ignore pattern and information about
889 debugignore display the combined ignore pattern and information about
891 ignored files
890 ignored files
892 debugindex dump the contents of an index file
891 debugindex dump the contents of an index file
893 debugindexdot
892 debugindexdot
894 dump an index DAG as a graphviz dot file
893 dump an index DAG as a graphviz dot file
895 debuginstall test Mercurial installation
894 debuginstall test Mercurial installation
896 debugknown test whether node ids are known to a repo
895 debugknown test whether node ids are known to a repo
897 debuglocks show or modify state of locks
896 debuglocks show or modify state of locks
898 debugmergestate
897 debugmergestate
899 print merge state
898 print merge state
900 debugnamecomplete
899 debugnamecomplete
901 complete "names" - tags, open branch names, bookmark names
900 complete "names" - tags, open branch names, bookmark names
902 debugobsolete
901 debugobsolete
903 create arbitrary obsolete marker
902 create arbitrary obsolete marker
904 debugoptADV (no help text available)
903 debugoptADV (no help text available)
905 debugoptDEP (no help text available)
904 debugoptDEP (no help text available)
906 debugoptEXP (no help text available)
905 debugoptEXP (no help text available)
907 debugpathcomplete
906 debugpathcomplete
908 complete part or all of a tracked path
907 complete part or all of a tracked path
909 debugpushkey access the pushkey key/value protocol
908 debugpushkey access the pushkey key/value protocol
910 debugpvec (no help text available)
909 debugpvec (no help text available)
911 debugrebuilddirstate
910 debugrebuilddirstate
912 rebuild the dirstate as it would look like for the given
911 rebuild the dirstate as it would look like for the given
913 revision
912 revision
914 debugrebuildfncache
913 debugrebuildfncache
915 rebuild the fncache file
914 rebuild the fncache file
916 debugrename dump rename information
915 debugrename dump rename information
917 debugrevlog show data and statistics about a revlog
916 debugrevlog show data and statistics about a revlog
918 debugrevspec parse and apply a revision specification
917 debugrevspec parse and apply a revision specification
919 debugsetparents
918 debugsetparents
920 manually set the parents of the current working directory
919 manually set the parents of the current working directory
921 debugsub (no help text available)
920 debugsub (no help text available)
922 debugsuccessorssets
921 debugsuccessorssets
923 show set of successors for revision
922 show set of successors for revision
924 debugtemplate
923 debugtemplate
925 parse and apply a template
924 parse and apply a template
926 debugupgraderepo
925 debugupgraderepo
927 upgrade a repository to use different features
926 upgrade a repository to use different features
928 debugwalk show how files match on given patterns
927 debugwalk show how files match on given patterns
929 debugwireargs
928 debugwireargs
930 (no help text available)
929 (no help text available)
931
930
932 (use 'hg help -v debug' to show built-in aliases and global options)
931 (use 'hg help -v debug' to show built-in aliases and global options)
933
932
934 internals topic renders index of available sub-topics
933 internals topic renders index of available sub-topics
935
934
936 $ hg help internals
935 $ hg help internals
937 Technical implementation topics
936 Technical implementation topics
938 """""""""""""""""""""""""""""""
937 """""""""""""""""""""""""""""""
939
938
940 bundles Bundles
939 bundles Bundles
941 changegroups Changegroups
940 changegroups Changegroups
942 requirements Repository Requirements
941 requirements Repository Requirements
943 revlogs Revision Logs
942 revlogs Revision Logs
944 wireprotocol Wire Protocol
943 wireprotocol Wire Protocol
945
944
946 sub-topics can be accessed
945 sub-topics can be accessed
947
946
948 $ hg help internals.changegroups
947 $ hg help internals.changegroups
949 Changegroups
948 Changegroups
950 """"""""""""
949 """"""""""""
951
950
952 Changegroups are representations of repository revlog data, specifically
951 Changegroups are representations of repository revlog data, specifically
953 the changelog, manifest, and filelogs.
952 the changelog, manifest, and filelogs.
954
953
955 There are 3 versions of changegroups: "1", "2", and "3". From a high-
954 There are 3 versions of changegroups: "1", "2", and "3". From a high-
956 level, versions "1" and "2" are almost exactly the same, with the only
955 level, versions "1" and "2" are almost exactly the same, with the only
957 difference being a header on entries in the changeset segment. Version "3"
956 difference being a header on entries in the changeset segment. Version "3"
958 adds support for exchanging treemanifests and includes revlog flags in the
957 adds support for exchanging treemanifests and includes revlog flags in the
959 delta header.
958 delta header.
960
959
961 Changegroups consists of 3 logical segments:
960 Changegroups consists of 3 logical segments:
962
961
963 +---------------------------------+
962 +---------------------------------+
964 | | | |
963 | | | |
965 | changeset | manifest | filelogs |
964 | changeset | manifest | filelogs |
966 | | | |
965 | | | |
967 +---------------------------------+
966 +---------------------------------+
968
967
969 The principle building block of each segment is a *chunk*. A *chunk* is a
968 The principle building block of each segment is a *chunk*. A *chunk* is a
970 framed piece of data:
969 framed piece of data:
971
970
972 +---------------------------------------+
971 +---------------------------------------+
973 | | |
972 | | |
974 | length | data |
973 | length | data |
975 | (32 bits) | <length> bytes |
974 | (32 bits) | <length> bytes |
976 | | |
975 | | |
977 +---------------------------------------+
976 +---------------------------------------+
978
977
979 Each chunk starts with a 32-bit big-endian signed integer indicating the
978 Each chunk starts with a 32-bit big-endian signed integer indicating the
980 length of the raw data that follows.
979 length of the raw data that follows.
981
980
982 There is a special case chunk that has 0 length ("0x00000000"). We call
981 There is a special case chunk that has 0 length ("0x00000000"). We call
983 this an *empty chunk*.
982 this an *empty chunk*.
984
983
985 Delta Groups
984 Delta Groups
986 ============
985 ============
987
986
988 A *delta group* expresses the content of a revlog as a series of deltas,
987 A *delta group* expresses the content of a revlog as a series of deltas,
989 or patches against previous revisions.
988 or patches against previous revisions.
990
989
991 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
990 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
992 to signal the end of the delta group:
991 to signal the end of the delta group:
993
992
994 +------------------------------------------------------------------------+
993 +------------------------------------------------------------------------+
995 | | | | | |
994 | | | | | |
996 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
995 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
997 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
996 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
998 | | | | | |
997 | | | | | |
999 +------------------------------------------------------------+-----------+
998 +------------------------------------------------------------+-----------+
1000
999
1001 Each *chunk*'s data consists of the following:
1000 Each *chunk*'s data consists of the following:
1002
1001
1003 +-----------------------------------------+
1002 +-----------------------------------------+
1004 | | | |
1003 | | | |
1005 | delta header | mdiff header | delta |
1004 | delta header | mdiff header | delta |
1006 | (various) | (12 bytes) | (various) |
1005 | (various) | (12 bytes) | (various) |
1007 | | | |
1006 | | | |
1008 +-----------------------------------------+
1007 +-----------------------------------------+
1009
1008
1010 The *length* field is the byte length of the remaining 3 logical pieces of
1009 The *length* field is the byte length of the remaining 3 logical pieces of
1011 data. The *delta* is a diff from an existing entry in the changelog.
1010 data. The *delta* is a diff from an existing entry in the changelog.
1012
1011
1013 The *delta header* is different between versions "1", "2", and "3" of the
1012 The *delta header* is different between versions "1", "2", and "3" of the
1014 changegroup format.
1013 changegroup format.
1015
1014
1016 Version 1:
1015 Version 1:
1017
1016
1018 +------------------------------------------------------+
1017 +------------------------------------------------------+
1019 | | | | |
1018 | | | | |
1020 | node | p1 node | p2 node | link node |
1019 | node | p1 node | p2 node | link node |
1021 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1020 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1022 | | | | |
1021 | | | | |
1023 +------------------------------------------------------+
1022 +------------------------------------------------------+
1024
1023
1025 Version 2:
1024 Version 2:
1026
1025
1027 +------------------------------------------------------------------+
1026 +------------------------------------------------------------------+
1028 | | | | | |
1027 | | | | | |
1029 | node | p1 node | p2 node | base node | link node |
1028 | node | p1 node | p2 node | base node | link node |
1030 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1029 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1031 | | | | | |
1030 | | | | | |
1032 +------------------------------------------------------------------+
1031 +------------------------------------------------------------------+
1033
1032
1034 Version 3:
1033 Version 3:
1035
1034
1036 +------------------------------------------------------------------------------+
1035 +------------------------------------------------------------------------------+
1037 | | | | | | |
1036 | | | | | | |
1038 | node | p1 node | p2 node | base node | link node | flags |
1037 | node | p1 node | p2 node | base node | link node | flags |
1039 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1038 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1040 | | | | | | |
1039 | | | | | | |
1041 +------------------------------------------------------------------------------+
1040 +------------------------------------------------------------------------------+
1042
1041
1043 The *mdiff header* consists of 3 32-bit big-endian signed integers
1042 The *mdiff header* consists of 3 32-bit big-endian signed integers
1044 describing offsets at which to apply the following delta content:
1043 describing offsets at which to apply the following delta content:
1045
1044
1046 +-------------------------------------+
1045 +-------------------------------------+
1047 | | | |
1046 | | | |
1048 | offset | old length | new length |
1047 | offset | old length | new length |
1049 | (32 bits) | (32 bits) | (32 bits) |
1048 | (32 bits) | (32 bits) | (32 bits) |
1050 | | | |
1049 | | | |
1051 +-------------------------------------+
1050 +-------------------------------------+
1052
1051
1053 In version 1, the delta is always applied against the previous node from
1052 In version 1, the delta is always applied against the previous node from
1054 the changegroup or the first parent if this is the first entry in the
1053 the changegroup or the first parent if this is the first entry in the
1055 changegroup.
1054 changegroup.
1056
1055
1057 In version 2, the delta base node is encoded in the entry in the
1056 In version 2, the delta base node is encoded in the entry in the
1058 changegroup. This allows the delta to be expressed against any parent,
1057 changegroup. This allows the delta to be expressed against any parent,
1059 which can result in smaller deltas and more efficient encoding of data.
1058 which can result in smaller deltas and more efficient encoding of data.
1060
1059
1061 Changeset Segment
1060 Changeset Segment
1062 =================
1061 =================
1063
1062
1064 The *changeset segment* consists of a single *delta group* holding
1063 The *changeset segment* consists of a single *delta group* holding
1065 changelog data. It is followed by an *empty chunk* to denote the boundary
1064 changelog data. It is followed by an *empty chunk* to denote the boundary
1066 to the *manifests segment*.
1065 to the *manifests segment*.
1067
1066
1068 Manifest Segment
1067 Manifest Segment
1069 ================
1068 ================
1070
1069
1071 The *manifest segment* consists of a single *delta group* holding manifest
1070 The *manifest segment* consists of a single *delta group* holding manifest
1072 data. It is followed by an *empty chunk* to denote the boundary to the
1071 data. It is followed by an *empty chunk* to denote the boundary to the
1073 *filelogs segment*.
1072 *filelogs segment*.
1074
1073
1075 Filelogs Segment
1074 Filelogs Segment
1076 ================
1075 ================
1077
1076
1078 The *filelogs* segment consists of multiple sub-segments, each
1077 The *filelogs* segment consists of multiple sub-segments, each
1079 corresponding to an individual file whose data is being described:
1078 corresponding to an individual file whose data is being described:
1080
1079
1081 +--------------------------------------+
1080 +--------------------------------------+
1082 | | | | |
1081 | | | | |
1083 | filelog0 | filelog1 | filelog2 | ... |
1082 | filelog0 | filelog1 | filelog2 | ... |
1084 | | | | |
1083 | | | | |
1085 +--------------------------------------+
1084 +--------------------------------------+
1086
1085
1087 In version "3" of the changegroup format, filelogs may include directory
1086 In version "3" of the changegroup format, filelogs may include directory
1088 logs when treemanifests are in use. directory logs are identified by
1087 logs when treemanifests are in use. directory logs are identified by
1089 having a trailing '/' on their filename (see below).
1088 having a trailing '/' on their filename (see below).
1090
1089
1091 The final filelog sub-segment is followed by an *empty chunk* to denote
1090 The final filelog sub-segment is followed by an *empty chunk* to denote
1092 the end of the segment and the overall changegroup.
1091 the end of the segment and the overall changegroup.
1093
1092
1094 Each filelog sub-segment consists of the following:
1093 Each filelog sub-segment consists of the following:
1095
1094
1096 +------------------------------------------+
1095 +------------------------------------------+
1097 | | | |
1096 | | | |
1098 | filename size | filename | delta group |
1097 | filename size | filename | delta group |
1099 | (32 bits) | (various) | (various) |
1098 | (32 bits) | (various) | (various) |
1100 | | | |
1099 | | | |
1101 +------------------------------------------+
1100 +------------------------------------------+
1102
1101
1103 That is, a *chunk* consisting of the filename (not terminated or padded)
1102 That is, a *chunk* consisting of the filename (not terminated or padded)
1104 followed by N chunks constituting the *delta group* for this file.
1103 followed by N chunks constituting the *delta group* for this file.
1105
1104
1106 Test list of commands with command with no help text
1105 Test list of commands with command with no help text
1107
1106
1108 $ hg help helpext
1107 $ hg help helpext
1109 helpext extension - no help text available
1108 helpext extension - no help text available
1110
1109
1111 list of commands:
1110 list of commands:
1112
1111
1113 nohelp (no help text available)
1112 nohelp (no help text available)
1114
1113
1115 (use 'hg help -v helpext' to show built-in aliases and global options)
1114 (use 'hg help -v helpext' to show built-in aliases and global options)
1116
1115
1117
1116
1118 test advanced, deprecated and experimental options are hidden in command help
1117 test advanced, deprecated and experimental options are hidden in command help
1119 $ hg help debugoptADV
1118 $ hg help debugoptADV
1120 hg debugoptADV
1119 hg debugoptADV
1121
1120
1122 (no help text available)
1121 (no help text available)
1123
1122
1124 options:
1123 options:
1125
1124
1126 (some details hidden, use --verbose to show complete help)
1125 (some details hidden, use --verbose to show complete help)
1127 $ hg help debugoptDEP
1126 $ hg help debugoptDEP
1128 hg debugoptDEP
1127 hg debugoptDEP
1129
1128
1130 (no help text available)
1129 (no help text available)
1131
1130
1132 options:
1131 options:
1133
1132
1134 (some details hidden, use --verbose to show complete help)
1133 (some details hidden, use --verbose to show complete help)
1135
1134
1136 $ hg help debugoptEXP
1135 $ hg help debugoptEXP
1137 hg debugoptEXP
1136 hg debugoptEXP
1138
1137
1139 (no help text available)
1138 (no help text available)
1140
1139
1141 options:
1140 options:
1142
1141
1143 (some details hidden, use --verbose to show complete help)
1142 (some details hidden, use --verbose to show complete help)
1144
1143
1145 test advanced, deprecated and experimental options are shown with -v
1144 test advanced, deprecated and experimental options are shown with -v
1146 $ hg help -v debugoptADV | grep aopt
1145 $ hg help -v debugoptADV | grep aopt
1147 --aopt option is (ADVANCED)
1146 --aopt option is (ADVANCED)
1148 $ hg help -v debugoptDEP | grep dopt
1147 $ hg help -v debugoptDEP | grep dopt
1149 --dopt option is (DEPRECATED)
1148 --dopt option is (DEPRECATED)
1150 $ hg help -v debugoptEXP | grep eopt
1149 $ hg help -v debugoptEXP | grep eopt
1151 --eopt option is (EXPERIMENTAL)
1150 --eopt option is (EXPERIMENTAL)
1152
1151
1153 #if gettext
1152 #if gettext
1154 test deprecated option is hidden with translation with untranslated description
1153 test deprecated option is hidden with translation with untranslated description
1155 (use many globy for not failing on changed transaction)
1154 (use many globy for not failing on changed transaction)
1156 $ LANGUAGE=sv hg help debugoptDEP
1155 $ LANGUAGE=sv hg help debugoptDEP
1157 hg debugoptDEP
1156 hg debugoptDEP
1158
1157
1159 (*) (glob)
1158 (*) (glob)
1160
1159
1161 options:
1160 options:
1162
1161
1163 (some details hidden, use --verbose to show complete help)
1162 (some details hidden, use --verbose to show complete help)
1164 #endif
1163 #endif
1165
1164
1166 Test commands that collide with topics (issue4240)
1165 Test commands that collide with topics (issue4240)
1167
1166
1168 $ hg config -hq
1167 $ hg config -hq
1169 hg config [-u] [NAME]...
1168 hg config [-u] [NAME]...
1170
1169
1171 show combined config settings from all hgrc files
1170 show combined config settings from all hgrc files
1172 $ hg showconfig -hq
1171 $ hg showconfig -hq
1173 hg config [-u] [NAME]...
1172 hg config [-u] [NAME]...
1174
1173
1175 show combined config settings from all hgrc files
1174 show combined config settings from all hgrc files
1176
1175
1177 Test a help topic
1176 Test a help topic
1178
1177
1179 $ hg help dates
1178 $ hg help dates
1180 Date Formats
1179 Date Formats
1181 """"""""""""
1180 """"""""""""
1182
1181
1183 Some commands allow the user to specify a date, e.g.:
1182 Some commands allow the user to specify a date, e.g.:
1184
1183
1185 - backout, commit, import, tag: Specify the commit date.
1184 - backout, commit, import, tag: Specify the commit date.
1186 - log, revert, update: Select revision(s) by date.
1185 - log, revert, update: Select revision(s) by date.
1187
1186
1188 Many date formats are valid. Here are some examples:
1187 Many date formats are valid. Here are some examples:
1189
1188
1190 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1189 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1191 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1190 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1192 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1191 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1193 - "Dec 6" (midnight)
1192 - "Dec 6" (midnight)
1194 - "13:18" (today assumed)
1193 - "13:18" (today assumed)
1195 - "3:39" (3:39AM assumed)
1194 - "3:39" (3:39AM assumed)
1196 - "3:39pm" (15:39)
1195 - "3:39pm" (15:39)
1197 - "2006-12-06 13:18:29" (ISO 8601 format)
1196 - "2006-12-06 13:18:29" (ISO 8601 format)
1198 - "2006-12-6 13:18"
1197 - "2006-12-6 13:18"
1199 - "2006-12-6"
1198 - "2006-12-6"
1200 - "12-6"
1199 - "12-6"
1201 - "12/6"
1200 - "12/6"
1202 - "12/6/6" (Dec 6 2006)
1201 - "12/6/6" (Dec 6 2006)
1203 - "today" (midnight)
1202 - "today" (midnight)
1204 - "yesterday" (midnight)
1203 - "yesterday" (midnight)
1205 - "now" - right now
1204 - "now" - right now
1206
1205
1207 Lastly, there is Mercurial's internal format:
1206 Lastly, there is Mercurial's internal format:
1208
1207
1209 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1208 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1210
1209
1211 This is the internal representation format for dates. The first number is
1210 This is the internal representation format for dates. The first number is
1212 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1211 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1213 is the offset of the local timezone, in seconds west of UTC (negative if
1212 is the offset of the local timezone, in seconds west of UTC (negative if
1214 the timezone is east of UTC).
1213 the timezone is east of UTC).
1215
1214
1216 The log command also accepts date ranges:
1215 The log command also accepts date ranges:
1217
1216
1218 - "<DATE" - at or before a given date/time
1217 - "<DATE" - at or before a given date/time
1219 - ">DATE" - on or after a given date/time
1218 - ">DATE" - on or after a given date/time
1220 - "DATE to DATE" - a date range, inclusive
1219 - "DATE to DATE" - a date range, inclusive
1221 - "-DAYS" - within a given number of days of today
1220 - "-DAYS" - within a given number of days of today
1222
1221
1223 Test repeated config section name
1222 Test repeated config section name
1224
1223
1225 $ hg help config.host
1224 $ hg help config.host
1226 "http_proxy.host"
1225 "http_proxy.host"
1227 Host name and (optional) port of the proxy server, for example
1226 Host name and (optional) port of the proxy server, for example
1228 "myproxy:8000".
1227 "myproxy:8000".
1229
1228
1230 "smtp.host"
1229 "smtp.host"
1231 Host name of mail server, e.g. "mail.example.com".
1230 Host name of mail server, e.g. "mail.example.com".
1232
1231
1233 Unrelated trailing paragraphs shouldn't be included
1232 Unrelated trailing paragraphs shouldn't be included
1234
1233
1235 $ hg help config.extramsg | grep '^$'
1234 $ hg help config.extramsg | grep '^$'
1236
1235
1237
1236
1238 Test capitalized section name
1237 Test capitalized section name
1239
1238
1240 $ hg help scripting.HGPLAIN > /dev/null
1239 $ hg help scripting.HGPLAIN > /dev/null
1241
1240
1242 Help subsection:
1241 Help subsection:
1243
1242
1244 $ hg help config.charsets |grep "Email example:" > /dev/null
1243 $ hg help config.charsets |grep "Email example:" > /dev/null
1245 [1]
1244 [1]
1246
1245
1247 Show nested definitions
1246 Show nested definitions
1248 ("profiling.type"[break]"ls"[break]"stat"[break])
1247 ("profiling.type"[break]"ls"[break]"stat"[break])
1249
1248
1250 $ hg help config.type | egrep '^$'|wc -l
1249 $ hg help config.type | egrep '^$'|wc -l
1251 \s*3 (re)
1250 \s*3 (re)
1252
1251
1253 Separate sections from subsections
1252 Separate sections from subsections
1254
1253
1255 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1254 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1256 "format"
1255 "format"
1257 --------
1256 --------
1258
1257
1259 "usegeneraldelta"
1258 "usegeneraldelta"
1260
1259
1261 "dotencode"
1260 "dotencode"
1262
1261
1263 "usefncache"
1262 "usefncache"
1264
1263
1265 "usestore"
1264 "usestore"
1266
1265
1267 "profiling"
1266 "profiling"
1268 -----------
1267 -----------
1269
1268
1270 "format"
1269 "format"
1271
1270
1272 "progress"
1271 "progress"
1273 ----------
1272 ----------
1274
1273
1275 "format"
1274 "format"
1276
1275
1277
1276
1278 Last item in help config.*:
1277 Last item in help config.*:
1279
1278
1280 $ hg help config.`hg help config|grep '^ "'| \
1279 $ hg help config.`hg help config|grep '^ "'| \
1281 > tail -1|sed 's![ "]*!!g'`| \
1280 > tail -1|sed 's![ "]*!!g'`| \
1282 > grep 'hg help -c config' > /dev/null
1281 > grep 'hg help -c config' > /dev/null
1283 [1]
1282 [1]
1284
1283
1285 note to use help -c for general hg help config:
1284 note to use help -c for general hg help config:
1286
1285
1287 $ hg help config |grep 'hg help -c config' > /dev/null
1286 $ hg help config |grep 'hg help -c config' > /dev/null
1288
1287
1289 Test templating help
1288 Test templating help
1290
1289
1291 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1290 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1292 desc String. The text of the changeset description.
1291 desc String. The text of the changeset description.
1293 diffstat String. Statistics of changes with the following format:
1292 diffstat String. Statistics of changes with the following format:
1294 firstline Any text. Returns the first line of text.
1293 firstline Any text. Returns the first line of text.
1295 nonempty Any text. Returns '(none)' if the string is empty.
1294 nonempty Any text. Returns '(none)' if the string is empty.
1296
1295
1297 Test deprecated items
1296 Test deprecated items
1298
1297
1299 $ hg help -v templating | grep currentbookmark
1298 $ hg help -v templating | grep currentbookmark
1300 currentbookmark
1299 currentbookmark
1301 $ hg help templating | (grep currentbookmark || true)
1300 $ hg help templating | (grep currentbookmark || true)
1302
1301
1303 Test help hooks
1302 Test help hooks
1304
1303
1305 $ cat > helphook1.py <<EOF
1304 $ cat > helphook1.py <<EOF
1306 > from mercurial import help
1305 > from mercurial import help
1307 >
1306 >
1308 > def rewrite(ui, topic, doc):
1307 > def rewrite(ui, topic, doc):
1309 > return doc + '\nhelphook1\n'
1308 > return doc + '\nhelphook1\n'
1310 >
1309 >
1311 > def extsetup(ui):
1310 > def extsetup(ui):
1312 > help.addtopichook('revisions', rewrite)
1311 > help.addtopichook('revisions', rewrite)
1313 > EOF
1312 > EOF
1314 $ cat > helphook2.py <<EOF
1313 $ cat > helphook2.py <<EOF
1315 > from mercurial import help
1314 > from mercurial import help
1316 >
1315 >
1317 > def rewrite(ui, topic, doc):
1316 > def rewrite(ui, topic, doc):
1318 > return doc + '\nhelphook2\n'
1317 > return doc + '\nhelphook2\n'
1319 >
1318 >
1320 > def extsetup(ui):
1319 > def extsetup(ui):
1321 > help.addtopichook('revisions', rewrite)
1320 > help.addtopichook('revisions', rewrite)
1322 > EOF
1321 > EOF
1323 $ echo '[extensions]' >> $HGRCPATH
1322 $ echo '[extensions]' >> $HGRCPATH
1324 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1323 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1325 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1324 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1326 $ hg help revsets | grep helphook
1325 $ hg help revsets | grep helphook
1327 helphook1
1326 helphook1
1328 helphook2
1327 helphook2
1329
1328
1330 help -c should only show debug --debug
1329 help -c should only show debug --debug
1331
1330
1332 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1331 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1333 [1]
1332 [1]
1334
1333
1335 help -c should only show deprecated for -v
1334 help -c should only show deprecated for -v
1336
1335
1337 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1336 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1338 [1]
1337 [1]
1339
1338
1340 Test -s / --system
1339 Test -s / --system
1341
1340
1342 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1341 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1343 > wc -l | sed -e 's/ //g'
1342 > wc -l | sed -e 's/ //g'
1344 0
1343 0
1345 $ hg help config.files --system unix | grep 'USER' | \
1344 $ hg help config.files --system unix | grep 'USER' | \
1346 > wc -l | sed -e 's/ //g'
1345 > wc -l | sed -e 's/ //g'
1347 0
1346 0
1348
1347
1349 Test -e / -c / -k combinations
1348 Test -e / -c / -k combinations
1350
1349
1351 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1350 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1352 Commands:
1351 Commands:
1353 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1352 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1354 Extensions:
1353 Extensions:
1355 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1354 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1356 Topics:
1355 Topics:
1357 Commands:
1356 Commands:
1358 Extensions:
1357 Extensions:
1359 Extension Commands:
1358 Extension Commands:
1360 $ hg help -c schemes
1359 $ hg help -c schemes
1361 abort: no such help topic: schemes
1360 abort: no such help topic: schemes
1362 (try 'hg help --keyword schemes')
1361 (try 'hg help --keyword schemes')
1363 [255]
1362 [255]
1364 $ hg help -e schemes |head -1
1363 $ hg help -e schemes |head -1
1365 schemes extension - extend schemes with shortcuts to repository swarms
1364 schemes extension - extend schemes with shortcuts to repository swarms
1366 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1365 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1367 Commands:
1366 Commands:
1368 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1367 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1369 Extensions:
1368 Extensions:
1370 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1369 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1371 Extensions:
1370 Extensions:
1372 Commands:
1371 Commands:
1373 $ hg help -c commit > /dev/null
1372 $ hg help -c commit > /dev/null
1374 $ hg help -e -c commit > /dev/null
1373 $ hg help -e -c commit > /dev/null
1375 $ hg help -e commit > /dev/null
1374 $ hg help -e commit > /dev/null
1376 abort: no such help topic: commit
1375 abort: no such help topic: commit
1377 (try 'hg help --keyword commit')
1376 (try 'hg help --keyword commit')
1378 [255]
1377 [255]
1379
1378
1380 Test keyword search help
1379 Test keyword search help
1381
1380
1382 $ cat > prefixedname.py <<EOF
1381 $ cat > prefixedname.py <<EOF
1383 > '''matched against word "clone"
1382 > '''matched against word "clone"
1384 > '''
1383 > '''
1385 > EOF
1384 > EOF
1386 $ echo '[extensions]' >> $HGRCPATH
1385 $ echo '[extensions]' >> $HGRCPATH
1387 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1386 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1388 $ hg help -k clone
1387 $ hg help -k clone
1389 Topics:
1388 Topics:
1390
1389
1391 config Configuration Files
1390 config Configuration Files
1392 extensions Using Additional Features
1391 extensions Using Additional Features
1393 glossary Glossary
1392 glossary Glossary
1394 phases Working with Phases
1393 phases Working with Phases
1395 subrepos Subrepositories
1394 subrepos Subrepositories
1396 urls URL Paths
1395 urls URL Paths
1397
1396
1398 Commands:
1397 Commands:
1399
1398
1400 bookmarks create a new bookmark or list existing bookmarks
1399 bookmarks create a new bookmark or list existing bookmarks
1401 clone make a copy of an existing repository
1400 clone make a copy of an existing repository
1402 paths show aliases for remote repositories
1401 paths show aliases for remote repositories
1403 update update working directory (or switch revisions)
1402 update update working directory (or switch revisions)
1404
1403
1405 Extensions:
1404 Extensions:
1406
1405
1407 clonebundles advertise pre-generated bundles to seed clones
1406 clonebundles advertise pre-generated bundles to seed clones
1408 prefixedname matched against word "clone"
1407 prefixedname matched against word "clone"
1409 relink recreates hardlinks between repository clones
1408 relink recreates hardlinks between repository clones
1410
1409
1411 Extension Commands:
1410 Extension Commands:
1412
1411
1413 qclone clone main and patch repository at same time
1412 qclone clone main and patch repository at same time
1414
1413
1415 Test unfound topic
1414 Test unfound topic
1416
1415
1417 $ hg help nonexistingtopicthatwillneverexisteverever
1416 $ hg help nonexistingtopicthatwillneverexisteverever
1418 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1417 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1419 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1418 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1420 [255]
1419 [255]
1421
1420
1422 Test unfound keyword
1421 Test unfound keyword
1423
1422
1424 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1423 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1425 abort: no matches
1424 abort: no matches
1426 (try 'hg help' for a list of topics)
1425 (try 'hg help' for a list of topics)
1427 [255]
1426 [255]
1428
1427
1429 Test omit indicating for help
1428 Test omit indicating for help
1430
1429
1431 $ cat > addverboseitems.py <<EOF
1430 $ cat > addverboseitems.py <<EOF
1432 > '''extension to test omit indicating.
1431 > '''extension to test omit indicating.
1433 >
1432 >
1434 > This paragraph is never omitted (for extension)
1433 > This paragraph is never omitted (for extension)
1435 >
1434 >
1436 > .. container:: verbose
1435 > .. container:: verbose
1437 >
1436 >
1438 > This paragraph is omitted,
1437 > This paragraph is omitted,
1439 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1438 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1440 >
1439 >
1441 > This paragraph is never omitted, too (for extension)
1440 > This paragraph is never omitted, too (for extension)
1442 > '''
1441 > '''
1443 >
1442 >
1444 > from mercurial import help, commands
1443 > from mercurial import help, commands
1445 > testtopic = """This paragraph is never omitted (for topic).
1444 > testtopic = """This paragraph is never omitted (for topic).
1446 >
1445 >
1447 > .. container:: verbose
1446 > .. container:: verbose
1448 >
1447 >
1449 > This paragraph is omitted,
1448 > This paragraph is omitted,
1450 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1449 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1451 >
1450 >
1452 > This paragraph is never omitted, too (for topic)
1451 > This paragraph is never omitted, too (for topic)
1453 > """
1452 > """
1454 > def extsetup(ui):
1453 > def extsetup(ui):
1455 > help.helptable.append((["topic-containing-verbose"],
1454 > help.helptable.append((["topic-containing-verbose"],
1456 > "This is the topic to test omit indicating.",
1455 > "This is the topic to test omit indicating.",
1457 > lambda ui: testtopic))
1456 > lambda ui: testtopic))
1458 > EOF
1457 > EOF
1459 $ echo '[extensions]' >> $HGRCPATH
1458 $ echo '[extensions]' >> $HGRCPATH
1460 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1459 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1461 $ hg help addverboseitems
1460 $ hg help addverboseitems
1462 addverboseitems extension - extension to test omit indicating.
1461 addverboseitems extension - extension to test omit indicating.
1463
1462
1464 This paragraph is never omitted (for extension)
1463 This paragraph is never omitted (for extension)
1465
1464
1466 This paragraph is never omitted, too (for extension)
1465 This paragraph is never omitted, too (for extension)
1467
1466
1468 (some details hidden, use --verbose to show complete help)
1467 (some details hidden, use --verbose to show complete help)
1469
1468
1470 no commands defined
1469 no commands defined
1471 $ hg help -v addverboseitems
1470 $ hg help -v addverboseitems
1472 addverboseitems extension - extension to test omit indicating.
1471 addverboseitems extension - extension to test omit indicating.
1473
1472
1474 This paragraph is never omitted (for extension)
1473 This paragraph is never omitted (for extension)
1475
1474
1476 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1475 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1477 extension)
1476 extension)
1478
1477
1479 This paragraph is never omitted, too (for extension)
1478 This paragraph is never omitted, too (for extension)
1480
1479
1481 no commands defined
1480 no commands defined
1482 $ hg help topic-containing-verbose
1481 $ hg help topic-containing-verbose
1483 This is the topic to test omit indicating.
1482 This is the topic to test omit indicating.
1484 """"""""""""""""""""""""""""""""""""""""""
1483 """"""""""""""""""""""""""""""""""""""""""
1485
1484
1486 This paragraph is never omitted (for topic).
1485 This paragraph is never omitted (for topic).
1487
1486
1488 This paragraph is never omitted, too (for topic)
1487 This paragraph is never omitted, too (for topic)
1489
1488
1490 (some details hidden, use --verbose to show complete help)
1489 (some details hidden, use --verbose to show complete help)
1491 $ hg help -v topic-containing-verbose
1490 $ hg help -v topic-containing-verbose
1492 This is the topic to test omit indicating.
1491 This is the topic to test omit indicating.
1493 """"""""""""""""""""""""""""""""""""""""""
1492 """"""""""""""""""""""""""""""""""""""""""
1494
1493
1495 This paragraph is never omitted (for topic).
1494 This paragraph is never omitted (for topic).
1496
1495
1497 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1496 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1498 topic)
1497 topic)
1499
1498
1500 This paragraph is never omitted, too (for topic)
1499 This paragraph is never omitted, too (for topic)
1501
1500
1502 Test section lookup
1501 Test section lookup
1503
1502
1504 $ hg help revset.merge
1503 $ hg help revset.merge
1505 "merge()"
1504 "merge()"
1506 Changeset is a merge changeset.
1505 Changeset is a merge changeset.
1507
1506
1508 $ hg help glossary.dag
1507 $ hg help glossary.dag
1509 DAG
1508 DAG
1510 The repository of changesets of a distributed version control system
1509 The repository of changesets of a distributed version control system
1511 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1510 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1512 of nodes and edges, where nodes correspond to changesets and edges
1511 of nodes and edges, where nodes correspond to changesets and edges
1513 imply a parent -> child relation. This graph can be visualized by
1512 imply a parent -> child relation. This graph can be visualized by
1514 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1513 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1515 limited by the requirement for children to have at most two parents.
1514 limited by the requirement for children to have at most two parents.
1516
1515
1517
1516
1518 $ hg help hgrc.paths
1517 $ hg help hgrc.paths
1519 "paths"
1518 "paths"
1520 -------
1519 -------
1521
1520
1522 Assigns symbolic names and behavior to repositories.
1521 Assigns symbolic names and behavior to repositories.
1523
1522
1524 Options are symbolic names defining the URL or directory that is the
1523 Options are symbolic names defining the URL or directory that is the
1525 location of the repository. Example:
1524 location of the repository. Example:
1526
1525
1527 [paths]
1526 [paths]
1528 my_server = https://example.com/my_repo
1527 my_server = https://example.com/my_repo
1529 local_path = /home/me/repo
1528 local_path = /home/me/repo
1530
1529
1531 These symbolic names can be used from the command line. To pull from
1530 These symbolic names can be used from the command line. To pull from
1532 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1531 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1533 local_path'.
1532 local_path'.
1534
1533
1535 Options containing colons (":") denote sub-options that can influence
1534 Options containing colons (":") denote sub-options that can influence
1536 behavior for that specific path. Example:
1535 behavior for that specific path. Example:
1537
1536
1538 [paths]
1537 [paths]
1539 my_server = https://example.com/my_path
1538 my_server = https://example.com/my_path
1540 my_server:pushurl = ssh://example.com/my_path
1539 my_server:pushurl = ssh://example.com/my_path
1541
1540
1542 The following sub-options can be defined:
1541 The following sub-options can be defined:
1543
1542
1544 "pushurl"
1543 "pushurl"
1545 The URL to use for push operations. If not defined, the location
1544 The URL to use for push operations. If not defined, the location
1546 defined by the path's main entry is used.
1545 defined by the path's main entry is used.
1547
1546
1548 "pushrev"
1547 "pushrev"
1549 A revset defining which revisions to push by default.
1548 A revset defining which revisions to push by default.
1550
1549
1551 When 'hg push' is executed without a "-r" argument, the revset defined
1550 When 'hg push' is executed without a "-r" argument, the revset defined
1552 by this sub-option is evaluated to determine what to push.
1551 by this sub-option is evaluated to determine what to push.
1553
1552
1554 For example, a value of "." will push the working directory's revision
1553 For example, a value of "." will push the working directory's revision
1555 by default.
1554 by default.
1556
1555
1557 Revsets specifying bookmarks will not result in the bookmark being
1556 Revsets specifying bookmarks will not result in the bookmark being
1558 pushed.
1557 pushed.
1559
1558
1560 The following special named paths exist:
1559 The following special named paths exist:
1561
1560
1562 "default"
1561 "default"
1563 The URL or directory to use when no source or remote is specified.
1562 The URL or directory to use when no source or remote is specified.
1564
1563
1565 'hg clone' will automatically define this path to the location the
1564 'hg clone' will automatically define this path to the location the
1566 repository was cloned from.
1565 repository was cloned from.
1567
1566
1568 "default-push"
1567 "default-push"
1569 (deprecated) The URL or directory for the default 'hg push' location.
1568 (deprecated) The URL or directory for the default 'hg push' location.
1570 "default:pushurl" should be used instead.
1569 "default:pushurl" should be used instead.
1571
1570
1572 $ hg help glossary.mcguffin
1571 $ hg help glossary.mcguffin
1573 abort: help section not found: glossary.mcguffin
1572 abort: help section not found: glossary.mcguffin
1574 [255]
1573 [255]
1575
1574
1576 $ hg help glossary.mc.guffin
1575 $ hg help glossary.mc.guffin
1577 abort: help section not found: glossary.mc.guffin
1576 abort: help section not found: glossary.mc.guffin
1578 [255]
1577 [255]
1579
1578
1580 $ hg help template.files
1579 $ hg help template.files
1581 files List of strings. All files modified, added, or removed by
1580 files List of strings. All files modified, added, or removed by
1582 this changeset.
1581 this changeset.
1583 files(pattern)
1582 files(pattern)
1584 All files of the current changeset matching the pattern. See
1583 All files of the current changeset matching the pattern. See
1585 'hg help patterns'.
1584 'hg help patterns'.
1586
1585
1587 Test section lookup by translated message
1586 Test section lookup by translated message
1588
1587
1589 str.lower() instead of encoding.lower(str) on translated message might
1588 str.lower() instead of encoding.lower(str) on translated message might
1590 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1589 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1591 as the second or later byte of multi-byte character.
1590 as the second or later byte of multi-byte character.
1592
1591
1593 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1592 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1594 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1593 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1595 replacement makes message meaningless.
1594 replacement makes message meaningless.
1596
1595
1597 This tests that section lookup by translated string isn't broken by
1596 This tests that section lookup by translated string isn't broken by
1598 such str.lower().
1597 such str.lower().
1599
1598
1600 $ python <<EOF
1599 $ python <<EOF
1601 > def escape(s):
1600 > def escape(s):
1602 > return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
1601 > return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
1603 > # translation of "record" in ja_JP.cp932
1602 > # translation of "record" in ja_JP.cp932
1604 > upper = "\x8bL\x98^"
1603 > upper = "\x8bL\x98^"
1605 > # str.lower()-ed section name should be treated as different one
1604 > # str.lower()-ed section name should be treated as different one
1606 > lower = "\x8bl\x98^"
1605 > lower = "\x8bl\x98^"
1607 > with open('ambiguous.py', 'w') as fp:
1606 > with open('ambiguous.py', 'w') as fp:
1608 > fp.write("""# ambiguous section names in ja_JP.cp932
1607 > fp.write("""# ambiguous section names in ja_JP.cp932
1609 > u'''summary of extension
1608 > u'''summary of extension
1610 >
1609 >
1611 > %s
1610 > %s
1612 > ----
1611 > ----
1613 >
1612 >
1614 > Upper name should show only this message
1613 > Upper name should show only this message
1615 >
1614 >
1616 > %s
1615 > %s
1617 > ----
1616 > ----
1618 >
1617 >
1619 > Lower name should show only this message
1618 > Lower name should show only this message
1620 >
1619 >
1621 > subsequent section
1620 > subsequent section
1622 > ------------------
1621 > ------------------
1623 >
1622 >
1624 > This should be hidden at 'hg help ambiguous' with section name.
1623 > This should be hidden at 'hg help ambiguous' with section name.
1625 > '''
1624 > '''
1626 > """ % (escape(upper), escape(lower)))
1625 > """ % (escape(upper), escape(lower)))
1627 > EOF
1626 > EOF
1628
1627
1629 $ cat >> $HGRCPATH <<EOF
1628 $ cat >> $HGRCPATH <<EOF
1630 > [extensions]
1629 > [extensions]
1631 > ambiguous = ./ambiguous.py
1630 > ambiguous = ./ambiguous.py
1632 > EOF
1631 > EOF
1633
1632
1634 $ python <<EOF | sh
1633 $ python <<EOF | sh
1635 > upper = "\x8bL\x98^"
1634 > upper = "\x8bL\x98^"
1636 > print "hg --encoding cp932 help -e ambiguous.%s" % upper
1635 > print "hg --encoding cp932 help -e ambiguous.%s" % upper
1637 > EOF
1636 > EOF
1638 \x8bL\x98^ (esc)
1637 \x8bL\x98^ (esc)
1639 ----
1638 ----
1640
1639
1641 Upper name should show only this message
1640 Upper name should show only this message
1642
1641
1643
1642
1644 $ python <<EOF | sh
1643 $ python <<EOF | sh
1645 > lower = "\x8bl\x98^"
1644 > lower = "\x8bl\x98^"
1646 > print "hg --encoding cp932 help -e ambiguous.%s" % lower
1645 > print "hg --encoding cp932 help -e ambiguous.%s" % lower
1647 > EOF
1646 > EOF
1648 \x8bl\x98^ (esc)
1647 \x8bl\x98^ (esc)
1649 ----
1648 ----
1650
1649
1651 Lower name should show only this message
1650 Lower name should show only this message
1652
1651
1653
1652
1654 $ cat >> $HGRCPATH <<EOF
1653 $ cat >> $HGRCPATH <<EOF
1655 > [extensions]
1654 > [extensions]
1656 > ambiguous = !
1655 > ambiguous = !
1657 > EOF
1656 > EOF
1658
1657
1659 Show help content of disabled extensions
1658 Show help content of disabled extensions
1660
1659
1661 $ cat >> $HGRCPATH <<EOF
1660 $ cat >> $HGRCPATH <<EOF
1662 > [extensions]
1661 > [extensions]
1663 > ambiguous = !./ambiguous.py
1662 > ambiguous = !./ambiguous.py
1664 > EOF
1663 > EOF
1665 $ hg help -e ambiguous
1664 $ hg help -e ambiguous
1666 ambiguous extension - (no help text available)
1665 ambiguous extension - (no help text available)
1667
1666
1668 (use 'hg help extensions' for information on enabling extensions)
1667 (use 'hg help extensions' for information on enabling extensions)
1669
1668
1670 Test dynamic list of merge tools only shows up once
1669 Test dynamic list of merge tools only shows up once
1671 $ hg help merge-tools
1670 $ hg help merge-tools
1672 Merge Tools
1671 Merge Tools
1673 """""""""""
1672 """""""""""
1674
1673
1675 To merge files Mercurial uses merge tools.
1674 To merge files Mercurial uses merge tools.
1676
1675
1677 A merge tool combines two different versions of a file into a merged file.
1676 A merge tool combines two different versions of a file into a merged file.
1678 Merge tools are given the two files and the greatest common ancestor of
1677 Merge tools are given the two files and the greatest common ancestor of
1679 the two file versions, so they can determine the changes made on both
1678 the two file versions, so they can determine the changes made on both
1680 branches.
1679 branches.
1681
1680
1682 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1681 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1683 backout' and in several extensions.
1682 backout' and in several extensions.
1684
1683
1685 Usually, the merge tool tries to automatically reconcile the files by
1684 Usually, the merge tool tries to automatically reconcile the files by
1686 combining all non-overlapping changes that occurred separately in the two
1685 combining all non-overlapping changes that occurred separately in the two
1687 different evolutions of the same initial base file. Furthermore, some
1686 different evolutions of the same initial base file. Furthermore, some
1688 interactive merge programs make it easier to manually resolve conflicting
1687 interactive merge programs make it easier to manually resolve conflicting
1689 merges, either in a graphical way, or by inserting some conflict markers.
1688 merges, either in a graphical way, or by inserting some conflict markers.
1690 Mercurial does not include any interactive merge programs but relies on
1689 Mercurial does not include any interactive merge programs but relies on
1691 external tools for that.
1690 external tools for that.
1692
1691
1693 Available merge tools
1692 Available merge tools
1694 =====================
1693 =====================
1695
1694
1696 External merge tools and their properties are configured in the merge-
1695 External merge tools and their properties are configured in the merge-
1697 tools configuration section - see hgrc(5) - but they can often just be
1696 tools configuration section - see hgrc(5) - but they can often just be
1698 named by their executable.
1697 named by their executable.
1699
1698
1700 A merge tool is generally usable if its executable can be found on the
1699 A merge tool is generally usable if its executable can be found on the
1701 system and if it can handle the merge. The executable is found if it is an
1700 system and if it can handle the merge. The executable is found if it is an
1702 absolute or relative executable path or the name of an application in the
1701 absolute or relative executable path or the name of an application in the
1703 executable search path. The tool is assumed to be able to handle the merge
1702 executable search path. The tool is assumed to be able to handle the merge
1704 if it can handle symlinks if the file is a symlink, if it can handle
1703 if it can handle symlinks if the file is a symlink, if it can handle
1705 binary files if the file is binary, and if a GUI is available if the tool
1704 binary files if the file is binary, and if a GUI is available if the tool
1706 requires a GUI.
1705 requires a GUI.
1707
1706
1708 There are some internal merge tools which can be used. The internal merge
1707 There are some internal merge tools which can be used. The internal merge
1709 tools are:
1708 tools are:
1710
1709
1711 ":dump"
1710 ":dump"
1712 Creates three versions of the files to merge, containing the contents of
1711 Creates three versions of the files to merge, containing the contents of
1713 local, other and base. These files can then be used to perform a merge
1712 local, other and base. These files can then be used to perform a merge
1714 manually. If the file to be merged is named "a.txt", these files will
1713 manually. If the file to be merged is named "a.txt", these files will
1715 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1714 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1716 they will be placed in the same directory as "a.txt".
1715 they will be placed in the same directory as "a.txt".
1717
1716
1718 ":fail"
1717 ":fail"
1719 Rather than attempting to merge files that were modified on both
1718 Rather than attempting to merge files that were modified on both
1720 branches, it marks them as unresolved. The resolve command must be used
1719 branches, it marks them as unresolved. The resolve command must be used
1721 to resolve these conflicts.
1720 to resolve these conflicts.
1722
1721
1723 ":local"
1722 ":local"
1724 Uses the local 'p1()' version of files as the merged version.
1723 Uses the local 'p1()' version of files as the merged version.
1725
1724
1726 ":merge"
1725 ":merge"
1727 Uses the internal non-interactive simple merge algorithm for merging
1726 Uses the internal non-interactive simple merge algorithm for merging
1728 files. It will fail if there are any conflicts and leave markers in the
1727 files. It will fail if there are any conflicts and leave markers in the
1729 partially merged file. Markers will have two sections, one for each side
1728 partially merged file. Markers will have two sections, one for each side
1730 of merge.
1729 of merge.
1731
1730
1732 ":merge-local"
1731 ":merge-local"
1733 Like :merge, but resolve all conflicts non-interactively in favor of the
1732 Like :merge, but resolve all conflicts non-interactively in favor of the
1734 local 'p1()' changes.
1733 local 'p1()' changes.
1735
1734
1736 ":merge-other"
1735 ":merge-other"
1737 Like :merge, but resolve all conflicts non-interactively in favor of the
1736 Like :merge, but resolve all conflicts non-interactively in favor of the
1738 other 'p2()' changes.
1737 other 'p2()' changes.
1739
1738
1740 ":merge3"
1739 ":merge3"
1741 Uses the internal non-interactive simple merge algorithm for merging
1740 Uses the internal non-interactive simple merge algorithm for merging
1742 files. It will fail if there are any conflicts and leave markers in the
1741 files. It will fail if there are any conflicts and leave markers in the
1743 partially merged file. Marker will have three sections, one from each
1742 partially merged file. Marker will have three sections, one from each
1744 side of the merge and one for the base content.
1743 side of the merge and one for the base content.
1745
1744
1746 ":other"
1745 ":other"
1747 Uses the other 'p2()' version of files as the merged version.
1746 Uses the other 'p2()' version of files as the merged version.
1748
1747
1749 ":prompt"
1748 ":prompt"
1750 Asks the user which of the local 'p1()' or the other 'p2()' version to
1749 Asks the user which of the local 'p1()' or the other 'p2()' version to
1751 keep as the merged version.
1750 keep as the merged version.
1752
1751
1753 ":tagmerge"
1752 ":tagmerge"
1754 Uses the internal tag merge algorithm (experimental).
1753 Uses the internal tag merge algorithm (experimental).
1755
1754
1756 ":union"
1755 ":union"
1757 Uses the internal non-interactive simple merge algorithm for merging
1756 Uses the internal non-interactive simple merge algorithm for merging
1758 files. It will use both left and right sides for conflict regions. No
1757 files. It will use both left and right sides for conflict regions. No
1759 markers are inserted.
1758 markers are inserted.
1760
1759
1761 Internal tools are always available and do not require a GUI but will by
1760 Internal tools are always available and do not require a GUI but will by
1762 default not handle symlinks or binary files.
1761 default not handle symlinks or binary files.
1763
1762
1764 Choosing a merge tool
1763 Choosing a merge tool
1765 =====================
1764 =====================
1766
1765
1767 Mercurial uses these rules when deciding which merge tool to use:
1766 Mercurial uses these rules when deciding which merge tool to use:
1768
1767
1769 1. If a tool has been specified with the --tool option to merge or
1768 1. If a tool has been specified with the --tool option to merge or
1770 resolve, it is used. If it is the name of a tool in the merge-tools
1769 resolve, it is used. If it is the name of a tool in the merge-tools
1771 configuration, its configuration is used. Otherwise the specified tool
1770 configuration, its configuration is used. Otherwise the specified tool
1772 must be executable by the shell.
1771 must be executable by the shell.
1773 2. If the "HGMERGE" environment variable is present, its value is used and
1772 2. If the "HGMERGE" environment variable is present, its value is used and
1774 must be executable by the shell.
1773 must be executable by the shell.
1775 3. If the filename of the file to be merged matches any of the patterns in
1774 3. If the filename of the file to be merged matches any of the patterns in
1776 the merge-patterns configuration section, the first usable merge tool
1775 the merge-patterns configuration section, the first usable merge tool
1777 corresponding to a matching pattern is used. Here, binary capabilities
1776 corresponding to a matching pattern is used. Here, binary capabilities
1778 of the merge tool are not considered.
1777 of the merge tool are not considered.
1779 4. If ui.merge is set it will be considered next. If the value is not the
1778 4. If ui.merge is set it will be considered next. If the value is not the
1780 name of a configured tool, the specified value is used and must be
1779 name of a configured tool, the specified value is used and must be
1781 executable by the shell. Otherwise the named tool is used if it is
1780 executable by the shell. Otherwise the named tool is used if it is
1782 usable.
1781 usable.
1783 5. If any usable merge tools are present in the merge-tools configuration
1782 5. If any usable merge tools are present in the merge-tools configuration
1784 section, the one with the highest priority is used.
1783 section, the one with the highest priority is used.
1785 6. If a program named "hgmerge" can be found on the system, it is used -
1784 6. If a program named "hgmerge" can be found on the system, it is used -
1786 but it will by default not be used for symlinks and binary files.
1785 but it will by default not be used for symlinks and binary files.
1787 7. If the file to be merged is not binary and is not a symlink, then
1786 7. If the file to be merged is not binary and is not a symlink, then
1788 internal ":merge" is used.
1787 internal ":merge" is used.
1789 8. The merge of the file fails and must be resolved before commit.
1788 8. The merge of the file fails and must be resolved before commit.
1790
1789
1791 Note:
1790 Note:
1792 After selecting a merge program, Mercurial will by default attempt to
1791 After selecting a merge program, Mercurial will by default attempt to
1793 merge the files using a simple merge algorithm first. Only if it
1792 merge the files using a simple merge algorithm first. Only if it
1794 doesn't succeed because of conflicting changes Mercurial will actually
1793 doesn't succeed because of conflicting changes Mercurial will actually
1795 execute the merge program. Whether to use the simple merge algorithm
1794 execute the merge program. Whether to use the simple merge algorithm
1796 first can be controlled by the premerge setting of the merge tool.
1795 first can be controlled by the premerge setting of the merge tool.
1797 Premerge is enabled by default unless the file is binary or a symlink.
1796 Premerge is enabled by default unless the file is binary or a symlink.
1798
1797
1799 See the merge-tools and ui sections of hgrc(5) for details on the
1798 See the merge-tools and ui sections of hgrc(5) for details on the
1800 configuration of merge tools.
1799 configuration of merge tools.
1801
1800
1802 Test usage of section marks in help documents
1801 Test usage of section marks in help documents
1803
1802
1804 $ cd "$TESTDIR"/../doc
1803 $ cd "$TESTDIR"/../doc
1805 $ python check-seclevel.py
1804 $ python check-seclevel.py
1806 $ cd $TESTTMP
1805 $ cd $TESTTMP
1807
1806
1808 #if serve
1807 #if serve
1809
1808
1810 Test the help pages in hgweb.
1809 Test the help pages in hgweb.
1811
1810
1812 Dish up an empty repo; serve it cold.
1811 Dish up an empty repo; serve it cold.
1813
1812
1814 $ hg init "$TESTTMP/test"
1813 $ hg init "$TESTTMP/test"
1815 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1814 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1816 $ cat hg.pid >> $DAEMON_PIDS
1815 $ cat hg.pid >> $DAEMON_PIDS
1817
1816
1818 $ get-with-headers.py $LOCALIP:$HGPORT "help"
1817 $ get-with-headers.py $LOCALIP:$HGPORT "help"
1819 200 Script output follows
1818 200 Script output follows
1820
1819
1821 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1820 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1822 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1821 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1823 <head>
1822 <head>
1824 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1823 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1825 <meta name="robots" content="index, nofollow" />
1824 <meta name="robots" content="index, nofollow" />
1826 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1825 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1827 <script type="text/javascript" src="/static/mercurial.js"></script>
1826 <script type="text/javascript" src="/static/mercurial.js"></script>
1828
1827
1829 <title>Help: Index</title>
1828 <title>Help: Index</title>
1830 </head>
1829 </head>
1831 <body>
1830 <body>
1832
1831
1833 <div class="container">
1832 <div class="container">
1834 <div class="menu">
1833 <div class="menu">
1835 <div class="logo">
1834 <div class="logo">
1836 <a href="https://mercurial-scm.org/">
1835 <a href="https://mercurial-scm.org/">
1837 <img src="/static/hglogo.png" alt="mercurial" /></a>
1836 <img src="/static/hglogo.png" alt="mercurial" /></a>
1838 </div>
1837 </div>
1839 <ul>
1838 <ul>
1840 <li><a href="/shortlog">log</a></li>
1839 <li><a href="/shortlog">log</a></li>
1841 <li><a href="/graph">graph</a></li>
1840 <li><a href="/graph">graph</a></li>
1842 <li><a href="/tags">tags</a></li>
1841 <li><a href="/tags">tags</a></li>
1843 <li><a href="/bookmarks">bookmarks</a></li>
1842 <li><a href="/bookmarks">bookmarks</a></li>
1844 <li><a href="/branches">branches</a></li>
1843 <li><a href="/branches">branches</a></li>
1845 </ul>
1844 </ul>
1846 <ul>
1845 <ul>
1847 <li class="active">help</li>
1846 <li class="active">help</li>
1848 </ul>
1847 </ul>
1849 </div>
1848 </div>
1850
1849
1851 <div class="main">
1850 <div class="main">
1852 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1851 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1853 <form class="search" action="/log">
1852 <form class="search" action="/log">
1854
1853
1855 <p><input name="rev" id="search1" type="text" size="30" /></p>
1854 <p><input name="rev" id="search1" type="text" size="30" /></p>
1856 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1855 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1857 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1856 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1858 </form>
1857 </form>
1859 <table class="bigtable">
1858 <table class="bigtable">
1860 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
1859 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
1861
1860
1862 <tr><td>
1861 <tr><td>
1863 <a href="/help/config">
1862 <a href="/help/config">
1864 config
1863 config
1865 </a>
1864 </a>
1866 </td><td>
1865 </td><td>
1867 Configuration Files
1866 Configuration Files
1868 </td></tr>
1867 </td></tr>
1869 <tr><td>
1868 <tr><td>
1870 <a href="/help/dates">
1869 <a href="/help/dates">
1871 dates
1870 dates
1872 </a>
1871 </a>
1873 </td><td>
1872 </td><td>
1874 Date Formats
1873 Date Formats
1875 </td></tr>
1874 </td></tr>
1876 <tr><td>
1875 <tr><td>
1877 <a href="/help/diffs">
1876 <a href="/help/diffs">
1878 diffs
1877 diffs
1879 </a>
1878 </a>
1880 </td><td>
1879 </td><td>
1881 Diff Formats
1880 Diff Formats
1882 </td></tr>
1881 </td></tr>
1883 <tr><td>
1882 <tr><td>
1884 <a href="/help/environment">
1883 <a href="/help/environment">
1885 environment
1884 environment
1886 </a>
1885 </a>
1887 </td><td>
1886 </td><td>
1888 Environment Variables
1887 Environment Variables
1889 </td></tr>
1888 </td></tr>
1890 <tr><td>
1889 <tr><td>
1891 <a href="/help/extensions">
1890 <a href="/help/extensions">
1892 extensions
1891 extensions
1893 </a>
1892 </a>
1894 </td><td>
1893 </td><td>
1895 Using Additional Features
1894 Using Additional Features
1896 </td></tr>
1895 </td></tr>
1897 <tr><td>
1896 <tr><td>
1898 <a href="/help/filesets">
1897 <a href="/help/filesets">
1899 filesets
1898 filesets
1900 </a>
1899 </a>
1901 </td><td>
1900 </td><td>
1902 Specifying File Sets
1901 Specifying File Sets
1903 </td></tr>
1902 </td></tr>
1904 <tr><td>
1903 <tr><td>
1905 <a href="/help/glossary">
1904 <a href="/help/glossary">
1906 glossary
1905 glossary
1907 </a>
1906 </a>
1908 </td><td>
1907 </td><td>
1909 Glossary
1908 Glossary
1910 </td></tr>
1909 </td></tr>
1911 <tr><td>
1910 <tr><td>
1912 <a href="/help/hgignore">
1911 <a href="/help/hgignore">
1913 hgignore
1912 hgignore
1914 </a>
1913 </a>
1915 </td><td>
1914 </td><td>
1916 Syntax for Mercurial Ignore Files
1915 Syntax for Mercurial Ignore Files
1917 </td></tr>
1916 </td></tr>
1918 <tr><td>
1917 <tr><td>
1919 <a href="/help/hgweb">
1918 <a href="/help/hgweb">
1920 hgweb
1919 hgweb
1921 </a>
1920 </a>
1922 </td><td>
1921 </td><td>
1923 Configuring hgweb
1922 Configuring hgweb
1924 </td></tr>
1923 </td></tr>
1925 <tr><td>
1924 <tr><td>
1926 <a href="/help/internals">
1925 <a href="/help/internals">
1927 internals
1926 internals
1928 </a>
1927 </a>
1929 </td><td>
1928 </td><td>
1930 Technical implementation topics
1929 Technical implementation topics
1931 </td></tr>
1930 </td></tr>
1932 <tr><td>
1931 <tr><td>
1933 <a href="/help/merge-tools">
1932 <a href="/help/merge-tools">
1934 merge-tools
1933 merge-tools
1935 </a>
1934 </a>
1936 </td><td>
1935 </td><td>
1937 Merge Tools
1936 Merge Tools
1938 </td></tr>
1937 </td></tr>
1939 <tr><td>
1938 <tr><td>
1940 <a href="/help/pager">
1939 <a href="/help/pager">
1941 pager
1940 pager
1942 </a>
1941 </a>
1943 </td><td>
1942 </td><td>
1944 Pager Support
1943 Pager Support
1945 </td></tr>
1944 </td></tr>
1946 <tr><td>
1945 <tr><td>
1947 <a href="/help/patterns">
1946 <a href="/help/patterns">
1948 patterns
1947 patterns
1949 </a>
1948 </a>
1950 </td><td>
1949 </td><td>
1951 File Name Patterns
1950 File Name Patterns
1952 </td></tr>
1951 </td></tr>
1953 <tr><td>
1952 <tr><td>
1954 <a href="/help/phases">
1953 <a href="/help/phases">
1955 phases
1954 phases
1956 </a>
1955 </a>
1957 </td><td>
1956 </td><td>
1958 Working with Phases
1957 Working with Phases
1959 </td></tr>
1958 </td></tr>
1960 <tr><td>
1959 <tr><td>
1961 <a href="/help/revisions">
1960 <a href="/help/revisions">
1962 revisions
1961 revisions
1963 </a>
1962 </a>
1964 </td><td>
1963 </td><td>
1965 Specifying Revisions
1964 Specifying Revisions
1966 </td></tr>
1965 </td></tr>
1967 <tr><td>
1966 <tr><td>
1968 <a href="/help/scripting">
1967 <a href="/help/scripting">
1969 scripting
1968 scripting
1970 </a>
1969 </a>
1971 </td><td>
1970 </td><td>
1972 Using Mercurial from scripts and automation
1971 Using Mercurial from scripts and automation
1973 </td></tr>
1972 </td></tr>
1974 <tr><td>
1973 <tr><td>
1975 <a href="/help/subrepos">
1974 <a href="/help/subrepos">
1976 subrepos
1975 subrepos
1977 </a>
1976 </a>
1978 </td><td>
1977 </td><td>
1979 Subrepositories
1978 Subrepositories
1980 </td></tr>
1979 </td></tr>
1981 <tr><td>
1980 <tr><td>
1982 <a href="/help/templating">
1981 <a href="/help/templating">
1983 templating
1982 templating
1984 </a>
1983 </a>
1985 </td><td>
1984 </td><td>
1986 Template Usage
1985 Template Usage
1987 </td></tr>
1986 </td></tr>
1988 <tr><td>
1987 <tr><td>
1989 <a href="/help/urls">
1988 <a href="/help/urls">
1990 urls
1989 urls
1991 </a>
1990 </a>
1992 </td><td>
1991 </td><td>
1993 URL Paths
1992 URL Paths
1994 </td></tr>
1993 </td></tr>
1995 <tr><td>
1994 <tr><td>
1996 <a href="/help/topic-containing-verbose">
1995 <a href="/help/topic-containing-verbose">
1997 topic-containing-verbose
1996 topic-containing-verbose
1998 </a>
1997 </a>
1999 </td><td>
1998 </td><td>
2000 This is the topic to test omit indicating.
1999 This is the topic to test omit indicating.
2001 </td></tr>
2000 </td></tr>
2002
2001
2003
2002
2004 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2003 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2005
2004
2006 <tr><td>
2005 <tr><td>
2007 <a href="/help/add">
2006 <a href="/help/add">
2008 add
2007 add
2009 </a>
2008 </a>
2010 </td><td>
2009 </td><td>
2011 add the specified files on the next commit
2010 add the specified files on the next commit
2012 </td></tr>
2011 </td></tr>
2013 <tr><td>
2012 <tr><td>
2014 <a href="/help/annotate">
2013 <a href="/help/annotate">
2015 annotate
2014 annotate
2016 </a>
2015 </a>
2017 </td><td>
2016 </td><td>
2018 show changeset information by line for each file
2017 show changeset information by line for each file
2019 </td></tr>
2018 </td></tr>
2020 <tr><td>
2019 <tr><td>
2021 <a href="/help/clone">
2020 <a href="/help/clone">
2022 clone
2021 clone
2023 </a>
2022 </a>
2024 </td><td>
2023 </td><td>
2025 make a copy of an existing repository
2024 make a copy of an existing repository
2026 </td></tr>
2025 </td></tr>
2027 <tr><td>
2026 <tr><td>
2028 <a href="/help/commit">
2027 <a href="/help/commit">
2029 commit
2028 commit
2030 </a>
2029 </a>
2031 </td><td>
2030 </td><td>
2032 commit the specified files or all outstanding changes
2031 commit the specified files or all outstanding changes
2033 </td></tr>
2032 </td></tr>
2034 <tr><td>
2033 <tr><td>
2035 <a href="/help/diff">
2034 <a href="/help/diff">
2036 diff
2035 diff
2037 </a>
2036 </a>
2038 </td><td>
2037 </td><td>
2039 diff repository (or selected files)
2038 diff repository (or selected files)
2040 </td></tr>
2039 </td></tr>
2041 <tr><td>
2040 <tr><td>
2042 <a href="/help/export">
2041 <a href="/help/export">
2043 export
2042 export
2044 </a>
2043 </a>
2045 </td><td>
2044 </td><td>
2046 dump the header and diffs for one or more changesets
2045 dump the header and diffs for one or more changesets
2047 </td></tr>
2046 </td></tr>
2048 <tr><td>
2047 <tr><td>
2049 <a href="/help/forget">
2048 <a href="/help/forget">
2050 forget
2049 forget
2051 </a>
2050 </a>
2052 </td><td>
2051 </td><td>
2053 forget the specified files on the next commit
2052 forget the specified files on the next commit
2054 </td></tr>
2053 </td></tr>
2055 <tr><td>
2054 <tr><td>
2056 <a href="/help/init">
2055 <a href="/help/init">
2057 init
2056 init
2058 </a>
2057 </a>
2059 </td><td>
2058 </td><td>
2060 create a new repository in the given directory
2059 create a new repository in the given directory
2061 </td></tr>
2060 </td></tr>
2062 <tr><td>
2061 <tr><td>
2063 <a href="/help/log">
2062 <a href="/help/log">
2064 log
2063 log
2065 </a>
2064 </a>
2066 </td><td>
2065 </td><td>
2067 show revision history of entire repository or files
2066 show revision history of entire repository or files
2068 </td></tr>
2067 </td></tr>
2069 <tr><td>
2068 <tr><td>
2070 <a href="/help/merge">
2069 <a href="/help/merge">
2071 merge
2070 merge
2072 </a>
2071 </a>
2073 </td><td>
2072 </td><td>
2074 merge another revision into working directory
2073 merge another revision into working directory
2075 </td></tr>
2074 </td></tr>
2076 <tr><td>
2075 <tr><td>
2077 <a href="/help/pull">
2076 <a href="/help/pull">
2078 pull
2077 pull
2079 </a>
2078 </a>
2080 </td><td>
2079 </td><td>
2081 pull changes from the specified source
2080 pull changes from the specified source
2082 </td></tr>
2081 </td></tr>
2083 <tr><td>
2082 <tr><td>
2084 <a href="/help/push">
2083 <a href="/help/push">
2085 push
2084 push
2086 </a>
2085 </a>
2087 </td><td>
2086 </td><td>
2088 push changes to the specified destination
2087 push changes to the specified destination
2089 </td></tr>
2088 </td></tr>
2090 <tr><td>
2089 <tr><td>
2091 <a href="/help/remove">
2090 <a href="/help/remove">
2092 remove
2091 remove
2093 </a>
2092 </a>
2094 </td><td>
2093 </td><td>
2095 remove the specified files on the next commit
2094 remove the specified files on the next commit
2096 </td></tr>
2095 </td></tr>
2097 <tr><td>
2096 <tr><td>
2098 <a href="/help/serve">
2097 <a href="/help/serve">
2099 serve
2098 serve
2100 </a>
2099 </a>
2101 </td><td>
2100 </td><td>
2102 start stand-alone webserver
2101 start stand-alone webserver
2103 </td></tr>
2102 </td></tr>
2104 <tr><td>
2103 <tr><td>
2105 <a href="/help/status">
2104 <a href="/help/status">
2106 status
2105 status
2107 </a>
2106 </a>
2108 </td><td>
2107 </td><td>
2109 show changed files in the working directory
2108 show changed files in the working directory
2110 </td></tr>
2109 </td></tr>
2111 <tr><td>
2110 <tr><td>
2112 <a href="/help/summary">
2111 <a href="/help/summary">
2113 summary
2112 summary
2114 </a>
2113 </a>
2115 </td><td>
2114 </td><td>
2116 summarize working directory state
2115 summarize working directory state
2117 </td></tr>
2116 </td></tr>
2118 <tr><td>
2117 <tr><td>
2119 <a href="/help/update">
2118 <a href="/help/update">
2120 update
2119 update
2121 </a>
2120 </a>
2122 </td><td>
2121 </td><td>
2123 update working directory (or switch revisions)
2122 update working directory (or switch revisions)
2124 </td></tr>
2123 </td></tr>
2125
2124
2126
2125
2127
2126
2128 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2127 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2129
2128
2130 <tr><td>
2129 <tr><td>
2131 <a href="/help/addremove">
2130 <a href="/help/addremove">
2132 addremove
2131 addremove
2133 </a>
2132 </a>
2134 </td><td>
2133 </td><td>
2135 add all new files, delete all missing files
2134 add all new files, delete all missing files
2136 </td></tr>
2135 </td></tr>
2137 <tr><td>
2136 <tr><td>
2138 <a href="/help/archive">
2137 <a href="/help/archive">
2139 archive
2138 archive
2140 </a>
2139 </a>
2141 </td><td>
2140 </td><td>
2142 create an unversioned archive of a repository revision
2141 create an unversioned archive of a repository revision
2143 </td></tr>
2142 </td></tr>
2144 <tr><td>
2143 <tr><td>
2145 <a href="/help/backout">
2144 <a href="/help/backout">
2146 backout
2145 backout
2147 </a>
2146 </a>
2148 </td><td>
2147 </td><td>
2149 reverse effect of earlier changeset
2148 reverse effect of earlier changeset
2150 </td></tr>
2149 </td></tr>
2151 <tr><td>
2150 <tr><td>
2152 <a href="/help/bisect">
2151 <a href="/help/bisect">
2153 bisect
2152 bisect
2154 </a>
2153 </a>
2155 </td><td>
2154 </td><td>
2156 subdivision search of changesets
2155 subdivision search of changesets
2157 </td></tr>
2156 </td></tr>
2158 <tr><td>
2157 <tr><td>
2159 <a href="/help/bookmarks">
2158 <a href="/help/bookmarks">
2160 bookmarks
2159 bookmarks
2161 </a>
2160 </a>
2162 </td><td>
2161 </td><td>
2163 create a new bookmark or list existing bookmarks
2162 create a new bookmark or list existing bookmarks
2164 </td></tr>
2163 </td></tr>
2165 <tr><td>
2164 <tr><td>
2166 <a href="/help/branch">
2165 <a href="/help/branch">
2167 branch
2166 branch
2168 </a>
2167 </a>
2169 </td><td>
2168 </td><td>
2170 set or show the current branch name
2169 set or show the current branch name
2171 </td></tr>
2170 </td></tr>
2172 <tr><td>
2171 <tr><td>
2173 <a href="/help/branches">
2172 <a href="/help/branches">
2174 branches
2173 branches
2175 </a>
2174 </a>
2176 </td><td>
2175 </td><td>
2177 list repository named branches
2176 list repository named branches
2178 </td></tr>
2177 </td></tr>
2179 <tr><td>
2178 <tr><td>
2180 <a href="/help/bundle">
2179 <a href="/help/bundle">
2181 bundle
2180 bundle
2182 </a>
2181 </a>
2183 </td><td>
2182 </td><td>
2184 create a changegroup file
2183 create a changegroup file
2185 </td></tr>
2184 </td></tr>
2186 <tr><td>
2185 <tr><td>
2187 <a href="/help/cat">
2186 <a href="/help/cat">
2188 cat
2187 cat
2189 </a>
2188 </a>
2190 </td><td>
2189 </td><td>
2191 output the current or given revision of files
2190 output the current or given revision of files
2192 </td></tr>
2191 </td></tr>
2193 <tr><td>
2192 <tr><td>
2194 <a href="/help/config">
2193 <a href="/help/config">
2195 config
2194 config
2196 </a>
2195 </a>
2197 </td><td>
2196 </td><td>
2198 show combined config settings from all hgrc files
2197 show combined config settings from all hgrc files
2199 </td></tr>
2198 </td></tr>
2200 <tr><td>
2199 <tr><td>
2201 <a href="/help/copy">
2200 <a href="/help/copy">
2202 copy
2201 copy
2203 </a>
2202 </a>
2204 </td><td>
2203 </td><td>
2205 mark files as copied for the next commit
2204 mark files as copied for the next commit
2206 </td></tr>
2205 </td></tr>
2207 <tr><td>
2206 <tr><td>
2208 <a href="/help/files">
2207 <a href="/help/files">
2209 files
2208 files
2210 </a>
2209 </a>
2211 </td><td>
2210 </td><td>
2212 list tracked files
2211 list tracked files
2213 </td></tr>
2212 </td></tr>
2214 <tr><td>
2213 <tr><td>
2215 <a href="/help/graft">
2214 <a href="/help/graft">
2216 graft
2215 graft
2217 </a>
2216 </a>
2218 </td><td>
2217 </td><td>
2219 copy changes from other branches onto the current branch
2218 copy changes from other branches onto the current branch
2220 </td></tr>
2219 </td></tr>
2221 <tr><td>
2220 <tr><td>
2222 <a href="/help/grep">
2221 <a href="/help/grep">
2223 grep
2222 grep
2224 </a>
2223 </a>
2225 </td><td>
2224 </td><td>
2226 search revision history for a pattern in specified files
2225 search revision history for a pattern in specified files
2227 </td></tr>
2226 </td></tr>
2228 <tr><td>
2227 <tr><td>
2229 <a href="/help/heads">
2228 <a href="/help/heads">
2230 heads
2229 heads
2231 </a>
2230 </a>
2232 </td><td>
2231 </td><td>
2233 show branch heads
2232 show branch heads
2234 </td></tr>
2233 </td></tr>
2235 <tr><td>
2234 <tr><td>
2236 <a href="/help/help">
2235 <a href="/help/help">
2237 help
2236 help
2238 </a>
2237 </a>
2239 </td><td>
2238 </td><td>
2240 show help for a given topic or a help overview
2239 show help for a given topic or a help overview
2241 </td></tr>
2240 </td></tr>
2242 <tr><td>
2241 <tr><td>
2243 <a href="/help/hgalias">
2242 <a href="/help/hgalias">
2244 hgalias
2243 hgalias
2245 </a>
2244 </a>
2246 </td><td>
2245 </td><td>
2247 summarize working directory state
2246 summarize working directory state
2248 </td></tr>
2247 </td></tr>
2249 <tr><td>
2248 <tr><td>
2250 <a href="/help/identify">
2249 <a href="/help/identify">
2251 identify
2250 identify
2252 </a>
2251 </a>
2253 </td><td>
2252 </td><td>
2254 identify the working directory or specified revision
2253 identify the working directory or specified revision
2255 </td></tr>
2254 </td></tr>
2256 <tr><td>
2255 <tr><td>
2257 <a href="/help/import">
2256 <a href="/help/import">
2258 import
2257 import
2259 </a>
2258 </a>
2260 </td><td>
2259 </td><td>
2261 import an ordered set of patches
2260 import an ordered set of patches
2262 </td></tr>
2261 </td></tr>
2263 <tr><td>
2262 <tr><td>
2264 <a href="/help/incoming">
2263 <a href="/help/incoming">
2265 incoming
2264 incoming
2266 </a>
2265 </a>
2267 </td><td>
2266 </td><td>
2268 show new changesets found in source
2267 show new changesets found in source
2269 </td></tr>
2268 </td></tr>
2270 <tr><td>
2269 <tr><td>
2271 <a href="/help/manifest">
2270 <a href="/help/manifest">
2272 manifest
2271 manifest
2273 </a>
2272 </a>
2274 </td><td>
2273 </td><td>
2275 output the current or given revision of the project manifest
2274 output the current or given revision of the project manifest
2276 </td></tr>
2275 </td></tr>
2277 <tr><td>
2276 <tr><td>
2278 <a href="/help/nohelp">
2277 <a href="/help/nohelp">
2279 nohelp
2278 nohelp
2280 </a>
2279 </a>
2281 </td><td>
2280 </td><td>
2282 (no help text available)
2281 (no help text available)
2283 </td></tr>
2282 </td></tr>
2284 <tr><td>
2283 <tr><td>
2285 <a href="/help/outgoing">
2284 <a href="/help/outgoing">
2286 outgoing
2285 outgoing
2287 </a>
2286 </a>
2288 </td><td>
2287 </td><td>
2289 show changesets not found in the destination
2288 show changesets not found in the destination
2290 </td></tr>
2289 </td></tr>
2291 <tr><td>
2290 <tr><td>
2292 <a href="/help/paths">
2291 <a href="/help/paths">
2293 paths
2292 paths
2294 </a>
2293 </a>
2295 </td><td>
2294 </td><td>
2296 show aliases for remote repositories
2295 show aliases for remote repositories
2297 </td></tr>
2296 </td></tr>
2298 <tr><td>
2297 <tr><td>
2299 <a href="/help/phase">
2298 <a href="/help/phase">
2300 phase
2299 phase
2301 </a>
2300 </a>
2302 </td><td>
2301 </td><td>
2303 set or show the current phase name
2302 set or show the current phase name
2304 </td></tr>
2303 </td></tr>
2305 <tr><td>
2304 <tr><td>
2306 <a href="/help/recover">
2305 <a href="/help/recover">
2307 recover
2306 recover
2308 </a>
2307 </a>
2309 </td><td>
2308 </td><td>
2310 roll back an interrupted transaction
2309 roll back an interrupted transaction
2311 </td></tr>
2310 </td></tr>
2312 <tr><td>
2311 <tr><td>
2313 <a href="/help/rename">
2312 <a href="/help/rename">
2314 rename
2313 rename
2315 </a>
2314 </a>
2316 </td><td>
2315 </td><td>
2317 rename files; equivalent of copy + remove
2316 rename files; equivalent of copy + remove
2318 </td></tr>
2317 </td></tr>
2319 <tr><td>
2318 <tr><td>
2320 <a href="/help/resolve">
2319 <a href="/help/resolve">
2321 resolve
2320 resolve
2322 </a>
2321 </a>
2323 </td><td>
2322 </td><td>
2324 redo merges or set/view the merge status of files
2323 redo merges or set/view the merge status of files
2325 </td></tr>
2324 </td></tr>
2326 <tr><td>
2325 <tr><td>
2327 <a href="/help/revert">
2326 <a href="/help/revert">
2328 revert
2327 revert
2329 </a>
2328 </a>
2330 </td><td>
2329 </td><td>
2331 restore files to their checkout state
2330 restore files to their checkout state
2332 </td></tr>
2331 </td></tr>
2333 <tr><td>
2332 <tr><td>
2334 <a href="/help/root">
2333 <a href="/help/root">
2335 root
2334 root
2336 </a>
2335 </a>
2337 </td><td>
2336 </td><td>
2338 print the root (top) of the current working directory
2337 print the root (top) of the current working directory
2339 </td></tr>
2338 </td></tr>
2340 <tr><td>
2339 <tr><td>
2341 <a href="/help/shellalias">
2340 <a href="/help/shellalias">
2342 shellalias
2341 shellalias
2343 </a>
2342 </a>
2344 </td><td>
2343 </td><td>
2345 (no help text available)
2344 (no help text available)
2346 </td></tr>
2345 </td></tr>
2347 <tr><td>
2346 <tr><td>
2348 <a href="/help/tag">
2347 <a href="/help/tag">
2349 tag
2348 tag
2350 </a>
2349 </a>
2351 </td><td>
2350 </td><td>
2352 add one or more tags for the current or given revision
2351 add one or more tags for the current or given revision
2353 </td></tr>
2352 </td></tr>
2354 <tr><td>
2353 <tr><td>
2355 <a href="/help/tags">
2354 <a href="/help/tags">
2356 tags
2355 tags
2357 </a>
2356 </a>
2358 </td><td>
2357 </td><td>
2359 list repository tags
2358 list repository tags
2360 </td></tr>
2359 </td></tr>
2361 <tr><td>
2360 <tr><td>
2362 <a href="/help/unbundle">
2361 <a href="/help/unbundle">
2363 unbundle
2362 unbundle
2364 </a>
2363 </a>
2365 </td><td>
2364 </td><td>
2366 apply one or more changegroup files
2365 apply one or more changegroup files
2367 </td></tr>
2366 </td></tr>
2368 <tr><td>
2367 <tr><td>
2369 <a href="/help/verify">
2368 <a href="/help/verify">
2370 verify
2369 verify
2371 </a>
2370 </a>
2372 </td><td>
2371 </td><td>
2373 verify the integrity of the repository
2372 verify the integrity of the repository
2374 </td></tr>
2373 </td></tr>
2375 <tr><td>
2374 <tr><td>
2376 <a href="/help/version">
2375 <a href="/help/version">
2377 version
2376 version
2378 </a>
2377 </a>
2379 </td><td>
2378 </td><td>
2380 output version and copyright information
2379 output version and copyright information
2381 </td></tr>
2380 </td></tr>
2382
2381
2383
2382
2384 </table>
2383 </table>
2385 </div>
2384 </div>
2386 </div>
2385 </div>
2387
2386
2388
2387
2389
2388
2390 </body>
2389 </body>
2391 </html>
2390 </html>
2392
2391
2393
2392
2394 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2393 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2395 200 Script output follows
2394 200 Script output follows
2396
2395
2397 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2396 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2398 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2397 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2399 <head>
2398 <head>
2400 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2399 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2401 <meta name="robots" content="index, nofollow" />
2400 <meta name="robots" content="index, nofollow" />
2402 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2401 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2403 <script type="text/javascript" src="/static/mercurial.js"></script>
2402 <script type="text/javascript" src="/static/mercurial.js"></script>
2404
2403
2405 <title>Help: add</title>
2404 <title>Help: add</title>
2406 </head>
2405 </head>
2407 <body>
2406 <body>
2408
2407
2409 <div class="container">
2408 <div class="container">
2410 <div class="menu">
2409 <div class="menu">
2411 <div class="logo">
2410 <div class="logo">
2412 <a href="https://mercurial-scm.org/">
2411 <a href="https://mercurial-scm.org/">
2413 <img src="/static/hglogo.png" alt="mercurial" /></a>
2412 <img src="/static/hglogo.png" alt="mercurial" /></a>
2414 </div>
2413 </div>
2415 <ul>
2414 <ul>
2416 <li><a href="/shortlog">log</a></li>
2415 <li><a href="/shortlog">log</a></li>
2417 <li><a href="/graph">graph</a></li>
2416 <li><a href="/graph">graph</a></li>
2418 <li><a href="/tags">tags</a></li>
2417 <li><a href="/tags">tags</a></li>
2419 <li><a href="/bookmarks">bookmarks</a></li>
2418 <li><a href="/bookmarks">bookmarks</a></li>
2420 <li><a href="/branches">branches</a></li>
2419 <li><a href="/branches">branches</a></li>
2421 </ul>
2420 </ul>
2422 <ul>
2421 <ul>
2423 <li class="active"><a href="/help">help</a></li>
2422 <li class="active"><a href="/help">help</a></li>
2424 </ul>
2423 </ul>
2425 </div>
2424 </div>
2426
2425
2427 <div class="main">
2426 <div class="main">
2428 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2427 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2429 <h3>Help: add</h3>
2428 <h3>Help: add</h3>
2430
2429
2431 <form class="search" action="/log">
2430 <form class="search" action="/log">
2432
2431
2433 <p><input name="rev" id="search1" type="text" size="30" /></p>
2432 <p><input name="rev" id="search1" type="text" size="30" /></p>
2434 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2433 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2435 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2434 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2436 </form>
2435 </form>
2437 <div id="doc">
2436 <div id="doc">
2438 <p>
2437 <p>
2439 hg add [OPTION]... [FILE]...
2438 hg add [OPTION]... [FILE]...
2440 </p>
2439 </p>
2441 <p>
2440 <p>
2442 add the specified files on the next commit
2441 add the specified files on the next commit
2443 </p>
2442 </p>
2444 <p>
2443 <p>
2445 Schedule files to be version controlled and added to the
2444 Schedule files to be version controlled and added to the
2446 repository.
2445 repository.
2447 </p>
2446 </p>
2448 <p>
2447 <p>
2449 The files will be added to the repository at the next commit. To
2448 The files will be added to the repository at the next commit. To
2450 undo an add before that, see 'hg forget'.
2449 undo an add before that, see 'hg forget'.
2451 </p>
2450 </p>
2452 <p>
2451 <p>
2453 If no names are given, add all files to the repository (except
2452 If no names are given, add all files to the repository (except
2454 files matching &quot;.hgignore&quot;).
2453 files matching &quot;.hgignore&quot;).
2455 </p>
2454 </p>
2456 <p>
2455 <p>
2457 Examples:
2456 Examples:
2458 </p>
2457 </p>
2459 <ul>
2458 <ul>
2460 <li> New (unknown) files are added automatically by 'hg add':
2459 <li> New (unknown) files are added automatically by 'hg add':
2461 <pre>
2460 <pre>
2462 \$ ls (re)
2461 \$ ls (re)
2463 foo.c
2462 foo.c
2464 \$ hg status (re)
2463 \$ hg status (re)
2465 ? foo.c
2464 ? foo.c
2466 \$ hg add (re)
2465 \$ hg add (re)
2467 adding foo.c
2466 adding foo.c
2468 \$ hg status (re)
2467 \$ hg status (re)
2469 A foo.c
2468 A foo.c
2470 </pre>
2469 </pre>
2471 <li> Specific files to be added can be specified:
2470 <li> Specific files to be added can be specified:
2472 <pre>
2471 <pre>
2473 \$ ls (re)
2472 \$ ls (re)
2474 bar.c foo.c
2473 bar.c foo.c
2475 \$ hg status (re)
2474 \$ hg status (re)
2476 ? bar.c
2475 ? bar.c
2477 ? foo.c
2476 ? foo.c
2478 \$ hg add bar.c (re)
2477 \$ hg add bar.c (re)
2479 \$ hg status (re)
2478 \$ hg status (re)
2480 A bar.c
2479 A bar.c
2481 ? foo.c
2480 ? foo.c
2482 </pre>
2481 </pre>
2483 </ul>
2482 </ul>
2484 <p>
2483 <p>
2485 Returns 0 if all files are successfully added.
2484 Returns 0 if all files are successfully added.
2486 </p>
2485 </p>
2487 <p>
2486 <p>
2488 options ([+] can be repeated):
2487 options ([+] can be repeated):
2489 </p>
2488 </p>
2490 <table>
2489 <table>
2491 <tr><td>-I</td>
2490 <tr><td>-I</td>
2492 <td>--include PATTERN [+]</td>
2491 <td>--include PATTERN [+]</td>
2493 <td>include names matching the given patterns</td></tr>
2492 <td>include names matching the given patterns</td></tr>
2494 <tr><td>-X</td>
2493 <tr><td>-X</td>
2495 <td>--exclude PATTERN [+]</td>
2494 <td>--exclude PATTERN [+]</td>
2496 <td>exclude names matching the given patterns</td></tr>
2495 <td>exclude names matching the given patterns</td></tr>
2497 <tr><td>-S</td>
2496 <tr><td>-S</td>
2498 <td>--subrepos</td>
2497 <td>--subrepos</td>
2499 <td>recurse into subrepositories</td></tr>
2498 <td>recurse into subrepositories</td></tr>
2500 <tr><td>-n</td>
2499 <tr><td>-n</td>
2501 <td>--dry-run</td>
2500 <td>--dry-run</td>
2502 <td>do not perform actions, just print output</td></tr>
2501 <td>do not perform actions, just print output</td></tr>
2503 </table>
2502 </table>
2504 <p>
2503 <p>
2505 global options ([+] can be repeated):
2504 global options ([+] can be repeated):
2506 </p>
2505 </p>
2507 <table>
2506 <table>
2508 <tr><td>-R</td>
2507 <tr><td>-R</td>
2509 <td>--repository REPO</td>
2508 <td>--repository REPO</td>
2510 <td>repository root directory or name of overlay bundle file</td></tr>
2509 <td>repository root directory or name of overlay bundle file</td></tr>
2511 <tr><td></td>
2510 <tr><td></td>
2512 <td>--cwd DIR</td>
2511 <td>--cwd DIR</td>
2513 <td>change working directory</td></tr>
2512 <td>change working directory</td></tr>
2514 <tr><td>-y</td>
2513 <tr><td>-y</td>
2515 <td>--noninteractive</td>
2514 <td>--noninteractive</td>
2516 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2515 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2517 <tr><td>-q</td>
2516 <tr><td>-q</td>
2518 <td>--quiet</td>
2517 <td>--quiet</td>
2519 <td>suppress output</td></tr>
2518 <td>suppress output</td></tr>
2520 <tr><td>-v</td>
2519 <tr><td>-v</td>
2521 <td>--verbose</td>
2520 <td>--verbose</td>
2522 <td>enable additional output</td></tr>
2521 <td>enable additional output</td></tr>
2523 <tr><td></td>
2522 <tr><td></td>
2524 <td>--color TYPE</td>
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 <tr><td></td>
2525 <tr><td></td>
2527 <td>--config CONFIG [+]</td>
2526 <td>--config CONFIG [+]</td>
2528 <td>set/override config option (use 'section.name=value')</td></tr>
2527 <td>set/override config option (use 'section.name=value')</td></tr>
2529 <tr><td></td>
2528 <tr><td></td>
2530 <td>--debug</td>
2529 <td>--debug</td>
2531 <td>enable debugging output</td></tr>
2530 <td>enable debugging output</td></tr>
2532 <tr><td></td>
2531 <tr><td></td>
2533 <td>--debugger</td>
2532 <td>--debugger</td>
2534 <td>start debugger</td></tr>
2533 <td>start debugger</td></tr>
2535 <tr><td></td>
2534 <tr><td></td>
2536 <td>--encoding ENCODE</td>
2535 <td>--encoding ENCODE</td>
2537 <td>set the charset encoding (default: ascii)</td></tr>
2536 <td>set the charset encoding (default: ascii)</td></tr>
2538 <tr><td></td>
2537 <tr><td></td>
2539 <td>--encodingmode MODE</td>
2538 <td>--encodingmode MODE</td>
2540 <td>set the charset encoding mode (default: strict)</td></tr>
2539 <td>set the charset encoding mode (default: strict)</td></tr>
2541 <tr><td></td>
2540 <tr><td></td>
2542 <td>--traceback</td>
2541 <td>--traceback</td>
2543 <td>always print a traceback on exception</td></tr>
2542 <td>always print a traceback on exception</td></tr>
2544 <tr><td></td>
2543 <tr><td></td>
2545 <td>--time</td>
2544 <td>--time</td>
2546 <td>time how long the command takes</td></tr>
2545 <td>time how long the command takes</td></tr>
2547 <tr><td></td>
2546 <tr><td></td>
2548 <td>--profile</td>
2547 <td>--profile</td>
2549 <td>print command execution profile</td></tr>
2548 <td>print command execution profile</td></tr>
2550 <tr><td></td>
2549 <tr><td></td>
2551 <td>--version</td>
2550 <td>--version</td>
2552 <td>output version information and exit</td></tr>
2551 <td>output version information and exit</td></tr>
2553 <tr><td>-h</td>
2552 <tr><td>-h</td>
2554 <td>--help</td>
2553 <td>--help</td>
2555 <td>display help and exit</td></tr>
2554 <td>display help and exit</td></tr>
2556 <tr><td></td>
2555 <tr><td></td>
2557 <td>--hidden</td>
2556 <td>--hidden</td>
2558 <td>consider hidden changesets</td></tr>
2557 <td>consider hidden changesets</td></tr>
2559 <tr><td></td>
2558 <tr><td></td>
2560 <td>--pager TYPE</td>
2559 <td>--pager TYPE</td>
2561 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2560 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2562 </table>
2561 </table>
2563
2562
2564 </div>
2563 </div>
2565 </div>
2564 </div>
2566 </div>
2565 </div>
2567
2566
2568
2567
2569
2568
2570 </body>
2569 </body>
2571 </html>
2570 </html>
2572
2571
2573
2572
2574 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2573 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2575 200 Script output follows
2574 200 Script output follows
2576
2575
2577 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2576 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2578 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2577 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2579 <head>
2578 <head>
2580 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2579 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2581 <meta name="robots" content="index, nofollow" />
2580 <meta name="robots" content="index, nofollow" />
2582 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2581 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2583 <script type="text/javascript" src="/static/mercurial.js"></script>
2582 <script type="text/javascript" src="/static/mercurial.js"></script>
2584
2583
2585 <title>Help: remove</title>
2584 <title>Help: remove</title>
2586 </head>
2585 </head>
2587 <body>
2586 <body>
2588
2587
2589 <div class="container">
2588 <div class="container">
2590 <div class="menu">
2589 <div class="menu">
2591 <div class="logo">
2590 <div class="logo">
2592 <a href="https://mercurial-scm.org/">
2591 <a href="https://mercurial-scm.org/">
2593 <img src="/static/hglogo.png" alt="mercurial" /></a>
2592 <img src="/static/hglogo.png" alt="mercurial" /></a>
2594 </div>
2593 </div>
2595 <ul>
2594 <ul>
2596 <li><a href="/shortlog">log</a></li>
2595 <li><a href="/shortlog">log</a></li>
2597 <li><a href="/graph">graph</a></li>
2596 <li><a href="/graph">graph</a></li>
2598 <li><a href="/tags">tags</a></li>
2597 <li><a href="/tags">tags</a></li>
2599 <li><a href="/bookmarks">bookmarks</a></li>
2598 <li><a href="/bookmarks">bookmarks</a></li>
2600 <li><a href="/branches">branches</a></li>
2599 <li><a href="/branches">branches</a></li>
2601 </ul>
2600 </ul>
2602 <ul>
2601 <ul>
2603 <li class="active"><a href="/help">help</a></li>
2602 <li class="active"><a href="/help">help</a></li>
2604 </ul>
2603 </ul>
2605 </div>
2604 </div>
2606
2605
2607 <div class="main">
2606 <div class="main">
2608 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2607 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2609 <h3>Help: remove</h3>
2608 <h3>Help: remove</h3>
2610
2609
2611 <form class="search" action="/log">
2610 <form class="search" action="/log">
2612
2611
2613 <p><input name="rev" id="search1" type="text" size="30" /></p>
2612 <p><input name="rev" id="search1" type="text" size="30" /></p>
2614 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2613 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2615 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2614 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2616 </form>
2615 </form>
2617 <div id="doc">
2616 <div id="doc">
2618 <p>
2617 <p>
2619 hg remove [OPTION]... FILE...
2618 hg remove [OPTION]... FILE...
2620 </p>
2619 </p>
2621 <p>
2620 <p>
2622 aliases: rm
2621 aliases: rm
2623 </p>
2622 </p>
2624 <p>
2623 <p>
2625 remove the specified files on the next commit
2624 remove the specified files on the next commit
2626 </p>
2625 </p>
2627 <p>
2626 <p>
2628 Schedule the indicated files for removal from the current branch.
2627 Schedule the indicated files for removal from the current branch.
2629 </p>
2628 </p>
2630 <p>
2629 <p>
2631 This command schedules the files to be removed at the next commit.
2630 This command schedules the files to be removed at the next commit.
2632 To undo a remove before that, see 'hg revert'. To undo added
2631 To undo a remove before that, see 'hg revert'. To undo added
2633 files, see 'hg forget'.
2632 files, see 'hg forget'.
2634 </p>
2633 </p>
2635 <p>
2634 <p>
2636 -A/--after can be used to remove only files that have already
2635 -A/--after can be used to remove only files that have already
2637 been deleted, -f/--force can be used to force deletion, and -Af
2636 been deleted, -f/--force can be used to force deletion, and -Af
2638 can be used to remove files from the next revision without
2637 can be used to remove files from the next revision without
2639 deleting them from the working directory.
2638 deleting them from the working directory.
2640 </p>
2639 </p>
2641 <p>
2640 <p>
2642 The following table details the behavior of remove for different
2641 The following table details the behavior of remove for different
2643 file states (columns) and option combinations (rows). The file
2642 file states (columns) and option combinations (rows). The file
2644 states are Added [A], Clean [C], Modified [M] and Missing [!]
2643 states are Added [A], Clean [C], Modified [M] and Missing [!]
2645 (as reported by 'hg status'). The actions are Warn, Remove
2644 (as reported by 'hg status'). The actions are Warn, Remove
2646 (from branch) and Delete (from disk):
2645 (from branch) and Delete (from disk):
2647 </p>
2646 </p>
2648 <table>
2647 <table>
2649 <tr><td>opt/state</td>
2648 <tr><td>opt/state</td>
2650 <td>A</td>
2649 <td>A</td>
2651 <td>C</td>
2650 <td>C</td>
2652 <td>M</td>
2651 <td>M</td>
2653 <td>!</td></tr>
2652 <td>!</td></tr>
2654 <tr><td>none</td>
2653 <tr><td>none</td>
2655 <td>W</td>
2654 <td>W</td>
2656 <td>RD</td>
2655 <td>RD</td>
2657 <td>W</td>
2656 <td>W</td>
2658 <td>R</td></tr>
2657 <td>R</td></tr>
2659 <tr><td>-f</td>
2658 <tr><td>-f</td>
2660 <td>R</td>
2659 <td>R</td>
2661 <td>RD</td>
2660 <td>RD</td>
2662 <td>RD</td>
2661 <td>RD</td>
2663 <td>R</td></tr>
2662 <td>R</td></tr>
2664 <tr><td>-A</td>
2663 <tr><td>-A</td>
2665 <td>W</td>
2664 <td>W</td>
2666 <td>W</td>
2665 <td>W</td>
2667 <td>W</td>
2666 <td>W</td>
2668 <td>R</td></tr>
2667 <td>R</td></tr>
2669 <tr><td>-Af</td>
2668 <tr><td>-Af</td>
2670 <td>R</td>
2669 <td>R</td>
2671 <td>R</td>
2670 <td>R</td>
2672 <td>R</td>
2671 <td>R</td>
2673 <td>R</td></tr>
2672 <td>R</td></tr>
2674 </table>
2673 </table>
2675 <p>
2674 <p>
2676 <b>Note:</b>
2675 <b>Note:</b>
2677 </p>
2676 </p>
2678 <p>
2677 <p>
2679 'hg remove' never deletes files in Added [A] state from the
2678 'hg remove' never deletes files in Added [A] state from the
2680 working directory, not even if &quot;--force&quot; is specified.
2679 working directory, not even if &quot;--force&quot; is specified.
2681 </p>
2680 </p>
2682 <p>
2681 <p>
2683 Returns 0 on success, 1 if any warnings encountered.
2682 Returns 0 on success, 1 if any warnings encountered.
2684 </p>
2683 </p>
2685 <p>
2684 <p>
2686 options ([+] can be repeated):
2685 options ([+] can be repeated):
2687 </p>
2686 </p>
2688 <table>
2687 <table>
2689 <tr><td>-A</td>
2688 <tr><td>-A</td>
2690 <td>--after</td>
2689 <td>--after</td>
2691 <td>record delete for missing files</td></tr>
2690 <td>record delete for missing files</td></tr>
2692 <tr><td>-f</td>
2691 <tr><td>-f</td>
2693 <td>--force</td>
2692 <td>--force</td>
2694 <td>forget added files, delete modified files</td></tr>
2693 <td>forget added files, delete modified files</td></tr>
2695 <tr><td>-S</td>
2694 <tr><td>-S</td>
2696 <td>--subrepos</td>
2695 <td>--subrepos</td>
2697 <td>recurse into subrepositories</td></tr>
2696 <td>recurse into subrepositories</td></tr>
2698 <tr><td>-I</td>
2697 <tr><td>-I</td>
2699 <td>--include PATTERN [+]</td>
2698 <td>--include PATTERN [+]</td>
2700 <td>include names matching the given patterns</td></tr>
2699 <td>include names matching the given patterns</td></tr>
2701 <tr><td>-X</td>
2700 <tr><td>-X</td>
2702 <td>--exclude PATTERN [+]</td>
2701 <td>--exclude PATTERN [+]</td>
2703 <td>exclude names matching the given patterns</td></tr>
2702 <td>exclude names matching the given patterns</td></tr>
2704 </table>
2703 </table>
2705 <p>
2704 <p>
2706 global options ([+] can be repeated):
2705 global options ([+] can be repeated):
2707 </p>
2706 </p>
2708 <table>
2707 <table>
2709 <tr><td>-R</td>
2708 <tr><td>-R</td>
2710 <td>--repository REPO</td>
2709 <td>--repository REPO</td>
2711 <td>repository root directory or name of overlay bundle file</td></tr>
2710 <td>repository root directory or name of overlay bundle file</td></tr>
2712 <tr><td></td>
2711 <tr><td></td>
2713 <td>--cwd DIR</td>
2712 <td>--cwd DIR</td>
2714 <td>change working directory</td></tr>
2713 <td>change working directory</td></tr>
2715 <tr><td>-y</td>
2714 <tr><td>-y</td>
2716 <td>--noninteractive</td>
2715 <td>--noninteractive</td>
2717 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2716 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2718 <tr><td>-q</td>
2717 <tr><td>-q</td>
2719 <td>--quiet</td>
2718 <td>--quiet</td>
2720 <td>suppress output</td></tr>
2719 <td>suppress output</td></tr>
2721 <tr><td>-v</td>
2720 <tr><td>-v</td>
2722 <td>--verbose</td>
2721 <td>--verbose</td>
2723 <td>enable additional output</td></tr>
2722 <td>enable additional output</td></tr>
2724 <tr><td></td>
2723 <tr><td></td>
2725 <td>--color TYPE</td>
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 <tr><td></td>
2726 <tr><td></td>
2728 <td>--config CONFIG [+]</td>
2727 <td>--config CONFIG [+]</td>
2729 <td>set/override config option (use 'section.name=value')</td></tr>
2728 <td>set/override config option (use 'section.name=value')</td></tr>
2730 <tr><td></td>
2729 <tr><td></td>
2731 <td>--debug</td>
2730 <td>--debug</td>
2732 <td>enable debugging output</td></tr>
2731 <td>enable debugging output</td></tr>
2733 <tr><td></td>
2732 <tr><td></td>
2734 <td>--debugger</td>
2733 <td>--debugger</td>
2735 <td>start debugger</td></tr>
2734 <td>start debugger</td></tr>
2736 <tr><td></td>
2735 <tr><td></td>
2737 <td>--encoding ENCODE</td>
2736 <td>--encoding ENCODE</td>
2738 <td>set the charset encoding (default: ascii)</td></tr>
2737 <td>set the charset encoding (default: ascii)</td></tr>
2739 <tr><td></td>
2738 <tr><td></td>
2740 <td>--encodingmode MODE</td>
2739 <td>--encodingmode MODE</td>
2741 <td>set the charset encoding mode (default: strict)</td></tr>
2740 <td>set the charset encoding mode (default: strict)</td></tr>
2742 <tr><td></td>
2741 <tr><td></td>
2743 <td>--traceback</td>
2742 <td>--traceback</td>
2744 <td>always print a traceback on exception</td></tr>
2743 <td>always print a traceback on exception</td></tr>
2745 <tr><td></td>
2744 <tr><td></td>
2746 <td>--time</td>
2745 <td>--time</td>
2747 <td>time how long the command takes</td></tr>
2746 <td>time how long the command takes</td></tr>
2748 <tr><td></td>
2747 <tr><td></td>
2749 <td>--profile</td>
2748 <td>--profile</td>
2750 <td>print command execution profile</td></tr>
2749 <td>print command execution profile</td></tr>
2751 <tr><td></td>
2750 <tr><td></td>
2752 <td>--version</td>
2751 <td>--version</td>
2753 <td>output version information and exit</td></tr>
2752 <td>output version information and exit</td></tr>
2754 <tr><td>-h</td>
2753 <tr><td>-h</td>
2755 <td>--help</td>
2754 <td>--help</td>
2756 <td>display help and exit</td></tr>
2755 <td>display help and exit</td></tr>
2757 <tr><td></td>
2756 <tr><td></td>
2758 <td>--hidden</td>
2757 <td>--hidden</td>
2759 <td>consider hidden changesets</td></tr>
2758 <td>consider hidden changesets</td></tr>
2760 <tr><td></td>
2759 <tr><td></td>
2761 <td>--pager TYPE</td>
2760 <td>--pager TYPE</td>
2762 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2761 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2763 </table>
2762 </table>
2764
2763
2765 </div>
2764 </div>
2766 </div>
2765 </div>
2767 </div>
2766 </div>
2768
2767
2769
2768
2770
2769
2771 </body>
2770 </body>
2772 </html>
2771 </html>
2773
2772
2774
2773
2775 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
2774 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
2776 200 Script output follows
2775 200 Script output follows
2777
2776
2778 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2777 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2779 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2778 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2780 <head>
2779 <head>
2781 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2780 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2782 <meta name="robots" content="index, nofollow" />
2781 <meta name="robots" content="index, nofollow" />
2783 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2782 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2784 <script type="text/javascript" src="/static/mercurial.js"></script>
2783 <script type="text/javascript" src="/static/mercurial.js"></script>
2785
2784
2786 <title>Help: dates</title>
2785 <title>Help: dates</title>
2787 </head>
2786 </head>
2788 <body>
2787 <body>
2789
2788
2790 <div class="container">
2789 <div class="container">
2791 <div class="menu">
2790 <div class="menu">
2792 <div class="logo">
2791 <div class="logo">
2793 <a href="https://mercurial-scm.org/">
2792 <a href="https://mercurial-scm.org/">
2794 <img src="/static/hglogo.png" alt="mercurial" /></a>
2793 <img src="/static/hglogo.png" alt="mercurial" /></a>
2795 </div>
2794 </div>
2796 <ul>
2795 <ul>
2797 <li><a href="/shortlog">log</a></li>
2796 <li><a href="/shortlog">log</a></li>
2798 <li><a href="/graph">graph</a></li>
2797 <li><a href="/graph">graph</a></li>
2799 <li><a href="/tags">tags</a></li>
2798 <li><a href="/tags">tags</a></li>
2800 <li><a href="/bookmarks">bookmarks</a></li>
2799 <li><a href="/bookmarks">bookmarks</a></li>
2801 <li><a href="/branches">branches</a></li>
2800 <li><a href="/branches">branches</a></li>
2802 </ul>
2801 </ul>
2803 <ul>
2802 <ul>
2804 <li class="active"><a href="/help">help</a></li>
2803 <li class="active"><a href="/help">help</a></li>
2805 </ul>
2804 </ul>
2806 </div>
2805 </div>
2807
2806
2808 <div class="main">
2807 <div class="main">
2809 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2808 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2810 <h3>Help: dates</h3>
2809 <h3>Help: dates</h3>
2811
2810
2812 <form class="search" action="/log">
2811 <form class="search" action="/log">
2813
2812
2814 <p><input name="rev" id="search1" type="text" size="30" /></p>
2813 <p><input name="rev" id="search1" type="text" size="30" /></p>
2815 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2814 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2816 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2815 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2817 </form>
2816 </form>
2818 <div id="doc">
2817 <div id="doc">
2819 <h1>Date Formats</h1>
2818 <h1>Date Formats</h1>
2820 <p>
2819 <p>
2821 Some commands allow the user to specify a date, e.g.:
2820 Some commands allow the user to specify a date, e.g.:
2822 </p>
2821 </p>
2823 <ul>
2822 <ul>
2824 <li> backout, commit, import, tag: Specify the commit date.
2823 <li> backout, commit, import, tag: Specify the commit date.
2825 <li> log, revert, update: Select revision(s) by date.
2824 <li> log, revert, update: Select revision(s) by date.
2826 </ul>
2825 </ul>
2827 <p>
2826 <p>
2828 Many date formats are valid. Here are some examples:
2827 Many date formats are valid. Here are some examples:
2829 </p>
2828 </p>
2830 <ul>
2829 <ul>
2831 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
2830 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
2832 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
2831 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
2833 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
2832 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
2834 <li> &quot;Dec 6&quot; (midnight)
2833 <li> &quot;Dec 6&quot; (midnight)
2835 <li> &quot;13:18&quot; (today assumed)
2834 <li> &quot;13:18&quot; (today assumed)
2836 <li> &quot;3:39&quot; (3:39AM assumed)
2835 <li> &quot;3:39&quot; (3:39AM assumed)
2837 <li> &quot;3:39pm&quot; (15:39)
2836 <li> &quot;3:39pm&quot; (15:39)
2838 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
2837 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
2839 <li> &quot;2006-12-6 13:18&quot;
2838 <li> &quot;2006-12-6 13:18&quot;
2840 <li> &quot;2006-12-6&quot;
2839 <li> &quot;2006-12-6&quot;
2841 <li> &quot;12-6&quot;
2840 <li> &quot;12-6&quot;
2842 <li> &quot;12/6&quot;
2841 <li> &quot;12/6&quot;
2843 <li> &quot;12/6/6&quot; (Dec 6 2006)
2842 <li> &quot;12/6/6&quot; (Dec 6 2006)
2844 <li> &quot;today&quot; (midnight)
2843 <li> &quot;today&quot; (midnight)
2845 <li> &quot;yesterday&quot; (midnight)
2844 <li> &quot;yesterday&quot; (midnight)
2846 <li> &quot;now&quot; - right now
2845 <li> &quot;now&quot; - right now
2847 </ul>
2846 </ul>
2848 <p>
2847 <p>
2849 Lastly, there is Mercurial's internal format:
2848 Lastly, there is Mercurial's internal format:
2850 </p>
2849 </p>
2851 <ul>
2850 <ul>
2852 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
2851 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
2853 </ul>
2852 </ul>
2854 <p>
2853 <p>
2855 This is the internal representation format for dates. The first number
2854 This is the internal representation format for dates. The first number
2856 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
2855 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
2857 second is the offset of the local timezone, in seconds west of UTC
2856 second is the offset of the local timezone, in seconds west of UTC
2858 (negative if the timezone is east of UTC).
2857 (negative if the timezone is east of UTC).
2859 </p>
2858 </p>
2860 <p>
2859 <p>
2861 The log command also accepts date ranges:
2860 The log command also accepts date ranges:
2862 </p>
2861 </p>
2863 <ul>
2862 <ul>
2864 <li> &quot;&lt;DATE&quot; - at or before a given date/time
2863 <li> &quot;&lt;DATE&quot; - at or before a given date/time
2865 <li> &quot;&gt;DATE&quot; - on or after a given date/time
2864 <li> &quot;&gt;DATE&quot; - on or after a given date/time
2866 <li> &quot;DATE to DATE&quot; - a date range, inclusive
2865 <li> &quot;DATE to DATE&quot; - a date range, inclusive
2867 <li> &quot;-DAYS&quot; - within a given number of days of today
2866 <li> &quot;-DAYS&quot; - within a given number of days of today
2868 </ul>
2867 </ul>
2869
2868
2870 </div>
2869 </div>
2871 </div>
2870 </div>
2872 </div>
2871 </div>
2873
2872
2874
2873
2875
2874
2876 </body>
2875 </body>
2877 </html>
2876 </html>
2878
2877
2879
2878
2880 Sub-topic indexes rendered properly
2879 Sub-topic indexes rendered properly
2881
2880
2882 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
2881 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
2883 200 Script output follows
2882 200 Script output follows
2884
2883
2885 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2884 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2886 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2885 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2887 <head>
2886 <head>
2888 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2887 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2889 <meta name="robots" content="index, nofollow" />
2888 <meta name="robots" content="index, nofollow" />
2890 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2889 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2891 <script type="text/javascript" src="/static/mercurial.js"></script>
2890 <script type="text/javascript" src="/static/mercurial.js"></script>
2892
2891
2893 <title>Help: internals</title>
2892 <title>Help: internals</title>
2894 </head>
2893 </head>
2895 <body>
2894 <body>
2896
2895
2897 <div class="container">
2896 <div class="container">
2898 <div class="menu">
2897 <div class="menu">
2899 <div class="logo">
2898 <div class="logo">
2900 <a href="https://mercurial-scm.org/">
2899 <a href="https://mercurial-scm.org/">
2901 <img src="/static/hglogo.png" alt="mercurial" /></a>
2900 <img src="/static/hglogo.png" alt="mercurial" /></a>
2902 </div>
2901 </div>
2903 <ul>
2902 <ul>
2904 <li><a href="/shortlog">log</a></li>
2903 <li><a href="/shortlog">log</a></li>
2905 <li><a href="/graph">graph</a></li>
2904 <li><a href="/graph">graph</a></li>
2906 <li><a href="/tags">tags</a></li>
2905 <li><a href="/tags">tags</a></li>
2907 <li><a href="/bookmarks">bookmarks</a></li>
2906 <li><a href="/bookmarks">bookmarks</a></li>
2908 <li><a href="/branches">branches</a></li>
2907 <li><a href="/branches">branches</a></li>
2909 </ul>
2908 </ul>
2910 <ul>
2909 <ul>
2911 <li><a href="/help">help</a></li>
2910 <li><a href="/help">help</a></li>
2912 </ul>
2911 </ul>
2913 </div>
2912 </div>
2914
2913
2915 <div class="main">
2914 <div class="main">
2916 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2915 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2917 <form class="search" action="/log">
2916 <form class="search" action="/log">
2918
2917
2919 <p><input name="rev" id="search1" type="text" size="30" /></p>
2918 <p><input name="rev" id="search1" type="text" size="30" /></p>
2920 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2919 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2921 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2920 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2922 </form>
2921 </form>
2923 <table class="bigtable">
2922 <table class="bigtable">
2924 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2923 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2925
2924
2926 <tr><td>
2925 <tr><td>
2927 <a href="/help/internals.bundles">
2926 <a href="/help/internals.bundles">
2928 bundles
2927 bundles
2929 </a>
2928 </a>
2930 </td><td>
2929 </td><td>
2931 Bundles
2930 Bundles
2932 </td></tr>
2931 </td></tr>
2933 <tr><td>
2932 <tr><td>
2934 <a href="/help/internals.changegroups">
2933 <a href="/help/internals.changegroups">
2935 changegroups
2934 changegroups
2936 </a>
2935 </a>
2937 </td><td>
2936 </td><td>
2938 Changegroups
2937 Changegroups
2939 </td></tr>
2938 </td></tr>
2940 <tr><td>
2939 <tr><td>
2941 <a href="/help/internals.requirements">
2940 <a href="/help/internals.requirements">
2942 requirements
2941 requirements
2943 </a>
2942 </a>
2944 </td><td>
2943 </td><td>
2945 Repository Requirements
2944 Repository Requirements
2946 </td></tr>
2945 </td></tr>
2947 <tr><td>
2946 <tr><td>
2948 <a href="/help/internals.revlogs">
2947 <a href="/help/internals.revlogs">
2949 revlogs
2948 revlogs
2950 </a>
2949 </a>
2951 </td><td>
2950 </td><td>
2952 Revision Logs
2951 Revision Logs
2953 </td></tr>
2952 </td></tr>
2954 <tr><td>
2953 <tr><td>
2955 <a href="/help/internals.wireprotocol">
2954 <a href="/help/internals.wireprotocol">
2956 wireprotocol
2955 wireprotocol
2957 </a>
2956 </a>
2958 </td><td>
2957 </td><td>
2959 Wire Protocol
2958 Wire Protocol
2960 </td></tr>
2959 </td></tr>
2961
2960
2962
2961
2963
2962
2964
2963
2965
2964
2966 </table>
2965 </table>
2967 </div>
2966 </div>
2968 </div>
2967 </div>
2969
2968
2970
2969
2971
2970
2972 </body>
2971 </body>
2973 </html>
2972 </html>
2974
2973
2975
2974
2976 Sub-topic topics rendered properly
2975 Sub-topic topics rendered properly
2977
2976
2978 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
2977 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
2979 200 Script output follows
2978 200 Script output follows
2980
2979
2981 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2980 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2982 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2981 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2983 <head>
2982 <head>
2984 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2983 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2985 <meta name="robots" content="index, nofollow" />
2984 <meta name="robots" content="index, nofollow" />
2986 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2985 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2987 <script type="text/javascript" src="/static/mercurial.js"></script>
2986 <script type="text/javascript" src="/static/mercurial.js"></script>
2988
2987
2989 <title>Help: internals.changegroups</title>
2988 <title>Help: internals.changegroups</title>
2990 </head>
2989 </head>
2991 <body>
2990 <body>
2992
2991
2993 <div class="container">
2992 <div class="container">
2994 <div class="menu">
2993 <div class="menu">
2995 <div class="logo">
2994 <div class="logo">
2996 <a href="https://mercurial-scm.org/">
2995 <a href="https://mercurial-scm.org/">
2997 <img src="/static/hglogo.png" alt="mercurial" /></a>
2996 <img src="/static/hglogo.png" alt="mercurial" /></a>
2998 </div>
2997 </div>
2999 <ul>
2998 <ul>
3000 <li><a href="/shortlog">log</a></li>
2999 <li><a href="/shortlog">log</a></li>
3001 <li><a href="/graph">graph</a></li>
3000 <li><a href="/graph">graph</a></li>
3002 <li><a href="/tags">tags</a></li>
3001 <li><a href="/tags">tags</a></li>
3003 <li><a href="/bookmarks">bookmarks</a></li>
3002 <li><a href="/bookmarks">bookmarks</a></li>
3004 <li><a href="/branches">branches</a></li>
3003 <li><a href="/branches">branches</a></li>
3005 </ul>
3004 </ul>
3006 <ul>
3005 <ul>
3007 <li class="active"><a href="/help">help</a></li>
3006 <li class="active"><a href="/help">help</a></li>
3008 </ul>
3007 </ul>
3009 </div>
3008 </div>
3010
3009
3011 <div class="main">
3010 <div class="main">
3012 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3011 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3013 <h3>Help: internals.changegroups</h3>
3012 <h3>Help: internals.changegroups</h3>
3014
3013
3015 <form class="search" action="/log">
3014 <form class="search" action="/log">
3016
3015
3017 <p><input name="rev" id="search1" type="text" size="30" /></p>
3016 <p><input name="rev" id="search1" type="text" size="30" /></p>
3018 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3017 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3019 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3018 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3020 </form>
3019 </form>
3021 <div id="doc">
3020 <div id="doc">
3022 <h1>Changegroups</h1>
3021 <h1>Changegroups</h1>
3023 <p>
3022 <p>
3024 Changegroups are representations of repository revlog data, specifically
3023 Changegroups are representations of repository revlog data, specifically
3025 the changelog, manifest, and filelogs.
3024 the changelog, manifest, and filelogs.
3026 </p>
3025 </p>
3027 <p>
3026 <p>
3028 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3027 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3029 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with
3028 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with
3030 the only difference being a header on entries in the changeset
3029 the only difference being a header on entries in the changeset
3031 segment. Version &quot;3&quot; adds support for exchanging treemanifests and
3030 segment. Version &quot;3&quot; adds support for exchanging treemanifests and
3032 includes revlog flags in the delta header.
3031 includes revlog flags in the delta header.
3033 </p>
3032 </p>
3034 <p>
3033 <p>
3035 Changegroups consists of 3 logical segments:
3034 Changegroups consists of 3 logical segments:
3036 </p>
3035 </p>
3037 <pre>
3036 <pre>
3038 +---------------------------------+
3037 +---------------------------------+
3039 | | | |
3038 | | | |
3040 | changeset | manifest | filelogs |
3039 | changeset | manifest | filelogs |
3041 | | | |
3040 | | | |
3042 +---------------------------------+
3041 +---------------------------------+
3043 </pre>
3042 </pre>
3044 <p>
3043 <p>
3045 The principle building block of each segment is a *chunk*. A *chunk*
3044 The principle building block of each segment is a *chunk*. A *chunk*
3046 is a framed piece of data:
3045 is a framed piece of data:
3047 </p>
3046 </p>
3048 <pre>
3047 <pre>
3049 +---------------------------------------+
3048 +---------------------------------------+
3050 | | |
3049 | | |
3051 | length | data |
3050 | length | data |
3052 | (32 bits) | &lt;length&gt; bytes |
3051 | (32 bits) | &lt;length&gt; bytes |
3053 | | |
3052 | | |
3054 +---------------------------------------+
3053 +---------------------------------------+
3055 </pre>
3054 </pre>
3056 <p>
3055 <p>
3057 Each chunk starts with a 32-bit big-endian signed integer indicating
3056 Each chunk starts with a 32-bit big-endian signed integer indicating
3058 the length of the raw data that follows.
3057 the length of the raw data that follows.
3059 </p>
3058 </p>
3060 <p>
3059 <p>
3061 There is a special case chunk that has 0 length (&quot;0x00000000&quot;). We
3060 There is a special case chunk that has 0 length (&quot;0x00000000&quot;). We
3062 call this an *empty chunk*.
3061 call this an *empty chunk*.
3063 </p>
3062 </p>
3064 <h2>Delta Groups</h2>
3063 <h2>Delta Groups</h2>
3065 <p>
3064 <p>
3066 A *delta group* expresses the content of a revlog as a series of deltas,
3065 A *delta group* expresses the content of a revlog as a series of deltas,
3067 or patches against previous revisions.
3066 or patches against previous revisions.
3068 </p>
3067 </p>
3069 <p>
3068 <p>
3070 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3069 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3071 to signal the end of the delta group:
3070 to signal the end of the delta group:
3072 </p>
3071 </p>
3073 <pre>
3072 <pre>
3074 +------------------------------------------------------------------------+
3073 +------------------------------------------------------------------------+
3075 | | | | | |
3074 | | | | | |
3076 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3075 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3077 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
3076 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
3078 | | | | | |
3077 | | | | | |
3079 +------------------------------------------------------------+-----------+
3078 +------------------------------------------------------------+-----------+
3080 </pre>
3079 </pre>
3081 <p>
3080 <p>
3082 Each *chunk*'s data consists of the following:
3081 Each *chunk*'s data consists of the following:
3083 </p>
3082 </p>
3084 <pre>
3083 <pre>
3085 +-----------------------------------------+
3084 +-----------------------------------------+
3086 | | | |
3085 | | | |
3087 | delta header | mdiff header | delta |
3086 | delta header | mdiff header | delta |
3088 | (various) | (12 bytes) | (various) |
3087 | (various) | (12 bytes) | (various) |
3089 | | | |
3088 | | | |
3090 +-----------------------------------------+
3089 +-----------------------------------------+
3091 </pre>
3090 </pre>
3092 <p>
3091 <p>
3093 The *length* field is the byte length of the remaining 3 logical pieces
3092 The *length* field is the byte length of the remaining 3 logical pieces
3094 of data. The *delta* is a diff from an existing entry in the changelog.
3093 of data. The *delta* is a diff from an existing entry in the changelog.
3095 </p>
3094 </p>
3096 <p>
3095 <p>
3097 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3096 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3098 &quot;3&quot; of the changegroup format.
3097 &quot;3&quot; of the changegroup format.
3099 </p>
3098 </p>
3100 <p>
3099 <p>
3101 Version 1:
3100 Version 1:
3102 </p>
3101 </p>
3103 <pre>
3102 <pre>
3104 +------------------------------------------------------+
3103 +------------------------------------------------------+
3105 | | | | |
3104 | | | | |
3106 | node | p1 node | p2 node | link node |
3105 | node | p1 node | p2 node | link node |
3107 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3106 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3108 | | | | |
3107 | | | | |
3109 +------------------------------------------------------+
3108 +------------------------------------------------------+
3110 </pre>
3109 </pre>
3111 <p>
3110 <p>
3112 Version 2:
3111 Version 2:
3113 </p>
3112 </p>
3114 <pre>
3113 <pre>
3115 +------------------------------------------------------------------+
3114 +------------------------------------------------------------------+
3116 | | | | | |
3115 | | | | | |
3117 | node | p1 node | p2 node | base node | link node |
3116 | node | p1 node | p2 node | base node | link node |
3118 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3117 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3119 | | | | | |
3118 | | | | | |
3120 +------------------------------------------------------------------+
3119 +------------------------------------------------------------------+
3121 </pre>
3120 </pre>
3122 <p>
3121 <p>
3123 Version 3:
3122 Version 3:
3124 </p>
3123 </p>
3125 <pre>
3124 <pre>
3126 +------------------------------------------------------------------------------+
3125 +------------------------------------------------------------------------------+
3127 | | | | | | |
3126 | | | | | | |
3128 | node | p1 node | p2 node | base node | link node | flags |
3127 | node | p1 node | p2 node | base node | link node | flags |
3129 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3128 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3130 | | | | | | |
3129 | | | | | | |
3131 +------------------------------------------------------------------------------+
3130 +------------------------------------------------------------------------------+
3132 </pre>
3131 </pre>
3133 <p>
3132 <p>
3134 The *mdiff header* consists of 3 32-bit big-endian signed integers
3133 The *mdiff header* consists of 3 32-bit big-endian signed integers
3135 describing offsets at which to apply the following delta content:
3134 describing offsets at which to apply the following delta content:
3136 </p>
3135 </p>
3137 <pre>
3136 <pre>
3138 +-------------------------------------+
3137 +-------------------------------------+
3139 | | | |
3138 | | | |
3140 | offset | old length | new length |
3139 | offset | old length | new length |
3141 | (32 bits) | (32 bits) | (32 bits) |
3140 | (32 bits) | (32 bits) | (32 bits) |
3142 | | | |
3141 | | | |
3143 +-------------------------------------+
3142 +-------------------------------------+
3144 </pre>
3143 </pre>
3145 <p>
3144 <p>
3146 In version 1, the delta is always applied against the previous node from
3145 In version 1, the delta is always applied against the previous node from
3147 the changegroup or the first parent if this is the first entry in the
3146 the changegroup or the first parent if this is the first entry in the
3148 changegroup.
3147 changegroup.
3149 </p>
3148 </p>
3150 <p>
3149 <p>
3151 In version 2, the delta base node is encoded in the entry in the
3150 In version 2, the delta base node is encoded in the entry in the
3152 changegroup. This allows the delta to be expressed against any parent,
3151 changegroup. This allows the delta to be expressed against any parent,
3153 which can result in smaller deltas and more efficient encoding of data.
3152 which can result in smaller deltas and more efficient encoding of data.
3154 </p>
3153 </p>
3155 <h2>Changeset Segment</h2>
3154 <h2>Changeset Segment</h2>
3156 <p>
3155 <p>
3157 The *changeset segment* consists of a single *delta group* holding
3156 The *changeset segment* consists of a single *delta group* holding
3158 changelog data. It is followed by an *empty chunk* to denote the
3157 changelog data. It is followed by an *empty chunk* to denote the
3159 boundary to the *manifests segment*.
3158 boundary to the *manifests segment*.
3160 </p>
3159 </p>
3161 <h2>Manifest Segment</h2>
3160 <h2>Manifest Segment</h2>
3162 <p>
3161 <p>
3163 The *manifest segment* consists of a single *delta group* holding
3162 The *manifest segment* consists of a single *delta group* holding
3164 manifest data. It is followed by an *empty chunk* to denote the boundary
3163 manifest data. It is followed by an *empty chunk* to denote the boundary
3165 to the *filelogs segment*.
3164 to the *filelogs segment*.
3166 </p>
3165 </p>
3167 <h2>Filelogs Segment</h2>
3166 <h2>Filelogs Segment</h2>
3168 <p>
3167 <p>
3169 The *filelogs* segment consists of multiple sub-segments, each
3168 The *filelogs* segment consists of multiple sub-segments, each
3170 corresponding to an individual file whose data is being described:
3169 corresponding to an individual file whose data is being described:
3171 </p>
3170 </p>
3172 <pre>
3171 <pre>
3173 +--------------------------------------+
3172 +--------------------------------------+
3174 | | | | |
3173 | | | | |
3175 | filelog0 | filelog1 | filelog2 | ... |
3174 | filelog0 | filelog1 | filelog2 | ... |
3176 | | | | |
3175 | | | | |
3177 +--------------------------------------+
3176 +--------------------------------------+
3178 </pre>
3177 </pre>
3179 <p>
3178 <p>
3180 In version &quot;3&quot; of the changegroup format, filelogs may include
3179 In version &quot;3&quot; of the changegroup format, filelogs may include
3181 directory logs when treemanifests are in use. directory logs are
3180 directory logs when treemanifests are in use. directory logs are
3182 identified by having a trailing '/' on their filename (see below).
3181 identified by having a trailing '/' on their filename (see below).
3183 </p>
3182 </p>
3184 <p>
3183 <p>
3185 The final filelog sub-segment is followed by an *empty chunk* to denote
3184 The final filelog sub-segment is followed by an *empty chunk* to denote
3186 the end of the segment and the overall changegroup.
3185 the end of the segment and the overall changegroup.
3187 </p>
3186 </p>
3188 <p>
3187 <p>
3189 Each filelog sub-segment consists of the following:
3188 Each filelog sub-segment consists of the following:
3190 </p>
3189 </p>
3191 <pre>
3190 <pre>
3192 +------------------------------------------+
3191 +------------------------------------------+
3193 | | | |
3192 | | | |
3194 | filename size | filename | delta group |
3193 | filename size | filename | delta group |
3195 | (32 bits) | (various) | (various) |
3194 | (32 bits) | (various) | (various) |
3196 | | | |
3195 | | | |
3197 +------------------------------------------+
3196 +------------------------------------------+
3198 </pre>
3197 </pre>
3199 <p>
3198 <p>
3200 That is, a *chunk* consisting of the filename (not terminated or padded)
3199 That is, a *chunk* consisting of the filename (not terminated or padded)
3201 followed by N chunks constituting the *delta group* for this file.
3200 followed by N chunks constituting the *delta group* for this file.
3202 </p>
3201 </p>
3203
3202
3204 </div>
3203 </div>
3205 </div>
3204 </div>
3206 </div>
3205 </div>
3207
3206
3208
3207
3209
3208
3210 </body>
3209 </body>
3211 </html>
3210 </html>
3212
3211
3213
3212
3214 $ killdaemons.py
3213 $ killdaemons.py
3215
3214
3216 #endif
3215 #endif
General Comments 0
You need to be logged in to leave comments. Login now