##// END OF EJS Templates
heads: modernize documentation (issue3992)...
Matt Mackall -
r19469:bf6bc468 stable
parent child Browse files
Show More
@@ -1,5908 +1,5906 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
11 import os, re, difflib, time, tempfile, errno
12 import hg, scmutil, util, revlog, copies, error, bookmarks
12 import hg, scmutil, util, revlog, copies, error, bookmarks
13 import patch, help, encoding, templatekw, discovery
13 import patch, help, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, hbisect
14 import archival, changegroup, cmdutil, hbisect
15 import sshserver, hgweb, hgweb.server, commandserver
15 import sshserver, hgweb, hgweb.server, commandserver
16 import merge as mergemod
16 import merge as mergemod
17 import minirst, revset, fileset
17 import minirst, revset, fileset
18 import dagparser, context, simplemerge, graphmod
18 import dagparser, context, simplemerge, graphmod
19 import random, setdiscovery, treediscovery, dagutil, pvec, localrepo
19 import random, setdiscovery, treediscovery, dagutil, pvec, localrepo
20 import phases, obsolete
20 import phases, obsolete
21
21
22 table = {}
22 table = {}
23
23
24 command = cmdutil.command(table)
24 command = cmdutil.command(table)
25
25
26 # common command options
26 # common command options
27
27
28 globalopts = [
28 globalopts = [
29 ('R', 'repository', '',
29 ('R', 'repository', '',
30 _('repository root directory or name of overlay bundle file'),
30 _('repository root directory or name of overlay bundle file'),
31 _('REPO')),
31 _('REPO')),
32 ('', 'cwd', '',
32 ('', 'cwd', '',
33 _('change working directory'), _('DIR')),
33 _('change working directory'), _('DIR')),
34 ('y', 'noninteractive', None,
34 ('y', 'noninteractive', None,
35 _('do not prompt, automatically pick the first choice for all prompts')),
35 _('do not prompt, automatically pick the first choice for all prompts')),
36 ('q', 'quiet', None, _('suppress output')),
36 ('q', 'quiet', None, _('suppress output')),
37 ('v', 'verbose', None, _('enable additional output')),
37 ('v', 'verbose', None, _('enable additional output')),
38 ('', 'config', [],
38 ('', 'config', [],
39 _('set/override config option (use \'section.name=value\')'),
39 _('set/override config option (use \'section.name=value\')'),
40 _('CONFIG')),
40 _('CONFIG')),
41 ('', 'debug', None, _('enable debugging output')),
41 ('', 'debug', None, _('enable debugging output')),
42 ('', 'debugger', None, _('start debugger')),
42 ('', 'debugger', None, _('start debugger')),
43 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
43 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
44 _('ENCODE')),
44 _('ENCODE')),
45 ('', 'encodingmode', encoding.encodingmode,
45 ('', 'encodingmode', encoding.encodingmode,
46 _('set the charset encoding mode'), _('MODE')),
46 _('set the charset encoding mode'), _('MODE')),
47 ('', 'traceback', None, _('always print a traceback on exception')),
47 ('', 'traceback', None, _('always print a traceback on exception')),
48 ('', 'time', None, _('time how long the command takes')),
48 ('', 'time', None, _('time how long the command takes')),
49 ('', 'profile', None, _('print command execution profile')),
49 ('', 'profile', None, _('print command execution profile')),
50 ('', 'version', None, _('output version information and exit')),
50 ('', 'version', None, _('output version information and exit')),
51 ('h', 'help', None, _('display help and exit')),
51 ('h', 'help', None, _('display help and exit')),
52 ('', 'hidden', False, _('consider hidden changesets')),
52 ('', 'hidden', False, _('consider hidden changesets')),
53 ]
53 ]
54
54
55 dryrunopts = [('n', 'dry-run', None,
55 dryrunopts = [('n', 'dry-run', None,
56 _('do not perform actions, just print output'))]
56 _('do not perform actions, just print output'))]
57
57
58 remoteopts = [
58 remoteopts = [
59 ('e', 'ssh', '',
59 ('e', 'ssh', '',
60 _('specify ssh command to use'), _('CMD')),
60 _('specify ssh command to use'), _('CMD')),
61 ('', 'remotecmd', '',
61 ('', 'remotecmd', '',
62 _('specify hg command to run on the remote side'), _('CMD')),
62 _('specify hg command to run on the remote side'), _('CMD')),
63 ('', 'insecure', None,
63 ('', 'insecure', None,
64 _('do not verify server certificate (ignoring web.cacerts config)')),
64 _('do not verify server certificate (ignoring web.cacerts config)')),
65 ]
65 ]
66
66
67 walkopts = [
67 walkopts = [
68 ('I', 'include', [],
68 ('I', 'include', [],
69 _('include names matching the given patterns'), _('PATTERN')),
69 _('include names matching the given patterns'), _('PATTERN')),
70 ('X', 'exclude', [],
70 ('X', 'exclude', [],
71 _('exclude names matching the given patterns'), _('PATTERN')),
71 _('exclude names matching the given patterns'), _('PATTERN')),
72 ]
72 ]
73
73
74 commitopts = [
74 commitopts = [
75 ('m', 'message', '',
75 ('m', 'message', '',
76 _('use text as commit message'), _('TEXT')),
76 _('use text as commit message'), _('TEXT')),
77 ('l', 'logfile', '',
77 ('l', 'logfile', '',
78 _('read commit message from file'), _('FILE')),
78 _('read commit message from file'), _('FILE')),
79 ]
79 ]
80
80
81 commitopts2 = [
81 commitopts2 = [
82 ('d', 'date', '',
82 ('d', 'date', '',
83 _('record the specified date as commit date'), _('DATE')),
83 _('record the specified date as commit date'), _('DATE')),
84 ('u', 'user', '',
84 ('u', 'user', '',
85 _('record the specified user as committer'), _('USER')),
85 _('record the specified user as committer'), _('USER')),
86 ]
86 ]
87
87
88 templateopts = [
88 templateopts = [
89 ('', 'style', '',
89 ('', 'style', '',
90 _('display using template map file'), _('STYLE')),
90 _('display using template map file'), _('STYLE')),
91 ('', 'template', '',
91 ('', 'template', '',
92 _('display with template'), _('TEMPLATE')),
92 _('display with template'), _('TEMPLATE')),
93 ]
93 ]
94
94
95 logopts = [
95 logopts = [
96 ('p', 'patch', None, _('show patch')),
96 ('p', 'patch', None, _('show patch')),
97 ('g', 'git', None, _('use git extended diff format')),
97 ('g', 'git', None, _('use git extended diff format')),
98 ('l', 'limit', '',
98 ('l', 'limit', '',
99 _('limit number of changes displayed'), _('NUM')),
99 _('limit number of changes displayed'), _('NUM')),
100 ('M', 'no-merges', None, _('do not show merges')),
100 ('M', 'no-merges', None, _('do not show merges')),
101 ('', 'stat', None, _('output diffstat-style summary of changes')),
101 ('', 'stat', None, _('output diffstat-style summary of changes')),
102 ('G', 'graph', None, _("show the revision DAG")),
102 ('G', 'graph', None, _("show the revision DAG")),
103 ] + templateopts
103 ] + templateopts
104
104
105 diffopts = [
105 diffopts = [
106 ('a', 'text', None, _('treat all files as text')),
106 ('a', 'text', None, _('treat all files as text')),
107 ('g', 'git', None, _('use git extended diff format')),
107 ('g', 'git', None, _('use git extended diff format')),
108 ('', 'nodates', None, _('omit dates from diff headers'))
108 ('', 'nodates', None, _('omit dates from diff headers'))
109 ]
109 ]
110
110
111 diffwsopts = [
111 diffwsopts = [
112 ('w', 'ignore-all-space', None,
112 ('w', 'ignore-all-space', None,
113 _('ignore white space when comparing lines')),
113 _('ignore white space when comparing lines')),
114 ('b', 'ignore-space-change', None,
114 ('b', 'ignore-space-change', None,
115 _('ignore changes in the amount of white space')),
115 _('ignore changes in the amount of white space')),
116 ('B', 'ignore-blank-lines', None,
116 ('B', 'ignore-blank-lines', None,
117 _('ignore changes whose lines are all blank')),
117 _('ignore changes whose lines are all blank')),
118 ]
118 ]
119
119
120 diffopts2 = [
120 diffopts2 = [
121 ('p', 'show-function', None, _('show which function each change is in')),
121 ('p', 'show-function', None, _('show which function each change is in')),
122 ('', 'reverse', None, _('produce a diff that undoes the changes')),
122 ('', 'reverse', None, _('produce a diff that undoes the changes')),
123 ] + diffwsopts + [
123 ] + diffwsopts + [
124 ('U', 'unified', '',
124 ('U', 'unified', '',
125 _('number of lines of context to show'), _('NUM')),
125 _('number of lines of context to show'), _('NUM')),
126 ('', 'stat', None, _('output diffstat-style summary of changes')),
126 ('', 'stat', None, _('output diffstat-style summary of changes')),
127 ]
127 ]
128
128
129 mergetoolopts = [
129 mergetoolopts = [
130 ('t', 'tool', '', _('specify merge tool')),
130 ('t', 'tool', '', _('specify merge tool')),
131 ]
131 ]
132
132
133 similarityopts = [
133 similarityopts = [
134 ('s', 'similarity', '',
134 ('s', 'similarity', '',
135 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
135 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
136 ]
136 ]
137
137
138 subrepoopts = [
138 subrepoopts = [
139 ('S', 'subrepos', None,
139 ('S', 'subrepos', None,
140 _('recurse into subrepositories'))
140 _('recurse into subrepositories'))
141 ]
141 ]
142
142
143 # Commands start here, listed alphabetically
143 # Commands start here, listed alphabetically
144
144
145 @command('^add',
145 @command('^add',
146 walkopts + subrepoopts + dryrunopts,
146 walkopts + subrepoopts + dryrunopts,
147 _('[OPTION]... [FILE]...'))
147 _('[OPTION]... [FILE]...'))
148 def add(ui, repo, *pats, **opts):
148 def add(ui, repo, *pats, **opts):
149 """add the specified files on the next commit
149 """add the specified files on the next commit
150
150
151 Schedule files to be version controlled and added to the
151 Schedule files to be version controlled and added to the
152 repository.
152 repository.
153
153
154 The files will be added to the repository at the next commit. To
154 The files will be added to the repository at the next commit. To
155 undo an add before that, see :hg:`forget`.
155 undo an add before that, see :hg:`forget`.
156
156
157 If no names are given, add all files to the repository.
157 If no names are given, add all files to the repository.
158
158
159 .. container:: verbose
159 .. container:: verbose
160
160
161 An example showing how new (unknown) files are added
161 An example showing how new (unknown) files are added
162 automatically by :hg:`add`::
162 automatically by :hg:`add`::
163
163
164 $ ls
164 $ ls
165 foo.c
165 foo.c
166 $ hg status
166 $ hg status
167 ? foo.c
167 ? foo.c
168 $ hg add
168 $ hg add
169 adding foo.c
169 adding foo.c
170 $ hg status
170 $ hg status
171 A foo.c
171 A foo.c
172
172
173 Returns 0 if all files are successfully added.
173 Returns 0 if all files are successfully added.
174 """
174 """
175
175
176 m = scmutil.match(repo[None], pats, opts)
176 m = scmutil.match(repo[None], pats, opts)
177 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
177 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
178 opts.get('subrepos'), prefix="", explicitonly=False)
178 opts.get('subrepos'), prefix="", explicitonly=False)
179 return rejected and 1 or 0
179 return rejected and 1 or 0
180
180
181 @command('addremove',
181 @command('addremove',
182 similarityopts + walkopts + dryrunopts,
182 similarityopts + walkopts + dryrunopts,
183 _('[OPTION]... [FILE]...'))
183 _('[OPTION]... [FILE]...'))
184 def addremove(ui, repo, *pats, **opts):
184 def addremove(ui, repo, *pats, **opts):
185 """add all new files, delete all missing files
185 """add all new files, delete all missing files
186
186
187 Add all new files and remove all missing files from the
187 Add all new files and remove all missing files from the
188 repository.
188 repository.
189
189
190 New files are ignored if they match any of the patterns in
190 New files are ignored if they match any of the patterns in
191 ``.hgignore``. As with add, these changes take effect at the next
191 ``.hgignore``. As with add, these changes take effect at the next
192 commit.
192 commit.
193
193
194 Use the -s/--similarity option to detect renamed files. This
194 Use the -s/--similarity option to detect renamed files. This
195 option takes a percentage between 0 (disabled) and 100 (files must
195 option takes a percentage between 0 (disabled) and 100 (files must
196 be identical) as its parameter. With a parameter greater than 0,
196 be identical) as its parameter. With a parameter greater than 0,
197 this compares every removed file with every added file and records
197 this compares every removed file with every added file and records
198 those similar enough as renames. Detecting renamed files this way
198 those similar enough as renames. Detecting renamed files this way
199 can be expensive. After using this option, :hg:`status -C` can be
199 can be expensive. After using this option, :hg:`status -C` can be
200 used to check which files were identified as moved or renamed. If
200 used to check which files were identified as moved or renamed. If
201 not specified, -s/--similarity defaults to 100 and only renames of
201 not specified, -s/--similarity defaults to 100 and only renames of
202 identical files are detected.
202 identical files are detected.
203
203
204 Returns 0 if all files are successfully added.
204 Returns 0 if all files are successfully added.
205 """
205 """
206 try:
206 try:
207 sim = float(opts.get('similarity') or 100)
207 sim = float(opts.get('similarity') or 100)
208 except ValueError:
208 except ValueError:
209 raise util.Abort(_('similarity must be a number'))
209 raise util.Abort(_('similarity must be a number'))
210 if sim < 0 or sim > 100:
210 if sim < 0 or sim > 100:
211 raise util.Abort(_('similarity must be between 0 and 100'))
211 raise util.Abort(_('similarity must be between 0 and 100'))
212 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
212 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
213
213
214 @command('^annotate|blame',
214 @command('^annotate|blame',
215 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
215 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
216 ('', 'follow', None,
216 ('', 'follow', None,
217 _('follow copies/renames and list the filename (DEPRECATED)')),
217 _('follow copies/renames and list the filename (DEPRECATED)')),
218 ('', 'no-follow', None, _("don't follow copies and renames")),
218 ('', 'no-follow', None, _("don't follow copies and renames")),
219 ('a', 'text', None, _('treat all files as text')),
219 ('a', 'text', None, _('treat all files as text')),
220 ('u', 'user', None, _('list the author (long with -v)')),
220 ('u', 'user', None, _('list the author (long with -v)')),
221 ('f', 'file', None, _('list the filename')),
221 ('f', 'file', None, _('list the filename')),
222 ('d', 'date', None, _('list the date (short with -q)')),
222 ('d', 'date', None, _('list the date (short with -q)')),
223 ('n', 'number', None, _('list the revision number (default)')),
223 ('n', 'number', None, _('list the revision number (default)')),
224 ('c', 'changeset', None, _('list the changeset')),
224 ('c', 'changeset', None, _('list the changeset')),
225 ('l', 'line-number', None, _('show line number at the first appearance'))
225 ('l', 'line-number', None, _('show line number at the first appearance'))
226 ] + diffwsopts + walkopts,
226 ] + diffwsopts + walkopts,
227 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'))
227 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'))
228 def annotate(ui, repo, *pats, **opts):
228 def annotate(ui, repo, *pats, **opts):
229 """show changeset information by line for each file
229 """show changeset information by line for each file
230
230
231 List changes in files, showing the revision id responsible for
231 List changes in files, showing the revision id responsible for
232 each line
232 each line
233
233
234 This command is useful for discovering when a change was made and
234 This command is useful for discovering when a change was made and
235 by whom.
235 by whom.
236
236
237 Without the -a/--text option, annotate will avoid processing files
237 Without the -a/--text option, annotate will avoid processing files
238 it detects as binary. With -a, annotate will annotate the file
238 it detects as binary. With -a, annotate will annotate the file
239 anyway, although the results will probably be neither useful
239 anyway, although the results will probably be neither useful
240 nor desirable.
240 nor desirable.
241
241
242 Returns 0 on success.
242 Returns 0 on success.
243 """
243 """
244 if opts.get('follow'):
244 if opts.get('follow'):
245 # --follow is deprecated and now just an alias for -f/--file
245 # --follow is deprecated and now just an alias for -f/--file
246 # to mimic the behavior of Mercurial before version 1.5
246 # to mimic the behavior of Mercurial before version 1.5
247 opts['file'] = True
247 opts['file'] = True
248
248
249 datefunc = ui.quiet and util.shortdate or util.datestr
249 datefunc = ui.quiet and util.shortdate or util.datestr
250 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
250 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
251
251
252 if not pats:
252 if not pats:
253 raise util.Abort(_('at least one filename or pattern is required'))
253 raise util.Abort(_('at least one filename or pattern is required'))
254
254
255 hexfn = ui.debugflag and hex or short
255 hexfn = ui.debugflag and hex or short
256
256
257 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
257 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
258 ('number', ' ', lambda x: str(x[0].rev())),
258 ('number', ' ', lambda x: str(x[0].rev())),
259 ('changeset', ' ', lambda x: hexfn(x[0].node())),
259 ('changeset', ' ', lambda x: hexfn(x[0].node())),
260 ('date', ' ', getdate),
260 ('date', ' ', getdate),
261 ('file', ' ', lambda x: x[0].path()),
261 ('file', ' ', lambda x: x[0].path()),
262 ('line_number', ':', lambda x: str(x[1])),
262 ('line_number', ':', lambda x: str(x[1])),
263 ]
263 ]
264
264
265 if (not opts.get('user') and not opts.get('changeset')
265 if (not opts.get('user') and not opts.get('changeset')
266 and not opts.get('date') and not opts.get('file')):
266 and not opts.get('date') and not opts.get('file')):
267 opts['number'] = True
267 opts['number'] = True
268
268
269 linenumber = opts.get('line_number') is not None
269 linenumber = opts.get('line_number') is not None
270 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
270 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
271 raise util.Abort(_('at least one of -n/-c is required for -l'))
271 raise util.Abort(_('at least one of -n/-c is required for -l'))
272
272
273 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
273 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
274 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
274 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
275
275
276 def bad(x, y):
276 def bad(x, y):
277 raise util.Abort("%s: %s" % (x, y))
277 raise util.Abort("%s: %s" % (x, y))
278
278
279 ctx = scmutil.revsingle(repo, opts.get('rev'))
279 ctx = scmutil.revsingle(repo, opts.get('rev'))
280 m = scmutil.match(ctx, pats, opts)
280 m = scmutil.match(ctx, pats, opts)
281 m.bad = bad
281 m.bad = bad
282 follow = not opts.get('no_follow')
282 follow = not opts.get('no_follow')
283 diffopts = patch.diffopts(ui, opts, section='annotate')
283 diffopts = patch.diffopts(ui, opts, section='annotate')
284 for abs in ctx.walk(m):
284 for abs in ctx.walk(m):
285 fctx = ctx[abs]
285 fctx = ctx[abs]
286 if not opts.get('text') and util.binary(fctx.data()):
286 if not opts.get('text') and util.binary(fctx.data()):
287 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
287 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
288 continue
288 continue
289
289
290 lines = fctx.annotate(follow=follow, linenumber=linenumber,
290 lines = fctx.annotate(follow=follow, linenumber=linenumber,
291 diffopts=diffopts)
291 diffopts=diffopts)
292 pieces = []
292 pieces = []
293
293
294 for f, sep in funcmap:
294 for f, sep in funcmap:
295 l = [f(n) for n, dummy in lines]
295 l = [f(n) for n, dummy in lines]
296 if l:
296 if l:
297 sized = [(x, encoding.colwidth(x)) for x in l]
297 sized = [(x, encoding.colwidth(x)) for x in l]
298 ml = max([w for x, w in sized])
298 ml = max([w for x, w in sized])
299 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
299 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
300 for x, w in sized])
300 for x, w in sized])
301
301
302 if pieces:
302 if pieces:
303 for p, l in zip(zip(*pieces), lines):
303 for p, l in zip(zip(*pieces), lines):
304 ui.write("%s: %s" % ("".join(p), l[1]))
304 ui.write("%s: %s" % ("".join(p), l[1]))
305
305
306 if lines and not lines[-1][1].endswith('\n'):
306 if lines and not lines[-1][1].endswith('\n'):
307 ui.write('\n')
307 ui.write('\n')
308
308
309 @command('archive',
309 @command('archive',
310 [('', 'no-decode', None, _('do not pass files through decoders')),
310 [('', 'no-decode', None, _('do not pass files through decoders')),
311 ('p', 'prefix', '', _('directory prefix for files in archive'),
311 ('p', 'prefix', '', _('directory prefix for files in archive'),
312 _('PREFIX')),
312 _('PREFIX')),
313 ('r', 'rev', '', _('revision to distribute'), _('REV')),
313 ('r', 'rev', '', _('revision to distribute'), _('REV')),
314 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
314 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
315 ] + subrepoopts + walkopts,
315 ] + subrepoopts + walkopts,
316 _('[OPTION]... DEST'))
316 _('[OPTION]... DEST'))
317 def archive(ui, repo, dest, **opts):
317 def archive(ui, repo, dest, **opts):
318 '''create an unversioned archive of a repository revision
318 '''create an unversioned archive of a repository revision
319
319
320 By default, the revision used is the parent of the working
320 By default, the revision used is the parent of the working
321 directory; use -r/--rev to specify a different revision.
321 directory; use -r/--rev to specify a different revision.
322
322
323 The archive type is automatically detected based on file
323 The archive type is automatically detected based on file
324 extension (or override using -t/--type).
324 extension (or override using -t/--type).
325
325
326 .. container:: verbose
326 .. container:: verbose
327
327
328 Examples:
328 Examples:
329
329
330 - create a zip file containing the 1.0 release::
330 - create a zip file containing the 1.0 release::
331
331
332 hg archive -r 1.0 project-1.0.zip
332 hg archive -r 1.0 project-1.0.zip
333
333
334 - create a tarball excluding .hg files::
334 - create a tarball excluding .hg files::
335
335
336 hg archive project.tar.gz -X ".hg*"
336 hg archive project.tar.gz -X ".hg*"
337
337
338 Valid types are:
338 Valid types are:
339
339
340 :``files``: a directory full of files (default)
340 :``files``: a directory full of files (default)
341 :``tar``: tar archive, uncompressed
341 :``tar``: tar archive, uncompressed
342 :``tbz2``: tar archive, compressed using bzip2
342 :``tbz2``: tar archive, compressed using bzip2
343 :``tgz``: tar archive, compressed using gzip
343 :``tgz``: tar archive, compressed using gzip
344 :``uzip``: zip archive, uncompressed
344 :``uzip``: zip archive, uncompressed
345 :``zip``: zip archive, compressed using deflate
345 :``zip``: zip archive, compressed using deflate
346
346
347 The exact name of the destination archive or directory is given
347 The exact name of the destination archive or directory is given
348 using a format string; see :hg:`help export` for details.
348 using a format string; see :hg:`help export` for details.
349
349
350 Each member added to an archive file has a directory prefix
350 Each member added to an archive file has a directory prefix
351 prepended. Use -p/--prefix to specify a format string for the
351 prepended. Use -p/--prefix to specify a format string for the
352 prefix. The default is the basename of the archive, with suffixes
352 prefix. The default is the basename of the archive, with suffixes
353 removed.
353 removed.
354
354
355 Returns 0 on success.
355 Returns 0 on success.
356 '''
356 '''
357
357
358 ctx = scmutil.revsingle(repo, opts.get('rev'))
358 ctx = scmutil.revsingle(repo, opts.get('rev'))
359 if not ctx:
359 if not ctx:
360 raise util.Abort(_('no working directory: please specify a revision'))
360 raise util.Abort(_('no working directory: please specify a revision'))
361 node = ctx.node()
361 node = ctx.node()
362 dest = cmdutil.makefilename(repo, dest, node)
362 dest = cmdutil.makefilename(repo, dest, node)
363 if os.path.realpath(dest) == repo.root:
363 if os.path.realpath(dest) == repo.root:
364 raise util.Abort(_('repository root cannot be destination'))
364 raise util.Abort(_('repository root cannot be destination'))
365
365
366 kind = opts.get('type') or archival.guesskind(dest) or 'files'
366 kind = opts.get('type') or archival.guesskind(dest) or 'files'
367 prefix = opts.get('prefix')
367 prefix = opts.get('prefix')
368
368
369 if dest == '-':
369 if dest == '-':
370 if kind == 'files':
370 if kind == 'files':
371 raise util.Abort(_('cannot archive plain files to stdout'))
371 raise util.Abort(_('cannot archive plain files to stdout'))
372 dest = cmdutil.makefileobj(repo, dest)
372 dest = cmdutil.makefileobj(repo, dest)
373 if not prefix:
373 if not prefix:
374 prefix = os.path.basename(repo.root) + '-%h'
374 prefix = os.path.basename(repo.root) + '-%h'
375
375
376 prefix = cmdutil.makefilename(repo, prefix, node)
376 prefix = cmdutil.makefilename(repo, prefix, node)
377 matchfn = scmutil.match(ctx, [], opts)
377 matchfn = scmutil.match(ctx, [], opts)
378 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
378 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
379 matchfn, prefix, subrepos=opts.get('subrepos'))
379 matchfn, prefix, subrepos=opts.get('subrepos'))
380
380
381 @command('backout',
381 @command('backout',
382 [('', 'merge', None, _('merge with old dirstate parent after backout')),
382 [('', 'merge', None, _('merge with old dirstate parent after backout')),
383 ('', 'parent', '',
383 ('', 'parent', '',
384 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
384 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
385 ('r', 'rev', '', _('revision to backout'), _('REV')),
385 ('r', 'rev', '', _('revision to backout'), _('REV')),
386 ] + mergetoolopts + walkopts + commitopts + commitopts2,
386 ] + mergetoolopts + walkopts + commitopts + commitopts2,
387 _('[OPTION]... [-r] REV'))
387 _('[OPTION]... [-r] REV'))
388 def backout(ui, repo, node=None, rev=None, **opts):
388 def backout(ui, repo, node=None, rev=None, **opts):
389 '''reverse effect of earlier changeset
389 '''reverse effect of earlier changeset
390
390
391 Prepare a new changeset with the effect of REV undone in the
391 Prepare a new changeset with the effect of REV undone in the
392 current working directory.
392 current working directory.
393
393
394 If REV is the parent of the working directory, then this new changeset
394 If REV is the parent of the working directory, then this new changeset
395 is committed automatically. Otherwise, hg needs to merge the
395 is committed automatically. Otherwise, hg needs to merge the
396 changes and the merged result is left uncommitted.
396 changes and the merged result is left uncommitted.
397
397
398 .. note::
398 .. note::
399 backout cannot be used to fix either an unwanted or
399 backout cannot be used to fix either an unwanted or
400 incorrect merge.
400 incorrect merge.
401
401
402 .. container:: verbose
402 .. container:: verbose
403
403
404 By default, the pending changeset will have one parent,
404 By default, the pending changeset will have one parent,
405 maintaining a linear history. With --merge, the pending
405 maintaining a linear history. With --merge, the pending
406 changeset will instead have two parents: the old parent of the
406 changeset will instead have two parents: the old parent of the
407 working directory and a new child of REV that simply undoes REV.
407 working directory and a new child of REV that simply undoes REV.
408
408
409 Before version 1.7, the behavior without --merge was equivalent
409 Before version 1.7, the behavior without --merge was equivalent
410 to specifying --merge followed by :hg:`update --clean .` to
410 to specifying --merge followed by :hg:`update --clean .` to
411 cancel the merge and leave the child of REV as a head to be
411 cancel the merge and leave the child of REV as a head to be
412 merged separately.
412 merged separately.
413
413
414 See :hg:`help dates` for a list of formats valid for -d/--date.
414 See :hg:`help dates` for a list of formats valid for -d/--date.
415
415
416 Returns 0 on success.
416 Returns 0 on success.
417 '''
417 '''
418 if rev and node:
418 if rev and node:
419 raise util.Abort(_("please specify just one revision"))
419 raise util.Abort(_("please specify just one revision"))
420
420
421 if not rev:
421 if not rev:
422 rev = node
422 rev = node
423
423
424 if not rev:
424 if not rev:
425 raise util.Abort(_("please specify a revision to backout"))
425 raise util.Abort(_("please specify a revision to backout"))
426
426
427 date = opts.get('date')
427 date = opts.get('date')
428 if date:
428 if date:
429 opts['date'] = util.parsedate(date)
429 opts['date'] = util.parsedate(date)
430
430
431 cmdutil.bailifchanged(repo)
431 cmdutil.bailifchanged(repo)
432 node = scmutil.revsingle(repo, rev).node()
432 node = scmutil.revsingle(repo, rev).node()
433
433
434 op1, op2 = repo.dirstate.parents()
434 op1, op2 = repo.dirstate.parents()
435 a = repo.changelog.ancestor(op1, node)
435 a = repo.changelog.ancestor(op1, node)
436 if a != node:
436 if a != node:
437 raise util.Abort(_('cannot backout change on a different branch'))
437 raise util.Abort(_('cannot backout change on a different branch'))
438
438
439 p1, p2 = repo.changelog.parents(node)
439 p1, p2 = repo.changelog.parents(node)
440 if p1 == nullid:
440 if p1 == nullid:
441 raise util.Abort(_('cannot backout a change with no parents'))
441 raise util.Abort(_('cannot backout a change with no parents'))
442 if p2 != nullid:
442 if p2 != nullid:
443 if not opts.get('parent'):
443 if not opts.get('parent'):
444 raise util.Abort(_('cannot backout a merge changeset'))
444 raise util.Abort(_('cannot backout a merge changeset'))
445 p = repo.lookup(opts['parent'])
445 p = repo.lookup(opts['parent'])
446 if p not in (p1, p2):
446 if p not in (p1, p2):
447 raise util.Abort(_('%s is not a parent of %s') %
447 raise util.Abort(_('%s is not a parent of %s') %
448 (short(p), short(node)))
448 (short(p), short(node)))
449 parent = p
449 parent = p
450 else:
450 else:
451 if opts.get('parent'):
451 if opts.get('parent'):
452 raise util.Abort(_('cannot use --parent on non-merge changeset'))
452 raise util.Abort(_('cannot use --parent on non-merge changeset'))
453 parent = p1
453 parent = p1
454
454
455 # the backout should appear on the same branch
455 # the backout should appear on the same branch
456 wlock = repo.wlock()
456 wlock = repo.wlock()
457 try:
457 try:
458 branch = repo.dirstate.branch()
458 branch = repo.dirstate.branch()
459 bheads = repo.branchheads(branch)
459 bheads = repo.branchheads(branch)
460 hg.clean(repo, node, show_stats=False)
460 hg.clean(repo, node, show_stats=False)
461 repo.dirstate.setbranch(branch)
461 repo.dirstate.setbranch(branch)
462 rctx = scmutil.revsingle(repo, hex(parent))
462 rctx = scmutil.revsingle(repo, hex(parent))
463 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
463 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
464 if not opts.get('merge') and op1 != node:
464 if not opts.get('merge') and op1 != node:
465 try:
465 try:
466 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
466 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
467 return hg.update(repo, op1)
467 return hg.update(repo, op1)
468 finally:
468 finally:
469 ui.setconfig('ui', 'forcemerge', '')
469 ui.setconfig('ui', 'forcemerge', '')
470
470
471 e = cmdutil.commiteditor
471 e = cmdutil.commiteditor
472 if not opts['message'] and not opts['logfile']:
472 if not opts['message'] and not opts['logfile']:
473 # we don't translate commit messages
473 # we don't translate commit messages
474 opts['message'] = "Backed out changeset %s" % short(node)
474 opts['message'] = "Backed out changeset %s" % short(node)
475 e = cmdutil.commitforceeditor
475 e = cmdutil.commitforceeditor
476
476
477 def commitfunc(ui, repo, message, match, opts):
477 def commitfunc(ui, repo, message, match, opts):
478 return repo.commit(message, opts.get('user'), opts.get('date'),
478 return repo.commit(message, opts.get('user'), opts.get('date'),
479 match, editor=e)
479 match, editor=e)
480 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
480 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
481 cmdutil.commitstatus(repo, newnode, branch, bheads)
481 cmdutil.commitstatus(repo, newnode, branch, bheads)
482
482
483 def nice(node):
483 def nice(node):
484 return '%d:%s' % (repo.changelog.rev(node), short(node))
484 return '%d:%s' % (repo.changelog.rev(node), short(node))
485 ui.status(_('changeset %s backs out changeset %s\n') %
485 ui.status(_('changeset %s backs out changeset %s\n') %
486 (nice(repo.changelog.tip()), nice(node)))
486 (nice(repo.changelog.tip()), nice(node)))
487 if opts.get('merge') and op1 != node:
487 if opts.get('merge') and op1 != node:
488 hg.clean(repo, op1, show_stats=False)
488 hg.clean(repo, op1, show_stats=False)
489 ui.status(_('merging with changeset %s\n')
489 ui.status(_('merging with changeset %s\n')
490 % nice(repo.changelog.tip()))
490 % nice(repo.changelog.tip()))
491 try:
491 try:
492 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
492 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
493 return hg.merge(repo, hex(repo.changelog.tip()))
493 return hg.merge(repo, hex(repo.changelog.tip()))
494 finally:
494 finally:
495 ui.setconfig('ui', 'forcemerge', '')
495 ui.setconfig('ui', 'forcemerge', '')
496 finally:
496 finally:
497 wlock.release()
497 wlock.release()
498 return 0
498 return 0
499
499
500 @command('bisect',
500 @command('bisect',
501 [('r', 'reset', False, _('reset bisect state')),
501 [('r', 'reset', False, _('reset bisect state')),
502 ('g', 'good', False, _('mark changeset good')),
502 ('g', 'good', False, _('mark changeset good')),
503 ('b', 'bad', False, _('mark changeset bad')),
503 ('b', 'bad', False, _('mark changeset bad')),
504 ('s', 'skip', False, _('skip testing changeset')),
504 ('s', 'skip', False, _('skip testing changeset')),
505 ('e', 'extend', False, _('extend the bisect range')),
505 ('e', 'extend', False, _('extend the bisect range')),
506 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
506 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
507 ('U', 'noupdate', False, _('do not update to target'))],
507 ('U', 'noupdate', False, _('do not update to target'))],
508 _("[-gbsr] [-U] [-c CMD] [REV]"))
508 _("[-gbsr] [-U] [-c CMD] [REV]"))
509 def bisect(ui, repo, rev=None, extra=None, command=None,
509 def bisect(ui, repo, rev=None, extra=None, command=None,
510 reset=None, good=None, bad=None, skip=None, extend=None,
510 reset=None, good=None, bad=None, skip=None, extend=None,
511 noupdate=None):
511 noupdate=None):
512 """subdivision search of changesets
512 """subdivision search of changesets
513
513
514 This command helps to find changesets which introduce problems. To
514 This command helps to find changesets which introduce problems. To
515 use, mark the earliest changeset you know exhibits the problem as
515 use, mark the earliest changeset you know exhibits the problem as
516 bad, then mark the latest changeset which is free from the problem
516 bad, then mark the latest changeset which is free from the problem
517 as good. Bisect will update your working directory to a revision
517 as good. Bisect will update your working directory to a revision
518 for testing (unless the -U/--noupdate option is specified). Once
518 for testing (unless the -U/--noupdate option is specified). Once
519 you have performed tests, mark the working directory as good or
519 you have performed tests, mark the working directory as good or
520 bad, and bisect will either update to another candidate changeset
520 bad, and bisect will either update to another candidate changeset
521 or announce that it has found the bad revision.
521 or announce that it has found the bad revision.
522
522
523 As a shortcut, you can also use the revision argument to mark a
523 As a shortcut, you can also use the revision argument to mark a
524 revision as good or bad without checking it out first.
524 revision as good or bad without checking it out first.
525
525
526 If you supply a command, it will be used for automatic bisection.
526 If you supply a command, it will be used for automatic bisection.
527 The environment variable HG_NODE will contain the ID of the
527 The environment variable HG_NODE will contain the ID of the
528 changeset being tested. The exit status of the command will be
528 changeset being tested. The exit status of the command will be
529 used to mark revisions as good or bad: status 0 means good, 125
529 used to mark revisions as good or bad: status 0 means good, 125
530 means to skip the revision, 127 (command not found) will abort the
530 means to skip the revision, 127 (command not found) will abort the
531 bisection, and any other non-zero exit status means the revision
531 bisection, and any other non-zero exit status means the revision
532 is bad.
532 is bad.
533
533
534 .. container:: verbose
534 .. container:: verbose
535
535
536 Some examples:
536 Some examples:
537
537
538 - start a bisection with known bad revision 12, and good revision 34::
538 - start a bisection with known bad revision 12, and good revision 34::
539
539
540 hg bisect --bad 34
540 hg bisect --bad 34
541 hg bisect --good 12
541 hg bisect --good 12
542
542
543 - advance the current bisection by marking current revision as good or
543 - advance the current bisection by marking current revision as good or
544 bad::
544 bad::
545
545
546 hg bisect --good
546 hg bisect --good
547 hg bisect --bad
547 hg bisect --bad
548
548
549 - mark the current revision, or a known revision, to be skipped (e.g. if
549 - mark the current revision, or a known revision, to be skipped (e.g. if
550 that revision is not usable because of another issue)::
550 that revision is not usable because of another issue)::
551
551
552 hg bisect --skip
552 hg bisect --skip
553 hg bisect --skip 23
553 hg bisect --skip 23
554
554
555 - skip all revisions that do not touch directories ``foo`` or ``bar``
555 - skip all revisions that do not touch directories ``foo`` or ``bar``
556
556
557 hg bisect --skip '!( file("path:foo") & file("path:bar") )'
557 hg bisect --skip '!( file("path:foo") & file("path:bar") )'
558
558
559 - forget the current bisection::
559 - forget the current bisection::
560
560
561 hg bisect --reset
561 hg bisect --reset
562
562
563 - use 'make && make tests' to automatically find the first broken
563 - use 'make && make tests' to automatically find the first broken
564 revision::
564 revision::
565
565
566 hg bisect --reset
566 hg bisect --reset
567 hg bisect --bad 34
567 hg bisect --bad 34
568 hg bisect --good 12
568 hg bisect --good 12
569 hg bisect --command 'make && make tests'
569 hg bisect --command 'make && make tests'
570
570
571 - see all changesets whose states are already known in the current
571 - see all changesets whose states are already known in the current
572 bisection::
572 bisection::
573
573
574 hg log -r "bisect(pruned)"
574 hg log -r "bisect(pruned)"
575
575
576 - see the changeset currently being bisected (especially useful
576 - see the changeset currently being bisected (especially useful
577 if running with -U/--noupdate)::
577 if running with -U/--noupdate)::
578
578
579 hg log -r "bisect(current)"
579 hg log -r "bisect(current)"
580
580
581 - see all changesets that took part in the current bisection::
581 - see all changesets that took part in the current bisection::
582
582
583 hg log -r "bisect(range)"
583 hg log -r "bisect(range)"
584
584
585 - with the graphlog extension, you can even get a nice graph::
585 - with the graphlog extension, you can even get a nice graph::
586
586
587 hg log --graph -r "bisect(range)"
587 hg log --graph -r "bisect(range)"
588
588
589 See :hg:`help revsets` for more about the `bisect()` keyword.
589 See :hg:`help revsets` for more about the `bisect()` keyword.
590
590
591 Returns 0 on success.
591 Returns 0 on success.
592 """
592 """
593 def extendbisectrange(nodes, good):
593 def extendbisectrange(nodes, good):
594 # bisect is incomplete when it ends on a merge node and
594 # bisect is incomplete when it ends on a merge node and
595 # one of the parent was not checked.
595 # one of the parent was not checked.
596 parents = repo[nodes[0]].parents()
596 parents = repo[nodes[0]].parents()
597 if len(parents) > 1:
597 if len(parents) > 1:
598 side = good and state['bad'] or state['good']
598 side = good and state['bad'] or state['good']
599 num = len(set(i.node() for i in parents) & set(side))
599 num = len(set(i.node() for i in parents) & set(side))
600 if num == 1:
600 if num == 1:
601 return parents[0].ancestor(parents[1])
601 return parents[0].ancestor(parents[1])
602 return None
602 return None
603
603
604 def print_result(nodes, good):
604 def print_result(nodes, good):
605 displayer = cmdutil.show_changeset(ui, repo, {})
605 displayer = cmdutil.show_changeset(ui, repo, {})
606 if len(nodes) == 1:
606 if len(nodes) == 1:
607 # narrowed it down to a single revision
607 # narrowed it down to a single revision
608 if good:
608 if good:
609 ui.write(_("The first good revision is:\n"))
609 ui.write(_("The first good revision is:\n"))
610 else:
610 else:
611 ui.write(_("The first bad revision is:\n"))
611 ui.write(_("The first bad revision is:\n"))
612 displayer.show(repo[nodes[0]])
612 displayer.show(repo[nodes[0]])
613 extendnode = extendbisectrange(nodes, good)
613 extendnode = extendbisectrange(nodes, good)
614 if extendnode is not None:
614 if extendnode is not None:
615 ui.write(_('Not all ancestors of this changeset have been'
615 ui.write(_('Not all ancestors of this changeset have been'
616 ' checked.\nUse bisect --extend to continue the '
616 ' checked.\nUse bisect --extend to continue the '
617 'bisection from\nthe common ancestor, %s.\n')
617 'bisection from\nthe common ancestor, %s.\n')
618 % extendnode)
618 % extendnode)
619 else:
619 else:
620 # multiple possible revisions
620 # multiple possible revisions
621 if good:
621 if good:
622 ui.write(_("Due to skipped revisions, the first "
622 ui.write(_("Due to skipped revisions, the first "
623 "good revision could be any of:\n"))
623 "good revision could be any of:\n"))
624 else:
624 else:
625 ui.write(_("Due to skipped revisions, the first "
625 ui.write(_("Due to skipped revisions, the first "
626 "bad revision could be any of:\n"))
626 "bad revision could be any of:\n"))
627 for n in nodes:
627 for n in nodes:
628 displayer.show(repo[n])
628 displayer.show(repo[n])
629 displayer.close()
629 displayer.close()
630
630
631 def check_state(state, interactive=True):
631 def check_state(state, interactive=True):
632 if not state['good'] or not state['bad']:
632 if not state['good'] or not state['bad']:
633 if (good or bad or skip or reset) and interactive:
633 if (good or bad or skip or reset) and interactive:
634 return
634 return
635 if not state['good']:
635 if not state['good']:
636 raise util.Abort(_('cannot bisect (no known good revisions)'))
636 raise util.Abort(_('cannot bisect (no known good revisions)'))
637 else:
637 else:
638 raise util.Abort(_('cannot bisect (no known bad revisions)'))
638 raise util.Abort(_('cannot bisect (no known bad revisions)'))
639 return True
639 return True
640
640
641 # backward compatibility
641 # backward compatibility
642 if rev in "good bad reset init".split():
642 if rev in "good bad reset init".split():
643 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
643 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
644 cmd, rev, extra = rev, extra, None
644 cmd, rev, extra = rev, extra, None
645 if cmd == "good":
645 if cmd == "good":
646 good = True
646 good = True
647 elif cmd == "bad":
647 elif cmd == "bad":
648 bad = True
648 bad = True
649 else:
649 else:
650 reset = True
650 reset = True
651 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
651 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
652 raise util.Abort(_('incompatible arguments'))
652 raise util.Abort(_('incompatible arguments'))
653
653
654 if reset:
654 if reset:
655 p = repo.join("bisect.state")
655 p = repo.join("bisect.state")
656 if os.path.exists(p):
656 if os.path.exists(p):
657 os.unlink(p)
657 os.unlink(p)
658 return
658 return
659
659
660 state = hbisect.load_state(repo)
660 state = hbisect.load_state(repo)
661
661
662 if command:
662 if command:
663 changesets = 1
663 changesets = 1
664 try:
664 try:
665 node = state['current'][0]
665 node = state['current'][0]
666 except LookupError:
666 except LookupError:
667 if noupdate:
667 if noupdate:
668 raise util.Abort(_('current bisect revision is unknown - '
668 raise util.Abort(_('current bisect revision is unknown - '
669 'start a new bisect to fix'))
669 'start a new bisect to fix'))
670 node, p2 = repo.dirstate.parents()
670 node, p2 = repo.dirstate.parents()
671 if p2 != nullid:
671 if p2 != nullid:
672 raise util.Abort(_('current bisect revision is a merge'))
672 raise util.Abort(_('current bisect revision is a merge'))
673 try:
673 try:
674 while changesets:
674 while changesets:
675 # update state
675 # update state
676 state['current'] = [node]
676 state['current'] = [node]
677 hbisect.save_state(repo, state)
677 hbisect.save_state(repo, state)
678 status = util.system(command,
678 status = util.system(command,
679 environ={'HG_NODE': hex(node)},
679 environ={'HG_NODE': hex(node)},
680 out=ui.fout)
680 out=ui.fout)
681 if status == 125:
681 if status == 125:
682 transition = "skip"
682 transition = "skip"
683 elif status == 0:
683 elif status == 0:
684 transition = "good"
684 transition = "good"
685 # status < 0 means process was killed
685 # status < 0 means process was killed
686 elif status == 127:
686 elif status == 127:
687 raise util.Abort(_("failed to execute %s") % command)
687 raise util.Abort(_("failed to execute %s") % command)
688 elif status < 0:
688 elif status < 0:
689 raise util.Abort(_("%s killed") % command)
689 raise util.Abort(_("%s killed") % command)
690 else:
690 else:
691 transition = "bad"
691 transition = "bad"
692 ctx = scmutil.revsingle(repo, rev, node)
692 ctx = scmutil.revsingle(repo, rev, node)
693 rev = None # clear for future iterations
693 rev = None # clear for future iterations
694 state[transition].append(ctx.node())
694 state[transition].append(ctx.node())
695 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
695 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
696 check_state(state, interactive=False)
696 check_state(state, interactive=False)
697 # bisect
697 # bisect
698 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
698 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
699 # update to next check
699 # update to next check
700 node = nodes[0]
700 node = nodes[0]
701 if not noupdate:
701 if not noupdate:
702 cmdutil.bailifchanged(repo)
702 cmdutil.bailifchanged(repo)
703 hg.clean(repo, node, show_stats=False)
703 hg.clean(repo, node, show_stats=False)
704 finally:
704 finally:
705 state['current'] = [node]
705 state['current'] = [node]
706 hbisect.save_state(repo, state)
706 hbisect.save_state(repo, state)
707 print_result(nodes, good)
707 print_result(nodes, good)
708 return
708 return
709
709
710 # update state
710 # update state
711
711
712 if rev:
712 if rev:
713 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
713 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
714 else:
714 else:
715 nodes = [repo.lookup('.')]
715 nodes = [repo.lookup('.')]
716
716
717 if good or bad or skip:
717 if good or bad or skip:
718 if good:
718 if good:
719 state['good'] += nodes
719 state['good'] += nodes
720 elif bad:
720 elif bad:
721 state['bad'] += nodes
721 state['bad'] += nodes
722 elif skip:
722 elif skip:
723 state['skip'] += nodes
723 state['skip'] += nodes
724 hbisect.save_state(repo, state)
724 hbisect.save_state(repo, state)
725
725
726 if not check_state(state):
726 if not check_state(state):
727 return
727 return
728
728
729 # actually bisect
729 # actually bisect
730 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
730 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
731 if extend:
731 if extend:
732 if not changesets:
732 if not changesets:
733 extendnode = extendbisectrange(nodes, good)
733 extendnode = extendbisectrange(nodes, good)
734 if extendnode is not None:
734 if extendnode is not None:
735 ui.write(_("Extending search to changeset %d:%s\n"
735 ui.write(_("Extending search to changeset %d:%s\n"
736 % (extendnode.rev(), extendnode)))
736 % (extendnode.rev(), extendnode)))
737 state['current'] = [extendnode.node()]
737 state['current'] = [extendnode.node()]
738 hbisect.save_state(repo, state)
738 hbisect.save_state(repo, state)
739 if noupdate:
739 if noupdate:
740 return
740 return
741 cmdutil.bailifchanged(repo)
741 cmdutil.bailifchanged(repo)
742 return hg.clean(repo, extendnode.node())
742 return hg.clean(repo, extendnode.node())
743 raise util.Abort(_("nothing to extend"))
743 raise util.Abort(_("nothing to extend"))
744
744
745 if changesets == 0:
745 if changesets == 0:
746 print_result(nodes, good)
746 print_result(nodes, good)
747 else:
747 else:
748 assert len(nodes) == 1 # only a single node can be tested next
748 assert len(nodes) == 1 # only a single node can be tested next
749 node = nodes[0]
749 node = nodes[0]
750 # compute the approximate number of remaining tests
750 # compute the approximate number of remaining tests
751 tests, size = 0, 2
751 tests, size = 0, 2
752 while size <= changesets:
752 while size <= changesets:
753 tests, size = tests + 1, size * 2
753 tests, size = tests + 1, size * 2
754 rev = repo.changelog.rev(node)
754 rev = repo.changelog.rev(node)
755 ui.write(_("Testing changeset %d:%s "
755 ui.write(_("Testing changeset %d:%s "
756 "(%d changesets remaining, ~%d tests)\n")
756 "(%d changesets remaining, ~%d tests)\n")
757 % (rev, short(node), changesets, tests))
757 % (rev, short(node), changesets, tests))
758 state['current'] = [node]
758 state['current'] = [node]
759 hbisect.save_state(repo, state)
759 hbisect.save_state(repo, state)
760 if not noupdate:
760 if not noupdate:
761 cmdutil.bailifchanged(repo)
761 cmdutil.bailifchanged(repo)
762 return hg.clean(repo, node)
762 return hg.clean(repo, node)
763
763
764 @command('bookmarks|bookmark',
764 @command('bookmarks|bookmark',
765 [('f', 'force', False, _('force')),
765 [('f', 'force', False, _('force')),
766 ('r', 'rev', '', _('revision'), _('REV')),
766 ('r', 'rev', '', _('revision'), _('REV')),
767 ('d', 'delete', False, _('delete a given bookmark')),
767 ('d', 'delete', False, _('delete a given bookmark')),
768 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
768 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
769 ('i', 'inactive', False, _('mark a bookmark inactive'))],
769 ('i', 'inactive', False, _('mark a bookmark inactive'))],
770 _('hg bookmarks [OPTIONS]... [NAME]...'))
770 _('hg bookmarks [OPTIONS]... [NAME]...'))
771 def bookmark(ui, repo, *names, **opts):
771 def bookmark(ui, repo, *names, **opts):
772 '''track a line of development with movable markers
772 '''track a line of development with movable markers
773
773
774 Bookmarks are pointers to certain commits that move when committing.
774 Bookmarks are pointers to certain commits that move when committing.
775 Bookmarks are local. They can be renamed, copied and deleted. It is
775 Bookmarks are local. They can be renamed, copied and deleted. It is
776 possible to use :hg:`merge NAME` to merge from a given bookmark, and
776 possible to use :hg:`merge NAME` to merge from a given bookmark, and
777 :hg:`update NAME` to update to a given bookmark.
777 :hg:`update NAME` to update to a given bookmark.
778
778
779 You can use :hg:`bookmark NAME` to set a bookmark on the working
779 You can use :hg:`bookmark NAME` to set a bookmark on the working
780 directory's parent revision with the given name. If you specify
780 directory's parent revision with the given name. If you specify
781 a revision using -r REV (where REV may be an existing bookmark),
781 a revision using -r REV (where REV may be an existing bookmark),
782 the bookmark is assigned to that revision.
782 the bookmark is assigned to that revision.
783
783
784 Bookmarks can be pushed and pulled between repositories (see :hg:`help
784 Bookmarks can be pushed and pulled between repositories (see :hg:`help
785 push` and :hg:`help pull`). This requires both the local and remote
785 push` and :hg:`help pull`). This requires both the local and remote
786 repositories to support bookmarks. For versions prior to 1.8, this means
786 repositories to support bookmarks. For versions prior to 1.8, this means
787 the bookmarks extension must be enabled.
787 the bookmarks extension must be enabled.
788
788
789 If you set a bookmark called '@', new clones of the repository will
789 If you set a bookmark called '@', new clones of the repository will
790 have that revision checked out (and the bookmark made active) by
790 have that revision checked out (and the bookmark made active) by
791 default.
791 default.
792
792
793 With -i/--inactive, the new bookmark will not be made the active
793 With -i/--inactive, the new bookmark will not be made the active
794 bookmark. If -r/--rev is given, the new bookmark will not be made
794 bookmark. If -r/--rev is given, the new bookmark will not be made
795 active even if -i/--inactive is not given. If no NAME is given, the
795 active even if -i/--inactive is not given. If no NAME is given, the
796 current active bookmark will be marked inactive.
796 current active bookmark will be marked inactive.
797 '''
797 '''
798 force = opts.get('force')
798 force = opts.get('force')
799 rev = opts.get('rev')
799 rev = opts.get('rev')
800 delete = opts.get('delete')
800 delete = opts.get('delete')
801 rename = opts.get('rename')
801 rename = opts.get('rename')
802 inactive = opts.get('inactive')
802 inactive = opts.get('inactive')
803
803
804 hexfn = ui.debugflag and hex or short
804 hexfn = ui.debugflag and hex or short
805 marks = repo._bookmarks
805 marks = repo._bookmarks
806 cur = repo.changectx('.').node()
806 cur = repo.changectx('.').node()
807
807
808 def checkformat(mark):
808 def checkformat(mark):
809 mark = mark.strip()
809 mark = mark.strip()
810 if not mark:
810 if not mark:
811 raise util.Abort(_("bookmark names cannot consist entirely of "
811 raise util.Abort(_("bookmark names cannot consist entirely of "
812 "whitespace"))
812 "whitespace"))
813 scmutil.checknewlabel(repo, mark, 'bookmark')
813 scmutil.checknewlabel(repo, mark, 'bookmark')
814 return mark
814 return mark
815
815
816 def checkconflict(repo, mark, force=False, target=None):
816 def checkconflict(repo, mark, force=False, target=None):
817 if mark in marks and not force:
817 if mark in marks and not force:
818 if target:
818 if target:
819 if marks[mark] == target and target == cur:
819 if marks[mark] == target and target == cur:
820 # re-activating a bookmark
820 # re-activating a bookmark
821 return
821 return
822 anc = repo.changelog.ancestors([repo[target].rev()])
822 anc = repo.changelog.ancestors([repo[target].rev()])
823 bmctx = repo[marks[mark]]
823 bmctx = repo[marks[mark]]
824 divs = [repo[b].node() for b in marks
824 divs = [repo[b].node() for b in marks
825 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
825 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
826
826
827 # allow resolving a single divergent bookmark even if moving
827 # allow resolving a single divergent bookmark even if moving
828 # the bookmark across branches when a revision is specified
828 # the bookmark across branches when a revision is specified
829 # that contains a divergent bookmark
829 # that contains a divergent bookmark
830 if bmctx.rev() not in anc and target in divs:
830 if bmctx.rev() not in anc and target in divs:
831 bookmarks.deletedivergent(repo, [target], mark)
831 bookmarks.deletedivergent(repo, [target], mark)
832 return
832 return
833
833
834 deletefrom = [b for b in divs
834 deletefrom = [b for b in divs
835 if repo[b].rev() in anc or b == target]
835 if repo[b].rev() in anc or b == target]
836 bookmarks.deletedivergent(repo, deletefrom, mark)
836 bookmarks.deletedivergent(repo, deletefrom, mark)
837 if bmctx.rev() in anc:
837 if bmctx.rev() in anc:
838 ui.status(_("moving bookmark '%s' forward from %s\n") %
838 ui.status(_("moving bookmark '%s' forward from %s\n") %
839 (mark, short(bmctx.node())))
839 (mark, short(bmctx.node())))
840 return
840 return
841 raise util.Abort(_("bookmark '%s' already exists "
841 raise util.Abort(_("bookmark '%s' already exists "
842 "(use -f to force)") % mark)
842 "(use -f to force)") % mark)
843 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
843 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
844 and not force):
844 and not force):
845 raise util.Abort(
845 raise util.Abort(
846 _("a bookmark cannot have the name of an existing branch"))
846 _("a bookmark cannot have the name of an existing branch"))
847
847
848 if delete and rename:
848 if delete and rename:
849 raise util.Abort(_("--delete and --rename are incompatible"))
849 raise util.Abort(_("--delete and --rename are incompatible"))
850 if delete and rev:
850 if delete and rev:
851 raise util.Abort(_("--rev is incompatible with --delete"))
851 raise util.Abort(_("--rev is incompatible with --delete"))
852 if rename and rev:
852 if rename and rev:
853 raise util.Abort(_("--rev is incompatible with --rename"))
853 raise util.Abort(_("--rev is incompatible with --rename"))
854 if not names and (delete or rev):
854 if not names and (delete or rev):
855 raise util.Abort(_("bookmark name required"))
855 raise util.Abort(_("bookmark name required"))
856
856
857 if delete:
857 if delete:
858 for mark in names:
858 for mark in names:
859 if mark not in marks:
859 if mark not in marks:
860 raise util.Abort(_("bookmark '%s' does not exist") % mark)
860 raise util.Abort(_("bookmark '%s' does not exist") % mark)
861 if mark == repo._bookmarkcurrent:
861 if mark == repo._bookmarkcurrent:
862 bookmarks.setcurrent(repo, None)
862 bookmarks.setcurrent(repo, None)
863 del marks[mark]
863 del marks[mark]
864 marks.write()
864 marks.write()
865
865
866 elif rename:
866 elif rename:
867 if not names:
867 if not names:
868 raise util.Abort(_("new bookmark name required"))
868 raise util.Abort(_("new bookmark name required"))
869 elif len(names) > 1:
869 elif len(names) > 1:
870 raise util.Abort(_("only one new bookmark name allowed"))
870 raise util.Abort(_("only one new bookmark name allowed"))
871 mark = checkformat(names[0])
871 mark = checkformat(names[0])
872 if rename not in marks:
872 if rename not in marks:
873 raise util.Abort(_("bookmark '%s' does not exist") % rename)
873 raise util.Abort(_("bookmark '%s' does not exist") % rename)
874 checkconflict(repo, mark, force)
874 checkconflict(repo, mark, force)
875 marks[mark] = marks[rename]
875 marks[mark] = marks[rename]
876 if repo._bookmarkcurrent == rename and not inactive:
876 if repo._bookmarkcurrent == rename and not inactive:
877 bookmarks.setcurrent(repo, mark)
877 bookmarks.setcurrent(repo, mark)
878 del marks[rename]
878 del marks[rename]
879 marks.write()
879 marks.write()
880
880
881 elif names:
881 elif names:
882 newact = None
882 newact = None
883 for mark in names:
883 for mark in names:
884 mark = checkformat(mark)
884 mark = checkformat(mark)
885 if newact is None:
885 if newact is None:
886 newact = mark
886 newact = mark
887 if inactive and mark == repo._bookmarkcurrent:
887 if inactive and mark == repo._bookmarkcurrent:
888 bookmarks.setcurrent(repo, None)
888 bookmarks.setcurrent(repo, None)
889 return
889 return
890 tgt = cur
890 tgt = cur
891 if rev:
891 if rev:
892 tgt = scmutil.revsingle(repo, rev).node()
892 tgt = scmutil.revsingle(repo, rev).node()
893 checkconflict(repo, mark, force, tgt)
893 checkconflict(repo, mark, force, tgt)
894 marks[mark] = tgt
894 marks[mark] = tgt
895 if not inactive and cur == marks[newact] and not rev:
895 if not inactive and cur == marks[newact] and not rev:
896 bookmarks.setcurrent(repo, newact)
896 bookmarks.setcurrent(repo, newact)
897 elif cur != tgt and newact == repo._bookmarkcurrent:
897 elif cur != tgt and newact == repo._bookmarkcurrent:
898 bookmarks.setcurrent(repo, None)
898 bookmarks.setcurrent(repo, None)
899 marks.write()
899 marks.write()
900
900
901 # Same message whether trying to deactivate the current bookmark (-i
901 # Same message whether trying to deactivate the current bookmark (-i
902 # with no NAME) or listing bookmarks
902 # with no NAME) or listing bookmarks
903 elif len(marks) == 0:
903 elif len(marks) == 0:
904 ui.status(_("no bookmarks set\n"))
904 ui.status(_("no bookmarks set\n"))
905
905
906 elif inactive:
906 elif inactive:
907 if not repo._bookmarkcurrent:
907 if not repo._bookmarkcurrent:
908 ui.status(_("no active bookmark\n"))
908 ui.status(_("no active bookmark\n"))
909 else:
909 else:
910 bookmarks.setcurrent(repo, None)
910 bookmarks.setcurrent(repo, None)
911
911
912 else: # show bookmarks
912 else: # show bookmarks
913 for bmark, n in sorted(marks.iteritems()):
913 for bmark, n in sorted(marks.iteritems()):
914 current = repo._bookmarkcurrent
914 current = repo._bookmarkcurrent
915 if bmark == current:
915 if bmark == current:
916 prefix, label = '*', 'bookmarks.current'
916 prefix, label = '*', 'bookmarks.current'
917 else:
917 else:
918 prefix, label = ' ', ''
918 prefix, label = ' ', ''
919
919
920 if ui.quiet:
920 if ui.quiet:
921 ui.write("%s\n" % bmark, label=label)
921 ui.write("%s\n" % bmark, label=label)
922 else:
922 else:
923 ui.write(" %s %-25s %d:%s\n" % (
923 ui.write(" %s %-25s %d:%s\n" % (
924 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
924 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
925 label=label)
925 label=label)
926
926
927 @command('branch',
927 @command('branch',
928 [('f', 'force', None,
928 [('f', 'force', None,
929 _('set branch name even if it shadows an existing branch')),
929 _('set branch name even if it shadows an existing branch')),
930 ('C', 'clean', None, _('reset branch name to parent branch name'))],
930 ('C', 'clean', None, _('reset branch name to parent branch name'))],
931 _('[-fC] [NAME]'))
931 _('[-fC] [NAME]'))
932 def branch(ui, repo, label=None, **opts):
932 def branch(ui, repo, label=None, **opts):
933 """set or show the current branch name
933 """set or show the current branch name
934
934
935 .. note::
935 .. note::
936 Branch names are permanent and global. Use :hg:`bookmark` to create a
936 Branch names are permanent and global. Use :hg:`bookmark` to create a
937 light-weight bookmark instead. See :hg:`help glossary` for more
937 light-weight bookmark instead. See :hg:`help glossary` for more
938 information about named branches and bookmarks.
938 information about named branches and bookmarks.
939
939
940 With no argument, show the current branch name. With one argument,
940 With no argument, show the current branch name. With one argument,
941 set the working directory branch name (the branch will not exist
941 set the working directory branch name (the branch will not exist
942 in the repository until the next commit). Standard practice
942 in the repository until the next commit). Standard practice
943 recommends that primary development take place on the 'default'
943 recommends that primary development take place on the 'default'
944 branch.
944 branch.
945
945
946 Unless -f/--force is specified, branch will not let you set a
946 Unless -f/--force is specified, branch will not let you set a
947 branch name that already exists, even if it's inactive.
947 branch name that already exists, even if it's inactive.
948
948
949 Use -C/--clean to reset the working directory branch to that of
949 Use -C/--clean to reset the working directory branch to that of
950 the parent of the working directory, negating a previous branch
950 the parent of the working directory, negating a previous branch
951 change.
951 change.
952
952
953 Use the command :hg:`update` to switch to an existing branch. Use
953 Use the command :hg:`update` to switch to an existing branch. Use
954 :hg:`commit --close-branch` to mark this branch as closed.
954 :hg:`commit --close-branch` to mark this branch as closed.
955
955
956 Returns 0 on success.
956 Returns 0 on success.
957 """
957 """
958 if label:
958 if label:
959 label = label.strip()
959 label = label.strip()
960
960
961 if not opts.get('clean') and not label:
961 if not opts.get('clean') and not label:
962 ui.write("%s\n" % repo.dirstate.branch())
962 ui.write("%s\n" % repo.dirstate.branch())
963 return
963 return
964
964
965 wlock = repo.wlock()
965 wlock = repo.wlock()
966 try:
966 try:
967 if opts.get('clean'):
967 if opts.get('clean'):
968 label = repo[None].p1().branch()
968 label = repo[None].p1().branch()
969 repo.dirstate.setbranch(label)
969 repo.dirstate.setbranch(label)
970 ui.status(_('reset working directory to branch %s\n') % label)
970 ui.status(_('reset working directory to branch %s\n') % label)
971 elif label:
971 elif label:
972 if not opts.get('force') and label in repo.branchmap():
972 if not opts.get('force') and label in repo.branchmap():
973 if label not in [p.branch() for p in repo.parents()]:
973 if label not in [p.branch() for p in repo.parents()]:
974 raise util.Abort(_('a branch of the same name already'
974 raise util.Abort(_('a branch of the same name already'
975 ' exists'),
975 ' exists'),
976 # i18n: "it" refers to an existing branch
976 # i18n: "it" refers to an existing branch
977 hint=_("use 'hg update' to switch to it"))
977 hint=_("use 'hg update' to switch to it"))
978 scmutil.checknewlabel(repo, label, 'branch')
978 scmutil.checknewlabel(repo, label, 'branch')
979 repo.dirstate.setbranch(label)
979 repo.dirstate.setbranch(label)
980 ui.status(_('marked working directory as branch %s\n') % label)
980 ui.status(_('marked working directory as branch %s\n') % label)
981 ui.status(_('(branches are permanent and global, '
981 ui.status(_('(branches are permanent and global, '
982 'did you want a bookmark?)\n'))
982 'did you want a bookmark?)\n'))
983 finally:
983 finally:
984 wlock.release()
984 wlock.release()
985
985
986 @command('branches',
986 @command('branches',
987 [('a', 'active', False, _('show only branches that have unmerged heads')),
987 [('a', 'active', False, _('show only branches that have unmerged heads')),
988 ('c', 'closed', False, _('show normal and closed branches'))],
988 ('c', 'closed', False, _('show normal and closed branches'))],
989 _('[-ac]'))
989 _('[-ac]'))
990 def branches(ui, repo, active=False, closed=False):
990 def branches(ui, repo, active=False, closed=False):
991 """list repository named branches
991 """list repository named branches
992
992
993 List the repository's named branches, indicating which ones are
993 List the repository's named branches, indicating which ones are
994 inactive. If -c/--closed is specified, also list branches which have
994 inactive. If -c/--closed is specified, also list branches which have
995 been marked closed (see :hg:`commit --close-branch`).
995 been marked closed (see :hg:`commit --close-branch`).
996
996
997 If -a/--active is specified, only show active branches. A branch
997 If -a/--active is specified, only show active branches. A branch
998 is considered active if it contains repository heads.
998 is considered active if it contains repository heads.
999
999
1000 Use the command :hg:`update` to switch to an existing branch.
1000 Use the command :hg:`update` to switch to an existing branch.
1001
1001
1002 Returns 0.
1002 Returns 0.
1003 """
1003 """
1004
1004
1005 hexfunc = ui.debugflag and hex or short
1005 hexfunc = ui.debugflag and hex or short
1006
1006
1007 activebranches = set([repo[n].branch() for n in repo.heads()])
1007 activebranches = set([repo[n].branch() for n in repo.heads()])
1008 branches = []
1008 branches = []
1009 for tag, heads in repo.branchmap().iteritems():
1009 for tag, heads in repo.branchmap().iteritems():
1010 for h in reversed(heads):
1010 for h in reversed(heads):
1011 ctx = repo[h]
1011 ctx = repo[h]
1012 isopen = not ctx.closesbranch()
1012 isopen = not ctx.closesbranch()
1013 if isopen:
1013 if isopen:
1014 tip = ctx
1014 tip = ctx
1015 break
1015 break
1016 else:
1016 else:
1017 tip = repo[heads[-1]]
1017 tip = repo[heads[-1]]
1018 isactive = tag in activebranches and isopen
1018 isactive = tag in activebranches and isopen
1019 branches.append((tip, isactive, isopen))
1019 branches.append((tip, isactive, isopen))
1020 branches.sort(key=lambda i: (i[1], i[0].rev(), i[0].branch(), i[2]),
1020 branches.sort(key=lambda i: (i[1], i[0].rev(), i[0].branch(), i[2]),
1021 reverse=True)
1021 reverse=True)
1022
1022
1023 for ctx, isactive, isopen in branches:
1023 for ctx, isactive, isopen in branches:
1024 if (not active) or isactive:
1024 if (not active) or isactive:
1025 if isactive:
1025 if isactive:
1026 label = 'branches.active'
1026 label = 'branches.active'
1027 notice = ''
1027 notice = ''
1028 elif not isopen:
1028 elif not isopen:
1029 if not closed:
1029 if not closed:
1030 continue
1030 continue
1031 label = 'branches.closed'
1031 label = 'branches.closed'
1032 notice = _(' (closed)')
1032 notice = _(' (closed)')
1033 else:
1033 else:
1034 label = 'branches.inactive'
1034 label = 'branches.inactive'
1035 notice = _(' (inactive)')
1035 notice = _(' (inactive)')
1036 if ctx.branch() == repo.dirstate.branch():
1036 if ctx.branch() == repo.dirstate.branch():
1037 label = 'branches.current'
1037 label = 'branches.current'
1038 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(ctx.branch()))
1038 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(ctx.branch()))
1039 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1039 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1040 'log.changeset changeset.%s' % ctx.phasestr())
1040 'log.changeset changeset.%s' % ctx.phasestr())
1041 tag = ui.label(ctx.branch(), label)
1041 tag = ui.label(ctx.branch(), label)
1042 if ui.quiet:
1042 if ui.quiet:
1043 ui.write("%s\n" % tag)
1043 ui.write("%s\n" % tag)
1044 else:
1044 else:
1045 ui.write("%s %s%s\n" % (tag, rev, notice))
1045 ui.write("%s %s%s\n" % (tag, rev, notice))
1046
1046
1047 @command('bundle',
1047 @command('bundle',
1048 [('f', 'force', None, _('run even when the destination is unrelated')),
1048 [('f', 'force', None, _('run even when the destination is unrelated')),
1049 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1049 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1050 _('REV')),
1050 _('REV')),
1051 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1051 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1052 _('BRANCH')),
1052 _('BRANCH')),
1053 ('', 'base', [],
1053 ('', 'base', [],
1054 _('a base changeset assumed to be available at the destination'),
1054 _('a base changeset assumed to be available at the destination'),
1055 _('REV')),
1055 _('REV')),
1056 ('a', 'all', None, _('bundle all changesets in the repository')),
1056 ('a', 'all', None, _('bundle all changesets in the repository')),
1057 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1057 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1058 ] + remoteopts,
1058 ] + remoteopts,
1059 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1059 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1060 def bundle(ui, repo, fname, dest=None, **opts):
1060 def bundle(ui, repo, fname, dest=None, **opts):
1061 """create a changegroup file
1061 """create a changegroup file
1062
1062
1063 Generate a compressed changegroup file collecting changesets not
1063 Generate a compressed changegroup file collecting changesets not
1064 known to be in another repository.
1064 known to be in another repository.
1065
1065
1066 If you omit the destination repository, then hg assumes the
1066 If you omit the destination repository, then hg assumes the
1067 destination will have all the nodes you specify with --base
1067 destination will have all the nodes you specify with --base
1068 parameters. To create a bundle containing all changesets, use
1068 parameters. To create a bundle containing all changesets, use
1069 -a/--all (or --base null).
1069 -a/--all (or --base null).
1070
1070
1071 You can change compression method with the -t/--type option.
1071 You can change compression method with the -t/--type option.
1072 The available compression methods are: none, bzip2, and
1072 The available compression methods are: none, bzip2, and
1073 gzip (by default, bundles are compressed using bzip2).
1073 gzip (by default, bundles are compressed using bzip2).
1074
1074
1075 The bundle file can then be transferred using conventional means
1075 The bundle file can then be transferred using conventional means
1076 and applied to another repository with the unbundle or pull
1076 and applied to another repository with the unbundle or pull
1077 command. This is useful when direct push and pull are not
1077 command. This is useful when direct push and pull are not
1078 available or when exporting an entire repository is undesirable.
1078 available or when exporting an entire repository is undesirable.
1079
1079
1080 Applying bundles preserves all changeset contents including
1080 Applying bundles preserves all changeset contents including
1081 permissions, copy/rename information, and revision history.
1081 permissions, copy/rename information, and revision history.
1082
1082
1083 Returns 0 on success, 1 if no changes found.
1083 Returns 0 on success, 1 if no changes found.
1084 """
1084 """
1085 revs = None
1085 revs = None
1086 if 'rev' in opts:
1086 if 'rev' in opts:
1087 revs = scmutil.revrange(repo, opts['rev'])
1087 revs = scmutil.revrange(repo, opts['rev'])
1088
1088
1089 bundletype = opts.get('type', 'bzip2').lower()
1089 bundletype = opts.get('type', 'bzip2').lower()
1090 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1090 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1091 bundletype = btypes.get(bundletype)
1091 bundletype = btypes.get(bundletype)
1092 if bundletype not in changegroup.bundletypes:
1092 if bundletype not in changegroup.bundletypes:
1093 raise util.Abort(_('unknown bundle type specified with --type'))
1093 raise util.Abort(_('unknown bundle type specified with --type'))
1094
1094
1095 if opts.get('all'):
1095 if opts.get('all'):
1096 base = ['null']
1096 base = ['null']
1097 else:
1097 else:
1098 base = scmutil.revrange(repo, opts.get('base'))
1098 base = scmutil.revrange(repo, opts.get('base'))
1099 # TODO: get desired bundlecaps from command line.
1099 # TODO: get desired bundlecaps from command line.
1100 bundlecaps = None
1100 bundlecaps = None
1101 if base:
1101 if base:
1102 if dest:
1102 if dest:
1103 raise util.Abort(_("--base is incompatible with specifying "
1103 raise util.Abort(_("--base is incompatible with specifying "
1104 "a destination"))
1104 "a destination"))
1105 common = [repo.lookup(rev) for rev in base]
1105 common = [repo.lookup(rev) for rev in base]
1106 heads = revs and map(repo.lookup, revs) or revs
1106 heads = revs and map(repo.lookup, revs) or revs
1107 cg = repo.getbundle('bundle', heads=heads, common=common,
1107 cg = repo.getbundle('bundle', heads=heads, common=common,
1108 bundlecaps=bundlecaps)
1108 bundlecaps=bundlecaps)
1109 outgoing = None
1109 outgoing = None
1110 else:
1110 else:
1111 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1111 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1112 dest, branches = hg.parseurl(dest, opts.get('branch'))
1112 dest, branches = hg.parseurl(dest, opts.get('branch'))
1113 other = hg.peer(repo, opts, dest)
1113 other = hg.peer(repo, opts, dest)
1114 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1114 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1115 heads = revs and map(repo.lookup, revs) or revs
1115 heads = revs and map(repo.lookup, revs) or revs
1116 outgoing = discovery.findcommonoutgoing(repo, other,
1116 outgoing = discovery.findcommonoutgoing(repo, other,
1117 onlyheads=heads,
1117 onlyheads=heads,
1118 force=opts.get('force'),
1118 force=opts.get('force'),
1119 portable=True)
1119 portable=True)
1120 cg = repo.getlocalbundle('bundle', outgoing, bundlecaps)
1120 cg = repo.getlocalbundle('bundle', outgoing, bundlecaps)
1121 if not cg:
1121 if not cg:
1122 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1122 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1123 return 1
1123 return 1
1124
1124
1125 changegroup.writebundle(cg, fname, bundletype)
1125 changegroup.writebundle(cg, fname, bundletype)
1126
1126
1127 @command('cat',
1127 @command('cat',
1128 [('o', 'output', '',
1128 [('o', 'output', '',
1129 _('print output to file with formatted name'), _('FORMAT')),
1129 _('print output to file with formatted name'), _('FORMAT')),
1130 ('r', 'rev', '', _('print the given revision'), _('REV')),
1130 ('r', 'rev', '', _('print the given revision'), _('REV')),
1131 ('', 'decode', None, _('apply any matching decode filter')),
1131 ('', 'decode', None, _('apply any matching decode filter')),
1132 ] + walkopts,
1132 ] + walkopts,
1133 _('[OPTION]... FILE...'))
1133 _('[OPTION]... FILE...'))
1134 def cat(ui, repo, file1, *pats, **opts):
1134 def cat(ui, repo, file1, *pats, **opts):
1135 """output the current or given revision of files
1135 """output the current or given revision of files
1136
1136
1137 Print the specified files as they were at the given revision. If
1137 Print the specified files as they were at the given revision. If
1138 no revision is given, the parent of the working directory is used.
1138 no revision is given, the parent of the working directory is used.
1139
1139
1140 Output may be to a file, in which case the name of the file is
1140 Output may be to a file, in which case the name of the file is
1141 given using a format string. The formatting rules are the same as
1141 given using a format string. The formatting rules are the same as
1142 for the export command, with the following additions:
1142 for the export command, with the following additions:
1143
1143
1144 :``%s``: basename of file being printed
1144 :``%s``: basename of file being printed
1145 :``%d``: dirname of file being printed, or '.' if in repository root
1145 :``%d``: dirname of file being printed, or '.' if in repository root
1146 :``%p``: root-relative path name of file being printed
1146 :``%p``: root-relative path name of file being printed
1147
1147
1148 Returns 0 on success.
1148 Returns 0 on success.
1149 """
1149 """
1150 ctx = scmutil.revsingle(repo, opts.get('rev'))
1150 ctx = scmutil.revsingle(repo, opts.get('rev'))
1151 err = 1
1151 err = 1
1152 m = scmutil.match(ctx, (file1,) + pats, opts)
1152 m = scmutil.match(ctx, (file1,) + pats, opts)
1153 for abs in ctx.walk(m):
1153 for abs in ctx.walk(m):
1154 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
1154 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
1155 pathname=abs)
1155 pathname=abs)
1156 data = ctx[abs].data()
1156 data = ctx[abs].data()
1157 if opts.get('decode'):
1157 if opts.get('decode'):
1158 data = repo.wwritedata(abs, data)
1158 data = repo.wwritedata(abs, data)
1159 fp.write(data)
1159 fp.write(data)
1160 fp.close()
1160 fp.close()
1161 err = 0
1161 err = 0
1162 return err
1162 return err
1163
1163
1164 @command('^clone',
1164 @command('^clone',
1165 [('U', 'noupdate', None,
1165 [('U', 'noupdate', None,
1166 _('the clone will include an empty working copy (only a repository)')),
1166 _('the clone will include an empty working copy (only a repository)')),
1167 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1167 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1168 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1168 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1169 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1169 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1170 ('', 'pull', None, _('use pull protocol to copy metadata')),
1170 ('', 'pull', None, _('use pull protocol to copy metadata')),
1171 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1171 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1172 ] + remoteopts,
1172 ] + remoteopts,
1173 _('[OPTION]... SOURCE [DEST]'))
1173 _('[OPTION]... SOURCE [DEST]'))
1174 def clone(ui, source, dest=None, **opts):
1174 def clone(ui, source, dest=None, **opts):
1175 """make a copy of an existing repository
1175 """make a copy of an existing repository
1176
1176
1177 Create a copy of an existing repository in a new directory.
1177 Create a copy of an existing repository in a new directory.
1178
1178
1179 If no destination directory name is specified, it defaults to the
1179 If no destination directory name is specified, it defaults to the
1180 basename of the source.
1180 basename of the source.
1181
1181
1182 The location of the source is added to the new repository's
1182 The location of the source is added to the new repository's
1183 ``.hg/hgrc`` file, as the default to be used for future pulls.
1183 ``.hg/hgrc`` file, as the default to be used for future pulls.
1184
1184
1185 Only local paths and ``ssh://`` URLs are supported as
1185 Only local paths and ``ssh://`` URLs are supported as
1186 destinations. For ``ssh://`` destinations, no working directory or
1186 destinations. For ``ssh://`` destinations, no working directory or
1187 ``.hg/hgrc`` will be created on the remote side.
1187 ``.hg/hgrc`` will be created on the remote side.
1188
1188
1189 To pull only a subset of changesets, specify one or more revisions
1189 To pull only a subset of changesets, specify one or more revisions
1190 identifiers with -r/--rev or branches with -b/--branch. The
1190 identifiers with -r/--rev or branches with -b/--branch. The
1191 resulting clone will contain only the specified changesets and
1191 resulting clone will contain only the specified changesets and
1192 their ancestors. These options (or 'clone src#rev dest') imply
1192 their ancestors. These options (or 'clone src#rev dest') imply
1193 --pull, even for local source repositories. Note that specifying a
1193 --pull, even for local source repositories. Note that specifying a
1194 tag will include the tagged changeset but not the changeset
1194 tag will include the tagged changeset but not the changeset
1195 containing the tag.
1195 containing the tag.
1196
1196
1197 If the source repository has a bookmark called '@' set, that
1197 If the source repository has a bookmark called '@' set, that
1198 revision will be checked out in the new repository by default.
1198 revision will be checked out in the new repository by default.
1199
1199
1200 To check out a particular version, use -u/--update, or
1200 To check out a particular version, use -u/--update, or
1201 -U/--noupdate to create a clone with no working directory.
1201 -U/--noupdate to create a clone with no working directory.
1202
1202
1203 .. container:: verbose
1203 .. container:: verbose
1204
1204
1205 For efficiency, hardlinks are used for cloning whenever the
1205 For efficiency, hardlinks are used for cloning whenever the
1206 source and destination are on the same filesystem (note this
1206 source and destination are on the same filesystem (note this
1207 applies only to the repository data, not to the working
1207 applies only to the repository data, not to the working
1208 directory). Some filesystems, such as AFS, implement hardlinking
1208 directory). Some filesystems, such as AFS, implement hardlinking
1209 incorrectly, but do not report errors. In these cases, use the
1209 incorrectly, but do not report errors. In these cases, use the
1210 --pull option to avoid hardlinking.
1210 --pull option to avoid hardlinking.
1211
1211
1212 In some cases, you can clone repositories and the working
1212 In some cases, you can clone repositories and the working
1213 directory using full hardlinks with ::
1213 directory using full hardlinks with ::
1214
1214
1215 $ cp -al REPO REPOCLONE
1215 $ cp -al REPO REPOCLONE
1216
1216
1217 This is the fastest way to clone, but it is not always safe. The
1217 This is the fastest way to clone, but it is not always safe. The
1218 operation is not atomic (making sure REPO is not modified during
1218 operation is not atomic (making sure REPO is not modified during
1219 the operation is up to you) and you have to make sure your
1219 the operation is up to you) and you have to make sure your
1220 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1220 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1221 so). Also, this is not compatible with certain extensions that
1221 so). Also, this is not compatible with certain extensions that
1222 place their metadata under the .hg directory, such as mq.
1222 place their metadata under the .hg directory, such as mq.
1223
1223
1224 Mercurial will update the working directory to the first applicable
1224 Mercurial will update the working directory to the first applicable
1225 revision from this list:
1225 revision from this list:
1226
1226
1227 a) null if -U or the source repository has no changesets
1227 a) null if -U or the source repository has no changesets
1228 b) if -u . and the source repository is local, the first parent of
1228 b) if -u . and the source repository is local, the first parent of
1229 the source repository's working directory
1229 the source repository's working directory
1230 c) the changeset specified with -u (if a branch name, this means the
1230 c) the changeset specified with -u (if a branch name, this means the
1231 latest head of that branch)
1231 latest head of that branch)
1232 d) the changeset specified with -r
1232 d) the changeset specified with -r
1233 e) the tipmost head specified with -b
1233 e) the tipmost head specified with -b
1234 f) the tipmost head specified with the url#branch source syntax
1234 f) the tipmost head specified with the url#branch source syntax
1235 g) the revision marked with the '@' bookmark, if present
1235 g) the revision marked with the '@' bookmark, if present
1236 h) the tipmost head of the default branch
1236 h) the tipmost head of the default branch
1237 i) tip
1237 i) tip
1238
1238
1239 Examples:
1239 Examples:
1240
1240
1241 - clone a remote repository to a new directory named hg/::
1241 - clone a remote repository to a new directory named hg/::
1242
1242
1243 hg clone http://selenic.com/hg
1243 hg clone http://selenic.com/hg
1244
1244
1245 - create a lightweight local clone::
1245 - create a lightweight local clone::
1246
1246
1247 hg clone project/ project-feature/
1247 hg clone project/ project-feature/
1248
1248
1249 - clone from an absolute path on an ssh server (note double-slash)::
1249 - clone from an absolute path on an ssh server (note double-slash)::
1250
1250
1251 hg clone ssh://user@server//home/projects/alpha/
1251 hg clone ssh://user@server//home/projects/alpha/
1252
1252
1253 - do a high-speed clone over a LAN while checking out a
1253 - do a high-speed clone over a LAN while checking out a
1254 specified version::
1254 specified version::
1255
1255
1256 hg clone --uncompressed http://server/repo -u 1.5
1256 hg clone --uncompressed http://server/repo -u 1.5
1257
1257
1258 - create a repository without changesets after a particular revision::
1258 - create a repository without changesets after a particular revision::
1259
1259
1260 hg clone -r 04e544 experimental/ good/
1260 hg clone -r 04e544 experimental/ good/
1261
1261
1262 - clone (and track) a particular named branch::
1262 - clone (and track) a particular named branch::
1263
1263
1264 hg clone http://selenic.com/hg#stable
1264 hg clone http://selenic.com/hg#stable
1265
1265
1266 See :hg:`help urls` for details on specifying URLs.
1266 See :hg:`help urls` for details on specifying URLs.
1267
1267
1268 Returns 0 on success.
1268 Returns 0 on success.
1269 """
1269 """
1270 if opts.get('noupdate') and opts.get('updaterev'):
1270 if opts.get('noupdate') and opts.get('updaterev'):
1271 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1271 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1272
1272
1273 r = hg.clone(ui, opts, source, dest,
1273 r = hg.clone(ui, opts, source, dest,
1274 pull=opts.get('pull'),
1274 pull=opts.get('pull'),
1275 stream=opts.get('uncompressed'),
1275 stream=opts.get('uncompressed'),
1276 rev=opts.get('rev'),
1276 rev=opts.get('rev'),
1277 update=opts.get('updaterev') or not opts.get('noupdate'),
1277 update=opts.get('updaterev') or not opts.get('noupdate'),
1278 branch=opts.get('branch'))
1278 branch=opts.get('branch'))
1279
1279
1280 return r is None
1280 return r is None
1281
1281
1282 @command('^commit|ci',
1282 @command('^commit|ci',
1283 [('A', 'addremove', None,
1283 [('A', 'addremove', None,
1284 _('mark new/missing files as added/removed before committing')),
1284 _('mark new/missing files as added/removed before committing')),
1285 ('', 'close-branch', None,
1285 ('', 'close-branch', None,
1286 _('mark a branch as closed, hiding it from the branch list')),
1286 _('mark a branch as closed, hiding it from the branch list')),
1287 ('', 'amend', None, _('amend the parent of the working dir')),
1287 ('', 'amend', None, _('amend the parent of the working dir')),
1288 ('s', 'secret', None, _('use the secret phase for committing')),
1288 ('s', 'secret', None, _('use the secret phase for committing')),
1289 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1289 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1290 _('[OPTION]... [FILE]...'))
1290 _('[OPTION]... [FILE]...'))
1291 def commit(ui, repo, *pats, **opts):
1291 def commit(ui, repo, *pats, **opts):
1292 """commit the specified files or all outstanding changes
1292 """commit the specified files or all outstanding changes
1293
1293
1294 Commit changes to the given files into the repository. Unlike a
1294 Commit changes to the given files into the repository. Unlike a
1295 centralized SCM, this operation is a local operation. See
1295 centralized SCM, this operation is a local operation. See
1296 :hg:`push` for a way to actively distribute your changes.
1296 :hg:`push` for a way to actively distribute your changes.
1297
1297
1298 If a list of files is omitted, all changes reported by :hg:`status`
1298 If a list of files is omitted, all changes reported by :hg:`status`
1299 will be committed.
1299 will be committed.
1300
1300
1301 If you are committing the result of a merge, do not provide any
1301 If you are committing the result of a merge, do not provide any
1302 filenames or -I/-X filters.
1302 filenames or -I/-X filters.
1303
1303
1304 If no commit message is specified, Mercurial starts your
1304 If no commit message is specified, Mercurial starts your
1305 configured editor where you can enter a message. In case your
1305 configured editor where you can enter a message. In case your
1306 commit fails, you will find a backup of your message in
1306 commit fails, you will find a backup of your message in
1307 ``.hg/last-message.txt``.
1307 ``.hg/last-message.txt``.
1308
1308
1309 The --amend flag can be used to amend the parent of the
1309 The --amend flag can be used to amend the parent of the
1310 working directory with a new commit that contains the changes
1310 working directory with a new commit that contains the changes
1311 in the parent in addition to those currently reported by :hg:`status`,
1311 in the parent in addition to those currently reported by :hg:`status`,
1312 if there are any. The old commit is stored in a backup bundle in
1312 if there are any. The old commit is stored in a backup bundle in
1313 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1313 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1314 on how to restore it).
1314 on how to restore it).
1315
1315
1316 Message, user and date are taken from the amended commit unless
1316 Message, user and date are taken from the amended commit unless
1317 specified. When a message isn't specified on the command line,
1317 specified. When a message isn't specified on the command line,
1318 the editor will open with the message of the amended commit.
1318 the editor will open with the message of the amended commit.
1319
1319
1320 It is not possible to amend public changesets (see :hg:`help phases`)
1320 It is not possible to amend public changesets (see :hg:`help phases`)
1321 or changesets that have children.
1321 or changesets that have children.
1322
1322
1323 See :hg:`help dates` for a list of formats valid for -d/--date.
1323 See :hg:`help dates` for a list of formats valid for -d/--date.
1324
1324
1325 Returns 0 on success, 1 if nothing changed.
1325 Returns 0 on success, 1 if nothing changed.
1326 """
1326 """
1327 if opts.get('subrepos'):
1327 if opts.get('subrepos'):
1328 if opts.get('amend'):
1328 if opts.get('amend'):
1329 raise util.Abort(_('cannot amend with --subrepos'))
1329 raise util.Abort(_('cannot amend with --subrepos'))
1330 # Let --subrepos on the command line override config setting.
1330 # Let --subrepos on the command line override config setting.
1331 ui.setconfig('ui', 'commitsubrepos', True)
1331 ui.setconfig('ui', 'commitsubrepos', True)
1332
1332
1333 # Save this for restoring it later
1333 # Save this for restoring it later
1334 oldcommitphase = ui.config('phases', 'new-commit')
1334 oldcommitphase = ui.config('phases', 'new-commit')
1335
1335
1336 if repo.vfs.exists('graftstate'):
1336 if repo.vfs.exists('graftstate'):
1337 raise util.Abort(_('cannot commit an interrupted graft operation'),
1337 raise util.Abort(_('cannot commit an interrupted graft operation'),
1338 hint=_('use "hg graft -c" to continue graft'))
1338 hint=_('use "hg graft -c" to continue graft'))
1339
1339
1340 branch = repo[None].branch()
1340 branch = repo[None].branch()
1341 bheads = repo.branchheads(branch)
1341 bheads = repo.branchheads(branch)
1342
1342
1343 extra = {}
1343 extra = {}
1344 if opts.get('close_branch'):
1344 if opts.get('close_branch'):
1345 extra['close'] = 1
1345 extra['close'] = 1
1346
1346
1347 if not bheads:
1347 if not bheads:
1348 raise util.Abort(_('can only close branch heads'))
1348 raise util.Abort(_('can only close branch heads'))
1349 elif opts.get('amend'):
1349 elif opts.get('amend'):
1350 if repo.parents()[0].p1().branch() != branch and \
1350 if repo.parents()[0].p1().branch() != branch and \
1351 repo.parents()[0].p2().branch() != branch:
1351 repo.parents()[0].p2().branch() != branch:
1352 raise util.Abort(_('can only close branch heads'))
1352 raise util.Abort(_('can only close branch heads'))
1353
1353
1354 if opts.get('amend'):
1354 if opts.get('amend'):
1355 if ui.configbool('ui', 'commitsubrepos'):
1355 if ui.configbool('ui', 'commitsubrepos'):
1356 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1356 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1357
1357
1358 old = repo['.']
1358 old = repo['.']
1359 if old.phase() == phases.public:
1359 if old.phase() == phases.public:
1360 raise util.Abort(_('cannot amend public changesets'))
1360 raise util.Abort(_('cannot amend public changesets'))
1361 if len(repo[None].parents()) > 1:
1361 if len(repo[None].parents()) > 1:
1362 raise util.Abort(_('cannot amend while merging'))
1362 raise util.Abort(_('cannot amend while merging'))
1363 if (not obsolete._enabled) and old.children():
1363 if (not obsolete._enabled) and old.children():
1364 raise util.Abort(_('cannot amend changeset with children'))
1364 raise util.Abort(_('cannot amend changeset with children'))
1365
1365
1366 e = cmdutil.commiteditor
1366 e = cmdutil.commiteditor
1367 if opts.get('force_editor'):
1367 if opts.get('force_editor'):
1368 e = cmdutil.commitforceeditor
1368 e = cmdutil.commitforceeditor
1369
1369
1370 def commitfunc(ui, repo, message, match, opts):
1370 def commitfunc(ui, repo, message, match, opts):
1371 editor = e
1371 editor = e
1372 # message contains text from -m or -l, if it's empty,
1372 # message contains text from -m or -l, if it's empty,
1373 # open the editor with the old message
1373 # open the editor with the old message
1374 if not message:
1374 if not message:
1375 message = old.description()
1375 message = old.description()
1376 editor = cmdutil.commitforceeditor
1376 editor = cmdutil.commitforceeditor
1377 try:
1377 try:
1378 if opts.get('secret'):
1378 if opts.get('secret'):
1379 ui.setconfig('phases', 'new-commit', 'secret')
1379 ui.setconfig('phases', 'new-commit', 'secret')
1380
1380
1381 return repo.commit(message,
1381 return repo.commit(message,
1382 opts.get('user') or old.user(),
1382 opts.get('user') or old.user(),
1383 opts.get('date') or old.date(),
1383 opts.get('date') or old.date(),
1384 match,
1384 match,
1385 editor=editor,
1385 editor=editor,
1386 extra=extra)
1386 extra=extra)
1387 finally:
1387 finally:
1388 ui.setconfig('phases', 'new-commit', oldcommitphase)
1388 ui.setconfig('phases', 'new-commit', oldcommitphase)
1389
1389
1390 current = repo._bookmarkcurrent
1390 current = repo._bookmarkcurrent
1391 marks = old.bookmarks()
1391 marks = old.bookmarks()
1392 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1392 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1393 if node == old.node():
1393 if node == old.node():
1394 ui.status(_("nothing changed\n"))
1394 ui.status(_("nothing changed\n"))
1395 return 1
1395 return 1
1396 elif marks:
1396 elif marks:
1397 ui.debug('moving bookmarks %r from %s to %s\n' %
1397 ui.debug('moving bookmarks %r from %s to %s\n' %
1398 (marks, old.hex(), hex(node)))
1398 (marks, old.hex(), hex(node)))
1399 newmarks = repo._bookmarks
1399 newmarks = repo._bookmarks
1400 for bm in marks:
1400 for bm in marks:
1401 newmarks[bm] = node
1401 newmarks[bm] = node
1402 if bm == current:
1402 if bm == current:
1403 bookmarks.setcurrent(repo, bm)
1403 bookmarks.setcurrent(repo, bm)
1404 newmarks.write()
1404 newmarks.write()
1405 else:
1405 else:
1406 e = cmdutil.commiteditor
1406 e = cmdutil.commiteditor
1407 if opts.get('force_editor'):
1407 if opts.get('force_editor'):
1408 e = cmdutil.commitforceeditor
1408 e = cmdutil.commitforceeditor
1409
1409
1410 def commitfunc(ui, repo, message, match, opts):
1410 def commitfunc(ui, repo, message, match, opts):
1411 try:
1411 try:
1412 if opts.get('secret'):
1412 if opts.get('secret'):
1413 ui.setconfig('phases', 'new-commit', 'secret')
1413 ui.setconfig('phases', 'new-commit', 'secret')
1414
1414
1415 return repo.commit(message, opts.get('user'), opts.get('date'),
1415 return repo.commit(message, opts.get('user'), opts.get('date'),
1416 match, editor=e, extra=extra)
1416 match, editor=e, extra=extra)
1417 finally:
1417 finally:
1418 ui.setconfig('phases', 'new-commit', oldcommitphase)
1418 ui.setconfig('phases', 'new-commit', oldcommitphase)
1419
1419
1420
1420
1421 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1421 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1422
1422
1423 if not node:
1423 if not node:
1424 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1424 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1425 if stat[3]:
1425 if stat[3]:
1426 ui.status(_("nothing changed (%d missing files, see "
1426 ui.status(_("nothing changed (%d missing files, see "
1427 "'hg status')\n") % len(stat[3]))
1427 "'hg status')\n") % len(stat[3]))
1428 else:
1428 else:
1429 ui.status(_("nothing changed\n"))
1429 ui.status(_("nothing changed\n"))
1430 return 1
1430 return 1
1431
1431
1432 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1432 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1433
1433
1434 @command('copy|cp',
1434 @command('copy|cp',
1435 [('A', 'after', None, _('record a copy that has already occurred')),
1435 [('A', 'after', None, _('record a copy that has already occurred')),
1436 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1436 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1437 ] + walkopts + dryrunopts,
1437 ] + walkopts + dryrunopts,
1438 _('[OPTION]... [SOURCE]... DEST'))
1438 _('[OPTION]... [SOURCE]... DEST'))
1439 def copy(ui, repo, *pats, **opts):
1439 def copy(ui, repo, *pats, **opts):
1440 """mark files as copied for the next commit
1440 """mark files as copied for the next commit
1441
1441
1442 Mark dest as having copies of source files. If dest is a
1442 Mark dest as having copies of source files. If dest is a
1443 directory, copies are put in that directory. If dest is a file,
1443 directory, copies are put in that directory. If dest is a file,
1444 the source must be a single file.
1444 the source must be a single file.
1445
1445
1446 By default, this command copies the contents of files as they
1446 By default, this command copies the contents of files as they
1447 exist in the working directory. If invoked with -A/--after, the
1447 exist in the working directory. If invoked with -A/--after, the
1448 operation is recorded, but no copying is performed.
1448 operation is recorded, but no copying is performed.
1449
1449
1450 This command takes effect with the next commit. To undo a copy
1450 This command takes effect with the next commit. To undo a copy
1451 before that, see :hg:`revert`.
1451 before that, see :hg:`revert`.
1452
1452
1453 Returns 0 on success, 1 if errors are encountered.
1453 Returns 0 on success, 1 if errors are encountered.
1454 """
1454 """
1455 wlock = repo.wlock(False)
1455 wlock = repo.wlock(False)
1456 try:
1456 try:
1457 return cmdutil.copy(ui, repo, pats, opts)
1457 return cmdutil.copy(ui, repo, pats, opts)
1458 finally:
1458 finally:
1459 wlock.release()
1459 wlock.release()
1460
1460
1461 @command('debugancestor', [], _('[INDEX] REV1 REV2'))
1461 @command('debugancestor', [], _('[INDEX] REV1 REV2'))
1462 def debugancestor(ui, repo, *args):
1462 def debugancestor(ui, repo, *args):
1463 """find the ancestor revision of two revisions in a given index"""
1463 """find the ancestor revision of two revisions in a given index"""
1464 if len(args) == 3:
1464 if len(args) == 3:
1465 index, rev1, rev2 = args
1465 index, rev1, rev2 = args
1466 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1466 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1467 lookup = r.lookup
1467 lookup = r.lookup
1468 elif len(args) == 2:
1468 elif len(args) == 2:
1469 if not repo:
1469 if not repo:
1470 raise util.Abort(_("there is no Mercurial repository here "
1470 raise util.Abort(_("there is no Mercurial repository here "
1471 "(.hg not found)"))
1471 "(.hg not found)"))
1472 rev1, rev2 = args
1472 rev1, rev2 = args
1473 r = repo.changelog
1473 r = repo.changelog
1474 lookup = repo.lookup
1474 lookup = repo.lookup
1475 else:
1475 else:
1476 raise util.Abort(_('either two or three arguments required'))
1476 raise util.Abort(_('either two or three arguments required'))
1477 a = r.ancestor(lookup(rev1), lookup(rev2))
1477 a = r.ancestor(lookup(rev1), lookup(rev2))
1478 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1478 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1479
1479
1480 @command('debugbuilddag',
1480 @command('debugbuilddag',
1481 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1481 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1482 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1482 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1483 ('n', 'new-file', None, _('add new file at each rev'))],
1483 ('n', 'new-file', None, _('add new file at each rev'))],
1484 _('[OPTION]... [TEXT]'))
1484 _('[OPTION]... [TEXT]'))
1485 def debugbuilddag(ui, repo, text=None,
1485 def debugbuilddag(ui, repo, text=None,
1486 mergeable_file=False,
1486 mergeable_file=False,
1487 overwritten_file=False,
1487 overwritten_file=False,
1488 new_file=False):
1488 new_file=False):
1489 """builds a repo with a given DAG from scratch in the current empty repo
1489 """builds a repo with a given DAG from scratch in the current empty repo
1490
1490
1491 The description of the DAG is read from stdin if not given on the
1491 The description of the DAG is read from stdin if not given on the
1492 command line.
1492 command line.
1493
1493
1494 Elements:
1494 Elements:
1495
1495
1496 - "+n" is a linear run of n nodes based on the current default parent
1496 - "+n" is a linear run of n nodes based on the current default parent
1497 - "." is a single node based on the current default parent
1497 - "." is a single node based on the current default parent
1498 - "$" resets the default parent to null (implied at the start);
1498 - "$" resets the default parent to null (implied at the start);
1499 otherwise the default parent is always the last node created
1499 otherwise the default parent is always the last node created
1500 - "<p" sets the default parent to the backref p
1500 - "<p" sets the default parent to the backref p
1501 - "*p" is a fork at parent p, which is a backref
1501 - "*p" is a fork at parent p, which is a backref
1502 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1502 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1503 - "/p2" is a merge of the preceding node and p2
1503 - "/p2" is a merge of the preceding node and p2
1504 - ":tag" defines a local tag for the preceding node
1504 - ":tag" defines a local tag for the preceding node
1505 - "@branch" sets the named branch for subsequent nodes
1505 - "@branch" sets the named branch for subsequent nodes
1506 - "#...\\n" is a comment up to the end of the line
1506 - "#...\\n" is a comment up to the end of the line
1507
1507
1508 Whitespace between the above elements is ignored.
1508 Whitespace between the above elements is ignored.
1509
1509
1510 A backref is either
1510 A backref is either
1511
1511
1512 - a number n, which references the node curr-n, where curr is the current
1512 - a number n, which references the node curr-n, where curr is the current
1513 node, or
1513 node, or
1514 - the name of a local tag you placed earlier using ":tag", or
1514 - the name of a local tag you placed earlier using ":tag", or
1515 - empty to denote the default parent.
1515 - empty to denote the default parent.
1516
1516
1517 All string valued-elements are either strictly alphanumeric, or must
1517 All string valued-elements are either strictly alphanumeric, or must
1518 be enclosed in double quotes ("..."), with "\\" as escape character.
1518 be enclosed in double quotes ("..."), with "\\" as escape character.
1519 """
1519 """
1520
1520
1521 if text is None:
1521 if text is None:
1522 ui.status(_("reading DAG from stdin\n"))
1522 ui.status(_("reading DAG from stdin\n"))
1523 text = ui.fin.read()
1523 text = ui.fin.read()
1524
1524
1525 cl = repo.changelog
1525 cl = repo.changelog
1526 if len(cl) > 0:
1526 if len(cl) > 0:
1527 raise util.Abort(_('repository is not empty'))
1527 raise util.Abort(_('repository is not empty'))
1528
1528
1529 # determine number of revs in DAG
1529 # determine number of revs in DAG
1530 total = 0
1530 total = 0
1531 for type, data in dagparser.parsedag(text):
1531 for type, data in dagparser.parsedag(text):
1532 if type == 'n':
1532 if type == 'n':
1533 total += 1
1533 total += 1
1534
1534
1535 if mergeable_file:
1535 if mergeable_file:
1536 linesperrev = 2
1536 linesperrev = 2
1537 # make a file with k lines per rev
1537 # make a file with k lines per rev
1538 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1538 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1539 initialmergedlines.append("")
1539 initialmergedlines.append("")
1540
1540
1541 tags = []
1541 tags = []
1542
1542
1543 lock = tr = None
1543 lock = tr = None
1544 try:
1544 try:
1545 lock = repo.lock()
1545 lock = repo.lock()
1546 tr = repo.transaction("builddag")
1546 tr = repo.transaction("builddag")
1547
1547
1548 at = -1
1548 at = -1
1549 atbranch = 'default'
1549 atbranch = 'default'
1550 nodeids = []
1550 nodeids = []
1551 id = 0
1551 id = 0
1552 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1552 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1553 for type, data in dagparser.parsedag(text):
1553 for type, data in dagparser.parsedag(text):
1554 if type == 'n':
1554 if type == 'n':
1555 ui.note(('node %s\n' % str(data)))
1555 ui.note(('node %s\n' % str(data)))
1556 id, ps = data
1556 id, ps = data
1557
1557
1558 files = []
1558 files = []
1559 fctxs = {}
1559 fctxs = {}
1560
1560
1561 p2 = None
1561 p2 = None
1562 if mergeable_file:
1562 if mergeable_file:
1563 fn = "mf"
1563 fn = "mf"
1564 p1 = repo[ps[0]]
1564 p1 = repo[ps[0]]
1565 if len(ps) > 1:
1565 if len(ps) > 1:
1566 p2 = repo[ps[1]]
1566 p2 = repo[ps[1]]
1567 pa = p1.ancestor(p2)
1567 pa = p1.ancestor(p2)
1568 base, local, other = [x[fn].data() for x in (pa, p1,
1568 base, local, other = [x[fn].data() for x in (pa, p1,
1569 p2)]
1569 p2)]
1570 m3 = simplemerge.Merge3Text(base, local, other)
1570 m3 = simplemerge.Merge3Text(base, local, other)
1571 ml = [l.strip() for l in m3.merge_lines()]
1571 ml = [l.strip() for l in m3.merge_lines()]
1572 ml.append("")
1572 ml.append("")
1573 elif at > 0:
1573 elif at > 0:
1574 ml = p1[fn].data().split("\n")
1574 ml = p1[fn].data().split("\n")
1575 else:
1575 else:
1576 ml = initialmergedlines
1576 ml = initialmergedlines
1577 ml[id * linesperrev] += " r%i" % id
1577 ml[id * linesperrev] += " r%i" % id
1578 mergedtext = "\n".join(ml)
1578 mergedtext = "\n".join(ml)
1579 files.append(fn)
1579 files.append(fn)
1580 fctxs[fn] = context.memfilectx(fn, mergedtext)
1580 fctxs[fn] = context.memfilectx(fn, mergedtext)
1581
1581
1582 if overwritten_file:
1582 if overwritten_file:
1583 fn = "of"
1583 fn = "of"
1584 files.append(fn)
1584 files.append(fn)
1585 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1585 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1586
1586
1587 if new_file:
1587 if new_file:
1588 fn = "nf%i" % id
1588 fn = "nf%i" % id
1589 files.append(fn)
1589 files.append(fn)
1590 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1590 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1591 if len(ps) > 1:
1591 if len(ps) > 1:
1592 if not p2:
1592 if not p2:
1593 p2 = repo[ps[1]]
1593 p2 = repo[ps[1]]
1594 for fn in p2:
1594 for fn in p2:
1595 if fn.startswith("nf"):
1595 if fn.startswith("nf"):
1596 files.append(fn)
1596 files.append(fn)
1597 fctxs[fn] = p2[fn]
1597 fctxs[fn] = p2[fn]
1598
1598
1599 def fctxfn(repo, cx, path):
1599 def fctxfn(repo, cx, path):
1600 return fctxs.get(path)
1600 return fctxs.get(path)
1601
1601
1602 if len(ps) == 0 or ps[0] < 0:
1602 if len(ps) == 0 or ps[0] < 0:
1603 pars = [None, None]
1603 pars = [None, None]
1604 elif len(ps) == 1:
1604 elif len(ps) == 1:
1605 pars = [nodeids[ps[0]], None]
1605 pars = [nodeids[ps[0]], None]
1606 else:
1606 else:
1607 pars = [nodeids[p] for p in ps]
1607 pars = [nodeids[p] for p in ps]
1608 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1608 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1609 date=(id, 0),
1609 date=(id, 0),
1610 user="debugbuilddag",
1610 user="debugbuilddag",
1611 extra={'branch': atbranch})
1611 extra={'branch': atbranch})
1612 nodeid = repo.commitctx(cx)
1612 nodeid = repo.commitctx(cx)
1613 nodeids.append(nodeid)
1613 nodeids.append(nodeid)
1614 at = id
1614 at = id
1615 elif type == 'l':
1615 elif type == 'l':
1616 id, name = data
1616 id, name = data
1617 ui.note(('tag %s\n' % name))
1617 ui.note(('tag %s\n' % name))
1618 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1618 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1619 elif type == 'a':
1619 elif type == 'a':
1620 ui.note(('branch %s\n' % data))
1620 ui.note(('branch %s\n' % data))
1621 atbranch = data
1621 atbranch = data
1622 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1622 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1623 tr.close()
1623 tr.close()
1624
1624
1625 if tags:
1625 if tags:
1626 repo.opener.write("localtags", "".join(tags))
1626 repo.opener.write("localtags", "".join(tags))
1627 finally:
1627 finally:
1628 ui.progress(_('building'), None)
1628 ui.progress(_('building'), None)
1629 release(tr, lock)
1629 release(tr, lock)
1630
1630
1631 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1631 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1632 def debugbundle(ui, bundlepath, all=None, **opts):
1632 def debugbundle(ui, bundlepath, all=None, **opts):
1633 """lists the contents of a bundle"""
1633 """lists the contents of a bundle"""
1634 f = hg.openpath(ui, bundlepath)
1634 f = hg.openpath(ui, bundlepath)
1635 try:
1635 try:
1636 gen = changegroup.readbundle(f, bundlepath)
1636 gen = changegroup.readbundle(f, bundlepath)
1637 if all:
1637 if all:
1638 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1638 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1639
1639
1640 def showchunks(named):
1640 def showchunks(named):
1641 ui.write("\n%s\n" % named)
1641 ui.write("\n%s\n" % named)
1642 chain = None
1642 chain = None
1643 while True:
1643 while True:
1644 chunkdata = gen.deltachunk(chain)
1644 chunkdata = gen.deltachunk(chain)
1645 if not chunkdata:
1645 if not chunkdata:
1646 break
1646 break
1647 node = chunkdata['node']
1647 node = chunkdata['node']
1648 p1 = chunkdata['p1']
1648 p1 = chunkdata['p1']
1649 p2 = chunkdata['p2']
1649 p2 = chunkdata['p2']
1650 cs = chunkdata['cs']
1650 cs = chunkdata['cs']
1651 deltabase = chunkdata['deltabase']
1651 deltabase = chunkdata['deltabase']
1652 delta = chunkdata['delta']
1652 delta = chunkdata['delta']
1653 ui.write("%s %s %s %s %s %s\n" %
1653 ui.write("%s %s %s %s %s %s\n" %
1654 (hex(node), hex(p1), hex(p2),
1654 (hex(node), hex(p1), hex(p2),
1655 hex(cs), hex(deltabase), len(delta)))
1655 hex(cs), hex(deltabase), len(delta)))
1656 chain = node
1656 chain = node
1657
1657
1658 chunkdata = gen.changelogheader()
1658 chunkdata = gen.changelogheader()
1659 showchunks("changelog")
1659 showchunks("changelog")
1660 chunkdata = gen.manifestheader()
1660 chunkdata = gen.manifestheader()
1661 showchunks("manifest")
1661 showchunks("manifest")
1662 while True:
1662 while True:
1663 chunkdata = gen.filelogheader()
1663 chunkdata = gen.filelogheader()
1664 if not chunkdata:
1664 if not chunkdata:
1665 break
1665 break
1666 fname = chunkdata['filename']
1666 fname = chunkdata['filename']
1667 showchunks(fname)
1667 showchunks(fname)
1668 else:
1668 else:
1669 chunkdata = gen.changelogheader()
1669 chunkdata = gen.changelogheader()
1670 chain = None
1670 chain = None
1671 while True:
1671 while True:
1672 chunkdata = gen.deltachunk(chain)
1672 chunkdata = gen.deltachunk(chain)
1673 if not chunkdata:
1673 if not chunkdata:
1674 break
1674 break
1675 node = chunkdata['node']
1675 node = chunkdata['node']
1676 ui.write("%s\n" % hex(node))
1676 ui.write("%s\n" % hex(node))
1677 chain = node
1677 chain = node
1678 finally:
1678 finally:
1679 f.close()
1679 f.close()
1680
1680
1681 @command('debugcheckstate', [], '')
1681 @command('debugcheckstate', [], '')
1682 def debugcheckstate(ui, repo):
1682 def debugcheckstate(ui, repo):
1683 """validate the correctness of the current dirstate"""
1683 """validate the correctness of the current dirstate"""
1684 parent1, parent2 = repo.dirstate.parents()
1684 parent1, parent2 = repo.dirstate.parents()
1685 m1 = repo[parent1].manifest()
1685 m1 = repo[parent1].manifest()
1686 m2 = repo[parent2].manifest()
1686 m2 = repo[parent2].manifest()
1687 errors = 0
1687 errors = 0
1688 for f in repo.dirstate:
1688 for f in repo.dirstate:
1689 state = repo.dirstate[f]
1689 state = repo.dirstate[f]
1690 if state in "nr" and f not in m1:
1690 if state in "nr" and f not in m1:
1691 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1691 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1692 errors += 1
1692 errors += 1
1693 if state in "a" and f in m1:
1693 if state in "a" and f in m1:
1694 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1694 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1695 errors += 1
1695 errors += 1
1696 if state in "m" and f not in m1 and f not in m2:
1696 if state in "m" and f not in m1 and f not in m2:
1697 ui.warn(_("%s in state %s, but not in either manifest\n") %
1697 ui.warn(_("%s in state %s, but not in either manifest\n") %
1698 (f, state))
1698 (f, state))
1699 errors += 1
1699 errors += 1
1700 for f in m1:
1700 for f in m1:
1701 state = repo.dirstate[f]
1701 state = repo.dirstate[f]
1702 if state not in "nrm":
1702 if state not in "nrm":
1703 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1703 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1704 errors += 1
1704 errors += 1
1705 if errors:
1705 if errors:
1706 error = _(".hg/dirstate inconsistent with current parent's manifest")
1706 error = _(".hg/dirstate inconsistent with current parent's manifest")
1707 raise util.Abort(error)
1707 raise util.Abort(error)
1708
1708
1709 @command('debugcommands', [], _('[COMMAND]'))
1709 @command('debugcommands', [], _('[COMMAND]'))
1710 def debugcommands(ui, cmd='', *args):
1710 def debugcommands(ui, cmd='', *args):
1711 """list all available commands and options"""
1711 """list all available commands and options"""
1712 for cmd, vals in sorted(table.iteritems()):
1712 for cmd, vals in sorted(table.iteritems()):
1713 cmd = cmd.split('|')[0].strip('^')
1713 cmd = cmd.split('|')[0].strip('^')
1714 opts = ', '.join([i[1] for i in vals[1]])
1714 opts = ', '.join([i[1] for i in vals[1]])
1715 ui.write('%s: %s\n' % (cmd, opts))
1715 ui.write('%s: %s\n' % (cmd, opts))
1716
1716
1717 @command('debugcomplete',
1717 @command('debugcomplete',
1718 [('o', 'options', None, _('show the command options'))],
1718 [('o', 'options', None, _('show the command options'))],
1719 _('[-o] CMD'))
1719 _('[-o] CMD'))
1720 def debugcomplete(ui, cmd='', **opts):
1720 def debugcomplete(ui, cmd='', **opts):
1721 """returns the completion list associated with the given command"""
1721 """returns the completion list associated with the given command"""
1722
1722
1723 if opts.get('options'):
1723 if opts.get('options'):
1724 options = []
1724 options = []
1725 otables = [globalopts]
1725 otables = [globalopts]
1726 if cmd:
1726 if cmd:
1727 aliases, entry = cmdutil.findcmd(cmd, table, False)
1727 aliases, entry = cmdutil.findcmd(cmd, table, False)
1728 otables.append(entry[1])
1728 otables.append(entry[1])
1729 for t in otables:
1729 for t in otables:
1730 for o in t:
1730 for o in t:
1731 if "(DEPRECATED)" in o[3]:
1731 if "(DEPRECATED)" in o[3]:
1732 continue
1732 continue
1733 if o[0]:
1733 if o[0]:
1734 options.append('-%s' % o[0])
1734 options.append('-%s' % o[0])
1735 options.append('--%s' % o[1])
1735 options.append('--%s' % o[1])
1736 ui.write("%s\n" % "\n".join(options))
1736 ui.write("%s\n" % "\n".join(options))
1737 return
1737 return
1738
1738
1739 cmdlist = cmdutil.findpossible(cmd, table)
1739 cmdlist = cmdutil.findpossible(cmd, table)
1740 if ui.verbose:
1740 if ui.verbose:
1741 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1741 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1742 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1742 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1743
1743
1744 @command('debugdag',
1744 @command('debugdag',
1745 [('t', 'tags', None, _('use tags as labels')),
1745 [('t', 'tags', None, _('use tags as labels')),
1746 ('b', 'branches', None, _('annotate with branch names')),
1746 ('b', 'branches', None, _('annotate with branch names')),
1747 ('', 'dots', None, _('use dots for runs')),
1747 ('', 'dots', None, _('use dots for runs')),
1748 ('s', 'spaces', None, _('separate elements by spaces'))],
1748 ('s', 'spaces', None, _('separate elements by spaces'))],
1749 _('[OPTION]... [FILE [REV]...]'))
1749 _('[OPTION]... [FILE [REV]...]'))
1750 def debugdag(ui, repo, file_=None, *revs, **opts):
1750 def debugdag(ui, repo, file_=None, *revs, **opts):
1751 """format the changelog or an index DAG as a concise textual description
1751 """format the changelog or an index DAG as a concise textual description
1752
1752
1753 If you pass a revlog index, the revlog's DAG is emitted. If you list
1753 If you pass a revlog index, the revlog's DAG is emitted. If you list
1754 revision numbers, they get labeled in the output as rN.
1754 revision numbers, they get labeled in the output as rN.
1755
1755
1756 Otherwise, the changelog DAG of the current repo is emitted.
1756 Otherwise, the changelog DAG of the current repo is emitted.
1757 """
1757 """
1758 spaces = opts.get('spaces')
1758 spaces = opts.get('spaces')
1759 dots = opts.get('dots')
1759 dots = opts.get('dots')
1760 if file_:
1760 if file_:
1761 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1761 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1762 revs = set((int(r) for r in revs))
1762 revs = set((int(r) for r in revs))
1763 def events():
1763 def events():
1764 for r in rlog:
1764 for r in rlog:
1765 yield 'n', (r, list(set(p for p in rlog.parentrevs(r)
1765 yield 'n', (r, list(set(p for p in rlog.parentrevs(r)
1766 if p != -1)))
1766 if p != -1)))
1767 if r in revs:
1767 if r in revs:
1768 yield 'l', (r, "r%i" % r)
1768 yield 'l', (r, "r%i" % r)
1769 elif repo:
1769 elif repo:
1770 cl = repo.changelog
1770 cl = repo.changelog
1771 tags = opts.get('tags')
1771 tags = opts.get('tags')
1772 branches = opts.get('branches')
1772 branches = opts.get('branches')
1773 if tags:
1773 if tags:
1774 labels = {}
1774 labels = {}
1775 for l, n in repo.tags().items():
1775 for l, n in repo.tags().items():
1776 labels.setdefault(cl.rev(n), []).append(l)
1776 labels.setdefault(cl.rev(n), []).append(l)
1777 def events():
1777 def events():
1778 b = "default"
1778 b = "default"
1779 for r in cl:
1779 for r in cl:
1780 if branches:
1780 if branches:
1781 newb = cl.read(cl.node(r))[5]['branch']
1781 newb = cl.read(cl.node(r))[5]['branch']
1782 if newb != b:
1782 if newb != b:
1783 yield 'a', newb
1783 yield 'a', newb
1784 b = newb
1784 b = newb
1785 yield 'n', (r, list(set(p for p in cl.parentrevs(r)
1785 yield 'n', (r, list(set(p for p in cl.parentrevs(r)
1786 if p != -1)))
1786 if p != -1)))
1787 if tags:
1787 if tags:
1788 ls = labels.get(r)
1788 ls = labels.get(r)
1789 if ls:
1789 if ls:
1790 for l in ls:
1790 for l in ls:
1791 yield 'l', (r, l)
1791 yield 'l', (r, l)
1792 else:
1792 else:
1793 raise util.Abort(_('need repo for changelog dag'))
1793 raise util.Abort(_('need repo for changelog dag'))
1794
1794
1795 for line in dagparser.dagtextlines(events(),
1795 for line in dagparser.dagtextlines(events(),
1796 addspaces=spaces,
1796 addspaces=spaces,
1797 wraplabels=True,
1797 wraplabels=True,
1798 wrapannotations=True,
1798 wrapannotations=True,
1799 wrapnonlinear=dots,
1799 wrapnonlinear=dots,
1800 usedots=dots,
1800 usedots=dots,
1801 maxlinewidth=70):
1801 maxlinewidth=70):
1802 ui.write(line)
1802 ui.write(line)
1803 ui.write("\n")
1803 ui.write("\n")
1804
1804
1805 @command('debugdata',
1805 @command('debugdata',
1806 [('c', 'changelog', False, _('open changelog')),
1806 [('c', 'changelog', False, _('open changelog')),
1807 ('m', 'manifest', False, _('open manifest'))],
1807 ('m', 'manifest', False, _('open manifest'))],
1808 _('-c|-m|FILE REV'))
1808 _('-c|-m|FILE REV'))
1809 def debugdata(ui, repo, file_, rev = None, **opts):
1809 def debugdata(ui, repo, file_, rev = None, **opts):
1810 """dump the contents of a data file revision"""
1810 """dump the contents of a data file revision"""
1811 if opts.get('changelog') or opts.get('manifest'):
1811 if opts.get('changelog') or opts.get('manifest'):
1812 file_, rev = None, file_
1812 file_, rev = None, file_
1813 elif rev is None:
1813 elif rev is None:
1814 raise error.CommandError('debugdata', _('invalid arguments'))
1814 raise error.CommandError('debugdata', _('invalid arguments'))
1815 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1815 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1816 try:
1816 try:
1817 ui.write(r.revision(r.lookup(rev)))
1817 ui.write(r.revision(r.lookup(rev)))
1818 except KeyError:
1818 except KeyError:
1819 raise util.Abort(_('invalid revision identifier %s') % rev)
1819 raise util.Abort(_('invalid revision identifier %s') % rev)
1820
1820
1821 @command('debugdate',
1821 @command('debugdate',
1822 [('e', 'extended', None, _('try extended date formats'))],
1822 [('e', 'extended', None, _('try extended date formats'))],
1823 _('[-e] DATE [RANGE]'))
1823 _('[-e] DATE [RANGE]'))
1824 def debugdate(ui, date, range=None, **opts):
1824 def debugdate(ui, date, range=None, **opts):
1825 """parse and display a date"""
1825 """parse and display a date"""
1826 if opts["extended"]:
1826 if opts["extended"]:
1827 d = util.parsedate(date, util.extendeddateformats)
1827 d = util.parsedate(date, util.extendeddateformats)
1828 else:
1828 else:
1829 d = util.parsedate(date)
1829 d = util.parsedate(date)
1830 ui.write(("internal: %s %s\n") % d)
1830 ui.write(("internal: %s %s\n") % d)
1831 ui.write(("standard: %s\n") % util.datestr(d))
1831 ui.write(("standard: %s\n") % util.datestr(d))
1832 if range:
1832 if range:
1833 m = util.matchdate(range)
1833 m = util.matchdate(range)
1834 ui.write(("match: %s\n") % m(d[0]))
1834 ui.write(("match: %s\n") % m(d[0]))
1835
1835
1836 @command('debugdiscovery',
1836 @command('debugdiscovery',
1837 [('', 'old', None, _('use old-style discovery')),
1837 [('', 'old', None, _('use old-style discovery')),
1838 ('', 'nonheads', None,
1838 ('', 'nonheads', None,
1839 _('use old-style discovery with non-heads included')),
1839 _('use old-style discovery with non-heads included')),
1840 ] + remoteopts,
1840 ] + remoteopts,
1841 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
1841 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
1842 def debugdiscovery(ui, repo, remoteurl="default", **opts):
1842 def debugdiscovery(ui, repo, remoteurl="default", **opts):
1843 """runs the changeset discovery protocol in isolation"""
1843 """runs the changeset discovery protocol in isolation"""
1844 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
1844 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
1845 opts.get('branch'))
1845 opts.get('branch'))
1846 remote = hg.peer(repo, opts, remoteurl)
1846 remote = hg.peer(repo, opts, remoteurl)
1847 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
1847 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
1848
1848
1849 # make sure tests are repeatable
1849 # make sure tests are repeatable
1850 random.seed(12323)
1850 random.seed(12323)
1851
1851
1852 def doit(localheads, remoteheads, remote=remote):
1852 def doit(localheads, remoteheads, remote=remote):
1853 if opts.get('old'):
1853 if opts.get('old'):
1854 if localheads:
1854 if localheads:
1855 raise util.Abort('cannot use localheads with old style '
1855 raise util.Abort('cannot use localheads with old style '
1856 'discovery')
1856 'discovery')
1857 if not util.safehasattr(remote, 'branches'):
1857 if not util.safehasattr(remote, 'branches'):
1858 # enable in-client legacy support
1858 # enable in-client legacy support
1859 remote = localrepo.locallegacypeer(remote.local())
1859 remote = localrepo.locallegacypeer(remote.local())
1860 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
1860 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
1861 force=True)
1861 force=True)
1862 common = set(common)
1862 common = set(common)
1863 if not opts.get('nonheads'):
1863 if not opts.get('nonheads'):
1864 ui.write(("unpruned common: %s\n") %
1864 ui.write(("unpruned common: %s\n") %
1865 " ".join(sorted(short(n) for n in common)))
1865 " ".join(sorted(short(n) for n in common)))
1866 dag = dagutil.revlogdag(repo.changelog)
1866 dag = dagutil.revlogdag(repo.changelog)
1867 all = dag.ancestorset(dag.internalizeall(common))
1867 all = dag.ancestorset(dag.internalizeall(common))
1868 common = dag.externalizeall(dag.headsetofconnecteds(all))
1868 common = dag.externalizeall(dag.headsetofconnecteds(all))
1869 else:
1869 else:
1870 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
1870 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
1871 common = set(common)
1871 common = set(common)
1872 rheads = set(hds)
1872 rheads = set(hds)
1873 lheads = set(repo.heads())
1873 lheads = set(repo.heads())
1874 ui.write(("common heads: %s\n") %
1874 ui.write(("common heads: %s\n") %
1875 " ".join(sorted(short(n) for n in common)))
1875 " ".join(sorted(short(n) for n in common)))
1876 if lheads <= common:
1876 if lheads <= common:
1877 ui.write(("local is subset\n"))
1877 ui.write(("local is subset\n"))
1878 elif rheads <= common:
1878 elif rheads <= common:
1879 ui.write(("remote is subset\n"))
1879 ui.write(("remote is subset\n"))
1880
1880
1881 serverlogs = opts.get('serverlog')
1881 serverlogs = opts.get('serverlog')
1882 if serverlogs:
1882 if serverlogs:
1883 for filename in serverlogs:
1883 for filename in serverlogs:
1884 logfile = open(filename, 'r')
1884 logfile = open(filename, 'r')
1885 try:
1885 try:
1886 line = logfile.readline()
1886 line = logfile.readline()
1887 while line:
1887 while line:
1888 parts = line.strip().split(';')
1888 parts = line.strip().split(';')
1889 op = parts[1]
1889 op = parts[1]
1890 if op == 'cg':
1890 if op == 'cg':
1891 pass
1891 pass
1892 elif op == 'cgss':
1892 elif op == 'cgss':
1893 doit(parts[2].split(' '), parts[3].split(' '))
1893 doit(parts[2].split(' '), parts[3].split(' '))
1894 elif op == 'unb':
1894 elif op == 'unb':
1895 doit(parts[3].split(' '), parts[2].split(' '))
1895 doit(parts[3].split(' '), parts[2].split(' '))
1896 line = logfile.readline()
1896 line = logfile.readline()
1897 finally:
1897 finally:
1898 logfile.close()
1898 logfile.close()
1899
1899
1900 else:
1900 else:
1901 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
1901 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
1902 opts.get('remote_head'))
1902 opts.get('remote_head'))
1903 localrevs = opts.get('local_head')
1903 localrevs = opts.get('local_head')
1904 doit(localrevs, remoterevs)
1904 doit(localrevs, remoterevs)
1905
1905
1906 @command('debugfileset',
1906 @command('debugfileset',
1907 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
1907 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
1908 _('[-r REV] FILESPEC'))
1908 _('[-r REV] FILESPEC'))
1909 def debugfileset(ui, repo, expr, **opts):
1909 def debugfileset(ui, repo, expr, **opts):
1910 '''parse and apply a fileset specification'''
1910 '''parse and apply a fileset specification'''
1911 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
1911 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
1912 if ui.verbose:
1912 if ui.verbose:
1913 tree = fileset.parse(expr)[0]
1913 tree = fileset.parse(expr)[0]
1914 ui.note(tree, "\n")
1914 ui.note(tree, "\n")
1915
1915
1916 for f in fileset.getfileset(ctx, expr):
1916 for f in fileset.getfileset(ctx, expr):
1917 ui.write("%s\n" % f)
1917 ui.write("%s\n" % f)
1918
1918
1919 @command('debugfsinfo', [], _('[PATH]'))
1919 @command('debugfsinfo', [], _('[PATH]'))
1920 def debugfsinfo(ui, path = "."):
1920 def debugfsinfo(ui, path = "."):
1921 """show information detected about current filesystem"""
1921 """show information detected about current filesystem"""
1922 util.writefile('.debugfsinfo', '')
1922 util.writefile('.debugfsinfo', '')
1923 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
1923 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
1924 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
1924 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
1925 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
1925 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
1926 and 'yes' or 'no'))
1926 and 'yes' or 'no'))
1927 os.unlink('.debugfsinfo')
1927 os.unlink('.debugfsinfo')
1928
1928
1929 @command('debuggetbundle',
1929 @command('debuggetbundle',
1930 [('H', 'head', [], _('id of head node'), _('ID')),
1930 [('H', 'head', [], _('id of head node'), _('ID')),
1931 ('C', 'common', [], _('id of common node'), _('ID')),
1931 ('C', 'common', [], _('id of common node'), _('ID')),
1932 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
1932 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
1933 _('REPO FILE [-H|-C ID]...'))
1933 _('REPO FILE [-H|-C ID]...'))
1934 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1934 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1935 """retrieves a bundle from a repo
1935 """retrieves a bundle from a repo
1936
1936
1937 Every ID must be a full-length hex node id string. Saves the bundle to the
1937 Every ID must be a full-length hex node id string. Saves the bundle to the
1938 given file.
1938 given file.
1939 """
1939 """
1940 repo = hg.peer(ui, opts, repopath)
1940 repo = hg.peer(ui, opts, repopath)
1941 if not repo.capable('getbundle'):
1941 if not repo.capable('getbundle'):
1942 raise util.Abort("getbundle() not supported by target repository")
1942 raise util.Abort("getbundle() not supported by target repository")
1943 args = {}
1943 args = {}
1944 if common:
1944 if common:
1945 args['common'] = [bin(s) for s in common]
1945 args['common'] = [bin(s) for s in common]
1946 if head:
1946 if head:
1947 args['heads'] = [bin(s) for s in head]
1947 args['heads'] = [bin(s) for s in head]
1948 # TODO: get desired bundlecaps from command line.
1948 # TODO: get desired bundlecaps from command line.
1949 args['bundlecaps'] = None
1949 args['bundlecaps'] = None
1950 bundle = repo.getbundle('debug', **args)
1950 bundle = repo.getbundle('debug', **args)
1951
1951
1952 bundletype = opts.get('type', 'bzip2').lower()
1952 bundletype = opts.get('type', 'bzip2').lower()
1953 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1953 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1954 bundletype = btypes.get(bundletype)
1954 bundletype = btypes.get(bundletype)
1955 if bundletype not in changegroup.bundletypes:
1955 if bundletype not in changegroup.bundletypes:
1956 raise util.Abort(_('unknown bundle type specified with --type'))
1956 raise util.Abort(_('unknown bundle type specified with --type'))
1957 changegroup.writebundle(bundle, bundlepath, bundletype)
1957 changegroup.writebundle(bundle, bundlepath, bundletype)
1958
1958
1959 @command('debugignore', [], '')
1959 @command('debugignore', [], '')
1960 def debugignore(ui, repo, *values, **opts):
1960 def debugignore(ui, repo, *values, **opts):
1961 """display the combined ignore pattern"""
1961 """display the combined ignore pattern"""
1962 ignore = repo.dirstate._ignore
1962 ignore = repo.dirstate._ignore
1963 includepat = getattr(ignore, 'includepat', None)
1963 includepat = getattr(ignore, 'includepat', None)
1964 if includepat is not None:
1964 if includepat is not None:
1965 ui.write("%s\n" % includepat)
1965 ui.write("%s\n" % includepat)
1966 else:
1966 else:
1967 raise util.Abort(_("no ignore patterns found"))
1967 raise util.Abort(_("no ignore patterns found"))
1968
1968
1969 @command('debugindex',
1969 @command('debugindex',
1970 [('c', 'changelog', False, _('open changelog')),
1970 [('c', 'changelog', False, _('open changelog')),
1971 ('m', 'manifest', False, _('open manifest')),
1971 ('m', 'manifest', False, _('open manifest')),
1972 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1972 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1973 _('[-f FORMAT] -c|-m|FILE'))
1973 _('[-f FORMAT] -c|-m|FILE'))
1974 def debugindex(ui, repo, file_ = None, **opts):
1974 def debugindex(ui, repo, file_ = None, **opts):
1975 """dump the contents of an index file"""
1975 """dump the contents of an index file"""
1976 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1976 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1977 format = opts.get('format', 0)
1977 format = opts.get('format', 0)
1978 if format not in (0, 1):
1978 if format not in (0, 1):
1979 raise util.Abort(_("unknown format %d") % format)
1979 raise util.Abort(_("unknown format %d") % format)
1980
1980
1981 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1981 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1982 if generaldelta:
1982 if generaldelta:
1983 basehdr = ' delta'
1983 basehdr = ' delta'
1984 else:
1984 else:
1985 basehdr = ' base'
1985 basehdr = ' base'
1986
1986
1987 if format == 0:
1987 if format == 0:
1988 ui.write(" rev offset length " + basehdr + " linkrev"
1988 ui.write(" rev offset length " + basehdr + " linkrev"
1989 " nodeid p1 p2\n")
1989 " nodeid p1 p2\n")
1990 elif format == 1:
1990 elif format == 1:
1991 ui.write(" rev flag offset length"
1991 ui.write(" rev flag offset length"
1992 " size " + basehdr + " link p1 p2"
1992 " size " + basehdr + " link p1 p2"
1993 " nodeid\n")
1993 " nodeid\n")
1994
1994
1995 for i in r:
1995 for i in r:
1996 node = r.node(i)
1996 node = r.node(i)
1997 if generaldelta:
1997 if generaldelta:
1998 base = r.deltaparent(i)
1998 base = r.deltaparent(i)
1999 else:
1999 else:
2000 base = r.chainbase(i)
2000 base = r.chainbase(i)
2001 if format == 0:
2001 if format == 0:
2002 try:
2002 try:
2003 pp = r.parents(node)
2003 pp = r.parents(node)
2004 except Exception:
2004 except Exception:
2005 pp = [nullid, nullid]
2005 pp = [nullid, nullid]
2006 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2006 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2007 i, r.start(i), r.length(i), base, r.linkrev(i),
2007 i, r.start(i), r.length(i), base, r.linkrev(i),
2008 short(node), short(pp[0]), short(pp[1])))
2008 short(node), short(pp[0]), short(pp[1])))
2009 elif format == 1:
2009 elif format == 1:
2010 pr = r.parentrevs(i)
2010 pr = r.parentrevs(i)
2011 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2011 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2012 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2012 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2013 base, r.linkrev(i), pr[0], pr[1], short(node)))
2013 base, r.linkrev(i), pr[0], pr[1], short(node)))
2014
2014
2015 @command('debugindexdot', [], _('FILE'))
2015 @command('debugindexdot', [], _('FILE'))
2016 def debugindexdot(ui, repo, file_):
2016 def debugindexdot(ui, repo, file_):
2017 """dump an index DAG as a graphviz dot file"""
2017 """dump an index DAG as a graphviz dot file"""
2018 r = None
2018 r = None
2019 if repo:
2019 if repo:
2020 filelog = repo.file(file_)
2020 filelog = repo.file(file_)
2021 if len(filelog):
2021 if len(filelog):
2022 r = filelog
2022 r = filelog
2023 if not r:
2023 if not r:
2024 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2024 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2025 ui.write(("digraph G {\n"))
2025 ui.write(("digraph G {\n"))
2026 for i in r:
2026 for i in r:
2027 node = r.node(i)
2027 node = r.node(i)
2028 pp = r.parents(node)
2028 pp = r.parents(node)
2029 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2029 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2030 if pp[1] != nullid:
2030 if pp[1] != nullid:
2031 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2031 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2032 ui.write("}\n")
2032 ui.write("}\n")
2033
2033
2034 @command('debuginstall', [], '')
2034 @command('debuginstall', [], '')
2035 def debuginstall(ui):
2035 def debuginstall(ui):
2036 '''test Mercurial installation
2036 '''test Mercurial installation
2037
2037
2038 Returns 0 on success.
2038 Returns 0 on success.
2039 '''
2039 '''
2040
2040
2041 def writetemp(contents):
2041 def writetemp(contents):
2042 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2042 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2043 f = os.fdopen(fd, "wb")
2043 f = os.fdopen(fd, "wb")
2044 f.write(contents)
2044 f.write(contents)
2045 f.close()
2045 f.close()
2046 return name
2046 return name
2047
2047
2048 problems = 0
2048 problems = 0
2049
2049
2050 # encoding
2050 # encoding
2051 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2051 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2052 try:
2052 try:
2053 encoding.fromlocal("test")
2053 encoding.fromlocal("test")
2054 except util.Abort, inst:
2054 except util.Abort, inst:
2055 ui.write(" %s\n" % inst)
2055 ui.write(" %s\n" % inst)
2056 ui.write(_(" (check that your locale is properly set)\n"))
2056 ui.write(_(" (check that your locale is properly set)\n"))
2057 problems += 1
2057 problems += 1
2058
2058
2059 # Python lib
2059 # Python lib
2060 ui.status(_("checking Python lib (%s)...\n")
2060 ui.status(_("checking Python lib (%s)...\n")
2061 % os.path.dirname(os.__file__))
2061 % os.path.dirname(os.__file__))
2062
2062
2063 # compiled modules
2063 # compiled modules
2064 ui.status(_("checking installed modules (%s)...\n")
2064 ui.status(_("checking installed modules (%s)...\n")
2065 % os.path.dirname(__file__))
2065 % os.path.dirname(__file__))
2066 try:
2066 try:
2067 import bdiff, mpatch, base85, osutil
2067 import bdiff, mpatch, base85, osutil
2068 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2068 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2069 except Exception, inst:
2069 except Exception, inst:
2070 ui.write(" %s\n" % inst)
2070 ui.write(" %s\n" % inst)
2071 ui.write(_(" One or more extensions could not be found"))
2071 ui.write(_(" One or more extensions could not be found"))
2072 ui.write(_(" (check that you compiled the extensions)\n"))
2072 ui.write(_(" (check that you compiled the extensions)\n"))
2073 problems += 1
2073 problems += 1
2074
2074
2075 # templates
2075 # templates
2076 import templater
2076 import templater
2077 p = templater.templatepath()
2077 p = templater.templatepath()
2078 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2078 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2079 try:
2079 try:
2080 templater.templater(templater.templatepath("map-cmdline.default"))
2080 templater.templater(templater.templatepath("map-cmdline.default"))
2081 except Exception, inst:
2081 except Exception, inst:
2082 ui.write(" %s\n" % inst)
2082 ui.write(" %s\n" % inst)
2083 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2083 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2084 problems += 1
2084 problems += 1
2085
2085
2086 # editor
2086 # editor
2087 ui.status(_("checking commit editor...\n"))
2087 ui.status(_("checking commit editor...\n"))
2088 editor = ui.geteditor()
2088 editor = ui.geteditor()
2089 cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
2089 cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
2090 if not cmdpath:
2090 if not cmdpath:
2091 if editor == 'vi':
2091 if editor == 'vi':
2092 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2092 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2093 ui.write(_(" (specify a commit editor in your configuration"
2093 ui.write(_(" (specify a commit editor in your configuration"
2094 " file)\n"))
2094 " file)\n"))
2095 else:
2095 else:
2096 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2096 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2097 ui.write(_(" (specify a commit editor in your configuration"
2097 ui.write(_(" (specify a commit editor in your configuration"
2098 " file)\n"))
2098 " file)\n"))
2099 problems += 1
2099 problems += 1
2100
2100
2101 # check username
2101 # check username
2102 ui.status(_("checking username...\n"))
2102 ui.status(_("checking username...\n"))
2103 try:
2103 try:
2104 ui.username()
2104 ui.username()
2105 except util.Abort, e:
2105 except util.Abort, e:
2106 ui.write(" %s\n" % e)
2106 ui.write(" %s\n" % e)
2107 ui.write(_(" (specify a username in your configuration file)\n"))
2107 ui.write(_(" (specify a username in your configuration file)\n"))
2108 problems += 1
2108 problems += 1
2109
2109
2110 if not problems:
2110 if not problems:
2111 ui.status(_("no problems detected\n"))
2111 ui.status(_("no problems detected\n"))
2112 else:
2112 else:
2113 ui.write(_("%s problems detected,"
2113 ui.write(_("%s problems detected,"
2114 " please check your install!\n") % problems)
2114 " please check your install!\n") % problems)
2115
2115
2116 return problems
2116 return problems
2117
2117
2118 @command('debugknown', [], _('REPO ID...'))
2118 @command('debugknown', [], _('REPO ID...'))
2119 def debugknown(ui, repopath, *ids, **opts):
2119 def debugknown(ui, repopath, *ids, **opts):
2120 """test whether node ids are known to a repo
2120 """test whether node ids are known to a repo
2121
2121
2122 Every ID must be a full-length hex node id string. Returns a list of 0s
2122 Every ID must be a full-length hex node id string. Returns a list of 0s
2123 and 1s indicating unknown/known.
2123 and 1s indicating unknown/known.
2124 """
2124 """
2125 repo = hg.peer(ui, opts, repopath)
2125 repo = hg.peer(ui, opts, repopath)
2126 if not repo.capable('known'):
2126 if not repo.capable('known'):
2127 raise util.Abort("known() not supported by target repository")
2127 raise util.Abort("known() not supported by target repository")
2128 flags = repo.known([bin(s) for s in ids])
2128 flags = repo.known([bin(s) for s in ids])
2129 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2129 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2130
2130
2131 @command('debuglabelcomplete', [], _('LABEL...'))
2131 @command('debuglabelcomplete', [], _('LABEL...'))
2132 def debuglabelcomplete(ui, repo, *args):
2132 def debuglabelcomplete(ui, repo, *args):
2133 '''complete "labels" - tags, open branch names, bookmark names'''
2133 '''complete "labels" - tags, open branch names, bookmark names'''
2134
2134
2135 labels = set()
2135 labels = set()
2136 labels.update(t[0] for t in repo.tagslist())
2136 labels.update(t[0] for t in repo.tagslist())
2137 labels.update(repo._bookmarks.keys())
2137 labels.update(repo._bookmarks.keys())
2138 for heads in repo.branchmap().itervalues():
2138 for heads in repo.branchmap().itervalues():
2139 for h in heads:
2139 for h in heads:
2140 ctx = repo[h]
2140 ctx = repo[h]
2141 if not ctx.closesbranch():
2141 if not ctx.closesbranch():
2142 labels.add(ctx.branch())
2142 labels.add(ctx.branch())
2143 completions = set()
2143 completions = set()
2144 if not args:
2144 if not args:
2145 args = ['']
2145 args = ['']
2146 for a in args:
2146 for a in args:
2147 completions.update(l for l in labels if l.startswith(a))
2147 completions.update(l for l in labels if l.startswith(a))
2148 ui.write('\n'.join(sorted(completions)))
2148 ui.write('\n'.join(sorted(completions)))
2149 ui.write('\n')
2149 ui.write('\n')
2150
2150
2151 @command('debugobsolete',
2151 @command('debugobsolete',
2152 [('', 'flags', 0, _('markers flag')),
2152 [('', 'flags', 0, _('markers flag')),
2153 ] + commitopts2,
2153 ] + commitopts2,
2154 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2154 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2155 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2155 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2156 """create arbitrary obsolete marker
2156 """create arbitrary obsolete marker
2157
2157
2158 With no arguments, displays the list of obsolescence markers."""
2158 With no arguments, displays the list of obsolescence markers."""
2159 def parsenodeid(s):
2159 def parsenodeid(s):
2160 try:
2160 try:
2161 # We do not use revsingle/revrange functions here to accept
2161 # We do not use revsingle/revrange functions here to accept
2162 # arbitrary node identifiers, possibly not present in the
2162 # arbitrary node identifiers, possibly not present in the
2163 # local repository.
2163 # local repository.
2164 n = bin(s)
2164 n = bin(s)
2165 if len(n) != len(nullid):
2165 if len(n) != len(nullid):
2166 raise TypeError()
2166 raise TypeError()
2167 return n
2167 return n
2168 except TypeError:
2168 except TypeError:
2169 raise util.Abort('changeset references must be full hexadecimal '
2169 raise util.Abort('changeset references must be full hexadecimal '
2170 'node identifiers')
2170 'node identifiers')
2171
2171
2172 if precursor is not None:
2172 if precursor is not None:
2173 metadata = {}
2173 metadata = {}
2174 if 'date' in opts:
2174 if 'date' in opts:
2175 metadata['date'] = opts['date']
2175 metadata['date'] = opts['date']
2176 metadata['user'] = opts['user'] or ui.username()
2176 metadata['user'] = opts['user'] or ui.username()
2177 succs = tuple(parsenodeid(succ) for succ in successors)
2177 succs = tuple(parsenodeid(succ) for succ in successors)
2178 l = repo.lock()
2178 l = repo.lock()
2179 try:
2179 try:
2180 tr = repo.transaction('debugobsolete')
2180 tr = repo.transaction('debugobsolete')
2181 try:
2181 try:
2182 repo.obsstore.create(tr, parsenodeid(precursor), succs,
2182 repo.obsstore.create(tr, parsenodeid(precursor), succs,
2183 opts['flags'], metadata)
2183 opts['flags'], metadata)
2184 tr.close()
2184 tr.close()
2185 finally:
2185 finally:
2186 tr.release()
2186 tr.release()
2187 finally:
2187 finally:
2188 l.release()
2188 l.release()
2189 else:
2189 else:
2190 for m in obsolete.allmarkers(repo):
2190 for m in obsolete.allmarkers(repo):
2191 ui.write(hex(m.precnode()))
2191 ui.write(hex(m.precnode()))
2192 for repl in m.succnodes():
2192 for repl in m.succnodes():
2193 ui.write(' ')
2193 ui.write(' ')
2194 ui.write(hex(repl))
2194 ui.write(hex(repl))
2195 ui.write(' %X ' % m._data[2])
2195 ui.write(' %X ' % m._data[2])
2196 ui.write('{%s}' % (', '.join('%r: %r' % t for t in
2196 ui.write('{%s}' % (', '.join('%r: %r' % t for t in
2197 sorted(m.metadata().items()))))
2197 sorted(m.metadata().items()))))
2198 ui.write('\n')
2198 ui.write('\n')
2199
2199
2200 @command('debugpathcomplete',
2200 @command('debugpathcomplete',
2201 [('f', 'full', None, _('complete an entire path')),
2201 [('f', 'full', None, _('complete an entire path')),
2202 ('n', 'normal', None, _('show only normal files')),
2202 ('n', 'normal', None, _('show only normal files')),
2203 ('a', 'added', None, _('show only added files')),
2203 ('a', 'added', None, _('show only added files')),
2204 ('r', 'removed', None, _('show only removed files'))],
2204 ('r', 'removed', None, _('show only removed files'))],
2205 _('FILESPEC...'))
2205 _('FILESPEC...'))
2206 def debugpathcomplete(ui, repo, *specs, **opts):
2206 def debugpathcomplete(ui, repo, *specs, **opts):
2207 '''complete part or all of a tracked path
2207 '''complete part or all of a tracked path
2208
2208
2209 This command supports shells that offer path name completion. It
2209 This command supports shells that offer path name completion. It
2210 currently completes only files already known to the dirstate.
2210 currently completes only files already known to the dirstate.
2211
2211
2212 Completion extends only to the next path segment unless
2212 Completion extends only to the next path segment unless
2213 --full is specified, in which case entire paths are used.'''
2213 --full is specified, in which case entire paths are used.'''
2214
2214
2215 def complete(path, acceptable):
2215 def complete(path, acceptable):
2216 dirstate = repo.dirstate
2216 dirstate = repo.dirstate
2217 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2217 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2218 rootdir = repo.root + os.sep
2218 rootdir = repo.root + os.sep
2219 if spec != repo.root and not spec.startswith(rootdir):
2219 if spec != repo.root and not spec.startswith(rootdir):
2220 return [], []
2220 return [], []
2221 if os.path.isdir(spec):
2221 if os.path.isdir(spec):
2222 spec += '/'
2222 spec += '/'
2223 spec = spec[len(rootdir):]
2223 spec = spec[len(rootdir):]
2224 fixpaths = os.sep != '/'
2224 fixpaths = os.sep != '/'
2225 if fixpaths:
2225 if fixpaths:
2226 spec = spec.replace(os.sep, '/')
2226 spec = spec.replace(os.sep, '/')
2227 speclen = len(spec)
2227 speclen = len(spec)
2228 fullpaths = opts['full']
2228 fullpaths = opts['full']
2229 files, dirs = set(), set()
2229 files, dirs = set(), set()
2230 adddir, addfile = dirs.add, files.add
2230 adddir, addfile = dirs.add, files.add
2231 for f, st in dirstate.iteritems():
2231 for f, st in dirstate.iteritems():
2232 if f.startswith(spec) and st[0] in acceptable:
2232 if f.startswith(spec) and st[0] in acceptable:
2233 if fixpaths:
2233 if fixpaths:
2234 f = f.replace('/', os.sep)
2234 f = f.replace('/', os.sep)
2235 if fullpaths:
2235 if fullpaths:
2236 addfile(f)
2236 addfile(f)
2237 continue
2237 continue
2238 s = f.find(os.sep, speclen)
2238 s = f.find(os.sep, speclen)
2239 if s >= 0:
2239 if s >= 0:
2240 adddir(f[:s + 1])
2240 adddir(f[:s + 1])
2241 else:
2241 else:
2242 addfile(f)
2242 addfile(f)
2243 return files, dirs
2243 return files, dirs
2244
2244
2245 acceptable = ''
2245 acceptable = ''
2246 if opts['normal']:
2246 if opts['normal']:
2247 acceptable += 'nm'
2247 acceptable += 'nm'
2248 if opts['added']:
2248 if opts['added']:
2249 acceptable += 'a'
2249 acceptable += 'a'
2250 if opts['removed']:
2250 if opts['removed']:
2251 acceptable += 'r'
2251 acceptable += 'r'
2252 cwd = repo.getcwd()
2252 cwd = repo.getcwd()
2253 if not specs:
2253 if not specs:
2254 specs = ['.']
2254 specs = ['.']
2255
2255
2256 files, dirs = set(), set()
2256 files, dirs = set(), set()
2257 for spec in specs:
2257 for spec in specs:
2258 f, d = complete(spec, acceptable or 'nmar')
2258 f, d = complete(spec, acceptable or 'nmar')
2259 files.update(f)
2259 files.update(f)
2260 dirs.update(d)
2260 dirs.update(d)
2261 if not files and len(dirs) == 1:
2261 if not files and len(dirs) == 1:
2262 # force the shell to consider a completion that matches one
2262 # force the shell to consider a completion that matches one
2263 # directory and zero files to be ambiguous
2263 # directory and zero files to be ambiguous
2264 dirs.add(iter(dirs).next() + '.')
2264 dirs.add(iter(dirs).next() + '.')
2265 files.update(dirs)
2265 files.update(dirs)
2266 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2266 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2267 ui.write('\n')
2267 ui.write('\n')
2268
2268
2269 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
2269 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
2270 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2270 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2271 '''access the pushkey key/value protocol
2271 '''access the pushkey key/value protocol
2272
2272
2273 With two args, list the keys in the given namespace.
2273 With two args, list the keys in the given namespace.
2274
2274
2275 With five args, set a key to new if it currently is set to old.
2275 With five args, set a key to new if it currently is set to old.
2276 Reports success or failure.
2276 Reports success or failure.
2277 '''
2277 '''
2278
2278
2279 target = hg.peer(ui, {}, repopath)
2279 target = hg.peer(ui, {}, repopath)
2280 if keyinfo:
2280 if keyinfo:
2281 key, old, new = keyinfo
2281 key, old, new = keyinfo
2282 r = target.pushkey(namespace, key, old, new)
2282 r = target.pushkey(namespace, key, old, new)
2283 ui.status(str(r) + '\n')
2283 ui.status(str(r) + '\n')
2284 return not r
2284 return not r
2285 else:
2285 else:
2286 for k, v in sorted(target.listkeys(namespace).iteritems()):
2286 for k, v in sorted(target.listkeys(namespace).iteritems()):
2287 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2287 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2288 v.encode('string-escape')))
2288 v.encode('string-escape')))
2289
2289
2290 @command('debugpvec', [], _('A B'))
2290 @command('debugpvec', [], _('A B'))
2291 def debugpvec(ui, repo, a, b=None):
2291 def debugpvec(ui, repo, a, b=None):
2292 ca = scmutil.revsingle(repo, a)
2292 ca = scmutil.revsingle(repo, a)
2293 cb = scmutil.revsingle(repo, b)
2293 cb = scmutil.revsingle(repo, b)
2294 pa = pvec.ctxpvec(ca)
2294 pa = pvec.ctxpvec(ca)
2295 pb = pvec.ctxpvec(cb)
2295 pb = pvec.ctxpvec(cb)
2296 if pa == pb:
2296 if pa == pb:
2297 rel = "="
2297 rel = "="
2298 elif pa > pb:
2298 elif pa > pb:
2299 rel = ">"
2299 rel = ">"
2300 elif pa < pb:
2300 elif pa < pb:
2301 rel = "<"
2301 rel = "<"
2302 elif pa | pb:
2302 elif pa | pb:
2303 rel = "|"
2303 rel = "|"
2304 ui.write(_("a: %s\n") % pa)
2304 ui.write(_("a: %s\n") % pa)
2305 ui.write(_("b: %s\n") % pb)
2305 ui.write(_("b: %s\n") % pb)
2306 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2306 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2307 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2307 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2308 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2308 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2309 pa.distance(pb), rel))
2309 pa.distance(pb), rel))
2310
2310
2311 @command('debugrebuilddirstate|debugrebuildstate',
2311 @command('debugrebuilddirstate|debugrebuildstate',
2312 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2312 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2313 _('[-r REV]'))
2313 _('[-r REV]'))
2314 def debugrebuilddirstate(ui, repo, rev):
2314 def debugrebuilddirstate(ui, repo, rev):
2315 """rebuild the dirstate as it would look like for the given revision
2315 """rebuild the dirstate as it would look like for the given revision
2316
2316
2317 If no revision is specified the first current parent will be used.
2317 If no revision is specified the first current parent will be used.
2318
2318
2319 The dirstate will be set to the files of the given revision.
2319 The dirstate will be set to the files of the given revision.
2320 The actual working directory content or existing dirstate
2320 The actual working directory content or existing dirstate
2321 information such as adds or removes is not considered.
2321 information such as adds or removes is not considered.
2322
2322
2323 One use of this command is to make the next :hg:`status` invocation
2323 One use of this command is to make the next :hg:`status` invocation
2324 check the actual file content.
2324 check the actual file content.
2325 """
2325 """
2326 ctx = scmutil.revsingle(repo, rev)
2326 ctx = scmutil.revsingle(repo, rev)
2327 wlock = repo.wlock()
2327 wlock = repo.wlock()
2328 try:
2328 try:
2329 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2329 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2330 finally:
2330 finally:
2331 wlock.release()
2331 wlock.release()
2332
2332
2333 @command('debugrename',
2333 @command('debugrename',
2334 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2334 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2335 _('[-r REV] FILE'))
2335 _('[-r REV] FILE'))
2336 def debugrename(ui, repo, file1, *pats, **opts):
2336 def debugrename(ui, repo, file1, *pats, **opts):
2337 """dump rename information"""
2337 """dump rename information"""
2338
2338
2339 ctx = scmutil.revsingle(repo, opts.get('rev'))
2339 ctx = scmutil.revsingle(repo, opts.get('rev'))
2340 m = scmutil.match(ctx, (file1,) + pats, opts)
2340 m = scmutil.match(ctx, (file1,) + pats, opts)
2341 for abs in ctx.walk(m):
2341 for abs in ctx.walk(m):
2342 fctx = ctx[abs]
2342 fctx = ctx[abs]
2343 o = fctx.filelog().renamed(fctx.filenode())
2343 o = fctx.filelog().renamed(fctx.filenode())
2344 rel = m.rel(abs)
2344 rel = m.rel(abs)
2345 if o:
2345 if o:
2346 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2346 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2347 else:
2347 else:
2348 ui.write(_("%s not renamed\n") % rel)
2348 ui.write(_("%s not renamed\n") % rel)
2349
2349
2350 @command('debugrevlog',
2350 @command('debugrevlog',
2351 [('c', 'changelog', False, _('open changelog')),
2351 [('c', 'changelog', False, _('open changelog')),
2352 ('m', 'manifest', False, _('open manifest')),
2352 ('m', 'manifest', False, _('open manifest')),
2353 ('d', 'dump', False, _('dump index data'))],
2353 ('d', 'dump', False, _('dump index data'))],
2354 _('-c|-m|FILE'))
2354 _('-c|-m|FILE'))
2355 def debugrevlog(ui, repo, file_ = None, **opts):
2355 def debugrevlog(ui, repo, file_ = None, **opts):
2356 """show data and statistics about a revlog"""
2356 """show data and statistics about a revlog"""
2357 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2357 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2358
2358
2359 if opts.get("dump"):
2359 if opts.get("dump"):
2360 numrevs = len(r)
2360 numrevs = len(r)
2361 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2361 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2362 " rawsize totalsize compression heads\n")
2362 " rawsize totalsize compression heads\n")
2363 ts = 0
2363 ts = 0
2364 heads = set()
2364 heads = set()
2365 for rev in xrange(numrevs):
2365 for rev in xrange(numrevs):
2366 dbase = r.deltaparent(rev)
2366 dbase = r.deltaparent(rev)
2367 if dbase == -1:
2367 if dbase == -1:
2368 dbase = rev
2368 dbase = rev
2369 cbase = r.chainbase(rev)
2369 cbase = r.chainbase(rev)
2370 p1, p2 = r.parentrevs(rev)
2370 p1, p2 = r.parentrevs(rev)
2371 rs = r.rawsize(rev)
2371 rs = r.rawsize(rev)
2372 ts = ts + rs
2372 ts = ts + rs
2373 heads -= set(r.parentrevs(rev))
2373 heads -= set(r.parentrevs(rev))
2374 heads.add(rev)
2374 heads.add(rev)
2375 ui.write("%d %d %d %d %d %d %d %d %d %d %d %d %d\n" %
2375 ui.write("%d %d %d %d %d %d %d %d %d %d %d %d %d\n" %
2376 (rev, p1, p2, r.start(rev), r.end(rev),
2376 (rev, p1, p2, r.start(rev), r.end(rev),
2377 r.start(dbase), r.start(cbase),
2377 r.start(dbase), r.start(cbase),
2378 r.start(p1), r.start(p2),
2378 r.start(p1), r.start(p2),
2379 rs, ts, ts / r.end(rev), len(heads)))
2379 rs, ts, ts / r.end(rev), len(heads)))
2380 return 0
2380 return 0
2381
2381
2382 v = r.version
2382 v = r.version
2383 format = v & 0xFFFF
2383 format = v & 0xFFFF
2384 flags = []
2384 flags = []
2385 gdelta = False
2385 gdelta = False
2386 if v & revlog.REVLOGNGINLINEDATA:
2386 if v & revlog.REVLOGNGINLINEDATA:
2387 flags.append('inline')
2387 flags.append('inline')
2388 if v & revlog.REVLOGGENERALDELTA:
2388 if v & revlog.REVLOGGENERALDELTA:
2389 gdelta = True
2389 gdelta = True
2390 flags.append('generaldelta')
2390 flags.append('generaldelta')
2391 if not flags:
2391 if not flags:
2392 flags = ['(none)']
2392 flags = ['(none)']
2393
2393
2394 nummerges = 0
2394 nummerges = 0
2395 numfull = 0
2395 numfull = 0
2396 numprev = 0
2396 numprev = 0
2397 nump1 = 0
2397 nump1 = 0
2398 nump2 = 0
2398 nump2 = 0
2399 numother = 0
2399 numother = 0
2400 nump1prev = 0
2400 nump1prev = 0
2401 nump2prev = 0
2401 nump2prev = 0
2402 chainlengths = []
2402 chainlengths = []
2403
2403
2404 datasize = [None, 0, 0L]
2404 datasize = [None, 0, 0L]
2405 fullsize = [None, 0, 0L]
2405 fullsize = [None, 0, 0L]
2406 deltasize = [None, 0, 0L]
2406 deltasize = [None, 0, 0L]
2407
2407
2408 def addsize(size, l):
2408 def addsize(size, l):
2409 if l[0] is None or size < l[0]:
2409 if l[0] is None or size < l[0]:
2410 l[0] = size
2410 l[0] = size
2411 if size > l[1]:
2411 if size > l[1]:
2412 l[1] = size
2412 l[1] = size
2413 l[2] += size
2413 l[2] += size
2414
2414
2415 numrevs = len(r)
2415 numrevs = len(r)
2416 for rev in xrange(numrevs):
2416 for rev in xrange(numrevs):
2417 p1, p2 = r.parentrevs(rev)
2417 p1, p2 = r.parentrevs(rev)
2418 delta = r.deltaparent(rev)
2418 delta = r.deltaparent(rev)
2419 if format > 0:
2419 if format > 0:
2420 addsize(r.rawsize(rev), datasize)
2420 addsize(r.rawsize(rev), datasize)
2421 if p2 != nullrev:
2421 if p2 != nullrev:
2422 nummerges += 1
2422 nummerges += 1
2423 size = r.length(rev)
2423 size = r.length(rev)
2424 if delta == nullrev:
2424 if delta == nullrev:
2425 chainlengths.append(0)
2425 chainlengths.append(0)
2426 numfull += 1
2426 numfull += 1
2427 addsize(size, fullsize)
2427 addsize(size, fullsize)
2428 else:
2428 else:
2429 chainlengths.append(chainlengths[delta] + 1)
2429 chainlengths.append(chainlengths[delta] + 1)
2430 addsize(size, deltasize)
2430 addsize(size, deltasize)
2431 if delta == rev - 1:
2431 if delta == rev - 1:
2432 numprev += 1
2432 numprev += 1
2433 if delta == p1:
2433 if delta == p1:
2434 nump1prev += 1
2434 nump1prev += 1
2435 elif delta == p2:
2435 elif delta == p2:
2436 nump2prev += 1
2436 nump2prev += 1
2437 elif delta == p1:
2437 elif delta == p1:
2438 nump1 += 1
2438 nump1 += 1
2439 elif delta == p2:
2439 elif delta == p2:
2440 nump2 += 1
2440 nump2 += 1
2441 elif delta != nullrev:
2441 elif delta != nullrev:
2442 numother += 1
2442 numother += 1
2443
2443
2444 # Adjust size min value for empty cases
2444 # Adjust size min value for empty cases
2445 for size in (datasize, fullsize, deltasize):
2445 for size in (datasize, fullsize, deltasize):
2446 if size[0] is None:
2446 if size[0] is None:
2447 size[0] = 0
2447 size[0] = 0
2448
2448
2449 numdeltas = numrevs - numfull
2449 numdeltas = numrevs - numfull
2450 numoprev = numprev - nump1prev - nump2prev
2450 numoprev = numprev - nump1prev - nump2prev
2451 totalrawsize = datasize[2]
2451 totalrawsize = datasize[2]
2452 datasize[2] /= numrevs
2452 datasize[2] /= numrevs
2453 fulltotal = fullsize[2]
2453 fulltotal = fullsize[2]
2454 fullsize[2] /= numfull
2454 fullsize[2] /= numfull
2455 deltatotal = deltasize[2]
2455 deltatotal = deltasize[2]
2456 if numrevs - numfull > 0:
2456 if numrevs - numfull > 0:
2457 deltasize[2] /= numrevs - numfull
2457 deltasize[2] /= numrevs - numfull
2458 totalsize = fulltotal + deltatotal
2458 totalsize = fulltotal + deltatotal
2459 avgchainlen = sum(chainlengths) / numrevs
2459 avgchainlen = sum(chainlengths) / numrevs
2460 compratio = totalrawsize / totalsize
2460 compratio = totalrawsize / totalsize
2461
2461
2462 basedfmtstr = '%%%dd\n'
2462 basedfmtstr = '%%%dd\n'
2463 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2463 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2464
2464
2465 def dfmtstr(max):
2465 def dfmtstr(max):
2466 return basedfmtstr % len(str(max))
2466 return basedfmtstr % len(str(max))
2467 def pcfmtstr(max, padding=0):
2467 def pcfmtstr(max, padding=0):
2468 return basepcfmtstr % (len(str(max)), ' ' * padding)
2468 return basepcfmtstr % (len(str(max)), ' ' * padding)
2469
2469
2470 def pcfmt(value, total):
2470 def pcfmt(value, total):
2471 return (value, 100 * float(value) / total)
2471 return (value, 100 * float(value) / total)
2472
2472
2473 ui.write(('format : %d\n') % format)
2473 ui.write(('format : %d\n') % format)
2474 ui.write(('flags : %s\n') % ', '.join(flags))
2474 ui.write(('flags : %s\n') % ', '.join(flags))
2475
2475
2476 ui.write('\n')
2476 ui.write('\n')
2477 fmt = pcfmtstr(totalsize)
2477 fmt = pcfmtstr(totalsize)
2478 fmt2 = dfmtstr(totalsize)
2478 fmt2 = dfmtstr(totalsize)
2479 ui.write(('revisions : ') + fmt2 % numrevs)
2479 ui.write(('revisions : ') + fmt2 % numrevs)
2480 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2480 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2481 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2481 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2482 ui.write(('revisions : ') + fmt2 % numrevs)
2482 ui.write(('revisions : ') + fmt2 % numrevs)
2483 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2483 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2484 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2484 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2485 ui.write(('revision size : ') + fmt2 % totalsize)
2485 ui.write(('revision size : ') + fmt2 % totalsize)
2486 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2486 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2487 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2487 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2488
2488
2489 ui.write('\n')
2489 ui.write('\n')
2490 fmt = dfmtstr(max(avgchainlen, compratio))
2490 fmt = dfmtstr(max(avgchainlen, compratio))
2491 ui.write(('avg chain length : ') + fmt % avgchainlen)
2491 ui.write(('avg chain length : ') + fmt % avgchainlen)
2492 ui.write(('compression ratio : ') + fmt % compratio)
2492 ui.write(('compression ratio : ') + fmt % compratio)
2493
2493
2494 if format > 0:
2494 if format > 0:
2495 ui.write('\n')
2495 ui.write('\n')
2496 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2496 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2497 % tuple(datasize))
2497 % tuple(datasize))
2498 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2498 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2499 % tuple(fullsize))
2499 % tuple(fullsize))
2500 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2500 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2501 % tuple(deltasize))
2501 % tuple(deltasize))
2502
2502
2503 if numdeltas > 0:
2503 if numdeltas > 0:
2504 ui.write('\n')
2504 ui.write('\n')
2505 fmt = pcfmtstr(numdeltas)
2505 fmt = pcfmtstr(numdeltas)
2506 fmt2 = pcfmtstr(numdeltas, 4)
2506 fmt2 = pcfmtstr(numdeltas, 4)
2507 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2507 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2508 if numprev > 0:
2508 if numprev > 0:
2509 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2509 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2510 numprev))
2510 numprev))
2511 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2511 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2512 numprev))
2512 numprev))
2513 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2513 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2514 numprev))
2514 numprev))
2515 if gdelta:
2515 if gdelta:
2516 ui.write(('deltas against p1 : ')
2516 ui.write(('deltas against p1 : ')
2517 + fmt % pcfmt(nump1, numdeltas))
2517 + fmt % pcfmt(nump1, numdeltas))
2518 ui.write(('deltas against p2 : ')
2518 ui.write(('deltas against p2 : ')
2519 + fmt % pcfmt(nump2, numdeltas))
2519 + fmt % pcfmt(nump2, numdeltas))
2520 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2520 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2521 numdeltas))
2521 numdeltas))
2522
2522
2523 @command('debugrevspec', [], ('REVSPEC'))
2523 @command('debugrevspec', [], ('REVSPEC'))
2524 def debugrevspec(ui, repo, expr):
2524 def debugrevspec(ui, repo, expr):
2525 """parse and apply a revision specification
2525 """parse and apply a revision specification
2526
2526
2527 Use --verbose to print the parsed tree before and after aliases
2527 Use --verbose to print the parsed tree before and after aliases
2528 expansion.
2528 expansion.
2529 """
2529 """
2530 if ui.verbose:
2530 if ui.verbose:
2531 tree = revset.parse(expr)[0]
2531 tree = revset.parse(expr)[0]
2532 ui.note(revset.prettyformat(tree), "\n")
2532 ui.note(revset.prettyformat(tree), "\n")
2533 newtree = revset.findaliases(ui, tree)
2533 newtree = revset.findaliases(ui, tree)
2534 if newtree != tree:
2534 if newtree != tree:
2535 ui.note(revset.prettyformat(newtree), "\n")
2535 ui.note(revset.prettyformat(newtree), "\n")
2536 func = revset.match(ui, expr)
2536 func = revset.match(ui, expr)
2537 for c in func(repo, range(len(repo))):
2537 for c in func(repo, range(len(repo))):
2538 ui.write("%s\n" % c)
2538 ui.write("%s\n" % c)
2539
2539
2540 @command('debugsetparents', [], _('REV1 [REV2]'))
2540 @command('debugsetparents', [], _('REV1 [REV2]'))
2541 def debugsetparents(ui, repo, rev1, rev2=None):
2541 def debugsetparents(ui, repo, rev1, rev2=None):
2542 """manually set the parents of the current working directory
2542 """manually set the parents of the current working directory
2543
2543
2544 This is useful for writing repository conversion tools, but should
2544 This is useful for writing repository conversion tools, but should
2545 be used with care.
2545 be used with care.
2546
2546
2547 Returns 0 on success.
2547 Returns 0 on success.
2548 """
2548 """
2549
2549
2550 r1 = scmutil.revsingle(repo, rev1).node()
2550 r1 = scmutil.revsingle(repo, rev1).node()
2551 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2551 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2552
2552
2553 wlock = repo.wlock()
2553 wlock = repo.wlock()
2554 try:
2554 try:
2555 repo.setparents(r1, r2)
2555 repo.setparents(r1, r2)
2556 finally:
2556 finally:
2557 wlock.release()
2557 wlock.release()
2558
2558
2559 @command('debugdirstate|debugstate',
2559 @command('debugdirstate|debugstate',
2560 [('', 'nodates', None, _('do not display the saved mtime')),
2560 [('', 'nodates', None, _('do not display the saved mtime')),
2561 ('', 'datesort', None, _('sort by saved mtime'))],
2561 ('', 'datesort', None, _('sort by saved mtime'))],
2562 _('[OPTION]...'))
2562 _('[OPTION]...'))
2563 def debugstate(ui, repo, nodates=None, datesort=None):
2563 def debugstate(ui, repo, nodates=None, datesort=None):
2564 """show the contents of the current dirstate"""
2564 """show the contents of the current dirstate"""
2565 timestr = ""
2565 timestr = ""
2566 showdate = not nodates
2566 showdate = not nodates
2567 if datesort:
2567 if datesort:
2568 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2568 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2569 else:
2569 else:
2570 keyfunc = None # sort by filename
2570 keyfunc = None # sort by filename
2571 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2571 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2572 if showdate:
2572 if showdate:
2573 if ent[3] == -1:
2573 if ent[3] == -1:
2574 # Pad or slice to locale representation
2574 # Pad or slice to locale representation
2575 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2575 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2576 time.localtime(0)))
2576 time.localtime(0)))
2577 timestr = 'unset'
2577 timestr = 'unset'
2578 timestr = (timestr[:locale_len] +
2578 timestr = (timestr[:locale_len] +
2579 ' ' * (locale_len - len(timestr)))
2579 ' ' * (locale_len - len(timestr)))
2580 else:
2580 else:
2581 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2581 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2582 time.localtime(ent[3]))
2582 time.localtime(ent[3]))
2583 if ent[1] & 020000:
2583 if ent[1] & 020000:
2584 mode = 'lnk'
2584 mode = 'lnk'
2585 else:
2585 else:
2586 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2586 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2587 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2587 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2588 for f in repo.dirstate.copies():
2588 for f in repo.dirstate.copies():
2589 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2589 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2590
2590
2591 @command('debugsub',
2591 @command('debugsub',
2592 [('r', 'rev', '',
2592 [('r', 'rev', '',
2593 _('revision to check'), _('REV'))],
2593 _('revision to check'), _('REV'))],
2594 _('[-r REV] [REV]'))
2594 _('[-r REV] [REV]'))
2595 def debugsub(ui, repo, rev=None):
2595 def debugsub(ui, repo, rev=None):
2596 ctx = scmutil.revsingle(repo, rev, None)
2596 ctx = scmutil.revsingle(repo, rev, None)
2597 for k, v in sorted(ctx.substate.items()):
2597 for k, v in sorted(ctx.substate.items()):
2598 ui.write(('path %s\n') % k)
2598 ui.write(('path %s\n') % k)
2599 ui.write((' source %s\n') % v[0])
2599 ui.write((' source %s\n') % v[0])
2600 ui.write((' revision %s\n') % v[1])
2600 ui.write((' revision %s\n') % v[1])
2601
2601
2602 @command('debugsuccessorssets',
2602 @command('debugsuccessorssets',
2603 [],
2603 [],
2604 _('[REV]'))
2604 _('[REV]'))
2605 def debugsuccessorssets(ui, repo, *revs):
2605 def debugsuccessorssets(ui, repo, *revs):
2606 """show set of successors for revision
2606 """show set of successors for revision
2607
2607
2608 A successors set of changeset A is a consistent group of revisions that
2608 A successors set of changeset A is a consistent group of revisions that
2609 succeed A. It contains non-obsolete changesets only.
2609 succeed A. It contains non-obsolete changesets only.
2610
2610
2611 In most cases a changeset A has a single successors set containing a single
2611 In most cases a changeset A has a single successors set containing a single
2612 successor (changeset A replaced by A').
2612 successor (changeset A replaced by A').
2613
2613
2614 A changeset that is made obsolete with no successors are called "pruned".
2614 A changeset that is made obsolete with no successors are called "pruned".
2615 Such changesets have no successors sets at all.
2615 Such changesets have no successors sets at all.
2616
2616
2617 A changeset that has been "split" will have a successors set containing
2617 A changeset that has been "split" will have a successors set containing
2618 more than one successor.
2618 more than one successor.
2619
2619
2620 A changeset that has been rewritten in multiple different ways is called
2620 A changeset that has been rewritten in multiple different ways is called
2621 "divergent". Such changesets have multiple successor sets (each of which
2621 "divergent". Such changesets have multiple successor sets (each of which
2622 may also be split, i.e. have multiple successors).
2622 may also be split, i.e. have multiple successors).
2623
2623
2624 Results are displayed as follows::
2624 Results are displayed as follows::
2625
2625
2626 <rev1>
2626 <rev1>
2627 <successors-1A>
2627 <successors-1A>
2628 <rev2>
2628 <rev2>
2629 <successors-2A>
2629 <successors-2A>
2630 <successors-2B1> <successors-2B2> <successors-2B3>
2630 <successors-2B1> <successors-2B2> <successors-2B3>
2631
2631
2632 Here rev2 has two possible (i.e. divergent) successors sets. The first
2632 Here rev2 has two possible (i.e. divergent) successors sets. The first
2633 holds one element, whereas the second holds three (i.e. the changeset has
2633 holds one element, whereas the second holds three (i.e. the changeset has
2634 been split).
2634 been split).
2635 """
2635 """
2636 # passed to successorssets caching computation from one call to another
2636 # passed to successorssets caching computation from one call to another
2637 cache = {}
2637 cache = {}
2638 ctx2str = str
2638 ctx2str = str
2639 node2str = short
2639 node2str = short
2640 if ui.debug():
2640 if ui.debug():
2641 def ctx2str(ctx):
2641 def ctx2str(ctx):
2642 return ctx.hex()
2642 return ctx.hex()
2643 node2str = hex
2643 node2str = hex
2644 for rev in scmutil.revrange(repo, revs):
2644 for rev in scmutil.revrange(repo, revs):
2645 ctx = repo[rev]
2645 ctx = repo[rev]
2646 ui.write('%s\n'% ctx2str(ctx))
2646 ui.write('%s\n'% ctx2str(ctx))
2647 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2647 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2648 if succsset:
2648 if succsset:
2649 ui.write(' ')
2649 ui.write(' ')
2650 ui.write(node2str(succsset[0]))
2650 ui.write(node2str(succsset[0]))
2651 for node in succsset[1:]:
2651 for node in succsset[1:]:
2652 ui.write(' ')
2652 ui.write(' ')
2653 ui.write(node2str(node))
2653 ui.write(node2str(node))
2654 ui.write('\n')
2654 ui.write('\n')
2655
2655
2656 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2656 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2657 def debugwalk(ui, repo, *pats, **opts):
2657 def debugwalk(ui, repo, *pats, **opts):
2658 """show how files match on given patterns"""
2658 """show how files match on given patterns"""
2659 m = scmutil.match(repo[None], pats, opts)
2659 m = scmutil.match(repo[None], pats, opts)
2660 items = list(repo.walk(m))
2660 items = list(repo.walk(m))
2661 if not items:
2661 if not items:
2662 return
2662 return
2663 f = lambda fn: fn
2663 f = lambda fn: fn
2664 if ui.configbool('ui', 'slash') and os.sep != '/':
2664 if ui.configbool('ui', 'slash') and os.sep != '/':
2665 f = lambda fn: util.normpath(fn)
2665 f = lambda fn: util.normpath(fn)
2666 fmt = 'f %%-%ds %%-%ds %%s' % (
2666 fmt = 'f %%-%ds %%-%ds %%s' % (
2667 max([len(abs) for abs in items]),
2667 max([len(abs) for abs in items]),
2668 max([len(m.rel(abs)) for abs in items]))
2668 max([len(m.rel(abs)) for abs in items]))
2669 for abs in items:
2669 for abs in items:
2670 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2670 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2671 ui.write("%s\n" % line.rstrip())
2671 ui.write("%s\n" % line.rstrip())
2672
2672
2673 @command('debugwireargs',
2673 @command('debugwireargs',
2674 [('', 'three', '', 'three'),
2674 [('', 'three', '', 'three'),
2675 ('', 'four', '', 'four'),
2675 ('', 'four', '', 'four'),
2676 ('', 'five', '', 'five'),
2676 ('', 'five', '', 'five'),
2677 ] + remoteopts,
2677 ] + remoteopts,
2678 _('REPO [OPTIONS]... [ONE [TWO]]'))
2678 _('REPO [OPTIONS]... [ONE [TWO]]'))
2679 def debugwireargs(ui, repopath, *vals, **opts):
2679 def debugwireargs(ui, repopath, *vals, **opts):
2680 repo = hg.peer(ui, opts, repopath)
2680 repo = hg.peer(ui, opts, repopath)
2681 for opt in remoteopts:
2681 for opt in remoteopts:
2682 del opts[opt[1]]
2682 del opts[opt[1]]
2683 args = {}
2683 args = {}
2684 for k, v in opts.iteritems():
2684 for k, v in opts.iteritems():
2685 if v:
2685 if v:
2686 args[k] = v
2686 args[k] = v
2687 # run twice to check that we don't mess up the stream for the next command
2687 # run twice to check that we don't mess up the stream for the next command
2688 res1 = repo.debugwireargs(*vals, **args)
2688 res1 = repo.debugwireargs(*vals, **args)
2689 res2 = repo.debugwireargs(*vals, **args)
2689 res2 = repo.debugwireargs(*vals, **args)
2690 ui.write("%s\n" % res1)
2690 ui.write("%s\n" % res1)
2691 if res1 != res2:
2691 if res1 != res2:
2692 ui.warn("%s\n" % res2)
2692 ui.warn("%s\n" % res2)
2693
2693
2694 @command('^diff',
2694 @command('^diff',
2695 [('r', 'rev', [], _('revision'), _('REV')),
2695 [('r', 'rev', [], _('revision'), _('REV')),
2696 ('c', 'change', '', _('change made by revision'), _('REV'))
2696 ('c', 'change', '', _('change made by revision'), _('REV'))
2697 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2697 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2698 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'))
2698 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'))
2699 def diff(ui, repo, *pats, **opts):
2699 def diff(ui, repo, *pats, **opts):
2700 """diff repository (or selected files)
2700 """diff repository (or selected files)
2701
2701
2702 Show differences between revisions for the specified files.
2702 Show differences between revisions for the specified files.
2703
2703
2704 Differences between files are shown using the unified diff format.
2704 Differences between files are shown using the unified diff format.
2705
2705
2706 .. note::
2706 .. note::
2707 diff may generate unexpected results for merges, as it will
2707 diff may generate unexpected results for merges, as it will
2708 default to comparing against the working directory's first
2708 default to comparing against the working directory's first
2709 parent changeset if no revisions are specified.
2709 parent changeset if no revisions are specified.
2710
2710
2711 When two revision arguments are given, then changes are shown
2711 When two revision arguments are given, then changes are shown
2712 between those revisions. If only one revision is specified then
2712 between those revisions. If only one revision is specified then
2713 that revision is compared to the working directory, and, when no
2713 that revision is compared to the working directory, and, when no
2714 revisions are specified, the working directory files are compared
2714 revisions are specified, the working directory files are compared
2715 to its parent.
2715 to its parent.
2716
2716
2717 Alternatively you can specify -c/--change with a revision to see
2717 Alternatively you can specify -c/--change with a revision to see
2718 the changes in that changeset relative to its first parent.
2718 the changes in that changeset relative to its first parent.
2719
2719
2720 Without the -a/--text option, diff will avoid generating diffs of
2720 Without the -a/--text option, diff will avoid generating diffs of
2721 files it detects as binary. With -a, diff will generate a diff
2721 files it detects as binary. With -a, diff will generate a diff
2722 anyway, probably with undesirable results.
2722 anyway, probably with undesirable results.
2723
2723
2724 Use the -g/--git option to generate diffs in the git extended diff
2724 Use the -g/--git option to generate diffs in the git extended diff
2725 format. For more information, read :hg:`help diffs`.
2725 format. For more information, read :hg:`help diffs`.
2726
2726
2727 .. container:: verbose
2727 .. container:: verbose
2728
2728
2729 Examples:
2729 Examples:
2730
2730
2731 - compare a file in the current working directory to its parent::
2731 - compare a file in the current working directory to its parent::
2732
2732
2733 hg diff foo.c
2733 hg diff foo.c
2734
2734
2735 - compare two historical versions of a directory, with rename info::
2735 - compare two historical versions of a directory, with rename info::
2736
2736
2737 hg diff --git -r 1.0:1.2 lib/
2737 hg diff --git -r 1.0:1.2 lib/
2738
2738
2739 - get change stats relative to the last change on some date::
2739 - get change stats relative to the last change on some date::
2740
2740
2741 hg diff --stat -r "date('may 2')"
2741 hg diff --stat -r "date('may 2')"
2742
2742
2743 - diff all newly-added files that contain a keyword::
2743 - diff all newly-added files that contain a keyword::
2744
2744
2745 hg diff "set:added() and grep(GNU)"
2745 hg diff "set:added() and grep(GNU)"
2746
2746
2747 - compare a revision and its parents::
2747 - compare a revision and its parents::
2748
2748
2749 hg diff -c 9353 # compare against first parent
2749 hg diff -c 9353 # compare against first parent
2750 hg diff -r 9353^:9353 # same using revset syntax
2750 hg diff -r 9353^:9353 # same using revset syntax
2751 hg diff -r 9353^2:9353 # compare against the second parent
2751 hg diff -r 9353^2:9353 # compare against the second parent
2752
2752
2753 Returns 0 on success.
2753 Returns 0 on success.
2754 """
2754 """
2755
2755
2756 revs = opts.get('rev')
2756 revs = opts.get('rev')
2757 change = opts.get('change')
2757 change = opts.get('change')
2758 stat = opts.get('stat')
2758 stat = opts.get('stat')
2759 reverse = opts.get('reverse')
2759 reverse = opts.get('reverse')
2760
2760
2761 if revs and change:
2761 if revs and change:
2762 msg = _('cannot specify --rev and --change at the same time')
2762 msg = _('cannot specify --rev and --change at the same time')
2763 raise util.Abort(msg)
2763 raise util.Abort(msg)
2764 elif change:
2764 elif change:
2765 node2 = scmutil.revsingle(repo, change, None).node()
2765 node2 = scmutil.revsingle(repo, change, None).node()
2766 node1 = repo[node2].p1().node()
2766 node1 = repo[node2].p1().node()
2767 else:
2767 else:
2768 node1, node2 = scmutil.revpair(repo, revs)
2768 node1, node2 = scmutil.revpair(repo, revs)
2769
2769
2770 if reverse:
2770 if reverse:
2771 node1, node2 = node2, node1
2771 node1, node2 = node2, node1
2772
2772
2773 diffopts = patch.diffopts(ui, opts)
2773 diffopts = patch.diffopts(ui, opts)
2774 m = scmutil.match(repo[node2], pats, opts)
2774 m = scmutil.match(repo[node2], pats, opts)
2775 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2775 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2776 listsubrepos=opts.get('subrepos'))
2776 listsubrepos=opts.get('subrepos'))
2777
2777
2778 @command('^export',
2778 @command('^export',
2779 [('o', 'output', '',
2779 [('o', 'output', '',
2780 _('print output to file with formatted name'), _('FORMAT')),
2780 _('print output to file with formatted name'), _('FORMAT')),
2781 ('', 'switch-parent', None, _('diff against the second parent')),
2781 ('', 'switch-parent', None, _('diff against the second parent')),
2782 ('r', 'rev', [], _('revisions to export'), _('REV')),
2782 ('r', 'rev', [], _('revisions to export'), _('REV')),
2783 ] + diffopts,
2783 ] + diffopts,
2784 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
2784 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
2785 def export(ui, repo, *changesets, **opts):
2785 def export(ui, repo, *changesets, **opts):
2786 """dump the header and diffs for one or more changesets
2786 """dump the header and diffs for one or more changesets
2787
2787
2788 Print the changeset header and diffs for one or more revisions.
2788 Print the changeset header and diffs for one or more revisions.
2789 If no revision is given, the parent of the working directory is used.
2789 If no revision is given, the parent of the working directory is used.
2790
2790
2791 The information shown in the changeset header is: author, date,
2791 The information shown in the changeset header is: author, date,
2792 branch name (if non-default), changeset hash, parent(s) and commit
2792 branch name (if non-default), changeset hash, parent(s) and commit
2793 comment.
2793 comment.
2794
2794
2795 .. note::
2795 .. note::
2796 export may generate unexpected diff output for merge
2796 export may generate unexpected diff output for merge
2797 changesets, as it will compare the merge changeset against its
2797 changesets, as it will compare the merge changeset against its
2798 first parent only.
2798 first parent only.
2799
2799
2800 Output may be to a file, in which case the name of the file is
2800 Output may be to a file, in which case the name of the file is
2801 given using a format string. The formatting rules are as follows:
2801 given using a format string. The formatting rules are as follows:
2802
2802
2803 :``%%``: literal "%" character
2803 :``%%``: literal "%" character
2804 :``%H``: changeset hash (40 hexadecimal digits)
2804 :``%H``: changeset hash (40 hexadecimal digits)
2805 :``%N``: number of patches being generated
2805 :``%N``: number of patches being generated
2806 :``%R``: changeset revision number
2806 :``%R``: changeset revision number
2807 :``%b``: basename of the exporting repository
2807 :``%b``: basename of the exporting repository
2808 :``%h``: short-form changeset hash (12 hexadecimal digits)
2808 :``%h``: short-form changeset hash (12 hexadecimal digits)
2809 :``%m``: first line of the commit message (only alphanumeric characters)
2809 :``%m``: first line of the commit message (only alphanumeric characters)
2810 :``%n``: zero-padded sequence number, starting at 1
2810 :``%n``: zero-padded sequence number, starting at 1
2811 :``%r``: zero-padded changeset revision number
2811 :``%r``: zero-padded changeset revision number
2812
2812
2813 Without the -a/--text option, export will avoid generating diffs
2813 Without the -a/--text option, export will avoid generating diffs
2814 of files it detects as binary. With -a, export will generate a
2814 of files it detects as binary. With -a, export will generate a
2815 diff anyway, probably with undesirable results.
2815 diff anyway, probably with undesirable results.
2816
2816
2817 Use the -g/--git option to generate diffs in the git extended diff
2817 Use the -g/--git option to generate diffs in the git extended diff
2818 format. See :hg:`help diffs` for more information.
2818 format. See :hg:`help diffs` for more information.
2819
2819
2820 With the --switch-parent option, the diff will be against the
2820 With the --switch-parent option, the diff will be against the
2821 second parent. It can be useful to review a merge.
2821 second parent. It can be useful to review a merge.
2822
2822
2823 .. container:: verbose
2823 .. container:: verbose
2824
2824
2825 Examples:
2825 Examples:
2826
2826
2827 - use export and import to transplant a bugfix to the current
2827 - use export and import to transplant a bugfix to the current
2828 branch::
2828 branch::
2829
2829
2830 hg export -r 9353 | hg import -
2830 hg export -r 9353 | hg import -
2831
2831
2832 - export all the changesets between two revisions to a file with
2832 - export all the changesets between two revisions to a file with
2833 rename information::
2833 rename information::
2834
2834
2835 hg export --git -r 123:150 > changes.txt
2835 hg export --git -r 123:150 > changes.txt
2836
2836
2837 - split outgoing changes into a series of patches with
2837 - split outgoing changes into a series of patches with
2838 descriptive names::
2838 descriptive names::
2839
2839
2840 hg export -r "outgoing()" -o "%n-%m.patch"
2840 hg export -r "outgoing()" -o "%n-%m.patch"
2841
2841
2842 Returns 0 on success.
2842 Returns 0 on success.
2843 """
2843 """
2844 changesets += tuple(opts.get('rev', []))
2844 changesets += tuple(opts.get('rev', []))
2845 if not changesets:
2845 if not changesets:
2846 changesets = ['.']
2846 changesets = ['.']
2847 revs = scmutil.revrange(repo, changesets)
2847 revs = scmutil.revrange(repo, changesets)
2848 if not revs:
2848 if not revs:
2849 raise util.Abort(_("export requires at least one changeset"))
2849 raise util.Abort(_("export requires at least one changeset"))
2850 if len(revs) > 1:
2850 if len(revs) > 1:
2851 ui.note(_('exporting patches:\n'))
2851 ui.note(_('exporting patches:\n'))
2852 else:
2852 else:
2853 ui.note(_('exporting patch:\n'))
2853 ui.note(_('exporting patch:\n'))
2854 cmdutil.export(repo, revs, template=opts.get('output'),
2854 cmdutil.export(repo, revs, template=opts.get('output'),
2855 switch_parent=opts.get('switch_parent'),
2855 switch_parent=opts.get('switch_parent'),
2856 opts=patch.diffopts(ui, opts))
2856 opts=patch.diffopts(ui, opts))
2857
2857
2858 @command('^forget', walkopts, _('[OPTION]... FILE...'))
2858 @command('^forget', walkopts, _('[OPTION]... FILE...'))
2859 def forget(ui, repo, *pats, **opts):
2859 def forget(ui, repo, *pats, **opts):
2860 """forget the specified files on the next commit
2860 """forget the specified files on the next commit
2861
2861
2862 Mark the specified files so they will no longer be tracked
2862 Mark the specified files so they will no longer be tracked
2863 after the next commit.
2863 after the next commit.
2864
2864
2865 This only removes files from the current branch, not from the
2865 This only removes files from the current branch, not from the
2866 entire project history, and it does not delete them from the
2866 entire project history, and it does not delete them from the
2867 working directory.
2867 working directory.
2868
2868
2869 To undo a forget before the next commit, see :hg:`add`.
2869 To undo a forget before the next commit, see :hg:`add`.
2870
2870
2871 .. container:: verbose
2871 .. container:: verbose
2872
2872
2873 Examples:
2873 Examples:
2874
2874
2875 - forget newly-added binary files::
2875 - forget newly-added binary files::
2876
2876
2877 hg forget "set:added() and binary()"
2877 hg forget "set:added() and binary()"
2878
2878
2879 - forget files that would be excluded by .hgignore::
2879 - forget files that would be excluded by .hgignore::
2880
2880
2881 hg forget "set:hgignore()"
2881 hg forget "set:hgignore()"
2882
2882
2883 Returns 0 on success.
2883 Returns 0 on success.
2884 """
2884 """
2885
2885
2886 if not pats:
2886 if not pats:
2887 raise util.Abort(_('no files specified'))
2887 raise util.Abort(_('no files specified'))
2888
2888
2889 m = scmutil.match(repo[None], pats, opts)
2889 m = scmutil.match(repo[None], pats, opts)
2890 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2890 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2891 return rejected and 1 or 0
2891 return rejected and 1 or 0
2892
2892
2893 @command(
2893 @command(
2894 'graft',
2894 'graft',
2895 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2895 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2896 ('c', 'continue', False, _('resume interrupted graft')),
2896 ('c', 'continue', False, _('resume interrupted graft')),
2897 ('e', 'edit', False, _('invoke editor on commit messages')),
2897 ('e', 'edit', False, _('invoke editor on commit messages')),
2898 ('', 'log', None, _('append graft info to log message')),
2898 ('', 'log', None, _('append graft info to log message')),
2899 ('D', 'currentdate', False,
2899 ('D', 'currentdate', False,
2900 _('record the current date as commit date')),
2900 _('record the current date as commit date')),
2901 ('U', 'currentuser', False,
2901 ('U', 'currentuser', False,
2902 _('record the current user as committer'), _('DATE'))]
2902 _('record the current user as committer'), _('DATE'))]
2903 + commitopts2 + mergetoolopts + dryrunopts,
2903 + commitopts2 + mergetoolopts + dryrunopts,
2904 _('[OPTION]... [-r] REV...'))
2904 _('[OPTION]... [-r] REV...'))
2905 def graft(ui, repo, *revs, **opts):
2905 def graft(ui, repo, *revs, **opts):
2906 '''copy changes from other branches onto the current branch
2906 '''copy changes from other branches onto the current branch
2907
2907
2908 This command uses Mercurial's merge logic to copy individual
2908 This command uses Mercurial's merge logic to copy individual
2909 changes from other branches without merging branches in the
2909 changes from other branches without merging branches in the
2910 history graph. This is sometimes known as 'backporting' or
2910 history graph. This is sometimes known as 'backporting' or
2911 'cherry-picking'. By default, graft will copy user, date, and
2911 'cherry-picking'. By default, graft will copy user, date, and
2912 description from the source changesets.
2912 description from the source changesets.
2913
2913
2914 Changesets that are ancestors of the current revision, that have
2914 Changesets that are ancestors of the current revision, that have
2915 already been grafted, or that are merges will be skipped.
2915 already been grafted, or that are merges will be skipped.
2916
2916
2917 If --log is specified, log messages will have a comment appended
2917 If --log is specified, log messages will have a comment appended
2918 of the form::
2918 of the form::
2919
2919
2920 (grafted from CHANGESETHASH)
2920 (grafted from CHANGESETHASH)
2921
2921
2922 If a graft merge results in conflicts, the graft process is
2922 If a graft merge results in conflicts, the graft process is
2923 interrupted so that the current merge can be manually resolved.
2923 interrupted so that the current merge can be manually resolved.
2924 Once all conflicts are addressed, the graft process can be
2924 Once all conflicts are addressed, the graft process can be
2925 continued with the -c/--continue option.
2925 continued with the -c/--continue option.
2926
2926
2927 .. note::
2927 .. note::
2928 The -c/--continue option does not reapply earlier options.
2928 The -c/--continue option does not reapply earlier options.
2929
2929
2930 .. container:: verbose
2930 .. container:: verbose
2931
2931
2932 Examples:
2932 Examples:
2933
2933
2934 - copy a single change to the stable branch and edit its description::
2934 - copy a single change to the stable branch and edit its description::
2935
2935
2936 hg update stable
2936 hg update stable
2937 hg graft --edit 9393
2937 hg graft --edit 9393
2938
2938
2939 - graft a range of changesets with one exception, updating dates::
2939 - graft a range of changesets with one exception, updating dates::
2940
2940
2941 hg graft -D "2085::2093 and not 2091"
2941 hg graft -D "2085::2093 and not 2091"
2942
2942
2943 - continue a graft after resolving conflicts::
2943 - continue a graft after resolving conflicts::
2944
2944
2945 hg graft -c
2945 hg graft -c
2946
2946
2947 - show the source of a grafted changeset::
2947 - show the source of a grafted changeset::
2948
2948
2949 hg log --debug -r .
2949 hg log --debug -r .
2950
2950
2951 Returns 0 on successful completion.
2951 Returns 0 on successful completion.
2952 '''
2952 '''
2953
2953
2954 revs = list(revs)
2954 revs = list(revs)
2955 revs.extend(opts['rev'])
2955 revs.extend(opts['rev'])
2956
2956
2957 if not opts.get('user') and opts.get('currentuser'):
2957 if not opts.get('user') and opts.get('currentuser'):
2958 opts['user'] = ui.username()
2958 opts['user'] = ui.username()
2959 if not opts.get('date') and opts.get('currentdate'):
2959 if not opts.get('date') and opts.get('currentdate'):
2960 opts['date'] = "%d %d" % util.makedate()
2960 opts['date'] = "%d %d" % util.makedate()
2961
2961
2962 editor = None
2962 editor = None
2963 if opts.get('edit'):
2963 if opts.get('edit'):
2964 editor = cmdutil.commitforceeditor
2964 editor = cmdutil.commitforceeditor
2965
2965
2966 cont = False
2966 cont = False
2967 if opts['continue']:
2967 if opts['continue']:
2968 cont = True
2968 cont = True
2969 if revs:
2969 if revs:
2970 raise util.Abort(_("can't specify --continue and revisions"))
2970 raise util.Abort(_("can't specify --continue and revisions"))
2971 # read in unfinished revisions
2971 # read in unfinished revisions
2972 try:
2972 try:
2973 nodes = repo.opener.read('graftstate').splitlines()
2973 nodes = repo.opener.read('graftstate').splitlines()
2974 revs = [repo[node].rev() for node in nodes]
2974 revs = [repo[node].rev() for node in nodes]
2975 except IOError, inst:
2975 except IOError, inst:
2976 if inst.errno != errno.ENOENT:
2976 if inst.errno != errno.ENOENT:
2977 raise
2977 raise
2978 raise util.Abort(_("no graft state found, can't continue"))
2978 raise util.Abort(_("no graft state found, can't continue"))
2979 else:
2979 else:
2980 cmdutil.bailifchanged(repo)
2980 cmdutil.bailifchanged(repo)
2981 if not revs:
2981 if not revs:
2982 raise util.Abort(_('no revisions specified'))
2982 raise util.Abort(_('no revisions specified'))
2983 revs = scmutil.revrange(repo, revs)
2983 revs = scmutil.revrange(repo, revs)
2984
2984
2985 # check for merges
2985 # check for merges
2986 for rev in repo.revs('%ld and merge()', revs):
2986 for rev in repo.revs('%ld and merge()', revs):
2987 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2987 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2988 revs.remove(rev)
2988 revs.remove(rev)
2989 if not revs:
2989 if not revs:
2990 return -1
2990 return -1
2991
2991
2992 # check for ancestors of dest branch
2992 # check for ancestors of dest branch
2993 crev = repo['.'].rev()
2993 crev = repo['.'].rev()
2994 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2994 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2995 # don't mutate while iterating, create a copy
2995 # don't mutate while iterating, create a copy
2996 for rev in list(revs):
2996 for rev in list(revs):
2997 if rev in ancestors:
2997 if rev in ancestors:
2998 ui.warn(_('skipping ancestor revision %s\n') % rev)
2998 ui.warn(_('skipping ancestor revision %s\n') % rev)
2999 revs.remove(rev)
2999 revs.remove(rev)
3000 if not revs:
3000 if not revs:
3001 return -1
3001 return -1
3002
3002
3003 # analyze revs for earlier grafts
3003 # analyze revs for earlier grafts
3004 ids = {}
3004 ids = {}
3005 for ctx in repo.set("%ld", revs):
3005 for ctx in repo.set("%ld", revs):
3006 ids[ctx.hex()] = ctx.rev()
3006 ids[ctx.hex()] = ctx.rev()
3007 n = ctx.extra().get('source')
3007 n = ctx.extra().get('source')
3008 if n:
3008 if n:
3009 ids[n] = ctx.rev()
3009 ids[n] = ctx.rev()
3010
3010
3011 # check ancestors for earlier grafts
3011 # check ancestors for earlier grafts
3012 ui.debug('scanning for duplicate grafts\n')
3012 ui.debug('scanning for duplicate grafts\n')
3013
3013
3014 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3014 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3015 ctx = repo[rev]
3015 ctx = repo[rev]
3016 n = ctx.extra().get('source')
3016 n = ctx.extra().get('source')
3017 if n in ids:
3017 if n in ids:
3018 r = repo[n].rev()
3018 r = repo[n].rev()
3019 if r in revs:
3019 if r in revs:
3020 ui.warn(_('skipping already grafted revision %s\n') % r)
3020 ui.warn(_('skipping already grafted revision %s\n') % r)
3021 revs.remove(r)
3021 revs.remove(r)
3022 elif ids[n] in revs:
3022 elif ids[n] in revs:
3023 ui.warn(_('skipping already grafted revision %s '
3023 ui.warn(_('skipping already grafted revision %s '
3024 '(same origin %d)\n') % (ids[n], r))
3024 '(same origin %d)\n') % (ids[n], r))
3025 revs.remove(ids[n])
3025 revs.remove(ids[n])
3026 elif ctx.hex() in ids:
3026 elif ctx.hex() in ids:
3027 r = ids[ctx.hex()]
3027 r = ids[ctx.hex()]
3028 ui.warn(_('skipping already grafted revision %s '
3028 ui.warn(_('skipping already grafted revision %s '
3029 '(was grafted from %d)\n') % (r, rev))
3029 '(was grafted from %d)\n') % (r, rev))
3030 revs.remove(r)
3030 revs.remove(r)
3031 if not revs:
3031 if not revs:
3032 return -1
3032 return -1
3033
3033
3034 wlock = repo.wlock()
3034 wlock = repo.wlock()
3035 try:
3035 try:
3036 current = repo['.']
3036 current = repo['.']
3037 for pos, ctx in enumerate(repo.set("%ld", revs)):
3037 for pos, ctx in enumerate(repo.set("%ld", revs)):
3038
3038
3039 ui.status(_('grafting revision %s\n') % ctx.rev())
3039 ui.status(_('grafting revision %s\n') % ctx.rev())
3040 if opts.get('dry_run'):
3040 if opts.get('dry_run'):
3041 continue
3041 continue
3042
3042
3043 source = ctx.extra().get('source')
3043 source = ctx.extra().get('source')
3044 if not source:
3044 if not source:
3045 source = ctx.hex()
3045 source = ctx.hex()
3046 extra = {'source': source}
3046 extra = {'source': source}
3047 user = ctx.user()
3047 user = ctx.user()
3048 if opts.get('user'):
3048 if opts.get('user'):
3049 user = opts['user']
3049 user = opts['user']
3050 date = ctx.date()
3050 date = ctx.date()
3051 if opts.get('date'):
3051 if opts.get('date'):
3052 date = opts['date']
3052 date = opts['date']
3053 message = ctx.description()
3053 message = ctx.description()
3054 if opts.get('log'):
3054 if opts.get('log'):
3055 message += '\n(grafted from %s)' % ctx.hex()
3055 message += '\n(grafted from %s)' % ctx.hex()
3056
3056
3057 # we don't merge the first commit when continuing
3057 # we don't merge the first commit when continuing
3058 if not cont:
3058 if not cont:
3059 # perform the graft merge with p1(rev) as 'ancestor'
3059 # perform the graft merge with p1(rev) as 'ancestor'
3060 try:
3060 try:
3061 # ui.forcemerge is an internal variable, do not document
3061 # ui.forcemerge is an internal variable, do not document
3062 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
3062 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
3063 stats = mergemod.update(repo, ctx.node(), True, True, False,
3063 stats = mergemod.update(repo, ctx.node(), True, True, False,
3064 ctx.p1().node())
3064 ctx.p1().node())
3065 finally:
3065 finally:
3066 repo.ui.setconfig('ui', 'forcemerge', '')
3066 repo.ui.setconfig('ui', 'forcemerge', '')
3067 # report any conflicts
3067 # report any conflicts
3068 if stats and stats[3] > 0:
3068 if stats and stats[3] > 0:
3069 # write out state for --continue
3069 # write out state for --continue
3070 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3070 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3071 repo.opener.write('graftstate', ''.join(nodelines))
3071 repo.opener.write('graftstate', ''.join(nodelines))
3072 raise util.Abort(
3072 raise util.Abort(
3073 _("unresolved conflicts, can't continue"),
3073 _("unresolved conflicts, can't continue"),
3074 hint=_('use hg resolve and hg graft --continue'))
3074 hint=_('use hg resolve and hg graft --continue'))
3075 else:
3075 else:
3076 cont = False
3076 cont = False
3077
3077
3078 # drop the second merge parent
3078 # drop the second merge parent
3079 repo.setparents(current.node(), nullid)
3079 repo.setparents(current.node(), nullid)
3080 repo.dirstate.write()
3080 repo.dirstate.write()
3081 # fix up dirstate for copies and renames
3081 # fix up dirstate for copies and renames
3082 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3082 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3083
3083
3084 # commit
3084 # commit
3085 node = repo.commit(text=message, user=user,
3085 node = repo.commit(text=message, user=user,
3086 date=date, extra=extra, editor=editor)
3086 date=date, extra=extra, editor=editor)
3087 if node is None:
3087 if node is None:
3088 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3088 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3089 else:
3089 else:
3090 current = repo[node]
3090 current = repo[node]
3091 finally:
3091 finally:
3092 wlock.release()
3092 wlock.release()
3093
3093
3094 # remove state when we complete successfully
3094 # remove state when we complete successfully
3095 if not opts.get('dry_run'):
3095 if not opts.get('dry_run'):
3096 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3096 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3097
3097
3098 return 0
3098 return 0
3099
3099
3100 @command('grep',
3100 @command('grep',
3101 [('0', 'print0', None, _('end fields with NUL')),
3101 [('0', 'print0', None, _('end fields with NUL')),
3102 ('', 'all', None, _('print all revisions that match')),
3102 ('', 'all', None, _('print all revisions that match')),
3103 ('a', 'text', None, _('treat all files as text')),
3103 ('a', 'text', None, _('treat all files as text')),
3104 ('f', 'follow', None,
3104 ('f', 'follow', None,
3105 _('follow changeset history,'
3105 _('follow changeset history,'
3106 ' or file history across copies and renames')),
3106 ' or file history across copies and renames')),
3107 ('i', 'ignore-case', None, _('ignore case when matching')),
3107 ('i', 'ignore-case', None, _('ignore case when matching')),
3108 ('l', 'files-with-matches', None,
3108 ('l', 'files-with-matches', None,
3109 _('print only filenames and revisions that match')),
3109 _('print only filenames and revisions that match')),
3110 ('n', 'line-number', None, _('print matching line numbers')),
3110 ('n', 'line-number', None, _('print matching line numbers')),
3111 ('r', 'rev', [],
3111 ('r', 'rev', [],
3112 _('only search files changed within revision range'), _('REV')),
3112 _('only search files changed within revision range'), _('REV')),
3113 ('u', 'user', None, _('list the author (long with -v)')),
3113 ('u', 'user', None, _('list the author (long with -v)')),
3114 ('d', 'date', None, _('list the date (short with -q)')),
3114 ('d', 'date', None, _('list the date (short with -q)')),
3115 ] + walkopts,
3115 ] + walkopts,
3116 _('[OPTION]... PATTERN [FILE]...'))
3116 _('[OPTION]... PATTERN [FILE]...'))
3117 def grep(ui, repo, pattern, *pats, **opts):
3117 def grep(ui, repo, pattern, *pats, **opts):
3118 """search for a pattern in specified files and revisions
3118 """search for a pattern in specified files and revisions
3119
3119
3120 Search revisions of files for a regular expression.
3120 Search revisions of files for a regular expression.
3121
3121
3122 This command behaves differently than Unix grep. It only accepts
3122 This command behaves differently than Unix grep. It only accepts
3123 Python/Perl regexps. It searches repository history, not the
3123 Python/Perl regexps. It searches repository history, not the
3124 working directory. It always prints the revision number in which a
3124 working directory. It always prints the revision number in which a
3125 match appears.
3125 match appears.
3126
3126
3127 By default, grep only prints output for the first revision of a
3127 By default, grep only prints output for the first revision of a
3128 file in which it finds a match. To get it to print every revision
3128 file in which it finds a match. To get it to print every revision
3129 that contains a change in match status ("-" for a match that
3129 that contains a change in match status ("-" for a match that
3130 becomes a non-match, or "+" for a non-match that becomes a match),
3130 becomes a non-match, or "+" for a non-match that becomes a match),
3131 use the --all flag.
3131 use the --all flag.
3132
3132
3133 Returns 0 if a match is found, 1 otherwise.
3133 Returns 0 if a match is found, 1 otherwise.
3134 """
3134 """
3135 reflags = re.M
3135 reflags = re.M
3136 if opts.get('ignore_case'):
3136 if opts.get('ignore_case'):
3137 reflags |= re.I
3137 reflags |= re.I
3138 try:
3138 try:
3139 regexp = util.compilere(pattern, reflags)
3139 regexp = util.compilere(pattern, reflags)
3140 except re.error, inst:
3140 except re.error, inst:
3141 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3141 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3142 return 1
3142 return 1
3143 sep, eol = ':', '\n'
3143 sep, eol = ':', '\n'
3144 if opts.get('print0'):
3144 if opts.get('print0'):
3145 sep = eol = '\0'
3145 sep = eol = '\0'
3146
3146
3147 getfile = util.lrucachefunc(repo.file)
3147 getfile = util.lrucachefunc(repo.file)
3148
3148
3149 def matchlines(body):
3149 def matchlines(body):
3150 begin = 0
3150 begin = 0
3151 linenum = 0
3151 linenum = 0
3152 while begin < len(body):
3152 while begin < len(body):
3153 match = regexp.search(body, begin)
3153 match = regexp.search(body, begin)
3154 if not match:
3154 if not match:
3155 break
3155 break
3156 mstart, mend = match.span()
3156 mstart, mend = match.span()
3157 linenum += body.count('\n', begin, mstart) + 1
3157 linenum += body.count('\n', begin, mstart) + 1
3158 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3158 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3159 begin = body.find('\n', mend) + 1 or len(body) + 1
3159 begin = body.find('\n', mend) + 1 or len(body) + 1
3160 lend = begin - 1
3160 lend = begin - 1
3161 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3161 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3162
3162
3163 class linestate(object):
3163 class linestate(object):
3164 def __init__(self, line, linenum, colstart, colend):
3164 def __init__(self, line, linenum, colstart, colend):
3165 self.line = line
3165 self.line = line
3166 self.linenum = linenum
3166 self.linenum = linenum
3167 self.colstart = colstart
3167 self.colstart = colstart
3168 self.colend = colend
3168 self.colend = colend
3169
3169
3170 def __hash__(self):
3170 def __hash__(self):
3171 return hash((self.linenum, self.line))
3171 return hash((self.linenum, self.line))
3172
3172
3173 def __eq__(self, other):
3173 def __eq__(self, other):
3174 return self.line == other.line
3174 return self.line == other.line
3175
3175
3176 matches = {}
3176 matches = {}
3177 copies = {}
3177 copies = {}
3178 def grepbody(fn, rev, body):
3178 def grepbody(fn, rev, body):
3179 matches[rev].setdefault(fn, [])
3179 matches[rev].setdefault(fn, [])
3180 m = matches[rev][fn]
3180 m = matches[rev][fn]
3181 for lnum, cstart, cend, line in matchlines(body):
3181 for lnum, cstart, cend, line in matchlines(body):
3182 s = linestate(line, lnum, cstart, cend)
3182 s = linestate(line, lnum, cstart, cend)
3183 m.append(s)
3183 m.append(s)
3184
3184
3185 def difflinestates(a, b):
3185 def difflinestates(a, b):
3186 sm = difflib.SequenceMatcher(None, a, b)
3186 sm = difflib.SequenceMatcher(None, a, b)
3187 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3187 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3188 if tag == 'insert':
3188 if tag == 'insert':
3189 for i in xrange(blo, bhi):
3189 for i in xrange(blo, bhi):
3190 yield ('+', b[i])
3190 yield ('+', b[i])
3191 elif tag == 'delete':
3191 elif tag == 'delete':
3192 for i in xrange(alo, ahi):
3192 for i in xrange(alo, ahi):
3193 yield ('-', a[i])
3193 yield ('-', a[i])
3194 elif tag == 'replace':
3194 elif tag == 'replace':
3195 for i in xrange(alo, ahi):
3195 for i in xrange(alo, ahi):
3196 yield ('-', a[i])
3196 yield ('-', a[i])
3197 for i in xrange(blo, bhi):
3197 for i in xrange(blo, bhi):
3198 yield ('+', b[i])
3198 yield ('+', b[i])
3199
3199
3200 def display(fn, ctx, pstates, states):
3200 def display(fn, ctx, pstates, states):
3201 rev = ctx.rev()
3201 rev = ctx.rev()
3202 datefunc = ui.quiet and util.shortdate or util.datestr
3202 datefunc = ui.quiet and util.shortdate or util.datestr
3203 found = False
3203 found = False
3204 filerevmatches = {}
3204 filerevmatches = {}
3205 def binary():
3205 def binary():
3206 flog = getfile(fn)
3206 flog = getfile(fn)
3207 return util.binary(flog.read(ctx.filenode(fn)))
3207 return util.binary(flog.read(ctx.filenode(fn)))
3208
3208
3209 if opts.get('all'):
3209 if opts.get('all'):
3210 iter = difflinestates(pstates, states)
3210 iter = difflinestates(pstates, states)
3211 else:
3211 else:
3212 iter = [('', l) for l in states]
3212 iter = [('', l) for l in states]
3213 for change, l in iter:
3213 for change, l in iter:
3214 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3214 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3215 before, match, after = None, None, None
3215 before, match, after = None, None, None
3216
3216
3217 if opts.get('line_number'):
3217 if opts.get('line_number'):
3218 cols.append((str(l.linenum), 'grep.linenumber'))
3218 cols.append((str(l.linenum), 'grep.linenumber'))
3219 if opts.get('all'):
3219 if opts.get('all'):
3220 cols.append((change, 'grep.change'))
3220 cols.append((change, 'grep.change'))
3221 if opts.get('user'):
3221 if opts.get('user'):
3222 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3222 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3223 if opts.get('date'):
3223 if opts.get('date'):
3224 cols.append((datefunc(ctx.date()), 'grep.date'))
3224 cols.append((datefunc(ctx.date()), 'grep.date'))
3225 if opts.get('files_with_matches'):
3225 if opts.get('files_with_matches'):
3226 c = (fn, rev)
3226 c = (fn, rev)
3227 if c in filerevmatches:
3227 if c in filerevmatches:
3228 continue
3228 continue
3229 filerevmatches[c] = 1
3229 filerevmatches[c] = 1
3230 else:
3230 else:
3231 before = l.line[:l.colstart]
3231 before = l.line[:l.colstart]
3232 match = l.line[l.colstart:l.colend]
3232 match = l.line[l.colstart:l.colend]
3233 after = l.line[l.colend:]
3233 after = l.line[l.colend:]
3234 for col, label in cols[:-1]:
3234 for col, label in cols[:-1]:
3235 ui.write(col, label=label)
3235 ui.write(col, label=label)
3236 ui.write(sep, label='grep.sep')
3236 ui.write(sep, label='grep.sep')
3237 ui.write(cols[-1][0], label=cols[-1][1])
3237 ui.write(cols[-1][0], label=cols[-1][1])
3238 if before is not None:
3238 if before is not None:
3239 ui.write(sep, label='grep.sep')
3239 ui.write(sep, label='grep.sep')
3240 if not opts.get('text') and binary():
3240 if not opts.get('text') and binary():
3241 ui.write(" Binary file matches")
3241 ui.write(" Binary file matches")
3242 else:
3242 else:
3243 ui.write(before)
3243 ui.write(before)
3244 ui.write(match, label='grep.match')
3244 ui.write(match, label='grep.match')
3245 ui.write(after)
3245 ui.write(after)
3246 ui.write(eol)
3246 ui.write(eol)
3247 found = True
3247 found = True
3248 return found
3248 return found
3249
3249
3250 skip = {}
3250 skip = {}
3251 revfiles = {}
3251 revfiles = {}
3252 matchfn = scmutil.match(repo[None], pats, opts)
3252 matchfn = scmutil.match(repo[None], pats, opts)
3253 found = False
3253 found = False
3254 follow = opts.get('follow')
3254 follow = opts.get('follow')
3255
3255
3256 def prep(ctx, fns):
3256 def prep(ctx, fns):
3257 rev = ctx.rev()
3257 rev = ctx.rev()
3258 pctx = ctx.p1()
3258 pctx = ctx.p1()
3259 parent = pctx.rev()
3259 parent = pctx.rev()
3260 matches.setdefault(rev, {})
3260 matches.setdefault(rev, {})
3261 matches.setdefault(parent, {})
3261 matches.setdefault(parent, {})
3262 files = revfiles.setdefault(rev, [])
3262 files = revfiles.setdefault(rev, [])
3263 for fn in fns:
3263 for fn in fns:
3264 flog = getfile(fn)
3264 flog = getfile(fn)
3265 try:
3265 try:
3266 fnode = ctx.filenode(fn)
3266 fnode = ctx.filenode(fn)
3267 except error.LookupError:
3267 except error.LookupError:
3268 continue
3268 continue
3269
3269
3270 copied = flog.renamed(fnode)
3270 copied = flog.renamed(fnode)
3271 copy = follow and copied and copied[0]
3271 copy = follow and copied and copied[0]
3272 if copy:
3272 if copy:
3273 copies.setdefault(rev, {})[fn] = copy
3273 copies.setdefault(rev, {})[fn] = copy
3274 if fn in skip:
3274 if fn in skip:
3275 if copy:
3275 if copy:
3276 skip[copy] = True
3276 skip[copy] = True
3277 continue
3277 continue
3278 files.append(fn)
3278 files.append(fn)
3279
3279
3280 if fn not in matches[rev]:
3280 if fn not in matches[rev]:
3281 grepbody(fn, rev, flog.read(fnode))
3281 grepbody(fn, rev, flog.read(fnode))
3282
3282
3283 pfn = copy or fn
3283 pfn = copy or fn
3284 if pfn not in matches[parent]:
3284 if pfn not in matches[parent]:
3285 try:
3285 try:
3286 fnode = pctx.filenode(pfn)
3286 fnode = pctx.filenode(pfn)
3287 grepbody(pfn, parent, flog.read(fnode))
3287 grepbody(pfn, parent, flog.read(fnode))
3288 except error.LookupError:
3288 except error.LookupError:
3289 pass
3289 pass
3290
3290
3291 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3291 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3292 rev = ctx.rev()
3292 rev = ctx.rev()
3293 parent = ctx.p1().rev()
3293 parent = ctx.p1().rev()
3294 for fn in sorted(revfiles.get(rev, [])):
3294 for fn in sorted(revfiles.get(rev, [])):
3295 states = matches[rev][fn]
3295 states = matches[rev][fn]
3296 copy = copies.get(rev, {}).get(fn)
3296 copy = copies.get(rev, {}).get(fn)
3297 if fn in skip:
3297 if fn in skip:
3298 if copy:
3298 if copy:
3299 skip[copy] = True
3299 skip[copy] = True
3300 continue
3300 continue
3301 pstates = matches.get(parent, {}).get(copy or fn, [])
3301 pstates = matches.get(parent, {}).get(copy or fn, [])
3302 if pstates or states:
3302 if pstates or states:
3303 r = display(fn, ctx, pstates, states)
3303 r = display(fn, ctx, pstates, states)
3304 found = found or r
3304 found = found or r
3305 if r and not opts.get('all'):
3305 if r and not opts.get('all'):
3306 skip[fn] = True
3306 skip[fn] = True
3307 if copy:
3307 if copy:
3308 skip[copy] = True
3308 skip[copy] = True
3309 del matches[rev]
3309 del matches[rev]
3310 del revfiles[rev]
3310 del revfiles[rev]
3311
3311
3312 return not found
3312 return not found
3313
3313
3314 @command('heads',
3314 @command('heads',
3315 [('r', 'rev', '',
3315 [('r', 'rev', '',
3316 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3316 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3317 ('t', 'topo', False, _('show topological heads only')),
3317 ('t', 'topo', False, _('show topological heads only')),
3318 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3318 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3319 ('c', 'closed', False, _('show normal and closed branch heads')),
3319 ('c', 'closed', False, _('show normal and closed branch heads')),
3320 ] + templateopts,
3320 ] + templateopts,
3321 _('[-ct] [-r STARTREV] [REV]...'))
3321 _('[-ct] [-r STARTREV] [REV]...'))
3322 def heads(ui, repo, *branchrevs, **opts):
3322 def heads(ui, repo, *branchrevs, **opts):
3323 """show current repository heads or show branch heads
3323 """show branch heads
3324
3324
3325 With no arguments, show all repository branch heads.
3325 With no arguments, show all open branch heads in the repository.
3326
3326 Branch heads are changesets that have no child changesets on the
3327 Repository "heads" are changesets with no child changesets. They are
3327 same branch. They are where development generally takes place and
3328 where development generally takes place and are the usual targets
3328 are the usual targets for update and merge operations.
3329 for update and merge operations. Branch heads are changesets that have
3329
3330 no child changeset on the same branch.
3330 If one or more REVs are given, only open branch heads on the
3331
3331 branches associated with the specified changesets are shown. This
3332 If one or more REVs are given, only branch heads on the branches
3332 means that you can use :hg:`heads .` to see the heads on the
3333 associated with the specified changesets are shown. This means
3333 currently checked-out branch.
3334 that you can use :hg:`heads foo` to see the heads on a branch
3335 named ``foo``.
3336
3334
3337 If -c/--closed is specified, also show branch heads marked closed
3335 If -c/--closed is specified, also show branch heads marked closed
3338 (see :hg:`commit --close-branch`).
3336 (see :hg:`commit --close-branch`).
3339
3337
3340 If STARTREV is specified, only those heads that are descendants of
3338 If STARTREV is specified, only those heads that are descendants of
3341 STARTREV will be displayed.
3339 STARTREV will be displayed.
3342
3340
3343 If -t/--topo is specified, named branch mechanics will be ignored and only
3341 If -t/--topo is specified, named branch mechanics will be ignored and only
3344 changesets without children will be shown.
3342 topological heads (changesets with no children) will be shown.
3345
3343
3346 Returns 0 if matching heads are found, 1 if not.
3344 Returns 0 if matching heads are found, 1 if not.
3347 """
3345 """
3348
3346
3349 start = None
3347 start = None
3350 if 'rev' in opts:
3348 if 'rev' in opts:
3351 start = scmutil.revsingle(repo, opts['rev'], None).node()
3349 start = scmutil.revsingle(repo, opts['rev'], None).node()
3352
3350
3353 if opts.get('topo'):
3351 if opts.get('topo'):
3354 heads = [repo[h] for h in repo.heads(start)]
3352 heads = [repo[h] for h in repo.heads(start)]
3355 else:
3353 else:
3356 heads = []
3354 heads = []
3357 for branch in repo.branchmap():
3355 for branch in repo.branchmap():
3358 heads += repo.branchheads(branch, start, opts.get('closed'))
3356 heads += repo.branchheads(branch, start, opts.get('closed'))
3359 heads = [repo[h] for h in heads]
3357 heads = [repo[h] for h in heads]
3360
3358
3361 if branchrevs:
3359 if branchrevs:
3362 branches = set(repo[br].branch() for br in branchrevs)
3360 branches = set(repo[br].branch() for br in branchrevs)
3363 heads = [h for h in heads if h.branch() in branches]
3361 heads = [h for h in heads if h.branch() in branches]
3364
3362
3365 if opts.get('active') and branchrevs:
3363 if opts.get('active') and branchrevs:
3366 dagheads = repo.heads(start)
3364 dagheads = repo.heads(start)
3367 heads = [h for h in heads if h.node() in dagheads]
3365 heads = [h for h in heads if h.node() in dagheads]
3368
3366
3369 if branchrevs:
3367 if branchrevs:
3370 haveheads = set(h.branch() for h in heads)
3368 haveheads = set(h.branch() for h in heads)
3371 if branches - haveheads:
3369 if branches - haveheads:
3372 headless = ', '.join(b for b in branches - haveheads)
3370 headless = ', '.join(b for b in branches - haveheads)
3373 msg = _('no open branch heads found on branches %s')
3371 msg = _('no open branch heads found on branches %s')
3374 if opts.get('rev'):
3372 if opts.get('rev'):
3375 msg += _(' (started at %s)') % opts['rev']
3373 msg += _(' (started at %s)') % opts['rev']
3376 ui.warn((msg + '\n') % headless)
3374 ui.warn((msg + '\n') % headless)
3377
3375
3378 if not heads:
3376 if not heads:
3379 return 1
3377 return 1
3380
3378
3381 heads = sorted(heads, key=lambda x: -x.rev())
3379 heads = sorted(heads, key=lambda x: -x.rev())
3382 displayer = cmdutil.show_changeset(ui, repo, opts)
3380 displayer = cmdutil.show_changeset(ui, repo, opts)
3383 for ctx in heads:
3381 for ctx in heads:
3384 displayer.show(ctx)
3382 displayer.show(ctx)
3385 displayer.close()
3383 displayer.close()
3386
3384
3387 @command('help',
3385 @command('help',
3388 [('e', 'extension', None, _('show only help for extensions')),
3386 [('e', 'extension', None, _('show only help for extensions')),
3389 ('c', 'command', None, _('show only help for commands')),
3387 ('c', 'command', None, _('show only help for commands')),
3390 ('k', 'keyword', '', _('show topics matching keyword')),
3388 ('k', 'keyword', '', _('show topics matching keyword')),
3391 ],
3389 ],
3392 _('[-ec] [TOPIC]'))
3390 _('[-ec] [TOPIC]'))
3393 def help_(ui, name=None, **opts):
3391 def help_(ui, name=None, **opts):
3394 """show help for a given topic or a help overview
3392 """show help for a given topic or a help overview
3395
3393
3396 With no arguments, print a list of commands with short help messages.
3394 With no arguments, print a list of commands with short help messages.
3397
3395
3398 Given a topic, extension, or command name, print help for that
3396 Given a topic, extension, or command name, print help for that
3399 topic.
3397 topic.
3400
3398
3401 Returns 0 if successful.
3399 Returns 0 if successful.
3402 """
3400 """
3403
3401
3404 textwidth = min(ui.termwidth(), 80) - 2
3402 textwidth = min(ui.termwidth(), 80) - 2
3405
3403
3406 keep = ui.verbose and ['verbose'] or []
3404 keep = ui.verbose and ['verbose'] or []
3407 text = help.help_(ui, name, **opts)
3405 text = help.help_(ui, name, **opts)
3408
3406
3409 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3407 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3410 if 'verbose' in pruned:
3408 if 'verbose' in pruned:
3411 keep.append('omitted')
3409 keep.append('omitted')
3412 else:
3410 else:
3413 keep.append('notomitted')
3411 keep.append('notomitted')
3414 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3412 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3415 ui.write(formatted)
3413 ui.write(formatted)
3416
3414
3417
3415
3418 @command('identify|id',
3416 @command('identify|id',
3419 [('r', 'rev', '',
3417 [('r', 'rev', '',
3420 _('identify the specified revision'), _('REV')),
3418 _('identify the specified revision'), _('REV')),
3421 ('n', 'num', None, _('show local revision number')),
3419 ('n', 'num', None, _('show local revision number')),
3422 ('i', 'id', None, _('show global revision id')),
3420 ('i', 'id', None, _('show global revision id')),
3423 ('b', 'branch', None, _('show branch')),
3421 ('b', 'branch', None, _('show branch')),
3424 ('t', 'tags', None, _('show tags')),
3422 ('t', 'tags', None, _('show tags')),
3425 ('B', 'bookmarks', None, _('show bookmarks')),
3423 ('B', 'bookmarks', None, _('show bookmarks')),
3426 ] + remoteopts,
3424 ] + remoteopts,
3427 _('[-nibtB] [-r REV] [SOURCE]'))
3425 _('[-nibtB] [-r REV] [SOURCE]'))
3428 def identify(ui, repo, source=None, rev=None,
3426 def identify(ui, repo, source=None, rev=None,
3429 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3427 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3430 """identify the working copy or specified revision
3428 """identify the working copy or specified revision
3431
3429
3432 Print a summary identifying the repository state at REV using one or
3430 Print a summary identifying the repository state at REV using one or
3433 two parent hash identifiers, followed by a "+" if the working
3431 two parent hash identifiers, followed by a "+" if the working
3434 directory has uncommitted changes, the branch name (if not default),
3432 directory has uncommitted changes, the branch name (if not default),
3435 a list of tags, and a list of bookmarks.
3433 a list of tags, and a list of bookmarks.
3436
3434
3437 When REV is not given, print a summary of the current state of the
3435 When REV is not given, print a summary of the current state of the
3438 repository.
3436 repository.
3439
3437
3440 Specifying a path to a repository root or Mercurial bundle will
3438 Specifying a path to a repository root or Mercurial bundle will
3441 cause lookup to operate on that repository/bundle.
3439 cause lookup to operate on that repository/bundle.
3442
3440
3443 .. container:: verbose
3441 .. container:: verbose
3444
3442
3445 Examples:
3443 Examples:
3446
3444
3447 - generate a build identifier for the working directory::
3445 - generate a build identifier for the working directory::
3448
3446
3449 hg id --id > build-id.dat
3447 hg id --id > build-id.dat
3450
3448
3451 - find the revision corresponding to a tag::
3449 - find the revision corresponding to a tag::
3452
3450
3453 hg id -n -r 1.3
3451 hg id -n -r 1.3
3454
3452
3455 - check the most recent revision of a remote repository::
3453 - check the most recent revision of a remote repository::
3456
3454
3457 hg id -r tip http://selenic.com/hg/
3455 hg id -r tip http://selenic.com/hg/
3458
3456
3459 Returns 0 if successful.
3457 Returns 0 if successful.
3460 """
3458 """
3461
3459
3462 if not repo and not source:
3460 if not repo and not source:
3463 raise util.Abort(_("there is no Mercurial repository here "
3461 raise util.Abort(_("there is no Mercurial repository here "
3464 "(.hg not found)"))
3462 "(.hg not found)"))
3465
3463
3466 hexfunc = ui.debugflag and hex or short
3464 hexfunc = ui.debugflag and hex or short
3467 default = not (num or id or branch or tags or bookmarks)
3465 default = not (num or id or branch or tags or bookmarks)
3468 output = []
3466 output = []
3469 revs = []
3467 revs = []
3470
3468
3471 if source:
3469 if source:
3472 source, branches = hg.parseurl(ui.expandpath(source))
3470 source, branches = hg.parseurl(ui.expandpath(source))
3473 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3471 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3474 repo = peer.local()
3472 repo = peer.local()
3475 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3473 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3476
3474
3477 if not repo:
3475 if not repo:
3478 if num or branch or tags:
3476 if num or branch or tags:
3479 raise util.Abort(
3477 raise util.Abort(
3480 _("can't query remote revision number, branch, or tags"))
3478 _("can't query remote revision number, branch, or tags"))
3481 if not rev and revs:
3479 if not rev and revs:
3482 rev = revs[0]
3480 rev = revs[0]
3483 if not rev:
3481 if not rev:
3484 rev = "tip"
3482 rev = "tip"
3485
3483
3486 remoterev = peer.lookup(rev)
3484 remoterev = peer.lookup(rev)
3487 if default or id:
3485 if default or id:
3488 output = [hexfunc(remoterev)]
3486 output = [hexfunc(remoterev)]
3489
3487
3490 def getbms():
3488 def getbms():
3491 bms = []
3489 bms = []
3492
3490
3493 if 'bookmarks' in peer.listkeys('namespaces'):
3491 if 'bookmarks' in peer.listkeys('namespaces'):
3494 hexremoterev = hex(remoterev)
3492 hexremoterev = hex(remoterev)
3495 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3493 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3496 if bmr == hexremoterev]
3494 if bmr == hexremoterev]
3497
3495
3498 return sorted(bms)
3496 return sorted(bms)
3499
3497
3500 if bookmarks:
3498 if bookmarks:
3501 output.extend(getbms())
3499 output.extend(getbms())
3502 elif default and not ui.quiet:
3500 elif default and not ui.quiet:
3503 # multiple bookmarks for a single parent separated by '/'
3501 # multiple bookmarks for a single parent separated by '/'
3504 bm = '/'.join(getbms())
3502 bm = '/'.join(getbms())
3505 if bm:
3503 if bm:
3506 output.append(bm)
3504 output.append(bm)
3507 else:
3505 else:
3508 if not rev:
3506 if not rev:
3509 ctx = repo[None]
3507 ctx = repo[None]
3510 parents = ctx.parents()
3508 parents = ctx.parents()
3511 changed = ""
3509 changed = ""
3512 if default or id or num:
3510 if default or id or num:
3513 if (util.any(repo.status())
3511 if (util.any(repo.status())
3514 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3512 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3515 changed = '+'
3513 changed = '+'
3516 if default or id:
3514 if default or id:
3517 output = ["%s%s" %
3515 output = ["%s%s" %
3518 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3516 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3519 if num:
3517 if num:
3520 output.append("%s%s" %
3518 output.append("%s%s" %
3521 ('+'.join([str(p.rev()) for p in parents]), changed))
3519 ('+'.join([str(p.rev()) for p in parents]), changed))
3522 else:
3520 else:
3523 ctx = scmutil.revsingle(repo, rev)
3521 ctx = scmutil.revsingle(repo, rev)
3524 if default or id:
3522 if default or id:
3525 output = [hexfunc(ctx.node())]
3523 output = [hexfunc(ctx.node())]
3526 if num:
3524 if num:
3527 output.append(str(ctx.rev()))
3525 output.append(str(ctx.rev()))
3528
3526
3529 if default and not ui.quiet:
3527 if default and not ui.quiet:
3530 b = ctx.branch()
3528 b = ctx.branch()
3531 if b != 'default':
3529 if b != 'default':
3532 output.append("(%s)" % b)
3530 output.append("(%s)" % b)
3533
3531
3534 # multiple tags for a single parent separated by '/'
3532 # multiple tags for a single parent separated by '/'
3535 t = '/'.join(ctx.tags())
3533 t = '/'.join(ctx.tags())
3536 if t:
3534 if t:
3537 output.append(t)
3535 output.append(t)
3538
3536
3539 # multiple bookmarks for a single parent separated by '/'
3537 # multiple bookmarks for a single parent separated by '/'
3540 bm = '/'.join(ctx.bookmarks())
3538 bm = '/'.join(ctx.bookmarks())
3541 if bm:
3539 if bm:
3542 output.append(bm)
3540 output.append(bm)
3543 else:
3541 else:
3544 if branch:
3542 if branch:
3545 output.append(ctx.branch())
3543 output.append(ctx.branch())
3546
3544
3547 if tags:
3545 if tags:
3548 output.extend(ctx.tags())
3546 output.extend(ctx.tags())
3549
3547
3550 if bookmarks:
3548 if bookmarks:
3551 output.extend(ctx.bookmarks())
3549 output.extend(ctx.bookmarks())
3552
3550
3553 ui.write("%s\n" % ' '.join(output))
3551 ui.write("%s\n" % ' '.join(output))
3554
3552
3555 @command('import|patch',
3553 @command('import|patch',
3556 [('p', 'strip', 1,
3554 [('p', 'strip', 1,
3557 _('directory strip option for patch. This has the same '
3555 _('directory strip option for patch. This has the same '
3558 'meaning as the corresponding patch option'), _('NUM')),
3556 'meaning as the corresponding patch option'), _('NUM')),
3559 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3557 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3560 ('e', 'edit', False, _('invoke editor on commit messages')),
3558 ('e', 'edit', False, _('invoke editor on commit messages')),
3561 ('f', 'force', None,
3559 ('f', 'force', None,
3562 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3560 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3563 ('', 'no-commit', None,
3561 ('', 'no-commit', None,
3564 _("don't commit, just update the working directory")),
3562 _("don't commit, just update the working directory")),
3565 ('', 'bypass', None,
3563 ('', 'bypass', None,
3566 _("apply patch without touching the working directory")),
3564 _("apply patch without touching the working directory")),
3567 ('', 'exact', None,
3565 ('', 'exact', None,
3568 _('apply patch to the nodes from which it was generated')),
3566 _('apply patch to the nodes from which it was generated')),
3569 ('', 'import-branch', None,
3567 ('', 'import-branch', None,
3570 _('use any branch information in patch (implied by --exact)'))] +
3568 _('use any branch information in patch (implied by --exact)'))] +
3571 commitopts + commitopts2 + similarityopts,
3569 commitopts + commitopts2 + similarityopts,
3572 _('[OPTION]... PATCH...'))
3570 _('[OPTION]... PATCH...'))
3573 def import_(ui, repo, patch1=None, *patches, **opts):
3571 def import_(ui, repo, patch1=None, *patches, **opts):
3574 """import an ordered set of patches
3572 """import an ordered set of patches
3575
3573
3576 Import a list of patches and commit them individually (unless
3574 Import a list of patches and commit them individually (unless
3577 --no-commit is specified).
3575 --no-commit is specified).
3578
3576
3579 Because import first applies changes to the working directory,
3577 Because import first applies changes to the working directory,
3580 import will abort if there are outstanding changes.
3578 import will abort if there are outstanding changes.
3581
3579
3582 You can import a patch straight from a mail message. Even patches
3580 You can import a patch straight from a mail message. Even patches
3583 as attachments work (to use the body part, it must have type
3581 as attachments work (to use the body part, it must have type
3584 text/plain or text/x-patch). From and Subject headers of email
3582 text/plain or text/x-patch). From and Subject headers of email
3585 message are used as default committer and commit message. All
3583 message are used as default committer and commit message. All
3586 text/plain body parts before first diff are added to commit
3584 text/plain body parts before first diff are added to commit
3587 message.
3585 message.
3588
3586
3589 If the imported patch was generated by :hg:`export`, user and
3587 If the imported patch was generated by :hg:`export`, user and
3590 description from patch override values from message headers and
3588 description from patch override values from message headers and
3591 body. Values given on command line with -m/--message and -u/--user
3589 body. Values given on command line with -m/--message and -u/--user
3592 override these.
3590 override these.
3593
3591
3594 If --exact is specified, import will set the working directory to
3592 If --exact is specified, import will set the working directory to
3595 the parent of each patch before applying it, and will abort if the
3593 the parent of each patch before applying it, and will abort if the
3596 resulting changeset has a different ID than the one recorded in
3594 resulting changeset has a different ID than the one recorded in
3597 the patch. This may happen due to character set problems or other
3595 the patch. This may happen due to character set problems or other
3598 deficiencies in the text patch format.
3596 deficiencies in the text patch format.
3599
3597
3600 Use --bypass to apply and commit patches directly to the
3598 Use --bypass to apply and commit patches directly to the
3601 repository, not touching the working directory. Without --exact,
3599 repository, not touching the working directory. Without --exact,
3602 patches will be applied on top of the working directory parent
3600 patches will be applied on top of the working directory parent
3603 revision.
3601 revision.
3604
3602
3605 With -s/--similarity, hg will attempt to discover renames and
3603 With -s/--similarity, hg will attempt to discover renames and
3606 copies in the patch in the same way as :hg:`addremove`.
3604 copies in the patch in the same way as :hg:`addremove`.
3607
3605
3608 To read a patch from standard input, use "-" as the patch name. If
3606 To read a patch from standard input, use "-" as the patch name. If
3609 a URL is specified, the patch will be downloaded from it.
3607 a URL is specified, the patch will be downloaded from it.
3610 See :hg:`help dates` for a list of formats valid for -d/--date.
3608 See :hg:`help dates` for a list of formats valid for -d/--date.
3611
3609
3612 .. container:: verbose
3610 .. container:: verbose
3613
3611
3614 Examples:
3612 Examples:
3615
3613
3616 - import a traditional patch from a website and detect renames::
3614 - import a traditional patch from a website and detect renames::
3617
3615
3618 hg import -s 80 http://example.com/bugfix.patch
3616 hg import -s 80 http://example.com/bugfix.patch
3619
3617
3620 - import a changeset from an hgweb server::
3618 - import a changeset from an hgweb server::
3621
3619
3622 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
3620 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
3623
3621
3624 - import all the patches in an Unix-style mbox::
3622 - import all the patches in an Unix-style mbox::
3625
3623
3626 hg import incoming-patches.mbox
3624 hg import incoming-patches.mbox
3627
3625
3628 - attempt to exactly restore an exported changeset (not always
3626 - attempt to exactly restore an exported changeset (not always
3629 possible)::
3627 possible)::
3630
3628
3631 hg import --exact proposed-fix.patch
3629 hg import --exact proposed-fix.patch
3632
3630
3633 Returns 0 on success.
3631 Returns 0 on success.
3634 """
3632 """
3635
3633
3636 if not patch1:
3634 if not patch1:
3637 raise util.Abort(_('need at least one patch to import'))
3635 raise util.Abort(_('need at least one patch to import'))
3638
3636
3639 patches = (patch1,) + patches
3637 patches = (patch1,) + patches
3640
3638
3641 date = opts.get('date')
3639 date = opts.get('date')
3642 if date:
3640 if date:
3643 opts['date'] = util.parsedate(date)
3641 opts['date'] = util.parsedate(date)
3644
3642
3645 editor = cmdutil.commiteditor
3643 editor = cmdutil.commiteditor
3646 if opts.get('edit'):
3644 if opts.get('edit'):
3647 editor = cmdutil.commitforceeditor
3645 editor = cmdutil.commitforceeditor
3648
3646
3649 update = not opts.get('bypass')
3647 update = not opts.get('bypass')
3650 if not update and opts.get('no_commit'):
3648 if not update and opts.get('no_commit'):
3651 raise util.Abort(_('cannot use --no-commit with --bypass'))
3649 raise util.Abort(_('cannot use --no-commit with --bypass'))
3652 try:
3650 try:
3653 sim = float(opts.get('similarity') or 0)
3651 sim = float(opts.get('similarity') or 0)
3654 except ValueError:
3652 except ValueError:
3655 raise util.Abort(_('similarity must be a number'))
3653 raise util.Abort(_('similarity must be a number'))
3656 if sim < 0 or sim > 100:
3654 if sim < 0 or sim > 100:
3657 raise util.Abort(_('similarity must be between 0 and 100'))
3655 raise util.Abort(_('similarity must be between 0 and 100'))
3658 if sim and not update:
3656 if sim and not update:
3659 raise util.Abort(_('cannot use --similarity with --bypass'))
3657 raise util.Abort(_('cannot use --similarity with --bypass'))
3660
3658
3661 if (opts.get('exact') or not opts.get('force')) and update:
3659 if (opts.get('exact') or not opts.get('force')) and update:
3662 cmdutil.bailifchanged(repo)
3660 cmdutil.bailifchanged(repo)
3663
3661
3664 base = opts["base"]
3662 base = opts["base"]
3665 strip = opts["strip"]
3663 strip = opts["strip"]
3666 wlock = lock = tr = None
3664 wlock = lock = tr = None
3667 msgs = []
3665 msgs = []
3668
3666
3669 def tryone(ui, hunk, parents):
3667 def tryone(ui, hunk, parents):
3670 tmpname, message, user, date, branch, nodeid, p1, p2 = \
3668 tmpname, message, user, date, branch, nodeid, p1, p2 = \
3671 patch.extract(ui, hunk)
3669 patch.extract(ui, hunk)
3672
3670
3673 if not tmpname:
3671 if not tmpname:
3674 return (None, None)
3672 return (None, None)
3675 msg = _('applied to working directory')
3673 msg = _('applied to working directory')
3676
3674
3677 try:
3675 try:
3678 cmdline_message = cmdutil.logmessage(ui, opts)
3676 cmdline_message = cmdutil.logmessage(ui, opts)
3679 if cmdline_message:
3677 if cmdline_message:
3680 # pickup the cmdline msg
3678 # pickup the cmdline msg
3681 message = cmdline_message
3679 message = cmdline_message
3682 elif message:
3680 elif message:
3683 # pickup the patch msg
3681 # pickup the patch msg
3684 message = message.strip()
3682 message = message.strip()
3685 else:
3683 else:
3686 # launch the editor
3684 # launch the editor
3687 message = None
3685 message = None
3688 ui.debug('message:\n%s\n' % message)
3686 ui.debug('message:\n%s\n' % message)
3689
3687
3690 if len(parents) == 1:
3688 if len(parents) == 1:
3691 parents.append(repo[nullid])
3689 parents.append(repo[nullid])
3692 if opts.get('exact'):
3690 if opts.get('exact'):
3693 if not nodeid or not p1:
3691 if not nodeid or not p1:
3694 raise util.Abort(_('not a Mercurial patch'))
3692 raise util.Abort(_('not a Mercurial patch'))
3695 p1 = repo[p1]
3693 p1 = repo[p1]
3696 p2 = repo[p2 or nullid]
3694 p2 = repo[p2 or nullid]
3697 elif p2:
3695 elif p2:
3698 try:
3696 try:
3699 p1 = repo[p1]
3697 p1 = repo[p1]
3700 p2 = repo[p2]
3698 p2 = repo[p2]
3701 # Without any options, consider p2 only if the
3699 # Without any options, consider p2 only if the
3702 # patch is being applied on top of the recorded
3700 # patch is being applied on top of the recorded
3703 # first parent.
3701 # first parent.
3704 if p1 != parents[0]:
3702 if p1 != parents[0]:
3705 p1 = parents[0]
3703 p1 = parents[0]
3706 p2 = repo[nullid]
3704 p2 = repo[nullid]
3707 except error.RepoError:
3705 except error.RepoError:
3708 p1, p2 = parents
3706 p1, p2 = parents
3709 else:
3707 else:
3710 p1, p2 = parents
3708 p1, p2 = parents
3711
3709
3712 n = None
3710 n = None
3713 if update:
3711 if update:
3714 if p1 != parents[0]:
3712 if p1 != parents[0]:
3715 hg.clean(repo, p1.node())
3713 hg.clean(repo, p1.node())
3716 if p2 != parents[1]:
3714 if p2 != parents[1]:
3717 repo.setparents(p1.node(), p2.node())
3715 repo.setparents(p1.node(), p2.node())
3718
3716
3719 if opts.get('exact') or opts.get('import_branch'):
3717 if opts.get('exact') or opts.get('import_branch'):
3720 repo.dirstate.setbranch(branch or 'default')
3718 repo.dirstate.setbranch(branch or 'default')
3721
3719
3722 files = set()
3720 files = set()
3723 patch.patch(ui, repo, tmpname, strip=strip, files=files,
3721 patch.patch(ui, repo, tmpname, strip=strip, files=files,
3724 eolmode=None, similarity=sim / 100.0)
3722 eolmode=None, similarity=sim / 100.0)
3725 files = list(files)
3723 files = list(files)
3726 if opts.get('no_commit'):
3724 if opts.get('no_commit'):
3727 if message:
3725 if message:
3728 msgs.append(message)
3726 msgs.append(message)
3729 else:
3727 else:
3730 if opts.get('exact') or p2:
3728 if opts.get('exact') or p2:
3731 # If you got here, you either use --force and know what
3729 # If you got here, you either use --force and know what
3732 # you are doing or used --exact or a merge patch while
3730 # you are doing or used --exact or a merge patch while
3733 # being updated to its first parent.
3731 # being updated to its first parent.
3734 m = None
3732 m = None
3735 else:
3733 else:
3736 m = scmutil.matchfiles(repo, files or [])
3734 m = scmutil.matchfiles(repo, files or [])
3737 n = repo.commit(message, opts.get('user') or user,
3735 n = repo.commit(message, opts.get('user') or user,
3738 opts.get('date') or date, match=m,
3736 opts.get('date') or date, match=m,
3739 editor=editor)
3737 editor=editor)
3740 else:
3738 else:
3741 if opts.get('exact') or opts.get('import_branch'):
3739 if opts.get('exact') or opts.get('import_branch'):
3742 branch = branch or 'default'
3740 branch = branch or 'default'
3743 else:
3741 else:
3744 branch = p1.branch()
3742 branch = p1.branch()
3745 store = patch.filestore()
3743 store = patch.filestore()
3746 try:
3744 try:
3747 files = set()
3745 files = set()
3748 try:
3746 try:
3749 patch.patchrepo(ui, repo, p1, store, tmpname, strip,
3747 patch.patchrepo(ui, repo, p1, store, tmpname, strip,
3750 files, eolmode=None)
3748 files, eolmode=None)
3751 except patch.PatchError, e:
3749 except patch.PatchError, e:
3752 raise util.Abort(str(e))
3750 raise util.Abort(str(e))
3753 memctx = patch.makememctx(repo, (p1.node(), p2.node()),
3751 memctx = patch.makememctx(repo, (p1.node(), p2.node()),
3754 message,
3752 message,
3755 opts.get('user') or user,
3753 opts.get('user') or user,
3756 opts.get('date') or date,
3754 opts.get('date') or date,
3757 branch, files, store,
3755 branch, files, store,
3758 editor=cmdutil.commiteditor)
3756 editor=cmdutil.commiteditor)
3759 repo.savecommitmessage(memctx.description())
3757 repo.savecommitmessage(memctx.description())
3760 n = memctx.commit()
3758 n = memctx.commit()
3761 finally:
3759 finally:
3762 store.close()
3760 store.close()
3763 if opts.get('exact') and hex(n) != nodeid:
3761 if opts.get('exact') and hex(n) != nodeid:
3764 raise util.Abort(_('patch is damaged or loses information'))
3762 raise util.Abort(_('patch is damaged or loses information'))
3765 if n:
3763 if n:
3766 # i18n: refers to a short changeset id
3764 # i18n: refers to a short changeset id
3767 msg = _('created %s') % short(n)
3765 msg = _('created %s') % short(n)
3768 return (msg, n)
3766 return (msg, n)
3769 finally:
3767 finally:
3770 os.unlink(tmpname)
3768 os.unlink(tmpname)
3771
3769
3772 try:
3770 try:
3773 try:
3771 try:
3774 wlock = repo.wlock()
3772 wlock = repo.wlock()
3775 if not opts.get('no_commit'):
3773 if not opts.get('no_commit'):
3776 lock = repo.lock()
3774 lock = repo.lock()
3777 tr = repo.transaction('import')
3775 tr = repo.transaction('import')
3778 parents = repo.parents()
3776 parents = repo.parents()
3779 for patchurl in patches:
3777 for patchurl in patches:
3780 if patchurl == '-':
3778 if patchurl == '-':
3781 ui.status(_('applying patch from stdin\n'))
3779 ui.status(_('applying patch from stdin\n'))
3782 patchfile = ui.fin
3780 patchfile = ui.fin
3783 patchurl = 'stdin' # for error message
3781 patchurl = 'stdin' # for error message
3784 else:
3782 else:
3785 patchurl = os.path.join(base, patchurl)
3783 patchurl = os.path.join(base, patchurl)
3786 ui.status(_('applying %s\n') % patchurl)
3784 ui.status(_('applying %s\n') % patchurl)
3787 patchfile = hg.openpath(ui, patchurl)
3785 patchfile = hg.openpath(ui, patchurl)
3788
3786
3789 haspatch = False
3787 haspatch = False
3790 for hunk in patch.split(patchfile):
3788 for hunk in patch.split(patchfile):
3791 (msg, node) = tryone(ui, hunk, parents)
3789 (msg, node) = tryone(ui, hunk, parents)
3792 if msg:
3790 if msg:
3793 haspatch = True
3791 haspatch = True
3794 ui.note(msg + '\n')
3792 ui.note(msg + '\n')
3795 if update or opts.get('exact'):
3793 if update or opts.get('exact'):
3796 parents = repo.parents()
3794 parents = repo.parents()
3797 else:
3795 else:
3798 parents = [repo[node]]
3796 parents = [repo[node]]
3799
3797
3800 if not haspatch:
3798 if not haspatch:
3801 raise util.Abort(_('%s: no diffs found') % patchurl)
3799 raise util.Abort(_('%s: no diffs found') % patchurl)
3802
3800
3803 if tr:
3801 if tr:
3804 tr.close()
3802 tr.close()
3805 if msgs:
3803 if msgs:
3806 repo.savecommitmessage('\n* * *\n'.join(msgs))
3804 repo.savecommitmessage('\n* * *\n'.join(msgs))
3807 except: # re-raises
3805 except: # re-raises
3808 # wlock.release() indirectly calls dirstate.write(): since
3806 # wlock.release() indirectly calls dirstate.write(): since
3809 # we're crashing, we do not want to change the working dir
3807 # we're crashing, we do not want to change the working dir
3810 # parent after all, so make sure it writes nothing
3808 # parent after all, so make sure it writes nothing
3811 repo.dirstate.invalidate()
3809 repo.dirstate.invalidate()
3812 raise
3810 raise
3813 finally:
3811 finally:
3814 if tr:
3812 if tr:
3815 tr.release()
3813 tr.release()
3816 release(lock, wlock)
3814 release(lock, wlock)
3817
3815
3818 @command('incoming|in',
3816 @command('incoming|in',
3819 [('f', 'force', None,
3817 [('f', 'force', None,
3820 _('run even if remote repository is unrelated')),
3818 _('run even if remote repository is unrelated')),
3821 ('n', 'newest-first', None, _('show newest record first')),
3819 ('n', 'newest-first', None, _('show newest record first')),
3822 ('', 'bundle', '',
3820 ('', 'bundle', '',
3823 _('file to store the bundles into'), _('FILE')),
3821 _('file to store the bundles into'), _('FILE')),
3824 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3822 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3825 ('B', 'bookmarks', False, _("compare bookmarks")),
3823 ('B', 'bookmarks', False, _("compare bookmarks")),
3826 ('b', 'branch', [],
3824 ('b', 'branch', [],
3827 _('a specific branch you would like to pull'), _('BRANCH')),
3825 _('a specific branch you would like to pull'), _('BRANCH')),
3828 ] + logopts + remoteopts + subrepoopts,
3826 ] + logopts + remoteopts + subrepoopts,
3829 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3827 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3830 def incoming(ui, repo, source="default", **opts):
3828 def incoming(ui, repo, source="default", **opts):
3831 """show new changesets found in source
3829 """show new changesets found in source
3832
3830
3833 Show new changesets found in the specified path/URL or the default
3831 Show new changesets found in the specified path/URL or the default
3834 pull location. These are the changesets that would have been pulled
3832 pull location. These are the changesets that would have been pulled
3835 if a pull at the time you issued this command.
3833 if a pull at the time you issued this command.
3836
3834
3837 For remote repository, using --bundle avoids downloading the
3835 For remote repository, using --bundle avoids downloading the
3838 changesets twice if the incoming is followed by a pull.
3836 changesets twice if the incoming is followed by a pull.
3839
3837
3840 See pull for valid source format details.
3838 See pull for valid source format details.
3841
3839
3842 Returns 0 if there are incoming changes, 1 otherwise.
3840 Returns 0 if there are incoming changes, 1 otherwise.
3843 """
3841 """
3844 if opts.get('graph'):
3842 if opts.get('graph'):
3845 cmdutil.checkunsupportedgraphflags([], opts)
3843 cmdutil.checkunsupportedgraphflags([], opts)
3846 def display(other, chlist, displayer):
3844 def display(other, chlist, displayer):
3847 revdag = cmdutil.graphrevs(other, chlist, opts)
3845 revdag = cmdutil.graphrevs(other, chlist, opts)
3848 showparents = [ctx.node() for ctx in repo[None].parents()]
3846 showparents = [ctx.node() for ctx in repo[None].parents()]
3849 cmdutil.displaygraph(ui, revdag, displayer, showparents,
3847 cmdutil.displaygraph(ui, revdag, displayer, showparents,
3850 graphmod.asciiedges)
3848 graphmod.asciiedges)
3851
3849
3852 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3850 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3853 return 0
3851 return 0
3854
3852
3855 if opts.get('bundle') and opts.get('subrepos'):
3853 if opts.get('bundle') and opts.get('subrepos'):
3856 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3854 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3857
3855
3858 if opts.get('bookmarks'):
3856 if opts.get('bookmarks'):
3859 source, branches = hg.parseurl(ui.expandpath(source),
3857 source, branches = hg.parseurl(ui.expandpath(source),
3860 opts.get('branch'))
3858 opts.get('branch'))
3861 other = hg.peer(repo, opts, source)
3859 other = hg.peer(repo, opts, source)
3862 if 'bookmarks' not in other.listkeys('namespaces'):
3860 if 'bookmarks' not in other.listkeys('namespaces'):
3863 ui.warn(_("remote doesn't support bookmarks\n"))
3861 ui.warn(_("remote doesn't support bookmarks\n"))
3864 return 0
3862 return 0
3865 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3863 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3866 return bookmarks.diff(ui, repo, other)
3864 return bookmarks.diff(ui, repo, other)
3867
3865
3868 repo._subtoppath = ui.expandpath(source)
3866 repo._subtoppath = ui.expandpath(source)
3869 try:
3867 try:
3870 return hg.incoming(ui, repo, source, opts)
3868 return hg.incoming(ui, repo, source, opts)
3871 finally:
3869 finally:
3872 del repo._subtoppath
3870 del repo._subtoppath
3873
3871
3874
3872
3875 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'))
3873 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'))
3876 def init(ui, dest=".", **opts):
3874 def init(ui, dest=".", **opts):
3877 """create a new repository in the given directory
3875 """create a new repository in the given directory
3878
3876
3879 Initialize a new repository in the given directory. If the given
3877 Initialize a new repository in the given directory. If the given
3880 directory does not exist, it will be created.
3878 directory does not exist, it will be created.
3881
3879
3882 If no directory is given, the current directory is used.
3880 If no directory is given, the current directory is used.
3883
3881
3884 It is possible to specify an ``ssh://`` URL as the destination.
3882 It is possible to specify an ``ssh://`` URL as the destination.
3885 See :hg:`help urls` for more information.
3883 See :hg:`help urls` for more information.
3886
3884
3887 Returns 0 on success.
3885 Returns 0 on success.
3888 """
3886 """
3889 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3887 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3890
3888
3891 @command('locate',
3889 @command('locate',
3892 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3890 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3893 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3891 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3894 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3892 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3895 ] + walkopts,
3893 ] + walkopts,
3896 _('[OPTION]... [PATTERN]...'))
3894 _('[OPTION]... [PATTERN]...'))
3897 def locate(ui, repo, *pats, **opts):
3895 def locate(ui, repo, *pats, **opts):
3898 """locate files matching specific patterns
3896 """locate files matching specific patterns
3899
3897
3900 Print files under Mercurial control in the working directory whose
3898 Print files under Mercurial control in the working directory whose
3901 names match the given patterns.
3899 names match the given patterns.
3902
3900
3903 By default, this command searches all directories in the working
3901 By default, this command searches all directories in the working
3904 directory. To search just the current directory and its
3902 directory. To search just the current directory and its
3905 subdirectories, use "--include .".
3903 subdirectories, use "--include .".
3906
3904
3907 If no patterns are given to match, this command prints the names
3905 If no patterns are given to match, this command prints the names
3908 of all files under Mercurial control in the working directory.
3906 of all files under Mercurial control in the working directory.
3909
3907
3910 If you want to feed the output of this command into the "xargs"
3908 If you want to feed the output of this command into the "xargs"
3911 command, use the -0 option to both this command and "xargs". This
3909 command, use the -0 option to both this command and "xargs". This
3912 will avoid the problem of "xargs" treating single filenames that
3910 will avoid the problem of "xargs" treating single filenames that
3913 contain whitespace as multiple filenames.
3911 contain whitespace as multiple filenames.
3914
3912
3915 Returns 0 if a match is found, 1 otherwise.
3913 Returns 0 if a match is found, 1 otherwise.
3916 """
3914 """
3917 end = opts.get('print0') and '\0' or '\n'
3915 end = opts.get('print0') and '\0' or '\n'
3918 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3916 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3919
3917
3920 ret = 1
3918 ret = 1
3921 m = scmutil.match(repo[rev], pats, opts, default='relglob')
3919 m = scmutil.match(repo[rev], pats, opts, default='relglob')
3922 m.bad = lambda x, y: False
3920 m.bad = lambda x, y: False
3923 for abs in repo[rev].walk(m):
3921 for abs in repo[rev].walk(m):
3924 if not rev and abs not in repo.dirstate:
3922 if not rev and abs not in repo.dirstate:
3925 continue
3923 continue
3926 if opts.get('fullpath'):
3924 if opts.get('fullpath'):
3927 ui.write(repo.wjoin(abs), end)
3925 ui.write(repo.wjoin(abs), end)
3928 else:
3926 else:
3929 ui.write(((pats and m.rel(abs)) or abs), end)
3927 ui.write(((pats and m.rel(abs)) or abs), end)
3930 ret = 0
3928 ret = 0
3931
3929
3932 return ret
3930 return ret
3933
3931
3934 @command('^log|history',
3932 @command('^log|history',
3935 [('f', 'follow', None,
3933 [('f', 'follow', None,
3936 _('follow changeset history, or file history across copies and renames')),
3934 _('follow changeset history, or file history across copies and renames')),
3937 ('', 'follow-first', None,
3935 ('', 'follow-first', None,
3938 _('only follow the first parent of merge changesets (DEPRECATED)')),
3936 _('only follow the first parent of merge changesets (DEPRECATED)')),
3939 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3937 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3940 ('C', 'copies', None, _('show copied files')),
3938 ('C', 'copies', None, _('show copied files')),
3941 ('k', 'keyword', [],
3939 ('k', 'keyword', [],
3942 _('do case-insensitive search for a given text'), _('TEXT')),
3940 _('do case-insensitive search for a given text'), _('TEXT')),
3943 ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
3941 ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
3944 ('', 'removed', None, _('include revisions where files were removed')),
3942 ('', 'removed', None, _('include revisions where files were removed')),
3945 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3943 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3946 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3944 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3947 ('', 'only-branch', [],
3945 ('', 'only-branch', [],
3948 _('show only changesets within the given named branch (DEPRECATED)'),
3946 _('show only changesets within the given named branch (DEPRECATED)'),
3949 _('BRANCH')),
3947 _('BRANCH')),
3950 ('b', 'branch', [],
3948 ('b', 'branch', [],
3951 _('show changesets within the given named branch'), _('BRANCH')),
3949 _('show changesets within the given named branch'), _('BRANCH')),
3952 ('P', 'prune', [],
3950 ('P', 'prune', [],
3953 _('do not display revision or any of its ancestors'), _('REV')),
3951 _('do not display revision or any of its ancestors'), _('REV')),
3954 ] + logopts + walkopts,
3952 ] + logopts + walkopts,
3955 _('[OPTION]... [FILE]'))
3953 _('[OPTION]... [FILE]'))
3956 def log(ui, repo, *pats, **opts):
3954 def log(ui, repo, *pats, **opts):
3957 """show revision history of entire repository or files
3955 """show revision history of entire repository or files
3958
3956
3959 Print the revision history of the specified files or the entire
3957 Print the revision history of the specified files or the entire
3960 project.
3958 project.
3961
3959
3962 If no revision range is specified, the default is ``tip:0`` unless
3960 If no revision range is specified, the default is ``tip:0`` unless
3963 --follow is set, in which case the working directory parent is
3961 --follow is set, in which case the working directory parent is
3964 used as the starting revision.
3962 used as the starting revision.
3965
3963
3966 File history is shown without following rename or copy history of
3964 File history is shown without following rename or copy history of
3967 files. Use -f/--follow with a filename to follow history across
3965 files. Use -f/--follow with a filename to follow history across
3968 renames and copies. --follow without a filename will only show
3966 renames and copies. --follow without a filename will only show
3969 ancestors or descendants of the starting revision.
3967 ancestors or descendants of the starting revision.
3970
3968
3971 By default this command prints revision number and changeset id,
3969 By default this command prints revision number and changeset id,
3972 tags, non-trivial parents, user, date and time, and a summary for
3970 tags, non-trivial parents, user, date and time, and a summary for
3973 each commit. When the -v/--verbose switch is used, the list of
3971 each commit. When the -v/--verbose switch is used, the list of
3974 changed files and full commit message are shown.
3972 changed files and full commit message are shown.
3975
3973
3976 .. note::
3974 .. note::
3977 log -p/--patch may generate unexpected diff output for merge
3975 log -p/--patch may generate unexpected diff output for merge
3978 changesets, as it will only compare the merge changeset against
3976 changesets, as it will only compare the merge changeset against
3979 its first parent. Also, only files different from BOTH parents
3977 its first parent. Also, only files different from BOTH parents
3980 will appear in files:.
3978 will appear in files:.
3981
3979
3982 .. note::
3980 .. note::
3983 for performance reasons, log FILE may omit duplicate changes
3981 for performance reasons, log FILE may omit duplicate changes
3984 made on branches and will not show deletions. To see all
3982 made on branches and will not show deletions. To see all
3985 changes including duplicates and deletions, use the --removed
3983 changes including duplicates and deletions, use the --removed
3986 switch.
3984 switch.
3987
3985
3988 .. container:: verbose
3986 .. container:: verbose
3989
3987
3990 Some examples:
3988 Some examples:
3991
3989
3992 - changesets with full descriptions and file lists::
3990 - changesets with full descriptions and file lists::
3993
3991
3994 hg log -v
3992 hg log -v
3995
3993
3996 - changesets ancestral to the working directory::
3994 - changesets ancestral to the working directory::
3997
3995
3998 hg log -f
3996 hg log -f
3999
3997
4000 - last 10 commits on the current branch::
3998 - last 10 commits on the current branch::
4001
3999
4002 hg log -l 10 -b .
4000 hg log -l 10 -b .
4003
4001
4004 - changesets showing all modifications of a file, including removals::
4002 - changesets showing all modifications of a file, including removals::
4005
4003
4006 hg log --removed file.c
4004 hg log --removed file.c
4007
4005
4008 - all changesets that touch a directory, with diffs, excluding merges::
4006 - all changesets that touch a directory, with diffs, excluding merges::
4009
4007
4010 hg log -Mp lib/
4008 hg log -Mp lib/
4011
4009
4012 - all revision numbers that match a keyword::
4010 - all revision numbers that match a keyword::
4013
4011
4014 hg log -k bug --template "{rev}\\n"
4012 hg log -k bug --template "{rev}\\n"
4015
4013
4016 - check if a given changeset is included is a tagged release::
4014 - check if a given changeset is included is a tagged release::
4017
4015
4018 hg log -r "a21ccf and ancestor(1.9)"
4016 hg log -r "a21ccf and ancestor(1.9)"
4019
4017
4020 - find all changesets by some user in a date range::
4018 - find all changesets by some user in a date range::
4021
4019
4022 hg log -k alice -d "may 2008 to jul 2008"
4020 hg log -k alice -d "may 2008 to jul 2008"
4023
4021
4024 - summary of all changesets after the last tag::
4022 - summary of all changesets after the last tag::
4025
4023
4026 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4024 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4027
4025
4028 See :hg:`help dates` for a list of formats valid for -d/--date.
4026 See :hg:`help dates` for a list of formats valid for -d/--date.
4029
4027
4030 See :hg:`help revisions` and :hg:`help revsets` for more about
4028 See :hg:`help revisions` and :hg:`help revsets` for more about
4031 specifying revisions.
4029 specifying revisions.
4032
4030
4033 See :hg:`help templates` for more about pre-packaged styles and
4031 See :hg:`help templates` for more about pre-packaged styles and
4034 specifying custom templates.
4032 specifying custom templates.
4035
4033
4036 Returns 0 on success.
4034 Returns 0 on success.
4037 """
4035 """
4038 if opts.get('graph'):
4036 if opts.get('graph'):
4039 return cmdutil.graphlog(ui, repo, *pats, **opts)
4037 return cmdutil.graphlog(ui, repo, *pats, **opts)
4040
4038
4041 matchfn = scmutil.match(repo[None], pats, opts)
4039 matchfn = scmutil.match(repo[None], pats, opts)
4042 limit = cmdutil.loglimit(opts)
4040 limit = cmdutil.loglimit(opts)
4043 count = 0
4041 count = 0
4044
4042
4045 getrenamed, endrev = None, None
4043 getrenamed, endrev = None, None
4046 if opts.get('copies'):
4044 if opts.get('copies'):
4047 if opts.get('rev'):
4045 if opts.get('rev'):
4048 endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
4046 endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
4049 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4047 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4050
4048
4051 df = False
4049 df = False
4052 if opts.get("date"):
4050 if opts.get("date"):
4053 df = util.matchdate(opts["date"])
4051 df = util.matchdate(opts["date"])
4054
4052
4055 branches = opts.get('branch', []) + opts.get('only_branch', [])
4053 branches = opts.get('branch', []) + opts.get('only_branch', [])
4056 opts['branch'] = [repo.lookupbranch(b) for b in branches]
4054 opts['branch'] = [repo.lookupbranch(b) for b in branches]
4057
4055
4058 displayer = cmdutil.show_changeset(ui, repo, opts, True)
4056 displayer = cmdutil.show_changeset(ui, repo, opts, True)
4059 def prep(ctx, fns):
4057 def prep(ctx, fns):
4060 rev = ctx.rev()
4058 rev = ctx.rev()
4061 parents = [p for p in repo.changelog.parentrevs(rev)
4059 parents = [p for p in repo.changelog.parentrevs(rev)
4062 if p != nullrev]
4060 if p != nullrev]
4063 if opts.get('no_merges') and len(parents) == 2:
4061 if opts.get('no_merges') and len(parents) == 2:
4064 return
4062 return
4065 if opts.get('only_merges') and len(parents) != 2:
4063 if opts.get('only_merges') and len(parents) != 2:
4066 return
4064 return
4067 if opts.get('branch') and ctx.branch() not in opts['branch']:
4065 if opts.get('branch') and ctx.branch() not in opts['branch']:
4068 return
4066 return
4069 if df and not df(ctx.date()[0]):
4067 if df and not df(ctx.date()[0]):
4070 return
4068 return
4071
4069
4072 lower = encoding.lower
4070 lower = encoding.lower
4073 if opts.get('user'):
4071 if opts.get('user'):
4074 luser = lower(ctx.user())
4072 luser = lower(ctx.user())
4075 for k in [lower(x) for x in opts['user']]:
4073 for k in [lower(x) for x in opts['user']]:
4076 if (k in luser):
4074 if (k in luser):
4077 break
4075 break
4078 else:
4076 else:
4079 return
4077 return
4080 if opts.get('keyword'):
4078 if opts.get('keyword'):
4081 luser = lower(ctx.user())
4079 luser = lower(ctx.user())
4082 ldesc = lower(ctx.description())
4080 ldesc = lower(ctx.description())
4083 lfiles = lower(" ".join(ctx.files()))
4081 lfiles = lower(" ".join(ctx.files()))
4084 for k in [lower(x) for x in opts['keyword']]:
4082 for k in [lower(x) for x in opts['keyword']]:
4085 if (k in luser or k in ldesc or k in lfiles):
4083 if (k in luser or k in ldesc or k in lfiles):
4086 break
4084 break
4087 else:
4085 else:
4088 return
4086 return
4089
4087
4090 copies = None
4088 copies = None
4091 if getrenamed is not None and rev:
4089 if getrenamed is not None and rev:
4092 copies = []
4090 copies = []
4093 for fn in ctx.files():
4091 for fn in ctx.files():
4094 rename = getrenamed(fn, rev)
4092 rename = getrenamed(fn, rev)
4095 if rename:
4093 if rename:
4096 copies.append((fn, rename[0]))
4094 copies.append((fn, rename[0]))
4097
4095
4098 revmatchfn = None
4096 revmatchfn = None
4099 if opts.get('patch') or opts.get('stat'):
4097 if opts.get('patch') or opts.get('stat'):
4100 if opts.get('follow') or opts.get('follow_first'):
4098 if opts.get('follow') or opts.get('follow_first'):
4101 # note: this might be wrong when following through merges
4099 # note: this might be wrong when following through merges
4102 revmatchfn = scmutil.match(repo[None], fns, default='path')
4100 revmatchfn = scmutil.match(repo[None], fns, default='path')
4103 else:
4101 else:
4104 revmatchfn = matchfn
4102 revmatchfn = matchfn
4105
4103
4106 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4104 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4107
4105
4108 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4106 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4109 if displayer.flush(ctx.rev()):
4107 if displayer.flush(ctx.rev()):
4110 count += 1
4108 count += 1
4111 if count == limit:
4109 if count == limit:
4112 break
4110 break
4113 displayer.close()
4111 displayer.close()
4114
4112
4115 @command('manifest',
4113 @command('manifest',
4116 [('r', 'rev', '', _('revision to display'), _('REV')),
4114 [('r', 'rev', '', _('revision to display'), _('REV')),
4117 ('', 'all', False, _("list files from all revisions"))],
4115 ('', 'all', False, _("list files from all revisions"))],
4118 _('[-r REV]'))
4116 _('[-r REV]'))
4119 def manifest(ui, repo, node=None, rev=None, **opts):
4117 def manifest(ui, repo, node=None, rev=None, **opts):
4120 """output the current or given revision of the project manifest
4118 """output the current or given revision of the project manifest
4121
4119
4122 Print a list of version controlled files for the given revision.
4120 Print a list of version controlled files for the given revision.
4123 If no revision is given, the first parent of the working directory
4121 If no revision is given, the first parent of the working directory
4124 is used, or the null revision if no revision is checked out.
4122 is used, or the null revision if no revision is checked out.
4125
4123
4126 With -v, print file permissions, symlink and executable bits.
4124 With -v, print file permissions, symlink and executable bits.
4127 With --debug, print file revision hashes.
4125 With --debug, print file revision hashes.
4128
4126
4129 If option --all is specified, the list of all files from all revisions
4127 If option --all is specified, the list of all files from all revisions
4130 is printed. This includes deleted and renamed files.
4128 is printed. This includes deleted and renamed files.
4131
4129
4132 Returns 0 on success.
4130 Returns 0 on success.
4133 """
4131 """
4134
4132
4135 fm = ui.formatter('manifest', opts)
4133 fm = ui.formatter('manifest', opts)
4136
4134
4137 if opts.get('all'):
4135 if opts.get('all'):
4138 if rev or node:
4136 if rev or node:
4139 raise util.Abort(_("can't specify a revision with --all"))
4137 raise util.Abort(_("can't specify a revision with --all"))
4140
4138
4141 res = []
4139 res = []
4142 prefix = "data/"
4140 prefix = "data/"
4143 suffix = ".i"
4141 suffix = ".i"
4144 plen = len(prefix)
4142 plen = len(prefix)
4145 slen = len(suffix)
4143 slen = len(suffix)
4146 lock = repo.lock()
4144 lock = repo.lock()
4147 try:
4145 try:
4148 for fn, b, size in repo.store.datafiles():
4146 for fn, b, size in repo.store.datafiles():
4149 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4147 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4150 res.append(fn[plen:-slen])
4148 res.append(fn[plen:-slen])
4151 finally:
4149 finally:
4152 lock.release()
4150 lock.release()
4153 for f in res:
4151 for f in res:
4154 fm.startitem()
4152 fm.startitem()
4155 fm.write("path", '%s\n', f)
4153 fm.write("path", '%s\n', f)
4156 fm.end()
4154 fm.end()
4157 return
4155 return
4158
4156
4159 if rev and node:
4157 if rev and node:
4160 raise util.Abort(_("please specify just one revision"))
4158 raise util.Abort(_("please specify just one revision"))
4161
4159
4162 if not node:
4160 if not node:
4163 node = rev
4161 node = rev
4164
4162
4165 char = {'l': '@', 'x': '*', '': ''}
4163 char = {'l': '@', 'x': '*', '': ''}
4166 mode = {'l': '644', 'x': '755', '': '644'}
4164 mode = {'l': '644', 'x': '755', '': '644'}
4167 ctx = scmutil.revsingle(repo, node)
4165 ctx = scmutil.revsingle(repo, node)
4168 mf = ctx.manifest()
4166 mf = ctx.manifest()
4169 for f in ctx:
4167 for f in ctx:
4170 fm.startitem()
4168 fm.startitem()
4171 fl = ctx[f].flags()
4169 fl = ctx[f].flags()
4172 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4170 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4173 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4171 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4174 fm.write('path', '%s\n', f)
4172 fm.write('path', '%s\n', f)
4175 fm.end()
4173 fm.end()
4176
4174
4177 @command('^merge',
4175 @command('^merge',
4178 [('f', 'force', None,
4176 [('f', 'force', None,
4179 _('force a merge including outstanding changes (DEPRECATED)')),
4177 _('force a merge including outstanding changes (DEPRECATED)')),
4180 ('r', 'rev', '', _('revision to merge'), _('REV')),
4178 ('r', 'rev', '', _('revision to merge'), _('REV')),
4181 ('P', 'preview', None,
4179 ('P', 'preview', None,
4182 _('review revisions to merge (no merge is performed)'))
4180 _('review revisions to merge (no merge is performed)'))
4183 ] + mergetoolopts,
4181 ] + mergetoolopts,
4184 _('[-P] [-f] [[-r] REV]'))
4182 _('[-P] [-f] [[-r] REV]'))
4185 def merge(ui, repo, node=None, **opts):
4183 def merge(ui, repo, node=None, **opts):
4186 """merge working directory with another revision
4184 """merge working directory with another revision
4187
4185
4188 The current working directory is updated with all changes made in
4186 The current working directory is updated with all changes made in
4189 the requested revision since the last common predecessor revision.
4187 the requested revision since the last common predecessor revision.
4190
4188
4191 Files that changed between either parent are marked as changed for
4189 Files that changed between either parent are marked as changed for
4192 the next commit and a commit must be performed before any further
4190 the next commit and a commit must be performed before any further
4193 updates to the repository are allowed. The next commit will have
4191 updates to the repository are allowed. The next commit will have
4194 two parents.
4192 two parents.
4195
4193
4196 ``--tool`` can be used to specify the merge tool used for file
4194 ``--tool`` can be used to specify the merge tool used for file
4197 merges. It overrides the HGMERGE environment variable and your
4195 merges. It overrides the HGMERGE environment variable and your
4198 configuration files. See :hg:`help merge-tools` for options.
4196 configuration files. See :hg:`help merge-tools` for options.
4199
4197
4200 If no revision is specified, the working directory's parent is a
4198 If no revision is specified, the working directory's parent is a
4201 head revision, and the current branch contains exactly one other
4199 head revision, and the current branch contains exactly one other
4202 head, the other head is merged with by default. Otherwise, an
4200 head, the other head is merged with by default. Otherwise, an
4203 explicit revision with which to merge with must be provided.
4201 explicit revision with which to merge with must be provided.
4204
4202
4205 :hg:`resolve` must be used to resolve unresolved files.
4203 :hg:`resolve` must be used to resolve unresolved files.
4206
4204
4207 To undo an uncommitted merge, use :hg:`update --clean .` which
4205 To undo an uncommitted merge, use :hg:`update --clean .` which
4208 will check out a clean copy of the original merge parent, losing
4206 will check out a clean copy of the original merge parent, losing
4209 all changes.
4207 all changes.
4210
4208
4211 Returns 0 on success, 1 if there are unresolved files.
4209 Returns 0 on success, 1 if there are unresolved files.
4212 """
4210 """
4213
4211
4214 if opts.get('rev') and node:
4212 if opts.get('rev') and node:
4215 raise util.Abort(_("please specify just one revision"))
4213 raise util.Abort(_("please specify just one revision"))
4216 if not node:
4214 if not node:
4217 node = opts.get('rev')
4215 node = opts.get('rev')
4218
4216
4219 if node:
4217 if node:
4220 node = scmutil.revsingle(repo, node).node()
4218 node = scmutil.revsingle(repo, node).node()
4221
4219
4222 if not node and repo._bookmarkcurrent:
4220 if not node and repo._bookmarkcurrent:
4223 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4221 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4224 curhead = repo[repo._bookmarkcurrent].node()
4222 curhead = repo[repo._bookmarkcurrent].node()
4225 if len(bmheads) == 2:
4223 if len(bmheads) == 2:
4226 if curhead == bmheads[0]:
4224 if curhead == bmheads[0]:
4227 node = bmheads[1]
4225 node = bmheads[1]
4228 else:
4226 else:
4229 node = bmheads[0]
4227 node = bmheads[0]
4230 elif len(bmheads) > 2:
4228 elif len(bmheads) > 2:
4231 raise util.Abort(_("multiple matching bookmarks to merge - "
4229 raise util.Abort(_("multiple matching bookmarks to merge - "
4232 "please merge with an explicit rev or bookmark"),
4230 "please merge with an explicit rev or bookmark"),
4233 hint=_("run 'hg heads' to see all heads"))
4231 hint=_("run 'hg heads' to see all heads"))
4234 elif len(bmheads) <= 1:
4232 elif len(bmheads) <= 1:
4235 raise util.Abort(_("no matching bookmark to merge - "
4233 raise util.Abort(_("no matching bookmark to merge - "
4236 "please merge with an explicit rev or bookmark"),
4234 "please merge with an explicit rev or bookmark"),
4237 hint=_("run 'hg heads' to see all heads"))
4235 hint=_("run 'hg heads' to see all heads"))
4238
4236
4239 if not node and not repo._bookmarkcurrent:
4237 if not node and not repo._bookmarkcurrent:
4240 branch = repo[None].branch()
4238 branch = repo[None].branch()
4241 bheads = repo.branchheads(branch)
4239 bheads = repo.branchheads(branch)
4242 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4240 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4243
4241
4244 if len(nbhs) > 2:
4242 if len(nbhs) > 2:
4245 raise util.Abort(_("branch '%s' has %d heads - "
4243 raise util.Abort(_("branch '%s' has %d heads - "
4246 "please merge with an explicit rev")
4244 "please merge with an explicit rev")
4247 % (branch, len(bheads)),
4245 % (branch, len(bheads)),
4248 hint=_("run 'hg heads .' to see heads"))
4246 hint=_("run 'hg heads .' to see heads"))
4249
4247
4250 parent = repo.dirstate.p1()
4248 parent = repo.dirstate.p1()
4251 if len(nbhs) <= 1:
4249 if len(nbhs) <= 1:
4252 if len(bheads) > 1:
4250 if len(bheads) > 1:
4253 raise util.Abort(_("heads are bookmarked - "
4251 raise util.Abort(_("heads are bookmarked - "
4254 "please merge with an explicit rev"),
4252 "please merge with an explicit rev"),
4255 hint=_("run 'hg heads' to see all heads"))
4253 hint=_("run 'hg heads' to see all heads"))
4256 if len(repo.heads()) > 1:
4254 if len(repo.heads()) > 1:
4257 raise util.Abort(_("branch '%s' has one head - "
4255 raise util.Abort(_("branch '%s' has one head - "
4258 "please merge with an explicit rev")
4256 "please merge with an explicit rev")
4259 % branch,
4257 % branch,
4260 hint=_("run 'hg heads' to see all heads"))
4258 hint=_("run 'hg heads' to see all heads"))
4261 msg, hint = _('nothing to merge'), None
4259 msg, hint = _('nothing to merge'), None
4262 if parent != repo.lookup(branch):
4260 if parent != repo.lookup(branch):
4263 hint = _("use 'hg update' instead")
4261 hint = _("use 'hg update' instead")
4264 raise util.Abort(msg, hint=hint)
4262 raise util.Abort(msg, hint=hint)
4265
4263
4266 if parent not in bheads:
4264 if parent not in bheads:
4267 raise util.Abort(_('working directory not at a head revision'),
4265 raise util.Abort(_('working directory not at a head revision'),
4268 hint=_("use 'hg update' or merge with an "
4266 hint=_("use 'hg update' or merge with an "
4269 "explicit revision"))
4267 "explicit revision"))
4270 if parent == nbhs[0]:
4268 if parent == nbhs[0]:
4271 node = nbhs[-1]
4269 node = nbhs[-1]
4272 else:
4270 else:
4273 node = nbhs[0]
4271 node = nbhs[0]
4274
4272
4275 if opts.get('preview'):
4273 if opts.get('preview'):
4276 # find nodes that are ancestors of p2 but not of p1
4274 # find nodes that are ancestors of p2 but not of p1
4277 p1 = repo.lookup('.')
4275 p1 = repo.lookup('.')
4278 p2 = repo.lookup(node)
4276 p2 = repo.lookup(node)
4279 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4277 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4280
4278
4281 displayer = cmdutil.show_changeset(ui, repo, opts)
4279 displayer = cmdutil.show_changeset(ui, repo, opts)
4282 for node in nodes:
4280 for node in nodes:
4283 displayer.show(repo[node])
4281 displayer.show(repo[node])
4284 displayer.close()
4282 displayer.close()
4285 return 0
4283 return 0
4286
4284
4287 try:
4285 try:
4288 # ui.forcemerge is an internal variable, do not document
4286 # ui.forcemerge is an internal variable, do not document
4289 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4287 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4290 return hg.merge(repo, node, force=opts.get('force'))
4288 return hg.merge(repo, node, force=opts.get('force'))
4291 finally:
4289 finally:
4292 ui.setconfig('ui', 'forcemerge', '')
4290 ui.setconfig('ui', 'forcemerge', '')
4293
4291
4294 @command('outgoing|out',
4292 @command('outgoing|out',
4295 [('f', 'force', None, _('run even when the destination is unrelated')),
4293 [('f', 'force', None, _('run even when the destination is unrelated')),
4296 ('r', 'rev', [],
4294 ('r', 'rev', [],
4297 _('a changeset intended to be included in the destination'), _('REV')),
4295 _('a changeset intended to be included in the destination'), _('REV')),
4298 ('n', 'newest-first', None, _('show newest record first')),
4296 ('n', 'newest-first', None, _('show newest record first')),
4299 ('B', 'bookmarks', False, _('compare bookmarks')),
4297 ('B', 'bookmarks', False, _('compare bookmarks')),
4300 ('b', 'branch', [], _('a specific branch you would like to push'),
4298 ('b', 'branch', [], _('a specific branch you would like to push'),
4301 _('BRANCH')),
4299 _('BRANCH')),
4302 ] + logopts + remoteopts + subrepoopts,
4300 ] + logopts + remoteopts + subrepoopts,
4303 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4301 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4304 def outgoing(ui, repo, dest=None, **opts):
4302 def outgoing(ui, repo, dest=None, **opts):
4305 """show changesets not found in the destination
4303 """show changesets not found in the destination
4306
4304
4307 Show changesets not found in the specified destination repository
4305 Show changesets not found in the specified destination repository
4308 or the default push location. These are the changesets that would
4306 or the default push location. These are the changesets that would
4309 be pushed if a push was requested.
4307 be pushed if a push was requested.
4310
4308
4311 See pull for details of valid destination formats.
4309 See pull for details of valid destination formats.
4312
4310
4313 Returns 0 if there are outgoing changes, 1 otherwise.
4311 Returns 0 if there are outgoing changes, 1 otherwise.
4314 """
4312 """
4315 if opts.get('graph'):
4313 if opts.get('graph'):
4316 cmdutil.checkunsupportedgraphflags([], opts)
4314 cmdutil.checkunsupportedgraphflags([], opts)
4317 o = hg._outgoing(ui, repo, dest, opts)
4315 o = hg._outgoing(ui, repo, dest, opts)
4318 if o is None:
4316 if o is None:
4319 return
4317 return
4320
4318
4321 revdag = cmdutil.graphrevs(repo, o, opts)
4319 revdag = cmdutil.graphrevs(repo, o, opts)
4322 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4320 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4323 showparents = [ctx.node() for ctx in repo[None].parents()]
4321 showparents = [ctx.node() for ctx in repo[None].parents()]
4324 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4322 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4325 graphmod.asciiedges)
4323 graphmod.asciiedges)
4326 return 0
4324 return 0
4327
4325
4328 if opts.get('bookmarks'):
4326 if opts.get('bookmarks'):
4329 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4327 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4330 dest, branches = hg.parseurl(dest, opts.get('branch'))
4328 dest, branches = hg.parseurl(dest, opts.get('branch'))
4331 other = hg.peer(repo, opts, dest)
4329 other = hg.peer(repo, opts, dest)
4332 if 'bookmarks' not in other.listkeys('namespaces'):
4330 if 'bookmarks' not in other.listkeys('namespaces'):
4333 ui.warn(_("remote doesn't support bookmarks\n"))
4331 ui.warn(_("remote doesn't support bookmarks\n"))
4334 return 0
4332 return 0
4335 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4333 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4336 return bookmarks.diff(ui, other, repo)
4334 return bookmarks.diff(ui, other, repo)
4337
4335
4338 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4336 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4339 try:
4337 try:
4340 return hg.outgoing(ui, repo, dest, opts)
4338 return hg.outgoing(ui, repo, dest, opts)
4341 finally:
4339 finally:
4342 del repo._subtoppath
4340 del repo._subtoppath
4343
4341
4344 @command('parents',
4342 @command('parents',
4345 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4343 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4346 ] + templateopts,
4344 ] + templateopts,
4347 _('[-r REV] [FILE]'))
4345 _('[-r REV] [FILE]'))
4348 def parents(ui, repo, file_=None, **opts):
4346 def parents(ui, repo, file_=None, **opts):
4349 """show the parents of the working directory or revision
4347 """show the parents of the working directory or revision
4350
4348
4351 Print the working directory's parent revisions. If a revision is
4349 Print the working directory's parent revisions. If a revision is
4352 given via -r/--rev, the parent of that revision will be printed.
4350 given via -r/--rev, the parent of that revision will be printed.
4353 If a file argument is given, the revision in which the file was
4351 If a file argument is given, the revision in which the file was
4354 last changed (before the working directory revision or the
4352 last changed (before the working directory revision or the
4355 argument to --rev if given) is printed.
4353 argument to --rev if given) is printed.
4356
4354
4357 Returns 0 on success.
4355 Returns 0 on success.
4358 """
4356 """
4359
4357
4360 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4358 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4361
4359
4362 if file_:
4360 if file_:
4363 m = scmutil.match(ctx, (file_,), opts)
4361 m = scmutil.match(ctx, (file_,), opts)
4364 if m.anypats() or len(m.files()) != 1:
4362 if m.anypats() or len(m.files()) != 1:
4365 raise util.Abort(_('can only specify an explicit filename'))
4363 raise util.Abort(_('can only specify an explicit filename'))
4366 file_ = m.files()[0]
4364 file_ = m.files()[0]
4367 filenodes = []
4365 filenodes = []
4368 for cp in ctx.parents():
4366 for cp in ctx.parents():
4369 if not cp:
4367 if not cp:
4370 continue
4368 continue
4371 try:
4369 try:
4372 filenodes.append(cp.filenode(file_))
4370 filenodes.append(cp.filenode(file_))
4373 except error.LookupError:
4371 except error.LookupError:
4374 pass
4372 pass
4375 if not filenodes:
4373 if not filenodes:
4376 raise util.Abort(_("'%s' not found in manifest!") % file_)
4374 raise util.Abort(_("'%s' not found in manifest!") % file_)
4377 p = []
4375 p = []
4378 for fn in filenodes:
4376 for fn in filenodes:
4379 fctx = repo.filectx(file_, fileid=fn)
4377 fctx = repo.filectx(file_, fileid=fn)
4380 p.append(fctx.node())
4378 p.append(fctx.node())
4381 else:
4379 else:
4382 p = [cp.node() for cp in ctx.parents()]
4380 p = [cp.node() for cp in ctx.parents()]
4383
4381
4384 displayer = cmdutil.show_changeset(ui, repo, opts)
4382 displayer = cmdutil.show_changeset(ui, repo, opts)
4385 for n in p:
4383 for n in p:
4386 if n != nullid:
4384 if n != nullid:
4387 displayer.show(repo[n])
4385 displayer.show(repo[n])
4388 displayer.close()
4386 displayer.close()
4389
4387
4390 @command('paths', [], _('[NAME]'))
4388 @command('paths', [], _('[NAME]'))
4391 def paths(ui, repo, search=None):
4389 def paths(ui, repo, search=None):
4392 """show aliases for remote repositories
4390 """show aliases for remote repositories
4393
4391
4394 Show definition of symbolic path name NAME. If no name is given,
4392 Show definition of symbolic path name NAME. If no name is given,
4395 show definition of all available names.
4393 show definition of all available names.
4396
4394
4397 Option -q/--quiet suppresses all output when searching for NAME
4395 Option -q/--quiet suppresses all output when searching for NAME
4398 and shows only the path names when listing all definitions.
4396 and shows only the path names when listing all definitions.
4399
4397
4400 Path names are defined in the [paths] section of your
4398 Path names are defined in the [paths] section of your
4401 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4399 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4402 repository, ``.hg/hgrc`` is used, too.
4400 repository, ``.hg/hgrc`` is used, too.
4403
4401
4404 The path names ``default`` and ``default-push`` have a special
4402 The path names ``default`` and ``default-push`` have a special
4405 meaning. When performing a push or pull operation, they are used
4403 meaning. When performing a push or pull operation, they are used
4406 as fallbacks if no location is specified on the command-line.
4404 as fallbacks if no location is specified on the command-line.
4407 When ``default-push`` is set, it will be used for push and
4405 When ``default-push`` is set, it will be used for push and
4408 ``default`` will be used for pull; otherwise ``default`` is used
4406 ``default`` will be used for pull; otherwise ``default`` is used
4409 as the fallback for both. When cloning a repository, the clone
4407 as the fallback for both. When cloning a repository, the clone
4410 source is written as ``default`` in ``.hg/hgrc``. Note that
4408 source is written as ``default`` in ``.hg/hgrc``. Note that
4411 ``default`` and ``default-push`` apply to all inbound (e.g.
4409 ``default`` and ``default-push`` apply to all inbound (e.g.
4412 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4410 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4413 :hg:`bundle`) operations.
4411 :hg:`bundle`) operations.
4414
4412
4415 See :hg:`help urls` for more information.
4413 See :hg:`help urls` for more information.
4416
4414
4417 Returns 0 on success.
4415 Returns 0 on success.
4418 """
4416 """
4419 if search:
4417 if search:
4420 for name, path in ui.configitems("paths"):
4418 for name, path in ui.configitems("paths"):
4421 if name == search:
4419 if name == search:
4422 ui.status("%s\n" % util.hidepassword(path))
4420 ui.status("%s\n" % util.hidepassword(path))
4423 return
4421 return
4424 if not ui.quiet:
4422 if not ui.quiet:
4425 ui.warn(_("not found!\n"))
4423 ui.warn(_("not found!\n"))
4426 return 1
4424 return 1
4427 else:
4425 else:
4428 for name, path in ui.configitems("paths"):
4426 for name, path in ui.configitems("paths"):
4429 if ui.quiet:
4427 if ui.quiet:
4430 ui.write("%s\n" % name)
4428 ui.write("%s\n" % name)
4431 else:
4429 else:
4432 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4430 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4433
4431
4434 @command('phase',
4432 @command('phase',
4435 [('p', 'public', False, _('set changeset phase to public')),
4433 [('p', 'public', False, _('set changeset phase to public')),
4436 ('d', 'draft', False, _('set changeset phase to draft')),
4434 ('d', 'draft', False, _('set changeset phase to draft')),
4437 ('s', 'secret', False, _('set changeset phase to secret')),
4435 ('s', 'secret', False, _('set changeset phase to secret')),
4438 ('f', 'force', False, _('allow to move boundary backward')),
4436 ('f', 'force', False, _('allow to move boundary backward')),
4439 ('r', 'rev', [], _('target revision'), _('REV')),
4437 ('r', 'rev', [], _('target revision'), _('REV')),
4440 ],
4438 ],
4441 _('[-p|-d|-s] [-f] [-r] REV...'))
4439 _('[-p|-d|-s] [-f] [-r] REV...'))
4442 def phase(ui, repo, *revs, **opts):
4440 def phase(ui, repo, *revs, **opts):
4443 """set or show the current phase name
4441 """set or show the current phase name
4444
4442
4445 With no argument, show the phase name of specified revisions.
4443 With no argument, show the phase name of specified revisions.
4446
4444
4447 With one of -p/--public, -d/--draft or -s/--secret, change the
4445 With one of -p/--public, -d/--draft or -s/--secret, change the
4448 phase value of the specified revisions.
4446 phase value of the specified revisions.
4449
4447
4450 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4448 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4451 lower phase to an higher phase. Phases are ordered as follows::
4449 lower phase to an higher phase. Phases are ordered as follows::
4452
4450
4453 public < draft < secret
4451 public < draft < secret
4454
4452
4455 Return 0 on success, 1 if no phases were changed or some could not
4453 Return 0 on success, 1 if no phases were changed or some could not
4456 be changed.
4454 be changed.
4457 """
4455 """
4458 # search for a unique phase argument
4456 # search for a unique phase argument
4459 targetphase = None
4457 targetphase = None
4460 for idx, name in enumerate(phases.phasenames):
4458 for idx, name in enumerate(phases.phasenames):
4461 if opts[name]:
4459 if opts[name]:
4462 if targetphase is not None:
4460 if targetphase is not None:
4463 raise util.Abort(_('only one phase can be specified'))
4461 raise util.Abort(_('only one phase can be specified'))
4464 targetphase = idx
4462 targetphase = idx
4465
4463
4466 # look for specified revision
4464 # look for specified revision
4467 revs = list(revs)
4465 revs = list(revs)
4468 revs.extend(opts['rev'])
4466 revs.extend(opts['rev'])
4469 if not revs:
4467 if not revs:
4470 raise util.Abort(_('no revisions specified'))
4468 raise util.Abort(_('no revisions specified'))
4471
4469
4472 revs = scmutil.revrange(repo, revs)
4470 revs = scmutil.revrange(repo, revs)
4473
4471
4474 lock = None
4472 lock = None
4475 ret = 0
4473 ret = 0
4476 if targetphase is None:
4474 if targetphase is None:
4477 # display
4475 # display
4478 for r in revs:
4476 for r in revs:
4479 ctx = repo[r]
4477 ctx = repo[r]
4480 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4478 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4481 else:
4479 else:
4482 lock = repo.lock()
4480 lock = repo.lock()
4483 try:
4481 try:
4484 # set phase
4482 # set phase
4485 if not revs:
4483 if not revs:
4486 raise util.Abort(_('empty revision set'))
4484 raise util.Abort(_('empty revision set'))
4487 nodes = [repo[r].node() for r in revs]
4485 nodes = [repo[r].node() for r in revs]
4488 olddata = repo._phasecache.getphaserevs(repo)[:]
4486 olddata = repo._phasecache.getphaserevs(repo)[:]
4489 phases.advanceboundary(repo, targetphase, nodes)
4487 phases.advanceboundary(repo, targetphase, nodes)
4490 if opts['force']:
4488 if opts['force']:
4491 phases.retractboundary(repo, targetphase, nodes)
4489 phases.retractboundary(repo, targetphase, nodes)
4492 finally:
4490 finally:
4493 lock.release()
4491 lock.release()
4494 # moving revision from public to draft may hide them
4492 # moving revision from public to draft may hide them
4495 # We have to check result on an unfiltered repository
4493 # We have to check result on an unfiltered repository
4496 unfi = repo.unfiltered()
4494 unfi = repo.unfiltered()
4497 newdata = repo._phasecache.getphaserevs(unfi)
4495 newdata = repo._phasecache.getphaserevs(unfi)
4498 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
4496 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
4499 cl = unfi.changelog
4497 cl = unfi.changelog
4500 rejected = [n for n in nodes
4498 rejected = [n for n in nodes
4501 if newdata[cl.rev(n)] < targetphase]
4499 if newdata[cl.rev(n)] < targetphase]
4502 if rejected:
4500 if rejected:
4503 ui.warn(_('cannot move %i changesets to a more permissive '
4501 ui.warn(_('cannot move %i changesets to a more permissive '
4504 'phase, use --force\n') % len(rejected))
4502 'phase, use --force\n') % len(rejected))
4505 ret = 1
4503 ret = 1
4506 if changes:
4504 if changes:
4507 msg = _('phase changed for %i changesets\n') % changes
4505 msg = _('phase changed for %i changesets\n') % changes
4508 if ret:
4506 if ret:
4509 ui.status(msg)
4507 ui.status(msg)
4510 else:
4508 else:
4511 ui.note(msg)
4509 ui.note(msg)
4512 else:
4510 else:
4513 ui.warn(_('no phases changed\n'))
4511 ui.warn(_('no phases changed\n'))
4514 ret = 1
4512 ret = 1
4515 return ret
4513 return ret
4516
4514
4517 def postincoming(ui, repo, modheads, optupdate, checkout):
4515 def postincoming(ui, repo, modheads, optupdate, checkout):
4518 if modheads == 0:
4516 if modheads == 0:
4519 return
4517 return
4520 if optupdate:
4518 if optupdate:
4521 movemarkfrom = repo['.'].node()
4519 movemarkfrom = repo['.'].node()
4522 try:
4520 try:
4523 ret = hg.update(repo, checkout)
4521 ret = hg.update(repo, checkout)
4524 except util.Abort, inst:
4522 except util.Abort, inst:
4525 ui.warn(_("not updating: %s\n") % str(inst))
4523 ui.warn(_("not updating: %s\n") % str(inst))
4526 return 0
4524 return 0
4527 if not ret and not checkout:
4525 if not ret and not checkout:
4528 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4526 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4529 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4527 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4530 return ret
4528 return ret
4531 if modheads > 1:
4529 if modheads > 1:
4532 currentbranchheads = len(repo.branchheads())
4530 currentbranchheads = len(repo.branchheads())
4533 if currentbranchheads == modheads:
4531 if currentbranchheads == modheads:
4534 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4532 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4535 elif currentbranchheads > 1:
4533 elif currentbranchheads > 1:
4536 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4534 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4537 "merge)\n"))
4535 "merge)\n"))
4538 else:
4536 else:
4539 ui.status(_("(run 'hg heads' to see heads)\n"))
4537 ui.status(_("(run 'hg heads' to see heads)\n"))
4540 else:
4538 else:
4541 ui.status(_("(run 'hg update' to get a working copy)\n"))
4539 ui.status(_("(run 'hg update' to get a working copy)\n"))
4542
4540
4543 @command('^pull',
4541 @command('^pull',
4544 [('u', 'update', None,
4542 [('u', 'update', None,
4545 _('update to new branch head if changesets were pulled')),
4543 _('update to new branch head if changesets were pulled')),
4546 ('f', 'force', None, _('run even when remote repository is unrelated')),
4544 ('f', 'force', None, _('run even when remote repository is unrelated')),
4547 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4545 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4548 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4546 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4549 ('b', 'branch', [], _('a specific branch you would like to pull'),
4547 ('b', 'branch', [], _('a specific branch you would like to pull'),
4550 _('BRANCH')),
4548 _('BRANCH')),
4551 ] + remoteopts,
4549 ] + remoteopts,
4552 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4550 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4553 def pull(ui, repo, source="default", **opts):
4551 def pull(ui, repo, source="default", **opts):
4554 """pull changes from the specified source
4552 """pull changes from the specified source
4555
4553
4556 Pull changes from a remote repository to a local one.
4554 Pull changes from a remote repository to a local one.
4557
4555
4558 This finds all changes from the repository at the specified path
4556 This finds all changes from the repository at the specified path
4559 or URL and adds them to a local repository (the current one unless
4557 or URL and adds them to a local repository (the current one unless
4560 -R is specified). By default, this does not update the copy of the
4558 -R is specified). By default, this does not update the copy of the
4561 project in the working directory.
4559 project in the working directory.
4562
4560
4563 Use :hg:`incoming` if you want to see what would have been added
4561 Use :hg:`incoming` if you want to see what would have been added
4564 by a pull at the time you issued this command. If you then decide
4562 by a pull at the time you issued this command. If you then decide
4565 to add those changes to the repository, you should use :hg:`pull
4563 to add those changes to the repository, you should use :hg:`pull
4566 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4564 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4567
4565
4568 If SOURCE is omitted, the 'default' path will be used.
4566 If SOURCE is omitted, the 'default' path will be used.
4569 See :hg:`help urls` for more information.
4567 See :hg:`help urls` for more information.
4570
4568
4571 Returns 0 on success, 1 if an update had unresolved files.
4569 Returns 0 on success, 1 if an update had unresolved files.
4572 """
4570 """
4573 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4571 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4574 other = hg.peer(repo, opts, source)
4572 other = hg.peer(repo, opts, source)
4575 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4573 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4576 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
4574 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
4577
4575
4578 remotebookmarks = other.listkeys('bookmarks')
4576 remotebookmarks = other.listkeys('bookmarks')
4579
4577
4580 if opts.get('bookmark'):
4578 if opts.get('bookmark'):
4581 if not revs:
4579 if not revs:
4582 revs = []
4580 revs = []
4583 for b in opts['bookmark']:
4581 for b in opts['bookmark']:
4584 if b not in remotebookmarks:
4582 if b not in remotebookmarks:
4585 raise util.Abort(_('remote bookmark %s not found!') % b)
4583 raise util.Abort(_('remote bookmark %s not found!') % b)
4586 revs.append(remotebookmarks[b])
4584 revs.append(remotebookmarks[b])
4587
4585
4588 if revs:
4586 if revs:
4589 try:
4587 try:
4590 revs = [other.lookup(rev) for rev in revs]
4588 revs = [other.lookup(rev) for rev in revs]
4591 except error.CapabilityError:
4589 except error.CapabilityError:
4592 err = _("other repository doesn't support revision lookup, "
4590 err = _("other repository doesn't support revision lookup, "
4593 "so a rev cannot be specified.")
4591 "so a rev cannot be specified.")
4594 raise util.Abort(err)
4592 raise util.Abort(err)
4595
4593
4596 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4594 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4597 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4595 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4598 if checkout:
4596 if checkout:
4599 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4597 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4600 repo._subtoppath = source
4598 repo._subtoppath = source
4601 try:
4599 try:
4602 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4600 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4603
4601
4604 finally:
4602 finally:
4605 del repo._subtoppath
4603 del repo._subtoppath
4606
4604
4607 # update specified bookmarks
4605 # update specified bookmarks
4608 if opts.get('bookmark'):
4606 if opts.get('bookmark'):
4609 marks = repo._bookmarks
4607 marks = repo._bookmarks
4610 for b in opts['bookmark']:
4608 for b in opts['bookmark']:
4611 # explicit pull overrides local bookmark if any
4609 # explicit pull overrides local bookmark if any
4612 ui.status(_("importing bookmark %s\n") % b)
4610 ui.status(_("importing bookmark %s\n") % b)
4613 marks[b] = repo[remotebookmarks[b]].node()
4611 marks[b] = repo[remotebookmarks[b]].node()
4614 marks.write()
4612 marks.write()
4615
4613
4616 return ret
4614 return ret
4617
4615
4618 @command('^push',
4616 @command('^push',
4619 [('f', 'force', None, _('force push')),
4617 [('f', 'force', None, _('force push')),
4620 ('r', 'rev', [],
4618 ('r', 'rev', [],
4621 _('a changeset intended to be included in the destination'),
4619 _('a changeset intended to be included in the destination'),
4622 _('REV')),
4620 _('REV')),
4623 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4621 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4624 ('b', 'branch', [],
4622 ('b', 'branch', [],
4625 _('a specific branch you would like to push'), _('BRANCH')),
4623 _('a specific branch you would like to push'), _('BRANCH')),
4626 ('', 'new-branch', False, _('allow pushing a new branch')),
4624 ('', 'new-branch', False, _('allow pushing a new branch')),
4627 ] + remoteopts,
4625 ] + remoteopts,
4628 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4626 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4629 def push(ui, repo, dest=None, **opts):
4627 def push(ui, repo, dest=None, **opts):
4630 """push changes to the specified destination
4628 """push changes to the specified destination
4631
4629
4632 Push changesets from the local repository to the specified
4630 Push changesets from the local repository to the specified
4633 destination.
4631 destination.
4634
4632
4635 This operation is symmetrical to pull: it is identical to a pull
4633 This operation is symmetrical to pull: it is identical to a pull
4636 in the destination repository from the current one.
4634 in the destination repository from the current one.
4637
4635
4638 By default, push will not allow creation of new heads at the
4636 By default, push will not allow creation of new heads at the
4639 destination, since multiple heads would make it unclear which head
4637 destination, since multiple heads would make it unclear which head
4640 to use. In this situation, it is recommended to pull and merge
4638 to use. In this situation, it is recommended to pull and merge
4641 before pushing.
4639 before pushing.
4642
4640
4643 Use --new-branch if you want to allow push to create a new named
4641 Use --new-branch if you want to allow push to create a new named
4644 branch that is not present at the destination. This allows you to
4642 branch that is not present at the destination. This allows you to
4645 only create a new branch without forcing other changes.
4643 only create a new branch without forcing other changes.
4646
4644
4647 Use -f/--force to override the default behavior and push all
4645 Use -f/--force to override the default behavior and push all
4648 changesets on all branches.
4646 changesets on all branches.
4649
4647
4650 If -r/--rev is used, the specified revision and all its ancestors
4648 If -r/--rev is used, the specified revision and all its ancestors
4651 will be pushed to the remote repository.
4649 will be pushed to the remote repository.
4652
4650
4653 If -B/--bookmark is used, the specified bookmarked revision, its
4651 If -B/--bookmark is used, the specified bookmarked revision, its
4654 ancestors, and the bookmark will be pushed to the remote
4652 ancestors, and the bookmark will be pushed to the remote
4655 repository.
4653 repository.
4656
4654
4657 Please see :hg:`help urls` for important details about ``ssh://``
4655 Please see :hg:`help urls` for important details about ``ssh://``
4658 URLs. If DESTINATION is omitted, a default path will be used.
4656 URLs. If DESTINATION is omitted, a default path will be used.
4659
4657
4660 Returns 0 if push was successful, 1 if nothing to push.
4658 Returns 0 if push was successful, 1 if nothing to push.
4661 """
4659 """
4662
4660
4663 if opts.get('bookmark'):
4661 if opts.get('bookmark'):
4664 for b in opts['bookmark']:
4662 for b in opts['bookmark']:
4665 # translate -B options to -r so changesets get pushed
4663 # translate -B options to -r so changesets get pushed
4666 if b in repo._bookmarks:
4664 if b in repo._bookmarks:
4667 opts.setdefault('rev', []).append(b)
4665 opts.setdefault('rev', []).append(b)
4668 else:
4666 else:
4669 # if we try to push a deleted bookmark, translate it to null
4667 # if we try to push a deleted bookmark, translate it to null
4670 # this lets simultaneous -r, -b options continue working
4668 # this lets simultaneous -r, -b options continue working
4671 opts.setdefault('rev', []).append("null")
4669 opts.setdefault('rev', []).append("null")
4672
4670
4673 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4671 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4674 dest, branches = hg.parseurl(dest, opts.get('branch'))
4672 dest, branches = hg.parseurl(dest, opts.get('branch'))
4675 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4673 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4676 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4674 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4677 other = hg.peer(repo, opts, dest)
4675 other = hg.peer(repo, opts, dest)
4678 if revs:
4676 if revs:
4679 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4677 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4680
4678
4681 repo._subtoppath = dest
4679 repo._subtoppath = dest
4682 try:
4680 try:
4683 # push subrepos depth-first for coherent ordering
4681 # push subrepos depth-first for coherent ordering
4684 c = repo['']
4682 c = repo['']
4685 subs = c.substate # only repos that are committed
4683 subs = c.substate # only repos that are committed
4686 for s in sorted(subs):
4684 for s in sorted(subs):
4687 if c.sub(s).push(opts) == 0:
4685 if c.sub(s).push(opts) == 0:
4688 return False
4686 return False
4689 finally:
4687 finally:
4690 del repo._subtoppath
4688 del repo._subtoppath
4691 result = repo.push(other, opts.get('force'), revs=revs,
4689 result = repo.push(other, opts.get('force'), revs=revs,
4692 newbranch=opts.get('new_branch'))
4690 newbranch=opts.get('new_branch'))
4693
4691
4694 result = not result
4692 result = not result
4695
4693
4696 if opts.get('bookmark'):
4694 if opts.get('bookmark'):
4697 rb = other.listkeys('bookmarks')
4695 rb = other.listkeys('bookmarks')
4698 for b in opts['bookmark']:
4696 for b in opts['bookmark']:
4699 # explicit push overrides remote bookmark if any
4697 # explicit push overrides remote bookmark if any
4700 if b in repo._bookmarks:
4698 if b in repo._bookmarks:
4701 ui.status(_("exporting bookmark %s\n") % b)
4699 ui.status(_("exporting bookmark %s\n") % b)
4702 new = repo[b].hex()
4700 new = repo[b].hex()
4703 elif b in rb:
4701 elif b in rb:
4704 ui.status(_("deleting remote bookmark %s\n") % b)
4702 ui.status(_("deleting remote bookmark %s\n") % b)
4705 new = '' # delete
4703 new = '' # delete
4706 else:
4704 else:
4707 ui.warn(_('bookmark %s does not exist on the local '
4705 ui.warn(_('bookmark %s does not exist on the local '
4708 'or remote repository!\n') % b)
4706 'or remote repository!\n') % b)
4709 return 2
4707 return 2
4710 old = rb.get(b, '')
4708 old = rb.get(b, '')
4711 r = other.pushkey('bookmarks', b, old, new)
4709 r = other.pushkey('bookmarks', b, old, new)
4712 if not r:
4710 if not r:
4713 ui.warn(_('updating bookmark %s failed!\n') % b)
4711 ui.warn(_('updating bookmark %s failed!\n') % b)
4714 if not result:
4712 if not result:
4715 result = 2
4713 result = 2
4716
4714
4717 return result
4715 return result
4718
4716
4719 @command('recover', [])
4717 @command('recover', [])
4720 def recover(ui, repo):
4718 def recover(ui, repo):
4721 """roll back an interrupted transaction
4719 """roll back an interrupted transaction
4722
4720
4723 Recover from an interrupted commit or pull.
4721 Recover from an interrupted commit or pull.
4724
4722
4725 This command tries to fix the repository status after an
4723 This command tries to fix the repository status after an
4726 interrupted operation. It should only be necessary when Mercurial
4724 interrupted operation. It should only be necessary when Mercurial
4727 suggests it.
4725 suggests it.
4728
4726
4729 Returns 0 if successful, 1 if nothing to recover or verify fails.
4727 Returns 0 if successful, 1 if nothing to recover or verify fails.
4730 """
4728 """
4731 if repo.recover():
4729 if repo.recover():
4732 return hg.verify(repo)
4730 return hg.verify(repo)
4733 return 1
4731 return 1
4734
4732
4735 @command('^remove|rm',
4733 @command('^remove|rm',
4736 [('A', 'after', None, _('record delete for missing files')),
4734 [('A', 'after', None, _('record delete for missing files')),
4737 ('f', 'force', None,
4735 ('f', 'force', None,
4738 _('remove (and delete) file even if added or modified')),
4736 _('remove (and delete) file even if added or modified')),
4739 ] + walkopts,
4737 ] + walkopts,
4740 _('[OPTION]... FILE...'))
4738 _('[OPTION]... FILE...'))
4741 def remove(ui, repo, *pats, **opts):
4739 def remove(ui, repo, *pats, **opts):
4742 """remove the specified files on the next commit
4740 """remove the specified files on the next commit
4743
4741
4744 Schedule the indicated files for removal from the current branch.
4742 Schedule the indicated files for removal from the current branch.
4745
4743
4746 This command schedules the files to be removed at the next commit.
4744 This command schedules the files to be removed at the next commit.
4747 To undo a remove before that, see :hg:`revert`. To undo added
4745 To undo a remove before that, see :hg:`revert`. To undo added
4748 files, see :hg:`forget`.
4746 files, see :hg:`forget`.
4749
4747
4750 .. container:: verbose
4748 .. container:: verbose
4751
4749
4752 -A/--after can be used to remove only files that have already
4750 -A/--after can be used to remove only files that have already
4753 been deleted, -f/--force can be used to force deletion, and -Af
4751 been deleted, -f/--force can be used to force deletion, and -Af
4754 can be used to remove files from the next revision without
4752 can be used to remove files from the next revision without
4755 deleting them from the working directory.
4753 deleting them from the working directory.
4756
4754
4757 The following table details the behavior of remove for different
4755 The following table details the behavior of remove for different
4758 file states (columns) and option combinations (rows). The file
4756 file states (columns) and option combinations (rows). The file
4759 states are Added [A], Clean [C], Modified [M] and Missing [!]
4757 states are Added [A], Clean [C], Modified [M] and Missing [!]
4760 (as reported by :hg:`status`). The actions are Warn, Remove
4758 (as reported by :hg:`status`). The actions are Warn, Remove
4761 (from branch) and Delete (from disk):
4759 (from branch) and Delete (from disk):
4762
4760
4763 ======= == == == ==
4761 ======= == == == ==
4764 A C M !
4762 A C M !
4765 ======= == == == ==
4763 ======= == == == ==
4766 none W RD W R
4764 none W RD W R
4767 -f R RD RD R
4765 -f R RD RD R
4768 -A W W W R
4766 -A W W W R
4769 -Af R R R R
4767 -Af R R R R
4770 ======= == == == ==
4768 ======= == == == ==
4771
4769
4772 Note that remove never deletes files in Added [A] state from the
4770 Note that remove never deletes files in Added [A] state from the
4773 working directory, not even if option --force is specified.
4771 working directory, not even if option --force is specified.
4774
4772
4775 Returns 0 on success, 1 if any warnings encountered.
4773 Returns 0 on success, 1 if any warnings encountered.
4776 """
4774 """
4777
4775
4778 ret = 0
4776 ret = 0
4779 after, force = opts.get('after'), opts.get('force')
4777 after, force = opts.get('after'), opts.get('force')
4780 if not pats and not after:
4778 if not pats and not after:
4781 raise util.Abort(_('no files specified'))
4779 raise util.Abort(_('no files specified'))
4782
4780
4783 m = scmutil.match(repo[None], pats, opts)
4781 m = scmutil.match(repo[None], pats, opts)
4784 s = repo.status(match=m, clean=True)
4782 s = repo.status(match=m, clean=True)
4785 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
4783 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
4786
4784
4787 # warn about failure to delete explicit files/dirs
4785 # warn about failure to delete explicit files/dirs
4788 wctx = repo[None]
4786 wctx = repo[None]
4789 for f in m.files():
4787 for f in m.files():
4790 if f in repo.dirstate or f in wctx.dirs():
4788 if f in repo.dirstate or f in wctx.dirs():
4791 continue
4789 continue
4792 if os.path.exists(m.rel(f)):
4790 if os.path.exists(m.rel(f)):
4793 if os.path.isdir(m.rel(f)):
4791 if os.path.isdir(m.rel(f)):
4794 ui.warn(_('not removing %s: no tracked files\n') % m.rel(f))
4792 ui.warn(_('not removing %s: no tracked files\n') % m.rel(f))
4795 else:
4793 else:
4796 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
4794 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
4797 # missing files will generate a warning elsewhere
4795 # missing files will generate a warning elsewhere
4798 ret = 1
4796 ret = 1
4799
4797
4800 if force:
4798 if force:
4801 list = modified + deleted + clean + added
4799 list = modified + deleted + clean + added
4802 elif after:
4800 elif after:
4803 list = deleted
4801 list = deleted
4804 for f in modified + added + clean:
4802 for f in modified + added + clean:
4805 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
4803 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
4806 ret = 1
4804 ret = 1
4807 else:
4805 else:
4808 list = deleted + clean
4806 list = deleted + clean
4809 for f in modified:
4807 for f in modified:
4810 ui.warn(_('not removing %s: file is modified (use -f'
4808 ui.warn(_('not removing %s: file is modified (use -f'
4811 ' to force removal)\n') % m.rel(f))
4809 ' to force removal)\n') % m.rel(f))
4812 ret = 1
4810 ret = 1
4813 for f in added:
4811 for f in added:
4814 ui.warn(_('not removing %s: file has been marked for add'
4812 ui.warn(_('not removing %s: file has been marked for add'
4815 ' (use forget to undo)\n') % m.rel(f))
4813 ' (use forget to undo)\n') % m.rel(f))
4816 ret = 1
4814 ret = 1
4817
4815
4818 for f in sorted(list):
4816 for f in sorted(list):
4819 if ui.verbose or not m.exact(f):
4817 if ui.verbose or not m.exact(f):
4820 ui.status(_('removing %s\n') % m.rel(f))
4818 ui.status(_('removing %s\n') % m.rel(f))
4821
4819
4822 wlock = repo.wlock()
4820 wlock = repo.wlock()
4823 try:
4821 try:
4824 if not after:
4822 if not after:
4825 for f in list:
4823 for f in list:
4826 if f in added:
4824 if f in added:
4827 continue # we never unlink added files on remove
4825 continue # we never unlink added files on remove
4828 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
4826 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
4829 repo[None].forget(list)
4827 repo[None].forget(list)
4830 finally:
4828 finally:
4831 wlock.release()
4829 wlock.release()
4832
4830
4833 return ret
4831 return ret
4834
4832
4835 @command('rename|move|mv',
4833 @command('rename|move|mv',
4836 [('A', 'after', None, _('record a rename that has already occurred')),
4834 [('A', 'after', None, _('record a rename that has already occurred')),
4837 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4835 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4838 ] + walkopts + dryrunopts,
4836 ] + walkopts + dryrunopts,
4839 _('[OPTION]... SOURCE... DEST'))
4837 _('[OPTION]... SOURCE... DEST'))
4840 def rename(ui, repo, *pats, **opts):
4838 def rename(ui, repo, *pats, **opts):
4841 """rename files; equivalent of copy + remove
4839 """rename files; equivalent of copy + remove
4842
4840
4843 Mark dest as copies of sources; mark sources for deletion. If dest
4841 Mark dest as copies of sources; mark sources for deletion. If dest
4844 is a directory, copies are put in that directory. If dest is a
4842 is a directory, copies are put in that directory. If dest is a
4845 file, there can only be one source.
4843 file, there can only be one source.
4846
4844
4847 By default, this command copies the contents of files as they
4845 By default, this command copies the contents of files as they
4848 exist in the working directory. If invoked with -A/--after, the
4846 exist in the working directory. If invoked with -A/--after, the
4849 operation is recorded, but no copying is performed.
4847 operation is recorded, but no copying is performed.
4850
4848
4851 This command takes effect at the next commit. To undo a rename
4849 This command takes effect at the next commit. To undo a rename
4852 before that, see :hg:`revert`.
4850 before that, see :hg:`revert`.
4853
4851
4854 Returns 0 on success, 1 if errors are encountered.
4852 Returns 0 on success, 1 if errors are encountered.
4855 """
4853 """
4856 wlock = repo.wlock(False)
4854 wlock = repo.wlock(False)
4857 try:
4855 try:
4858 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4856 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4859 finally:
4857 finally:
4860 wlock.release()
4858 wlock.release()
4861
4859
4862 @command('resolve',
4860 @command('resolve',
4863 [('a', 'all', None, _('select all unresolved files')),
4861 [('a', 'all', None, _('select all unresolved files')),
4864 ('l', 'list', None, _('list state of files needing merge')),
4862 ('l', 'list', None, _('list state of files needing merge')),
4865 ('m', 'mark', None, _('mark files as resolved')),
4863 ('m', 'mark', None, _('mark files as resolved')),
4866 ('u', 'unmark', None, _('mark files as unresolved')),
4864 ('u', 'unmark', None, _('mark files as unresolved')),
4867 ('n', 'no-status', None, _('hide status prefix'))]
4865 ('n', 'no-status', None, _('hide status prefix'))]
4868 + mergetoolopts + walkopts,
4866 + mergetoolopts + walkopts,
4869 _('[OPTION]... [FILE]...'))
4867 _('[OPTION]... [FILE]...'))
4870 def resolve(ui, repo, *pats, **opts):
4868 def resolve(ui, repo, *pats, **opts):
4871 """redo merges or set/view the merge status of files
4869 """redo merges or set/view the merge status of files
4872
4870
4873 Merges with unresolved conflicts are often the result of
4871 Merges with unresolved conflicts are often the result of
4874 non-interactive merging using the ``internal:merge`` configuration
4872 non-interactive merging using the ``internal:merge`` configuration
4875 setting, or a command-line merge tool like ``diff3``. The resolve
4873 setting, or a command-line merge tool like ``diff3``. The resolve
4876 command is used to manage the files involved in a merge, after
4874 command is used to manage the files involved in a merge, after
4877 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4875 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4878 working directory must have two parents). See :hg:`help
4876 working directory must have two parents). See :hg:`help
4879 merge-tools` for information on configuring merge tools.
4877 merge-tools` for information on configuring merge tools.
4880
4878
4881 The resolve command can be used in the following ways:
4879 The resolve command can be used in the following ways:
4882
4880
4883 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4881 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4884 files, discarding any previous merge attempts. Re-merging is not
4882 files, discarding any previous merge attempts. Re-merging is not
4885 performed for files already marked as resolved. Use ``--all/-a``
4883 performed for files already marked as resolved. Use ``--all/-a``
4886 to select all unresolved files. ``--tool`` can be used to specify
4884 to select all unresolved files. ``--tool`` can be used to specify
4887 the merge tool used for the given files. It overrides the HGMERGE
4885 the merge tool used for the given files. It overrides the HGMERGE
4888 environment variable and your configuration files. Previous file
4886 environment variable and your configuration files. Previous file
4889 contents are saved with a ``.orig`` suffix.
4887 contents are saved with a ``.orig`` suffix.
4890
4888
4891 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4889 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4892 (e.g. after having manually fixed-up the files). The default is
4890 (e.g. after having manually fixed-up the files). The default is
4893 to mark all unresolved files.
4891 to mark all unresolved files.
4894
4892
4895 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4893 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4896 default is to mark all resolved files.
4894 default is to mark all resolved files.
4897
4895
4898 - :hg:`resolve -l`: list files which had or still have conflicts.
4896 - :hg:`resolve -l`: list files which had or still have conflicts.
4899 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4897 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4900
4898
4901 Note that Mercurial will not let you commit files with unresolved
4899 Note that Mercurial will not let you commit files with unresolved
4902 merge conflicts. You must use :hg:`resolve -m ...` before you can
4900 merge conflicts. You must use :hg:`resolve -m ...` before you can
4903 commit after a conflicting merge.
4901 commit after a conflicting merge.
4904
4902
4905 Returns 0 on success, 1 if any files fail a resolve attempt.
4903 Returns 0 on success, 1 if any files fail a resolve attempt.
4906 """
4904 """
4907
4905
4908 all, mark, unmark, show, nostatus = \
4906 all, mark, unmark, show, nostatus = \
4909 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
4907 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
4910
4908
4911 if (show and (mark or unmark)) or (mark and unmark):
4909 if (show and (mark or unmark)) or (mark and unmark):
4912 raise util.Abort(_("too many options specified"))
4910 raise util.Abort(_("too many options specified"))
4913 if pats and all:
4911 if pats and all:
4914 raise util.Abort(_("can't specify --all and patterns"))
4912 raise util.Abort(_("can't specify --all and patterns"))
4915 if not (all or pats or show or mark or unmark):
4913 if not (all or pats or show or mark or unmark):
4916 raise util.Abort(_('no files or directories specified; '
4914 raise util.Abort(_('no files or directories specified; '
4917 'use --all to remerge all files'))
4915 'use --all to remerge all files'))
4918
4916
4919 ms = mergemod.mergestate(repo)
4917 ms = mergemod.mergestate(repo)
4920 m = scmutil.match(repo[None], pats, opts)
4918 m = scmutil.match(repo[None], pats, opts)
4921 ret = 0
4919 ret = 0
4922
4920
4923 for f in ms:
4921 for f in ms:
4924 if m(f):
4922 if m(f):
4925 if show:
4923 if show:
4926 if nostatus:
4924 if nostatus:
4927 ui.write("%s\n" % f)
4925 ui.write("%s\n" % f)
4928 else:
4926 else:
4929 ui.write("%s %s\n" % (ms[f].upper(), f),
4927 ui.write("%s %s\n" % (ms[f].upper(), f),
4930 label='resolve.' +
4928 label='resolve.' +
4931 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
4929 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
4932 elif mark:
4930 elif mark:
4933 ms.mark(f, "r")
4931 ms.mark(f, "r")
4934 elif unmark:
4932 elif unmark:
4935 ms.mark(f, "u")
4933 ms.mark(f, "u")
4936 else:
4934 else:
4937 wctx = repo[None]
4935 wctx = repo[None]
4938 mctx = wctx.parents()[-1]
4936 mctx = wctx.parents()[-1]
4939
4937
4940 # backup pre-resolve (merge uses .orig for its own purposes)
4938 # backup pre-resolve (merge uses .orig for its own purposes)
4941 a = repo.wjoin(f)
4939 a = repo.wjoin(f)
4942 util.copyfile(a, a + ".resolve")
4940 util.copyfile(a, a + ".resolve")
4943
4941
4944 try:
4942 try:
4945 # resolve file
4943 # resolve file
4946 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4944 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4947 if ms.resolve(f, wctx, mctx):
4945 if ms.resolve(f, wctx, mctx):
4948 ret = 1
4946 ret = 1
4949 finally:
4947 finally:
4950 ui.setconfig('ui', 'forcemerge', '')
4948 ui.setconfig('ui', 'forcemerge', '')
4951 ms.commit()
4949 ms.commit()
4952
4950
4953 # replace filemerge's .orig file with our resolve file
4951 # replace filemerge's .orig file with our resolve file
4954 util.rename(a + ".resolve", a + ".orig")
4952 util.rename(a + ".resolve", a + ".orig")
4955
4953
4956 ms.commit()
4954 ms.commit()
4957 return ret
4955 return ret
4958
4956
4959 @command('revert',
4957 @command('revert',
4960 [('a', 'all', None, _('revert all changes when no arguments given')),
4958 [('a', 'all', None, _('revert all changes when no arguments given')),
4961 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4959 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4962 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4960 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4963 ('C', 'no-backup', None, _('do not save backup copies of files')),
4961 ('C', 'no-backup', None, _('do not save backup copies of files')),
4964 ] + walkopts + dryrunopts,
4962 ] + walkopts + dryrunopts,
4965 _('[OPTION]... [-r REV] [NAME]...'))
4963 _('[OPTION]... [-r REV] [NAME]...'))
4966 def revert(ui, repo, *pats, **opts):
4964 def revert(ui, repo, *pats, **opts):
4967 """restore files to their checkout state
4965 """restore files to their checkout state
4968
4966
4969 .. note::
4967 .. note::
4970 To check out earlier revisions, you should use :hg:`update REV`.
4968 To check out earlier revisions, you should use :hg:`update REV`.
4971 To cancel an uncommitted merge (and lose your changes),
4969 To cancel an uncommitted merge (and lose your changes),
4972 use :hg:`update --clean .`.
4970 use :hg:`update --clean .`.
4973
4971
4974 With no revision specified, revert the specified files or directories
4972 With no revision specified, revert the specified files or directories
4975 to the contents they had in the parent of the working directory.
4973 to the contents they had in the parent of the working directory.
4976 This restores the contents of files to an unmodified
4974 This restores the contents of files to an unmodified
4977 state and unschedules adds, removes, copies, and renames. If the
4975 state and unschedules adds, removes, copies, and renames. If the
4978 working directory has two parents, you must explicitly specify a
4976 working directory has two parents, you must explicitly specify a
4979 revision.
4977 revision.
4980
4978
4981 Using the -r/--rev or -d/--date options, revert the given files or
4979 Using the -r/--rev or -d/--date options, revert the given files or
4982 directories to their states as of a specific revision. Because
4980 directories to their states as of a specific revision. Because
4983 revert does not change the working directory parents, this will
4981 revert does not change the working directory parents, this will
4984 cause these files to appear modified. This can be helpful to "back
4982 cause these files to appear modified. This can be helpful to "back
4985 out" some or all of an earlier change. See :hg:`backout` for a
4983 out" some or all of an earlier change. See :hg:`backout` for a
4986 related method.
4984 related method.
4987
4985
4988 Modified files are saved with a .orig suffix before reverting.
4986 Modified files are saved with a .orig suffix before reverting.
4989 To disable these backups, use --no-backup.
4987 To disable these backups, use --no-backup.
4990
4988
4991 See :hg:`help dates` for a list of formats valid for -d/--date.
4989 See :hg:`help dates` for a list of formats valid for -d/--date.
4992
4990
4993 Returns 0 on success.
4991 Returns 0 on success.
4994 """
4992 """
4995
4993
4996 if opts.get("date"):
4994 if opts.get("date"):
4997 if opts.get("rev"):
4995 if opts.get("rev"):
4998 raise util.Abort(_("you can't specify a revision and a date"))
4996 raise util.Abort(_("you can't specify a revision and a date"))
4999 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4997 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5000
4998
5001 parent, p2 = repo.dirstate.parents()
4999 parent, p2 = repo.dirstate.parents()
5002 if not opts.get('rev') and p2 != nullid:
5000 if not opts.get('rev') and p2 != nullid:
5003 # revert after merge is a trap for new users (issue2915)
5001 # revert after merge is a trap for new users (issue2915)
5004 raise util.Abort(_('uncommitted merge with no revision specified'),
5002 raise util.Abort(_('uncommitted merge with no revision specified'),
5005 hint=_('use "hg update" or see "hg help revert"'))
5003 hint=_('use "hg update" or see "hg help revert"'))
5006
5004
5007 ctx = scmutil.revsingle(repo, opts.get('rev'))
5005 ctx = scmutil.revsingle(repo, opts.get('rev'))
5008
5006
5009 if not pats and not opts.get('all'):
5007 if not pats and not opts.get('all'):
5010 msg = _("no files or directories specified")
5008 msg = _("no files or directories specified")
5011 if p2 != nullid:
5009 if p2 != nullid:
5012 hint = _("uncommitted merge, use --all to discard all changes,"
5010 hint = _("uncommitted merge, use --all to discard all changes,"
5013 " or 'hg update -C .' to abort the merge")
5011 " or 'hg update -C .' to abort the merge")
5014 raise util.Abort(msg, hint=hint)
5012 raise util.Abort(msg, hint=hint)
5015 dirty = util.any(repo.status())
5013 dirty = util.any(repo.status())
5016 node = ctx.node()
5014 node = ctx.node()
5017 if node != parent:
5015 if node != parent:
5018 if dirty:
5016 if dirty:
5019 hint = _("uncommitted changes, use --all to discard all"
5017 hint = _("uncommitted changes, use --all to discard all"
5020 " changes, or 'hg update %s' to update") % ctx.rev()
5018 " changes, or 'hg update %s' to update") % ctx.rev()
5021 else:
5019 else:
5022 hint = _("use --all to revert all files,"
5020 hint = _("use --all to revert all files,"
5023 " or 'hg update %s' to update") % ctx.rev()
5021 " or 'hg update %s' to update") % ctx.rev()
5024 elif dirty:
5022 elif dirty:
5025 hint = _("uncommitted changes, use --all to discard all changes")
5023 hint = _("uncommitted changes, use --all to discard all changes")
5026 else:
5024 else:
5027 hint = _("use --all to revert all files")
5025 hint = _("use --all to revert all files")
5028 raise util.Abort(msg, hint=hint)
5026 raise util.Abort(msg, hint=hint)
5029
5027
5030 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5028 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5031
5029
5032 @command('rollback', dryrunopts +
5030 @command('rollback', dryrunopts +
5033 [('f', 'force', False, _('ignore safety measures'))])
5031 [('f', 'force', False, _('ignore safety measures'))])
5034 def rollback(ui, repo, **opts):
5032 def rollback(ui, repo, **opts):
5035 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5033 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5036
5034
5037 Please use :hg:`commit --amend` instead of rollback to correct
5035 Please use :hg:`commit --amend` instead of rollback to correct
5038 mistakes in the last commit.
5036 mistakes in the last commit.
5039
5037
5040 This command should be used with care. There is only one level of
5038 This command should be used with care. There is only one level of
5041 rollback, and there is no way to undo a rollback. It will also
5039 rollback, and there is no way to undo a rollback. It will also
5042 restore the dirstate at the time of the last transaction, losing
5040 restore the dirstate at the time of the last transaction, losing
5043 any dirstate changes since that time. This command does not alter
5041 any dirstate changes since that time. This command does not alter
5044 the working directory.
5042 the working directory.
5045
5043
5046 Transactions are used to encapsulate the effects of all commands
5044 Transactions are used to encapsulate the effects of all commands
5047 that create new changesets or propagate existing changesets into a
5045 that create new changesets or propagate existing changesets into a
5048 repository.
5046 repository.
5049
5047
5050 .. container:: verbose
5048 .. container:: verbose
5051
5049
5052 For example, the following commands are transactional, and their
5050 For example, the following commands are transactional, and their
5053 effects can be rolled back:
5051 effects can be rolled back:
5054
5052
5055 - commit
5053 - commit
5056 - import
5054 - import
5057 - pull
5055 - pull
5058 - push (with this repository as the destination)
5056 - push (with this repository as the destination)
5059 - unbundle
5057 - unbundle
5060
5058
5061 To avoid permanent data loss, rollback will refuse to rollback a
5059 To avoid permanent data loss, rollback will refuse to rollback a
5062 commit transaction if it isn't checked out. Use --force to
5060 commit transaction if it isn't checked out. Use --force to
5063 override this protection.
5061 override this protection.
5064
5062
5065 This command is not intended for use on public repositories. Once
5063 This command is not intended for use on public repositories. Once
5066 changes are visible for pull by other users, rolling a transaction
5064 changes are visible for pull by other users, rolling a transaction
5067 back locally is ineffective (someone else may already have pulled
5065 back locally is ineffective (someone else may already have pulled
5068 the changes). Furthermore, a race is possible with readers of the
5066 the changes). Furthermore, a race is possible with readers of the
5069 repository; for example an in-progress pull from the repository
5067 repository; for example an in-progress pull from the repository
5070 may fail if a rollback is performed.
5068 may fail if a rollback is performed.
5071
5069
5072 Returns 0 on success, 1 if no rollback data is available.
5070 Returns 0 on success, 1 if no rollback data is available.
5073 """
5071 """
5074 return repo.rollback(dryrun=opts.get('dry_run'),
5072 return repo.rollback(dryrun=opts.get('dry_run'),
5075 force=opts.get('force'))
5073 force=opts.get('force'))
5076
5074
5077 @command('root', [])
5075 @command('root', [])
5078 def root(ui, repo):
5076 def root(ui, repo):
5079 """print the root (top) of the current working directory
5077 """print the root (top) of the current working directory
5080
5078
5081 Print the root directory of the current repository.
5079 Print the root directory of the current repository.
5082
5080
5083 Returns 0 on success.
5081 Returns 0 on success.
5084 """
5082 """
5085 ui.write(repo.root + "\n")
5083 ui.write(repo.root + "\n")
5086
5084
5087 @command('^serve',
5085 @command('^serve',
5088 [('A', 'accesslog', '', _('name of access log file to write to'),
5086 [('A', 'accesslog', '', _('name of access log file to write to'),
5089 _('FILE')),
5087 _('FILE')),
5090 ('d', 'daemon', None, _('run server in background')),
5088 ('d', 'daemon', None, _('run server in background')),
5091 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')),
5089 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')),
5092 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5090 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5093 # use string type, then we can check if something was passed
5091 # use string type, then we can check if something was passed
5094 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5092 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5095 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5093 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5096 _('ADDR')),
5094 _('ADDR')),
5097 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5095 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5098 _('PREFIX')),
5096 _('PREFIX')),
5099 ('n', 'name', '',
5097 ('n', 'name', '',
5100 _('name to show in web pages (default: working directory)'), _('NAME')),
5098 _('name to show in web pages (default: working directory)'), _('NAME')),
5101 ('', 'web-conf', '',
5099 ('', 'web-conf', '',
5102 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5100 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5103 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5101 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5104 _('FILE')),
5102 _('FILE')),
5105 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5103 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5106 ('', 'stdio', None, _('for remote clients')),
5104 ('', 'stdio', None, _('for remote clients')),
5107 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5105 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5108 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5106 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5109 ('', 'style', '', _('template style to use'), _('STYLE')),
5107 ('', 'style', '', _('template style to use'), _('STYLE')),
5110 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5108 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5111 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5109 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5112 _('[OPTION]...'))
5110 _('[OPTION]...'))
5113 def serve(ui, repo, **opts):
5111 def serve(ui, repo, **opts):
5114 """start stand-alone webserver
5112 """start stand-alone webserver
5115
5113
5116 Start a local HTTP repository browser and pull server. You can use
5114 Start a local HTTP repository browser and pull server. You can use
5117 this for ad-hoc sharing and browsing of repositories. It is
5115 this for ad-hoc sharing and browsing of repositories. It is
5118 recommended to use a real web server to serve a repository for
5116 recommended to use a real web server to serve a repository for
5119 longer periods of time.
5117 longer periods of time.
5120
5118
5121 Please note that the server does not implement access control.
5119 Please note that the server does not implement access control.
5122 This means that, by default, anybody can read from the server and
5120 This means that, by default, anybody can read from the server and
5123 nobody can write to it by default. Set the ``web.allow_push``
5121 nobody can write to it by default. Set the ``web.allow_push``
5124 option to ``*`` to allow everybody to push to the server. You
5122 option to ``*`` to allow everybody to push to the server. You
5125 should use a real web server if you need to authenticate users.
5123 should use a real web server if you need to authenticate users.
5126
5124
5127 By default, the server logs accesses to stdout and errors to
5125 By default, the server logs accesses to stdout and errors to
5128 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5126 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5129 files.
5127 files.
5130
5128
5131 To have the server choose a free port number to listen on, specify
5129 To have the server choose a free port number to listen on, specify
5132 a port number of 0; in this case, the server will print the port
5130 a port number of 0; in this case, the server will print the port
5133 number it uses.
5131 number it uses.
5134
5132
5135 Returns 0 on success.
5133 Returns 0 on success.
5136 """
5134 """
5137
5135
5138 if opts["stdio"] and opts["cmdserver"]:
5136 if opts["stdio"] and opts["cmdserver"]:
5139 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5137 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5140
5138
5141 def checkrepo():
5139 def checkrepo():
5142 if repo is None:
5140 if repo is None:
5143 raise error.RepoError(_("there is no Mercurial repository here"
5141 raise error.RepoError(_("there is no Mercurial repository here"
5144 " (.hg not found)"))
5142 " (.hg not found)"))
5145
5143
5146 if opts["stdio"]:
5144 if opts["stdio"]:
5147 checkrepo()
5145 checkrepo()
5148 s = sshserver.sshserver(ui, repo)
5146 s = sshserver.sshserver(ui, repo)
5149 s.serve_forever()
5147 s.serve_forever()
5150
5148
5151 if opts["cmdserver"]:
5149 if opts["cmdserver"]:
5152 checkrepo()
5150 checkrepo()
5153 s = commandserver.server(ui, repo, opts["cmdserver"])
5151 s = commandserver.server(ui, repo, opts["cmdserver"])
5154 return s.serve()
5152 return s.serve()
5155
5153
5156 # this way we can check if something was given in the command-line
5154 # this way we can check if something was given in the command-line
5157 if opts.get('port'):
5155 if opts.get('port'):
5158 opts['port'] = util.getport(opts.get('port'))
5156 opts['port'] = util.getport(opts.get('port'))
5159
5157
5160 baseui = repo and repo.baseui or ui
5158 baseui = repo and repo.baseui or ui
5161 optlist = ("name templates style address port prefix ipv6"
5159 optlist = ("name templates style address port prefix ipv6"
5162 " accesslog errorlog certificate encoding")
5160 " accesslog errorlog certificate encoding")
5163 for o in optlist.split():
5161 for o in optlist.split():
5164 val = opts.get(o, '')
5162 val = opts.get(o, '')
5165 if val in (None, ''): # should check against default options instead
5163 if val in (None, ''): # should check against default options instead
5166 continue
5164 continue
5167 baseui.setconfig("web", o, val)
5165 baseui.setconfig("web", o, val)
5168 if repo and repo.ui != baseui:
5166 if repo and repo.ui != baseui:
5169 repo.ui.setconfig("web", o, val)
5167 repo.ui.setconfig("web", o, val)
5170
5168
5171 o = opts.get('web_conf') or opts.get('webdir_conf')
5169 o = opts.get('web_conf') or opts.get('webdir_conf')
5172 if not o:
5170 if not o:
5173 if not repo:
5171 if not repo:
5174 raise error.RepoError(_("there is no Mercurial repository"
5172 raise error.RepoError(_("there is no Mercurial repository"
5175 " here (.hg not found)"))
5173 " here (.hg not found)"))
5176 o = repo
5174 o = repo
5177
5175
5178 app = hgweb.hgweb(o, baseui=baseui)
5176 app = hgweb.hgweb(o, baseui=baseui)
5179
5177
5180 class service(object):
5178 class service(object):
5181 def init(self):
5179 def init(self):
5182 util.setsignalhandler()
5180 util.setsignalhandler()
5183 self.httpd = hgweb.server.create_server(ui, app)
5181 self.httpd = hgweb.server.create_server(ui, app)
5184
5182
5185 if opts['port'] and not ui.verbose:
5183 if opts['port'] and not ui.verbose:
5186 return
5184 return
5187
5185
5188 if self.httpd.prefix:
5186 if self.httpd.prefix:
5189 prefix = self.httpd.prefix.strip('/') + '/'
5187 prefix = self.httpd.prefix.strip('/') + '/'
5190 else:
5188 else:
5191 prefix = ''
5189 prefix = ''
5192
5190
5193 port = ':%d' % self.httpd.port
5191 port = ':%d' % self.httpd.port
5194 if port == ':80':
5192 if port == ':80':
5195 port = ''
5193 port = ''
5196
5194
5197 bindaddr = self.httpd.addr
5195 bindaddr = self.httpd.addr
5198 if bindaddr == '0.0.0.0':
5196 if bindaddr == '0.0.0.0':
5199 bindaddr = '*'
5197 bindaddr = '*'
5200 elif ':' in bindaddr: # IPv6
5198 elif ':' in bindaddr: # IPv6
5201 bindaddr = '[%s]' % bindaddr
5199 bindaddr = '[%s]' % bindaddr
5202
5200
5203 fqaddr = self.httpd.fqaddr
5201 fqaddr = self.httpd.fqaddr
5204 if ':' in fqaddr:
5202 if ':' in fqaddr:
5205 fqaddr = '[%s]' % fqaddr
5203 fqaddr = '[%s]' % fqaddr
5206 if opts['port']:
5204 if opts['port']:
5207 write = ui.status
5205 write = ui.status
5208 else:
5206 else:
5209 write = ui.write
5207 write = ui.write
5210 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5208 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5211 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5209 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5212
5210
5213 def run(self):
5211 def run(self):
5214 self.httpd.serve_forever()
5212 self.httpd.serve_forever()
5215
5213
5216 service = service()
5214 service = service()
5217
5215
5218 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5216 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5219
5217
5220 @command('showconfig|debugconfig',
5218 @command('showconfig|debugconfig',
5221 [('u', 'untrusted', None, _('show untrusted configuration options'))],
5219 [('u', 'untrusted', None, _('show untrusted configuration options'))],
5222 _('[-u] [NAME]...'))
5220 _('[-u] [NAME]...'))
5223 def showconfig(ui, repo, *values, **opts):
5221 def showconfig(ui, repo, *values, **opts):
5224 """show combined config settings from all hgrc files
5222 """show combined config settings from all hgrc files
5225
5223
5226 With no arguments, print names and values of all config items.
5224 With no arguments, print names and values of all config items.
5227
5225
5228 With one argument of the form section.name, print just the value
5226 With one argument of the form section.name, print just the value
5229 of that config item.
5227 of that config item.
5230
5228
5231 With multiple arguments, print names and values of all config
5229 With multiple arguments, print names and values of all config
5232 items with matching section names.
5230 items with matching section names.
5233
5231
5234 With --debug, the source (filename and line number) is printed
5232 With --debug, the source (filename and line number) is printed
5235 for each config item.
5233 for each config item.
5236
5234
5237 Returns 0 on success.
5235 Returns 0 on success.
5238 """
5236 """
5239
5237
5240 for f in scmutil.rcpath():
5238 for f in scmutil.rcpath():
5241 ui.debug('read config from: %s\n' % f)
5239 ui.debug('read config from: %s\n' % f)
5242 untrusted = bool(opts.get('untrusted'))
5240 untrusted = bool(opts.get('untrusted'))
5243 if values:
5241 if values:
5244 sections = [v for v in values if '.' not in v]
5242 sections = [v for v in values if '.' not in v]
5245 items = [v for v in values if '.' in v]
5243 items = [v for v in values if '.' in v]
5246 if len(items) > 1 or items and sections:
5244 if len(items) > 1 or items and sections:
5247 raise util.Abort(_('only one config item permitted'))
5245 raise util.Abort(_('only one config item permitted'))
5248 for section, name, value in ui.walkconfig(untrusted=untrusted):
5246 for section, name, value in ui.walkconfig(untrusted=untrusted):
5249 value = str(value).replace('\n', '\\n')
5247 value = str(value).replace('\n', '\\n')
5250 sectname = section + '.' + name
5248 sectname = section + '.' + name
5251 if values:
5249 if values:
5252 for v in values:
5250 for v in values:
5253 if v == section:
5251 if v == section:
5254 ui.debug('%s: ' %
5252 ui.debug('%s: ' %
5255 ui.configsource(section, name, untrusted))
5253 ui.configsource(section, name, untrusted))
5256 ui.write('%s=%s\n' % (sectname, value))
5254 ui.write('%s=%s\n' % (sectname, value))
5257 elif v == sectname:
5255 elif v == sectname:
5258 ui.debug('%s: ' %
5256 ui.debug('%s: ' %
5259 ui.configsource(section, name, untrusted))
5257 ui.configsource(section, name, untrusted))
5260 ui.write(value, '\n')
5258 ui.write(value, '\n')
5261 else:
5259 else:
5262 ui.debug('%s: ' %
5260 ui.debug('%s: ' %
5263 ui.configsource(section, name, untrusted))
5261 ui.configsource(section, name, untrusted))
5264 ui.write('%s=%s\n' % (sectname, value))
5262 ui.write('%s=%s\n' % (sectname, value))
5265
5263
5266 @command('^status|st',
5264 @command('^status|st',
5267 [('A', 'all', None, _('show status of all files')),
5265 [('A', 'all', None, _('show status of all files')),
5268 ('m', 'modified', None, _('show only modified files')),
5266 ('m', 'modified', None, _('show only modified files')),
5269 ('a', 'added', None, _('show only added files')),
5267 ('a', 'added', None, _('show only added files')),
5270 ('r', 'removed', None, _('show only removed files')),
5268 ('r', 'removed', None, _('show only removed files')),
5271 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5269 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5272 ('c', 'clean', None, _('show only files without changes')),
5270 ('c', 'clean', None, _('show only files without changes')),
5273 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5271 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5274 ('i', 'ignored', None, _('show only ignored files')),
5272 ('i', 'ignored', None, _('show only ignored files')),
5275 ('n', 'no-status', None, _('hide status prefix')),
5273 ('n', 'no-status', None, _('hide status prefix')),
5276 ('C', 'copies', None, _('show source of copied files')),
5274 ('C', 'copies', None, _('show source of copied files')),
5277 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5275 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5278 ('', 'rev', [], _('show difference from revision'), _('REV')),
5276 ('', 'rev', [], _('show difference from revision'), _('REV')),
5279 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5277 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5280 ] + walkopts + subrepoopts,
5278 ] + walkopts + subrepoopts,
5281 _('[OPTION]... [FILE]...'))
5279 _('[OPTION]... [FILE]...'))
5282 def status(ui, repo, *pats, **opts):
5280 def status(ui, repo, *pats, **opts):
5283 """show changed files in the working directory
5281 """show changed files in the working directory
5284
5282
5285 Show status of files in the repository. If names are given, only
5283 Show status of files in the repository. If names are given, only
5286 files that match are shown. Files that are clean or ignored or
5284 files that match are shown. Files that are clean or ignored or
5287 the source of a copy/move operation, are not listed unless
5285 the source of a copy/move operation, are not listed unless
5288 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5286 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5289 Unless options described with "show only ..." are given, the
5287 Unless options described with "show only ..." are given, the
5290 options -mardu are used.
5288 options -mardu are used.
5291
5289
5292 Option -q/--quiet hides untracked (unknown and ignored) files
5290 Option -q/--quiet hides untracked (unknown and ignored) files
5293 unless explicitly requested with -u/--unknown or -i/--ignored.
5291 unless explicitly requested with -u/--unknown or -i/--ignored.
5294
5292
5295 .. note::
5293 .. note::
5296 status may appear to disagree with diff if permissions have
5294 status may appear to disagree with diff if permissions have
5297 changed or a merge has occurred. The standard diff format does
5295 changed or a merge has occurred. The standard diff format does
5298 not report permission changes and diff only reports changes
5296 not report permission changes and diff only reports changes
5299 relative to one merge parent.
5297 relative to one merge parent.
5300
5298
5301 If one revision is given, it is used as the base revision.
5299 If one revision is given, it is used as the base revision.
5302 If two revisions are given, the differences between them are
5300 If two revisions are given, the differences between them are
5303 shown. The --change option can also be used as a shortcut to list
5301 shown. The --change option can also be used as a shortcut to list
5304 the changed files of a revision from its first parent.
5302 the changed files of a revision from its first parent.
5305
5303
5306 The codes used to show the status of files are::
5304 The codes used to show the status of files are::
5307
5305
5308 M = modified
5306 M = modified
5309 A = added
5307 A = added
5310 R = removed
5308 R = removed
5311 C = clean
5309 C = clean
5312 ! = missing (deleted by non-hg command, but still tracked)
5310 ! = missing (deleted by non-hg command, but still tracked)
5313 ? = not tracked
5311 ? = not tracked
5314 I = ignored
5312 I = ignored
5315 = origin of the previous file listed as A (added)
5313 = origin of the previous file listed as A (added)
5316
5314
5317 .. container:: verbose
5315 .. container:: verbose
5318
5316
5319 Examples:
5317 Examples:
5320
5318
5321 - show changes in the working directory relative to a
5319 - show changes in the working directory relative to a
5322 changeset::
5320 changeset::
5323
5321
5324 hg status --rev 9353
5322 hg status --rev 9353
5325
5323
5326 - show all changes including copies in an existing changeset::
5324 - show all changes including copies in an existing changeset::
5327
5325
5328 hg status --copies --change 9353
5326 hg status --copies --change 9353
5329
5327
5330 - get a NUL separated list of added files, suitable for xargs::
5328 - get a NUL separated list of added files, suitable for xargs::
5331
5329
5332 hg status -an0
5330 hg status -an0
5333
5331
5334 Returns 0 on success.
5332 Returns 0 on success.
5335 """
5333 """
5336
5334
5337 revs = opts.get('rev')
5335 revs = opts.get('rev')
5338 change = opts.get('change')
5336 change = opts.get('change')
5339
5337
5340 if revs and change:
5338 if revs and change:
5341 msg = _('cannot specify --rev and --change at the same time')
5339 msg = _('cannot specify --rev and --change at the same time')
5342 raise util.Abort(msg)
5340 raise util.Abort(msg)
5343 elif change:
5341 elif change:
5344 node2 = scmutil.revsingle(repo, change, None).node()
5342 node2 = scmutil.revsingle(repo, change, None).node()
5345 node1 = repo[node2].p1().node()
5343 node1 = repo[node2].p1().node()
5346 else:
5344 else:
5347 node1, node2 = scmutil.revpair(repo, revs)
5345 node1, node2 = scmutil.revpair(repo, revs)
5348
5346
5349 cwd = (pats and repo.getcwd()) or ''
5347 cwd = (pats and repo.getcwd()) or ''
5350 end = opts.get('print0') and '\0' or '\n'
5348 end = opts.get('print0') and '\0' or '\n'
5351 copy = {}
5349 copy = {}
5352 states = 'modified added removed deleted unknown ignored clean'.split()
5350 states = 'modified added removed deleted unknown ignored clean'.split()
5353 show = [k for k in states if opts.get(k)]
5351 show = [k for k in states if opts.get(k)]
5354 if opts.get('all'):
5352 if opts.get('all'):
5355 show += ui.quiet and (states[:4] + ['clean']) or states
5353 show += ui.quiet and (states[:4] + ['clean']) or states
5356 if not show:
5354 if not show:
5357 show = ui.quiet and states[:4] or states[:5]
5355 show = ui.quiet and states[:4] or states[:5]
5358
5356
5359 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5357 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5360 'ignored' in show, 'clean' in show, 'unknown' in show,
5358 'ignored' in show, 'clean' in show, 'unknown' in show,
5361 opts.get('subrepos'))
5359 opts.get('subrepos'))
5362 changestates = zip(states, 'MAR!?IC', stat)
5360 changestates = zip(states, 'MAR!?IC', stat)
5363
5361
5364 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5362 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5365 copy = copies.pathcopies(repo[node1], repo[node2])
5363 copy = copies.pathcopies(repo[node1], repo[node2])
5366
5364
5367 fm = ui.formatter('status', opts)
5365 fm = ui.formatter('status', opts)
5368 fmt = '%s' + end
5366 fmt = '%s' + end
5369 showchar = not opts.get('no_status')
5367 showchar = not opts.get('no_status')
5370
5368
5371 for state, char, files in changestates:
5369 for state, char, files in changestates:
5372 if state in show:
5370 if state in show:
5373 label = 'status.' + state
5371 label = 'status.' + state
5374 for f in files:
5372 for f in files:
5375 fm.startitem()
5373 fm.startitem()
5376 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5374 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5377 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5375 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5378 if f in copy:
5376 if f in copy:
5379 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5377 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5380 label='status.copied')
5378 label='status.copied')
5381 fm.end()
5379 fm.end()
5382
5380
5383 @command('^summary|sum',
5381 @command('^summary|sum',
5384 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5382 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5385 def summary(ui, repo, **opts):
5383 def summary(ui, repo, **opts):
5386 """summarize working directory state
5384 """summarize working directory state
5387
5385
5388 This generates a brief summary of the working directory state,
5386 This generates a brief summary of the working directory state,
5389 including parents, branch, commit status, and available updates.
5387 including parents, branch, commit status, and available updates.
5390
5388
5391 With the --remote option, this will check the default paths for
5389 With the --remote option, this will check the default paths for
5392 incoming and outgoing changes. This can be time-consuming.
5390 incoming and outgoing changes. This can be time-consuming.
5393
5391
5394 Returns 0 on success.
5392 Returns 0 on success.
5395 """
5393 """
5396
5394
5397 ctx = repo[None]
5395 ctx = repo[None]
5398 parents = ctx.parents()
5396 parents = ctx.parents()
5399 pnode = parents[0].node()
5397 pnode = parents[0].node()
5400 marks = []
5398 marks = []
5401
5399
5402 for p in parents:
5400 for p in parents:
5403 # label with log.changeset (instead of log.parent) since this
5401 # label with log.changeset (instead of log.parent) since this
5404 # shows a working directory parent *changeset*:
5402 # shows a working directory parent *changeset*:
5405 # i18n: column positioning for "hg summary"
5403 # i18n: column positioning for "hg summary"
5406 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5404 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5407 label='log.changeset changeset.%s' % p.phasestr())
5405 label='log.changeset changeset.%s' % p.phasestr())
5408 ui.write(' '.join(p.tags()), label='log.tag')
5406 ui.write(' '.join(p.tags()), label='log.tag')
5409 if p.bookmarks():
5407 if p.bookmarks():
5410 marks.extend(p.bookmarks())
5408 marks.extend(p.bookmarks())
5411 if p.rev() == -1:
5409 if p.rev() == -1:
5412 if not len(repo):
5410 if not len(repo):
5413 ui.write(_(' (empty repository)'))
5411 ui.write(_(' (empty repository)'))
5414 else:
5412 else:
5415 ui.write(_(' (no revision checked out)'))
5413 ui.write(_(' (no revision checked out)'))
5416 ui.write('\n')
5414 ui.write('\n')
5417 if p.description():
5415 if p.description():
5418 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5416 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5419 label='log.summary')
5417 label='log.summary')
5420
5418
5421 branch = ctx.branch()
5419 branch = ctx.branch()
5422 bheads = repo.branchheads(branch)
5420 bheads = repo.branchheads(branch)
5423 # i18n: column positioning for "hg summary"
5421 # i18n: column positioning for "hg summary"
5424 m = _('branch: %s\n') % branch
5422 m = _('branch: %s\n') % branch
5425 if branch != 'default':
5423 if branch != 'default':
5426 ui.write(m, label='log.branch')
5424 ui.write(m, label='log.branch')
5427 else:
5425 else:
5428 ui.status(m, label='log.branch')
5426 ui.status(m, label='log.branch')
5429
5427
5430 if marks:
5428 if marks:
5431 current = repo._bookmarkcurrent
5429 current = repo._bookmarkcurrent
5432 # i18n: column positioning for "hg summary"
5430 # i18n: column positioning for "hg summary"
5433 ui.write(_('bookmarks:'), label='log.bookmark')
5431 ui.write(_('bookmarks:'), label='log.bookmark')
5434 if current is not None:
5432 if current is not None:
5435 if current in marks:
5433 if current in marks:
5436 ui.write(' *' + current, label='bookmarks.current')
5434 ui.write(' *' + current, label='bookmarks.current')
5437 marks.remove(current)
5435 marks.remove(current)
5438 else:
5436 else:
5439 ui.write(' [%s]' % current, label='bookmarks.current')
5437 ui.write(' [%s]' % current, label='bookmarks.current')
5440 for m in marks:
5438 for m in marks:
5441 ui.write(' ' + m, label='log.bookmark')
5439 ui.write(' ' + m, label='log.bookmark')
5442 ui.write('\n', label='log.bookmark')
5440 ui.write('\n', label='log.bookmark')
5443
5441
5444 st = list(repo.status(unknown=True))[:6]
5442 st = list(repo.status(unknown=True))[:6]
5445
5443
5446 c = repo.dirstate.copies()
5444 c = repo.dirstate.copies()
5447 copied, renamed = [], []
5445 copied, renamed = [], []
5448 for d, s in c.iteritems():
5446 for d, s in c.iteritems():
5449 if s in st[2]:
5447 if s in st[2]:
5450 st[2].remove(s)
5448 st[2].remove(s)
5451 renamed.append(d)
5449 renamed.append(d)
5452 else:
5450 else:
5453 copied.append(d)
5451 copied.append(d)
5454 if d in st[1]:
5452 if d in st[1]:
5455 st[1].remove(d)
5453 st[1].remove(d)
5456 st.insert(3, renamed)
5454 st.insert(3, renamed)
5457 st.insert(4, copied)
5455 st.insert(4, copied)
5458
5456
5459 ms = mergemod.mergestate(repo)
5457 ms = mergemod.mergestate(repo)
5460 st.append([f for f in ms if ms[f] == 'u'])
5458 st.append([f for f in ms if ms[f] == 'u'])
5461
5459
5462 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5460 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5463 st.append(subs)
5461 st.append(subs)
5464
5462
5465 labels = [ui.label(_('%d modified'), 'status.modified'),
5463 labels = [ui.label(_('%d modified'), 'status.modified'),
5466 ui.label(_('%d added'), 'status.added'),
5464 ui.label(_('%d added'), 'status.added'),
5467 ui.label(_('%d removed'), 'status.removed'),
5465 ui.label(_('%d removed'), 'status.removed'),
5468 ui.label(_('%d renamed'), 'status.copied'),
5466 ui.label(_('%d renamed'), 'status.copied'),
5469 ui.label(_('%d copied'), 'status.copied'),
5467 ui.label(_('%d copied'), 'status.copied'),
5470 ui.label(_('%d deleted'), 'status.deleted'),
5468 ui.label(_('%d deleted'), 'status.deleted'),
5471 ui.label(_('%d unknown'), 'status.unknown'),
5469 ui.label(_('%d unknown'), 'status.unknown'),
5472 ui.label(_('%d ignored'), 'status.ignored'),
5470 ui.label(_('%d ignored'), 'status.ignored'),
5473 ui.label(_('%d unresolved'), 'resolve.unresolved'),
5471 ui.label(_('%d unresolved'), 'resolve.unresolved'),
5474 ui.label(_('%d subrepos'), 'status.modified')]
5472 ui.label(_('%d subrepos'), 'status.modified')]
5475 t = []
5473 t = []
5476 for s, l in zip(st, labels):
5474 for s, l in zip(st, labels):
5477 if s:
5475 if s:
5478 t.append(l % len(s))
5476 t.append(l % len(s))
5479
5477
5480 t = ', '.join(t)
5478 t = ', '.join(t)
5481 cleanworkdir = False
5479 cleanworkdir = False
5482
5480
5483 if len(parents) > 1:
5481 if len(parents) > 1:
5484 t += _(' (merge)')
5482 t += _(' (merge)')
5485 elif branch != parents[0].branch():
5483 elif branch != parents[0].branch():
5486 t += _(' (new branch)')
5484 t += _(' (new branch)')
5487 elif (parents[0].closesbranch() and
5485 elif (parents[0].closesbranch() and
5488 pnode in repo.branchheads(branch, closed=True)):
5486 pnode in repo.branchheads(branch, closed=True)):
5489 t += _(' (head closed)')
5487 t += _(' (head closed)')
5490 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
5488 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
5491 t += _(' (clean)')
5489 t += _(' (clean)')
5492 cleanworkdir = True
5490 cleanworkdir = True
5493 elif pnode not in bheads:
5491 elif pnode not in bheads:
5494 t += _(' (new branch head)')
5492 t += _(' (new branch head)')
5495
5493
5496 if cleanworkdir:
5494 if cleanworkdir:
5497 # i18n: column positioning for "hg summary"
5495 # i18n: column positioning for "hg summary"
5498 ui.status(_('commit: %s\n') % t.strip())
5496 ui.status(_('commit: %s\n') % t.strip())
5499 else:
5497 else:
5500 # i18n: column positioning for "hg summary"
5498 # i18n: column positioning for "hg summary"
5501 ui.write(_('commit: %s\n') % t.strip())
5499 ui.write(_('commit: %s\n') % t.strip())
5502
5500
5503 # all ancestors of branch heads - all ancestors of parent = new csets
5501 # all ancestors of branch heads - all ancestors of parent = new csets
5504 new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
5502 new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
5505 bheads))
5503 bheads))
5506
5504
5507 if new == 0:
5505 if new == 0:
5508 # i18n: column positioning for "hg summary"
5506 # i18n: column positioning for "hg summary"
5509 ui.status(_('update: (current)\n'))
5507 ui.status(_('update: (current)\n'))
5510 elif pnode not in bheads:
5508 elif pnode not in bheads:
5511 # i18n: column positioning for "hg summary"
5509 # i18n: column positioning for "hg summary"
5512 ui.write(_('update: %d new changesets (update)\n') % new)
5510 ui.write(_('update: %d new changesets (update)\n') % new)
5513 else:
5511 else:
5514 # i18n: column positioning for "hg summary"
5512 # i18n: column positioning for "hg summary"
5515 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5513 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5516 (new, len(bheads)))
5514 (new, len(bheads)))
5517
5515
5518 cmdutil.summaryhooks(ui, repo)
5516 cmdutil.summaryhooks(ui, repo)
5519
5517
5520 if opts.get('remote'):
5518 if opts.get('remote'):
5521 t = []
5519 t = []
5522 source, branches = hg.parseurl(ui.expandpath('default'))
5520 source, branches = hg.parseurl(ui.expandpath('default'))
5523 sbranch = branches[0]
5521 sbranch = branches[0]
5524 other = hg.peer(repo, {}, source)
5522 other = hg.peer(repo, {}, source)
5525 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5523 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5526 if revs:
5524 if revs:
5527 revs = [other.lookup(rev) for rev in revs]
5525 revs = [other.lookup(rev) for rev in revs]
5528 ui.debug('comparing with %s\n' % util.hidepassword(source))
5526 ui.debug('comparing with %s\n' % util.hidepassword(source))
5529 repo.ui.pushbuffer()
5527 repo.ui.pushbuffer()
5530 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5528 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5531 _common, incoming, _rheads = commoninc
5529 _common, incoming, _rheads = commoninc
5532 repo.ui.popbuffer()
5530 repo.ui.popbuffer()
5533 if incoming:
5531 if incoming:
5534 t.append(_('1 or more incoming'))
5532 t.append(_('1 or more incoming'))
5535
5533
5536 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5534 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5537 dbranch = branches[0]
5535 dbranch = branches[0]
5538 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5536 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5539 if source != dest:
5537 if source != dest:
5540 other = hg.peer(repo, {}, dest)
5538 other = hg.peer(repo, {}, dest)
5541 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5539 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5542 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5540 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5543 commoninc = None
5541 commoninc = None
5544 if revs:
5542 if revs:
5545 revs = [repo.lookup(rev) for rev in revs]
5543 revs = [repo.lookup(rev) for rev in revs]
5546 repo.ui.pushbuffer()
5544 repo.ui.pushbuffer()
5547 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs,
5545 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs,
5548 commoninc=commoninc)
5546 commoninc=commoninc)
5549 repo.ui.popbuffer()
5547 repo.ui.popbuffer()
5550 o = outgoing.missing
5548 o = outgoing.missing
5551 if o:
5549 if o:
5552 t.append(_('%d outgoing') % len(o))
5550 t.append(_('%d outgoing') % len(o))
5553 if 'bookmarks' in other.listkeys('namespaces'):
5551 if 'bookmarks' in other.listkeys('namespaces'):
5554 lmarks = repo.listkeys('bookmarks')
5552 lmarks = repo.listkeys('bookmarks')
5555 rmarks = other.listkeys('bookmarks')
5553 rmarks = other.listkeys('bookmarks')
5556 diff = set(rmarks) - set(lmarks)
5554 diff = set(rmarks) - set(lmarks)
5557 if len(diff) > 0:
5555 if len(diff) > 0:
5558 t.append(_('%d incoming bookmarks') % len(diff))
5556 t.append(_('%d incoming bookmarks') % len(diff))
5559 diff = set(lmarks) - set(rmarks)
5557 diff = set(lmarks) - set(rmarks)
5560 if len(diff) > 0:
5558 if len(diff) > 0:
5561 t.append(_('%d outgoing bookmarks') % len(diff))
5559 t.append(_('%d outgoing bookmarks') % len(diff))
5562
5560
5563 if t:
5561 if t:
5564 # i18n: column positioning for "hg summary"
5562 # i18n: column positioning for "hg summary"
5565 ui.write(_('remote: %s\n') % (', '.join(t)))
5563 ui.write(_('remote: %s\n') % (', '.join(t)))
5566 else:
5564 else:
5567 # i18n: column positioning for "hg summary"
5565 # i18n: column positioning for "hg summary"
5568 ui.status(_('remote: (synced)\n'))
5566 ui.status(_('remote: (synced)\n'))
5569
5567
5570 @command('tag',
5568 @command('tag',
5571 [('f', 'force', None, _('force tag')),
5569 [('f', 'force', None, _('force tag')),
5572 ('l', 'local', None, _('make the tag local')),
5570 ('l', 'local', None, _('make the tag local')),
5573 ('r', 'rev', '', _('revision to tag'), _('REV')),
5571 ('r', 'rev', '', _('revision to tag'), _('REV')),
5574 ('', 'remove', None, _('remove a tag')),
5572 ('', 'remove', None, _('remove a tag')),
5575 # -l/--local is already there, commitopts cannot be used
5573 # -l/--local is already there, commitopts cannot be used
5576 ('e', 'edit', None, _('edit commit message')),
5574 ('e', 'edit', None, _('edit commit message')),
5577 ('m', 'message', '', _('use <text> as commit message'), _('TEXT')),
5575 ('m', 'message', '', _('use <text> as commit message'), _('TEXT')),
5578 ] + commitopts2,
5576 ] + commitopts2,
5579 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5577 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5580 def tag(ui, repo, name1, *names, **opts):
5578 def tag(ui, repo, name1, *names, **opts):
5581 """add one or more tags for the current or given revision
5579 """add one or more tags for the current or given revision
5582
5580
5583 Name a particular revision using <name>.
5581 Name a particular revision using <name>.
5584
5582
5585 Tags are used to name particular revisions of the repository and are
5583 Tags are used to name particular revisions of the repository and are
5586 very useful to compare different revisions, to go back to significant
5584 very useful to compare different revisions, to go back to significant
5587 earlier versions or to mark branch points as releases, etc. Changing
5585 earlier versions or to mark branch points as releases, etc. Changing
5588 an existing tag is normally disallowed; use -f/--force to override.
5586 an existing tag is normally disallowed; use -f/--force to override.
5589
5587
5590 If no revision is given, the parent of the working directory is
5588 If no revision is given, the parent of the working directory is
5591 used.
5589 used.
5592
5590
5593 To facilitate version control, distribution, and merging of tags,
5591 To facilitate version control, distribution, and merging of tags,
5594 they are stored as a file named ".hgtags" which is managed similarly
5592 they are stored as a file named ".hgtags" which is managed similarly
5595 to other project files and can be hand-edited if necessary. This
5593 to other project files and can be hand-edited if necessary. This
5596 also means that tagging creates a new commit. The file
5594 also means that tagging creates a new commit. The file
5597 ".hg/localtags" is used for local tags (not shared among
5595 ".hg/localtags" is used for local tags (not shared among
5598 repositories).
5596 repositories).
5599
5597
5600 Tag commits are usually made at the head of a branch. If the parent
5598 Tag commits are usually made at the head of a branch. If the parent
5601 of the working directory is not a branch head, :hg:`tag` aborts; use
5599 of the working directory is not a branch head, :hg:`tag` aborts; use
5602 -f/--force to force the tag commit to be based on a non-head
5600 -f/--force to force the tag commit to be based on a non-head
5603 changeset.
5601 changeset.
5604
5602
5605 See :hg:`help dates` for a list of formats valid for -d/--date.
5603 See :hg:`help dates` for a list of formats valid for -d/--date.
5606
5604
5607 Since tag names have priority over branch names during revision
5605 Since tag names have priority over branch names during revision
5608 lookup, using an existing branch name as a tag name is discouraged.
5606 lookup, using an existing branch name as a tag name is discouraged.
5609
5607
5610 Returns 0 on success.
5608 Returns 0 on success.
5611 """
5609 """
5612 wlock = lock = None
5610 wlock = lock = None
5613 try:
5611 try:
5614 wlock = repo.wlock()
5612 wlock = repo.wlock()
5615 lock = repo.lock()
5613 lock = repo.lock()
5616 rev_ = "."
5614 rev_ = "."
5617 names = [t.strip() for t in (name1,) + names]
5615 names = [t.strip() for t in (name1,) + names]
5618 if len(names) != len(set(names)):
5616 if len(names) != len(set(names)):
5619 raise util.Abort(_('tag names must be unique'))
5617 raise util.Abort(_('tag names must be unique'))
5620 for n in names:
5618 for n in names:
5621 scmutil.checknewlabel(repo, n, 'tag')
5619 scmutil.checknewlabel(repo, n, 'tag')
5622 if not n:
5620 if not n:
5623 raise util.Abort(_('tag names cannot consist entirely of '
5621 raise util.Abort(_('tag names cannot consist entirely of '
5624 'whitespace'))
5622 'whitespace'))
5625 if opts.get('rev') and opts.get('remove'):
5623 if opts.get('rev') and opts.get('remove'):
5626 raise util.Abort(_("--rev and --remove are incompatible"))
5624 raise util.Abort(_("--rev and --remove are incompatible"))
5627 if opts.get('rev'):
5625 if opts.get('rev'):
5628 rev_ = opts['rev']
5626 rev_ = opts['rev']
5629 message = opts.get('message')
5627 message = opts.get('message')
5630 if opts.get('remove'):
5628 if opts.get('remove'):
5631 expectedtype = opts.get('local') and 'local' or 'global'
5629 expectedtype = opts.get('local') and 'local' or 'global'
5632 for n in names:
5630 for n in names:
5633 if not repo.tagtype(n):
5631 if not repo.tagtype(n):
5634 raise util.Abort(_("tag '%s' does not exist") % n)
5632 raise util.Abort(_("tag '%s' does not exist") % n)
5635 if repo.tagtype(n) != expectedtype:
5633 if repo.tagtype(n) != expectedtype:
5636 if expectedtype == 'global':
5634 if expectedtype == 'global':
5637 raise util.Abort(_("tag '%s' is not a global tag") % n)
5635 raise util.Abort(_("tag '%s' is not a global tag") % n)
5638 else:
5636 else:
5639 raise util.Abort(_("tag '%s' is not a local tag") % n)
5637 raise util.Abort(_("tag '%s' is not a local tag") % n)
5640 rev_ = nullid
5638 rev_ = nullid
5641 if not message:
5639 if not message:
5642 # we don't translate commit messages
5640 # we don't translate commit messages
5643 message = 'Removed tag %s' % ', '.join(names)
5641 message = 'Removed tag %s' % ', '.join(names)
5644 elif not opts.get('force'):
5642 elif not opts.get('force'):
5645 for n in names:
5643 for n in names:
5646 if n in repo.tags():
5644 if n in repo.tags():
5647 raise util.Abort(_("tag '%s' already exists "
5645 raise util.Abort(_("tag '%s' already exists "
5648 "(use -f to force)") % n)
5646 "(use -f to force)") % n)
5649 if not opts.get('local'):
5647 if not opts.get('local'):
5650 p1, p2 = repo.dirstate.parents()
5648 p1, p2 = repo.dirstate.parents()
5651 if p2 != nullid:
5649 if p2 != nullid:
5652 raise util.Abort(_('uncommitted merge'))
5650 raise util.Abort(_('uncommitted merge'))
5653 bheads = repo.branchheads()
5651 bheads = repo.branchheads()
5654 if not opts.get('force') and bheads and p1 not in bheads:
5652 if not opts.get('force') and bheads and p1 not in bheads:
5655 raise util.Abort(_('not at a branch head (use -f to force)'))
5653 raise util.Abort(_('not at a branch head (use -f to force)'))
5656 r = scmutil.revsingle(repo, rev_).node()
5654 r = scmutil.revsingle(repo, rev_).node()
5657
5655
5658 if not message:
5656 if not message:
5659 # we don't translate commit messages
5657 # we don't translate commit messages
5660 message = ('Added tag %s for changeset %s' %
5658 message = ('Added tag %s for changeset %s' %
5661 (', '.join(names), short(r)))
5659 (', '.join(names), short(r)))
5662
5660
5663 date = opts.get('date')
5661 date = opts.get('date')
5664 if date:
5662 if date:
5665 date = util.parsedate(date)
5663 date = util.parsedate(date)
5666
5664
5667 if opts.get('edit'):
5665 if opts.get('edit'):
5668 message = ui.edit(message, ui.username())
5666 message = ui.edit(message, ui.username())
5669
5667
5670 # don't allow tagging the null rev
5668 # don't allow tagging the null rev
5671 if (not opts.get('remove') and
5669 if (not opts.get('remove') and
5672 scmutil.revsingle(repo, rev_).rev() == nullrev):
5670 scmutil.revsingle(repo, rev_).rev() == nullrev):
5673 raise util.Abort(_("cannot tag null revision"))
5671 raise util.Abort(_("cannot tag null revision"))
5674
5672
5675 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
5673 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
5676 finally:
5674 finally:
5677 release(lock, wlock)
5675 release(lock, wlock)
5678
5676
5679 @command('tags', [], '')
5677 @command('tags', [], '')
5680 def tags(ui, repo, **opts):
5678 def tags(ui, repo, **opts):
5681 """list repository tags
5679 """list repository tags
5682
5680
5683 This lists both regular and local tags. When the -v/--verbose
5681 This lists both regular and local tags. When the -v/--verbose
5684 switch is used, a third column "local" is printed for local tags.
5682 switch is used, a third column "local" is printed for local tags.
5685
5683
5686 Returns 0 on success.
5684 Returns 0 on success.
5687 """
5685 """
5688
5686
5689 fm = ui.formatter('tags', opts)
5687 fm = ui.formatter('tags', opts)
5690 hexfunc = ui.debugflag and hex or short
5688 hexfunc = ui.debugflag and hex or short
5691 tagtype = ""
5689 tagtype = ""
5692
5690
5693 for t, n in reversed(repo.tagslist()):
5691 for t, n in reversed(repo.tagslist()):
5694 hn = hexfunc(n)
5692 hn = hexfunc(n)
5695 label = 'tags.normal'
5693 label = 'tags.normal'
5696 tagtype = ''
5694 tagtype = ''
5697 if repo.tagtype(t) == 'local':
5695 if repo.tagtype(t) == 'local':
5698 label = 'tags.local'
5696 label = 'tags.local'
5699 tagtype = 'local'
5697 tagtype = 'local'
5700
5698
5701 fm.startitem()
5699 fm.startitem()
5702 fm.write('tag', '%s', t, label=label)
5700 fm.write('tag', '%s', t, label=label)
5703 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5701 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5704 fm.condwrite(not ui.quiet, 'rev id', fmt,
5702 fm.condwrite(not ui.quiet, 'rev id', fmt,
5705 repo.changelog.rev(n), hn, label=label)
5703 repo.changelog.rev(n), hn, label=label)
5706 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5704 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5707 tagtype, label=label)
5705 tagtype, label=label)
5708 fm.plain('\n')
5706 fm.plain('\n')
5709 fm.end()
5707 fm.end()
5710
5708
5711 @command('tip',
5709 @command('tip',
5712 [('p', 'patch', None, _('show patch')),
5710 [('p', 'patch', None, _('show patch')),
5713 ('g', 'git', None, _('use git extended diff format')),
5711 ('g', 'git', None, _('use git extended diff format')),
5714 ] + templateopts,
5712 ] + templateopts,
5715 _('[-p] [-g]'))
5713 _('[-p] [-g]'))
5716 def tip(ui, repo, **opts):
5714 def tip(ui, repo, **opts):
5717 """show the tip revision (DEPRECATED)
5715 """show the tip revision (DEPRECATED)
5718
5716
5719 The tip revision (usually just called the tip) is the changeset
5717 The tip revision (usually just called the tip) is the changeset
5720 most recently added to the repository (and therefore the most
5718 most recently added to the repository (and therefore the most
5721 recently changed head).
5719 recently changed head).
5722
5720
5723 If you have just made a commit, that commit will be the tip. If
5721 If you have just made a commit, that commit will be the tip. If
5724 you have just pulled changes from another repository, the tip of
5722 you have just pulled changes from another repository, the tip of
5725 that repository becomes the current tip. The "tip" tag is special
5723 that repository becomes the current tip. The "tip" tag is special
5726 and cannot be renamed or assigned to a different changeset.
5724 and cannot be renamed or assigned to a different changeset.
5727
5725
5728 This command is deprecated, please use :hg:`heads` instead.
5726 This command is deprecated, please use :hg:`heads` instead.
5729
5727
5730 Returns 0 on success.
5728 Returns 0 on success.
5731 """
5729 """
5732 displayer = cmdutil.show_changeset(ui, repo, opts)
5730 displayer = cmdutil.show_changeset(ui, repo, opts)
5733 displayer.show(repo['tip'])
5731 displayer.show(repo['tip'])
5734 displayer.close()
5732 displayer.close()
5735
5733
5736 @command('unbundle',
5734 @command('unbundle',
5737 [('u', 'update', None,
5735 [('u', 'update', None,
5738 _('update to new branch head if changesets were unbundled'))],
5736 _('update to new branch head if changesets were unbundled'))],
5739 _('[-u] FILE...'))
5737 _('[-u] FILE...'))
5740 def unbundle(ui, repo, fname1, *fnames, **opts):
5738 def unbundle(ui, repo, fname1, *fnames, **opts):
5741 """apply one or more changegroup files
5739 """apply one or more changegroup files
5742
5740
5743 Apply one or more compressed changegroup files generated by the
5741 Apply one or more compressed changegroup files generated by the
5744 bundle command.
5742 bundle command.
5745
5743
5746 Returns 0 on success, 1 if an update has unresolved files.
5744 Returns 0 on success, 1 if an update has unresolved files.
5747 """
5745 """
5748 fnames = (fname1,) + fnames
5746 fnames = (fname1,) + fnames
5749
5747
5750 lock = repo.lock()
5748 lock = repo.lock()
5751 wc = repo['.']
5749 wc = repo['.']
5752 try:
5750 try:
5753 for fname in fnames:
5751 for fname in fnames:
5754 f = hg.openpath(ui, fname)
5752 f = hg.openpath(ui, fname)
5755 gen = changegroup.readbundle(f, fname)
5753 gen = changegroup.readbundle(f, fname)
5756 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
5754 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
5757 finally:
5755 finally:
5758 lock.release()
5756 lock.release()
5759 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
5757 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
5760 return postincoming(ui, repo, modheads, opts.get('update'), None)
5758 return postincoming(ui, repo, modheads, opts.get('update'), None)
5761
5759
5762 @command('^update|up|checkout|co',
5760 @command('^update|up|checkout|co',
5763 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5761 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5764 ('c', 'check', None,
5762 ('c', 'check', None,
5765 _('update across branches if no uncommitted changes')),
5763 _('update across branches if no uncommitted changes')),
5766 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5764 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5767 ('r', 'rev', '', _('revision'), _('REV'))],
5765 ('r', 'rev', '', _('revision'), _('REV'))],
5768 _('[-c] [-C] [-d DATE] [[-r] REV]'))
5766 _('[-c] [-C] [-d DATE] [[-r] REV]'))
5769 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
5767 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
5770 """update working directory (or switch revisions)
5768 """update working directory (or switch revisions)
5771
5769
5772 Update the repository's working directory to the specified
5770 Update the repository's working directory to the specified
5773 changeset. If no changeset is specified, update to the tip of the
5771 changeset. If no changeset is specified, update to the tip of the
5774 current named branch and move the current bookmark (see :hg:`help
5772 current named branch and move the current bookmark (see :hg:`help
5775 bookmarks`).
5773 bookmarks`).
5776
5774
5777 Update sets the working directory's parent revision to the specified
5775 Update sets the working directory's parent revision to the specified
5778 changeset (see :hg:`help parents`).
5776 changeset (see :hg:`help parents`).
5779
5777
5780 If the changeset is not a descendant or ancestor of the working
5778 If the changeset is not a descendant or ancestor of the working
5781 directory's parent, the update is aborted. With the -c/--check
5779 directory's parent, the update is aborted. With the -c/--check
5782 option, the working directory is checked for uncommitted changes; if
5780 option, the working directory is checked for uncommitted changes; if
5783 none are found, the working directory is updated to the specified
5781 none are found, the working directory is updated to the specified
5784 changeset.
5782 changeset.
5785
5783
5786 .. container:: verbose
5784 .. container:: verbose
5787
5785
5788 The following rules apply when the working directory contains
5786 The following rules apply when the working directory contains
5789 uncommitted changes:
5787 uncommitted changes:
5790
5788
5791 1. If neither -c/--check nor -C/--clean is specified, and if
5789 1. If neither -c/--check nor -C/--clean is specified, and if
5792 the requested changeset is an ancestor or descendant of
5790 the requested changeset is an ancestor or descendant of
5793 the working directory's parent, the uncommitted changes
5791 the working directory's parent, the uncommitted changes
5794 are merged into the requested changeset and the merged
5792 are merged into the requested changeset and the merged
5795 result is left uncommitted. If the requested changeset is
5793 result is left uncommitted. If the requested changeset is
5796 not an ancestor or descendant (that is, it is on another
5794 not an ancestor or descendant (that is, it is on another
5797 branch), the update is aborted and the uncommitted changes
5795 branch), the update is aborted and the uncommitted changes
5798 are preserved.
5796 are preserved.
5799
5797
5800 2. With the -c/--check option, the update is aborted and the
5798 2. With the -c/--check option, the update is aborted and the
5801 uncommitted changes are preserved.
5799 uncommitted changes are preserved.
5802
5800
5803 3. With the -C/--clean option, uncommitted changes are discarded and
5801 3. With the -C/--clean option, uncommitted changes are discarded and
5804 the working directory is updated to the requested changeset.
5802 the working directory is updated to the requested changeset.
5805
5803
5806 To cancel an uncommitted merge (and lose your changes), use
5804 To cancel an uncommitted merge (and lose your changes), use
5807 :hg:`update --clean .`.
5805 :hg:`update --clean .`.
5808
5806
5809 Use null as the changeset to remove the working directory (like
5807 Use null as the changeset to remove the working directory (like
5810 :hg:`clone -U`).
5808 :hg:`clone -U`).
5811
5809
5812 If you want to revert just one file to an older revision, use
5810 If you want to revert just one file to an older revision, use
5813 :hg:`revert [-r REV] NAME`.
5811 :hg:`revert [-r REV] NAME`.
5814
5812
5815 See :hg:`help dates` for a list of formats valid for -d/--date.
5813 See :hg:`help dates` for a list of formats valid for -d/--date.
5816
5814
5817 Returns 0 on success, 1 if there are unresolved files.
5815 Returns 0 on success, 1 if there are unresolved files.
5818 """
5816 """
5819 if rev and node:
5817 if rev and node:
5820 raise util.Abort(_("please specify just one revision"))
5818 raise util.Abort(_("please specify just one revision"))
5821
5819
5822 if rev is None or rev == '':
5820 if rev is None or rev == '':
5823 rev = node
5821 rev = node
5824
5822
5825 # with no argument, we also move the current bookmark, if any
5823 # with no argument, we also move the current bookmark, if any
5826 movemarkfrom = None
5824 movemarkfrom = None
5827 if rev is None:
5825 if rev is None:
5828 curmark = repo._bookmarkcurrent
5826 curmark = repo._bookmarkcurrent
5829 if bookmarks.iscurrent(repo):
5827 if bookmarks.iscurrent(repo):
5830 movemarkfrom = repo['.'].node()
5828 movemarkfrom = repo['.'].node()
5831 elif curmark:
5829 elif curmark:
5832 ui.status(_("updating to active bookmark %s\n") % curmark)
5830 ui.status(_("updating to active bookmark %s\n") % curmark)
5833 rev = curmark
5831 rev = curmark
5834
5832
5835 # if we defined a bookmark, we have to remember the original bookmark name
5833 # if we defined a bookmark, we have to remember the original bookmark name
5836 brev = rev
5834 brev = rev
5837 rev = scmutil.revsingle(repo, rev, rev).rev()
5835 rev = scmutil.revsingle(repo, rev, rev).rev()
5838
5836
5839 if check and clean:
5837 if check and clean:
5840 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
5838 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
5841
5839
5842 if date:
5840 if date:
5843 if rev is not None:
5841 if rev is not None:
5844 raise util.Abort(_("you can't specify a revision and a date"))
5842 raise util.Abort(_("you can't specify a revision and a date"))
5845 rev = cmdutil.finddate(ui, repo, date)
5843 rev = cmdutil.finddate(ui, repo, date)
5846
5844
5847 if check:
5845 if check:
5848 c = repo[None]
5846 c = repo[None]
5849 if c.dirty(merge=False, branch=False, missing=True):
5847 if c.dirty(merge=False, branch=False, missing=True):
5850 raise util.Abort(_("uncommitted local changes"))
5848 raise util.Abort(_("uncommitted local changes"))
5851 if rev is None:
5849 if rev is None:
5852 rev = repo[repo[None].branch()].rev()
5850 rev = repo[repo[None].branch()].rev()
5853 mergemod._checkunknown(repo, repo[None], repo[rev])
5851 mergemod._checkunknown(repo, repo[None], repo[rev])
5854
5852
5855 if clean:
5853 if clean:
5856 ret = hg.clean(repo, rev)
5854 ret = hg.clean(repo, rev)
5857 else:
5855 else:
5858 ret = hg.update(repo, rev)
5856 ret = hg.update(repo, rev)
5859
5857
5860 if not ret and movemarkfrom:
5858 if not ret and movemarkfrom:
5861 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5859 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5862 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
5860 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
5863 elif brev in repo._bookmarks:
5861 elif brev in repo._bookmarks:
5864 bookmarks.setcurrent(repo, brev)
5862 bookmarks.setcurrent(repo, brev)
5865 elif brev:
5863 elif brev:
5866 bookmarks.unsetcurrent(repo)
5864 bookmarks.unsetcurrent(repo)
5867
5865
5868 return ret
5866 return ret
5869
5867
5870 @command('verify', [])
5868 @command('verify', [])
5871 def verify(ui, repo):
5869 def verify(ui, repo):
5872 """verify the integrity of the repository
5870 """verify the integrity of the repository
5873
5871
5874 Verify the integrity of the current repository.
5872 Verify the integrity of the current repository.
5875
5873
5876 This will perform an extensive check of the repository's
5874 This will perform an extensive check of the repository's
5877 integrity, validating the hashes and checksums of each entry in
5875 integrity, validating the hashes and checksums of each entry in
5878 the changelog, manifest, and tracked files, as well as the
5876 the changelog, manifest, and tracked files, as well as the
5879 integrity of their crosslinks and indices.
5877 integrity of their crosslinks and indices.
5880
5878
5881 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
5879 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
5882 for more information about recovery from corruption of the
5880 for more information about recovery from corruption of the
5883 repository.
5881 repository.
5884
5882
5885 Returns 0 on success, 1 if errors are encountered.
5883 Returns 0 on success, 1 if errors are encountered.
5886 """
5884 """
5887 return hg.verify(repo)
5885 return hg.verify(repo)
5888
5886
5889 @command('version', [])
5887 @command('version', [])
5890 def version_(ui):
5888 def version_(ui):
5891 """output version and copyright information"""
5889 """output version and copyright information"""
5892 ui.write(_("Mercurial Distributed SCM (version %s)\n")
5890 ui.write(_("Mercurial Distributed SCM (version %s)\n")
5893 % util.version())
5891 % util.version())
5894 ui.status(_(
5892 ui.status(_(
5895 "(see http://mercurial.selenic.com for more information)\n"
5893 "(see http://mercurial.selenic.com for more information)\n"
5896 "\nCopyright (C) 2005-2013 Matt Mackall and others\n"
5894 "\nCopyright (C) 2005-2013 Matt Mackall and others\n"
5897 "This is free software; see the source for copying conditions. "
5895 "This is free software; see the source for copying conditions. "
5898 "There is NO\nwarranty; "
5896 "There is NO\nwarranty; "
5899 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5897 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5900 ))
5898 ))
5901
5899
5902 norepo = ("clone init version help debugcommands debugcomplete"
5900 norepo = ("clone init version help debugcommands debugcomplete"
5903 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
5901 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
5904 " debugknown debuggetbundle debugbundle")
5902 " debugknown debuggetbundle debugbundle")
5905 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
5903 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
5906 " debugdata debugindex debugindexdot debugrevlog")
5904 " debugdata debugindex debugindexdot debugrevlog")
5907 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
5905 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
5908 " remove resolve status debugwalk")
5906 " remove resolve status debugwalk")
@@ -1,445 +1,445 b''
1 $ hg init a
1 $ hg init a
2 $ cd a
2 $ cd a
3 $ echo a > a
3 $ echo a > a
4 $ hg ci -A -d'1 0' -m a
4 $ hg ci -A -d'1 0' -m a
5 adding a
5 adding a
6
6
7 $ cd ..
7 $ cd ..
8
8
9 $ hg init b
9 $ hg init b
10 $ cd b
10 $ cd b
11 $ echo b > b
11 $ echo b > b
12 $ hg ci -A -d'1 0' -m b
12 $ hg ci -A -d'1 0' -m b
13 adding b
13 adding b
14
14
15 $ cd ..
15 $ cd ..
16
16
17 $ hg clone a c
17 $ hg clone a c
18 updating to branch default
18 updating to branch default
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 $ cd c
20 $ cd c
21 $ cat >> .hg/hgrc <<EOF
21 $ cat >> .hg/hgrc <<EOF
22 > [paths]
22 > [paths]
23 > relative = ../a
23 > relative = ../a
24 > EOF
24 > EOF
25 $ hg pull -f ../b
25 $ hg pull -f ../b
26 pulling from ../b
26 pulling from ../b
27 searching for changes
27 searching for changes
28 warning: repository is unrelated
28 warning: repository is unrelated
29 requesting all changes
29 requesting all changes
30 adding changesets
30 adding changesets
31 adding manifests
31 adding manifests
32 adding file changes
32 adding file changes
33 added 1 changesets with 1 changes to 1 files (+1 heads)
33 added 1 changesets with 1 changes to 1 files (+1 heads)
34 (run 'hg heads' to see heads, 'hg merge' to merge)
34 (run 'hg heads' to see heads, 'hg merge' to merge)
35 $ hg merge
35 $ hg merge
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 (branch merge, don't forget to commit)
37 (branch merge, don't forget to commit)
38
38
39 $ cd ..
39 $ cd ..
40
40
41 Testing -R/--repository:
41 Testing -R/--repository:
42
42
43 $ hg -R a tip
43 $ hg -R a tip
44 changeset: 0:8580ff50825a
44 changeset: 0:8580ff50825a
45 tag: tip
45 tag: tip
46 user: test
46 user: test
47 date: Thu Jan 01 00:00:01 1970 +0000
47 date: Thu Jan 01 00:00:01 1970 +0000
48 summary: a
48 summary: a
49
49
50 $ hg --repository b tip
50 $ hg --repository b tip
51 changeset: 0:b6c483daf290
51 changeset: 0:b6c483daf290
52 tag: tip
52 tag: tip
53 user: test
53 user: test
54 date: Thu Jan 01 00:00:01 1970 +0000
54 date: Thu Jan 01 00:00:01 1970 +0000
55 summary: b
55 summary: b
56
56
57
57
58 -R with a URL:
58 -R with a URL:
59
59
60 $ hg -R file:a identify
60 $ hg -R file:a identify
61 8580ff50825a tip
61 8580ff50825a tip
62 $ hg -R file://localhost/`pwd`/a/ identify
62 $ hg -R file://localhost/`pwd`/a/ identify
63 8580ff50825a tip
63 8580ff50825a tip
64
64
65 -R with path aliases:
65 -R with path aliases:
66
66
67 $ cd c
67 $ cd c
68 $ hg -R default identify
68 $ hg -R default identify
69 8580ff50825a tip
69 8580ff50825a tip
70 $ hg -R relative identify
70 $ hg -R relative identify
71 8580ff50825a tip
71 8580ff50825a tip
72 $ echo '[paths]' >> $HGRCPATH
72 $ echo '[paths]' >> $HGRCPATH
73 $ echo 'relativetohome = a' >> $HGRCPATH
73 $ echo 'relativetohome = a' >> $HGRCPATH
74 $ HOME=`pwd`/../ hg -R relativetohome identify
74 $ HOME=`pwd`/../ hg -R relativetohome identify
75 8580ff50825a tip
75 8580ff50825a tip
76 $ cd ..
76 $ cd ..
77
77
78 #if no-outer-repo
78 #if no-outer-repo
79
79
80 Implicit -R:
80 Implicit -R:
81
81
82 $ hg ann a/a
82 $ hg ann a/a
83 0: a
83 0: a
84 $ hg ann a/a a/a
84 $ hg ann a/a a/a
85 0: a
85 0: a
86 $ hg ann a/a b/b
86 $ hg ann a/a b/b
87 abort: no repository found in '$TESTTMP' (.hg not found)!
87 abort: no repository found in '$TESTTMP' (.hg not found)!
88 [255]
88 [255]
89 $ hg -R b ann a/a
89 $ hg -R b ann a/a
90 abort: a/a not under root '$TESTTMP/b' (glob)
90 abort: a/a not under root '$TESTTMP/b' (glob)
91 [255]
91 [255]
92 $ hg log
92 $ hg log
93 abort: no repository found in '$TESTTMP' (.hg not found)!
93 abort: no repository found in '$TESTTMP' (.hg not found)!
94 [255]
94 [255]
95
95
96 #endif
96 #endif
97
97
98 Abbreviation of long option:
98 Abbreviation of long option:
99
99
100 $ hg --repo c tip
100 $ hg --repo c tip
101 changeset: 1:b6c483daf290
101 changeset: 1:b6c483daf290
102 tag: tip
102 tag: tip
103 parent: -1:000000000000
103 parent: -1:000000000000
104 user: test
104 user: test
105 date: Thu Jan 01 00:00:01 1970 +0000
105 date: Thu Jan 01 00:00:01 1970 +0000
106 summary: b
106 summary: b
107
107
108
108
109 earlygetopt with duplicate options (36d23de02da1):
109 earlygetopt with duplicate options (36d23de02da1):
110
110
111 $ hg --cwd a --cwd b --cwd c tip
111 $ hg --cwd a --cwd b --cwd c tip
112 changeset: 1:b6c483daf290
112 changeset: 1:b6c483daf290
113 tag: tip
113 tag: tip
114 parent: -1:000000000000
114 parent: -1:000000000000
115 user: test
115 user: test
116 date: Thu Jan 01 00:00:01 1970 +0000
116 date: Thu Jan 01 00:00:01 1970 +0000
117 summary: b
117 summary: b
118
118
119 $ hg --repo c --repository b -R a tip
119 $ hg --repo c --repository b -R a tip
120 changeset: 0:8580ff50825a
120 changeset: 0:8580ff50825a
121 tag: tip
121 tag: tip
122 user: test
122 user: test
123 date: Thu Jan 01 00:00:01 1970 +0000
123 date: Thu Jan 01 00:00:01 1970 +0000
124 summary: a
124 summary: a
125
125
126
126
127 earlygetopt short option without following space:
127 earlygetopt short option without following space:
128
128
129 $ hg -q -Rb tip
129 $ hg -q -Rb tip
130 0:b6c483daf290
130 0:b6c483daf290
131
131
132 earlygetopt with illegal abbreviations:
132 earlygetopt with illegal abbreviations:
133
133
134 $ hg --confi "foo.bar=baz"
134 $ hg --confi "foo.bar=baz"
135 abort: option --config may not be abbreviated!
135 abort: option --config may not be abbreviated!
136 [255]
136 [255]
137 $ hg --cw a tip
137 $ hg --cw a tip
138 abort: option --cwd may not be abbreviated!
138 abort: option --cwd may not be abbreviated!
139 [255]
139 [255]
140 $ hg --rep a tip
140 $ hg --rep a tip
141 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
141 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
142 [255]
142 [255]
143 $ hg --repositor a tip
143 $ hg --repositor a tip
144 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
144 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
145 [255]
145 [255]
146 $ hg -qR a tip
146 $ hg -qR a tip
147 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
147 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
148 [255]
148 [255]
149 $ hg -qRa tip
149 $ hg -qRa tip
150 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
150 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
151 [255]
151 [255]
152
152
153 Testing --cwd:
153 Testing --cwd:
154
154
155 $ hg --cwd a parents
155 $ hg --cwd a parents
156 changeset: 0:8580ff50825a
156 changeset: 0:8580ff50825a
157 tag: tip
157 tag: tip
158 user: test
158 user: test
159 date: Thu Jan 01 00:00:01 1970 +0000
159 date: Thu Jan 01 00:00:01 1970 +0000
160 summary: a
160 summary: a
161
161
162
162
163 Testing -y/--noninteractive - just be sure it is parsed:
163 Testing -y/--noninteractive - just be sure it is parsed:
164
164
165 $ hg --cwd a tip -q --noninteractive
165 $ hg --cwd a tip -q --noninteractive
166 0:8580ff50825a
166 0:8580ff50825a
167 $ hg --cwd a tip -q -y
167 $ hg --cwd a tip -q -y
168 0:8580ff50825a
168 0:8580ff50825a
169
169
170 Testing -q/--quiet:
170 Testing -q/--quiet:
171
171
172 $ hg -R a -q tip
172 $ hg -R a -q tip
173 0:8580ff50825a
173 0:8580ff50825a
174 $ hg -R b -q tip
174 $ hg -R b -q tip
175 0:b6c483daf290
175 0:b6c483daf290
176 $ hg -R c --quiet parents
176 $ hg -R c --quiet parents
177 0:8580ff50825a
177 0:8580ff50825a
178 1:b6c483daf290
178 1:b6c483daf290
179
179
180 Testing -v/--verbose:
180 Testing -v/--verbose:
181
181
182 $ hg --cwd c head -v
182 $ hg --cwd c head -v
183 changeset: 1:b6c483daf290
183 changeset: 1:b6c483daf290
184 tag: tip
184 tag: tip
185 parent: -1:000000000000
185 parent: -1:000000000000
186 user: test
186 user: test
187 date: Thu Jan 01 00:00:01 1970 +0000
187 date: Thu Jan 01 00:00:01 1970 +0000
188 files: b
188 files: b
189 description:
189 description:
190 b
190 b
191
191
192
192
193 changeset: 0:8580ff50825a
193 changeset: 0:8580ff50825a
194 user: test
194 user: test
195 date: Thu Jan 01 00:00:01 1970 +0000
195 date: Thu Jan 01 00:00:01 1970 +0000
196 files: a
196 files: a
197 description:
197 description:
198 a
198 a
199
199
200
200
201 $ hg --cwd b tip --verbose
201 $ hg --cwd b tip --verbose
202 changeset: 0:b6c483daf290
202 changeset: 0:b6c483daf290
203 tag: tip
203 tag: tip
204 user: test
204 user: test
205 date: Thu Jan 01 00:00:01 1970 +0000
205 date: Thu Jan 01 00:00:01 1970 +0000
206 files: b
206 files: b
207 description:
207 description:
208 b
208 b
209
209
210
210
211
211
212 Testing --config:
212 Testing --config:
213
213
214 $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
214 $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
215 quuxfoo
215 quuxfoo
216 $ hg --cwd c --config '' tip -q
216 $ hg --cwd c --config '' tip -q
217 abort: malformed --config option: '' (use --config section.name=value)
217 abort: malformed --config option: '' (use --config section.name=value)
218 [255]
218 [255]
219 $ hg --cwd c --config a.b tip -q
219 $ hg --cwd c --config a.b tip -q
220 abort: malformed --config option: 'a.b' (use --config section.name=value)
220 abort: malformed --config option: 'a.b' (use --config section.name=value)
221 [255]
221 [255]
222 $ hg --cwd c --config a tip -q
222 $ hg --cwd c --config a tip -q
223 abort: malformed --config option: 'a' (use --config section.name=value)
223 abort: malformed --config option: 'a' (use --config section.name=value)
224 [255]
224 [255]
225 $ hg --cwd c --config a.= tip -q
225 $ hg --cwd c --config a.= tip -q
226 abort: malformed --config option: 'a.=' (use --config section.name=value)
226 abort: malformed --config option: 'a.=' (use --config section.name=value)
227 [255]
227 [255]
228 $ hg --cwd c --config .b= tip -q
228 $ hg --cwd c --config .b= tip -q
229 abort: malformed --config option: '.b=' (use --config section.name=value)
229 abort: malformed --config option: '.b=' (use --config section.name=value)
230 [255]
230 [255]
231
231
232 Testing --debug:
232 Testing --debug:
233
233
234 $ hg --cwd c log --debug
234 $ hg --cwd c log --debug
235 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
235 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
236 tag: tip
236 tag: tip
237 parent: -1:0000000000000000000000000000000000000000
237 parent: -1:0000000000000000000000000000000000000000
238 parent: -1:0000000000000000000000000000000000000000
238 parent: -1:0000000000000000000000000000000000000000
239 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
239 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
240 user: test
240 user: test
241 date: Thu Jan 01 00:00:01 1970 +0000
241 date: Thu Jan 01 00:00:01 1970 +0000
242 files+: b
242 files+: b
243 extra: branch=default
243 extra: branch=default
244 description:
244 description:
245 b
245 b
246
246
247
247
248 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
248 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
249 parent: -1:0000000000000000000000000000000000000000
249 parent: -1:0000000000000000000000000000000000000000
250 parent: -1:0000000000000000000000000000000000000000
250 parent: -1:0000000000000000000000000000000000000000
251 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
251 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
252 user: test
252 user: test
253 date: Thu Jan 01 00:00:01 1970 +0000
253 date: Thu Jan 01 00:00:01 1970 +0000
254 files+: a
254 files+: a
255 extra: branch=default
255 extra: branch=default
256 description:
256 description:
257 a
257 a
258
258
259
259
260
260
261 Testing --traceback:
261 Testing --traceback:
262
262
263 $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
263 $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
264 Traceback (most recent call last):
264 Traceback (most recent call last):
265
265
266 Testing --time:
266 Testing --time:
267
267
268 $ hg --cwd a --time id
268 $ hg --cwd a --time id
269 8580ff50825a tip
269 8580ff50825a tip
270 time: real * (glob)
270 time: real * (glob)
271
271
272 Testing --version:
272 Testing --version:
273
273
274 $ hg --version -q
274 $ hg --version -q
275 Mercurial Distributed SCM * (glob)
275 Mercurial Distributed SCM * (glob)
276
276
277 hide outer repo
277 hide outer repo
278 $ hg init
278 $ hg init
279
279
280 Testing -h/--help:
280 Testing -h/--help:
281
281
282 $ hg -h
282 $ hg -h
283 Mercurial Distributed SCM
283 Mercurial Distributed SCM
284
284
285 list of commands:
285 list of commands:
286
286
287 add add the specified files on the next commit
287 add add the specified files on the next commit
288 addremove add all new files, delete all missing files
288 addremove add all new files, delete all missing files
289 annotate show changeset information by line for each file
289 annotate show changeset information by line for each file
290 archive create an unversioned archive of a repository revision
290 archive create an unversioned archive of a repository revision
291 backout reverse effect of earlier changeset
291 backout reverse effect of earlier changeset
292 bisect subdivision search of changesets
292 bisect subdivision search of changesets
293 bookmarks track a line of development with movable markers
293 bookmarks track a line of development with movable markers
294 branch set or show the current branch name
294 branch set or show the current branch name
295 branches list repository named branches
295 branches list repository named branches
296 bundle create a changegroup file
296 bundle create a changegroup file
297 cat output the current or given revision of files
297 cat output the current or given revision of files
298 clone make a copy of an existing repository
298 clone make a copy of an existing repository
299 commit commit the specified files or all outstanding changes
299 commit commit the specified files or all outstanding changes
300 copy mark files as copied for the next commit
300 copy mark files as copied for the next commit
301 diff diff repository (or selected files)
301 diff diff repository (or selected files)
302 export dump the header and diffs for one or more changesets
302 export dump the header and diffs for one or more changesets
303 forget forget the specified files on the next commit
303 forget forget the specified files on the next commit
304 graft copy changes from other branches onto the current branch
304 graft copy changes from other branches onto the current branch
305 grep search for a pattern in specified files and revisions
305 grep search for a pattern in specified files and revisions
306 heads show current repository heads or show branch heads
306 heads show branch heads
307 help show help for a given topic or a help overview
307 help show help for a given topic or a help overview
308 identify identify the working copy or specified revision
308 identify identify the working copy or specified revision
309 import import an ordered set of patches
309 import import an ordered set of patches
310 incoming show new changesets found in source
310 incoming show new changesets found in source
311 init create a new repository in the given directory
311 init create a new repository in the given directory
312 locate locate files matching specific patterns
312 locate locate files matching specific patterns
313 log show revision history of entire repository or files
313 log show revision history of entire repository or files
314 manifest output the current or given revision of the project manifest
314 manifest output the current or given revision of the project manifest
315 merge merge working directory with another revision
315 merge merge working directory with another revision
316 outgoing show changesets not found in the destination
316 outgoing show changesets not found in the destination
317 parents show the parents of the working directory or revision
317 parents show the parents of the working directory or revision
318 paths show aliases for remote repositories
318 paths show aliases for remote repositories
319 phase set or show the current phase name
319 phase set or show the current phase name
320 pull pull changes from the specified source
320 pull pull changes from the specified source
321 push push changes to the specified destination
321 push push changes to the specified destination
322 recover roll back an interrupted transaction
322 recover roll back an interrupted transaction
323 remove remove the specified files on the next commit
323 remove remove the specified files on the next commit
324 rename rename files; equivalent of copy + remove
324 rename rename files; equivalent of copy + remove
325 resolve redo merges or set/view the merge status of files
325 resolve redo merges or set/view the merge status of files
326 revert restore files to their checkout state
326 revert restore files to their checkout state
327 root print the root (top) of the current working directory
327 root print the root (top) of the current working directory
328 serve start stand-alone webserver
328 serve start stand-alone webserver
329 showconfig show combined config settings from all hgrc files
329 showconfig show combined config settings from all hgrc files
330 status show changed files in the working directory
330 status show changed files in the working directory
331 summary summarize working directory state
331 summary summarize working directory state
332 tag add one or more tags for the current or given revision
332 tag add one or more tags for the current or given revision
333 tags list repository tags
333 tags list repository tags
334 unbundle apply one or more changegroup files
334 unbundle apply one or more changegroup files
335 update update working directory (or switch revisions)
335 update update working directory (or switch revisions)
336 verify verify the integrity of the repository
336 verify verify the integrity of the repository
337 version output version and copyright information
337 version output version and copyright information
338
338
339 additional help topics:
339 additional help topics:
340
340
341 config Configuration Files
341 config Configuration Files
342 dates Date Formats
342 dates Date Formats
343 diffs Diff Formats
343 diffs Diff Formats
344 environment Environment Variables
344 environment Environment Variables
345 extensions Using Additional Features
345 extensions Using Additional Features
346 filesets Specifying File Sets
346 filesets Specifying File Sets
347 glossary Glossary
347 glossary Glossary
348 hgignore Syntax for Mercurial Ignore Files
348 hgignore Syntax for Mercurial Ignore Files
349 hgweb Configuring hgweb
349 hgweb Configuring hgweb
350 merge-tools Merge Tools
350 merge-tools Merge Tools
351 multirevs Specifying Multiple Revisions
351 multirevs Specifying Multiple Revisions
352 patterns File Name Patterns
352 patterns File Name Patterns
353 phases Working with Phases
353 phases Working with Phases
354 revisions Specifying Single Revisions
354 revisions Specifying Single Revisions
355 revsets Specifying Revision Sets
355 revsets Specifying Revision Sets
356 subrepos Subrepositories
356 subrepos Subrepositories
357 templating Template Usage
357 templating Template Usage
358 urls URL Paths
358 urls URL Paths
359
359
360 use "hg -v help" to show builtin aliases and global options
360 use "hg -v help" to show builtin aliases and global options
361
361
362
362
363
363
364 $ hg --help
364 $ hg --help
365 Mercurial Distributed SCM
365 Mercurial Distributed SCM
366
366
367 list of commands:
367 list of commands:
368
368
369 add add the specified files on the next commit
369 add add the specified files on the next commit
370 addremove add all new files, delete all missing files
370 addremove add all new files, delete all missing files
371 annotate show changeset information by line for each file
371 annotate show changeset information by line for each file
372 archive create an unversioned archive of a repository revision
372 archive create an unversioned archive of a repository revision
373 backout reverse effect of earlier changeset
373 backout reverse effect of earlier changeset
374 bisect subdivision search of changesets
374 bisect subdivision search of changesets
375 bookmarks track a line of development with movable markers
375 bookmarks track a line of development with movable markers
376 branch set or show the current branch name
376 branch set or show the current branch name
377 branches list repository named branches
377 branches list repository named branches
378 bundle create a changegroup file
378 bundle create a changegroup file
379 cat output the current or given revision of files
379 cat output the current or given revision of files
380 clone make a copy of an existing repository
380 clone make a copy of an existing repository
381 commit commit the specified files or all outstanding changes
381 commit commit the specified files or all outstanding changes
382 copy mark files as copied for the next commit
382 copy mark files as copied for the next commit
383 diff diff repository (or selected files)
383 diff diff repository (or selected files)
384 export dump the header and diffs for one or more changesets
384 export dump the header and diffs for one or more changesets
385 forget forget the specified files on the next commit
385 forget forget the specified files on the next commit
386 graft copy changes from other branches onto the current branch
386 graft copy changes from other branches onto the current branch
387 grep search for a pattern in specified files and revisions
387 grep search for a pattern in specified files and revisions
388 heads show current repository heads or show branch heads
388 heads show branch heads
389 help show help for a given topic or a help overview
389 help show help for a given topic or a help overview
390 identify identify the working copy or specified revision
390 identify identify the working copy or specified revision
391 import import an ordered set of patches
391 import import an ordered set of patches
392 incoming show new changesets found in source
392 incoming show new changesets found in source
393 init create a new repository in the given directory
393 init create a new repository in the given directory
394 locate locate files matching specific patterns
394 locate locate files matching specific patterns
395 log show revision history of entire repository or files
395 log show revision history of entire repository or files
396 manifest output the current or given revision of the project manifest
396 manifest output the current or given revision of the project manifest
397 merge merge working directory with another revision
397 merge merge working directory with another revision
398 outgoing show changesets not found in the destination
398 outgoing show changesets not found in the destination
399 parents show the parents of the working directory or revision
399 parents show the parents of the working directory or revision
400 paths show aliases for remote repositories
400 paths show aliases for remote repositories
401 phase set or show the current phase name
401 phase set or show the current phase name
402 pull pull changes from the specified source
402 pull pull changes from the specified source
403 push push changes to the specified destination
403 push push changes to the specified destination
404 recover roll back an interrupted transaction
404 recover roll back an interrupted transaction
405 remove remove the specified files on the next commit
405 remove remove the specified files on the next commit
406 rename rename files; equivalent of copy + remove
406 rename rename files; equivalent of copy + remove
407 resolve redo merges or set/view the merge status of files
407 resolve redo merges or set/view the merge status of files
408 revert restore files to their checkout state
408 revert restore files to their checkout state
409 root print the root (top) of the current working directory
409 root print the root (top) of the current working directory
410 serve start stand-alone webserver
410 serve start stand-alone webserver
411 showconfig show combined config settings from all hgrc files
411 showconfig show combined config settings from all hgrc files
412 status show changed files in the working directory
412 status show changed files in the working directory
413 summary summarize working directory state
413 summary summarize working directory state
414 tag add one or more tags for the current or given revision
414 tag add one or more tags for the current or given revision
415 tags list repository tags
415 tags list repository tags
416 unbundle apply one or more changegroup files
416 unbundle apply one or more changegroup files
417 update update working directory (or switch revisions)
417 update update working directory (or switch revisions)
418 verify verify the integrity of the repository
418 verify verify the integrity of the repository
419 version output version and copyright information
419 version output version and copyright information
420
420
421 additional help topics:
421 additional help topics:
422
422
423 config Configuration Files
423 config Configuration Files
424 dates Date Formats
424 dates Date Formats
425 diffs Diff Formats
425 diffs Diff Formats
426 environment Environment Variables
426 environment Environment Variables
427 extensions Using Additional Features
427 extensions Using Additional Features
428 filesets Specifying File Sets
428 filesets Specifying File Sets
429 glossary Glossary
429 glossary Glossary
430 hgignore Syntax for Mercurial Ignore Files
430 hgignore Syntax for Mercurial Ignore Files
431 hgweb Configuring hgweb
431 hgweb Configuring hgweb
432 merge-tools Merge Tools
432 merge-tools Merge Tools
433 multirevs Specifying Multiple Revisions
433 multirevs Specifying Multiple Revisions
434 patterns File Name Patterns
434 patterns File Name Patterns
435 phases Working with Phases
435 phases Working with Phases
436 revisions Specifying Single Revisions
436 revisions Specifying Single Revisions
437 revsets Specifying Revision Sets
437 revsets Specifying Revision Sets
438 subrepos Subrepositories
438 subrepos Subrepositories
439 templating Template Usage
439 templating Template Usage
440 urls URL Paths
440 urls URL Paths
441
441
442 use "hg -v help" to show builtin aliases and global options
442 use "hg -v help" to show builtin aliases and global options
443
443
444 Not tested: --debugger
444 Not tested: --debugger
445
445
@@ -1,1905 +1,1905 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 working directory with another revision
17 merge merge working directory with another revision
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 working directory with another revision
38 merge merge working directory with another revision
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 track a line of development with movable markers
58 bookmarks track a line of development with movable markers
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 copy mark files as copied for the next commit
65 copy mark files as copied for the next commit
66 diff diff repository (or selected files)
66 diff diff repository (or selected files)
67 export dump the header and diffs for one or more changesets
67 export dump the header and diffs for one or more changesets
68 forget forget the specified files on the next commit
68 forget forget the specified files on the next commit
69 graft copy changes from other branches onto the current branch
69 graft copy changes from other branches onto the current branch
70 grep search for a pattern in specified files and revisions
70 grep search for a pattern in specified files and revisions
71 heads show current repository heads or show branch heads
71 heads show branch heads
72 help show help for a given topic or a help overview
72 help show help for a given topic or a help overview
73 identify identify the working copy or specified revision
73 identify identify the working copy or specified revision
74 import import an ordered set of patches
74 import import an ordered set of patches
75 incoming show new changesets found in source
75 incoming show new changesets found in source
76 init create a new repository in the given directory
76 init create a new repository in the given directory
77 locate locate files matching specific patterns
77 locate locate files matching specific patterns
78 log show revision history of entire repository or files
78 log show revision history of entire repository or files
79 manifest output the current or given revision of the project manifest
79 manifest output the current or given revision of the project manifest
80 merge merge working directory with another revision
80 merge merge working directory with another revision
81 outgoing show changesets not found in the destination
81 outgoing show changesets not found in the destination
82 parents show the parents of the working directory or revision
82 parents show the parents of the working directory or revision
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 showconfig show combined config settings from all hgrc files
94 showconfig show combined config settings from all hgrc files
95 status show changed files in the working directory
95 status show changed files in the working directory
96 summary summarize working directory state
96 summary summarize working directory state
97 tag add one or more tags for the current or given revision
97 tag add one or more tags for the current or given revision
98 tags list repository tags
98 tags list repository tags
99 unbundle apply one or more changegroup files
99 unbundle apply one or more changegroup files
100 update update working directory (or switch revisions)
100 update update working directory (or switch revisions)
101 verify verify the integrity of the repository
101 verify verify the integrity of the repository
102 version output version and copyright information
102 version output version and copyright information
103
103
104 additional help topics:
104 additional help topics:
105
105
106 config Configuration Files
106 config Configuration Files
107 dates Date Formats
107 dates Date Formats
108 diffs Diff Formats
108 diffs Diff Formats
109 environment Environment Variables
109 environment Environment Variables
110 extensions Using Additional Features
110 extensions Using Additional Features
111 filesets Specifying File Sets
111 filesets Specifying File Sets
112 glossary Glossary
112 glossary Glossary
113 hgignore Syntax for Mercurial Ignore Files
113 hgignore Syntax for Mercurial Ignore Files
114 hgweb Configuring hgweb
114 hgweb Configuring hgweb
115 merge-tools Merge Tools
115 merge-tools Merge Tools
116 multirevs Specifying Multiple Revisions
116 multirevs Specifying Multiple Revisions
117 patterns File Name Patterns
117 patterns File Name Patterns
118 phases Working with Phases
118 phases Working with Phases
119 revisions Specifying Single Revisions
119 revisions Specifying Single Revisions
120 revsets Specifying Revision Sets
120 revsets Specifying Revision Sets
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 -v help" to show builtin aliases and global options
125 use "hg -v help" to show builtin 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 track a line of development with movable markers
134 bookmarks track a line of development with movable markers
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 copy mark files as copied for the next commit
141 copy mark files as copied for the next commit
142 diff diff repository (or selected files)
142 diff diff repository (or selected files)
143 export dump the header and diffs for one or more changesets
143 export dump the header and diffs for one or more changesets
144 forget forget the specified files on the next commit
144 forget forget the specified files on the next commit
145 graft copy changes from other branches onto the current branch
145 graft copy changes from other branches onto the current branch
146 grep search for a pattern in specified files and revisions
146 grep search for a pattern in specified files and revisions
147 heads show current repository heads or show branch heads
147 heads show branch heads
148 help show help for a given topic or a help overview
148 help show help for a given topic or a help overview
149 identify identify the working copy or specified revision
149 identify identify the working copy or specified revision
150 import import an ordered set of patches
150 import import an ordered set of patches
151 incoming show new changesets found in source
151 incoming show new changesets found in source
152 init create a new repository in the given directory
152 init create a new repository in the given directory
153 locate locate files matching specific patterns
153 locate locate files matching specific patterns
154 log show revision history of entire repository or files
154 log show revision history of entire repository or files
155 manifest output the current or given revision of the project manifest
155 manifest output the current or given revision of the project manifest
156 merge merge working directory with another revision
156 merge merge working directory with another revision
157 outgoing show changesets not found in the destination
157 outgoing show changesets not found in the destination
158 parents show the parents of the working directory or revision
158 parents show the parents of the working directory or revision
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 showconfig show combined config settings from all hgrc files
170 showconfig show combined config settings from all hgrc files
171 status show changed files in the working directory
171 status show changed files in the working directory
172 summary summarize working directory state
172 summary summarize working directory state
173 tag add one or more tags for the current or given revision
173 tag add one or more tags for the current or given revision
174 tags list repository tags
174 tags list repository tags
175 unbundle apply one or more changegroup files
175 unbundle apply one or more changegroup files
176 update update working directory (or switch revisions)
176 update update working directory (or switch revisions)
177 verify verify the integrity of the repository
177 verify verify the integrity of the repository
178 version output version and copyright information
178 version output version and copyright information
179
179
180 additional help topics:
180 additional help topics:
181
181
182 config Configuration Files
182 config Configuration Files
183 dates Date Formats
183 dates Date Formats
184 diffs Diff Formats
184 diffs Diff Formats
185 environment Environment Variables
185 environment Environment Variables
186 extensions Using Additional Features
186 extensions Using Additional Features
187 filesets Specifying File Sets
187 filesets Specifying File Sets
188 glossary Glossary
188 glossary Glossary
189 hgignore Syntax for Mercurial Ignore Files
189 hgignore Syntax for Mercurial Ignore Files
190 hgweb Configuring hgweb
190 hgweb Configuring hgweb
191 merge-tools Merge Tools
191 merge-tools Merge Tools
192 multirevs Specifying Multiple Revisions
192 multirevs Specifying Multiple Revisions
193 patterns File Name Patterns
193 patterns File Name Patterns
194 phases Working with Phases
194 phases Working with Phases
195 revisions Specifying Single Revisions
195 revisions Specifying Single Revisions
196 revsets Specifying Revision Sets
196 revsets Specifying Revision Sets
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 short command list with verbose option
201 Test short command list with verbose option
202
202
203 $ hg -v help shortlist
203 $ hg -v help shortlist
204 Mercurial Distributed SCM
204 Mercurial Distributed SCM
205
205
206 basic commands:
206 basic commands:
207
207
208 add add the specified files on the next commit
208 add add the specified files on the next commit
209 annotate, blame
209 annotate, blame
210 show changeset information by line for each file
210 show changeset information by line for each file
211 clone make a copy of an existing repository
211 clone make a copy of an existing repository
212 commit, ci commit the specified files or all outstanding changes
212 commit, ci commit the specified files or all outstanding changes
213 diff diff repository (or selected files)
213 diff diff repository (or selected files)
214 export dump the header and diffs for one or more changesets
214 export dump the header and diffs for one or more changesets
215 forget forget the specified files on the next commit
215 forget forget the specified files on the next commit
216 init create a new repository in the given directory
216 init create a new repository in the given directory
217 log, history show revision history of entire repository or files
217 log, history show revision history of entire repository or files
218 merge merge working directory with another revision
218 merge merge working directory with another revision
219 pull pull changes from the specified source
219 pull pull changes from the specified source
220 push push changes to the specified destination
220 push push changes to the specified destination
221 remove, rm remove the specified files on the next commit
221 remove, rm remove the specified files on the next commit
222 serve start stand-alone webserver
222 serve start stand-alone webserver
223 status, st show changed files in the working directory
223 status, st show changed files in the working directory
224 summary, sum summarize working directory state
224 summary, sum summarize working directory state
225 update, up, checkout, co
225 update, up, checkout, co
226 update working directory (or switch revisions)
226 update working directory (or switch revisions)
227
227
228 global options:
228 global options:
229
229
230 -R --repository REPO repository root directory or name of overlay bundle
230 -R --repository REPO repository root directory or name of overlay bundle
231 file
231 file
232 --cwd DIR change working directory
232 --cwd DIR change working directory
233 -y --noninteractive do not prompt, automatically pick the first choice for
233 -y --noninteractive do not prompt, automatically pick the first choice for
234 all prompts
234 all prompts
235 -q --quiet suppress output
235 -q --quiet suppress output
236 -v --verbose enable additional output
236 -v --verbose enable additional output
237 --config CONFIG [+] set/override config option (use 'section.name=value')
237 --config CONFIG [+] set/override config option (use 'section.name=value')
238 --debug enable debugging output
238 --debug enable debugging output
239 --debugger start debugger
239 --debugger start debugger
240 --encoding ENCODE set the charset encoding (default: ascii)
240 --encoding ENCODE set the charset encoding (default: ascii)
241 --encodingmode MODE set the charset encoding mode (default: strict)
241 --encodingmode MODE set the charset encoding mode (default: strict)
242 --traceback always print a traceback on exception
242 --traceback always print a traceback on exception
243 --time time how long the command takes
243 --time time how long the command takes
244 --profile print command execution profile
244 --profile print command execution profile
245 --version output version information and exit
245 --version output version information and exit
246 -h --help display help and exit
246 -h --help display help and exit
247 --hidden consider hidden changesets
247 --hidden consider hidden changesets
248
248
249 [+] marked option can be specified multiple times
249 [+] marked option can be specified multiple times
250
250
251 use "hg help" for the full list of commands
251 use "hg help" for the full list of commands
252
252
253 $ hg add -h
253 $ hg add -h
254 hg add [OPTION]... [FILE]...
254 hg add [OPTION]... [FILE]...
255
255
256 add the specified files on the next commit
256 add the specified files on the next commit
257
257
258 Schedule files to be version controlled and added to the repository.
258 Schedule files to be version controlled and added to the repository.
259
259
260 The files will be added to the repository at the next commit. To undo an
260 The files will be added to the repository at the next commit. To undo an
261 add before that, see "hg forget".
261 add before that, see "hg forget".
262
262
263 If no names are given, add all files to the repository.
263 If no names are given, add all files to the repository.
264
264
265 Returns 0 if all files are successfully added.
265 Returns 0 if all files are successfully added.
266
266
267 options:
267 options:
268
268
269 -I --include PATTERN [+] include names matching the given patterns
269 -I --include PATTERN [+] include names matching the given patterns
270 -X --exclude PATTERN [+] exclude names matching the given patterns
270 -X --exclude PATTERN [+] exclude names matching the given patterns
271 -S --subrepos recurse into subrepositories
271 -S --subrepos recurse into subrepositories
272 -n --dry-run do not perform actions, just print output
272 -n --dry-run do not perform actions, just print output
273
273
274 [+] marked option can be specified multiple times
274 [+] marked option can be specified multiple times
275
275
276 use "hg -v help add" to show more complete help and the global options
276 use "hg -v help add" to show more complete help and the global options
277
277
278 Verbose help for add
278 Verbose help for add
279
279
280 $ hg add -hv
280 $ hg add -hv
281 hg add [OPTION]... [FILE]...
281 hg add [OPTION]... [FILE]...
282
282
283 add the specified files on the next commit
283 add the specified files on the next commit
284
284
285 Schedule files to be version controlled and added to the repository.
285 Schedule files to be version controlled and added to the repository.
286
286
287 The files will be added to the repository at the next commit. To undo an
287 The files will be added to the repository at the next commit. To undo an
288 add before that, see "hg forget".
288 add before that, see "hg forget".
289
289
290 If no names are given, add all files to the repository.
290 If no names are given, add all files to the repository.
291
291
292 An example showing how new (unknown) files are added automatically by "hg
292 An example showing how new (unknown) files are added automatically by "hg
293 add":
293 add":
294
294
295 $ ls
295 $ ls
296 foo.c
296 foo.c
297 $ hg status
297 $ hg status
298 ? foo.c
298 ? foo.c
299 $ hg add
299 $ hg add
300 adding foo.c
300 adding foo.c
301 $ hg status
301 $ hg status
302 A foo.c
302 A foo.c
303
303
304 Returns 0 if all files are successfully added.
304 Returns 0 if all files are successfully added.
305
305
306 options:
306 options:
307
307
308 -I --include PATTERN [+] include names matching the given patterns
308 -I --include PATTERN [+] include names matching the given patterns
309 -X --exclude PATTERN [+] exclude names matching the given patterns
309 -X --exclude PATTERN [+] exclude names matching the given patterns
310 -S --subrepos recurse into subrepositories
310 -S --subrepos recurse into subrepositories
311 -n --dry-run do not perform actions, just print output
311 -n --dry-run do not perform actions, just print output
312
312
313 [+] marked option can be specified multiple times
313 [+] marked option can be specified multiple times
314
314
315 global options:
315 global options:
316
316
317 -R --repository REPO repository root directory or name of overlay bundle
317 -R --repository REPO repository root directory or name of overlay bundle
318 file
318 file
319 --cwd DIR change working directory
319 --cwd DIR change working directory
320 -y --noninteractive do not prompt, automatically pick the first choice for
320 -y --noninteractive do not prompt, automatically pick the first choice for
321 all prompts
321 all prompts
322 -q --quiet suppress output
322 -q --quiet suppress output
323 -v --verbose enable additional output
323 -v --verbose enable additional output
324 --config CONFIG [+] set/override config option (use 'section.name=value')
324 --config CONFIG [+] set/override config option (use 'section.name=value')
325 --debug enable debugging output
325 --debug enable debugging output
326 --debugger start debugger
326 --debugger start debugger
327 --encoding ENCODE set the charset encoding (default: ascii)
327 --encoding ENCODE set the charset encoding (default: ascii)
328 --encodingmode MODE set the charset encoding mode (default: strict)
328 --encodingmode MODE set the charset encoding mode (default: strict)
329 --traceback always print a traceback on exception
329 --traceback always print a traceback on exception
330 --time time how long the command takes
330 --time time how long the command takes
331 --profile print command execution profile
331 --profile print command execution profile
332 --version output version information and exit
332 --version output version information and exit
333 -h --help display help and exit
333 -h --help display help and exit
334 --hidden consider hidden changesets
334 --hidden consider hidden changesets
335
335
336 [+] marked option can be specified multiple times
336 [+] marked option can be specified multiple times
337
337
338 Test help option with version option
338 Test help option with version option
339
339
340 $ hg add -h --version
340 $ hg add -h --version
341 Mercurial Distributed SCM (version *) (glob)
341 Mercurial Distributed SCM (version *) (glob)
342 (see http://mercurial.selenic.com for more information)
342 (see http://mercurial.selenic.com for more information)
343
343
344 Copyright (C) 2005-2013 Matt Mackall and others
344 Copyright (C) 2005-2013 Matt Mackall and others
345 This is free software; see the source for copying conditions. There is NO
345 This is free software; see the source for copying conditions. There is NO
346 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
346 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
347
347
348 $ hg add --skjdfks
348 $ hg add --skjdfks
349 hg add: option --skjdfks not recognized
349 hg add: option --skjdfks not recognized
350 hg add [OPTION]... [FILE]...
350 hg add [OPTION]... [FILE]...
351
351
352 add the specified files on the next commit
352 add the specified files on the next commit
353
353
354 options:
354 options:
355
355
356 -I --include PATTERN [+] include names matching the given patterns
356 -I --include PATTERN [+] include names matching the given patterns
357 -X --exclude PATTERN [+] exclude names matching the given patterns
357 -X --exclude PATTERN [+] exclude names matching the given patterns
358 -S --subrepos recurse into subrepositories
358 -S --subrepos recurse into subrepositories
359 -n --dry-run do not perform actions, just print output
359 -n --dry-run do not perform actions, just print output
360
360
361 [+] marked option can be specified multiple times
361 [+] marked option can be specified multiple times
362
362
363 use "hg help add" to show the full help text
363 use "hg help add" to show the full help text
364 [255]
364 [255]
365
365
366 Test ambiguous command help
366 Test ambiguous command help
367
367
368 $ hg help ad
368 $ hg help ad
369 list of commands:
369 list of commands:
370
370
371 add add the specified files on the next commit
371 add add the specified files on the next commit
372 addremove add all new files, delete all missing files
372 addremove add all new files, delete all missing files
373
373
374 use "hg -v help ad" to show builtin aliases and global options
374 use "hg -v help ad" to show builtin aliases and global options
375
375
376 Test command without options
376 Test command without options
377
377
378 $ hg help verify
378 $ hg help verify
379 hg verify
379 hg verify
380
380
381 verify the integrity of the repository
381 verify the integrity of the repository
382
382
383 Verify the integrity of the current repository.
383 Verify the integrity of the current repository.
384
384
385 This will perform an extensive check of the repository's integrity,
385 This will perform an extensive check of the repository's integrity,
386 validating the hashes and checksums of each entry in the changelog,
386 validating the hashes and checksums of each entry in the changelog,
387 manifest, and tracked files, as well as the integrity of their crosslinks
387 manifest, and tracked files, as well as the integrity of their crosslinks
388 and indices.
388 and indices.
389
389
390 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
390 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
391 information about recovery from corruption of the repository.
391 information about recovery from corruption of the repository.
392
392
393 Returns 0 on success, 1 if errors are encountered.
393 Returns 0 on success, 1 if errors are encountered.
394
394
395 use "hg -v help verify" to show the global options
395 use "hg -v help verify" to show the global options
396
396
397 $ hg help diff
397 $ hg help diff
398 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
398 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
399
399
400 diff repository (or selected files)
400 diff repository (or selected files)
401
401
402 Show differences between revisions for the specified files.
402 Show differences between revisions for the specified files.
403
403
404 Differences between files are shown using the unified diff format.
404 Differences between files are shown using the unified diff format.
405
405
406 Note:
406 Note:
407 diff may generate unexpected results for merges, as it will default to
407 diff may generate unexpected results for merges, as it will default to
408 comparing against the working directory's first parent changeset if no
408 comparing against the working directory's first parent changeset if no
409 revisions are specified.
409 revisions are specified.
410
410
411 When two revision arguments are given, then changes are shown between
411 When two revision arguments are given, then changes are shown between
412 those revisions. If only one revision is specified then that revision is
412 those revisions. If only one revision is specified then that revision is
413 compared to the working directory, and, when no revisions are specified,
413 compared to the working directory, and, when no revisions are specified,
414 the working directory files are compared to its parent.
414 the working directory files are compared to its parent.
415
415
416 Alternatively you can specify -c/--change with a revision to see the
416 Alternatively you can specify -c/--change with a revision to see the
417 changes in that changeset relative to its first parent.
417 changes in that changeset relative to its first parent.
418
418
419 Without the -a/--text option, diff will avoid generating diffs of files it
419 Without the -a/--text option, diff will avoid generating diffs of files it
420 detects as binary. With -a, diff will generate a diff anyway, probably
420 detects as binary. With -a, diff will generate a diff anyway, probably
421 with undesirable results.
421 with undesirable results.
422
422
423 Use the -g/--git option to generate diffs in the git extended diff format.
423 Use the -g/--git option to generate diffs in the git extended diff format.
424 For more information, read "hg help diffs".
424 For more information, read "hg help diffs".
425
425
426 Returns 0 on success.
426 Returns 0 on success.
427
427
428 options:
428 options:
429
429
430 -r --rev REV [+] revision
430 -r --rev REV [+] revision
431 -c --change REV change made by revision
431 -c --change REV change made by revision
432 -a --text treat all files as text
432 -a --text treat all files as text
433 -g --git use git extended diff format
433 -g --git use git extended diff format
434 --nodates omit dates from diff headers
434 --nodates omit dates from diff headers
435 -p --show-function show which function each change is in
435 -p --show-function show which function each change is in
436 --reverse produce a diff that undoes the changes
436 --reverse produce a diff that undoes the changes
437 -w --ignore-all-space ignore white space when comparing lines
437 -w --ignore-all-space ignore white space when comparing lines
438 -b --ignore-space-change ignore changes in the amount of white space
438 -b --ignore-space-change ignore changes in the amount of white space
439 -B --ignore-blank-lines ignore changes whose lines are all blank
439 -B --ignore-blank-lines ignore changes whose lines are all blank
440 -U --unified NUM number of lines of context to show
440 -U --unified NUM number of lines of context to show
441 --stat output diffstat-style summary of changes
441 --stat output diffstat-style summary of changes
442 -I --include PATTERN [+] include names matching the given patterns
442 -I --include PATTERN [+] include names matching the given patterns
443 -X --exclude PATTERN [+] exclude names matching the given patterns
443 -X --exclude PATTERN [+] exclude names matching the given patterns
444 -S --subrepos recurse into subrepositories
444 -S --subrepos recurse into subrepositories
445
445
446 [+] marked option can be specified multiple times
446 [+] marked option can be specified multiple times
447
447
448 use "hg -v help diff" to show more complete help and the global options
448 use "hg -v help diff" to show more complete help and the global options
449
449
450 $ hg help status
450 $ hg help status
451 hg status [OPTION]... [FILE]...
451 hg status [OPTION]... [FILE]...
452
452
453 aliases: st
453 aliases: st
454
454
455 show changed files in the working directory
455 show changed files in the working directory
456
456
457 Show status of files in the repository. If names are given, only files
457 Show status of files in the repository. If names are given, only files
458 that match are shown. Files that are clean or ignored or the source of a
458 that match are shown. Files that are clean or ignored or the source of a
459 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
459 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
460 -C/--copies or -A/--all are given. Unless options described with "show
460 -C/--copies or -A/--all are given. Unless options described with "show
461 only ..." are given, the options -mardu are used.
461 only ..." are given, the options -mardu are used.
462
462
463 Option -q/--quiet hides untracked (unknown and ignored) files unless
463 Option -q/--quiet hides untracked (unknown and ignored) files unless
464 explicitly requested with -u/--unknown or -i/--ignored.
464 explicitly requested with -u/--unknown or -i/--ignored.
465
465
466 Note:
466 Note:
467 status may appear to disagree with diff if permissions have changed or
467 status may appear to disagree with diff if permissions have changed or
468 a merge has occurred. The standard diff format does not report
468 a merge has occurred. The standard diff format does not report
469 permission changes and diff only reports changes relative to one merge
469 permission changes and diff only reports changes relative to one merge
470 parent.
470 parent.
471
471
472 If one revision is given, it is used as the base revision. If two
472 If one revision is given, it is used as the base revision. If two
473 revisions are given, the differences between them are shown. The --change
473 revisions are given, the differences between them are shown. The --change
474 option can also be used as a shortcut to list the changed files of a
474 option can also be used as a shortcut to list the changed files of a
475 revision from its first parent.
475 revision from its first parent.
476
476
477 The codes used to show the status of files are:
477 The codes used to show the status of files are:
478
478
479 M = modified
479 M = modified
480 A = added
480 A = added
481 R = removed
481 R = removed
482 C = clean
482 C = clean
483 ! = missing (deleted by non-hg command, but still tracked)
483 ! = missing (deleted by non-hg command, but still tracked)
484 ? = not tracked
484 ? = not tracked
485 I = ignored
485 I = ignored
486 = origin of the previous file listed as A (added)
486 = origin of the previous file listed as A (added)
487
487
488 Returns 0 on success.
488 Returns 0 on success.
489
489
490 options:
490 options:
491
491
492 -A --all show status of all files
492 -A --all show status of all files
493 -m --modified show only modified files
493 -m --modified show only modified files
494 -a --added show only added files
494 -a --added show only added files
495 -r --removed show only removed files
495 -r --removed show only removed files
496 -d --deleted show only deleted (but tracked) files
496 -d --deleted show only deleted (but tracked) files
497 -c --clean show only files without changes
497 -c --clean show only files without changes
498 -u --unknown show only unknown (not tracked) files
498 -u --unknown show only unknown (not tracked) files
499 -i --ignored show only ignored files
499 -i --ignored show only ignored files
500 -n --no-status hide status prefix
500 -n --no-status hide status prefix
501 -C --copies show source of copied files
501 -C --copies show source of copied files
502 -0 --print0 end filenames with NUL, for use with xargs
502 -0 --print0 end filenames with NUL, for use with xargs
503 --rev REV [+] show difference from revision
503 --rev REV [+] show difference from revision
504 --change REV list the changed files of a revision
504 --change REV list the changed files of a revision
505 -I --include PATTERN [+] include names matching the given patterns
505 -I --include PATTERN [+] include names matching the given patterns
506 -X --exclude PATTERN [+] exclude names matching the given patterns
506 -X --exclude PATTERN [+] exclude names matching the given patterns
507 -S --subrepos recurse into subrepositories
507 -S --subrepos recurse into subrepositories
508
508
509 [+] marked option can be specified multiple times
509 [+] marked option can be specified multiple times
510
510
511 use "hg -v help status" to show more complete help and the global options
511 use "hg -v help status" to show more complete help and the global options
512
512
513 $ hg -q help status
513 $ hg -q help status
514 hg status [OPTION]... [FILE]...
514 hg status [OPTION]... [FILE]...
515
515
516 show changed files in the working directory
516 show changed files in the working directory
517
517
518 $ hg help foo
518 $ hg help foo
519 hg: unknown command 'foo'
519 hg: unknown command 'foo'
520 Mercurial Distributed SCM
520 Mercurial Distributed SCM
521
521
522 basic commands:
522 basic commands:
523
523
524 add add the specified files on the next commit
524 add add the specified files on the next commit
525 annotate show changeset information by line for each file
525 annotate show changeset information by line for each file
526 clone make a copy of an existing repository
526 clone make a copy of an existing repository
527 commit commit the specified files or all outstanding changes
527 commit commit the specified files or all outstanding changes
528 diff diff repository (or selected files)
528 diff diff repository (or selected files)
529 export dump the header and diffs for one or more changesets
529 export dump the header and diffs for one or more changesets
530 forget forget the specified files on the next commit
530 forget forget the specified files on the next commit
531 init create a new repository in the given directory
531 init create a new repository in the given directory
532 log show revision history of entire repository or files
532 log show revision history of entire repository or files
533 merge merge working directory with another revision
533 merge merge working directory with another revision
534 pull pull changes from the specified source
534 pull pull changes from the specified source
535 push push changes to the specified destination
535 push push changes to the specified destination
536 remove remove the specified files on the next commit
536 remove remove the specified files on the next commit
537 serve start stand-alone webserver
537 serve start stand-alone webserver
538 status show changed files in the working directory
538 status show changed files in the working directory
539 summary summarize working directory state
539 summary summarize working directory state
540 update update working directory (or switch revisions)
540 update update working directory (or switch revisions)
541
541
542 use "hg help" for the full list of commands or "hg -v" for details
542 use "hg help" for the full list of commands or "hg -v" for details
543 [255]
543 [255]
544
544
545 $ hg skjdfks
545 $ hg skjdfks
546 hg: unknown command 'skjdfks'
546 hg: unknown command 'skjdfks'
547 Mercurial Distributed SCM
547 Mercurial Distributed SCM
548
548
549 basic commands:
549 basic commands:
550
550
551 add add the specified files on the next commit
551 add add the specified files on the next commit
552 annotate show changeset information by line for each file
552 annotate show changeset information by line for each file
553 clone make a copy of an existing repository
553 clone make a copy of an existing repository
554 commit commit the specified files or all outstanding changes
554 commit commit the specified files or all outstanding changes
555 diff diff repository (or selected files)
555 diff diff repository (or selected files)
556 export dump the header and diffs for one or more changesets
556 export dump the header and diffs for one or more changesets
557 forget forget the specified files on the next commit
557 forget forget the specified files on the next commit
558 init create a new repository in the given directory
558 init create a new repository in the given directory
559 log show revision history of entire repository or files
559 log show revision history of entire repository or files
560 merge merge working directory with another revision
560 merge merge working directory with another revision
561 pull pull changes from the specified source
561 pull pull changes from the specified source
562 push push changes to the specified destination
562 push push changes to the specified destination
563 remove remove the specified files on the next commit
563 remove remove the specified files on the next commit
564 serve start stand-alone webserver
564 serve start stand-alone webserver
565 status show changed files in the working directory
565 status show changed files in the working directory
566 summary summarize working directory state
566 summary summarize working directory state
567 update update working directory (or switch revisions)
567 update update working directory (or switch revisions)
568
568
569 use "hg help" for the full list of commands or "hg -v" for details
569 use "hg help" for the full list of commands or "hg -v" for details
570 [255]
570 [255]
571
571
572 $ cat > helpext.py <<EOF
572 $ cat > helpext.py <<EOF
573 > import os
573 > import os
574 > from mercurial import commands
574 > from mercurial import commands
575 >
575 >
576 > def nohelp(ui, *args, **kwargs):
576 > def nohelp(ui, *args, **kwargs):
577 > pass
577 > pass
578 >
578 >
579 > cmdtable = {
579 > cmdtable = {
580 > "nohelp": (nohelp, [], "hg nohelp"),
580 > "nohelp": (nohelp, [], "hg nohelp"),
581 > }
581 > }
582 >
582 >
583 > commands.norepo += ' nohelp'
583 > commands.norepo += ' nohelp'
584 > EOF
584 > EOF
585 $ echo '[extensions]' >> $HGRCPATH
585 $ echo '[extensions]' >> $HGRCPATH
586 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
586 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
587
587
588 Test command with no help text
588 Test command with no help text
589
589
590 $ hg help nohelp
590 $ hg help nohelp
591 hg nohelp
591 hg nohelp
592
592
593 (no help text available)
593 (no help text available)
594
594
595 use "hg -v help nohelp" to show the global options
595 use "hg -v help nohelp" to show the global options
596
596
597 $ hg help -k nohelp
597 $ hg help -k nohelp
598 Commands:
598 Commands:
599
599
600 nohelp hg nohelp
600 nohelp hg nohelp
601
601
602 Extension Commands:
602 Extension Commands:
603
603
604 nohelp (no help text available)
604 nohelp (no help text available)
605
605
606 Test that default list of commands omits extension commands
606 Test that default list of commands omits extension commands
607
607
608 $ hg help
608 $ hg help
609 Mercurial Distributed SCM
609 Mercurial Distributed SCM
610
610
611 list of commands:
611 list of commands:
612
612
613 add add the specified files on the next commit
613 add add the specified files on the next commit
614 addremove add all new files, delete all missing files
614 addremove add all new files, delete all missing files
615 annotate show changeset information by line for each file
615 annotate show changeset information by line for each file
616 archive create an unversioned archive of a repository revision
616 archive create an unversioned archive of a repository revision
617 backout reverse effect of earlier changeset
617 backout reverse effect of earlier changeset
618 bisect subdivision search of changesets
618 bisect subdivision search of changesets
619 bookmarks track a line of development with movable markers
619 bookmarks track a line of development with movable markers
620 branch set or show the current branch name
620 branch set or show the current branch name
621 branches list repository named branches
621 branches list repository named branches
622 bundle create a changegroup file
622 bundle create a changegroup file
623 cat output the current or given revision of files
623 cat output the current or given revision of files
624 clone make a copy of an existing repository
624 clone make a copy of an existing repository
625 commit commit the specified files or all outstanding changes
625 commit commit the specified files or all outstanding changes
626 copy mark files as copied for the next commit
626 copy mark files as copied for the next commit
627 diff diff repository (or selected files)
627 diff diff repository (or selected files)
628 export dump the header and diffs for one or more changesets
628 export dump the header and diffs for one or more changesets
629 forget forget the specified files on the next commit
629 forget forget the specified files on the next commit
630 graft copy changes from other branches onto the current branch
630 graft copy changes from other branches onto the current branch
631 grep search for a pattern in specified files and revisions
631 grep search for a pattern in specified files and revisions
632 heads show current repository heads or show branch heads
632 heads show branch heads
633 help show help for a given topic or a help overview
633 help show help for a given topic or a help overview
634 identify identify the working copy or specified revision
634 identify identify the working copy or specified revision
635 import import an ordered set of patches
635 import import an ordered set of patches
636 incoming show new changesets found in source
636 incoming show new changesets found in source
637 init create a new repository in the given directory
637 init create a new repository in the given directory
638 locate locate files matching specific patterns
638 locate locate files matching specific patterns
639 log show revision history of entire repository or files
639 log show revision history of entire repository or files
640 manifest output the current or given revision of the project manifest
640 manifest output the current or given revision of the project manifest
641 merge merge working directory with another revision
641 merge merge working directory with another revision
642 outgoing show changesets not found in the destination
642 outgoing show changesets not found in the destination
643 parents show the parents of the working directory or revision
643 parents show the parents of the working directory or revision
644 paths show aliases for remote repositories
644 paths show aliases for remote repositories
645 phase set or show the current phase name
645 phase set or show the current phase name
646 pull pull changes from the specified source
646 pull pull changes from the specified source
647 push push changes to the specified destination
647 push push changes to the specified destination
648 recover roll back an interrupted transaction
648 recover roll back an interrupted transaction
649 remove remove the specified files on the next commit
649 remove remove the specified files on the next commit
650 rename rename files; equivalent of copy + remove
650 rename rename files; equivalent of copy + remove
651 resolve redo merges or set/view the merge status of files
651 resolve redo merges or set/view the merge status of files
652 revert restore files to their checkout state
652 revert restore files to their checkout state
653 root print the root (top) of the current working directory
653 root print the root (top) of the current working directory
654 serve start stand-alone webserver
654 serve start stand-alone webserver
655 showconfig show combined config settings from all hgrc files
655 showconfig show combined config settings from all hgrc files
656 status show changed files in the working directory
656 status show changed files in the working directory
657 summary summarize working directory state
657 summary summarize working directory state
658 tag add one or more tags for the current or given revision
658 tag add one or more tags for the current or given revision
659 tags list repository tags
659 tags list repository tags
660 unbundle apply one or more changegroup files
660 unbundle apply one or more changegroup files
661 update update working directory (or switch revisions)
661 update update working directory (or switch revisions)
662 verify verify the integrity of the repository
662 verify verify the integrity of the repository
663 version output version and copyright information
663 version output version and copyright information
664
664
665 enabled extensions:
665 enabled extensions:
666
666
667 helpext (no help text available)
667 helpext (no help text available)
668
668
669 additional help topics:
669 additional help topics:
670
670
671 config Configuration Files
671 config Configuration Files
672 dates Date Formats
672 dates Date Formats
673 diffs Diff Formats
673 diffs Diff Formats
674 environment Environment Variables
674 environment Environment Variables
675 extensions Using Additional Features
675 extensions Using Additional Features
676 filesets Specifying File Sets
676 filesets Specifying File Sets
677 glossary Glossary
677 glossary Glossary
678 hgignore Syntax for Mercurial Ignore Files
678 hgignore Syntax for Mercurial Ignore Files
679 hgweb Configuring hgweb
679 hgweb Configuring hgweb
680 merge-tools Merge Tools
680 merge-tools Merge Tools
681 multirevs Specifying Multiple Revisions
681 multirevs Specifying Multiple Revisions
682 patterns File Name Patterns
682 patterns File Name Patterns
683 phases Working with Phases
683 phases Working with Phases
684 revisions Specifying Single Revisions
684 revisions Specifying Single Revisions
685 revsets Specifying Revision Sets
685 revsets Specifying Revision Sets
686 subrepos Subrepositories
686 subrepos Subrepositories
687 templating Template Usage
687 templating Template Usage
688 urls URL Paths
688 urls URL Paths
689
689
690 use "hg -v help" to show builtin aliases and global options
690 use "hg -v help" to show builtin aliases and global options
691
691
692
692
693
693
694 Test list of commands with command with no help text
694 Test list of commands with command with no help text
695
695
696 $ hg help helpext
696 $ hg help helpext
697 helpext extension - no help text available
697 helpext extension - no help text available
698
698
699 list of commands:
699 list of commands:
700
700
701 nohelp (no help text available)
701 nohelp (no help text available)
702
702
703 use "hg -v help helpext" to show builtin aliases and global options
703 use "hg -v help helpext" to show builtin aliases and global options
704
704
705 Test a help topic
705 Test a help topic
706
706
707 $ hg help revs
707 $ hg help revs
708 Specifying Single Revisions
708 Specifying Single Revisions
709 """""""""""""""""""""""""""
709 """""""""""""""""""""""""""
710
710
711 Mercurial supports several ways to specify individual revisions.
711 Mercurial supports several ways to specify individual revisions.
712
712
713 A plain integer is treated as a revision number. Negative integers are
713 A plain integer is treated as a revision number. Negative integers are
714 treated as sequential offsets from the tip, with -1 denoting the tip, -2
714 treated as sequential offsets from the tip, with -1 denoting the tip, -2
715 denoting the revision prior to the tip, and so forth.
715 denoting the revision prior to the tip, and so forth.
716
716
717 A 40-digit hexadecimal string is treated as a unique revision identifier.
717 A 40-digit hexadecimal string is treated as a unique revision identifier.
718
718
719 A hexadecimal string less than 40 characters long is treated as a unique
719 A hexadecimal string less than 40 characters long is treated as a unique
720 revision identifier and is referred to as a short-form identifier. A
720 revision identifier and is referred to as a short-form identifier. A
721 short-form identifier is only valid if it is the prefix of exactly one
721 short-form identifier is only valid if it is the prefix of exactly one
722 full-length identifier.
722 full-length identifier.
723
723
724 Any other string is treated as a bookmark, tag, or branch name. A bookmark
724 Any other string is treated as a bookmark, tag, or branch name. A bookmark
725 is a movable pointer to a revision. A tag is a permanent name associated
725 is a movable pointer to a revision. A tag is a permanent name associated
726 with a revision. A branch name denotes the tipmost revision of that
726 with a revision. A branch name denotes the tipmost revision of that
727 branch. Bookmark, tag, and branch names must not contain the ":"
727 branch. Bookmark, tag, and branch names must not contain the ":"
728 character.
728 character.
729
729
730 The reserved name "tip" always identifies the most recent revision.
730 The reserved name "tip" always identifies the most recent revision.
731
731
732 The reserved name "null" indicates the null revision. This is the revision
732 The reserved name "null" indicates the null revision. This is the revision
733 of an empty repository, and the parent of revision 0.
733 of an empty repository, and the parent of revision 0.
734
734
735 The reserved name "." indicates the working directory parent. If no
735 The reserved name "." indicates the working directory parent. If no
736 working directory is checked out, it is equivalent to null. If an
736 working directory is checked out, it is equivalent to null. If an
737 uncommitted merge is in progress, "." is the revision of the first parent.
737 uncommitted merge is in progress, "." is the revision of the first parent.
738
738
739 Test templating help
739 Test templating help
740
740
741 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
741 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
742 desc String. The text of the changeset description.
742 desc String. The text of the changeset description.
743 diffstat String. Statistics of changes with the following format:
743 diffstat String. Statistics of changes with the following format:
744 firstline Any text. Returns the first line of text.
744 firstline Any text. Returns the first line of text.
745 nonempty Any text. Returns '(none)' if the string is empty.
745 nonempty Any text. Returns '(none)' if the string is empty.
746
746
747 Test help hooks
747 Test help hooks
748
748
749 $ cat > helphook1.py <<EOF
749 $ cat > helphook1.py <<EOF
750 > from mercurial import help
750 > from mercurial import help
751 >
751 >
752 > def rewrite(topic, doc):
752 > def rewrite(topic, doc):
753 > return doc + '\nhelphook1\n'
753 > return doc + '\nhelphook1\n'
754 >
754 >
755 > def extsetup(ui):
755 > def extsetup(ui):
756 > help.addtopichook('revsets', rewrite)
756 > help.addtopichook('revsets', rewrite)
757 > EOF
757 > EOF
758 $ cat > helphook2.py <<EOF
758 $ cat > helphook2.py <<EOF
759 > from mercurial import help
759 > from mercurial import help
760 >
760 >
761 > def rewrite(topic, doc):
761 > def rewrite(topic, doc):
762 > return doc + '\nhelphook2\n'
762 > return doc + '\nhelphook2\n'
763 >
763 >
764 > def extsetup(ui):
764 > def extsetup(ui):
765 > help.addtopichook('revsets', rewrite)
765 > help.addtopichook('revsets', rewrite)
766 > EOF
766 > EOF
767 $ echo '[extensions]' >> $HGRCPATH
767 $ echo '[extensions]' >> $HGRCPATH
768 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
768 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
769 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
769 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
770 $ hg help revsets | grep helphook
770 $ hg help revsets | grep helphook
771 helphook1
771 helphook1
772 helphook2
772 helphook2
773
773
774 Test keyword search help
774 Test keyword search help
775
775
776 $ hg help -k clone
776 $ hg help -k clone
777 Topics:
777 Topics:
778
778
779 config Configuration Files
779 config Configuration Files
780 extensions Using Additional Features
780 extensions Using Additional Features
781 glossary Glossary
781 glossary Glossary
782 phases Working with Phases
782 phases Working with Phases
783 subrepos Subrepositories
783 subrepos Subrepositories
784 urls URL Paths
784 urls URL Paths
785
785
786 Commands:
786 Commands:
787
787
788 bookmarks track a line of development with movable markers
788 bookmarks track a line of development with movable markers
789 clone make a copy of an existing repository
789 clone make a copy of an existing repository
790 paths show aliases for remote repositories
790 paths show aliases for remote repositories
791 update update working directory (or switch revisions)
791 update update working directory (or switch revisions)
792
792
793 Extensions:
793 Extensions:
794
794
795 relink recreates hardlinks between repository clones
795 relink recreates hardlinks between repository clones
796
796
797 Extension Commands:
797 Extension Commands:
798
798
799 qclone clone main and patch repository at same time
799 qclone clone main and patch repository at same time
800
800
801 Test omit indicating for help
801 Test omit indicating for help
802
802
803 $ cat > addverboseitems.py <<EOF
803 $ cat > addverboseitems.py <<EOF
804 > '''extension to test omit indicating.
804 > '''extension to test omit indicating.
805 >
805 >
806 > This paragraph is never omitted (for extension)
806 > This paragraph is never omitted (for extension)
807 >
807 >
808 > .. container:: verbose
808 > .. container:: verbose
809 >
809 >
810 > This paragraph is omitted,
810 > This paragraph is omitted,
811 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension)
811 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension)
812 >
812 >
813 > This paragraph is never omitted, too (for extension)
813 > This paragraph is never omitted, too (for extension)
814 > '''
814 > '''
815 >
815 >
816 > from mercurial import help, commands
816 > from mercurial import help, commands
817 > testtopic = """This paragraph is never omitted (for topic).
817 > testtopic = """This paragraph is never omitted (for topic).
818 >
818 >
819 > .. container:: verbose
819 > .. container:: verbose
820 >
820 >
821 > This paragraph is omitted,
821 > This paragraph is omitted,
822 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic)
822 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic)
823 >
823 >
824 > This paragraph is never omitted, too (for topic)
824 > This paragraph is never omitted, too (for topic)
825 > """
825 > """
826 > def extsetup(ui):
826 > def extsetup(ui):
827 > help.helptable.append((["topic-containing-verbose"],
827 > help.helptable.append((["topic-containing-verbose"],
828 > "This is the topic to test omit indicating.",
828 > "This is the topic to test omit indicating.",
829 > lambda : testtopic))
829 > lambda : testtopic))
830 > EOF
830 > EOF
831 $ echo '[extensions]' >> $HGRCPATH
831 $ echo '[extensions]' >> $HGRCPATH
832 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
832 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
833 $ hg help addverboseitems
833 $ hg help addverboseitems
834 addverboseitems extension - extension to test omit indicating.
834 addverboseitems extension - extension to test omit indicating.
835
835
836 This paragraph is never omitted (for extension)
836 This paragraph is never omitted (for extension)
837
837
838 This paragraph is never omitted, too (for extension)
838 This paragraph is never omitted, too (for extension)
839
839
840 use "hg help -v addverboseitems" to show more complete help
840 use "hg help -v addverboseitems" to show more complete help
841
841
842 no commands defined
842 no commands defined
843 $ hg help -v addverboseitems
843 $ hg help -v addverboseitems
844 addverboseitems extension - extension to test omit indicating.
844 addverboseitems extension - extension to test omit indicating.
845
845
846 This paragraph is never omitted (for extension)
846 This paragraph is never omitted (for extension)
847
847
848 This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension)
848 This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension)
849
849
850 This paragraph is never omitted, too (for extension)
850 This paragraph is never omitted, too (for extension)
851
851
852 no commands defined
852 no commands defined
853 $ hg help topic-containing-verbose
853 $ hg help topic-containing-verbose
854 This is the topic to test omit indicating.
854 This is the topic to test omit indicating.
855 """"""""""""""""""""""""""""""""""""""""""
855 """"""""""""""""""""""""""""""""""""""""""
856
856
857 This paragraph is never omitted (for topic).
857 This paragraph is never omitted (for topic).
858
858
859 This paragraph is never omitted, too (for topic)
859 This paragraph is never omitted, too (for topic)
860
860
861 use "hg help -v topic-containing-verbose" to show more complete help
861 use "hg help -v topic-containing-verbose" to show more complete help
862 $ hg help -v topic-containing-verbose
862 $ hg help -v topic-containing-verbose
863 This is the topic to test omit indicating.
863 This is the topic to test omit indicating.
864 """"""""""""""""""""""""""""""""""""""""""
864 """"""""""""""""""""""""""""""""""""""""""
865
865
866 This paragraph is never omitted (for topic).
866 This paragraph is never omitted (for topic).
867
867
868 This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic)
868 This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic)
869
869
870 This paragraph is never omitted, too (for topic)
870 This paragraph is never omitted, too (for topic)
871
871
872 Test usage of section marks in help documents
872 Test usage of section marks in help documents
873
873
874 $ cd "$TESTDIR"/../doc
874 $ cd "$TESTDIR"/../doc
875 $ python check-seclevel.py
875 $ python check-seclevel.py
876 $ cd $TESTTMP
876 $ cd $TESTTMP
877
877
878 #if serve
878 #if serve
879
879
880 Test the help pages in hgweb.
880 Test the help pages in hgweb.
881
881
882 Dish up an empty repo; serve it cold.
882 Dish up an empty repo; serve it cold.
883
883
884 $ hg init "$TESTTMP/test"
884 $ hg init "$TESTTMP/test"
885 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
885 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
886 $ cat hg.pid >> $DAEMON_PIDS
886 $ cat hg.pid >> $DAEMON_PIDS
887
887
888 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help"
888 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help"
889 200 Script output follows
889 200 Script output follows
890
890
891 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
891 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
892 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
892 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
893 <head>
893 <head>
894 <link rel="icon" href="/static/hgicon.png" type="image/png" />
894 <link rel="icon" href="/static/hgicon.png" type="image/png" />
895 <meta name="robots" content="index, nofollow" />
895 <meta name="robots" content="index, nofollow" />
896 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
896 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
897 <script type="text/javascript" src="/static/mercurial.js"></script>
897 <script type="text/javascript" src="/static/mercurial.js"></script>
898
898
899 <title>Help: Index</title>
899 <title>Help: Index</title>
900 </head>
900 </head>
901 <body>
901 <body>
902
902
903 <div class="container">
903 <div class="container">
904 <div class="menu">
904 <div class="menu">
905 <div class="logo">
905 <div class="logo">
906 <a href="http://mercurial.selenic.com/">
906 <a href="http://mercurial.selenic.com/">
907 <img src="/static/hglogo.png" alt="mercurial" /></a>
907 <img src="/static/hglogo.png" alt="mercurial" /></a>
908 </div>
908 </div>
909 <ul>
909 <ul>
910 <li><a href="/shortlog">log</a></li>
910 <li><a href="/shortlog">log</a></li>
911 <li><a href="/graph">graph</a></li>
911 <li><a href="/graph">graph</a></li>
912 <li><a href="/tags">tags</a></li>
912 <li><a href="/tags">tags</a></li>
913 <li><a href="/bookmarks">bookmarks</a></li>
913 <li><a href="/bookmarks">bookmarks</a></li>
914 <li><a href="/branches">branches</a></li>
914 <li><a href="/branches">branches</a></li>
915 </ul>
915 </ul>
916 <ul>
916 <ul>
917 <li class="active">help</li>
917 <li class="active">help</li>
918 </ul>
918 </ul>
919 </div>
919 </div>
920
920
921 <div class="main">
921 <div class="main">
922 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
922 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
923 <form class="search" action="/log">
923 <form class="search" action="/log">
924
924
925 <p><input name="rev" id="search1" type="text" size="30" /></p>
925 <p><input name="rev" id="search1" type="text" size="30" /></p>
926 <div id="hint">find changesets by author, revision,
926 <div id="hint">find changesets by author, revision,
927 files, or words in the commit message</div>
927 files, or words in the commit message</div>
928 </form>
928 </form>
929 <table class="bigtable">
929 <table class="bigtable">
930 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
930 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
931
931
932 <tr><td>
932 <tr><td>
933 <a href="/help/config">
933 <a href="/help/config">
934 config
934 config
935 </a>
935 </a>
936 </td><td>
936 </td><td>
937 Configuration Files
937 Configuration Files
938 </td></tr>
938 </td></tr>
939 <tr><td>
939 <tr><td>
940 <a href="/help/dates">
940 <a href="/help/dates">
941 dates
941 dates
942 </a>
942 </a>
943 </td><td>
943 </td><td>
944 Date Formats
944 Date Formats
945 </td></tr>
945 </td></tr>
946 <tr><td>
946 <tr><td>
947 <a href="/help/diffs">
947 <a href="/help/diffs">
948 diffs
948 diffs
949 </a>
949 </a>
950 </td><td>
950 </td><td>
951 Diff Formats
951 Diff Formats
952 </td></tr>
952 </td></tr>
953 <tr><td>
953 <tr><td>
954 <a href="/help/environment">
954 <a href="/help/environment">
955 environment
955 environment
956 </a>
956 </a>
957 </td><td>
957 </td><td>
958 Environment Variables
958 Environment Variables
959 </td></tr>
959 </td></tr>
960 <tr><td>
960 <tr><td>
961 <a href="/help/extensions">
961 <a href="/help/extensions">
962 extensions
962 extensions
963 </a>
963 </a>
964 </td><td>
964 </td><td>
965 Using Additional Features
965 Using Additional Features
966 </td></tr>
966 </td></tr>
967 <tr><td>
967 <tr><td>
968 <a href="/help/filesets">
968 <a href="/help/filesets">
969 filesets
969 filesets
970 </a>
970 </a>
971 </td><td>
971 </td><td>
972 Specifying File Sets
972 Specifying File Sets
973 </td></tr>
973 </td></tr>
974 <tr><td>
974 <tr><td>
975 <a href="/help/glossary">
975 <a href="/help/glossary">
976 glossary
976 glossary
977 </a>
977 </a>
978 </td><td>
978 </td><td>
979 Glossary
979 Glossary
980 </td></tr>
980 </td></tr>
981 <tr><td>
981 <tr><td>
982 <a href="/help/hgignore">
982 <a href="/help/hgignore">
983 hgignore
983 hgignore
984 </a>
984 </a>
985 </td><td>
985 </td><td>
986 Syntax for Mercurial Ignore Files
986 Syntax for Mercurial Ignore Files
987 </td></tr>
987 </td></tr>
988 <tr><td>
988 <tr><td>
989 <a href="/help/hgweb">
989 <a href="/help/hgweb">
990 hgweb
990 hgweb
991 </a>
991 </a>
992 </td><td>
992 </td><td>
993 Configuring hgweb
993 Configuring hgweb
994 </td></tr>
994 </td></tr>
995 <tr><td>
995 <tr><td>
996 <a href="/help/merge-tools">
996 <a href="/help/merge-tools">
997 merge-tools
997 merge-tools
998 </a>
998 </a>
999 </td><td>
999 </td><td>
1000 Merge Tools
1000 Merge Tools
1001 </td></tr>
1001 </td></tr>
1002 <tr><td>
1002 <tr><td>
1003 <a href="/help/multirevs">
1003 <a href="/help/multirevs">
1004 multirevs
1004 multirevs
1005 </a>
1005 </a>
1006 </td><td>
1006 </td><td>
1007 Specifying Multiple Revisions
1007 Specifying Multiple Revisions
1008 </td></tr>
1008 </td></tr>
1009 <tr><td>
1009 <tr><td>
1010 <a href="/help/patterns">
1010 <a href="/help/patterns">
1011 patterns
1011 patterns
1012 </a>
1012 </a>
1013 </td><td>
1013 </td><td>
1014 File Name Patterns
1014 File Name Patterns
1015 </td></tr>
1015 </td></tr>
1016 <tr><td>
1016 <tr><td>
1017 <a href="/help/phases">
1017 <a href="/help/phases">
1018 phases
1018 phases
1019 </a>
1019 </a>
1020 </td><td>
1020 </td><td>
1021 Working with Phases
1021 Working with Phases
1022 </td></tr>
1022 </td></tr>
1023 <tr><td>
1023 <tr><td>
1024 <a href="/help/revisions">
1024 <a href="/help/revisions">
1025 revisions
1025 revisions
1026 </a>
1026 </a>
1027 </td><td>
1027 </td><td>
1028 Specifying Single Revisions
1028 Specifying Single Revisions
1029 </td></tr>
1029 </td></tr>
1030 <tr><td>
1030 <tr><td>
1031 <a href="/help/revsets">
1031 <a href="/help/revsets">
1032 revsets
1032 revsets
1033 </a>
1033 </a>
1034 </td><td>
1034 </td><td>
1035 Specifying Revision Sets
1035 Specifying Revision Sets
1036 </td></tr>
1036 </td></tr>
1037 <tr><td>
1037 <tr><td>
1038 <a href="/help/subrepos">
1038 <a href="/help/subrepos">
1039 subrepos
1039 subrepos
1040 </a>
1040 </a>
1041 </td><td>
1041 </td><td>
1042 Subrepositories
1042 Subrepositories
1043 </td></tr>
1043 </td></tr>
1044 <tr><td>
1044 <tr><td>
1045 <a href="/help/templating">
1045 <a href="/help/templating">
1046 templating
1046 templating
1047 </a>
1047 </a>
1048 </td><td>
1048 </td><td>
1049 Template Usage
1049 Template Usage
1050 </td></tr>
1050 </td></tr>
1051 <tr><td>
1051 <tr><td>
1052 <a href="/help/urls">
1052 <a href="/help/urls">
1053 urls
1053 urls
1054 </a>
1054 </a>
1055 </td><td>
1055 </td><td>
1056 URL Paths
1056 URL Paths
1057 </td></tr>
1057 </td></tr>
1058 <tr><td>
1058 <tr><td>
1059 <a href="/help/topic-containing-verbose">
1059 <a href="/help/topic-containing-verbose">
1060 topic-containing-verbose
1060 topic-containing-verbose
1061 </a>
1061 </a>
1062 </td><td>
1062 </td><td>
1063 This is the topic to test omit indicating.
1063 This is the topic to test omit indicating.
1064 </td></tr>
1064 </td></tr>
1065
1065
1066 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1066 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1067
1067
1068 <tr><td>
1068 <tr><td>
1069 <a href="/help/add">
1069 <a href="/help/add">
1070 add
1070 add
1071 </a>
1071 </a>
1072 </td><td>
1072 </td><td>
1073 add the specified files on the next commit
1073 add the specified files on the next commit
1074 </td></tr>
1074 </td></tr>
1075 <tr><td>
1075 <tr><td>
1076 <a href="/help/annotate">
1076 <a href="/help/annotate">
1077 annotate
1077 annotate
1078 </a>
1078 </a>
1079 </td><td>
1079 </td><td>
1080 show changeset information by line for each file
1080 show changeset information by line for each file
1081 </td></tr>
1081 </td></tr>
1082 <tr><td>
1082 <tr><td>
1083 <a href="/help/clone">
1083 <a href="/help/clone">
1084 clone
1084 clone
1085 </a>
1085 </a>
1086 </td><td>
1086 </td><td>
1087 make a copy of an existing repository
1087 make a copy of an existing repository
1088 </td></tr>
1088 </td></tr>
1089 <tr><td>
1089 <tr><td>
1090 <a href="/help/commit">
1090 <a href="/help/commit">
1091 commit
1091 commit
1092 </a>
1092 </a>
1093 </td><td>
1093 </td><td>
1094 commit the specified files or all outstanding changes
1094 commit the specified files or all outstanding changes
1095 </td></tr>
1095 </td></tr>
1096 <tr><td>
1096 <tr><td>
1097 <a href="/help/diff">
1097 <a href="/help/diff">
1098 diff
1098 diff
1099 </a>
1099 </a>
1100 </td><td>
1100 </td><td>
1101 diff repository (or selected files)
1101 diff repository (or selected files)
1102 </td></tr>
1102 </td></tr>
1103 <tr><td>
1103 <tr><td>
1104 <a href="/help/export">
1104 <a href="/help/export">
1105 export
1105 export
1106 </a>
1106 </a>
1107 </td><td>
1107 </td><td>
1108 dump the header and diffs for one or more changesets
1108 dump the header and diffs for one or more changesets
1109 </td></tr>
1109 </td></tr>
1110 <tr><td>
1110 <tr><td>
1111 <a href="/help/forget">
1111 <a href="/help/forget">
1112 forget
1112 forget
1113 </a>
1113 </a>
1114 </td><td>
1114 </td><td>
1115 forget the specified files on the next commit
1115 forget the specified files on the next commit
1116 </td></tr>
1116 </td></tr>
1117 <tr><td>
1117 <tr><td>
1118 <a href="/help/init">
1118 <a href="/help/init">
1119 init
1119 init
1120 </a>
1120 </a>
1121 </td><td>
1121 </td><td>
1122 create a new repository in the given directory
1122 create a new repository in the given directory
1123 </td></tr>
1123 </td></tr>
1124 <tr><td>
1124 <tr><td>
1125 <a href="/help/log">
1125 <a href="/help/log">
1126 log
1126 log
1127 </a>
1127 </a>
1128 </td><td>
1128 </td><td>
1129 show revision history of entire repository or files
1129 show revision history of entire repository or files
1130 </td></tr>
1130 </td></tr>
1131 <tr><td>
1131 <tr><td>
1132 <a href="/help/merge">
1132 <a href="/help/merge">
1133 merge
1133 merge
1134 </a>
1134 </a>
1135 </td><td>
1135 </td><td>
1136 merge working directory with another revision
1136 merge working directory with another revision
1137 </td></tr>
1137 </td></tr>
1138 <tr><td>
1138 <tr><td>
1139 <a href="/help/pull">
1139 <a href="/help/pull">
1140 pull
1140 pull
1141 </a>
1141 </a>
1142 </td><td>
1142 </td><td>
1143 pull changes from the specified source
1143 pull changes from the specified source
1144 </td></tr>
1144 </td></tr>
1145 <tr><td>
1145 <tr><td>
1146 <a href="/help/push">
1146 <a href="/help/push">
1147 push
1147 push
1148 </a>
1148 </a>
1149 </td><td>
1149 </td><td>
1150 push changes to the specified destination
1150 push changes to the specified destination
1151 </td></tr>
1151 </td></tr>
1152 <tr><td>
1152 <tr><td>
1153 <a href="/help/remove">
1153 <a href="/help/remove">
1154 remove
1154 remove
1155 </a>
1155 </a>
1156 </td><td>
1156 </td><td>
1157 remove the specified files on the next commit
1157 remove the specified files on the next commit
1158 </td></tr>
1158 </td></tr>
1159 <tr><td>
1159 <tr><td>
1160 <a href="/help/serve">
1160 <a href="/help/serve">
1161 serve
1161 serve
1162 </a>
1162 </a>
1163 </td><td>
1163 </td><td>
1164 start stand-alone webserver
1164 start stand-alone webserver
1165 </td></tr>
1165 </td></tr>
1166 <tr><td>
1166 <tr><td>
1167 <a href="/help/status">
1167 <a href="/help/status">
1168 status
1168 status
1169 </a>
1169 </a>
1170 </td><td>
1170 </td><td>
1171 show changed files in the working directory
1171 show changed files in the working directory
1172 </td></tr>
1172 </td></tr>
1173 <tr><td>
1173 <tr><td>
1174 <a href="/help/summary">
1174 <a href="/help/summary">
1175 summary
1175 summary
1176 </a>
1176 </a>
1177 </td><td>
1177 </td><td>
1178 summarize working directory state
1178 summarize working directory state
1179 </td></tr>
1179 </td></tr>
1180 <tr><td>
1180 <tr><td>
1181 <a href="/help/update">
1181 <a href="/help/update">
1182 update
1182 update
1183 </a>
1183 </a>
1184 </td><td>
1184 </td><td>
1185 update working directory (or switch revisions)
1185 update working directory (or switch revisions)
1186 </td></tr>
1186 </td></tr>
1187
1187
1188 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1188 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1189
1189
1190 <tr><td>
1190 <tr><td>
1191 <a href="/help/addremove">
1191 <a href="/help/addremove">
1192 addremove
1192 addremove
1193 </a>
1193 </a>
1194 </td><td>
1194 </td><td>
1195 add all new files, delete all missing files
1195 add all new files, delete all missing files
1196 </td></tr>
1196 </td></tr>
1197 <tr><td>
1197 <tr><td>
1198 <a href="/help/archive">
1198 <a href="/help/archive">
1199 archive
1199 archive
1200 </a>
1200 </a>
1201 </td><td>
1201 </td><td>
1202 create an unversioned archive of a repository revision
1202 create an unversioned archive of a repository revision
1203 </td></tr>
1203 </td></tr>
1204 <tr><td>
1204 <tr><td>
1205 <a href="/help/backout">
1205 <a href="/help/backout">
1206 backout
1206 backout
1207 </a>
1207 </a>
1208 </td><td>
1208 </td><td>
1209 reverse effect of earlier changeset
1209 reverse effect of earlier changeset
1210 </td></tr>
1210 </td></tr>
1211 <tr><td>
1211 <tr><td>
1212 <a href="/help/bisect">
1212 <a href="/help/bisect">
1213 bisect
1213 bisect
1214 </a>
1214 </a>
1215 </td><td>
1215 </td><td>
1216 subdivision search of changesets
1216 subdivision search of changesets
1217 </td></tr>
1217 </td></tr>
1218 <tr><td>
1218 <tr><td>
1219 <a href="/help/bookmarks">
1219 <a href="/help/bookmarks">
1220 bookmarks
1220 bookmarks
1221 </a>
1221 </a>
1222 </td><td>
1222 </td><td>
1223 track a line of development with movable markers
1223 track a line of development with movable markers
1224 </td></tr>
1224 </td></tr>
1225 <tr><td>
1225 <tr><td>
1226 <a href="/help/branch">
1226 <a href="/help/branch">
1227 branch
1227 branch
1228 </a>
1228 </a>
1229 </td><td>
1229 </td><td>
1230 set or show the current branch name
1230 set or show the current branch name
1231 </td></tr>
1231 </td></tr>
1232 <tr><td>
1232 <tr><td>
1233 <a href="/help/branches">
1233 <a href="/help/branches">
1234 branches
1234 branches
1235 </a>
1235 </a>
1236 </td><td>
1236 </td><td>
1237 list repository named branches
1237 list repository named branches
1238 </td></tr>
1238 </td></tr>
1239 <tr><td>
1239 <tr><td>
1240 <a href="/help/bundle">
1240 <a href="/help/bundle">
1241 bundle
1241 bundle
1242 </a>
1242 </a>
1243 </td><td>
1243 </td><td>
1244 create a changegroup file
1244 create a changegroup file
1245 </td></tr>
1245 </td></tr>
1246 <tr><td>
1246 <tr><td>
1247 <a href="/help/cat">
1247 <a href="/help/cat">
1248 cat
1248 cat
1249 </a>
1249 </a>
1250 </td><td>
1250 </td><td>
1251 output the current or given revision of files
1251 output the current or given revision of files
1252 </td></tr>
1252 </td></tr>
1253 <tr><td>
1253 <tr><td>
1254 <a href="/help/copy">
1254 <a href="/help/copy">
1255 copy
1255 copy
1256 </a>
1256 </a>
1257 </td><td>
1257 </td><td>
1258 mark files as copied for the next commit
1258 mark files as copied for the next commit
1259 </td></tr>
1259 </td></tr>
1260 <tr><td>
1260 <tr><td>
1261 <a href="/help/graft">
1261 <a href="/help/graft">
1262 graft
1262 graft
1263 </a>
1263 </a>
1264 </td><td>
1264 </td><td>
1265 copy changes from other branches onto the current branch
1265 copy changes from other branches onto the current branch
1266 </td></tr>
1266 </td></tr>
1267 <tr><td>
1267 <tr><td>
1268 <a href="/help/grep">
1268 <a href="/help/grep">
1269 grep
1269 grep
1270 </a>
1270 </a>
1271 </td><td>
1271 </td><td>
1272 search for a pattern in specified files and revisions
1272 search for a pattern in specified files and revisions
1273 </td></tr>
1273 </td></tr>
1274 <tr><td>
1274 <tr><td>
1275 <a href="/help/heads">
1275 <a href="/help/heads">
1276 heads
1276 heads
1277 </a>
1277 </a>
1278 </td><td>
1278 </td><td>
1279 show current repository heads or show branch heads
1279 show branch heads
1280 </td></tr>
1280 </td></tr>
1281 <tr><td>
1281 <tr><td>
1282 <a href="/help/help">
1282 <a href="/help/help">
1283 help
1283 help
1284 </a>
1284 </a>
1285 </td><td>
1285 </td><td>
1286 show help for a given topic or a help overview
1286 show help for a given topic or a help overview
1287 </td></tr>
1287 </td></tr>
1288 <tr><td>
1288 <tr><td>
1289 <a href="/help/identify">
1289 <a href="/help/identify">
1290 identify
1290 identify
1291 </a>
1291 </a>
1292 </td><td>
1292 </td><td>
1293 identify the working copy or specified revision
1293 identify the working copy or specified revision
1294 </td></tr>
1294 </td></tr>
1295 <tr><td>
1295 <tr><td>
1296 <a href="/help/import">
1296 <a href="/help/import">
1297 import
1297 import
1298 </a>
1298 </a>
1299 </td><td>
1299 </td><td>
1300 import an ordered set of patches
1300 import an ordered set of patches
1301 </td></tr>
1301 </td></tr>
1302 <tr><td>
1302 <tr><td>
1303 <a href="/help/incoming">
1303 <a href="/help/incoming">
1304 incoming
1304 incoming
1305 </a>
1305 </a>
1306 </td><td>
1306 </td><td>
1307 show new changesets found in source
1307 show new changesets found in source
1308 </td></tr>
1308 </td></tr>
1309 <tr><td>
1309 <tr><td>
1310 <a href="/help/locate">
1310 <a href="/help/locate">
1311 locate
1311 locate
1312 </a>
1312 </a>
1313 </td><td>
1313 </td><td>
1314 locate files matching specific patterns
1314 locate files matching specific patterns
1315 </td></tr>
1315 </td></tr>
1316 <tr><td>
1316 <tr><td>
1317 <a href="/help/manifest">
1317 <a href="/help/manifest">
1318 manifest
1318 manifest
1319 </a>
1319 </a>
1320 </td><td>
1320 </td><td>
1321 output the current or given revision of the project manifest
1321 output the current or given revision of the project manifest
1322 </td></tr>
1322 </td></tr>
1323 <tr><td>
1323 <tr><td>
1324 <a href="/help/nohelp">
1324 <a href="/help/nohelp">
1325 nohelp
1325 nohelp
1326 </a>
1326 </a>
1327 </td><td>
1327 </td><td>
1328 (no help text available)
1328 (no help text available)
1329 </td></tr>
1329 </td></tr>
1330 <tr><td>
1330 <tr><td>
1331 <a href="/help/outgoing">
1331 <a href="/help/outgoing">
1332 outgoing
1332 outgoing
1333 </a>
1333 </a>
1334 </td><td>
1334 </td><td>
1335 show changesets not found in the destination
1335 show changesets not found in the destination
1336 </td></tr>
1336 </td></tr>
1337 <tr><td>
1337 <tr><td>
1338 <a href="/help/parents">
1338 <a href="/help/parents">
1339 parents
1339 parents
1340 </a>
1340 </a>
1341 </td><td>
1341 </td><td>
1342 show the parents of the working directory or revision
1342 show the parents of the working directory or revision
1343 </td></tr>
1343 </td></tr>
1344 <tr><td>
1344 <tr><td>
1345 <a href="/help/paths">
1345 <a href="/help/paths">
1346 paths
1346 paths
1347 </a>
1347 </a>
1348 </td><td>
1348 </td><td>
1349 show aliases for remote repositories
1349 show aliases for remote repositories
1350 </td></tr>
1350 </td></tr>
1351 <tr><td>
1351 <tr><td>
1352 <a href="/help/phase">
1352 <a href="/help/phase">
1353 phase
1353 phase
1354 </a>
1354 </a>
1355 </td><td>
1355 </td><td>
1356 set or show the current phase name
1356 set or show the current phase name
1357 </td></tr>
1357 </td></tr>
1358 <tr><td>
1358 <tr><td>
1359 <a href="/help/recover">
1359 <a href="/help/recover">
1360 recover
1360 recover
1361 </a>
1361 </a>
1362 </td><td>
1362 </td><td>
1363 roll back an interrupted transaction
1363 roll back an interrupted transaction
1364 </td></tr>
1364 </td></tr>
1365 <tr><td>
1365 <tr><td>
1366 <a href="/help/rename">
1366 <a href="/help/rename">
1367 rename
1367 rename
1368 </a>
1368 </a>
1369 </td><td>
1369 </td><td>
1370 rename files; equivalent of copy + remove
1370 rename files; equivalent of copy + remove
1371 </td></tr>
1371 </td></tr>
1372 <tr><td>
1372 <tr><td>
1373 <a href="/help/resolve">
1373 <a href="/help/resolve">
1374 resolve
1374 resolve
1375 </a>
1375 </a>
1376 </td><td>
1376 </td><td>
1377 redo merges or set/view the merge status of files
1377 redo merges or set/view the merge status of files
1378 </td></tr>
1378 </td></tr>
1379 <tr><td>
1379 <tr><td>
1380 <a href="/help/revert">
1380 <a href="/help/revert">
1381 revert
1381 revert
1382 </a>
1382 </a>
1383 </td><td>
1383 </td><td>
1384 restore files to their checkout state
1384 restore files to their checkout state
1385 </td></tr>
1385 </td></tr>
1386 <tr><td>
1386 <tr><td>
1387 <a href="/help/root">
1387 <a href="/help/root">
1388 root
1388 root
1389 </a>
1389 </a>
1390 </td><td>
1390 </td><td>
1391 print the root (top) of the current working directory
1391 print the root (top) of the current working directory
1392 </td></tr>
1392 </td></tr>
1393 <tr><td>
1393 <tr><td>
1394 <a href="/help/showconfig">
1394 <a href="/help/showconfig">
1395 showconfig
1395 showconfig
1396 </a>
1396 </a>
1397 </td><td>
1397 </td><td>
1398 show combined config settings from all hgrc files
1398 show combined config settings from all hgrc files
1399 </td></tr>
1399 </td></tr>
1400 <tr><td>
1400 <tr><td>
1401 <a href="/help/tag">
1401 <a href="/help/tag">
1402 tag
1402 tag
1403 </a>
1403 </a>
1404 </td><td>
1404 </td><td>
1405 add one or more tags for the current or given revision
1405 add one or more tags for the current or given revision
1406 </td></tr>
1406 </td></tr>
1407 <tr><td>
1407 <tr><td>
1408 <a href="/help/tags">
1408 <a href="/help/tags">
1409 tags
1409 tags
1410 </a>
1410 </a>
1411 </td><td>
1411 </td><td>
1412 list repository tags
1412 list repository tags
1413 </td></tr>
1413 </td></tr>
1414 <tr><td>
1414 <tr><td>
1415 <a href="/help/unbundle">
1415 <a href="/help/unbundle">
1416 unbundle
1416 unbundle
1417 </a>
1417 </a>
1418 </td><td>
1418 </td><td>
1419 apply one or more changegroup files
1419 apply one or more changegroup files
1420 </td></tr>
1420 </td></tr>
1421 <tr><td>
1421 <tr><td>
1422 <a href="/help/verify">
1422 <a href="/help/verify">
1423 verify
1423 verify
1424 </a>
1424 </a>
1425 </td><td>
1425 </td><td>
1426 verify the integrity of the repository
1426 verify the integrity of the repository
1427 </td></tr>
1427 </td></tr>
1428 <tr><td>
1428 <tr><td>
1429 <a href="/help/version">
1429 <a href="/help/version">
1430 version
1430 version
1431 </a>
1431 </a>
1432 </td><td>
1432 </td><td>
1433 output version and copyright information
1433 output version and copyright information
1434 </td></tr>
1434 </td></tr>
1435 </table>
1435 </table>
1436 </div>
1436 </div>
1437 </div>
1437 </div>
1438
1438
1439 <script type="text/javascript">process_dates()</script>
1439 <script type="text/javascript">process_dates()</script>
1440
1440
1441
1441
1442 </body>
1442 </body>
1443 </html>
1443 </html>
1444
1444
1445
1445
1446 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add"
1446 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add"
1447 200 Script output follows
1447 200 Script output follows
1448
1448
1449 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1449 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1450 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1450 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1451 <head>
1451 <head>
1452 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1452 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1453 <meta name="robots" content="index, nofollow" />
1453 <meta name="robots" content="index, nofollow" />
1454 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1454 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1455 <script type="text/javascript" src="/static/mercurial.js"></script>
1455 <script type="text/javascript" src="/static/mercurial.js"></script>
1456
1456
1457 <title>Help: add</title>
1457 <title>Help: add</title>
1458 </head>
1458 </head>
1459 <body>
1459 <body>
1460
1460
1461 <div class="container">
1461 <div class="container">
1462 <div class="menu">
1462 <div class="menu">
1463 <div class="logo">
1463 <div class="logo">
1464 <a href="http://mercurial.selenic.com/">
1464 <a href="http://mercurial.selenic.com/">
1465 <img src="/static/hglogo.png" alt="mercurial" /></a>
1465 <img src="/static/hglogo.png" alt="mercurial" /></a>
1466 </div>
1466 </div>
1467 <ul>
1467 <ul>
1468 <li><a href="/shortlog">log</a></li>
1468 <li><a href="/shortlog">log</a></li>
1469 <li><a href="/graph">graph</a></li>
1469 <li><a href="/graph">graph</a></li>
1470 <li><a href="/tags">tags</a></li>
1470 <li><a href="/tags">tags</a></li>
1471 <li><a href="/bookmarks">bookmarks</a></li>
1471 <li><a href="/bookmarks">bookmarks</a></li>
1472 <li><a href="/branches">branches</a></li>
1472 <li><a href="/branches">branches</a></li>
1473 </ul>
1473 </ul>
1474 <ul>
1474 <ul>
1475 <li class="active"><a href="/help">help</a></li>
1475 <li class="active"><a href="/help">help</a></li>
1476 </ul>
1476 </ul>
1477 </div>
1477 </div>
1478
1478
1479 <div class="main">
1479 <div class="main">
1480 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1480 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1481 <h3>Help: add</h3>
1481 <h3>Help: add</h3>
1482
1482
1483 <form class="search" action="/log">
1483 <form class="search" action="/log">
1484
1484
1485 <p><input name="rev" id="search1" type="text" size="30" /></p>
1485 <p><input name="rev" id="search1" type="text" size="30" /></p>
1486 <div id="hint">find changesets by author, revision,
1486 <div id="hint">find changesets by author, revision,
1487 files, or words in the commit message</div>
1487 files, or words in the commit message</div>
1488 </form>
1488 </form>
1489 <div id="doc">
1489 <div id="doc">
1490 <p>
1490 <p>
1491 hg add [OPTION]... [FILE]...
1491 hg add [OPTION]... [FILE]...
1492 </p>
1492 </p>
1493 <p>
1493 <p>
1494 add the specified files on the next commit
1494 add the specified files on the next commit
1495 </p>
1495 </p>
1496 <p>
1496 <p>
1497 Schedule files to be version controlled and added to the
1497 Schedule files to be version controlled and added to the
1498 repository.
1498 repository.
1499 </p>
1499 </p>
1500 <p>
1500 <p>
1501 The files will be added to the repository at the next commit. To
1501 The files will be added to the repository at the next commit. To
1502 undo an add before that, see &quot;hg forget&quot;.
1502 undo an add before that, see &quot;hg forget&quot;.
1503 </p>
1503 </p>
1504 <p>
1504 <p>
1505 If no names are given, add all files to the repository.
1505 If no names are given, add all files to the repository.
1506 </p>
1506 </p>
1507 <p>
1507 <p>
1508 An example showing how new (unknown) files are added
1508 An example showing how new (unknown) files are added
1509 automatically by &quot;hg add&quot;:
1509 automatically by &quot;hg add&quot;:
1510 </p>
1510 </p>
1511 <pre>
1511 <pre>
1512 \$ ls (re)
1512 \$ ls (re)
1513 foo.c
1513 foo.c
1514 \$ hg status (re)
1514 \$ hg status (re)
1515 ? foo.c
1515 ? foo.c
1516 \$ hg add (re)
1516 \$ hg add (re)
1517 adding foo.c
1517 adding foo.c
1518 \$ hg status (re)
1518 \$ hg status (re)
1519 A foo.c
1519 A foo.c
1520 </pre>
1520 </pre>
1521 <p>
1521 <p>
1522 Returns 0 if all files are successfully added.
1522 Returns 0 if all files are successfully added.
1523 </p>
1523 </p>
1524 <p>
1524 <p>
1525 options:
1525 options:
1526 </p>
1526 </p>
1527 <table>
1527 <table>
1528 <tr><td>-I</td>
1528 <tr><td>-I</td>
1529 <td>--include PATTERN [+]</td>
1529 <td>--include PATTERN [+]</td>
1530 <td>include names matching the given patterns</td></tr>
1530 <td>include names matching the given patterns</td></tr>
1531 <tr><td>-X</td>
1531 <tr><td>-X</td>
1532 <td>--exclude PATTERN [+]</td>
1532 <td>--exclude PATTERN [+]</td>
1533 <td>exclude names matching the given patterns</td></tr>
1533 <td>exclude names matching the given patterns</td></tr>
1534 <tr><td>-S</td>
1534 <tr><td>-S</td>
1535 <td>--subrepos</td>
1535 <td>--subrepos</td>
1536 <td>recurse into subrepositories</td></tr>
1536 <td>recurse into subrepositories</td></tr>
1537 <tr><td>-n</td>
1537 <tr><td>-n</td>
1538 <td>--dry-run</td>
1538 <td>--dry-run</td>
1539 <td>do not perform actions, just print output</td></tr>
1539 <td>do not perform actions, just print output</td></tr>
1540 </table>
1540 </table>
1541 <p>
1541 <p>
1542 [+] marked option can be specified multiple times
1542 [+] marked option can be specified multiple times
1543 </p>
1543 </p>
1544 <p>
1544 <p>
1545 global options:
1545 global options:
1546 </p>
1546 </p>
1547 <table>
1547 <table>
1548 <tr><td>-R</td>
1548 <tr><td>-R</td>
1549 <td>--repository REPO</td>
1549 <td>--repository REPO</td>
1550 <td>repository root directory or name of overlay bundle file</td></tr>
1550 <td>repository root directory or name of overlay bundle file</td></tr>
1551 <tr><td></td>
1551 <tr><td></td>
1552 <td>--cwd DIR</td>
1552 <td>--cwd DIR</td>
1553 <td>change working directory</td></tr>
1553 <td>change working directory</td></tr>
1554 <tr><td>-y</td>
1554 <tr><td>-y</td>
1555 <td>--noninteractive</td>
1555 <td>--noninteractive</td>
1556 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1556 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1557 <tr><td>-q</td>
1557 <tr><td>-q</td>
1558 <td>--quiet</td>
1558 <td>--quiet</td>
1559 <td>suppress output</td></tr>
1559 <td>suppress output</td></tr>
1560 <tr><td>-v</td>
1560 <tr><td>-v</td>
1561 <td>--verbose</td>
1561 <td>--verbose</td>
1562 <td>enable additional output</td></tr>
1562 <td>enable additional output</td></tr>
1563 <tr><td></td>
1563 <tr><td></td>
1564 <td>--config CONFIG [+]</td>
1564 <td>--config CONFIG [+]</td>
1565 <td>set/override config option (use 'section.name=value')</td></tr>
1565 <td>set/override config option (use 'section.name=value')</td></tr>
1566 <tr><td></td>
1566 <tr><td></td>
1567 <td>--debug</td>
1567 <td>--debug</td>
1568 <td>enable debugging output</td></tr>
1568 <td>enable debugging output</td></tr>
1569 <tr><td></td>
1569 <tr><td></td>
1570 <td>--debugger</td>
1570 <td>--debugger</td>
1571 <td>start debugger</td></tr>
1571 <td>start debugger</td></tr>
1572 <tr><td></td>
1572 <tr><td></td>
1573 <td>--encoding ENCODE</td>
1573 <td>--encoding ENCODE</td>
1574 <td>set the charset encoding (default: ascii)</td></tr>
1574 <td>set the charset encoding (default: ascii)</td></tr>
1575 <tr><td></td>
1575 <tr><td></td>
1576 <td>--encodingmode MODE</td>
1576 <td>--encodingmode MODE</td>
1577 <td>set the charset encoding mode (default: strict)</td></tr>
1577 <td>set the charset encoding mode (default: strict)</td></tr>
1578 <tr><td></td>
1578 <tr><td></td>
1579 <td>--traceback</td>
1579 <td>--traceback</td>
1580 <td>always print a traceback on exception</td></tr>
1580 <td>always print a traceback on exception</td></tr>
1581 <tr><td></td>
1581 <tr><td></td>
1582 <td>--time</td>
1582 <td>--time</td>
1583 <td>time how long the command takes</td></tr>
1583 <td>time how long the command takes</td></tr>
1584 <tr><td></td>
1584 <tr><td></td>
1585 <td>--profile</td>
1585 <td>--profile</td>
1586 <td>print command execution profile</td></tr>
1586 <td>print command execution profile</td></tr>
1587 <tr><td></td>
1587 <tr><td></td>
1588 <td>--version</td>
1588 <td>--version</td>
1589 <td>output version information and exit</td></tr>
1589 <td>output version information and exit</td></tr>
1590 <tr><td>-h</td>
1590 <tr><td>-h</td>
1591 <td>--help</td>
1591 <td>--help</td>
1592 <td>display help and exit</td></tr>
1592 <td>display help and exit</td></tr>
1593 <tr><td></td>
1593 <tr><td></td>
1594 <td>--hidden</td>
1594 <td>--hidden</td>
1595 <td>consider hidden changesets</td></tr>
1595 <td>consider hidden changesets</td></tr>
1596 </table>
1596 </table>
1597 <p>
1597 <p>
1598 [+] marked option can be specified multiple times
1598 [+] marked option can be specified multiple times
1599 </p>
1599 </p>
1600
1600
1601 </div>
1601 </div>
1602 </div>
1602 </div>
1603 </div>
1603 </div>
1604
1604
1605 <script type="text/javascript">process_dates()</script>
1605 <script type="text/javascript">process_dates()</script>
1606
1606
1607
1607
1608 </body>
1608 </body>
1609 </html>
1609 </html>
1610
1610
1611
1611
1612 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove"
1612 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove"
1613 200 Script output follows
1613 200 Script output follows
1614
1614
1615 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1615 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1616 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1616 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1617 <head>
1617 <head>
1618 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1618 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1619 <meta name="robots" content="index, nofollow" />
1619 <meta name="robots" content="index, nofollow" />
1620 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1620 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1621 <script type="text/javascript" src="/static/mercurial.js"></script>
1621 <script type="text/javascript" src="/static/mercurial.js"></script>
1622
1622
1623 <title>Help: remove</title>
1623 <title>Help: remove</title>
1624 </head>
1624 </head>
1625 <body>
1625 <body>
1626
1626
1627 <div class="container">
1627 <div class="container">
1628 <div class="menu">
1628 <div class="menu">
1629 <div class="logo">
1629 <div class="logo">
1630 <a href="http://mercurial.selenic.com/">
1630 <a href="http://mercurial.selenic.com/">
1631 <img src="/static/hglogo.png" alt="mercurial" /></a>
1631 <img src="/static/hglogo.png" alt="mercurial" /></a>
1632 </div>
1632 </div>
1633 <ul>
1633 <ul>
1634 <li><a href="/shortlog">log</a></li>
1634 <li><a href="/shortlog">log</a></li>
1635 <li><a href="/graph">graph</a></li>
1635 <li><a href="/graph">graph</a></li>
1636 <li><a href="/tags">tags</a></li>
1636 <li><a href="/tags">tags</a></li>
1637 <li><a href="/bookmarks">bookmarks</a></li>
1637 <li><a href="/bookmarks">bookmarks</a></li>
1638 <li><a href="/branches">branches</a></li>
1638 <li><a href="/branches">branches</a></li>
1639 </ul>
1639 </ul>
1640 <ul>
1640 <ul>
1641 <li class="active"><a href="/help">help</a></li>
1641 <li class="active"><a href="/help">help</a></li>
1642 </ul>
1642 </ul>
1643 </div>
1643 </div>
1644
1644
1645 <div class="main">
1645 <div class="main">
1646 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1646 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1647 <h3>Help: remove</h3>
1647 <h3>Help: remove</h3>
1648
1648
1649 <form class="search" action="/log">
1649 <form class="search" action="/log">
1650
1650
1651 <p><input name="rev" id="search1" type="text" size="30" /></p>
1651 <p><input name="rev" id="search1" type="text" size="30" /></p>
1652 <div id="hint">find changesets by author, revision,
1652 <div id="hint">find changesets by author, revision,
1653 files, or words in the commit message</div>
1653 files, or words in the commit message</div>
1654 </form>
1654 </form>
1655 <div id="doc">
1655 <div id="doc">
1656 <p>
1656 <p>
1657 hg remove [OPTION]... FILE...
1657 hg remove [OPTION]... FILE...
1658 </p>
1658 </p>
1659 <p>
1659 <p>
1660 aliases: rm
1660 aliases: rm
1661 </p>
1661 </p>
1662 <p>
1662 <p>
1663 remove the specified files on the next commit
1663 remove the specified files on the next commit
1664 </p>
1664 </p>
1665 <p>
1665 <p>
1666 Schedule the indicated files for removal from the current branch.
1666 Schedule the indicated files for removal from the current branch.
1667 </p>
1667 </p>
1668 <p>
1668 <p>
1669 This command schedules the files to be removed at the next commit.
1669 This command schedules the files to be removed at the next commit.
1670 To undo a remove before that, see &quot;hg revert&quot;. To undo added
1670 To undo a remove before that, see &quot;hg revert&quot;. To undo added
1671 files, see &quot;hg forget&quot;.
1671 files, see &quot;hg forget&quot;.
1672 </p>
1672 </p>
1673 <p>
1673 <p>
1674 -A/--after can be used to remove only files that have already
1674 -A/--after can be used to remove only files that have already
1675 been deleted, -f/--force can be used to force deletion, and -Af
1675 been deleted, -f/--force can be used to force deletion, and -Af
1676 can be used to remove files from the next revision without
1676 can be used to remove files from the next revision without
1677 deleting them from the working directory.
1677 deleting them from the working directory.
1678 </p>
1678 </p>
1679 <p>
1679 <p>
1680 The following table details the behavior of remove for different
1680 The following table details the behavior of remove for different
1681 file states (columns) and option combinations (rows). The file
1681 file states (columns) and option combinations (rows). The file
1682 states are Added [A], Clean [C], Modified [M] and Missing [!]
1682 states are Added [A], Clean [C], Modified [M] and Missing [!]
1683 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
1683 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
1684 (from branch) and Delete (from disk):
1684 (from branch) and Delete (from disk):
1685 </p>
1685 </p>
1686 <table>
1686 <table>
1687 <tr><td></td>
1687 <tr><td></td>
1688 <td>A</td>
1688 <td>A</td>
1689 <td>C</td>
1689 <td>C</td>
1690 <td>M</td>
1690 <td>M</td>
1691 <td>!</td></tr>
1691 <td>!</td></tr>
1692 <tr><td>none</td>
1692 <tr><td>none</td>
1693 <td>W</td>
1693 <td>W</td>
1694 <td>RD</td>
1694 <td>RD</td>
1695 <td>W</td>
1695 <td>W</td>
1696 <td>R</td></tr>
1696 <td>R</td></tr>
1697 <tr><td>-f</td>
1697 <tr><td>-f</td>
1698 <td>R</td>
1698 <td>R</td>
1699 <td>RD</td>
1699 <td>RD</td>
1700 <td>RD</td>
1700 <td>RD</td>
1701 <td>R</td></tr>
1701 <td>R</td></tr>
1702 <tr><td>-A</td>
1702 <tr><td>-A</td>
1703 <td>W</td>
1703 <td>W</td>
1704 <td>W</td>
1704 <td>W</td>
1705 <td>W</td>
1705 <td>W</td>
1706 <td>R</td></tr>
1706 <td>R</td></tr>
1707 <tr><td>-Af</td>
1707 <tr><td>-Af</td>
1708 <td>R</td>
1708 <td>R</td>
1709 <td>R</td>
1709 <td>R</td>
1710 <td>R</td>
1710 <td>R</td>
1711 <td>R</td></tr>
1711 <td>R</td></tr>
1712 </table>
1712 </table>
1713 <p>
1713 <p>
1714 Note that remove never deletes files in Added [A] state from the
1714 Note that remove never deletes files in Added [A] state from the
1715 working directory, not even if option --force is specified.
1715 working directory, not even if option --force is specified.
1716 </p>
1716 </p>
1717 <p>
1717 <p>
1718 Returns 0 on success, 1 if any warnings encountered.
1718 Returns 0 on success, 1 if any warnings encountered.
1719 </p>
1719 </p>
1720 <p>
1720 <p>
1721 options:
1721 options:
1722 </p>
1722 </p>
1723 <table>
1723 <table>
1724 <tr><td>-A</td>
1724 <tr><td>-A</td>
1725 <td>--after</td>
1725 <td>--after</td>
1726 <td>record delete for missing files</td></tr>
1726 <td>record delete for missing files</td></tr>
1727 <tr><td>-f</td>
1727 <tr><td>-f</td>
1728 <td>--force</td>
1728 <td>--force</td>
1729 <td>remove (and delete) file even if added or modified</td></tr>
1729 <td>remove (and delete) file even if added or modified</td></tr>
1730 <tr><td>-I</td>
1730 <tr><td>-I</td>
1731 <td>--include PATTERN [+]</td>
1731 <td>--include PATTERN [+]</td>
1732 <td>include names matching the given patterns</td></tr>
1732 <td>include names matching the given patterns</td></tr>
1733 <tr><td>-X</td>
1733 <tr><td>-X</td>
1734 <td>--exclude PATTERN [+]</td>
1734 <td>--exclude PATTERN [+]</td>
1735 <td>exclude names matching the given patterns</td></tr>
1735 <td>exclude names matching the given patterns</td></tr>
1736 </table>
1736 </table>
1737 <p>
1737 <p>
1738 [+] marked option can be specified multiple times
1738 [+] marked option can be specified multiple times
1739 </p>
1739 </p>
1740 <p>
1740 <p>
1741 global options:
1741 global options:
1742 </p>
1742 </p>
1743 <table>
1743 <table>
1744 <tr><td>-R</td>
1744 <tr><td>-R</td>
1745 <td>--repository REPO</td>
1745 <td>--repository REPO</td>
1746 <td>repository root directory or name of overlay bundle file</td></tr>
1746 <td>repository root directory or name of overlay bundle file</td></tr>
1747 <tr><td></td>
1747 <tr><td></td>
1748 <td>--cwd DIR</td>
1748 <td>--cwd DIR</td>
1749 <td>change working directory</td></tr>
1749 <td>change working directory</td></tr>
1750 <tr><td>-y</td>
1750 <tr><td>-y</td>
1751 <td>--noninteractive</td>
1751 <td>--noninteractive</td>
1752 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1752 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1753 <tr><td>-q</td>
1753 <tr><td>-q</td>
1754 <td>--quiet</td>
1754 <td>--quiet</td>
1755 <td>suppress output</td></tr>
1755 <td>suppress output</td></tr>
1756 <tr><td>-v</td>
1756 <tr><td>-v</td>
1757 <td>--verbose</td>
1757 <td>--verbose</td>
1758 <td>enable additional output</td></tr>
1758 <td>enable additional output</td></tr>
1759 <tr><td></td>
1759 <tr><td></td>
1760 <td>--config CONFIG [+]</td>
1760 <td>--config CONFIG [+]</td>
1761 <td>set/override config option (use 'section.name=value')</td></tr>
1761 <td>set/override config option (use 'section.name=value')</td></tr>
1762 <tr><td></td>
1762 <tr><td></td>
1763 <td>--debug</td>
1763 <td>--debug</td>
1764 <td>enable debugging output</td></tr>
1764 <td>enable debugging output</td></tr>
1765 <tr><td></td>
1765 <tr><td></td>
1766 <td>--debugger</td>
1766 <td>--debugger</td>
1767 <td>start debugger</td></tr>
1767 <td>start debugger</td></tr>
1768 <tr><td></td>
1768 <tr><td></td>
1769 <td>--encoding ENCODE</td>
1769 <td>--encoding ENCODE</td>
1770 <td>set the charset encoding (default: ascii)</td></tr>
1770 <td>set the charset encoding (default: ascii)</td></tr>
1771 <tr><td></td>
1771 <tr><td></td>
1772 <td>--encodingmode MODE</td>
1772 <td>--encodingmode MODE</td>
1773 <td>set the charset encoding mode (default: strict)</td></tr>
1773 <td>set the charset encoding mode (default: strict)</td></tr>
1774 <tr><td></td>
1774 <tr><td></td>
1775 <td>--traceback</td>
1775 <td>--traceback</td>
1776 <td>always print a traceback on exception</td></tr>
1776 <td>always print a traceback on exception</td></tr>
1777 <tr><td></td>
1777 <tr><td></td>
1778 <td>--time</td>
1778 <td>--time</td>
1779 <td>time how long the command takes</td></tr>
1779 <td>time how long the command takes</td></tr>
1780 <tr><td></td>
1780 <tr><td></td>
1781 <td>--profile</td>
1781 <td>--profile</td>
1782 <td>print command execution profile</td></tr>
1782 <td>print command execution profile</td></tr>
1783 <tr><td></td>
1783 <tr><td></td>
1784 <td>--version</td>
1784 <td>--version</td>
1785 <td>output version information and exit</td></tr>
1785 <td>output version information and exit</td></tr>
1786 <tr><td>-h</td>
1786 <tr><td>-h</td>
1787 <td>--help</td>
1787 <td>--help</td>
1788 <td>display help and exit</td></tr>
1788 <td>display help and exit</td></tr>
1789 <tr><td></td>
1789 <tr><td></td>
1790 <td>--hidden</td>
1790 <td>--hidden</td>
1791 <td>consider hidden changesets</td></tr>
1791 <td>consider hidden changesets</td></tr>
1792 </table>
1792 </table>
1793 <p>
1793 <p>
1794 [+] marked option can be specified multiple times
1794 [+] marked option can be specified multiple times
1795 </p>
1795 </p>
1796
1796
1797 </div>
1797 </div>
1798 </div>
1798 </div>
1799 </div>
1799 </div>
1800
1800
1801 <script type="text/javascript">process_dates()</script>
1801 <script type="text/javascript">process_dates()</script>
1802
1802
1803
1803
1804 </body>
1804 </body>
1805 </html>
1805 </html>
1806
1806
1807
1807
1808 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions"
1808 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions"
1809 200 Script output follows
1809 200 Script output follows
1810
1810
1811 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1811 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1812 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1812 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1813 <head>
1813 <head>
1814 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1814 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1815 <meta name="robots" content="index, nofollow" />
1815 <meta name="robots" content="index, nofollow" />
1816 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1816 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1817 <script type="text/javascript" src="/static/mercurial.js"></script>
1817 <script type="text/javascript" src="/static/mercurial.js"></script>
1818
1818
1819 <title>Help: revisions</title>
1819 <title>Help: revisions</title>
1820 </head>
1820 </head>
1821 <body>
1821 <body>
1822
1822
1823 <div class="container">
1823 <div class="container">
1824 <div class="menu">
1824 <div class="menu">
1825 <div class="logo">
1825 <div class="logo">
1826 <a href="http://mercurial.selenic.com/">
1826 <a href="http://mercurial.selenic.com/">
1827 <img src="/static/hglogo.png" alt="mercurial" /></a>
1827 <img src="/static/hglogo.png" alt="mercurial" /></a>
1828 </div>
1828 </div>
1829 <ul>
1829 <ul>
1830 <li><a href="/shortlog">log</a></li>
1830 <li><a href="/shortlog">log</a></li>
1831 <li><a href="/graph">graph</a></li>
1831 <li><a href="/graph">graph</a></li>
1832 <li><a href="/tags">tags</a></li>
1832 <li><a href="/tags">tags</a></li>
1833 <li><a href="/bookmarks">bookmarks</a></li>
1833 <li><a href="/bookmarks">bookmarks</a></li>
1834 <li><a href="/branches">branches</a></li>
1834 <li><a href="/branches">branches</a></li>
1835 </ul>
1835 </ul>
1836 <ul>
1836 <ul>
1837 <li class="active"><a href="/help">help</a></li>
1837 <li class="active"><a href="/help">help</a></li>
1838 </ul>
1838 </ul>
1839 </div>
1839 </div>
1840
1840
1841 <div class="main">
1841 <div class="main">
1842 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1842 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1843 <h3>Help: revisions</h3>
1843 <h3>Help: revisions</h3>
1844
1844
1845 <form class="search" action="/log">
1845 <form class="search" action="/log">
1846
1846
1847 <p><input name="rev" id="search1" type="text" size="30" /></p>
1847 <p><input name="rev" id="search1" type="text" size="30" /></p>
1848 <div id="hint">find changesets by author, revision,
1848 <div id="hint">find changesets by author, revision,
1849 files, or words in the commit message</div>
1849 files, or words in the commit message</div>
1850 </form>
1850 </form>
1851 <div id="doc">
1851 <div id="doc">
1852 <h1>Specifying Single Revisions</h1>
1852 <h1>Specifying Single Revisions</h1>
1853 <p>
1853 <p>
1854 Mercurial supports several ways to specify individual revisions.
1854 Mercurial supports several ways to specify individual revisions.
1855 </p>
1855 </p>
1856 <p>
1856 <p>
1857 A plain integer is treated as a revision number. Negative integers are
1857 A plain integer is treated as a revision number. Negative integers are
1858 treated as sequential offsets from the tip, with -1 denoting the tip,
1858 treated as sequential offsets from the tip, with -1 denoting the tip,
1859 -2 denoting the revision prior to the tip, and so forth.
1859 -2 denoting the revision prior to the tip, and so forth.
1860 </p>
1860 </p>
1861 <p>
1861 <p>
1862 A 40-digit hexadecimal string is treated as a unique revision
1862 A 40-digit hexadecimal string is treated as a unique revision
1863 identifier.
1863 identifier.
1864 </p>
1864 </p>
1865 <p>
1865 <p>
1866 A hexadecimal string less than 40 characters long is treated as a
1866 A hexadecimal string less than 40 characters long is treated as a
1867 unique revision identifier and is referred to as a short-form
1867 unique revision identifier and is referred to as a short-form
1868 identifier. A short-form identifier is only valid if it is the prefix
1868 identifier. A short-form identifier is only valid if it is the prefix
1869 of exactly one full-length identifier.
1869 of exactly one full-length identifier.
1870 </p>
1870 </p>
1871 <p>
1871 <p>
1872 Any other string is treated as a bookmark, tag, or branch name. A
1872 Any other string is treated as a bookmark, tag, or branch name. A
1873 bookmark is a movable pointer to a revision. A tag is a permanent name
1873 bookmark is a movable pointer to a revision. A tag is a permanent name
1874 associated with a revision. A branch name denotes the tipmost revision
1874 associated with a revision. A branch name denotes the tipmost revision
1875 of that branch. Bookmark, tag, and branch names must not contain the &quot;:&quot;
1875 of that branch. Bookmark, tag, and branch names must not contain the &quot;:&quot;
1876 character.
1876 character.
1877 </p>
1877 </p>
1878 <p>
1878 <p>
1879 The reserved name &quot;tip&quot; always identifies the most recent revision.
1879 The reserved name &quot;tip&quot; always identifies the most recent revision.
1880 </p>
1880 </p>
1881 <p>
1881 <p>
1882 The reserved name &quot;null&quot; indicates the null revision. This is the
1882 The reserved name &quot;null&quot; indicates the null revision. This is the
1883 revision of an empty repository, and the parent of revision 0.
1883 revision of an empty repository, and the parent of revision 0.
1884 </p>
1884 </p>
1885 <p>
1885 <p>
1886 The reserved name &quot;.&quot; indicates the working directory parent. If no
1886 The reserved name &quot;.&quot; indicates the working directory parent. If no
1887 working directory is checked out, it is equivalent to null. If an
1887 working directory is checked out, it is equivalent to null. If an
1888 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
1888 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
1889 parent.
1889 parent.
1890 </p>
1890 </p>
1891
1891
1892 </div>
1892 </div>
1893 </div>
1893 </div>
1894 </div>
1894 </div>
1895
1895
1896 <script type="text/javascript">process_dates()</script>
1896 <script type="text/javascript">process_dates()</script>
1897
1897
1898
1898
1899 </body>
1899 </body>
1900 </html>
1900 </html>
1901
1901
1902
1902
1903 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1903 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1904
1904
1905 #endif
1905 #endif
General Comments 0
You need to be logged in to leave comments. Login now