##// END OF EJS Templates
mercurial: add debugextensions command (issue4676)...
liscju -
r26351:8c7d8d5e default
parent child Browse files
Show More
@@ -0,0 +1,83 b''
1 $ hg debugextensions
2
3 $ debugpath=`pwd`/extwithoutinfos.py
4
5 $ cat > extwithoutinfos.py <<EOF
6 > EOF
7
8 $ cat >> $HGRCPATH <<EOF
9 > [extensions]
10 > color=
11 > histedit=
12 > patchbomb=
13 > rebase=
14 > mq=
15 > ext1 = $debugpath
16 > EOF
17
18 $ hg debugextensions
19 color
20 ext1 (untested!)
21 histedit
22 mq
23 patchbomb
24 rebase
25
26 $ hg debugextensions -v
27 color
28 location: */hgext/color.pyc (glob)
29 tested with: internal
30 ext1
31 location: */extwithoutinfos.pyc (glob)
32 histedit
33 location: */hgext/histedit.pyc (glob)
34 tested with: internal
35 mq
36 location: */hgext/mq.pyc (glob)
37 tested with: internal
38 patchbomb
39 location: */hgext/patchbomb.pyc (glob)
40 tested with: internal
41 rebase
42 location: */hgext/rebase.pyc (glob)
43 tested with: internal
44
45 $ hg debugextensions -Tjson
46 [
47 {
48 "buglink": "",
49 "name": "color",
50 "source": "*/hgext/color.pyc", (glob)
51 "testedwith": "internal"
52 },
53 {
54 "buglink": "",
55 "name": "ext1",
56 "source": "*/extwithoutinfos.pyc", (glob)
57 "testedwith": ""
58 },
59 {
60 "buglink": "",
61 "name": "histedit",
62 "source": "*/hgext/histedit.pyc", (glob)
63 "testedwith": "internal"
64 },
65 {
66 "buglink": "",
67 "name": "mq",
68 "source": "*/hgext/mq.pyc", (glob)
69 "testedwith": "internal"
70 },
71 {
72 "buglink": "",
73 "name": "patchbomb",
74 "source": "*/hgext/patchbomb.pyc", (glob)
75 "testedwith": "internal"
76 },
77 {
78 "buglink": "",
79 "name": "rebase",
80 "source": "*/hgext/rebase.pyc", (glob)
81 "testedwith": "internal"
82 }
83 ]
@@ -1,6524 +1,6563 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 node import hex, bin, nullid, nullrev, short
8 from node import hex, bin, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _
10 from i18n import _
11 import os, re, difflib, time, tempfile, errno, shlex
11 import os, re, difflib, time, tempfile, errno, shlex
12 import sys, socket
12 import sys, socket
13 import hg, scmutil, util, revlog, copies, error, bookmarks
13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 import patch, help, encoding, templatekw, discovery
14 import patch, help, encoding, templatekw, discovery
15 import archival, changegroup, cmdutil, hbisect
15 import archival, changegroup, cmdutil, hbisect
16 import sshserver, hgweb
16 import sshserver, hgweb
17 import extensions
17 import extensions
18 from hgweb import server as hgweb_server
18 from hgweb import server as hgweb_server
19 import merge as mergemod
19 import merge as mergemod
20 import minirst, revset, fileset
20 import minirst, revset, fileset
21 import dagparser, context, simplemerge, graphmod, copies
21 import dagparser, context, simplemerge, graphmod, copies
22 import random
22 import random, operator
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
25 import ui as uimod
25 import ui as uimod
26
26
27 table = {}
27 table = {}
28
28
29 command = cmdutil.command(table)
29 command = cmdutil.command(table)
30
30
31 # Space delimited list of commands that don't require local repositories.
31 # Space delimited list of commands that don't require local repositories.
32 # This should be populated by passing norepo=True into the @command decorator.
32 # This should be populated by passing norepo=True into the @command decorator.
33 norepo = ''
33 norepo = ''
34 # Space delimited list of commands that optionally require local repositories.
34 # Space delimited list of commands that optionally require local repositories.
35 # This should be populated by passing optionalrepo=True into the @command
35 # This should be populated by passing optionalrepo=True into the @command
36 # decorator.
36 # decorator.
37 optionalrepo = ''
37 optionalrepo = ''
38 # Space delimited list of commands that will examine arguments looking for
38 # Space delimited list of commands that will examine arguments looking for
39 # a repository. This should be populated by passing inferrepo=True into the
39 # a repository. This should be populated by passing inferrepo=True into the
40 # @command decorator.
40 # @command decorator.
41 inferrepo = ''
41 inferrepo = ''
42
42
43 # label constants
43 # label constants
44 # until 3.5, bookmarks.current was the advertised name, not
44 # until 3.5, bookmarks.current was the advertised name, not
45 # bookmarks.active, so we must use both to avoid breaking old
45 # bookmarks.active, so we must use both to avoid breaking old
46 # custom styles
46 # custom styles
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
48
48
49 # common command options
49 # common command options
50
50
51 globalopts = [
51 globalopts = [
52 ('R', 'repository', '',
52 ('R', 'repository', '',
53 _('repository root directory or name of overlay bundle file'),
53 _('repository root directory or name of overlay bundle file'),
54 _('REPO')),
54 _('REPO')),
55 ('', 'cwd', '',
55 ('', 'cwd', '',
56 _('change working directory'), _('DIR')),
56 _('change working directory'), _('DIR')),
57 ('y', 'noninteractive', None,
57 ('y', 'noninteractive', None,
58 _('do not prompt, automatically pick the first choice for all prompts')),
58 _('do not prompt, automatically pick the first choice for all prompts')),
59 ('q', 'quiet', None, _('suppress output')),
59 ('q', 'quiet', None, _('suppress output')),
60 ('v', 'verbose', None, _('enable additional output')),
60 ('v', 'verbose', None, _('enable additional output')),
61 ('', 'config', [],
61 ('', 'config', [],
62 _('set/override config option (use \'section.name=value\')'),
62 _('set/override config option (use \'section.name=value\')'),
63 _('CONFIG')),
63 _('CONFIG')),
64 ('', 'debug', None, _('enable debugging output')),
64 ('', 'debug', None, _('enable debugging output')),
65 ('', 'debugger', None, _('start debugger')),
65 ('', 'debugger', None, _('start debugger')),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
67 _('ENCODE')),
67 _('ENCODE')),
68 ('', 'encodingmode', encoding.encodingmode,
68 ('', 'encodingmode', encoding.encodingmode,
69 _('set the charset encoding mode'), _('MODE')),
69 _('set the charset encoding mode'), _('MODE')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
71 ('', 'time', None, _('time how long the command takes')),
71 ('', 'time', None, _('time how long the command takes')),
72 ('', 'profile', None, _('print command execution profile')),
72 ('', 'profile', None, _('print command execution profile')),
73 ('', 'version', None, _('output version information and exit')),
73 ('', 'version', None, _('output version information and exit')),
74 ('h', 'help', None, _('display help and exit')),
74 ('h', 'help', None, _('display help and exit')),
75 ('', 'hidden', False, _('consider hidden changesets')),
75 ('', 'hidden', False, _('consider hidden changesets')),
76 ]
76 ]
77
77
78 dryrunopts = [('n', 'dry-run', None,
78 dryrunopts = [('n', 'dry-run', None,
79 _('do not perform actions, just print output'))]
79 _('do not perform actions, just print output'))]
80
80
81 remoteopts = [
81 remoteopts = [
82 ('e', 'ssh', '',
82 ('e', 'ssh', '',
83 _('specify ssh command to use'), _('CMD')),
83 _('specify ssh command to use'), _('CMD')),
84 ('', 'remotecmd', '',
84 ('', 'remotecmd', '',
85 _('specify hg command to run on the remote side'), _('CMD')),
85 _('specify hg command to run on the remote side'), _('CMD')),
86 ('', 'insecure', None,
86 ('', 'insecure', None,
87 _('do not verify server certificate (ignoring web.cacerts config)')),
87 _('do not verify server certificate (ignoring web.cacerts config)')),
88 ]
88 ]
89
89
90 walkopts = [
90 walkopts = [
91 ('I', 'include', [],
91 ('I', 'include', [],
92 _('include names matching the given patterns'), _('PATTERN')),
92 _('include names matching the given patterns'), _('PATTERN')),
93 ('X', 'exclude', [],
93 ('X', 'exclude', [],
94 _('exclude names matching the given patterns'), _('PATTERN')),
94 _('exclude names matching the given patterns'), _('PATTERN')),
95 ]
95 ]
96
96
97 commitopts = [
97 commitopts = [
98 ('m', 'message', '',
98 ('m', 'message', '',
99 _('use text as commit message'), _('TEXT')),
99 _('use text as commit message'), _('TEXT')),
100 ('l', 'logfile', '',
100 ('l', 'logfile', '',
101 _('read commit message from file'), _('FILE')),
101 _('read commit message from file'), _('FILE')),
102 ]
102 ]
103
103
104 commitopts2 = [
104 commitopts2 = [
105 ('d', 'date', '',
105 ('d', 'date', '',
106 _('record the specified date as commit date'), _('DATE')),
106 _('record the specified date as commit date'), _('DATE')),
107 ('u', 'user', '',
107 ('u', 'user', '',
108 _('record the specified user as committer'), _('USER')),
108 _('record the specified user as committer'), _('USER')),
109 ]
109 ]
110
110
111 # hidden for now
111 # hidden for now
112 formatteropts = [
112 formatteropts = [
113 ('T', 'template', '',
113 ('T', 'template', '',
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
115 ]
115 ]
116
116
117 templateopts = [
117 templateopts = [
118 ('', 'style', '',
118 ('', 'style', '',
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
120 ('T', 'template', '',
120 ('T', 'template', '',
121 _('display with template'), _('TEMPLATE')),
121 _('display with template'), _('TEMPLATE')),
122 ]
122 ]
123
123
124 logopts = [
124 logopts = [
125 ('p', 'patch', None, _('show patch')),
125 ('p', 'patch', None, _('show patch')),
126 ('g', 'git', None, _('use git extended diff format')),
126 ('g', 'git', None, _('use git extended diff format')),
127 ('l', 'limit', '',
127 ('l', 'limit', '',
128 _('limit number of changes displayed'), _('NUM')),
128 _('limit number of changes displayed'), _('NUM')),
129 ('M', 'no-merges', None, _('do not show merges')),
129 ('M', 'no-merges', None, _('do not show merges')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
131 ('G', 'graph', None, _("show the revision DAG")),
131 ('G', 'graph', None, _("show the revision DAG")),
132 ] + templateopts
132 ] + templateopts
133
133
134 diffopts = [
134 diffopts = [
135 ('a', 'text', None, _('treat all files as text')),
135 ('a', 'text', None, _('treat all files as text')),
136 ('g', 'git', None, _('use git extended diff format')),
136 ('g', 'git', None, _('use git extended diff format')),
137 ('', 'nodates', None, _('omit dates from diff headers'))
137 ('', 'nodates', None, _('omit dates from diff headers'))
138 ]
138 ]
139
139
140 diffwsopts = [
140 diffwsopts = [
141 ('w', 'ignore-all-space', None,
141 ('w', 'ignore-all-space', None,
142 _('ignore white space when comparing lines')),
142 _('ignore white space when comparing lines')),
143 ('b', 'ignore-space-change', None,
143 ('b', 'ignore-space-change', None,
144 _('ignore changes in the amount of white space')),
144 _('ignore changes in the amount of white space')),
145 ('B', 'ignore-blank-lines', None,
145 ('B', 'ignore-blank-lines', None,
146 _('ignore changes whose lines are all blank')),
146 _('ignore changes whose lines are all blank')),
147 ]
147 ]
148
148
149 diffopts2 = [
149 diffopts2 = [
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
151 ('p', 'show-function', None, _('show which function each change is in')),
151 ('p', 'show-function', None, _('show which function each change is in')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
153 ] + diffwsopts + [
153 ] + diffwsopts + [
154 ('U', 'unified', '',
154 ('U', 'unified', '',
155 _('number of lines of context to show'), _('NUM')),
155 _('number of lines of context to show'), _('NUM')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
158 ]
158 ]
159
159
160 mergetoolopts = [
160 mergetoolopts = [
161 ('t', 'tool', '', _('specify merge tool')),
161 ('t', 'tool', '', _('specify merge tool')),
162 ]
162 ]
163
163
164 similarityopts = [
164 similarityopts = [
165 ('s', 'similarity', '',
165 ('s', 'similarity', '',
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
167 ]
167 ]
168
168
169 subrepoopts = [
169 subrepoopts = [
170 ('S', 'subrepos', None,
170 ('S', 'subrepos', None,
171 _('recurse into subrepositories'))
171 _('recurse into subrepositories'))
172 ]
172 ]
173
173
174 # Commands start here, listed alphabetically
174 # Commands start here, listed alphabetically
175
175
176 @command('^add',
176 @command('^add',
177 walkopts + subrepoopts + dryrunopts,
177 walkopts + subrepoopts + dryrunopts,
178 _('[OPTION]... [FILE]...'),
178 _('[OPTION]... [FILE]...'),
179 inferrepo=True)
179 inferrepo=True)
180 def add(ui, repo, *pats, **opts):
180 def add(ui, repo, *pats, **opts):
181 """add the specified files on the next commit
181 """add the specified files on the next commit
182
182
183 Schedule files to be version controlled and added to the
183 Schedule files to be version controlled and added to the
184 repository.
184 repository.
185
185
186 The files will be added to the repository at the next commit. To
186 The files will be added to the repository at the next commit. To
187 undo an add before that, see :hg:`forget`.
187 undo an add before that, see :hg:`forget`.
188
188
189 If no names are given, add all files to the repository.
189 If no names are given, add all files to the repository.
190
190
191 .. container:: verbose
191 .. container:: verbose
192
192
193 An example showing how new (unknown) files are added
193 An example showing how new (unknown) files are added
194 automatically by :hg:`add`::
194 automatically by :hg:`add`::
195
195
196 $ ls
196 $ ls
197 foo.c
197 foo.c
198 $ hg status
198 $ hg status
199 ? foo.c
199 ? foo.c
200 $ hg add
200 $ hg add
201 adding foo.c
201 adding foo.c
202 $ hg status
202 $ hg status
203 A foo.c
203 A foo.c
204
204
205 Returns 0 if all files are successfully added.
205 Returns 0 if all files are successfully added.
206 """
206 """
207
207
208 m = scmutil.match(repo[None], pats, opts)
208 m = scmutil.match(repo[None], pats, opts)
209 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
209 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
210 return rejected and 1 or 0
210 return rejected and 1 or 0
211
211
212 @command('addremove',
212 @command('addremove',
213 similarityopts + subrepoopts + walkopts + dryrunopts,
213 similarityopts + subrepoopts + walkopts + dryrunopts,
214 _('[OPTION]... [FILE]...'),
214 _('[OPTION]... [FILE]...'),
215 inferrepo=True)
215 inferrepo=True)
216 def addremove(ui, repo, *pats, **opts):
216 def addremove(ui, repo, *pats, **opts):
217 """add all new files, delete all missing files
217 """add all new files, delete all missing files
218
218
219 Add all new files and remove all missing files from the
219 Add all new files and remove all missing files from the
220 repository.
220 repository.
221
221
222 New files are ignored if they match any of the patterns in
222 New files are ignored if they match any of the patterns in
223 ``.hgignore``. As with add, these changes take effect at the next
223 ``.hgignore``. As with add, these changes take effect at the next
224 commit.
224 commit.
225
225
226 Use the -s/--similarity option to detect renamed files. This
226 Use the -s/--similarity option to detect renamed files. This
227 option takes a percentage between 0 (disabled) and 100 (files must
227 option takes a percentage between 0 (disabled) and 100 (files must
228 be identical) as its parameter. With a parameter greater than 0,
228 be identical) as its parameter. With a parameter greater than 0,
229 this compares every removed file with every added file and records
229 this compares every removed file with every added file and records
230 those similar enough as renames. Detecting renamed files this way
230 those similar enough as renames. Detecting renamed files this way
231 can be expensive. After using this option, :hg:`status -C` can be
231 can be expensive. After using this option, :hg:`status -C` can be
232 used to check which files were identified as moved or renamed. If
232 used to check which files were identified as moved or renamed. If
233 not specified, -s/--similarity defaults to 100 and only renames of
233 not specified, -s/--similarity defaults to 100 and only renames of
234 identical files are detected.
234 identical files are detected.
235
235
236 Returns 0 if all files are successfully added.
236 Returns 0 if all files are successfully added.
237 """
237 """
238 try:
238 try:
239 sim = float(opts.get('similarity') or 100)
239 sim = float(opts.get('similarity') or 100)
240 except ValueError:
240 except ValueError:
241 raise util.Abort(_('similarity must be a number'))
241 raise util.Abort(_('similarity must be a number'))
242 if sim < 0 or sim > 100:
242 if sim < 0 or sim > 100:
243 raise util.Abort(_('similarity must be between 0 and 100'))
243 raise util.Abort(_('similarity must be between 0 and 100'))
244 matcher = scmutil.match(repo[None], pats, opts)
244 matcher = scmutil.match(repo[None], pats, opts)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
246
246
247 @command('^annotate|blame',
247 @command('^annotate|blame',
248 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
248 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
249 ('', 'follow', None,
249 ('', 'follow', None,
250 _('follow copies/renames and list the filename (DEPRECATED)')),
250 _('follow copies/renames and list the filename (DEPRECATED)')),
251 ('', 'no-follow', None, _("don't follow copies and renames")),
251 ('', 'no-follow', None, _("don't follow copies and renames")),
252 ('a', 'text', None, _('treat all files as text')),
252 ('a', 'text', None, _('treat all files as text')),
253 ('u', 'user', None, _('list the author (long with -v)')),
253 ('u', 'user', None, _('list the author (long with -v)')),
254 ('f', 'file', None, _('list the filename')),
254 ('f', 'file', None, _('list the filename')),
255 ('d', 'date', None, _('list the date (short with -q)')),
255 ('d', 'date', None, _('list the date (short with -q)')),
256 ('n', 'number', None, _('list the revision number (default)')),
256 ('n', 'number', None, _('list the revision number (default)')),
257 ('c', 'changeset', None, _('list the changeset')),
257 ('c', 'changeset', None, _('list the changeset')),
258 ('l', 'line-number', None, _('show line number at the first appearance'))
258 ('l', 'line-number', None, _('show line number at the first appearance'))
259 ] + diffwsopts + walkopts + formatteropts,
259 ] + diffwsopts + walkopts + formatteropts,
260 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
260 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
261 inferrepo=True)
261 inferrepo=True)
262 def annotate(ui, repo, *pats, **opts):
262 def annotate(ui, repo, *pats, **opts):
263 """show changeset information by line for each file
263 """show changeset information by line for each file
264
264
265 List changes in files, showing the revision id responsible for
265 List changes in files, showing the revision id responsible for
266 each line
266 each line
267
267
268 This command is useful for discovering when a change was made and
268 This command is useful for discovering when a change was made and
269 by whom.
269 by whom.
270
270
271 Without the -a/--text option, annotate will avoid processing files
271 Without the -a/--text option, annotate will avoid processing files
272 it detects as binary. With -a, annotate will annotate the file
272 it detects as binary. With -a, annotate will annotate the file
273 anyway, although the results will probably be neither useful
273 anyway, although the results will probably be neither useful
274 nor desirable.
274 nor desirable.
275
275
276 Returns 0 on success.
276 Returns 0 on success.
277 """
277 """
278 if not pats:
278 if not pats:
279 raise util.Abort(_('at least one filename or pattern is required'))
279 raise util.Abort(_('at least one filename or pattern is required'))
280
280
281 if opts.get('follow'):
281 if opts.get('follow'):
282 # --follow is deprecated and now just an alias for -f/--file
282 # --follow is deprecated and now just an alias for -f/--file
283 # to mimic the behavior of Mercurial before version 1.5
283 # to mimic the behavior of Mercurial before version 1.5
284 opts['file'] = True
284 opts['file'] = True
285
285
286 ctx = scmutil.revsingle(repo, opts.get('rev'))
286 ctx = scmutil.revsingle(repo, opts.get('rev'))
287
287
288 fm = ui.formatter('annotate', opts)
288 fm = ui.formatter('annotate', opts)
289 if ui.quiet:
289 if ui.quiet:
290 datefunc = util.shortdate
290 datefunc = util.shortdate
291 else:
291 else:
292 datefunc = util.datestr
292 datefunc = util.datestr
293 if ctx.rev() is None:
293 if ctx.rev() is None:
294 def hexfn(node):
294 def hexfn(node):
295 if node is None:
295 if node is None:
296 return None
296 return None
297 else:
297 else:
298 return fm.hexfunc(node)
298 return fm.hexfunc(node)
299 if opts.get('changeset'):
299 if opts.get('changeset'):
300 # omit "+" suffix which is appended to node hex
300 # omit "+" suffix which is appended to node hex
301 def formatrev(rev):
301 def formatrev(rev):
302 if rev is None:
302 if rev is None:
303 return '%d' % ctx.p1().rev()
303 return '%d' % ctx.p1().rev()
304 else:
304 else:
305 return '%d' % rev
305 return '%d' % rev
306 else:
306 else:
307 def formatrev(rev):
307 def formatrev(rev):
308 if rev is None:
308 if rev is None:
309 return '%d+' % ctx.p1().rev()
309 return '%d+' % ctx.p1().rev()
310 else:
310 else:
311 return '%d ' % rev
311 return '%d ' % rev
312 def formathex(hex):
312 def formathex(hex):
313 if hex is None:
313 if hex is None:
314 return '%s+' % fm.hexfunc(ctx.p1().node())
314 return '%s+' % fm.hexfunc(ctx.p1().node())
315 else:
315 else:
316 return '%s ' % hex
316 return '%s ' % hex
317 else:
317 else:
318 hexfn = fm.hexfunc
318 hexfn = fm.hexfunc
319 formatrev = formathex = str
319 formatrev = formathex = str
320
320
321 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
321 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
322 ('number', ' ', lambda x: x[0].rev(), formatrev),
322 ('number', ' ', lambda x: x[0].rev(), formatrev),
323 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
323 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
324 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
324 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
325 ('file', ' ', lambda x: x[0].path(), str),
325 ('file', ' ', lambda x: x[0].path(), str),
326 ('line_number', ':', lambda x: x[1], str),
326 ('line_number', ':', lambda x: x[1], str),
327 ]
327 ]
328 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
328 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
329
329
330 if (not opts.get('user') and not opts.get('changeset')
330 if (not opts.get('user') and not opts.get('changeset')
331 and not opts.get('date') and not opts.get('file')):
331 and not opts.get('date') and not opts.get('file')):
332 opts['number'] = True
332 opts['number'] = True
333
333
334 linenumber = opts.get('line_number') is not None
334 linenumber = opts.get('line_number') is not None
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
336 raise util.Abort(_('at least one of -n/-c is required for -l'))
336 raise util.Abort(_('at least one of -n/-c is required for -l'))
337
337
338 if fm:
338 if fm:
339 def makefunc(get, fmt):
339 def makefunc(get, fmt):
340 return get
340 return get
341 else:
341 else:
342 def makefunc(get, fmt):
342 def makefunc(get, fmt):
343 return lambda x: fmt(get(x))
343 return lambda x: fmt(get(x))
344 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
344 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
345 if opts.get(op)]
345 if opts.get(op)]
346 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
346 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
347 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
347 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
348 if opts.get(op))
348 if opts.get(op))
349
349
350 def bad(x, y):
350 def bad(x, y):
351 raise util.Abort("%s: %s" % (x, y))
351 raise util.Abort("%s: %s" % (x, y))
352
352
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
354
354
355 follow = not opts.get('no_follow')
355 follow = not opts.get('no_follow')
356 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
356 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
357 whitespace=True)
357 whitespace=True)
358 for abs in ctx.walk(m):
358 for abs in ctx.walk(m):
359 fctx = ctx[abs]
359 fctx = ctx[abs]
360 if not opts.get('text') and util.binary(fctx.data()):
360 if not opts.get('text') and util.binary(fctx.data()):
361 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
361 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
362 continue
362 continue
363
363
364 lines = fctx.annotate(follow=follow, linenumber=linenumber,
364 lines = fctx.annotate(follow=follow, linenumber=linenumber,
365 diffopts=diffopts)
365 diffopts=diffopts)
366 formats = []
366 formats = []
367 pieces = []
367 pieces = []
368
368
369 for f, sep in funcmap:
369 for f, sep in funcmap:
370 l = [f(n) for n, dummy in lines]
370 l = [f(n) for n, dummy in lines]
371 if l:
371 if l:
372 if fm:
372 if fm:
373 formats.append(['%s' for x in l])
373 formats.append(['%s' for x in l])
374 else:
374 else:
375 sizes = [encoding.colwidth(x) for x in l]
375 sizes = [encoding.colwidth(x) for x in l]
376 ml = max(sizes)
376 ml = max(sizes)
377 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
377 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
378 pieces.append(l)
378 pieces.append(l)
379
379
380 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
380 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
381 fm.startitem()
381 fm.startitem()
382 fm.write(fields, "".join(f), *p)
382 fm.write(fields, "".join(f), *p)
383 fm.write('line', ": %s", l[1])
383 fm.write('line', ": %s", l[1])
384
384
385 if lines and not lines[-1][1].endswith('\n'):
385 if lines and not lines[-1][1].endswith('\n'):
386 fm.plain('\n')
386 fm.plain('\n')
387
387
388 fm.end()
388 fm.end()
389
389
390 @command('archive',
390 @command('archive',
391 [('', 'no-decode', None, _('do not pass files through decoders')),
391 [('', 'no-decode', None, _('do not pass files through decoders')),
392 ('p', 'prefix', '', _('directory prefix for files in archive'),
392 ('p', 'prefix', '', _('directory prefix for files in archive'),
393 _('PREFIX')),
393 _('PREFIX')),
394 ('r', 'rev', '', _('revision to distribute'), _('REV')),
394 ('r', 'rev', '', _('revision to distribute'), _('REV')),
395 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
395 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
396 ] + subrepoopts + walkopts,
396 ] + subrepoopts + walkopts,
397 _('[OPTION]... DEST'))
397 _('[OPTION]... DEST'))
398 def archive(ui, repo, dest, **opts):
398 def archive(ui, repo, dest, **opts):
399 '''create an unversioned archive of a repository revision
399 '''create an unversioned archive of a repository revision
400
400
401 By default, the revision used is the parent of the working
401 By default, the revision used is the parent of the working
402 directory; use -r/--rev to specify a different revision.
402 directory; use -r/--rev to specify a different revision.
403
403
404 The archive type is automatically detected based on file
404 The archive type is automatically detected based on file
405 extension (or override using -t/--type).
405 extension (or override using -t/--type).
406
406
407 .. container:: verbose
407 .. container:: verbose
408
408
409 Examples:
409 Examples:
410
410
411 - create a zip file containing the 1.0 release::
411 - create a zip file containing the 1.0 release::
412
412
413 hg archive -r 1.0 project-1.0.zip
413 hg archive -r 1.0 project-1.0.zip
414
414
415 - create a tarball excluding .hg files::
415 - create a tarball excluding .hg files::
416
416
417 hg archive project.tar.gz -X ".hg*"
417 hg archive project.tar.gz -X ".hg*"
418
418
419 Valid types are:
419 Valid types are:
420
420
421 :``files``: a directory full of files (default)
421 :``files``: a directory full of files (default)
422 :``tar``: tar archive, uncompressed
422 :``tar``: tar archive, uncompressed
423 :``tbz2``: tar archive, compressed using bzip2
423 :``tbz2``: tar archive, compressed using bzip2
424 :``tgz``: tar archive, compressed using gzip
424 :``tgz``: tar archive, compressed using gzip
425 :``uzip``: zip archive, uncompressed
425 :``uzip``: zip archive, uncompressed
426 :``zip``: zip archive, compressed using deflate
426 :``zip``: zip archive, compressed using deflate
427
427
428 The exact name of the destination archive or directory is given
428 The exact name of the destination archive or directory is given
429 using a format string; see :hg:`help export` for details.
429 using a format string; see :hg:`help export` for details.
430
430
431 Each member added to an archive file has a directory prefix
431 Each member added to an archive file has a directory prefix
432 prepended. Use -p/--prefix to specify a format string for the
432 prepended. Use -p/--prefix to specify a format string for the
433 prefix. The default is the basename of the archive, with suffixes
433 prefix. The default is the basename of the archive, with suffixes
434 removed.
434 removed.
435
435
436 Returns 0 on success.
436 Returns 0 on success.
437 '''
437 '''
438
438
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
440 if not ctx:
440 if not ctx:
441 raise util.Abort(_('no working directory: please specify a revision'))
441 raise util.Abort(_('no working directory: please specify a revision'))
442 node = ctx.node()
442 node = ctx.node()
443 dest = cmdutil.makefilename(repo, dest, node)
443 dest = cmdutil.makefilename(repo, dest, node)
444 if os.path.realpath(dest) == repo.root:
444 if os.path.realpath(dest) == repo.root:
445 raise util.Abort(_('repository root cannot be destination'))
445 raise util.Abort(_('repository root cannot be destination'))
446
446
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
448 prefix = opts.get('prefix')
448 prefix = opts.get('prefix')
449
449
450 if dest == '-':
450 if dest == '-':
451 if kind == 'files':
451 if kind == 'files':
452 raise util.Abort(_('cannot archive plain files to stdout'))
452 raise util.Abort(_('cannot archive plain files to stdout'))
453 dest = cmdutil.makefileobj(repo, dest)
453 dest = cmdutil.makefileobj(repo, dest)
454 if not prefix:
454 if not prefix:
455 prefix = os.path.basename(repo.root) + '-%h'
455 prefix = os.path.basename(repo.root) + '-%h'
456
456
457 prefix = cmdutil.makefilename(repo, prefix, node)
457 prefix = cmdutil.makefilename(repo, prefix, node)
458 matchfn = scmutil.match(ctx, [], opts)
458 matchfn = scmutil.match(ctx, [], opts)
459 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
459 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
460 matchfn, prefix, subrepos=opts.get('subrepos'))
460 matchfn, prefix, subrepos=opts.get('subrepos'))
461
461
462 @command('backout',
462 @command('backout',
463 [('', 'merge', None, _('merge with old dirstate parent after backout')),
463 [('', 'merge', None, _('merge with old dirstate parent after backout')),
464 ('', 'commit', None, _('commit if no conflicts were encountered')),
464 ('', 'commit', None, _('commit if no conflicts were encountered')),
465 ('', 'parent', '',
465 ('', 'parent', '',
466 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
466 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
467 ('r', 'rev', '', _('revision to backout'), _('REV')),
467 ('r', 'rev', '', _('revision to backout'), _('REV')),
468 ('e', 'edit', False, _('invoke editor on commit messages')),
468 ('e', 'edit', False, _('invoke editor on commit messages')),
469 ] + mergetoolopts + walkopts + commitopts + commitopts2,
469 ] + mergetoolopts + walkopts + commitopts + commitopts2,
470 _('[OPTION]... [-r] REV'))
470 _('[OPTION]... [-r] REV'))
471 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
471 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
472 '''reverse effect of earlier changeset
472 '''reverse effect of earlier changeset
473
473
474 Prepare a new changeset with the effect of REV undone in the
474 Prepare a new changeset with the effect of REV undone in the
475 current working directory.
475 current working directory.
476
476
477 If REV is the parent of the working directory, then this new changeset
477 If REV is the parent of the working directory, then this new changeset
478 is committed automatically. Otherwise, hg needs to merge the
478 is committed automatically. Otherwise, hg needs to merge the
479 changes and the merged result is left uncommitted.
479 changes and the merged result is left uncommitted.
480
480
481 .. note::
481 .. note::
482
482
483 backout cannot be used to fix either an unwanted or
483 backout cannot be used to fix either an unwanted or
484 incorrect merge.
484 incorrect merge.
485
485
486 .. container:: verbose
486 .. container:: verbose
487
487
488 By default, the pending changeset will have one parent,
488 By default, the pending changeset will have one parent,
489 maintaining a linear history. With --merge, the pending
489 maintaining a linear history. With --merge, the pending
490 changeset will instead have two parents: the old parent of the
490 changeset will instead have two parents: the old parent of the
491 working directory and a new child of REV that simply undoes REV.
491 working directory and a new child of REV that simply undoes REV.
492
492
493 Before version 1.7, the behavior without --merge was equivalent
493 Before version 1.7, the behavior without --merge was equivalent
494 to specifying --merge followed by :hg:`update --clean .` to
494 to specifying --merge followed by :hg:`update --clean .` to
495 cancel the merge and leave the child of REV as a head to be
495 cancel the merge and leave the child of REV as a head to be
496 merged separately.
496 merged separately.
497
497
498 See :hg:`help dates` for a list of formats valid for -d/--date.
498 See :hg:`help dates` for a list of formats valid for -d/--date.
499
499
500 Returns 0 on success, 1 if nothing to backout or there are unresolved
500 Returns 0 on success, 1 if nothing to backout or there are unresolved
501 files.
501 files.
502 '''
502 '''
503 if rev and node:
503 if rev and node:
504 raise util.Abort(_("please specify just one revision"))
504 raise util.Abort(_("please specify just one revision"))
505
505
506 if not rev:
506 if not rev:
507 rev = node
507 rev = node
508
508
509 if not rev:
509 if not rev:
510 raise util.Abort(_("please specify a revision to backout"))
510 raise util.Abort(_("please specify a revision to backout"))
511
511
512 date = opts.get('date')
512 date = opts.get('date')
513 if date:
513 if date:
514 opts['date'] = util.parsedate(date)
514 opts['date'] = util.parsedate(date)
515
515
516 cmdutil.checkunfinished(repo)
516 cmdutil.checkunfinished(repo)
517 cmdutil.bailifchanged(repo)
517 cmdutil.bailifchanged(repo)
518 node = scmutil.revsingle(repo, rev).node()
518 node = scmutil.revsingle(repo, rev).node()
519
519
520 op1, op2 = repo.dirstate.parents()
520 op1, op2 = repo.dirstate.parents()
521 if not repo.changelog.isancestor(node, op1):
521 if not repo.changelog.isancestor(node, op1):
522 raise util.Abort(_('cannot backout change that is not an ancestor'))
522 raise util.Abort(_('cannot backout change that is not an ancestor'))
523
523
524 p1, p2 = repo.changelog.parents(node)
524 p1, p2 = repo.changelog.parents(node)
525 if p1 == nullid:
525 if p1 == nullid:
526 raise util.Abort(_('cannot backout a change with no parents'))
526 raise util.Abort(_('cannot backout a change with no parents'))
527 if p2 != nullid:
527 if p2 != nullid:
528 if not opts.get('parent'):
528 if not opts.get('parent'):
529 raise util.Abort(_('cannot backout a merge changeset'))
529 raise util.Abort(_('cannot backout a merge changeset'))
530 p = repo.lookup(opts['parent'])
530 p = repo.lookup(opts['parent'])
531 if p not in (p1, p2):
531 if p not in (p1, p2):
532 raise util.Abort(_('%s is not a parent of %s') %
532 raise util.Abort(_('%s is not a parent of %s') %
533 (short(p), short(node)))
533 (short(p), short(node)))
534 parent = p
534 parent = p
535 else:
535 else:
536 if opts.get('parent'):
536 if opts.get('parent'):
537 raise util.Abort(_('cannot use --parent on non-merge changeset'))
537 raise util.Abort(_('cannot use --parent on non-merge changeset'))
538 parent = p1
538 parent = p1
539
539
540 # the backout should appear on the same branch
540 # the backout should appear on the same branch
541 wlock = repo.wlock()
541 wlock = repo.wlock()
542 try:
542 try:
543 branch = repo.dirstate.branch()
543 branch = repo.dirstate.branch()
544 bheads = repo.branchheads(branch)
544 bheads = repo.branchheads(branch)
545 rctx = scmutil.revsingle(repo, hex(parent))
545 rctx = scmutil.revsingle(repo, hex(parent))
546 if not opts.get('merge') and op1 != node:
546 if not opts.get('merge') and op1 != node:
547 try:
547 try:
548 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
548 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
549 'backout')
549 'backout')
550 repo.dirstate.beginparentchange()
550 repo.dirstate.beginparentchange()
551 stats = mergemod.update(repo, parent, True, True, False,
551 stats = mergemod.update(repo, parent, True, True, False,
552 node, False)
552 node, False)
553 repo.setparents(op1, op2)
553 repo.setparents(op1, op2)
554 repo.dirstate.endparentchange()
554 repo.dirstate.endparentchange()
555 hg._showstats(repo, stats)
555 hg._showstats(repo, stats)
556 if stats[3]:
556 if stats[3]:
557 repo.ui.status(_("use 'hg resolve' to retry unresolved "
557 repo.ui.status(_("use 'hg resolve' to retry unresolved "
558 "file merges\n"))
558 "file merges\n"))
559 return 1
559 return 1
560 elif not commit:
560 elif not commit:
561 msg = _("changeset %s backed out, "
561 msg = _("changeset %s backed out, "
562 "don't forget to commit.\n")
562 "don't forget to commit.\n")
563 ui.status(msg % short(node))
563 ui.status(msg % short(node))
564 return 0
564 return 0
565 finally:
565 finally:
566 ui.setconfig('ui', 'forcemerge', '', '')
566 ui.setconfig('ui', 'forcemerge', '', '')
567 else:
567 else:
568 hg.clean(repo, node, show_stats=False)
568 hg.clean(repo, node, show_stats=False)
569 repo.dirstate.setbranch(branch)
569 repo.dirstate.setbranch(branch)
570 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
570 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
571
571
572
572
573 def commitfunc(ui, repo, message, match, opts):
573 def commitfunc(ui, repo, message, match, opts):
574 editform = 'backout'
574 editform = 'backout'
575 e = cmdutil.getcommiteditor(editform=editform, **opts)
575 e = cmdutil.getcommiteditor(editform=editform, **opts)
576 if not message:
576 if not message:
577 # we don't translate commit messages
577 # we don't translate commit messages
578 message = "Backed out changeset %s" % short(node)
578 message = "Backed out changeset %s" % short(node)
579 e = cmdutil.getcommiteditor(edit=True, editform=editform)
579 e = cmdutil.getcommiteditor(edit=True, editform=editform)
580 return repo.commit(message, opts.get('user'), opts.get('date'),
580 return repo.commit(message, opts.get('user'), opts.get('date'),
581 match, editor=e)
581 match, editor=e)
582 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
582 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
583 if not newnode:
583 if not newnode:
584 ui.status(_("nothing changed\n"))
584 ui.status(_("nothing changed\n"))
585 return 1
585 return 1
586 cmdutil.commitstatus(repo, newnode, branch, bheads)
586 cmdutil.commitstatus(repo, newnode, branch, bheads)
587
587
588 def nice(node):
588 def nice(node):
589 return '%d:%s' % (repo.changelog.rev(node), short(node))
589 return '%d:%s' % (repo.changelog.rev(node), short(node))
590 ui.status(_('changeset %s backs out changeset %s\n') %
590 ui.status(_('changeset %s backs out changeset %s\n') %
591 (nice(repo.changelog.tip()), nice(node)))
591 (nice(repo.changelog.tip()), nice(node)))
592 if opts.get('merge') and op1 != node:
592 if opts.get('merge') and op1 != node:
593 hg.clean(repo, op1, show_stats=False)
593 hg.clean(repo, op1, show_stats=False)
594 ui.status(_('merging with changeset %s\n')
594 ui.status(_('merging with changeset %s\n')
595 % nice(repo.changelog.tip()))
595 % nice(repo.changelog.tip()))
596 try:
596 try:
597 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
597 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
598 'backout')
598 'backout')
599 return hg.merge(repo, hex(repo.changelog.tip()))
599 return hg.merge(repo, hex(repo.changelog.tip()))
600 finally:
600 finally:
601 ui.setconfig('ui', 'forcemerge', '', '')
601 ui.setconfig('ui', 'forcemerge', '', '')
602 finally:
602 finally:
603 wlock.release()
603 wlock.release()
604 return 0
604 return 0
605
605
606 @command('bisect',
606 @command('bisect',
607 [('r', 'reset', False, _('reset bisect state')),
607 [('r', 'reset', False, _('reset bisect state')),
608 ('g', 'good', False, _('mark changeset good')),
608 ('g', 'good', False, _('mark changeset good')),
609 ('b', 'bad', False, _('mark changeset bad')),
609 ('b', 'bad', False, _('mark changeset bad')),
610 ('s', 'skip', False, _('skip testing changeset')),
610 ('s', 'skip', False, _('skip testing changeset')),
611 ('e', 'extend', False, _('extend the bisect range')),
611 ('e', 'extend', False, _('extend the bisect range')),
612 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
612 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
613 ('U', 'noupdate', False, _('do not update to target'))],
613 ('U', 'noupdate', False, _('do not update to target'))],
614 _("[-gbsr] [-U] [-c CMD] [REV]"))
614 _("[-gbsr] [-U] [-c CMD] [REV]"))
615 def bisect(ui, repo, rev=None, extra=None, command=None,
615 def bisect(ui, repo, rev=None, extra=None, command=None,
616 reset=None, good=None, bad=None, skip=None, extend=None,
616 reset=None, good=None, bad=None, skip=None, extend=None,
617 noupdate=None):
617 noupdate=None):
618 """subdivision search of changesets
618 """subdivision search of changesets
619
619
620 This command helps to find changesets which introduce problems. To
620 This command helps to find changesets which introduce problems. To
621 use, mark the earliest changeset you know exhibits the problem as
621 use, mark the earliest changeset you know exhibits the problem as
622 bad, then mark the latest changeset which is free from the problem
622 bad, then mark the latest changeset which is free from the problem
623 as good. Bisect will update your working directory to a revision
623 as good. Bisect will update your working directory to a revision
624 for testing (unless the -U/--noupdate option is specified). Once
624 for testing (unless the -U/--noupdate option is specified). Once
625 you have performed tests, mark the working directory as good or
625 you have performed tests, mark the working directory as good or
626 bad, and bisect will either update to another candidate changeset
626 bad, and bisect will either update to another candidate changeset
627 or announce that it has found the bad revision.
627 or announce that it has found the bad revision.
628
628
629 As a shortcut, you can also use the revision argument to mark a
629 As a shortcut, you can also use the revision argument to mark a
630 revision as good or bad without checking it out first.
630 revision as good or bad without checking it out first.
631
631
632 If you supply a command, it will be used for automatic bisection.
632 If you supply a command, it will be used for automatic bisection.
633 The environment variable HG_NODE will contain the ID of the
633 The environment variable HG_NODE will contain the ID of the
634 changeset being tested. The exit status of the command will be
634 changeset being tested. The exit status of the command will be
635 used to mark revisions as good or bad: status 0 means good, 125
635 used to mark revisions as good or bad: status 0 means good, 125
636 means to skip the revision, 127 (command not found) will abort the
636 means to skip the revision, 127 (command not found) will abort the
637 bisection, and any other non-zero exit status means the revision
637 bisection, and any other non-zero exit status means the revision
638 is bad.
638 is bad.
639
639
640 .. container:: verbose
640 .. container:: verbose
641
641
642 Some examples:
642 Some examples:
643
643
644 - start a bisection with known bad revision 34, and good revision 12::
644 - start a bisection with known bad revision 34, and good revision 12::
645
645
646 hg bisect --bad 34
646 hg bisect --bad 34
647 hg bisect --good 12
647 hg bisect --good 12
648
648
649 - advance the current bisection by marking current revision as good or
649 - advance the current bisection by marking current revision as good or
650 bad::
650 bad::
651
651
652 hg bisect --good
652 hg bisect --good
653 hg bisect --bad
653 hg bisect --bad
654
654
655 - mark the current revision, or a known revision, to be skipped (e.g. if
655 - mark the current revision, or a known revision, to be skipped (e.g. if
656 that revision is not usable because of another issue)::
656 that revision is not usable because of another issue)::
657
657
658 hg bisect --skip
658 hg bisect --skip
659 hg bisect --skip 23
659 hg bisect --skip 23
660
660
661 - skip all revisions that do not touch directories ``foo`` or ``bar``::
661 - skip all revisions that do not touch directories ``foo`` or ``bar``::
662
662
663 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
663 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
664
664
665 - forget the current bisection::
665 - forget the current bisection::
666
666
667 hg bisect --reset
667 hg bisect --reset
668
668
669 - use 'make && make tests' to automatically find the first broken
669 - use 'make && make tests' to automatically find the first broken
670 revision::
670 revision::
671
671
672 hg bisect --reset
672 hg bisect --reset
673 hg bisect --bad 34
673 hg bisect --bad 34
674 hg bisect --good 12
674 hg bisect --good 12
675 hg bisect --command "make && make tests"
675 hg bisect --command "make && make tests"
676
676
677 - see all changesets whose states are already known in the current
677 - see all changesets whose states are already known in the current
678 bisection::
678 bisection::
679
679
680 hg log -r "bisect(pruned)"
680 hg log -r "bisect(pruned)"
681
681
682 - see the changeset currently being bisected (especially useful
682 - see the changeset currently being bisected (especially useful
683 if running with -U/--noupdate)::
683 if running with -U/--noupdate)::
684
684
685 hg log -r "bisect(current)"
685 hg log -r "bisect(current)"
686
686
687 - see all changesets that took part in the current bisection::
687 - see all changesets that took part in the current bisection::
688
688
689 hg log -r "bisect(range)"
689 hg log -r "bisect(range)"
690
690
691 - you can even get a nice graph::
691 - you can even get a nice graph::
692
692
693 hg log --graph -r "bisect(range)"
693 hg log --graph -r "bisect(range)"
694
694
695 See :hg:`help revsets` for more about the `bisect()` keyword.
695 See :hg:`help revsets` for more about the `bisect()` keyword.
696
696
697 Returns 0 on success.
697 Returns 0 on success.
698 """
698 """
699 def extendbisectrange(nodes, good):
699 def extendbisectrange(nodes, good):
700 # bisect is incomplete when it ends on a merge node and
700 # bisect is incomplete when it ends on a merge node and
701 # one of the parent was not checked.
701 # one of the parent was not checked.
702 parents = repo[nodes[0]].parents()
702 parents = repo[nodes[0]].parents()
703 if len(parents) > 1:
703 if len(parents) > 1:
704 if good:
704 if good:
705 side = state['bad']
705 side = state['bad']
706 else:
706 else:
707 side = state['good']
707 side = state['good']
708 num = len(set(i.node() for i in parents) & set(side))
708 num = len(set(i.node() for i in parents) & set(side))
709 if num == 1:
709 if num == 1:
710 return parents[0].ancestor(parents[1])
710 return parents[0].ancestor(parents[1])
711 return None
711 return None
712
712
713 def print_result(nodes, good):
713 def print_result(nodes, good):
714 displayer = cmdutil.show_changeset(ui, repo, {})
714 displayer = cmdutil.show_changeset(ui, repo, {})
715 if len(nodes) == 1:
715 if len(nodes) == 1:
716 # narrowed it down to a single revision
716 # narrowed it down to a single revision
717 if good:
717 if good:
718 ui.write(_("The first good revision is:\n"))
718 ui.write(_("The first good revision is:\n"))
719 else:
719 else:
720 ui.write(_("The first bad revision is:\n"))
720 ui.write(_("The first bad revision is:\n"))
721 displayer.show(repo[nodes[0]])
721 displayer.show(repo[nodes[0]])
722 extendnode = extendbisectrange(nodes, good)
722 extendnode = extendbisectrange(nodes, good)
723 if extendnode is not None:
723 if extendnode is not None:
724 ui.write(_('Not all ancestors of this changeset have been'
724 ui.write(_('Not all ancestors of this changeset have been'
725 ' checked.\nUse bisect --extend to continue the '
725 ' checked.\nUse bisect --extend to continue the '
726 'bisection from\nthe common ancestor, %s.\n')
726 'bisection from\nthe common ancestor, %s.\n')
727 % extendnode)
727 % extendnode)
728 else:
728 else:
729 # multiple possible revisions
729 # multiple possible revisions
730 if good:
730 if good:
731 ui.write(_("Due to skipped revisions, the first "
731 ui.write(_("Due to skipped revisions, the first "
732 "good revision could be any of:\n"))
732 "good revision could be any of:\n"))
733 else:
733 else:
734 ui.write(_("Due to skipped revisions, the first "
734 ui.write(_("Due to skipped revisions, the first "
735 "bad revision could be any of:\n"))
735 "bad revision could be any of:\n"))
736 for n in nodes:
736 for n in nodes:
737 displayer.show(repo[n])
737 displayer.show(repo[n])
738 displayer.close()
738 displayer.close()
739
739
740 def check_state(state, interactive=True):
740 def check_state(state, interactive=True):
741 if not state['good'] or not state['bad']:
741 if not state['good'] or not state['bad']:
742 if (good or bad or skip or reset) and interactive:
742 if (good or bad or skip or reset) and interactive:
743 return
743 return
744 if not state['good']:
744 if not state['good']:
745 raise util.Abort(_('cannot bisect (no known good revisions)'))
745 raise util.Abort(_('cannot bisect (no known good revisions)'))
746 else:
746 else:
747 raise util.Abort(_('cannot bisect (no known bad revisions)'))
747 raise util.Abort(_('cannot bisect (no known bad revisions)'))
748 return True
748 return True
749
749
750 # backward compatibility
750 # backward compatibility
751 if rev in "good bad reset init".split():
751 if rev in "good bad reset init".split():
752 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
752 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
753 cmd, rev, extra = rev, extra, None
753 cmd, rev, extra = rev, extra, None
754 if cmd == "good":
754 if cmd == "good":
755 good = True
755 good = True
756 elif cmd == "bad":
756 elif cmd == "bad":
757 bad = True
757 bad = True
758 else:
758 else:
759 reset = True
759 reset = True
760 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
760 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
761 raise util.Abort(_('incompatible arguments'))
761 raise util.Abort(_('incompatible arguments'))
762
762
763 cmdutil.checkunfinished(repo)
763 cmdutil.checkunfinished(repo)
764
764
765 if reset:
765 if reset:
766 p = repo.join("bisect.state")
766 p = repo.join("bisect.state")
767 if os.path.exists(p):
767 if os.path.exists(p):
768 os.unlink(p)
768 os.unlink(p)
769 return
769 return
770
770
771 state = hbisect.load_state(repo)
771 state = hbisect.load_state(repo)
772
772
773 if command:
773 if command:
774 changesets = 1
774 changesets = 1
775 if noupdate:
775 if noupdate:
776 try:
776 try:
777 node = state['current'][0]
777 node = state['current'][0]
778 except LookupError:
778 except LookupError:
779 raise util.Abort(_('current bisect revision is unknown - '
779 raise util.Abort(_('current bisect revision is unknown - '
780 'start a new bisect to fix'))
780 'start a new bisect to fix'))
781 else:
781 else:
782 node, p2 = repo.dirstate.parents()
782 node, p2 = repo.dirstate.parents()
783 if p2 != nullid:
783 if p2 != nullid:
784 raise util.Abort(_('current bisect revision is a merge'))
784 raise util.Abort(_('current bisect revision is a merge'))
785 try:
785 try:
786 while changesets:
786 while changesets:
787 # update state
787 # update state
788 state['current'] = [node]
788 state['current'] = [node]
789 hbisect.save_state(repo, state)
789 hbisect.save_state(repo, state)
790 status = ui.system(command, environ={'HG_NODE': hex(node)})
790 status = ui.system(command, environ={'HG_NODE': hex(node)})
791 if status == 125:
791 if status == 125:
792 transition = "skip"
792 transition = "skip"
793 elif status == 0:
793 elif status == 0:
794 transition = "good"
794 transition = "good"
795 # status < 0 means process was killed
795 # status < 0 means process was killed
796 elif status == 127:
796 elif status == 127:
797 raise util.Abort(_("failed to execute %s") % command)
797 raise util.Abort(_("failed to execute %s") % command)
798 elif status < 0:
798 elif status < 0:
799 raise util.Abort(_("%s killed") % command)
799 raise util.Abort(_("%s killed") % command)
800 else:
800 else:
801 transition = "bad"
801 transition = "bad"
802 ctx = scmutil.revsingle(repo, rev, node)
802 ctx = scmutil.revsingle(repo, rev, node)
803 rev = None # clear for future iterations
803 rev = None # clear for future iterations
804 state[transition].append(ctx.node())
804 state[transition].append(ctx.node())
805 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
805 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
806 check_state(state, interactive=False)
806 check_state(state, interactive=False)
807 # bisect
807 # bisect
808 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
808 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
809 # update to next check
809 # update to next check
810 node = nodes[0]
810 node = nodes[0]
811 if not noupdate:
811 if not noupdate:
812 cmdutil.bailifchanged(repo)
812 cmdutil.bailifchanged(repo)
813 hg.clean(repo, node, show_stats=False)
813 hg.clean(repo, node, show_stats=False)
814 finally:
814 finally:
815 state['current'] = [node]
815 state['current'] = [node]
816 hbisect.save_state(repo, state)
816 hbisect.save_state(repo, state)
817 print_result(nodes, bgood)
817 print_result(nodes, bgood)
818 return
818 return
819
819
820 # update state
820 # update state
821
821
822 if rev:
822 if rev:
823 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
823 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
824 else:
824 else:
825 nodes = [repo.lookup('.')]
825 nodes = [repo.lookup('.')]
826
826
827 if good or bad or skip:
827 if good or bad or skip:
828 if good:
828 if good:
829 state['good'] += nodes
829 state['good'] += nodes
830 elif bad:
830 elif bad:
831 state['bad'] += nodes
831 state['bad'] += nodes
832 elif skip:
832 elif skip:
833 state['skip'] += nodes
833 state['skip'] += nodes
834 hbisect.save_state(repo, state)
834 hbisect.save_state(repo, state)
835
835
836 if not check_state(state):
836 if not check_state(state):
837 return
837 return
838
838
839 # actually bisect
839 # actually bisect
840 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
840 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
841 if extend:
841 if extend:
842 if not changesets:
842 if not changesets:
843 extendnode = extendbisectrange(nodes, good)
843 extendnode = extendbisectrange(nodes, good)
844 if extendnode is not None:
844 if extendnode is not None:
845 ui.write(_("Extending search to changeset %d:%s\n")
845 ui.write(_("Extending search to changeset %d:%s\n")
846 % (extendnode.rev(), extendnode))
846 % (extendnode.rev(), extendnode))
847 state['current'] = [extendnode.node()]
847 state['current'] = [extendnode.node()]
848 hbisect.save_state(repo, state)
848 hbisect.save_state(repo, state)
849 if noupdate:
849 if noupdate:
850 return
850 return
851 cmdutil.bailifchanged(repo)
851 cmdutil.bailifchanged(repo)
852 return hg.clean(repo, extendnode.node())
852 return hg.clean(repo, extendnode.node())
853 raise util.Abort(_("nothing to extend"))
853 raise util.Abort(_("nothing to extend"))
854
854
855 if changesets == 0:
855 if changesets == 0:
856 print_result(nodes, good)
856 print_result(nodes, good)
857 else:
857 else:
858 assert len(nodes) == 1 # only a single node can be tested next
858 assert len(nodes) == 1 # only a single node can be tested next
859 node = nodes[0]
859 node = nodes[0]
860 # compute the approximate number of remaining tests
860 # compute the approximate number of remaining tests
861 tests, size = 0, 2
861 tests, size = 0, 2
862 while size <= changesets:
862 while size <= changesets:
863 tests, size = tests + 1, size * 2
863 tests, size = tests + 1, size * 2
864 rev = repo.changelog.rev(node)
864 rev = repo.changelog.rev(node)
865 ui.write(_("Testing changeset %d:%s "
865 ui.write(_("Testing changeset %d:%s "
866 "(%d changesets remaining, ~%d tests)\n")
866 "(%d changesets remaining, ~%d tests)\n")
867 % (rev, short(node), changesets, tests))
867 % (rev, short(node), changesets, tests))
868 state['current'] = [node]
868 state['current'] = [node]
869 hbisect.save_state(repo, state)
869 hbisect.save_state(repo, state)
870 if not noupdate:
870 if not noupdate:
871 cmdutil.bailifchanged(repo)
871 cmdutil.bailifchanged(repo)
872 return hg.clean(repo, node)
872 return hg.clean(repo, node)
873
873
874 @command('bookmarks|bookmark',
874 @command('bookmarks|bookmark',
875 [('f', 'force', False, _('force')),
875 [('f', 'force', False, _('force')),
876 ('r', 'rev', '', _('revision'), _('REV')),
876 ('r', 'rev', '', _('revision'), _('REV')),
877 ('d', 'delete', False, _('delete a given bookmark')),
877 ('d', 'delete', False, _('delete a given bookmark')),
878 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
878 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
879 ('i', 'inactive', False, _('mark a bookmark inactive')),
879 ('i', 'inactive', False, _('mark a bookmark inactive')),
880 ] + formatteropts,
880 ] + formatteropts,
881 _('hg bookmarks [OPTIONS]... [NAME]...'))
881 _('hg bookmarks [OPTIONS]... [NAME]...'))
882 def bookmark(ui, repo, *names, **opts):
882 def bookmark(ui, repo, *names, **opts):
883 '''create a new bookmark or list existing bookmarks
883 '''create a new bookmark or list existing bookmarks
884
884
885 Bookmarks are labels on changesets to help track lines of development.
885 Bookmarks are labels on changesets to help track lines of development.
886 Bookmarks are unversioned and can be moved, renamed and deleted.
886 Bookmarks are unversioned and can be moved, renamed and deleted.
887 Deleting or moving a bookmark has no effect on the associated changesets.
887 Deleting or moving a bookmark has no effect on the associated changesets.
888
888
889 Creating or updating to a bookmark causes it to be marked as 'active'.
889 Creating or updating to a bookmark causes it to be marked as 'active'.
890 The active bookmark is indicated with a '*'.
890 The active bookmark is indicated with a '*'.
891 When a commit is made, the active bookmark will advance to the new commit.
891 When a commit is made, the active bookmark will advance to the new commit.
892 A plain :hg:`update` will also advance an active bookmark, if possible.
892 A plain :hg:`update` will also advance an active bookmark, if possible.
893 Updating away from a bookmark will cause it to be deactivated.
893 Updating away from a bookmark will cause it to be deactivated.
894
894
895 Bookmarks can be pushed and pulled between repositories (see
895 Bookmarks can be pushed and pulled between repositories (see
896 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
896 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
897 diverged, a new 'divergent bookmark' of the form 'name@path' will
897 diverged, a new 'divergent bookmark' of the form 'name@path' will
898 be created. Using :hg:`merge` will resolve the divergence.
898 be created. Using :hg:`merge` will resolve the divergence.
899
899
900 A bookmark named '@' has the special property that :hg:`clone` will
900 A bookmark named '@' has the special property that :hg:`clone` will
901 check it out by default if it exists.
901 check it out by default if it exists.
902
902
903 .. container:: verbose
903 .. container:: verbose
904
904
905 Examples:
905 Examples:
906
906
907 - create an active bookmark for a new line of development::
907 - create an active bookmark for a new line of development::
908
908
909 hg book new-feature
909 hg book new-feature
910
910
911 - create an inactive bookmark as a place marker::
911 - create an inactive bookmark as a place marker::
912
912
913 hg book -i reviewed
913 hg book -i reviewed
914
914
915 - create an inactive bookmark on another changeset::
915 - create an inactive bookmark on another changeset::
916
916
917 hg book -r .^ tested
917 hg book -r .^ tested
918
918
919 - rename bookmark turkey to dinner::
919 - rename bookmark turkey to dinner::
920
920
921 hg book -m turkey dinner
921 hg book -m turkey dinner
922
922
923 - move the '@' bookmark from another branch::
923 - move the '@' bookmark from another branch::
924
924
925 hg book -f @
925 hg book -f @
926 '''
926 '''
927 force = opts.get('force')
927 force = opts.get('force')
928 rev = opts.get('rev')
928 rev = opts.get('rev')
929 delete = opts.get('delete')
929 delete = opts.get('delete')
930 rename = opts.get('rename')
930 rename = opts.get('rename')
931 inactive = opts.get('inactive')
931 inactive = opts.get('inactive')
932
932
933 def checkformat(mark):
933 def checkformat(mark):
934 mark = mark.strip()
934 mark = mark.strip()
935 if not mark:
935 if not mark:
936 raise util.Abort(_("bookmark names cannot consist entirely of "
936 raise util.Abort(_("bookmark names cannot consist entirely of "
937 "whitespace"))
937 "whitespace"))
938 scmutil.checknewlabel(repo, mark, 'bookmark')
938 scmutil.checknewlabel(repo, mark, 'bookmark')
939 return mark
939 return mark
940
940
941 def checkconflict(repo, mark, cur, force=False, target=None):
941 def checkconflict(repo, mark, cur, force=False, target=None):
942 if mark in marks and not force:
942 if mark in marks and not force:
943 if target:
943 if target:
944 if marks[mark] == target and target == cur:
944 if marks[mark] == target and target == cur:
945 # re-activating a bookmark
945 # re-activating a bookmark
946 return
946 return
947 anc = repo.changelog.ancestors([repo[target].rev()])
947 anc = repo.changelog.ancestors([repo[target].rev()])
948 bmctx = repo[marks[mark]]
948 bmctx = repo[marks[mark]]
949 divs = [repo[b].node() for b in marks
949 divs = [repo[b].node() for b in marks
950 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
950 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
951
951
952 # allow resolving a single divergent bookmark even if moving
952 # allow resolving a single divergent bookmark even if moving
953 # the bookmark across branches when a revision is specified
953 # the bookmark across branches when a revision is specified
954 # that contains a divergent bookmark
954 # that contains a divergent bookmark
955 if bmctx.rev() not in anc and target in divs:
955 if bmctx.rev() not in anc and target in divs:
956 bookmarks.deletedivergent(repo, [target], mark)
956 bookmarks.deletedivergent(repo, [target], mark)
957 return
957 return
958
958
959 deletefrom = [b for b in divs
959 deletefrom = [b for b in divs
960 if repo[b].rev() in anc or b == target]
960 if repo[b].rev() in anc or b == target]
961 bookmarks.deletedivergent(repo, deletefrom, mark)
961 bookmarks.deletedivergent(repo, deletefrom, mark)
962 if bookmarks.validdest(repo, bmctx, repo[target]):
962 if bookmarks.validdest(repo, bmctx, repo[target]):
963 ui.status(_("moving bookmark '%s' forward from %s\n") %
963 ui.status(_("moving bookmark '%s' forward from %s\n") %
964 (mark, short(bmctx.node())))
964 (mark, short(bmctx.node())))
965 return
965 return
966 raise util.Abort(_("bookmark '%s' already exists "
966 raise util.Abort(_("bookmark '%s' already exists "
967 "(use -f to force)") % mark)
967 "(use -f to force)") % mark)
968 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
968 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
969 and not force):
969 and not force):
970 raise util.Abort(
970 raise util.Abort(
971 _("a bookmark cannot have the name of an existing branch"))
971 _("a bookmark cannot have the name of an existing branch"))
972
972
973 if delete and rename:
973 if delete and rename:
974 raise util.Abort(_("--delete and --rename are incompatible"))
974 raise util.Abort(_("--delete and --rename are incompatible"))
975 if delete and rev:
975 if delete and rev:
976 raise util.Abort(_("--rev is incompatible with --delete"))
976 raise util.Abort(_("--rev is incompatible with --delete"))
977 if rename and rev:
977 if rename and rev:
978 raise util.Abort(_("--rev is incompatible with --rename"))
978 raise util.Abort(_("--rev is incompatible with --rename"))
979 if not names and (delete or rev):
979 if not names and (delete or rev):
980 raise util.Abort(_("bookmark name required"))
980 raise util.Abort(_("bookmark name required"))
981
981
982 if delete or rename or names or inactive:
982 if delete or rename or names or inactive:
983 wlock = lock = tr = None
983 wlock = lock = tr = None
984 try:
984 try:
985 wlock = repo.wlock()
985 wlock = repo.wlock()
986 lock = repo.lock()
986 lock = repo.lock()
987 cur = repo.changectx('.').node()
987 cur = repo.changectx('.').node()
988 marks = repo._bookmarks
988 marks = repo._bookmarks
989 if delete:
989 if delete:
990 tr = repo.transaction('bookmark')
990 tr = repo.transaction('bookmark')
991 for mark in names:
991 for mark in names:
992 if mark not in marks:
992 if mark not in marks:
993 raise util.Abort(_("bookmark '%s' does not exist") %
993 raise util.Abort(_("bookmark '%s' does not exist") %
994 mark)
994 mark)
995 if mark == repo._activebookmark:
995 if mark == repo._activebookmark:
996 bookmarks.deactivate(repo)
996 bookmarks.deactivate(repo)
997 del marks[mark]
997 del marks[mark]
998
998
999 elif rename:
999 elif rename:
1000 tr = repo.transaction('bookmark')
1000 tr = repo.transaction('bookmark')
1001 if not names:
1001 if not names:
1002 raise util.Abort(_("new bookmark name required"))
1002 raise util.Abort(_("new bookmark name required"))
1003 elif len(names) > 1:
1003 elif len(names) > 1:
1004 raise util.Abort(_("only one new bookmark name allowed"))
1004 raise util.Abort(_("only one new bookmark name allowed"))
1005 mark = checkformat(names[0])
1005 mark = checkformat(names[0])
1006 if rename not in marks:
1006 if rename not in marks:
1007 raise util.Abort(_("bookmark '%s' does not exist") % rename)
1007 raise util.Abort(_("bookmark '%s' does not exist") % rename)
1008 checkconflict(repo, mark, cur, force)
1008 checkconflict(repo, mark, cur, force)
1009 marks[mark] = marks[rename]
1009 marks[mark] = marks[rename]
1010 if repo._activebookmark == rename and not inactive:
1010 if repo._activebookmark == rename and not inactive:
1011 bookmarks.activate(repo, mark)
1011 bookmarks.activate(repo, mark)
1012 del marks[rename]
1012 del marks[rename]
1013 elif names:
1013 elif names:
1014 tr = repo.transaction('bookmark')
1014 tr = repo.transaction('bookmark')
1015 newact = None
1015 newact = None
1016 for mark in names:
1016 for mark in names:
1017 mark = checkformat(mark)
1017 mark = checkformat(mark)
1018 if newact is None:
1018 if newact is None:
1019 newact = mark
1019 newact = mark
1020 if inactive and mark == repo._activebookmark:
1020 if inactive and mark == repo._activebookmark:
1021 bookmarks.deactivate(repo)
1021 bookmarks.deactivate(repo)
1022 return
1022 return
1023 tgt = cur
1023 tgt = cur
1024 if rev:
1024 if rev:
1025 tgt = scmutil.revsingle(repo, rev).node()
1025 tgt = scmutil.revsingle(repo, rev).node()
1026 checkconflict(repo, mark, cur, force, tgt)
1026 checkconflict(repo, mark, cur, force, tgt)
1027 marks[mark] = tgt
1027 marks[mark] = tgt
1028 if not inactive and cur == marks[newact] and not rev:
1028 if not inactive and cur == marks[newact] and not rev:
1029 bookmarks.activate(repo, newact)
1029 bookmarks.activate(repo, newact)
1030 elif cur != tgt and newact == repo._activebookmark:
1030 elif cur != tgt and newact == repo._activebookmark:
1031 bookmarks.deactivate(repo)
1031 bookmarks.deactivate(repo)
1032 elif inactive:
1032 elif inactive:
1033 if len(marks) == 0:
1033 if len(marks) == 0:
1034 ui.status(_("no bookmarks set\n"))
1034 ui.status(_("no bookmarks set\n"))
1035 elif not repo._activebookmark:
1035 elif not repo._activebookmark:
1036 ui.status(_("no active bookmark\n"))
1036 ui.status(_("no active bookmark\n"))
1037 else:
1037 else:
1038 bookmarks.deactivate(repo)
1038 bookmarks.deactivate(repo)
1039 if tr is not None:
1039 if tr is not None:
1040 marks.recordchange(tr)
1040 marks.recordchange(tr)
1041 tr.close()
1041 tr.close()
1042 finally:
1042 finally:
1043 lockmod.release(tr, lock, wlock)
1043 lockmod.release(tr, lock, wlock)
1044 else: # show bookmarks
1044 else: # show bookmarks
1045 fm = ui.formatter('bookmarks', opts)
1045 fm = ui.formatter('bookmarks', opts)
1046 hexfn = fm.hexfunc
1046 hexfn = fm.hexfunc
1047 marks = repo._bookmarks
1047 marks = repo._bookmarks
1048 if len(marks) == 0 and not fm:
1048 if len(marks) == 0 and not fm:
1049 ui.status(_("no bookmarks set\n"))
1049 ui.status(_("no bookmarks set\n"))
1050 for bmark, n in sorted(marks.iteritems()):
1050 for bmark, n in sorted(marks.iteritems()):
1051 active = repo._activebookmark
1051 active = repo._activebookmark
1052 if bmark == active:
1052 if bmark == active:
1053 prefix, label = '*', activebookmarklabel
1053 prefix, label = '*', activebookmarklabel
1054 else:
1054 else:
1055 prefix, label = ' ', ''
1055 prefix, label = ' ', ''
1056
1056
1057 fm.startitem()
1057 fm.startitem()
1058 if not ui.quiet:
1058 if not ui.quiet:
1059 fm.plain(' %s ' % prefix, label=label)
1059 fm.plain(' %s ' % prefix, label=label)
1060 fm.write('bookmark', '%s', bmark, label=label)
1060 fm.write('bookmark', '%s', bmark, label=label)
1061 pad = " " * (25 - encoding.colwidth(bmark))
1061 pad = " " * (25 - encoding.colwidth(bmark))
1062 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1062 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1063 repo.changelog.rev(n), hexfn(n), label=label)
1063 repo.changelog.rev(n), hexfn(n), label=label)
1064 fm.data(active=(bmark == active))
1064 fm.data(active=(bmark == active))
1065 fm.plain('\n')
1065 fm.plain('\n')
1066 fm.end()
1066 fm.end()
1067
1067
1068 @command('branch',
1068 @command('branch',
1069 [('f', 'force', None,
1069 [('f', 'force', None,
1070 _('set branch name even if it shadows an existing branch')),
1070 _('set branch name even if it shadows an existing branch')),
1071 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1071 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1072 _('[-fC] [NAME]'))
1072 _('[-fC] [NAME]'))
1073 def branch(ui, repo, label=None, **opts):
1073 def branch(ui, repo, label=None, **opts):
1074 """set or show the current branch name
1074 """set or show the current branch name
1075
1075
1076 .. note::
1076 .. note::
1077
1077
1078 Branch names are permanent and global. Use :hg:`bookmark` to create a
1078 Branch names are permanent and global. Use :hg:`bookmark` to create a
1079 light-weight bookmark instead. See :hg:`help glossary` for more
1079 light-weight bookmark instead. See :hg:`help glossary` for more
1080 information about named branches and bookmarks.
1080 information about named branches and bookmarks.
1081
1081
1082 With no argument, show the current branch name. With one argument,
1082 With no argument, show the current branch name. With one argument,
1083 set the working directory branch name (the branch will not exist
1083 set the working directory branch name (the branch will not exist
1084 in the repository until the next commit). Standard practice
1084 in the repository until the next commit). Standard practice
1085 recommends that primary development take place on the 'default'
1085 recommends that primary development take place on the 'default'
1086 branch.
1086 branch.
1087
1087
1088 Unless -f/--force is specified, branch will not let you set a
1088 Unless -f/--force is specified, branch will not let you set a
1089 branch name that already exists.
1089 branch name that already exists.
1090
1090
1091 Use -C/--clean to reset the working directory branch to that of
1091 Use -C/--clean to reset the working directory branch to that of
1092 the parent of the working directory, negating a previous branch
1092 the parent of the working directory, negating a previous branch
1093 change.
1093 change.
1094
1094
1095 Use the command :hg:`update` to switch to an existing branch. Use
1095 Use the command :hg:`update` to switch to an existing branch. Use
1096 :hg:`commit --close-branch` to mark this branch head as closed.
1096 :hg:`commit --close-branch` to mark this branch head as closed.
1097 When all heads of the branch are closed, the branch will be
1097 When all heads of the branch are closed, the branch will be
1098 considered closed.
1098 considered closed.
1099
1099
1100 Returns 0 on success.
1100 Returns 0 on success.
1101 """
1101 """
1102 if label:
1102 if label:
1103 label = label.strip()
1103 label = label.strip()
1104
1104
1105 if not opts.get('clean') and not label:
1105 if not opts.get('clean') and not label:
1106 ui.write("%s\n" % repo.dirstate.branch())
1106 ui.write("%s\n" % repo.dirstate.branch())
1107 return
1107 return
1108
1108
1109 wlock = repo.wlock()
1109 wlock = repo.wlock()
1110 try:
1110 try:
1111 if opts.get('clean'):
1111 if opts.get('clean'):
1112 label = repo[None].p1().branch()
1112 label = repo[None].p1().branch()
1113 repo.dirstate.setbranch(label)
1113 repo.dirstate.setbranch(label)
1114 ui.status(_('reset working directory to branch %s\n') % label)
1114 ui.status(_('reset working directory to branch %s\n') % label)
1115 elif label:
1115 elif label:
1116 if not opts.get('force') and label in repo.branchmap():
1116 if not opts.get('force') and label in repo.branchmap():
1117 if label not in [p.branch() for p in repo.parents()]:
1117 if label not in [p.branch() for p in repo.parents()]:
1118 raise util.Abort(_('a branch of the same name already'
1118 raise util.Abort(_('a branch of the same name already'
1119 ' exists'),
1119 ' exists'),
1120 # i18n: "it" refers to an existing branch
1120 # i18n: "it" refers to an existing branch
1121 hint=_("use 'hg update' to switch to it"))
1121 hint=_("use 'hg update' to switch to it"))
1122 scmutil.checknewlabel(repo, label, 'branch')
1122 scmutil.checknewlabel(repo, label, 'branch')
1123 repo.dirstate.setbranch(label)
1123 repo.dirstate.setbranch(label)
1124 ui.status(_('marked working directory as branch %s\n') % label)
1124 ui.status(_('marked working directory as branch %s\n') % label)
1125
1125
1126 # find any open named branches aside from default
1126 # find any open named branches aside from default
1127 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1127 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1128 if n != "default" and not c]
1128 if n != "default" and not c]
1129 if not others:
1129 if not others:
1130 ui.status(_('(branches are permanent and global, '
1130 ui.status(_('(branches are permanent and global, '
1131 'did you want a bookmark?)\n'))
1131 'did you want a bookmark?)\n'))
1132 finally:
1132 finally:
1133 wlock.release()
1133 wlock.release()
1134
1134
1135 @command('branches',
1135 @command('branches',
1136 [('a', 'active', False,
1136 [('a', 'active', False,
1137 _('show only branches that have unmerged heads (DEPRECATED)')),
1137 _('show only branches that have unmerged heads (DEPRECATED)')),
1138 ('c', 'closed', False, _('show normal and closed branches')),
1138 ('c', 'closed', False, _('show normal and closed branches')),
1139 ] + formatteropts,
1139 ] + formatteropts,
1140 _('[-ac]'))
1140 _('[-ac]'))
1141 def branches(ui, repo, active=False, closed=False, **opts):
1141 def branches(ui, repo, active=False, closed=False, **opts):
1142 """list repository named branches
1142 """list repository named branches
1143
1143
1144 List the repository's named branches, indicating which ones are
1144 List the repository's named branches, indicating which ones are
1145 inactive. If -c/--closed is specified, also list branches which have
1145 inactive. If -c/--closed is specified, also list branches which have
1146 been marked closed (see :hg:`commit --close-branch`).
1146 been marked closed (see :hg:`commit --close-branch`).
1147
1147
1148 Use the command :hg:`update` to switch to an existing branch.
1148 Use the command :hg:`update` to switch to an existing branch.
1149
1149
1150 Returns 0.
1150 Returns 0.
1151 """
1151 """
1152
1152
1153 fm = ui.formatter('branches', opts)
1153 fm = ui.formatter('branches', opts)
1154 hexfunc = fm.hexfunc
1154 hexfunc = fm.hexfunc
1155
1155
1156 allheads = set(repo.heads())
1156 allheads = set(repo.heads())
1157 branches = []
1157 branches = []
1158 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1158 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1159 isactive = not isclosed and bool(set(heads) & allheads)
1159 isactive = not isclosed and bool(set(heads) & allheads)
1160 branches.append((tag, repo[tip], isactive, not isclosed))
1160 branches.append((tag, repo[tip], isactive, not isclosed))
1161 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1161 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1162 reverse=True)
1162 reverse=True)
1163
1163
1164 for tag, ctx, isactive, isopen in branches:
1164 for tag, ctx, isactive, isopen in branches:
1165 if active and not isactive:
1165 if active and not isactive:
1166 continue
1166 continue
1167 if isactive:
1167 if isactive:
1168 label = 'branches.active'
1168 label = 'branches.active'
1169 notice = ''
1169 notice = ''
1170 elif not isopen:
1170 elif not isopen:
1171 if not closed:
1171 if not closed:
1172 continue
1172 continue
1173 label = 'branches.closed'
1173 label = 'branches.closed'
1174 notice = _(' (closed)')
1174 notice = _(' (closed)')
1175 else:
1175 else:
1176 label = 'branches.inactive'
1176 label = 'branches.inactive'
1177 notice = _(' (inactive)')
1177 notice = _(' (inactive)')
1178 current = (tag == repo.dirstate.branch())
1178 current = (tag == repo.dirstate.branch())
1179 if current:
1179 if current:
1180 label = 'branches.current'
1180 label = 'branches.current'
1181
1181
1182 fm.startitem()
1182 fm.startitem()
1183 fm.write('branch', '%s', tag, label=label)
1183 fm.write('branch', '%s', tag, label=label)
1184 rev = ctx.rev()
1184 rev = ctx.rev()
1185 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1185 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1186 fmt = ' ' * padsize + ' %d:%s'
1186 fmt = ' ' * padsize + ' %d:%s'
1187 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1187 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1188 label='log.changeset changeset.%s' % ctx.phasestr())
1188 label='log.changeset changeset.%s' % ctx.phasestr())
1189 fm.data(active=isactive, closed=not isopen, current=current)
1189 fm.data(active=isactive, closed=not isopen, current=current)
1190 if not ui.quiet:
1190 if not ui.quiet:
1191 fm.plain(notice)
1191 fm.plain(notice)
1192 fm.plain('\n')
1192 fm.plain('\n')
1193 fm.end()
1193 fm.end()
1194
1194
1195 @command('bundle',
1195 @command('bundle',
1196 [('f', 'force', None, _('run even when the destination is unrelated')),
1196 [('f', 'force', None, _('run even when the destination is unrelated')),
1197 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1197 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1198 _('REV')),
1198 _('REV')),
1199 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1199 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1200 _('BRANCH')),
1200 _('BRANCH')),
1201 ('', 'base', [],
1201 ('', 'base', [],
1202 _('a base changeset assumed to be available at the destination'),
1202 _('a base changeset assumed to be available at the destination'),
1203 _('REV')),
1203 _('REV')),
1204 ('a', 'all', None, _('bundle all changesets in the repository')),
1204 ('a', 'all', None, _('bundle all changesets in the repository')),
1205 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1205 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1206 ] + remoteopts,
1206 ] + remoteopts,
1207 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1207 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1208 def bundle(ui, repo, fname, dest=None, **opts):
1208 def bundle(ui, repo, fname, dest=None, **opts):
1209 """create a changegroup file
1209 """create a changegroup file
1210
1210
1211 Generate a compressed changegroup file collecting changesets not
1211 Generate a compressed changegroup file collecting changesets not
1212 known to be in another repository.
1212 known to be in another repository.
1213
1213
1214 If you omit the destination repository, then hg assumes the
1214 If you omit the destination repository, then hg assumes the
1215 destination will have all the nodes you specify with --base
1215 destination will have all the nodes you specify with --base
1216 parameters. To create a bundle containing all changesets, use
1216 parameters. To create a bundle containing all changesets, use
1217 -a/--all (or --base null).
1217 -a/--all (or --base null).
1218
1218
1219 You can change compression method with the -t/--type option.
1219 You can change compression method with the -t/--type option.
1220 The available compression methods are: none, bzip2, and
1220 The available compression methods are: none, bzip2, and
1221 gzip (by default, bundles are compressed using bzip2).
1221 gzip (by default, bundles are compressed using bzip2).
1222
1222
1223 The bundle file can then be transferred using conventional means
1223 The bundle file can then be transferred using conventional means
1224 and applied to another repository with the unbundle or pull
1224 and applied to another repository with the unbundle or pull
1225 command. This is useful when direct push and pull are not
1225 command. This is useful when direct push and pull are not
1226 available or when exporting an entire repository is undesirable.
1226 available or when exporting an entire repository is undesirable.
1227
1227
1228 Applying bundles preserves all changeset contents including
1228 Applying bundles preserves all changeset contents including
1229 permissions, copy/rename information, and revision history.
1229 permissions, copy/rename information, and revision history.
1230
1230
1231 Returns 0 on success, 1 if no changes found.
1231 Returns 0 on success, 1 if no changes found.
1232 """
1232 """
1233 revs = None
1233 revs = None
1234 if 'rev' in opts:
1234 if 'rev' in opts:
1235 revs = scmutil.revrange(repo, opts['rev'])
1235 revs = scmutil.revrange(repo, opts['rev'])
1236
1236
1237 bundletype = opts.get('type', 'bzip2').lower()
1237 bundletype = opts.get('type', 'bzip2').lower()
1238 btypes = {'none': 'HG10UN',
1238 btypes = {'none': 'HG10UN',
1239 'bzip2': 'HG10BZ',
1239 'bzip2': 'HG10BZ',
1240 'gzip': 'HG10GZ',
1240 'gzip': 'HG10GZ',
1241 'bundle2': 'HG20'}
1241 'bundle2': 'HG20'}
1242 bundletype = btypes.get(bundletype)
1242 bundletype = btypes.get(bundletype)
1243 if bundletype not in changegroup.bundletypes:
1243 if bundletype not in changegroup.bundletypes:
1244 raise util.Abort(_('unknown bundle type specified with --type'))
1244 raise util.Abort(_('unknown bundle type specified with --type'))
1245
1245
1246 if opts.get('all'):
1246 if opts.get('all'):
1247 base = ['null']
1247 base = ['null']
1248 else:
1248 else:
1249 base = scmutil.revrange(repo, opts.get('base'))
1249 base = scmutil.revrange(repo, opts.get('base'))
1250 # TODO: get desired bundlecaps from command line.
1250 # TODO: get desired bundlecaps from command line.
1251 bundlecaps = None
1251 bundlecaps = None
1252 if base:
1252 if base:
1253 if dest:
1253 if dest:
1254 raise util.Abort(_("--base is incompatible with specifying "
1254 raise util.Abort(_("--base is incompatible with specifying "
1255 "a destination"))
1255 "a destination"))
1256 common = [repo.lookup(rev) for rev in base]
1256 common = [repo.lookup(rev) for rev in base]
1257 heads = revs and map(repo.lookup, revs) or revs
1257 heads = revs and map(repo.lookup, revs) or revs
1258 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1258 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1259 common=common, bundlecaps=bundlecaps)
1259 common=common, bundlecaps=bundlecaps)
1260 outgoing = None
1260 outgoing = None
1261 else:
1261 else:
1262 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1262 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1263 dest, branches = hg.parseurl(dest, opts.get('branch'))
1263 dest, branches = hg.parseurl(dest, opts.get('branch'))
1264 other = hg.peer(repo, opts, dest)
1264 other = hg.peer(repo, opts, dest)
1265 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1265 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1266 heads = revs and map(repo.lookup, revs) or revs
1266 heads = revs and map(repo.lookup, revs) or revs
1267 outgoing = discovery.findcommonoutgoing(repo, other,
1267 outgoing = discovery.findcommonoutgoing(repo, other,
1268 onlyheads=heads,
1268 onlyheads=heads,
1269 force=opts.get('force'),
1269 force=opts.get('force'),
1270 portable=True)
1270 portable=True)
1271 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1271 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1272 bundlecaps)
1272 bundlecaps)
1273 if not cg:
1273 if not cg:
1274 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1274 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1275 return 1
1275 return 1
1276
1276
1277 changegroup.writebundle(ui, cg, fname, bundletype)
1277 changegroup.writebundle(ui, cg, fname, bundletype)
1278
1278
1279 @command('cat',
1279 @command('cat',
1280 [('o', 'output', '',
1280 [('o', 'output', '',
1281 _('print output to file with formatted name'), _('FORMAT')),
1281 _('print output to file with formatted name'), _('FORMAT')),
1282 ('r', 'rev', '', _('print the given revision'), _('REV')),
1282 ('r', 'rev', '', _('print the given revision'), _('REV')),
1283 ('', 'decode', None, _('apply any matching decode filter')),
1283 ('', 'decode', None, _('apply any matching decode filter')),
1284 ] + walkopts,
1284 ] + walkopts,
1285 _('[OPTION]... FILE...'),
1285 _('[OPTION]... FILE...'),
1286 inferrepo=True)
1286 inferrepo=True)
1287 def cat(ui, repo, file1, *pats, **opts):
1287 def cat(ui, repo, file1, *pats, **opts):
1288 """output the current or given revision of files
1288 """output the current or given revision of files
1289
1289
1290 Print the specified files as they were at the given revision. If
1290 Print the specified files as they were at the given revision. If
1291 no revision is given, the parent of the working directory is used.
1291 no revision is given, the parent of the working directory is used.
1292
1292
1293 Output may be to a file, in which case the name of the file is
1293 Output may be to a file, in which case the name of the file is
1294 given using a format string. The formatting rules as follows:
1294 given using a format string. The formatting rules as follows:
1295
1295
1296 :``%%``: literal "%" character
1296 :``%%``: literal "%" character
1297 :``%s``: basename of file being printed
1297 :``%s``: basename of file being printed
1298 :``%d``: dirname of file being printed, or '.' if in repository root
1298 :``%d``: dirname of file being printed, or '.' if in repository root
1299 :``%p``: root-relative path name of file being printed
1299 :``%p``: root-relative path name of file being printed
1300 :``%H``: changeset hash (40 hexadecimal digits)
1300 :``%H``: changeset hash (40 hexadecimal digits)
1301 :``%R``: changeset revision number
1301 :``%R``: changeset revision number
1302 :``%h``: short-form changeset hash (12 hexadecimal digits)
1302 :``%h``: short-form changeset hash (12 hexadecimal digits)
1303 :``%r``: zero-padded changeset revision number
1303 :``%r``: zero-padded changeset revision number
1304 :``%b``: basename of the exporting repository
1304 :``%b``: basename of the exporting repository
1305
1305
1306 Returns 0 on success.
1306 Returns 0 on success.
1307 """
1307 """
1308 ctx = scmutil.revsingle(repo, opts.get('rev'))
1308 ctx = scmutil.revsingle(repo, opts.get('rev'))
1309 m = scmutil.match(ctx, (file1,) + pats, opts)
1309 m = scmutil.match(ctx, (file1,) + pats, opts)
1310
1310
1311 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1311 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1312
1312
1313 @command('^clone',
1313 @command('^clone',
1314 [('U', 'noupdate', None, _('the clone will include an empty working '
1314 [('U', 'noupdate', None, _('the clone will include an empty working '
1315 'directory (only a repository)')),
1315 'directory (only a repository)')),
1316 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1316 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1317 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1317 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1318 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1318 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1319 ('', 'pull', None, _('use pull protocol to copy metadata')),
1319 ('', 'pull', None, _('use pull protocol to copy metadata')),
1320 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1320 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1321 ] + remoteopts,
1321 ] + remoteopts,
1322 _('[OPTION]... SOURCE [DEST]'),
1322 _('[OPTION]... SOURCE [DEST]'),
1323 norepo=True)
1323 norepo=True)
1324 def clone(ui, source, dest=None, **opts):
1324 def clone(ui, source, dest=None, **opts):
1325 """make a copy of an existing repository
1325 """make a copy of an existing repository
1326
1326
1327 Create a copy of an existing repository in a new directory.
1327 Create a copy of an existing repository in a new directory.
1328
1328
1329 If no destination directory name is specified, it defaults to the
1329 If no destination directory name is specified, it defaults to the
1330 basename of the source.
1330 basename of the source.
1331
1331
1332 The location of the source is added to the new repository's
1332 The location of the source is added to the new repository's
1333 ``.hg/hgrc`` file, as the default to be used for future pulls.
1333 ``.hg/hgrc`` file, as the default to be used for future pulls.
1334
1334
1335 Only local paths and ``ssh://`` URLs are supported as
1335 Only local paths and ``ssh://`` URLs are supported as
1336 destinations. For ``ssh://`` destinations, no working directory or
1336 destinations. For ``ssh://`` destinations, no working directory or
1337 ``.hg/hgrc`` will be created on the remote side.
1337 ``.hg/hgrc`` will be created on the remote side.
1338
1338
1339 To pull only a subset of changesets, specify one or more revisions
1339 To pull only a subset of changesets, specify one or more revisions
1340 identifiers with -r/--rev or branches with -b/--branch. The
1340 identifiers with -r/--rev or branches with -b/--branch. The
1341 resulting clone will contain only the specified changesets and
1341 resulting clone will contain only the specified changesets and
1342 their ancestors. These options (or 'clone src#rev dest') imply
1342 their ancestors. These options (or 'clone src#rev dest') imply
1343 --pull, even for local source repositories. Note that specifying a
1343 --pull, even for local source repositories. Note that specifying a
1344 tag will include the tagged changeset but not the changeset
1344 tag will include the tagged changeset but not the changeset
1345 containing the tag.
1345 containing the tag.
1346
1346
1347 If the source repository has a bookmark called '@' set, that
1347 If the source repository has a bookmark called '@' set, that
1348 revision will be checked out in the new repository by default.
1348 revision will be checked out in the new repository by default.
1349
1349
1350 To check out a particular version, use -u/--update, or
1350 To check out a particular version, use -u/--update, or
1351 -U/--noupdate to create a clone with no working directory.
1351 -U/--noupdate to create a clone with no working directory.
1352
1352
1353 .. container:: verbose
1353 .. container:: verbose
1354
1354
1355 For efficiency, hardlinks are used for cloning whenever the
1355 For efficiency, hardlinks are used for cloning whenever the
1356 source and destination are on the same filesystem (note this
1356 source and destination are on the same filesystem (note this
1357 applies only to the repository data, not to the working
1357 applies only to the repository data, not to the working
1358 directory). Some filesystems, such as AFS, implement hardlinking
1358 directory). Some filesystems, such as AFS, implement hardlinking
1359 incorrectly, but do not report errors. In these cases, use the
1359 incorrectly, but do not report errors. In these cases, use the
1360 --pull option to avoid hardlinking.
1360 --pull option to avoid hardlinking.
1361
1361
1362 In some cases, you can clone repositories and the working
1362 In some cases, you can clone repositories and the working
1363 directory using full hardlinks with ::
1363 directory using full hardlinks with ::
1364
1364
1365 $ cp -al REPO REPOCLONE
1365 $ cp -al REPO REPOCLONE
1366
1366
1367 This is the fastest way to clone, but it is not always safe. The
1367 This is the fastest way to clone, but it is not always safe. The
1368 operation is not atomic (making sure REPO is not modified during
1368 operation is not atomic (making sure REPO is not modified during
1369 the operation is up to you) and you have to make sure your
1369 the operation is up to you) and you have to make sure your
1370 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1370 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1371 so). Also, this is not compatible with certain extensions that
1371 so). Also, this is not compatible with certain extensions that
1372 place their metadata under the .hg directory, such as mq.
1372 place their metadata under the .hg directory, such as mq.
1373
1373
1374 Mercurial will update the working directory to the first applicable
1374 Mercurial will update the working directory to the first applicable
1375 revision from this list:
1375 revision from this list:
1376
1376
1377 a) null if -U or the source repository has no changesets
1377 a) null if -U or the source repository has no changesets
1378 b) if -u . and the source repository is local, the first parent of
1378 b) if -u . and the source repository is local, the first parent of
1379 the source repository's working directory
1379 the source repository's working directory
1380 c) the changeset specified with -u (if a branch name, this means the
1380 c) the changeset specified with -u (if a branch name, this means the
1381 latest head of that branch)
1381 latest head of that branch)
1382 d) the changeset specified with -r
1382 d) the changeset specified with -r
1383 e) the tipmost head specified with -b
1383 e) the tipmost head specified with -b
1384 f) the tipmost head specified with the url#branch source syntax
1384 f) the tipmost head specified with the url#branch source syntax
1385 g) the revision marked with the '@' bookmark, if present
1385 g) the revision marked with the '@' bookmark, if present
1386 h) the tipmost head of the default branch
1386 h) the tipmost head of the default branch
1387 i) tip
1387 i) tip
1388
1388
1389 Examples:
1389 Examples:
1390
1390
1391 - clone a remote repository to a new directory named hg/::
1391 - clone a remote repository to a new directory named hg/::
1392
1392
1393 hg clone http://selenic.com/hg
1393 hg clone http://selenic.com/hg
1394
1394
1395 - create a lightweight local clone::
1395 - create a lightweight local clone::
1396
1396
1397 hg clone project/ project-feature/
1397 hg clone project/ project-feature/
1398
1398
1399 - clone from an absolute path on an ssh server (note double-slash)::
1399 - clone from an absolute path on an ssh server (note double-slash)::
1400
1400
1401 hg clone ssh://user@server//home/projects/alpha/
1401 hg clone ssh://user@server//home/projects/alpha/
1402
1402
1403 - do a high-speed clone over a LAN while checking out a
1403 - do a high-speed clone over a LAN while checking out a
1404 specified version::
1404 specified version::
1405
1405
1406 hg clone --uncompressed http://server/repo -u 1.5
1406 hg clone --uncompressed http://server/repo -u 1.5
1407
1407
1408 - create a repository without changesets after a particular revision::
1408 - create a repository without changesets after a particular revision::
1409
1409
1410 hg clone -r 04e544 experimental/ good/
1410 hg clone -r 04e544 experimental/ good/
1411
1411
1412 - clone (and track) a particular named branch::
1412 - clone (and track) a particular named branch::
1413
1413
1414 hg clone http://selenic.com/hg#stable
1414 hg clone http://selenic.com/hg#stable
1415
1415
1416 See :hg:`help urls` for details on specifying URLs.
1416 See :hg:`help urls` for details on specifying URLs.
1417
1417
1418 Returns 0 on success.
1418 Returns 0 on success.
1419 """
1419 """
1420 if opts.get('noupdate') and opts.get('updaterev'):
1420 if opts.get('noupdate') and opts.get('updaterev'):
1421 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1421 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1422
1422
1423 r = hg.clone(ui, opts, source, dest,
1423 r = hg.clone(ui, opts, source, dest,
1424 pull=opts.get('pull'),
1424 pull=opts.get('pull'),
1425 stream=opts.get('uncompressed'),
1425 stream=opts.get('uncompressed'),
1426 rev=opts.get('rev'),
1426 rev=opts.get('rev'),
1427 update=opts.get('updaterev') or not opts.get('noupdate'),
1427 update=opts.get('updaterev') or not opts.get('noupdate'),
1428 branch=opts.get('branch'),
1428 branch=opts.get('branch'),
1429 shareopts=opts.get('shareopts'))
1429 shareopts=opts.get('shareopts'))
1430
1430
1431 return r is None
1431 return r is None
1432
1432
1433 @command('^commit|ci',
1433 @command('^commit|ci',
1434 [('A', 'addremove', None,
1434 [('A', 'addremove', None,
1435 _('mark new/missing files as added/removed before committing')),
1435 _('mark new/missing files as added/removed before committing')),
1436 ('', 'close-branch', None,
1436 ('', 'close-branch', None,
1437 _('mark a branch head as closed')),
1437 _('mark a branch head as closed')),
1438 ('', 'amend', None, _('amend the parent of the working directory')),
1438 ('', 'amend', None, _('amend the parent of the working directory')),
1439 ('s', 'secret', None, _('use the secret phase for committing')),
1439 ('s', 'secret', None, _('use the secret phase for committing')),
1440 ('e', 'edit', None, _('invoke editor on commit messages')),
1440 ('e', 'edit', None, _('invoke editor on commit messages')),
1441 ('i', 'interactive', None, _('use interactive mode')),
1441 ('i', 'interactive', None, _('use interactive mode')),
1442 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1442 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1443 _('[OPTION]... [FILE]...'),
1443 _('[OPTION]... [FILE]...'),
1444 inferrepo=True)
1444 inferrepo=True)
1445 def commit(ui, repo, *pats, **opts):
1445 def commit(ui, repo, *pats, **opts):
1446 """commit the specified files or all outstanding changes
1446 """commit the specified files or all outstanding changes
1447
1447
1448 Commit changes to the given files into the repository. Unlike a
1448 Commit changes to the given files into the repository. Unlike a
1449 centralized SCM, this operation is a local operation. See
1449 centralized SCM, this operation is a local operation. See
1450 :hg:`push` for a way to actively distribute your changes.
1450 :hg:`push` for a way to actively distribute your changes.
1451
1451
1452 If a list of files is omitted, all changes reported by :hg:`status`
1452 If a list of files is omitted, all changes reported by :hg:`status`
1453 will be committed.
1453 will be committed.
1454
1454
1455 If you are committing the result of a merge, do not provide any
1455 If you are committing the result of a merge, do not provide any
1456 filenames or -I/-X filters.
1456 filenames or -I/-X filters.
1457
1457
1458 If no commit message is specified, Mercurial starts your
1458 If no commit message is specified, Mercurial starts your
1459 configured editor where you can enter a message. In case your
1459 configured editor where you can enter a message. In case your
1460 commit fails, you will find a backup of your message in
1460 commit fails, you will find a backup of your message in
1461 ``.hg/last-message.txt``.
1461 ``.hg/last-message.txt``.
1462
1462
1463 The --close-branch flag can be used to mark the current branch
1463 The --close-branch flag can be used to mark the current branch
1464 head closed. When all heads of a branch are closed, the branch
1464 head closed. When all heads of a branch are closed, the branch
1465 will be considered closed and no longer listed.
1465 will be considered closed and no longer listed.
1466
1466
1467 The --amend flag can be used to amend the parent of the
1467 The --amend flag can be used to amend the parent of the
1468 working directory with a new commit that contains the changes
1468 working directory with a new commit that contains the changes
1469 in the parent in addition to those currently reported by :hg:`status`,
1469 in the parent in addition to those currently reported by :hg:`status`,
1470 if there are any. The old commit is stored in a backup bundle in
1470 if there are any. The old commit is stored in a backup bundle in
1471 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1471 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1472 on how to restore it).
1472 on how to restore it).
1473
1473
1474 Message, user and date are taken from the amended commit unless
1474 Message, user and date are taken from the amended commit unless
1475 specified. When a message isn't specified on the command line,
1475 specified. When a message isn't specified on the command line,
1476 the editor will open with the message of the amended commit.
1476 the editor will open with the message of the amended commit.
1477
1477
1478 It is not possible to amend public changesets (see :hg:`help phases`)
1478 It is not possible to amend public changesets (see :hg:`help phases`)
1479 or changesets that have children.
1479 or changesets that have children.
1480
1480
1481 See :hg:`help dates` for a list of formats valid for -d/--date.
1481 See :hg:`help dates` for a list of formats valid for -d/--date.
1482
1482
1483 Returns 0 on success, 1 if nothing changed.
1483 Returns 0 on success, 1 if nothing changed.
1484 """
1484 """
1485 if opts.get('interactive'):
1485 if opts.get('interactive'):
1486 opts.pop('interactive')
1486 opts.pop('interactive')
1487 cmdutil.dorecord(ui, repo, commit, None, False,
1487 cmdutil.dorecord(ui, repo, commit, None, False,
1488 cmdutil.recordfilter, *pats, **opts)
1488 cmdutil.recordfilter, *pats, **opts)
1489 return
1489 return
1490
1490
1491 if opts.get('subrepos'):
1491 if opts.get('subrepos'):
1492 if opts.get('amend'):
1492 if opts.get('amend'):
1493 raise util.Abort(_('cannot amend with --subrepos'))
1493 raise util.Abort(_('cannot amend with --subrepos'))
1494 # Let --subrepos on the command line override config setting.
1494 # Let --subrepos on the command line override config setting.
1495 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1495 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1496
1496
1497 cmdutil.checkunfinished(repo, commit=True)
1497 cmdutil.checkunfinished(repo, commit=True)
1498
1498
1499 branch = repo[None].branch()
1499 branch = repo[None].branch()
1500 bheads = repo.branchheads(branch)
1500 bheads = repo.branchheads(branch)
1501
1501
1502 extra = {}
1502 extra = {}
1503 if opts.get('close_branch'):
1503 if opts.get('close_branch'):
1504 extra['close'] = 1
1504 extra['close'] = 1
1505
1505
1506 if not bheads:
1506 if not bheads:
1507 raise util.Abort(_('can only close branch heads'))
1507 raise util.Abort(_('can only close branch heads'))
1508 elif opts.get('amend'):
1508 elif opts.get('amend'):
1509 if repo.parents()[0].p1().branch() != branch and \
1509 if repo.parents()[0].p1().branch() != branch and \
1510 repo.parents()[0].p2().branch() != branch:
1510 repo.parents()[0].p2().branch() != branch:
1511 raise util.Abort(_('can only close branch heads'))
1511 raise util.Abort(_('can only close branch heads'))
1512
1512
1513 if opts.get('amend'):
1513 if opts.get('amend'):
1514 if ui.configbool('ui', 'commitsubrepos'):
1514 if ui.configbool('ui', 'commitsubrepos'):
1515 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1515 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1516
1516
1517 old = repo['.']
1517 old = repo['.']
1518 if not old.mutable():
1518 if not old.mutable():
1519 raise util.Abort(_('cannot amend public changesets'))
1519 raise util.Abort(_('cannot amend public changesets'))
1520 if len(repo[None].parents()) > 1:
1520 if len(repo[None].parents()) > 1:
1521 raise util.Abort(_('cannot amend while merging'))
1521 raise util.Abort(_('cannot amend while merging'))
1522 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1522 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1523 if not allowunstable and old.children():
1523 if not allowunstable and old.children():
1524 raise util.Abort(_('cannot amend changeset with children'))
1524 raise util.Abort(_('cannot amend changeset with children'))
1525
1525
1526 # commitfunc is used only for temporary amend commit by cmdutil.amend
1526 # commitfunc is used only for temporary amend commit by cmdutil.amend
1527 def commitfunc(ui, repo, message, match, opts):
1527 def commitfunc(ui, repo, message, match, opts):
1528 return repo.commit(message,
1528 return repo.commit(message,
1529 opts.get('user') or old.user(),
1529 opts.get('user') or old.user(),
1530 opts.get('date') or old.date(),
1530 opts.get('date') or old.date(),
1531 match,
1531 match,
1532 extra=extra)
1532 extra=extra)
1533
1533
1534 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1534 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1535 if node == old.node():
1535 if node == old.node():
1536 ui.status(_("nothing changed\n"))
1536 ui.status(_("nothing changed\n"))
1537 return 1
1537 return 1
1538 else:
1538 else:
1539 def commitfunc(ui, repo, message, match, opts):
1539 def commitfunc(ui, repo, message, match, opts):
1540 backup = ui.backupconfig('phases', 'new-commit')
1540 backup = ui.backupconfig('phases', 'new-commit')
1541 baseui = repo.baseui
1541 baseui = repo.baseui
1542 basebackup = baseui.backupconfig('phases', 'new-commit')
1542 basebackup = baseui.backupconfig('phases', 'new-commit')
1543 try:
1543 try:
1544 if opts.get('secret'):
1544 if opts.get('secret'):
1545 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1545 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1546 # Propagate to subrepos
1546 # Propagate to subrepos
1547 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1547 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1548
1548
1549 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1549 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1550 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1550 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1551 return repo.commit(message, opts.get('user'), opts.get('date'),
1551 return repo.commit(message, opts.get('user'), opts.get('date'),
1552 match,
1552 match,
1553 editor=editor,
1553 editor=editor,
1554 extra=extra)
1554 extra=extra)
1555 finally:
1555 finally:
1556 ui.restoreconfig(backup)
1556 ui.restoreconfig(backup)
1557 repo.baseui.restoreconfig(basebackup)
1557 repo.baseui.restoreconfig(basebackup)
1558
1558
1559
1559
1560 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1560 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1561
1561
1562 if not node:
1562 if not node:
1563 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1563 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1564 if stat[3]:
1564 if stat[3]:
1565 ui.status(_("nothing changed (%d missing files, see "
1565 ui.status(_("nothing changed (%d missing files, see "
1566 "'hg status')\n") % len(stat[3]))
1566 "'hg status')\n") % len(stat[3]))
1567 else:
1567 else:
1568 ui.status(_("nothing changed\n"))
1568 ui.status(_("nothing changed\n"))
1569 return 1
1569 return 1
1570
1570
1571 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1571 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1572
1572
1573 @command('config|showconfig|debugconfig',
1573 @command('config|showconfig|debugconfig',
1574 [('u', 'untrusted', None, _('show untrusted configuration options')),
1574 [('u', 'untrusted', None, _('show untrusted configuration options')),
1575 ('e', 'edit', None, _('edit user config')),
1575 ('e', 'edit', None, _('edit user config')),
1576 ('l', 'local', None, _('edit repository config')),
1576 ('l', 'local', None, _('edit repository config')),
1577 ('g', 'global', None, _('edit global config'))],
1577 ('g', 'global', None, _('edit global config'))],
1578 _('[-u] [NAME]...'),
1578 _('[-u] [NAME]...'),
1579 optionalrepo=True)
1579 optionalrepo=True)
1580 def config(ui, repo, *values, **opts):
1580 def config(ui, repo, *values, **opts):
1581 """show combined config settings from all hgrc files
1581 """show combined config settings from all hgrc files
1582
1582
1583 With no arguments, print names and values of all config items.
1583 With no arguments, print names and values of all config items.
1584
1584
1585 With one argument of the form section.name, print just the value
1585 With one argument of the form section.name, print just the value
1586 of that config item.
1586 of that config item.
1587
1587
1588 With multiple arguments, print names and values of all config
1588 With multiple arguments, print names and values of all config
1589 items with matching section names.
1589 items with matching section names.
1590
1590
1591 With --edit, start an editor on the user-level config file. With
1591 With --edit, start an editor on the user-level config file. With
1592 --global, edit the system-wide config file. With --local, edit the
1592 --global, edit the system-wide config file. With --local, edit the
1593 repository-level config file.
1593 repository-level config file.
1594
1594
1595 With --debug, the source (filename and line number) is printed
1595 With --debug, the source (filename and line number) is printed
1596 for each config item.
1596 for each config item.
1597
1597
1598 See :hg:`help config` for more information about config files.
1598 See :hg:`help config` for more information about config files.
1599
1599
1600 Returns 0 on success, 1 if NAME does not exist.
1600 Returns 0 on success, 1 if NAME does not exist.
1601
1601
1602 """
1602 """
1603
1603
1604 if opts.get('edit') or opts.get('local') or opts.get('global'):
1604 if opts.get('edit') or opts.get('local') or opts.get('global'):
1605 if opts.get('local') and opts.get('global'):
1605 if opts.get('local') and opts.get('global'):
1606 raise util.Abort(_("can't use --local and --global together"))
1606 raise util.Abort(_("can't use --local and --global together"))
1607
1607
1608 if opts.get('local'):
1608 if opts.get('local'):
1609 if not repo:
1609 if not repo:
1610 raise util.Abort(_("can't use --local outside a repository"))
1610 raise util.Abort(_("can't use --local outside a repository"))
1611 paths = [repo.join('hgrc')]
1611 paths = [repo.join('hgrc')]
1612 elif opts.get('global'):
1612 elif opts.get('global'):
1613 paths = scmutil.systemrcpath()
1613 paths = scmutil.systemrcpath()
1614 else:
1614 else:
1615 paths = scmutil.userrcpath()
1615 paths = scmutil.userrcpath()
1616
1616
1617 for f in paths:
1617 for f in paths:
1618 if os.path.exists(f):
1618 if os.path.exists(f):
1619 break
1619 break
1620 else:
1620 else:
1621 if opts.get('global'):
1621 if opts.get('global'):
1622 samplehgrc = uimod.samplehgrcs['global']
1622 samplehgrc = uimod.samplehgrcs['global']
1623 elif opts.get('local'):
1623 elif opts.get('local'):
1624 samplehgrc = uimod.samplehgrcs['local']
1624 samplehgrc = uimod.samplehgrcs['local']
1625 else:
1625 else:
1626 samplehgrc = uimod.samplehgrcs['user']
1626 samplehgrc = uimod.samplehgrcs['user']
1627
1627
1628 f = paths[0]
1628 f = paths[0]
1629 fp = open(f, "w")
1629 fp = open(f, "w")
1630 fp.write(samplehgrc)
1630 fp.write(samplehgrc)
1631 fp.close()
1631 fp.close()
1632
1632
1633 editor = ui.geteditor()
1633 editor = ui.geteditor()
1634 ui.system("%s \"%s\"" % (editor, f),
1634 ui.system("%s \"%s\"" % (editor, f),
1635 onerr=util.Abort, errprefix=_("edit failed"))
1635 onerr=util.Abort, errprefix=_("edit failed"))
1636 return
1636 return
1637
1637
1638 for f in scmutil.rcpath():
1638 for f in scmutil.rcpath():
1639 ui.debug('read config from: %s\n' % f)
1639 ui.debug('read config from: %s\n' % f)
1640 untrusted = bool(opts.get('untrusted'))
1640 untrusted = bool(opts.get('untrusted'))
1641 if values:
1641 if values:
1642 sections = [v for v in values if '.' not in v]
1642 sections = [v for v in values if '.' not in v]
1643 items = [v for v in values if '.' in v]
1643 items = [v for v in values if '.' in v]
1644 if len(items) > 1 or items and sections:
1644 if len(items) > 1 or items and sections:
1645 raise util.Abort(_('only one config item permitted'))
1645 raise util.Abort(_('only one config item permitted'))
1646 matched = False
1646 matched = False
1647 for section, name, value in ui.walkconfig(untrusted=untrusted):
1647 for section, name, value in ui.walkconfig(untrusted=untrusted):
1648 value = str(value).replace('\n', '\\n')
1648 value = str(value).replace('\n', '\\n')
1649 sectname = section + '.' + name
1649 sectname = section + '.' + name
1650 if values:
1650 if values:
1651 for v in values:
1651 for v in values:
1652 if v == section:
1652 if v == section:
1653 ui.debug('%s: ' %
1653 ui.debug('%s: ' %
1654 ui.configsource(section, name, untrusted))
1654 ui.configsource(section, name, untrusted))
1655 ui.write('%s=%s\n' % (sectname, value))
1655 ui.write('%s=%s\n' % (sectname, value))
1656 matched = True
1656 matched = True
1657 elif v == sectname:
1657 elif v == sectname:
1658 ui.debug('%s: ' %
1658 ui.debug('%s: ' %
1659 ui.configsource(section, name, untrusted))
1659 ui.configsource(section, name, untrusted))
1660 ui.write(value, '\n')
1660 ui.write(value, '\n')
1661 matched = True
1661 matched = True
1662 else:
1662 else:
1663 ui.debug('%s: ' %
1663 ui.debug('%s: ' %
1664 ui.configsource(section, name, untrusted))
1664 ui.configsource(section, name, untrusted))
1665 ui.write('%s=%s\n' % (sectname, value))
1665 ui.write('%s=%s\n' % (sectname, value))
1666 matched = True
1666 matched = True
1667 if matched:
1667 if matched:
1668 return 0
1668 return 0
1669 return 1
1669 return 1
1670
1670
1671 @command('copy|cp',
1671 @command('copy|cp',
1672 [('A', 'after', None, _('record a copy that has already occurred')),
1672 [('A', 'after', None, _('record a copy that has already occurred')),
1673 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1673 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1674 ] + walkopts + dryrunopts,
1674 ] + walkopts + dryrunopts,
1675 _('[OPTION]... [SOURCE]... DEST'))
1675 _('[OPTION]... [SOURCE]... DEST'))
1676 def copy(ui, repo, *pats, **opts):
1676 def copy(ui, repo, *pats, **opts):
1677 """mark files as copied for the next commit
1677 """mark files as copied for the next commit
1678
1678
1679 Mark dest as having copies of source files. If dest is a
1679 Mark dest as having copies of source files. If dest is a
1680 directory, copies are put in that directory. If dest is a file,
1680 directory, copies are put in that directory. If dest is a file,
1681 the source must be a single file.
1681 the source must be a single file.
1682
1682
1683 By default, this command copies the contents of files as they
1683 By default, this command copies the contents of files as they
1684 exist in the working directory. If invoked with -A/--after, the
1684 exist in the working directory. If invoked with -A/--after, the
1685 operation is recorded, but no copying is performed.
1685 operation is recorded, but no copying is performed.
1686
1686
1687 This command takes effect with the next commit. To undo a copy
1687 This command takes effect with the next commit. To undo a copy
1688 before that, see :hg:`revert`.
1688 before that, see :hg:`revert`.
1689
1689
1690 Returns 0 on success, 1 if errors are encountered.
1690 Returns 0 on success, 1 if errors are encountered.
1691 """
1691 """
1692 wlock = repo.wlock(False)
1692 wlock = repo.wlock(False)
1693 try:
1693 try:
1694 return cmdutil.copy(ui, repo, pats, opts)
1694 return cmdutil.copy(ui, repo, pats, opts)
1695 finally:
1695 finally:
1696 wlock.release()
1696 wlock.release()
1697
1697
1698 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1698 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1699 def debugancestor(ui, repo, *args):
1699 def debugancestor(ui, repo, *args):
1700 """find the ancestor revision of two revisions in a given index"""
1700 """find the ancestor revision of two revisions in a given index"""
1701 if len(args) == 3:
1701 if len(args) == 3:
1702 index, rev1, rev2 = args
1702 index, rev1, rev2 = args
1703 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1703 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1704 lookup = r.lookup
1704 lookup = r.lookup
1705 elif len(args) == 2:
1705 elif len(args) == 2:
1706 if not repo:
1706 if not repo:
1707 raise util.Abort(_("there is no Mercurial repository here "
1707 raise util.Abort(_("there is no Mercurial repository here "
1708 "(.hg not found)"))
1708 "(.hg not found)"))
1709 rev1, rev2 = args
1709 rev1, rev2 = args
1710 r = repo.changelog
1710 r = repo.changelog
1711 lookup = repo.lookup
1711 lookup = repo.lookup
1712 else:
1712 else:
1713 raise util.Abort(_('either two or three arguments required'))
1713 raise util.Abort(_('either two or three arguments required'))
1714 a = r.ancestor(lookup(rev1), lookup(rev2))
1714 a = r.ancestor(lookup(rev1), lookup(rev2))
1715 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1715 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1716
1716
1717 @command('debugbuilddag',
1717 @command('debugbuilddag',
1718 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1718 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1719 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1719 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1720 ('n', 'new-file', None, _('add new file at each rev'))],
1720 ('n', 'new-file', None, _('add new file at each rev'))],
1721 _('[OPTION]... [TEXT]'))
1721 _('[OPTION]... [TEXT]'))
1722 def debugbuilddag(ui, repo, text=None,
1722 def debugbuilddag(ui, repo, text=None,
1723 mergeable_file=False,
1723 mergeable_file=False,
1724 overwritten_file=False,
1724 overwritten_file=False,
1725 new_file=False):
1725 new_file=False):
1726 """builds a repo with a given DAG from scratch in the current empty repo
1726 """builds a repo with a given DAG from scratch in the current empty repo
1727
1727
1728 The description of the DAG is read from stdin if not given on the
1728 The description of the DAG is read from stdin if not given on the
1729 command line.
1729 command line.
1730
1730
1731 Elements:
1731 Elements:
1732
1732
1733 - "+n" is a linear run of n nodes based on the current default parent
1733 - "+n" is a linear run of n nodes based on the current default parent
1734 - "." is a single node based on the current default parent
1734 - "." is a single node based on the current default parent
1735 - "$" resets the default parent to null (implied at the start);
1735 - "$" resets the default parent to null (implied at the start);
1736 otherwise the default parent is always the last node created
1736 otherwise the default parent is always the last node created
1737 - "<p" sets the default parent to the backref p
1737 - "<p" sets the default parent to the backref p
1738 - "*p" is a fork at parent p, which is a backref
1738 - "*p" is a fork at parent p, which is a backref
1739 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1739 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1740 - "/p2" is a merge of the preceding node and p2
1740 - "/p2" is a merge of the preceding node and p2
1741 - ":tag" defines a local tag for the preceding node
1741 - ":tag" defines a local tag for the preceding node
1742 - "@branch" sets the named branch for subsequent nodes
1742 - "@branch" sets the named branch for subsequent nodes
1743 - "#...\\n" is a comment up to the end of the line
1743 - "#...\\n" is a comment up to the end of the line
1744
1744
1745 Whitespace between the above elements is ignored.
1745 Whitespace between the above elements is ignored.
1746
1746
1747 A backref is either
1747 A backref is either
1748
1748
1749 - a number n, which references the node curr-n, where curr is the current
1749 - a number n, which references the node curr-n, where curr is the current
1750 node, or
1750 node, or
1751 - the name of a local tag you placed earlier using ":tag", or
1751 - the name of a local tag you placed earlier using ":tag", or
1752 - empty to denote the default parent.
1752 - empty to denote the default parent.
1753
1753
1754 All string valued-elements are either strictly alphanumeric, or must
1754 All string valued-elements are either strictly alphanumeric, or must
1755 be enclosed in double quotes ("..."), with "\\" as escape character.
1755 be enclosed in double quotes ("..."), with "\\" as escape character.
1756 """
1756 """
1757
1757
1758 if text is None:
1758 if text is None:
1759 ui.status(_("reading DAG from stdin\n"))
1759 ui.status(_("reading DAG from stdin\n"))
1760 text = ui.fin.read()
1760 text = ui.fin.read()
1761
1761
1762 cl = repo.changelog
1762 cl = repo.changelog
1763 if len(cl) > 0:
1763 if len(cl) > 0:
1764 raise util.Abort(_('repository is not empty'))
1764 raise util.Abort(_('repository is not empty'))
1765
1765
1766 # determine number of revs in DAG
1766 # determine number of revs in DAG
1767 total = 0
1767 total = 0
1768 for type, data in dagparser.parsedag(text):
1768 for type, data in dagparser.parsedag(text):
1769 if type == 'n':
1769 if type == 'n':
1770 total += 1
1770 total += 1
1771
1771
1772 if mergeable_file:
1772 if mergeable_file:
1773 linesperrev = 2
1773 linesperrev = 2
1774 # make a file with k lines per rev
1774 # make a file with k lines per rev
1775 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1775 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1776 initialmergedlines.append("")
1776 initialmergedlines.append("")
1777
1777
1778 tags = []
1778 tags = []
1779
1779
1780 lock = tr = None
1780 lock = tr = None
1781 try:
1781 try:
1782 lock = repo.lock()
1782 lock = repo.lock()
1783 tr = repo.transaction("builddag")
1783 tr = repo.transaction("builddag")
1784
1784
1785 at = -1
1785 at = -1
1786 atbranch = 'default'
1786 atbranch = 'default'
1787 nodeids = []
1787 nodeids = []
1788 id = 0
1788 id = 0
1789 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1789 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1790 for type, data in dagparser.parsedag(text):
1790 for type, data in dagparser.parsedag(text):
1791 if type == 'n':
1791 if type == 'n':
1792 ui.note(('node %s\n' % str(data)))
1792 ui.note(('node %s\n' % str(data)))
1793 id, ps = data
1793 id, ps = data
1794
1794
1795 files = []
1795 files = []
1796 fctxs = {}
1796 fctxs = {}
1797
1797
1798 p2 = None
1798 p2 = None
1799 if mergeable_file:
1799 if mergeable_file:
1800 fn = "mf"
1800 fn = "mf"
1801 p1 = repo[ps[0]]
1801 p1 = repo[ps[0]]
1802 if len(ps) > 1:
1802 if len(ps) > 1:
1803 p2 = repo[ps[1]]
1803 p2 = repo[ps[1]]
1804 pa = p1.ancestor(p2)
1804 pa = p1.ancestor(p2)
1805 base, local, other = [x[fn].data() for x in (pa, p1,
1805 base, local, other = [x[fn].data() for x in (pa, p1,
1806 p2)]
1806 p2)]
1807 m3 = simplemerge.Merge3Text(base, local, other)
1807 m3 = simplemerge.Merge3Text(base, local, other)
1808 ml = [l.strip() for l in m3.merge_lines()]
1808 ml = [l.strip() for l in m3.merge_lines()]
1809 ml.append("")
1809 ml.append("")
1810 elif at > 0:
1810 elif at > 0:
1811 ml = p1[fn].data().split("\n")
1811 ml = p1[fn].data().split("\n")
1812 else:
1812 else:
1813 ml = initialmergedlines
1813 ml = initialmergedlines
1814 ml[id * linesperrev] += " r%i" % id
1814 ml[id * linesperrev] += " r%i" % id
1815 mergedtext = "\n".join(ml)
1815 mergedtext = "\n".join(ml)
1816 files.append(fn)
1816 files.append(fn)
1817 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1817 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1818
1818
1819 if overwritten_file:
1819 if overwritten_file:
1820 fn = "of"
1820 fn = "of"
1821 files.append(fn)
1821 files.append(fn)
1822 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1822 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1823
1823
1824 if new_file:
1824 if new_file:
1825 fn = "nf%i" % id
1825 fn = "nf%i" % id
1826 files.append(fn)
1826 files.append(fn)
1827 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1827 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1828 if len(ps) > 1:
1828 if len(ps) > 1:
1829 if not p2:
1829 if not p2:
1830 p2 = repo[ps[1]]
1830 p2 = repo[ps[1]]
1831 for fn in p2:
1831 for fn in p2:
1832 if fn.startswith("nf"):
1832 if fn.startswith("nf"):
1833 files.append(fn)
1833 files.append(fn)
1834 fctxs[fn] = p2[fn]
1834 fctxs[fn] = p2[fn]
1835
1835
1836 def fctxfn(repo, cx, path):
1836 def fctxfn(repo, cx, path):
1837 return fctxs.get(path)
1837 return fctxs.get(path)
1838
1838
1839 if len(ps) == 0 or ps[0] < 0:
1839 if len(ps) == 0 or ps[0] < 0:
1840 pars = [None, None]
1840 pars = [None, None]
1841 elif len(ps) == 1:
1841 elif len(ps) == 1:
1842 pars = [nodeids[ps[0]], None]
1842 pars = [nodeids[ps[0]], None]
1843 else:
1843 else:
1844 pars = [nodeids[p] for p in ps]
1844 pars = [nodeids[p] for p in ps]
1845 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1845 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1846 date=(id, 0),
1846 date=(id, 0),
1847 user="debugbuilddag",
1847 user="debugbuilddag",
1848 extra={'branch': atbranch})
1848 extra={'branch': atbranch})
1849 nodeid = repo.commitctx(cx)
1849 nodeid = repo.commitctx(cx)
1850 nodeids.append(nodeid)
1850 nodeids.append(nodeid)
1851 at = id
1851 at = id
1852 elif type == 'l':
1852 elif type == 'l':
1853 id, name = data
1853 id, name = data
1854 ui.note(('tag %s\n' % name))
1854 ui.note(('tag %s\n' % name))
1855 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1855 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1856 elif type == 'a':
1856 elif type == 'a':
1857 ui.note(('branch %s\n' % data))
1857 ui.note(('branch %s\n' % data))
1858 atbranch = data
1858 atbranch = data
1859 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1859 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1860 tr.close()
1860 tr.close()
1861
1861
1862 if tags:
1862 if tags:
1863 repo.vfs.write("localtags", "".join(tags))
1863 repo.vfs.write("localtags", "".join(tags))
1864 finally:
1864 finally:
1865 ui.progress(_('building'), None)
1865 ui.progress(_('building'), None)
1866 release(tr, lock)
1866 release(tr, lock)
1867
1867
1868 @command('debugbundle',
1868 @command('debugbundle',
1869 [('a', 'all', None, _('show all details'))],
1869 [('a', 'all', None, _('show all details'))],
1870 _('FILE'),
1870 _('FILE'),
1871 norepo=True)
1871 norepo=True)
1872 def debugbundle(ui, bundlepath, all=None, **opts):
1872 def debugbundle(ui, bundlepath, all=None, **opts):
1873 """lists the contents of a bundle"""
1873 """lists the contents of a bundle"""
1874 f = hg.openpath(ui, bundlepath)
1874 f = hg.openpath(ui, bundlepath)
1875 try:
1875 try:
1876 gen = exchange.readbundle(ui, f, bundlepath)
1876 gen = exchange.readbundle(ui, f, bundlepath)
1877 if isinstance(gen, bundle2.unbundle20):
1877 if isinstance(gen, bundle2.unbundle20):
1878 return _debugbundle2(ui, gen, all=all, **opts)
1878 return _debugbundle2(ui, gen, all=all, **opts)
1879 if all:
1879 if all:
1880 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1880 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1881
1881
1882 def showchunks(named):
1882 def showchunks(named):
1883 ui.write("\n%s\n" % named)
1883 ui.write("\n%s\n" % named)
1884 chain = None
1884 chain = None
1885 while True:
1885 while True:
1886 chunkdata = gen.deltachunk(chain)
1886 chunkdata = gen.deltachunk(chain)
1887 if not chunkdata:
1887 if not chunkdata:
1888 break
1888 break
1889 node = chunkdata['node']
1889 node = chunkdata['node']
1890 p1 = chunkdata['p1']
1890 p1 = chunkdata['p1']
1891 p2 = chunkdata['p2']
1891 p2 = chunkdata['p2']
1892 cs = chunkdata['cs']
1892 cs = chunkdata['cs']
1893 deltabase = chunkdata['deltabase']
1893 deltabase = chunkdata['deltabase']
1894 delta = chunkdata['delta']
1894 delta = chunkdata['delta']
1895 ui.write("%s %s %s %s %s %s\n" %
1895 ui.write("%s %s %s %s %s %s\n" %
1896 (hex(node), hex(p1), hex(p2),
1896 (hex(node), hex(p1), hex(p2),
1897 hex(cs), hex(deltabase), len(delta)))
1897 hex(cs), hex(deltabase), len(delta)))
1898 chain = node
1898 chain = node
1899
1899
1900 chunkdata = gen.changelogheader()
1900 chunkdata = gen.changelogheader()
1901 showchunks("changelog")
1901 showchunks("changelog")
1902 chunkdata = gen.manifestheader()
1902 chunkdata = gen.manifestheader()
1903 showchunks("manifest")
1903 showchunks("manifest")
1904 while True:
1904 while True:
1905 chunkdata = gen.filelogheader()
1905 chunkdata = gen.filelogheader()
1906 if not chunkdata:
1906 if not chunkdata:
1907 break
1907 break
1908 fname = chunkdata['filename']
1908 fname = chunkdata['filename']
1909 showchunks(fname)
1909 showchunks(fname)
1910 else:
1910 else:
1911 if isinstance(gen, bundle2.unbundle20):
1911 if isinstance(gen, bundle2.unbundle20):
1912 raise util.Abort(_('use debugbundle2 for this file'))
1912 raise util.Abort(_('use debugbundle2 for this file'))
1913 chunkdata = gen.changelogheader()
1913 chunkdata = gen.changelogheader()
1914 chain = None
1914 chain = None
1915 while True:
1915 while True:
1916 chunkdata = gen.deltachunk(chain)
1916 chunkdata = gen.deltachunk(chain)
1917 if not chunkdata:
1917 if not chunkdata:
1918 break
1918 break
1919 node = chunkdata['node']
1919 node = chunkdata['node']
1920 ui.write("%s\n" % hex(node))
1920 ui.write("%s\n" % hex(node))
1921 chain = node
1921 chain = node
1922 finally:
1922 finally:
1923 f.close()
1923 f.close()
1924
1924
1925 def _debugbundle2(ui, gen, **opts):
1925 def _debugbundle2(ui, gen, **opts):
1926 """lists the contents of a bundle2"""
1926 """lists the contents of a bundle2"""
1927 if not isinstance(gen, bundle2.unbundle20):
1927 if not isinstance(gen, bundle2.unbundle20):
1928 raise util.Abort(_('not a bundle2 file'))
1928 raise util.Abort(_('not a bundle2 file'))
1929 ui.write(('Stream params: %s\n' % repr(gen.params)))
1929 ui.write(('Stream params: %s\n' % repr(gen.params)))
1930 for part in gen.iterparts():
1930 for part in gen.iterparts():
1931 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1931 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1932 if part.type == 'changegroup':
1932 if part.type == 'changegroup':
1933 version = part.params.get('version', '01')
1933 version = part.params.get('version', '01')
1934 cg = changegroup.packermap[version][1](part, 'UN')
1934 cg = changegroup.packermap[version][1](part, 'UN')
1935 chunkdata = cg.changelogheader()
1935 chunkdata = cg.changelogheader()
1936 chain = None
1936 chain = None
1937 while True:
1937 while True:
1938 chunkdata = cg.deltachunk(chain)
1938 chunkdata = cg.deltachunk(chain)
1939 if not chunkdata:
1939 if not chunkdata:
1940 break
1940 break
1941 node = chunkdata['node']
1941 node = chunkdata['node']
1942 ui.write(" %s\n" % hex(node))
1942 ui.write(" %s\n" % hex(node))
1943 chain = node
1943 chain = node
1944
1944
1945 @command('debugcheckstate', [], '')
1945 @command('debugcheckstate', [], '')
1946 def debugcheckstate(ui, repo):
1946 def debugcheckstate(ui, repo):
1947 """validate the correctness of the current dirstate"""
1947 """validate the correctness of the current dirstate"""
1948 parent1, parent2 = repo.dirstate.parents()
1948 parent1, parent2 = repo.dirstate.parents()
1949 m1 = repo[parent1].manifest()
1949 m1 = repo[parent1].manifest()
1950 m2 = repo[parent2].manifest()
1950 m2 = repo[parent2].manifest()
1951 errors = 0
1951 errors = 0
1952 for f in repo.dirstate:
1952 for f in repo.dirstate:
1953 state = repo.dirstate[f]
1953 state = repo.dirstate[f]
1954 if state in "nr" and f not in m1:
1954 if state in "nr" and f not in m1:
1955 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1955 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1956 errors += 1
1956 errors += 1
1957 if state in "a" and f in m1:
1957 if state in "a" and f in m1:
1958 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1958 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1959 errors += 1
1959 errors += 1
1960 if state in "m" and f not in m1 and f not in m2:
1960 if state in "m" and f not in m1 and f not in m2:
1961 ui.warn(_("%s in state %s, but not in either manifest\n") %
1961 ui.warn(_("%s in state %s, but not in either manifest\n") %
1962 (f, state))
1962 (f, state))
1963 errors += 1
1963 errors += 1
1964 for f in m1:
1964 for f in m1:
1965 state = repo.dirstate[f]
1965 state = repo.dirstate[f]
1966 if state not in "nrm":
1966 if state not in "nrm":
1967 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1967 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1968 errors += 1
1968 errors += 1
1969 if errors:
1969 if errors:
1970 error = _(".hg/dirstate inconsistent with current parent's manifest")
1970 error = _(".hg/dirstate inconsistent with current parent's manifest")
1971 raise util.Abort(error)
1971 raise util.Abort(error)
1972
1972
1973 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1973 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1974 def debugcommands(ui, cmd='', *args):
1974 def debugcommands(ui, cmd='', *args):
1975 """list all available commands and options"""
1975 """list all available commands and options"""
1976 for cmd, vals in sorted(table.iteritems()):
1976 for cmd, vals in sorted(table.iteritems()):
1977 cmd = cmd.split('|')[0].strip('^')
1977 cmd = cmd.split('|')[0].strip('^')
1978 opts = ', '.join([i[1] for i in vals[1]])
1978 opts = ', '.join([i[1] for i in vals[1]])
1979 ui.write('%s: %s\n' % (cmd, opts))
1979 ui.write('%s: %s\n' % (cmd, opts))
1980
1980
1981 @command('debugcomplete',
1981 @command('debugcomplete',
1982 [('o', 'options', None, _('show the command options'))],
1982 [('o', 'options', None, _('show the command options'))],
1983 _('[-o] CMD'),
1983 _('[-o] CMD'),
1984 norepo=True)
1984 norepo=True)
1985 def debugcomplete(ui, cmd='', **opts):
1985 def debugcomplete(ui, cmd='', **opts):
1986 """returns the completion list associated with the given command"""
1986 """returns the completion list associated with the given command"""
1987
1987
1988 if opts.get('options'):
1988 if opts.get('options'):
1989 options = []
1989 options = []
1990 otables = [globalopts]
1990 otables = [globalopts]
1991 if cmd:
1991 if cmd:
1992 aliases, entry = cmdutil.findcmd(cmd, table, False)
1992 aliases, entry = cmdutil.findcmd(cmd, table, False)
1993 otables.append(entry[1])
1993 otables.append(entry[1])
1994 for t in otables:
1994 for t in otables:
1995 for o in t:
1995 for o in t:
1996 if "(DEPRECATED)" in o[3]:
1996 if "(DEPRECATED)" in o[3]:
1997 continue
1997 continue
1998 if o[0]:
1998 if o[0]:
1999 options.append('-%s' % o[0])
1999 options.append('-%s' % o[0])
2000 options.append('--%s' % o[1])
2000 options.append('--%s' % o[1])
2001 ui.write("%s\n" % "\n".join(options))
2001 ui.write("%s\n" % "\n".join(options))
2002 return
2002 return
2003
2003
2004 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2004 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2005 if ui.verbose:
2005 if ui.verbose:
2006 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2006 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2007 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2007 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2008
2008
2009 @command('debugdag',
2009 @command('debugdag',
2010 [('t', 'tags', None, _('use tags as labels')),
2010 [('t', 'tags', None, _('use tags as labels')),
2011 ('b', 'branches', None, _('annotate with branch names')),
2011 ('b', 'branches', None, _('annotate with branch names')),
2012 ('', 'dots', None, _('use dots for runs')),
2012 ('', 'dots', None, _('use dots for runs')),
2013 ('s', 'spaces', None, _('separate elements by spaces'))],
2013 ('s', 'spaces', None, _('separate elements by spaces'))],
2014 _('[OPTION]... [FILE [REV]...]'),
2014 _('[OPTION]... [FILE [REV]...]'),
2015 optionalrepo=True)
2015 optionalrepo=True)
2016 def debugdag(ui, repo, file_=None, *revs, **opts):
2016 def debugdag(ui, repo, file_=None, *revs, **opts):
2017 """format the changelog or an index DAG as a concise textual description
2017 """format the changelog or an index DAG as a concise textual description
2018
2018
2019 If you pass a revlog index, the revlog's DAG is emitted. If you list
2019 If you pass a revlog index, the revlog's DAG is emitted. If you list
2020 revision numbers, they get labeled in the output as rN.
2020 revision numbers, they get labeled in the output as rN.
2021
2021
2022 Otherwise, the changelog DAG of the current repo is emitted.
2022 Otherwise, the changelog DAG of the current repo is emitted.
2023 """
2023 """
2024 spaces = opts.get('spaces')
2024 spaces = opts.get('spaces')
2025 dots = opts.get('dots')
2025 dots = opts.get('dots')
2026 if file_:
2026 if file_:
2027 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2027 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2028 revs = set((int(r) for r in revs))
2028 revs = set((int(r) for r in revs))
2029 def events():
2029 def events():
2030 for r in rlog:
2030 for r in rlog:
2031 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2031 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2032 if p != -1))
2032 if p != -1))
2033 if r in revs:
2033 if r in revs:
2034 yield 'l', (r, "r%i" % r)
2034 yield 'l', (r, "r%i" % r)
2035 elif repo:
2035 elif repo:
2036 cl = repo.changelog
2036 cl = repo.changelog
2037 tags = opts.get('tags')
2037 tags = opts.get('tags')
2038 branches = opts.get('branches')
2038 branches = opts.get('branches')
2039 if tags:
2039 if tags:
2040 labels = {}
2040 labels = {}
2041 for l, n in repo.tags().items():
2041 for l, n in repo.tags().items():
2042 labels.setdefault(cl.rev(n), []).append(l)
2042 labels.setdefault(cl.rev(n), []).append(l)
2043 def events():
2043 def events():
2044 b = "default"
2044 b = "default"
2045 for r in cl:
2045 for r in cl:
2046 if branches:
2046 if branches:
2047 newb = cl.read(cl.node(r))[5]['branch']
2047 newb = cl.read(cl.node(r))[5]['branch']
2048 if newb != b:
2048 if newb != b:
2049 yield 'a', newb
2049 yield 'a', newb
2050 b = newb
2050 b = newb
2051 yield 'n', (r, list(p for p in cl.parentrevs(r)
2051 yield 'n', (r, list(p for p in cl.parentrevs(r)
2052 if p != -1))
2052 if p != -1))
2053 if tags:
2053 if tags:
2054 ls = labels.get(r)
2054 ls = labels.get(r)
2055 if ls:
2055 if ls:
2056 for l in ls:
2056 for l in ls:
2057 yield 'l', (r, l)
2057 yield 'l', (r, l)
2058 else:
2058 else:
2059 raise util.Abort(_('need repo for changelog dag'))
2059 raise util.Abort(_('need repo for changelog dag'))
2060
2060
2061 for line in dagparser.dagtextlines(events(),
2061 for line in dagparser.dagtextlines(events(),
2062 addspaces=spaces,
2062 addspaces=spaces,
2063 wraplabels=True,
2063 wraplabels=True,
2064 wrapannotations=True,
2064 wrapannotations=True,
2065 wrapnonlinear=dots,
2065 wrapnonlinear=dots,
2066 usedots=dots,
2066 usedots=dots,
2067 maxlinewidth=70):
2067 maxlinewidth=70):
2068 ui.write(line)
2068 ui.write(line)
2069 ui.write("\n")
2069 ui.write("\n")
2070
2070
2071 @command('debugdata',
2071 @command('debugdata',
2072 [('c', 'changelog', False, _('open changelog')),
2072 [('c', 'changelog', False, _('open changelog')),
2073 ('m', 'manifest', False, _('open manifest')),
2073 ('m', 'manifest', False, _('open manifest')),
2074 ('', 'dir', False, _('open directory manifest'))],
2074 ('', 'dir', False, _('open directory manifest'))],
2075 _('-c|-m|FILE REV'))
2075 _('-c|-m|FILE REV'))
2076 def debugdata(ui, repo, file_, rev=None, **opts):
2076 def debugdata(ui, repo, file_, rev=None, **opts):
2077 """dump the contents of a data file revision"""
2077 """dump the contents of a data file revision"""
2078 if opts.get('changelog') or opts.get('manifest'):
2078 if opts.get('changelog') or opts.get('manifest'):
2079 file_, rev = None, file_
2079 file_, rev = None, file_
2080 elif rev is None:
2080 elif rev is None:
2081 raise error.CommandError('debugdata', _('invalid arguments'))
2081 raise error.CommandError('debugdata', _('invalid arguments'))
2082 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2082 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2083 try:
2083 try:
2084 ui.write(r.revision(r.lookup(rev)))
2084 ui.write(r.revision(r.lookup(rev)))
2085 except KeyError:
2085 except KeyError:
2086 raise util.Abort(_('invalid revision identifier %s') % rev)
2086 raise util.Abort(_('invalid revision identifier %s') % rev)
2087
2087
2088 @command('debugdate',
2088 @command('debugdate',
2089 [('e', 'extended', None, _('try extended date formats'))],
2089 [('e', 'extended', None, _('try extended date formats'))],
2090 _('[-e] DATE [RANGE]'),
2090 _('[-e] DATE [RANGE]'),
2091 norepo=True, optionalrepo=True)
2091 norepo=True, optionalrepo=True)
2092 def debugdate(ui, date, range=None, **opts):
2092 def debugdate(ui, date, range=None, **opts):
2093 """parse and display a date"""
2093 """parse and display a date"""
2094 if opts["extended"]:
2094 if opts["extended"]:
2095 d = util.parsedate(date, util.extendeddateformats)
2095 d = util.parsedate(date, util.extendeddateformats)
2096 else:
2096 else:
2097 d = util.parsedate(date)
2097 d = util.parsedate(date)
2098 ui.write(("internal: %s %s\n") % d)
2098 ui.write(("internal: %s %s\n") % d)
2099 ui.write(("standard: %s\n") % util.datestr(d))
2099 ui.write(("standard: %s\n") % util.datestr(d))
2100 if range:
2100 if range:
2101 m = util.matchdate(range)
2101 m = util.matchdate(range)
2102 ui.write(("match: %s\n") % m(d[0]))
2102 ui.write(("match: %s\n") % m(d[0]))
2103
2103
2104 @command('debugdiscovery',
2104 @command('debugdiscovery',
2105 [('', 'old', None, _('use old-style discovery')),
2105 [('', 'old', None, _('use old-style discovery')),
2106 ('', 'nonheads', None,
2106 ('', 'nonheads', None,
2107 _('use old-style discovery with non-heads included')),
2107 _('use old-style discovery with non-heads included')),
2108 ] + remoteopts,
2108 ] + remoteopts,
2109 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2109 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2110 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2110 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2111 """runs the changeset discovery protocol in isolation"""
2111 """runs the changeset discovery protocol in isolation"""
2112 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2112 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2113 opts.get('branch'))
2113 opts.get('branch'))
2114 remote = hg.peer(repo, opts, remoteurl)
2114 remote = hg.peer(repo, opts, remoteurl)
2115 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2115 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2116
2116
2117 # make sure tests are repeatable
2117 # make sure tests are repeatable
2118 random.seed(12323)
2118 random.seed(12323)
2119
2119
2120 def doit(localheads, remoteheads, remote=remote):
2120 def doit(localheads, remoteheads, remote=remote):
2121 if opts.get('old'):
2121 if opts.get('old'):
2122 if localheads:
2122 if localheads:
2123 raise util.Abort('cannot use localheads with old style '
2123 raise util.Abort('cannot use localheads with old style '
2124 'discovery')
2124 'discovery')
2125 if not util.safehasattr(remote, 'branches'):
2125 if not util.safehasattr(remote, 'branches'):
2126 # enable in-client legacy support
2126 # enable in-client legacy support
2127 remote = localrepo.locallegacypeer(remote.local())
2127 remote = localrepo.locallegacypeer(remote.local())
2128 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2128 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2129 force=True)
2129 force=True)
2130 common = set(common)
2130 common = set(common)
2131 if not opts.get('nonheads'):
2131 if not opts.get('nonheads'):
2132 ui.write(("unpruned common: %s\n") %
2132 ui.write(("unpruned common: %s\n") %
2133 " ".join(sorted(short(n) for n in common)))
2133 " ".join(sorted(short(n) for n in common)))
2134 dag = dagutil.revlogdag(repo.changelog)
2134 dag = dagutil.revlogdag(repo.changelog)
2135 all = dag.ancestorset(dag.internalizeall(common))
2135 all = dag.ancestorset(dag.internalizeall(common))
2136 common = dag.externalizeall(dag.headsetofconnecteds(all))
2136 common = dag.externalizeall(dag.headsetofconnecteds(all))
2137 else:
2137 else:
2138 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2138 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2139 common = set(common)
2139 common = set(common)
2140 rheads = set(hds)
2140 rheads = set(hds)
2141 lheads = set(repo.heads())
2141 lheads = set(repo.heads())
2142 ui.write(("common heads: %s\n") %
2142 ui.write(("common heads: %s\n") %
2143 " ".join(sorted(short(n) for n in common)))
2143 " ".join(sorted(short(n) for n in common)))
2144 if lheads <= common:
2144 if lheads <= common:
2145 ui.write(("local is subset\n"))
2145 ui.write(("local is subset\n"))
2146 elif rheads <= common:
2146 elif rheads <= common:
2147 ui.write(("remote is subset\n"))
2147 ui.write(("remote is subset\n"))
2148
2148
2149 serverlogs = opts.get('serverlog')
2149 serverlogs = opts.get('serverlog')
2150 if serverlogs:
2150 if serverlogs:
2151 for filename in serverlogs:
2151 for filename in serverlogs:
2152 logfile = open(filename, 'r')
2152 logfile = open(filename, 'r')
2153 try:
2153 try:
2154 line = logfile.readline()
2154 line = logfile.readline()
2155 while line:
2155 while line:
2156 parts = line.strip().split(';')
2156 parts = line.strip().split(';')
2157 op = parts[1]
2157 op = parts[1]
2158 if op == 'cg':
2158 if op == 'cg':
2159 pass
2159 pass
2160 elif op == 'cgss':
2160 elif op == 'cgss':
2161 doit(parts[2].split(' '), parts[3].split(' '))
2161 doit(parts[2].split(' '), parts[3].split(' '))
2162 elif op == 'unb':
2162 elif op == 'unb':
2163 doit(parts[3].split(' '), parts[2].split(' '))
2163 doit(parts[3].split(' '), parts[2].split(' '))
2164 line = logfile.readline()
2164 line = logfile.readline()
2165 finally:
2165 finally:
2166 logfile.close()
2166 logfile.close()
2167
2167
2168 else:
2168 else:
2169 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2169 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2170 opts.get('remote_head'))
2170 opts.get('remote_head'))
2171 localrevs = opts.get('local_head')
2171 localrevs = opts.get('local_head')
2172 doit(localrevs, remoterevs)
2172 doit(localrevs, remoterevs)
2173
2173
2174 @command('debugextensions', formatteropts, [], norepo=True)
2175 def debugextensions(ui, **opts):
2176 '''show information about active extensions'''
2177 exts = extensions.extensions(ui)
2178 fm = ui.formatter('debugextensions', opts)
2179 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2180 extsource = extmod.__file__
2181 exttestedwith = getattr(extmod, 'testedwith', None)
2182 if exttestedwith is not None:
2183 exttestedwith = exttestedwith.split()
2184 extbuglink = getattr(extmod, 'buglink', None)
2185
2186 fm.startitem()
2187
2188 if ui.quiet or ui.verbose:
2189 fm.write('name', '%s\n', extname)
2190 else:
2191 fm.write('name', '%s', extname)
2192 if not exttestedwith:
2193 fm.plain(_(' (untested!)\n'))
2194 else:
2195 if exttestedwith == ['internal'] or \
2196 util.version() in exttestedwith:
2197 fm.plain('\n')
2198 else:
2199 lasttestedversion = exttestedwith[-1]
2200 fm.plain(' (%s!)\n' % lasttestedversion)
2201
2202 fm.condwrite(ui.verbose and extsource, 'source',
2203 _(' location: %s\n'), extsource or "")
2204
2205 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2206 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2207
2208 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2209 _(' bug reporting: %s\n'), extbuglink or "")
2210
2211 fm.end()
2212
2174 @command('debugfileset',
2213 @command('debugfileset',
2175 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2214 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2176 _('[-r REV] FILESPEC'))
2215 _('[-r REV] FILESPEC'))
2177 def debugfileset(ui, repo, expr, **opts):
2216 def debugfileset(ui, repo, expr, **opts):
2178 '''parse and apply a fileset specification'''
2217 '''parse and apply a fileset specification'''
2179 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2218 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2180 if ui.verbose:
2219 if ui.verbose:
2181 tree = fileset.parse(expr)
2220 tree = fileset.parse(expr)
2182 ui.note(fileset.prettyformat(tree), "\n")
2221 ui.note(fileset.prettyformat(tree), "\n")
2183
2222
2184 for f in ctx.getfileset(expr):
2223 for f in ctx.getfileset(expr):
2185 ui.write("%s\n" % f)
2224 ui.write("%s\n" % f)
2186
2225
2187 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2226 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2188 def debugfsinfo(ui, path="."):
2227 def debugfsinfo(ui, path="."):
2189 """show information detected about current filesystem"""
2228 """show information detected about current filesystem"""
2190 util.writefile('.debugfsinfo', '')
2229 util.writefile('.debugfsinfo', '')
2191 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2230 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2192 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2231 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2193 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2232 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2194 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2233 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2195 and 'yes' or 'no'))
2234 and 'yes' or 'no'))
2196 os.unlink('.debugfsinfo')
2235 os.unlink('.debugfsinfo')
2197
2236
2198 @command('debuggetbundle',
2237 @command('debuggetbundle',
2199 [('H', 'head', [], _('id of head node'), _('ID')),
2238 [('H', 'head', [], _('id of head node'), _('ID')),
2200 ('C', 'common', [], _('id of common node'), _('ID')),
2239 ('C', 'common', [], _('id of common node'), _('ID')),
2201 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2240 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2202 _('REPO FILE [-H|-C ID]...'),
2241 _('REPO FILE [-H|-C ID]...'),
2203 norepo=True)
2242 norepo=True)
2204 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2243 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2205 """retrieves a bundle from a repo
2244 """retrieves a bundle from a repo
2206
2245
2207 Every ID must be a full-length hex node id string. Saves the bundle to the
2246 Every ID must be a full-length hex node id string. Saves the bundle to the
2208 given file.
2247 given file.
2209 """
2248 """
2210 repo = hg.peer(ui, opts, repopath)
2249 repo = hg.peer(ui, opts, repopath)
2211 if not repo.capable('getbundle'):
2250 if not repo.capable('getbundle'):
2212 raise util.Abort("getbundle() not supported by target repository")
2251 raise util.Abort("getbundle() not supported by target repository")
2213 args = {}
2252 args = {}
2214 if common:
2253 if common:
2215 args['common'] = [bin(s) for s in common]
2254 args['common'] = [bin(s) for s in common]
2216 if head:
2255 if head:
2217 args['heads'] = [bin(s) for s in head]
2256 args['heads'] = [bin(s) for s in head]
2218 # TODO: get desired bundlecaps from command line.
2257 # TODO: get desired bundlecaps from command line.
2219 args['bundlecaps'] = None
2258 args['bundlecaps'] = None
2220 bundle = repo.getbundle('debug', **args)
2259 bundle = repo.getbundle('debug', **args)
2221
2260
2222 bundletype = opts.get('type', 'bzip2').lower()
2261 bundletype = opts.get('type', 'bzip2').lower()
2223 btypes = {'none': 'HG10UN',
2262 btypes = {'none': 'HG10UN',
2224 'bzip2': 'HG10BZ',
2263 'bzip2': 'HG10BZ',
2225 'gzip': 'HG10GZ',
2264 'gzip': 'HG10GZ',
2226 'bundle2': 'HG20'}
2265 'bundle2': 'HG20'}
2227 bundletype = btypes.get(bundletype)
2266 bundletype = btypes.get(bundletype)
2228 if bundletype not in changegroup.bundletypes:
2267 if bundletype not in changegroup.bundletypes:
2229 raise util.Abort(_('unknown bundle type specified with --type'))
2268 raise util.Abort(_('unknown bundle type specified with --type'))
2230 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2269 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2231
2270
2232 @command('debugignore', [], '')
2271 @command('debugignore', [], '')
2233 def debugignore(ui, repo, *values, **opts):
2272 def debugignore(ui, repo, *values, **opts):
2234 """display the combined ignore pattern"""
2273 """display the combined ignore pattern"""
2235 ignore = repo.dirstate._ignore
2274 ignore = repo.dirstate._ignore
2236 includepat = getattr(ignore, 'includepat', None)
2275 includepat = getattr(ignore, 'includepat', None)
2237 if includepat is not None:
2276 if includepat is not None:
2238 ui.write("%s\n" % includepat)
2277 ui.write("%s\n" % includepat)
2239 else:
2278 else:
2240 raise util.Abort(_("no ignore patterns found"))
2279 raise util.Abort(_("no ignore patterns found"))
2241
2280
2242 @command('debugindex',
2281 @command('debugindex',
2243 [('c', 'changelog', False, _('open changelog')),
2282 [('c', 'changelog', False, _('open changelog')),
2244 ('m', 'manifest', False, _('open manifest')),
2283 ('m', 'manifest', False, _('open manifest')),
2245 ('', 'dir', False, _('open directory manifest')),
2284 ('', 'dir', False, _('open directory manifest')),
2246 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2285 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2247 _('[-f FORMAT] -c|-m|FILE'),
2286 _('[-f FORMAT] -c|-m|FILE'),
2248 optionalrepo=True)
2287 optionalrepo=True)
2249 def debugindex(ui, repo, file_=None, **opts):
2288 def debugindex(ui, repo, file_=None, **opts):
2250 """dump the contents of an index file"""
2289 """dump the contents of an index file"""
2251 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2290 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2252 format = opts.get('format', 0)
2291 format = opts.get('format', 0)
2253 if format not in (0, 1):
2292 if format not in (0, 1):
2254 raise util.Abort(_("unknown format %d") % format)
2293 raise util.Abort(_("unknown format %d") % format)
2255
2294
2256 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2295 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2257 if generaldelta:
2296 if generaldelta:
2258 basehdr = ' delta'
2297 basehdr = ' delta'
2259 else:
2298 else:
2260 basehdr = ' base'
2299 basehdr = ' base'
2261
2300
2262 if ui.debugflag:
2301 if ui.debugflag:
2263 shortfn = hex
2302 shortfn = hex
2264 else:
2303 else:
2265 shortfn = short
2304 shortfn = short
2266
2305
2267 # There might not be anything in r, so have a sane default
2306 # There might not be anything in r, so have a sane default
2268 idlen = 12
2307 idlen = 12
2269 for i in r:
2308 for i in r:
2270 idlen = len(shortfn(r.node(i)))
2309 idlen = len(shortfn(r.node(i)))
2271 break
2310 break
2272
2311
2273 if format == 0:
2312 if format == 0:
2274 ui.write(" rev offset length " + basehdr + " linkrev"
2313 ui.write(" rev offset length " + basehdr + " linkrev"
2275 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2314 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2276 elif format == 1:
2315 elif format == 1:
2277 ui.write(" rev flag offset length"
2316 ui.write(" rev flag offset length"
2278 " size " + basehdr + " link p1 p2"
2317 " size " + basehdr + " link p1 p2"
2279 " %s\n" % "nodeid".rjust(idlen))
2318 " %s\n" % "nodeid".rjust(idlen))
2280
2319
2281 for i in r:
2320 for i in r:
2282 node = r.node(i)
2321 node = r.node(i)
2283 if generaldelta:
2322 if generaldelta:
2284 base = r.deltaparent(i)
2323 base = r.deltaparent(i)
2285 else:
2324 else:
2286 base = r.chainbase(i)
2325 base = r.chainbase(i)
2287 if format == 0:
2326 if format == 0:
2288 try:
2327 try:
2289 pp = r.parents(node)
2328 pp = r.parents(node)
2290 except Exception:
2329 except Exception:
2291 pp = [nullid, nullid]
2330 pp = [nullid, nullid]
2292 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2331 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2293 i, r.start(i), r.length(i), base, r.linkrev(i),
2332 i, r.start(i), r.length(i), base, r.linkrev(i),
2294 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2333 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2295 elif format == 1:
2334 elif format == 1:
2296 pr = r.parentrevs(i)
2335 pr = r.parentrevs(i)
2297 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2336 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2298 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2337 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2299 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2338 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2300
2339
2301 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2340 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2302 def debugindexdot(ui, repo, file_):
2341 def debugindexdot(ui, repo, file_):
2303 """dump an index DAG as a graphviz dot file"""
2342 """dump an index DAG as a graphviz dot file"""
2304 r = None
2343 r = None
2305 if repo:
2344 if repo:
2306 filelog = repo.file(file_)
2345 filelog = repo.file(file_)
2307 if len(filelog):
2346 if len(filelog):
2308 r = filelog
2347 r = filelog
2309 if not r:
2348 if not r:
2310 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2349 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2311 ui.write(("digraph G {\n"))
2350 ui.write(("digraph G {\n"))
2312 for i in r:
2351 for i in r:
2313 node = r.node(i)
2352 node = r.node(i)
2314 pp = r.parents(node)
2353 pp = r.parents(node)
2315 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2354 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2316 if pp[1] != nullid:
2355 if pp[1] != nullid:
2317 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2356 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2318 ui.write("}\n")
2357 ui.write("}\n")
2319
2358
2320 @command('debuginstall', [], '', norepo=True)
2359 @command('debuginstall', [], '', norepo=True)
2321 def debuginstall(ui):
2360 def debuginstall(ui):
2322 '''test Mercurial installation
2361 '''test Mercurial installation
2323
2362
2324 Returns 0 on success.
2363 Returns 0 on success.
2325 '''
2364 '''
2326
2365
2327 def writetemp(contents):
2366 def writetemp(contents):
2328 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2367 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2329 f = os.fdopen(fd, "wb")
2368 f = os.fdopen(fd, "wb")
2330 f.write(contents)
2369 f.write(contents)
2331 f.close()
2370 f.close()
2332 return name
2371 return name
2333
2372
2334 problems = 0
2373 problems = 0
2335
2374
2336 # encoding
2375 # encoding
2337 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2376 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2338 try:
2377 try:
2339 encoding.fromlocal("test")
2378 encoding.fromlocal("test")
2340 except util.Abort as inst:
2379 except util.Abort as inst:
2341 ui.write(" %s\n" % inst)
2380 ui.write(" %s\n" % inst)
2342 ui.write(_(" (check that your locale is properly set)\n"))
2381 ui.write(_(" (check that your locale is properly set)\n"))
2343 problems += 1
2382 problems += 1
2344
2383
2345 # Python
2384 # Python
2346 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2385 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2347 ui.status(_("checking Python version (%s)\n")
2386 ui.status(_("checking Python version (%s)\n")
2348 % ("%s.%s.%s" % sys.version_info[:3]))
2387 % ("%s.%s.%s" % sys.version_info[:3]))
2349 ui.status(_("checking Python lib (%s)...\n")
2388 ui.status(_("checking Python lib (%s)...\n")
2350 % os.path.dirname(os.__file__))
2389 % os.path.dirname(os.__file__))
2351
2390
2352 # compiled modules
2391 # compiled modules
2353 ui.status(_("checking installed modules (%s)...\n")
2392 ui.status(_("checking installed modules (%s)...\n")
2354 % os.path.dirname(__file__))
2393 % os.path.dirname(__file__))
2355 try:
2394 try:
2356 import bdiff, mpatch, base85, osutil
2395 import bdiff, mpatch, base85, osutil
2357 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2396 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2358 except Exception as inst:
2397 except Exception as inst:
2359 ui.write(" %s\n" % inst)
2398 ui.write(" %s\n" % inst)
2360 ui.write(_(" One or more extensions could not be found"))
2399 ui.write(_(" One or more extensions could not be found"))
2361 ui.write(_(" (check that you compiled the extensions)\n"))
2400 ui.write(_(" (check that you compiled the extensions)\n"))
2362 problems += 1
2401 problems += 1
2363
2402
2364 # templates
2403 # templates
2365 import templater
2404 import templater
2366 p = templater.templatepaths()
2405 p = templater.templatepaths()
2367 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2406 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2368 if p:
2407 if p:
2369 m = templater.templatepath("map-cmdline.default")
2408 m = templater.templatepath("map-cmdline.default")
2370 if m:
2409 if m:
2371 # template found, check if it is working
2410 # template found, check if it is working
2372 try:
2411 try:
2373 templater.templater(m)
2412 templater.templater(m)
2374 except Exception as inst:
2413 except Exception as inst:
2375 ui.write(" %s\n" % inst)
2414 ui.write(" %s\n" % inst)
2376 p = None
2415 p = None
2377 else:
2416 else:
2378 ui.write(_(" template 'default' not found\n"))
2417 ui.write(_(" template 'default' not found\n"))
2379 p = None
2418 p = None
2380 else:
2419 else:
2381 ui.write(_(" no template directories found\n"))
2420 ui.write(_(" no template directories found\n"))
2382 if not p:
2421 if not p:
2383 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2422 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2384 problems += 1
2423 problems += 1
2385
2424
2386 # editor
2425 # editor
2387 ui.status(_("checking commit editor...\n"))
2426 ui.status(_("checking commit editor...\n"))
2388 editor = ui.geteditor()
2427 editor = ui.geteditor()
2389 editor = util.expandpath(editor)
2428 editor = util.expandpath(editor)
2390 cmdpath = util.findexe(shlex.split(editor)[0])
2429 cmdpath = util.findexe(shlex.split(editor)[0])
2391 if not cmdpath:
2430 if not cmdpath:
2392 if editor == 'vi':
2431 if editor == 'vi':
2393 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2432 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2394 ui.write(_(" (specify a commit editor in your configuration"
2433 ui.write(_(" (specify a commit editor in your configuration"
2395 " file)\n"))
2434 " file)\n"))
2396 else:
2435 else:
2397 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2436 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2398 ui.write(_(" (specify a commit editor in your configuration"
2437 ui.write(_(" (specify a commit editor in your configuration"
2399 " file)\n"))
2438 " file)\n"))
2400 problems += 1
2439 problems += 1
2401
2440
2402 # check username
2441 # check username
2403 ui.status(_("checking username...\n"))
2442 ui.status(_("checking username...\n"))
2404 try:
2443 try:
2405 ui.username()
2444 ui.username()
2406 except util.Abort as e:
2445 except util.Abort as e:
2407 ui.write(" %s\n" % e)
2446 ui.write(" %s\n" % e)
2408 ui.write(_(" (specify a username in your configuration file)\n"))
2447 ui.write(_(" (specify a username in your configuration file)\n"))
2409 problems += 1
2448 problems += 1
2410
2449
2411 if not problems:
2450 if not problems:
2412 ui.status(_("no problems detected\n"))
2451 ui.status(_("no problems detected\n"))
2413 else:
2452 else:
2414 ui.write(_("%s problems detected,"
2453 ui.write(_("%s problems detected,"
2415 " please check your install!\n") % problems)
2454 " please check your install!\n") % problems)
2416
2455
2417 return problems
2456 return problems
2418
2457
2419 @command('debugknown', [], _('REPO ID...'), norepo=True)
2458 @command('debugknown', [], _('REPO ID...'), norepo=True)
2420 def debugknown(ui, repopath, *ids, **opts):
2459 def debugknown(ui, repopath, *ids, **opts):
2421 """test whether node ids are known to a repo
2460 """test whether node ids are known to a repo
2422
2461
2423 Every ID must be a full-length hex node id string. Returns a list of 0s
2462 Every ID must be a full-length hex node id string. Returns a list of 0s
2424 and 1s indicating unknown/known.
2463 and 1s indicating unknown/known.
2425 """
2464 """
2426 repo = hg.peer(ui, opts, repopath)
2465 repo = hg.peer(ui, opts, repopath)
2427 if not repo.capable('known'):
2466 if not repo.capable('known'):
2428 raise util.Abort("known() not supported by target repository")
2467 raise util.Abort("known() not supported by target repository")
2429 flags = repo.known([bin(s) for s in ids])
2468 flags = repo.known([bin(s) for s in ids])
2430 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2469 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2431
2470
2432 @command('debuglabelcomplete', [], _('LABEL...'))
2471 @command('debuglabelcomplete', [], _('LABEL...'))
2433 def debuglabelcomplete(ui, repo, *args):
2472 def debuglabelcomplete(ui, repo, *args):
2434 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2473 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2435 debugnamecomplete(ui, repo, *args)
2474 debugnamecomplete(ui, repo, *args)
2436
2475
2437 @command('debugnamecomplete', [], _('NAME...'))
2476 @command('debugnamecomplete', [], _('NAME...'))
2438 def debugnamecomplete(ui, repo, *args):
2477 def debugnamecomplete(ui, repo, *args):
2439 '''complete "names" - tags, open branch names, bookmark names'''
2478 '''complete "names" - tags, open branch names, bookmark names'''
2440
2479
2441 names = set()
2480 names = set()
2442 # since we previously only listed open branches, we will handle that
2481 # since we previously only listed open branches, we will handle that
2443 # specially (after this for loop)
2482 # specially (after this for loop)
2444 for name, ns in repo.names.iteritems():
2483 for name, ns in repo.names.iteritems():
2445 if name != 'branches':
2484 if name != 'branches':
2446 names.update(ns.listnames(repo))
2485 names.update(ns.listnames(repo))
2447 names.update(tag for (tag, heads, tip, closed)
2486 names.update(tag for (tag, heads, tip, closed)
2448 in repo.branchmap().iterbranches() if not closed)
2487 in repo.branchmap().iterbranches() if not closed)
2449 completions = set()
2488 completions = set()
2450 if not args:
2489 if not args:
2451 args = ['']
2490 args = ['']
2452 for a in args:
2491 for a in args:
2453 completions.update(n for n in names if n.startswith(a))
2492 completions.update(n for n in names if n.startswith(a))
2454 ui.write('\n'.join(sorted(completions)))
2493 ui.write('\n'.join(sorted(completions)))
2455 ui.write('\n')
2494 ui.write('\n')
2456
2495
2457 @command('debuglocks',
2496 @command('debuglocks',
2458 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2497 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2459 ('W', 'force-wlock', None,
2498 ('W', 'force-wlock', None,
2460 _('free the working state lock (DANGEROUS)'))],
2499 _('free the working state lock (DANGEROUS)'))],
2461 _('[OPTION]...'))
2500 _('[OPTION]...'))
2462 def debuglocks(ui, repo, **opts):
2501 def debuglocks(ui, repo, **opts):
2463 """show or modify state of locks
2502 """show or modify state of locks
2464
2503
2465 By default, this command will show which locks are held. This
2504 By default, this command will show which locks are held. This
2466 includes the user and process holding the lock, the amount of time
2505 includes the user and process holding the lock, the amount of time
2467 the lock has been held, and the machine name where the process is
2506 the lock has been held, and the machine name where the process is
2468 running if it's not local.
2507 running if it's not local.
2469
2508
2470 Locks protect the integrity of Mercurial's data, so should be
2509 Locks protect the integrity of Mercurial's data, so should be
2471 treated with care. System crashes or other interruptions may cause
2510 treated with care. System crashes or other interruptions may cause
2472 locks to not be properly released, though Mercurial will usually
2511 locks to not be properly released, though Mercurial will usually
2473 detect and remove such stale locks automatically.
2512 detect and remove such stale locks automatically.
2474
2513
2475 However, detecting stale locks may not always be possible (for
2514 However, detecting stale locks may not always be possible (for
2476 instance, on a shared filesystem). Removing locks may also be
2515 instance, on a shared filesystem). Removing locks may also be
2477 blocked by filesystem permissions.
2516 blocked by filesystem permissions.
2478
2517
2479 Returns 0 if no locks are held.
2518 Returns 0 if no locks are held.
2480
2519
2481 """
2520 """
2482
2521
2483 if opts.get('force_lock'):
2522 if opts.get('force_lock'):
2484 repo.svfs.unlink('lock')
2523 repo.svfs.unlink('lock')
2485 if opts.get('force_wlock'):
2524 if opts.get('force_wlock'):
2486 repo.vfs.unlink('wlock')
2525 repo.vfs.unlink('wlock')
2487 if opts.get('force_lock') or opts.get('force_lock'):
2526 if opts.get('force_lock') or opts.get('force_lock'):
2488 return 0
2527 return 0
2489
2528
2490 now = time.time()
2529 now = time.time()
2491 held = 0
2530 held = 0
2492
2531
2493 def report(vfs, name, method):
2532 def report(vfs, name, method):
2494 # this causes stale locks to get reaped for more accurate reporting
2533 # this causes stale locks to get reaped for more accurate reporting
2495 try:
2534 try:
2496 l = method(False)
2535 l = method(False)
2497 except error.LockHeld:
2536 except error.LockHeld:
2498 l = None
2537 l = None
2499
2538
2500 if l:
2539 if l:
2501 l.release()
2540 l.release()
2502 else:
2541 else:
2503 try:
2542 try:
2504 stat = vfs.lstat(name)
2543 stat = vfs.lstat(name)
2505 age = now - stat.st_mtime
2544 age = now - stat.st_mtime
2506 user = util.username(stat.st_uid)
2545 user = util.username(stat.st_uid)
2507 locker = vfs.readlock(name)
2546 locker = vfs.readlock(name)
2508 if ":" in locker:
2547 if ":" in locker:
2509 host, pid = locker.split(':')
2548 host, pid = locker.split(':')
2510 if host == socket.gethostname():
2549 if host == socket.gethostname():
2511 locker = 'user %s, process %s' % (user, pid)
2550 locker = 'user %s, process %s' % (user, pid)
2512 else:
2551 else:
2513 locker = 'user %s, process %s, host %s' \
2552 locker = 'user %s, process %s, host %s' \
2514 % (user, pid, host)
2553 % (user, pid, host)
2515 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2554 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2516 return 1
2555 return 1
2517 except OSError as e:
2556 except OSError as e:
2518 if e.errno != errno.ENOENT:
2557 if e.errno != errno.ENOENT:
2519 raise
2558 raise
2520
2559
2521 ui.write("%-6s free\n" % (name + ":"))
2560 ui.write("%-6s free\n" % (name + ":"))
2522 return 0
2561 return 0
2523
2562
2524 held += report(repo.svfs, "lock", repo.lock)
2563 held += report(repo.svfs, "lock", repo.lock)
2525 held += report(repo.vfs, "wlock", repo.wlock)
2564 held += report(repo.vfs, "wlock", repo.wlock)
2526
2565
2527 return held
2566 return held
2528
2567
2529 @command('debugobsolete',
2568 @command('debugobsolete',
2530 [('', 'flags', 0, _('markers flag')),
2569 [('', 'flags', 0, _('markers flag')),
2531 ('', 'record-parents', False,
2570 ('', 'record-parents', False,
2532 _('record parent information for the precursor')),
2571 _('record parent information for the precursor')),
2533 ('r', 'rev', [], _('display markers relevant to REV')),
2572 ('r', 'rev', [], _('display markers relevant to REV')),
2534 ] + commitopts2,
2573 ] + commitopts2,
2535 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2574 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2536 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2575 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2537 """create arbitrary obsolete marker
2576 """create arbitrary obsolete marker
2538
2577
2539 With no arguments, displays the list of obsolescence markers."""
2578 With no arguments, displays the list of obsolescence markers."""
2540
2579
2541 def parsenodeid(s):
2580 def parsenodeid(s):
2542 try:
2581 try:
2543 # We do not use revsingle/revrange functions here to accept
2582 # We do not use revsingle/revrange functions here to accept
2544 # arbitrary node identifiers, possibly not present in the
2583 # arbitrary node identifiers, possibly not present in the
2545 # local repository.
2584 # local repository.
2546 n = bin(s)
2585 n = bin(s)
2547 if len(n) != len(nullid):
2586 if len(n) != len(nullid):
2548 raise TypeError()
2587 raise TypeError()
2549 return n
2588 return n
2550 except TypeError:
2589 except TypeError:
2551 raise util.Abort('changeset references must be full hexadecimal '
2590 raise util.Abort('changeset references must be full hexadecimal '
2552 'node identifiers')
2591 'node identifiers')
2553
2592
2554 if precursor is not None:
2593 if precursor is not None:
2555 if opts['rev']:
2594 if opts['rev']:
2556 raise util.Abort('cannot select revision when creating marker')
2595 raise util.Abort('cannot select revision when creating marker')
2557 metadata = {}
2596 metadata = {}
2558 metadata['user'] = opts['user'] or ui.username()
2597 metadata['user'] = opts['user'] or ui.username()
2559 succs = tuple(parsenodeid(succ) for succ in successors)
2598 succs = tuple(parsenodeid(succ) for succ in successors)
2560 l = repo.lock()
2599 l = repo.lock()
2561 try:
2600 try:
2562 tr = repo.transaction('debugobsolete')
2601 tr = repo.transaction('debugobsolete')
2563 try:
2602 try:
2564 date = opts.get('date')
2603 date = opts.get('date')
2565 if date:
2604 if date:
2566 date = util.parsedate(date)
2605 date = util.parsedate(date)
2567 else:
2606 else:
2568 date = None
2607 date = None
2569 prec = parsenodeid(precursor)
2608 prec = parsenodeid(precursor)
2570 parents = None
2609 parents = None
2571 if opts['record_parents']:
2610 if opts['record_parents']:
2572 if prec not in repo.unfiltered():
2611 if prec not in repo.unfiltered():
2573 raise util.Abort('cannot used --record-parents on '
2612 raise util.Abort('cannot used --record-parents on '
2574 'unknown changesets')
2613 'unknown changesets')
2575 parents = repo.unfiltered()[prec].parents()
2614 parents = repo.unfiltered()[prec].parents()
2576 parents = tuple(p.node() for p in parents)
2615 parents = tuple(p.node() for p in parents)
2577 repo.obsstore.create(tr, prec, succs, opts['flags'],
2616 repo.obsstore.create(tr, prec, succs, opts['flags'],
2578 parents=parents, date=date,
2617 parents=parents, date=date,
2579 metadata=metadata)
2618 metadata=metadata)
2580 tr.close()
2619 tr.close()
2581 except ValueError as exc:
2620 except ValueError as exc:
2582 raise util.Abort(_('bad obsmarker input: %s') % exc)
2621 raise util.Abort(_('bad obsmarker input: %s') % exc)
2583 finally:
2622 finally:
2584 tr.release()
2623 tr.release()
2585 finally:
2624 finally:
2586 l.release()
2625 l.release()
2587 else:
2626 else:
2588 if opts['rev']:
2627 if opts['rev']:
2589 revs = scmutil.revrange(repo, opts['rev'])
2628 revs = scmutil.revrange(repo, opts['rev'])
2590 nodes = [repo[r].node() for r in revs]
2629 nodes = [repo[r].node() for r in revs]
2591 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2630 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2592 markers.sort(key=lambda x: x._data)
2631 markers.sort(key=lambda x: x._data)
2593 else:
2632 else:
2594 markers = obsolete.getmarkers(repo)
2633 markers = obsolete.getmarkers(repo)
2595
2634
2596 for m in markers:
2635 for m in markers:
2597 cmdutil.showmarker(ui, m)
2636 cmdutil.showmarker(ui, m)
2598
2637
2599 @command('debugpathcomplete',
2638 @command('debugpathcomplete',
2600 [('f', 'full', None, _('complete an entire path')),
2639 [('f', 'full', None, _('complete an entire path')),
2601 ('n', 'normal', None, _('show only normal files')),
2640 ('n', 'normal', None, _('show only normal files')),
2602 ('a', 'added', None, _('show only added files')),
2641 ('a', 'added', None, _('show only added files')),
2603 ('r', 'removed', None, _('show only removed files'))],
2642 ('r', 'removed', None, _('show only removed files'))],
2604 _('FILESPEC...'))
2643 _('FILESPEC...'))
2605 def debugpathcomplete(ui, repo, *specs, **opts):
2644 def debugpathcomplete(ui, repo, *specs, **opts):
2606 '''complete part or all of a tracked path
2645 '''complete part or all of a tracked path
2607
2646
2608 This command supports shells that offer path name completion. It
2647 This command supports shells that offer path name completion. It
2609 currently completes only files already known to the dirstate.
2648 currently completes only files already known to the dirstate.
2610
2649
2611 Completion extends only to the next path segment unless
2650 Completion extends only to the next path segment unless
2612 --full is specified, in which case entire paths are used.'''
2651 --full is specified, in which case entire paths are used.'''
2613
2652
2614 def complete(path, acceptable):
2653 def complete(path, acceptable):
2615 dirstate = repo.dirstate
2654 dirstate = repo.dirstate
2616 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2655 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2617 rootdir = repo.root + os.sep
2656 rootdir = repo.root + os.sep
2618 if spec != repo.root and not spec.startswith(rootdir):
2657 if spec != repo.root and not spec.startswith(rootdir):
2619 return [], []
2658 return [], []
2620 if os.path.isdir(spec):
2659 if os.path.isdir(spec):
2621 spec += '/'
2660 spec += '/'
2622 spec = spec[len(rootdir):]
2661 spec = spec[len(rootdir):]
2623 fixpaths = os.sep != '/'
2662 fixpaths = os.sep != '/'
2624 if fixpaths:
2663 if fixpaths:
2625 spec = spec.replace(os.sep, '/')
2664 spec = spec.replace(os.sep, '/')
2626 speclen = len(spec)
2665 speclen = len(spec)
2627 fullpaths = opts['full']
2666 fullpaths = opts['full']
2628 files, dirs = set(), set()
2667 files, dirs = set(), set()
2629 adddir, addfile = dirs.add, files.add
2668 adddir, addfile = dirs.add, files.add
2630 for f, st in dirstate.iteritems():
2669 for f, st in dirstate.iteritems():
2631 if f.startswith(spec) and st[0] in acceptable:
2670 if f.startswith(spec) and st[0] in acceptable:
2632 if fixpaths:
2671 if fixpaths:
2633 f = f.replace('/', os.sep)
2672 f = f.replace('/', os.sep)
2634 if fullpaths:
2673 if fullpaths:
2635 addfile(f)
2674 addfile(f)
2636 continue
2675 continue
2637 s = f.find(os.sep, speclen)
2676 s = f.find(os.sep, speclen)
2638 if s >= 0:
2677 if s >= 0:
2639 adddir(f[:s])
2678 adddir(f[:s])
2640 else:
2679 else:
2641 addfile(f)
2680 addfile(f)
2642 return files, dirs
2681 return files, dirs
2643
2682
2644 acceptable = ''
2683 acceptable = ''
2645 if opts['normal']:
2684 if opts['normal']:
2646 acceptable += 'nm'
2685 acceptable += 'nm'
2647 if opts['added']:
2686 if opts['added']:
2648 acceptable += 'a'
2687 acceptable += 'a'
2649 if opts['removed']:
2688 if opts['removed']:
2650 acceptable += 'r'
2689 acceptable += 'r'
2651 cwd = repo.getcwd()
2690 cwd = repo.getcwd()
2652 if not specs:
2691 if not specs:
2653 specs = ['.']
2692 specs = ['.']
2654
2693
2655 files, dirs = set(), set()
2694 files, dirs = set(), set()
2656 for spec in specs:
2695 for spec in specs:
2657 f, d = complete(spec, acceptable or 'nmar')
2696 f, d = complete(spec, acceptable or 'nmar')
2658 files.update(f)
2697 files.update(f)
2659 dirs.update(d)
2698 dirs.update(d)
2660 files.update(dirs)
2699 files.update(dirs)
2661 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2700 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2662 ui.write('\n')
2701 ui.write('\n')
2663
2702
2664 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2703 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2665 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2704 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2666 '''access the pushkey key/value protocol
2705 '''access the pushkey key/value protocol
2667
2706
2668 With two args, list the keys in the given namespace.
2707 With two args, list the keys in the given namespace.
2669
2708
2670 With five args, set a key to new if it currently is set to old.
2709 With five args, set a key to new if it currently is set to old.
2671 Reports success or failure.
2710 Reports success or failure.
2672 '''
2711 '''
2673
2712
2674 target = hg.peer(ui, {}, repopath)
2713 target = hg.peer(ui, {}, repopath)
2675 if keyinfo:
2714 if keyinfo:
2676 key, old, new = keyinfo
2715 key, old, new = keyinfo
2677 r = target.pushkey(namespace, key, old, new)
2716 r = target.pushkey(namespace, key, old, new)
2678 ui.status(str(r) + '\n')
2717 ui.status(str(r) + '\n')
2679 return not r
2718 return not r
2680 else:
2719 else:
2681 for k, v in sorted(target.listkeys(namespace).iteritems()):
2720 for k, v in sorted(target.listkeys(namespace).iteritems()):
2682 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2721 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2683 v.encode('string-escape')))
2722 v.encode('string-escape')))
2684
2723
2685 @command('debugpvec', [], _('A B'))
2724 @command('debugpvec', [], _('A B'))
2686 def debugpvec(ui, repo, a, b=None):
2725 def debugpvec(ui, repo, a, b=None):
2687 ca = scmutil.revsingle(repo, a)
2726 ca = scmutil.revsingle(repo, a)
2688 cb = scmutil.revsingle(repo, b)
2727 cb = scmutil.revsingle(repo, b)
2689 pa = pvec.ctxpvec(ca)
2728 pa = pvec.ctxpvec(ca)
2690 pb = pvec.ctxpvec(cb)
2729 pb = pvec.ctxpvec(cb)
2691 if pa == pb:
2730 if pa == pb:
2692 rel = "="
2731 rel = "="
2693 elif pa > pb:
2732 elif pa > pb:
2694 rel = ">"
2733 rel = ">"
2695 elif pa < pb:
2734 elif pa < pb:
2696 rel = "<"
2735 rel = "<"
2697 elif pa | pb:
2736 elif pa | pb:
2698 rel = "|"
2737 rel = "|"
2699 ui.write(_("a: %s\n") % pa)
2738 ui.write(_("a: %s\n") % pa)
2700 ui.write(_("b: %s\n") % pb)
2739 ui.write(_("b: %s\n") % pb)
2701 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2740 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2702 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2741 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2703 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2742 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2704 pa.distance(pb), rel))
2743 pa.distance(pb), rel))
2705
2744
2706 @command('debugrebuilddirstate|debugrebuildstate',
2745 @command('debugrebuilddirstate|debugrebuildstate',
2707 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2746 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2708 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2747 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2709 'the working copy parent')),
2748 'the working copy parent')),
2710 ],
2749 ],
2711 _('[-r REV]'))
2750 _('[-r REV]'))
2712 def debugrebuilddirstate(ui, repo, rev, **opts):
2751 def debugrebuilddirstate(ui, repo, rev, **opts):
2713 """rebuild the dirstate as it would look like for the given revision
2752 """rebuild the dirstate as it would look like for the given revision
2714
2753
2715 If no revision is specified the first current parent will be used.
2754 If no revision is specified the first current parent will be used.
2716
2755
2717 The dirstate will be set to the files of the given revision.
2756 The dirstate will be set to the files of the given revision.
2718 The actual working directory content or existing dirstate
2757 The actual working directory content or existing dirstate
2719 information such as adds or removes is not considered.
2758 information such as adds or removes is not considered.
2720
2759
2721 ``minimal`` will only rebuild the dirstate status for files that claim to be
2760 ``minimal`` will only rebuild the dirstate status for files that claim to be
2722 tracked but are not in the parent manifest, or that exist in the parent
2761 tracked but are not in the parent manifest, or that exist in the parent
2723 manifest but are not in the dirstate. It will not change adds, removes, or
2762 manifest but are not in the dirstate. It will not change adds, removes, or
2724 modified files that are in the working copy parent.
2763 modified files that are in the working copy parent.
2725
2764
2726 One use of this command is to make the next :hg:`status` invocation
2765 One use of this command is to make the next :hg:`status` invocation
2727 check the actual file content.
2766 check the actual file content.
2728 """
2767 """
2729 ctx = scmutil.revsingle(repo, rev)
2768 ctx = scmutil.revsingle(repo, rev)
2730 wlock = repo.wlock()
2769 wlock = repo.wlock()
2731 try:
2770 try:
2732 dirstate = repo.dirstate
2771 dirstate = repo.dirstate
2733
2772
2734 # See command doc for what minimal does.
2773 # See command doc for what minimal does.
2735 if opts.get('minimal'):
2774 if opts.get('minimal'):
2736 dirstatefiles = set(dirstate)
2775 dirstatefiles = set(dirstate)
2737 ctxfiles = set(ctx.manifest().keys())
2776 ctxfiles = set(ctx.manifest().keys())
2738 for file in (dirstatefiles | ctxfiles):
2777 for file in (dirstatefiles | ctxfiles):
2739 indirstate = file in dirstatefiles
2778 indirstate = file in dirstatefiles
2740 inctx = file in ctxfiles
2779 inctx = file in ctxfiles
2741
2780
2742 if indirstate and not inctx and dirstate[file] != 'a':
2781 if indirstate and not inctx and dirstate[file] != 'a':
2743 dirstate.drop(file)
2782 dirstate.drop(file)
2744 elif inctx and not indirstate:
2783 elif inctx and not indirstate:
2745 dirstate.normallookup(file)
2784 dirstate.normallookup(file)
2746 else:
2785 else:
2747 dirstate.rebuild(ctx.node(), ctx.manifest())
2786 dirstate.rebuild(ctx.node(), ctx.manifest())
2748 finally:
2787 finally:
2749 wlock.release()
2788 wlock.release()
2750
2789
2751 @command('debugrebuildfncache', [], '')
2790 @command('debugrebuildfncache', [], '')
2752 def debugrebuildfncache(ui, repo):
2791 def debugrebuildfncache(ui, repo):
2753 """rebuild the fncache file"""
2792 """rebuild the fncache file"""
2754 repair.rebuildfncache(ui, repo)
2793 repair.rebuildfncache(ui, repo)
2755
2794
2756 @command('debugrename',
2795 @command('debugrename',
2757 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2796 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2758 _('[-r REV] FILE'))
2797 _('[-r REV] FILE'))
2759 def debugrename(ui, repo, file1, *pats, **opts):
2798 def debugrename(ui, repo, file1, *pats, **opts):
2760 """dump rename information"""
2799 """dump rename information"""
2761
2800
2762 ctx = scmutil.revsingle(repo, opts.get('rev'))
2801 ctx = scmutil.revsingle(repo, opts.get('rev'))
2763 m = scmutil.match(ctx, (file1,) + pats, opts)
2802 m = scmutil.match(ctx, (file1,) + pats, opts)
2764 for abs in ctx.walk(m):
2803 for abs in ctx.walk(m):
2765 fctx = ctx[abs]
2804 fctx = ctx[abs]
2766 o = fctx.filelog().renamed(fctx.filenode())
2805 o = fctx.filelog().renamed(fctx.filenode())
2767 rel = m.rel(abs)
2806 rel = m.rel(abs)
2768 if o:
2807 if o:
2769 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2808 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2770 else:
2809 else:
2771 ui.write(_("%s not renamed\n") % rel)
2810 ui.write(_("%s not renamed\n") % rel)
2772
2811
2773 @command('debugrevlog',
2812 @command('debugrevlog',
2774 [('c', 'changelog', False, _('open changelog')),
2813 [('c', 'changelog', False, _('open changelog')),
2775 ('m', 'manifest', False, _('open manifest')),
2814 ('m', 'manifest', False, _('open manifest')),
2776 ('', 'dir', False, _('open directory manifest')),
2815 ('', 'dir', False, _('open directory manifest')),
2777 ('d', 'dump', False, _('dump index data'))],
2816 ('d', 'dump', False, _('dump index data'))],
2778 _('-c|-m|FILE'),
2817 _('-c|-m|FILE'),
2779 optionalrepo=True)
2818 optionalrepo=True)
2780 def debugrevlog(ui, repo, file_=None, **opts):
2819 def debugrevlog(ui, repo, file_=None, **opts):
2781 """show data and statistics about a revlog"""
2820 """show data and statistics about a revlog"""
2782 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2821 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2783
2822
2784 if opts.get("dump"):
2823 if opts.get("dump"):
2785 numrevs = len(r)
2824 numrevs = len(r)
2786 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2825 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2787 " rawsize totalsize compression heads chainlen\n")
2826 " rawsize totalsize compression heads chainlen\n")
2788 ts = 0
2827 ts = 0
2789 heads = set()
2828 heads = set()
2790
2829
2791 for rev in xrange(numrevs):
2830 for rev in xrange(numrevs):
2792 dbase = r.deltaparent(rev)
2831 dbase = r.deltaparent(rev)
2793 if dbase == -1:
2832 if dbase == -1:
2794 dbase = rev
2833 dbase = rev
2795 cbase = r.chainbase(rev)
2834 cbase = r.chainbase(rev)
2796 clen = r.chainlen(rev)
2835 clen = r.chainlen(rev)
2797 p1, p2 = r.parentrevs(rev)
2836 p1, p2 = r.parentrevs(rev)
2798 rs = r.rawsize(rev)
2837 rs = r.rawsize(rev)
2799 ts = ts + rs
2838 ts = ts + rs
2800 heads -= set(r.parentrevs(rev))
2839 heads -= set(r.parentrevs(rev))
2801 heads.add(rev)
2840 heads.add(rev)
2802 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2841 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2803 "%11d %5d %8d\n" %
2842 "%11d %5d %8d\n" %
2804 (rev, p1, p2, r.start(rev), r.end(rev),
2843 (rev, p1, p2, r.start(rev), r.end(rev),
2805 r.start(dbase), r.start(cbase),
2844 r.start(dbase), r.start(cbase),
2806 r.start(p1), r.start(p2),
2845 r.start(p1), r.start(p2),
2807 rs, ts, ts / r.end(rev), len(heads), clen))
2846 rs, ts, ts / r.end(rev), len(heads), clen))
2808 return 0
2847 return 0
2809
2848
2810 v = r.version
2849 v = r.version
2811 format = v & 0xFFFF
2850 format = v & 0xFFFF
2812 flags = []
2851 flags = []
2813 gdelta = False
2852 gdelta = False
2814 if v & revlog.REVLOGNGINLINEDATA:
2853 if v & revlog.REVLOGNGINLINEDATA:
2815 flags.append('inline')
2854 flags.append('inline')
2816 if v & revlog.REVLOGGENERALDELTA:
2855 if v & revlog.REVLOGGENERALDELTA:
2817 gdelta = True
2856 gdelta = True
2818 flags.append('generaldelta')
2857 flags.append('generaldelta')
2819 if not flags:
2858 if not flags:
2820 flags = ['(none)']
2859 flags = ['(none)']
2821
2860
2822 nummerges = 0
2861 nummerges = 0
2823 numfull = 0
2862 numfull = 0
2824 numprev = 0
2863 numprev = 0
2825 nump1 = 0
2864 nump1 = 0
2826 nump2 = 0
2865 nump2 = 0
2827 numother = 0
2866 numother = 0
2828 nump1prev = 0
2867 nump1prev = 0
2829 nump2prev = 0
2868 nump2prev = 0
2830 chainlengths = []
2869 chainlengths = []
2831
2870
2832 datasize = [None, 0, 0L]
2871 datasize = [None, 0, 0L]
2833 fullsize = [None, 0, 0L]
2872 fullsize = [None, 0, 0L]
2834 deltasize = [None, 0, 0L]
2873 deltasize = [None, 0, 0L]
2835
2874
2836 def addsize(size, l):
2875 def addsize(size, l):
2837 if l[0] is None or size < l[0]:
2876 if l[0] is None or size < l[0]:
2838 l[0] = size
2877 l[0] = size
2839 if size > l[1]:
2878 if size > l[1]:
2840 l[1] = size
2879 l[1] = size
2841 l[2] += size
2880 l[2] += size
2842
2881
2843 numrevs = len(r)
2882 numrevs = len(r)
2844 for rev in xrange(numrevs):
2883 for rev in xrange(numrevs):
2845 p1, p2 = r.parentrevs(rev)
2884 p1, p2 = r.parentrevs(rev)
2846 delta = r.deltaparent(rev)
2885 delta = r.deltaparent(rev)
2847 if format > 0:
2886 if format > 0:
2848 addsize(r.rawsize(rev), datasize)
2887 addsize(r.rawsize(rev), datasize)
2849 if p2 != nullrev:
2888 if p2 != nullrev:
2850 nummerges += 1
2889 nummerges += 1
2851 size = r.length(rev)
2890 size = r.length(rev)
2852 if delta == nullrev:
2891 if delta == nullrev:
2853 chainlengths.append(0)
2892 chainlengths.append(0)
2854 numfull += 1
2893 numfull += 1
2855 addsize(size, fullsize)
2894 addsize(size, fullsize)
2856 else:
2895 else:
2857 chainlengths.append(chainlengths[delta] + 1)
2896 chainlengths.append(chainlengths[delta] + 1)
2858 addsize(size, deltasize)
2897 addsize(size, deltasize)
2859 if delta == rev - 1:
2898 if delta == rev - 1:
2860 numprev += 1
2899 numprev += 1
2861 if delta == p1:
2900 if delta == p1:
2862 nump1prev += 1
2901 nump1prev += 1
2863 elif delta == p2:
2902 elif delta == p2:
2864 nump2prev += 1
2903 nump2prev += 1
2865 elif delta == p1:
2904 elif delta == p1:
2866 nump1 += 1
2905 nump1 += 1
2867 elif delta == p2:
2906 elif delta == p2:
2868 nump2 += 1
2907 nump2 += 1
2869 elif delta != nullrev:
2908 elif delta != nullrev:
2870 numother += 1
2909 numother += 1
2871
2910
2872 # Adjust size min value for empty cases
2911 # Adjust size min value for empty cases
2873 for size in (datasize, fullsize, deltasize):
2912 for size in (datasize, fullsize, deltasize):
2874 if size[0] is None:
2913 if size[0] is None:
2875 size[0] = 0
2914 size[0] = 0
2876
2915
2877 numdeltas = numrevs - numfull
2916 numdeltas = numrevs - numfull
2878 numoprev = numprev - nump1prev - nump2prev
2917 numoprev = numprev - nump1prev - nump2prev
2879 totalrawsize = datasize[2]
2918 totalrawsize = datasize[2]
2880 datasize[2] /= numrevs
2919 datasize[2] /= numrevs
2881 fulltotal = fullsize[2]
2920 fulltotal = fullsize[2]
2882 fullsize[2] /= numfull
2921 fullsize[2] /= numfull
2883 deltatotal = deltasize[2]
2922 deltatotal = deltasize[2]
2884 if numrevs - numfull > 0:
2923 if numrevs - numfull > 0:
2885 deltasize[2] /= numrevs - numfull
2924 deltasize[2] /= numrevs - numfull
2886 totalsize = fulltotal + deltatotal
2925 totalsize = fulltotal + deltatotal
2887 avgchainlen = sum(chainlengths) / numrevs
2926 avgchainlen = sum(chainlengths) / numrevs
2888 maxchainlen = max(chainlengths)
2927 maxchainlen = max(chainlengths)
2889 compratio = totalrawsize / totalsize
2928 compratio = totalrawsize / totalsize
2890
2929
2891 basedfmtstr = '%%%dd\n'
2930 basedfmtstr = '%%%dd\n'
2892 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2931 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2893
2932
2894 def dfmtstr(max):
2933 def dfmtstr(max):
2895 return basedfmtstr % len(str(max))
2934 return basedfmtstr % len(str(max))
2896 def pcfmtstr(max, padding=0):
2935 def pcfmtstr(max, padding=0):
2897 return basepcfmtstr % (len(str(max)), ' ' * padding)
2936 return basepcfmtstr % (len(str(max)), ' ' * padding)
2898
2937
2899 def pcfmt(value, total):
2938 def pcfmt(value, total):
2900 return (value, 100 * float(value) / total)
2939 return (value, 100 * float(value) / total)
2901
2940
2902 ui.write(('format : %d\n') % format)
2941 ui.write(('format : %d\n') % format)
2903 ui.write(('flags : %s\n') % ', '.join(flags))
2942 ui.write(('flags : %s\n') % ', '.join(flags))
2904
2943
2905 ui.write('\n')
2944 ui.write('\n')
2906 fmt = pcfmtstr(totalsize)
2945 fmt = pcfmtstr(totalsize)
2907 fmt2 = dfmtstr(totalsize)
2946 fmt2 = dfmtstr(totalsize)
2908 ui.write(('revisions : ') + fmt2 % numrevs)
2947 ui.write(('revisions : ') + fmt2 % numrevs)
2909 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2948 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2910 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2949 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2911 ui.write(('revisions : ') + fmt2 % numrevs)
2950 ui.write(('revisions : ') + fmt2 % numrevs)
2912 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2951 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2913 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2952 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2914 ui.write(('revision size : ') + fmt2 % totalsize)
2953 ui.write(('revision size : ') + fmt2 % totalsize)
2915 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2954 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2916 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2955 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2917
2956
2918 ui.write('\n')
2957 ui.write('\n')
2919 fmt = dfmtstr(max(avgchainlen, compratio))
2958 fmt = dfmtstr(max(avgchainlen, compratio))
2920 ui.write(('avg chain length : ') + fmt % avgchainlen)
2959 ui.write(('avg chain length : ') + fmt % avgchainlen)
2921 ui.write(('max chain length : ') + fmt % maxchainlen)
2960 ui.write(('max chain length : ') + fmt % maxchainlen)
2922 ui.write(('compression ratio : ') + fmt % compratio)
2961 ui.write(('compression ratio : ') + fmt % compratio)
2923
2962
2924 if format > 0:
2963 if format > 0:
2925 ui.write('\n')
2964 ui.write('\n')
2926 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2965 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2927 % tuple(datasize))
2966 % tuple(datasize))
2928 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2967 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2929 % tuple(fullsize))
2968 % tuple(fullsize))
2930 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2969 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2931 % tuple(deltasize))
2970 % tuple(deltasize))
2932
2971
2933 if numdeltas > 0:
2972 if numdeltas > 0:
2934 ui.write('\n')
2973 ui.write('\n')
2935 fmt = pcfmtstr(numdeltas)
2974 fmt = pcfmtstr(numdeltas)
2936 fmt2 = pcfmtstr(numdeltas, 4)
2975 fmt2 = pcfmtstr(numdeltas, 4)
2937 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2976 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2938 if numprev > 0:
2977 if numprev > 0:
2939 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2978 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2940 numprev))
2979 numprev))
2941 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2980 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2942 numprev))
2981 numprev))
2943 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2982 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2944 numprev))
2983 numprev))
2945 if gdelta:
2984 if gdelta:
2946 ui.write(('deltas against p1 : ')
2985 ui.write(('deltas against p1 : ')
2947 + fmt % pcfmt(nump1, numdeltas))
2986 + fmt % pcfmt(nump1, numdeltas))
2948 ui.write(('deltas against p2 : ')
2987 ui.write(('deltas against p2 : ')
2949 + fmt % pcfmt(nump2, numdeltas))
2988 + fmt % pcfmt(nump2, numdeltas))
2950 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2989 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2951 numdeltas))
2990 numdeltas))
2952
2991
2953 @command('debugrevspec',
2992 @command('debugrevspec',
2954 [('', 'optimize', None, _('print parsed tree after optimizing'))],
2993 [('', 'optimize', None, _('print parsed tree after optimizing'))],
2955 ('REVSPEC'))
2994 ('REVSPEC'))
2956 def debugrevspec(ui, repo, expr, **opts):
2995 def debugrevspec(ui, repo, expr, **opts):
2957 """parse and apply a revision specification
2996 """parse and apply a revision specification
2958
2997
2959 Use --verbose to print the parsed tree before and after aliases
2998 Use --verbose to print the parsed tree before and after aliases
2960 expansion.
2999 expansion.
2961 """
3000 """
2962 if ui.verbose:
3001 if ui.verbose:
2963 tree = revset.parse(expr, lookup=repo.__contains__)
3002 tree = revset.parse(expr, lookup=repo.__contains__)
2964 ui.note(revset.prettyformat(tree), "\n")
3003 ui.note(revset.prettyformat(tree), "\n")
2965 newtree = revset.findaliases(ui, tree)
3004 newtree = revset.findaliases(ui, tree)
2966 if newtree != tree:
3005 if newtree != tree:
2967 ui.note(revset.prettyformat(newtree), "\n")
3006 ui.note(revset.prettyformat(newtree), "\n")
2968 tree = newtree
3007 tree = newtree
2969 newtree = revset.foldconcat(tree)
3008 newtree = revset.foldconcat(tree)
2970 if newtree != tree:
3009 if newtree != tree:
2971 ui.note(revset.prettyformat(newtree), "\n")
3010 ui.note(revset.prettyformat(newtree), "\n")
2972 if opts["optimize"]:
3011 if opts["optimize"]:
2973 weight, optimizedtree = revset.optimize(newtree, True)
3012 weight, optimizedtree = revset.optimize(newtree, True)
2974 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3013 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
2975 func = revset.match(ui, expr, repo)
3014 func = revset.match(ui, expr, repo)
2976 revs = func(repo)
3015 revs = func(repo)
2977 if ui.verbose:
3016 if ui.verbose:
2978 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3017 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
2979 for c in revs:
3018 for c in revs:
2980 ui.write("%s\n" % c)
3019 ui.write("%s\n" % c)
2981
3020
2982 @command('debugsetparents', [], _('REV1 [REV2]'))
3021 @command('debugsetparents', [], _('REV1 [REV2]'))
2983 def debugsetparents(ui, repo, rev1, rev2=None):
3022 def debugsetparents(ui, repo, rev1, rev2=None):
2984 """manually set the parents of the current working directory
3023 """manually set the parents of the current working directory
2985
3024
2986 This is useful for writing repository conversion tools, but should
3025 This is useful for writing repository conversion tools, but should
2987 be used with care. For example, neither the working directory nor the
3026 be used with care. For example, neither the working directory nor the
2988 dirstate is updated, so file status may be incorrect after running this
3027 dirstate is updated, so file status may be incorrect after running this
2989 command.
3028 command.
2990
3029
2991 Returns 0 on success.
3030 Returns 0 on success.
2992 """
3031 """
2993
3032
2994 r1 = scmutil.revsingle(repo, rev1).node()
3033 r1 = scmutil.revsingle(repo, rev1).node()
2995 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3034 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2996
3035
2997 wlock = repo.wlock()
3036 wlock = repo.wlock()
2998 try:
3037 try:
2999 repo.dirstate.beginparentchange()
3038 repo.dirstate.beginparentchange()
3000 repo.setparents(r1, r2)
3039 repo.setparents(r1, r2)
3001 repo.dirstate.endparentchange()
3040 repo.dirstate.endparentchange()
3002 finally:
3041 finally:
3003 wlock.release()
3042 wlock.release()
3004
3043
3005 @command('debugdirstate|debugstate',
3044 @command('debugdirstate|debugstate',
3006 [('', 'nodates', None, _('do not display the saved mtime')),
3045 [('', 'nodates', None, _('do not display the saved mtime')),
3007 ('', 'datesort', None, _('sort by saved mtime'))],
3046 ('', 'datesort', None, _('sort by saved mtime'))],
3008 _('[OPTION]...'))
3047 _('[OPTION]...'))
3009 def debugstate(ui, repo, nodates=None, datesort=None):
3048 def debugstate(ui, repo, nodates=None, datesort=None):
3010 """show the contents of the current dirstate"""
3049 """show the contents of the current dirstate"""
3011 timestr = ""
3050 timestr = ""
3012 if datesort:
3051 if datesort:
3013 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3052 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3014 else:
3053 else:
3015 keyfunc = None # sort by filename
3054 keyfunc = None # sort by filename
3016 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3055 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3017 if ent[3] == -1:
3056 if ent[3] == -1:
3018 timestr = 'unset '
3057 timestr = 'unset '
3019 elif nodates:
3058 elif nodates:
3020 timestr = 'set '
3059 timestr = 'set '
3021 else:
3060 else:
3022 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3061 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3023 time.localtime(ent[3]))
3062 time.localtime(ent[3]))
3024 if ent[1] & 0o20000:
3063 if ent[1] & 0o20000:
3025 mode = 'lnk'
3064 mode = 'lnk'
3026 else:
3065 else:
3027 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3066 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3028 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3067 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3029 for f in repo.dirstate.copies():
3068 for f in repo.dirstate.copies():
3030 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3069 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3031
3070
3032 @command('debugsub',
3071 @command('debugsub',
3033 [('r', 'rev', '',
3072 [('r', 'rev', '',
3034 _('revision to check'), _('REV'))],
3073 _('revision to check'), _('REV'))],
3035 _('[-r REV] [REV]'))
3074 _('[-r REV] [REV]'))
3036 def debugsub(ui, repo, rev=None):
3075 def debugsub(ui, repo, rev=None):
3037 ctx = scmutil.revsingle(repo, rev, None)
3076 ctx = scmutil.revsingle(repo, rev, None)
3038 for k, v in sorted(ctx.substate.items()):
3077 for k, v in sorted(ctx.substate.items()):
3039 ui.write(('path %s\n') % k)
3078 ui.write(('path %s\n') % k)
3040 ui.write((' source %s\n') % v[0])
3079 ui.write((' source %s\n') % v[0])
3041 ui.write((' revision %s\n') % v[1])
3080 ui.write((' revision %s\n') % v[1])
3042
3081
3043 @command('debugsuccessorssets',
3082 @command('debugsuccessorssets',
3044 [],
3083 [],
3045 _('[REV]'))
3084 _('[REV]'))
3046 def debugsuccessorssets(ui, repo, *revs):
3085 def debugsuccessorssets(ui, repo, *revs):
3047 """show set of successors for revision
3086 """show set of successors for revision
3048
3087
3049 A successors set of changeset A is a consistent group of revisions that
3088 A successors set of changeset A is a consistent group of revisions that
3050 succeed A. It contains non-obsolete changesets only.
3089 succeed A. It contains non-obsolete changesets only.
3051
3090
3052 In most cases a changeset A has a single successors set containing a single
3091 In most cases a changeset A has a single successors set containing a single
3053 successor (changeset A replaced by A').
3092 successor (changeset A replaced by A').
3054
3093
3055 A changeset that is made obsolete with no successors are called "pruned".
3094 A changeset that is made obsolete with no successors are called "pruned".
3056 Such changesets have no successors sets at all.
3095 Such changesets have no successors sets at all.
3057
3096
3058 A changeset that has been "split" will have a successors set containing
3097 A changeset that has been "split" will have a successors set containing
3059 more than one successor.
3098 more than one successor.
3060
3099
3061 A changeset that has been rewritten in multiple different ways is called
3100 A changeset that has been rewritten in multiple different ways is called
3062 "divergent". Such changesets have multiple successor sets (each of which
3101 "divergent". Such changesets have multiple successor sets (each of which
3063 may also be split, i.e. have multiple successors).
3102 may also be split, i.e. have multiple successors).
3064
3103
3065 Results are displayed as follows::
3104 Results are displayed as follows::
3066
3105
3067 <rev1>
3106 <rev1>
3068 <successors-1A>
3107 <successors-1A>
3069 <rev2>
3108 <rev2>
3070 <successors-2A>
3109 <successors-2A>
3071 <successors-2B1> <successors-2B2> <successors-2B3>
3110 <successors-2B1> <successors-2B2> <successors-2B3>
3072
3111
3073 Here rev2 has two possible (i.e. divergent) successors sets. The first
3112 Here rev2 has two possible (i.e. divergent) successors sets. The first
3074 holds one element, whereas the second holds three (i.e. the changeset has
3113 holds one element, whereas the second holds three (i.e. the changeset has
3075 been split).
3114 been split).
3076 """
3115 """
3077 # passed to successorssets caching computation from one call to another
3116 # passed to successorssets caching computation from one call to another
3078 cache = {}
3117 cache = {}
3079 ctx2str = str
3118 ctx2str = str
3080 node2str = short
3119 node2str = short
3081 if ui.debug():
3120 if ui.debug():
3082 def ctx2str(ctx):
3121 def ctx2str(ctx):
3083 return ctx.hex()
3122 return ctx.hex()
3084 node2str = hex
3123 node2str = hex
3085 for rev in scmutil.revrange(repo, revs):
3124 for rev in scmutil.revrange(repo, revs):
3086 ctx = repo[rev]
3125 ctx = repo[rev]
3087 ui.write('%s\n'% ctx2str(ctx))
3126 ui.write('%s\n'% ctx2str(ctx))
3088 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3127 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3089 if succsset:
3128 if succsset:
3090 ui.write(' ')
3129 ui.write(' ')
3091 ui.write(node2str(succsset[0]))
3130 ui.write(node2str(succsset[0]))
3092 for node in succsset[1:]:
3131 for node in succsset[1:]:
3093 ui.write(' ')
3132 ui.write(' ')
3094 ui.write(node2str(node))
3133 ui.write(node2str(node))
3095 ui.write('\n')
3134 ui.write('\n')
3096
3135
3097 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3136 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3098 def debugwalk(ui, repo, *pats, **opts):
3137 def debugwalk(ui, repo, *pats, **opts):
3099 """show how files match on given patterns"""
3138 """show how files match on given patterns"""
3100 m = scmutil.match(repo[None], pats, opts)
3139 m = scmutil.match(repo[None], pats, opts)
3101 items = list(repo.walk(m))
3140 items = list(repo.walk(m))
3102 if not items:
3141 if not items:
3103 return
3142 return
3104 f = lambda fn: fn
3143 f = lambda fn: fn
3105 if ui.configbool('ui', 'slash') and os.sep != '/':
3144 if ui.configbool('ui', 'slash') and os.sep != '/':
3106 f = lambda fn: util.normpath(fn)
3145 f = lambda fn: util.normpath(fn)
3107 fmt = 'f %%-%ds %%-%ds %%s' % (
3146 fmt = 'f %%-%ds %%-%ds %%s' % (
3108 max([len(abs) for abs in items]),
3147 max([len(abs) for abs in items]),
3109 max([len(m.rel(abs)) for abs in items]))
3148 max([len(m.rel(abs)) for abs in items]))
3110 for abs in items:
3149 for abs in items:
3111 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3150 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3112 ui.write("%s\n" % line.rstrip())
3151 ui.write("%s\n" % line.rstrip())
3113
3152
3114 @command('debugwireargs',
3153 @command('debugwireargs',
3115 [('', 'three', '', 'three'),
3154 [('', 'three', '', 'three'),
3116 ('', 'four', '', 'four'),
3155 ('', 'four', '', 'four'),
3117 ('', 'five', '', 'five'),
3156 ('', 'five', '', 'five'),
3118 ] + remoteopts,
3157 ] + remoteopts,
3119 _('REPO [OPTIONS]... [ONE [TWO]]'),
3158 _('REPO [OPTIONS]... [ONE [TWO]]'),
3120 norepo=True)
3159 norepo=True)
3121 def debugwireargs(ui, repopath, *vals, **opts):
3160 def debugwireargs(ui, repopath, *vals, **opts):
3122 repo = hg.peer(ui, opts, repopath)
3161 repo = hg.peer(ui, opts, repopath)
3123 for opt in remoteopts:
3162 for opt in remoteopts:
3124 del opts[opt[1]]
3163 del opts[opt[1]]
3125 args = {}
3164 args = {}
3126 for k, v in opts.iteritems():
3165 for k, v in opts.iteritems():
3127 if v:
3166 if v:
3128 args[k] = v
3167 args[k] = v
3129 # run twice to check that we don't mess up the stream for the next command
3168 # run twice to check that we don't mess up the stream for the next command
3130 res1 = repo.debugwireargs(*vals, **args)
3169 res1 = repo.debugwireargs(*vals, **args)
3131 res2 = repo.debugwireargs(*vals, **args)
3170 res2 = repo.debugwireargs(*vals, **args)
3132 ui.write("%s\n" % res1)
3171 ui.write("%s\n" % res1)
3133 if res1 != res2:
3172 if res1 != res2:
3134 ui.warn("%s\n" % res2)
3173 ui.warn("%s\n" % res2)
3135
3174
3136 @command('^diff',
3175 @command('^diff',
3137 [('r', 'rev', [], _('revision'), _('REV')),
3176 [('r', 'rev', [], _('revision'), _('REV')),
3138 ('c', 'change', '', _('change made by revision'), _('REV'))
3177 ('c', 'change', '', _('change made by revision'), _('REV'))
3139 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3178 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3140 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3179 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3141 inferrepo=True)
3180 inferrepo=True)
3142 def diff(ui, repo, *pats, **opts):
3181 def diff(ui, repo, *pats, **opts):
3143 """diff repository (or selected files)
3182 """diff repository (or selected files)
3144
3183
3145 Show differences between revisions for the specified files.
3184 Show differences between revisions for the specified files.
3146
3185
3147 Differences between files are shown using the unified diff format.
3186 Differences between files are shown using the unified diff format.
3148
3187
3149 .. note::
3188 .. note::
3150
3189
3151 diff may generate unexpected results for merges, as it will
3190 diff may generate unexpected results for merges, as it will
3152 default to comparing against the working directory's first
3191 default to comparing against the working directory's first
3153 parent changeset if no revisions are specified.
3192 parent changeset if no revisions are specified.
3154
3193
3155 When two revision arguments are given, then changes are shown
3194 When two revision arguments are given, then changes are shown
3156 between those revisions. If only one revision is specified then
3195 between those revisions. If only one revision is specified then
3157 that revision is compared to the working directory, and, when no
3196 that revision is compared to the working directory, and, when no
3158 revisions are specified, the working directory files are compared
3197 revisions are specified, the working directory files are compared
3159 to its parent.
3198 to its parent.
3160
3199
3161 Alternatively you can specify -c/--change with a revision to see
3200 Alternatively you can specify -c/--change with a revision to see
3162 the changes in that changeset relative to its first parent.
3201 the changes in that changeset relative to its first parent.
3163
3202
3164 Without the -a/--text option, diff will avoid generating diffs of
3203 Without the -a/--text option, diff will avoid generating diffs of
3165 files it detects as binary. With -a, diff will generate a diff
3204 files it detects as binary. With -a, diff will generate a diff
3166 anyway, probably with undesirable results.
3205 anyway, probably with undesirable results.
3167
3206
3168 Use the -g/--git option to generate diffs in the git extended diff
3207 Use the -g/--git option to generate diffs in the git extended diff
3169 format. For more information, read :hg:`help diffs`.
3208 format. For more information, read :hg:`help diffs`.
3170
3209
3171 .. container:: verbose
3210 .. container:: verbose
3172
3211
3173 Examples:
3212 Examples:
3174
3213
3175 - compare a file in the current working directory to its parent::
3214 - compare a file in the current working directory to its parent::
3176
3215
3177 hg diff foo.c
3216 hg diff foo.c
3178
3217
3179 - compare two historical versions of a directory, with rename info::
3218 - compare two historical versions of a directory, with rename info::
3180
3219
3181 hg diff --git -r 1.0:1.2 lib/
3220 hg diff --git -r 1.0:1.2 lib/
3182
3221
3183 - get change stats relative to the last change on some date::
3222 - get change stats relative to the last change on some date::
3184
3223
3185 hg diff --stat -r "date('may 2')"
3224 hg diff --stat -r "date('may 2')"
3186
3225
3187 - diff all newly-added files that contain a keyword::
3226 - diff all newly-added files that contain a keyword::
3188
3227
3189 hg diff "set:added() and grep(GNU)"
3228 hg diff "set:added() and grep(GNU)"
3190
3229
3191 - compare a revision and its parents::
3230 - compare a revision and its parents::
3192
3231
3193 hg diff -c 9353 # compare against first parent
3232 hg diff -c 9353 # compare against first parent
3194 hg diff -r 9353^:9353 # same using revset syntax
3233 hg diff -r 9353^:9353 # same using revset syntax
3195 hg diff -r 9353^2:9353 # compare against the second parent
3234 hg diff -r 9353^2:9353 # compare against the second parent
3196
3235
3197 Returns 0 on success.
3236 Returns 0 on success.
3198 """
3237 """
3199
3238
3200 revs = opts.get('rev')
3239 revs = opts.get('rev')
3201 change = opts.get('change')
3240 change = opts.get('change')
3202 stat = opts.get('stat')
3241 stat = opts.get('stat')
3203 reverse = opts.get('reverse')
3242 reverse = opts.get('reverse')
3204
3243
3205 if revs and change:
3244 if revs and change:
3206 msg = _('cannot specify --rev and --change at the same time')
3245 msg = _('cannot specify --rev and --change at the same time')
3207 raise util.Abort(msg)
3246 raise util.Abort(msg)
3208 elif change:
3247 elif change:
3209 node2 = scmutil.revsingle(repo, change, None).node()
3248 node2 = scmutil.revsingle(repo, change, None).node()
3210 node1 = repo[node2].p1().node()
3249 node1 = repo[node2].p1().node()
3211 else:
3250 else:
3212 node1, node2 = scmutil.revpair(repo, revs)
3251 node1, node2 = scmutil.revpair(repo, revs)
3213
3252
3214 if reverse:
3253 if reverse:
3215 node1, node2 = node2, node1
3254 node1, node2 = node2, node1
3216
3255
3217 diffopts = patch.diffallopts(ui, opts)
3256 diffopts = patch.diffallopts(ui, opts)
3218 m = scmutil.match(repo[node2], pats, opts)
3257 m = scmutil.match(repo[node2], pats, opts)
3219 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3258 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3220 listsubrepos=opts.get('subrepos'),
3259 listsubrepos=opts.get('subrepos'),
3221 root=opts.get('root'))
3260 root=opts.get('root'))
3222
3261
3223 @command('^export',
3262 @command('^export',
3224 [('o', 'output', '',
3263 [('o', 'output', '',
3225 _('print output to file with formatted name'), _('FORMAT')),
3264 _('print output to file with formatted name'), _('FORMAT')),
3226 ('', 'switch-parent', None, _('diff against the second parent')),
3265 ('', 'switch-parent', None, _('diff against the second parent')),
3227 ('r', 'rev', [], _('revisions to export'), _('REV')),
3266 ('r', 'rev', [], _('revisions to export'), _('REV')),
3228 ] + diffopts,
3267 ] + diffopts,
3229 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3268 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3230 def export(ui, repo, *changesets, **opts):
3269 def export(ui, repo, *changesets, **opts):
3231 """dump the header and diffs for one or more changesets
3270 """dump the header and diffs for one or more changesets
3232
3271
3233 Print the changeset header and diffs for one or more revisions.
3272 Print the changeset header and diffs for one or more revisions.
3234 If no revision is given, the parent of the working directory is used.
3273 If no revision is given, the parent of the working directory is used.
3235
3274
3236 The information shown in the changeset header is: author, date,
3275 The information shown in the changeset header is: author, date,
3237 branch name (if non-default), changeset hash, parent(s) and commit
3276 branch name (if non-default), changeset hash, parent(s) and commit
3238 comment.
3277 comment.
3239
3278
3240 .. note::
3279 .. note::
3241
3280
3242 export may generate unexpected diff output for merge
3281 export may generate unexpected diff output for merge
3243 changesets, as it will compare the merge changeset against its
3282 changesets, as it will compare the merge changeset against its
3244 first parent only.
3283 first parent only.
3245
3284
3246 Output may be to a file, in which case the name of the file is
3285 Output may be to a file, in which case the name of the file is
3247 given using a format string. The formatting rules are as follows:
3286 given using a format string. The formatting rules are as follows:
3248
3287
3249 :``%%``: literal "%" character
3288 :``%%``: literal "%" character
3250 :``%H``: changeset hash (40 hexadecimal digits)
3289 :``%H``: changeset hash (40 hexadecimal digits)
3251 :``%N``: number of patches being generated
3290 :``%N``: number of patches being generated
3252 :``%R``: changeset revision number
3291 :``%R``: changeset revision number
3253 :``%b``: basename of the exporting repository
3292 :``%b``: basename of the exporting repository
3254 :``%h``: short-form changeset hash (12 hexadecimal digits)
3293 :``%h``: short-form changeset hash (12 hexadecimal digits)
3255 :``%m``: first line of the commit message (only alphanumeric characters)
3294 :``%m``: first line of the commit message (only alphanumeric characters)
3256 :``%n``: zero-padded sequence number, starting at 1
3295 :``%n``: zero-padded sequence number, starting at 1
3257 :``%r``: zero-padded changeset revision number
3296 :``%r``: zero-padded changeset revision number
3258
3297
3259 Without the -a/--text option, export will avoid generating diffs
3298 Without the -a/--text option, export will avoid generating diffs
3260 of files it detects as binary. With -a, export will generate a
3299 of files it detects as binary. With -a, export will generate a
3261 diff anyway, probably with undesirable results.
3300 diff anyway, probably with undesirable results.
3262
3301
3263 Use the -g/--git option to generate diffs in the git extended diff
3302 Use the -g/--git option to generate diffs in the git extended diff
3264 format. See :hg:`help diffs` for more information.
3303 format. See :hg:`help diffs` for more information.
3265
3304
3266 With the --switch-parent option, the diff will be against the
3305 With the --switch-parent option, the diff will be against the
3267 second parent. It can be useful to review a merge.
3306 second parent. It can be useful to review a merge.
3268
3307
3269 .. container:: verbose
3308 .. container:: verbose
3270
3309
3271 Examples:
3310 Examples:
3272
3311
3273 - use export and import to transplant a bugfix to the current
3312 - use export and import to transplant a bugfix to the current
3274 branch::
3313 branch::
3275
3314
3276 hg export -r 9353 | hg import -
3315 hg export -r 9353 | hg import -
3277
3316
3278 - export all the changesets between two revisions to a file with
3317 - export all the changesets between two revisions to a file with
3279 rename information::
3318 rename information::
3280
3319
3281 hg export --git -r 123:150 > changes.txt
3320 hg export --git -r 123:150 > changes.txt
3282
3321
3283 - split outgoing changes into a series of patches with
3322 - split outgoing changes into a series of patches with
3284 descriptive names::
3323 descriptive names::
3285
3324
3286 hg export -r "outgoing()" -o "%n-%m.patch"
3325 hg export -r "outgoing()" -o "%n-%m.patch"
3287
3326
3288 Returns 0 on success.
3327 Returns 0 on success.
3289 """
3328 """
3290 changesets += tuple(opts.get('rev', []))
3329 changesets += tuple(opts.get('rev', []))
3291 if not changesets:
3330 if not changesets:
3292 changesets = ['.']
3331 changesets = ['.']
3293 revs = scmutil.revrange(repo, changesets)
3332 revs = scmutil.revrange(repo, changesets)
3294 if not revs:
3333 if not revs:
3295 raise util.Abort(_("export requires at least one changeset"))
3334 raise util.Abort(_("export requires at least one changeset"))
3296 if len(revs) > 1:
3335 if len(revs) > 1:
3297 ui.note(_('exporting patches:\n'))
3336 ui.note(_('exporting patches:\n'))
3298 else:
3337 else:
3299 ui.note(_('exporting patch:\n'))
3338 ui.note(_('exporting patch:\n'))
3300 cmdutil.export(repo, revs, template=opts.get('output'),
3339 cmdutil.export(repo, revs, template=opts.get('output'),
3301 switch_parent=opts.get('switch_parent'),
3340 switch_parent=opts.get('switch_parent'),
3302 opts=patch.diffallopts(ui, opts))
3341 opts=patch.diffallopts(ui, opts))
3303
3342
3304 @command('files',
3343 @command('files',
3305 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3344 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3306 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3345 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3307 ] + walkopts + formatteropts + subrepoopts,
3346 ] + walkopts + formatteropts + subrepoopts,
3308 _('[OPTION]... [PATTERN]...'))
3347 _('[OPTION]... [PATTERN]...'))
3309 def files(ui, repo, *pats, **opts):
3348 def files(ui, repo, *pats, **opts):
3310 """list tracked files
3349 """list tracked files
3311
3350
3312 Print files under Mercurial control in the working directory or
3351 Print files under Mercurial control in the working directory or
3313 specified revision whose names match the given patterns (excluding
3352 specified revision whose names match the given patterns (excluding
3314 removed files).
3353 removed files).
3315
3354
3316 If no patterns are given to match, this command prints the names
3355 If no patterns are given to match, this command prints the names
3317 of all files under Mercurial control in the working directory.
3356 of all files under Mercurial control in the working directory.
3318
3357
3319 .. container:: verbose
3358 .. container:: verbose
3320
3359
3321 Examples:
3360 Examples:
3322
3361
3323 - list all files under the current directory::
3362 - list all files under the current directory::
3324
3363
3325 hg files .
3364 hg files .
3326
3365
3327 - shows sizes and flags for current revision::
3366 - shows sizes and flags for current revision::
3328
3367
3329 hg files -vr .
3368 hg files -vr .
3330
3369
3331 - list all files named README::
3370 - list all files named README::
3332
3371
3333 hg files -I "**/README"
3372 hg files -I "**/README"
3334
3373
3335 - list all binary files::
3374 - list all binary files::
3336
3375
3337 hg files "set:binary()"
3376 hg files "set:binary()"
3338
3377
3339 - find files containing a regular expression::
3378 - find files containing a regular expression::
3340
3379
3341 hg files "set:grep('bob')"
3380 hg files "set:grep('bob')"
3342
3381
3343 - search tracked file contents with xargs and grep::
3382 - search tracked file contents with xargs and grep::
3344
3383
3345 hg files -0 | xargs -0 grep foo
3384 hg files -0 | xargs -0 grep foo
3346
3385
3347 See :hg:`help patterns` and :hg:`help filesets` for more information
3386 See :hg:`help patterns` and :hg:`help filesets` for more information
3348 on specifying file patterns.
3387 on specifying file patterns.
3349
3388
3350 Returns 0 if a match is found, 1 otherwise.
3389 Returns 0 if a match is found, 1 otherwise.
3351
3390
3352 """
3391 """
3353 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3392 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3354
3393
3355 end = '\n'
3394 end = '\n'
3356 if opts.get('print0'):
3395 if opts.get('print0'):
3357 end = '\0'
3396 end = '\0'
3358 fm = ui.formatter('files', opts)
3397 fm = ui.formatter('files', opts)
3359 fmt = '%s' + end
3398 fmt = '%s' + end
3360
3399
3361 m = scmutil.match(ctx, pats, opts)
3400 m = scmutil.match(ctx, pats, opts)
3362 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3401 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3363
3402
3364 fm.end()
3403 fm.end()
3365
3404
3366 return ret
3405 return ret
3367
3406
3368 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3407 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3369 def forget(ui, repo, *pats, **opts):
3408 def forget(ui, repo, *pats, **opts):
3370 """forget the specified files on the next commit
3409 """forget the specified files on the next commit
3371
3410
3372 Mark the specified files so they will no longer be tracked
3411 Mark the specified files so they will no longer be tracked
3373 after the next commit.
3412 after the next commit.
3374
3413
3375 This only removes files from the current branch, not from the
3414 This only removes files from the current branch, not from the
3376 entire project history, and it does not delete them from the
3415 entire project history, and it does not delete them from the
3377 working directory.
3416 working directory.
3378
3417
3379 To delete the file from the working directory, see :hg:`remove`.
3418 To delete the file from the working directory, see :hg:`remove`.
3380
3419
3381 To undo a forget before the next commit, see :hg:`add`.
3420 To undo a forget before the next commit, see :hg:`add`.
3382
3421
3383 .. container:: verbose
3422 .. container:: verbose
3384
3423
3385 Examples:
3424 Examples:
3386
3425
3387 - forget newly-added binary files::
3426 - forget newly-added binary files::
3388
3427
3389 hg forget "set:added() and binary()"
3428 hg forget "set:added() and binary()"
3390
3429
3391 - forget files that would be excluded by .hgignore::
3430 - forget files that would be excluded by .hgignore::
3392
3431
3393 hg forget "set:hgignore()"
3432 hg forget "set:hgignore()"
3394
3433
3395 Returns 0 on success.
3434 Returns 0 on success.
3396 """
3435 """
3397
3436
3398 if not pats:
3437 if not pats:
3399 raise util.Abort(_('no files specified'))
3438 raise util.Abort(_('no files specified'))
3400
3439
3401 m = scmutil.match(repo[None], pats, opts)
3440 m = scmutil.match(repo[None], pats, opts)
3402 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3441 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3403 return rejected and 1 or 0
3442 return rejected and 1 or 0
3404
3443
3405 @command(
3444 @command(
3406 'graft',
3445 'graft',
3407 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3446 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3408 ('c', 'continue', False, _('resume interrupted graft')),
3447 ('c', 'continue', False, _('resume interrupted graft')),
3409 ('e', 'edit', False, _('invoke editor on commit messages')),
3448 ('e', 'edit', False, _('invoke editor on commit messages')),
3410 ('', 'log', None, _('append graft info to log message')),
3449 ('', 'log', None, _('append graft info to log message')),
3411 ('f', 'force', False, _('force graft')),
3450 ('f', 'force', False, _('force graft')),
3412 ('D', 'currentdate', False,
3451 ('D', 'currentdate', False,
3413 _('record the current date as commit date')),
3452 _('record the current date as commit date')),
3414 ('U', 'currentuser', False,
3453 ('U', 'currentuser', False,
3415 _('record the current user as committer'), _('DATE'))]
3454 _('record the current user as committer'), _('DATE'))]
3416 + commitopts2 + mergetoolopts + dryrunopts,
3455 + commitopts2 + mergetoolopts + dryrunopts,
3417 _('[OPTION]... [-r] REV...'))
3456 _('[OPTION]... [-r] REV...'))
3418 def graft(ui, repo, *revs, **opts):
3457 def graft(ui, repo, *revs, **opts):
3419 '''copy changes from other branches onto the current branch
3458 '''copy changes from other branches onto the current branch
3420
3459
3421 This command uses Mercurial's merge logic to copy individual
3460 This command uses Mercurial's merge logic to copy individual
3422 changes from other branches without merging branches in the
3461 changes from other branches without merging branches in the
3423 history graph. This is sometimes known as 'backporting' or
3462 history graph. This is sometimes known as 'backporting' or
3424 'cherry-picking'. By default, graft will copy user, date, and
3463 'cherry-picking'. By default, graft will copy user, date, and
3425 description from the source changesets.
3464 description from the source changesets.
3426
3465
3427 Changesets that are ancestors of the current revision, that have
3466 Changesets that are ancestors of the current revision, that have
3428 already been grafted, or that are merges will be skipped.
3467 already been grafted, or that are merges will be skipped.
3429
3468
3430 If --log is specified, log messages will have a comment appended
3469 If --log is specified, log messages will have a comment appended
3431 of the form::
3470 of the form::
3432
3471
3433 (grafted from CHANGESETHASH)
3472 (grafted from CHANGESETHASH)
3434
3473
3435 If --force is specified, revisions will be grafted even if they
3474 If --force is specified, revisions will be grafted even if they
3436 are already ancestors of or have been grafted to the destination.
3475 are already ancestors of or have been grafted to the destination.
3437 This is useful when the revisions have since been backed out.
3476 This is useful when the revisions have since been backed out.
3438
3477
3439 If a graft merge results in conflicts, the graft process is
3478 If a graft merge results in conflicts, the graft process is
3440 interrupted so that the current merge can be manually resolved.
3479 interrupted so that the current merge can be manually resolved.
3441 Once all conflicts are addressed, the graft process can be
3480 Once all conflicts are addressed, the graft process can be
3442 continued with the -c/--continue option.
3481 continued with the -c/--continue option.
3443
3482
3444 .. note::
3483 .. note::
3445
3484
3446 The -c/--continue option does not reapply earlier options, except
3485 The -c/--continue option does not reapply earlier options, except
3447 for --force.
3486 for --force.
3448
3487
3449 .. container:: verbose
3488 .. container:: verbose
3450
3489
3451 Examples:
3490 Examples:
3452
3491
3453 - copy a single change to the stable branch and edit its description::
3492 - copy a single change to the stable branch and edit its description::
3454
3493
3455 hg update stable
3494 hg update stable
3456 hg graft --edit 9393
3495 hg graft --edit 9393
3457
3496
3458 - graft a range of changesets with one exception, updating dates::
3497 - graft a range of changesets with one exception, updating dates::
3459
3498
3460 hg graft -D "2085::2093 and not 2091"
3499 hg graft -D "2085::2093 and not 2091"
3461
3500
3462 - continue a graft after resolving conflicts::
3501 - continue a graft after resolving conflicts::
3463
3502
3464 hg graft -c
3503 hg graft -c
3465
3504
3466 - show the source of a grafted changeset::
3505 - show the source of a grafted changeset::
3467
3506
3468 hg log --debug -r .
3507 hg log --debug -r .
3469
3508
3470 See :hg:`help revisions` and :hg:`help revsets` for more about
3509 See :hg:`help revisions` and :hg:`help revsets` for more about
3471 specifying revisions.
3510 specifying revisions.
3472
3511
3473 Returns 0 on successful completion.
3512 Returns 0 on successful completion.
3474 '''
3513 '''
3475
3514
3476 revs = list(revs)
3515 revs = list(revs)
3477 revs.extend(opts['rev'])
3516 revs.extend(opts['rev'])
3478
3517
3479 if not opts.get('user') and opts.get('currentuser'):
3518 if not opts.get('user') and opts.get('currentuser'):
3480 opts['user'] = ui.username()
3519 opts['user'] = ui.username()
3481 if not opts.get('date') and opts.get('currentdate'):
3520 if not opts.get('date') and opts.get('currentdate'):
3482 opts['date'] = "%d %d" % util.makedate()
3521 opts['date'] = "%d %d" % util.makedate()
3483
3522
3484 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3523 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3485
3524
3486 cont = False
3525 cont = False
3487 if opts['continue']:
3526 if opts['continue']:
3488 cont = True
3527 cont = True
3489 if revs:
3528 if revs:
3490 raise util.Abort(_("can't specify --continue and revisions"))
3529 raise util.Abort(_("can't specify --continue and revisions"))
3491 # read in unfinished revisions
3530 # read in unfinished revisions
3492 try:
3531 try:
3493 nodes = repo.vfs.read('graftstate').splitlines()
3532 nodes = repo.vfs.read('graftstate').splitlines()
3494 revs = [repo[node].rev() for node in nodes]
3533 revs = [repo[node].rev() for node in nodes]
3495 except IOError as inst:
3534 except IOError as inst:
3496 if inst.errno != errno.ENOENT:
3535 if inst.errno != errno.ENOENT:
3497 raise
3536 raise
3498 raise util.Abort(_("no graft state found, can't continue"))
3537 raise util.Abort(_("no graft state found, can't continue"))
3499 else:
3538 else:
3500 cmdutil.checkunfinished(repo)
3539 cmdutil.checkunfinished(repo)
3501 cmdutil.bailifchanged(repo)
3540 cmdutil.bailifchanged(repo)
3502 if not revs:
3541 if not revs:
3503 raise util.Abort(_('no revisions specified'))
3542 raise util.Abort(_('no revisions specified'))
3504 revs = scmutil.revrange(repo, revs)
3543 revs = scmutil.revrange(repo, revs)
3505
3544
3506 skipped = set()
3545 skipped = set()
3507 # check for merges
3546 # check for merges
3508 for rev in repo.revs('%ld and merge()', revs):
3547 for rev in repo.revs('%ld and merge()', revs):
3509 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3548 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3510 skipped.add(rev)
3549 skipped.add(rev)
3511 revs = [r for r in revs if r not in skipped]
3550 revs = [r for r in revs if r not in skipped]
3512 if not revs:
3551 if not revs:
3513 return -1
3552 return -1
3514
3553
3515 # Don't check in the --continue case, in effect retaining --force across
3554 # Don't check in the --continue case, in effect retaining --force across
3516 # --continues. That's because without --force, any revisions we decided to
3555 # --continues. That's because without --force, any revisions we decided to
3517 # skip would have been filtered out here, so they wouldn't have made their
3556 # skip would have been filtered out here, so they wouldn't have made their
3518 # way to the graftstate. With --force, any revisions we would have otherwise
3557 # way to the graftstate. With --force, any revisions we would have otherwise
3519 # skipped would not have been filtered out, and if they hadn't been applied
3558 # skipped would not have been filtered out, and if they hadn't been applied
3520 # already, they'd have been in the graftstate.
3559 # already, they'd have been in the graftstate.
3521 if not (cont or opts.get('force')):
3560 if not (cont or opts.get('force')):
3522 # check for ancestors of dest branch
3561 # check for ancestors of dest branch
3523 crev = repo['.'].rev()
3562 crev = repo['.'].rev()
3524 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3563 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3525 # Cannot use x.remove(y) on smart set, this has to be a list.
3564 # Cannot use x.remove(y) on smart set, this has to be a list.
3526 # XXX make this lazy in the future
3565 # XXX make this lazy in the future
3527 revs = list(revs)
3566 revs = list(revs)
3528 # don't mutate while iterating, create a copy
3567 # don't mutate while iterating, create a copy
3529 for rev in list(revs):
3568 for rev in list(revs):
3530 if rev in ancestors:
3569 if rev in ancestors:
3531 ui.warn(_('skipping ancestor revision %d:%s\n') %
3570 ui.warn(_('skipping ancestor revision %d:%s\n') %
3532 (rev, repo[rev]))
3571 (rev, repo[rev]))
3533 # XXX remove on list is slow
3572 # XXX remove on list is slow
3534 revs.remove(rev)
3573 revs.remove(rev)
3535 if not revs:
3574 if not revs:
3536 return -1
3575 return -1
3537
3576
3538 # analyze revs for earlier grafts
3577 # analyze revs for earlier grafts
3539 ids = {}
3578 ids = {}
3540 for ctx in repo.set("%ld", revs):
3579 for ctx in repo.set("%ld", revs):
3541 ids[ctx.hex()] = ctx.rev()
3580 ids[ctx.hex()] = ctx.rev()
3542 n = ctx.extra().get('source')
3581 n = ctx.extra().get('source')
3543 if n:
3582 if n:
3544 ids[n] = ctx.rev()
3583 ids[n] = ctx.rev()
3545
3584
3546 # check ancestors for earlier grafts
3585 # check ancestors for earlier grafts
3547 ui.debug('scanning for duplicate grafts\n')
3586 ui.debug('scanning for duplicate grafts\n')
3548
3587
3549 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3588 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3550 ctx = repo[rev]
3589 ctx = repo[rev]
3551 n = ctx.extra().get('source')
3590 n = ctx.extra().get('source')
3552 if n in ids:
3591 if n in ids:
3553 try:
3592 try:
3554 r = repo[n].rev()
3593 r = repo[n].rev()
3555 except error.RepoLookupError:
3594 except error.RepoLookupError:
3556 r = None
3595 r = None
3557 if r in revs:
3596 if r in revs:
3558 ui.warn(_('skipping revision %d:%s '
3597 ui.warn(_('skipping revision %d:%s '
3559 '(already grafted to %d:%s)\n')
3598 '(already grafted to %d:%s)\n')
3560 % (r, repo[r], rev, ctx))
3599 % (r, repo[r], rev, ctx))
3561 revs.remove(r)
3600 revs.remove(r)
3562 elif ids[n] in revs:
3601 elif ids[n] in revs:
3563 if r is None:
3602 if r is None:
3564 ui.warn(_('skipping already grafted revision %d:%s '
3603 ui.warn(_('skipping already grafted revision %d:%s '
3565 '(%d:%s also has unknown origin %s)\n')
3604 '(%d:%s also has unknown origin %s)\n')
3566 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3605 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3567 else:
3606 else:
3568 ui.warn(_('skipping already grafted revision %d:%s '
3607 ui.warn(_('skipping already grafted revision %d:%s '
3569 '(%d:%s also has origin %d:%s)\n')
3608 '(%d:%s also has origin %d:%s)\n')
3570 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3609 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3571 revs.remove(ids[n])
3610 revs.remove(ids[n])
3572 elif ctx.hex() in ids:
3611 elif ctx.hex() in ids:
3573 r = ids[ctx.hex()]
3612 r = ids[ctx.hex()]
3574 ui.warn(_('skipping already grafted revision %d:%s '
3613 ui.warn(_('skipping already grafted revision %d:%s '
3575 '(was grafted from %d:%s)\n') %
3614 '(was grafted from %d:%s)\n') %
3576 (r, repo[r], rev, ctx))
3615 (r, repo[r], rev, ctx))
3577 revs.remove(r)
3616 revs.remove(r)
3578 if not revs:
3617 if not revs:
3579 return -1
3618 return -1
3580
3619
3581 wlock = repo.wlock()
3620 wlock = repo.wlock()
3582 try:
3621 try:
3583 for pos, ctx in enumerate(repo.set("%ld", revs)):
3622 for pos, ctx in enumerate(repo.set("%ld", revs)):
3584 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3623 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3585 ctx.description().split('\n', 1)[0])
3624 ctx.description().split('\n', 1)[0])
3586 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3625 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3587 if names:
3626 if names:
3588 desc += ' (%s)' % ' '.join(names)
3627 desc += ' (%s)' % ' '.join(names)
3589 ui.status(_('grafting %s\n') % desc)
3628 ui.status(_('grafting %s\n') % desc)
3590 if opts.get('dry_run'):
3629 if opts.get('dry_run'):
3591 continue
3630 continue
3592
3631
3593 source = ctx.extra().get('source')
3632 source = ctx.extra().get('source')
3594 extra = {}
3633 extra = {}
3595 if source:
3634 if source:
3596 extra['source'] = source
3635 extra['source'] = source
3597 extra['intermediate-source'] = ctx.hex()
3636 extra['intermediate-source'] = ctx.hex()
3598 else:
3637 else:
3599 extra['source'] = ctx.hex()
3638 extra['source'] = ctx.hex()
3600 user = ctx.user()
3639 user = ctx.user()
3601 if opts.get('user'):
3640 if opts.get('user'):
3602 user = opts['user']
3641 user = opts['user']
3603 date = ctx.date()
3642 date = ctx.date()
3604 if opts.get('date'):
3643 if opts.get('date'):
3605 date = opts['date']
3644 date = opts['date']
3606 message = ctx.description()
3645 message = ctx.description()
3607 if opts.get('log'):
3646 if opts.get('log'):
3608 message += '\n(grafted from %s)' % ctx.hex()
3647 message += '\n(grafted from %s)' % ctx.hex()
3609
3648
3610 # we don't merge the first commit when continuing
3649 # we don't merge the first commit when continuing
3611 if not cont:
3650 if not cont:
3612 # perform the graft merge with p1(rev) as 'ancestor'
3651 # perform the graft merge with p1(rev) as 'ancestor'
3613 try:
3652 try:
3614 # ui.forcemerge is an internal variable, do not document
3653 # ui.forcemerge is an internal variable, do not document
3615 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3654 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3616 'graft')
3655 'graft')
3617 stats = mergemod.graft(repo, ctx, ctx.p1(),
3656 stats = mergemod.graft(repo, ctx, ctx.p1(),
3618 ['local', 'graft'])
3657 ['local', 'graft'])
3619 finally:
3658 finally:
3620 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3659 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3621 # report any conflicts
3660 # report any conflicts
3622 if stats and stats[3] > 0:
3661 if stats and stats[3] > 0:
3623 # write out state for --continue
3662 # write out state for --continue
3624 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3663 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3625 repo.vfs.write('graftstate', ''.join(nodelines))
3664 repo.vfs.write('graftstate', ''.join(nodelines))
3626 raise util.Abort(
3665 raise util.Abort(
3627 _("unresolved conflicts, can't continue"),
3666 _("unresolved conflicts, can't continue"),
3628 hint=_('use hg resolve and hg graft --continue'))
3667 hint=_('use hg resolve and hg graft --continue'))
3629 else:
3668 else:
3630 cont = False
3669 cont = False
3631
3670
3632 # commit
3671 # commit
3633 node = repo.commit(text=message, user=user,
3672 node = repo.commit(text=message, user=user,
3634 date=date, extra=extra, editor=editor)
3673 date=date, extra=extra, editor=editor)
3635 if node is None:
3674 if node is None:
3636 ui.warn(
3675 ui.warn(
3637 _('note: graft of %d:%s created no changes to commit\n') %
3676 _('note: graft of %d:%s created no changes to commit\n') %
3638 (ctx.rev(), ctx))
3677 (ctx.rev(), ctx))
3639 finally:
3678 finally:
3640 wlock.release()
3679 wlock.release()
3641
3680
3642 # remove state when we complete successfully
3681 # remove state when we complete successfully
3643 if not opts.get('dry_run'):
3682 if not opts.get('dry_run'):
3644 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3683 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3645
3684
3646 return 0
3685 return 0
3647
3686
3648 @command('grep',
3687 @command('grep',
3649 [('0', 'print0', None, _('end fields with NUL')),
3688 [('0', 'print0', None, _('end fields with NUL')),
3650 ('', 'all', None, _('print all revisions that match')),
3689 ('', 'all', None, _('print all revisions that match')),
3651 ('a', 'text', None, _('treat all files as text')),
3690 ('a', 'text', None, _('treat all files as text')),
3652 ('f', 'follow', None,
3691 ('f', 'follow', None,
3653 _('follow changeset history,'
3692 _('follow changeset history,'
3654 ' or file history across copies and renames')),
3693 ' or file history across copies and renames')),
3655 ('i', 'ignore-case', None, _('ignore case when matching')),
3694 ('i', 'ignore-case', None, _('ignore case when matching')),
3656 ('l', 'files-with-matches', None,
3695 ('l', 'files-with-matches', None,
3657 _('print only filenames and revisions that match')),
3696 _('print only filenames and revisions that match')),
3658 ('n', 'line-number', None, _('print matching line numbers')),
3697 ('n', 'line-number', None, _('print matching line numbers')),
3659 ('r', 'rev', [],
3698 ('r', 'rev', [],
3660 _('only search files changed within revision range'), _('REV')),
3699 _('only search files changed within revision range'), _('REV')),
3661 ('u', 'user', None, _('list the author (long with -v)')),
3700 ('u', 'user', None, _('list the author (long with -v)')),
3662 ('d', 'date', None, _('list the date (short with -q)')),
3701 ('d', 'date', None, _('list the date (short with -q)')),
3663 ] + walkopts,
3702 ] + walkopts,
3664 _('[OPTION]... PATTERN [FILE]...'),
3703 _('[OPTION]... PATTERN [FILE]...'),
3665 inferrepo=True)
3704 inferrepo=True)
3666 def grep(ui, repo, pattern, *pats, **opts):
3705 def grep(ui, repo, pattern, *pats, **opts):
3667 """search for a pattern in specified files and revisions
3706 """search for a pattern in specified files and revisions
3668
3707
3669 Search revisions of files for a regular expression.
3708 Search revisions of files for a regular expression.
3670
3709
3671 This command behaves differently than Unix grep. It only accepts
3710 This command behaves differently than Unix grep. It only accepts
3672 Python/Perl regexps. It searches repository history, not the
3711 Python/Perl regexps. It searches repository history, not the
3673 working directory. It always prints the revision number in which a
3712 working directory. It always prints the revision number in which a
3674 match appears.
3713 match appears.
3675
3714
3676 By default, grep only prints output for the first revision of a
3715 By default, grep only prints output for the first revision of a
3677 file in which it finds a match. To get it to print every revision
3716 file in which it finds a match. To get it to print every revision
3678 that contains a change in match status ("-" for a match that
3717 that contains a change in match status ("-" for a match that
3679 becomes a non-match, or "+" for a non-match that becomes a match),
3718 becomes a non-match, or "+" for a non-match that becomes a match),
3680 use the --all flag.
3719 use the --all flag.
3681
3720
3682 Returns 0 if a match is found, 1 otherwise.
3721 Returns 0 if a match is found, 1 otherwise.
3683 """
3722 """
3684 reflags = re.M
3723 reflags = re.M
3685 if opts.get('ignore_case'):
3724 if opts.get('ignore_case'):
3686 reflags |= re.I
3725 reflags |= re.I
3687 try:
3726 try:
3688 regexp = util.re.compile(pattern, reflags)
3727 regexp = util.re.compile(pattern, reflags)
3689 except re.error as inst:
3728 except re.error as inst:
3690 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3729 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3691 return 1
3730 return 1
3692 sep, eol = ':', '\n'
3731 sep, eol = ':', '\n'
3693 if opts.get('print0'):
3732 if opts.get('print0'):
3694 sep = eol = '\0'
3733 sep = eol = '\0'
3695
3734
3696 getfile = util.lrucachefunc(repo.file)
3735 getfile = util.lrucachefunc(repo.file)
3697
3736
3698 def matchlines(body):
3737 def matchlines(body):
3699 begin = 0
3738 begin = 0
3700 linenum = 0
3739 linenum = 0
3701 while begin < len(body):
3740 while begin < len(body):
3702 match = regexp.search(body, begin)
3741 match = regexp.search(body, begin)
3703 if not match:
3742 if not match:
3704 break
3743 break
3705 mstart, mend = match.span()
3744 mstart, mend = match.span()
3706 linenum += body.count('\n', begin, mstart) + 1
3745 linenum += body.count('\n', begin, mstart) + 1
3707 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3746 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3708 begin = body.find('\n', mend) + 1 or len(body) + 1
3747 begin = body.find('\n', mend) + 1 or len(body) + 1
3709 lend = begin - 1
3748 lend = begin - 1
3710 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3749 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3711
3750
3712 class linestate(object):
3751 class linestate(object):
3713 def __init__(self, line, linenum, colstart, colend):
3752 def __init__(self, line, linenum, colstart, colend):
3714 self.line = line
3753 self.line = line
3715 self.linenum = linenum
3754 self.linenum = linenum
3716 self.colstart = colstart
3755 self.colstart = colstart
3717 self.colend = colend
3756 self.colend = colend
3718
3757
3719 def __hash__(self):
3758 def __hash__(self):
3720 return hash((self.linenum, self.line))
3759 return hash((self.linenum, self.line))
3721
3760
3722 def __eq__(self, other):
3761 def __eq__(self, other):
3723 return self.line == other.line
3762 return self.line == other.line
3724
3763
3725 def __iter__(self):
3764 def __iter__(self):
3726 yield (self.line[:self.colstart], '')
3765 yield (self.line[:self.colstart], '')
3727 yield (self.line[self.colstart:self.colend], 'grep.match')
3766 yield (self.line[self.colstart:self.colend], 'grep.match')
3728 rest = self.line[self.colend:]
3767 rest = self.line[self.colend:]
3729 while rest != '':
3768 while rest != '':
3730 match = regexp.search(rest)
3769 match = regexp.search(rest)
3731 if not match:
3770 if not match:
3732 yield (rest, '')
3771 yield (rest, '')
3733 break
3772 break
3734 mstart, mend = match.span()
3773 mstart, mend = match.span()
3735 yield (rest[:mstart], '')
3774 yield (rest[:mstart], '')
3736 yield (rest[mstart:mend], 'grep.match')
3775 yield (rest[mstart:mend], 'grep.match')
3737 rest = rest[mend:]
3776 rest = rest[mend:]
3738
3777
3739 matches = {}
3778 matches = {}
3740 copies = {}
3779 copies = {}
3741 def grepbody(fn, rev, body):
3780 def grepbody(fn, rev, body):
3742 matches[rev].setdefault(fn, [])
3781 matches[rev].setdefault(fn, [])
3743 m = matches[rev][fn]
3782 m = matches[rev][fn]
3744 for lnum, cstart, cend, line in matchlines(body):
3783 for lnum, cstart, cend, line in matchlines(body):
3745 s = linestate(line, lnum, cstart, cend)
3784 s = linestate(line, lnum, cstart, cend)
3746 m.append(s)
3785 m.append(s)
3747
3786
3748 def difflinestates(a, b):
3787 def difflinestates(a, b):
3749 sm = difflib.SequenceMatcher(None, a, b)
3788 sm = difflib.SequenceMatcher(None, a, b)
3750 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3789 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3751 if tag == 'insert':
3790 if tag == 'insert':
3752 for i in xrange(blo, bhi):
3791 for i in xrange(blo, bhi):
3753 yield ('+', b[i])
3792 yield ('+', b[i])
3754 elif tag == 'delete':
3793 elif tag == 'delete':
3755 for i in xrange(alo, ahi):
3794 for i in xrange(alo, ahi):
3756 yield ('-', a[i])
3795 yield ('-', a[i])
3757 elif tag == 'replace':
3796 elif tag == 'replace':
3758 for i in xrange(alo, ahi):
3797 for i in xrange(alo, ahi):
3759 yield ('-', a[i])
3798 yield ('-', a[i])
3760 for i in xrange(blo, bhi):
3799 for i in xrange(blo, bhi):
3761 yield ('+', b[i])
3800 yield ('+', b[i])
3762
3801
3763 def display(fn, ctx, pstates, states):
3802 def display(fn, ctx, pstates, states):
3764 rev = ctx.rev()
3803 rev = ctx.rev()
3765 if ui.quiet:
3804 if ui.quiet:
3766 datefunc = util.shortdate
3805 datefunc = util.shortdate
3767 else:
3806 else:
3768 datefunc = util.datestr
3807 datefunc = util.datestr
3769 found = False
3808 found = False
3770 @util.cachefunc
3809 @util.cachefunc
3771 def binary():
3810 def binary():
3772 flog = getfile(fn)
3811 flog = getfile(fn)
3773 return util.binary(flog.read(ctx.filenode(fn)))
3812 return util.binary(flog.read(ctx.filenode(fn)))
3774
3813
3775 if opts.get('all'):
3814 if opts.get('all'):
3776 iter = difflinestates(pstates, states)
3815 iter = difflinestates(pstates, states)
3777 else:
3816 else:
3778 iter = [('', l) for l in states]
3817 iter = [('', l) for l in states]
3779 for change, l in iter:
3818 for change, l in iter:
3780 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3819 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3781
3820
3782 if opts.get('line_number'):
3821 if opts.get('line_number'):
3783 cols.append((str(l.linenum), 'grep.linenumber'))
3822 cols.append((str(l.linenum), 'grep.linenumber'))
3784 if opts.get('all'):
3823 if opts.get('all'):
3785 cols.append((change, 'grep.change'))
3824 cols.append((change, 'grep.change'))
3786 if opts.get('user'):
3825 if opts.get('user'):
3787 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3826 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3788 if opts.get('date'):
3827 if opts.get('date'):
3789 cols.append((datefunc(ctx.date()), 'grep.date'))
3828 cols.append((datefunc(ctx.date()), 'grep.date'))
3790 for col, label in cols[:-1]:
3829 for col, label in cols[:-1]:
3791 ui.write(col, label=label)
3830 ui.write(col, label=label)
3792 ui.write(sep, label='grep.sep')
3831 ui.write(sep, label='grep.sep')
3793 ui.write(cols[-1][0], label=cols[-1][1])
3832 ui.write(cols[-1][0], label=cols[-1][1])
3794 if not opts.get('files_with_matches'):
3833 if not opts.get('files_with_matches'):
3795 ui.write(sep, label='grep.sep')
3834 ui.write(sep, label='grep.sep')
3796 if not opts.get('text') and binary():
3835 if not opts.get('text') and binary():
3797 ui.write(" Binary file matches")
3836 ui.write(" Binary file matches")
3798 else:
3837 else:
3799 for s, label in l:
3838 for s, label in l:
3800 ui.write(s, label=label)
3839 ui.write(s, label=label)
3801 ui.write(eol)
3840 ui.write(eol)
3802 found = True
3841 found = True
3803 if opts.get('files_with_matches'):
3842 if opts.get('files_with_matches'):
3804 break
3843 break
3805 return found
3844 return found
3806
3845
3807 skip = {}
3846 skip = {}
3808 revfiles = {}
3847 revfiles = {}
3809 matchfn = scmutil.match(repo[None], pats, opts)
3848 matchfn = scmutil.match(repo[None], pats, opts)
3810 found = False
3849 found = False
3811 follow = opts.get('follow')
3850 follow = opts.get('follow')
3812
3851
3813 def prep(ctx, fns):
3852 def prep(ctx, fns):
3814 rev = ctx.rev()
3853 rev = ctx.rev()
3815 pctx = ctx.p1()
3854 pctx = ctx.p1()
3816 parent = pctx.rev()
3855 parent = pctx.rev()
3817 matches.setdefault(rev, {})
3856 matches.setdefault(rev, {})
3818 matches.setdefault(parent, {})
3857 matches.setdefault(parent, {})
3819 files = revfiles.setdefault(rev, [])
3858 files = revfiles.setdefault(rev, [])
3820 for fn in fns:
3859 for fn in fns:
3821 flog = getfile(fn)
3860 flog = getfile(fn)
3822 try:
3861 try:
3823 fnode = ctx.filenode(fn)
3862 fnode = ctx.filenode(fn)
3824 except error.LookupError:
3863 except error.LookupError:
3825 continue
3864 continue
3826
3865
3827 copied = flog.renamed(fnode)
3866 copied = flog.renamed(fnode)
3828 copy = follow and copied and copied[0]
3867 copy = follow and copied and copied[0]
3829 if copy:
3868 if copy:
3830 copies.setdefault(rev, {})[fn] = copy
3869 copies.setdefault(rev, {})[fn] = copy
3831 if fn in skip:
3870 if fn in skip:
3832 if copy:
3871 if copy:
3833 skip[copy] = True
3872 skip[copy] = True
3834 continue
3873 continue
3835 files.append(fn)
3874 files.append(fn)
3836
3875
3837 if fn not in matches[rev]:
3876 if fn not in matches[rev]:
3838 grepbody(fn, rev, flog.read(fnode))
3877 grepbody(fn, rev, flog.read(fnode))
3839
3878
3840 pfn = copy or fn
3879 pfn = copy or fn
3841 if pfn not in matches[parent]:
3880 if pfn not in matches[parent]:
3842 try:
3881 try:
3843 fnode = pctx.filenode(pfn)
3882 fnode = pctx.filenode(pfn)
3844 grepbody(pfn, parent, flog.read(fnode))
3883 grepbody(pfn, parent, flog.read(fnode))
3845 except error.LookupError:
3884 except error.LookupError:
3846 pass
3885 pass
3847
3886
3848 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3887 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3849 rev = ctx.rev()
3888 rev = ctx.rev()
3850 parent = ctx.p1().rev()
3889 parent = ctx.p1().rev()
3851 for fn in sorted(revfiles.get(rev, [])):
3890 for fn in sorted(revfiles.get(rev, [])):
3852 states = matches[rev][fn]
3891 states = matches[rev][fn]
3853 copy = copies.get(rev, {}).get(fn)
3892 copy = copies.get(rev, {}).get(fn)
3854 if fn in skip:
3893 if fn in skip:
3855 if copy:
3894 if copy:
3856 skip[copy] = True
3895 skip[copy] = True
3857 continue
3896 continue
3858 pstates = matches.get(parent, {}).get(copy or fn, [])
3897 pstates = matches.get(parent, {}).get(copy or fn, [])
3859 if pstates or states:
3898 if pstates or states:
3860 r = display(fn, ctx, pstates, states)
3899 r = display(fn, ctx, pstates, states)
3861 found = found or r
3900 found = found or r
3862 if r and not opts.get('all'):
3901 if r and not opts.get('all'):
3863 skip[fn] = True
3902 skip[fn] = True
3864 if copy:
3903 if copy:
3865 skip[copy] = True
3904 skip[copy] = True
3866 del matches[rev]
3905 del matches[rev]
3867 del revfiles[rev]
3906 del revfiles[rev]
3868
3907
3869 return not found
3908 return not found
3870
3909
3871 @command('heads',
3910 @command('heads',
3872 [('r', 'rev', '',
3911 [('r', 'rev', '',
3873 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3912 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3874 ('t', 'topo', False, _('show topological heads only')),
3913 ('t', 'topo', False, _('show topological heads only')),
3875 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3914 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3876 ('c', 'closed', False, _('show normal and closed branch heads')),
3915 ('c', 'closed', False, _('show normal and closed branch heads')),
3877 ] + templateopts,
3916 ] + templateopts,
3878 _('[-ct] [-r STARTREV] [REV]...'))
3917 _('[-ct] [-r STARTREV] [REV]...'))
3879 def heads(ui, repo, *branchrevs, **opts):
3918 def heads(ui, repo, *branchrevs, **opts):
3880 """show branch heads
3919 """show branch heads
3881
3920
3882 With no arguments, show all open branch heads in the repository.
3921 With no arguments, show all open branch heads in the repository.
3883 Branch heads are changesets that have no descendants on the
3922 Branch heads are changesets that have no descendants on the
3884 same branch. They are where development generally takes place and
3923 same branch. They are where development generally takes place and
3885 are the usual targets for update and merge operations.
3924 are the usual targets for update and merge operations.
3886
3925
3887 If one or more REVs are given, only open branch heads on the
3926 If one or more REVs are given, only open branch heads on the
3888 branches associated with the specified changesets are shown. This
3927 branches associated with the specified changesets are shown. This
3889 means that you can use :hg:`heads .` to see the heads on the
3928 means that you can use :hg:`heads .` to see the heads on the
3890 currently checked-out branch.
3929 currently checked-out branch.
3891
3930
3892 If -c/--closed is specified, also show branch heads marked closed
3931 If -c/--closed is specified, also show branch heads marked closed
3893 (see :hg:`commit --close-branch`).
3932 (see :hg:`commit --close-branch`).
3894
3933
3895 If STARTREV is specified, only those heads that are descendants of
3934 If STARTREV is specified, only those heads that are descendants of
3896 STARTREV will be displayed.
3935 STARTREV will be displayed.
3897
3936
3898 If -t/--topo is specified, named branch mechanics will be ignored and only
3937 If -t/--topo is specified, named branch mechanics will be ignored and only
3899 topological heads (changesets with no children) will be shown.
3938 topological heads (changesets with no children) will be shown.
3900
3939
3901 Returns 0 if matching heads are found, 1 if not.
3940 Returns 0 if matching heads are found, 1 if not.
3902 """
3941 """
3903
3942
3904 start = None
3943 start = None
3905 if 'rev' in opts:
3944 if 'rev' in opts:
3906 start = scmutil.revsingle(repo, opts['rev'], None).node()
3945 start = scmutil.revsingle(repo, opts['rev'], None).node()
3907
3946
3908 if opts.get('topo'):
3947 if opts.get('topo'):
3909 heads = [repo[h] for h in repo.heads(start)]
3948 heads = [repo[h] for h in repo.heads(start)]
3910 else:
3949 else:
3911 heads = []
3950 heads = []
3912 for branch in repo.branchmap():
3951 for branch in repo.branchmap():
3913 heads += repo.branchheads(branch, start, opts.get('closed'))
3952 heads += repo.branchheads(branch, start, opts.get('closed'))
3914 heads = [repo[h] for h in heads]
3953 heads = [repo[h] for h in heads]
3915
3954
3916 if branchrevs:
3955 if branchrevs:
3917 branches = set(repo[br].branch() for br in branchrevs)
3956 branches = set(repo[br].branch() for br in branchrevs)
3918 heads = [h for h in heads if h.branch() in branches]
3957 heads = [h for h in heads if h.branch() in branches]
3919
3958
3920 if opts.get('active') and branchrevs:
3959 if opts.get('active') and branchrevs:
3921 dagheads = repo.heads(start)
3960 dagheads = repo.heads(start)
3922 heads = [h for h in heads if h.node() in dagheads]
3961 heads = [h for h in heads if h.node() in dagheads]
3923
3962
3924 if branchrevs:
3963 if branchrevs:
3925 haveheads = set(h.branch() for h in heads)
3964 haveheads = set(h.branch() for h in heads)
3926 if branches - haveheads:
3965 if branches - haveheads:
3927 headless = ', '.join(b for b in branches - haveheads)
3966 headless = ', '.join(b for b in branches - haveheads)
3928 msg = _('no open branch heads found on branches %s')
3967 msg = _('no open branch heads found on branches %s')
3929 if opts.get('rev'):
3968 if opts.get('rev'):
3930 msg += _(' (started at %s)') % opts['rev']
3969 msg += _(' (started at %s)') % opts['rev']
3931 ui.warn((msg + '\n') % headless)
3970 ui.warn((msg + '\n') % headless)
3932
3971
3933 if not heads:
3972 if not heads:
3934 return 1
3973 return 1
3935
3974
3936 heads = sorted(heads, key=lambda x: -x.rev())
3975 heads = sorted(heads, key=lambda x: -x.rev())
3937 displayer = cmdutil.show_changeset(ui, repo, opts)
3976 displayer = cmdutil.show_changeset(ui, repo, opts)
3938 for ctx in heads:
3977 for ctx in heads:
3939 displayer.show(ctx)
3978 displayer.show(ctx)
3940 displayer.close()
3979 displayer.close()
3941
3980
3942 @command('help',
3981 @command('help',
3943 [('e', 'extension', None, _('show only help for extensions')),
3982 [('e', 'extension', None, _('show only help for extensions')),
3944 ('c', 'command', None, _('show only help for commands')),
3983 ('c', 'command', None, _('show only help for commands')),
3945 ('k', 'keyword', None, _('show topics matching keyword')),
3984 ('k', 'keyword', None, _('show topics matching keyword')),
3946 ],
3985 ],
3947 _('[-eck] [TOPIC]'),
3986 _('[-eck] [TOPIC]'),
3948 norepo=True)
3987 norepo=True)
3949 def help_(ui, name=None, **opts):
3988 def help_(ui, name=None, **opts):
3950 """show help for a given topic or a help overview
3989 """show help for a given topic or a help overview
3951
3990
3952 With no arguments, print a list of commands with short help messages.
3991 With no arguments, print a list of commands with short help messages.
3953
3992
3954 Given a topic, extension, or command name, print help for that
3993 Given a topic, extension, or command name, print help for that
3955 topic.
3994 topic.
3956
3995
3957 Returns 0 if successful.
3996 Returns 0 if successful.
3958 """
3997 """
3959
3998
3960 textwidth = min(ui.termwidth(), 80) - 2
3999 textwidth = min(ui.termwidth(), 80) - 2
3961
4000
3962 keep = []
4001 keep = []
3963 if ui.verbose:
4002 if ui.verbose:
3964 keep.append('verbose')
4003 keep.append('verbose')
3965 if sys.platform.startswith('win'):
4004 if sys.platform.startswith('win'):
3966 keep.append('windows')
4005 keep.append('windows')
3967 elif sys.platform == 'OpenVMS':
4006 elif sys.platform == 'OpenVMS':
3968 keep.append('vms')
4007 keep.append('vms')
3969 elif sys.platform == 'plan9':
4008 elif sys.platform == 'plan9':
3970 keep.append('plan9')
4009 keep.append('plan9')
3971 else:
4010 else:
3972 keep.append('unix')
4011 keep.append('unix')
3973 keep.append(sys.platform.lower())
4012 keep.append(sys.platform.lower())
3974
4013
3975 section = None
4014 section = None
3976 if name and '.' in name:
4015 if name and '.' in name:
3977 name, section = name.split('.', 1)
4016 name, section = name.split('.', 1)
3978 section = section.lower()
4017 section = section.lower()
3979
4018
3980 text = help.help_(ui, name, **opts)
4019 text = help.help_(ui, name, **opts)
3981
4020
3982 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4021 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3983 section=section)
4022 section=section)
3984 if section and not formatted:
4023 if section and not formatted:
3985 raise util.Abort(_("help section not found"))
4024 raise util.Abort(_("help section not found"))
3986
4025
3987 if 'verbose' in pruned:
4026 if 'verbose' in pruned:
3988 keep.append('omitted')
4027 keep.append('omitted')
3989 else:
4028 else:
3990 keep.append('notomitted')
4029 keep.append('notomitted')
3991 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4030 formatted, pruned = minirst.format(text, textwidth, keep=keep,
3992 section=section)
4031 section=section)
3993 ui.write(formatted)
4032 ui.write(formatted)
3994
4033
3995
4034
3996 @command('identify|id',
4035 @command('identify|id',
3997 [('r', 'rev', '',
4036 [('r', 'rev', '',
3998 _('identify the specified revision'), _('REV')),
4037 _('identify the specified revision'), _('REV')),
3999 ('n', 'num', None, _('show local revision number')),
4038 ('n', 'num', None, _('show local revision number')),
4000 ('i', 'id', None, _('show global revision id')),
4039 ('i', 'id', None, _('show global revision id')),
4001 ('b', 'branch', None, _('show branch')),
4040 ('b', 'branch', None, _('show branch')),
4002 ('t', 'tags', None, _('show tags')),
4041 ('t', 'tags', None, _('show tags')),
4003 ('B', 'bookmarks', None, _('show bookmarks')),
4042 ('B', 'bookmarks', None, _('show bookmarks')),
4004 ] + remoteopts,
4043 ] + remoteopts,
4005 _('[-nibtB] [-r REV] [SOURCE]'),
4044 _('[-nibtB] [-r REV] [SOURCE]'),
4006 optionalrepo=True)
4045 optionalrepo=True)
4007 def identify(ui, repo, source=None, rev=None,
4046 def identify(ui, repo, source=None, rev=None,
4008 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4047 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4009 """identify the working directory or specified revision
4048 """identify the working directory or specified revision
4010
4049
4011 Print a summary identifying the repository state at REV using one or
4050 Print a summary identifying the repository state at REV using one or
4012 two parent hash identifiers, followed by a "+" if the working
4051 two parent hash identifiers, followed by a "+" if the working
4013 directory has uncommitted changes, the branch name (if not default),
4052 directory has uncommitted changes, the branch name (if not default),
4014 a list of tags, and a list of bookmarks.
4053 a list of tags, and a list of bookmarks.
4015
4054
4016 When REV is not given, print a summary of the current state of the
4055 When REV is not given, print a summary of the current state of the
4017 repository.
4056 repository.
4018
4057
4019 Specifying a path to a repository root or Mercurial bundle will
4058 Specifying a path to a repository root or Mercurial bundle will
4020 cause lookup to operate on that repository/bundle.
4059 cause lookup to operate on that repository/bundle.
4021
4060
4022 .. container:: verbose
4061 .. container:: verbose
4023
4062
4024 Examples:
4063 Examples:
4025
4064
4026 - generate a build identifier for the working directory::
4065 - generate a build identifier for the working directory::
4027
4066
4028 hg id --id > build-id.dat
4067 hg id --id > build-id.dat
4029
4068
4030 - find the revision corresponding to a tag::
4069 - find the revision corresponding to a tag::
4031
4070
4032 hg id -n -r 1.3
4071 hg id -n -r 1.3
4033
4072
4034 - check the most recent revision of a remote repository::
4073 - check the most recent revision of a remote repository::
4035
4074
4036 hg id -r tip http://selenic.com/hg/
4075 hg id -r tip http://selenic.com/hg/
4037
4076
4038 Returns 0 if successful.
4077 Returns 0 if successful.
4039 """
4078 """
4040
4079
4041 if not repo and not source:
4080 if not repo and not source:
4042 raise util.Abort(_("there is no Mercurial repository here "
4081 raise util.Abort(_("there is no Mercurial repository here "
4043 "(.hg not found)"))
4082 "(.hg not found)"))
4044
4083
4045 if ui.debugflag:
4084 if ui.debugflag:
4046 hexfunc = hex
4085 hexfunc = hex
4047 else:
4086 else:
4048 hexfunc = short
4087 hexfunc = short
4049 default = not (num or id or branch or tags or bookmarks)
4088 default = not (num or id or branch or tags or bookmarks)
4050 output = []
4089 output = []
4051 revs = []
4090 revs = []
4052
4091
4053 if source:
4092 if source:
4054 source, branches = hg.parseurl(ui.expandpath(source))
4093 source, branches = hg.parseurl(ui.expandpath(source))
4055 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4094 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4056 repo = peer.local()
4095 repo = peer.local()
4057 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4096 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4058
4097
4059 if not repo:
4098 if not repo:
4060 if num or branch or tags:
4099 if num or branch or tags:
4061 raise util.Abort(
4100 raise util.Abort(
4062 _("can't query remote revision number, branch, or tags"))
4101 _("can't query remote revision number, branch, or tags"))
4063 if not rev and revs:
4102 if not rev and revs:
4064 rev = revs[0]
4103 rev = revs[0]
4065 if not rev:
4104 if not rev:
4066 rev = "tip"
4105 rev = "tip"
4067
4106
4068 remoterev = peer.lookup(rev)
4107 remoterev = peer.lookup(rev)
4069 if default or id:
4108 if default or id:
4070 output = [hexfunc(remoterev)]
4109 output = [hexfunc(remoterev)]
4071
4110
4072 def getbms():
4111 def getbms():
4073 bms = []
4112 bms = []
4074
4113
4075 if 'bookmarks' in peer.listkeys('namespaces'):
4114 if 'bookmarks' in peer.listkeys('namespaces'):
4076 hexremoterev = hex(remoterev)
4115 hexremoterev = hex(remoterev)
4077 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4116 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4078 if bmr == hexremoterev]
4117 if bmr == hexremoterev]
4079
4118
4080 return sorted(bms)
4119 return sorted(bms)
4081
4120
4082 if bookmarks:
4121 if bookmarks:
4083 output.extend(getbms())
4122 output.extend(getbms())
4084 elif default and not ui.quiet:
4123 elif default and not ui.quiet:
4085 # multiple bookmarks for a single parent separated by '/'
4124 # multiple bookmarks for a single parent separated by '/'
4086 bm = '/'.join(getbms())
4125 bm = '/'.join(getbms())
4087 if bm:
4126 if bm:
4088 output.append(bm)
4127 output.append(bm)
4089 else:
4128 else:
4090 ctx = scmutil.revsingle(repo, rev, None)
4129 ctx = scmutil.revsingle(repo, rev, None)
4091
4130
4092 if ctx.rev() is None:
4131 if ctx.rev() is None:
4093 ctx = repo[None]
4132 ctx = repo[None]
4094 parents = ctx.parents()
4133 parents = ctx.parents()
4095 taglist = []
4134 taglist = []
4096 for p in parents:
4135 for p in parents:
4097 taglist.extend(p.tags())
4136 taglist.extend(p.tags())
4098
4137
4099 changed = ""
4138 changed = ""
4100 if default or id or num:
4139 if default or id or num:
4101 if (any(repo.status())
4140 if (any(repo.status())
4102 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4141 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4103 changed = '+'
4142 changed = '+'
4104 if default or id:
4143 if default or id:
4105 output = ["%s%s" %
4144 output = ["%s%s" %
4106 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4145 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4107 if num:
4146 if num:
4108 output.append("%s%s" %
4147 output.append("%s%s" %
4109 ('+'.join([str(p.rev()) for p in parents]), changed))
4148 ('+'.join([str(p.rev()) for p in parents]), changed))
4110 else:
4149 else:
4111 if default or id:
4150 if default or id:
4112 output = [hexfunc(ctx.node())]
4151 output = [hexfunc(ctx.node())]
4113 if num:
4152 if num:
4114 output.append(str(ctx.rev()))
4153 output.append(str(ctx.rev()))
4115 taglist = ctx.tags()
4154 taglist = ctx.tags()
4116
4155
4117 if default and not ui.quiet:
4156 if default and not ui.quiet:
4118 b = ctx.branch()
4157 b = ctx.branch()
4119 if b != 'default':
4158 if b != 'default':
4120 output.append("(%s)" % b)
4159 output.append("(%s)" % b)
4121
4160
4122 # multiple tags for a single parent separated by '/'
4161 # multiple tags for a single parent separated by '/'
4123 t = '/'.join(taglist)
4162 t = '/'.join(taglist)
4124 if t:
4163 if t:
4125 output.append(t)
4164 output.append(t)
4126
4165
4127 # multiple bookmarks for a single parent separated by '/'
4166 # multiple bookmarks for a single parent separated by '/'
4128 bm = '/'.join(ctx.bookmarks())
4167 bm = '/'.join(ctx.bookmarks())
4129 if bm:
4168 if bm:
4130 output.append(bm)
4169 output.append(bm)
4131 else:
4170 else:
4132 if branch:
4171 if branch:
4133 output.append(ctx.branch())
4172 output.append(ctx.branch())
4134
4173
4135 if tags:
4174 if tags:
4136 output.extend(taglist)
4175 output.extend(taglist)
4137
4176
4138 if bookmarks:
4177 if bookmarks:
4139 output.extend(ctx.bookmarks())
4178 output.extend(ctx.bookmarks())
4140
4179
4141 ui.write("%s\n" % ' '.join(output))
4180 ui.write("%s\n" % ' '.join(output))
4142
4181
4143 @command('import|patch',
4182 @command('import|patch',
4144 [('p', 'strip', 1,
4183 [('p', 'strip', 1,
4145 _('directory strip option for patch. This has the same '
4184 _('directory strip option for patch. This has the same '
4146 'meaning as the corresponding patch option'), _('NUM')),
4185 'meaning as the corresponding patch option'), _('NUM')),
4147 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4186 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4148 ('e', 'edit', False, _('invoke editor on commit messages')),
4187 ('e', 'edit', False, _('invoke editor on commit messages')),
4149 ('f', 'force', None,
4188 ('f', 'force', None,
4150 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4189 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4151 ('', 'no-commit', None,
4190 ('', 'no-commit', None,
4152 _("don't commit, just update the working directory")),
4191 _("don't commit, just update the working directory")),
4153 ('', 'bypass', None,
4192 ('', 'bypass', None,
4154 _("apply patch without touching the working directory")),
4193 _("apply patch without touching the working directory")),
4155 ('', 'partial', None,
4194 ('', 'partial', None,
4156 _('commit even if some hunks fail')),
4195 _('commit even if some hunks fail')),
4157 ('', 'exact', None,
4196 ('', 'exact', None,
4158 _('apply patch to the nodes from which it was generated')),
4197 _('apply patch to the nodes from which it was generated')),
4159 ('', 'prefix', '',
4198 ('', 'prefix', '',
4160 _('apply patch to subdirectory'), _('DIR')),
4199 _('apply patch to subdirectory'), _('DIR')),
4161 ('', 'import-branch', None,
4200 ('', 'import-branch', None,
4162 _('use any branch information in patch (implied by --exact)'))] +
4201 _('use any branch information in patch (implied by --exact)'))] +
4163 commitopts + commitopts2 + similarityopts,
4202 commitopts + commitopts2 + similarityopts,
4164 _('[OPTION]... PATCH...'))
4203 _('[OPTION]... PATCH...'))
4165 def import_(ui, repo, patch1=None, *patches, **opts):
4204 def import_(ui, repo, patch1=None, *patches, **opts):
4166 """import an ordered set of patches
4205 """import an ordered set of patches
4167
4206
4168 Import a list of patches and commit them individually (unless
4207 Import a list of patches and commit them individually (unless
4169 --no-commit is specified).
4208 --no-commit is specified).
4170
4209
4171 Because import first applies changes to the working directory,
4210 Because import first applies changes to the working directory,
4172 import will abort if there are outstanding changes.
4211 import will abort if there are outstanding changes.
4173
4212
4174 You can import a patch straight from a mail message. Even patches
4213 You can import a patch straight from a mail message. Even patches
4175 as attachments work (to use the body part, it must have type
4214 as attachments work (to use the body part, it must have type
4176 text/plain or text/x-patch). From and Subject headers of email
4215 text/plain or text/x-patch). From and Subject headers of email
4177 message are used as default committer and commit message. All
4216 message are used as default committer and commit message. All
4178 text/plain body parts before first diff are added to commit
4217 text/plain body parts before first diff are added to commit
4179 message.
4218 message.
4180
4219
4181 If the imported patch was generated by :hg:`export`, user and
4220 If the imported patch was generated by :hg:`export`, user and
4182 description from patch override values from message headers and
4221 description from patch override values from message headers and
4183 body. Values given on command line with -m/--message and -u/--user
4222 body. Values given on command line with -m/--message and -u/--user
4184 override these.
4223 override these.
4185
4224
4186 If --exact is specified, import will set the working directory to
4225 If --exact is specified, import will set the working directory to
4187 the parent of each patch before applying it, and will abort if the
4226 the parent of each patch before applying it, and will abort if the
4188 resulting changeset has a different ID than the one recorded in
4227 resulting changeset has a different ID than the one recorded in
4189 the patch. This may happen due to character set problems or other
4228 the patch. This may happen due to character set problems or other
4190 deficiencies in the text patch format.
4229 deficiencies in the text patch format.
4191
4230
4192 Use --bypass to apply and commit patches directly to the
4231 Use --bypass to apply and commit patches directly to the
4193 repository, not touching the working directory. Without --exact,
4232 repository, not touching the working directory. Without --exact,
4194 patches will be applied on top of the working directory parent
4233 patches will be applied on top of the working directory parent
4195 revision.
4234 revision.
4196
4235
4197 With -s/--similarity, hg will attempt to discover renames and
4236 With -s/--similarity, hg will attempt to discover renames and
4198 copies in the patch in the same way as :hg:`addremove`.
4237 copies in the patch in the same way as :hg:`addremove`.
4199
4238
4200 Use --partial to ensure a changeset will be created from the patch
4239 Use --partial to ensure a changeset will be created from the patch
4201 even if some hunks fail to apply. Hunks that fail to apply will be
4240 even if some hunks fail to apply. Hunks that fail to apply will be
4202 written to a <target-file>.rej file. Conflicts can then be resolved
4241 written to a <target-file>.rej file. Conflicts can then be resolved
4203 by hand before :hg:`commit --amend` is run to update the created
4242 by hand before :hg:`commit --amend` is run to update the created
4204 changeset. This flag exists to let people import patches that
4243 changeset. This flag exists to let people import patches that
4205 partially apply without losing the associated metadata (author,
4244 partially apply without losing the associated metadata (author,
4206 date, description, ...). Note that when none of the hunk applies
4245 date, description, ...). Note that when none of the hunk applies
4207 cleanly, :hg:`import --partial` will create an empty changeset,
4246 cleanly, :hg:`import --partial` will create an empty changeset,
4208 importing only the patch metadata.
4247 importing only the patch metadata.
4209
4248
4210 It is possible to use external patch programs to perform the patch
4249 It is possible to use external patch programs to perform the patch
4211 by setting the ``ui.patch`` configuration option. For the default
4250 by setting the ``ui.patch`` configuration option. For the default
4212 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4251 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4213 See :hg:`help config` for more information about configuration
4252 See :hg:`help config` for more information about configuration
4214 files and how to use these options.
4253 files and how to use these options.
4215
4254
4216 To read a patch from standard input, use "-" as the patch name. If
4255 To read a patch from standard input, use "-" as the patch name. If
4217 a URL is specified, the patch will be downloaded from it.
4256 a URL is specified, the patch will be downloaded from it.
4218 See :hg:`help dates` for a list of formats valid for -d/--date.
4257 See :hg:`help dates` for a list of formats valid for -d/--date.
4219
4258
4220 .. container:: verbose
4259 .. container:: verbose
4221
4260
4222 Examples:
4261 Examples:
4223
4262
4224 - import a traditional patch from a website and detect renames::
4263 - import a traditional patch from a website and detect renames::
4225
4264
4226 hg import -s 80 http://example.com/bugfix.patch
4265 hg import -s 80 http://example.com/bugfix.patch
4227
4266
4228 - import a changeset from an hgweb server::
4267 - import a changeset from an hgweb server::
4229
4268
4230 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4269 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4231
4270
4232 - import all the patches in an Unix-style mbox::
4271 - import all the patches in an Unix-style mbox::
4233
4272
4234 hg import incoming-patches.mbox
4273 hg import incoming-patches.mbox
4235
4274
4236 - attempt to exactly restore an exported changeset (not always
4275 - attempt to exactly restore an exported changeset (not always
4237 possible)::
4276 possible)::
4238
4277
4239 hg import --exact proposed-fix.patch
4278 hg import --exact proposed-fix.patch
4240
4279
4241 - use an external tool to apply a patch which is too fuzzy for
4280 - use an external tool to apply a patch which is too fuzzy for
4242 the default internal tool.
4281 the default internal tool.
4243
4282
4244 hg import --config ui.patch="patch --merge" fuzzy.patch
4283 hg import --config ui.patch="patch --merge" fuzzy.patch
4245
4284
4246 - change the default fuzzing from 2 to a less strict 7
4285 - change the default fuzzing from 2 to a less strict 7
4247
4286
4248 hg import --config ui.fuzz=7 fuzz.patch
4287 hg import --config ui.fuzz=7 fuzz.patch
4249
4288
4250 Returns 0 on success, 1 on partial success (see --partial).
4289 Returns 0 on success, 1 on partial success (see --partial).
4251 """
4290 """
4252
4291
4253 if not patch1:
4292 if not patch1:
4254 raise util.Abort(_('need at least one patch to import'))
4293 raise util.Abort(_('need at least one patch to import'))
4255
4294
4256 patches = (patch1,) + patches
4295 patches = (patch1,) + patches
4257
4296
4258 date = opts.get('date')
4297 date = opts.get('date')
4259 if date:
4298 if date:
4260 opts['date'] = util.parsedate(date)
4299 opts['date'] = util.parsedate(date)
4261
4300
4262 update = not opts.get('bypass')
4301 update = not opts.get('bypass')
4263 if not update and opts.get('no_commit'):
4302 if not update and opts.get('no_commit'):
4264 raise util.Abort(_('cannot use --no-commit with --bypass'))
4303 raise util.Abort(_('cannot use --no-commit with --bypass'))
4265 try:
4304 try:
4266 sim = float(opts.get('similarity') or 0)
4305 sim = float(opts.get('similarity') or 0)
4267 except ValueError:
4306 except ValueError:
4268 raise util.Abort(_('similarity must be a number'))
4307 raise util.Abort(_('similarity must be a number'))
4269 if sim < 0 or sim > 100:
4308 if sim < 0 or sim > 100:
4270 raise util.Abort(_('similarity must be between 0 and 100'))
4309 raise util.Abort(_('similarity must be between 0 and 100'))
4271 if sim and not update:
4310 if sim and not update:
4272 raise util.Abort(_('cannot use --similarity with --bypass'))
4311 raise util.Abort(_('cannot use --similarity with --bypass'))
4273 if opts.get('exact') and opts.get('edit'):
4312 if opts.get('exact') and opts.get('edit'):
4274 raise util.Abort(_('cannot use --exact with --edit'))
4313 raise util.Abort(_('cannot use --exact with --edit'))
4275 if opts.get('exact') and opts.get('prefix'):
4314 if opts.get('exact') and opts.get('prefix'):
4276 raise util.Abort(_('cannot use --exact with --prefix'))
4315 raise util.Abort(_('cannot use --exact with --prefix'))
4277
4316
4278 if update:
4317 if update:
4279 cmdutil.checkunfinished(repo)
4318 cmdutil.checkunfinished(repo)
4280 if (opts.get('exact') or not opts.get('force')) and update:
4319 if (opts.get('exact') or not opts.get('force')) and update:
4281 cmdutil.bailifchanged(repo)
4320 cmdutil.bailifchanged(repo)
4282
4321
4283 base = opts["base"]
4322 base = opts["base"]
4284 wlock = dsguard = lock = tr = None
4323 wlock = dsguard = lock = tr = None
4285 msgs = []
4324 msgs = []
4286 ret = 0
4325 ret = 0
4287
4326
4288
4327
4289 try:
4328 try:
4290 try:
4329 try:
4291 wlock = repo.wlock()
4330 wlock = repo.wlock()
4292 dsguard = cmdutil.dirstateguard(repo, 'import')
4331 dsguard = cmdutil.dirstateguard(repo, 'import')
4293 if not opts.get('no_commit'):
4332 if not opts.get('no_commit'):
4294 lock = repo.lock()
4333 lock = repo.lock()
4295 tr = repo.transaction('import')
4334 tr = repo.transaction('import')
4296 parents = repo.parents()
4335 parents = repo.parents()
4297 for patchurl in patches:
4336 for patchurl in patches:
4298 if patchurl == '-':
4337 if patchurl == '-':
4299 ui.status(_('applying patch from stdin\n'))
4338 ui.status(_('applying patch from stdin\n'))
4300 patchfile = ui.fin
4339 patchfile = ui.fin
4301 patchurl = 'stdin' # for error message
4340 patchurl = 'stdin' # for error message
4302 else:
4341 else:
4303 patchurl = os.path.join(base, patchurl)
4342 patchurl = os.path.join(base, patchurl)
4304 ui.status(_('applying %s\n') % patchurl)
4343 ui.status(_('applying %s\n') % patchurl)
4305 patchfile = hg.openpath(ui, patchurl)
4344 patchfile = hg.openpath(ui, patchurl)
4306
4345
4307 haspatch = False
4346 haspatch = False
4308 for hunk in patch.split(patchfile):
4347 for hunk in patch.split(patchfile):
4309 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4348 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4310 parents, opts,
4349 parents, opts,
4311 msgs, hg.clean)
4350 msgs, hg.clean)
4312 if msg:
4351 if msg:
4313 haspatch = True
4352 haspatch = True
4314 ui.note(msg + '\n')
4353 ui.note(msg + '\n')
4315 if update or opts.get('exact'):
4354 if update or opts.get('exact'):
4316 parents = repo.parents()
4355 parents = repo.parents()
4317 else:
4356 else:
4318 parents = [repo[node]]
4357 parents = [repo[node]]
4319 if rej:
4358 if rej:
4320 ui.write_err(_("patch applied partially\n"))
4359 ui.write_err(_("patch applied partially\n"))
4321 ui.write_err(_("(fix the .rej files and run "
4360 ui.write_err(_("(fix the .rej files and run "
4322 "`hg commit --amend`)\n"))
4361 "`hg commit --amend`)\n"))
4323 ret = 1
4362 ret = 1
4324 break
4363 break
4325
4364
4326 if not haspatch:
4365 if not haspatch:
4327 raise util.Abort(_('%s: no diffs found') % patchurl)
4366 raise util.Abort(_('%s: no diffs found') % patchurl)
4328
4367
4329 if tr:
4368 if tr:
4330 tr.close()
4369 tr.close()
4331 if msgs:
4370 if msgs:
4332 repo.savecommitmessage('\n* * *\n'.join(msgs))
4371 repo.savecommitmessage('\n* * *\n'.join(msgs))
4333 dsguard.close()
4372 dsguard.close()
4334 return ret
4373 return ret
4335 finally:
4374 finally:
4336 # TODO: get rid of this meaningless try/finally enclosing.
4375 # TODO: get rid of this meaningless try/finally enclosing.
4337 # this is kept only to reduce changes in a patch.
4376 # this is kept only to reduce changes in a patch.
4338 pass
4377 pass
4339 finally:
4378 finally:
4340 if tr:
4379 if tr:
4341 tr.release()
4380 tr.release()
4342 release(lock, dsguard, wlock)
4381 release(lock, dsguard, wlock)
4343
4382
4344 @command('incoming|in',
4383 @command('incoming|in',
4345 [('f', 'force', None,
4384 [('f', 'force', None,
4346 _('run even if remote repository is unrelated')),
4385 _('run even if remote repository is unrelated')),
4347 ('n', 'newest-first', None, _('show newest record first')),
4386 ('n', 'newest-first', None, _('show newest record first')),
4348 ('', 'bundle', '',
4387 ('', 'bundle', '',
4349 _('file to store the bundles into'), _('FILE')),
4388 _('file to store the bundles into'), _('FILE')),
4350 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4389 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4351 ('B', 'bookmarks', False, _("compare bookmarks")),
4390 ('B', 'bookmarks', False, _("compare bookmarks")),
4352 ('b', 'branch', [],
4391 ('b', 'branch', [],
4353 _('a specific branch you would like to pull'), _('BRANCH')),
4392 _('a specific branch you would like to pull'), _('BRANCH')),
4354 ] + logopts + remoteopts + subrepoopts,
4393 ] + logopts + remoteopts + subrepoopts,
4355 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4394 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4356 def incoming(ui, repo, source="default", **opts):
4395 def incoming(ui, repo, source="default", **opts):
4357 """show new changesets found in source
4396 """show new changesets found in source
4358
4397
4359 Show new changesets found in the specified path/URL or the default
4398 Show new changesets found in the specified path/URL or the default
4360 pull location. These are the changesets that would have been pulled
4399 pull location. These are the changesets that would have been pulled
4361 if a pull at the time you issued this command.
4400 if a pull at the time you issued this command.
4362
4401
4363 See pull for valid source format details.
4402 See pull for valid source format details.
4364
4403
4365 .. container:: verbose
4404 .. container:: verbose
4366
4405
4367 With -B/--bookmarks, the result of bookmark comparison between
4406 With -B/--bookmarks, the result of bookmark comparison between
4368 local and remote repositories is displayed. With -v/--verbose,
4407 local and remote repositories is displayed. With -v/--verbose,
4369 status is also displayed for each bookmark like below::
4408 status is also displayed for each bookmark like below::
4370
4409
4371 BM1 01234567890a added
4410 BM1 01234567890a added
4372 BM2 1234567890ab advanced
4411 BM2 1234567890ab advanced
4373 BM3 234567890abc diverged
4412 BM3 234567890abc diverged
4374 BM4 34567890abcd changed
4413 BM4 34567890abcd changed
4375
4414
4376 The action taken locally when pulling depends on the
4415 The action taken locally when pulling depends on the
4377 status of each bookmark:
4416 status of each bookmark:
4378
4417
4379 :``added``: pull will create it
4418 :``added``: pull will create it
4380 :``advanced``: pull will update it
4419 :``advanced``: pull will update it
4381 :``diverged``: pull will create a divergent bookmark
4420 :``diverged``: pull will create a divergent bookmark
4382 :``changed``: result depends on remote changesets
4421 :``changed``: result depends on remote changesets
4383
4422
4384 From the point of view of pulling behavior, bookmark
4423 From the point of view of pulling behavior, bookmark
4385 existing only in the remote repository are treated as ``added``,
4424 existing only in the remote repository are treated as ``added``,
4386 even if it is in fact locally deleted.
4425 even if it is in fact locally deleted.
4387
4426
4388 .. container:: verbose
4427 .. container:: verbose
4389
4428
4390 For remote repository, using --bundle avoids downloading the
4429 For remote repository, using --bundle avoids downloading the
4391 changesets twice if the incoming is followed by a pull.
4430 changesets twice if the incoming is followed by a pull.
4392
4431
4393 Examples:
4432 Examples:
4394
4433
4395 - show incoming changes with patches and full description::
4434 - show incoming changes with patches and full description::
4396
4435
4397 hg incoming -vp
4436 hg incoming -vp
4398
4437
4399 - show incoming changes excluding merges, store a bundle::
4438 - show incoming changes excluding merges, store a bundle::
4400
4439
4401 hg in -vpM --bundle incoming.hg
4440 hg in -vpM --bundle incoming.hg
4402 hg pull incoming.hg
4441 hg pull incoming.hg
4403
4442
4404 - briefly list changes inside a bundle::
4443 - briefly list changes inside a bundle::
4405
4444
4406 hg in changes.hg -T "{desc|firstline}\\n"
4445 hg in changes.hg -T "{desc|firstline}\\n"
4407
4446
4408 Returns 0 if there are incoming changes, 1 otherwise.
4447 Returns 0 if there are incoming changes, 1 otherwise.
4409 """
4448 """
4410 if opts.get('graph'):
4449 if opts.get('graph'):
4411 cmdutil.checkunsupportedgraphflags([], opts)
4450 cmdutil.checkunsupportedgraphflags([], opts)
4412 def display(other, chlist, displayer):
4451 def display(other, chlist, displayer):
4413 revdag = cmdutil.graphrevs(other, chlist, opts)
4452 revdag = cmdutil.graphrevs(other, chlist, opts)
4414 showparents = [ctx.node() for ctx in repo[None].parents()]
4453 showparents = [ctx.node() for ctx in repo[None].parents()]
4415 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4454 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4416 graphmod.asciiedges)
4455 graphmod.asciiedges)
4417
4456
4418 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4457 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4419 return 0
4458 return 0
4420
4459
4421 if opts.get('bundle') and opts.get('subrepos'):
4460 if opts.get('bundle') and opts.get('subrepos'):
4422 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4461 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4423
4462
4424 if opts.get('bookmarks'):
4463 if opts.get('bookmarks'):
4425 source, branches = hg.parseurl(ui.expandpath(source),
4464 source, branches = hg.parseurl(ui.expandpath(source),
4426 opts.get('branch'))
4465 opts.get('branch'))
4427 other = hg.peer(repo, opts, source)
4466 other = hg.peer(repo, opts, source)
4428 if 'bookmarks' not in other.listkeys('namespaces'):
4467 if 'bookmarks' not in other.listkeys('namespaces'):
4429 ui.warn(_("remote doesn't support bookmarks\n"))
4468 ui.warn(_("remote doesn't support bookmarks\n"))
4430 return 0
4469 return 0
4431 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4470 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4432 return bookmarks.incoming(ui, repo, other)
4471 return bookmarks.incoming(ui, repo, other)
4433
4472
4434 repo._subtoppath = ui.expandpath(source)
4473 repo._subtoppath = ui.expandpath(source)
4435 try:
4474 try:
4436 return hg.incoming(ui, repo, source, opts)
4475 return hg.incoming(ui, repo, source, opts)
4437 finally:
4476 finally:
4438 del repo._subtoppath
4477 del repo._subtoppath
4439
4478
4440
4479
4441 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4480 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4442 norepo=True)
4481 norepo=True)
4443 def init(ui, dest=".", **opts):
4482 def init(ui, dest=".", **opts):
4444 """create a new repository in the given directory
4483 """create a new repository in the given directory
4445
4484
4446 Initialize a new repository in the given directory. If the given
4485 Initialize a new repository in the given directory. If the given
4447 directory does not exist, it will be created.
4486 directory does not exist, it will be created.
4448
4487
4449 If no directory is given, the current directory is used.
4488 If no directory is given, the current directory is used.
4450
4489
4451 It is possible to specify an ``ssh://`` URL as the destination.
4490 It is possible to specify an ``ssh://`` URL as the destination.
4452 See :hg:`help urls` for more information.
4491 See :hg:`help urls` for more information.
4453
4492
4454 Returns 0 on success.
4493 Returns 0 on success.
4455 """
4494 """
4456 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4495 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4457
4496
4458 @command('locate',
4497 @command('locate',
4459 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4498 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4460 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4499 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4461 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4500 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4462 ] + walkopts,
4501 ] + walkopts,
4463 _('[OPTION]... [PATTERN]...'))
4502 _('[OPTION]... [PATTERN]...'))
4464 def locate(ui, repo, *pats, **opts):
4503 def locate(ui, repo, *pats, **opts):
4465 """locate files matching specific patterns (DEPRECATED)
4504 """locate files matching specific patterns (DEPRECATED)
4466
4505
4467 Print files under Mercurial control in the working directory whose
4506 Print files under Mercurial control in the working directory whose
4468 names match the given patterns.
4507 names match the given patterns.
4469
4508
4470 By default, this command searches all directories in the working
4509 By default, this command searches all directories in the working
4471 directory. To search just the current directory and its
4510 directory. To search just the current directory and its
4472 subdirectories, use "--include .".
4511 subdirectories, use "--include .".
4473
4512
4474 If no patterns are given to match, this command prints the names
4513 If no patterns are given to match, this command prints the names
4475 of all files under Mercurial control in the working directory.
4514 of all files under Mercurial control in the working directory.
4476
4515
4477 If you want to feed the output of this command into the "xargs"
4516 If you want to feed the output of this command into the "xargs"
4478 command, use the -0 option to both this command and "xargs". This
4517 command, use the -0 option to both this command and "xargs". This
4479 will avoid the problem of "xargs" treating single filenames that
4518 will avoid the problem of "xargs" treating single filenames that
4480 contain whitespace as multiple filenames.
4519 contain whitespace as multiple filenames.
4481
4520
4482 See :hg:`help files` for a more versatile command.
4521 See :hg:`help files` for a more versatile command.
4483
4522
4484 Returns 0 if a match is found, 1 otherwise.
4523 Returns 0 if a match is found, 1 otherwise.
4485 """
4524 """
4486 if opts.get('print0'):
4525 if opts.get('print0'):
4487 end = '\0'
4526 end = '\0'
4488 else:
4527 else:
4489 end = '\n'
4528 end = '\n'
4490 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4529 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4491
4530
4492 ret = 1
4531 ret = 1
4493 ctx = repo[rev]
4532 ctx = repo[rev]
4494 m = scmutil.match(ctx, pats, opts, default='relglob',
4533 m = scmutil.match(ctx, pats, opts, default='relglob',
4495 badfn=lambda x, y: False)
4534 badfn=lambda x, y: False)
4496
4535
4497 for abs in ctx.matches(m):
4536 for abs in ctx.matches(m):
4498 if opts.get('fullpath'):
4537 if opts.get('fullpath'):
4499 ui.write(repo.wjoin(abs), end)
4538 ui.write(repo.wjoin(abs), end)
4500 else:
4539 else:
4501 ui.write(((pats and m.rel(abs)) or abs), end)
4540 ui.write(((pats and m.rel(abs)) or abs), end)
4502 ret = 0
4541 ret = 0
4503
4542
4504 return ret
4543 return ret
4505
4544
4506 @command('^log|history',
4545 @command('^log|history',
4507 [('f', 'follow', None,
4546 [('f', 'follow', None,
4508 _('follow changeset history, or file history across copies and renames')),
4547 _('follow changeset history, or file history across copies and renames')),
4509 ('', 'follow-first', None,
4548 ('', 'follow-first', None,
4510 _('only follow the first parent of merge changesets (DEPRECATED)')),
4549 _('only follow the first parent of merge changesets (DEPRECATED)')),
4511 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4550 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4512 ('C', 'copies', None, _('show copied files')),
4551 ('C', 'copies', None, _('show copied files')),
4513 ('k', 'keyword', [],
4552 ('k', 'keyword', [],
4514 _('do case-insensitive search for a given text'), _('TEXT')),
4553 _('do case-insensitive search for a given text'), _('TEXT')),
4515 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4554 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4516 ('', 'removed', None, _('include revisions where files were removed')),
4555 ('', 'removed', None, _('include revisions where files were removed')),
4517 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4556 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4518 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4557 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4519 ('', 'only-branch', [],
4558 ('', 'only-branch', [],
4520 _('show only changesets within the given named branch (DEPRECATED)'),
4559 _('show only changesets within the given named branch (DEPRECATED)'),
4521 _('BRANCH')),
4560 _('BRANCH')),
4522 ('b', 'branch', [],
4561 ('b', 'branch', [],
4523 _('show changesets within the given named branch'), _('BRANCH')),
4562 _('show changesets within the given named branch'), _('BRANCH')),
4524 ('P', 'prune', [],
4563 ('P', 'prune', [],
4525 _('do not display revision or any of its ancestors'), _('REV')),
4564 _('do not display revision or any of its ancestors'), _('REV')),
4526 ] + logopts + walkopts,
4565 ] + logopts + walkopts,
4527 _('[OPTION]... [FILE]'),
4566 _('[OPTION]... [FILE]'),
4528 inferrepo=True)
4567 inferrepo=True)
4529 def log(ui, repo, *pats, **opts):
4568 def log(ui, repo, *pats, **opts):
4530 """show revision history of entire repository or files
4569 """show revision history of entire repository or files
4531
4570
4532 Print the revision history of the specified files or the entire
4571 Print the revision history of the specified files or the entire
4533 project.
4572 project.
4534
4573
4535 If no revision range is specified, the default is ``tip:0`` unless
4574 If no revision range is specified, the default is ``tip:0`` unless
4536 --follow is set, in which case the working directory parent is
4575 --follow is set, in which case the working directory parent is
4537 used as the starting revision.
4576 used as the starting revision.
4538
4577
4539 File history is shown without following rename or copy history of
4578 File history is shown without following rename or copy history of
4540 files. Use -f/--follow with a filename to follow history across
4579 files. Use -f/--follow with a filename to follow history across
4541 renames and copies. --follow without a filename will only show
4580 renames and copies. --follow without a filename will only show
4542 ancestors or descendants of the starting revision.
4581 ancestors or descendants of the starting revision.
4543
4582
4544 By default this command prints revision number and changeset id,
4583 By default this command prints revision number and changeset id,
4545 tags, non-trivial parents, user, date and time, and a summary for
4584 tags, non-trivial parents, user, date and time, and a summary for
4546 each commit. When the -v/--verbose switch is used, the list of
4585 each commit. When the -v/--verbose switch is used, the list of
4547 changed files and full commit message are shown.
4586 changed files and full commit message are shown.
4548
4587
4549 With --graph the revisions are shown as an ASCII art DAG with the most
4588 With --graph the revisions are shown as an ASCII art DAG with the most
4550 recent changeset at the top.
4589 recent changeset at the top.
4551 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4590 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4552 and '+' represents a fork where the changeset from the lines below is a
4591 and '+' represents a fork where the changeset from the lines below is a
4553 parent of the 'o' merge on the same line.
4592 parent of the 'o' merge on the same line.
4554
4593
4555 .. note::
4594 .. note::
4556
4595
4557 log -p/--patch may generate unexpected diff output for merge
4596 log -p/--patch may generate unexpected diff output for merge
4558 changesets, as it will only compare the merge changeset against
4597 changesets, as it will only compare the merge changeset against
4559 its first parent. Also, only files different from BOTH parents
4598 its first parent. Also, only files different from BOTH parents
4560 will appear in files:.
4599 will appear in files:.
4561
4600
4562 .. note::
4601 .. note::
4563
4602
4564 for performance reasons, log FILE may omit duplicate changes
4603 for performance reasons, log FILE may omit duplicate changes
4565 made on branches and will not show removals or mode changes. To
4604 made on branches and will not show removals or mode changes. To
4566 see all such changes, use the --removed switch.
4605 see all such changes, use the --removed switch.
4567
4606
4568 .. container:: verbose
4607 .. container:: verbose
4569
4608
4570 Some examples:
4609 Some examples:
4571
4610
4572 - changesets with full descriptions and file lists::
4611 - changesets with full descriptions and file lists::
4573
4612
4574 hg log -v
4613 hg log -v
4575
4614
4576 - changesets ancestral to the working directory::
4615 - changesets ancestral to the working directory::
4577
4616
4578 hg log -f
4617 hg log -f
4579
4618
4580 - last 10 commits on the current branch::
4619 - last 10 commits on the current branch::
4581
4620
4582 hg log -l 10 -b .
4621 hg log -l 10 -b .
4583
4622
4584 - changesets showing all modifications of a file, including removals::
4623 - changesets showing all modifications of a file, including removals::
4585
4624
4586 hg log --removed file.c
4625 hg log --removed file.c
4587
4626
4588 - all changesets that touch a directory, with diffs, excluding merges::
4627 - all changesets that touch a directory, with diffs, excluding merges::
4589
4628
4590 hg log -Mp lib/
4629 hg log -Mp lib/
4591
4630
4592 - all revision numbers that match a keyword::
4631 - all revision numbers that match a keyword::
4593
4632
4594 hg log -k bug --template "{rev}\\n"
4633 hg log -k bug --template "{rev}\\n"
4595
4634
4596 - list available log templates::
4635 - list available log templates::
4597
4636
4598 hg log -T list
4637 hg log -T list
4599
4638
4600 - check if a given changeset is included in a tagged release::
4639 - check if a given changeset is included in a tagged release::
4601
4640
4602 hg log -r "a21ccf and ancestor(1.9)"
4641 hg log -r "a21ccf and ancestor(1.9)"
4603
4642
4604 - find all changesets by some user in a date range::
4643 - find all changesets by some user in a date range::
4605
4644
4606 hg log -k alice -d "may 2008 to jul 2008"
4645 hg log -k alice -d "may 2008 to jul 2008"
4607
4646
4608 - summary of all changesets after the last tag::
4647 - summary of all changesets after the last tag::
4609
4648
4610 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4649 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4611
4650
4612 See :hg:`help dates` for a list of formats valid for -d/--date.
4651 See :hg:`help dates` for a list of formats valid for -d/--date.
4613
4652
4614 See :hg:`help revisions` and :hg:`help revsets` for more about
4653 See :hg:`help revisions` and :hg:`help revsets` for more about
4615 specifying revisions.
4654 specifying revisions.
4616
4655
4617 See :hg:`help templates` for more about pre-packaged styles and
4656 See :hg:`help templates` for more about pre-packaged styles and
4618 specifying custom templates.
4657 specifying custom templates.
4619
4658
4620 Returns 0 on success.
4659 Returns 0 on success.
4621
4660
4622 """
4661 """
4623 if opts.get('follow') and opts.get('rev'):
4662 if opts.get('follow') and opts.get('rev'):
4624 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4663 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4625 del opts['follow']
4664 del opts['follow']
4626
4665
4627 if opts.get('graph'):
4666 if opts.get('graph'):
4628 return cmdutil.graphlog(ui, repo, *pats, **opts)
4667 return cmdutil.graphlog(ui, repo, *pats, **opts)
4629
4668
4630 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4669 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4631 limit = cmdutil.loglimit(opts)
4670 limit = cmdutil.loglimit(opts)
4632 count = 0
4671 count = 0
4633
4672
4634 getrenamed = None
4673 getrenamed = None
4635 if opts.get('copies'):
4674 if opts.get('copies'):
4636 endrev = None
4675 endrev = None
4637 if opts.get('rev'):
4676 if opts.get('rev'):
4638 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4677 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4639 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4678 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4640
4679
4641 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4680 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4642 for rev in revs:
4681 for rev in revs:
4643 if count == limit:
4682 if count == limit:
4644 break
4683 break
4645 ctx = repo[rev]
4684 ctx = repo[rev]
4646 copies = None
4685 copies = None
4647 if getrenamed is not None and rev:
4686 if getrenamed is not None and rev:
4648 copies = []
4687 copies = []
4649 for fn in ctx.files():
4688 for fn in ctx.files():
4650 rename = getrenamed(fn, rev)
4689 rename = getrenamed(fn, rev)
4651 if rename:
4690 if rename:
4652 copies.append((fn, rename[0]))
4691 copies.append((fn, rename[0]))
4653 if filematcher:
4692 if filematcher:
4654 revmatchfn = filematcher(ctx.rev())
4693 revmatchfn = filematcher(ctx.rev())
4655 else:
4694 else:
4656 revmatchfn = None
4695 revmatchfn = None
4657 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4696 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4658 if displayer.flush(ctx):
4697 if displayer.flush(ctx):
4659 count += 1
4698 count += 1
4660
4699
4661 displayer.close()
4700 displayer.close()
4662
4701
4663 @command('manifest',
4702 @command('manifest',
4664 [('r', 'rev', '', _('revision to display'), _('REV')),
4703 [('r', 'rev', '', _('revision to display'), _('REV')),
4665 ('', 'all', False, _("list files from all revisions"))]
4704 ('', 'all', False, _("list files from all revisions"))]
4666 + formatteropts,
4705 + formatteropts,
4667 _('[-r REV]'))
4706 _('[-r REV]'))
4668 def manifest(ui, repo, node=None, rev=None, **opts):
4707 def manifest(ui, repo, node=None, rev=None, **opts):
4669 """output the current or given revision of the project manifest
4708 """output the current or given revision of the project manifest
4670
4709
4671 Print a list of version controlled files for the given revision.
4710 Print a list of version controlled files for the given revision.
4672 If no revision is given, the first parent of the working directory
4711 If no revision is given, the first parent of the working directory
4673 is used, or the null revision if no revision is checked out.
4712 is used, or the null revision if no revision is checked out.
4674
4713
4675 With -v, print file permissions, symlink and executable bits.
4714 With -v, print file permissions, symlink and executable bits.
4676 With --debug, print file revision hashes.
4715 With --debug, print file revision hashes.
4677
4716
4678 If option --all is specified, the list of all files from all revisions
4717 If option --all is specified, the list of all files from all revisions
4679 is printed. This includes deleted and renamed files.
4718 is printed. This includes deleted and renamed files.
4680
4719
4681 Returns 0 on success.
4720 Returns 0 on success.
4682 """
4721 """
4683
4722
4684 fm = ui.formatter('manifest', opts)
4723 fm = ui.formatter('manifest', opts)
4685
4724
4686 if opts.get('all'):
4725 if opts.get('all'):
4687 if rev or node:
4726 if rev or node:
4688 raise util.Abort(_("can't specify a revision with --all"))
4727 raise util.Abort(_("can't specify a revision with --all"))
4689
4728
4690 res = []
4729 res = []
4691 prefix = "data/"
4730 prefix = "data/"
4692 suffix = ".i"
4731 suffix = ".i"
4693 plen = len(prefix)
4732 plen = len(prefix)
4694 slen = len(suffix)
4733 slen = len(suffix)
4695 lock = repo.lock()
4734 lock = repo.lock()
4696 try:
4735 try:
4697 for fn, b, size in repo.store.datafiles():
4736 for fn, b, size in repo.store.datafiles():
4698 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4737 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4699 res.append(fn[plen:-slen])
4738 res.append(fn[plen:-slen])
4700 finally:
4739 finally:
4701 lock.release()
4740 lock.release()
4702 for f in res:
4741 for f in res:
4703 fm.startitem()
4742 fm.startitem()
4704 fm.write("path", '%s\n', f)
4743 fm.write("path", '%s\n', f)
4705 fm.end()
4744 fm.end()
4706 return
4745 return
4707
4746
4708 if rev and node:
4747 if rev and node:
4709 raise util.Abort(_("please specify just one revision"))
4748 raise util.Abort(_("please specify just one revision"))
4710
4749
4711 if not node:
4750 if not node:
4712 node = rev
4751 node = rev
4713
4752
4714 char = {'l': '@', 'x': '*', '': ''}
4753 char = {'l': '@', 'x': '*', '': ''}
4715 mode = {'l': '644', 'x': '755', '': '644'}
4754 mode = {'l': '644', 'x': '755', '': '644'}
4716 ctx = scmutil.revsingle(repo, node)
4755 ctx = scmutil.revsingle(repo, node)
4717 mf = ctx.manifest()
4756 mf = ctx.manifest()
4718 for f in ctx:
4757 for f in ctx:
4719 fm.startitem()
4758 fm.startitem()
4720 fl = ctx[f].flags()
4759 fl = ctx[f].flags()
4721 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4760 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4722 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4761 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4723 fm.write('path', '%s\n', f)
4762 fm.write('path', '%s\n', f)
4724 fm.end()
4763 fm.end()
4725
4764
4726 @command('^merge',
4765 @command('^merge',
4727 [('f', 'force', None,
4766 [('f', 'force', None,
4728 _('force a merge including outstanding changes (DEPRECATED)')),
4767 _('force a merge including outstanding changes (DEPRECATED)')),
4729 ('r', 'rev', '', _('revision to merge'), _('REV')),
4768 ('r', 'rev', '', _('revision to merge'), _('REV')),
4730 ('P', 'preview', None,
4769 ('P', 'preview', None,
4731 _('review revisions to merge (no merge is performed)'))
4770 _('review revisions to merge (no merge is performed)'))
4732 ] + mergetoolopts,
4771 ] + mergetoolopts,
4733 _('[-P] [-f] [[-r] REV]'))
4772 _('[-P] [-f] [[-r] REV]'))
4734 def merge(ui, repo, node=None, **opts):
4773 def merge(ui, repo, node=None, **opts):
4735 """merge another revision into working directory
4774 """merge another revision into working directory
4736
4775
4737 The current working directory is updated with all changes made in
4776 The current working directory is updated with all changes made in
4738 the requested revision since the last common predecessor revision.
4777 the requested revision since the last common predecessor revision.
4739
4778
4740 Files that changed between either parent are marked as changed for
4779 Files that changed between either parent are marked as changed for
4741 the next commit and a commit must be performed before any further
4780 the next commit and a commit must be performed before any further
4742 updates to the repository are allowed. The next commit will have
4781 updates to the repository are allowed. The next commit will have
4743 two parents.
4782 two parents.
4744
4783
4745 ``--tool`` can be used to specify the merge tool used for file
4784 ``--tool`` can be used to specify the merge tool used for file
4746 merges. It overrides the HGMERGE environment variable and your
4785 merges. It overrides the HGMERGE environment variable and your
4747 configuration files. See :hg:`help merge-tools` for options.
4786 configuration files. See :hg:`help merge-tools` for options.
4748
4787
4749 If no revision is specified, the working directory's parent is a
4788 If no revision is specified, the working directory's parent is a
4750 head revision, and the current branch contains exactly one other
4789 head revision, and the current branch contains exactly one other
4751 head, the other head is merged with by default. Otherwise, an
4790 head, the other head is merged with by default. Otherwise, an
4752 explicit revision with which to merge with must be provided.
4791 explicit revision with which to merge with must be provided.
4753
4792
4754 :hg:`resolve` must be used to resolve unresolved files.
4793 :hg:`resolve` must be used to resolve unresolved files.
4755
4794
4756 To undo an uncommitted merge, use :hg:`update --clean .` which
4795 To undo an uncommitted merge, use :hg:`update --clean .` which
4757 will check out a clean copy of the original merge parent, losing
4796 will check out a clean copy of the original merge parent, losing
4758 all changes.
4797 all changes.
4759
4798
4760 Returns 0 on success, 1 if there are unresolved files.
4799 Returns 0 on success, 1 if there are unresolved files.
4761 """
4800 """
4762
4801
4763 if opts.get('rev') and node:
4802 if opts.get('rev') and node:
4764 raise util.Abort(_("please specify just one revision"))
4803 raise util.Abort(_("please specify just one revision"))
4765 if not node:
4804 if not node:
4766 node = opts.get('rev')
4805 node = opts.get('rev')
4767
4806
4768 if node:
4807 if node:
4769 node = scmutil.revsingle(repo, node).node()
4808 node = scmutil.revsingle(repo, node).node()
4770
4809
4771 if not node:
4810 if not node:
4772 node = scmutil.revsingle(repo, '_mergedefaultdest()').node()
4811 node = scmutil.revsingle(repo, '_mergedefaultdest()').node()
4773
4812
4774 if opts.get('preview'):
4813 if opts.get('preview'):
4775 # find nodes that are ancestors of p2 but not of p1
4814 # find nodes that are ancestors of p2 but not of p1
4776 p1 = repo.lookup('.')
4815 p1 = repo.lookup('.')
4777 p2 = repo.lookup(node)
4816 p2 = repo.lookup(node)
4778 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4817 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4779
4818
4780 displayer = cmdutil.show_changeset(ui, repo, opts)
4819 displayer = cmdutil.show_changeset(ui, repo, opts)
4781 for node in nodes:
4820 for node in nodes:
4782 displayer.show(repo[node])
4821 displayer.show(repo[node])
4783 displayer.close()
4822 displayer.close()
4784 return 0
4823 return 0
4785
4824
4786 try:
4825 try:
4787 # ui.forcemerge is an internal variable, do not document
4826 # ui.forcemerge is an internal variable, do not document
4788 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4827 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4789 return hg.merge(repo, node, force=opts.get('force'))
4828 return hg.merge(repo, node, force=opts.get('force'))
4790 finally:
4829 finally:
4791 ui.setconfig('ui', 'forcemerge', '', 'merge')
4830 ui.setconfig('ui', 'forcemerge', '', 'merge')
4792
4831
4793 @command('outgoing|out',
4832 @command('outgoing|out',
4794 [('f', 'force', None, _('run even when the destination is unrelated')),
4833 [('f', 'force', None, _('run even when the destination is unrelated')),
4795 ('r', 'rev', [],
4834 ('r', 'rev', [],
4796 _('a changeset intended to be included in the destination'), _('REV')),
4835 _('a changeset intended to be included in the destination'), _('REV')),
4797 ('n', 'newest-first', None, _('show newest record first')),
4836 ('n', 'newest-first', None, _('show newest record first')),
4798 ('B', 'bookmarks', False, _('compare bookmarks')),
4837 ('B', 'bookmarks', False, _('compare bookmarks')),
4799 ('b', 'branch', [], _('a specific branch you would like to push'),
4838 ('b', 'branch', [], _('a specific branch you would like to push'),
4800 _('BRANCH')),
4839 _('BRANCH')),
4801 ] + logopts + remoteopts + subrepoopts,
4840 ] + logopts + remoteopts + subrepoopts,
4802 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4841 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4803 def outgoing(ui, repo, dest=None, **opts):
4842 def outgoing(ui, repo, dest=None, **opts):
4804 """show changesets not found in the destination
4843 """show changesets not found in the destination
4805
4844
4806 Show changesets not found in the specified destination repository
4845 Show changesets not found in the specified destination repository
4807 or the default push location. These are the changesets that would
4846 or the default push location. These are the changesets that would
4808 be pushed if a push was requested.
4847 be pushed if a push was requested.
4809
4848
4810 See pull for details of valid destination formats.
4849 See pull for details of valid destination formats.
4811
4850
4812 .. container:: verbose
4851 .. container:: verbose
4813
4852
4814 With -B/--bookmarks, the result of bookmark comparison between
4853 With -B/--bookmarks, the result of bookmark comparison between
4815 local and remote repositories is displayed. With -v/--verbose,
4854 local and remote repositories is displayed. With -v/--verbose,
4816 status is also displayed for each bookmark like below::
4855 status is also displayed for each bookmark like below::
4817
4856
4818 BM1 01234567890a added
4857 BM1 01234567890a added
4819 BM2 deleted
4858 BM2 deleted
4820 BM3 234567890abc advanced
4859 BM3 234567890abc advanced
4821 BM4 34567890abcd diverged
4860 BM4 34567890abcd diverged
4822 BM5 4567890abcde changed
4861 BM5 4567890abcde changed
4823
4862
4824 The action taken when pushing depends on the
4863 The action taken when pushing depends on the
4825 status of each bookmark:
4864 status of each bookmark:
4826
4865
4827 :``added``: push with ``-B`` will create it
4866 :``added``: push with ``-B`` will create it
4828 :``deleted``: push with ``-B`` will delete it
4867 :``deleted``: push with ``-B`` will delete it
4829 :``advanced``: push will update it
4868 :``advanced``: push will update it
4830 :``diverged``: push with ``-B`` will update it
4869 :``diverged``: push with ``-B`` will update it
4831 :``changed``: push with ``-B`` will update it
4870 :``changed``: push with ``-B`` will update it
4832
4871
4833 From the point of view of pushing behavior, bookmarks
4872 From the point of view of pushing behavior, bookmarks
4834 existing only in the remote repository are treated as
4873 existing only in the remote repository are treated as
4835 ``deleted``, even if it is in fact added remotely.
4874 ``deleted``, even if it is in fact added remotely.
4836
4875
4837 Returns 0 if there are outgoing changes, 1 otherwise.
4876 Returns 0 if there are outgoing changes, 1 otherwise.
4838 """
4877 """
4839 if opts.get('graph'):
4878 if opts.get('graph'):
4840 cmdutil.checkunsupportedgraphflags([], opts)
4879 cmdutil.checkunsupportedgraphflags([], opts)
4841 o, other = hg._outgoing(ui, repo, dest, opts)
4880 o, other = hg._outgoing(ui, repo, dest, opts)
4842 if not o:
4881 if not o:
4843 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4882 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4844 return
4883 return
4845
4884
4846 revdag = cmdutil.graphrevs(repo, o, opts)
4885 revdag = cmdutil.graphrevs(repo, o, opts)
4847 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4886 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4848 showparents = [ctx.node() for ctx in repo[None].parents()]
4887 showparents = [ctx.node() for ctx in repo[None].parents()]
4849 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4888 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4850 graphmod.asciiedges)
4889 graphmod.asciiedges)
4851 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4890 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4852 return 0
4891 return 0
4853
4892
4854 if opts.get('bookmarks'):
4893 if opts.get('bookmarks'):
4855 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4894 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4856 dest, branches = hg.parseurl(dest, opts.get('branch'))
4895 dest, branches = hg.parseurl(dest, opts.get('branch'))
4857 other = hg.peer(repo, opts, dest)
4896 other = hg.peer(repo, opts, dest)
4858 if 'bookmarks' not in other.listkeys('namespaces'):
4897 if 'bookmarks' not in other.listkeys('namespaces'):
4859 ui.warn(_("remote doesn't support bookmarks\n"))
4898 ui.warn(_("remote doesn't support bookmarks\n"))
4860 return 0
4899 return 0
4861 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4900 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4862 return bookmarks.outgoing(ui, repo, other)
4901 return bookmarks.outgoing(ui, repo, other)
4863
4902
4864 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4903 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4865 try:
4904 try:
4866 return hg.outgoing(ui, repo, dest, opts)
4905 return hg.outgoing(ui, repo, dest, opts)
4867 finally:
4906 finally:
4868 del repo._subtoppath
4907 del repo._subtoppath
4869
4908
4870 @command('parents',
4909 @command('parents',
4871 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4910 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4872 ] + templateopts,
4911 ] + templateopts,
4873 _('[-r REV] [FILE]'),
4912 _('[-r REV] [FILE]'),
4874 inferrepo=True)
4913 inferrepo=True)
4875 def parents(ui, repo, file_=None, **opts):
4914 def parents(ui, repo, file_=None, **opts):
4876 """show the parents of the working directory or revision (DEPRECATED)
4915 """show the parents of the working directory or revision (DEPRECATED)
4877
4916
4878 Print the working directory's parent revisions. If a revision is
4917 Print the working directory's parent revisions. If a revision is
4879 given via -r/--rev, the parent of that revision will be printed.
4918 given via -r/--rev, the parent of that revision will be printed.
4880 If a file argument is given, the revision in which the file was
4919 If a file argument is given, the revision in which the file was
4881 last changed (before the working directory revision or the
4920 last changed (before the working directory revision or the
4882 argument to --rev if given) is printed.
4921 argument to --rev if given) is printed.
4883
4922
4884 See :hg:`summary` and :hg:`help revsets` for related information.
4923 See :hg:`summary` and :hg:`help revsets` for related information.
4885
4924
4886 Returns 0 on success.
4925 Returns 0 on success.
4887 """
4926 """
4888
4927
4889 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4928 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4890
4929
4891 if file_:
4930 if file_:
4892 m = scmutil.match(ctx, (file_,), opts)
4931 m = scmutil.match(ctx, (file_,), opts)
4893 if m.anypats() or len(m.files()) != 1:
4932 if m.anypats() or len(m.files()) != 1:
4894 raise util.Abort(_('can only specify an explicit filename'))
4933 raise util.Abort(_('can only specify an explicit filename'))
4895 file_ = m.files()[0]
4934 file_ = m.files()[0]
4896 filenodes = []
4935 filenodes = []
4897 for cp in ctx.parents():
4936 for cp in ctx.parents():
4898 if not cp:
4937 if not cp:
4899 continue
4938 continue
4900 try:
4939 try:
4901 filenodes.append(cp.filenode(file_))
4940 filenodes.append(cp.filenode(file_))
4902 except error.LookupError:
4941 except error.LookupError:
4903 pass
4942 pass
4904 if not filenodes:
4943 if not filenodes:
4905 raise util.Abort(_("'%s' not found in manifest!") % file_)
4944 raise util.Abort(_("'%s' not found in manifest!") % file_)
4906 p = []
4945 p = []
4907 for fn in filenodes:
4946 for fn in filenodes:
4908 fctx = repo.filectx(file_, fileid=fn)
4947 fctx = repo.filectx(file_, fileid=fn)
4909 p.append(fctx.node())
4948 p.append(fctx.node())
4910 else:
4949 else:
4911 p = [cp.node() for cp in ctx.parents()]
4950 p = [cp.node() for cp in ctx.parents()]
4912
4951
4913 displayer = cmdutil.show_changeset(ui, repo, opts)
4952 displayer = cmdutil.show_changeset(ui, repo, opts)
4914 for n in p:
4953 for n in p:
4915 if n != nullid:
4954 if n != nullid:
4916 displayer.show(repo[n])
4955 displayer.show(repo[n])
4917 displayer.close()
4956 displayer.close()
4918
4957
4919 @command('paths', [], _('[NAME]'), optionalrepo=True)
4958 @command('paths', [], _('[NAME]'), optionalrepo=True)
4920 def paths(ui, repo, search=None):
4959 def paths(ui, repo, search=None):
4921 """show aliases for remote repositories
4960 """show aliases for remote repositories
4922
4961
4923 Show definition of symbolic path name NAME. If no name is given,
4962 Show definition of symbolic path name NAME. If no name is given,
4924 show definition of all available names.
4963 show definition of all available names.
4925
4964
4926 Option -q/--quiet suppresses all output when searching for NAME
4965 Option -q/--quiet suppresses all output when searching for NAME
4927 and shows only the path names when listing all definitions.
4966 and shows only the path names when listing all definitions.
4928
4967
4929 Path names are defined in the [paths] section of your
4968 Path names are defined in the [paths] section of your
4930 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4969 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4931 repository, ``.hg/hgrc`` is used, too.
4970 repository, ``.hg/hgrc`` is used, too.
4932
4971
4933 The path names ``default`` and ``default-push`` have a special
4972 The path names ``default`` and ``default-push`` have a special
4934 meaning. When performing a push or pull operation, they are used
4973 meaning. When performing a push or pull operation, they are used
4935 as fallbacks if no location is specified on the command-line.
4974 as fallbacks if no location is specified on the command-line.
4936 When ``default-push`` is set, it will be used for push and
4975 When ``default-push`` is set, it will be used for push and
4937 ``default`` will be used for pull; otherwise ``default`` is used
4976 ``default`` will be used for pull; otherwise ``default`` is used
4938 as the fallback for both. When cloning a repository, the clone
4977 as the fallback for both. When cloning a repository, the clone
4939 source is written as ``default`` in ``.hg/hgrc``. Note that
4978 source is written as ``default`` in ``.hg/hgrc``. Note that
4940 ``default`` and ``default-push`` apply to all inbound (e.g.
4979 ``default`` and ``default-push`` apply to all inbound (e.g.
4941 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4980 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4942 :hg:`bundle`) operations.
4981 :hg:`bundle`) operations.
4943
4982
4944 See :hg:`help urls` for more information.
4983 See :hg:`help urls` for more information.
4945
4984
4946 Returns 0 on success.
4985 Returns 0 on success.
4947 """
4986 """
4948 if search:
4987 if search:
4949 for name, path in sorted(ui.paths.iteritems()):
4988 for name, path in sorted(ui.paths.iteritems()):
4950 if name == search:
4989 if name == search:
4951 ui.status("%s\n" % util.hidepassword(path.loc))
4990 ui.status("%s\n" % util.hidepassword(path.loc))
4952 return
4991 return
4953 if not ui.quiet:
4992 if not ui.quiet:
4954 ui.warn(_("not found!\n"))
4993 ui.warn(_("not found!\n"))
4955 return 1
4994 return 1
4956 else:
4995 else:
4957 for name, path in sorted(ui.paths.iteritems()):
4996 for name, path in sorted(ui.paths.iteritems()):
4958 if ui.quiet:
4997 if ui.quiet:
4959 ui.write("%s\n" % name)
4998 ui.write("%s\n" % name)
4960 else:
4999 else:
4961 ui.write("%s = %s\n" % (name,
5000 ui.write("%s = %s\n" % (name,
4962 util.hidepassword(path.loc)))
5001 util.hidepassword(path.loc)))
4963
5002
4964 @command('phase',
5003 @command('phase',
4965 [('p', 'public', False, _('set changeset phase to public')),
5004 [('p', 'public', False, _('set changeset phase to public')),
4966 ('d', 'draft', False, _('set changeset phase to draft')),
5005 ('d', 'draft', False, _('set changeset phase to draft')),
4967 ('s', 'secret', False, _('set changeset phase to secret')),
5006 ('s', 'secret', False, _('set changeset phase to secret')),
4968 ('f', 'force', False, _('allow to move boundary backward')),
5007 ('f', 'force', False, _('allow to move boundary backward')),
4969 ('r', 'rev', [], _('target revision'), _('REV')),
5008 ('r', 'rev', [], _('target revision'), _('REV')),
4970 ],
5009 ],
4971 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5010 _('[-p|-d|-s] [-f] [-r] [REV...]'))
4972 def phase(ui, repo, *revs, **opts):
5011 def phase(ui, repo, *revs, **opts):
4973 """set or show the current phase name
5012 """set or show the current phase name
4974
5013
4975 With no argument, show the phase name of the current revision(s).
5014 With no argument, show the phase name of the current revision(s).
4976
5015
4977 With one of -p/--public, -d/--draft or -s/--secret, change the
5016 With one of -p/--public, -d/--draft or -s/--secret, change the
4978 phase value of the specified revisions.
5017 phase value of the specified revisions.
4979
5018
4980 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5019 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4981 lower phase to an higher phase. Phases are ordered as follows::
5020 lower phase to an higher phase. Phases are ordered as follows::
4982
5021
4983 public < draft < secret
5022 public < draft < secret
4984
5023
4985 Returns 0 on success, 1 if no phases were changed or some could not
5024 Returns 0 on success, 1 if no phases were changed or some could not
4986 be changed.
5025 be changed.
4987
5026
4988 (For more information about the phases concept, see :hg:`help phases`.)
5027 (For more information about the phases concept, see :hg:`help phases`.)
4989 """
5028 """
4990 # search for a unique phase argument
5029 # search for a unique phase argument
4991 targetphase = None
5030 targetphase = None
4992 for idx, name in enumerate(phases.phasenames):
5031 for idx, name in enumerate(phases.phasenames):
4993 if opts[name]:
5032 if opts[name]:
4994 if targetphase is not None:
5033 if targetphase is not None:
4995 raise util.Abort(_('only one phase can be specified'))
5034 raise util.Abort(_('only one phase can be specified'))
4996 targetphase = idx
5035 targetphase = idx
4997
5036
4998 # look for specified revision
5037 # look for specified revision
4999 revs = list(revs)
5038 revs = list(revs)
5000 revs.extend(opts['rev'])
5039 revs.extend(opts['rev'])
5001 if not revs:
5040 if not revs:
5002 # display both parents as the second parent phase can influence
5041 # display both parents as the second parent phase can influence
5003 # the phase of a merge commit
5042 # the phase of a merge commit
5004 revs = [c.rev() for c in repo[None].parents()]
5043 revs = [c.rev() for c in repo[None].parents()]
5005
5044
5006 revs = scmutil.revrange(repo, revs)
5045 revs = scmutil.revrange(repo, revs)
5007
5046
5008 lock = None
5047 lock = None
5009 ret = 0
5048 ret = 0
5010 if targetphase is None:
5049 if targetphase is None:
5011 # display
5050 # display
5012 for r in revs:
5051 for r in revs:
5013 ctx = repo[r]
5052 ctx = repo[r]
5014 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5053 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5015 else:
5054 else:
5016 tr = None
5055 tr = None
5017 lock = repo.lock()
5056 lock = repo.lock()
5018 try:
5057 try:
5019 tr = repo.transaction("phase")
5058 tr = repo.transaction("phase")
5020 # set phase
5059 # set phase
5021 if not revs:
5060 if not revs:
5022 raise util.Abort(_('empty revision set'))
5061 raise util.Abort(_('empty revision set'))
5023 nodes = [repo[r].node() for r in revs]
5062 nodes = [repo[r].node() for r in revs]
5024 # moving revision from public to draft may hide them
5063 # moving revision from public to draft may hide them
5025 # We have to check result on an unfiltered repository
5064 # We have to check result on an unfiltered repository
5026 unfi = repo.unfiltered()
5065 unfi = repo.unfiltered()
5027 getphase = unfi._phasecache.phase
5066 getphase = unfi._phasecache.phase
5028 olddata = [getphase(unfi, r) for r in unfi]
5067 olddata = [getphase(unfi, r) for r in unfi]
5029 phases.advanceboundary(repo, tr, targetphase, nodes)
5068 phases.advanceboundary(repo, tr, targetphase, nodes)
5030 if opts['force']:
5069 if opts['force']:
5031 phases.retractboundary(repo, tr, targetphase, nodes)
5070 phases.retractboundary(repo, tr, targetphase, nodes)
5032 tr.close()
5071 tr.close()
5033 finally:
5072 finally:
5034 if tr is not None:
5073 if tr is not None:
5035 tr.release()
5074 tr.release()
5036 lock.release()
5075 lock.release()
5037 getphase = unfi._phasecache.phase
5076 getphase = unfi._phasecache.phase
5038 newdata = [getphase(unfi, r) for r in unfi]
5077 newdata = [getphase(unfi, r) for r in unfi]
5039 changes = sum(newdata[r] != olddata[r] for r in unfi)
5078 changes = sum(newdata[r] != olddata[r] for r in unfi)
5040 cl = unfi.changelog
5079 cl = unfi.changelog
5041 rejected = [n for n in nodes
5080 rejected = [n for n in nodes
5042 if newdata[cl.rev(n)] < targetphase]
5081 if newdata[cl.rev(n)] < targetphase]
5043 if rejected:
5082 if rejected:
5044 ui.warn(_('cannot move %i changesets to a higher '
5083 ui.warn(_('cannot move %i changesets to a higher '
5045 'phase, use --force\n') % len(rejected))
5084 'phase, use --force\n') % len(rejected))
5046 ret = 1
5085 ret = 1
5047 if changes:
5086 if changes:
5048 msg = _('phase changed for %i changesets\n') % changes
5087 msg = _('phase changed for %i changesets\n') % changes
5049 if ret:
5088 if ret:
5050 ui.status(msg)
5089 ui.status(msg)
5051 else:
5090 else:
5052 ui.note(msg)
5091 ui.note(msg)
5053 else:
5092 else:
5054 ui.warn(_('no phases changed\n'))
5093 ui.warn(_('no phases changed\n'))
5055 ret = 1
5094 ret = 1
5056 return ret
5095 return ret
5057
5096
5058 def postincoming(ui, repo, modheads, optupdate, checkout):
5097 def postincoming(ui, repo, modheads, optupdate, checkout):
5059 if modheads == 0:
5098 if modheads == 0:
5060 return
5099 return
5061 if optupdate:
5100 if optupdate:
5062 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5101 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5063 try:
5102 try:
5064 ret = hg.update(repo, checkout)
5103 ret = hg.update(repo, checkout)
5065 except util.Abort as inst:
5104 except util.Abort as inst:
5066 ui.warn(_("not updating: %s\n") % str(inst))
5105 ui.warn(_("not updating: %s\n") % str(inst))
5067 if inst.hint:
5106 if inst.hint:
5068 ui.warn(_("(%s)\n") % inst.hint)
5107 ui.warn(_("(%s)\n") % inst.hint)
5069 return 0
5108 return 0
5070 if not ret and not checkout:
5109 if not ret and not checkout:
5071 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5110 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5072 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5111 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5073 return ret
5112 return ret
5074 if modheads > 1:
5113 if modheads > 1:
5075 currentbranchheads = len(repo.branchheads())
5114 currentbranchheads = len(repo.branchheads())
5076 if currentbranchheads == modheads:
5115 if currentbranchheads == modheads:
5077 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5116 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5078 elif currentbranchheads > 1:
5117 elif currentbranchheads > 1:
5079 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5118 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5080 "merge)\n"))
5119 "merge)\n"))
5081 else:
5120 else:
5082 ui.status(_("(run 'hg heads' to see heads)\n"))
5121 ui.status(_("(run 'hg heads' to see heads)\n"))
5083 else:
5122 else:
5084 ui.status(_("(run 'hg update' to get a working copy)\n"))
5123 ui.status(_("(run 'hg update' to get a working copy)\n"))
5085
5124
5086 @command('^pull',
5125 @command('^pull',
5087 [('u', 'update', None,
5126 [('u', 'update', None,
5088 _('update to new branch head if changesets were pulled')),
5127 _('update to new branch head if changesets were pulled')),
5089 ('f', 'force', None, _('run even when remote repository is unrelated')),
5128 ('f', 'force', None, _('run even when remote repository is unrelated')),
5090 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5129 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5091 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5130 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5092 ('b', 'branch', [], _('a specific branch you would like to pull'),
5131 ('b', 'branch', [], _('a specific branch you would like to pull'),
5093 _('BRANCH')),
5132 _('BRANCH')),
5094 ] + remoteopts,
5133 ] + remoteopts,
5095 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5134 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5096 def pull(ui, repo, source="default", **opts):
5135 def pull(ui, repo, source="default", **opts):
5097 """pull changes from the specified source
5136 """pull changes from the specified source
5098
5137
5099 Pull changes from a remote repository to a local one.
5138 Pull changes from a remote repository to a local one.
5100
5139
5101 This finds all changes from the repository at the specified path
5140 This finds all changes from the repository at the specified path
5102 or URL and adds them to a local repository (the current one unless
5141 or URL and adds them to a local repository (the current one unless
5103 -R is specified). By default, this does not update the copy of the
5142 -R is specified). By default, this does not update the copy of the
5104 project in the working directory.
5143 project in the working directory.
5105
5144
5106 Use :hg:`incoming` if you want to see what would have been added
5145 Use :hg:`incoming` if you want to see what would have been added
5107 by a pull at the time you issued this command. If you then decide
5146 by a pull at the time you issued this command. If you then decide
5108 to add those changes to the repository, you should use :hg:`pull
5147 to add those changes to the repository, you should use :hg:`pull
5109 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5148 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5110
5149
5111 If SOURCE is omitted, the 'default' path will be used.
5150 If SOURCE is omitted, the 'default' path will be used.
5112 See :hg:`help urls` for more information.
5151 See :hg:`help urls` for more information.
5113
5152
5114 Returns 0 on success, 1 if an update had unresolved files.
5153 Returns 0 on success, 1 if an update had unresolved files.
5115 """
5154 """
5116 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5155 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5117 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5156 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5118 other = hg.peer(repo, opts, source)
5157 other = hg.peer(repo, opts, source)
5119 try:
5158 try:
5120 revs, checkout = hg.addbranchrevs(repo, other, branches,
5159 revs, checkout = hg.addbranchrevs(repo, other, branches,
5121 opts.get('rev'))
5160 opts.get('rev'))
5122
5161
5123
5162
5124 pullopargs = {}
5163 pullopargs = {}
5125 if opts.get('bookmark'):
5164 if opts.get('bookmark'):
5126 if not revs:
5165 if not revs:
5127 revs = []
5166 revs = []
5128 # The list of bookmark used here is not the one used to actually
5167 # The list of bookmark used here is not the one used to actually
5129 # update the bookmark name. This can result in the revision pulled
5168 # update the bookmark name. This can result in the revision pulled
5130 # not ending up with the name of the bookmark because of a race
5169 # not ending up with the name of the bookmark because of a race
5131 # condition on the server. (See issue 4689 for details)
5170 # condition on the server. (See issue 4689 for details)
5132 remotebookmarks = other.listkeys('bookmarks')
5171 remotebookmarks = other.listkeys('bookmarks')
5133 pullopargs['remotebookmarks'] = remotebookmarks
5172 pullopargs['remotebookmarks'] = remotebookmarks
5134 for b in opts['bookmark']:
5173 for b in opts['bookmark']:
5135 if b not in remotebookmarks:
5174 if b not in remotebookmarks:
5136 raise util.Abort(_('remote bookmark %s not found!') % b)
5175 raise util.Abort(_('remote bookmark %s not found!') % b)
5137 revs.append(remotebookmarks[b])
5176 revs.append(remotebookmarks[b])
5138
5177
5139 if revs:
5178 if revs:
5140 try:
5179 try:
5141 # When 'rev' is a bookmark name, we cannot guarantee that it
5180 # When 'rev' is a bookmark name, we cannot guarantee that it
5142 # will be updated with that name because of a race condition
5181 # will be updated with that name because of a race condition
5143 # server side. (See issue 4689 for details)
5182 # server side. (See issue 4689 for details)
5144 oldrevs = revs
5183 oldrevs = revs
5145 revs = [] # actually, nodes
5184 revs = [] # actually, nodes
5146 for r in oldrevs:
5185 for r in oldrevs:
5147 node = other.lookup(r)
5186 node = other.lookup(r)
5148 revs.append(node)
5187 revs.append(node)
5149 if r == checkout:
5188 if r == checkout:
5150 checkout = node
5189 checkout = node
5151 except error.CapabilityError:
5190 except error.CapabilityError:
5152 err = _("other repository doesn't support revision lookup, "
5191 err = _("other repository doesn't support revision lookup, "
5153 "so a rev cannot be specified.")
5192 "so a rev cannot be specified.")
5154 raise util.Abort(err)
5193 raise util.Abort(err)
5155
5194
5156 modheads = exchange.pull(repo, other, heads=revs,
5195 modheads = exchange.pull(repo, other, heads=revs,
5157 force=opts.get('force'),
5196 force=opts.get('force'),
5158 bookmarks=opts.get('bookmark', ()),
5197 bookmarks=opts.get('bookmark', ()),
5159 opargs=pullopargs).cgresult
5198 opargs=pullopargs).cgresult
5160 if checkout:
5199 if checkout:
5161 checkout = str(repo.changelog.rev(checkout))
5200 checkout = str(repo.changelog.rev(checkout))
5162 repo._subtoppath = source
5201 repo._subtoppath = source
5163 try:
5202 try:
5164 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5203 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5165
5204
5166 finally:
5205 finally:
5167 del repo._subtoppath
5206 del repo._subtoppath
5168
5207
5169 finally:
5208 finally:
5170 other.close()
5209 other.close()
5171 return ret
5210 return ret
5172
5211
5173 @command('^push',
5212 @command('^push',
5174 [('f', 'force', None, _('force push')),
5213 [('f', 'force', None, _('force push')),
5175 ('r', 'rev', [],
5214 ('r', 'rev', [],
5176 _('a changeset intended to be included in the destination'),
5215 _('a changeset intended to be included in the destination'),
5177 _('REV')),
5216 _('REV')),
5178 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5217 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5179 ('b', 'branch', [],
5218 ('b', 'branch', [],
5180 _('a specific branch you would like to push'), _('BRANCH')),
5219 _('a specific branch you would like to push'), _('BRANCH')),
5181 ('', 'new-branch', False, _('allow pushing a new branch')),
5220 ('', 'new-branch', False, _('allow pushing a new branch')),
5182 ] + remoteopts,
5221 ] + remoteopts,
5183 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5222 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5184 def push(ui, repo, dest=None, **opts):
5223 def push(ui, repo, dest=None, **opts):
5185 """push changes to the specified destination
5224 """push changes to the specified destination
5186
5225
5187 Push changesets from the local repository to the specified
5226 Push changesets from the local repository to the specified
5188 destination.
5227 destination.
5189
5228
5190 This operation is symmetrical to pull: it is identical to a pull
5229 This operation is symmetrical to pull: it is identical to a pull
5191 in the destination repository from the current one.
5230 in the destination repository from the current one.
5192
5231
5193 By default, push will not allow creation of new heads at the
5232 By default, push will not allow creation of new heads at the
5194 destination, since multiple heads would make it unclear which head
5233 destination, since multiple heads would make it unclear which head
5195 to use. In this situation, it is recommended to pull and merge
5234 to use. In this situation, it is recommended to pull and merge
5196 before pushing.
5235 before pushing.
5197
5236
5198 Use --new-branch if you want to allow push to create a new named
5237 Use --new-branch if you want to allow push to create a new named
5199 branch that is not present at the destination. This allows you to
5238 branch that is not present at the destination. This allows you to
5200 only create a new branch without forcing other changes.
5239 only create a new branch without forcing other changes.
5201
5240
5202 .. note::
5241 .. note::
5203
5242
5204 Extra care should be taken with the -f/--force option,
5243 Extra care should be taken with the -f/--force option,
5205 which will push all new heads on all branches, an action which will
5244 which will push all new heads on all branches, an action which will
5206 almost always cause confusion for collaborators.
5245 almost always cause confusion for collaborators.
5207
5246
5208 If -r/--rev is used, the specified revision and all its ancestors
5247 If -r/--rev is used, the specified revision and all its ancestors
5209 will be pushed to the remote repository.
5248 will be pushed to the remote repository.
5210
5249
5211 If -B/--bookmark is used, the specified bookmarked revision, its
5250 If -B/--bookmark is used, the specified bookmarked revision, its
5212 ancestors, and the bookmark will be pushed to the remote
5251 ancestors, and the bookmark will be pushed to the remote
5213 repository.
5252 repository.
5214
5253
5215 Please see :hg:`help urls` for important details about ``ssh://``
5254 Please see :hg:`help urls` for important details about ``ssh://``
5216 URLs. If DESTINATION is omitted, a default path will be used.
5255 URLs. If DESTINATION is omitted, a default path will be used.
5217
5256
5218 Returns 0 if push was successful, 1 if nothing to push.
5257 Returns 0 if push was successful, 1 if nothing to push.
5219 """
5258 """
5220
5259
5221 if opts.get('bookmark'):
5260 if opts.get('bookmark'):
5222 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5261 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5223 for b in opts['bookmark']:
5262 for b in opts['bookmark']:
5224 # translate -B options to -r so changesets get pushed
5263 # translate -B options to -r so changesets get pushed
5225 if b in repo._bookmarks:
5264 if b in repo._bookmarks:
5226 opts.setdefault('rev', []).append(b)
5265 opts.setdefault('rev', []).append(b)
5227 else:
5266 else:
5228 # if we try to push a deleted bookmark, translate it to null
5267 # if we try to push a deleted bookmark, translate it to null
5229 # this lets simultaneous -r, -b options continue working
5268 # this lets simultaneous -r, -b options continue working
5230 opts.setdefault('rev', []).append("null")
5269 opts.setdefault('rev', []).append("null")
5231
5270
5232 path = ui.paths.getpath(dest, default='default')
5271 path = ui.paths.getpath(dest, default='default')
5233 if not path:
5272 if not path:
5234 raise util.Abort(_('default repository not configured!'),
5273 raise util.Abort(_('default repository not configured!'),
5235 hint=_('see the "path" section in "hg help config"'))
5274 hint=_('see the "path" section in "hg help config"'))
5236 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5275 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5237 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5276 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5238 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5277 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5239 other = hg.peer(repo, opts, dest)
5278 other = hg.peer(repo, opts, dest)
5240
5279
5241 if revs:
5280 if revs:
5242 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5281 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5243 if not revs:
5282 if not revs:
5244 raise util.Abort(_("specified revisions evaluate to an empty set"),
5283 raise util.Abort(_("specified revisions evaluate to an empty set"),
5245 hint=_("use different revision arguments"))
5284 hint=_("use different revision arguments"))
5246
5285
5247 repo._subtoppath = dest
5286 repo._subtoppath = dest
5248 try:
5287 try:
5249 # push subrepos depth-first for coherent ordering
5288 # push subrepos depth-first for coherent ordering
5250 c = repo['']
5289 c = repo['']
5251 subs = c.substate # only repos that are committed
5290 subs = c.substate # only repos that are committed
5252 for s in sorted(subs):
5291 for s in sorted(subs):
5253 result = c.sub(s).push(opts)
5292 result = c.sub(s).push(opts)
5254 if result == 0:
5293 if result == 0:
5255 return not result
5294 return not result
5256 finally:
5295 finally:
5257 del repo._subtoppath
5296 del repo._subtoppath
5258 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5297 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5259 newbranch=opts.get('new_branch'),
5298 newbranch=opts.get('new_branch'),
5260 bookmarks=opts.get('bookmark', ()))
5299 bookmarks=opts.get('bookmark', ()))
5261
5300
5262 result = not pushop.cgresult
5301 result = not pushop.cgresult
5263
5302
5264 if pushop.bkresult is not None:
5303 if pushop.bkresult is not None:
5265 if pushop.bkresult == 2:
5304 if pushop.bkresult == 2:
5266 result = 2
5305 result = 2
5267 elif not result and pushop.bkresult:
5306 elif not result and pushop.bkresult:
5268 result = 2
5307 result = 2
5269
5308
5270 return result
5309 return result
5271
5310
5272 @command('recover', [])
5311 @command('recover', [])
5273 def recover(ui, repo):
5312 def recover(ui, repo):
5274 """roll back an interrupted transaction
5313 """roll back an interrupted transaction
5275
5314
5276 Recover from an interrupted commit or pull.
5315 Recover from an interrupted commit or pull.
5277
5316
5278 This command tries to fix the repository status after an
5317 This command tries to fix the repository status after an
5279 interrupted operation. It should only be necessary when Mercurial
5318 interrupted operation. It should only be necessary when Mercurial
5280 suggests it.
5319 suggests it.
5281
5320
5282 Returns 0 if successful, 1 if nothing to recover or verify fails.
5321 Returns 0 if successful, 1 if nothing to recover or verify fails.
5283 """
5322 """
5284 if repo.recover():
5323 if repo.recover():
5285 return hg.verify(repo)
5324 return hg.verify(repo)
5286 return 1
5325 return 1
5287
5326
5288 @command('^remove|rm',
5327 @command('^remove|rm',
5289 [('A', 'after', None, _('record delete for missing files')),
5328 [('A', 'after', None, _('record delete for missing files')),
5290 ('f', 'force', None,
5329 ('f', 'force', None,
5291 _('remove (and delete) file even if added or modified')),
5330 _('remove (and delete) file even if added or modified')),
5292 ] + subrepoopts + walkopts,
5331 ] + subrepoopts + walkopts,
5293 _('[OPTION]... FILE...'),
5332 _('[OPTION]... FILE...'),
5294 inferrepo=True)
5333 inferrepo=True)
5295 def remove(ui, repo, *pats, **opts):
5334 def remove(ui, repo, *pats, **opts):
5296 """remove the specified files on the next commit
5335 """remove the specified files on the next commit
5297
5336
5298 Schedule the indicated files for removal from the current branch.
5337 Schedule the indicated files for removal from the current branch.
5299
5338
5300 This command schedules the files to be removed at the next commit.
5339 This command schedules the files to be removed at the next commit.
5301 To undo a remove before that, see :hg:`revert`. To undo added
5340 To undo a remove before that, see :hg:`revert`. To undo added
5302 files, see :hg:`forget`.
5341 files, see :hg:`forget`.
5303
5342
5304 .. container:: verbose
5343 .. container:: verbose
5305
5344
5306 -A/--after can be used to remove only files that have already
5345 -A/--after can be used to remove only files that have already
5307 been deleted, -f/--force can be used to force deletion, and -Af
5346 been deleted, -f/--force can be used to force deletion, and -Af
5308 can be used to remove files from the next revision without
5347 can be used to remove files from the next revision without
5309 deleting them from the working directory.
5348 deleting them from the working directory.
5310
5349
5311 The following table details the behavior of remove for different
5350 The following table details the behavior of remove for different
5312 file states (columns) and option combinations (rows). The file
5351 file states (columns) and option combinations (rows). The file
5313 states are Added [A], Clean [C], Modified [M] and Missing [!]
5352 states are Added [A], Clean [C], Modified [M] and Missing [!]
5314 (as reported by :hg:`status`). The actions are Warn, Remove
5353 (as reported by :hg:`status`). The actions are Warn, Remove
5315 (from branch) and Delete (from disk):
5354 (from branch) and Delete (from disk):
5316
5355
5317 ========= == == == ==
5356 ========= == == == ==
5318 opt/state A C M !
5357 opt/state A C M !
5319 ========= == == == ==
5358 ========= == == == ==
5320 none W RD W R
5359 none W RD W R
5321 -f R RD RD R
5360 -f R RD RD R
5322 -A W W W R
5361 -A W W W R
5323 -Af R R R R
5362 -Af R R R R
5324 ========= == == == ==
5363 ========= == == == ==
5325
5364
5326 Note that remove never deletes files in Added [A] state from the
5365 Note that remove never deletes files in Added [A] state from the
5327 working directory, not even if option --force is specified.
5366 working directory, not even if option --force is specified.
5328
5367
5329 Returns 0 on success, 1 if any warnings encountered.
5368 Returns 0 on success, 1 if any warnings encountered.
5330 """
5369 """
5331
5370
5332 after, force = opts.get('after'), opts.get('force')
5371 after, force = opts.get('after'), opts.get('force')
5333 if not pats and not after:
5372 if not pats and not after:
5334 raise util.Abort(_('no files specified'))
5373 raise util.Abort(_('no files specified'))
5335
5374
5336 m = scmutil.match(repo[None], pats, opts)
5375 m = scmutil.match(repo[None], pats, opts)
5337 subrepos = opts.get('subrepos')
5376 subrepos = opts.get('subrepos')
5338 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5377 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5339
5378
5340 @command('rename|move|mv',
5379 @command('rename|move|mv',
5341 [('A', 'after', None, _('record a rename that has already occurred')),
5380 [('A', 'after', None, _('record a rename that has already occurred')),
5342 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5381 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5343 ] + walkopts + dryrunopts,
5382 ] + walkopts + dryrunopts,
5344 _('[OPTION]... SOURCE... DEST'))
5383 _('[OPTION]... SOURCE... DEST'))
5345 def rename(ui, repo, *pats, **opts):
5384 def rename(ui, repo, *pats, **opts):
5346 """rename files; equivalent of copy + remove
5385 """rename files; equivalent of copy + remove
5347
5386
5348 Mark dest as copies of sources; mark sources for deletion. If dest
5387 Mark dest as copies of sources; mark sources for deletion. If dest
5349 is a directory, copies are put in that directory. If dest is a
5388 is a directory, copies are put in that directory. If dest is a
5350 file, there can only be one source.
5389 file, there can only be one source.
5351
5390
5352 By default, this command copies the contents of files as they
5391 By default, this command copies the contents of files as they
5353 exist in the working directory. If invoked with -A/--after, the
5392 exist in the working directory. If invoked with -A/--after, the
5354 operation is recorded, but no copying is performed.
5393 operation is recorded, but no copying is performed.
5355
5394
5356 This command takes effect at the next commit. To undo a rename
5395 This command takes effect at the next commit. To undo a rename
5357 before that, see :hg:`revert`.
5396 before that, see :hg:`revert`.
5358
5397
5359 Returns 0 on success, 1 if errors are encountered.
5398 Returns 0 on success, 1 if errors are encountered.
5360 """
5399 """
5361 wlock = repo.wlock(False)
5400 wlock = repo.wlock(False)
5362 try:
5401 try:
5363 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5402 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5364 finally:
5403 finally:
5365 wlock.release()
5404 wlock.release()
5366
5405
5367 @command('resolve',
5406 @command('resolve',
5368 [('a', 'all', None, _('select all unresolved files')),
5407 [('a', 'all', None, _('select all unresolved files')),
5369 ('l', 'list', None, _('list state of files needing merge')),
5408 ('l', 'list', None, _('list state of files needing merge')),
5370 ('m', 'mark', None, _('mark files as resolved')),
5409 ('m', 'mark', None, _('mark files as resolved')),
5371 ('u', 'unmark', None, _('mark files as unresolved')),
5410 ('u', 'unmark', None, _('mark files as unresolved')),
5372 ('n', 'no-status', None, _('hide status prefix'))]
5411 ('n', 'no-status', None, _('hide status prefix'))]
5373 + mergetoolopts + walkopts + formatteropts,
5412 + mergetoolopts + walkopts + formatteropts,
5374 _('[OPTION]... [FILE]...'),
5413 _('[OPTION]... [FILE]...'),
5375 inferrepo=True)
5414 inferrepo=True)
5376 def resolve(ui, repo, *pats, **opts):
5415 def resolve(ui, repo, *pats, **opts):
5377 """redo merges or set/view the merge status of files
5416 """redo merges or set/view the merge status of files
5378
5417
5379 Merges with unresolved conflicts are often the result of
5418 Merges with unresolved conflicts are often the result of
5380 non-interactive merging using the ``internal:merge`` configuration
5419 non-interactive merging using the ``internal:merge`` configuration
5381 setting, or a command-line merge tool like ``diff3``. The resolve
5420 setting, or a command-line merge tool like ``diff3``. The resolve
5382 command is used to manage the files involved in a merge, after
5421 command is used to manage the files involved in a merge, after
5383 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5422 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5384 working directory must have two parents). See :hg:`help
5423 working directory must have two parents). See :hg:`help
5385 merge-tools` for information on configuring merge tools.
5424 merge-tools` for information on configuring merge tools.
5386
5425
5387 The resolve command can be used in the following ways:
5426 The resolve command can be used in the following ways:
5388
5427
5389 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5428 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5390 files, discarding any previous merge attempts. Re-merging is not
5429 files, discarding any previous merge attempts. Re-merging is not
5391 performed for files already marked as resolved. Use ``--all/-a``
5430 performed for files already marked as resolved. Use ``--all/-a``
5392 to select all unresolved files. ``--tool`` can be used to specify
5431 to select all unresolved files. ``--tool`` can be used to specify
5393 the merge tool used for the given files. It overrides the HGMERGE
5432 the merge tool used for the given files. It overrides the HGMERGE
5394 environment variable and your configuration files. Previous file
5433 environment variable and your configuration files. Previous file
5395 contents are saved with a ``.orig`` suffix.
5434 contents are saved with a ``.orig`` suffix.
5396
5435
5397 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5436 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5398 (e.g. after having manually fixed-up the files). The default is
5437 (e.g. after having manually fixed-up the files). The default is
5399 to mark all unresolved files.
5438 to mark all unresolved files.
5400
5439
5401 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5440 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5402 default is to mark all resolved files.
5441 default is to mark all resolved files.
5403
5442
5404 - :hg:`resolve -l`: list files which had or still have conflicts.
5443 - :hg:`resolve -l`: list files which had or still have conflicts.
5405 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5444 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5406
5445
5407 Note that Mercurial will not let you commit files with unresolved
5446 Note that Mercurial will not let you commit files with unresolved
5408 merge conflicts. You must use :hg:`resolve -m ...` before you can
5447 merge conflicts. You must use :hg:`resolve -m ...` before you can
5409 commit after a conflicting merge.
5448 commit after a conflicting merge.
5410
5449
5411 Returns 0 on success, 1 if any files fail a resolve attempt.
5450 Returns 0 on success, 1 if any files fail a resolve attempt.
5412 """
5451 """
5413
5452
5414 all, mark, unmark, show, nostatus = \
5453 all, mark, unmark, show, nostatus = \
5415 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5454 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5416
5455
5417 if (show and (mark or unmark)) or (mark and unmark):
5456 if (show and (mark or unmark)) or (mark and unmark):
5418 raise util.Abort(_("too many options specified"))
5457 raise util.Abort(_("too many options specified"))
5419 if pats and all:
5458 if pats and all:
5420 raise util.Abort(_("can't specify --all and patterns"))
5459 raise util.Abort(_("can't specify --all and patterns"))
5421 if not (all or pats or show or mark or unmark):
5460 if not (all or pats or show or mark or unmark):
5422 raise util.Abort(_('no files or directories specified'),
5461 raise util.Abort(_('no files or directories specified'),
5423 hint=('use --all to remerge all files'))
5462 hint=('use --all to remerge all files'))
5424
5463
5425 if show:
5464 if show:
5426 fm = ui.formatter('resolve', opts)
5465 fm = ui.formatter('resolve', opts)
5427 ms = mergemod.mergestate(repo)
5466 ms = mergemod.mergestate(repo)
5428 m = scmutil.match(repo[None], pats, opts)
5467 m = scmutil.match(repo[None], pats, opts)
5429 for f in ms:
5468 for f in ms:
5430 if not m(f):
5469 if not m(f):
5431 continue
5470 continue
5432 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
5471 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
5433 fm.startitem()
5472 fm.startitem()
5434 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5473 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5435 fm.write('path', '%s\n', f, label=l)
5474 fm.write('path', '%s\n', f, label=l)
5436 fm.end()
5475 fm.end()
5437 return 0
5476 return 0
5438
5477
5439 wlock = repo.wlock()
5478 wlock = repo.wlock()
5440 try:
5479 try:
5441 ms = mergemod.mergestate(repo)
5480 ms = mergemod.mergestate(repo)
5442
5481
5443 if not (ms.active() or repo.dirstate.p2() != nullid):
5482 if not (ms.active() or repo.dirstate.p2() != nullid):
5444 raise util.Abort(
5483 raise util.Abort(
5445 _('resolve command not applicable when not merging'))
5484 _('resolve command not applicable when not merging'))
5446
5485
5447 m = scmutil.match(repo[None], pats, opts)
5486 m = scmutil.match(repo[None], pats, opts)
5448 ret = 0
5487 ret = 0
5449 didwork = False
5488 didwork = False
5450
5489
5451 for f in ms:
5490 for f in ms:
5452 if not m(f):
5491 if not m(f):
5453 continue
5492 continue
5454
5493
5455 didwork = True
5494 didwork = True
5456
5495
5457 if mark:
5496 if mark:
5458 ms.mark(f, "r")
5497 ms.mark(f, "r")
5459 elif unmark:
5498 elif unmark:
5460 ms.mark(f, "u")
5499 ms.mark(f, "u")
5461 else:
5500 else:
5462 wctx = repo[None]
5501 wctx = repo[None]
5463
5502
5464 # backup pre-resolve (merge uses .orig for its own purposes)
5503 # backup pre-resolve (merge uses .orig for its own purposes)
5465 a = repo.wjoin(f)
5504 a = repo.wjoin(f)
5466 util.copyfile(a, a + ".resolve")
5505 util.copyfile(a, a + ".resolve")
5467
5506
5468 try:
5507 try:
5469 # resolve file
5508 # resolve file
5470 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5509 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5471 'resolve')
5510 'resolve')
5472 if ms.resolve(f, wctx):
5511 if ms.resolve(f, wctx):
5473 ret = 1
5512 ret = 1
5474 finally:
5513 finally:
5475 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5514 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5476 ms.commit()
5515 ms.commit()
5477
5516
5478 # replace filemerge's .orig file with our resolve file
5517 # replace filemerge's .orig file with our resolve file
5479 util.rename(a + ".resolve", a + ".orig")
5518 util.rename(a + ".resolve", a + ".orig")
5480
5519
5481 ms.commit()
5520 ms.commit()
5482
5521
5483 if not didwork and pats:
5522 if not didwork and pats:
5484 ui.warn(_("arguments do not match paths that need resolving\n"))
5523 ui.warn(_("arguments do not match paths that need resolving\n"))
5485
5524
5486 finally:
5525 finally:
5487 wlock.release()
5526 wlock.release()
5488
5527
5489 # Nudge users into finishing an unfinished operation
5528 # Nudge users into finishing an unfinished operation
5490 if not list(ms.unresolved()):
5529 if not list(ms.unresolved()):
5491 ui.status(_('(no more unresolved files)\n'))
5530 ui.status(_('(no more unresolved files)\n'))
5492
5531
5493 return ret
5532 return ret
5494
5533
5495 @command('revert',
5534 @command('revert',
5496 [('a', 'all', None, _('revert all changes when no arguments given')),
5535 [('a', 'all', None, _('revert all changes when no arguments given')),
5497 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5536 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5498 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5537 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5499 ('C', 'no-backup', None, _('do not save backup copies of files')),
5538 ('C', 'no-backup', None, _('do not save backup copies of files')),
5500 ('i', 'interactive', None,
5539 ('i', 'interactive', None,
5501 _('interactively select the changes (EXPERIMENTAL)')),
5540 _('interactively select the changes (EXPERIMENTAL)')),
5502 ] + walkopts + dryrunopts,
5541 ] + walkopts + dryrunopts,
5503 _('[OPTION]... [-r REV] [NAME]...'))
5542 _('[OPTION]... [-r REV] [NAME]...'))
5504 def revert(ui, repo, *pats, **opts):
5543 def revert(ui, repo, *pats, **opts):
5505 """restore files to their checkout state
5544 """restore files to their checkout state
5506
5545
5507 .. note::
5546 .. note::
5508
5547
5509 To check out earlier revisions, you should use :hg:`update REV`.
5548 To check out earlier revisions, you should use :hg:`update REV`.
5510 To cancel an uncommitted merge (and lose your changes),
5549 To cancel an uncommitted merge (and lose your changes),
5511 use :hg:`update --clean .`.
5550 use :hg:`update --clean .`.
5512
5551
5513 With no revision specified, revert the specified files or directories
5552 With no revision specified, revert the specified files or directories
5514 to the contents they had in the parent of the working directory.
5553 to the contents they had in the parent of the working directory.
5515 This restores the contents of files to an unmodified
5554 This restores the contents of files to an unmodified
5516 state and unschedules adds, removes, copies, and renames. If the
5555 state and unschedules adds, removes, copies, and renames. If the
5517 working directory has two parents, you must explicitly specify a
5556 working directory has two parents, you must explicitly specify a
5518 revision.
5557 revision.
5519
5558
5520 Using the -r/--rev or -d/--date options, revert the given files or
5559 Using the -r/--rev or -d/--date options, revert the given files or
5521 directories to their states as of a specific revision. Because
5560 directories to their states as of a specific revision. Because
5522 revert does not change the working directory parents, this will
5561 revert does not change the working directory parents, this will
5523 cause these files to appear modified. This can be helpful to "back
5562 cause these files to appear modified. This can be helpful to "back
5524 out" some or all of an earlier change. See :hg:`backout` for a
5563 out" some or all of an earlier change. See :hg:`backout` for a
5525 related method.
5564 related method.
5526
5565
5527 Modified files are saved with a .orig suffix before reverting.
5566 Modified files are saved with a .orig suffix before reverting.
5528 To disable these backups, use --no-backup.
5567 To disable these backups, use --no-backup.
5529
5568
5530 See :hg:`help dates` for a list of formats valid for -d/--date.
5569 See :hg:`help dates` for a list of formats valid for -d/--date.
5531
5570
5532 Returns 0 on success.
5571 Returns 0 on success.
5533 """
5572 """
5534
5573
5535 if opts.get("date"):
5574 if opts.get("date"):
5536 if opts.get("rev"):
5575 if opts.get("rev"):
5537 raise util.Abort(_("you can't specify a revision and a date"))
5576 raise util.Abort(_("you can't specify a revision and a date"))
5538 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5577 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5539
5578
5540 parent, p2 = repo.dirstate.parents()
5579 parent, p2 = repo.dirstate.parents()
5541 if not opts.get('rev') and p2 != nullid:
5580 if not opts.get('rev') and p2 != nullid:
5542 # revert after merge is a trap for new users (issue2915)
5581 # revert after merge is a trap for new users (issue2915)
5543 raise util.Abort(_('uncommitted merge with no revision specified'),
5582 raise util.Abort(_('uncommitted merge with no revision specified'),
5544 hint=_('use "hg update" or see "hg help revert"'))
5583 hint=_('use "hg update" or see "hg help revert"'))
5545
5584
5546 ctx = scmutil.revsingle(repo, opts.get('rev'))
5585 ctx = scmutil.revsingle(repo, opts.get('rev'))
5547
5586
5548 if (not (pats or opts.get('include') or opts.get('exclude') or
5587 if (not (pats or opts.get('include') or opts.get('exclude') or
5549 opts.get('all') or opts.get('interactive'))):
5588 opts.get('all') or opts.get('interactive'))):
5550 msg = _("no files or directories specified")
5589 msg = _("no files or directories specified")
5551 if p2 != nullid:
5590 if p2 != nullid:
5552 hint = _("uncommitted merge, use --all to discard all changes,"
5591 hint = _("uncommitted merge, use --all to discard all changes,"
5553 " or 'hg update -C .' to abort the merge")
5592 " or 'hg update -C .' to abort the merge")
5554 raise util.Abort(msg, hint=hint)
5593 raise util.Abort(msg, hint=hint)
5555 dirty = any(repo.status())
5594 dirty = any(repo.status())
5556 node = ctx.node()
5595 node = ctx.node()
5557 if node != parent:
5596 if node != parent:
5558 if dirty:
5597 if dirty:
5559 hint = _("uncommitted changes, use --all to discard all"
5598 hint = _("uncommitted changes, use --all to discard all"
5560 " changes, or 'hg update %s' to update") % ctx.rev()
5599 " changes, or 'hg update %s' to update") % ctx.rev()
5561 else:
5600 else:
5562 hint = _("use --all to revert all files,"
5601 hint = _("use --all to revert all files,"
5563 " or 'hg update %s' to update") % ctx.rev()
5602 " or 'hg update %s' to update") % ctx.rev()
5564 elif dirty:
5603 elif dirty:
5565 hint = _("uncommitted changes, use --all to discard all changes")
5604 hint = _("uncommitted changes, use --all to discard all changes")
5566 else:
5605 else:
5567 hint = _("use --all to revert all files")
5606 hint = _("use --all to revert all files")
5568 raise util.Abort(msg, hint=hint)
5607 raise util.Abort(msg, hint=hint)
5569
5608
5570 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5609 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5571
5610
5572 @command('rollback', dryrunopts +
5611 @command('rollback', dryrunopts +
5573 [('f', 'force', False, _('ignore safety measures'))])
5612 [('f', 'force', False, _('ignore safety measures'))])
5574 def rollback(ui, repo, **opts):
5613 def rollback(ui, repo, **opts):
5575 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5614 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5576
5615
5577 Please use :hg:`commit --amend` instead of rollback to correct
5616 Please use :hg:`commit --amend` instead of rollback to correct
5578 mistakes in the last commit.
5617 mistakes in the last commit.
5579
5618
5580 This command should be used with care. There is only one level of
5619 This command should be used with care. There is only one level of
5581 rollback, and there is no way to undo a rollback. It will also
5620 rollback, and there is no way to undo a rollback. It will also
5582 restore the dirstate at the time of the last transaction, losing
5621 restore the dirstate at the time of the last transaction, losing
5583 any dirstate changes since that time. This command does not alter
5622 any dirstate changes since that time. This command does not alter
5584 the working directory.
5623 the working directory.
5585
5624
5586 Transactions are used to encapsulate the effects of all commands
5625 Transactions are used to encapsulate the effects of all commands
5587 that create new changesets or propagate existing changesets into a
5626 that create new changesets or propagate existing changesets into a
5588 repository.
5627 repository.
5589
5628
5590 .. container:: verbose
5629 .. container:: verbose
5591
5630
5592 For example, the following commands are transactional, and their
5631 For example, the following commands are transactional, and their
5593 effects can be rolled back:
5632 effects can be rolled back:
5594
5633
5595 - commit
5634 - commit
5596 - import
5635 - import
5597 - pull
5636 - pull
5598 - push (with this repository as the destination)
5637 - push (with this repository as the destination)
5599 - unbundle
5638 - unbundle
5600
5639
5601 To avoid permanent data loss, rollback will refuse to rollback a
5640 To avoid permanent data loss, rollback will refuse to rollback a
5602 commit transaction if it isn't checked out. Use --force to
5641 commit transaction if it isn't checked out. Use --force to
5603 override this protection.
5642 override this protection.
5604
5643
5605 This command is not intended for use on public repositories. Once
5644 This command is not intended for use on public repositories. Once
5606 changes are visible for pull by other users, rolling a transaction
5645 changes are visible for pull by other users, rolling a transaction
5607 back locally is ineffective (someone else may already have pulled
5646 back locally is ineffective (someone else may already have pulled
5608 the changes). Furthermore, a race is possible with readers of the
5647 the changes). Furthermore, a race is possible with readers of the
5609 repository; for example an in-progress pull from the repository
5648 repository; for example an in-progress pull from the repository
5610 may fail if a rollback is performed.
5649 may fail if a rollback is performed.
5611
5650
5612 Returns 0 on success, 1 if no rollback data is available.
5651 Returns 0 on success, 1 if no rollback data is available.
5613 """
5652 """
5614 return repo.rollback(dryrun=opts.get('dry_run'),
5653 return repo.rollback(dryrun=opts.get('dry_run'),
5615 force=opts.get('force'))
5654 force=opts.get('force'))
5616
5655
5617 @command('root', [])
5656 @command('root', [])
5618 def root(ui, repo):
5657 def root(ui, repo):
5619 """print the root (top) of the current working directory
5658 """print the root (top) of the current working directory
5620
5659
5621 Print the root directory of the current repository.
5660 Print the root directory of the current repository.
5622
5661
5623 Returns 0 on success.
5662 Returns 0 on success.
5624 """
5663 """
5625 ui.write(repo.root + "\n")
5664 ui.write(repo.root + "\n")
5626
5665
5627 @command('^serve',
5666 @command('^serve',
5628 [('A', 'accesslog', '', _('name of access log file to write to'),
5667 [('A', 'accesslog', '', _('name of access log file to write to'),
5629 _('FILE')),
5668 _('FILE')),
5630 ('d', 'daemon', None, _('run server in background')),
5669 ('d', 'daemon', None, _('run server in background')),
5631 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5670 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5632 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5671 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5633 # use string type, then we can check if something was passed
5672 # use string type, then we can check if something was passed
5634 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5673 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5635 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5674 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5636 _('ADDR')),
5675 _('ADDR')),
5637 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5676 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5638 _('PREFIX')),
5677 _('PREFIX')),
5639 ('n', 'name', '',
5678 ('n', 'name', '',
5640 _('name to show in web pages (default: working directory)'), _('NAME')),
5679 _('name to show in web pages (default: working directory)'), _('NAME')),
5641 ('', 'web-conf', '',
5680 ('', 'web-conf', '',
5642 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5681 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5643 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5682 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5644 _('FILE')),
5683 _('FILE')),
5645 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5684 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5646 ('', 'stdio', None, _('for remote clients')),
5685 ('', 'stdio', None, _('for remote clients')),
5647 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5686 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5648 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5687 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5649 ('', 'style', '', _('template style to use'), _('STYLE')),
5688 ('', 'style', '', _('template style to use'), _('STYLE')),
5650 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5689 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5651 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5690 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5652 _('[OPTION]...'),
5691 _('[OPTION]...'),
5653 optionalrepo=True)
5692 optionalrepo=True)
5654 def serve(ui, repo, **opts):
5693 def serve(ui, repo, **opts):
5655 """start stand-alone webserver
5694 """start stand-alone webserver
5656
5695
5657 Start a local HTTP repository browser and pull server. You can use
5696 Start a local HTTP repository browser and pull server. You can use
5658 this for ad-hoc sharing and browsing of repositories. It is
5697 this for ad-hoc sharing and browsing of repositories. It is
5659 recommended to use a real web server to serve a repository for
5698 recommended to use a real web server to serve a repository for
5660 longer periods of time.
5699 longer periods of time.
5661
5700
5662 Please note that the server does not implement access control.
5701 Please note that the server does not implement access control.
5663 This means that, by default, anybody can read from the server and
5702 This means that, by default, anybody can read from the server and
5664 nobody can write to it by default. Set the ``web.allow_push``
5703 nobody can write to it by default. Set the ``web.allow_push``
5665 option to ``*`` to allow everybody to push to the server. You
5704 option to ``*`` to allow everybody to push to the server. You
5666 should use a real web server if you need to authenticate users.
5705 should use a real web server if you need to authenticate users.
5667
5706
5668 By default, the server logs accesses to stdout and errors to
5707 By default, the server logs accesses to stdout and errors to
5669 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5708 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5670 files.
5709 files.
5671
5710
5672 To have the server choose a free port number to listen on, specify
5711 To have the server choose a free port number to listen on, specify
5673 a port number of 0; in this case, the server will print the port
5712 a port number of 0; in this case, the server will print the port
5674 number it uses.
5713 number it uses.
5675
5714
5676 Returns 0 on success.
5715 Returns 0 on success.
5677 """
5716 """
5678
5717
5679 if opts["stdio"] and opts["cmdserver"]:
5718 if opts["stdio"] and opts["cmdserver"]:
5680 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5719 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5681
5720
5682 if opts["stdio"]:
5721 if opts["stdio"]:
5683 if repo is None:
5722 if repo is None:
5684 raise error.RepoError(_("there is no Mercurial repository here"
5723 raise error.RepoError(_("there is no Mercurial repository here"
5685 " (.hg not found)"))
5724 " (.hg not found)"))
5686 s = sshserver.sshserver(ui, repo)
5725 s = sshserver.sshserver(ui, repo)
5687 s.serve_forever()
5726 s.serve_forever()
5688
5727
5689 if opts["cmdserver"]:
5728 if opts["cmdserver"]:
5690 import commandserver
5729 import commandserver
5691 service = commandserver.createservice(ui, repo, opts)
5730 service = commandserver.createservice(ui, repo, opts)
5692 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5731 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5693
5732
5694 # this way we can check if something was given in the command-line
5733 # this way we can check if something was given in the command-line
5695 if opts.get('port'):
5734 if opts.get('port'):
5696 opts['port'] = util.getport(opts.get('port'))
5735 opts['port'] = util.getport(opts.get('port'))
5697
5736
5698 if repo:
5737 if repo:
5699 baseui = repo.baseui
5738 baseui = repo.baseui
5700 else:
5739 else:
5701 baseui = ui
5740 baseui = ui
5702 optlist = ("name templates style address port prefix ipv6"
5741 optlist = ("name templates style address port prefix ipv6"
5703 " accesslog errorlog certificate encoding")
5742 " accesslog errorlog certificate encoding")
5704 for o in optlist.split():
5743 for o in optlist.split():
5705 val = opts.get(o, '')
5744 val = opts.get(o, '')
5706 if val in (None, ''): # should check against default options instead
5745 if val in (None, ''): # should check against default options instead
5707 continue
5746 continue
5708 baseui.setconfig("web", o, val, 'serve')
5747 baseui.setconfig("web", o, val, 'serve')
5709 if repo and repo.ui != baseui:
5748 if repo and repo.ui != baseui:
5710 repo.ui.setconfig("web", o, val, 'serve')
5749 repo.ui.setconfig("web", o, val, 'serve')
5711
5750
5712 o = opts.get('web_conf') or opts.get('webdir_conf')
5751 o = opts.get('web_conf') or opts.get('webdir_conf')
5713 if not o:
5752 if not o:
5714 if not repo:
5753 if not repo:
5715 raise error.RepoError(_("there is no Mercurial repository"
5754 raise error.RepoError(_("there is no Mercurial repository"
5716 " here (.hg not found)"))
5755 " here (.hg not found)"))
5717 o = repo
5756 o = repo
5718
5757
5719 app = hgweb.hgweb(o, baseui=baseui)
5758 app = hgweb.hgweb(o, baseui=baseui)
5720 service = httpservice(ui, app, opts)
5759 service = httpservice(ui, app, opts)
5721 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5760 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5722
5761
5723 class httpservice(object):
5762 class httpservice(object):
5724 def __init__(self, ui, app, opts):
5763 def __init__(self, ui, app, opts):
5725 self.ui = ui
5764 self.ui = ui
5726 self.app = app
5765 self.app = app
5727 self.opts = opts
5766 self.opts = opts
5728
5767
5729 def init(self):
5768 def init(self):
5730 util.setsignalhandler()
5769 util.setsignalhandler()
5731 self.httpd = hgweb_server.create_server(self.ui, self.app)
5770 self.httpd = hgweb_server.create_server(self.ui, self.app)
5732
5771
5733 if self.opts['port'] and not self.ui.verbose:
5772 if self.opts['port'] and not self.ui.verbose:
5734 return
5773 return
5735
5774
5736 if self.httpd.prefix:
5775 if self.httpd.prefix:
5737 prefix = self.httpd.prefix.strip('/') + '/'
5776 prefix = self.httpd.prefix.strip('/') + '/'
5738 else:
5777 else:
5739 prefix = ''
5778 prefix = ''
5740
5779
5741 port = ':%d' % self.httpd.port
5780 port = ':%d' % self.httpd.port
5742 if port == ':80':
5781 if port == ':80':
5743 port = ''
5782 port = ''
5744
5783
5745 bindaddr = self.httpd.addr
5784 bindaddr = self.httpd.addr
5746 if bindaddr == '0.0.0.0':
5785 if bindaddr == '0.0.0.0':
5747 bindaddr = '*'
5786 bindaddr = '*'
5748 elif ':' in bindaddr: # IPv6
5787 elif ':' in bindaddr: # IPv6
5749 bindaddr = '[%s]' % bindaddr
5788 bindaddr = '[%s]' % bindaddr
5750
5789
5751 fqaddr = self.httpd.fqaddr
5790 fqaddr = self.httpd.fqaddr
5752 if ':' in fqaddr:
5791 if ':' in fqaddr:
5753 fqaddr = '[%s]' % fqaddr
5792 fqaddr = '[%s]' % fqaddr
5754 if self.opts['port']:
5793 if self.opts['port']:
5755 write = self.ui.status
5794 write = self.ui.status
5756 else:
5795 else:
5757 write = self.ui.write
5796 write = self.ui.write
5758 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5797 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5759 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5798 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5760 self.ui.flush() # avoid buffering of status message
5799 self.ui.flush() # avoid buffering of status message
5761
5800
5762 def run(self):
5801 def run(self):
5763 self.httpd.serve_forever()
5802 self.httpd.serve_forever()
5764
5803
5765
5804
5766 @command('^status|st',
5805 @command('^status|st',
5767 [('A', 'all', None, _('show status of all files')),
5806 [('A', 'all', None, _('show status of all files')),
5768 ('m', 'modified', None, _('show only modified files')),
5807 ('m', 'modified', None, _('show only modified files')),
5769 ('a', 'added', None, _('show only added files')),
5808 ('a', 'added', None, _('show only added files')),
5770 ('r', 'removed', None, _('show only removed files')),
5809 ('r', 'removed', None, _('show only removed files')),
5771 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5810 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5772 ('c', 'clean', None, _('show only files without changes')),
5811 ('c', 'clean', None, _('show only files without changes')),
5773 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5812 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5774 ('i', 'ignored', None, _('show only ignored files')),
5813 ('i', 'ignored', None, _('show only ignored files')),
5775 ('n', 'no-status', None, _('hide status prefix')),
5814 ('n', 'no-status', None, _('hide status prefix')),
5776 ('C', 'copies', None, _('show source of copied files')),
5815 ('C', 'copies', None, _('show source of copied files')),
5777 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5816 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5778 ('', 'rev', [], _('show difference from revision'), _('REV')),
5817 ('', 'rev', [], _('show difference from revision'), _('REV')),
5779 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5818 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5780 ] + walkopts + subrepoopts + formatteropts,
5819 ] + walkopts + subrepoopts + formatteropts,
5781 _('[OPTION]... [FILE]...'),
5820 _('[OPTION]... [FILE]...'),
5782 inferrepo=True)
5821 inferrepo=True)
5783 def status(ui, repo, *pats, **opts):
5822 def status(ui, repo, *pats, **opts):
5784 """show changed files in the working directory
5823 """show changed files in the working directory
5785
5824
5786 Show status of files in the repository. If names are given, only
5825 Show status of files in the repository. If names are given, only
5787 files that match are shown. Files that are clean or ignored or
5826 files that match are shown. Files that are clean or ignored or
5788 the source of a copy/move operation, are not listed unless
5827 the source of a copy/move operation, are not listed unless
5789 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5828 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5790 Unless options described with "show only ..." are given, the
5829 Unless options described with "show only ..." are given, the
5791 options -mardu are used.
5830 options -mardu are used.
5792
5831
5793 Option -q/--quiet hides untracked (unknown and ignored) files
5832 Option -q/--quiet hides untracked (unknown and ignored) files
5794 unless explicitly requested with -u/--unknown or -i/--ignored.
5833 unless explicitly requested with -u/--unknown or -i/--ignored.
5795
5834
5796 .. note::
5835 .. note::
5797
5836
5798 status may appear to disagree with diff if permissions have
5837 status may appear to disagree with diff if permissions have
5799 changed or a merge has occurred. The standard diff format does
5838 changed or a merge has occurred. The standard diff format does
5800 not report permission changes and diff only reports changes
5839 not report permission changes and diff only reports changes
5801 relative to one merge parent.
5840 relative to one merge parent.
5802
5841
5803 If one revision is given, it is used as the base revision.
5842 If one revision is given, it is used as the base revision.
5804 If two revisions are given, the differences between them are
5843 If two revisions are given, the differences between them are
5805 shown. The --change option can also be used as a shortcut to list
5844 shown. The --change option can also be used as a shortcut to list
5806 the changed files of a revision from its first parent.
5845 the changed files of a revision from its first parent.
5807
5846
5808 The codes used to show the status of files are::
5847 The codes used to show the status of files are::
5809
5848
5810 M = modified
5849 M = modified
5811 A = added
5850 A = added
5812 R = removed
5851 R = removed
5813 C = clean
5852 C = clean
5814 ! = missing (deleted by non-hg command, but still tracked)
5853 ! = missing (deleted by non-hg command, but still tracked)
5815 ? = not tracked
5854 ? = not tracked
5816 I = ignored
5855 I = ignored
5817 = origin of the previous file (with --copies)
5856 = origin of the previous file (with --copies)
5818
5857
5819 .. container:: verbose
5858 .. container:: verbose
5820
5859
5821 Examples:
5860 Examples:
5822
5861
5823 - show changes in the working directory relative to a
5862 - show changes in the working directory relative to a
5824 changeset::
5863 changeset::
5825
5864
5826 hg status --rev 9353
5865 hg status --rev 9353
5827
5866
5828 - show changes in the working directory relative to the
5867 - show changes in the working directory relative to the
5829 current directory (see :hg:`help patterns` for more information)::
5868 current directory (see :hg:`help patterns` for more information)::
5830
5869
5831 hg status re:
5870 hg status re:
5832
5871
5833 - show all changes including copies in an existing changeset::
5872 - show all changes including copies in an existing changeset::
5834
5873
5835 hg status --copies --change 9353
5874 hg status --copies --change 9353
5836
5875
5837 - get a NUL separated list of added files, suitable for xargs::
5876 - get a NUL separated list of added files, suitable for xargs::
5838
5877
5839 hg status -an0
5878 hg status -an0
5840
5879
5841 Returns 0 on success.
5880 Returns 0 on success.
5842 """
5881 """
5843
5882
5844 revs = opts.get('rev')
5883 revs = opts.get('rev')
5845 change = opts.get('change')
5884 change = opts.get('change')
5846
5885
5847 if revs and change:
5886 if revs and change:
5848 msg = _('cannot specify --rev and --change at the same time')
5887 msg = _('cannot specify --rev and --change at the same time')
5849 raise util.Abort(msg)
5888 raise util.Abort(msg)
5850 elif change:
5889 elif change:
5851 node2 = scmutil.revsingle(repo, change, None).node()
5890 node2 = scmutil.revsingle(repo, change, None).node()
5852 node1 = repo[node2].p1().node()
5891 node1 = repo[node2].p1().node()
5853 else:
5892 else:
5854 node1, node2 = scmutil.revpair(repo, revs)
5893 node1, node2 = scmutil.revpair(repo, revs)
5855
5894
5856 if pats:
5895 if pats:
5857 cwd = repo.getcwd()
5896 cwd = repo.getcwd()
5858 else:
5897 else:
5859 cwd = ''
5898 cwd = ''
5860
5899
5861 if opts.get('print0'):
5900 if opts.get('print0'):
5862 end = '\0'
5901 end = '\0'
5863 else:
5902 else:
5864 end = '\n'
5903 end = '\n'
5865 copy = {}
5904 copy = {}
5866 states = 'modified added removed deleted unknown ignored clean'.split()
5905 states = 'modified added removed deleted unknown ignored clean'.split()
5867 show = [k for k in states if opts.get(k)]
5906 show = [k for k in states if opts.get(k)]
5868 if opts.get('all'):
5907 if opts.get('all'):
5869 show += ui.quiet and (states[:4] + ['clean']) or states
5908 show += ui.quiet and (states[:4] + ['clean']) or states
5870 if not show:
5909 if not show:
5871 if ui.quiet:
5910 if ui.quiet:
5872 show = states[:4]
5911 show = states[:4]
5873 else:
5912 else:
5874 show = states[:5]
5913 show = states[:5]
5875
5914
5876 m = scmutil.match(repo[node2], pats, opts)
5915 m = scmutil.match(repo[node2], pats, opts)
5877 stat = repo.status(node1, node2, m,
5916 stat = repo.status(node1, node2, m,
5878 'ignored' in show, 'clean' in show, 'unknown' in show,
5917 'ignored' in show, 'clean' in show, 'unknown' in show,
5879 opts.get('subrepos'))
5918 opts.get('subrepos'))
5880 changestates = zip(states, 'MAR!?IC', stat)
5919 changestates = zip(states, 'MAR!?IC', stat)
5881
5920
5882 if (opts.get('all') or opts.get('copies')
5921 if (opts.get('all') or opts.get('copies')
5883 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
5922 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
5884 copy = copies.pathcopies(repo[node1], repo[node2], m)
5923 copy = copies.pathcopies(repo[node1], repo[node2], m)
5885
5924
5886 fm = ui.formatter('status', opts)
5925 fm = ui.formatter('status', opts)
5887 fmt = '%s' + end
5926 fmt = '%s' + end
5888 showchar = not opts.get('no_status')
5927 showchar = not opts.get('no_status')
5889
5928
5890 for state, char, files in changestates:
5929 for state, char, files in changestates:
5891 if state in show:
5930 if state in show:
5892 label = 'status.' + state
5931 label = 'status.' + state
5893 for f in files:
5932 for f in files:
5894 fm.startitem()
5933 fm.startitem()
5895 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5934 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5896 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5935 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5897 if f in copy:
5936 if f in copy:
5898 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5937 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5899 label='status.copied')
5938 label='status.copied')
5900 fm.end()
5939 fm.end()
5901
5940
5902 @command('^summary|sum',
5941 @command('^summary|sum',
5903 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5942 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5904 def summary(ui, repo, **opts):
5943 def summary(ui, repo, **opts):
5905 """summarize working directory state
5944 """summarize working directory state
5906
5945
5907 This generates a brief summary of the working directory state,
5946 This generates a brief summary of the working directory state,
5908 including parents, branch, commit status, phase and available updates.
5947 including parents, branch, commit status, phase and available updates.
5909
5948
5910 With the --remote option, this will check the default paths for
5949 With the --remote option, this will check the default paths for
5911 incoming and outgoing changes. This can be time-consuming.
5950 incoming and outgoing changes. This can be time-consuming.
5912
5951
5913 Returns 0 on success.
5952 Returns 0 on success.
5914 """
5953 """
5915
5954
5916 ctx = repo[None]
5955 ctx = repo[None]
5917 parents = ctx.parents()
5956 parents = ctx.parents()
5918 pnode = parents[0].node()
5957 pnode = parents[0].node()
5919 marks = []
5958 marks = []
5920
5959
5921 for p in parents:
5960 for p in parents:
5922 # label with log.changeset (instead of log.parent) since this
5961 # label with log.changeset (instead of log.parent) since this
5923 # shows a working directory parent *changeset*:
5962 # shows a working directory parent *changeset*:
5924 # i18n: column positioning for "hg summary"
5963 # i18n: column positioning for "hg summary"
5925 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5964 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5926 label='log.changeset changeset.%s' % p.phasestr())
5965 label='log.changeset changeset.%s' % p.phasestr())
5927 ui.write(' '.join(p.tags()), label='log.tag')
5966 ui.write(' '.join(p.tags()), label='log.tag')
5928 if p.bookmarks():
5967 if p.bookmarks():
5929 marks.extend(p.bookmarks())
5968 marks.extend(p.bookmarks())
5930 if p.rev() == -1:
5969 if p.rev() == -1:
5931 if not len(repo):
5970 if not len(repo):
5932 ui.write(_(' (empty repository)'))
5971 ui.write(_(' (empty repository)'))
5933 else:
5972 else:
5934 ui.write(_(' (no revision checked out)'))
5973 ui.write(_(' (no revision checked out)'))
5935 ui.write('\n')
5974 ui.write('\n')
5936 if p.description():
5975 if p.description():
5937 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5976 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5938 label='log.summary')
5977 label='log.summary')
5939
5978
5940 branch = ctx.branch()
5979 branch = ctx.branch()
5941 bheads = repo.branchheads(branch)
5980 bheads = repo.branchheads(branch)
5942 # i18n: column positioning for "hg summary"
5981 # i18n: column positioning for "hg summary"
5943 m = _('branch: %s\n') % branch
5982 m = _('branch: %s\n') % branch
5944 if branch != 'default':
5983 if branch != 'default':
5945 ui.write(m, label='log.branch')
5984 ui.write(m, label='log.branch')
5946 else:
5985 else:
5947 ui.status(m, label='log.branch')
5986 ui.status(m, label='log.branch')
5948
5987
5949 if marks:
5988 if marks:
5950 active = repo._activebookmark
5989 active = repo._activebookmark
5951 # i18n: column positioning for "hg summary"
5990 # i18n: column positioning for "hg summary"
5952 ui.write(_('bookmarks:'), label='log.bookmark')
5991 ui.write(_('bookmarks:'), label='log.bookmark')
5953 if active is not None:
5992 if active is not None:
5954 if active in marks:
5993 if active in marks:
5955 ui.write(' *' + active, label=activebookmarklabel)
5994 ui.write(' *' + active, label=activebookmarklabel)
5956 marks.remove(active)
5995 marks.remove(active)
5957 else:
5996 else:
5958 ui.write(' [%s]' % active, label=activebookmarklabel)
5997 ui.write(' [%s]' % active, label=activebookmarklabel)
5959 for m in marks:
5998 for m in marks:
5960 ui.write(' ' + m, label='log.bookmark')
5999 ui.write(' ' + m, label='log.bookmark')
5961 ui.write('\n', label='log.bookmark')
6000 ui.write('\n', label='log.bookmark')
5962
6001
5963 status = repo.status(unknown=True)
6002 status = repo.status(unknown=True)
5964
6003
5965 c = repo.dirstate.copies()
6004 c = repo.dirstate.copies()
5966 copied, renamed = [], []
6005 copied, renamed = [], []
5967 for d, s in c.iteritems():
6006 for d, s in c.iteritems():
5968 if s in status.removed:
6007 if s in status.removed:
5969 status.removed.remove(s)
6008 status.removed.remove(s)
5970 renamed.append(d)
6009 renamed.append(d)
5971 else:
6010 else:
5972 copied.append(d)
6011 copied.append(d)
5973 if d in status.added:
6012 if d in status.added:
5974 status.added.remove(d)
6013 status.added.remove(d)
5975
6014
5976 ms = mergemod.mergestate(repo)
6015 ms = mergemod.mergestate(repo)
5977 unresolved = [f for f in ms if ms[f] == 'u']
6016 unresolved = [f for f in ms if ms[f] == 'u']
5978
6017
5979 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6018 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5980
6019
5981 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6020 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
5982 (ui.label(_('%d added'), 'status.added'), status.added),
6021 (ui.label(_('%d added'), 'status.added'), status.added),
5983 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6022 (ui.label(_('%d removed'), 'status.removed'), status.removed),
5984 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6023 (ui.label(_('%d renamed'), 'status.copied'), renamed),
5985 (ui.label(_('%d copied'), 'status.copied'), copied),
6024 (ui.label(_('%d copied'), 'status.copied'), copied),
5986 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6025 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
5987 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6026 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
5988 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6027 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
5989 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6028 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
5990 t = []
6029 t = []
5991 for l, s in labels:
6030 for l, s in labels:
5992 if s:
6031 if s:
5993 t.append(l % len(s))
6032 t.append(l % len(s))
5994
6033
5995 t = ', '.join(t)
6034 t = ', '.join(t)
5996 cleanworkdir = False
6035 cleanworkdir = False
5997
6036
5998 if repo.vfs.exists('updatestate'):
6037 if repo.vfs.exists('updatestate'):
5999 t += _(' (interrupted update)')
6038 t += _(' (interrupted update)')
6000 elif len(parents) > 1:
6039 elif len(parents) > 1:
6001 t += _(' (merge)')
6040 t += _(' (merge)')
6002 elif branch != parents[0].branch():
6041 elif branch != parents[0].branch():
6003 t += _(' (new branch)')
6042 t += _(' (new branch)')
6004 elif (parents[0].closesbranch() and
6043 elif (parents[0].closesbranch() and
6005 pnode in repo.branchheads(branch, closed=True)):
6044 pnode in repo.branchheads(branch, closed=True)):
6006 t += _(' (head closed)')
6045 t += _(' (head closed)')
6007 elif not (status.modified or status.added or status.removed or renamed or
6046 elif not (status.modified or status.added or status.removed or renamed or
6008 copied or subs):
6047 copied or subs):
6009 t += _(' (clean)')
6048 t += _(' (clean)')
6010 cleanworkdir = True
6049 cleanworkdir = True
6011 elif pnode not in bheads:
6050 elif pnode not in bheads:
6012 t += _(' (new branch head)')
6051 t += _(' (new branch head)')
6013
6052
6014 if parents:
6053 if parents:
6015 pendingphase = max(p.phase() for p in parents)
6054 pendingphase = max(p.phase() for p in parents)
6016 else:
6055 else:
6017 pendingphase = phases.public
6056 pendingphase = phases.public
6018
6057
6019 if pendingphase > phases.newcommitphase(ui):
6058 if pendingphase > phases.newcommitphase(ui):
6020 t += ' (%s)' % phases.phasenames[pendingphase]
6059 t += ' (%s)' % phases.phasenames[pendingphase]
6021
6060
6022 if cleanworkdir:
6061 if cleanworkdir:
6023 # i18n: column positioning for "hg summary"
6062 # i18n: column positioning for "hg summary"
6024 ui.status(_('commit: %s\n') % t.strip())
6063 ui.status(_('commit: %s\n') % t.strip())
6025 else:
6064 else:
6026 # i18n: column positioning for "hg summary"
6065 # i18n: column positioning for "hg summary"
6027 ui.write(_('commit: %s\n') % t.strip())
6066 ui.write(_('commit: %s\n') % t.strip())
6028
6067
6029 # all ancestors of branch heads - all ancestors of parent = new csets
6068 # all ancestors of branch heads - all ancestors of parent = new csets
6030 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6069 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6031 bheads))
6070 bheads))
6032
6071
6033 if new == 0:
6072 if new == 0:
6034 # i18n: column positioning for "hg summary"
6073 # i18n: column positioning for "hg summary"
6035 ui.status(_('update: (current)\n'))
6074 ui.status(_('update: (current)\n'))
6036 elif pnode not in bheads:
6075 elif pnode not in bheads:
6037 # i18n: column positioning for "hg summary"
6076 # i18n: column positioning for "hg summary"
6038 ui.write(_('update: %d new changesets (update)\n') % new)
6077 ui.write(_('update: %d new changesets (update)\n') % new)
6039 else:
6078 else:
6040 # i18n: column positioning for "hg summary"
6079 # i18n: column positioning for "hg summary"
6041 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6080 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6042 (new, len(bheads)))
6081 (new, len(bheads)))
6043
6082
6044 t = []
6083 t = []
6045 draft = len(repo.revs('draft()'))
6084 draft = len(repo.revs('draft()'))
6046 if draft:
6085 if draft:
6047 t.append(_('%d draft') % draft)
6086 t.append(_('%d draft') % draft)
6048 secret = len(repo.revs('secret()'))
6087 secret = len(repo.revs('secret()'))
6049 if secret:
6088 if secret:
6050 t.append(_('%d secret') % secret)
6089 t.append(_('%d secret') % secret)
6051
6090
6052 if draft or secret:
6091 if draft or secret:
6053 ui.status(_('phases: %s\n') % ', '.join(t))
6092 ui.status(_('phases: %s\n') % ', '.join(t))
6054
6093
6055 cmdutil.summaryhooks(ui, repo)
6094 cmdutil.summaryhooks(ui, repo)
6056
6095
6057 if opts.get('remote'):
6096 if opts.get('remote'):
6058 needsincoming, needsoutgoing = True, True
6097 needsincoming, needsoutgoing = True, True
6059 else:
6098 else:
6060 needsincoming, needsoutgoing = False, False
6099 needsincoming, needsoutgoing = False, False
6061 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6100 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6062 if i:
6101 if i:
6063 needsincoming = True
6102 needsincoming = True
6064 if o:
6103 if o:
6065 needsoutgoing = True
6104 needsoutgoing = True
6066 if not needsincoming and not needsoutgoing:
6105 if not needsincoming and not needsoutgoing:
6067 return
6106 return
6068
6107
6069 def getincoming():
6108 def getincoming():
6070 source, branches = hg.parseurl(ui.expandpath('default'))
6109 source, branches = hg.parseurl(ui.expandpath('default'))
6071 sbranch = branches[0]
6110 sbranch = branches[0]
6072 try:
6111 try:
6073 other = hg.peer(repo, {}, source)
6112 other = hg.peer(repo, {}, source)
6074 except error.RepoError:
6113 except error.RepoError:
6075 if opts.get('remote'):
6114 if opts.get('remote'):
6076 raise
6115 raise
6077 return source, sbranch, None, None, None
6116 return source, sbranch, None, None, None
6078 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6117 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6079 if revs:
6118 if revs:
6080 revs = [other.lookup(rev) for rev in revs]
6119 revs = [other.lookup(rev) for rev in revs]
6081 ui.debug('comparing with %s\n' % util.hidepassword(source))
6120 ui.debug('comparing with %s\n' % util.hidepassword(source))
6082 repo.ui.pushbuffer()
6121 repo.ui.pushbuffer()
6083 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6122 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6084 repo.ui.popbuffer()
6123 repo.ui.popbuffer()
6085 return source, sbranch, other, commoninc, commoninc[1]
6124 return source, sbranch, other, commoninc, commoninc[1]
6086
6125
6087 if needsincoming:
6126 if needsincoming:
6088 source, sbranch, sother, commoninc, incoming = getincoming()
6127 source, sbranch, sother, commoninc, incoming = getincoming()
6089 else:
6128 else:
6090 source = sbranch = sother = commoninc = incoming = None
6129 source = sbranch = sother = commoninc = incoming = None
6091
6130
6092 def getoutgoing():
6131 def getoutgoing():
6093 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6132 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6094 dbranch = branches[0]
6133 dbranch = branches[0]
6095 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6134 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6096 if source != dest:
6135 if source != dest:
6097 try:
6136 try:
6098 dother = hg.peer(repo, {}, dest)
6137 dother = hg.peer(repo, {}, dest)
6099 except error.RepoError:
6138 except error.RepoError:
6100 if opts.get('remote'):
6139 if opts.get('remote'):
6101 raise
6140 raise
6102 return dest, dbranch, None, None
6141 return dest, dbranch, None, None
6103 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6142 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6104 elif sother is None:
6143 elif sother is None:
6105 # there is no explicit destination peer, but source one is invalid
6144 # there is no explicit destination peer, but source one is invalid
6106 return dest, dbranch, None, None
6145 return dest, dbranch, None, None
6107 else:
6146 else:
6108 dother = sother
6147 dother = sother
6109 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6148 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6110 common = None
6149 common = None
6111 else:
6150 else:
6112 common = commoninc
6151 common = commoninc
6113 if revs:
6152 if revs:
6114 revs = [repo.lookup(rev) for rev in revs]
6153 revs = [repo.lookup(rev) for rev in revs]
6115 repo.ui.pushbuffer()
6154 repo.ui.pushbuffer()
6116 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6155 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6117 commoninc=common)
6156 commoninc=common)
6118 repo.ui.popbuffer()
6157 repo.ui.popbuffer()
6119 return dest, dbranch, dother, outgoing
6158 return dest, dbranch, dother, outgoing
6120
6159
6121 if needsoutgoing:
6160 if needsoutgoing:
6122 dest, dbranch, dother, outgoing = getoutgoing()
6161 dest, dbranch, dother, outgoing = getoutgoing()
6123 else:
6162 else:
6124 dest = dbranch = dother = outgoing = None
6163 dest = dbranch = dother = outgoing = None
6125
6164
6126 if opts.get('remote'):
6165 if opts.get('remote'):
6127 t = []
6166 t = []
6128 if incoming:
6167 if incoming:
6129 t.append(_('1 or more incoming'))
6168 t.append(_('1 or more incoming'))
6130 o = outgoing.missing
6169 o = outgoing.missing
6131 if o:
6170 if o:
6132 t.append(_('%d outgoing') % len(o))
6171 t.append(_('%d outgoing') % len(o))
6133 other = dother or sother
6172 other = dother or sother
6134 if 'bookmarks' in other.listkeys('namespaces'):
6173 if 'bookmarks' in other.listkeys('namespaces'):
6135 counts = bookmarks.summary(repo, other)
6174 counts = bookmarks.summary(repo, other)
6136 if counts[0] > 0:
6175 if counts[0] > 0:
6137 t.append(_('%d incoming bookmarks') % counts[0])
6176 t.append(_('%d incoming bookmarks') % counts[0])
6138 if counts[1] > 0:
6177 if counts[1] > 0:
6139 t.append(_('%d outgoing bookmarks') % counts[1])
6178 t.append(_('%d outgoing bookmarks') % counts[1])
6140
6179
6141 if t:
6180 if t:
6142 # i18n: column positioning for "hg summary"
6181 # i18n: column positioning for "hg summary"
6143 ui.write(_('remote: %s\n') % (', '.join(t)))
6182 ui.write(_('remote: %s\n') % (', '.join(t)))
6144 else:
6183 else:
6145 # i18n: column positioning for "hg summary"
6184 # i18n: column positioning for "hg summary"
6146 ui.status(_('remote: (synced)\n'))
6185 ui.status(_('remote: (synced)\n'))
6147
6186
6148 cmdutil.summaryremotehooks(ui, repo, opts,
6187 cmdutil.summaryremotehooks(ui, repo, opts,
6149 ((source, sbranch, sother, commoninc),
6188 ((source, sbranch, sother, commoninc),
6150 (dest, dbranch, dother, outgoing)))
6189 (dest, dbranch, dother, outgoing)))
6151
6190
6152 @command('tag',
6191 @command('tag',
6153 [('f', 'force', None, _('force tag')),
6192 [('f', 'force', None, _('force tag')),
6154 ('l', 'local', None, _('make the tag local')),
6193 ('l', 'local', None, _('make the tag local')),
6155 ('r', 'rev', '', _('revision to tag'), _('REV')),
6194 ('r', 'rev', '', _('revision to tag'), _('REV')),
6156 ('', 'remove', None, _('remove a tag')),
6195 ('', 'remove', None, _('remove a tag')),
6157 # -l/--local is already there, commitopts cannot be used
6196 # -l/--local is already there, commitopts cannot be used
6158 ('e', 'edit', None, _('invoke editor on commit messages')),
6197 ('e', 'edit', None, _('invoke editor on commit messages')),
6159 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6198 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6160 ] + commitopts2,
6199 ] + commitopts2,
6161 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6200 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6162 def tag(ui, repo, name1, *names, **opts):
6201 def tag(ui, repo, name1, *names, **opts):
6163 """add one or more tags for the current or given revision
6202 """add one or more tags for the current or given revision
6164
6203
6165 Name a particular revision using <name>.
6204 Name a particular revision using <name>.
6166
6205
6167 Tags are used to name particular revisions of the repository and are
6206 Tags are used to name particular revisions of the repository and are
6168 very useful to compare different revisions, to go back to significant
6207 very useful to compare different revisions, to go back to significant
6169 earlier versions or to mark branch points as releases, etc. Changing
6208 earlier versions or to mark branch points as releases, etc. Changing
6170 an existing tag is normally disallowed; use -f/--force to override.
6209 an existing tag is normally disallowed; use -f/--force to override.
6171
6210
6172 If no revision is given, the parent of the working directory is
6211 If no revision is given, the parent of the working directory is
6173 used.
6212 used.
6174
6213
6175 To facilitate version control, distribution, and merging of tags,
6214 To facilitate version control, distribution, and merging of tags,
6176 they are stored as a file named ".hgtags" which is managed similarly
6215 they are stored as a file named ".hgtags" which is managed similarly
6177 to other project files and can be hand-edited if necessary. This
6216 to other project files and can be hand-edited if necessary. This
6178 also means that tagging creates a new commit. The file
6217 also means that tagging creates a new commit. The file
6179 ".hg/localtags" is used for local tags (not shared among
6218 ".hg/localtags" is used for local tags (not shared among
6180 repositories).
6219 repositories).
6181
6220
6182 Tag commits are usually made at the head of a branch. If the parent
6221 Tag commits are usually made at the head of a branch. If the parent
6183 of the working directory is not a branch head, :hg:`tag` aborts; use
6222 of the working directory is not a branch head, :hg:`tag` aborts; use
6184 -f/--force to force the tag commit to be based on a non-head
6223 -f/--force to force the tag commit to be based on a non-head
6185 changeset.
6224 changeset.
6186
6225
6187 See :hg:`help dates` for a list of formats valid for -d/--date.
6226 See :hg:`help dates` for a list of formats valid for -d/--date.
6188
6227
6189 Since tag names have priority over branch names during revision
6228 Since tag names have priority over branch names during revision
6190 lookup, using an existing branch name as a tag name is discouraged.
6229 lookup, using an existing branch name as a tag name is discouraged.
6191
6230
6192 Returns 0 on success.
6231 Returns 0 on success.
6193 """
6232 """
6194 wlock = lock = None
6233 wlock = lock = None
6195 try:
6234 try:
6196 wlock = repo.wlock()
6235 wlock = repo.wlock()
6197 lock = repo.lock()
6236 lock = repo.lock()
6198 rev_ = "."
6237 rev_ = "."
6199 names = [t.strip() for t in (name1,) + names]
6238 names = [t.strip() for t in (name1,) + names]
6200 if len(names) != len(set(names)):
6239 if len(names) != len(set(names)):
6201 raise util.Abort(_('tag names must be unique'))
6240 raise util.Abort(_('tag names must be unique'))
6202 for n in names:
6241 for n in names:
6203 scmutil.checknewlabel(repo, n, 'tag')
6242 scmutil.checknewlabel(repo, n, 'tag')
6204 if not n:
6243 if not n:
6205 raise util.Abort(_('tag names cannot consist entirely of '
6244 raise util.Abort(_('tag names cannot consist entirely of '
6206 'whitespace'))
6245 'whitespace'))
6207 if opts.get('rev') and opts.get('remove'):
6246 if opts.get('rev') and opts.get('remove'):
6208 raise util.Abort(_("--rev and --remove are incompatible"))
6247 raise util.Abort(_("--rev and --remove are incompatible"))
6209 if opts.get('rev'):
6248 if opts.get('rev'):
6210 rev_ = opts['rev']
6249 rev_ = opts['rev']
6211 message = opts.get('message')
6250 message = opts.get('message')
6212 if opts.get('remove'):
6251 if opts.get('remove'):
6213 if opts.get('local'):
6252 if opts.get('local'):
6214 expectedtype = 'local'
6253 expectedtype = 'local'
6215 else:
6254 else:
6216 expectedtype = 'global'
6255 expectedtype = 'global'
6217
6256
6218 for n in names:
6257 for n in names:
6219 if not repo.tagtype(n):
6258 if not repo.tagtype(n):
6220 raise util.Abort(_("tag '%s' does not exist") % n)
6259 raise util.Abort(_("tag '%s' does not exist") % n)
6221 if repo.tagtype(n) != expectedtype:
6260 if repo.tagtype(n) != expectedtype:
6222 if expectedtype == 'global':
6261 if expectedtype == 'global':
6223 raise util.Abort(_("tag '%s' is not a global tag") % n)
6262 raise util.Abort(_("tag '%s' is not a global tag") % n)
6224 else:
6263 else:
6225 raise util.Abort(_("tag '%s' is not a local tag") % n)
6264 raise util.Abort(_("tag '%s' is not a local tag") % n)
6226 rev_ = 'null'
6265 rev_ = 'null'
6227 if not message:
6266 if not message:
6228 # we don't translate commit messages
6267 # we don't translate commit messages
6229 message = 'Removed tag %s' % ', '.join(names)
6268 message = 'Removed tag %s' % ', '.join(names)
6230 elif not opts.get('force'):
6269 elif not opts.get('force'):
6231 for n in names:
6270 for n in names:
6232 if n in repo.tags():
6271 if n in repo.tags():
6233 raise util.Abort(_("tag '%s' already exists "
6272 raise util.Abort(_("tag '%s' already exists "
6234 "(use -f to force)") % n)
6273 "(use -f to force)") % n)
6235 if not opts.get('local'):
6274 if not opts.get('local'):
6236 p1, p2 = repo.dirstate.parents()
6275 p1, p2 = repo.dirstate.parents()
6237 if p2 != nullid:
6276 if p2 != nullid:
6238 raise util.Abort(_('uncommitted merge'))
6277 raise util.Abort(_('uncommitted merge'))
6239 bheads = repo.branchheads()
6278 bheads = repo.branchheads()
6240 if not opts.get('force') and bheads and p1 not in bheads:
6279 if not opts.get('force') and bheads and p1 not in bheads:
6241 raise util.Abort(_('not at a branch head (use -f to force)'))
6280 raise util.Abort(_('not at a branch head (use -f to force)'))
6242 r = scmutil.revsingle(repo, rev_).node()
6281 r = scmutil.revsingle(repo, rev_).node()
6243
6282
6244 if not message:
6283 if not message:
6245 # we don't translate commit messages
6284 # we don't translate commit messages
6246 message = ('Added tag %s for changeset %s' %
6285 message = ('Added tag %s for changeset %s' %
6247 (', '.join(names), short(r)))
6286 (', '.join(names), short(r)))
6248
6287
6249 date = opts.get('date')
6288 date = opts.get('date')
6250 if date:
6289 if date:
6251 date = util.parsedate(date)
6290 date = util.parsedate(date)
6252
6291
6253 if opts.get('remove'):
6292 if opts.get('remove'):
6254 editform = 'tag.remove'
6293 editform = 'tag.remove'
6255 else:
6294 else:
6256 editform = 'tag.add'
6295 editform = 'tag.add'
6257 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6296 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6258
6297
6259 # don't allow tagging the null rev
6298 # don't allow tagging the null rev
6260 if (not opts.get('remove') and
6299 if (not opts.get('remove') and
6261 scmutil.revsingle(repo, rev_).rev() == nullrev):
6300 scmutil.revsingle(repo, rev_).rev() == nullrev):
6262 raise util.Abort(_("cannot tag null revision"))
6301 raise util.Abort(_("cannot tag null revision"))
6263
6302
6264 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6303 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6265 editor=editor)
6304 editor=editor)
6266 finally:
6305 finally:
6267 release(lock, wlock)
6306 release(lock, wlock)
6268
6307
6269 @command('tags', formatteropts, '')
6308 @command('tags', formatteropts, '')
6270 def tags(ui, repo, **opts):
6309 def tags(ui, repo, **opts):
6271 """list repository tags
6310 """list repository tags
6272
6311
6273 This lists both regular and local tags. When the -v/--verbose
6312 This lists both regular and local tags. When the -v/--verbose
6274 switch is used, a third column "local" is printed for local tags.
6313 switch is used, a third column "local" is printed for local tags.
6275
6314
6276 Returns 0 on success.
6315 Returns 0 on success.
6277 """
6316 """
6278
6317
6279 fm = ui.formatter('tags', opts)
6318 fm = ui.formatter('tags', opts)
6280 hexfunc = fm.hexfunc
6319 hexfunc = fm.hexfunc
6281 tagtype = ""
6320 tagtype = ""
6282
6321
6283 for t, n in reversed(repo.tagslist()):
6322 for t, n in reversed(repo.tagslist()):
6284 hn = hexfunc(n)
6323 hn = hexfunc(n)
6285 label = 'tags.normal'
6324 label = 'tags.normal'
6286 tagtype = ''
6325 tagtype = ''
6287 if repo.tagtype(t) == 'local':
6326 if repo.tagtype(t) == 'local':
6288 label = 'tags.local'
6327 label = 'tags.local'
6289 tagtype = 'local'
6328 tagtype = 'local'
6290
6329
6291 fm.startitem()
6330 fm.startitem()
6292 fm.write('tag', '%s', t, label=label)
6331 fm.write('tag', '%s', t, label=label)
6293 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6332 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6294 fm.condwrite(not ui.quiet, 'rev node', fmt,
6333 fm.condwrite(not ui.quiet, 'rev node', fmt,
6295 repo.changelog.rev(n), hn, label=label)
6334 repo.changelog.rev(n), hn, label=label)
6296 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6335 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6297 tagtype, label=label)
6336 tagtype, label=label)
6298 fm.plain('\n')
6337 fm.plain('\n')
6299 fm.end()
6338 fm.end()
6300
6339
6301 @command('tip',
6340 @command('tip',
6302 [('p', 'patch', None, _('show patch')),
6341 [('p', 'patch', None, _('show patch')),
6303 ('g', 'git', None, _('use git extended diff format')),
6342 ('g', 'git', None, _('use git extended diff format')),
6304 ] + templateopts,
6343 ] + templateopts,
6305 _('[-p] [-g]'))
6344 _('[-p] [-g]'))
6306 def tip(ui, repo, **opts):
6345 def tip(ui, repo, **opts):
6307 """show the tip revision (DEPRECATED)
6346 """show the tip revision (DEPRECATED)
6308
6347
6309 The tip revision (usually just called the tip) is the changeset
6348 The tip revision (usually just called the tip) is the changeset
6310 most recently added to the repository (and therefore the most
6349 most recently added to the repository (and therefore the most
6311 recently changed head).
6350 recently changed head).
6312
6351
6313 If you have just made a commit, that commit will be the tip. If
6352 If you have just made a commit, that commit will be the tip. If
6314 you have just pulled changes from another repository, the tip of
6353 you have just pulled changes from another repository, the tip of
6315 that repository becomes the current tip. The "tip" tag is special
6354 that repository becomes the current tip. The "tip" tag is special
6316 and cannot be renamed or assigned to a different changeset.
6355 and cannot be renamed or assigned to a different changeset.
6317
6356
6318 This command is deprecated, please use :hg:`heads` instead.
6357 This command is deprecated, please use :hg:`heads` instead.
6319
6358
6320 Returns 0 on success.
6359 Returns 0 on success.
6321 """
6360 """
6322 displayer = cmdutil.show_changeset(ui, repo, opts)
6361 displayer = cmdutil.show_changeset(ui, repo, opts)
6323 displayer.show(repo['tip'])
6362 displayer.show(repo['tip'])
6324 displayer.close()
6363 displayer.close()
6325
6364
6326 @command('unbundle',
6365 @command('unbundle',
6327 [('u', 'update', None,
6366 [('u', 'update', None,
6328 _('update to new branch head if changesets were unbundled'))],
6367 _('update to new branch head if changesets were unbundled'))],
6329 _('[-u] FILE...'))
6368 _('[-u] FILE...'))
6330 def unbundle(ui, repo, fname1, *fnames, **opts):
6369 def unbundle(ui, repo, fname1, *fnames, **opts):
6331 """apply one or more changegroup files
6370 """apply one or more changegroup files
6332
6371
6333 Apply one or more compressed changegroup files generated by the
6372 Apply one or more compressed changegroup files generated by the
6334 bundle command.
6373 bundle command.
6335
6374
6336 Returns 0 on success, 1 if an update has unresolved files.
6375 Returns 0 on success, 1 if an update has unresolved files.
6337 """
6376 """
6338 fnames = (fname1,) + fnames
6377 fnames = (fname1,) + fnames
6339
6378
6340 lock = repo.lock()
6379 lock = repo.lock()
6341 try:
6380 try:
6342 for fname in fnames:
6381 for fname in fnames:
6343 f = hg.openpath(ui, fname)
6382 f = hg.openpath(ui, fname)
6344 gen = exchange.readbundle(ui, f, fname)
6383 gen = exchange.readbundle(ui, f, fname)
6345 if isinstance(gen, bundle2.unbundle20):
6384 if isinstance(gen, bundle2.unbundle20):
6346 tr = repo.transaction('unbundle')
6385 tr = repo.transaction('unbundle')
6347 try:
6386 try:
6348 op = bundle2.processbundle(repo, gen, lambda: tr)
6387 op = bundle2.processbundle(repo, gen, lambda: tr)
6349 tr.close()
6388 tr.close()
6350 finally:
6389 finally:
6351 if tr:
6390 if tr:
6352 tr.release()
6391 tr.release()
6353 changes = [r.get('result', 0)
6392 changes = [r.get('result', 0)
6354 for r in op.records['changegroup']]
6393 for r in op.records['changegroup']]
6355 modheads = changegroup.combineresults(changes)
6394 modheads = changegroup.combineresults(changes)
6356 else:
6395 else:
6357 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6396 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6358 'bundle:' + fname)
6397 'bundle:' + fname)
6359 finally:
6398 finally:
6360 lock.release()
6399 lock.release()
6361
6400
6362 return postincoming(ui, repo, modheads, opts.get('update'), None)
6401 return postincoming(ui, repo, modheads, opts.get('update'), None)
6363
6402
6364 @command('^update|up|checkout|co',
6403 @command('^update|up|checkout|co',
6365 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6404 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6366 ('c', 'check', None,
6405 ('c', 'check', None,
6367 _('update across branches if no uncommitted changes')),
6406 _('update across branches if no uncommitted changes')),
6368 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6407 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6369 ('r', 'rev', '', _('revision'), _('REV'))
6408 ('r', 'rev', '', _('revision'), _('REV'))
6370 ] + mergetoolopts,
6409 ] + mergetoolopts,
6371 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6410 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6372 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6411 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6373 tool=None):
6412 tool=None):
6374 """update working directory (or switch revisions)
6413 """update working directory (or switch revisions)
6375
6414
6376 Update the repository's working directory to the specified
6415 Update the repository's working directory to the specified
6377 changeset. If no changeset is specified, update to the tip of the
6416 changeset. If no changeset is specified, update to the tip of the
6378 current named branch and move the active bookmark (see :hg:`help
6417 current named branch and move the active bookmark (see :hg:`help
6379 bookmarks`).
6418 bookmarks`).
6380
6419
6381 Update sets the working directory's parent revision to the specified
6420 Update sets the working directory's parent revision to the specified
6382 changeset (see :hg:`help parents`).
6421 changeset (see :hg:`help parents`).
6383
6422
6384 If the changeset is not a descendant or ancestor of the working
6423 If the changeset is not a descendant or ancestor of the working
6385 directory's parent, the update is aborted. With the -c/--check
6424 directory's parent, the update is aborted. With the -c/--check
6386 option, the working directory is checked for uncommitted changes; if
6425 option, the working directory is checked for uncommitted changes; if
6387 none are found, the working directory is updated to the specified
6426 none are found, the working directory is updated to the specified
6388 changeset.
6427 changeset.
6389
6428
6390 .. container:: verbose
6429 .. container:: verbose
6391
6430
6392 The following rules apply when the working directory contains
6431 The following rules apply when the working directory contains
6393 uncommitted changes:
6432 uncommitted changes:
6394
6433
6395 1. If neither -c/--check nor -C/--clean is specified, and if
6434 1. If neither -c/--check nor -C/--clean is specified, and if
6396 the requested changeset is an ancestor or descendant of
6435 the requested changeset is an ancestor or descendant of
6397 the working directory's parent, the uncommitted changes
6436 the working directory's parent, the uncommitted changes
6398 are merged into the requested changeset and the merged
6437 are merged into the requested changeset and the merged
6399 result is left uncommitted. If the requested changeset is
6438 result is left uncommitted. If the requested changeset is
6400 not an ancestor or descendant (that is, it is on another
6439 not an ancestor or descendant (that is, it is on another
6401 branch), the update is aborted and the uncommitted changes
6440 branch), the update is aborted and the uncommitted changes
6402 are preserved.
6441 are preserved.
6403
6442
6404 2. With the -c/--check option, the update is aborted and the
6443 2. With the -c/--check option, the update is aborted and the
6405 uncommitted changes are preserved.
6444 uncommitted changes are preserved.
6406
6445
6407 3. With the -C/--clean option, uncommitted changes are discarded and
6446 3. With the -C/--clean option, uncommitted changes are discarded and
6408 the working directory is updated to the requested changeset.
6447 the working directory is updated to the requested changeset.
6409
6448
6410 To cancel an uncommitted merge (and lose your changes), use
6449 To cancel an uncommitted merge (and lose your changes), use
6411 :hg:`update --clean .`.
6450 :hg:`update --clean .`.
6412
6451
6413 Use null as the changeset to remove the working directory (like
6452 Use null as the changeset to remove the working directory (like
6414 :hg:`clone -U`).
6453 :hg:`clone -U`).
6415
6454
6416 If you want to revert just one file to an older revision, use
6455 If you want to revert just one file to an older revision, use
6417 :hg:`revert [-r REV] NAME`.
6456 :hg:`revert [-r REV] NAME`.
6418
6457
6419 See :hg:`help dates` for a list of formats valid for -d/--date.
6458 See :hg:`help dates` for a list of formats valid for -d/--date.
6420
6459
6421 Returns 0 on success, 1 if there are unresolved files.
6460 Returns 0 on success, 1 if there are unresolved files.
6422 """
6461 """
6423 if rev and node:
6462 if rev and node:
6424 raise util.Abort(_("please specify just one revision"))
6463 raise util.Abort(_("please specify just one revision"))
6425
6464
6426 if rev is None or rev == '':
6465 if rev is None or rev == '':
6427 rev = node
6466 rev = node
6428
6467
6429 wlock = repo.wlock()
6468 wlock = repo.wlock()
6430 try:
6469 try:
6431 cmdutil.clearunfinished(repo)
6470 cmdutil.clearunfinished(repo)
6432
6471
6433 if date:
6472 if date:
6434 if rev is not None:
6473 if rev is not None:
6435 raise util.Abort(_("you can't specify a revision and a date"))
6474 raise util.Abort(_("you can't specify a revision and a date"))
6436 rev = cmdutil.finddate(ui, repo, date)
6475 rev = cmdutil.finddate(ui, repo, date)
6437
6476
6438 # with no argument, we also move the active bookmark, if any
6477 # with no argument, we also move the active bookmark, if any
6439 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6478 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6440
6479
6441 # if we defined a bookmark, we have to remember the original name
6480 # if we defined a bookmark, we have to remember the original name
6442 brev = rev
6481 brev = rev
6443 rev = scmutil.revsingle(repo, rev, rev).rev()
6482 rev = scmutil.revsingle(repo, rev, rev).rev()
6444
6483
6445 if check and clean:
6484 if check and clean:
6446 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6485 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6447
6486
6448 if check:
6487 if check:
6449 cmdutil.bailifchanged(repo, merge=False)
6488 cmdutil.bailifchanged(repo, merge=False)
6450 if rev is None:
6489 if rev is None:
6451 rev = repo[repo[None].branch()].rev()
6490 rev = repo[repo[None].branch()].rev()
6452
6491
6453 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6492 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6454
6493
6455 if clean:
6494 if clean:
6456 ret = hg.clean(repo, rev)
6495 ret = hg.clean(repo, rev)
6457 else:
6496 else:
6458 ret = hg.update(repo, rev)
6497 ret = hg.update(repo, rev)
6459
6498
6460 if not ret and movemarkfrom:
6499 if not ret and movemarkfrom:
6461 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6500 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6462 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6501 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6463 else:
6502 else:
6464 # this can happen with a non-linear update
6503 # this can happen with a non-linear update
6465 ui.status(_("(leaving bookmark %s)\n") %
6504 ui.status(_("(leaving bookmark %s)\n") %
6466 repo._activebookmark)
6505 repo._activebookmark)
6467 bookmarks.deactivate(repo)
6506 bookmarks.deactivate(repo)
6468 elif brev in repo._bookmarks:
6507 elif brev in repo._bookmarks:
6469 bookmarks.activate(repo, brev)
6508 bookmarks.activate(repo, brev)
6470 ui.status(_("(activating bookmark %s)\n") % brev)
6509 ui.status(_("(activating bookmark %s)\n") % brev)
6471 elif brev:
6510 elif brev:
6472 if repo._activebookmark:
6511 if repo._activebookmark:
6473 ui.status(_("(leaving bookmark %s)\n") %
6512 ui.status(_("(leaving bookmark %s)\n") %
6474 repo._activebookmark)
6513 repo._activebookmark)
6475 bookmarks.deactivate(repo)
6514 bookmarks.deactivate(repo)
6476 finally:
6515 finally:
6477 wlock.release()
6516 wlock.release()
6478
6517
6479 return ret
6518 return ret
6480
6519
6481 @command('verify', [])
6520 @command('verify', [])
6482 def verify(ui, repo):
6521 def verify(ui, repo):
6483 """verify the integrity of the repository
6522 """verify the integrity of the repository
6484
6523
6485 Verify the integrity of the current repository.
6524 Verify the integrity of the current repository.
6486
6525
6487 This will perform an extensive check of the repository's
6526 This will perform an extensive check of the repository's
6488 integrity, validating the hashes and checksums of each entry in
6527 integrity, validating the hashes and checksums of each entry in
6489 the changelog, manifest, and tracked files, as well as the
6528 the changelog, manifest, and tracked files, as well as the
6490 integrity of their crosslinks and indices.
6529 integrity of their crosslinks and indices.
6491
6530
6492 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
6531 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
6493 for more information about recovery from corruption of the
6532 for more information about recovery from corruption of the
6494 repository.
6533 repository.
6495
6534
6496 Returns 0 on success, 1 if errors are encountered.
6535 Returns 0 on success, 1 if errors are encountered.
6497 """
6536 """
6498 return hg.verify(repo)
6537 return hg.verify(repo)
6499
6538
6500 @command('version', [], norepo=True)
6539 @command('version', [], norepo=True)
6501 def version_(ui):
6540 def version_(ui):
6502 """output version and copyright information"""
6541 """output version and copyright information"""
6503 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6542 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6504 % util.version())
6543 % util.version())
6505 ui.status(_(
6544 ui.status(_(
6506 "(see http://mercurial.selenic.com for more information)\n"
6545 "(see http://mercurial.selenic.com for more information)\n"
6507 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6546 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6508 "This is free software; see the source for copying conditions. "
6547 "This is free software; see the source for copying conditions. "
6509 "There is NO\nwarranty; "
6548 "There is NO\nwarranty; "
6510 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6549 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6511 ))
6550 ))
6512
6551
6513 ui.note(_("\nEnabled extensions:\n\n"))
6552 ui.note(_("\nEnabled extensions:\n\n"))
6514 if ui.verbose:
6553 if ui.verbose:
6515 # format names and versions into columns
6554 # format names and versions into columns
6516 names = []
6555 names = []
6517 vers = []
6556 vers = []
6518 for name, module in extensions.extensions():
6557 for name, module in extensions.extensions():
6519 names.append(name)
6558 names.append(name)
6520 vers.append(extensions.moduleversion(module))
6559 vers.append(extensions.moduleversion(module))
6521 if names:
6560 if names:
6522 maxnamelen = max(len(n) for n in names)
6561 maxnamelen = max(len(n) for n in names)
6523 for i, name in enumerate(names):
6562 for i, name in enumerate(names):
6524 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
6563 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,340 +1,342 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 add
3 add
4 addremove
4 addremove
5 annotate
5 annotate
6 archive
6 archive
7 backout
7 backout
8 bisect
8 bisect
9 bookmarks
9 bookmarks
10 branch
10 branch
11 branches
11 branches
12 bundle
12 bundle
13 cat
13 cat
14 clone
14 clone
15 commit
15 commit
16 config
16 config
17 copy
17 copy
18 diff
18 diff
19 export
19 export
20 files
20 files
21 forget
21 forget
22 graft
22 graft
23 grep
23 grep
24 heads
24 heads
25 help
25 help
26 identify
26 identify
27 import
27 import
28 incoming
28 incoming
29 init
29 init
30 locate
30 locate
31 log
31 log
32 manifest
32 manifest
33 merge
33 merge
34 outgoing
34 outgoing
35 parents
35 parents
36 paths
36 paths
37 phase
37 phase
38 pull
38 pull
39 push
39 push
40 recover
40 recover
41 remove
41 remove
42 rename
42 rename
43 resolve
43 resolve
44 revert
44 revert
45 rollback
45 rollback
46 root
46 root
47 serve
47 serve
48 status
48 status
49 summary
49 summary
50 tag
50 tag
51 tags
51 tags
52 tip
52 tip
53 unbundle
53 unbundle
54 update
54 update
55 verify
55 verify
56 version
56 version
57
57
58 Show all commands that start with "a"
58 Show all commands that start with "a"
59 $ hg debugcomplete a
59 $ hg debugcomplete a
60 add
60 add
61 addremove
61 addremove
62 annotate
62 annotate
63 archive
63 archive
64
64
65 Do not show debug commands if there are other candidates
65 Do not show debug commands if there are other candidates
66 $ hg debugcomplete d
66 $ hg debugcomplete d
67 diff
67 diff
68
68
69 Show debug commands if there are no other candidates
69 Show debug commands if there are no other candidates
70 $ hg debugcomplete debug
70 $ hg debugcomplete debug
71 debugancestor
71 debugancestor
72 debugbuilddag
72 debugbuilddag
73 debugbundle
73 debugbundle
74 debugcheckstate
74 debugcheckstate
75 debugcommands
75 debugcommands
76 debugcomplete
76 debugcomplete
77 debugconfig
77 debugconfig
78 debugdag
78 debugdag
79 debugdata
79 debugdata
80 debugdate
80 debugdate
81 debugdirstate
81 debugdirstate
82 debugdiscovery
82 debugdiscovery
83 debugextensions
83 debugfileset
84 debugfileset
84 debugfsinfo
85 debugfsinfo
85 debuggetbundle
86 debuggetbundle
86 debugignore
87 debugignore
87 debugindex
88 debugindex
88 debugindexdot
89 debugindexdot
89 debuginstall
90 debuginstall
90 debugknown
91 debugknown
91 debuglabelcomplete
92 debuglabelcomplete
92 debuglocks
93 debuglocks
93 debugnamecomplete
94 debugnamecomplete
94 debugobsolete
95 debugobsolete
95 debugpathcomplete
96 debugpathcomplete
96 debugpushkey
97 debugpushkey
97 debugpvec
98 debugpvec
98 debugrebuilddirstate
99 debugrebuilddirstate
99 debugrebuildfncache
100 debugrebuildfncache
100 debugrename
101 debugrename
101 debugrevlog
102 debugrevlog
102 debugrevspec
103 debugrevspec
103 debugsetparents
104 debugsetparents
104 debugsub
105 debugsub
105 debugsuccessorssets
106 debugsuccessorssets
106 debugwalk
107 debugwalk
107 debugwireargs
108 debugwireargs
108
109
109 Do not show the alias of a debug command if there are other candidates
110 Do not show the alias of a debug command if there are other candidates
110 (this should hide rawcommit)
111 (this should hide rawcommit)
111 $ hg debugcomplete r
112 $ hg debugcomplete r
112 recover
113 recover
113 remove
114 remove
114 rename
115 rename
115 resolve
116 resolve
116 revert
117 revert
117 rollback
118 rollback
118 root
119 root
119 Show the alias of a debug command if there are no other candidates
120 Show the alias of a debug command if there are no other candidates
120 $ hg debugcomplete rawc
121 $ hg debugcomplete rawc
121
122
122
123
123 Show the global options
124 Show the global options
124 $ hg debugcomplete --options | sort
125 $ hg debugcomplete --options | sort
125 --config
126 --config
126 --cwd
127 --cwd
127 --debug
128 --debug
128 --debugger
129 --debugger
129 --encoding
130 --encoding
130 --encodingmode
131 --encodingmode
131 --help
132 --help
132 --hidden
133 --hidden
133 --noninteractive
134 --noninteractive
134 --profile
135 --profile
135 --quiet
136 --quiet
136 --repository
137 --repository
137 --time
138 --time
138 --traceback
139 --traceback
139 --verbose
140 --verbose
140 --version
141 --version
141 -R
142 -R
142 -h
143 -h
143 -q
144 -q
144 -v
145 -v
145 -y
146 -y
146
147
147 Show the options for the "serve" command
148 Show the options for the "serve" command
148 $ hg debugcomplete --options serve | sort
149 $ hg debugcomplete --options serve | sort
149 --accesslog
150 --accesslog
150 --address
151 --address
151 --certificate
152 --certificate
152 --cmdserver
153 --cmdserver
153 --config
154 --config
154 --cwd
155 --cwd
155 --daemon
156 --daemon
156 --daemon-pipefds
157 --daemon-pipefds
157 --debug
158 --debug
158 --debugger
159 --debugger
159 --encoding
160 --encoding
160 --encodingmode
161 --encodingmode
161 --errorlog
162 --errorlog
162 --help
163 --help
163 --hidden
164 --hidden
164 --ipv6
165 --ipv6
165 --name
166 --name
166 --noninteractive
167 --noninteractive
167 --pid-file
168 --pid-file
168 --port
169 --port
169 --prefix
170 --prefix
170 --profile
171 --profile
171 --quiet
172 --quiet
172 --repository
173 --repository
173 --stdio
174 --stdio
174 --style
175 --style
175 --templates
176 --templates
176 --time
177 --time
177 --traceback
178 --traceback
178 --verbose
179 --verbose
179 --version
180 --version
180 --web-conf
181 --web-conf
181 -6
182 -6
182 -A
183 -A
183 -E
184 -E
184 -R
185 -R
185 -a
186 -a
186 -d
187 -d
187 -h
188 -h
188 -n
189 -n
189 -p
190 -p
190 -q
191 -q
191 -t
192 -t
192 -v
193 -v
193 -y
194 -y
194
195
195 Show an error if we use --options with an ambiguous abbreviation
196 Show an error if we use --options with an ambiguous abbreviation
196 $ hg debugcomplete --options s
197 $ hg debugcomplete --options s
197 hg: command 's' is ambiguous:
198 hg: command 's' is ambiguous:
198 serve showconfig status summary
199 serve showconfig status summary
199 [255]
200 [255]
200
201
201 Show all commands + options
202 Show all commands + options
202 $ hg debugcommands
203 $ hg debugcommands
203 add: include, exclude, subrepos, dry-run
204 add: include, exclude, subrepos, dry-run
204 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
205 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
205 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
206 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
206 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
207 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
207 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
208 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
208 export: output, switch-parent, rev, text, git, nodates
209 export: output, switch-parent, rev, text, git, nodates
209 forget: include, exclude
210 forget: include, exclude
210 init: ssh, remotecmd, insecure
211 init: ssh, remotecmd, insecure
211 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
212 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
212 merge: force, rev, preview, tool
213 merge: force, rev, preview, tool
213 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
214 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
214 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
215 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
215 remove: after, force, subrepos, include, exclude
216 remove: after, force, subrepos, include, exclude
216 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
217 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
217 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
218 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
218 summary: remote
219 summary: remote
219 update: clean, check, date, rev, tool
220 update: clean, check, date, rev, tool
220 addremove: similarity, subrepos, include, exclude, dry-run
221 addremove: similarity, subrepos, include, exclude, dry-run
221 archive: no-decode, prefix, rev, type, subrepos, include, exclude
222 archive: no-decode, prefix, rev, type, subrepos, include, exclude
222 backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
223 backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
223 bisect: reset, good, bad, skip, extend, command, noupdate
224 bisect: reset, good, bad, skip, extend, command, noupdate
224 bookmarks: force, rev, delete, rename, inactive, template
225 bookmarks: force, rev, delete, rename, inactive, template
225 branch: force, clean
226 branch: force, clean
226 branches: active, closed, template
227 branches: active, closed, template
227 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
228 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
228 cat: output, rev, decode, include, exclude
229 cat: output, rev, decode, include, exclude
229 config: untrusted, edit, local, global
230 config: untrusted, edit, local, global
230 copy: after, force, include, exclude, dry-run
231 copy: after, force, include, exclude, dry-run
231 debugancestor:
232 debugancestor:
232 debugbuilddag: mergeable-file, overwritten-file, new-file
233 debugbuilddag: mergeable-file, overwritten-file, new-file
233 debugbundle: all
234 debugbundle: all
234 debugcheckstate:
235 debugcheckstate:
235 debugcommands:
236 debugcommands:
236 debugcomplete: options
237 debugcomplete: options
237 debugdag: tags, branches, dots, spaces
238 debugdag: tags, branches, dots, spaces
238 debugdata: changelog, manifest, dir
239 debugdata: changelog, manifest, dir
239 debugdate: extended
240 debugdate: extended
240 debugdirstate: nodates, datesort
241 debugdirstate: nodates, datesort
241 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
242 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
243 debugextensions: template
242 debugfileset: rev
244 debugfileset: rev
243 debugfsinfo:
245 debugfsinfo:
244 debuggetbundle: head, common, type
246 debuggetbundle: head, common, type
245 debugignore:
247 debugignore:
246 debugindex: changelog, manifest, dir, format
248 debugindex: changelog, manifest, dir, format
247 debugindexdot:
249 debugindexdot:
248 debuginstall:
250 debuginstall:
249 debugknown:
251 debugknown:
250 debuglabelcomplete:
252 debuglabelcomplete:
251 debuglocks: force-lock, force-wlock
253 debuglocks: force-lock, force-wlock
252 debugnamecomplete:
254 debugnamecomplete:
253 debugobsolete: flags, record-parents, rev, date, user
255 debugobsolete: flags, record-parents, rev, date, user
254 debugpathcomplete: full, normal, added, removed
256 debugpathcomplete: full, normal, added, removed
255 debugpushkey:
257 debugpushkey:
256 debugpvec:
258 debugpvec:
257 debugrebuilddirstate: rev, minimal
259 debugrebuilddirstate: rev, minimal
258 debugrebuildfncache:
260 debugrebuildfncache:
259 debugrename: rev
261 debugrename: rev
260 debugrevlog: changelog, manifest, dir, dump
262 debugrevlog: changelog, manifest, dir, dump
261 debugrevspec: optimize
263 debugrevspec: optimize
262 debugsetparents:
264 debugsetparents:
263 debugsub: rev
265 debugsub: rev
264 debugsuccessorssets:
266 debugsuccessorssets:
265 debugwalk: include, exclude
267 debugwalk: include, exclude
266 debugwireargs: three, four, five, ssh, remotecmd, insecure
268 debugwireargs: three, four, five, ssh, remotecmd, insecure
267 files: rev, print0, include, exclude, template, subrepos
269 files: rev, print0, include, exclude, template, subrepos
268 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
270 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
269 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
271 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
270 heads: rev, topo, active, closed, style, template
272 heads: rev, topo, active, closed, style, template
271 help: extension, command, keyword
273 help: extension, command, keyword
272 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
274 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
273 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
275 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
274 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
276 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
275 locate: rev, print0, fullpath, include, exclude
277 locate: rev, print0, fullpath, include, exclude
276 manifest: rev, all, template
278 manifest: rev, all, template
277 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
279 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
278 parents: rev, style, template
280 parents: rev, style, template
279 paths:
281 paths:
280 phase: public, draft, secret, force, rev
282 phase: public, draft, secret, force, rev
281 recover:
283 recover:
282 rename: after, force, include, exclude, dry-run
284 rename: after, force, include, exclude, dry-run
283 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
285 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
284 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
286 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
285 rollback: dry-run, force
287 rollback: dry-run, force
286 root:
288 root:
287 tag: force, local, rev, remove, edit, message, date, user
289 tag: force, local, rev, remove, edit, message, date, user
288 tags: template
290 tags: template
289 tip: patch, git, style, template
291 tip: patch, git, style, template
290 unbundle: update
292 unbundle: update
291 verify:
293 verify:
292 version:
294 version:
293
295
294 $ hg init a
296 $ hg init a
295 $ cd a
297 $ cd a
296 $ echo fee > fee
298 $ echo fee > fee
297 $ hg ci -q -Amfee
299 $ hg ci -q -Amfee
298 $ hg tag fee
300 $ hg tag fee
299 $ mkdir fie
301 $ mkdir fie
300 $ echo dead > fie/dead
302 $ echo dead > fie/dead
301 $ echo live > fie/live
303 $ echo live > fie/live
302 $ hg bookmark fo
304 $ hg bookmark fo
303 $ hg branch -q fie
305 $ hg branch -q fie
304 $ hg ci -q -Amfie
306 $ hg ci -q -Amfie
305 $ echo fo > fo
307 $ echo fo > fo
306 $ hg branch -qf default
308 $ hg branch -qf default
307 $ hg ci -q -Amfo
309 $ hg ci -q -Amfo
308 $ echo Fum > Fum
310 $ echo Fum > Fum
309 $ hg ci -q -AmFum
311 $ hg ci -q -AmFum
310 $ hg bookmark Fum
312 $ hg bookmark Fum
311
313
312 Test debugpathcomplete
314 Test debugpathcomplete
313
315
314 $ hg debugpathcomplete f
316 $ hg debugpathcomplete f
315 fee
317 fee
316 fie
318 fie
317 fo
319 fo
318 $ hg debugpathcomplete -f f
320 $ hg debugpathcomplete -f f
319 fee
321 fee
320 fie/dead
322 fie/dead
321 fie/live
323 fie/live
322 fo
324 fo
323
325
324 $ hg rm Fum
326 $ hg rm Fum
325 $ hg debugpathcomplete -r F
327 $ hg debugpathcomplete -r F
326 Fum
328 Fum
327
329
328 Test debugnamecomplete
330 Test debugnamecomplete
329
331
330 $ hg debugnamecomplete
332 $ hg debugnamecomplete
331 Fum
333 Fum
332 default
334 default
333 fee
335 fee
334 fie
336 fie
335 fo
337 fo
336 tip
338 tip
337 $ hg debugnamecomplete f
339 $ hg debugnamecomplete f
338 fee
340 fee
339 fie
341 fie
340 fo
342 fo
@@ -1,1178 +1,1171 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 > def reposetup(ui, repo):
10 > def reposetup(ui, repo):
11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
13 > @command('foo', [], 'hg foo')
13 > @command('foo', [], 'hg foo')
14 > def foo(ui, *args, **kwargs):
14 > def foo(ui, *args, **kwargs):
15 > ui.write("Foo\\n")
15 > ui.write("Foo\\n")
16 > @command('bar', [], 'hg bar', norepo=True)
16 > @command('bar', [], 'hg bar', norepo=True)
17 > def bar(ui, *args, **kwargs):
17 > def bar(ui, *args, **kwargs):
18 > ui.write("Bar\\n")
18 > ui.write("Bar\\n")
19 > EOF
19 > EOF
20 $ abspath=`pwd`/foobar.py
20 $ abspath=`pwd`/foobar.py
21
21
22 $ mkdir barfoo
22 $ mkdir barfoo
23 $ cp foobar.py barfoo/__init__.py
23 $ cp foobar.py barfoo/__init__.py
24 $ barfoopath=`pwd`/barfoo
24 $ barfoopath=`pwd`/barfoo
25
25
26 $ hg init a
26 $ hg init a
27 $ cd a
27 $ cd a
28 $ echo foo > file
28 $ echo foo > file
29 $ hg add file
29 $ hg add file
30 $ hg commit -m 'add file'
30 $ hg commit -m 'add file'
31
31
32 $ echo '[extensions]' >> $HGRCPATH
32 $ echo '[extensions]' >> $HGRCPATH
33 $ echo "foobar = $abspath" >> $HGRCPATH
33 $ echo "foobar = $abspath" >> $HGRCPATH
34 $ hg foo
34 $ hg foo
35 uisetup called
35 uisetup called
36 reposetup called for a
36 reposetup called for a
37 ui == repo.ui
37 ui == repo.ui
38 Foo
38 Foo
39
39
40 $ cd ..
40 $ cd ..
41 $ hg clone a b
41 $ hg clone a b
42 uisetup called
42 uisetup called
43 reposetup called for a
43 reposetup called for a
44 ui == repo.ui
44 ui == repo.ui
45 reposetup called for b
45 reposetup called for b
46 ui == repo.ui
46 ui == repo.ui
47 updating to branch default
47 updating to branch default
48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
49
49
50 $ hg bar
50 $ hg bar
51 uisetup called
51 uisetup called
52 Bar
52 Bar
53 $ echo 'foobar = !' >> $HGRCPATH
53 $ echo 'foobar = !' >> $HGRCPATH
54
54
55 module/__init__.py-style
55 module/__init__.py-style
56
56
57 $ echo "barfoo = $barfoopath" >> $HGRCPATH
57 $ echo "barfoo = $barfoopath" >> $HGRCPATH
58 $ cd a
58 $ cd a
59 $ hg foo
59 $ hg foo
60 uisetup called
60 uisetup called
61 reposetup called for a
61 reposetup called for a
62 ui == repo.ui
62 ui == repo.ui
63 Foo
63 Foo
64 $ echo 'barfoo = !' >> $HGRCPATH
64 $ echo 'barfoo = !' >> $HGRCPATH
65
65
66 Check that extensions are loaded in phases:
66 Check that extensions are loaded in phases:
67
67
68 $ cat > foo.py <<EOF
68 $ cat > foo.py <<EOF
69 > import os
69 > import os
70 > name = os.path.basename(__file__).rsplit('.', 1)[0]
70 > name = os.path.basename(__file__).rsplit('.', 1)[0]
71 > print "1) %s imported" % name
71 > print "1) %s imported" % name
72 > def uisetup(ui):
72 > def uisetup(ui):
73 > print "2) %s uisetup" % name
73 > print "2) %s uisetup" % name
74 > def extsetup():
74 > def extsetup():
75 > print "3) %s extsetup" % name
75 > print "3) %s extsetup" % name
76 > def reposetup(ui, repo):
76 > def reposetup(ui, repo):
77 > print "4) %s reposetup" % name
77 > print "4) %s reposetup" % name
78 > EOF
78 > EOF
79
79
80 $ cp foo.py bar.py
80 $ cp foo.py bar.py
81 $ echo 'foo = foo.py' >> $HGRCPATH
81 $ echo 'foo = foo.py' >> $HGRCPATH
82 $ echo 'bar = bar.py' >> $HGRCPATH
82 $ echo 'bar = bar.py' >> $HGRCPATH
83
83
84 Command with no output, we just want to see the extensions loaded:
84 Command with no output, we just want to see the extensions loaded:
85
85
86 $ hg paths
86 $ hg paths
87 1) foo imported
87 1) foo imported
88 1) bar imported
88 1) bar imported
89 2) foo uisetup
89 2) foo uisetup
90 2) bar uisetup
90 2) bar uisetup
91 3) foo extsetup
91 3) foo extsetup
92 3) bar extsetup
92 3) bar extsetup
93 4) foo reposetup
93 4) foo reposetup
94 4) bar reposetup
94 4) bar reposetup
95
95
96 Check hgweb's load order:
96 Check hgweb's load order:
97
97
98 $ cat > hgweb.cgi <<EOF
98 $ cat > hgweb.cgi <<EOF
99 > #!/usr/bin/env python
99 > #!/usr/bin/env python
100 > from mercurial import demandimport; demandimport.enable()
100 > from mercurial import demandimport; demandimport.enable()
101 > from mercurial.hgweb import hgweb
101 > from mercurial.hgweb import hgweb
102 > from mercurial.hgweb import wsgicgi
102 > from mercurial.hgweb import wsgicgi
103 > application = hgweb('.', 'test repo')
103 > application = hgweb('.', 'test repo')
104 > wsgicgi.launch(application)
104 > wsgicgi.launch(application)
105 > EOF
105 > EOF
106
106
107 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
107 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
108 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
108 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
109 > | grep '^[0-9]) ' # ignores HTML output
109 > | grep '^[0-9]) ' # ignores HTML output
110 1) foo imported
110 1) foo imported
111 1) bar imported
111 1) bar imported
112 2) foo uisetup
112 2) foo uisetup
113 2) bar uisetup
113 2) bar uisetup
114 3) foo extsetup
114 3) foo extsetup
115 3) bar extsetup
115 3) bar extsetup
116 4) foo reposetup
116 4) foo reposetup
117 4) bar reposetup
117 4) bar reposetup
118
118
119 $ echo 'foo = !' >> $HGRCPATH
119 $ echo 'foo = !' >> $HGRCPATH
120 $ echo 'bar = !' >> $HGRCPATH
120 $ echo 'bar = !' >> $HGRCPATH
121
121
122 Check "from __future__ import absolute_import" support for external libraries
122 Check "from __future__ import absolute_import" support for external libraries
123
123
124 #if windows
124 #if windows
125 $ PATHSEP=";"
125 $ PATHSEP=";"
126 #else
126 #else
127 $ PATHSEP=":"
127 $ PATHSEP=":"
128 #endif
128 #endif
129 $ export PATHSEP
129 $ export PATHSEP
130
130
131 $ mkdir $TESTTMP/libroot
131 $ mkdir $TESTTMP/libroot
132 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
132 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
133 $ mkdir $TESTTMP/libroot/mod
133 $ mkdir $TESTTMP/libroot/mod
134 $ touch $TESTTMP/libroot/mod/__init__.py
134 $ touch $TESTTMP/libroot/mod/__init__.py
135 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
135 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
136
136
137 #if absimport
137 #if absimport
138 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
138 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
139 > from __future__ import absolute_import
139 > from __future__ import absolute_import
140 > import ambig # should load "libroot/ambig.py"
140 > import ambig # should load "libroot/ambig.py"
141 > s = ambig.s
141 > s = ambig.s
142 > EOF
142 > EOF
143 $ cat > loadabs.py <<EOF
143 $ cat > loadabs.py <<EOF
144 > import mod.ambigabs as ambigabs
144 > import mod.ambigabs as ambigabs
145 > def extsetup():
145 > def extsetup():
146 > print 'ambigabs.s=%s' % ambigabs.s
146 > print 'ambigabs.s=%s' % ambigabs.s
147 > EOF
147 > EOF
148 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
148 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
149 ambigabs.s=libroot/ambig.py
149 ambigabs.s=libroot/ambig.py
150 $TESTTMP/a (glob)
150 $TESTTMP/a (glob)
151 #endif
151 #endif
152
152
153 #if no-py3k
153 #if no-py3k
154 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
154 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
155 > import ambig # should load "libroot/mod/ambig.py"
155 > import ambig # should load "libroot/mod/ambig.py"
156 > s = ambig.s
156 > s = ambig.s
157 > EOF
157 > EOF
158 $ cat > loadrel.py <<EOF
158 $ cat > loadrel.py <<EOF
159 > import mod.ambigrel as ambigrel
159 > import mod.ambigrel as ambigrel
160 > def extsetup():
160 > def extsetup():
161 > print 'ambigrel.s=%s' % ambigrel.s
161 > print 'ambigrel.s=%s' % ambigrel.s
162 > EOF
162 > EOF
163 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
163 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
164 ambigrel.s=libroot/mod/ambig.py
164 ambigrel.s=libroot/mod/ambig.py
165 $TESTTMP/a (glob)
165 $TESTTMP/a (glob)
166 #endif
166 #endif
167
167
168 Check absolute/relative import of extension specific modules
168 Check absolute/relative import of extension specific modules
169
169
170 $ mkdir $TESTTMP/extroot
170 $ mkdir $TESTTMP/extroot
171 $ cat > $TESTTMP/extroot/bar.py <<EOF
171 $ cat > $TESTTMP/extroot/bar.py <<EOF
172 > s = 'this is extroot.bar'
172 > s = 'this is extroot.bar'
173 > EOF
173 > EOF
174 $ mkdir $TESTTMP/extroot/sub1
174 $ mkdir $TESTTMP/extroot/sub1
175 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
175 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
176 > s = 'this is extroot.sub1.__init__'
176 > s = 'this is extroot.sub1.__init__'
177 > EOF
177 > EOF
178 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
178 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
179 > s = 'this is extroot.sub1.baz'
179 > s = 'this is extroot.sub1.baz'
180 > EOF
180 > EOF
181 $ cat > $TESTTMP/extroot/__init__.py <<EOF
181 $ cat > $TESTTMP/extroot/__init__.py <<EOF
182 > s = 'this is extroot.__init__'
182 > s = 'this is extroot.__init__'
183 > import foo
183 > import foo
184 > def extsetup(ui):
184 > def extsetup(ui):
185 > ui.write('(extroot) ', foo.func(), '\n')
185 > ui.write('(extroot) ', foo.func(), '\n')
186 > EOF
186 > EOF
187
187
188 $ cat > $TESTTMP/extroot/foo.py <<EOF
188 $ cat > $TESTTMP/extroot/foo.py <<EOF
189 > # test absolute import
189 > # test absolute import
190 > buf = []
190 > buf = []
191 > def func():
191 > def func():
192 > # "not locals" case
192 > # "not locals" case
193 > import extroot.bar
193 > import extroot.bar
194 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
194 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
195 > return '\n(extroot) '.join(buf)
195 > return '\n(extroot) '.join(buf)
196 > # "fromlist == ('*',)" case
196 > # "fromlist == ('*',)" case
197 > from extroot.bar import *
197 > from extroot.bar import *
198 > buf.append('from extroot.bar import *: %s' % s)
198 > buf.append('from extroot.bar import *: %s' % s)
199 > # "not fromlist" and "if '.' in name" case
199 > # "not fromlist" and "if '.' in name" case
200 > import extroot.sub1.baz
200 > import extroot.sub1.baz
201 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
201 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
202 > # "not fromlist" and NOT "if '.' in name" case
202 > # "not fromlist" and NOT "if '.' in name" case
203 > import extroot
203 > import extroot
204 > buf.append('import extroot: %s' % extroot.s)
204 > buf.append('import extroot: %s' % extroot.s)
205 > # NOT "not fromlist" and NOT "level != -1" case
205 > # NOT "not fromlist" and NOT "level != -1" case
206 > from extroot.bar import s
206 > from extroot.bar import s
207 > buf.append('from extroot.bar import s: %s' % s)
207 > buf.append('from extroot.bar import s: %s' % s)
208 > EOF
208 > EOF
209 $ hg --config extensions.extroot=$TESTTMP/extroot root
209 $ hg --config extensions.extroot=$TESTTMP/extroot root
210 (extroot) from extroot.bar import *: this is extroot.bar
210 (extroot) from extroot.bar import *: this is extroot.bar
211 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
211 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
212 (extroot) import extroot: this is extroot.__init__
212 (extroot) import extroot: this is extroot.__init__
213 (extroot) from extroot.bar import s: this is extroot.bar
213 (extroot) from extroot.bar import s: this is extroot.bar
214 (extroot) import extroot.bar in func(): this is extroot.bar
214 (extroot) import extroot.bar in func(): this is extroot.bar
215 $TESTTMP/a (glob)
215 $TESTTMP/a (glob)
216
216
217 #if no-py3k
217 #if no-py3k
218 $ rm "$TESTTMP"/extroot/foo.*
218 $ rm "$TESTTMP"/extroot/foo.*
219 $ cat > $TESTTMP/extroot/foo.py <<EOF
219 $ cat > $TESTTMP/extroot/foo.py <<EOF
220 > # test relative import
220 > # test relative import
221 > buf = []
221 > buf = []
222 > def func():
222 > def func():
223 > # "not locals" case
223 > # "not locals" case
224 > import bar
224 > import bar
225 > buf.append('import bar in func(): %s' % bar.s)
225 > buf.append('import bar in func(): %s' % bar.s)
226 > return '\n(extroot) '.join(buf)
226 > return '\n(extroot) '.join(buf)
227 > # "fromlist == ('*',)" case
227 > # "fromlist == ('*',)" case
228 > from bar import *
228 > from bar import *
229 > buf.append('from bar import *: %s' % s)
229 > buf.append('from bar import *: %s' % s)
230 > # "not fromlist" and "if '.' in name" case
230 > # "not fromlist" and "if '.' in name" case
231 > import sub1.baz
231 > import sub1.baz
232 > buf.append('import sub1.baz: %s' % sub1.baz.s)
232 > buf.append('import sub1.baz: %s' % sub1.baz.s)
233 > # "not fromlist" and NOT "if '.' in name" case
233 > # "not fromlist" and NOT "if '.' in name" case
234 > import sub1
234 > import sub1
235 > buf.append('import sub1: %s' % sub1.s)
235 > buf.append('import sub1: %s' % sub1.s)
236 > # NOT "not fromlist" and NOT "level != -1" case
236 > # NOT "not fromlist" and NOT "level != -1" case
237 > from bar import s
237 > from bar import s
238 > buf.append('from bar import s: %s' % s)
238 > buf.append('from bar import s: %s' % s)
239 > EOF
239 > EOF
240 $ hg --config extensions.extroot=$TESTTMP/extroot root
240 $ hg --config extensions.extroot=$TESTTMP/extroot root
241 (extroot) from bar import *: this is extroot.bar
241 (extroot) from bar import *: this is extroot.bar
242 (extroot) import sub1.baz: this is extroot.sub1.baz
242 (extroot) import sub1.baz: this is extroot.sub1.baz
243 (extroot) import sub1: this is extroot.sub1.__init__
243 (extroot) import sub1: this is extroot.sub1.__init__
244 (extroot) from bar import s: this is extroot.bar
244 (extroot) from bar import s: this is extroot.bar
245 (extroot) import bar in func(): this is extroot.bar
245 (extroot) import bar in func(): this is extroot.bar
246 $TESTTMP/a (glob)
246 $TESTTMP/a (glob)
247 #endif
247 #endif
248
248
249 $ cd ..
249 $ cd ..
250
250
251 hide outer repo
251 hide outer repo
252 $ hg init
252 $ hg init
253
253
254 $ cat > empty.py <<EOF
254 $ cat > empty.py <<EOF
255 > '''empty cmdtable
255 > '''empty cmdtable
256 > '''
256 > '''
257 > cmdtable = {}
257 > cmdtable = {}
258 > EOF
258 > EOF
259 $ emptypath=`pwd`/empty.py
259 $ emptypath=`pwd`/empty.py
260 $ echo "empty = $emptypath" >> $HGRCPATH
260 $ echo "empty = $emptypath" >> $HGRCPATH
261 $ hg help empty
261 $ hg help empty
262 empty extension - empty cmdtable
262 empty extension - empty cmdtable
263
263
264 no commands defined
264 no commands defined
265
265
266
266
267 $ echo 'empty = !' >> $HGRCPATH
267 $ echo 'empty = !' >> $HGRCPATH
268
268
269 $ cat > debugextension.py <<EOF
269 $ cat > debugextension.py <<EOF
270 > '''only debugcommands
270 > '''only debugcommands
271 > '''
271 > '''
272 > from mercurial import cmdutil
272 > from mercurial import cmdutil
273 > cmdtable = {}
273 > cmdtable = {}
274 > command = cmdutil.command(cmdtable)
274 > command = cmdutil.command(cmdtable)
275 > @command('debugfoobar', [], 'hg debugfoobar')
275 > @command('debugfoobar', [], 'hg debugfoobar')
276 > def debugfoobar(ui, repo, *args, **opts):
276 > def debugfoobar(ui, repo, *args, **opts):
277 > "yet another debug command"
277 > "yet another debug command"
278 > pass
278 > pass
279 > @command('foo', [], 'hg foo')
279 > @command('foo', [], 'hg foo')
280 > def foo(ui, repo, *args, **opts):
280 > def foo(ui, repo, *args, **opts):
281 > """yet another foo command
281 > """yet another foo command
282 > This command has been DEPRECATED since forever.
282 > This command has been DEPRECATED since forever.
283 > """
283 > """
284 > pass
284 > pass
285 > EOF
285 > EOF
286 $ debugpath=`pwd`/debugextension.py
286 $ debugpath=`pwd`/debugextension.py
287 $ echo "debugextension = $debugpath" >> $HGRCPATH
287 $ echo "debugextension = $debugpath" >> $HGRCPATH
288
288
289 $ hg help debugextension
289 $ hg help debugextension
290 debugextension extension - only debugcommands
290 hg debugextensions
291
292 show information about active extensions
291
293
292 no commands defined
294 options:
295
296 (some details hidden, use --verbose to show complete help)
293
297
294
298
295 $ hg --verbose help debugextension
299 $ hg --verbose help debugextension
296 debugextension extension - only debugcommands
300 hg debugextensions
301
302 show information about active extensions
297
303
298 list of commands:
304 options:
299
305
300 foo yet another foo command
306 -T --template TEMPLATE display with template (EXPERIMENTAL)
301
307
302 global options ([+] can be repeated):
308 global options ([+] can be repeated):
303
309
304 -R --repository REPO repository root directory or name of overlay bundle
310 -R --repository REPO repository root directory or name of overlay bundle
305 file
311 file
306 --cwd DIR change working directory
312 --cwd DIR change working directory
307 -y --noninteractive do not prompt, automatically pick the first choice for
313 -y --noninteractive do not prompt, automatically pick the first choice for
308 all prompts
314 all prompts
309 -q --quiet suppress output
315 -q --quiet suppress output
310 -v --verbose enable additional output
316 -v --verbose enable additional output
311 --config CONFIG [+] set/override config option (use 'section.name=value')
317 --config CONFIG [+] set/override config option (use 'section.name=value')
312 --debug enable debugging output
318 --debug enable debugging output
313 --debugger start debugger
319 --debugger start debugger
314 --encoding ENCODE set the charset encoding (default: ascii)
320 --encoding ENCODE set the charset encoding (default: ascii)
315 --encodingmode MODE set the charset encoding mode (default: strict)
321 --encodingmode MODE set the charset encoding mode (default: strict)
316 --traceback always print a traceback on exception
322 --traceback always print a traceback on exception
317 --time time how long the command takes
323 --time time how long the command takes
318 --profile print command execution profile
324 --profile print command execution profile
319 --version output version information and exit
325 --version output version information and exit
320 -h --help display help and exit
326 -h --help display help and exit
321 --hidden consider hidden changesets
327 --hidden consider hidden changesets
322
328
323
329
324
330
325
331
326
332
327
333
328 $ hg --debug help debugextension
334 $ hg --debug help debugextension
329 debugextension extension - only debugcommands
335 hg debugextensions
336
337 show information about active extensions
330
338
331 list of commands:
339 options:
332
340
333 debugfoobar yet another debug command
341 -T --template TEMPLATE display with template (EXPERIMENTAL)
334 foo yet another foo command
335
342
336 global options ([+] can be repeated):
343 global options ([+] can be repeated):
337
344
338 -R --repository REPO repository root directory or name of overlay bundle
345 -R --repository REPO repository root directory or name of overlay bundle
339 file
346 file
340 --cwd DIR change working directory
347 --cwd DIR change working directory
341 -y --noninteractive do not prompt, automatically pick the first choice for
348 -y --noninteractive do not prompt, automatically pick the first choice for
342 all prompts
349 all prompts
343 -q --quiet suppress output
350 -q --quiet suppress output
344 -v --verbose enable additional output
351 -v --verbose enable additional output
345 --config CONFIG [+] set/override config option (use 'section.name=value')
352 --config CONFIG [+] set/override config option (use 'section.name=value')
346 --debug enable debugging output
353 --debug enable debugging output
347 --debugger start debugger
354 --debugger start debugger
348 --encoding ENCODE set the charset encoding (default: ascii)
355 --encoding ENCODE set the charset encoding (default: ascii)
349 --encodingmode MODE set the charset encoding mode (default: strict)
356 --encodingmode MODE set the charset encoding mode (default: strict)
350 --traceback always print a traceback on exception
357 --traceback always print a traceback on exception
351 --time time how long the command takes
358 --time time how long the command takes
352 --profile print command execution profile
359 --profile print command execution profile
353 --version output version information and exit
360 --version output version information and exit
354 -h --help display help and exit
361 -h --help display help and exit
355 --hidden consider hidden changesets
362 --hidden consider hidden changesets
356
363
357
364
358
365
359
366
360
367
361 $ echo 'debugextension = !' >> $HGRCPATH
368 $ echo 'debugextension = !' >> $HGRCPATH
362
369
363 Extension module help vs command help:
370 Extension module help vs command help:
364
371
365 $ echo 'extdiff =' >> $HGRCPATH
372 $ echo 'extdiff =' >> $HGRCPATH
366 $ hg help extdiff
373 $ hg help extdiff
367 hg extdiff [OPT]... [FILE]...
374 hg extdiff [OPT]... [FILE]...
368
375
369 use external program to diff repository (or selected files)
376 use external program to diff repository (or selected files)
370
377
371 Show differences between revisions for the specified files, using an
378 Show differences between revisions for the specified files, using an
372 external program. The default program used is diff, with default options
379 external program. The default program used is diff, with default options
373 "-Npru".
380 "-Npru".
374
381
375 To select a different program, use the -p/--program option. The program
382 To select a different program, use the -p/--program option. The program
376 will be passed the names of two directories to compare. To pass additional
383 will be passed the names of two directories to compare. To pass additional
377 options to the program, use -o/--option. These will be passed before the
384 options to the program, use -o/--option. These will be passed before the
378 names of the directories to compare.
385 names of the directories to compare.
379
386
380 When two revision arguments are given, then changes are shown between
387 When two revision arguments are given, then changes are shown between
381 those revisions. If only one revision is specified then that revision is
388 those revisions. If only one revision is specified then that revision is
382 compared to the working directory, and, when no revisions are specified,
389 compared to the working directory, and, when no revisions are specified,
383 the working directory files are compared to its parent.
390 the working directory files are compared to its parent.
384
391
385 (use "hg help -e extdiff" to show help for the extdiff extension)
392 (use "hg help -e extdiff" to show help for the extdiff extension)
386
393
387 options ([+] can be repeated):
394 options ([+] can be repeated):
388
395
389 -p --program CMD comparison program to run
396 -p --program CMD comparison program to run
390 -o --option OPT [+] pass option to comparison program
397 -o --option OPT [+] pass option to comparison program
391 -r --rev REV [+] revision
398 -r --rev REV [+] revision
392 -c --change REV change made by revision
399 -c --change REV change made by revision
393 --patch compare patches for two revisions
400 --patch compare patches for two revisions
394 -I --include PATTERN [+] include names matching the given patterns
401 -I --include PATTERN [+] include names matching the given patterns
395 -X --exclude PATTERN [+] exclude names matching the given patterns
402 -X --exclude PATTERN [+] exclude names matching the given patterns
396 -S --subrepos recurse into subrepositories
403 -S --subrepos recurse into subrepositories
397
404
398 (some details hidden, use --verbose to show complete help)
405 (some details hidden, use --verbose to show complete help)
399
406
400
407
401
408
402
409
403
410
404
411
405
412
406
413
407
414
408
415
409 $ hg help --extension extdiff
416 $ hg help --extension extdiff
410 extdiff extension - command to allow external programs to compare revisions
417 extdiff extension - command to allow external programs to compare revisions
411
418
412 The extdiff Mercurial extension allows you to use external programs to compare
419 The extdiff Mercurial extension allows you to use external programs to compare
413 revisions, or revision with working directory. The external diff programs are
420 revisions, or revision with working directory. The external diff programs are
414 called with a configurable set of options and two non-option arguments: paths
421 called with a configurable set of options and two non-option arguments: paths
415 to directories containing snapshots of files to compare.
422 to directories containing snapshots of files to compare.
416
423
417 The extdiff extension also allows you to configure new diff commands, so you
424 The extdiff extension also allows you to configure new diff commands, so you
418 do not need to type "hg extdiff -p kdiff3" always.
425 do not need to type "hg extdiff -p kdiff3" always.
419
426
420 [extdiff]
427 [extdiff]
421 # add new command that runs GNU diff(1) in 'context diff' mode
428 # add new command that runs GNU diff(1) in 'context diff' mode
422 cdiff = gdiff -Nprc5
429 cdiff = gdiff -Nprc5
423 ## or the old way:
430 ## or the old way:
424 #cmd.cdiff = gdiff
431 #cmd.cdiff = gdiff
425 #opts.cdiff = -Nprc5
432 #opts.cdiff = -Nprc5
426
433
427 # add new command called meld, runs meld (no need to name twice). If
434 # add new command called meld, runs meld (no need to name twice). If
428 # the meld executable is not available, the meld tool in [merge-tools]
435 # the meld executable is not available, the meld tool in [merge-tools]
429 # will be used, if available
436 # will be used, if available
430 meld =
437 meld =
431
438
432 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
439 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
433 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
440 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
434 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
441 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
435 # your .vimrc
442 # your .vimrc
436 vimdiff = gvim -f "+next" \
443 vimdiff = gvim -f "+next" \
437 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
444 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
438
445
439 Tool arguments can include variables that are expanded at runtime:
446 Tool arguments can include variables that are expanded at runtime:
440
447
441 $parent1, $plabel1 - filename, descriptive label of first parent
448 $parent1, $plabel1 - filename, descriptive label of first parent
442 $child, $clabel - filename, descriptive label of child revision
449 $child, $clabel - filename, descriptive label of child revision
443 $parent2, $plabel2 - filename, descriptive label of second parent
450 $parent2, $plabel2 - filename, descriptive label of second parent
444 $root - repository root
451 $root - repository root
445 $parent is an alias for $parent1.
452 $parent is an alias for $parent1.
446
453
447 The extdiff extension will look in your [diff-tools] and [merge-tools]
454 The extdiff extension will look in your [diff-tools] and [merge-tools]
448 sections for diff tool arguments, when none are specified in [extdiff].
455 sections for diff tool arguments, when none are specified in [extdiff].
449
456
450 [extdiff]
457 [extdiff]
451 kdiff3 =
458 kdiff3 =
452
459
453 [diff-tools]
460 [diff-tools]
454 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
461 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
455
462
456 You can use -I/-X and list of file or directory names like normal "hg diff"
463 You can use -I/-X and list of file or directory names like normal "hg diff"
457 command. The extdiff extension makes snapshots of only needed files, so
464 command. The extdiff extension makes snapshots of only needed files, so
458 running the external diff program will actually be pretty fast (at least
465 running the external diff program will actually be pretty fast (at least
459 faster than having to compare the entire tree).
466 faster than having to compare the entire tree).
460
467
461 list of commands:
468 list of commands:
462
469
463 extdiff use external program to diff repository (or selected files)
470 extdiff use external program to diff repository (or selected files)
464
471
465 (use "hg help -v -e extdiff" to show built-in aliases and global options)
472 (use "hg help -v -e extdiff" to show built-in aliases and global options)
466
473
467
474
468
475
469
476
470
477
471
478
472
479
473
480
474
481
475
482
476
483
477
484
478
485
479
486
480
487
481
488
482 $ echo 'extdiff = !' >> $HGRCPATH
489 $ echo 'extdiff = !' >> $HGRCPATH
483
490
484 Test help topic with same name as extension
491 Test help topic with same name as extension
485
492
486 $ cat > multirevs.py <<EOF
493 $ cat > multirevs.py <<EOF
487 > from mercurial import cmdutil, commands
494 > from mercurial import cmdutil, commands
488 > cmdtable = {}
495 > cmdtable = {}
489 > command = cmdutil.command(cmdtable)
496 > command = cmdutil.command(cmdtable)
490 > """multirevs extension
497 > """multirevs extension
491 > Big multi-line module docstring."""
498 > Big multi-line module docstring."""
492 > @command('multirevs', [], 'ARG', norepo=True)
499 > @command('multirevs', [], 'ARG', norepo=True)
493 > def multirevs(ui, repo, arg, *args, **opts):
500 > def multirevs(ui, repo, arg, *args, **opts):
494 > """multirevs command"""
501 > """multirevs command"""
495 > pass
502 > pass
496 > EOF
503 > EOF
497 $ echo "multirevs = multirevs.py" >> $HGRCPATH
504 $ echo "multirevs = multirevs.py" >> $HGRCPATH
498
505
499 $ hg help multirevs
506 $ hg help multirevs
500 Specifying Multiple Revisions
507 Specifying Multiple Revisions
501 """""""""""""""""""""""""""""
508 """""""""""""""""""""""""""""
502
509
503 When Mercurial accepts more than one revision, they may be specified
510 When Mercurial accepts more than one revision, they may be specified
504 individually, or provided as a topologically continuous range, separated
511 individually, or provided as a topologically continuous range, separated
505 by the ":" character.
512 by the ":" character.
506
513
507 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
514 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
508 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
515 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
509 specified, it defaults to revision number 0. If END is not specified, it
516 specified, it defaults to revision number 0. If END is not specified, it
510 defaults to the tip. The range ":" thus means "all revisions".
517 defaults to the tip. The range ":" thus means "all revisions".
511
518
512 If BEGIN is greater than END, revisions are treated in reverse order.
519 If BEGIN is greater than END, revisions are treated in reverse order.
513
520
514 A range acts as a closed interval. This means that a range of 3:5 gives 3,
521 A range acts as a closed interval. This means that a range of 3:5 gives 3,
515 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
522 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
516
523
517 use "hg help -c multirevs" to see help for the multirevs command
524 use "hg help -c multirevs" to see help for the multirevs command
518
525
519
526
520
527
521
528
522
529
523
530
524 $ hg help -c multirevs
531 $ hg help -c multirevs
525 hg multirevs ARG
532 hg multirevs ARG
526
533
527 multirevs command
534 multirevs command
528
535
529 (some details hidden, use --verbose to show complete help)
536 (some details hidden, use --verbose to show complete help)
530
537
531
538
532
539
533 $ hg multirevs
540 $ hg multirevs
534 hg multirevs: invalid arguments
541 hg multirevs: invalid arguments
535 hg multirevs ARG
542 hg multirevs ARG
536
543
537 multirevs command
544 multirevs command
538
545
539 (use "hg multirevs -h" to show more help)
546 (use "hg multirevs -h" to show more help)
540 [255]
547 [255]
541
548
542
549
543
550
544 $ echo "multirevs = !" >> $HGRCPATH
551 $ echo "multirevs = !" >> $HGRCPATH
545
552
546 Issue811: Problem loading extensions twice (by site and by user)
553 Issue811: Problem loading extensions twice (by site and by user)
547
554
548 $ debugpath=`pwd`/debugissue811.py
549 $ cat > debugissue811.py <<EOF
550 > '''show all loaded extensions
551 > '''
552 > from mercurial import cmdutil, commands, extensions
553 > cmdtable = {}
554 > command = cmdutil.command(cmdtable)
555 > @command('debugextensions', [], 'hg debugextensions', norepo=True)
556 > def debugextensions(ui):
557 > "yet another debug command"
558 > ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
559 > EOF
560 $ cat <<EOF >> $HGRCPATH
555 $ cat <<EOF >> $HGRCPATH
561 > debugissue811 = $debugpath
562 > mq =
556 > mq =
563 > strip =
557 > strip =
564 > hgext.mq =
558 > hgext.mq =
565 > hgext/mq =
559 > hgext/mq =
566 > EOF
560 > EOF
567
561
568 Show extensions:
562 Show extensions:
569 (note that mq force load strip, also checking it's not loaded twice)
563 (note that mq force load strip, also checking it's not loaded twice)
570
564
571 $ hg debugextensions
565 $ hg debugextensions
572 debugissue811
566 mq
573 strip
567 strip
574 mq
575
568
576 For extensions, which name matches one of its commands, help
569 For extensions, which name matches one of its commands, help
577 message should ask '-v -e' to get list of built-in aliases
570 message should ask '-v -e' to get list of built-in aliases
578 along with extension help itself
571 along with extension help itself
579
572
580 $ mkdir $TESTTMP/d
573 $ mkdir $TESTTMP/d
581 $ cat > $TESTTMP/d/dodo.py <<EOF
574 $ cat > $TESTTMP/d/dodo.py <<EOF
582 > """
575 > """
583 > This is an awesome 'dodo' extension. It does nothing and
576 > This is an awesome 'dodo' extension. It does nothing and
584 > writes 'Foo foo'
577 > writes 'Foo foo'
585 > """
578 > """
586 > from mercurial import cmdutil, commands
579 > from mercurial import cmdutil, commands
587 > cmdtable = {}
580 > cmdtable = {}
588 > command = cmdutil.command(cmdtable)
581 > command = cmdutil.command(cmdtable)
589 > @command('dodo', [], 'hg dodo')
582 > @command('dodo', [], 'hg dodo')
590 > def dodo(ui, *args, **kwargs):
583 > def dodo(ui, *args, **kwargs):
591 > """Does nothing"""
584 > """Does nothing"""
592 > ui.write("I do nothing. Yay\\n")
585 > ui.write("I do nothing. Yay\\n")
593 > @command('foofoo', [], 'hg foofoo')
586 > @command('foofoo', [], 'hg foofoo')
594 > def foofoo(ui, *args, **kwargs):
587 > def foofoo(ui, *args, **kwargs):
595 > """Writes 'Foo foo'"""
588 > """Writes 'Foo foo'"""
596 > ui.write("Foo foo\\n")
589 > ui.write("Foo foo\\n")
597 > EOF
590 > EOF
598 $ dodopath=$TESTTMP/d/dodo.py
591 $ dodopath=$TESTTMP/d/dodo.py
599
592
600 $ echo "dodo = $dodopath" >> $HGRCPATH
593 $ echo "dodo = $dodopath" >> $HGRCPATH
601
594
602 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
595 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
603 $ hg help -e dodo
596 $ hg help -e dodo
604 dodo extension -
597 dodo extension -
605
598
606 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
599 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
607
600
608 list of commands:
601 list of commands:
609
602
610 dodo Does nothing
603 dodo Does nothing
611 foofoo Writes 'Foo foo'
604 foofoo Writes 'Foo foo'
612
605
613 (use "hg help -v -e dodo" to show built-in aliases and global options)
606 (use "hg help -v -e dodo" to show built-in aliases and global options)
614
607
615 Make sure that '-v -e' prints list of built-in aliases along with
608 Make sure that '-v -e' prints list of built-in aliases along with
616 extension help itself
609 extension help itself
617 $ hg help -v -e dodo
610 $ hg help -v -e dodo
618 dodo extension -
611 dodo extension -
619
612
620 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
613 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
621
614
622 list of commands:
615 list of commands:
623
616
624 dodo Does nothing
617 dodo Does nothing
625 foofoo Writes 'Foo foo'
618 foofoo Writes 'Foo foo'
626
619
627 global options ([+] can be repeated):
620 global options ([+] can be repeated):
628
621
629 -R --repository REPO repository root directory or name of overlay bundle
622 -R --repository REPO repository root directory or name of overlay bundle
630 file
623 file
631 --cwd DIR change working directory
624 --cwd DIR change working directory
632 -y --noninteractive do not prompt, automatically pick the first choice for
625 -y --noninteractive do not prompt, automatically pick the first choice for
633 all prompts
626 all prompts
634 -q --quiet suppress output
627 -q --quiet suppress output
635 -v --verbose enable additional output
628 -v --verbose enable additional output
636 --config CONFIG [+] set/override config option (use 'section.name=value')
629 --config CONFIG [+] set/override config option (use 'section.name=value')
637 --debug enable debugging output
630 --debug enable debugging output
638 --debugger start debugger
631 --debugger start debugger
639 --encoding ENCODE set the charset encoding (default: ascii)
632 --encoding ENCODE set the charset encoding (default: ascii)
640 --encodingmode MODE set the charset encoding mode (default: strict)
633 --encodingmode MODE set the charset encoding mode (default: strict)
641 --traceback always print a traceback on exception
634 --traceback always print a traceback on exception
642 --time time how long the command takes
635 --time time how long the command takes
643 --profile print command execution profile
636 --profile print command execution profile
644 --version output version information and exit
637 --version output version information and exit
645 -h --help display help and exit
638 -h --help display help and exit
646 --hidden consider hidden changesets
639 --hidden consider hidden changesets
647
640
648 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
641 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
649 $ hg help -v dodo
642 $ hg help -v dodo
650 hg dodo
643 hg dodo
651
644
652 Does nothing
645 Does nothing
653
646
654 (use "hg help -e dodo" to show help for the dodo extension)
647 (use "hg help -e dodo" to show help for the dodo extension)
655
648
656 options:
649 options:
657
650
658 --mq operate on patch repository
651 --mq operate on patch repository
659
652
660 global options ([+] can be repeated):
653 global options ([+] can be repeated):
661
654
662 -R --repository REPO repository root directory or name of overlay bundle
655 -R --repository REPO repository root directory or name of overlay bundle
663 file
656 file
664 --cwd DIR change working directory
657 --cwd DIR change working directory
665 -y --noninteractive do not prompt, automatically pick the first choice for
658 -y --noninteractive do not prompt, automatically pick the first choice for
666 all prompts
659 all prompts
667 -q --quiet suppress output
660 -q --quiet suppress output
668 -v --verbose enable additional output
661 -v --verbose enable additional output
669 --config CONFIG [+] set/override config option (use 'section.name=value')
662 --config CONFIG [+] set/override config option (use 'section.name=value')
670 --debug enable debugging output
663 --debug enable debugging output
671 --debugger start debugger
664 --debugger start debugger
672 --encoding ENCODE set the charset encoding (default: ascii)
665 --encoding ENCODE set the charset encoding (default: ascii)
673 --encodingmode MODE set the charset encoding mode (default: strict)
666 --encodingmode MODE set the charset encoding mode (default: strict)
674 --traceback always print a traceback on exception
667 --traceback always print a traceback on exception
675 --time time how long the command takes
668 --time time how long the command takes
676 --profile print command execution profile
669 --profile print command execution profile
677 --version output version information and exit
670 --version output version information and exit
678 -h --help display help and exit
671 -h --help display help and exit
679 --hidden consider hidden changesets
672 --hidden consider hidden changesets
680
673
681 In case when extension name doesn't match any of its commands,
674 In case when extension name doesn't match any of its commands,
682 help message should ask for '-v' to get list of built-in aliases
675 help message should ask for '-v' to get list of built-in aliases
683 along with extension help
676 along with extension help
684 $ cat > $TESTTMP/d/dudu.py <<EOF
677 $ cat > $TESTTMP/d/dudu.py <<EOF
685 > """
678 > """
686 > This is an awesome 'dudu' extension. It does something and
679 > This is an awesome 'dudu' extension. It does something and
687 > also writes 'Beep beep'
680 > also writes 'Beep beep'
688 > """
681 > """
689 > from mercurial import cmdutil, commands
682 > from mercurial import cmdutil, commands
690 > cmdtable = {}
683 > cmdtable = {}
691 > command = cmdutil.command(cmdtable)
684 > command = cmdutil.command(cmdtable)
692 > @command('something', [], 'hg something')
685 > @command('something', [], 'hg something')
693 > def something(ui, *args, **kwargs):
686 > def something(ui, *args, **kwargs):
694 > """Does something"""
687 > """Does something"""
695 > ui.write("I do something. Yaaay\\n")
688 > ui.write("I do something. Yaaay\\n")
696 > @command('beep', [], 'hg beep')
689 > @command('beep', [], 'hg beep')
697 > def beep(ui, *args, **kwargs):
690 > def beep(ui, *args, **kwargs):
698 > """Writes 'Beep beep'"""
691 > """Writes 'Beep beep'"""
699 > ui.write("Beep beep\\n")
692 > ui.write("Beep beep\\n")
700 > EOF
693 > EOF
701 $ dudupath=$TESTTMP/d/dudu.py
694 $ dudupath=$TESTTMP/d/dudu.py
702
695
703 $ echo "dudu = $dudupath" >> $HGRCPATH
696 $ echo "dudu = $dudupath" >> $HGRCPATH
704
697
705 $ hg help -e dudu
698 $ hg help -e dudu
706 dudu extension -
699 dudu extension -
707
700
708 This is an awesome 'dudu' extension. It does something and also writes 'Beep
701 This is an awesome 'dudu' extension. It does something and also writes 'Beep
709 beep'
702 beep'
710
703
711 list of commands:
704 list of commands:
712
705
713 beep Writes 'Beep beep'
706 beep Writes 'Beep beep'
714 something Does something
707 something Does something
715
708
716 (use "hg help -v dudu" to show built-in aliases and global options)
709 (use "hg help -v dudu" to show built-in aliases and global options)
717
710
718 In case when extension name doesn't match any of its commands,
711 In case when extension name doesn't match any of its commands,
719 help options '-v' and '-v -e' should be equivalent
712 help options '-v' and '-v -e' should be equivalent
720 $ hg help -v dudu
713 $ hg help -v dudu
721 dudu extension -
714 dudu extension -
722
715
723 This is an awesome 'dudu' extension. It does something and also writes 'Beep
716 This is an awesome 'dudu' extension. It does something and also writes 'Beep
724 beep'
717 beep'
725
718
726 list of commands:
719 list of commands:
727
720
728 beep Writes 'Beep beep'
721 beep Writes 'Beep beep'
729 something Does something
722 something Does something
730
723
731 global options ([+] can be repeated):
724 global options ([+] can be repeated):
732
725
733 -R --repository REPO repository root directory or name of overlay bundle
726 -R --repository REPO repository root directory or name of overlay bundle
734 file
727 file
735 --cwd DIR change working directory
728 --cwd DIR change working directory
736 -y --noninteractive do not prompt, automatically pick the first choice for
729 -y --noninteractive do not prompt, automatically pick the first choice for
737 all prompts
730 all prompts
738 -q --quiet suppress output
731 -q --quiet suppress output
739 -v --verbose enable additional output
732 -v --verbose enable additional output
740 --config CONFIG [+] set/override config option (use 'section.name=value')
733 --config CONFIG [+] set/override config option (use 'section.name=value')
741 --debug enable debugging output
734 --debug enable debugging output
742 --debugger start debugger
735 --debugger start debugger
743 --encoding ENCODE set the charset encoding (default: ascii)
736 --encoding ENCODE set the charset encoding (default: ascii)
744 --encodingmode MODE set the charset encoding mode (default: strict)
737 --encodingmode MODE set the charset encoding mode (default: strict)
745 --traceback always print a traceback on exception
738 --traceback always print a traceback on exception
746 --time time how long the command takes
739 --time time how long the command takes
747 --profile print command execution profile
740 --profile print command execution profile
748 --version output version information and exit
741 --version output version information and exit
749 -h --help display help and exit
742 -h --help display help and exit
750 --hidden consider hidden changesets
743 --hidden consider hidden changesets
751
744
752 $ hg help -v -e dudu
745 $ hg help -v -e dudu
753 dudu extension -
746 dudu extension -
754
747
755 This is an awesome 'dudu' extension. It does something and also writes 'Beep
748 This is an awesome 'dudu' extension. It does something and also writes 'Beep
756 beep'
749 beep'
757
750
758 list of commands:
751 list of commands:
759
752
760 beep Writes 'Beep beep'
753 beep Writes 'Beep beep'
761 something Does something
754 something Does something
762
755
763 global options ([+] can be repeated):
756 global options ([+] can be repeated):
764
757
765 -R --repository REPO repository root directory or name of overlay bundle
758 -R --repository REPO repository root directory or name of overlay bundle
766 file
759 file
767 --cwd DIR change working directory
760 --cwd DIR change working directory
768 -y --noninteractive do not prompt, automatically pick the first choice for
761 -y --noninteractive do not prompt, automatically pick the first choice for
769 all prompts
762 all prompts
770 -q --quiet suppress output
763 -q --quiet suppress output
771 -v --verbose enable additional output
764 -v --verbose enable additional output
772 --config CONFIG [+] set/override config option (use 'section.name=value')
765 --config CONFIG [+] set/override config option (use 'section.name=value')
773 --debug enable debugging output
766 --debug enable debugging output
774 --debugger start debugger
767 --debugger start debugger
775 --encoding ENCODE set the charset encoding (default: ascii)
768 --encoding ENCODE set the charset encoding (default: ascii)
776 --encodingmode MODE set the charset encoding mode (default: strict)
769 --encodingmode MODE set the charset encoding mode (default: strict)
777 --traceback always print a traceback on exception
770 --traceback always print a traceback on exception
778 --time time how long the command takes
771 --time time how long the command takes
779 --profile print command execution profile
772 --profile print command execution profile
780 --version output version information and exit
773 --version output version information and exit
781 -h --help display help and exit
774 -h --help display help and exit
782 --hidden consider hidden changesets
775 --hidden consider hidden changesets
783
776
784 Disabled extension commands:
777 Disabled extension commands:
785
778
786 $ ORGHGRCPATH=$HGRCPATH
779 $ ORGHGRCPATH=$HGRCPATH
787 $ HGRCPATH=
780 $ HGRCPATH=
788 $ export HGRCPATH
781 $ export HGRCPATH
789 $ hg help email
782 $ hg help email
790 'email' is provided by the following extension:
783 'email' is provided by the following extension:
791
784
792 patchbomb command to send changesets as (a series of) patch emails
785 patchbomb command to send changesets as (a series of) patch emails
793
786
794 (use "hg help extensions" for information on enabling extensions)
787 (use "hg help extensions" for information on enabling extensions)
795
788
796
789
797 $ hg qdel
790 $ hg qdel
798 hg: unknown command 'qdel'
791 hg: unknown command 'qdel'
799 'qdelete' is provided by the following extension:
792 'qdelete' is provided by the following extension:
800
793
801 mq manage a stack of patches
794 mq manage a stack of patches
802
795
803 (use "hg help extensions" for information on enabling extensions)
796 (use "hg help extensions" for information on enabling extensions)
804 [255]
797 [255]
805
798
806
799
807 $ hg churn
800 $ hg churn
808 hg: unknown command 'churn'
801 hg: unknown command 'churn'
809 'churn' is provided by the following extension:
802 'churn' is provided by the following extension:
810
803
811 churn command to display statistics about repository history
804 churn command to display statistics about repository history
812
805
813 (use "hg help extensions" for information on enabling extensions)
806 (use "hg help extensions" for information on enabling extensions)
814 [255]
807 [255]
815
808
816
809
817
810
818 Disabled extensions:
811 Disabled extensions:
819
812
820 $ hg help churn
813 $ hg help churn
821 churn extension - command to display statistics about repository history
814 churn extension - command to display statistics about repository history
822
815
823 (use "hg help extensions" for information on enabling extensions)
816 (use "hg help extensions" for information on enabling extensions)
824
817
825 $ hg help patchbomb
818 $ hg help patchbomb
826 patchbomb extension - command to send changesets as (a series of) patch emails
819 patchbomb extension - command to send changesets as (a series of) patch emails
827
820
828 (use "hg help extensions" for information on enabling extensions)
821 (use "hg help extensions" for information on enabling extensions)
829
822
830
823
831 Broken disabled extension and command:
824 Broken disabled extension and command:
832
825
833 $ mkdir hgext
826 $ mkdir hgext
834 $ echo > hgext/__init__.py
827 $ echo > hgext/__init__.py
835 $ cat > hgext/broken.py <<EOF
828 $ cat > hgext/broken.py <<EOF
836 > "broken extension'
829 > "broken extension'
837 > EOF
830 > EOF
838 $ cat > path.py <<EOF
831 $ cat > path.py <<EOF
839 > import os, sys
832 > import os, sys
840 > sys.path.insert(0, os.environ['HGEXTPATH'])
833 > sys.path.insert(0, os.environ['HGEXTPATH'])
841 > EOF
834 > EOF
842 $ HGEXTPATH=`pwd`
835 $ HGEXTPATH=`pwd`
843 $ export HGEXTPATH
836 $ export HGEXTPATH
844
837
845 $ hg --config extensions.path=./path.py help broken
838 $ hg --config extensions.path=./path.py help broken
846 broken extension - (no help text available)
839 broken extension - (no help text available)
847
840
848 (use "hg help extensions" for information on enabling extensions)
841 (use "hg help extensions" for information on enabling extensions)
849
842
850
843
851 $ cat > hgext/forest.py <<EOF
844 $ cat > hgext/forest.py <<EOF
852 > cmdtable = None
845 > cmdtable = None
853 > EOF
846 > EOF
854 $ hg --config extensions.path=./path.py help foo > /dev/null
847 $ hg --config extensions.path=./path.py help foo > /dev/null
855 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
848 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
856 abort: no such help topic: foo
849 abort: no such help topic: foo
857 (try "hg help --keyword foo")
850 (try "hg help --keyword foo")
858 [255]
851 [255]
859
852
860 $ cat > throw.py <<EOF
853 $ cat > throw.py <<EOF
861 > from mercurial import cmdutil, commands, util
854 > from mercurial import cmdutil, commands, util
862 > cmdtable = {}
855 > cmdtable = {}
863 > command = cmdutil.command(cmdtable)
856 > command = cmdutil.command(cmdtable)
864 > class Bogon(Exception): pass
857 > class Bogon(Exception): pass
865 > @command('throw', [], 'hg throw', norepo=True)
858 > @command('throw', [], 'hg throw', norepo=True)
866 > def throw(ui, **opts):
859 > def throw(ui, **opts):
867 > """throws an exception"""
860 > """throws an exception"""
868 > raise Bogon()
861 > raise Bogon()
869 > EOF
862 > EOF
870
863
871 No declared supported version, extension complains:
864 No declared supported version, extension complains:
872 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
865 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
873 ** Unknown exception encountered with possibly-broken third-party extension throw
866 ** Unknown exception encountered with possibly-broken third-party extension throw
874 ** which supports versions unknown of Mercurial.
867 ** which supports versions unknown of Mercurial.
875 ** Please disable throw and try your action again.
868 ** Please disable throw and try your action again.
876 ** If that fixes the bug please report it to the extension author.
869 ** If that fixes the bug please report it to the extension author.
877 ** Python * (glob)
870 ** Python * (glob)
878 ** Mercurial Distributed SCM * (glob)
871 ** Mercurial Distributed SCM * (glob)
879 ** Extensions loaded: throw
872 ** Extensions loaded: throw
880
873
881 empty declaration of supported version, extension complains:
874 empty declaration of supported version, extension complains:
882 $ echo "testedwith = ''" >> throw.py
875 $ echo "testedwith = ''" >> throw.py
883 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
876 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
884 ** Unknown exception encountered with possibly-broken third-party extension throw
877 ** Unknown exception encountered with possibly-broken third-party extension throw
885 ** which supports versions unknown of Mercurial.
878 ** which supports versions unknown of Mercurial.
886 ** Please disable throw and try your action again.
879 ** Please disable throw and try your action again.
887 ** If that fixes the bug please report it to the extension author.
880 ** If that fixes the bug please report it to the extension author.
888 ** Python * (glob)
881 ** Python * (glob)
889 ** Mercurial Distributed SCM (*) (glob)
882 ** Mercurial Distributed SCM (*) (glob)
890 ** Extensions loaded: throw
883 ** Extensions loaded: throw
891
884
892 If the extension specifies a buglink, show that:
885 If the extension specifies a buglink, show that:
893 $ echo 'buglink = "http://example.com/bts"' >> throw.py
886 $ echo 'buglink = "http://example.com/bts"' >> throw.py
894 $ rm -f throw.pyc throw.pyo
887 $ rm -f throw.pyc throw.pyo
895 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
888 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
896 ** Unknown exception encountered with possibly-broken third-party extension throw
889 ** Unknown exception encountered with possibly-broken third-party extension throw
897 ** which supports versions unknown of Mercurial.
890 ** which supports versions unknown of Mercurial.
898 ** Please disable throw and try your action again.
891 ** Please disable throw and try your action again.
899 ** If that fixes the bug please report it to http://example.com/bts
892 ** If that fixes the bug please report it to http://example.com/bts
900 ** Python * (glob)
893 ** Python * (glob)
901 ** Mercurial Distributed SCM (*) (glob)
894 ** Mercurial Distributed SCM (*) (glob)
902 ** Extensions loaded: throw
895 ** Extensions loaded: throw
903
896
904 If the extensions declare outdated versions, accuse the older extension first:
897 If the extensions declare outdated versions, accuse the older extension first:
905 $ echo "from mercurial import util" >> older.py
898 $ echo "from mercurial import util" >> older.py
906 $ echo "util.version = lambda:'2.2'" >> older.py
899 $ echo "util.version = lambda:'2.2'" >> older.py
907 $ echo "testedwith = '1.9.3'" >> older.py
900 $ echo "testedwith = '1.9.3'" >> older.py
908 $ echo "testedwith = '2.1.1'" >> throw.py
901 $ echo "testedwith = '2.1.1'" >> throw.py
909 $ rm -f throw.pyc throw.pyo
902 $ rm -f throw.pyc throw.pyo
910 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
903 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
911 > throw 2>&1 | egrep '^\*\*'
904 > throw 2>&1 | egrep '^\*\*'
912 ** Unknown exception encountered with possibly-broken third-party extension older
905 ** Unknown exception encountered with possibly-broken third-party extension older
913 ** which supports versions 1.9 of Mercurial.
906 ** which supports versions 1.9 of Mercurial.
914 ** Please disable older and try your action again.
907 ** Please disable older and try your action again.
915 ** If that fixes the bug please report it to the extension author.
908 ** If that fixes the bug please report it to the extension author.
916 ** Python * (glob)
909 ** Python * (glob)
917 ** Mercurial Distributed SCM (version 2.2)
910 ** Mercurial Distributed SCM (version 2.2)
918 ** Extensions loaded: throw, older
911 ** Extensions loaded: throw, older
919
912
920 One extension only tested with older, one only with newer versions:
913 One extension only tested with older, one only with newer versions:
921 $ echo "util.version = lambda:'2.1'" >> older.py
914 $ echo "util.version = lambda:'2.1'" >> older.py
922 $ rm -f older.pyc older.pyo
915 $ rm -f older.pyc older.pyo
923 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
916 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
924 > throw 2>&1 | egrep '^\*\*'
917 > throw 2>&1 | egrep '^\*\*'
925 ** Unknown exception encountered with possibly-broken third-party extension older
918 ** Unknown exception encountered with possibly-broken third-party extension older
926 ** which supports versions 1.9 of Mercurial.
919 ** which supports versions 1.9 of Mercurial.
927 ** Please disable older and try your action again.
920 ** Please disable older and try your action again.
928 ** If that fixes the bug please report it to the extension author.
921 ** If that fixes the bug please report it to the extension author.
929 ** Python * (glob)
922 ** Python * (glob)
930 ** Mercurial Distributed SCM (version 2.1)
923 ** Mercurial Distributed SCM (version 2.1)
931 ** Extensions loaded: throw, older
924 ** Extensions loaded: throw, older
932
925
933 Older extension is tested with current version, the other only with newer:
926 Older extension is tested with current version, the other only with newer:
934 $ echo "util.version = lambda:'1.9.3'" >> older.py
927 $ echo "util.version = lambda:'1.9.3'" >> older.py
935 $ rm -f older.pyc older.pyo
928 $ rm -f older.pyc older.pyo
936 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
929 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
937 > throw 2>&1 | egrep '^\*\*'
930 > throw 2>&1 | egrep '^\*\*'
938 ** Unknown exception encountered with possibly-broken third-party extension throw
931 ** Unknown exception encountered with possibly-broken third-party extension throw
939 ** which supports versions 2.1 of Mercurial.
932 ** which supports versions 2.1 of Mercurial.
940 ** Please disable throw and try your action again.
933 ** Please disable throw and try your action again.
941 ** If that fixes the bug please report it to http://example.com/bts
934 ** If that fixes the bug please report it to http://example.com/bts
942 ** Python * (glob)
935 ** Python * (glob)
943 ** Mercurial Distributed SCM (version 1.9.3)
936 ** Mercurial Distributed SCM (version 1.9.3)
944 ** Extensions loaded: throw, older
937 ** Extensions loaded: throw, older
945
938
946 Ability to point to a different point
939 Ability to point to a different point
947 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
940 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
948 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
941 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
949 ** unknown exception encountered, please report by visiting
942 ** unknown exception encountered, please report by visiting
950 ** Your Local Goat Lenders
943 ** Your Local Goat Lenders
951 ** Python * (glob)
944 ** Python * (glob)
952 ** Mercurial Distributed SCM (*) (glob)
945 ** Mercurial Distributed SCM (*) (glob)
953 ** Extensions loaded: throw, older
946 ** Extensions loaded: throw, older
954
947
955 Declare the version as supporting this hg version, show regular bts link:
948 Declare the version as supporting this hg version, show regular bts link:
956 $ hgver=`$PYTHON -c 'from mercurial import util; print util.version().split("+")[0]'`
949 $ hgver=`$PYTHON -c 'from mercurial import util; print util.version().split("+")[0]'`
957 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
950 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
958 $ if [ -z "$hgver" ]; then
951 $ if [ -z "$hgver" ]; then
959 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
952 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
960 > fi
953 > fi
961 $ rm -f throw.pyc throw.pyo
954 $ rm -f throw.pyc throw.pyo
962 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
955 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
963 ** unknown exception encountered, please report by visiting
956 ** unknown exception encountered, please report by visiting
964 ** http://mercurial.selenic.com/wiki/BugTracker
957 ** http://mercurial.selenic.com/wiki/BugTracker
965 ** Python * (glob)
958 ** Python * (glob)
966 ** Mercurial Distributed SCM (*) (glob)
959 ** Mercurial Distributed SCM (*) (glob)
967 ** Extensions loaded: throw
960 ** Extensions loaded: throw
968
961
969 Patch version is ignored during compatibility check
962 Patch version is ignored during compatibility check
970 $ echo "testedwith = '3.2'" >> throw.py
963 $ echo "testedwith = '3.2'" >> throw.py
971 $ echo "util.version = lambda:'3.2.2'" >> throw.py
964 $ echo "util.version = lambda:'3.2.2'" >> throw.py
972 $ rm -f throw.pyc throw.pyo
965 $ rm -f throw.pyc throw.pyo
973 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
966 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
974 ** unknown exception encountered, please report by visiting
967 ** unknown exception encountered, please report by visiting
975 ** http://mercurial.selenic.com/wiki/BugTracker
968 ** http://mercurial.selenic.com/wiki/BugTracker
976 ** Python * (glob)
969 ** Python * (glob)
977 ** Mercurial Distributed SCM (*) (glob)
970 ** Mercurial Distributed SCM (*) (glob)
978 ** Extensions loaded: throw
971 ** Extensions loaded: throw
979
972
980 Test version number support in 'hg version':
973 Test version number support in 'hg version':
981 $ echo '__version__ = (1, 2, 3)' >> throw.py
974 $ echo '__version__ = (1, 2, 3)' >> throw.py
982 $ rm -f throw.pyc throw.pyo
975 $ rm -f throw.pyc throw.pyo
983 $ hg version -v
976 $ hg version -v
984 Mercurial Distributed SCM (version *) (glob)
977 Mercurial Distributed SCM (version *) (glob)
985 (see http://mercurial.selenic.com for more information)
978 (see http://mercurial.selenic.com for more information)
986
979
987 Copyright (C) 2005-* Matt Mackall and others (glob)
980 Copyright (C) 2005-* Matt Mackall and others (glob)
988 This is free software; see the source for copying conditions. There is NO
981 This is free software; see the source for copying conditions. There is NO
989 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
982 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
990
983
991 Enabled extensions:
984 Enabled extensions:
992
985
993
986
994 $ hg version -v --config extensions.throw=throw.py
987 $ hg version -v --config extensions.throw=throw.py
995 Mercurial Distributed SCM (version *) (glob)
988 Mercurial Distributed SCM (version *) (glob)
996 (see http://mercurial.selenic.com for more information)
989 (see http://mercurial.selenic.com for more information)
997
990
998 Copyright (C) 2005-* Matt Mackall and others (glob)
991 Copyright (C) 2005-* Matt Mackall and others (glob)
999 This is free software; see the source for copying conditions. There is NO
992 This is free software; see the source for copying conditions. There is NO
1000 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
993 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1001
994
1002 Enabled extensions:
995 Enabled extensions:
1003
996
1004 throw 1.2.3
997 throw 1.2.3
1005 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
998 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
1006 $ rm -f throw.pyc throw.pyo
999 $ rm -f throw.pyc throw.pyo
1007 $ hg version -v --config extensions.throw=throw.py
1000 $ hg version -v --config extensions.throw=throw.py
1008 Mercurial Distributed SCM (version *) (glob)
1001 Mercurial Distributed SCM (version *) (glob)
1009 (see http://mercurial.selenic.com for more information)
1002 (see http://mercurial.selenic.com for more information)
1010
1003
1011 Copyright (C) 2005-* Matt Mackall and others (glob)
1004 Copyright (C) 2005-* Matt Mackall and others (glob)
1012 This is free software; see the source for copying conditions. There is NO
1005 This is free software; see the source for copying conditions. There is NO
1013 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1006 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1014
1007
1015 Enabled extensions:
1008 Enabled extensions:
1016
1009
1017 throw 1.twentythree
1010 throw 1.twentythree
1018
1011
1019 Restore HGRCPATH
1012 Restore HGRCPATH
1020
1013
1021 $ HGRCPATH=$ORGHGRCPATH
1014 $ HGRCPATH=$ORGHGRCPATH
1022 $ export HGRCPATH
1015 $ export HGRCPATH
1023
1016
1024 Commands handling multiple repositories at a time should invoke only
1017 Commands handling multiple repositories at a time should invoke only
1025 "reposetup()" of extensions enabling in the target repository.
1018 "reposetup()" of extensions enabling in the target repository.
1026
1019
1027 $ mkdir reposetup-test
1020 $ mkdir reposetup-test
1028 $ cd reposetup-test
1021 $ cd reposetup-test
1029
1022
1030 $ cat > $TESTTMP/reposetuptest.py <<EOF
1023 $ cat > $TESTTMP/reposetuptest.py <<EOF
1031 > from mercurial import extensions
1024 > from mercurial import extensions
1032 > def reposetup(ui, repo):
1025 > def reposetup(ui, repo):
1033 > ui.write('reposetup() for %s\n' % (repo.root))
1026 > ui.write('reposetup() for %s\n' % (repo.root))
1034 > EOF
1027 > EOF
1035 $ hg init src
1028 $ hg init src
1036 $ echo a > src/a
1029 $ echo a > src/a
1037 $ hg -R src commit -Am '#0 at src/a'
1030 $ hg -R src commit -Am '#0 at src/a'
1038 adding a
1031 adding a
1039 $ echo '[extensions]' >> src/.hg/hgrc
1032 $ echo '[extensions]' >> src/.hg/hgrc
1040 $ echo '# enable extension locally' >> src/.hg/hgrc
1033 $ echo '# enable extension locally' >> src/.hg/hgrc
1041 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1034 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1042 $ hg -R src status
1035 $ hg -R src status
1043 reposetup() for $TESTTMP/reposetup-test/src (glob)
1036 reposetup() for $TESTTMP/reposetup-test/src (glob)
1044
1037
1045 $ hg clone -U src clone-dst1
1038 $ hg clone -U src clone-dst1
1046 reposetup() for $TESTTMP/reposetup-test/src (glob)
1039 reposetup() for $TESTTMP/reposetup-test/src (glob)
1047 $ hg init push-dst1
1040 $ hg init push-dst1
1048 $ hg -q -R src push push-dst1
1041 $ hg -q -R src push push-dst1
1049 reposetup() for $TESTTMP/reposetup-test/src (glob)
1042 reposetup() for $TESTTMP/reposetup-test/src (glob)
1050 $ hg init pull-src1
1043 $ hg init pull-src1
1051 $ hg -q -R pull-src1 pull src
1044 $ hg -q -R pull-src1 pull src
1052 reposetup() for $TESTTMP/reposetup-test/src (glob)
1045 reposetup() for $TESTTMP/reposetup-test/src (glob)
1053
1046
1054 $ cat <<EOF >> $HGRCPATH
1047 $ cat <<EOF >> $HGRCPATH
1055 > [extensions]
1048 > [extensions]
1056 > # disable extension globally and explicitly
1049 > # disable extension globally and explicitly
1057 > reposetuptest = !
1050 > reposetuptest = !
1058 > EOF
1051 > EOF
1059 $ hg clone -U src clone-dst2
1052 $ hg clone -U src clone-dst2
1060 reposetup() for $TESTTMP/reposetup-test/src (glob)
1053 reposetup() for $TESTTMP/reposetup-test/src (glob)
1061 $ hg init push-dst2
1054 $ hg init push-dst2
1062 $ hg -q -R src push push-dst2
1055 $ hg -q -R src push push-dst2
1063 reposetup() for $TESTTMP/reposetup-test/src (glob)
1056 reposetup() for $TESTTMP/reposetup-test/src (glob)
1064 $ hg init pull-src2
1057 $ hg init pull-src2
1065 $ hg -q -R pull-src2 pull src
1058 $ hg -q -R pull-src2 pull src
1066 reposetup() for $TESTTMP/reposetup-test/src (glob)
1059 reposetup() for $TESTTMP/reposetup-test/src (glob)
1067
1060
1068 $ cat <<EOF >> $HGRCPATH
1061 $ cat <<EOF >> $HGRCPATH
1069 > [extensions]
1062 > [extensions]
1070 > # enable extension globally
1063 > # enable extension globally
1071 > reposetuptest = $TESTTMP/reposetuptest.py
1064 > reposetuptest = $TESTTMP/reposetuptest.py
1072 > EOF
1065 > EOF
1073 $ hg clone -U src clone-dst3
1066 $ hg clone -U src clone-dst3
1074 reposetup() for $TESTTMP/reposetup-test/src (glob)
1067 reposetup() for $TESTTMP/reposetup-test/src (glob)
1075 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1068 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
1076 $ hg init push-dst3
1069 $ hg init push-dst3
1077 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1070 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1078 $ hg -q -R src push push-dst3
1071 $ hg -q -R src push push-dst3
1079 reposetup() for $TESTTMP/reposetup-test/src (glob)
1072 reposetup() for $TESTTMP/reposetup-test/src (glob)
1080 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1073 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
1081 $ hg init pull-src3
1074 $ hg init pull-src3
1082 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1075 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1083 $ hg -q -R pull-src3 pull src
1076 $ hg -q -R pull-src3 pull src
1084 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1077 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
1085 reposetup() for $TESTTMP/reposetup-test/src (glob)
1078 reposetup() for $TESTTMP/reposetup-test/src (glob)
1086
1079
1087 $ echo '[extensions]' >> src/.hg/hgrc
1080 $ echo '[extensions]' >> src/.hg/hgrc
1088 $ echo '# disable extension locally' >> src/.hg/hgrc
1081 $ echo '# disable extension locally' >> src/.hg/hgrc
1089 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1082 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1090 $ hg clone -U src clone-dst4
1083 $ hg clone -U src clone-dst4
1091 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1084 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
1092 $ hg init push-dst4
1085 $ hg init push-dst4
1093 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1086 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1094 $ hg -q -R src push push-dst4
1087 $ hg -q -R src push push-dst4
1095 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1088 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
1096 $ hg init pull-src4
1089 $ hg init pull-src4
1097 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1090 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1098 $ hg -q -R pull-src4 pull src
1091 $ hg -q -R pull-src4 pull src
1099 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1092 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
1100
1093
1101 disabling in command line overlays with all configuration
1094 disabling in command line overlays with all configuration
1102 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1095 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1103 $ hg --config extensions.reposetuptest=! init push-dst5
1096 $ hg --config extensions.reposetuptest=! init push-dst5
1104 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1097 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1105 $ hg --config extensions.reposetuptest=! init pull-src5
1098 $ hg --config extensions.reposetuptest=! init pull-src5
1106 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1099 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1107
1100
1108 $ cat <<EOF >> $HGRCPATH
1101 $ cat <<EOF >> $HGRCPATH
1109 > [extensions]
1102 > [extensions]
1110 > # disable extension globally and explicitly
1103 > # disable extension globally and explicitly
1111 > reposetuptest = !
1104 > reposetuptest = !
1112 > EOF
1105 > EOF
1113 $ hg init parent
1106 $ hg init parent
1114 $ hg init parent/sub1
1107 $ hg init parent/sub1
1115 $ echo 1 > parent/sub1/1
1108 $ echo 1 > parent/sub1/1
1116 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1109 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1117 adding 1
1110 adding 1
1118 $ hg init parent/sub2
1111 $ hg init parent/sub2
1119 $ hg init parent/sub2/sub21
1112 $ hg init parent/sub2/sub21
1120 $ echo 21 > parent/sub2/sub21/21
1113 $ echo 21 > parent/sub2/sub21/21
1121 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1114 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1122 adding 21
1115 adding 21
1123 $ cat > parent/sub2/.hgsub <<EOF
1116 $ cat > parent/sub2/.hgsub <<EOF
1124 > sub21 = sub21
1117 > sub21 = sub21
1125 > EOF
1118 > EOF
1126 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1119 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1127 adding .hgsub
1120 adding .hgsub
1128 $ hg init parent/sub3
1121 $ hg init parent/sub3
1129 $ echo 3 > parent/sub3/3
1122 $ echo 3 > parent/sub3/3
1130 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1123 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1131 adding 3
1124 adding 3
1132 $ cat > parent/.hgsub <<EOF
1125 $ cat > parent/.hgsub <<EOF
1133 > sub1 = sub1
1126 > sub1 = sub1
1134 > sub2 = sub2
1127 > sub2 = sub2
1135 > sub3 = sub3
1128 > sub3 = sub3
1136 > EOF
1129 > EOF
1137 $ hg -R parent commit -Am '#0 at parent'
1130 $ hg -R parent commit -Am '#0 at parent'
1138 adding .hgsub
1131 adding .hgsub
1139 $ echo '[extensions]' >> parent/.hg/hgrc
1132 $ echo '[extensions]' >> parent/.hg/hgrc
1140 $ echo '# enable extension locally' >> parent/.hg/hgrc
1133 $ echo '# enable extension locally' >> parent/.hg/hgrc
1141 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1134 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1142 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1135 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1143 $ hg -R parent status -S -A
1136 $ hg -R parent status -S -A
1144 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1137 reposetup() for $TESTTMP/reposetup-test/parent (glob)
1145 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1138 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
1146 C .hgsub
1139 C .hgsub
1147 C .hgsubstate
1140 C .hgsubstate
1148 C sub1/1
1141 C sub1/1
1149 C sub2/.hgsub
1142 C sub2/.hgsub
1150 C sub2/.hgsubstate
1143 C sub2/.hgsubstate
1151 C sub2/sub21/21
1144 C sub2/sub21/21
1152 C sub3/3
1145 C sub3/3
1153
1146
1154 $ cd ..
1147 $ cd ..
1155
1148
1156 Test synopsis and docstring extending
1149 Test synopsis and docstring extending
1157
1150
1158 $ hg init exthelp
1151 $ hg init exthelp
1159 $ cat > exthelp.py <<EOF
1152 $ cat > exthelp.py <<EOF
1160 > from mercurial import commands, extensions
1153 > from mercurial import commands, extensions
1161 > def exbookmarks(orig, *args, **opts):
1154 > def exbookmarks(orig, *args, **opts):
1162 > return orig(*args, **opts)
1155 > return orig(*args, **opts)
1163 > def uisetup(ui):
1156 > def uisetup(ui):
1164 > synopsis = ' GREPME [--foo] [-x]'
1157 > synopsis = ' GREPME [--foo] [-x]'
1165 > docstring = '''
1158 > docstring = '''
1166 > GREPME make sure that this is in the help!
1159 > GREPME make sure that this is in the help!
1167 > '''
1160 > '''
1168 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1161 > extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks,
1169 > synopsis, docstring)
1162 > synopsis, docstring)
1170 > EOF
1163 > EOF
1171 $ abspath=`pwd`/exthelp.py
1164 $ abspath=`pwd`/exthelp.py
1172 $ echo '[extensions]' >> $HGRCPATH
1165 $ echo '[extensions]' >> $HGRCPATH
1173 $ echo "exthelp = $abspath" >> $HGRCPATH
1166 $ echo "exthelp = $abspath" >> $HGRCPATH
1174 $ cd exthelp
1167 $ cd exthelp
1175 $ hg help bookmarks | grep GREPME
1168 $ hg help bookmarks | grep GREPME
1176 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1169 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1177 GREPME make sure that this is in the help!
1170 GREPME make sure that this is in the help!
1178
1171
@@ -1,2345 +1,2347 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 for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
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 merge-tools Merge Tools
114 merge-tools Merge Tools
115 multirevs Specifying Multiple Revisions
115 multirevs Specifying Multiple Revisions
116 patterns File Name Patterns
116 patterns File Name Patterns
117 phases Working with Phases
117 phases Working with Phases
118 revisions Specifying Single Revisions
118 revisions Specifying Single Revisions
119 revsets Specifying Revision Sets
119 revsets Specifying Revision Sets
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 for a pattern in specified files and revisions
148 grep search for a pattern in specified files and revisions
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 merge-tools Merge Tools
190 merge-tools Merge Tools
191 multirevs Specifying Multiple Revisions
191 multirevs Specifying Multiple Revisions
192 patterns File Name Patterns
192 patterns File Name Patterns
193 phases Working with Phases
193 phases Working with Phases
194 revisions Specifying Single Revisions
194 revisions Specifying Single Revisions
195 revsets Specifying Revision Sets
195 revsets Specifying Revision Sets
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 color colorize output from some commands
252 color colorize output from some commands
253 convert import revisions from foreign VCS repositories into
253 convert import revisions from foreign VCS repositories into
254 Mercurial
254 Mercurial
255 eol automatically manage newlines in repository files
255 eol automatically manage newlines in repository files
256 extdiff command to allow external programs to compare revisions
256 extdiff command to allow external programs to compare revisions
257 factotum http authentication with factotum
257 factotum http authentication with factotum
258 gpg commands to sign and verify changesets
258 gpg commands to sign and verify changesets
259 hgcia hooks for integrating with the CIA.vc notification service
259 hgcia hooks for integrating with the CIA.vc notification service
260 hgk browse the repository in a graphical way
260 hgk browse the repository in a graphical way
261 highlight syntax highlighting for hgweb (requires Pygments)
261 highlight syntax highlighting for hgweb (requires Pygments)
262 histedit interactive history editing
262 histedit interactive history editing
263 keyword expand keywords in tracked files
263 keyword expand keywords in tracked files
264 largefiles track large binary files
264 largefiles track large binary files
265 mq manage a stack of patches
265 mq manage a stack of patches
266 notify hooks for sending email push notifications
266 notify hooks for sending email push notifications
267 pager browse command output with an external pager
267 pager browse command output with an external pager
268 patchbomb command to send changesets as (a series of) patch emails
268 patchbomb command to send changesets as (a series of) patch emails
269 purge command to delete untracked files from the working
269 purge command to delete untracked files from the working
270 directory
270 directory
271 record commands to interactively select changes for
271 record commands to interactively select changes for
272 commit/qrefresh
272 commit/qrefresh
273 relink recreates hardlinks between repository clones
273 relink recreates hardlinks between repository clones
274 schemes extend schemes with shortcuts to repository swarms
274 schemes extend schemes with shortcuts to repository swarms
275 share share a common history between several working directories
275 share share a common history between several working directories
276 shelve save and restore changes to the working directory
276 shelve save and restore changes to the working directory
277 strip strip changesets and their descendants from history
277 strip strip changesets and their descendants from history
278 transplant command to transplant changesets from another branch
278 transplant command to transplant changesets from another branch
279 win32mbcs allow the use of MBCS paths with problematic encodings
279 win32mbcs allow the use of MBCS paths with problematic encodings
280 zeroconf discover and advertise repositories on the local network
280 zeroconf discover and advertise repositories on the local network
281 Test short command list with verbose option
281 Test short command list with verbose option
282
282
283 $ hg -v help shortlist
283 $ hg -v help shortlist
284 Mercurial Distributed SCM
284 Mercurial Distributed SCM
285
285
286 basic commands:
286 basic commands:
287
287
288 add add the specified files on the next commit
288 add add the specified files on the next commit
289 annotate, blame
289 annotate, blame
290 show changeset information by line for each file
290 show changeset information by line for each file
291 clone make a copy of an existing repository
291 clone make a copy of an existing repository
292 commit, ci commit the specified files or all outstanding changes
292 commit, ci commit the specified files or all outstanding changes
293 diff diff repository (or selected files)
293 diff diff repository (or selected files)
294 export dump the header and diffs for one or more changesets
294 export dump the header and diffs for one or more changesets
295 forget forget the specified files on the next commit
295 forget forget the specified files on the next commit
296 init create a new repository in the given directory
296 init create a new repository in the given directory
297 log, history show revision history of entire repository or files
297 log, history show revision history of entire repository or files
298 merge merge another revision into working directory
298 merge merge another revision into working directory
299 pull pull changes from the specified source
299 pull pull changes from the specified source
300 push push changes to the specified destination
300 push push changes to the specified destination
301 remove, rm remove the specified files on the next commit
301 remove, rm remove the specified files on the next commit
302 serve start stand-alone webserver
302 serve start stand-alone webserver
303 status, st show changed files in the working directory
303 status, st show changed files in the working directory
304 summary, sum summarize working directory state
304 summary, sum summarize working directory state
305 update, up, checkout, co
305 update, up, checkout, co
306 update working directory (or switch revisions)
306 update working directory (or switch revisions)
307
307
308 global options ([+] can be repeated):
308 global options ([+] can be repeated):
309
309
310 -R --repository REPO repository root directory or name of overlay bundle
310 -R --repository REPO repository root directory or name of overlay bundle
311 file
311 file
312 --cwd DIR change working directory
312 --cwd DIR change working directory
313 -y --noninteractive do not prompt, automatically pick the first choice for
313 -y --noninteractive do not prompt, automatically pick the first choice for
314 all prompts
314 all prompts
315 -q --quiet suppress output
315 -q --quiet suppress output
316 -v --verbose enable additional output
316 -v --verbose enable additional output
317 --config CONFIG [+] set/override config option (use 'section.name=value')
317 --config CONFIG [+] set/override config option (use 'section.name=value')
318 --debug enable debugging output
318 --debug enable debugging output
319 --debugger start debugger
319 --debugger start debugger
320 --encoding ENCODE set the charset encoding (default: ascii)
320 --encoding ENCODE set the charset encoding (default: ascii)
321 --encodingmode MODE set the charset encoding mode (default: strict)
321 --encodingmode MODE set the charset encoding mode (default: strict)
322 --traceback always print a traceback on exception
322 --traceback always print a traceback on exception
323 --time time how long the command takes
323 --time time how long the command takes
324 --profile print command execution profile
324 --profile print command execution profile
325 --version output version information and exit
325 --version output version information and exit
326 -h --help display help and exit
326 -h --help display help and exit
327 --hidden consider hidden changesets
327 --hidden consider hidden changesets
328
328
329 (use "hg help" for the full list of commands)
329 (use "hg help" for the full list of commands)
330
330
331 $ hg add -h
331 $ hg add -h
332 hg add [OPTION]... [FILE]...
332 hg add [OPTION]... [FILE]...
333
333
334 add the specified files on the next commit
334 add the specified files on the next commit
335
335
336 Schedule files to be version controlled and added to the repository.
336 Schedule files to be version controlled and added to the repository.
337
337
338 The files will be added to the repository at the next commit. To undo an
338 The files will be added to the repository at the next commit. To undo an
339 add before that, see "hg forget".
339 add before that, see "hg forget".
340
340
341 If no names are given, add all files to the repository.
341 If no names are given, add all files to the repository.
342
342
343 Returns 0 if all files are successfully added.
343 Returns 0 if all files are successfully added.
344
344
345 options ([+] can be repeated):
345 options ([+] can be repeated):
346
346
347 -I --include PATTERN [+] include names matching the given patterns
347 -I --include PATTERN [+] include names matching the given patterns
348 -X --exclude PATTERN [+] exclude names matching the given patterns
348 -X --exclude PATTERN [+] exclude names matching the given patterns
349 -S --subrepos recurse into subrepositories
349 -S --subrepos recurse into subrepositories
350 -n --dry-run do not perform actions, just print output
350 -n --dry-run do not perform actions, just print output
351
351
352 (some details hidden, use --verbose to show complete help)
352 (some details hidden, use --verbose to show complete help)
353
353
354 Verbose help for add
354 Verbose help for add
355
355
356 $ hg add -hv
356 $ hg add -hv
357 hg add [OPTION]... [FILE]...
357 hg add [OPTION]... [FILE]...
358
358
359 add the specified files on the next commit
359 add the specified files on the next commit
360
360
361 Schedule files to be version controlled and added to the repository.
361 Schedule files to be version controlled and added to the repository.
362
362
363 The files will be added to the repository at the next commit. To undo an
363 The files will be added to the repository at the next commit. To undo an
364 add before that, see "hg forget".
364 add before that, see "hg forget".
365
365
366 If no names are given, add all files to the repository.
366 If no names are given, add all files to the repository.
367
367
368 An example showing how new (unknown) files are added automatically by "hg
368 An example showing how new (unknown) files are added automatically by "hg
369 add":
369 add":
370
370
371 $ ls
371 $ ls
372 foo.c
372 foo.c
373 $ hg status
373 $ hg status
374 ? foo.c
374 ? foo.c
375 $ hg add
375 $ hg add
376 adding foo.c
376 adding foo.c
377 $ hg status
377 $ hg status
378 A foo.c
378 A foo.c
379
379
380 Returns 0 if all files are successfully added.
380 Returns 0 if all files are successfully added.
381
381
382 options ([+] can be repeated):
382 options ([+] can be repeated):
383
383
384 -I --include PATTERN [+] include names matching the given patterns
384 -I --include PATTERN [+] include names matching the given patterns
385 -X --exclude PATTERN [+] exclude names matching the given patterns
385 -X --exclude PATTERN [+] exclude names matching the given patterns
386 -S --subrepos recurse into subrepositories
386 -S --subrepos recurse into subrepositories
387 -n --dry-run do not perform actions, just print output
387 -n --dry-run do not perform actions, just print output
388
388
389 global options ([+] can be repeated):
389 global options ([+] can be repeated):
390
390
391 -R --repository REPO repository root directory or name of overlay bundle
391 -R --repository REPO repository root directory or name of overlay bundle
392 file
392 file
393 --cwd DIR change working directory
393 --cwd DIR change working directory
394 -y --noninteractive do not prompt, automatically pick the first choice for
394 -y --noninteractive do not prompt, automatically pick the first choice for
395 all prompts
395 all prompts
396 -q --quiet suppress output
396 -q --quiet suppress output
397 -v --verbose enable additional output
397 -v --verbose enable additional output
398 --config CONFIG [+] set/override config option (use 'section.name=value')
398 --config CONFIG [+] set/override config option (use 'section.name=value')
399 --debug enable debugging output
399 --debug enable debugging output
400 --debugger start debugger
400 --debugger start debugger
401 --encoding ENCODE set the charset encoding (default: ascii)
401 --encoding ENCODE set the charset encoding (default: ascii)
402 --encodingmode MODE set the charset encoding mode (default: strict)
402 --encodingmode MODE set the charset encoding mode (default: strict)
403 --traceback always print a traceback on exception
403 --traceback always print a traceback on exception
404 --time time how long the command takes
404 --time time how long the command takes
405 --profile print command execution profile
405 --profile print command execution profile
406 --version output version information and exit
406 --version output version information and exit
407 -h --help display help and exit
407 -h --help display help and exit
408 --hidden consider hidden changesets
408 --hidden consider hidden changesets
409
409
410 Test help option with version option
410 Test help option with version option
411
411
412 $ hg add -h --version
412 $ hg add -h --version
413 Mercurial Distributed SCM (version *) (glob)
413 Mercurial Distributed SCM (version *) (glob)
414 (see http://mercurial.selenic.com for more information)
414 (see http://mercurial.selenic.com for more information)
415
415
416 Copyright (C) 2005-2015 Matt Mackall and others
416 Copyright (C) 2005-2015 Matt Mackall and others
417 This is free software; see the source for copying conditions. There is NO
417 This is free software; see the source for copying conditions. There is NO
418 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
418 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
419
419
420 $ hg add --skjdfks
420 $ hg add --skjdfks
421 hg add: option --skjdfks not recognized
421 hg add: option --skjdfks not recognized
422 hg add [OPTION]... [FILE]...
422 hg add [OPTION]... [FILE]...
423
423
424 add the specified files on the next commit
424 add the specified files on the next commit
425
425
426 options ([+] can be repeated):
426 options ([+] can be repeated):
427
427
428 -I --include PATTERN [+] include names matching the given patterns
428 -I --include PATTERN [+] include names matching the given patterns
429 -X --exclude PATTERN [+] exclude names matching the given patterns
429 -X --exclude PATTERN [+] exclude names matching the given patterns
430 -S --subrepos recurse into subrepositories
430 -S --subrepos recurse into subrepositories
431 -n --dry-run do not perform actions, just print output
431 -n --dry-run do not perform actions, just print output
432
432
433 (use "hg add -h" to show more help)
433 (use "hg add -h" to show more help)
434 [255]
434 [255]
435
435
436 Test ambiguous command help
436 Test ambiguous command help
437
437
438 $ hg help ad
438 $ hg help ad
439 list of commands:
439 list of commands:
440
440
441 add add the specified files on the next commit
441 add add the specified files on the next commit
442 addremove add all new files, delete all missing files
442 addremove add all new files, delete all missing files
443
443
444 (use "hg help -v ad" to show built-in aliases and global options)
444 (use "hg help -v ad" to show built-in aliases and global options)
445
445
446 Test command without options
446 Test command without options
447
447
448 $ hg help verify
448 $ hg help verify
449 hg verify
449 hg verify
450
450
451 verify the integrity of the repository
451 verify the integrity of the repository
452
452
453 Verify the integrity of the current repository.
453 Verify the integrity of the current repository.
454
454
455 This will perform an extensive check of the repository's integrity,
455 This will perform an extensive check of the repository's integrity,
456 validating the hashes and checksums of each entry in the changelog,
456 validating the hashes and checksums of each entry in the changelog,
457 manifest, and tracked files, as well as the integrity of their crosslinks
457 manifest, and tracked files, as well as the integrity of their crosslinks
458 and indices.
458 and indices.
459
459
460 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
460 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
461 information about recovery from corruption of the repository.
461 information about recovery from corruption of the repository.
462
462
463 Returns 0 on success, 1 if errors are encountered.
463 Returns 0 on success, 1 if errors are encountered.
464
464
465 (some details hidden, use --verbose to show complete help)
465 (some details hidden, use --verbose to show complete help)
466
466
467 $ hg help diff
467 $ hg help diff
468 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
468 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
469
469
470 diff repository (or selected files)
470 diff repository (or selected files)
471
471
472 Show differences between revisions for the specified files.
472 Show differences between revisions for the specified files.
473
473
474 Differences between files are shown using the unified diff format.
474 Differences between files are shown using the unified diff format.
475
475
476 Note:
476 Note:
477 diff may generate unexpected results for merges, as it will default to
477 diff may generate unexpected results for merges, as it will default to
478 comparing against the working directory's first parent changeset if no
478 comparing against the working directory's first parent changeset if no
479 revisions are specified.
479 revisions are specified.
480
480
481 When two revision arguments are given, then changes are shown between
481 When two revision arguments are given, then changes are shown between
482 those revisions. If only one revision is specified then that revision is
482 those revisions. If only one revision is specified then that revision is
483 compared to the working directory, and, when no revisions are specified,
483 compared to the working directory, and, when no revisions are specified,
484 the working directory files are compared to its parent.
484 the working directory files are compared to its parent.
485
485
486 Alternatively you can specify -c/--change with a revision to see the
486 Alternatively you can specify -c/--change with a revision to see the
487 changes in that changeset relative to its first parent.
487 changes in that changeset relative to its first parent.
488
488
489 Without the -a/--text option, diff will avoid generating diffs of files it
489 Without the -a/--text option, diff will avoid generating diffs of files it
490 detects as binary. With -a, diff will generate a diff anyway, probably
490 detects as binary. With -a, diff will generate a diff anyway, probably
491 with undesirable results.
491 with undesirable results.
492
492
493 Use the -g/--git option to generate diffs in the git extended diff format.
493 Use the -g/--git option to generate diffs in the git extended diff format.
494 For more information, read "hg help diffs".
494 For more information, read "hg help diffs".
495
495
496 Returns 0 on success.
496 Returns 0 on success.
497
497
498 options ([+] can be repeated):
498 options ([+] can be repeated):
499
499
500 -r --rev REV [+] revision
500 -r --rev REV [+] revision
501 -c --change REV change made by revision
501 -c --change REV change made by revision
502 -a --text treat all files as text
502 -a --text treat all files as text
503 -g --git use git extended diff format
503 -g --git use git extended diff format
504 --nodates omit dates from diff headers
504 --nodates omit dates from diff headers
505 --noprefix omit a/ and b/ prefixes from filenames
505 --noprefix omit a/ and b/ prefixes from filenames
506 -p --show-function show which function each change is in
506 -p --show-function show which function each change is in
507 --reverse produce a diff that undoes the changes
507 --reverse produce a diff that undoes the changes
508 -w --ignore-all-space ignore white space when comparing lines
508 -w --ignore-all-space ignore white space when comparing lines
509 -b --ignore-space-change ignore changes in the amount of white space
509 -b --ignore-space-change ignore changes in the amount of white space
510 -B --ignore-blank-lines ignore changes whose lines are all blank
510 -B --ignore-blank-lines ignore changes whose lines are all blank
511 -U --unified NUM number of lines of context to show
511 -U --unified NUM number of lines of context to show
512 --stat output diffstat-style summary of changes
512 --stat output diffstat-style summary of changes
513 --root DIR produce diffs relative to subdirectory
513 --root DIR produce diffs relative to subdirectory
514 -I --include PATTERN [+] include names matching the given patterns
514 -I --include PATTERN [+] include names matching the given patterns
515 -X --exclude PATTERN [+] exclude names matching the given patterns
515 -X --exclude PATTERN [+] exclude names matching the given patterns
516 -S --subrepos recurse into subrepositories
516 -S --subrepos recurse into subrepositories
517
517
518 (some details hidden, use --verbose to show complete help)
518 (some details hidden, use --verbose to show complete help)
519
519
520 $ hg help status
520 $ hg help status
521 hg status [OPTION]... [FILE]...
521 hg status [OPTION]... [FILE]...
522
522
523 aliases: st
523 aliases: st
524
524
525 show changed files in the working directory
525 show changed files in the working directory
526
526
527 Show status of files in the repository. If names are given, only files
527 Show status of files in the repository. If names are given, only files
528 that match are shown. Files that are clean or ignored or the source of a
528 that match are shown. Files that are clean or ignored or the source of a
529 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
529 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
530 -C/--copies or -A/--all are given. Unless options described with "show
530 -C/--copies or -A/--all are given. Unless options described with "show
531 only ..." are given, the options -mardu are used.
531 only ..." are given, the options -mardu are used.
532
532
533 Option -q/--quiet hides untracked (unknown and ignored) files unless
533 Option -q/--quiet hides untracked (unknown and ignored) files unless
534 explicitly requested with -u/--unknown or -i/--ignored.
534 explicitly requested with -u/--unknown or -i/--ignored.
535
535
536 Note:
536 Note:
537 status may appear to disagree with diff if permissions have changed or
537 status may appear to disagree with diff if permissions have changed or
538 a merge has occurred. The standard diff format does not report
538 a merge has occurred. The standard diff format does not report
539 permission changes and diff only reports changes relative to one merge
539 permission changes and diff only reports changes relative to one merge
540 parent.
540 parent.
541
541
542 If one revision is given, it is used as the base revision. If two
542 If one revision is given, it is used as the base revision. If two
543 revisions are given, the differences between them are shown. The --change
543 revisions are given, the differences between them are shown. The --change
544 option can also be used as a shortcut to list the changed files of a
544 option can also be used as a shortcut to list the changed files of a
545 revision from its first parent.
545 revision from its first parent.
546
546
547 The codes used to show the status of files are:
547 The codes used to show the status of files are:
548
548
549 M = modified
549 M = modified
550 A = added
550 A = added
551 R = removed
551 R = removed
552 C = clean
552 C = clean
553 ! = missing (deleted by non-hg command, but still tracked)
553 ! = missing (deleted by non-hg command, but still tracked)
554 ? = not tracked
554 ? = not tracked
555 I = ignored
555 I = ignored
556 = origin of the previous file (with --copies)
556 = origin of the previous file (with --copies)
557
557
558 Returns 0 on success.
558 Returns 0 on success.
559
559
560 options ([+] can be repeated):
560 options ([+] can be repeated):
561
561
562 -A --all show status of all files
562 -A --all show status of all files
563 -m --modified show only modified files
563 -m --modified show only modified files
564 -a --added show only added files
564 -a --added show only added files
565 -r --removed show only removed files
565 -r --removed show only removed files
566 -d --deleted show only deleted (but tracked) files
566 -d --deleted show only deleted (but tracked) files
567 -c --clean show only files without changes
567 -c --clean show only files without changes
568 -u --unknown show only unknown (not tracked) files
568 -u --unknown show only unknown (not tracked) files
569 -i --ignored show only ignored files
569 -i --ignored show only ignored files
570 -n --no-status hide status prefix
570 -n --no-status hide status prefix
571 -C --copies show source of copied files
571 -C --copies show source of copied files
572 -0 --print0 end filenames with NUL, for use with xargs
572 -0 --print0 end filenames with NUL, for use with xargs
573 --rev REV [+] show difference from revision
573 --rev REV [+] show difference from revision
574 --change REV list the changed files of a revision
574 --change REV list the changed files of a revision
575 -I --include PATTERN [+] include names matching the given patterns
575 -I --include PATTERN [+] include names matching the given patterns
576 -X --exclude PATTERN [+] exclude names matching the given patterns
576 -X --exclude PATTERN [+] exclude names matching the given patterns
577 -S --subrepos recurse into subrepositories
577 -S --subrepos recurse into subrepositories
578
578
579 (some details hidden, use --verbose to show complete help)
579 (some details hidden, use --verbose to show complete help)
580
580
581 $ hg -q help status
581 $ hg -q help status
582 hg status [OPTION]... [FILE]...
582 hg status [OPTION]... [FILE]...
583
583
584 show changed files in the working directory
584 show changed files in the working directory
585
585
586 $ hg help foo
586 $ hg help foo
587 abort: no such help topic: foo
587 abort: no such help topic: foo
588 (try "hg help --keyword foo")
588 (try "hg help --keyword foo")
589 [255]
589 [255]
590
590
591 $ hg skjdfks
591 $ hg skjdfks
592 hg: unknown command 'skjdfks'
592 hg: unknown command 'skjdfks'
593 Mercurial Distributed SCM
593 Mercurial Distributed SCM
594
594
595 basic commands:
595 basic commands:
596
596
597 add add the specified files on the next commit
597 add add the specified files on the next commit
598 annotate show changeset information by line for each file
598 annotate show changeset information by line for each file
599 clone make a copy of an existing repository
599 clone make a copy of an existing repository
600 commit commit the specified files or all outstanding changes
600 commit commit the specified files or all outstanding changes
601 diff diff repository (or selected files)
601 diff diff repository (or selected files)
602 export dump the header and diffs for one or more changesets
602 export dump the header and diffs for one or more changesets
603 forget forget the specified files on the next commit
603 forget forget the specified files on the next commit
604 init create a new repository in the given directory
604 init create a new repository in the given directory
605 log show revision history of entire repository or files
605 log show revision history of entire repository or files
606 merge merge another revision into working directory
606 merge merge another revision into working directory
607 pull pull changes from the specified source
607 pull pull changes from the specified source
608 push push changes to the specified destination
608 push push changes to the specified destination
609 remove remove the specified files on the next commit
609 remove remove the specified files on the next commit
610 serve start stand-alone webserver
610 serve start stand-alone webserver
611 status show changed files in the working directory
611 status show changed files in the working directory
612 summary summarize working directory state
612 summary summarize working directory state
613 update update working directory (or switch revisions)
613 update update working directory (or switch revisions)
614
614
615 (use "hg help" for the full list of commands or "hg -v" for details)
615 (use "hg help" for the full list of commands or "hg -v" for details)
616 [255]
616 [255]
617
617
618
618
619 $ cat > helpext.py <<EOF
619 $ cat > helpext.py <<EOF
620 > import os
620 > import os
621 > from mercurial import cmdutil, commands
621 > from mercurial import cmdutil, commands
622 >
622 >
623 > cmdtable = {}
623 > cmdtable = {}
624 > command = cmdutil.command(cmdtable)
624 > command = cmdutil.command(cmdtable)
625 >
625 >
626 > @command('nohelp',
626 > @command('nohelp',
627 > [('', 'longdesc', 3, 'x'*90),
627 > [('', 'longdesc', 3, 'x'*90),
628 > ('n', '', None, 'normal desc'),
628 > ('n', '', None, 'normal desc'),
629 > ('', 'newline', '', 'line1\nline2')],
629 > ('', 'newline', '', 'line1\nline2')],
630 > 'hg nohelp',
630 > 'hg nohelp',
631 > norepo=True)
631 > norepo=True)
632 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
632 > @command('debugoptDEP', [('', 'dopt', None, 'option is DEPRECATED')])
633 > @command('debugoptEXP', [('', 'eopt', None, 'option is EXPERIMENTAL')])
633 > @command('debugoptEXP', [('', 'eopt', None, 'option is EXPERIMENTAL')])
634 > def nohelp(ui, *args, **kwargs):
634 > def nohelp(ui, *args, **kwargs):
635 > pass
635 > pass
636 >
636 >
637 > EOF
637 > EOF
638 $ echo '[extensions]' >> $HGRCPATH
638 $ echo '[extensions]' >> $HGRCPATH
639 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
639 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
640
640
641 Test command with no help text
641 Test command with no help text
642
642
643 $ hg help nohelp
643 $ hg help nohelp
644 hg nohelp
644 hg nohelp
645
645
646 (no help text available)
646 (no help text available)
647
647
648 options:
648 options:
649
649
650 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
650 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
651 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
651 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
652 -n -- normal desc
652 -n -- normal desc
653 --newline VALUE line1 line2
653 --newline VALUE line1 line2
654
654
655 (some details hidden, use --verbose to show complete help)
655 (some details hidden, use --verbose to show complete help)
656
656
657 $ hg help -k nohelp
657 $ hg help -k nohelp
658 Commands:
658 Commands:
659
659
660 nohelp hg nohelp
660 nohelp hg nohelp
661
661
662 Extension Commands:
662 Extension Commands:
663
663
664 nohelp (no help text available)
664 nohelp (no help text available)
665
665
666 Test that default list of commands omits extension commands
666 Test that default list of commands omits extension commands
667
667
668 $ hg help
668 $ hg help
669 Mercurial Distributed SCM
669 Mercurial Distributed SCM
670
670
671 list of commands:
671 list of commands:
672
672
673 add add the specified files on the next commit
673 add add the specified files on the next commit
674 addremove add all new files, delete all missing files
674 addremove add all new files, delete all missing files
675 annotate show changeset information by line for each file
675 annotate show changeset information by line for each file
676 archive create an unversioned archive of a repository revision
676 archive create an unversioned archive of a repository revision
677 backout reverse effect of earlier changeset
677 backout reverse effect of earlier changeset
678 bisect subdivision search of changesets
678 bisect subdivision search of changesets
679 bookmarks create a new bookmark or list existing bookmarks
679 bookmarks create a new bookmark or list existing bookmarks
680 branch set or show the current branch name
680 branch set or show the current branch name
681 branches list repository named branches
681 branches list repository named branches
682 bundle create a changegroup file
682 bundle create a changegroup file
683 cat output the current or given revision of files
683 cat output the current or given revision of files
684 clone make a copy of an existing repository
684 clone make a copy of an existing repository
685 commit commit the specified files or all outstanding changes
685 commit commit the specified files or all outstanding changes
686 config show combined config settings from all hgrc files
686 config show combined config settings from all hgrc files
687 copy mark files as copied for the next commit
687 copy mark files as copied for the next commit
688 diff diff repository (or selected files)
688 diff diff repository (or selected files)
689 export dump the header and diffs for one or more changesets
689 export dump the header and diffs for one or more changesets
690 files list tracked files
690 files list tracked files
691 forget forget the specified files on the next commit
691 forget forget the specified files on the next commit
692 graft copy changes from other branches onto the current branch
692 graft copy changes from other branches onto the current branch
693 grep search for a pattern in specified files and revisions
693 grep search for a pattern in specified files and revisions
694 heads show branch heads
694 heads show branch heads
695 help show help for a given topic or a help overview
695 help show help for a given topic or a help overview
696 identify identify the working directory or specified revision
696 identify identify the working directory or specified revision
697 import import an ordered set of patches
697 import import an ordered set of patches
698 incoming show new changesets found in source
698 incoming show new changesets found in source
699 init create a new repository in the given directory
699 init create a new repository in the given directory
700 log show revision history of entire repository or files
700 log show revision history of entire repository or files
701 manifest output the current or given revision of the project manifest
701 manifest output the current or given revision of the project manifest
702 merge merge another revision into working directory
702 merge merge another revision into working directory
703 outgoing show changesets not found in the destination
703 outgoing show changesets not found in the destination
704 paths show aliases for remote repositories
704 paths show aliases for remote repositories
705 phase set or show the current phase name
705 phase set or show the current phase name
706 pull pull changes from the specified source
706 pull pull changes from the specified source
707 push push changes to the specified destination
707 push push changes to the specified destination
708 recover roll back an interrupted transaction
708 recover roll back an interrupted transaction
709 remove remove the specified files on the next commit
709 remove remove the specified files on the next commit
710 rename rename files; equivalent of copy + remove
710 rename rename files; equivalent of copy + remove
711 resolve redo merges or set/view the merge status of files
711 resolve redo merges or set/view the merge status of files
712 revert restore files to their checkout state
712 revert restore files to their checkout state
713 root print the root (top) of the current working directory
713 root print the root (top) of the current working directory
714 serve start stand-alone webserver
714 serve start stand-alone webserver
715 status show changed files in the working directory
715 status show changed files in the working directory
716 summary summarize working directory state
716 summary summarize working directory state
717 tag add one or more tags for the current or given revision
717 tag add one or more tags for the current or given revision
718 tags list repository tags
718 tags list repository tags
719 unbundle apply one or more changegroup files
719 unbundle apply one or more changegroup files
720 update update working directory (or switch revisions)
720 update update working directory (or switch revisions)
721 verify verify the integrity of the repository
721 verify verify the integrity of the repository
722 version output version and copyright information
722 version output version and copyright information
723
723
724 enabled extensions:
724 enabled extensions:
725
725
726 helpext (no help text available)
726 helpext (no help text available)
727
727
728 additional help topics:
728 additional help topics:
729
729
730 config Configuration Files
730 config Configuration Files
731 dates Date Formats
731 dates Date Formats
732 diffs Diff Formats
732 diffs Diff Formats
733 environment Environment Variables
733 environment Environment Variables
734 extensions Using Additional Features
734 extensions Using Additional Features
735 filesets Specifying File Sets
735 filesets Specifying File Sets
736 glossary Glossary
736 glossary Glossary
737 hgignore Syntax for Mercurial Ignore Files
737 hgignore Syntax for Mercurial Ignore Files
738 hgweb Configuring hgweb
738 hgweb Configuring hgweb
739 merge-tools Merge Tools
739 merge-tools Merge Tools
740 multirevs Specifying Multiple Revisions
740 multirevs Specifying Multiple Revisions
741 patterns File Name Patterns
741 patterns File Name Patterns
742 phases Working with Phases
742 phases Working with Phases
743 revisions Specifying Single Revisions
743 revisions Specifying Single Revisions
744 revsets Specifying Revision Sets
744 revsets Specifying Revision Sets
745 scripting Using Mercurial from scripts and automation
745 scripting Using Mercurial from scripts and automation
746 subrepos Subrepositories
746 subrepos Subrepositories
747 templating Template Usage
747 templating Template Usage
748 urls URL Paths
748 urls URL Paths
749
749
750 (use "hg help -v" to show built-in aliases and global options)
750 (use "hg help -v" to show built-in aliases and global options)
751
751
752
752
753 Test list of internal help commands
753 Test list of internal help commands
754
754
755 $ hg help debug
755 $ hg help debug
756 debug commands (internal and unsupported):
756 debug commands (internal and unsupported):
757
757
758 debugancestor
758 debugancestor
759 find the ancestor revision of two revisions in a given index
759 find the ancestor revision of two revisions in a given index
760 debugbuilddag
760 debugbuilddag
761 builds a repo with a given DAG from scratch in the current
761 builds a repo with a given DAG from scratch in the current
762 empty repo
762 empty repo
763 debugbundle lists the contents of a bundle
763 debugbundle lists the contents of a bundle
764 debugcheckstate
764 debugcheckstate
765 validate the correctness of the current dirstate
765 validate the correctness of the current dirstate
766 debugcommands
766 debugcommands
767 list all available commands and options
767 list all available commands and options
768 debugcomplete
768 debugcomplete
769 returns the completion list associated with the given command
769 returns the completion list associated with the given command
770 debugdag format the changelog or an index DAG as a concise textual
770 debugdag format the changelog or an index DAG as a concise textual
771 description
771 description
772 debugdata dump the contents of a data file revision
772 debugdata dump the contents of a data file revision
773 debugdate parse and display a date
773 debugdate parse and display a date
774 debugdirstate
774 debugdirstate
775 show the contents of the current dirstate
775 show the contents of the current dirstate
776 debugdiscovery
776 debugdiscovery
777 runs the changeset discovery protocol in isolation
777 runs the changeset discovery protocol in isolation
778 debugextensions
779 show information about active extensions
778 debugfileset parse and apply a fileset specification
780 debugfileset parse and apply a fileset specification
779 debugfsinfo show information detected about current filesystem
781 debugfsinfo show information detected about current filesystem
780 debuggetbundle
782 debuggetbundle
781 retrieves a bundle from a repo
783 retrieves a bundle from a repo
782 debugignore display the combined ignore pattern
784 debugignore display the combined ignore pattern
783 debugindex dump the contents of an index file
785 debugindex dump the contents of an index file
784 debugindexdot
786 debugindexdot
785 dump an index DAG as a graphviz dot file
787 dump an index DAG as a graphviz dot file
786 debuginstall test Mercurial installation
788 debuginstall test Mercurial installation
787 debugknown test whether node ids are known to a repo
789 debugknown test whether node ids are known to a repo
788 debuglocks show or modify state of locks
790 debuglocks show or modify state of locks
789 debugnamecomplete
791 debugnamecomplete
790 complete "names" - tags, open branch names, bookmark names
792 complete "names" - tags, open branch names, bookmark names
791 debugobsolete
793 debugobsolete
792 create arbitrary obsolete marker
794 create arbitrary obsolete marker
793 debugoptDEP (no help text available)
795 debugoptDEP (no help text available)
794 debugoptEXP (no help text available)
796 debugoptEXP (no help text available)
795 debugpathcomplete
797 debugpathcomplete
796 complete part or all of a tracked path
798 complete part or all of a tracked path
797 debugpushkey access the pushkey key/value protocol
799 debugpushkey access the pushkey key/value protocol
798 debugpvec (no help text available)
800 debugpvec (no help text available)
799 debugrebuilddirstate
801 debugrebuilddirstate
800 rebuild the dirstate as it would look like for the given
802 rebuild the dirstate as it would look like for the given
801 revision
803 revision
802 debugrebuildfncache
804 debugrebuildfncache
803 rebuild the fncache file
805 rebuild the fncache file
804 debugrename dump rename information
806 debugrename dump rename information
805 debugrevlog show data and statistics about a revlog
807 debugrevlog show data and statistics about a revlog
806 debugrevspec parse and apply a revision specification
808 debugrevspec parse and apply a revision specification
807 debugsetparents
809 debugsetparents
808 manually set the parents of the current working directory
810 manually set the parents of the current working directory
809 debugsub (no help text available)
811 debugsub (no help text available)
810 debugsuccessorssets
812 debugsuccessorssets
811 show set of successors for revision
813 show set of successors for revision
812 debugwalk show how files match on given patterns
814 debugwalk show how files match on given patterns
813 debugwireargs
815 debugwireargs
814 (no help text available)
816 (no help text available)
815
817
816 (use "hg help -v debug" to show built-in aliases and global options)
818 (use "hg help -v debug" to show built-in aliases and global options)
817
819
818
820
819 Test list of commands with command with no help text
821 Test list of commands with command with no help text
820
822
821 $ hg help helpext
823 $ hg help helpext
822 helpext extension - no help text available
824 helpext extension - no help text available
823
825
824 list of commands:
826 list of commands:
825
827
826 nohelp (no help text available)
828 nohelp (no help text available)
827
829
828 (use "hg help -v helpext" to show built-in aliases and global options)
830 (use "hg help -v helpext" to show built-in aliases and global options)
829
831
830
832
831 test deprecated and experimental options are hidden in command help
833 test deprecated and experimental options are hidden in command help
832 $ hg help debugoptDEP
834 $ hg help debugoptDEP
833 hg debugoptDEP
835 hg debugoptDEP
834
836
835 (no help text available)
837 (no help text available)
836
838
837 options:
839 options:
838
840
839 (some details hidden, use --verbose to show complete help)
841 (some details hidden, use --verbose to show complete help)
840
842
841 $ hg help debugoptEXP
843 $ hg help debugoptEXP
842 hg debugoptEXP
844 hg debugoptEXP
843
845
844 (no help text available)
846 (no help text available)
845
847
846 options:
848 options:
847
849
848 (some details hidden, use --verbose to show complete help)
850 (some details hidden, use --verbose to show complete help)
849
851
850 test deprecated and experimental options is shown with -v
852 test deprecated and experimental options is shown with -v
851 $ hg help -v debugoptDEP | grep dopt
853 $ hg help -v debugoptDEP | grep dopt
852 --dopt option is DEPRECATED
854 --dopt option is DEPRECATED
853 $ hg help -v debugoptEXP | grep eopt
855 $ hg help -v debugoptEXP | grep eopt
854 --eopt option is EXPERIMENTAL
856 --eopt option is EXPERIMENTAL
855
857
856 #if gettext
858 #if gettext
857 test deprecated option is hidden with translation with untranslated description
859 test deprecated option is hidden with translation with untranslated description
858 (use many globy for not failing on changed transaction)
860 (use many globy for not failing on changed transaction)
859 $ LANGUAGE=sv hg help debugoptDEP
861 $ LANGUAGE=sv hg help debugoptDEP
860 hg debugoptDEP
862 hg debugoptDEP
861
863
862 (*) (glob)
864 (*) (glob)
863
865
864 options:
866 options:
865
867
866 (some details hidden, use --verbose to show complete help)
868 (some details hidden, use --verbose to show complete help)
867 #endif
869 #endif
868
870
869 Test commands that collide with topics (issue4240)
871 Test commands that collide with topics (issue4240)
870
872
871 $ hg config -hq
873 $ hg config -hq
872 hg config [-u] [NAME]...
874 hg config [-u] [NAME]...
873
875
874 show combined config settings from all hgrc files
876 show combined config settings from all hgrc files
875 $ hg showconfig -hq
877 $ hg showconfig -hq
876 hg config [-u] [NAME]...
878 hg config [-u] [NAME]...
877
879
878 show combined config settings from all hgrc files
880 show combined config settings from all hgrc files
879
881
880 Test a help topic
882 Test a help topic
881
883
882 $ hg help revs
884 $ hg help revs
883 Specifying Single Revisions
885 Specifying Single Revisions
884 """""""""""""""""""""""""""
886 """""""""""""""""""""""""""
885
887
886 Mercurial supports several ways to specify individual revisions.
888 Mercurial supports several ways to specify individual revisions.
887
889
888 A plain integer is treated as a revision number. Negative integers are
890 A plain integer is treated as a revision number. Negative integers are
889 treated as sequential offsets from the tip, with -1 denoting the tip, -2
891 treated as sequential offsets from the tip, with -1 denoting the tip, -2
890 denoting the revision prior to the tip, and so forth.
892 denoting the revision prior to the tip, and so forth.
891
893
892 A 40-digit hexadecimal string is treated as a unique revision identifier.
894 A 40-digit hexadecimal string is treated as a unique revision identifier.
893
895
894 A hexadecimal string less than 40 characters long is treated as a unique
896 A hexadecimal string less than 40 characters long is treated as a unique
895 revision identifier and is referred to as a short-form identifier. A
897 revision identifier and is referred to as a short-form identifier. A
896 short-form identifier is only valid if it is the prefix of exactly one
898 short-form identifier is only valid if it is the prefix of exactly one
897 full-length identifier.
899 full-length identifier.
898
900
899 Any other string is treated as a bookmark, tag, or branch name. A bookmark
901 Any other string is treated as a bookmark, tag, or branch name. A bookmark
900 is a movable pointer to a revision. A tag is a permanent name associated
902 is a movable pointer to a revision. A tag is a permanent name associated
901 with a revision. A branch name denotes the tipmost open branch head of
903 with a revision. A branch name denotes the tipmost open branch head of
902 that branch - or if they are all closed, the tipmost closed head of the
904 that branch - or if they are all closed, the tipmost closed head of the
903 branch. Bookmark, tag, and branch names must not contain the ":"
905 branch. Bookmark, tag, and branch names must not contain the ":"
904 character.
906 character.
905
907
906 The reserved name "tip" always identifies the most recent revision.
908 The reserved name "tip" always identifies the most recent revision.
907
909
908 The reserved name "null" indicates the null revision. This is the revision
910 The reserved name "null" indicates the null revision. This is the revision
909 of an empty repository, and the parent of revision 0.
911 of an empty repository, and the parent of revision 0.
910
912
911 The reserved name "." indicates the working directory parent. If no
913 The reserved name "." indicates the working directory parent. If no
912 working directory is checked out, it is equivalent to null. If an
914 working directory is checked out, it is equivalent to null. If an
913 uncommitted merge is in progress, "." is the revision of the first parent.
915 uncommitted merge is in progress, "." is the revision of the first parent.
914
916
915 Test repeated config section name
917 Test repeated config section name
916
918
917 $ hg help config.host
919 $ hg help config.host
918 "http_proxy.host"
920 "http_proxy.host"
919 Host name and (optional) port of the proxy server, for example
921 Host name and (optional) port of the proxy server, for example
920 "myproxy:8000".
922 "myproxy:8000".
921
923
922 "smtp.host"
924 "smtp.host"
923 Host name of mail server, e.g. "mail.example.com".
925 Host name of mail server, e.g. "mail.example.com".
924
926
925 Unrelated trailing paragraphs shouldn't be included
927 Unrelated trailing paragraphs shouldn't be included
926
928
927 $ hg help config.extramsg | grep '^$'
929 $ hg help config.extramsg | grep '^$'
928
930
929
931
930 Test capitalized section name
932 Test capitalized section name
931
933
932 $ hg help scripting.HGPLAIN > /dev/null
934 $ hg help scripting.HGPLAIN > /dev/null
933
935
934 Help subsection:
936 Help subsection:
935
937
936 $ hg help config.charsets |grep "Email example:" > /dev/null
938 $ hg help config.charsets |grep "Email example:" > /dev/null
937 [1]
939 [1]
938
940
939 Show nested definitions
941 Show nested definitions
940 ("profiling.type"[break]"ls"[break]"stat"[break])
942 ("profiling.type"[break]"ls"[break]"stat"[break])
941
943
942 $ hg help config.type | egrep '^$'|wc -l
944 $ hg help config.type | egrep '^$'|wc -l
943 \s*3 (re)
945 \s*3 (re)
944
946
945 Last item in help config.*:
947 Last item in help config.*:
946
948
947 $ hg help config.`hg help config|grep '^ "'| \
949 $ hg help config.`hg help config|grep '^ "'| \
948 > tail -1|sed 's![ "]*!!g'`| \
950 > tail -1|sed 's![ "]*!!g'`| \
949 > grep "hg help -c config" > /dev/null
951 > grep "hg help -c config" > /dev/null
950 [1]
952 [1]
951
953
952 note to use help -c for general hg help config:
954 note to use help -c for general hg help config:
953
955
954 $ hg help config |grep "hg help -c config" > /dev/null
956 $ hg help config |grep "hg help -c config" > /dev/null
955
957
956 Test templating help
958 Test templating help
957
959
958 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
960 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
959 desc String. The text of the changeset description.
961 desc String. The text of the changeset description.
960 diffstat String. Statistics of changes with the following format:
962 diffstat String. Statistics of changes with the following format:
961 firstline Any text. Returns the first line of text.
963 firstline Any text. Returns the first line of text.
962 nonempty Any text. Returns '(none)' if the string is empty.
964 nonempty Any text. Returns '(none)' if the string is empty.
963
965
964 Test help hooks
966 Test help hooks
965
967
966 $ cat > helphook1.py <<EOF
968 $ cat > helphook1.py <<EOF
967 > from mercurial import help
969 > from mercurial import help
968 >
970 >
969 > def rewrite(topic, doc):
971 > def rewrite(topic, doc):
970 > return doc + '\nhelphook1\n'
972 > return doc + '\nhelphook1\n'
971 >
973 >
972 > def extsetup(ui):
974 > def extsetup(ui):
973 > help.addtopichook('revsets', rewrite)
975 > help.addtopichook('revsets', rewrite)
974 > EOF
976 > EOF
975 $ cat > helphook2.py <<EOF
977 $ cat > helphook2.py <<EOF
976 > from mercurial import help
978 > from mercurial import help
977 >
979 >
978 > def rewrite(topic, doc):
980 > def rewrite(topic, doc):
979 > return doc + '\nhelphook2\n'
981 > return doc + '\nhelphook2\n'
980 >
982 >
981 > def extsetup(ui):
983 > def extsetup(ui):
982 > help.addtopichook('revsets', rewrite)
984 > help.addtopichook('revsets', rewrite)
983 > EOF
985 > EOF
984 $ echo '[extensions]' >> $HGRCPATH
986 $ echo '[extensions]' >> $HGRCPATH
985 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
987 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
986 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
988 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
987 $ hg help revsets | grep helphook
989 $ hg help revsets | grep helphook
988 helphook1
990 helphook1
989 helphook2
991 helphook2
990
992
991 Test -e / -c / -k combinations
993 Test -e / -c / -k combinations
992
994
993 $ hg help -c progress
995 $ hg help -c progress
994 abort: no such help topic: progress
996 abort: no such help topic: progress
995 (try "hg help --keyword progress")
997 (try "hg help --keyword progress")
996 [255]
998 [255]
997 $ hg help -e progress |head -1
999 $ hg help -e progress |head -1
998 progress extension - show progress bars for some actions (DEPRECATED)
1000 progress extension - show progress bars for some actions (DEPRECATED)
999 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1001 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1000 Commands:
1002 Commands:
1001 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1003 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1002 Extensions:
1004 Extensions:
1003 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1005 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1004 Extensions:
1006 Extensions:
1005 Commands:
1007 Commands:
1006 $ hg help -c commit > /dev/null
1008 $ hg help -c commit > /dev/null
1007 $ hg help -e -c commit > /dev/null
1009 $ hg help -e -c commit > /dev/null
1008 $ hg help -e commit > /dev/null
1010 $ hg help -e commit > /dev/null
1009 abort: no such help topic: commit
1011 abort: no such help topic: commit
1010 (try "hg help --keyword commit")
1012 (try "hg help --keyword commit")
1011 [255]
1013 [255]
1012
1014
1013 Test keyword search help
1015 Test keyword search help
1014
1016
1015 $ cat > prefixedname.py <<EOF
1017 $ cat > prefixedname.py <<EOF
1016 > '''matched against word "clone"
1018 > '''matched against word "clone"
1017 > '''
1019 > '''
1018 > EOF
1020 > EOF
1019 $ echo '[extensions]' >> $HGRCPATH
1021 $ echo '[extensions]' >> $HGRCPATH
1020 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1022 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1021 $ hg help -k clone
1023 $ hg help -k clone
1022 Topics:
1024 Topics:
1023
1025
1024 config Configuration Files
1026 config Configuration Files
1025 extensions Using Additional Features
1027 extensions Using Additional Features
1026 glossary Glossary
1028 glossary Glossary
1027 phases Working with Phases
1029 phases Working with Phases
1028 subrepos Subrepositories
1030 subrepos Subrepositories
1029 urls URL Paths
1031 urls URL Paths
1030
1032
1031 Commands:
1033 Commands:
1032
1034
1033 bookmarks create a new bookmark or list existing bookmarks
1035 bookmarks create a new bookmark or list existing bookmarks
1034 clone make a copy of an existing repository
1036 clone make a copy of an existing repository
1035 paths show aliases for remote repositories
1037 paths show aliases for remote repositories
1036 update update working directory (or switch revisions)
1038 update update working directory (or switch revisions)
1037
1039
1038 Extensions:
1040 Extensions:
1039
1041
1040 prefixedname matched against word "clone"
1042 prefixedname matched against word "clone"
1041 relink recreates hardlinks between repository clones
1043 relink recreates hardlinks between repository clones
1042
1044
1043 Extension Commands:
1045 Extension Commands:
1044
1046
1045 qclone clone main and patch repository at same time
1047 qclone clone main and patch repository at same time
1046
1048
1047 Test unfound topic
1049 Test unfound topic
1048
1050
1049 $ hg help nonexistingtopicthatwillneverexisteverever
1051 $ hg help nonexistingtopicthatwillneverexisteverever
1050 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1052 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1051 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1053 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1052 [255]
1054 [255]
1053
1055
1054 Test unfound keyword
1056 Test unfound keyword
1055
1057
1056 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1058 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1057 abort: no matches
1059 abort: no matches
1058 (try "hg help" for a list of topics)
1060 (try "hg help" for a list of topics)
1059 [255]
1061 [255]
1060
1062
1061 Test omit indicating for help
1063 Test omit indicating for help
1062
1064
1063 $ cat > addverboseitems.py <<EOF
1065 $ cat > addverboseitems.py <<EOF
1064 > '''extension to test omit indicating.
1066 > '''extension to test omit indicating.
1065 >
1067 >
1066 > This paragraph is never omitted (for extension)
1068 > This paragraph is never omitted (for extension)
1067 >
1069 >
1068 > .. container:: verbose
1070 > .. container:: verbose
1069 >
1071 >
1070 > This paragraph is omitted,
1072 > This paragraph is omitted,
1071 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1073 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1072 >
1074 >
1073 > This paragraph is never omitted, too (for extension)
1075 > This paragraph is never omitted, too (for extension)
1074 > '''
1076 > '''
1075 >
1077 >
1076 > from mercurial import help, commands
1078 > from mercurial import help, commands
1077 > testtopic = """This paragraph is never omitted (for topic).
1079 > testtopic = """This paragraph is never omitted (for topic).
1078 >
1080 >
1079 > .. container:: verbose
1081 > .. container:: verbose
1080 >
1082 >
1081 > This paragraph is omitted,
1083 > This paragraph is omitted,
1082 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1084 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1083 >
1085 >
1084 > This paragraph is never omitted, too (for topic)
1086 > This paragraph is never omitted, too (for topic)
1085 > """
1087 > """
1086 > def extsetup(ui):
1088 > def extsetup(ui):
1087 > help.helptable.append((["topic-containing-verbose"],
1089 > help.helptable.append((["topic-containing-verbose"],
1088 > "This is the topic to test omit indicating.",
1090 > "This is the topic to test omit indicating.",
1089 > lambda : testtopic))
1091 > lambda : testtopic))
1090 > EOF
1092 > EOF
1091 $ echo '[extensions]' >> $HGRCPATH
1093 $ echo '[extensions]' >> $HGRCPATH
1092 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1094 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1093 $ hg help addverboseitems
1095 $ hg help addverboseitems
1094 addverboseitems extension - extension to test omit indicating.
1096 addverboseitems extension - extension to test omit indicating.
1095
1097
1096 This paragraph is never omitted (for extension)
1098 This paragraph is never omitted (for extension)
1097
1099
1098 This paragraph is never omitted, too (for extension)
1100 This paragraph is never omitted, too (for extension)
1099
1101
1100 (some details hidden, use --verbose to show complete help)
1102 (some details hidden, use --verbose to show complete help)
1101
1103
1102 no commands defined
1104 no commands defined
1103 $ hg help -v addverboseitems
1105 $ hg help -v addverboseitems
1104 addverboseitems extension - extension to test omit indicating.
1106 addverboseitems extension - extension to test omit indicating.
1105
1107
1106 This paragraph is never omitted (for extension)
1108 This paragraph is never omitted (for extension)
1107
1109
1108 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1110 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1109 extension)
1111 extension)
1110
1112
1111 This paragraph is never omitted, too (for extension)
1113 This paragraph is never omitted, too (for extension)
1112
1114
1113 no commands defined
1115 no commands defined
1114 $ hg help topic-containing-verbose
1116 $ hg help topic-containing-verbose
1115 This is the topic to test omit indicating.
1117 This is the topic to test omit indicating.
1116 """"""""""""""""""""""""""""""""""""""""""
1118 """"""""""""""""""""""""""""""""""""""""""
1117
1119
1118 This paragraph is never omitted (for topic).
1120 This paragraph is never omitted (for topic).
1119
1121
1120 This paragraph is never omitted, too (for topic)
1122 This paragraph is never omitted, too (for topic)
1121
1123
1122 (some details hidden, use --verbose to show complete help)
1124 (some details hidden, use --verbose to show complete help)
1123 $ hg help -v topic-containing-verbose
1125 $ hg help -v topic-containing-verbose
1124 This is the topic to test omit indicating.
1126 This is the topic to test omit indicating.
1125 """"""""""""""""""""""""""""""""""""""""""
1127 """"""""""""""""""""""""""""""""""""""""""
1126
1128
1127 This paragraph is never omitted (for topic).
1129 This paragraph is never omitted (for topic).
1128
1130
1129 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1131 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1130 topic)
1132 topic)
1131
1133
1132 This paragraph is never omitted, too (for topic)
1134 This paragraph is never omitted, too (for topic)
1133
1135
1134 Test section lookup
1136 Test section lookup
1135
1137
1136 $ hg help revset.merge
1138 $ hg help revset.merge
1137 "merge()"
1139 "merge()"
1138 Changeset is a merge changeset.
1140 Changeset is a merge changeset.
1139
1141
1140 $ hg help glossary.dag
1142 $ hg help glossary.dag
1141 DAG
1143 DAG
1142 The repository of changesets of a distributed version control system
1144 The repository of changesets of a distributed version control system
1143 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1145 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1144 of nodes and edges, where nodes correspond to changesets and edges
1146 of nodes and edges, where nodes correspond to changesets and edges
1145 imply a parent -> child relation. This graph can be visualized by
1147 imply a parent -> child relation. This graph can be visualized by
1146 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1148 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1147 limited by the requirement for children to have at most two parents.
1149 limited by the requirement for children to have at most two parents.
1148
1150
1149
1151
1150 $ hg help hgrc.paths
1152 $ hg help hgrc.paths
1151 "paths"
1153 "paths"
1152 -------
1154 -------
1153
1155
1154 Assigns symbolic names to repositories. The left side is the symbolic
1156 Assigns symbolic names to repositories. The left side is the symbolic
1155 name, and the right gives the directory or URL that is the location of the
1157 name, and the right gives the directory or URL that is the location of the
1156 repository. Default paths can be declared by setting the following
1158 repository. Default paths can be declared by setting the following
1157 entries.
1159 entries.
1158
1160
1159 "default"
1161 "default"
1160 Directory or URL to use when pulling if no source is specified.
1162 Directory or URL to use when pulling if no source is specified.
1161 (default: repository from which the current repository was cloned)
1163 (default: repository from which the current repository was cloned)
1162
1164
1163 "default-push"
1165 "default-push"
1164 Optional. Directory or URL to use when pushing if no destination is
1166 Optional. Directory or URL to use when pushing if no destination is
1165 specified.
1167 specified.
1166
1168
1167 Custom paths can be defined by assigning the path to a name that later can
1169 Custom paths can be defined by assigning the path to a name that later can
1168 be used from the command line. Example:
1170 be used from the command line. Example:
1169
1171
1170 [paths]
1172 [paths]
1171 my_path = http://example.com/path
1173 my_path = http://example.com/path
1172
1174
1173 To push to the path defined in "my_path" run the command:
1175 To push to the path defined in "my_path" run the command:
1174
1176
1175 hg push my_path
1177 hg push my_path
1176
1178
1177 $ hg help glossary.mcguffin
1179 $ hg help glossary.mcguffin
1178 abort: help section not found
1180 abort: help section not found
1179 [255]
1181 [255]
1180
1182
1181 $ hg help glossary.mc.guffin
1183 $ hg help glossary.mc.guffin
1182 abort: help section not found
1184 abort: help section not found
1183 [255]
1185 [255]
1184
1186
1185 $ hg help template.files
1187 $ hg help template.files
1186 files List of strings. All files modified, added, or removed by
1188 files List of strings. All files modified, added, or removed by
1187 this changeset.
1189 this changeset.
1188
1190
1189 Test dynamic list of merge tools only shows up once
1191 Test dynamic list of merge tools only shows up once
1190 $ hg help merge-tools
1192 $ hg help merge-tools
1191 Merge Tools
1193 Merge Tools
1192 """""""""""
1194 """""""""""
1193
1195
1194 To merge files Mercurial uses merge tools.
1196 To merge files Mercurial uses merge tools.
1195
1197
1196 A merge tool combines two different versions of a file into a merged file.
1198 A merge tool combines two different versions of a file into a merged file.
1197 Merge tools are given the two files and the greatest common ancestor of
1199 Merge tools are given the two files and the greatest common ancestor of
1198 the two file versions, so they can determine the changes made on both
1200 the two file versions, so they can determine the changes made on both
1199 branches.
1201 branches.
1200
1202
1201 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1203 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1202 backout" and in several extensions.
1204 backout" and in several extensions.
1203
1205
1204 Usually, the merge tool tries to automatically reconcile the files by
1206 Usually, the merge tool tries to automatically reconcile the files by
1205 combining all non-overlapping changes that occurred separately in the two
1207 combining all non-overlapping changes that occurred separately in the two
1206 different evolutions of the same initial base file. Furthermore, some
1208 different evolutions of the same initial base file. Furthermore, some
1207 interactive merge programs make it easier to manually resolve conflicting
1209 interactive merge programs make it easier to manually resolve conflicting
1208 merges, either in a graphical way, or by inserting some conflict markers.
1210 merges, either in a graphical way, or by inserting some conflict markers.
1209 Mercurial does not include any interactive merge programs but relies on
1211 Mercurial does not include any interactive merge programs but relies on
1210 external tools for that.
1212 external tools for that.
1211
1213
1212 Available merge tools
1214 Available merge tools
1213 =====================
1215 =====================
1214
1216
1215 External merge tools and their properties are configured in the merge-
1217 External merge tools and their properties are configured in the merge-
1216 tools configuration section - see hgrc(5) - but they can often just be
1218 tools configuration section - see hgrc(5) - but they can often just be
1217 named by their executable.
1219 named by their executable.
1218
1220
1219 A merge tool is generally usable if its executable can be found on the
1221 A merge tool is generally usable if its executable can be found on the
1220 system and if it can handle the merge. The executable is found if it is an
1222 system and if it can handle the merge. The executable is found if it is an
1221 absolute or relative executable path or the name of an application in the
1223 absolute or relative executable path or the name of an application in the
1222 executable search path. The tool is assumed to be able to handle the merge
1224 executable search path. The tool is assumed to be able to handle the merge
1223 if it can handle symlinks if the file is a symlink, if it can handle
1225 if it can handle symlinks if the file is a symlink, if it can handle
1224 binary files if the file is binary, and if a GUI is available if the tool
1226 binary files if the file is binary, and if a GUI is available if the tool
1225 requires a GUI.
1227 requires a GUI.
1226
1228
1227 There are some internal merge tools which can be used. The internal merge
1229 There are some internal merge tools which can be used. The internal merge
1228 tools are:
1230 tools are:
1229
1231
1230 ":dump"
1232 ":dump"
1231 Creates three versions of the files to merge, containing the contents of
1233 Creates three versions of the files to merge, containing the contents of
1232 local, other and base. These files can then be used to perform a merge
1234 local, other and base. These files can then be used to perform a merge
1233 manually. If the file to be merged is named "a.txt", these files will
1235 manually. If the file to be merged is named "a.txt", these files will
1234 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1236 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1235 they will be placed in the same directory as "a.txt".
1237 they will be placed in the same directory as "a.txt".
1236
1238
1237 ":fail"
1239 ":fail"
1238 Rather than attempting to merge files that were modified on both
1240 Rather than attempting to merge files that were modified on both
1239 branches, it marks them as unresolved. The resolve command must be used
1241 branches, it marks them as unresolved. The resolve command must be used
1240 to resolve these conflicts.
1242 to resolve these conflicts.
1241
1243
1242 ":local"
1244 ":local"
1243 Uses the local version of files as the merged version.
1245 Uses the local version of files as the merged version.
1244
1246
1245 ":merge"
1247 ":merge"
1246 Uses the internal non-interactive simple merge algorithm for merging
1248 Uses the internal non-interactive simple merge algorithm for merging
1247 files. It will fail if there are any conflicts and leave markers in the
1249 files. It will fail if there are any conflicts and leave markers in the
1248 partially merged file. Markers will have two sections, one for each side
1250 partially merged file. Markers will have two sections, one for each side
1249 of merge.
1251 of merge.
1250
1252
1251 ":merge-local"
1253 ":merge-local"
1252 Like :merge, but resolve all conflicts non-interactively in favor of the
1254 Like :merge, but resolve all conflicts non-interactively in favor of the
1253 local changes.
1255 local changes.
1254
1256
1255 ":merge-other"
1257 ":merge-other"
1256 Like :merge, but resolve all conflicts non-interactively in favor of the
1258 Like :merge, but resolve all conflicts non-interactively in favor of the
1257 other changes.
1259 other changes.
1258
1260
1259 ":merge3"
1261 ":merge3"
1260 Uses the internal non-interactive simple merge algorithm for merging
1262 Uses the internal non-interactive simple merge algorithm for merging
1261 files. It will fail if there are any conflicts and leave markers in the
1263 files. It will fail if there are any conflicts and leave markers in the
1262 partially merged file. Marker will have three sections, one from each
1264 partially merged file. Marker will have three sections, one from each
1263 side of the merge and one for the base content.
1265 side of the merge and one for the base content.
1264
1266
1265 ":other"
1267 ":other"
1266 Uses the other version of files as the merged version.
1268 Uses the other version of files as the merged version.
1267
1269
1268 ":prompt"
1270 ":prompt"
1269 Asks the user which of the local or the other version to keep as the
1271 Asks the user which of the local or the other version to keep as the
1270 merged version.
1272 merged version.
1271
1273
1272 ":tagmerge"
1274 ":tagmerge"
1273 Uses the internal tag merge algorithm (experimental).
1275 Uses the internal tag merge algorithm (experimental).
1274
1276
1275 ":union"
1277 ":union"
1276 Uses the internal non-interactive simple merge algorithm for merging
1278 Uses the internal non-interactive simple merge algorithm for merging
1277 files. It will use both left and right sides for conflict regions. No
1279 files. It will use both left and right sides for conflict regions. No
1278 markers are inserted.
1280 markers are inserted.
1279
1281
1280 Internal tools are always available and do not require a GUI but will by
1282 Internal tools are always available and do not require a GUI but will by
1281 default not handle symlinks or binary files.
1283 default not handle symlinks or binary files.
1282
1284
1283 Choosing a merge tool
1285 Choosing a merge tool
1284 =====================
1286 =====================
1285
1287
1286 Mercurial uses these rules when deciding which merge tool to use:
1288 Mercurial uses these rules when deciding which merge tool to use:
1287
1289
1288 1. If a tool has been specified with the --tool option to merge or
1290 1. If a tool has been specified with the --tool option to merge or
1289 resolve, it is used. If it is the name of a tool in the merge-tools
1291 resolve, it is used. If it is the name of a tool in the merge-tools
1290 configuration, its configuration is used. Otherwise the specified tool
1292 configuration, its configuration is used. Otherwise the specified tool
1291 must be executable by the shell.
1293 must be executable by the shell.
1292 2. If the "HGMERGE" environment variable is present, its value is used and
1294 2. If the "HGMERGE" environment variable is present, its value is used and
1293 must be executable by the shell.
1295 must be executable by the shell.
1294 3. If the filename of the file to be merged matches any of the patterns in
1296 3. If the filename of the file to be merged matches any of the patterns in
1295 the merge-patterns configuration section, the first usable merge tool
1297 the merge-patterns configuration section, the first usable merge tool
1296 corresponding to a matching pattern is used. Here, binary capabilities
1298 corresponding to a matching pattern is used. Here, binary capabilities
1297 of the merge tool are not considered.
1299 of the merge tool are not considered.
1298 4. If ui.merge is set it will be considered next. If the value is not the
1300 4. If ui.merge is set it will be considered next. If the value is not the
1299 name of a configured tool, the specified value is used and must be
1301 name of a configured tool, the specified value is used and must be
1300 executable by the shell. Otherwise the named tool is used if it is
1302 executable by the shell. Otherwise the named tool is used if it is
1301 usable.
1303 usable.
1302 5. If any usable merge tools are present in the merge-tools configuration
1304 5. If any usable merge tools are present in the merge-tools configuration
1303 section, the one with the highest priority is used.
1305 section, the one with the highest priority is used.
1304 6. If a program named "hgmerge" can be found on the system, it is used -
1306 6. If a program named "hgmerge" can be found on the system, it is used -
1305 but it will by default not be used for symlinks and binary files.
1307 but it will by default not be used for symlinks and binary files.
1306 7. If the file to be merged is not binary and is not a symlink, then
1308 7. If the file to be merged is not binary and is not a symlink, then
1307 internal ":merge" is used.
1309 internal ":merge" is used.
1308 8. The merge of the file fails and must be resolved before commit.
1310 8. The merge of the file fails and must be resolved before commit.
1309
1311
1310 Note:
1312 Note:
1311 After selecting a merge program, Mercurial will by default attempt to
1313 After selecting a merge program, Mercurial will by default attempt to
1312 merge the files using a simple merge algorithm first. Only if it
1314 merge the files using a simple merge algorithm first. Only if it
1313 doesn't succeed because of conflicting changes Mercurial will actually
1315 doesn't succeed because of conflicting changes Mercurial will actually
1314 execute the merge program. Whether to use the simple merge algorithm
1316 execute the merge program. Whether to use the simple merge algorithm
1315 first can be controlled by the premerge setting of the merge tool.
1317 first can be controlled by the premerge setting of the merge tool.
1316 Premerge is enabled by default unless the file is binary or a symlink.
1318 Premerge is enabled by default unless the file is binary or a symlink.
1317
1319
1318 See the merge-tools and ui sections of hgrc(5) for details on the
1320 See the merge-tools and ui sections of hgrc(5) for details on the
1319 configuration of merge tools.
1321 configuration of merge tools.
1320
1322
1321 Test usage of section marks in help documents
1323 Test usage of section marks in help documents
1322
1324
1323 $ cd "$TESTDIR"/../doc
1325 $ cd "$TESTDIR"/../doc
1324 $ python check-seclevel.py
1326 $ python check-seclevel.py
1325 $ cd $TESTTMP
1327 $ cd $TESTTMP
1326
1328
1327 #if serve
1329 #if serve
1328
1330
1329 Test the help pages in hgweb.
1331 Test the help pages in hgweb.
1330
1332
1331 Dish up an empty repo; serve it cold.
1333 Dish up an empty repo; serve it cold.
1332
1334
1333 $ hg init "$TESTTMP/test"
1335 $ hg init "$TESTTMP/test"
1334 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1336 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1335 $ cat hg.pid >> $DAEMON_PIDS
1337 $ cat hg.pid >> $DAEMON_PIDS
1336
1338
1337 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1339 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1338 200 Script output follows
1340 200 Script output follows
1339
1341
1340 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1342 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1341 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1343 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1342 <head>
1344 <head>
1343 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1345 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1344 <meta name="robots" content="index, nofollow" />
1346 <meta name="robots" content="index, nofollow" />
1345 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1347 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1346 <script type="text/javascript" src="/static/mercurial.js"></script>
1348 <script type="text/javascript" src="/static/mercurial.js"></script>
1347
1349
1348 <title>Help: Index</title>
1350 <title>Help: Index</title>
1349 </head>
1351 </head>
1350 <body>
1352 <body>
1351
1353
1352 <div class="container">
1354 <div class="container">
1353 <div class="menu">
1355 <div class="menu">
1354 <div class="logo">
1356 <div class="logo">
1355 <a href="http://mercurial.selenic.com/">
1357 <a href="http://mercurial.selenic.com/">
1356 <img src="/static/hglogo.png" alt="mercurial" /></a>
1358 <img src="/static/hglogo.png" alt="mercurial" /></a>
1357 </div>
1359 </div>
1358 <ul>
1360 <ul>
1359 <li><a href="/shortlog">log</a></li>
1361 <li><a href="/shortlog">log</a></li>
1360 <li><a href="/graph">graph</a></li>
1362 <li><a href="/graph">graph</a></li>
1361 <li><a href="/tags">tags</a></li>
1363 <li><a href="/tags">tags</a></li>
1362 <li><a href="/bookmarks">bookmarks</a></li>
1364 <li><a href="/bookmarks">bookmarks</a></li>
1363 <li><a href="/branches">branches</a></li>
1365 <li><a href="/branches">branches</a></li>
1364 </ul>
1366 </ul>
1365 <ul>
1367 <ul>
1366 <li class="active">help</li>
1368 <li class="active">help</li>
1367 </ul>
1369 </ul>
1368 </div>
1370 </div>
1369
1371
1370 <div class="main">
1372 <div class="main">
1371 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1373 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1372 <form class="search" action="/log">
1374 <form class="search" action="/log">
1373
1375
1374 <p><input name="rev" id="search1" type="text" size="30" /></p>
1376 <p><input name="rev" id="search1" type="text" size="30" /></p>
1375 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1377 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1376 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1378 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1377 </form>
1379 </form>
1378 <table class="bigtable">
1380 <table class="bigtable">
1379 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1381 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1380
1382
1381 <tr><td>
1383 <tr><td>
1382 <a href="/help/config">
1384 <a href="/help/config">
1383 config
1385 config
1384 </a>
1386 </a>
1385 </td><td>
1387 </td><td>
1386 Configuration Files
1388 Configuration Files
1387 </td></tr>
1389 </td></tr>
1388 <tr><td>
1390 <tr><td>
1389 <a href="/help/dates">
1391 <a href="/help/dates">
1390 dates
1392 dates
1391 </a>
1393 </a>
1392 </td><td>
1394 </td><td>
1393 Date Formats
1395 Date Formats
1394 </td></tr>
1396 </td></tr>
1395 <tr><td>
1397 <tr><td>
1396 <a href="/help/diffs">
1398 <a href="/help/diffs">
1397 diffs
1399 diffs
1398 </a>
1400 </a>
1399 </td><td>
1401 </td><td>
1400 Diff Formats
1402 Diff Formats
1401 </td></tr>
1403 </td></tr>
1402 <tr><td>
1404 <tr><td>
1403 <a href="/help/environment">
1405 <a href="/help/environment">
1404 environment
1406 environment
1405 </a>
1407 </a>
1406 </td><td>
1408 </td><td>
1407 Environment Variables
1409 Environment Variables
1408 </td></tr>
1410 </td></tr>
1409 <tr><td>
1411 <tr><td>
1410 <a href="/help/extensions">
1412 <a href="/help/extensions">
1411 extensions
1413 extensions
1412 </a>
1414 </a>
1413 </td><td>
1415 </td><td>
1414 Using Additional Features
1416 Using Additional Features
1415 </td></tr>
1417 </td></tr>
1416 <tr><td>
1418 <tr><td>
1417 <a href="/help/filesets">
1419 <a href="/help/filesets">
1418 filesets
1420 filesets
1419 </a>
1421 </a>
1420 </td><td>
1422 </td><td>
1421 Specifying File Sets
1423 Specifying File Sets
1422 </td></tr>
1424 </td></tr>
1423 <tr><td>
1425 <tr><td>
1424 <a href="/help/glossary">
1426 <a href="/help/glossary">
1425 glossary
1427 glossary
1426 </a>
1428 </a>
1427 </td><td>
1429 </td><td>
1428 Glossary
1430 Glossary
1429 </td></tr>
1431 </td></tr>
1430 <tr><td>
1432 <tr><td>
1431 <a href="/help/hgignore">
1433 <a href="/help/hgignore">
1432 hgignore
1434 hgignore
1433 </a>
1435 </a>
1434 </td><td>
1436 </td><td>
1435 Syntax for Mercurial Ignore Files
1437 Syntax for Mercurial Ignore Files
1436 </td></tr>
1438 </td></tr>
1437 <tr><td>
1439 <tr><td>
1438 <a href="/help/hgweb">
1440 <a href="/help/hgweb">
1439 hgweb
1441 hgweb
1440 </a>
1442 </a>
1441 </td><td>
1443 </td><td>
1442 Configuring hgweb
1444 Configuring hgweb
1443 </td></tr>
1445 </td></tr>
1444 <tr><td>
1446 <tr><td>
1445 <a href="/help/merge-tools">
1447 <a href="/help/merge-tools">
1446 merge-tools
1448 merge-tools
1447 </a>
1449 </a>
1448 </td><td>
1450 </td><td>
1449 Merge Tools
1451 Merge Tools
1450 </td></tr>
1452 </td></tr>
1451 <tr><td>
1453 <tr><td>
1452 <a href="/help/multirevs">
1454 <a href="/help/multirevs">
1453 multirevs
1455 multirevs
1454 </a>
1456 </a>
1455 </td><td>
1457 </td><td>
1456 Specifying Multiple Revisions
1458 Specifying Multiple Revisions
1457 </td></tr>
1459 </td></tr>
1458 <tr><td>
1460 <tr><td>
1459 <a href="/help/patterns">
1461 <a href="/help/patterns">
1460 patterns
1462 patterns
1461 </a>
1463 </a>
1462 </td><td>
1464 </td><td>
1463 File Name Patterns
1465 File Name Patterns
1464 </td></tr>
1466 </td></tr>
1465 <tr><td>
1467 <tr><td>
1466 <a href="/help/phases">
1468 <a href="/help/phases">
1467 phases
1469 phases
1468 </a>
1470 </a>
1469 </td><td>
1471 </td><td>
1470 Working with Phases
1472 Working with Phases
1471 </td></tr>
1473 </td></tr>
1472 <tr><td>
1474 <tr><td>
1473 <a href="/help/revisions">
1475 <a href="/help/revisions">
1474 revisions
1476 revisions
1475 </a>
1477 </a>
1476 </td><td>
1478 </td><td>
1477 Specifying Single Revisions
1479 Specifying Single Revisions
1478 </td></tr>
1480 </td></tr>
1479 <tr><td>
1481 <tr><td>
1480 <a href="/help/revsets">
1482 <a href="/help/revsets">
1481 revsets
1483 revsets
1482 </a>
1484 </a>
1483 </td><td>
1485 </td><td>
1484 Specifying Revision Sets
1486 Specifying Revision Sets
1485 </td></tr>
1487 </td></tr>
1486 <tr><td>
1488 <tr><td>
1487 <a href="/help/scripting">
1489 <a href="/help/scripting">
1488 scripting
1490 scripting
1489 </a>
1491 </a>
1490 </td><td>
1492 </td><td>
1491 Using Mercurial from scripts and automation
1493 Using Mercurial from scripts and automation
1492 </td></tr>
1494 </td></tr>
1493 <tr><td>
1495 <tr><td>
1494 <a href="/help/subrepos">
1496 <a href="/help/subrepos">
1495 subrepos
1497 subrepos
1496 </a>
1498 </a>
1497 </td><td>
1499 </td><td>
1498 Subrepositories
1500 Subrepositories
1499 </td></tr>
1501 </td></tr>
1500 <tr><td>
1502 <tr><td>
1501 <a href="/help/templating">
1503 <a href="/help/templating">
1502 templating
1504 templating
1503 </a>
1505 </a>
1504 </td><td>
1506 </td><td>
1505 Template Usage
1507 Template Usage
1506 </td></tr>
1508 </td></tr>
1507 <tr><td>
1509 <tr><td>
1508 <a href="/help/urls">
1510 <a href="/help/urls">
1509 urls
1511 urls
1510 </a>
1512 </a>
1511 </td><td>
1513 </td><td>
1512 URL Paths
1514 URL Paths
1513 </td></tr>
1515 </td></tr>
1514 <tr><td>
1516 <tr><td>
1515 <a href="/help/topic-containing-verbose">
1517 <a href="/help/topic-containing-verbose">
1516 topic-containing-verbose
1518 topic-containing-verbose
1517 </a>
1519 </a>
1518 </td><td>
1520 </td><td>
1519 This is the topic to test omit indicating.
1521 This is the topic to test omit indicating.
1520 </td></tr>
1522 </td></tr>
1521
1523
1522 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1524 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1523
1525
1524 <tr><td>
1526 <tr><td>
1525 <a href="/help/add">
1527 <a href="/help/add">
1526 add
1528 add
1527 </a>
1529 </a>
1528 </td><td>
1530 </td><td>
1529 add the specified files on the next commit
1531 add the specified files on the next commit
1530 </td></tr>
1532 </td></tr>
1531 <tr><td>
1533 <tr><td>
1532 <a href="/help/annotate">
1534 <a href="/help/annotate">
1533 annotate
1535 annotate
1534 </a>
1536 </a>
1535 </td><td>
1537 </td><td>
1536 show changeset information by line for each file
1538 show changeset information by line for each file
1537 </td></tr>
1539 </td></tr>
1538 <tr><td>
1540 <tr><td>
1539 <a href="/help/clone">
1541 <a href="/help/clone">
1540 clone
1542 clone
1541 </a>
1543 </a>
1542 </td><td>
1544 </td><td>
1543 make a copy of an existing repository
1545 make a copy of an existing repository
1544 </td></tr>
1546 </td></tr>
1545 <tr><td>
1547 <tr><td>
1546 <a href="/help/commit">
1548 <a href="/help/commit">
1547 commit
1549 commit
1548 </a>
1550 </a>
1549 </td><td>
1551 </td><td>
1550 commit the specified files or all outstanding changes
1552 commit the specified files or all outstanding changes
1551 </td></tr>
1553 </td></tr>
1552 <tr><td>
1554 <tr><td>
1553 <a href="/help/diff">
1555 <a href="/help/diff">
1554 diff
1556 diff
1555 </a>
1557 </a>
1556 </td><td>
1558 </td><td>
1557 diff repository (or selected files)
1559 diff repository (or selected files)
1558 </td></tr>
1560 </td></tr>
1559 <tr><td>
1561 <tr><td>
1560 <a href="/help/export">
1562 <a href="/help/export">
1561 export
1563 export
1562 </a>
1564 </a>
1563 </td><td>
1565 </td><td>
1564 dump the header and diffs for one or more changesets
1566 dump the header and diffs for one or more changesets
1565 </td></tr>
1567 </td></tr>
1566 <tr><td>
1568 <tr><td>
1567 <a href="/help/forget">
1569 <a href="/help/forget">
1568 forget
1570 forget
1569 </a>
1571 </a>
1570 </td><td>
1572 </td><td>
1571 forget the specified files on the next commit
1573 forget the specified files on the next commit
1572 </td></tr>
1574 </td></tr>
1573 <tr><td>
1575 <tr><td>
1574 <a href="/help/init">
1576 <a href="/help/init">
1575 init
1577 init
1576 </a>
1578 </a>
1577 </td><td>
1579 </td><td>
1578 create a new repository in the given directory
1580 create a new repository in the given directory
1579 </td></tr>
1581 </td></tr>
1580 <tr><td>
1582 <tr><td>
1581 <a href="/help/log">
1583 <a href="/help/log">
1582 log
1584 log
1583 </a>
1585 </a>
1584 </td><td>
1586 </td><td>
1585 show revision history of entire repository or files
1587 show revision history of entire repository or files
1586 </td></tr>
1588 </td></tr>
1587 <tr><td>
1589 <tr><td>
1588 <a href="/help/merge">
1590 <a href="/help/merge">
1589 merge
1591 merge
1590 </a>
1592 </a>
1591 </td><td>
1593 </td><td>
1592 merge another revision into working directory
1594 merge another revision into working directory
1593 </td></tr>
1595 </td></tr>
1594 <tr><td>
1596 <tr><td>
1595 <a href="/help/pull">
1597 <a href="/help/pull">
1596 pull
1598 pull
1597 </a>
1599 </a>
1598 </td><td>
1600 </td><td>
1599 pull changes from the specified source
1601 pull changes from the specified source
1600 </td></tr>
1602 </td></tr>
1601 <tr><td>
1603 <tr><td>
1602 <a href="/help/push">
1604 <a href="/help/push">
1603 push
1605 push
1604 </a>
1606 </a>
1605 </td><td>
1607 </td><td>
1606 push changes to the specified destination
1608 push changes to the specified destination
1607 </td></tr>
1609 </td></tr>
1608 <tr><td>
1610 <tr><td>
1609 <a href="/help/remove">
1611 <a href="/help/remove">
1610 remove
1612 remove
1611 </a>
1613 </a>
1612 </td><td>
1614 </td><td>
1613 remove the specified files on the next commit
1615 remove the specified files on the next commit
1614 </td></tr>
1616 </td></tr>
1615 <tr><td>
1617 <tr><td>
1616 <a href="/help/serve">
1618 <a href="/help/serve">
1617 serve
1619 serve
1618 </a>
1620 </a>
1619 </td><td>
1621 </td><td>
1620 start stand-alone webserver
1622 start stand-alone webserver
1621 </td></tr>
1623 </td></tr>
1622 <tr><td>
1624 <tr><td>
1623 <a href="/help/status">
1625 <a href="/help/status">
1624 status
1626 status
1625 </a>
1627 </a>
1626 </td><td>
1628 </td><td>
1627 show changed files in the working directory
1629 show changed files in the working directory
1628 </td></tr>
1630 </td></tr>
1629 <tr><td>
1631 <tr><td>
1630 <a href="/help/summary">
1632 <a href="/help/summary">
1631 summary
1633 summary
1632 </a>
1634 </a>
1633 </td><td>
1635 </td><td>
1634 summarize working directory state
1636 summarize working directory state
1635 </td></tr>
1637 </td></tr>
1636 <tr><td>
1638 <tr><td>
1637 <a href="/help/update">
1639 <a href="/help/update">
1638 update
1640 update
1639 </a>
1641 </a>
1640 </td><td>
1642 </td><td>
1641 update working directory (or switch revisions)
1643 update working directory (or switch revisions)
1642 </td></tr>
1644 </td></tr>
1643
1645
1644 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1646 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1645
1647
1646 <tr><td>
1648 <tr><td>
1647 <a href="/help/addremove">
1649 <a href="/help/addremove">
1648 addremove
1650 addremove
1649 </a>
1651 </a>
1650 </td><td>
1652 </td><td>
1651 add all new files, delete all missing files
1653 add all new files, delete all missing files
1652 </td></tr>
1654 </td></tr>
1653 <tr><td>
1655 <tr><td>
1654 <a href="/help/archive">
1656 <a href="/help/archive">
1655 archive
1657 archive
1656 </a>
1658 </a>
1657 </td><td>
1659 </td><td>
1658 create an unversioned archive of a repository revision
1660 create an unversioned archive of a repository revision
1659 </td></tr>
1661 </td></tr>
1660 <tr><td>
1662 <tr><td>
1661 <a href="/help/backout">
1663 <a href="/help/backout">
1662 backout
1664 backout
1663 </a>
1665 </a>
1664 </td><td>
1666 </td><td>
1665 reverse effect of earlier changeset
1667 reverse effect of earlier changeset
1666 </td></tr>
1668 </td></tr>
1667 <tr><td>
1669 <tr><td>
1668 <a href="/help/bisect">
1670 <a href="/help/bisect">
1669 bisect
1671 bisect
1670 </a>
1672 </a>
1671 </td><td>
1673 </td><td>
1672 subdivision search of changesets
1674 subdivision search of changesets
1673 </td></tr>
1675 </td></tr>
1674 <tr><td>
1676 <tr><td>
1675 <a href="/help/bookmarks">
1677 <a href="/help/bookmarks">
1676 bookmarks
1678 bookmarks
1677 </a>
1679 </a>
1678 </td><td>
1680 </td><td>
1679 create a new bookmark or list existing bookmarks
1681 create a new bookmark or list existing bookmarks
1680 </td></tr>
1682 </td></tr>
1681 <tr><td>
1683 <tr><td>
1682 <a href="/help/branch">
1684 <a href="/help/branch">
1683 branch
1685 branch
1684 </a>
1686 </a>
1685 </td><td>
1687 </td><td>
1686 set or show the current branch name
1688 set or show the current branch name
1687 </td></tr>
1689 </td></tr>
1688 <tr><td>
1690 <tr><td>
1689 <a href="/help/branches">
1691 <a href="/help/branches">
1690 branches
1692 branches
1691 </a>
1693 </a>
1692 </td><td>
1694 </td><td>
1693 list repository named branches
1695 list repository named branches
1694 </td></tr>
1696 </td></tr>
1695 <tr><td>
1697 <tr><td>
1696 <a href="/help/bundle">
1698 <a href="/help/bundle">
1697 bundle
1699 bundle
1698 </a>
1700 </a>
1699 </td><td>
1701 </td><td>
1700 create a changegroup file
1702 create a changegroup file
1701 </td></tr>
1703 </td></tr>
1702 <tr><td>
1704 <tr><td>
1703 <a href="/help/cat">
1705 <a href="/help/cat">
1704 cat
1706 cat
1705 </a>
1707 </a>
1706 </td><td>
1708 </td><td>
1707 output the current or given revision of files
1709 output the current or given revision of files
1708 </td></tr>
1710 </td></tr>
1709 <tr><td>
1711 <tr><td>
1710 <a href="/help/config">
1712 <a href="/help/config">
1711 config
1713 config
1712 </a>
1714 </a>
1713 </td><td>
1715 </td><td>
1714 show combined config settings from all hgrc files
1716 show combined config settings from all hgrc files
1715 </td></tr>
1717 </td></tr>
1716 <tr><td>
1718 <tr><td>
1717 <a href="/help/copy">
1719 <a href="/help/copy">
1718 copy
1720 copy
1719 </a>
1721 </a>
1720 </td><td>
1722 </td><td>
1721 mark files as copied for the next commit
1723 mark files as copied for the next commit
1722 </td></tr>
1724 </td></tr>
1723 <tr><td>
1725 <tr><td>
1724 <a href="/help/files">
1726 <a href="/help/files">
1725 files
1727 files
1726 </a>
1728 </a>
1727 </td><td>
1729 </td><td>
1728 list tracked files
1730 list tracked files
1729 </td></tr>
1731 </td></tr>
1730 <tr><td>
1732 <tr><td>
1731 <a href="/help/graft">
1733 <a href="/help/graft">
1732 graft
1734 graft
1733 </a>
1735 </a>
1734 </td><td>
1736 </td><td>
1735 copy changes from other branches onto the current branch
1737 copy changes from other branches onto the current branch
1736 </td></tr>
1738 </td></tr>
1737 <tr><td>
1739 <tr><td>
1738 <a href="/help/grep">
1740 <a href="/help/grep">
1739 grep
1741 grep
1740 </a>
1742 </a>
1741 </td><td>
1743 </td><td>
1742 search for a pattern in specified files and revisions
1744 search for a pattern in specified files and revisions
1743 </td></tr>
1745 </td></tr>
1744 <tr><td>
1746 <tr><td>
1745 <a href="/help/heads">
1747 <a href="/help/heads">
1746 heads
1748 heads
1747 </a>
1749 </a>
1748 </td><td>
1750 </td><td>
1749 show branch heads
1751 show branch heads
1750 </td></tr>
1752 </td></tr>
1751 <tr><td>
1753 <tr><td>
1752 <a href="/help/help">
1754 <a href="/help/help">
1753 help
1755 help
1754 </a>
1756 </a>
1755 </td><td>
1757 </td><td>
1756 show help for a given topic or a help overview
1758 show help for a given topic or a help overview
1757 </td></tr>
1759 </td></tr>
1758 <tr><td>
1760 <tr><td>
1759 <a href="/help/identify">
1761 <a href="/help/identify">
1760 identify
1762 identify
1761 </a>
1763 </a>
1762 </td><td>
1764 </td><td>
1763 identify the working directory or specified revision
1765 identify the working directory or specified revision
1764 </td></tr>
1766 </td></tr>
1765 <tr><td>
1767 <tr><td>
1766 <a href="/help/import">
1768 <a href="/help/import">
1767 import
1769 import
1768 </a>
1770 </a>
1769 </td><td>
1771 </td><td>
1770 import an ordered set of patches
1772 import an ordered set of patches
1771 </td></tr>
1773 </td></tr>
1772 <tr><td>
1774 <tr><td>
1773 <a href="/help/incoming">
1775 <a href="/help/incoming">
1774 incoming
1776 incoming
1775 </a>
1777 </a>
1776 </td><td>
1778 </td><td>
1777 show new changesets found in source
1779 show new changesets found in source
1778 </td></tr>
1780 </td></tr>
1779 <tr><td>
1781 <tr><td>
1780 <a href="/help/manifest">
1782 <a href="/help/manifest">
1781 manifest
1783 manifest
1782 </a>
1784 </a>
1783 </td><td>
1785 </td><td>
1784 output the current or given revision of the project manifest
1786 output the current or given revision of the project manifest
1785 </td></tr>
1787 </td></tr>
1786 <tr><td>
1788 <tr><td>
1787 <a href="/help/nohelp">
1789 <a href="/help/nohelp">
1788 nohelp
1790 nohelp
1789 </a>
1791 </a>
1790 </td><td>
1792 </td><td>
1791 (no help text available)
1793 (no help text available)
1792 </td></tr>
1794 </td></tr>
1793 <tr><td>
1795 <tr><td>
1794 <a href="/help/outgoing">
1796 <a href="/help/outgoing">
1795 outgoing
1797 outgoing
1796 </a>
1798 </a>
1797 </td><td>
1799 </td><td>
1798 show changesets not found in the destination
1800 show changesets not found in the destination
1799 </td></tr>
1801 </td></tr>
1800 <tr><td>
1802 <tr><td>
1801 <a href="/help/paths">
1803 <a href="/help/paths">
1802 paths
1804 paths
1803 </a>
1805 </a>
1804 </td><td>
1806 </td><td>
1805 show aliases for remote repositories
1807 show aliases for remote repositories
1806 </td></tr>
1808 </td></tr>
1807 <tr><td>
1809 <tr><td>
1808 <a href="/help/phase">
1810 <a href="/help/phase">
1809 phase
1811 phase
1810 </a>
1812 </a>
1811 </td><td>
1813 </td><td>
1812 set or show the current phase name
1814 set or show the current phase name
1813 </td></tr>
1815 </td></tr>
1814 <tr><td>
1816 <tr><td>
1815 <a href="/help/recover">
1817 <a href="/help/recover">
1816 recover
1818 recover
1817 </a>
1819 </a>
1818 </td><td>
1820 </td><td>
1819 roll back an interrupted transaction
1821 roll back an interrupted transaction
1820 </td></tr>
1822 </td></tr>
1821 <tr><td>
1823 <tr><td>
1822 <a href="/help/rename">
1824 <a href="/help/rename">
1823 rename
1825 rename
1824 </a>
1826 </a>
1825 </td><td>
1827 </td><td>
1826 rename files; equivalent of copy + remove
1828 rename files; equivalent of copy + remove
1827 </td></tr>
1829 </td></tr>
1828 <tr><td>
1830 <tr><td>
1829 <a href="/help/resolve">
1831 <a href="/help/resolve">
1830 resolve
1832 resolve
1831 </a>
1833 </a>
1832 </td><td>
1834 </td><td>
1833 redo merges or set/view the merge status of files
1835 redo merges or set/view the merge status of files
1834 </td></tr>
1836 </td></tr>
1835 <tr><td>
1837 <tr><td>
1836 <a href="/help/revert">
1838 <a href="/help/revert">
1837 revert
1839 revert
1838 </a>
1840 </a>
1839 </td><td>
1841 </td><td>
1840 restore files to their checkout state
1842 restore files to their checkout state
1841 </td></tr>
1843 </td></tr>
1842 <tr><td>
1844 <tr><td>
1843 <a href="/help/root">
1845 <a href="/help/root">
1844 root
1846 root
1845 </a>
1847 </a>
1846 </td><td>
1848 </td><td>
1847 print the root (top) of the current working directory
1849 print the root (top) of the current working directory
1848 </td></tr>
1850 </td></tr>
1849 <tr><td>
1851 <tr><td>
1850 <a href="/help/tag">
1852 <a href="/help/tag">
1851 tag
1853 tag
1852 </a>
1854 </a>
1853 </td><td>
1855 </td><td>
1854 add one or more tags for the current or given revision
1856 add one or more tags for the current or given revision
1855 </td></tr>
1857 </td></tr>
1856 <tr><td>
1858 <tr><td>
1857 <a href="/help/tags">
1859 <a href="/help/tags">
1858 tags
1860 tags
1859 </a>
1861 </a>
1860 </td><td>
1862 </td><td>
1861 list repository tags
1863 list repository tags
1862 </td></tr>
1864 </td></tr>
1863 <tr><td>
1865 <tr><td>
1864 <a href="/help/unbundle">
1866 <a href="/help/unbundle">
1865 unbundle
1867 unbundle
1866 </a>
1868 </a>
1867 </td><td>
1869 </td><td>
1868 apply one or more changegroup files
1870 apply one or more changegroup files
1869 </td></tr>
1871 </td></tr>
1870 <tr><td>
1872 <tr><td>
1871 <a href="/help/verify">
1873 <a href="/help/verify">
1872 verify
1874 verify
1873 </a>
1875 </a>
1874 </td><td>
1876 </td><td>
1875 verify the integrity of the repository
1877 verify the integrity of the repository
1876 </td></tr>
1878 </td></tr>
1877 <tr><td>
1879 <tr><td>
1878 <a href="/help/version">
1880 <a href="/help/version">
1879 version
1881 version
1880 </a>
1882 </a>
1881 </td><td>
1883 </td><td>
1882 output version and copyright information
1884 output version and copyright information
1883 </td></tr>
1885 </td></tr>
1884 </table>
1886 </table>
1885 </div>
1887 </div>
1886 </div>
1888 </div>
1887
1889
1888 <script type="text/javascript">process_dates()</script>
1890 <script type="text/javascript">process_dates()</script>
1889
1891
1890
1892
1891 </body>
1893 </body>
1892 </html>
1894 </html>
1893
1895
1894
1896
1895 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1897 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1896 200 Script output follows
1898 200 Script output follows
1897
1899
1898 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1900 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1899 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1901 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1900 <head>
1902 <head>
1901 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1903 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1902 <meta name="robots" content="index, nofollow" />
1904 <meta name="robots" content="index, nofollow" />
1903 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1905 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1904 <script type="text/javascript" src="/static/mercurial.js"></script>
1906 <script type="text/javascript" src="/static/mercurial.js"></script>
1905
1907
1906 <title>Help: add</title>
1908 <title>Help: add</title>
1907 </head>
1909 </head>
1908 <body>
1910 <body>
1909
1911
1910 <div class="container">
1912 <div class="container">
1911 <div class="menu">
1913 <div class="menu">
1912 <div class="logo">
1914 <div class="logo">
1913 <a href="http://mercurial.selenic.com/">
1915 <a href="http://mercurial.selenic.com/">
1914 <img src="/static/hglogo.png" alt="mercurial" /></a>
1916 <img src="/static/hglogo.png" alt="mercurial" /></a>
1915 </div>
1917 </div>
1916 <ul>
1918 <ul>
1917 <li><a href="/shortlog">log</a></li>
1919 <li><a href="/shortlog">log</a></li>
1918 <li><a href="/graph">graph</a></li>
1920 <li><a href="/graph">graph</a></li>
1919 <li><a href="/tags">tags</a></li>
1921 <li><a href="/tags">tags</a></li>
1920 <li><a href="/bookmarks">bookmarks</a></li>
1922 <li><a href="/bookmarks">bookmarks</a></li>
1921 <li><a href="/branches">branches</a></li>
1923 <li><a href="/branches">branches</a></li>
1922 </ul>
1924 </ul>
1923 <ul>
1925 <ul>
1924 <li class="active"><a href="/help">help</a></li>
1926 <li class="active"><a href="/help">help</a></li>
1925 </ul>
1927 </ul>
1926 </div>
1928 </div>
1927
1929
1928 <div class="main">
1930 <div class="main">
1929 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1931 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1930 <h3>Help: add</h3>
1932 <h3>Help: add</h3>
1931
1933
1932 <form class="search" action="/log">
1934 <form class="search" action="/log">
1933
1935
1934 <p><input name="rev" id="search1" type="text" size="30" /></p>
1936 <p><input name="rev" id="search1" type="text" size="30" /></p>
1935 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1937 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1936 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1938 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1937 </form>
1939 </form>
1938 <div id="doc">
1940 <div id="doc">
1939 <p>
1941 <p>
1940 hg add [OPTION]... [FILE]...
1942 hg add [OPTION]... [FILE]...
1941 </p>
1943 </p>
1942 <p>
1944 <p>
1943 add the specified files on the next commit
1945 add the specified files on the next commit
1944 </p>
1946 </p>
1945 <p>
1947 <p>
1946 Schedule files to be version controlled and added to the
1948 Schedule files to be version controlled and added to the
1947 repository.
1949 repository.
1948 </p>
1950 </p>
1949 <p>
1951 <p>
1950 The files will be added to the repository at the next commit. To
1952 The files will be added to the repository at the next commit. To
1951 undo an add before that, see &quot;hg forget&quot;.
1953 undo an add before that, see &quot;hg forget&quot;.
1952 </p>
1954 </p>
1953 <p>
1955 <p>
1954 If no names are given, add all files to the repository.
1956 If no names are given, add all files to the repository.
1955 </p>
1957 </p>
1956 <p>
1958 <p>
1957 An example showing how new (unknown) files are added
1959 An example showing how new (unknown) files are added
1958 automatically by &quot;hg add&quot;:
1960 automatically by &quot;hg add&quot;:
1959 </p>
1961 </p>
1960 <pre>
1962 <pre>
1961 \$ ls (re)
1963 \$ ls (re)
1962 foo.c
1964 foo.c
1963 \$ hg status (re)
1965 \$ hg status (re)
1964 ? foo.c
1966 ? foo.c
1965 \$ hg add (re)
1967 \$ hg add (re)
1966 adding foo.c
1968 adding foo.c
1967 \$ hg status (re)
1969 \$ hg status (re)
1968 A foo.c
1970 A foo.c
1969 </pre>
1971 </pre>
1970 <p>
1972 <p>
1971 Returns 0 if all files are successfully added.
1973 Returns 0 if all files are successfully added.
1972 </p>
1974 </p>
1973 <p>
1975 <p>
1974 options ([+] can be repeated):
1976 options ([+] can be repeated):
1975 </p>
1977 </p>
1976 <table>
1978 <table>
1977 <tr><td>-I</td>
1979 <tr><td>-I</td>
1978 <td>--include PATTERN [+]</td>
1980 <td>--include PATTERN [+]</td>
1979 <td>include names matching the given patterns</td></tr>
1981 <td>include names matching the given patterns</td></tr>
1980 <tr><td>-X</td>
1982 <tr><td>-X</td>
1981 <td>--exclude PATTERN [+]</td>
1983 <td>--exclude PATTERN [+]</td>
1982 <td>exclude names matching the given patterns</td></tr>
1984 <td>exclude names matching the given patterns</td></tr>
1983 <tr><td>-S</td>
1985 <tr><td>-S</td>
1984 <td>--subrepos</td>
1986 <td>--subrepos</td>
1985 <td>recurse into subrepositories</td></tr>
1987 <td>recurse into subrepositories</td></tr>
1986 <tr><td>-n</td>
1988 <tr><td>-n</td>
1987 <td>--dry-run</td>
1989 <td>--dry-run</td>
1988 <td>do not perform actions, just print output</td></tr>
1990 <td>do not perform actions, just print output</td></tr>
1989 </table>
1991 </table>
1990 <p>
1992 <p>
1991 global options ([+] can be repeated):
1993 global options ([+] can be repeated):
1992 </p>
1994 </p>
1993 <table>
1995 <table>
1994 <tr><td>-R</td>
1996 <tr><td>-R</td>
1995 <td>--repository REPO</td>
1997 <td>--repository REPO</td>
1996 <td>repository root directory or name of overlay bundle file</td></tr>
1998 <td>repository root directory or name of overlay bundle file</td></tr>
1997 <tr><td></td>
1999 <tr><td></td>
1998 <td>--cwd DIR</td>
2000 <td>--cwd DIR</td>
1999 <td>change working directory</td></tr>
2001 <td>change working directory</td></tr>
2000 <tr><td>-y</td>
2002 <tr><td>-y</td>
2001 <td>--noninteractive</td>
2003 <td>--noninteractive</td>
2002 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2004 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2003 <tr><td>-q</td>
2005 <tr><td>-q</td>
2004 <td>--quiet</td>
2006 <td>--quiet</td>
2005 <td>suppress output</td></tr>
2007 <td>suppress output</td></tr>
2006 <tr><td>-v</td>
2008 <tr><td>-v</td>
2007 <td>--verbose</td>
2009 <td>--verbose</td>
2008 <td>enable additional output</td></tr>
2010 <td>enable additional output</td></tr>
2009 <tr><td></td>
2011 <tr><td></td>
2010 <td>--config CONFIG [+]</td>
2012 <td>--config CONFIG [+]</td>
2011 <td>set/override config option (use 'section.name=value')</td></tr>
2013 <td>set/override config option (use 'section.name=value')</td></tr>
2012 <tr><td></td>
2014 <tr><td></td>
2013 <td>--debug</td>
2015 <td>--debug</td>
2014 <td>enable debugging output</td></tr>
2016 <td>enable debugging output</td></tr>
2015 <tr><td></td>
2017 <tr><td></td>
2016 <td>--debugger</td>
2018 <td>--debugger</td>
2017 <td>start debugger</td></tr>
2019 <td>start debugger</td></tr>
2018 <tr><td></td>
2020 <tr><td></td>
2019 <td>--encoding ENCODE</td>
2021 <td>--encoding ENCODE</td>
2020 <td>set the charset encoding (default: ascii)</td></tr>
2022 <td>set the charset encoding (default: ascii)</td></tr>
2021 <tr><td></td>
2023 <tr><td></td>
2022 <td>--encodingmode MODE</td>
2024 <td>--encodingmode MODE</td>
2023 <td>set the charset encoding mode (default: strict)</td></tr>
2025 <td>set the charset encoding mode (default: strict)</td></tr>
2024 <tr><td></td>
2026 <tr><td></td>
2025 <td>--traceback</td>
2027 <td>--traceback</td>
2026 <td>always print a traceback on exception</td></tr>
2028 <td>always print a traceback on exception</td></tr>
2027 <tr><td></td>
2029 <tr><td></td>
2028 <td>--time</td>
2030 <td>--time</td>
2029 <td>time how long the command takes</td></tr>
2031 <td>time how long the command takes</td></tr>
2030 <tr><td></td>
2032 <tr><td></td>
2031 <td>--profile</td>
2033 <td>--profile</td>
2032 <td>print command execution profile</td></tr>
2034 <td>print command execution profile</td></tr>
2033 <tr><td></td>
2035 <tr><td></td>
2034 <td>--version</td>
2036 <td>--version</td>
2035 <td>output version information and exit</td></tr>
2037 <td>output version information and exit</td></tr>
2036 <tr><td>-h</td>
2038 <tr><td>-h</td>
2037 <td>--help</td>
2039 <td>--help</td>
2038 <td>display help and exit</td></tr>
2040 <td>display help and exit</td></tr>
2039 <tr><td></td>
2041 <tr><td></td>
2040 <td>--hidden</td>
2042 <td>--hidden</td>
2041 <td>consider hidden changesets</td></tr>
2043 <td>consider hidden changesets</td></tr>
2042 </table>
2044 </table>
2043
2045
2044 </div>
2046 </div>
2045 </div>
2047 </div>
2046 </div>
2048 </div>
2047
2049
2048 <script type="text/javascript">process_dates()</script>
2050 <script type="text/javascript">process_dates()</script>
2049
2051
2050
2052
2051 </body>
2053 </body>
2052 </html>
2054 </html>
2053
2055
2054
2056
2055 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2057 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2056 200 Script output follows
2058 200 Script output follows
2057
2059
2058 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2060 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2059 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2061 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2060 <head>
2062 <head>
2061 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2063 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2062 <meta name="robots" content="index, nofollow" />
2064 <meta name="robots" content="index, nofollow" />
2063 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2065 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2064 <script type="text/javascript" src="/static/mercurial.js"></script>
2066 <script type="text/javascript" src="/static/mercurial.js"></script>
2065
2067
2066 <title>Help: remove</title>
2068 <title>Help: remove</title>
2067 </head>
2069 </head>
2068 <body>
2070 <body>
2069
2071
2070 <div class="container">
2072 <div class="container">
2071 <div class="menu">
2073 <div class="menu">
2072 <div class="logo">
2074 <div class="logo">
2073 <a href="http://mercurial.selenic.com/">
2075 <a href="http://mercurial.selenic.com/">
2074 <img src="/static/hglogo.png" alt="mercurial" /></a>
2076 <img src="/static/hglogo.png" alt="mercurial" /></a>
2075 </div>
2077 </div>
2076 <ul>
2078 <ul>
2077 <li><a href="/shortlog">log</a></li>
2079 <li><a href="/shortlog">log</a></li>
2078 <li><a href="/graph">graph</a></li>
2080 <li><a href="/graph">graph</a></li>
2079 <li><a href="/tags">tags</a></li>
2081 <li><a href="/tags">tags</a></li>
2080 <li><a href="/bookmarks">bookmarks</a></li>
2082 <li><a href="/bookmarks">bookmarks</a></li>
2081 <li><a href="/branches">branches</a></li>
2083 <li><a href="/branches">branches</a></li>
2082 </ul>
2084 </ul>
2083 <ul>
2085 <ul>
2084 <li class="active"><a href="/help">help</a></li>
2086 <li class="active"><a href="/help">help</a></li>
2085 </ul>
2087 </ul>
2086 </div>
2088 </div>
2087
2089
2088 <div class="main">
2090 <div class="main">
2089 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2091 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2090 <h3>Help: remove</h3>
2092 <h3>Help: remove</h3>
2091
2093
2092 <form class="search" action="/log">
2094 <form class="search" action="/log">
2093
2095
2094 <p><input name="rev" id="search1" type="text" size="30" /></p>
2096 <p><input name="rev" id="search1" type="text" size="30" /></p>
2095 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2097 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2096 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2098 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2097 </form>
2099 </form>
2098 <div id="doc">
2100 <div id="doc">
2099 <p>
2101 <p>
2100 hg remove [OPTION]... FILE...
2102 hg remove [OPTION]... FILE...
2101 </p>
2103 </p>
2102 <p>
2104 <p>
2103 aliases: rm
2105 aliases: rm
2104 </p>
2106 </p>
2105 <p>
2107 <p>
2106 remove the specified files on the next commit
2108 remove the specified files on the next commit
2107 </p>
2109 </p>
2108 <p>
2110 <p>
2109 Schedule the indicated files for removal from the current branch.
2111 Schedule the indicated files for removal from the current branch.
2110 </p>
2112 </p>
2111 <p>
2113 <p>
2112 This command schedules the files to be removed at the next commit.
2114 This command schedules the files to be removed at the next commit.
2113 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2115 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2114 files, see &quot;hg forget&quot;.
2116 files, see &quot;hg forget&quot;.
2115 </p>
2117 </p>
2116 <p>
2118 <p>
2117 -A/--after can be used to remove only files that have already
2119 -A/--after can be used to remove only files that have already
2118 been deleted, -f/--force can be used to force deletion, and -Af
2120 been deleted, -f/--force can be used to force deletion, and -Af
2119 can be used to remove files from the next revision without
2121 can be used to remove files from the next revision without
2120 deleting them from the working directory.
2122 deleting them from the working directory.
2121 </p>
2123 </p>
2122 <p>
2124 <p>
2123 The following table details the behavior of remove for different
2125 The following table details the behavior of remove for different
2124 file states (columns) and option combinations (rows). The file
2126 file states (columns) and option combinations (rows). The file
2125 states are Added [A], Clean [C], Modified [M] and Missing [!]
2127 states are Added [A], Clean [C], Modified [M] and Missing [!]
2126 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2128 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2127 (from branch) and Delete (from disk):
2129 (from branch) and Delete (from disk):
2128 </p>
2130 </p>
2129 <table>
2131 <table>
2130 <tr><td>opt/state</td>
2132 <tr><td>opt/state</td>
2131 <td>A</td>
2133 <td>A</td>
2132 <td>C</td>
2134 <td>C</td>
2133 <td>M</td>
2135 <td>M</td>
2134 <td>!</td></tr>
2136 <td>!</td></tr>
2135 <tr><td>none</td>
2137 <tr><td>none</td>
2136 <td>W</td>
2138 <td>W</td>
2137 <td>RD</td>
2139 <td>RD</td>
2138 <td>W</td>
2140 <td>W</td>
2139 <td>R</td></tr>
2141 <td>R</td></tr>
2140 <tr><td>-f</td>
2142 <tr><td>-f</td>
2141 <td>R</td>
2143 <td>R</td>
2142 <td>RD</td>
2144 <td>RD</td>
2143 <td>RD</td>
2145 <td>RD</td>
2144 <td>R</td></tr>
2146 <td>R</td></tr>
2145 <tr><td>-A</td>
2147 <tr><td>-A</td>
2146 <td>W</td>
2148 <td>W</td>
2147 <td>W</td>
2149 <td>W</td>
2148 <td>W</td>
2150 <td>W</td>
2149 <td>R</td></tr>
2151 <td>R</td></tr>
2150 <tr><td>-Af</td>
2152 <tr><td>-Af</td>
2151 <td>R</td>
2153 <td>R</td>
2152 <td>R</td>
2154 <td>R</td>
2153 <td>R</td>
2155 <td>R</td>
2154 <td>R</td></tr>
2156 <td>R</td></tr>
2155 </table>
2157 </table>
2156 <p>
2158 <p>
2157 Note that remove never deletes files in Added [A] state from the
2159 Note that remove never deletes files in Added [A] state from the
2158 working directory, not even if option --force is specified.
2160 working directory, not even if option --force is specified.
2159 </p>
2161 </p>
2160 <p>
2162 <p>
2161 Returns 0 on success, 1 if any warnings encountered.
2163 Returns 0 on success, 1 if any warnings encountered.
2162 </p>
2164 </p>
2163 <p>
2165 <p>
2164 options ([+] can be repeated):
2166 options ([+] can be repeated):
2165 </p>
2167 </p>
2166 <table>
2168 <table>
2167 <tr><td>-A</td>
2169 <tr><td>-A</td>
2168 <td>--after</td>
2170 <td>--after</td>
2169 <td>record delete for missing files</td></tr>
2171 <td>record delete for missing files</td></tr>
2170 <tr><td>-f</td>
2172 <tr><td>-f</td>
2171 <td>--force</td>
2173 <td>--force</td>
2172 <td>remove (and delete) file even if added or modified</td></tr>
2174 <td>remove (and delete) file even if added or modified</td></tr>
2173 <tr><td>-S</td>
2175 <tr><td>-S</td>
2174 <td>--subrepos</td>
2176 <td>--subrepos</td>
2175 <td>recurse into subrepositories</td></tr>
2177 <td>recurse into subrepositories</td></tr>
2176 <tr><td>-I</td>
2178 <tr><td>-I</td>
2177 <td>--include PATTERN [+]</td>
2179 <td>--include PATTERN [+]</td>
2178 <td>include names matching the given patterns</td></tr>
2180 <td>include names matching the given patterns</td></tr>
2179 <tr><td>-X</td>
2181 <tr><td>-X</td>
2180 <td>--exclude PATTERN [+]</td>
2182 <td>--exclude PATTERN [+]</td>
2181 <td>exclude names matching the given patterns</td></tr>
2183 <td>exclude names matching the given patterns</td></tr>
2182 </table>
2184 </table>
2183 <p>
2185 <p>
2184 global options ([+] can be repeated):
2186 global options ([+] can be repeated):
2185 </p>
2187 </p>
2186 <table>
2188 <table>
2187 <tr><td>-R</td>
2189 <tr><td>-R</td>
2188 <td>--repository REPO</td>
2190 <td>--repository REPO</td>
2189 <td>repository root directory or name of overlay bundle file</td></tr>
2191 <td>repository root directory or name of overlay bundle file</td></tr>
2190 <tr><td></td>
2192 <tr><td></td>
2191 <td>--cwd DIR</td>
2193 <td>--cwd DIR</td>
2192 <td>change working directory</td></tr>
2194 <td>change working directory</td></tr>
2193 <tr><td>-y</td>
2195 <tr><td>-y</td>
2194 <td>--noninteractive</td>
2196 <td>--noninteractive</td>
2195 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2197 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2196 <tr><td>-q</td>
2198 <tr><td>-q</td>
2197 <td>--quiet</td>
2199 <td>--quiet</td>
2198 <td>suppress output</td></tr>
2200 <td>suppress output</td></tr>
2199 <tr><td>-v</td>
2201 <tr><td>-v</td>
2200 <td>--verbose</td>
2202 <td>--verbose</td>
2201 <td>enable additional output</td></tr>
2203 <td>enable additional output</td></tr>
2202 <tr><td></td>
2204 <tr><td></td>
2203 <td>--config CONFIG [+]</td>
2205 <td>--config CONFIG [+]</td>
2204 <td>set/override config option (use 'section.name=value')</td></tr>
2206 <td>set/override config option (use 'section.name=value')</td></tr>
2205 <tr><td></td>
2207 <tr><td></td>
2206 <td>--debug</td>
2208 <td>--debug</td>
2207 <td>enable debugging output</td></tr>
2209 <td>enable debugging output</td></tr>
2208 <tr><td></td>
2210 <tr><td></td>
2209 <td>--debugger</td>
2211 <td>--debugger</td>
2210 <td>start debugger</td></tr>
2212 <td>start debugger</td></tr>
2211 <tr><td></td>
2213 <tr><td></td>
2212 <td>--encoding ENCODE</td>
2214 <td>--encoding ENCODE</td>
2213 <td>set the charset encoding (default: ascii)</td></tr>
2215 <td>set the charset encoding (default: ascii)</td></tr>
2214 <tr><td></td>
2216 <tr><td></td>
2215 <td>--encodingmode MODE</td>
2217 <td>--encodingmode MODE</td>
2216 <td>set the charset encoding mode (default: strict)</td></tr>
2218 <td>set the charset encoding mode (default: strict)</td></tr>
2217 <tr><td></td>
2219 <tr><td></td>
2218 <td>--traceback</td>
2220 <td>--traceback</td>
2219 <td>always print a traceback on exception</td></tr>
2221 <td>always print a traceback on exception</td></tr>
2220 <tr><td></td>
2222 <tr><td></td>
2221 <td>--time</td>
2223 <td>--time</td>
2222 <td>time how long the command takes</td></tr>
2224 <td>time how long the command takes</td></tr>
2223 <tr><td></td>
2225 <tr><td></td>
2224 <td>--profile</td>
2226 <td>--profile</td>
2225 <td>print command execution profile</td></tr>
2227 <td>print command execution profile</td></tr>
2226 <tr><td></td>
2228 <tr><td></td>
2227 <td>--version</td>
2229 <td>--version</td>
2228 <td>output version information and exit</td></tr>
2230 <td>output version information and exit</td></tr>
2229 <tr><td>-h</td>
2231 <tr><td>-h</td>
2230 <td>--help</td>
2232 <td>--help</td>
2231 <td>display help and exit</td></tr>
2233 <td>display help and exit</td></tr>
2232 <tr><td></td>
2234 <tr><td></td>
2233 <td>--hidden</td>
2235 <td>--hidden</td>
2234 <td>consider hidden changesets</td></tr>
2236 <td>consider hidden changesets</td></tr>
2235 </table>
2237 </table>
2236
2238
2237 </div>
2239 </div>
2238 </div>
2240 </div>
2239 </div>
2241 </div>
2240
2242
2241 <script type="text/javascript">process_dates()</script>
2243 <script type="text/javascript">process_dates()</script>
2242
2244
2243
2245
2244 </body>
2246 </body>
2245 </html>
2247 </html>
2246
2248
2247
2249
2248 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2250 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2249 200 Script output follows
2251 200 Script output follows
2250
2252
2251 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2253 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2252 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2254 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2253 <head>
2255 <head>
2254 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2256 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2255 <meta name="robots" content="index, nofollow" />
2257 <meta name="robots" content="index, nofollow" />
2256 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2258 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2257 <script type="text/javascript" src="/static/mercurial.js"></script>
2259 <script type="text/javascript" src="/static/mercurial.js"></script>
2258
2260
2259 <title>Help: revisions</title>
2261 <title>Help: revisions</title>
2260 </head>
2262 </head>
2261 <body>
2263 <body>
2262
2264
2263 <div class="container">
2265 <div class="container">
2264 <div class="menu">
2266 <div class="menu">
2265 <div class="logo">
2267 <div class="logo">
2266 <a href="http://mercurial.selenic.com/">
2268 <a href="http://mercurial.selenic.com/">
2267 <img src="/static/hglogo.png" alt="mercurial" /></a>
2269 <img src="/static/hglogo.png" alt="mercurial" /></a>
2268 </div>
2270 </div>
2269 <ul>
2271 <ul>
2270 <li><a href="/shortlog">log</a></li>
2272 <li><a href="/shortlog">log</a></li>
2271 <li><a href="/graph">graph</a></li>
2273 <li><a href="/graph">graph</a></li>
2272 <li><a href="/tags">tags</a></li>
2274 <li><a href="/tags">tags</a></li>
2273 <li><a href="/bookmarks">bookmarks</a></li>
2275 <li><a href="/bookmarks">bookmarks</a></li>
2274 <li><a href="/branches">branches</a></li>
2276 <li><a href="/branches">branches</a></li>
2275 </ul>
2277 </ul>
2276 <ul>
2278 <ul>
2277 <li class="active"><a href="/help">help</a></li>
2279 <li class="active"><a href="/help">help</a></li>
2278 </ul>
2280 </ul>
2279 </div>
2281 </div>
2280
2282
2281 <div class="main">
2283 <div class="main">
2282 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2284 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2283 <h3>Help: revisions</h3>
2285 <h3>Help: revisions</h3>
2284
2286
2285 <form class="search" action="/log">
2287 <form class="search" action="/log">
2286
2288
2287 <p><input name="rev" id="search1" type="text" size="30" /></p>
2289 <p><input name="rev" id="search1" type="text" size="30" /></p>
2288 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2290 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2289 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2291 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2290 </form>
2292 </form>
2291 <div id="doc">
2293 <div id="doc">
2292 <h1>Specifying Single Revisions</h1>
2294 <h1>Specifying Single Revisions</h1>
2293 <p>
2295 <p>
2294 Mercurial supports several ways to specify individual revisions.
2296 Mercurial supports several ways to specify individual revisions.
2295 </p>
2297 </p>
2296 <p>
2298 <p>
2297 A plain integer is treated as a revision number. Negative integers are
2299 A plain integer is treated as a revision number. Negative integers are
2298 treated as sequential offsets from the tip, with -1 denoting the tip,
2300 treated as sequential offsets from the tip, with -1 denoting the tip,
2299 -2 denoting the revision prior to the tip, and so forth.
2301 -2 denoting the revision prior to the tip, and so forth.
2300 </p>
2302 </p>
2301 <p>
2303 <p>
2302 A 40-digit hexadecimal string is treated as a unique revision
2304 A 40-digit hexadecimal string is treated as a unique revision
2303 identifier.
2305 identifier.
2304 </p>
2306 </p>
2305 <p>
2307 <p>
2306 A hexadecimal string less than 40 characters long is treated as a
2308 A hexadecimal string less than 40 characters long is treated as a
2307 unique revision identifier and is referred to as a short-form
2309 unique revision identifier and is referred to as a short-form
2308 identifier. A short-form identifier is only valid if it is the prefix
2310 identifier. A short-form identifier is only valid if it is the prefix
2309 of exactly one full-length identifier.
2311 of exactly one full-length identifier.
2310 </p>
2312 </p>
2311 <p>
2313 <p>
2312 Any other string is treated as a bookmark, tag, or branch name. A
2314 Any other string is treated as a bookmark, tag, or branch name. A
2313 bookmark is a movable pointer to a revision. A tag is a permanent name
2315 bookmark is a movable pointer to a revision. A tag is a permanent name
2314 associated with a revision. A branch name denotes the tipmost open branch head
2316 associated with a revision. A branch name denotes the tipmost open branch head
2315 of that branch - or if they are all closed, the tipmost closed head of the
2317 of that branch - or if they are all closed, the tipmost closed head of the
2316 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2318 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2317 </p>
2319 </p>
2318 <p>
2320 <p>
2319 The reserved name &quot;tip&quot; always identifies the most recent revision.
2321 The reserved name &quot;tip&quot; always identifies the most recent revision.
2320 </p>
2322 </p>
2321 <p>
2323 <p>
2322 The reserved name &quot;null&quot; indicates the null revision. This is the
2324 The reserved name &quot;null&quot; indicates the null revision. This is the
2323 revision of an empty repository, and the parent of revision 0.
2325 revision of an empty repository, and the parent of revision 0.
2324 </p>
2326 </p>
2325 <p>
2327 <p>
2326 The reserved name &quot;.&quot; indicates the working directory parent. If no
2328 The reserved name &quot;.&quot; indicates the working directory parent. If no
2327 working directory is checked out, it is equivalent to null. If an
2329 working directory is checked out, it is equivalent to null. If an
2328 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2330 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2329 parent.
2331 parent.
2330 </p>
2332 </p>
2331
2333
2332 </div>
2334 </div>
2333 </div>
2335 </div>
2334 </div>
2336 </div>
2335
2337
2336 <script type="text/javascript">process_dates()</script>
2338 <script type="text/javascript">process_dates()</script>
2337
2339
2338
2340
2339 </body>
2341 </body>
2340 </html>
2342 </html>
2341
2343
2342
2344
2343 $ killdaemons.py
2345 $ killdaemons.py
2344
2346
2345 #endif
2347 #endif
General Comments 0
You need to be logged in to leave comments. Login now