##// END OF EJS Templates
commands: add example for 'hg add'
Mathias De Maré -
r27143:fab21bac default
parent child Browse files
Show More
@@ -1,6757 +1,6771 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, nullhex, nullid, nullrev, short
8 from node import hex, bin, nullhex, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _
10 from i18n import _
11 import os, re, difflib, time, tempfile, errno, shlex
11 import os, re, difflib, time, tempfile, errno, shlex
12 import sys, socket
12 import sys, socket
13 import hg, scmutil, util, revlog, copies, error, bookmarks
13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 import patch, help, encoding, templatekw, discovery
14 import patch, help, encoding, templatekw, discovery
15 import archival, changegroup, cmdutil, hbisect
15 import archival, changegroup, cmdutil, hbisect
16 import sshserver, hgweb
16 import sshserver, hgweb
17 import extensions
17 import extensions
18 import merge as mergemod
18 import merge as mergemod
19 import minirst, revset, fileset
19 import minirst, revset, fileset
20 import dagparser, context, simplemerge, graphmod, copies
20 import dagparser, context, simplemerge, graphmod, copies
21 import random, operator
21 import random, operator
22 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
22 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
23 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
23 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
24 import ui as uimod
24 import ui as uimod
25 import streamclone
25 import streamclone
26
26
27 table = {}
27 table = {}
28
28
29 command = cmdutil.command(table)
29 command = cmdutil.command(table)
30
30
31 # Space delimited list of commands that don't require local repositories.
31 # Space delimited list of commands that don't require local repositories.
32 # This should be populated by passing norepo=True into the @command decorator.
32 # This should be populated by passing norepo=True into the @command decorator.
33 norepo = ''
33 norepo = ''
34 # Space delimited list of commands that optionally require local repositories.
34 # Space delimited list of commands that optionally require local repositories.
35 # This should be populated by passing optionalrepo=True into the @command
35 # This should be populated by passing optionalrepo=True into the @command
36 # decorator.
36 # decorator.
37 optionalrepo = ''
37 optionalrepo = ''
38 # Space delimited list of commands that will examine arguments looking for
38 # Space delimited list of commands that will examine arguments looking for
39 # a repository. This should be populated by passing inferrepo=True into the
39 # a repository. This should be populated by passing inferrepo=True into the
40 # @command decorator.
40 # @command decorator.
41 inferrepo = ''
41 inferrepo = ''
42
42
43 # label constants
43 # label constants
44 # until 3.5, bookmarks.current was the advertised name, not
44 # until 3.5, bookmarks.current was the advertised name, not
45 # bookmarks.active, so we must use both to avoid breaking old
45 # bookmarks.active, so we must use both to avoid breaking old
46 # custom styles
46 # custom styles
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
48
48
49 # common command options
49 # common command options
50
50
51 globalopts = [
51 globalopts = [
52 ('R', 'repository', '',
52 ('R', 'repository', '',
53 _('repository root directory or name of overlay bundle file'),
53 _('repository root directory or name of overlay bundle file'),
54 _('REPO')),
54 _('REPO')),
55 ('', 'cwd', '',
55 ('', 'cwd', '',
56 _('change working directory'), _('DIR')),
56 _('change working directory'), _('DIR')),
57 ('y', 'noninteractive', None,
57 ('y', 'noninteractive', None,
58 _('do not prompt, automatically pick the first choice for all prompts')),
58 _('do not prompt, automatically pick the first choice for all prompts')),
59 ('q', 'quiet', None, _('suppress output')),
59 ('q', 'quiet', None, _('suppress output')),
60 ('v', 'verbose', None, _('enable additional output')),
60 ('v', 'verbose', None, _('enable additional output')),
61 ('', 'config', [],
61 ('', 'config', [],
62 _('set/override config option (use \'section.name=value\')'),
62 _('set/override config option (use \'section.name=value\')'),
63 _('CONFIG')),
63 _('CONFIG')),
64 ('', 'debug', None, _('enable debugging output')),
64 ('', 'debug', None, _('enable debugging output')),
65 ('', 'debugger', None, _('start debugger')),
65 ('', 'debugger', None, _('start debugger')),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
67 _('ENCODE')),
67 _('ENCODE')),
68 ('', 'encodingmode', encoding.encodingmode,
68 ('', 'encodingmode', encoding.encodingmode,
69 _('set the charset encoding mode'), _('MODE')),
69 _('set the charset encoding mode'), _('MODE')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
71 ('', 'time', None, _('time how long the command takes')),
71 ('', 'time', None, _('time how long the command takes')),
72 ('', 'profile', None, _('print command execution profile')),
72 ('', 'profile', None, _('print command execution profile')),
73 ('', 'version', None, _('output version information and exit')),
73 ('', 'version', None, _('output version information and exit')),
74 ('h', 'help', None, _('display help and exit')),
74 ('h', 'help', None, _('display help and exit')),
75 ('', 'hidden', False, _('consider hidden changesets')),
75 ('', 'hidden', False, _('consider hidden changesets')),
76 ]
76 ]
77
77
78 dryrunopts = [('n', 'dry-run', None,
78 dryrunopts = [('n', 'dry-run', None,
79 _('do not perform actions, just print output'))]
79 _('do not perform actions, just print output'))]
80
80
81 remoteopts = [
81 remoteopts = [
82 ('e', 'ssh', '',
82 ('e', 'ssh', '',
83 _('specify ssh command to use'), _('CMD')),
83 _('specify ssh command to use'), _('CMD')),
84 ('', 'remotecmd', '',
84 ('', 'remotecmd', '',
85 _('specify hg command to run on the remote side'), _('CMD')),
85 _('specify hg command to run on the remote side'), _('CMD')),
86 ('', 'insecure', None,
86 ('', 'insecure', None,
87 _('do not verify server certificate (ignoring web.cacerts config)')),
87 _('do not verify server certificate (ignoring web.cacerts config)')),
88 ]
88 ]
89
89
90 walkopts = [
90 walkopts = [
91 ('I', 'include', [],
91 ('I', 'include', [],
92 _('include names matching the given patterns'), _('PATTERN')),
92 _('include names matching the given patterns'), _('PATTERN')),
93 ('X', 'exclude', [],
93 ('X', 'exclude', [],
94 _('exclude names matching the given patterns'), _('PATTERN')),
94 _('exclude names matching the given patterns'), _('PATTERN')),
95 ]
95 ]
96
96
97 commitopts = [
97 commitopts = [
98 ('m', 'message', '',
98 ('m', 'message', '',
99 _('use text as commit message'), _('TEXT')),
99 _('use text as commit message'), _('TEXT')),
100 ('l', 'logfile', '',
100 ('l', 'logfile', '',
101 _('read commit message from file'), _('FILE')),
101 _('read commit message from file'), _('FILE')),
102 ]
102 ]
103
103
104 commitopts2 = [
104 commitopts2 = [
105 ('d', 'date', '',
105 ('d', 'date', '',
106 _('record the specified date as commit date'), _('DATE')),
106 _('record the specified date as commit date'), _('DATE')),
107 ('u', 'user', '',
107 ('u', 'user', '',
108 _('record the specified user as committer'), _('USER')),
108 _('record the specified user as committer'), _('USER')),
109 ]
109 ]
110
110
111 # hidden for now
111 # hidden for now
112 formatteropts = [
112 formatteropts = [
113 ('T', 'template', '',
113 ('T', 'template', '',
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
115 ]
115 ]
116
116
117 templateopts = [
117 templateopts = [
118 ('', 'style', '',
118 ('', 'style', '',
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
120 ('T', 'template', '',
120 ('T', 'template', '',
121 _('display with template'), _('TEMPLATE')),
121 _('display with template'), _('TEMPLATE')),
122 ]
122 ]
123
123
124 logopts = [
124 logopts = [
125 ('p', 'patch', None, _('show patch')),
125 ('p', 'patch', None, _('show patch')),
126 ('g', 'git', None, _('use git extended diff format')),
126 ('g', 'git', None, _('use git extended diff format')),
127 ('l', 'limit', '',
127 ('l', 'limit', '',
128 _('limit number of changes displayed'), _('NUM')),
128 _('limit number of changes displayed'), _('NUM')),
129 ('M', 'no-merges', None, _('do not show merges')),
129 ('M', 'no-merges', None, _('do not show merges')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
131 ('G', 'graph', None, _("show the revision DAG")),
131 ('G', 'graph', None, _("show the revision DAG")),
132 ] + templateopts
132 ] + templateopts
133
133
134 diffopts = [
134 diffopts = [
135 ('a', 'text', None, _('treat all files as text')),
135 ('a', 'text', None, _('treat all files as text')),
136 ('g', 'git', None, _('use git extended diff format')),
136 ('g', 'git', None, _('use git extended diff format')),
137 ('', 'nodates', None, _('omit dates from diff headers'))
137 ('', 'nodates', None, _('omit dates from diff headers'))
138 ]
138 ]
139
139
140 diffwsopts = [
140 diffwsopts = [
141 ('w', 'ignore-all-space', None,
141 ('w', 'ignore-all-space', None,
142 _('ignore white space when comparing lines')),
142 _('ignore white space when comparing lines')),
143 ('b', 'ignore-space-change', None,
143 ('b', 'ignore-space-change', None,
144 _('ignore changes in the amount of white space')),
144 _('ignore changes in the amount of white space')),
145 ('B', 'ignore-blank-lines', None,
145 ('B', 'ignore-blank-lines', None,
146 _('ignore changes whose lines are all blank')),
146 _('ignore changes whose lines are all blank')),
147 ]
147 ]
148
148
149 diffopts2 = [
149 diffopts2 = [
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
151 ('p', 'show-function', None, _('show which function each change is in')),
151 ('p', 'show-function', None, _('show which function each change is in')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
153 ] + diffwsopts + [
153 ] + diffwsopts + [
154 ('U', 'unified', '',
154 ('U', 'unified', '',
155 _('number of lines of context to show'), _('NUM')),
155 _('number of lines of context to show'), _('NUM')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
158 ]
158 ]
159
159
160 mergetoolopts = [
160 mergetoolopts = [
161 ('t', 'tool', '', _('specify merge tool')),
161 ('t', 'tool', '', _('specify merge tool')),
162 ]
162 ]
163
163
164 similarityopts = [
164 similarityopts = [
165 ('s', 'similarity', '',
165 ('s', 'similarity', '',
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
167 ]
167 ]
168
168
169 subrepoopts = [
169 subrepoopts = [
170 ('S', 'subrepos', None,
170 ('S', 'subrepos', None,
171 _('recurse into subrepositories'))
171 _('recurse into subrepositories'))
172 ]
172 ]
173
173
174 # Commands start here, listed alphabetically
174 # Commands start here, listed alphabetically
175
175
176 @command('^add',
176 @command('^add',
177 walkopts + subrepoopts + dryrunopts,
177 walkopts + subrepoopts + dryrunopts,
178 _('[OPTION]... [FILE]...'),
178 _('[OPTION]... [FILE]...'),
179 inferrepo=True)
179 inferrepo=True)
180 def add(ui, repo, *pats, **opts):
180 def add(ui, repo, *pats, **opts):
181 """add the specified files on the next commit
181 """add the specified files on the next commit
182
182
183 Schedule files to be version controlled and added to the
183 Schedule files to be version controlled and added to the
184 repository.
184 repository.
185
185
186 The files will be added to the repository at the next commit. To
186 The files will be added to the repository at the next commit. To
187 undo an add before that, see :hg:`forget`.
187 undo an add before that, see :hg:`forget`.
188
188
189 If no names are given, add all files to the repository.
189 If no names are given, add all files to the repository.
190
190
191 .. container:: verbose
191 .. container:: verbose
192
192
193 An example showing how new (unknown) files are added
193 Examples:
194
195 - New (unknown) files are added
194 automatically by :hg:`add`::
196 automatically by :hg:`add`::
195
197
196 $ ls
198 $ ls
197 foo.c
199 foo.c
198 $ hg status
200 $ hg status
199 ? foo.c
201 ? foo.c
200 $ hg add
202 $ hg add
201 adding foo.c
203 adding foo.c
202 $ hg status
204 $ hg status
203 A foo.c
205 A foo.c
204
206
207 - Specific files to be added can be specified::
208
209 $ ls
210 bar.c foo.c
211 $ hg status
212 ? bar.c
213 ? foo.c
214 $ hg add bar.c
215 $ hg status
216 A bar.c
217 ? foo.c
218
205 Returns 0 if all files are successfully added.
219 Returns 0 if all files are successfully added.
206 """
220 """
207
221
208 m = scmutil.match(repo[None], pats, opts)
222 m = scmutil.match(repo[None], pats, opts)
209 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
223 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
210 return rejected and 1 or 0
224 return rejected and 1 or 0
211
225
212 @command('addremove',
226 @command('addremove',
213 similarityopts + subrepoopts + walkopts + dryrunopts,
227 similarityopts + subrepoopts + walkopts + dryrunopts,
214 _('[OPTION]... [FILE]...'),
228 _('[OPTION]... [FILE]...'),
215 inferrepo=True)
229 inferrepo=True)
216 def addremove(ui, repo, *pats, **opts):
230 def addremove(ui, repo, *pats, **opts):
217 """add all new files, delete all missing files
231 """add all new files, delete all missing files
218
232
219 Add all new files and remove all missing files from the
233 Add all new files and remove all missing files from the
220 repository.
234 repository.
221
235
222 New files are ignored if they match any of the patterns in
236 New files are ignored if they match any of the patterns in
223 ``.hgignore``. As with add, these changes take effect at the next
237 ``.hgignore``. As with add, these changes take effect at the next
224 commit.
238 commit.
225
239
226 Use the -s/--similarity option to detect renamed files. This
240 Use the -s/--similarity option to detect renamed files. This
227 option takes a percentage between 0 (disabled) and 100 (files must
241 option takes a percentage between 0 (disabled) and 100 (files must
228 be identical) as its parameter. With a parameter greater than 0,
242 be identical) as its parameter. With a parameter greater than 0,
229 this compares every removed file with every added file and records
243 this compares every removed file with every added file and records
230 those similar enough as renames. Detecting renamed files this way
244 those similar enough as renames. Detecting renamed files this way
231 can be expensive. After using this option, :hg:`status -C` can be
245 can be expensive. After using this option, :hg:`status -C` can be
232 used to check which files were identified as moved or renamed. If
246 used to check which files were identified as moved or renamed. If
233 not specified, -s/--similarity defaults to 100 and only renames of
247 not specified, -s/--similarity defaults to 100 and only renames of
234 identical files are detected.
248 identical files are detected.
235
249
236 Returns 0 if all files are successfully added.
250 Returns 0 if all files are successfully added.
237 """
251 """
238 try:
252 try:
239 sim = float(opts.get('similarity') or 100)
253 sim = float(opts.get('similarity') or 100)
240 except ValueError:
254 except ValueError:
241 raise error.Abort(_('similarity must be a number'))
255 raise error.Abort(_('similarity must be a number'))
242 if sim < 0 or sim > 100:
256 if sim < 0 or sim > 100:
243 raise error.Abort(_('similarity must be between 0 and 100'))
257 raise error.Abort(_('similarity must be between 0 and 100'))
244 matcher = scmutil.match(repo[None], pats, opts)
258 matcher = scmutil.match(repo[None], pats, opts)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
259 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
246
260
247 @command('^annotate|blame',
261 @command('^annotate|blame',
248 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
262 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
249 ('', 'follow', None,
263 ('', 'follow', None,
250 _('follow copies/renames and list the filename (DEPRECATED)')),
264 _('follow copies/renames and list the filename (DEPRECATED)')),
251 ('', 'no-follow', None, _("don't follow copies and renames")),
265 ('', 'no-follow', None, _("don't follow copies and renames")),
252 ('a', 'text', None, _('treat all files as text')),
266 ('a', 'text', None, _('treat all files as text')),
253 ('u', 'user', None, _('list the author (long with -v)')),
267 ('u', 'user', None, _('list the author (long with -v)')),
254 ('f', 'file', None, _('list the filename')),
268 ('f', 'file', None, _('list the filename')),
255 ('d', 'date', None, _('list the date (short with -q)')),
269 ('d', 'date', None, _('list the date (short with -q)')),
256 ('n', 'number', None, _('list the revision number (default)')),
270 ('n', 'number', None, _('list the revision number (default)')),
257 ('c', 'changeset', None, _('list the changeset')),
271 ('c', 'changeset', None, _('list the changeset')),
258 ('l', 'line-number', None, _('show line number at the first appearance'))
272 ('l', 'line-number', None, _('show line number at the first appearance'))
259 ] + diffwsopts + walkopts + formatteropts,
273 ] + diffwsopts + walkopts + formatteropts,
260 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
274 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
261 inferrepo=True)
275 inferrepo=True)
262 def annotate(ui, repo, *pats, **opts):
276 def annotate(ui, repo, *pats, **opts):
263 """show changeset information by line for each file
277 """show changeset information by line for each file
264
278
265 List changes in files, showing the revision id responsible for
279 List changes in files, showing the revision id responsible for
266 each line
280 each line
267
281
268 This command is useful for discovering when a change was made and
282 This command is useful for discovering when a change was made and
269 by whom.
283 by whom.
270
284
271 Without the -a/--text option, annotate will avoid processing files
285 Without the -a/--text option, annotate will avoid processing files
272 it detects as binary. With -a, annotate will annotate the file
286 it detects as binary. With -a, annotate will annotate the file
273 anyway, although the results will probably be neither useful
287 anyway, although the results will probably be neither useful
274 nor desirable.
288 nor desirable.
275
289
276 Returns 0 on success.
290 Returns 0 on success.
277 """
291 """
278 if not pats:
292 if not pats:
279 raise error.Abort(_('at least one filename or pattern is required'))
293 raise error.Abort(_('at least one filename or pattern is required'))
280
294
281 if opts.get('follow'):
295 if opts.get('follow'):
282 # --follow is deprecated and now just an alias for -f/--file
296 # --follow is deprecated and now just an alias for -f/--file
283 # to mimic the behavior of Mercurial before version 1.5
297 # to mimic the behavior of Mercurial before version 1.5
284 opts['file'] = True
298 opts['file'] = True
285
299
286 ctx = scmutil.revsingle(repo, opts.get('rev'))
300 ctx = scmutil.revsingle(repo, opts.get('rev'))
287
301
288 fm = ui.formatter('annotate', opts)
302 fm = ui.formatter('annotate', opts)
289 if ui.quiet:
303 if ui.quiet:
290 datefunc = util.shortdate
304 datefunc = util.shortdate
291 else:
305 else:
292 datefunc = util.datestr
306 datefunc = util.datestr
293 if ctx.rev() is None:
307 if ctx.rev() is None:
294 def hexfn(node):
308 def hexfn(node):
295 if node is None:
309 if node is None:
296 return None
310 return None
297 else:
311 else:
298 return fm.hexfunc(node)
312 return fm.hexfunc(node)
299 if opts.get('changeset'):
313 if opts.get('changeset'):
300 # omit "+" suffix which is appended to node hex
314 # omit "+" suffix which is appended to node hex
301 def formatrev(rev):
315 def formatrev(rev):
302 if rev is None:
316 if rev is None:
303 return '%d' % ctx.p1().rev()
317 return '%d' % ctx.p1().rev()
304 else:
318 else:
305 return '%d' % rev
319 return '%d' % rev
306 else:
320 else:
307 def formatrev(rev):
321 def formatrev(rev):
308 if rev is None:
322 if rev is None:
309 return '%d+' % ctx.p1().rev()
323 return '%d+' % ctx.p1().rev()
310 else:
324 else:
311 return '%d ' % rev
325 return '%d ' % rev
312 def formathex(hex):
326 def formathex(hex):
313 if hex is None:
327 if hex is None:
314 return '%s+' % fm.hexfunc(ctx.p1().node())
328 return '%s+' % fm.hexfunc(ctx.p1().node())
315 else:
329 else:
316 return '%s ' % hex
330 return '%s ' % hex
317 else:
331 else:
318 hexfn = fm.hexfunc
332 hexfn = fm.hexfunc
319 formatrev = formathex = str
333 formatrev = formathex = str
320
334
321 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
335 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
322 ('number', ' ', lambda x: x[0].rev(), formatrev),
336 ('number', ' ', lambda x: x[0].rev(), formatrev),
323 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
337 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
324 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
338 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
325 ('file', ' ', lambda x: x[0].path(), str),
339 ('file', ' ', lambda x: x[0].path(), str),
326 ('line_number', ':', lambda x: x[1], str),
340 ('line_number', ':', lambda x: x[1], str),
327 ]
341 ]
328 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
342 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
329
343
330 if (not opts.get('user') and not opts.get('changeset')
344 if (not opts.get('user') and not opts.get('changeset')
331 and not opts.get('date') and not opts.get('file')):
345 and not opts.get('date') and not opts.get('file')):
332 opts['number'] = True
346 opts['number'] = True
333
347
334 linenumber = opts.get('line_number') is not None
348 linenumber = opts.get('line_number') is not None
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
349 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
336 raise error.Abort(_('at least one of -n/-c is required for -l'))
350 raise error.Abort(_('at least one of -n/-c is required for -l'))
337
351
338 if fm:
352 if fm:
339 def makefunc(get, fmt):
353 def makefunc(get, fmt):
340 return get
354 return get
341 else:
355 else:
342 def makefunc(get, fmt):
356 def makefunc(get, fmt):
343 return lambda x: fmt(get(x))
357 return lambda x: fmt(get(x))
344 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
358 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
345 if opts.get(op)]
359 if opts.get(op)]
346 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
360 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
347 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
361 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
348 if opts.get(op))
362 if opts.get(op))
349
363
350 def bad(x, y):
364 def bad(x, y):
351 raise error.Abort("%s: %s" % (x, y))
365 raise error.Abort("%s: %s" % (x, y))
352
366
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
367 m = scmutil.match(ctx, pats, opts, badfn=bad)
354
368
355 follow = not opts.get('no_follow')
369 follow = not opts.get('no_follow')
356 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
370 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
357 whitespace=True)
371 whitespace=True)
358 for abs in ctx.walk(m):
372 for abs in ctx.walk(m):
359 fctx = ctx[abs]
373 fctx = ctx[abs]
360 if not opts.get('text') and util.binary(fctx.data()):
374 if not opts.get('text') and util.binary(fctx.data()):
361 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
375 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
362 continue
376 continue
363
377
364 lines = fctx.annotate(follow=follow, linenumber=linenumber,
378 lines = fctx.annotate(follow=follow, linenumber=linenumber,
365 diffopts=diffopts)
379 diffopts=diffopts)
366 formats = []
380 formats = []
367 pieces = []
381 pieces = []
368
382
369 for f, sep in funcmap:
383 for f, sep in funcmap:
370 l = [f(n) for n, dummy in lines]
384 l = [f(n) for n, dummy in lines]
371 if l:
385 if l:
372 if fm:
386 if fm:
373 formats.append(['%s' for x in l])
387 formats.append(['%s' for x in l])
374 else:
388 else:
375 sizes = [encoding.colwidth(x) for x in l]
389 sizes = [encoding.colwidth(x) for x in l]
376 ml = max(sizes)
390 ml = max(sizes)
377 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
391 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
378 pieces.append(l)
392 pieces.append(l)
379
393
380 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
394 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
381 fm.startitem()
395 fm.startitem()
382 fm.write(fields, "".join(f), *p)
396 fm.write(fields, "".join(f), *p)
383 fm.write('line', ": %s", l[1])
397 fm.write('line', ": %s", l[1])
384
398
385 if lines and not lines[-1][1].endswith('\n'):
399 if lines and not lines[-1][1].endswith('\n'):
386 fm.plain('\n')
400 fm.plain('\n')
387
401
388 fm.end()
402 fm.end()
389
403
390 @command('archive',
404 @command('archive',
391 [('', 'no-decode', None, _('do not pass files through decoders')),
405 [('', 'no-decode', None, _('do not pass files through decoders')),
392 ('p', 'prefix', '', _('directory prefix for files in archive'),
406 ('p', 'prefix', '', _('directory prefix for files in archive'),
393 _('PREFIX')),
407 _('PREFIX')),
394 ('r', 'rev', '', _('revision to distribute'), _('REV')),
408 ('r', 'rev', '', _('revision to distribute'), _('REV')),
395 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
409 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
396 ] + subrepoopts + walkopts,
410 ] + subrepoopts + walkopts,
397 _('[OPTION]... DEST'))
411 _('[OPTION]... DEST'))
398 def archive(ui, repo, dest, **opts):
412 def archive(ui, repo, dest, **opts):
399 '''create an unversioned archive of a repository revision
413 '''create an unversioned archive of a repository revision
400
414
401 By default, the revision used is the parent of the working
415 By default, the revision used is the parent of the working
402 directory; use -r/--rev to specify a different revision.
416 directory; use -r/--rev to specify a different revision.
403
417
404 The archive type is automatically detected based on file
418 The archive type is automatically detected based on file
405 extension (or override using -t/--type).
419 extension (or override using -t/--type).
406
420
407 .. container:: verbose
421 .. container:: verbose
408
422
409 Examples:
423 Examples:
410
424
411 - create a zip file containing the 1.0 release::
425 - create a zip file containing the 1.0 release::
412
426
413 hg archive -r 1.0 project-1.0.zip
427 hg archive -r 1.0 project-1.0.zip
414
428
415 - create a tarball excluding .hg files::
429 - create a tarball excluding .hg files::
416
430
417 hg archive project.tar.gz -X ".hg*"
431 hg archive project.tar.gz -X ".hg*"
418
432
419 Valid types are:
433 Valid types are:
420
434
421 :``files``: a directory full of files (default)
435 :``files``: a directory full of files (default)
422 :``tar``: tar archive, uncompressed
436 :``tar``: tar archive, uncompressed
423 :``tbz2``: tar archive, compressed using bzip2
437 :``tbz2``: tar archive, compressed using bzip2
424 :``tgz``: tar archive, compressed using gzip
438 :``tgz``: tar archive, compressed using gzip
425 :``uzip``: zip archive, uncompressed
439 :``uzip``: zip archive, uncompressed
426 :``zip``: zip archive, compressed using deflate
440 :``zip``: zip archive, compressed using deflate
427
441
428 The exact name of the destination archive or directory is given
442 The exact name of the destination archive or directory is given
429 using a format string; see :hg:`help export` for details.
443 using a format string; see :hg:`help export` for details.
430
444
431 Each member added to an archive file has a directory prefix
445 Each member added to an archive file has a directory prefix
432 prepended. Use -p/--prefix to specify a format string for the
446 prepended. Use -p/--prefix to specify a format string for the
433 prefix. The default is the basename of the archive, with suffixes
447 prefix. The default is the basename of the archive, with suffixes
434 removed.
448 removed.
435
449
436 Returns 0 on success.
450 Returns 0 on success.
437 '''
451 '''
438
452
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
453 ctx = scmutil.revsingle(repo, opts.get('rev'))
440 if not ctx:
454 if not ctx:
441 raise error.Abort(_('no working directory: please specify a revision'))
455 raise error.Abort(_('no working directory: please specify a revision'))
442 node = ctx.node()
456 node = ctx.node()
443 dest = cmdutil.makefilename(repo, dest, node)
457 dest = cmdutil.makefilename(repo, dest, node)
444 if os.path.realpath(dest) == repo.root:
458 if os.path.realpath(dest) == repo.root:
445 raise error.Abort(_('repository root cannot be destination'))
459 raise error.Abort(_('repository root cannot be destination'))
446
460
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
461 kind = opts.get('type') or archival.guesskind(dest) or 'files'
448 prefix = opts.get('prefix')
462 prefix = opts.get('prefix')
449
463
450 if dest == '-':
464 if dest == '-':
451 if kind == 'files':
465 if kind == 'files':
452 raise error.Abort(_('cannot archive plain files to stdout'))
466 raise error.Abort(_('cannot archive plain files to stdout'))
453 dest = cmdutil.makefileobj(repo, dest)
467 dest = cmdutil.makefileobj(repo, dest)
454 if not prefix:
468 if not prefix:
455 prefix = os.path.basename(repo.root) + '-%h'
469 prefix = os.path.basename(repo.root) + '-%h'
456
470
457 prefix = cmdutil.makefilename(repo, prefix, node)
471 prefix = cmdutil.makefilename(repo, prefix, node)
458 matchfn = scmutil.match(ctx, [], opts)
472 matchfn = scmutil.match(ctx, [], opts)
459 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
473 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
460 matchfn, prefix, subrepos=opts.get('subrepos'))
474 matchfn, prefix, subrepos=opts.get('subrepos'))
461
475
462 @command('backout',
476 @command('backout',
463 [('', 'merge', None, _('merge with old dirstate parent after backout')),
477 [('', 'merge', None, _('merge with old dirstate parent after backout')),
464 ('', 'commit', None, _('commit if no conflicts were encountered')),
478 ('', 'commit', None, _('commit if no conflicts were encountered')),
465 ('', 'parent', '',
479 ('', 'parent', '',
466 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
480 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
467 ('r', 'rev', '', _('revision to backout'), _('REV')),
481 ('r', 'rev', '', _('revision to backout'), _('REV')),
468 ('e', 'edit', False, _('invoke editor on commit messages')),
482 ('e', 'edit', False, _('invoke editor on commit messages')),
469 ] + mergetoolopts + walkopts + commitopts + commitopts2,
483 ] + mergetoolopts + walkopts + commitopts + commitopts2,
470 _('[OPTION]... [-r] REV'))
484 _('[OPTION]... [-r] REV'))
471 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
485 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
472 '''reverse effect of earlier changeset
486 '''reverse effect of earlier changeset
473
487
474 Prepare a new changeset with the effect of REV undone in the
488 Prepare a new changeset with the effect of REV undone in the
475 current working directory.
489 current working directory.
476
490
477 If REV is the parent of the working directory, then this new changeset
491 If REV is the parent of the working directory, then this new changeset
478 is committed automatically. Otherwise, hg needs to merge the
492 is committed automatically. Otherwise, hg needs to merge the
479 changes and the merged result is left uncommitted.
493 changes and the merged result is left uncommitted.
480
494
481 .. note::
495 .. note::
482
496
483 backout cannot be used to fix either an unwanted or
497 backout cannot be used to fix either an unwanted or
484 incorrect merge.
498 incorrect merge.
485
499
486 .. container:: verbose
500 .. container:: verbose
487
501
488 Examples:
502 Examples:
489
503
490 - Reverse the effect of the parent of the working directory.
504 - Reverse the effect of the parent of the working directory.
491 This backout will be committed immediately::
505 This backout will be committed immediately::
492
506
493 hg backout -r .
507 hg backout -r .
494
508
495 - Reverse the effect of previous bad revision 23::
509 - Reverse the effect of previous bad revision 23::
496
510
497 hg backout -r 23
511 hg backout -r 23
498 hg commit -m "Backout revision 23"
512 hg commit -m "Backout revision 23"
499
513
500 - Reverse the effect of previous bad revision 23 and
514 - Reverse the effect of previous bad revision 23 and
501 commit the backout immediately::
515 commit the backout immediately::
502
516
503 hg backout -r 23 --commit
517 hg backout -r 23 --commit
504
518
505 By default, the pending changeset will have one parent,
519 By default, the pending changeset will have one parent,
506 maintaining a linear history. With --merge, the pending
520 maintaining a linear history. With --merge, the pending
507 changeset will instead have two parents: the old parent of the
521 changeset will instead have two parents: the old parent of the
508 working directory and a new child of REV that simply undoes REV.
522 working directory and a new child of REV that simply undoes REV.
509
523
510 Before version 1.7, the behavior without --merge was equivalent
524 Before version 1.7, the behavior without --merge was equivalent
511 to specifying --merge followed by :hg:`update --clean .` to
525 to specifying --merge followed by :hg:`update --clean .` to
512 cancel the merge and leave the child of REV as a head to be
526 cancel the merge and leave the child of REV as a head to be
513 merged separately.
527 merged separately.
514
528
515 See :hg:`help dates` for a list of formats valid for -d/--date.
529 See :hg:`help dates` for a list of formats valid for -d/--date.
516
530
517 See :hg:`help revert` for a way to restore files to the state
531 See :hg:`help revert` for a way to restore files to the state
518 of another revision.
532 of another revision.
519
533
520 Returns 0 on success, 1 if nothing to backout or there are unresolved
534 Returns 0 on success, 1 if nothing to backout or there are unresolved
521 files.
535 files.
522 '''
536 '''
523 if rev and node:
537 if rev and node:
524 raise error.Abort(_("please specify just one revision"))
538 raise error.Abort(_("please specify just one revision"))
525
539
526 if not rev:
540 if not rev:
527 rev = node
541 rev = node
528
542
529 if not rev:
543 if not rev:
530 raise error.Abort(_("please specify a revision to backout"))
544 raise error.Abort(_("please specify a revision to backout"))
531
545
532 date = opts.get('date')
546 date = opts.get('date')
533 if date:
547 if date:
534 opts['date'] = util.parsedate(date)
548 opts['date'] = util.parsedate(date)
535
549
536 cmdutil.checkunfinished(repo)
550 cmdutil.checkunfinished(repo)
537 cmdutil.bailifchanged(repo)
551 cmdutil.bailifchanged(repo)
538 node = scmutil.revsingle(repo, rev).node()
552 node = scmutil.revsingle(repo, rev).node()
539
553
540 op1, op2 = repo.dirstate.parents()
554 op1, op2 = repo.dirstate.parents()
541 if not repo.changelog.isancestor(node, op1):
555 if not repo.changelog.isancestor(node, op1):
542 raise error.Abort(_('cannot backout change that is not an ancestor'))
556 raise error.Abort(_('cannot backout change that is not an ancestor'))
543
557
544 p1, p2 = repo.changelog.parents(node)
558 p1, p2 = repo.changelog.parents(node)
545 if p1 == nullid:
559 if p1 == nullid:
546 raise error.Abort(_('cannot backout a change with no parents'))
560 raise error.Abort(_('cannot backout a change with no parents'))
547 if p2 != nullid:
561 if p2 != nullid:
548 if not opts.get('parent'):
562 if not opts.get('parent'):
549 raise error.Abort(_('cannot backout a merge changeset'))
563 raise error.Abort(_('cannot backout a merge changeset'))
550 p = repo.lookup(opts['parent'])
564 p = repo.lookup(opts['parent'])
551 if p not in (p1, p2):
565 if p not in (p1, p2):
552 raise error.Abort(_('%s is not a parent of %s') %
566 raise error.Abort(_('%s is not a parent of %s') %
553 (short(p), short(node)))
567 (short(p), short(node)))
554 parent = p
568 parent = p
555 else:
569 else:
556 if opts.get('parent'):
570 if opts.get('parent'):
557 raise error.Abort(_('cannot use --parent on non-merge changeset'))
571 raise error.Abort(_('cannot use --parent on non-merge changeset'))
558 parent = p1
572 parent = p1
559
573
560 # the backout should appear on the same branch
574 # the backout should appear on the same branch
561 wlock = repo.wlock()
575 wlock = repo.wlock()
562 try:
576 try:
563 branch = repo.dirstate.branch()
577 branch = repo.dirstate.branch()
564 bheads = repo.branchheads(branch)
578 bheads = repo.branchheads(branch)
565 rctx = scmutil.revsingle(repo, hex(parent))
579 rctx = scmutil.revsingle(repo, hex(parent))
566 if not opts.get('merge') and op1 != node:
580 if not opts.get('merge') and op1 != node:
567 dsguard = cmdutil.dirstateguard(repo, 'backout')
581 dsguard = cmdutil.dirstateguard(repo, 'backout')
568 try:
582 try:
569 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
583 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
570 'backout')
584 'backout')
571 stats = mergemod.update(repo, parent, True, True, False,
585 stats = mergemod.update(repo, parent, True, True, False,
572 node, False)
586 node, False)
573 repo.setparents(op1, op2)
587 repo.setparents(op1, op2)
574 dsguard.close()
588 dsguard.close()
575 hg._showstats(repo, stats)
589 hg._showstats(repo, stats)
576 if stats[3]:
590 if stats[3]:
577 repo.ui.status(_("use 'hg resolve' to retry unresolved "
591 repo.ui.status(_("use 'hg resolve' to retry unresolved "
578 "file merges\n"))
592 "file merges\n"))
579 return 1
593 return 1
580 elif not commit:
594 elif not commit:
581 msg = _("changeset %s backed out, "
595 msg = _("changeset %s backed out, "
582 "don't forget to commit.\n")
596 "don't forget to commit.\n")
583 ui.status(msg % short(node))
597 ui.status(msg % short(node))
584 return 0
598 return 0
585 finally:
599 finally:
586 ui.setconfig('ui', 'forcemerge', '', '')
600 ui.setconfig('ui', 'forcemerge', '', '')
587 lockmod.release(dsguard)
601 lockmod.release(dsguard)
588 else:
602 else:
589 hg.clean(repo, node, show_stats=False)
603 hg.clean(repo, node, show_stats=False)
590 repo.dirstate.setbranch(branch)
604 repo.dirstate.setbranch(branch)
591 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
605 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
592
606
593
607
594 def commitfunc(ui, repo, message, match, opts):
608 def commitfunc(ui, repo, message, match, opts):
595 editform = 'backout'
609 editform = 'backout'
596 e = cmdutil.getcommiteditor(editform=editform, **opts)
610 e = cmdutil.getcommiteditor(editform=editform, **opts)
597 if not message:
611 if not message:
598 # we don't translate commit messages
612 # we don't translate commit messages
599 message = "Backed out changeset %s" % short(node)
613 message = "Backed out changeset %s" % short(node)
600 e = cmdutil.getcommiteditor(edit=True, editform=editform)
614 e = cmdutil.getcommiteditor(edit=True, editform=editform)
601 return repo.commit(message, opts.get('user'), opts.get('date'),
615 return repo.commit(message, opts.get('user'), opts.get('date'),
602 match, editor=e)
616 match, editor=e)
603 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
617 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
604 if not newnode:
618 if not newnode:
605 ui.status(_("nothing changed\n"))
619 ui.status(_("nothing changed\n"))
606 return 1
620 return 1
607 cmdutil.commitstatus(repo, newnode, branch, bheads)
621 cmdutil.commitstatus(repo, newnode, branch, bheads)
608
622
609 def nice(node):
623 def nice(node):
610 return '%d:%s' % (repo.changelog.rev(node), short(node))
624 return '%d:%s' % (repo.changelog.rev(node), short(node))
611 ui.status(_('changeset %s backs out changeset %s\n') %
625 ui.status(_('changeset %s backs out changeset %s\n') %
612 (nice(repo.changelog.tip()), nice(node)))
626 (nice(repo.changelog.tip()), nice(node)))
613 if opts.get('merge') and op1 != node:
627 if opts.get('merge') and op1 != node:
614 hg.clean(repo, op1, show_stats=False)
628 hg.clean(repo, op1, show_stats=False)
615 ui.status(_('merging with changeset %s\n')
629 ui.status(_('merging with changeset %s\n')
616 % nice(repo.changelog.tip()))
630 % nice(repo.changelog.tip()))
617 try:
631 try:
618 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
632 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
619 'backout')
633 'backout')
620 return hg.merge(repo, hex(repo.changelog.tip()))
634 return hg.merge(repo, hex(repo.changelog.tip()))
621 finally:
635 finally:
622 ui.setconfig('ui', 'forcemerge', '', '')
636 ui.setconfig('ui', 'forcemerge', '', '')
623 finally:
637 finally:
624 wlock.release()
638 wlock.release()
625 return 0
639 return 0
626
640
627 @command('bisect',
641 @command('bisect',
628 [('r', 'reset', False, _('reset bisect state')),
642 [('r', 'reset', False, _('reset bisect state')),
629 ('g', 'good', False, _('mark changeset good')),
643 ('g', 'good', False, _('mark changeset good')),
630 ('b', 'bad', False, _('mark changeset bad')),
644 ('b', 'bad', False, _('mark changeset bad')),
631 ('s', 'skip', False, _('skip testing changeset')),
645 ('s', 'skip', False, _('skip testing changeset')),
632 ('e', 'extend', False, _('extend the bisect range')),
646 ('e', 'extend', False, _('extend the bisect range')),
633 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
647 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
634 ('U', 'noupdate', False, _('do not update to target'))],
648 ('U', 'noupdate', False, _('do not update to target'))],
635 _("[-gbsr] [-U] [-c CMD] [REV]"))
649 _("[-gbsr] [-U] [-c CMD] [REV]"))
636 def bisect(ui, repo, rev=None, extra=None, command=None,
650 def bisect(ui, repo, rev=None, extra=None, command=None,
637 reset=None, good=None, bad=None, skip=None, extend=None,
651 reset=None, good=None, bad=None, skip=None, extend=None,
638 noupdate=None):
652 noupdate=None):
639 """subdivision search of changesets
653 """subdivision search of changesets
640
654
641 This command helps to find changesets which introduce problems. To
655 This command helps to find changesets which introduce problems. To
642 use, mark the earliest changeset you know exhibits the problem as
656 use, mark the earliest changeset you know exhibits the problem as
643 bad, then mark the latest changeset which is free from the problem
657 bad, then mark the latest changeset which is free from the problem
644 as good. Bisect will update your working directory to a revision
658 as good. Bisect will update your working directory to a revision
645 for testing (unless the -U/--noupdate option is specified). Once
659 for testing (unless the -U/--noupdate option is specified). Once
646 you have performed tests, mark the working directory as good or
660 you have performed tests, mark the working directory as good or
647 bad, and bisect will either update to another candidate changeset
661 bad, and bisect will either update to another candidate changeset
648 or announce that it has found the bad revision.
662 or announce that it has found the bad revision.
649
663
650 As a shortcut, you can also use the revision argument to mark a
664 As a shortcut, you can also use the revision argument to mark a
651 revision as good or bad without checking it out first.
665 revision as good or bad without checking it out first.
652
666
653 If you supply a command, it will be used for automatic bisection.
667 If you supply a command, it will be used for automatic bisection.
654 The environment variable HG_NODE will contain the ID of the
668 The environment variable HG_NODE will contain the ID of the
655 changeset being tested. The exit status of the command will be
669 changeset being tested. The exit status of the command will be
656 used to mark revisions as good or bad: status 0 means good, 125
670 used to mark revisions as good or bad: status 0 means good, 125
657 means to skip the revision, 127 (command not found) will abort the
671 means to skip the revision, 127 (command not found) will abort the
658 bisection, and any other non-zero exit status means the revision
672 bisection, and any other non-zero exit status means the revision
659 is bad.
673 is bad.
660
674
661 .. container:: verbose
675 .. container:: verbose
662
676
663 Some examples:
677 Some examples:
664
678
665 - start a bisection with known bad revision 34, and good revision 12::
679 - start a bisection with known bad revision 34, and good revision 12::
666
680
667 hg bisect --bad 34
681 hg bisect --bad 34
668 hg bisect --good 12
682 hg bisect --good 12
669
683
670 - advance the current bisection by marking current revision as good or
684 - advance the current bisection by marking current revision as good or
671 bad::
685 bad::
672
686
673 hg bisect --good
687 hg bisect --good
674 hg bisect --bad
688 hg bisect --bad
675
689
676 - mark the current revision, or a known revision, to be skipped (e.g. if
690 - mark the current revision, or a known revision, to be skipped (e.g. if
677 that revision is not usable because of another issue)::
691 that revision is not usable because of another issue)::
678
692
679 hg bisect --skip
693 hg bisect --skip
680 hg bisect --skip 23
694 hg bisect --skip 23
681
695
682 - skip all revisions that do not touch directories ``foo`` or ``bar``::
696 - skip all revisions that do not touch directories ``foo`` or ``bar``::
683
697
684 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
698 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
685
699
686 - forget the current bisection::
700 - forget the current bisection::
687
701
688 hg bisect --reset
702 hg bisect --reset
689
703
690 - use 'make && make tests' to automatically find the first broken
704 - use 'make && make tests' to automatically find the first broken
691 revision::
705 revision::
692
706
693 hg bisect --reset
707 hg bisect --reset
694 hg bisect --bad 34
708 hg bisect --bad 34
695 hg bisect --good 12
709 hg bisect --good 12
696 hg bisect --command "make && make tests"
710 hg bisect --command "make && make tests"
697
711
698 - see all changesets whose states are already known in the current
712 - see all changesets whose states are already known in the current
699 bisection::
713 bisection::
700
714
701 hg log -r "bisect(pruned)"
715 hg log -r "bisect(pruned)"
702
716
703 - see the changeset currently being bisected (especially useful
717 - see the changeset currently being bisected (especially useful
704 if running with -U/--noupdate)::
718 if running with -U/--noupdate)::
705
719
706 hg log -r "bisect(current)"
720 hg log -r "bisect(current)"
707
721
708 - see all changesets that took part in the current bisection::
722 - see all changesets that took part in the current bisection::
709
723
710 hg log -r "bisect(range)"
724 hg log -r "bisect(range)"
711
725
712 - you can even get a nice graph::
726 - you can even get a nice graph::
713
727
714 hg log --graph -r "bisect(range)"
728 hg log --graph -r "bisect(range)"
715
729
716 See :hg:`help revsets` for more about the `bisect()` keyword.
730 See :hg:`help revsets` for more about the `bisect()` keyword.
717
731
718 Returns 0 on success.
732 Returns 0 on success.
719 """
733 """
720 def extendbisectrange(nodes, good):
734 def extendbisectrange(nodes, good):
721 # bisect is incomplete when it ends on a merge node and
735 # bisect is incomplete when it ends on a merge node and
722 # one of the parent was not checked.
736 # one of the parent was not checked.
723 parents = repo[nodes[0]].parents()
737 parents = repo[nodes[0]].parents()
724 if len(parents) > 1:
738 if len(parents) > 1:
725 if good:
739 if good:
726 side = state['bad']
740 side = state['bad']
727 else:
741 else:
728 side = state['good']
742 side = state['good']
729 num = len(set(i.node() for i in parents) & set(side))
743 num = len(set(i.node() for i in parents) & set(side))
730 if num == 1:
744 if num == 1:
731 return parents[0].ancestor(parents[1])
745 return parents[0].ancestor(parents[1])
732 return None
746 return None
733
747
734 def print_result(nodes, good):
748 def print_result(nodes, good):
735 displayer = cmdutil.show_changeset(ui, repo, {})
749 displayer = cmdutil.show_changeset(ui, repo, {})
736 if len(nodes) == 1:
750 if len(nodes) == 1:
737 # narrowed it down to a single revision
751 # narrowed it down to a single revision
738 if good:
752 if good:
739 ui.write(_("The first good revision is:\n"))
753 ui.write(_("The first good revision is:\n"))
740 else:
754 else:
741 ui.write(_("The first bad revision is:\n"))
755 ui.write(_("The first bad revision is:\n"))
742 displayer.show(repo[nodes[0]])
756 displayer.show(repo[nodes[0]])
743 extendnode = extendbisectrange(nodes, good)
757 extendnode = extendbisectrange(nodes, good)
744 if extendnode is not None:
758 if extendnode is not None:
745 ui.write(_('Not all ancestors of this changeset have been'
759 ui.write(_('Not all ancestors of this changeset have been'
746 ' checked.\nUse bisect --extend to continue the '
760 ' checked.\nUse bisect --extend to continue the '
747 'bisection from\nthe common ancestor, %s.\n')
761 'bisection from\nthe common ancestor, %s.\n')
748 % extendnode)
762 % extendnode)
749 else:
763 else:
750 # multiple possible revisions
764 # multiple possible revisions
751 if good:
765 if good:
752 ui.write(_("Due to skipped revisions, the first "
766 ui.write(_("Due to skipped revisions, the first "
753 "good revision could be any of:\n"))
767 "good revision could be any of:\n"))
754 else:
768 else:
755 ui.write(_("Due to skipped revisions, the first "
769 ui.write(_("Due to skipped revisions, the first "
756 "bad revision could be any of:\n"))
770 "bad revision could be any of:\n"))
757 for n in nodes:
771 for n in nodes:
758 displayer.show(repo[n])
772 displayer.show(repo[n])
759 displayer.close()
773 displayer.close()
760
774
761 def check_state(state, interactive=True):
775 def check_state(state, interactive=True):
762 if not state['good'] or not state['bad']:
776 if not state['good'] or not state['bad']:
763 if (good or bad or skip or reset) and interactive:
777 if (good or bad or skip or reset) and interactive:
764 return
778 return
765 if not state['good']:
779 if not state['good']:
766 raise error.Abort(_('cannot bisect (no known good revisions)'))
780 raise error.Abort(_('cannot bisect (no known good revisions)'))
767 else:
781 else:
768 raise error.Abort(_('cannot bisect (no known bad revisions)'))
782 raise error.Abort(_('cannot bisect (no known bad revisions)'))
769 return True
783 return True
770
784
771 # backward compatibility
785 # backward compatibility
772 if rev in "good bad reset init".split():
786 if rev in "good bad reset init".split():
773 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
787 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
774 cmd, rev, extra = rev, extra, None
788 cmd, rev, extra = rev, extra, None
775 if cmd == "good":
789 if cmd == "good":
776 good = True
790 good = True
777 elif cmd == "bad":
791 elif cmd == "bad":
778 bad = True
792 bad = True
779 else:
793 else:
780 reset = True
794 reset = True
781 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
795 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
782 raise error.Abort(_('incompatible arguments'))
796 raise error.Abort(_('incompatible arguments'))
783
797
784 cmdutil.checkunfinished(repo)
798 cmdutil.checkunfinished(repo)
785
799
786 if reset:
800 if reset:
787 p = repo.join("bisect.state")
801 p = repo.join("bisect.state")
788 if os.path.exists(p):
802 if os.path.exists(p):
789 os.unlink(p)
803 os.unlink(p)
790 return
804 return
791
805
792 state = hbisect.load_state(repo)
806 state = hbisect.load_state(repo)
793
807
794 if command:
808 if command:
795 changesets = 1
809 changesets = 1
796 if noupdate:
810 if noupdate:
797 try:
811 try:
798 node = state['current'][0]
812 node = state['current'][0]
799 except LookupError:
813 except LookupError:
800 raise error.Abort(_('current bisect revision is unknown - '
814 raise error.Abort(_('current bisect revision is unknown - '
801 'start a new bisect to fix'))
815 'start a new bisect to fix'))
802 else:
816 else:
803 node, p2 = repo.dirstate.parents()
817 node, p2 = repo.dirstate.parents()
804 if p2 != nullid:
818 if p2 != nullid:
805 raise error.Abort(_('current bisect revision is a merge'))
819 raise error.Abort(_('current bisect revision is a merge'))
806 try:
820 try:
807 while changesets:
821 while changesets:
808 # update state
822 # update state
809 state['current'] = [node]
823 state['current'] = [node]
810 hbisect.save_state(repo, state)
824 hbisect.save_state(repo, state)
811 status = ui.system(command, environ={'HG_NODE': hex(node)})
825 status = ui.system(command, environ={'HG_NODE': hex(node)})
812 if status == 125:
826 if status == 125:
813 transition = "skip"
827 transition = "skip"
814 elif status == 0:
828 elif status == 0:
815 transition = "good"
829 transition = "good"
816 # status < 0 means process was killed
830 # status < 0 means process was killed
817 elif status == 127:
831 elif status == 127:
818 raise error.Abort(_("failed to execute %s") % command)
832 raise error.Abort(_("failed to execute %s") % command)
819 elif status < 0:
833 elif status < 0:
820 raise error.Abort(_("%s killed") % command)
834 raise error.Abort(_("%s killed") % command)
821 else:
835 else:
822 transition = "bad"
836 transition = "bad"
823 ctx = scmutil.revsingle(repo, rev, node)
837 ctx = scmutil.revsingle(repo, rev, node)
824 rev = None # clear for future iterations
838 rev = None # clear for future iterations
825 state[transition].append(ctx.node())
839 state[transition].append(ctx.node())
826 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
840 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
827 check_state(state, interactive=False)
841 check_state(state, interactive=False)
828 # bisect
842 # bisect
829 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
843 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
830 # update to next check
844 # update to next check
831 node = nodes[0]
845 node = nodes[0]
832 if not noupdate:
846 if not noupdate:
833 cmdutil.bailifchanged(repo)
847 cmdutil.bailifchanged(repo)
834 hg.clean(repo, node, show_stats=False)
848 hg.clean(repo, node, show_stats=False)
835 finally:
849 finally:
836 state['current'] = [node]
850 state['current'] = [node]
837 hbisect.save_state(repo, state)
851 hbisect.save_state(repo, state)
838 print_result(nodes, bgood)
852 print_result(nodes, bgood)
839 return
853 return
840
854
841 # update state
855 # update state
842
856
843 if rev:
857 if rev:
844 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
858 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
845 else:
859 else:
846 nodes = [repo.lookup('.')]
860 nodes = [repo.lookup('.')]
847
861
848 if good or bad or skip:
862 if good or bad or skip:
849 if good:
863 if good:
850 state['good'] += nodes
864 state['good'] += nodes
851 elif bad:
865 elif bad:
852 state['bad'] += nodes
866 state['bad'] += nodes
853 elif skip:
867 elif skip:
854 state['skip'] += nodes
868 state['skip'] += nodes
855 hbisect.save_state(repo, state)
869 hbisect.save_state(repo, state)
856
870
857 if not check_state(state):
871 if not check_state(state):
858 return
872 return
859
873
860 # actually bisect
874 # actually bisect
861 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
875 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
862 if extend:
876 if extend:
863 if not changesets:
877 if not changesets:
864 extendnode = extendbisectrange(nodes, good)
878 extendnode = extendbisectrange(nodes, good)
865 if extendnode is not None:
879 if extendnode is not None:
866 ui.write(_("Extending search to changeset %d:%s\n")
880 ui.write(_("Extending search to changeset %d:%s\n")
867 % (extendnode.rev(), extendnode))
881 % (extendnode.rev(), extendnode))
868 state['current'] = [extendnode.node()]
882 state['current'] = [extendnode.node()]
869 hbisect.save_state(repo, state)
883 hbisect.save_state(repo, state)
870 if noupdate:
884 if noupdate:
871 return
885 return
872 cmdutil.bailifchanged(repo)
886 cmdutil.bailifchanged(repo)
873 return hg.clean(repo, extendnode.node())
887 return hg.clean(repo, extendnode.node())
874 raise error.Abort(_("nothing to extend"))
888 raise error.Abort(_("nothing to extend"))
875
889
876 if changesets == 0:
890 if changesets == 0:
877 print_result(nodes, good)
891 print_result(nodes, good)
878 else:
892 else:
879 assert len(nodes) == 1 # only a single node can be tested next
893 assert len(nodes) == 1 # only a single node can be tested next
880 node = nodes[0]
894 node = nodes[0]
881 # compute the approximate number of remaining tests
895 # compute the approximate number of remaining tests
882 tests, size = 0, 2
896 tests, size = 0, 2
883 while size <= changesets:
897 while size <= changesets:
884 tests, size = tests + 1, size * 2
898 tests, size = tests + 1, size * 2
885 rev = repo.changelog.rev(node)
899 rev = repo.changelog.rev(node)
886 ui.write(_("Testing changeset %d:%s "
900 ui.write(_("Testing changeset %d:%s "
887 "(%d changesets remaining, ~%d tests)\n")
901 "(%d changesets remaining, ~%d tests)\n")
888 % (rev, short(node), changesets, tests))
902 % (rev, short(node), changesets, tests))
889 state['current'] = [node]
903 state['current'] = [node]
890 hbisect.save_state(repo, state)
904 hbisect.save_state(repo, state)
891 if not noupdate:
905 if not noupdate:
892 cmdutil.bailifchanged(repo)
906 cmdutil.bailifchanged(repo)
893 return hg.clean(repo, node)
907 return hg.clean(repo, node)
894
908
895 @command('bookmarks|bookmark',
909 @command('bookmarks|bookmark',
896 [('f', 'force', False, _('force')),
910 [('f', 'force', False, _('force')),
897 ('r', 'rev', '', _('revision'), _('REV')),
911 ('r', 'rev', '', _('revision'), _('REV')),
898 ('d', 'delete', False, _('delete a given bookmark')),
912 ('d', 'delete', False, _('delete a given bookmark')),
899 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
913 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
900 ('i', 'inactive', False, _('mark a bookmark inactive')),
914 ('i', 'inactive', False, _('mark a bookmark inactive')),
901 ] + formatteropts,
915 ] + formatteropts,
902 _('hg bookmarks [OPTIONS]... [NAME]...'))
916 _('hg bookmarks [OPTIONS]... [NAME]...'))
903 def bookmark(ui, repo, *names, **opts):
917 def bookmark(ui, repo, *names, **opts):
904 '''create a new bookmark or list existing bookmarks
918 '''create a new bookmark or list existing bookmarks
905
919
906 Bookmarks are labels on changesets to help track lines of development.
920 Bookmarks are labels on changesets to help track lines of development.
907 Bookmarks are unversioned and can be moved, renamed and deleted.
921 Bookmarks are unversioned and can be moved, renamed and deleted.
908 Deleting or moving a bookmark has no effect on the associated changesets.
922 Deleting or moving a bookmark has no effect on the associated changesets.
909
923
910 Creating or updating to a bookmark causes it to be marked as 'active'.
924 Creating or updating to a bookmark causes it to be marked as 'active'.
911 The active bookmark is indicated with a '*'.
925 The active bookmark is indicated with a '*'.
912 When a commit is made, the active bookmark will advance to the new commit.
926 When a commit is made, the active bookmark will advance to the new commit.
913 A plain :hg:`update` will also advance an active bookmark, if possible.
927 A plain :hg:`update` will also advance an active bookmark, if possible.
914 Updating away from a bookmark will cause it to be deactivated.
928 Updating away from a bookmark will cause it to be deactivated.
915
929
916 Bookmarks can be pushed and pulled between repositories (see
930 Bookmarks can be pushed and pulled between repositories (see
917 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
931 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
918 diverged, a new 'divergent bookmark' of the form 'name@path' will
932 diverged, a new 'divergent bookmark' of the form 'name@path' will
919 be created. Using :hg:`merge` will resolve the divergence.
933 be created. Using :hg:`merge` will resolve the divergence.
920
934
921 A bookmark named '@' has the special property that :hg:`clone` will
935 A bookmark named '@' has the special property that :hg:`clone` will
922 check it out by default if it exists.
936 check it out by default if it exists.
923
937
924 .. container:: verbose
938 .. container:: verbose
925
939
926 Examples:
940 Examples:
927
941
928 - create an active bookmark for a new line of development::
942 - create an active bookmark for a new line of development::
929
943
930 hg book new-feature
944 hg book new-feature
931
945
932 - create an inactive bookmark as a place marker::
946 - create an inactive bookmark as a place marker::
933
947
934 hg book -i reviewed
948 hg book -i reviewed
935
949
936 - create an inactive bookmark on another changeset::
950 - create an inactive bookmark on another changeset::
937
951
938 hg book -r .^ tested
952 hg book -r .^ tested
939
953
940 - rename bookmark turkey to dinner::
954 - rename bookmark turkey to dinner::
941
955
942 hg book -m turkey dinner
956 hg book -m turkey dinner
943
957
944 - move the '@' bookmark from another branch::
958 - move the '@' bookmark from another branch::
945
959
946 hg book -f @
960 hg book -f @
947 '''
961 '''
948 force = opts.get('force')
962 force = opts.get('force')
949 rev = opts.get('rev')
963 rev = opts.get('rev')
950 delete = opts.get('delete')
964 delete = opts.get('delete')
951 rename = opts.get('rename')
965 rename = opts.get('rename')
952 inactive = opts.get('inactive')
966 inactive = opts.get('inactive')
953
967
954 def checkformat(mark):
968 def checkformat(mark):
955 mark = mark.strip()
969 mark = mark.strip()
956 if not mark:
970 if not mark:
957 raise error.Abort(_("bookmark names cannot consist entirely of "
971 raise error.Abort(_("bookmark names cannot consist entirely of "
958 "whitespace"))
972 "whitespace"))
959 scmutil.checknewlabel(repo, mark, 'bookmark')
973 scmutil.checknewlabel(repo, mark, 'bookmark')
960 return mark
974 return mark
961
975
962 def checkconflict(repo, mark, cur, force=False, target=None):
976 def checkconflict(repo, mark, cur, force=False, target=None):
963 if mark in marks and not force:
977 if mark in marks and not force:
964 if target:
978 if target:
965 if marks[mark] == target and target == cur:
979 if marks[mark] == target and target == cur:
966 # re-activating a bookmark
980 # re-activating a bookmark
967 return
981 return
968 anc = repo.changelog.ancestors([repo[target].rev()])
982 anc = repo.changelog.ancestors([repo[target].rev()])
969 bmctx = repo[marks[mark]]
983 bmctx = repo[marks[mark]]
970 divs = [repo[b].node() for b in marks
984 divs = [repo[b].node() for b in marks
971 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
985 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
972
986
973 # allow resolving a single divergent bookmark even if moving
987 # allow resolving a single divergent bookmark even if moving
974 # the bookmark across branches when a revision is specified
988 # the bookmark across branches when a revision is specified
975 # that contains a divergent bookmark
989 # that contains a divergent bookmark
976 if bmctx.rev() not in anc and target in divs:
990 if bmctx.rev() not in anc and target in divs:
977 bookmarks.deletedivergent(repo, [target], mark)
991 bookmarks.deletedivergent(repo, [target], mark)
978 return
992 return
979
993
980 deletefrom = [b for b in divs
994 deletefrom = [b for b in divs
981 if repo[b].rev() in anc or b == target]
995 if repo[b].rev() in anc or b == target]
982 bookmarks.deletedivergent(repo, deletefrom, mark)
996 bookmarks.deletedivergent(repo, deletefrom, mark)
983 if bookmarks.validdest(repo, bmctx, repo[target]):
997 if bookmarks.validdest(repo, bmctx, repo[target]):
984 ui.status(_("moving bookmark '%s' forward from %s\n") %
998 ui.status(_("moving bookmark '%s' forward from %s\n") %
985 (mark, short(bmctx.node())))
999 (mark, short(bmctx.node())))
986 return
1000 return
987 raise error.Abort(_("bookmark '%s' already exists "
1001 raise error.Abort(_("bookmark '%s' already exists "
988 "(use -f to force)") % mark)
1002 "(use -f to force)") % mark)
989 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1003 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
990 and not force):
1004 and not force):
991 raise error.Abort(
1005 raise error.Abort(
992 _("a bookmark cannot have the name of an existing branch"))
1006 _("a bookmark cannot have the name of an existing branch"))
993
1007
994 if delete and rename:
1008 if delete and rename:
995 raise error.Abort(_("--delete and --rename are incompatible"))
1009 raise error.Abort(_("--delete and --rename are incompatible"))
996 if delete and rev:
1010 if delete and rev:
997 raise error.Abort(_("--rev is incompatible with --delete"))
1011 raise error.Abort(_("--rev is incompatible with --delete"))
998 if rename and rev:
1012 if rename and rev:
999 raise error.Abort(_("--rev is incompatible with --rename"))
1013 raise error.Abort(_("--rev is incompatible with --rename"))
1000 if not names and (delete or rev):
1014 if not names and (delete or rev):
1001 raise error.Abort(_("bookmark name required"))
1015 raise error.Abort(_("bookmark name required"))
1002
1016
1003 if delete or rename or names or inactive:
1017 if delete or rename or names or inactive:
1004 wlock = lock = tr = None
1018 wlock = lock = tr = None
1005 try:
1019 try:
1006 wlock = repo.wlock()
1020 wlock = repo.wlock()
1007 lock = repo.lock()
1021 lock = repo.lock()
1008 cur = repo.changectx('.').node()
1022 cur = repo.changectx('.').node()
1009 marks = repo._bookmarks
1023 marks = repo._bookmarks
1010 if delete:
1024 if delete:
1011 tr = repo.transaction('bookmark')
1025 tr = repo.transaction('bookmark')
1012 for mark in names:
1026 for mark in names:
1013 if mark not in marks:
1027 if mark not in marks:
1014 raise error.Abort(_("bookmark '%s' does not exist") %
1028 raise error.Abort(_("bookmark '%s' does not exist") %
1015 mark)
1029 mark)
1016 if mark == repo._activebookmark:
1030 if mark == repo._activebookmark:
1017 bookmarks.deactivate(repo)
1031 bookmarks.deactivate(repo)
1018 del marks[mark]
1032 del marks[mark]
1019
1033
1020 elif rename:
1034 elif rename:
1021 tr = repo.transaction('bookmark')
1035 tr = repo.transaction('bookmark')
1022 if not names:
1036 if not names:
1023 raise error.Abort(_("new bookmark name required"))
1037 raise error.Abort(_("new bookmark name required"))
1024 elif len(names) > 1:
1038 elif len(names) > 1:
1025 raise error.Abort(_("only one new bookmark name allowed"))
1039 raise error.Abort(_("only one new bookmark name allowed"))
1026 mark = checkformat(names[0])
1040 mark = checkformat(names[0])
1027 if rename not in marks:
1041 if rename not in marks:
1028 raise error.Abort(_("bookmark '%s' does not exist")
1042 raise error.Abort(_("bookmark '%s' does not exist")
1029 % rename)
1043 % rename)
1030 checkconflict(repo, mark, cur, force)
1044 checkconflict(repo, mark, cur, force)
1031 marks[mark] = marks[rename]
1045 marks[mark] = marks[rename]
1032 if repo._activebookmark == rename and not inactive:
1046 if repo._activebookmark == rename and not inactive:
1033 bookmarks.activate(repo, mark)
1047 bookmarks.activate(repo, mark)
1034 del marks[rename]
1048 del marks[rename]
1035 elif names:
1049 elif names:
1036 tr = repo.transaction('bookmark')
1050 tr = repo.transaction('bookmark')
1037 newact = None
1051 newact = None
1038 for mark in names:
1052 for mark in names:
1039 mark = checkformat(mark)
1053 mark = checkformat(mark)
1040 if newact is None:
1054 if newact is None:
1041 newact = mark
1055 newact = mark
1042 if inactive and mark == repo._activebookmark:
1056 if inactive and mark == repo._activebookmark:
1043 bookmarks.deactivate(repo)
1057 bookmarks.deactivate(repo)
1044 return
1058 return
1045 tgt = cur
1059 tgt = cur
1046 if rev:
1060 if rev:
1047 tgt = scmutil.revsingle(repo, rev).node()
1061 tgt = scmutil.revsingle(repo, rev).node()
1048 checkconflict(repo, mark, cur, force, tgt)
1062 checkconflict(repo, mark, cur, force, tgt)
1049 marks[mark] = tgt
1063 marks[mark] = tgt
1050 if not inactive and cur == marks[newact] and not rev:
1064 if not inactive and cur == marks[newact] and not rev:
1051 bookmarks.activate(repo, newact)
1065 bookmarks.activate(repo, newact)
1052 elif cur != tgt and newact == repo._activebookmark:
1066 elif cur != tgt and newact == repo._activebookmark:
1053 bookmarks.deactivate(repo)
1067 bookmarks.deactivate(repo)
1054 elif inactive:
1068 elif inactive:
1055 if len(marks) == 0:
1069 if len(marks) == 0:
1056 ui.status(_("no bookmarks set\n"))
1070 ui.status(_("no bookmarks set\n"))
1057 elif not repo._activebookmark:
1071 elif not repo._activebookmark:
1058 ui.status(_("no active bookmark\n"))
1072 ui.status(_("no active bookmark\n"))
1059 else:
1073 else:
1060 bookmarks.deactivate(repo)
1074 bookmarks.deactivate(repo)
1061 if tr is not None:
1075 if tr is not None:
1062 marks.recordchange(tr)
1076 marks.recordchange(tr)
1063 tr.close()
1077 tr.close()
1064 finally:
1078 finally:
1065 lockmod.release(tr, lock, wlock)
1079 lockmod.release(tr, lock, wlock)
1066 else: # show bookmarks
1080 else: # show bookmarks
1067 fm = ui.formatter('bookmarks', opts)
1081 fm = ui.formatter('bookmarks', opts)
1068 hexfn = fm.hexfunc
1082 hexfn = fm.hexfunc
1069 marks = repo._bookmarks
1083 marks = repo._bookmarks
1070 if len(marks) == 0 and not fm:
1084 if len(marks) == 0 and not fm:
1071 ui.status(_("no bookmarks set\n"))
1085 ui.status(_("no bookmarks set\n"))
1072 for bmark, n in sorted(marks.iteritems()):
1086 for bmark, n in sorted(marks.iteritems()):
1073 active = repo._activebookmark
1087 active = repo._activebookmark
1074 if bmark == active:
1088 if bmark == active:
1075 prefix, label = '*', activebookmarklabel
1089 prefix, label = '*', activebookmarklabel
1076 else:
1090 else:
1077 prefix, label = ' ', ''
1091 prefix, label = ' ', ''
1078
1092
1079 fm.startitem()
1093 fm.startitem()
1080 if not ui.quiet:
1094 if not ui.quiet:
1081 fm.plain(' %s ' % prefix, label=label)
1095 fm.plain(' %s ' % prefix, label=label)
1082 fm.write('bookmark', '%s', bmark, label=label)
1096 fm.write('bookmark', '%s', bmark, label=label)
1083 pad = " " * (25 - encoding.colwidth(bmark))
1097 pad = " " * (25 - encoding.colwidth(bmark))
1084 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1098 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1085 repo.changelog.rev(n), hexfn(n), label=label)
1099 repo.changelog.rev(n), hexfn(n), label=label)
1086 fm.data(active=(bmark == active))
1100 fm.data(active=(bmark == active))
1087 fm.plain('\n')
1101 fm.plain('\n')
1088 fm.end()
1102 fm.end()
1089
1103
1090 @command('branch',
1104 @command('branch',
1091 [('f', 'force', None,
1105 [('f', 'force', None,
1092 _('set branch name even if it shadows an existing branch')),
1106 _('set branch name even if it shadows an existing branch')),
1093 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1107 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1094 _('[-fC] [NAME]'))
1108 _('[-fC] [NAME]'))
1095 def branch(ui, repo, label=None, **opts):
1109 def branch(ui, repo, label=None, **opts):
1096 """set or show the current branch name
1110 """set or show the current branch name
1097
1111
1098 .. note::
1112 .. note::
1099
1113
1100 Branch names are permanent and global. Use :hg:`bookmark` to create a
1114 Branch names are permanent and global. Use :hg:`bookmark` to create a
1101 light-weight bookmark instead. See :hg:`help glossary` for more
1115 light-weight bookmark instead. See :hg:`help glossary` for more
1102 information about named branches and bookmarks.
1116 information about named branches and bookmarks.
1103
1117
1104 With no argument, show the current branch name. With one argument,
1118 With no argument, show the current branch name. With one argument,
1105 set the working directory branch name (the branch will not exist
1119 set the working directory branch name (the branch will not exist
1106 in the repository until the next commit). Standard practice
1120 in the repository until the next commit). Standard practice
1107 recommends that primary development take place on the 'default'
1121 recommends that primary development take place on the 'default'
1108 branch.
1122 branch.
1109
1123
1110 Unless -f/--force is specified, branch will not let you set a
1124 Unless -f/--force is specified, branch will not let you set a
1111 branch name that already exists.
1125 branch name that already exists.
1112
1126
1113 Use -C/--clean to reset the working directory branch to that of
1127 Use -C/--clean to reset the working directory branch to that of
1114 the parent of the working directory, negating a previous branch
1128 the parent of the working directory, negating a previous branch
1115 change.
1129 change.
1116
1130
1117 Use the command :hg:`update` to switch to an existing branch. Use
1131 Use the command :hg:`update` to switch to an existing branch. Use
1118 :hg:`commit --close-branch` to mark this branch head as closed.
1132 :hg:`commit --close-branch` to mark this branch head as closed.
1119 When all heads of the branch are closed, the branch will be
1133 When all heads of the branch are closed, the branch will be
1120 considered closed.
1134 considered closed.
1121
1135
1122 Returns 0 on success.
1136 Returns 0 on success.
1123 """
1137 """
1124 if label:
1138 if label:
1125 label = label.strip()
1139 label = label.strip()
1126
1140
1127 if not opts.get('clean') and not label:
1141 if not opts.get('clean') and not label:
1128 ui.write("%s\n" % repo.dirstate.branch())
1142 ui.write("%s\n" % repo.dirstate.branch())
1129 return
1143 return
1130
1144
1131 wlock = repo.wlock()
1145 wlock = repo.wlock()
1132 try:
1146 try:
1133 if opts.get('clean'):
1147 if opts.get('clean'):
1134 label = repo[None].p1().branch()
1148 label = repo[None].p1().branch()
1135 repo.dirstate.setbranch(label)
1149 repo.dirstate.setbranch(label)
1136 ui.status(_('reset working directory to branch %s\n') % label)
1150 ui.status(_('reset working directory to branch %s\n') % label)
1137 elif label:
1151 elif label:
1138 if not opts.get('force') and label in repo.branchmap():
1152 if not opts.get('force') and label in repo.branchmap():
1139 if label not in [p.branch() for p in repo.parents()]:
1153 if label not in [p.branch() for p in repo.parents()]:
1140 raise error.Abort(_('a branch of the same name already'
1154 raise error.Abort(_('a branch of the same name already'
1141 ' exists'),
1155 ' exists'),
1142 # i18n: "it" refers to an existing branch
1156 # i18n: "it" refers to an existing branch
1143 hint=_("use 'hg update' to switch to it"))
1157 hint=_("use 'hg update' to switch to it"))
1144 scmutil.checknewlabel(repo, label, 'branch')
1158 scmutil.checknewlabel(repo, label, 'branch')
1145 repo.dirstate.setbranch(label)
1159 repo.dirstate.setbranch(label)
1146 ui.status(_('marked working directory as branch %s\n') % label)
1160 ui.status(_('marked working directory as branch %s\n') % label)
1147
1161
1148 # find any open named branches aside from default
1162 # find any open named branches aside from default
1149 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1163 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1150 if n != "default" and not c]
1164 if n != "default" and not c]
1151 if not others:
1165 if not others:
1152 ui.status(_('(branches are permanent and global, '
1166 ui.status(_('(branches are permanent and global, '
1153 'did you want a bookmark?)\n'))
1167 'did you want a bookmark?)\n'))
1154 finally:
1168 finally:
1155 wlock.release()
1169 wlock.release()
1156
1170
1157 @command('branches',
1171 @command('branches',
1158 [('a', 'active', False,
1172 [('a', 'active', False,
1159 _('show only branches that have unmerged heads (DEPRECATED)')),
1173 _('show only branches that have unmerged heads (DEPRECATED)')),
1160 ('c', 'closed', False, _('show normal and closed branches')),
1174 ('c', 'closed', False, _('show normal and closed branches')),
1161 ] + formatteropts,
1175 ] + formatteropts,
1162 _('[-ac]'))
1176 _('[-ac]'))
1163 def branches(ui, repo, active=False, closed=False, **opts):
1177 def branches(ui, repo, active=False, closed=False, **opts):
1164 """list repository named branches
1178 """list repository named branches
1165
1179
1166 List the repository's named branches, indicating which ones are
1180 List the repository's named branches, indicating which ones are
1167 inactive. If -c/--closed is specified, also list branches which have
1181 inactive. If -c/--closed is specified, also list branches which have
1168 been marked closed (see :hg:`commit --close-branch`).
1182 been marked closed (see :hg:`commit --close-branch`).
1169
1183
1170 Use the command :hg:`update` to switch to an existing branch.
1184 Use the command :hg:`update` to switch to an existing branch.
1171
1185
1172 Returns 0.
1186 Returns 0.
1173 """
1187 """
1174
1188
1175 fm = ui.formatter('branches', opts)
1189 fm = ui.formatter('branches', opts)
1176 hexfunc = fm.hexfunc
1190 hexfunc = fm.hexfunc
1177
1191
1178 allheads = set(repo.heads())
1192 allheads = set(repo.heads())
1179 branches = []
1193 branches = []
1180 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1194 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1181 isactive = not isclosed and bool(set(heads) & allheads)
1195 isactive = not isclosed and bool(set(heads) & allheads)
1182 branches.append((tag, repo[tip], isactive, not isclosed))
1196 branches.append((tag, repo[tip], isactive, not isclosed))
1183 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1197 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1184 reverse=True)
1198 reverse=True)
1185
1199
1186 for tag, ctx, isactive, isopen in branches:
1200 for tag, ctx, isactive, isopen in branches:
1187 if active and not isactive:
1201 if active and not isactive:
1188 continue
1202 continue
1189 if isactive:
1203 if isactive:
1190 label = 'branches.active'
1204 label = 'branches.active'
1191 notice = ''
1205 notice = ''
1192 elif not isopen:
1206 elif not isopen:
1193 if not closed:
1207 if not closed:
1194 continue
1208 continue
1195 label = 'branches.closed'
1209 label = 'branches.closed'
1196 notice = _(' (closed)')
1210 notice = _(' (closed)')
1197 else:
1211 else:
1198 label = 'branches.inactive'
1212 label = 'branches.inactive'
1199 notice = _(' (inactive)')
1213 notice = _(' (inactive)')
1200 current = (tag == repo.dirstate.branch())
1214 current = (tag == repo.dirstate.branch())
1201 if current:
1215 if current:
1202 label = 'branches.current'
1216 label = 'branches.current'
1203
1217
1204 fm.startitem()
1218 fm.startitem()
1205 fm.write('branch', '%s', tag, label=label)
1219 fm.write('branch', '%s', tag, label=label)
1206 rev = ctx.rev()
1220 rev = ctx.rev()
1207 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1221 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1208 fmt = ' ' * padsize + ' %d:%s'
1222 fmt = ' ' * padsize + ' %d:%s'
1209 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1223 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1210 label='log.changeset changeset.%s' % ctx.phasestr())
1224 label='log.changeset changeset.%s' % ctx.phasestr())
1211 fm.data(active=isactive, closed=not isopen, current=current)
1225 fm.data(active=isactive, closed=not isopen, current=current)
1212 if not ui.quiet:
1226 if not ui.quiet:
1213 fm.plain(notice)
1227 fm.plain(notice)
1214 fm.plain('\n')
1228 fm.plain('\n')
1215 fm.end()
1229 fm.end()
1216
1230
1217 @command('bundle',
1231 @command('bundle',
1218 [('f', 'force', None, _('run even when the destination is unrelated')),
1232 [('f', 'force', None, _('run even when the destination is unrelated')),
1219 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1233 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1220 _('REV')),
1234 _('REV')),
1221 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1235 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1222 _('BRANCH')),
1236 _('BRANCH')),
1223 ('', 'base', [],
1237 ('', 'base', [],
1224 _('a base changeset assumed to be available at the destination'),
1238 _('a base changeset assumed to be available at the destination'),
1225 _('REV')),
1239 _('REV')),
1226 ('a', 'all', None, _('bundle all changesets in the repository')),
1240 ('a', 'all', None, _('bundle all changesets in the repository')),
1227 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1241 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1228 ] + remoteopts,
1242 ] + remoteopts,
1229 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1243 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1230 def bundle(ui, repo, fname, dest=None, **opts):
1244 def bundle(ui, repo, fname, dest=None, **opts):
1231 """create a changegroup file
1245 """create a changegroup file
1232
1246
1233 Generate a compressed changegroup file collecting changesets not
1247 Generate a compressed changegroup file collecting changesets not
1234 known to be in another repository.
1248 known to be in another repository.
1235
1249
1236 If you omit the destination repository, then hg assumes the
1250 If you omit the destination repository, then hg assumes the
1237 destination will have all the nodes you specify with --base
1251 destination will have all the nodes you specify with --base
1238 parameters. To create a bundle containing all changesets, use
1252 parameters. To create a bundle containing all changesets, use
1239 -a/--all (or --base null).
1253 -a/--all (or --base null).
1240
1254
1241 You can change bundle format with the -t/--type option. You can
1255 You can change bundle format with the -t/--type option. You can
1242 specify a compression, a bundle version or both using a dash
1256 specify a compression, a bundle version or both using a dash
1243 (comp-version). The available compression methods are: none, bzip2,
1257 (comp-version). The available compression methods are: none, bzip2,
1244 and gzip (by default, bundles are compressed using bzip2). The
1258 and gzip (by default, bundles are compressed using bzip2). The
1245 available format are: v1, v2 (default to most suitable).
1259 available format are: v1, v2 (default to most suitable).
1246
1260
1247 The bundle file can then be transferred using conventional means
1261 The bundle file can then be transferred using conventional means
1248 and applied to another repository with the unbundle or pull
1262 and applied to another repository with the unbundle or pull
1249 command. This is useful when direct push and pull are not
1263 command. This is useful when direct push and pull are not
1250 available or when exporting an entire repository is undesirable.
1264 available or when exporting an entire repository is undesirable.
1251
1265
1252 Applying bundles preserves all changeset contents including
1266 Applying bundles preserves all changeset contents including
1253 permissions, copy/rename information, and revision history.
1267 permissions, copy/rename information, and revision history.
1254
1268
1255 Returns 0 on success, 1 if no changes found.
1269 Returns 0 on success, 1 if no changes found.
1256 """
1270 """
1257 revs = None
1271 revs = None
1258 if 'rev' in opts:
1272 if 'rev' in opts:
1259 revs = scmutil.revrange(repo, opts['rev'])
1273 revs = scmutil.revrange(repo, opts['rev'])
1260
1274
1261 bundletype = opts.get('type', 'bzip2').lower()
1275 bundletype = opts.get('type', 'bzip2').lower()
1262 try:
1276 try:
1263 bcompression, cgversion, params = exchange.parsebundlespec(
1277 bcompression, cgversion, params = exchange.parsebundlespec(
1264 repo, bundletype, strict=False)
1278 repo, bundletype, strict=False)
1265 except error.UnsupportedBundleSpecification as e:
1279 except error.UnsupportedBundleSpecification as e:
1266 raise error.Abort(str(e),
1280 raise error.Abort(str(e),
1267 hint=_('see "hg help bundle" for supported '
1281 hint=_('see "hg help bundle" for supported '
1268 'values for --type'))
1282 'values for --type'))
1269
1283
1270 # Packed bundles are a pseudo bundle format for now.
1284 # Packed bundles are a pseudo bundle format for now.
1271 if cgversion == 's1':
1285 if cgversion == 's1':
1272 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1286 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1273 hint=_('use "hg debugcreatestreamclonebundle"'))
1287 hint=_('use "hg debugcreatestreamclonebundle"'))
1274
1288
1275 if opts.get('all'):
1289 if opts.get('all'):
1276 base = ['null']
1290 base = ['null']
1277 else:
1291 else:
1278 base = scmutil.revrange(repo, opts.get('base'))
1292 base = scmutil.revrange(repo, opts.get('base'))
1279 # TODO: get desired bundlecaps from command line.
1293 # TODO: get desired bundlecaps from command line.
1280 bundlecaps = None
1294 bundlecaps = None
1281 if base:
1295 if base:
1282 if dest:
1296 if dest:
1283 raise error.Abort(_("--base is incompatible with specifying "
1297 raise error.Abort(_("--base is incompatible with specifying "
1284 "a destination"))
1298 "a destination"))
1285 common = [repo.lookup(rev) for rev in base]
1299 common = [repo.lookup(rev) for rev in base]
1286 heads = revs and map(repo.lookup, revs) or revs
1300 heads = revs and map(repo.lookup, revs) or revs
1287 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1301 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1288 common=common, bundlecaps=bundlecaps,
1302 common=common, bundlecaps=bundlecaps,
1289 version=cgversion)
1303 version=cgversion)
1290 outgoing = None
1304 outgoing = None
1291 else:
1305 else:
1292 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1306 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1293 dest, branches = hg.parseurl(dest, opts.get('branch'))
1307 dest, branches = hg.parseurl(dest, opts.get('branch'))
1294 other = hg.peer(repo, opts, dest)
1308 other = hg.peer(repo, opts, dest)
1295 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1309 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1296 heads = revs and map(repo.lookup, revs) or revs
1310 heads = revs and map(repo.lookup, revs) or revs
1297 outgoing = discovery.findcommonoutgoing(repo, other,
1311 outgoing = discovery.findcommonoutgoing(repo, other,
1298 onlyheads=heads,
1312 onlyheads=heads,
1299 force=opts.get('force'),
1313 force=opts.get('force'),
1300 portable=True)
1314 portable=True)
1301 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1315 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1302 bundlecaps, version=cgversion)
1316 bundlecaps, version=cgversion)
1303 if not cg:
1317 if not cg:
1304 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1318 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1305 return 1
1319 return 1
1306
1320
1307 if cgversion == '01': #bundle1
1321 if cgversion == '01': #bundle1
1308 if bcompression is None:
1322 if bcompression is None:
1309 bcompression = 'UN'
1323 bcompression = 'UN'
1310 bversion = 'HG10' + bcompression
1324 bversion = 'HG10' + bcompression
1311 bcompression = None
1325 bcompression = None
1312 else:
1326 else:
1313 assert cgversion == '02'
1327 assert cgversion == '02'
1314 bversion = 'HG20'
1328 bversion = 'HG20'
1315
1329
1316
1330
1317 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1331 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1318
1332
1319 @command('cat',
1333 @command('cat',
1320 [('o', 'output', '',
1334 [('o', 'output', '',
1321 _('print output to file with formatted name'), _('FORMAT')),
1335 _('print output to file with formatted name'), _('FORMAT')),
1322 ('r', 'rev', '', _('print the given revision'), _('REV')),
1336 ('r', 'rev', '', _('print the given revision'), _('REV')),
1323 ('', 'decode', None, _('apply any matching decode filter')),
1337 ('', 'decode', None, _('apply any matching decode filter')),
1324 ] + walkopts,
1338 ] + walkopts,
1325 _('[OPTION]... FILE...'),
1339 _('[OPTION]... FILE...'),
1326 inferrepo=True)
1340 inferrepo=True)
1327 def cat(ui, repo, file1, *pats, **opts):
1341 def cat(ui, repo, file1, *pats, **opts):
1328 """output the current or given revision of files
1342 """output the current or given revision of files
1329
1343
1330 Print the specified files as they were at the given revision. If
1344 Print the specified files as they were at the given revision. If
1331 no revision is given, the parent of the working directory is used.
1345 no revision is given, the parent of the working directory is used.
1332
1346
1333 Output may be to a file, in which case the name of the file is
1347 Output may be to a file, in which case the name of the file is
1334 given using a format string. The formatting rules as follows:
1348 given using a format string. The formatting rules as follows:
1335
1349
1336 :``%%``: literal "%" character
1350 :``%%``: literal "%" character
1337 :``%s``: basename of file being printed
1351 :``%s``: basename of file being printed
1338 :``%d``: dirname of file being printed, or '.' if in repository root
1352 :``%d``: dirname of file being printed, or '.' if in repository root
1339 :``%p``: root-relative path name of file being printed
1353 :``%p``: root-relative path name of file being printed
1340 :``%H``: changeset hash (40 hexadecimal digits)
1354 :``%H``: changeset hash (40 hexadecimal digits)
1341 :``%R``: changeset revision number
1355 :``%R``: changeset revision number
1342 :``%h``: short-form changeset hash (12 hexadecimal digits)
1356 :``%h``: short-form changeset hash (12 hexadecimal digits)
1343 :``%r``: zero-padded changeset revision number
1357 :``%r``: zero-padded changeset revision number
1344 :``%b``: basename of the exporting repository
1358 :``%b``: basename of the exporting repository
1345
1359
1346 Returns 0 on success.
1360 Returns 0 on success.
1347 """
1361 """
1348 ctx = scmutil.revsingle(repo, opts.get('rev'))
1362 ctx = scmutil.revsingle(repo, opts.get('rev'))
1349 m = scmutil.match(ctx, (file1,) + pats, opts)
1363 m = scmutil.match(ctx, (file1,) + pats, opts)
1350
1364
1351 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1365 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1352
1366
1353 @command('^clone',
1367 @command('^clone',
1354 [('U', 'noupdate', None, _('the clone will include an empty working '
1368 [('U', 'noupdate', None, _('the clone will include an empty working '
1355 'directory (only a repository)')),
1369 'directory (only a repository)')),
1356 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1370 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1357 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1371 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1358 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1372 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1359 ('', 'pull', None, _('use pull protocol to copy metadata')),
1373 ('', 'pull', None, _('use pull protocol to copy metadata')),
1360 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1374 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1361 ] + remoteopts,
1375 ] + remoteopts,
1362 _('[OPTION]... SOURCE [DEST]'),
1376 _('[OPTION]... SOURCE [DEST]'),
1363 norepo=True)
1377 norepo=True)
1364 def clone(ui, source, dest=None, **opts):
1378 def clone(ui, source, dest=None, **opts):
1365 """make a copy of an existing repository
1379 """make a copy of an existing repository
1366
1380
1367 Create a copy of an existing repository in a new directory.
1381 Create a copy of an existing repository in a new directory.
1368
1382
1369 If no destination directory name is specified, it defaults to the
1383 If no destination directory name is specified, it defaults to the
1370 basename of the source.
1384 basename of the source.
1371
1385
1372 The location of the source is added to the new repository's
1386 The location of the source is added to the new repository's
1373 ``.hg/hgrc`` file, as the default to be used for future pulls.
1387 ``.hg/hgrc`` file, as the default to be used for future pulls.
1374
1388
1375 Only local paths and ``ssh://`` URLs are supported as
1389 Only local paths and ``ssh://`` URLs are supported as
1376 destinations. For ``ssh://`` destinations, no working directory or
1390 destinations. For ``ssh://`` destinations, no working directory or
1377 ``.hg/hgrc`` will be created on the remote side.
1391 ``.hg/hgrc`` will be created on the remote side.
1378
1392
1379 To pull only a subset of changesets, specify one or more revisions
1393 To pull only a subset of changesets, specify one or more revisions
1380 identifiers with -r/--rev or branches with -b/--branch. The
1394 identifiers with -r/--rev or branches with -b/--branch. The
1381 resulting clone will contain only the specified changesets and
1395 resulting clone will contain only the specified changesets and
1382 their ancestors. These options (or 'clone src#rev dest') imply
1396 their ancestors. These options (or 'clone src#rev dest') imply
1383 --pull, even for local source repositories. Note that specifying a
1397 --pull, even for local source repositories. Note that specifying a
1384 tag will include the tagged changeset but not the changeset
1398 tag will include the tagged changeset but not the changeset
1385 containing the tag.
1399 containing the tag.
1386
1400
1387 If the source repository has a bookmark called '@' set, that
1401 If the source repository has a bookmark called '@' set, that
1388 revision will be checked out in the new repository by default.
1402 revision will be checked out in the new repository by default.
1389
1403
1390 To check out a particular version, use -u/--update, or
1404 To check out a particular version, use -u/--update, or
1391 -U/--noupdate to create a clone with no working directory.
1405 -U/--noupdate to create a clone with no working directory.
1392
1406
1393 .. container:: verbose
1407 .. container:: verbose
1394
1408
1395 For efficiency, hardlinks are used for cloning whenever the
1409 For efficiency, hardlinks are used for cloning whenever the
1396 source and destination are on the same filesystem (note this
1410 source and destination are on the same filesystem (note this
1397 applies only to the repository data, not to the working
1411 applies only to the repository data, not to the working
1398 directory). Some filesystems, such as AFS, implement hardlinking
1412 directory). Some filesystems, such as AFS, implement hardlinking
1399 incorrectly, but do not report errors. In these cases, use the
1413 incorrectly, but do not report errors. In these cases, use the
1400 --pull option to avoid hardlinking.
1414 --pull option to avoid hardlinking.
1401
1415
1402 In some cases, you can clone repositories and the working
1416 In some cases, you can clone repositories and the working
1403 directory using full hardlinks with ::
1417 directory using full hardlinks with ::
1404
1418
1405 $ cp -al REPO REPOCLONE
1419 $ cp -al REPO REPOCLONE
1406
1420
1407 This is the fastest way to clone, but it is not always safe. The
1421 This is the fastest way to clone, but it is not always safe. The
1408 operation is not atomic (making sure REPO is not modified during
1422 operation is not atomic (making sure REPO is not modified during
1409 the operation is up to you) and you have to make sure your
1423 the operation is up to you) and you have to make sure your
1410 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1424 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1411 so). Also, this is not compatible with certain extensions that
1425 so). Also, this is not compatible with certain extensions that
1412 place their metadata under the .hg directory, such as mq.
1426 place their metadata under the .hg directory, such as mq.
1413
1427
1414 Mercurial will update the working directory to the first applicable
1428 Mercurial will update the working directory to the first applicable
1415 revision from this list:
1429 revision from this list:
1416
1430
1417 a) null if -U or the source repository has no changesets
1431 a) null if -U or the source repository has no changesets
1418 b) if -u . and the source repository is local, the first parent of
1432 b) if -u . and the source repository is local, the first parent of
1419 the source repository's working directory
1433 the source repository's working directory
1420 c) the changeset specified with -u (if a branch name, this means the
1434 c) the changeset specified with -u (if a branch name, this means the
1421 latest head of that branch)
1435 latest head of that branch)
1422 d) the changeset specified with -r
1436 d) the changeset specified with -r
1423 e) the tipmost head specified with -b
1437 e) the tipmost head specified with -b
1424 f) the tipmost head specified with the url#branch source syntax
1438 f) the tipmost head specified with the url#branch source syntax
1425 g) the revision marked with the '@' bookmark, if present
1439 g) the revision marked with the '@' bookmark, if present
1426 h) the tipmost head of the default branch
1440 h) the tipmost head of the default branch
1427 i) tip
1441 i) tip
1428
1442
1429 Examples:
1443 Examples:
1430
1444
1431 - clone a remote repository to a new directory named hg/::
1445 - clone a remote repository to a new directory named hg/::
1432
1446
1433 hg clone http://selenic.com/hg
1447 hg clone http://selenic.com/hg
1434
1448
1435 - create a lightweight local clone::
1449 - create a lightweight local clone::
1436
1450
1437 hg clone project/ project-feature/
1451 hg clone project/ project-feature/
1438
1452
1439 - clone from an absolute path on an ssh server (note double-slash)::
1453 - clone from an absolute path on an ssh server (note double-slash)::
1440
1454
1441 hg clone ssh://user@server//home/projects/alpha/
1455 hg clone ssh://user@server//home/projects/alpha/
1442
1456
1443 - do a high-speed clone over a LAN while checking out a
1457 - do a high-speed clone over a LAN while checking out a
1444 specified version::
1458 specified version::
1445
1459
1446 hg clone --uncompressed http://server/repo -u 1.5
1460 hg clone --uncompressed http://server/repo -u 1.5
1447
1461
1448 - create a repository without changesets after a particular revision::
1462 - create a repository without changesets after a particular revision::
1449
1463
1450 hg clone -r 04e544 experimental/ good/
1464 hg clone -r 04e544 experimental/ good/
1451
1465
1452 - clone (and track) a particular named branch::
1466 - clone (and track) a particular named branch::
1453
1467
1454 hg clone http://selenic.com/hg#stable
1468 hg clone http://selenic.com/hg#stable
1455
1469
1456 See :hg:`help urls` for details on specifying URLs.
1470 See :hg:`help urls` for details on specifying URLs.
1457
1471
1458 Returns 0 on success.
1472 Returns 0 on success.
1459 """
1473 """
1460 if opts.get('noupdate') and opts.get('updaterev'):
1474 if opts.get('noupdate') and opts.get('updaterev'):
1461 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1475 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1462
1476
1463 r = hg.clone(ui, opts, source, dest,
1477 r = hg.clone(ui, opts, source, dest,
1464 pull=opts.get('pull'),
1478 pull=opts.get('pull'),
1465 stream=opts.get('uncompressed'),
1479 stream=opts.get('uncompressed'),
1466 rev=opts.get('rev'),
1480 rev=opts.get('rev'),
1467 update=opts.get('updaterev') or not opts.get('noupdate'),
1481 update=opts.get('updaterev') or not opts.get('noupdate'),
1468 branch=opts.get('branch'),
1482 branch=opts.get('branch'),
1469 shareopts=opts.get('shareopts'))
1483 shareopts=opts.get('shareopts'))
1470
1484
1471 return r is None
1485 return r is None
1472
1486
1473 @command('^commit|ci',
1487 @command('^commit|ci',
1474 [('A', 'addremove', None,
1488 [('A', 'addremove', None,
1475 _('mark new/missing files as added/removed before committing')),
1489 _('mark new/missing files as added/removed before committing')),
1476 ('', 'close-branch', None,
1490 ('', 'close-branch', None,
1477 _('mark a branch head as closed')),
1491 _('mark a branch head as closed')),
1478 ('', 'amend', None, _('amend the parent of the working directory')),
1492 ('', 'amend', None, _('amend the parent of the working directory')),
1479 ('s', 'secret', None, _('use the secret phase for committing')),
1493 ('s', 'secret', None, _('use the secret phase for committing')),
1480 ('e', 'edit', None, _('invoke editor on commit messages')),
1494 ('e', 'edit', None, _('invoke editor on commit messages')),
1481 ('i', 'interactive', None, _('use interactive mode')),
1495 ('i', 'interactive', None, _('use interactive mode')),
1482 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1496 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1483 _('[OPTION]... [FILE]...'),
1497 _('[OPTION]... [FILE]...'),
1484 inferrepo=True)
1498 inferrepo=True)
1485 def commit(ui, repo, *pats, **opts):
1499 def commit(ui, repo, *pats, **opts):
1486 """commit the specified files or all outstanding changes
1500 """commit the specified files or all outstanding changes
1487
1501
1488 Commit changes to the given files into the repository. Unlike a
1502 Commit changes to the given files into the repository. Unlike a
1489 centralized SCM, this operation is a local operation. See
1503 centralized SCM, this operation is a local operation. See
1490 :hg:`push` for a way to actively distribute your changes.
1504 :hg:`push` for a way to actively distribute your changes.
1491
1505
1492 If a list of files is omitted, all changes reported by :hg:`status`
1506 If a list of files is omitted, all changes reported by :hg:`status`
1493 will be committed.
1507 will be committed.
1494
1508
1495 If you are committing the result of a merge, do not provide any
1509 If you are committing the result of a merge, do not provide any
1496 filenames or -I/-X filters.
1510 filenames or -I/-X filters.
1497
1511
1498 If no commit message is specified, Mercurial starts your
1512 If no commit message is specified, Mercurial starts your
1499 configured editor where you can enter a message. In case your
1513 configured editor where you can enter a message. In case your
1500 commit fails, you will find a backup of your message in
1514 commit fails, you will find a backup of your message in
1501 ``.hg/last-message.txt``.
1515 ``.hg/last-message.txt``.
1502
1516
1503 The --close-branch flag can be used to mark the current branch
1517 The --close-branch flag can be used to mark the current branch
1504 head closed. When all heads of a branch are closed, the branch
1518 head closed. When all heads of a branch are closed, the branch
1505 will be considered closed and no longer listed.
1519 will be considered closed and no longer listed.
1506
1520
1507 The --amend flag can be used to amend the parent of the
1521 The --amend flag can be used to amend the parent of the
1508 working directory with a new commit that contains the changes
1522 working directory with a new commit that contains the changes
1509 in the parent in addition to those currently reported by :hg:`status`,
1523 in the parent in addition to those currently reported by :hg:`status`,
1510 if there are any. The old commit is stored in a backup bundle in
1524 if there are any. The old commit is stored in a backup bundle in
1511 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1525 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1512 on how to restore it).
1526 on how to restore it).
1513
1527
1514 Message, user and date are taken from the amended commit unless
1528 Message, user and date are taken from the amended commit unless
1515 specified. When a message isn't specified on the command line,
1529 specified. When a message isn't specified on the command line,
1516 the editor will open with the message of the amended commit.
1530 the editor will open with the message of the amended commit.
1517
1531
1518 It is not possible to amend public changesets (see :hg:`help phases`)
1532 It is not possible to amend public changesets (see :hg:`help phases`)
1519 or changesets that have children.
1533 or changesets that have children.
1520
1534
1521 See :hg:`help dates` for a list of formats valid for -d/--date.
1535 See :hg:`help dates` for a list of formats valid for -d/--date.
1522
1536
1523 Returns 0 on success, 1 if nothing changed.
1537 Returns 0 on success, 1 if nothing changed.
1524 """
1538 """
1525 if opts.get('interactive'):
1539 if opts.get('interactive'):
1526 opts.pop('interactive')
1540 opts.pop('interactive')
1527 cmdutil.dorecord(ui, repo, commit, None, False,
1541 cmdutil.dorecord(ui, repo, commit, None, False,
1528 cmdutil.recordfilter, *pats, **opts)
1542 cmdutil.recordfilter, *pats, **opts)
1529 return
1543 return
1530
1544
1531 if opts.get('subrepos'):
1545 if opts.get('subrepos'):
1532 if opts.get('amend'):
1546 if opts.get('amend'):
1533 raise error.Abort(_('cannot amend with --subrepos'))
1547 raise error.Abort(_('cannot amend with --subrepos'))
1534 # Let --subrepos on the command line override config setting.
1548 # Let --subrepos on the command line override config setting.
1535 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1549 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1536
1550
1537 cmdutil.checkunfinished(repo, commit=True)
1551 cmdutil.checkunfinished(repo, commit=True)
1538
1552
1539 branch = repo[None].branch()
1553 branch = repo[None].branch()
1540 bheads = repo.branchheads(branch)
1554 bheads = repo.branchheads(branch)
1541
1555
1542 extra = {}
1556 extra = {}
1543 if opts.get('close_branch'):
1557 if opts.get('close_branch'):
1544 extra['close'] = 1
1558 extra['close'] = 1
1545
1559
1546 if not bheads:
1560 if not bheads:
1547 raise error.Abort(_('can only close branch heads'))
1561 raise error.Abort(_('can only close branch heads'))
1548 elif opts.get('amend'):
1562 elif opts.get('amend'):
1549 if repo.parents()[0].p1().branch() != branch and \
1563 if repo.parents()[0].p1().branch() != branch and \
1550 repo.parents()[0].p2().branch() != branch:
1564 repo.parents()[0].p2().branch() != branch:
1551 raise error.Abort(_('can only close branch heads'))
1565 raise error.Abort(_('can only close branch heads'))
1552
1566
1553 if opts.get('amend'):
1567 if opts.get('amend'):
1554 if ui.configbool('ui', 'commitsubrepos'):
1568 if ui.configbool('ui', 'commitsubrepos'):
1555 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1569 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1556
1570
1557 old = repo['.']
1571 old = repo['.']
1558 if not old.mutable():
1572 if not old.mutable():
1559 raise error.Abort(_('cannot amend public changesets'))
1573 raise error.Abort(_('cannot amend public changesets'))
1560 if len(repo[None].parents()) > 1:
1574 if len(repo[None].parents()) > 1:
1561 raise error.Abort(_('cannot amend while merging'))
1575 raise error.Abort(_('cannot amend while merging'))
1562 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1576 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1563 if not allowunstable and old.children():
1577 if not allowunstable and old.children():
1564 raise error.Abort(_('cannot amend changeset with children'))
1578 raise error.Abort(_('cannot amend changeset with children'))
1565
1579
1566 # commitfunc is used only for temporary amend commit by cmdutil.amend
1580 # commitfunc is used only for temporary amend commit by cmdutil.amend
1567 def commitfunc(ui, repo, message, match, opts):
1581 def commitfunc(ui, repo, message, match, opts):
1568 return repo.commit(message,
1582 return repo.commit(message,
1569 opts.get('user') or old.user(),
1583 opts.get('user') or old.user(),
1570 opts.get('date') or old.date(),
1584 opts.get('date') or old.date(),
1571 match,
1585 match,
1572 extra=extra)
1586 extra=extra)
1573
1587
1574 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1588 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1575 if node == old.node():
1589 if node == old.node():
1576 ui.status(_("nothing changed\n"))
1590 ui.status(_("nothing changed\n"))
1577 return 1
1591 return 1
1578 else:
1592 else:
1579 def commitfunc(ui, repo, message, match, opts):
1593 def commitfunc(ui, repo, message, match, opts):
1580 backup = ui.backupconfig('phases', 'new-commit')
1594 backup = ui.backupconfig('phases', 'new-commit')
1581 baseui = repo.baseui
1595 baseui = repo.baseui
1582 basebackup = baseui.backupconfig('phases', 'new-commit')
1596 basebackup = baseui.backupconfig('phases', 'new-commit')
1583 try:
1597 try:
1584 if opts.get('secret'):
1598 if opts.get('secret'):
1585 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1599 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1586 # Propagate to subrepos
1600 # Propagate to subrepos
1587 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1601 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1588
1602
1589 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1603 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1590 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1604 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1591 return repo.commit(message, opts.get('user'), opts.get('date'),
1605 return repo.commit(message, opts.get('user'), opts.get('date'),
1592 match,
1606 match,
1593 editor=editor,
1607 editor=editor,
1594 extra=extra)
1608 extra=extra)
1595 finally:
1609 finally:
1596 ui.restoreconfig(backup)
1610 ui.restoreconfig(backup)
1597 repo.baseui.restoreconfig(basebackup)
1611 repo.baseui.restoreconfig(basebackup)
1598
1612
1599
1613
1600 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1614 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1601
1615
1602 if not node:
1616 if not node:
1603 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1617 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1604 if stat[3]:
1618 if stat[3]:
1605 ui.status(_("nothing changed (%d missing files, see "
1619 ui.status(_("nothing changed (%d missing files, see "
1606 "'hg status')\n") % len(stat[3]))
1620 "'hg status')\n") % len(stat[3]))
1607 else:
1621 else:
1608 ui.status(_("nothing changed\n"))
1622 ui.status(_("nothing changed\n"))
1609 return 1
1623 return 1
1610
1624
1611 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1625 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1612
1626
1613 @command('config|showconfig|debugconfig',
1627 @command('config|showconfig|debugconfig',
1614 [('u', 'untrusted', None, _('show untrusted configuration options')),
1628 [('u', 'untrusted', None, _('show untrusted configuration options')),
1615 ('e', 'edit', None, _('edit user config')),
1629 ('e', 'edit', None, _('edit user config')),
1616 ('l', 'local', None, _('edit repository config')),
1630 ('l', 'local', None, _('edit repository config')),
1617 ('g', 'global', None, _('edit global config'))],
1631 ('g', 'global', None, _('edit global config'))],
1618 _('[-u] [NAME]...'),
1632 _('[-u] [NAME]...'),
1619 optionalrepo=True)
1633 optionalrepo=True)
1620 def config(ui, repo, *values, **opts):
1634 def config(ui, repo, *values, **opts):
1621 """show combined config settings from all hgrc files
1635 """show combined config settings from all hgrc files
1622
1636
1623 With no arguments, print names and values of all config items.
1637 With no arguments, print names and values of all config items.
1624
1638
1625 With one argument of the form section.name, print just the value
1639 With one argument of the form section.name, print just the value
1626 of that config item.
1640 of that config item.
1627
1641
1628 With multiple arguments, print names and values of all config
1642 With multiple arguments, print names and values of all config
1629 items with matching section names.
1643 items with matching section names.
1630
1644
1631 With --edit, start an editor on the user-level config file. With
1645 With --edit, start an editor on the user-level config file. With
1632 --global, edit the system-wide config file. With --local, edit the
1646 --global, edit the system-wide config file. With --local, edit the
1633 repository-level config file.
1647 repository-level config file.
1634
1648
1635 With --debug, the source (filename and line number) is printed
1649 With --debug, the source (filename and line number) is printed
1636 for each config item.
1650 for each config item.
1637
1651
1638 See :hg:`help config` for more information about config files.
1652 See :hg:`help config` for more information about config files.
1639
1653
1640 Returns 0 on success, 1 if NAME does not exist.
1654 Returns 0 on success, 1 if NAME does not exist.
1641
1655
1642 """
1656 """
1643
1657
1644 if opts.get('edit') or opts.get('local') or opts.get('global'):
1658 if opts.get('edit') or opts.get('local') or opts.get('global'):
1645 if opts.get('local') and opts.get('global'):
1659 if opts.get('local') and opts.get('global'):
1646 raise error.Abort(_("can't use --local and --global together"))
1660 raise error.Abort(_("can't use --local and --global together"))
1647
1661
1648 if opts.get('local'):
1662 if opts.get('local'):
1649 if not repo:
1663 if not repo:
1650 raise error.Abort(_("can't use --local outside a repository"))
1664 raise error.Abort(_("can't use --local outside a repository"))
1651 paths = [repo.join('hgrc')]
1665 paths = [repo.join('hgrc')]
1652 elif opts.get('global'):
1666 elif opts.get('global'):
1653 paths = scmutil.systemrcpath()
1667 paths = scmutil.systemrcpath()
1654 else:
1668 else:
1655 paths = scmutil.userrcpath()
1669 paths = scmutil.userrcpath()
1656
1670
1657 for f in paths:
1671 for f in paths:
1658 if os.path.exists(f):
1672 if os.path.exists(f):
1659 break
1673 break
1660 else:
1674 else:
1661 if opts.get('global'):
1675 if opts.get('global'):
1662 samplehgrc = uimod.samplehgrcs['global']
1676 samplehgrc = uimod.samplehgrcs['global']
1663 elif opts.get('local'):
1677 elif opts.get('local'):
1664 samplehgrc = uimod.samplehgrcs['local']
1678 samplehgrc = uimod.samplehgrcs['local']
1665 else:
1679 else:
1666 samplehgrc = uimod.samplehgrcs['user']
1680 samplehgrc = uimod.samplehgrcs['user']
1667
1681
1668 f = paths[0]
1682 f = paths[0]
1669 fp = open(f, "w")
1683 fp = open(f, "w")
1670 fp.write(samplehgrc)
1684 fp.write(samplehgrc)
1671 fp.close()
1685 fp.close()
1672
1686
1673 editor = ui.geteditor()
1687 editor = ui.geteditor()
1674 ui.system("%s \"%s\"" % (editor, f),
1688 ui.system("%s \"%s\"" % (editor, f),
1675 onerr=error.Abort, errprefix=_("edit failed"))
1689 onerr=error.Abort, errprefix=_("edit failed"))
1676 return
1690 return
1677
1691
1678 for f in scmutil.rcpath():
1692 for f in scmutil.rcpath():
1679 ui.debug('read config from: %s\n' % f)
1693 ui.debug('read config from: %s\n' % f)
1680 untrusted = bool(opts.get('untrusted'))
1694 untrusted = bool(opts.get('untrusted'))
1681 if values:
1695 if values:
1682 sections = [v for v in values if '.' not in v]
1696 sections = [v for v in values if '.' not in v]
1683 items = [v for v in values if '.' in v]
1697 items = [v for v in values if '.' in v]
1684 if len(items) > 1 or items and sections:
1698 if len(items) > 1 or items and sections:
1685 raise error.Abort(_('only one config item permitted'))
1699 raise error.Abort(_('only one config item permitted'))
1686 matched = False
1700 matched = False
1687 for section, name, value in ui.walkconfig(untrusted=untrusted):
1701 for section, name, value in ui.walkconfig(untrusted=untrusted):
1688 value = str(value).replace('\n', '\\n')
1702 value = str(value).replace('\n', '\\n')
1689 sectname = section + '.' + name
1703 sectname = section + '.' + name
1690 if values:
1704 if values:
1691 for v in values:
1705 for v in values:
1692 if v == section:
1706 if v == section:
1693 ui.debug('%s: ' %
1707 ui.debug('%s: ' %
1694 ui.configsource(section, name, untrusted))
1708 ui.configsource(section, name, untrusted))
1695 ui.write('%s=%s\n' % (sectname, value))
1709 ui.write('%s=%s\n' % (sectname, value))
1696 matched = True
1710 matched = True
1697 elif v == sectname:
1711 elif v == sectname:
1698 ui.debug('%s: ' %
1712 ui.debug('%s: ' %
1699 ui.configsource(section, name, untrusted))
1713 ui.configsource(section, name, untrusted))
1700 ui.write(value, '\n')
1714 ui.write(value, '\n')
1701 matched = True
1715 matched = True
1702 else:
1716 else:
1703 ui.debug('%s: ' %
1717 ui.debug('%s: ' %
1704 ui.configsource(section, name, untrusted))
1718 ui.configsource(section, name, untrusted))
1705 ui.write('%s=%s\n' % (sectname, value))
1719 ui.write('%s=%s\n' % (sectname, value))
1706 matched = True
1720 matched = True
1707 if matched:
1721 if matched:
1708 return 0
1722 return 0
1709 return 1
1723 return 1
1710
1724
1711 @command('copy|cp',
1725 @command('copy|cp',
1712 [('A', 'after', None, _('record a copy that has already occurred')),
1726 [('A', 'after', None, _('record a copy that has already occurred')),
1713 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1727 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1714 ] + walkopts + dryrunopts,
1728 ] + walkopts + dryrunopts,
1715 _('[OPTION]... [SOURCE]... DEST'))
1729 _('[OPTION]... [SOURCE]... DEST'))
1716 def copy(ui, repo, *pats, **opts):
1730 def copy(ui, repo, *pats, **opts):
1717 """mark files as copied for the next commit
1731 """mark files as copied for the next commit
1718
1732
1719 Mark dest as having copies of source files. If dest is a
1733 Mark dest as having copies of source files. If dest is a
1720 directory, copies are put in that directory. If dest is a file,
1734 directory, copies are put in that directory. If dest is a file,
1721 the source must be a single file.
1735 the source must be a single file.
1722
1736
1723 By default, this command copies the contents of files as they
1737 By default, this command copies the contents of files as they
1724 exist in the working directory. If invoked with -A/--after, the
1738 exist in the working directory. If invoked with -A/--after, the
1725 operation is recorded, but no copying is performed.
1739 operation is recorded, but no copying is performed.
1726
1740
1727 This command takes effect with the next commit. To undo a copy
1741 This command takes effect with the next commit. To undo a copy
1728 before that, see :hg:`revert`.
1742 before that, see :hg:`revert`.
1729
1743
1730 Returns 0 on success, 1 if errors are encountered.
1744 Returns 0 on success, 1 if errors are encountered.
1731 """
1745 """
1732 wlock = repo.wlock(False)
1746 wlock = repo.wlock(False)
1733 try:
1747 try:
1734 return cmdutil.copy(ui, repo, pats, opts)
1748 return cmdutil.copy(ui, repo, pats, opts)
1735 finally:
1749 finally:
1736 wlock.release()
1750 wlock.release()
1737
1751
1738 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1752 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1739 def debugancestor(ui, repo, *args):
1753 def debugancestor(ui, repo, *args):
1740 """find the ancestor revision of two revisions in a given index"""
1754 """find the ancestor revision of two revisions in a given index"""
1741 if len(args) == 3:
1755 if len(args) == 3:
1742 index, rev1, rev2 = args
1756 index, rev1, rev2 = args
1743 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1757 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1744 lookup = r.lookup
1758 lookup = r.lookup
1745 elif len(args) == 2:
1759 elif len(args) == 2:
1746 if not repo:
1760 if not repo:
1747 raise error.Abort(_("there is no Mercurial repository here "
1761 raise error.Abort(_("there is no Mercurial repository here "
1748 "(.hg not found)"))
1762 "(.hg not found)"))
1749 rev1, rev2 = args
1763 rev1, rev2 = args
1750 r = repo.changelog
1764 r = repo.changelog
1751 lookup = repo.lookup
1765 lookup = repo.lookup
1752 else:
1766 else:
1753 raise error.Abort(_('either two or three arguments required'))
1767 raise error.Abort(_('either two or three arguments required'))
1754 a = r.ancestor(lookup(rev1), lookup(rev2))
1768 a = r.ancestor(lookup(rev1), lookup(rev2))
1755 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1769 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1756
1770
1757 @command('debugbuilddag',
1771 @command('debugbuilddag',
1758 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1772 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1759 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1773 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1760 ('n', 'new-file', None, _('add new file at each rev'))],
1774 ('n', 'new-file', None, _('add new file at each rev'))],
1761 _('[OPTION]... [TEXT]'))
1775 _('[OPTION]... [TEXT]'))
1762 def debugbuilddag(ui, repo, text=None,
1776 def debugbuilddag(ui, repo, text=None,
1763 mergeable_file=False,
1777 mergeable_file=False,
1764 overwritten_file=False,
1778 overwritten_file=False,
1765 new_file=False):
1779 new_file=False):
1766 """builds a repo with a given DAG from scratch in the current empty repo
1780 """builds a repo with a given DAG from scratch in the current empty repo
1767
1781
1768 The description of the DAG is read from stdin if not given on the
1782 The description of the DAG is read from stdin if not given on the
1769 command line.
1783 command line.
1770
1784
1771 Elements:
1785 Elements:
1772
1786
1773 - "+n" is a linear run of n nodes based on the current default parent
1787 - "+n" is a linear run of n nodes based on the current default parent
1774 - "." is a single node based on the current default parent
1788 - "." is a single node based on the current default parent
1775 - "$" resets the default parent to null (implied at the start);
1789 - "$" resets the default parent to null (implied at the start);
1776 otherwise the default parent is always the last node created
1790 otherwise the default parent is always the last node created
1777 - "<p" sets the default parent to the backref p
1791 - "<p" sets the default parent to the backref p
1778 - "*p" is a fork at parent p, which is a backref
1792 - "*p" is a fork at parent p, which is a backref
1779 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1793 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1780 - "/p2" is a merge of the preceding node and p2
1794 - "/p2" is a merge of the preceding node and p2
1781 - ":tag" defines a local tag for the preceding node
1795 - ":tag" defines a local tag for the preceding node
1782 - "@branch" sets the named branch for subsequent nodes
1796 - "@branch" sets the named branch for subsequent nodes
1783 - "#...\\n" is a comment up to the end of the line
1797 - "#...\\n" is a comment up to the end of the line
1784
1798
1785 Whitespace between the above elements is ignored.
1799 Whitespace between the above elements is ignored.
1786
1800
1787 A backref is either
1801 A backref is either
1788
1802
1789 - a number n, which references the node curr-n, where curr is the current
1803 - a number n, which references the node curr-n, where curr is the current
1790 node, or
1804 node, or
1791 - the name of a local tag you placed earlier using ":tag", or
1805 - the name of a local tag you placed earlier using ":tag", or
1792 - empty to denote the default parent.
1806 - empty to denote the default parent.
1793
1807
1794 All string valued-elements are either strictly alphanumeric, or must
1808 All string valued-elements are either strictly alphanumeric, or must
1795 be enclosed in double quotes ("..."), with "\\" as escape character.
1809 be enclosed in double quotes ("..."), with "\\" as escape character.
1796 """
1810 """
1797
1811
1798 if text is None:
1812 if text is None:
1799 ui.status(_("reading DAG from stdin\n"))
1813 ui.status(_("reading DAG from stdin\n"))
1800 text = ui.fin.read()
1814 text = ui.fin.read()
1801
1815
1802 cl = repo.changelog
1816 cl = repo.changelog
1803 if len(cl) > 0:
1817 if len(cl) > 0:
1804 raise error.Abort(_('repository is not empty'))
1818 raise error.Abort(_('repository is not empty'))
1805
1819
1806 # determine number of revs in DAG
1820 # determine number of revs in DAG
1807 total = 0
1821 total = 0
1808 for type, data in dagparser.parsedag(text):
1822 for type, data in dagparser.parsedag(text):
1809 if type == 'n':
1823 if type == 'n':
1810 total += 1
1824 total += 1
1811
1825
1812 if mergeable_file:
1826 if mergeable_file:
1813 linesperrev = 2
1827 linesperrev = 2
1814 # make a file with k lines per rev
1828 # make a file with k lines per rev
1815 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1829 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1816 initialmergedlines.append("")
1830 initialmergedlines.append("")
1817
1831
1818 tags = []
1832 tags = []
1819
1833
1820 lock = tr = None
1834 lock = tr = None
1821 try:
1835 try:
1822 lock = repo.lock()
1836 lock = repo.lock()
1823 tr = repo.transaction("builddag")
1837 tr = repo.transaction("builddag")
1824
1838
1825 at = -1
1839 at = -1
1826 atbranch = 'default'
1840 atbranch = 'default'
1827 nodeids = []
1841 nodeids = []
1828 id = 0
1842 id = 0
1829 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1843 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1830 for type, data in dagparser.parsedag(text):
1844 for type, data in dagparser.parsedag(text):
1831 if type == 'n':
1845 if type == 'n':
1832 ui.note(('node %s\n' % str(data)))
1846 ui.note(('node %s\n' % str(data)))
1833 id, ps = data
1847 id, ps = data
1834
1848
1835 files = []
1849 files = []
1836 fctxs = {}
1850 fctxs = {}
1837
1851
1838 p2 = None
1852 p2 = None
1839 if mergeable_file:
1853 if mergeable_file:
1840 fn = "mf"
1854 fn = "mf"
1841 p1 = repo[ps[0]]
1855 p1 = repo[ps[0]]
1842 if len(ps) > 1:
1856 if len(ps) > 1:
1843 p2 = repo[ps[1]]
1857 p2 = repo[ps[1]]
1844 pa = p1.ancestor(p2)
1858 pa = p1.ancestor(p2)
1845 base, local, other = [x[fn].data() for x in (pa, p1,
1859 base, local, other = [x[fn].data() for x in (pa, p1,
1846 p2)]
1860 p2)]
1847 m3 = simplemerge.Merge3Text(base, local, other)
1861 m3 = simplemerge.Merge3Text(base, local, other)
1848 ml = [l.strip() for l in m3.merge_lines()]
1862 ml = [l.strip() for l in m3.merge_lines()]
1849 ml.append("")
1863 ml.append("")
1850 elif at > 0:
1864 elif at > 0:
1851 ml = p1[fn].data().split("\n")
1865 ml = p1[fn].data().split("\n")
1852 else:
1866 else:
1853 ml = initialmergedlines
1867 ml = initialmergedlines
1854 ml[id * linesperrev] += " r%i" % id
1868 ml[id * linesperrev] += " r%i" % id
1855 mergedtext = "\n".join(ml)
1869 mergedtext = "\n".join(ml)
1856 files.append(fn)
1870 files.append(fn)
1857 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1871 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1858
1872
1859 if overwritten_file:
1873 if overwritten_file:
1860 fn = "of"
1874 fn = "of"
1861 files.append(fn)
1875 files.append(fn)
1862 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1876 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1863
1877
1864 if new_file:
1878 if new_file:
1865 fn = "nf%i" % id
1879 fn = "nf%i" % id
1866 files.append(fn)
1880 files.append(fn)
1867 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1881 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1868 if len(ps) > 1:
1882 if len(ps) > 1:
1869 if not p2:
1883 if not p2:
1870 p2 = repo[ps[1]]
1884 p2 = repo[ps[1]]
1871 for fn in p2:
1885 for fn in p2:
1872 if fn.startswith("nf"):
1886 if fn.startswith("nf"):
1873 files.append(fn)
1887 files.append(fn)
1874 fctxs[fn] = p2[fn]
1888 fctxs[fn] = p2[fn]
1875
1889
1876 def fctxfn(repo, cx, path):
1890 def fctxfn(repo, cx, path):
1877 return fctxs.get(path)
1891 return fctxs.get(path)
1878
1892
1879 if len(ps) == 0 or ps[0] < 0:
1893 if len(ps) == 0 or ps[0] < 0:
1880 pars = [None, None]
1894 pars = [None, None]
1881 elif len(ps) == 1:
1895 elif len(ps) == 1:
1882 pars = [nodeids[ps[0]], None]
1896 pars = [nodeids[ps[0]], None]
1883 else:
1897 else:
1884 pars = [nodeids[p] for p in ps]
1898 pars = [nodeids[p] for p in ps]
1885 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1899 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1886 date=(id, 0),
1900 date=(id, 0),
1887 user="debugbuilddag",
1901 user="debugbuilddag",
1888 extra={'branch': atbranch})
1902 extra={'branch': atbranch})
1889 nodeid = repo.commitctx(cx)
1903 nodeid = repo.commitctx(cx)
1890 nodeids.append(nodeid)
1904 nodeids.append(nodeid)
1891 at = id
1905 at = id
1892 elif type == 'l':
1906 elif type == 'l':
1893 id, name = data
1907 id, name = data
1894 ui.note(('tag %s\n' % name))
1908 ui.note(('tag %s\n' % name))
1895 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1909 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1896 elif type == 'a':
1910 elif type == 'a':
1897 ui.note(('branch %s\n' % data))
1911 ui.note(('branch %s\n' % data))
1898 atbranch = data
1912 atbranch = data
1899 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1913 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1900 tr.close()
1914 tr.close()
1901
1915
1902 if tags:
1916 if tags:
1903 repo.vfs.write("localtags", "".join(tags))
1917 repo.vfs.write("localtags", "".join(tags))
1904 finally:
1918 finally:
1905 ui.progress(_('building'), None)
1919 ui.progress(_('building'), None)
1906 release(tr, lock)
1920 release(tr, lock)
1907
1921
1908 @command('debugbundle',
1922 @command('debugbundle',
1909 [('a', 'all', None, _('show all details'))],
1923 [('a', 'all', None, _('show all details'))],
1910 _('FILE'),
1924 _('FILE'),
1911 norepo=True)
1925 norepo=True)
1912 def debugbundle(ui, bundlepath, all=None, **opts):
1926 def debugbundle(ui, bundlepath, all=None, **opts):
1913 """lists the contents of a bundle"""
1927 """lists the contents of a bundle"""
1914 f = hg.openpath(ui, bundlepath)
1928 f = hg.openpath(ui, bundlepath)
1915 try:
1929 try:
1916 gen = exchange.readbundle(ui, f, bundlepath)
1930 gen = exchange.readbundle(ui, f, bundlepath)
1917 if isinstance(gen, bundle2.unbundle20):
1931 if isinstance(gen, bundle2.unbundle20):
1918 return _debugbundle2(ui, gen, all=all, **opts)
1932 return _debugbundle2(ui, gen, all=all, **opts)
1919 if all:
1933 if all:
1920 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1934 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1921
1935
1922 def showchunks(named):
1936 def showchunks(named):
1923 ui.write("\n%s\n" % named)
1937 ui.write("\n%s\n" % named)
1924 chain = None
1938 chain = None
1925 while True:
1939 while True:
1926 chunkdata = gen.deltachunk(chain)
1940 chunkdata = gen.deltachunk(chain)
1927 if not chunkdata:
1941 if not chunkdata:
1928 break
1942 break
1929 node = chunkdata['node']
1943 node = chunkdata['node']
1930 p1 = chunkdata['p1']
1944 p1 = chunkdata['p1']
1931 p2 = chunkdata['p2']
1945 p2 = chunkdata['p2']
1932 cs = chunkdata['cs']
1946 cs = chunkdata['cs']
1933 deltabase = chunkdata['deltabase']
1947 deltabase = chunkdata['deltabase']
1934 delta = chunkdata['delta']
1948 delta = chunkdata['delta']
1935 ui.write("%s %s %s %s %s %s\n" %
1949 ui.write("%s %s %s %s %s %s\n" %
1936 (hex(node), hex(p1), hex(p2),
1950 (hex(node), hex(p1), hex(p2),
1937 hex(cs), hex(deltabase), len(delta)))
1951 hex(cs), hex(deltabase), len(delta)))
1938 chain = node
1952 chain = node
1939
1953
1940 chunkdata = gen.changelogheader()
1954 chunkdata = gen.changelogheader()
1941 showchunks("changelog")
1955 showchunks("changelog")
1942 chunkdata = gen.manifestheader()
1956 chunkdata = gen.manifestheader()
1943 showchunks("manifest")
1957 showchunks("manifest")
1944 while True:
1958 while True:
1945 chunkdata = gen.filelogheader()
1959 chunkdata = gen.filelogheader()
1946 if not chunkdata:
1960 if not chunkdata:
1947 break
1961 break
1948 fname = chunkdata['filename']
1962 fname = chunkdata['filename']
1949 showchunks(fname)
1963 showchunks(fname)
1950 else:
1964 else:
1951 if isinstance(gen, bundle2.unbundle20):
1965 if isinstance(gen, bundle2.unbundle20):
1952 raise error.Abort(_('use debugbundle2 for this file'))
1966 raise error.Abort(_('use debugbundle2 for this file'))
1953 chunkdata = gen.changelogheader()
1967 chunkdata = gen.changelogheader()
1954 chain = None
1968 chain = None
1955 while True:
1969 while True:
1956 chunkdata = gen.deltachunk(chain)
1970 chunkdata = gen.deltachunk(chain)
1957 if not chunkdata:
1971 if not chunkdata:
1958 break
1972 break
1959 node = chunkdata['node']
1973 node = chunkdata['node']
1960 ui.write("%s\n" % hex(node))
1974 ui.write("%s\n" % hex(node))
1961 chain = node
1975 chain = node
1962 finally:
1976 finally:
1963 f.close()
1977 f.close()
1964
1978
1965 def _debugbundle2(ui, gen, **opts):
1979 def _debugbundle2(ui, gen, **opts):
1966 """lists the contents of a bundle2"""
1980 """lists the contents of a bundle2"""
1967 if not isinstance(gen, bundle2.unbundle20):
1981 if not isinstance(gen, bundle2.unbundle20):
1968 raise error.Abort(_('not a bundle2 file'))
1982 raise error.Abort(_('not a bundle2 file'))
1969 ui.write(('Stream params: %s\n' % repr(gen.params)))
1983 ui.write(('Stream params: %s\n' % repr(gen.params)))
1970 for part in gen.iterparts():
1984 for part in gen.iterparts():
1971 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1985 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1972 if part.type == 'changegroup':
1986 if part.type == 'changegroup':
1973 version = part.params.get('version', '01')
1987 version = part.params.get('version', '01')
1974 cg = changegroup.packermap[version][1](part, 'UN')
1988 cg = changegroup.packermap[version][1](part, 'UN')
1975 chunkdata = cg.changelogheader()
1989 chunkdata = cg.changelogheader()
1976 chain = None
1990 chain = None
1977 while True:
1991 while True:
1978 chunkdata = cg.deltachunk(chain)
1992 chunkdata = cg.deltachunk(chain)
1979 if not chunkdata:
1993 if not chunkdata:
1980 break
1994 break
1981 node = chunkdata['node']
1995 node = chunkdata['node']
1982 ui.write(" %s\n" % hex(node))
1996 ui.write(" %s\n" % hex(node))
1983 chain = node
1997 chain = node
1984
1998
1985 @command('debugcreatestreamclonebundle', [], 'FILE')
1999 @command('debugcreatestreamclonebundle', [], 'FILE')
1986 def debugcreatestreamclonebundle(ui, repo, fname):
2000 def debugcreatestreamclonebundle(ui, repo, fname):
1987 """create a stream clone bundle file
2001 """create a stream clone bundle file
1988
2002
1989 Stream bundles are special bundles that are essentially archives of
2003 Stream bundles are special bundles that are essentially archives of
1990 revlog files. They are commonly used for cloning very quickly.
2004 revlog files. They are commonly used for cloning very quickly.
1991 """
2005 """
1992 requirements, gen = streamclone.generatebundlev1(repo)
2006 requirements, gen = streamclone.generatebundlev1(repo)
1993 changegroup.writechunks(ui, gen, fname)
2007 changegroup.writechunks(ui, gen, fname)
1994
2008
1995 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
2009 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
1996
2010
1997 @command('debugapplystreamclonebundle', [], 'FILE')
2011 @command('debugapplystreamclonebundle', [], 'FILE')
1998 def debugapplystreamclonebundle(ui, repo, fname):
2012 def debugapplystreamclonebundle(ui, repo, fname):
1999 """apply a stream clone bundle file"""
2013 """apply a stream clone bundle file"""
2000 f = hg.openpath(ui, fname)
2014 f = hg.openpath(ui, fname)
2001 gen = exchange.readbundle(ui, f, fname)
2015 gen = exchange.readbundle(ui, f, fname)
2002 gen.apply(repo)
2016 gen.apply(repo)
2003
2017
2004 @command('debugcheckstate', [], '')
2018 @command('debugcheckstate', [], '')
2005 def debugcheckstate(ui, repo):
2019 def debugcheckstate(ui, repo):
2006 """validate the correctness of the current dirstate"""
2020 """validate the correctness of the current dirstate"""
2007 parent1, parent2 = repo.dirstate.parents()
2021 parent1, parent2 = repo.dirstate.parents()
2008 m1 = repo[parent1].manifest()
2022 m1 = repo[parent1].manifest()
2009 m2 = repo[parent2].manifest()
2023 m2 = repo[parent2].manifest()
2010 errors = 0
2024 errors = 0
2011 for f in repo.dirstate:
2025 for f in repo.dirstate:
2012 state = repo.dirstate[f]
2026 state = repo.dirstate[f]
2013 if state in "nr" and f not in m1:
2027 if state in "nr" and f not in m1:
2014 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
2028 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
2015 errors += 1
2029 errors += 1
2016 if state in "a" and f in m1:
2030 if state in "a" and f in m1:
2017 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
2031 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
2018 errors += 1
2032 errors += 1
2019 if state in "m" and f not in m1 and f not in m2:
2033 if state in "m" and f not in m1 and f not in m2:
2020 ui.warn(_("%s in state %s, but not in either manifest\n") %
2034 ui.warn(_("%s in state %s, but not in either manifest\n") %
2021 (f, state))
2035 (f, state))
2022 errors += 1
2036 errors += 1
2023 for f in m1:
2037 for f in m1:
2024 state = repo.dirstate[f]
2038 state = repo.dirstate[f]
2025 if state not in "nrm":
2039 if state not in "nrm":
2026 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
2040 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
2027 errors += 1
2041 errors += 1
2028 if errors:
2042 if errors:
2029 error = _(".hg/dirstate inconsistent with current parent's manifest")
2043 error = _(".hg/dirstate inconsistent with current parent's manifest")
2030 raise error.Abort(error)
2044 raise error.Abort(error)
2031
2045
2032 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
2046 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
2033 def debugcommands(ui, cmd='', *args):
2047 def debugcommands(ui, cmd='', *args):
2034 """list all available commands and options"""
2048 """list all available commands and options"""
2035 for cmd, vals in sorted(table.iteritems()):
2049 for cmd, vals in sorted(table.iteritems()):
2036 cmd = cmd.split('|')[0].strip('^')
2050 cmd = cmd.split('|')[0].strip('^')
2037 opts = ', '.join([i[1] for i in vals[1]])
2051 opts = ', '.join([i[1] for i in vals[1]])
2038 ui.write('%s: %s\n' % (cmd, opts))
2052 ui.write('%s: %s\n' % (cmd, opts))
2039
2053
2040 @command('debugcomplete',
2054 @command('debugcomplete',
2041 [('o', 'options', None, _('show the command options'))],
2055 [('o', 'options', None, _('show the command options'))],
2042 _('[-o] CMD'),
2056 _('[-o] CMD'),
2043 norepo=True)
2057 norepo=True)
2044 def debugcomplete(ui, cmd='', **opts):
2058 def debugcomplete(ui, cmd='', **opts):
2045 """returns the completion list associated with the given command"""
2059 """returns the completion list associated with the given command"""
2046
2060
2047 if opts.get('options'):
2061 if opts.get('options'):
2048 options = []
2062 options = []
2049 otables = [globalopts]
2063 otables = [globalopts]
2050 if cmd:
2064 if cmd:
2051 aliases, entry = cmdutil.findcmd(cmd, table, False)
2065 aliases, entry = cmdutil.findcmd(cmd, table, False)
2052 otables.append(entry[1])
2066 otables.append(entry[1])
2053 for t in otables:
2067 for t in otables:
2054 for o in t:
2068 for o in t:
2055 if "(DEPRECATED)" in o[3]:
2069 if "(DEPRECATED)" in o[3]:
2056 continue
2070 continue
2057 if o[0]:
2071 if o[0]:
2058 options.append('-%s' % o[0])
2072 options.append('-%s' % o[0])
2059 options.append('--%s' % o[1])
2073 options.append('--%s' % o[1])
2060 ui.write("%s\n" % "\n".join(options))
2074 ui.write("%s\n" % "\n".join(options))
2061 return
2075 return
2062
2076
2063 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2077 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2064 if ui.verbose:
2078 if ui.verbose:
2065 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2079 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2066 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2080 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2067
2081
2068 @command('debugdag',
2082 @command('debugdag',
2069 [('t', 'tags', None, _('use tags as labels')),
2083 [('t', 'tags', None, _('use tags as labels')),
2070 ('b', 'branches', None, _('annotate with branch names')),
2084 ('b', 'branches', None, _('annotate with branch names')),
2071 ('', 'dots', None, _('use dots for runs')),
2085 ('', 'dots', None, _('use dots for runs')),
2072 ('s', 'spaces', None, _('separate elements by spaces'))],
2086 ('s', 'spaces', None, _('separate elements by spaces'))],
2073 _('[OPTION]... [FILE [REV]...]'),
2087 _('[OPTION]... [FILE [REV]...]'),
2074 optionalrepo=True)
2088 optionalrepo=True)
2075 def debugdag(ui, repo, file_=None, *revs, **opts):
2089 def debugdag(ui, repo, file_=None, *revs, **opts):
2076 """format the changelog or an index DAG as a concise textual description
2090 """format the changelog or an index DAG as a concise textual description
2077
2091
2078 If you pass a revlog index, the revlog's DAG is emitted. If you list
2092 If you pass a revlog index, the revlog's DAG is emitted. If you list
2079 revision numbers, they get labeled in the output as rN.
2093 revision numbers, they get labeled in the output as rN.
2080
2094
2081 Otherwise, the changelog DAG of the current repo is emitted.
2095 Otherwise, the changelog DAG of the current repo is emitted.
2082 """
2096 """
2083 spaces = opts.get('spaces')
2097 spaces = opts.get('spaces')
2084 dots = opts.get('dots')
2098 dots = opts.get('dots')
2085 if file_:
2099 if file_:
2086 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2100 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2087 revs = set((int(r) for r in revs))
2101 revs = set((int(r) for r in revs))
2088 def events():
2102 def events():
2089 for r in rlog:
2103 for r in rlog:
2090 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2104 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2091 if p != -1))
2105 if p != -1))
2092 if r in revs:
2106 if r in revs:
2093 yield 'l', (r, "r%i" % r)
2107 yield 'l', (r, "r%i" % r)
2094 elif repo:
2108 elif repo:
2095 cl = repo.changelog
2109 cl = repo.changelog
2096 tags = opts.get('tags')
2110 tags = opts.get('tags')
2097 branches = opts.get('branches')
2111 branches = opts.get('branches')
2098 if tags:
2112 if tags:
2099 labels = {}
2113 labels = {}
2100 for l, n in repo.tags().items():
2114 for l, n in repo.tags().items():
2101 labels.setdefault(cl.rev(n), []).append(l)
2115 labels.setdefault(cl.rev(n), []).append(l)
2102 def events():
2116 def events():
2103 b = "default"
2117 b = "default"
2104 for r in cl:
2118 for r in cl:
2105 if branches:
2119 if branches:
2106 newb = cl.read(cl.node(r))[5]['branch']
2120 newb = cl.read(cl.node(r))[5]['branch']
2107 if newb != b:
2121 if newb != b:
2108 yield 'a', newb
2122 yield 'a', newb
2109 b = newb
2123 b = newb
2110 yield 'n', (r, list(p for p in cl.parentrevs(r)
2124 yield 'n', (r, list(p for p in cl.parentrevs(r)
2111 if p != -1))
2125 if p != -1))
2112 if tags:
2126 if tags:
2113 ls = labels.get(r)
2127 ls = labels.get(r)
2114 if ls:
2128 if ls:
2115 for l in ls:
2129 for l in ls:
2116 yield 'l', (r, l)
2130 yield 'l', (r, l)
2117 else:
2131 else:
2118 raise error.Abort(_('need repo for changelog dag'))
2132 raise error.Abort(_('need repo for changelog dag'))
2119
2133
2120 for line in dagparser.dagtextlines(events(),
2134 for line in dagparser.dagtextlines(events(),
2121 addspaces=spaces,
2135 addspaces=spaces,
2122 wraplabels=True,
2136 wraplabels=True,
2123 wrapannotations=True,
2137 wrapannotations=True,
2124 wrapnonlinear=dots,
2138 wrapnonlinear=dots,
2125 usedots=dots,
2139 usedots=dots,
2126 maxlinewidth=70):
2140 maxlinewidth=70):
2127 ui.write(line)
2141 ui.write(line)
2128 ui.write("\n")
2142 ui.write("\n")
2129
2143
2130 @command('debugdata',
2144 @command('debugdata',
2131 [('c', 'changelog', False, _('open changelog')),
2145 [('c', 'changelog', False, _('open changelog')),
2132 ('m', 'manifest', False, _('open manifest')),
2146 ('m', 'manifest', False, _('open manifest')),
2133 ('', 'dir', False, _('open directory manifest'))],
2147 ('', 'dir', False, _('open directory manifest'))],
2134 _('-c|-m|FILE REV'))
2148 _('-c|-m|FILE REV'))
2135 def debugdata(ui, repo, file_, rev=None, **opts):
2149 def debugdata(ui, repo, file_, rev=None, **opts):
2136 """dump the contents of a data file revision"""
2150 """dump the contents of a data file revision"""
2137 if opts.get('changelog') or opts.get('manifest'):
2151 if opts.get('changelog') or opts.get('manifest'):
2138 file_, rev = None, file_
2152 file_, rev = None, file_
2139 elif rev is None:
2153 elif rev is None:
2140 raise error.CommandError('debugdata', _('invalid arguments'))
2154 raise error.CommandError('debugdata', _('invalid arguments'))
2141 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2155 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2142 try:
2156 try:
2143 ui.write(r.revision(r.lookup(rev)))
2157 ui.write(r.revision(r.lookup(rev)))
2144 except KeyError:
2158 except KeyError:
2145 raise error.Abort(_('invalid revision identifier %s') % rev)
2159 raise error.Abort(_('invalid revision identifier %s') % rev)
2146
2160
2147 @command('debugdate',
2161 @command('debugdate',
2148 [('e', 'extended', None, _('try extended date formats'))],
2162 [('e', 'extended', None, _('try extended date formats'))],
2149 _('[-e] DATE [RANGE]'),
2163 _('[-e] DATE [RANGE]'),
2150 norepo=True, optionalrepo=True)
2164 norepo=True, optionalrepo=True)
2151 def debugdate(ui, date, range=None, **opts):
2165 def debugdate(ui, date, range=None, **opts):
2152 """parse and display a date"""
2166 """parse and display a date"""
2153 if opts["extended"]:
2167 if opts["extended"]:
2154 d = util.parsedate(date, util.extendeddateformats)
2168 d = util.parsedate(date, util.extendeddateformats)
2155 else:
2169 else:
2156 d = util.parsedate(date)
2170 d = util.parsedate(date)
2157 ui.write(("internal: %s %s\n") % d)
2171 ui.write(("internal: %s %s\n") % d)
2158 ui.write(("standard: %s\n") % util.datestr(d))
2172 ui.write(("standard: %s\n") % util.datestr(d))
2159 if range:
2173 if range:
2160 m = util.matchdate(range)
2174 m = util.matchdate(range)
2161 ui.write(("match: %s\n") % m(d[0]))
2175 ui.write(("match: %s\n") % m(d[0]))
2162
2176
2163 @command('debugdiscovery',
2177 @command('debugdiscovery',
2164 [('', 'old', None, _('use old-style discovery')),
2178 [('', 'old', None, _('use old-style discovery')),
2165 ('', 'nonheads', None,
2179 ('', 'nonheads', None,
2166 _('use old-style discovery with non-heads included')),
2180 _('use old-style discovery with non-heads included')),
2167 ] + remoteopts,
2181 ] + remoteopts,
2168 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2182 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2169 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2183 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2170 """runs the changeset discovery protocol in isolation"""
2184 """runs the changeset discovery protocol in isolation"""
2171 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2185 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2172 opts.get('branch'))
2186 opts.get('branch'))
2173 remote = hg.peer(repo, opts, remoteurl)
2187 remote = hg.peer(repo, opts, remoteurl)
2174 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2188 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2175
2189
2176 # make sure tests are repeatable
2190 # make sure tests are repeatable
2177 random.seed(12323)
2191 random.seed(12323)
2178
2192
2179 def doit(localheads, remoteheads, remote=remote):
2193 def doit(localheads, remoteheads, remote=remote):
2180 if opts.get('old'):
2194 if opts.get('old'):
2181 if localheads:
2195 if localheads:
2182 raise error.Abort('cannot use localheads with old style '
2196 raise error.Abort('cannot use localheads with old style '
2183 'discovery')
2197 'discovery')
2184 if not util.safehasattr(remote, 'branches'):
2198 if not util.safehasattr(remote, 'branches'):
2185 # enable in-client legacy support
2199 # enable in-client legacy support
2186 remote = localrepo.locallegacypeer(remote.local())
2200 remote = localrepo.locallegacypeer(remote.local())
2187 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2201 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2188 force=True)
2202 force=True)
2189 common = set(common)
2203 common = set(common)
2190 if not opts.get('nonheads'):
2204 if not opts.get('nonheads'):
2191 ui.write(("unpruned common: %s\n") %
2205 ui.write(("unpruned common: %s\n") %
2192 " ".join(sorted(short(n) for n in common)))
2206 " ".join(sorted(short(n) for n in common)))
2193 dag = dagutil.revlogdag(repo.changelog)
2207 dag = dagutil.revlogdag(repo.changelog)
2194 all = dag.ancestorset(dag.internalizeall(common))
2208 all = dag.ancestorset(dag.internalizeall(common))
2195 common = dag.externalizeall(dag.headsetofconnecteds(all))
2209 common = dag.externalizeall(dag.headsetofconnecteds(all))
2196 else:
2210 else:
2197 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2211 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2198 common = set(common)
2212 common = set(common)
2199 rheads = set(hds)
2213 rheads = set(hds)
2200 lheads = set(repo.heads())
2214 lheads = set(repo.heads())
2201 ui.write(("common heads: %s\n") %
2215 ui.write(("common heads: %s\n") %
2202 " ".join(sorted(short(n) for n in common)))
2216 " ".join(sorted(short(n) for n in common)))
2203 if lheads <= common:
2217 if lheads <= common:
2204 ui.write(("local is subset\n"))
2218 ui.write(("local is subset\n"))
2205 elif rheads <= common:
2219 elif rheads <= common:
2206 ui.write(("remote is subset\n"))
2220 ui.write(("remote is subset\n"))
2207
2221
2208 serverlogs = opts.get('serverlog')
2222 serverlogs = opts.get('serverlog')
2209 if serverlogs:
2223 if serverlogs:
2210 for filename in serverlogs:
2224 for filename in serverlogs:
2211 logfile = open(filename, 'r')
2225 logfile = open(filename, 'r')
2212 try:
2226 try:
2213 line = logfile.readline()
2227 line = logfile.readline()
2214 while line:
2228 while line:
2215 parts = line.strip().split(';')
2229 parts = line.strip().split(';')
2216 op = parts[1]
2230 op = parts[1]
2217 if op == 'cg':
2231 if op == 'cg':
2218 pass
2232 pass
2219 elif op == 'cgss':
2233 elif op == 'cgss':
2220 doit(parts[2].split(' '), parts[3].split(' '))
2234 doit(parts[2].split(' '), parts[3].split(' '))
2221 elif op == 'unb':
2235 elif op == 'unb':
2222 doit(parts[3].split(' '), parts[2].split(' '))
2236 doit(parts[3].split(' '), parts[2].split(' '))
2223 line = logfile.readline()
2237 line = logfile.readline()
2224 finally:
2238 finally:
2225 logfile.close()
2239 logfile.close()
2226
2240
2227 else:
2241 else:
2228 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2242 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2229 opts.get('remote_head'))
2243 opts.get('remote_head'))
2230 localrevs = opts.get('local_head')
2244 localrevs = opts.get('local_head')
2231 doit(localrevs, remoterevs)
2245 doit(localrevs, remoterevs)
2232
2246
2233 @command('debugextensions', formatteropts, [], norepo=True)
2247 @command('debugextensions', formatteropts, [], norepo=True)
2234 def debugextensions(ui, **opts):
2248 def debugextensions(ui, **opts):
2235 '''show information about active extensions'''
2249 '''show information about active extensions'''
2236 exts = extensions.extensions(ui)
2250 exts = extensions.extensions(ui)
2237 fm = ui.formatter('debugextensions', opts)
2251 fm = ui.formatter('debugextensions', opts)
2238 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2252 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2239 extsource = extmod.__file__
2253 extsource = extmod.__file__
2240 exttestedwith = getattr(extmod, 'testedwith', None)
2254 exttestedwith = getattr(extmod, 'testedwith', None)
2241 if exttestedwith is not None:
2255 if exttestedwith is not None:
2242 exttestedwith = exttestedwith.split()
2256 exttestedwith = exttestedwith.split()
2243 extbuglink = getattr(extmod, 'buglink', None)
2257 extbuglink = getattr(extmod, 'buglink', None)
2244
2258
2245 fm.startitem()
2259 fm.startitem()
2246
2260
2247 if ui.quiet or ui.verbose:
2261 if ui.quiet or ui.verbose:
2248 fm.write('name', '%s\n', extname)
2262 fm.write('name', '%s\n', extname)
2249 else:
2263 else:
2250 fm.write('name', '%s', extname)
2264 fm.write('name', '%s', extname)
2251 if not exttestedwith:
2265 if not exttestedwith:
2252 fm.plain(_(' (untested!)\n'))
2266 fm.plain(_(' (untested!)\n'))
2253 else:
2267 else:
2254 if exttestedwith == ['internal'] or \
2268 if exttestedwith == ['internal'] or \
2255 util.version() in exttestedwith:
2269 util.version() in exttestedwith:
2256 fm.plain('\n')
2270 fm.plain('\n')
2257 else:
2271 else:
2258 lasttestedversion = exttestedwith[-1]
2272 lasttestedversion = exttestedwith[-1]
2259 fm.plain(' (%s!)\n' % lasttestedversion)
2273 fm.plain(' (%s!)\n' % lasttestedversion)
2260
2274
2261 fm.condwrite(ui.verbose and extsource, 'source',
2275 fm.condwrite(ui.verbose and extsource, 'source',
2262 _(' location: %s\n'), extsource or "")
2276 _(' location: %s\n'), extsource or "")
2263
2277
2264 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2278 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2265 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2279 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2266
2280
2267 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2281 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2268 _(' bug reporting: %s\n'), extbuglink or "")
2282 _(' bug reporting: %s\n'), extbuglink or "")
2269
2283
2270 fm.end()
2284 fm.end()
2271
2285
2272 @command('debugfileset',
2286 @command('debugfileset',
2273 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2287 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2274 _('[-r REV] FILESPEC'))
2288 _('[-r REV] FILESPEC'))
2275 def debugfileset(ui, repo, expr, **opts):
2289 def debugfileset(ui, repo, expr, **opts):
2276 '''parse and apply a fileset specification'''
2290 '''parse and apply a fileset specification'''
2277 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2291 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2278 if ui.verbose:
2292 if ui.verbose:
2279 tree = fileset.parse(expr)
2293 tree = fileset.parse(expr)
2280 ui.note(fileset.prettyformat(tree), "\n")
2294 ui.note(fileset.prettyformat(tree), "\n")
2281
2295
2282 for f in ctx.getfileset(expr):
2296 for f in ctx.getfileset(expr):
2283 ui.write("%s\n" % f)
2297 ui.write("%s\n" % f)
2284
2298
2285 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2299 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2286 def debugfsinfo(ui, path="."):
2300 def debugfsinfo(ui, path="."):
2287 """show information detected about current filesystem"""
2301 """show information detected about current filesystem"""
2288 util.writefile('.debugfsinfo', '')
2302 util.writefile('.debugfsinfo', '')
2289 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2303 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2290 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2304 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2291 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2305 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2292 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2306 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2293 and 'yes' or 'no'))
2307 and 'yes' or 'no'))
2294 os.unlink('.debugfsinfo')
2308 os.unlink('.debugfsinfo')
2295
2309
2296 @command('debuggetbundle',
2310 @command('debuggetbundle',
2297 [('H', 'head', [], _('id of head node'), _('ID')),
2311 [('H', 'head', [], _('id of head node'), _('ID')),
2298 ('C', 'common', [], _('id of common node'), _('ID')),
2312 ('C', 'common', [], _('id of common node'), _('ID')),
2299 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2313 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2300 _('REPO FILE [-H|-C ID]...'),
2314 _('REPO FILE [-H|-C ID]...'),
2301 norepo=True)
2315 norepo=True)
2302 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2316 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2303 """retrieves a bundle from a repo
2317 """retrieves a bundle from a repo
2304
2318
2305 Every ID must be a full-length hex node id string. Saves the bundle to the
2319 Every ID must be a full-length hex node id string. Saves the bundle to the
2306 given file.
2320 given file.
2307 """
2321 """
2308 repo = hg.peer(ui, opts, repopath)
2322 repo = hg.peer(ui, opts, repopath)
2309 if not repo.capable('getbundle'):
2323 if not repo.capable('getbundle'):
2310 raise error.Abort("getbundle() not supported by target repository")
2324 raise error.Abort("getbundle() not supported by target repository")
2311 args = {}
2325 args = {}
2312 if common:
2326 if common:
2313 args['common'] = [bin(s) for s in common]
2327 args['common'] = [bin(s) for s in common]
2314 if head:
2328 if head:
2315 args['heads'] = [bin(s) for s in head]
2329 args['heads'] = [bin(s) for s in head]
2316 # TODO: get desired bundlecaps from command line.
2330 # TODO: get desired bundlecaps from command line.
2317 args['bundlecaps'] = None
2331 args['bundlecaps'] = None
2318 bundle = repo.getbundle('debug', **args)
2332 bundle = repo.getbundle('debug', **args)
2319
2333
2320 bundletype = opts.get('type', 'bzip2').lower()
2334 bundletype = opts.get('type', 'bzip2').lower()
2321 btypes = {'none': 'HG10UN',
2335 btypes = {'none': 'HG10UN',
2322 'bzip2': 'HG10BZ',
2336 'bzip2': 'HG10BZ',
2323 'gzip': 'HG10GZ',
2337 'gzip': 'HG10GZ',
2324 'bundle2': 'HG20'}
2338 'bundle2': 'HG20'}
2325 bundletype = btypes.get(bundletype)
2339 bundletype = btypes.get(bundletype)
2326 if bundletype not in changegroup.bundletypes:
2340 if bundletype not in changegroup.bundletypes:
2327 raise error.Abort(_('unknown bundle type specified with --type'))
2341 raise error.Abort(_('unknown bundle type specified with --type'))
2328 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2342 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2329
2343
2330 @command('debugignore', [], '')
2344 @command('debugignore', [], '')
2331 def debugignore(ui, repo, *values, **opts):
2345 def debugignore(ui, repo, *values, **opts):
2332 """display the combined ignore pattern"""
2346 """display the combined ignore pattern"""
2333 ignore = repo.dirstate._ignore
2347 ignore = repo.dirstate._ignore
2334 includepat = getattr(ignore, 'includepat', None)
2348 includepat = getattr(ignore, 'includepat', None)
2335 if includepat is not None:
2349 if includepat is not None:
2336 ui.write("%s\n" % includepat)
2350 ui.write("%s\n" % includepat)
2337 else:
2351 else:
2338 raise error.Abort(_("no ignore patterns found"))
2352 raise error.Abort(_("no ignore patterns found"))
2339
2353
2340 @command('debugindex',
2354 @command('debugindex',
2341 [('c', 'changelog', False, _('open changelog')),
2355 [('c', 'changelog', False, _('open changelog')),
2342 ('m', 'manifest', False, _('open manifest')),
2356 ('m', 'manifest', False, _('open manifest')),
2343 ('', 'dir', False, _('open directory manifest')),
2357 ('', 'dir', False, _('open directory manifest')),
2344 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2358 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2345 _('[-f FORMAT] -c|-m|FILE'),
2359 _('[-f FORMAT] -c|-m|FILE'),
2346 optionalrepo=True)
2360 optionalrepo=True)
2347 def debugindex(ui, repo, file_=None, **opts):
2361 def debugindex(ui, repo, file_=None, **opts):
2348 """dump the contents of an index file"""
2362 """dump the contents of an index file"""
2349 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2363 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2350 format = opts.get('format', 0)
2364 format = opts.get('format', 0)
2351 if format not in (0, 1):
2365 if format not in (0, 1):
2352 raise error.Abort(_("unknown format %d") % format)
2366 raise error.Abort(_("unknown format %d") % format)
2353
2367
2354 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2368 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2355 if generaldelta:
2369 if generaldelta:
2356 basehdr = ' delta'
2370 basehdr = ' delta'
2357 else:
2371 else:
2358 basehdr = ' base'
2372 basehdr = ' base'
2359
2373
2360 if ui.debugflag:
2374 if ui.debugflag:
2361 shortfn = hex
2375 shortfn = hex
2362 else:
2376 else:
2363 shortfn = short
2377 shortfn = short
2364
2378
2365 # There might not be anything in r, so have a sane default
2379 # There might not be anything in r, so have a sane default
2366 idlen = 12
2380 idlen = 12
2367 for i in r:
2381 for i in r:
2368 idlen = len(shortfn(r.node(i)))
2382 idlen = len(shortfn(r.node(i)))
2369 break
2383 break
2370
2384
2371 if format == 0:
2385 if format == 0:
2372 ui.write(" rev offset length " + basehdr + " linkrev"
2386 ui.write(" rev offset length " + basehdr + " linkrev"
2373 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2387 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2374 elif format == 1:
2388 elif format == 1:
2375 ui.write(" rev flag offset length"
2389 ui.write(" rev flag offset length"
2376 " size " + basehdr + " link p1 p2"
2390 " size " + basehdr + " link p1 p2"
2377 " %s\n" % "nodeid".rjust(idlen))
2391 " %s\n" % "nodeid".rjust(idlen))
2378
2392
2379 for i in r:
2393 for i in r:
2380 node = r.node(i)
2394 node = r.node(i)
2381 if generaldelta:
2395 if generaldelta:
2382 base = r.deltaparent(i)
2396 base = r.deltaparent(i)
2383 else:
2397 else:
2384 base = r.chainbase(i)
2398 base = r.chainbase(i)
2385 if format == 0:
2399 if format == 0:
2386 try:
2400 try:
2387 pp = r.parents(node)
2401 pp = r.parents(node)
2388 except Exception:
2402 except Exception:
2389 pp = [nullid, nullid]
2403 pp = [nullid, nullid]
2390 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2404 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2391 i, r.start(i), r.length(i), base, r.linkrev(i),
2405 i, r.start(i), r.length(i), base, r.linkrev(i),
2392 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2406 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2393 elif format == 1:
2407 elif format == 1:
2394 pr = r.parentrevs(i)
2408 pr = r.parentrevs(i)
2395 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2409 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2396 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2410 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2397 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2411 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2398
2412
2399 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2413 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2400 def debugindexdot(ui, repo, file_):
2414 def debugindexdot(ui, repo, file_):
2401 """dump an index DAG as a graphviz dot file"""
2415 """dump an index DAG as a graphviz dot file"""
2402 r = None
2416 r = None
2403 if repo:
2417 if repo:
2404 filelog = repo.file(file_)
2418 filelog = repo.file(file_)
2405 if len(filelog):
2419 if len(filelog):
2406 r = filelog
2420 r = filelog
2407 if not r:
2421 if not r:
2408 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2422 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2409 ui.write(("digraph G {\n"))
2423 ui.write(("digraph G {\n"))
2410 for i in r:
2424 for i in r:
2411 node = r.node(i)
2425 node = r.node(i)
2412 pp = r.parents(node)
2426 pp = r.parents(node)
2413 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2427 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2414 if pp[1] != nullid:
2428 if pp[1] != nullid:
2415 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2429 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2416 ui.write("}\n")
2430 ui.write("}\n")
2417
2431
2418 @command('debuginstall', [], '', norepo=True)
2432 @command('debuginstall', [], '', norepo=True)
2419 def debuginstall(ui):
2433 def debuginstall(ui):
2420 '''test Mercurial installation
2434 '''test Mercurial installation
2421
2435
2422 Returns 0 on success.
2436 Returns 0 on success.
2423 '''
2437 '''
2424
2438
2425 def writetemp(contents):
2439 def writetemp(contents):
2426 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2440 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2427 f = os.fdopen(fd, "wb")
2441 f = os.fdopen(fd, "wb")
2428 f.write(contents)
2442 f.write(contents)
2429 f.close()
2443 f.close()
2430 return name
2444 return name
2431
2445
2432 problems = 0
2446 problems = 0
2433
2447
2434 # encoding
2448 # encoding
2435 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2449 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2436 try:
2450 try:
2437 encoding.fromlocal("test")
2451 encoding.fromlocal("test")
2438 except error.Abort as inst:
2452 except error.Abort as inst:
2439 ui.write(" %s\n" % inst)
2453 ui.write(" %s\n" % inst)
2440 ui.write(_(" (check that your locale is properly set)\n"))
2454 ui.write(_(" (check that your locale is properly set)\n"))
2441 problems += 1
2455 problems += 1
2442
2456
2443 # Python
2457 # Python
2444 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2458 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2445 ui.status(_("checking Python version (%s)\n")
2459 ui.status(_("checking Python version (%s)\n")
2446 % ("%s.%s.%s" % sys.version_info[:3]))
2460 % ("%s.%s.%s" % sys.version_info[:3]))
2447 ui.status(_("checking Python lib (%s)...\n")
2461 ui.status(_("checking Python lib (%s)...\n")
2448 % os.path.dirname(os.__file__))
2462 % os.path.dirname(os.__file__))
2449
2463
2450 # compiled modules
2464 # compiled modules
2451 ui.status(_("checking installed modules (%s)...\n")
2465 ui.status(_("checking installed modules (%s)...\n")
2452 % os.path.dirname(__file__))
2466 % os.path.dirname(__file__))
2453 try:
2467 try:
2454 import bdiff, mpatch, base85, osutil
2468 import bdiff, mpatch, base85, osutil
2455 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2469 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2456 except Exception as inst:
2470 except Exception as inst:
2457 ui.write(" %s\n" % inst)
2471 ui.write(" %s\n" % inst)
2458 ui.write(_(" One or more extensions could not be found"))
2472 ui.write(_(" One or more extensions could not be found"))
2459 ui.write(_(" (check that you compiled the extensions)\n"))
2473 ui.write(_(" (check that you compiled the extensions)\n"))
2460 problems += 1
2474 problems += 1
2461
2475
2462 # templates
2476 # templates
2463 import templater
2477 import templater
2464 p = templater.templatepaths()
2478 p = templater.templatepaths()
2465 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2479 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2466 if p:
2480 if p:
2467 m = templater.templatepath("map-cmdline.default")
2481 m = templater.templatepath("map-cmdline.default")
2468 if m:
2482 if m:
2469 # template found, check if it is working
2483 # template found, check if it is working
2470 try:
2484 try:
2471 templater.templater(m)
2485 templater.templater(m)
2472 except Exception as inst:
2486 except Exception as inst:
2473 ui.write(" %s\n" % inst)
2487 ui.write(" %s\n" % inst)
2474 p = None
2488 p = None
2475 else:
2489 else:
2476 ui.write(_(" template 'default' not found\n"))
2490 ui.write(_(" template 'default' not found\n"))
2477 p = None
2491 p = None
2478 else:
2492 else:
2479 ui.write(_(" no template directories found\n"))
2493 ui.write(_(" no template directories found\n"))
2480 if not p:
2494 if not p:
2481 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2495 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2482 problems += 1
2496 problems += 1
2483
2497
2484 # editor
2498 # editor
2485 ui.status(_("checking commit editor...\n"))
2499 ui.status(_("checking commit editor...\n"))
2486 editor = ui.geteditor()
2500 editor = ui.geteditor()
2487 editor = util.expandpath(editor)
2501 editor = util.expandpath(editor)
2488 cmdpath = util.findexe(shlex.split(editor)[0])
2502 cmdpath = util.findexe(shlex.split(editor)[0])
2489 if not cmdpath:
2503 if not cmdpath:
2490 if editor == 'vi':
2504 if editor == 'vi':
2491 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2505 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2492 ui.write(_(" (specify a commit editor in your configuration"
2506 ui.write(_(" (specify a commit editor in your configuration"
2493 " file)\n"))
2507 " file)\n"))
2494 else:
2508 else:
2495 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2509 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2496 ui.write(_(" (specify a commit editor in your configuration"
2510 ui.write(_(" (specify a commit editor in your configuration"
2497 " file)\n"))
2511 " file)\n"))
2498 problems += 1
2512 problems += 1
2499
2513
2500 # check username
2514 # check username
2501 ui.status(_("checking username...\n"))
2515 ui.status(_("checking username...\n"))
2502 try:
2516 try:
2503 ui.username()
2517 ui.username()
2504 except error.Abort as e:
2518 except error.Abort as e:
2505 ui.write(" %s\n" % e)
2519 ui.write(" %s\n" % e)
2506 ui.write(_(" (specify a username in your configuration file)\n"))
2520 ui.write(_(" (specify a username in your configuration file)\n"))
2507 problems += 1
2521 problems += 1
2508
2522
2509 if not problems:
2523 if not problems:
2510 ui.status(_("no problems detected\n"))
2524 ui.status(_("no problems detected\n"))
2511 else:
2525 else:
2512 ui.write(_("%s problems detected,"
2526 ui.write(_("%s problems detected,"
2513 " please check your install!\n") % problems)
2527 " please check your install!\n") % problems)
2514
2528
2515 return problems
2529 return problems
2516
2530
2517 @command('debugknown', [], _('REPO ID...'), norepo=True)
2531 @command('debugknown', [], _('REPO ID...'), norepo=True)
2518 def debugknown(ui, repopath, *ids, **opts):
2532 def debugknown(ui, repopath, *ids, **opts):
2519 """test whether node ids are known to a repo
2533 """test whether node ids are known to a repo
2520
2534
2521 Every ID must be a full-length hex node id string. Returns a list of 0s
2535 Every ID must be a full-length hex node id string. Returns a list of 0s
2522 and 1s indicating unknown/known.
2536 and 1s indicating unknown/known.
2523 """
2537 """
2524 repo = hg.peer(ui, opts, repopath)
2538 repo = hg.peer(ui, opts, repopath)
2525 if not repo.capable('known'):
2539 if not repo.capable('known'):
2526 raise error.Abort("known() not supported by target repository")
2540 raise error.Abort("known() not supported by target repository")
2527 flags = repo.known([bin(s) for s in ids])
2541 flags = repo.known([bin(s) for s in ids])
2528 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2542 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2529
2543
2530 @command('debuglabelcomplete', [], _('LABEL...'))
2544 @command('debuglabelcomplete', [], _('LABEL...'))
2531 def debuglabelcomplete(ui, repo, *args):
2545 def debuglabelcomplete(ui, repo, *args):
2532 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2546 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2533 debugnamecomplete(ui, repo, *args)
2547 debugnamecomplete(ui, repo, *args)
2534
2548
2535 @command('debugmergestate', [], '')
2549 @command('debugmergestate', [], '')
2536 def debugmergestate(ui, repo, *args):
2550 def debugmergestate(ui, repo, *args):
2537 """print merge state
2551 """print merge state
2538
2552
2539 Use --verbose to print out information about whether v1 or v2 merge state
2553 Use --verbose to print out information about whether v1 or v2 merge state
2540 was chosen."""
2554 was chosen."""
2541 def _hashornull(h):
2555 def _hashornull(h):
2542 if h == nullhex:
2556 if h == nullhex:
2543 return 'null'
2557 return 'null'
2544 else:
2558 else:
2545 return h
2559 return h
2546
2560
2547 def printrecords(version):
2561 def printrecords(version):
2548 ui.write(('* version %s records\n') % version)
2562 ui.write(('* version %s records\n') % version)
2549 if version == 1:
2563 if version == 1:
2550 records = v1records
2564 records = v1records
2551 else:
2565 else:
2552 records = v2records
2566 records = v2records
2553
2567
2554 for rtype, record in records:
2568 for rtype, record in records:
2555 # pretty print some record types
2569 # pretty print some record types
2556 if rtype == 'L':
2570 if rtype == 'L':
2557 ui.write(('local: %s\n') % record)
2571 ui.write(('local: %s\n') % record)
2558 elif rtype == 'O':
2572 elif rtype == 'O':
2559 ui.write(('other: %s\n') % record)
2573 ui.write(('other: %s\n') % record)
2560 elif rtype == 'm':
2574 elif rtype == 'm':
2561 driver, mdstate = record.split('\0', 1)
2575 driver, mdstate = record.split('\0', 1)
2562 ui.write(('merge driver: %s (state "%s")\n')
2576 ui.write(('merge driver: %s (state "%s")\n')
2563 % (driver, mdstate))
2577 % (driver, mdstate))
2564 elif rtype in 'FDC':
2578 elif rtype in 'FDC':
2565 r = record.split('\0')
2579 r = record.split('\0')
2566 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2580 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2567 if version == 1:
2581 if version == 1:
2568 onode = 'not stored in v1 format'
2582 onode = 'not stored in v1 format'
2569 flags = r[7]
2583 flags = r[7]
2570 else:
2584 else:
2571 onode, flags = r[7:9]
2585 onode, flags = r[7:9]
2572 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
2586 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
2573 % (f, rtype, state, _hashornull(hash)))
2587 % (f, rtype, state, _hashornull(hash)))
2574 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2588 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2575 ui.write((' ancestor path: %s (node %s)\n')
2589 ui.write((' ancestor path: %s (node %s)\n')
2576 % (afile, _hashornull(anode)))
2590 % (afile, _hashornull(anode)))
2577 ui.write((' other path: %s (node %s)\n')
2591 ui.write((' other path: %s (node %s)\n')
2578 % (ofile, _hashornull(onode)))
2592 % (ofile, _hashornull(onode)))
2579 else:
2593 else:
2580 ui.write(('unrecognized entry: %s\t%s\n')
2594 ui.write(('unrecognized entry: %s\t%s\n')
2581 % (rtype, record.replace('\0', '\t')))
2595 % (rtype, record.replace('\0', '\t')))
2582
2596
2583 # Avoid mergestate.read() since it may raise an exception for unsupported
2597 # Avoid mergestate.read() since it may raise an exception for unsupported
2584 # merge state records. We shouldn't be doing this, but this is OK since this
2598 # merge state records. We shouldn't be doing this, but this is OK since this
2585 # command is pretty low-level.
2599 # command is pretty low-level.
2586 ms = mergemod.mergestate(repo)
2600 ms = mergemod.mergestate(repo)
2587
2601
2588 # sort so that reasonable information is on top
2602 # sort so that reasonable information is on top
2589 v1records = ms._readrecordsv1()
2603 v1records = ms._readrecordsv1()
2590 v2records = ms._readrecordsv2()
2604 v2records = ms._readrecordsv2()
2591 order = 'LOm'
2605 order = 'LOm'
2592 def key(r):
2606 def key(r):
2593 idx = order.find(r[0])
2607 idx = order.find(r[0])
2594 if idx == -1:
2608 if idx == -1:
2595 return (1, r[1])
2609 return (1, r[1])
2596 else:
2610 else:
2597 return (0, idx)
2611 return (0, idx)
2598 v1records.sort(key=key)
2612 v1records.sort(key=key)
2599 v2records.sort(key=key)
2613 v2records.sort(key=key)
2600
2614
2601 if not v1records and not v2records:
2615 if not v1records and not v2records:
2602 ui.write(('no merge state found\n'))
2616 ui.write(('no merge state found\n'))
2603 elif not v2records:
2617 elif not v2records:
2604 ui.note(('no version 2 merge state\n'))
2618 ui.note(('no version 2 merge state\n'))
2605 printrecords(1)
2619 printrecords(1)
2606 elif ms._v1v2match(v1records, v2records):
2620 elif ms._v1v2match(v1records, v2records):
2607 ui.note(('v1 and v2 states match: using v2\n'))
2621 ui.note(('v1 and v2 states match: using v2\n'))
2608 printrecords(2)
2622 printrecords(2)
2609 else:
2623 else:
2610 ui.note(('v1 and v2 states mismatch: using v1\n'))
2624 ui.note(('v1 and v2 states mismatch: using v1\n'))
2611 printrecords(1)
2625 printrecords(1)
2612 if ui.verbose:
2626 if ui.verbose:
2613 printrecords(2)
2627 printrecords(2)
2614
2628
2615 @command('debugnamecomplete', [], _('NAME...'))
2629 @command('debugnamecomplete', [], _('NAME...'))
2616 def debugnamecomplete(ui, repo, *args):
2630 def debugnamecomplete(ui, repo, *args):
2617 '''complete "names" - tags, open branch names, bookmark names'''
2631 '''complete "names" - tags, open branch names, bookmark names'''
2618
2632
2619 names = set()
2633 names = set()
2620 # since we previously only listed open branches, we will handle that
2634 # since we previously only listed open branches, we will handle that
2621 # specially (after this for loop)
2635 # specially (after this for loop)
2622 for name, ns in repo.names.iteritems():
2636 for name, ns in repo.names.iteritems():
2623 if name != 'branches':
2637 if name != 'branches':
2624 names.update(ns.listnames(repo))
2638 names.update(ns.listnames(repo))
2625 names.update(tag for (tag, heads, tip, closed)
2639 names.update(tag for (tag, heads, tip, closed)
2626 in repo.branchmap().iterbranches() if not closed)
2640 in repo.branchmap().iterbranches() if not closed)
2627 completions = set()
2641 completions = set()
2628 if not args:
2642 if not args:
2629 args = ['']
2643 args = ['']
2630 for a in args:
2644 for a in args:
2631 completions.update(n for n in names if n.startswith(a))
2645 completions.update(n for n in names if n.startswith(a))
2632 ui.write('\n'.join(sorted(completions)))
2646 ui.write('\n'.join(sorted(completions)))
2633 ui.write('\n')
2647 ui.write('\n')
2634
2648
2635 @command('debuglocks',
2649 @command('debuglocks',
2636 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2650 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2637 ('W', 'force-wlock', None,
2651 ('W', 'force-wlock', None,
2638 _('free the working state lock (DANGEROUS)'))],
2652 _('free the working state lock (DANGEROUS)'))],
2639 _('[OPTION]...'))
2653 _('[OPTION]...'))
2640 def debuglocks(ui, repo, **opts):
2654 def debuglocks(ui, repo, **opts):
2641 """show or modify state of locks
2655 """show or modify state of locks
2642
2656
2643 By default, this command will show which locks are held. This
2657 By default, this command will show which locks are held. This
2644 includes the user and process holding the lock, the amount of time
2658 includes the user and process holding the lock, the amount of time
2645 the lock has been held, and the machine name where the process is
2659 the lock has been held, and the machine name where the process is
2646 running if it's not local.
2660 running if it's not local.
2647
2661
2648 Locks protect the integrity of Mercurial's data, so should be
2662 Locks protect the integrity of Mercurial's data, so should be
2649 treated with care. System crashes or other interruptions may cause
2663 treated with care. System crashes or other interruptions may cause
2650 locks to not be properly released, though Mercurial will usually
2664 locks to not be properly released, though Mercurial will usually
2651 detect and remove such stale locks automatically.
2665 detect and remove such stale locks automatically.
2652
2666
2653 However, detecting stale locks may not always be possible (for
2667 However, detecting stale locks may not always be possible (for
2654 instance, on a shared filesystem). Removing locks may also be
2668 instance, on a shared filesystem). Removing locks may also be
2655 blocked by filesystem permissions.
2669 blocked by filesystem permissions.
2656
2670
2657 Returns 0 if no locks are held.
2671 Returns 0 if no locks are held.
2658
2672
2659 """
2673 """
2660
2674
2661 if opts.get('force_lock'):
2675 if opts.get('force_lock'):
2662 repo.svfs.unlink('lock')
2676 repo.svfs.unlink('lock')
2663 if opts.get('force_wlock'):
2677 if opts.get('force_wlock'):
2664 repo.vfs.unlink('wlock')
2678 repo.vfs.unlink('wlock')
2665 if opts.get('force_lock') or opts.get('force_lock'):
2679 if opts.get('force_lock') or opts.get('force_lock'):
2666 return 0
2680 return 0
2667
2681
2668 now = time.time()
2682 now = time.time()
2669 held = 0
2683 held = 0
2670
2684
2671 def report(vfs, name, method):
2685 def report(vfs, name, method):
2672 # this causes stale locks to get reaped for more accurate reporting
2686 # this causes stale locks to get reaped for more accurate reporting
2673 try:
2687 try:
2674 l = method(False)
2688 l = method(False)
2675 except error.LockHeld:
2689 except error.LockHeld:
2676 l = None
2690 l = None
2677
2691
2678 if l:
2692 if l:
2679 l.release()
2693 l.release()
2680 else:
2694 else:
2681 try:
2695 try:
2682 stat = vfs.lstat(name)
2696 stat = vfs.lstat(name)
2683 age = now - stat.st_mtime
2697 age = now - stat.st_mtime
2684 user = util.username(stat.st_uid)
2698 user = util.username(stat.st_uid)
2685 locker = vfs.readlock(name)
2699 locker = vfs.readlock(name)
2686 if ":" in locker:
2700 if ":" in locker:
2687 host, pid = locker.split(':')
2701 host, pid = locker.split(':')
2688 if host == socket.gethostname():
2702 if host == socket.gethostname():
2689 locker = 'user %s, process %s' % (user, pid)
2703 locker = 'user %s, process %s' % (user, pid)
2690 else:
2704 else:
2691 locker = 'user %s, process %s, host %s' \
2705 locker = 'user %s, process %s, host %s' \
2692 % (user, pid, host)
2706 % (user, pid, host)
2693 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2707 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2694 return 1
2708 return 1
2695 except OSError as e:
2709 except OSError as e:
2696 if e.errno != errno.ENOENT:
2710 if e.errno != errno.ENOENT:
2697 raise
2711 raise
2698
2712
2699 ui.write("%-6s free\n" % (name + ":"))
2713 ui.write("%-6s free\n" % (name + ":"))
2700 return 0
2714 return 0
2701
2715
2702 held += report(repo.svfs, "lock", repo.lock)
2716 held += report(repo.svfs, "lock", repo.lock)
2703 held += report(repo.vfs, "wlock", repo.wlock)
2717 held += report(repo.vfs, "wlock", repo.wlock)
2704
2718
2705 return held
2719 return held
2706
2720
2707 @command('debugobsolete',
2721 @command('debugobsolete',
2708 [('', 'flags', 0, _('markers flag')),
2722 [('', 'flags', 0, _('markers flag')),
2709 ('', 'record-parents', False,
2723 ('', 'record-parents', False,
2710 _('record parent information for the precursor')),
2724 _('record parent information for the precursor')),
2711 ('r', 'rev', [], _('display markers relevant to REV')),
2725 ('r', 'rev', [], _('display markers relevant to REV')),
2712 ] + commitopts2,
2726 ] + commitopts2,
2713 _('[OBSOLETED [REPLACEMENT ...]]'))
2727 _('[OBSOLETED [REPLACEMENT ...]]'))
2714 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2728 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2715 """create arbitrary obsolete marker
2729 """create arbitrary obsolete marker
2716
2730
2717 With no arguments, displays the list of obsolescence markers."""
2731 With no arguments, displays the list of obsolescence markers."""
2718
2732
2719 def parsenodeid(s):
2733 def parsenodeid(s):
2720 try:
2734 try:
2721 # We do not use revsingle/revrange functions here to accept
2735 # We do not use revsingle/revrange functions here to accept
2722 # arbitrary node identifiers, possibly not present in the
2736 # arbitrary node identifiers, possibly not present in the
2723 # local repository.
2737 # local repository.
2724 n = bin(s)
2738 n = bin(s)
2725 if len(n) != len(nullid):
2739 if len(n) != len(nullid):
2726 raise TypeError()
2740 raise TypeError()
2727 return n
2741 return n
2728 except TypeError:
2742 except TypeError:
2729 raise error.Abort('changeset references must be full hexadecimal '
2743 raise error.Abort('changeset references must be full hexadecimal '
2730 'node identifiers')
2744 'node identifiers')
2731
2745
2732 if precursor is not None:
2746 if precursor is not None:
2733 if opts['rev']:
2747 if opts['rev']:
2734 raise error.Abort('cannot select revision when creating marker')
2748 raise error.Abort('cannot select revision when creating marker')
2735 metadata = {}
2749 metadata = {}
2736 metadata['user'] = opts['user'] or ui.username()
2750 metadata['user'] = opts['user'] or ui.username()
2737 succs = tuple(parsenodeid(succ) for succ in successors)
2751 succs = tuple(parsenodeid(succ) for succ in successors)
2738 l = repo.lock()
2752 l = repo.lock()
2739 try:
2753 try:
2740 tr = repo.transaction('debugobsolete')
2754 tr = repo.transaction('debugobsolete')
2741 try:
2755 try:
2742 date = opts.get('date')
2756 date = opts.get('date')
2743 if date:
2757 if date:
2744 date = util.parsedate(date)
2758 date = util.parsedate(date)
2745 else:
2759 else:
2746 date = None
2760 date = None
2747 prec = parsenodeid(precursor)
2761 prec = parsenodeid(precursor)
2748 parents = None
2762 parents = None
2749 if opts['record_parents']:
2763 if opts['record_parents']:
2750 if prec not in repo.unfiltered():
2764 if prec not in repo.unfiltered():
2751 raise error.Abort('cannot used --record-parents on '
2765 raise error.Abort('cannot used --record-parents on '
2752 'unknown changesets')
2766 'unknown changesets')
2753 parents = repo.unfiltered()[prec].parents()
2767 parents = repo.unfiltered()[prec].parents()
2754 parents = tuple(p.node() for p in parents)
2768 parents = tuple(p.node() for p in parents)
2755 repo.obsstore.create(tr, prec, succs, opts['flags'],
2769 repo.obsstore.create(tr, prec, succs, opts['flags'],
2756 parents=parents, date=date,
2770 parents=parents, date=date,
2757 metadata=metadata)
2771 metadata=metadata)
2758 tr.close()
2772 tr.close()
2759 except ValueError as exc:
2773 except ValueError as exc:
2760 raise error.Abort(_('bad obsmarker input: %s') % exc)
2774 raise error.Abort(_('bad obsmarker input: %s') % exc)
2761 finally:
2775 finally:
2762 tr.release()
2776 tr.release()
2763 finally:
2777 finally:
2764 l.release()
2778 l.release()
2765 else:
2779 else:
2766 if opts['rev']:
2780 if opts['rev']:
2767 revs = scmutil.revrange(repo, opts['rev'])
2781 revs = scmutil.revrange(repo, opts['rev'])
2768 nodes = [repo[r].node() for r in revs]
2782 nodes = [repo[r].node() for r in revs]
2769 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2783 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2770 markers.sort(key=lambda x: x._data)
2784 markers.sort(key=lambda x: x._data)
2771 else:
2785 else:
2772 markers = obsolete.getmarkers(repo)
2786 markers = obsolete.getmarkers(repo)
2773
2787
2774 for m in markers:
2788 for m in markers:
2775 cmdutil.showmarker(ui, m)
2789 cmdutil.showmarker(ui, m)
2776
2790
2777 @command('debugpathcomplete',
2791 @command('debugpathcomplete',
2778 [('f', 'full', None, _('complete an entire path')),
2792 [('f', 'full', None, _('complete an entire path')),
2779 ('n', 'normal', None, _('show only normal files')),
2793 ('n', 'normal', None, _('show only normal files')),
2780 ('a', 'added', None, _('show only added files')),
2794 ('a', 'added', None, _('show only added files')),
2781 ('r', 'removed', None, _('show only removed files'))],
2795 ('r', 'removed', None, _('show only removed files'))],
2782 _('FILESPEC...'))
2796 _('FILESPEC...'))
2783 def debugpathcomplete(ui, repo, *specs, **opts):
2797 def debugpathcomplete(ui, repo, *specs, **opts):
2784 '''complete part or all of a tracked path
2798 '''complete part or all of a tracked path
2785
2799
2786 This command supports shells that offer path name completion. It
2800 This command supports shells that offer path name completion. It
2787 currently completes only files already known to the dirstate.
2801 currently completes only files already known to the dirstate.
2788
2802
2789 Completion extends only to the next path segment unless
2803 Completion extends only to the next path segment unless
2790 --full is specified, in which case entire paths are used.'''
2804 --full is specified, in which case entire paths are used.'''
2791
2805
2792 def complete(path, acceptable):
2806 def complete(path, acceptable):
2793 dirstate = repo.dirstate
2807 dirstate = repo.dirstate
2794 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2808 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2795 rootdir = repo.root + os.sep
2809 rootdir = repo.root + os.sep
2796 if spec != repo.root and not spec.startswith(rootdir):
2810 if spec != repo.root and not spec.startswith(rootdir):
2797 return [], []
2811 return [], []
2798 if os.path.isdir(spec):
2812 if os.path.isdir(spec):
2799 spec += '/'
2813 spec += '/'
2800 spec = spec[len(rootdir):]
2814 spec = spec[len(rootdir):]
2801 fixpaths = os.sep != '/'
2815 fixpaths = os.sep != '/'
2802 if fixpaths:
2816 if fixpaths:
2803 spec = spec.replace(os.sep, '/')
2817 spec = spec.replace(os.sep, '/')
2804 speclen = len(spec)
2818 speclen = len(spec)
2805 fullpaths = opts['full']
2819 fullpaths = opts['full']
2806 files, dirs = set(), set()
2820 files, dirs = set(), set()
2807 adddir, addfile = dirs.add, files.add
2821 adddir, addfile = dirs.add, files.add
2808 for f, st in dirstate.iteritems():
2822 for f, st in dirstate.iteritems():
2809 if f.startswith(spec) and st[0] in acceptable:
2823 if f.startswith(spec) and st[0] in acceptable:
2810 if fixpaths:
2824 if fixpaths:
2811 f = f.replace('/', os.sep)
2825 f = f.replace('/', os.sep)
2812 if fullpaths:
2826 if fullpaths:
2813 addfile(f)
2827 addfile(f)
2814 continue
2828 continue
2815 s = f.find(os.sep, speclen)
2829 s = f.find(os.sep, speclen)
2816 if s >= 0:
2830 if s >= 0:
2817 adddir(f[:s])
2831 adddir(f[:s])
2818 else:
2832 else:
2819 addfile(f)
2833 addfile(f)
2820 return files, dirs
2834 return files, dirs
2821
2835
2822 acceptable = ''
2836 acceptable = ''
2823 if opts['normal']:
2837 if opts['normal']:
2824 acceptable += 'nm'
2838 acceptable += 'nm'
2825 if opts['added']:
2839 if opts['added']:
2826 acceptable += 'a'
2840 acceptable += 'a'
2827 if opts['removed']:
2841 if opts['removed']:
2828 acceptable += 'r'
2842 acceptable += 'r'
2829 cwd = repo.getcwd()
2843 cwd = repo.getcwd()
2830 if not specs:
2844 if not specs:
2831 specs = ['.']
2845 specs = ['.']
2832
2846
2833 files, dirs = set(), set()
2847 files, dirs = set(), set()
2834 for spec in specs:
2848 for spec in specs:
2835 f, d = complete(spec, acceptable or 'nmar')
2849 f, d = complete(spec, acceptable or 'nmar')
2836 files.update(f)
2850 files.update(f)
2837 dirs.update(d)
2851 dirs.update(d)
2838 files.update(dirs)
2852 files.update(dirs)
2839 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2853 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2840 ui.write('\n')
2854 ui.write('\n')
2841
2855
2842 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2856 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2843 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2857 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2844 '''access the pushkey key/value protocol
2858 '''access the pushkey key/value protocol
2845
2859
2846 With two args, list the keys in the given namespace.
2860 With two args, list the keys in the given namespace.
2847
2861
2848 With five args, set a key to new if it currently is set to old.
2862 With five args, set a key to new if it currently is set to old.
2849 Reports success or failure.
2863 Reports success or failure.
2850 '''
2864 '''
2851
2865
2852 target = hg.peer(ui, {}, repopath)
2866 target = hg.peer(ui, {}, repopath)
2853 if keyinfo:
2867 if keyinfo:
2854 key, old, new = keyinfo
2868 key, old, new = keyinfo
2855 r = target.pushkey(namespace, key, old, new)
2869 r = target.pushkey(namespace, key, old, new)
2856 ui.status(str(r) + '\n')
2870 ui.status(str(r) + '\n')
2857 return not r
2871 return not r
2858 else:
2872 else:
2859 for k, v in sorted(target.listkeys(namespace).iteritems()):
2873 for k, v in sorted(target.listkeys(namespace).iteritems()):
2860 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2874 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2861 v.encode('string-escape')))
2875 v.encode('string-escape')))
2862
2876
2863 @command('debugpvec', [], _('A B'))
2877 @command('debugpvec', [], _('A B'))
2864 def debugpvec(ui, repo, a, b=None):
2878 def debugpvec(ui, repo, a, b=None):
2865 ca = scmutil.revsingle(repo, a)
2879 ca = scmutil.revsingle(repo, a)
2866 cb = scmutil.revsingle(repo, b)
2880 cb = scmutil.revsingle(repo, b)
2867 pa = pvec.ctxpvec(ca)
2881 pa = pvec.ctxpvec(ca)
2868 pb = pvec.ctxpvec(cb)
2882 pb = pvec.ctxpvec(cb)
2869 if pa == pb:
2883 if pa == pb:
2870 rel = "="
2884 rel = "="
2871 elif pa > pb:
2885 elif pa > pb:
2872 rel = ">"
2886 rel = ">"
2873 elif pa < pb:
2887 elif pa < pb:
2874 rel = "<"
2888 rel = "<"
2875 elif pa | pb:
2889 elif pa | pb:
2876 rel = "|"
2890 rel = "|"
2877 ui.write(_("a: %s\n") % pa)
2891 ui.write(_("a: %s\n") % pa)
2878 ui.write(_("b: %s\n") % pb)
2892 ui.write(_("b: %s\n") % pb)
2879 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2893 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2880 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2894 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2881 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2895 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2882 pa.distance(pb), rel))
2896 pa.distance(pb), rel))
2883
2897
2884 @command('debugrebuilddirstate|debugrebuildstate',
2898 @command('debugrebuilddirstate|debugrebuildstate',
2885 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2899 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2886 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2900 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2887 'the working copy parent')),
2901 'the working copy parent')),
2888 ],
2902 ],
2889 _('[-r REV]'))
2903 _('[-r REV]'))
2890 def debugrebuilddirstate(ui, repo, rev, **opts):
2904 def debugrebuilddirstate(ui, repo, rev, **opts):
2891 """rebuild the dirstate as it would look like for the given revision
2905 """rebuild the dirstate as it would look like for the given revision
2892
2906
2893 If no revision is specified the first current parent will be used.
2907 If no revision is specified the first current parent will be used.
2894
2908
2895 The dirstate will be set to the files of the given revision.
2909 The dirstate will be set to the files of the given revision.
2896 The actual working directory content or existing dirstate
2910 The actual working directory content or existing dirstate
2897 information such as adds or removes is not considered.
2911 information such as adds or removes is not considered.
2898
2912
2899 ``minimal`` will only rebuild the dirstate status for files that claim to be
2913 ``minimal`` will only rebuild the dirstate status for files that claim to be
2900 tracked but are not in the parent manifest, or that exist in the parent
2914 tracked but are not in the parent manifest, or that exist in the parent
2901 manifest but are not in the dirstate. It will not change adds, removes, or
2915 manifest but are not in the dirstate. It will not change adds, removes, or
2902 modified files that are in the working copy parent.
2916 modified files that are in the working copy parent.
2903
2917
2904 One use of this command is to make the next :hg:`status` invocation
2918 One use of this command is to make the next :hg:`status` invocation
2905 check the actual file content.
2919 check the actual file content.
2906 """
2920 """
2907 ctx = scmutil.revsingle(repo, rev)
2921 ctx = scmutil.revsingle(repo, rev)
2908 wlock = repo.wlock()
2922 wlock = repo.wlock()
2909 try:
2923 try:
2910 dirstate = repo.dirstate
2924 dirstate = repo.dirstate
2911
2925
2912 # See command doc for what minimal does.
2926 # See command doc for what minimal does.
2913 if opts.get('minimal'):
2927 if opts.get('minimal'):
2914 dirstatefiles = set(dirstate)
2928 dirstatefiles = set(dirstate)
2915 ctxfiles = set(ctx.manifest().keys())
2929 ctxfiles = set(ctx.manifest().keys())
2916 for file in (dirstatefiles | ctxfiles):
2930 for file in (dirstatefiles | ctxfiles):
2917 indirstate = file in dirstatefiles
2931 indirstate = file in dirstatefiles
2918 inctx = file in ctxfiles
2932 inctx = file in ctxfiles
2919
2933
2920 if indirstate and not inctx and dirstate[file] != 'a':
2934 if indirstate and not inctx and dirstate[file] != 'a':
2921 dirstate.drop(file)
2935 dirstate.drop(file)
2922 elif inctx and not indirstate:
2936 elif inctx and not indirstate:
2923 dirstate.normallookup(file)
2937 dirstate.normallookup(file)
2924 else:
2938 else:
2925 dirstate.rebuild(ctx.node(), ctx.manifest())
2939 dirstate.rebuild(ctx.node(), ctx.manifest())
2926 finally:
2940 finally:
2927 wlock.release()
2941 wlock.release()
2928
2942
2929 @command('debugrebuildfncache', [], '')
2943 @command('debugrebuildfncache', [], '')
2930 def debugrebuildfncache(ui, repo):
2944 def debugrebuildfncache(ui, repo):
2931 """rebuild the fncache file"""
2945 """rebuild the fncache file"""
2932 repair.rebuildfncache(ui, repo)
2946 repair.rebuildfncache(ui, repo)
2933
2947
2934 @command('debugrename',
2948 @command('debugrename',
2935 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2949 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2936 _('[-r REV] FILE'))
2950 _('[-r REV] FILE'))
2937 def debugrename(ui, repo, file1, *pats, **opts):
2951 def debugrename(ui, repo, file1, *pats, **opts):
2938 """dump rename information"""
2952 """dump rename information"""
2939
2953
2940 ctx = scmutil.revsingle(repo, opts.get('rev'))
2954 ctx = scmutil.revsingle(repo, opts.get('rev'))
2941 m = scmutil.match(ctx, (file1,) + pats, opts)
2955 m = scmutil.match(ctx, (file1,) + pats, opts)
2942 for abs in ctx.walk(m):
2956 for abs in ctx.walk(m):
2943 fctx = ctx[abs]
2957 fctx = ctx[abs]
2944 o = fctx.filelog().renamed(fctx.filenode())
2958 o = fctx.filelog().renamed(fctx.filenode())
2945 rel = m.rel(abs)
2959 rel = m.rel(abs)
2946 if o:
2960 if o:
2947 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2961 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2948 else:
2962 else:
2949 ui.write(_("%s not renamed\n") % rel)
2963 ui.write(_("%s not renamed\n") % rel)
2950
2964
2951 @command('debugrevlog',
2965 @command('debugrevlog',
2952 [('c', 'changelog', False, _('open changelog')),
2966 [('c', 'changelog', False, _('open changelog')),
2953 ('m', 'manifest', False, _('open manifest')),
2967 ('m', 'manifest', False, _('open manifest')),
2954 ('', 'dir', False, _('open directory manifest')),
2968 ('', 'dir', False, _('open directory manifest')),
2955 ('d', 'dump', False, _('dump index data'))],
2969 ('d', 'dump', False, _('dump index data'))],
2956 _('-c|-m|FILE'),
2970 _('-c|-m|FILE'),
2957 optionalrepo=True)
2971 optionalrepo=True)
2958 def debugrevlog(ui, repo, file_=None, **opts):
2972 def debugrevlog(ui, repo, file_=None, **opts):
2959 """show data and statistics about a revlog"""
2973 """show data and statistics about a revlog"""
2960 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2974 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2961
2975
2962 if opts.get("dump"):
2976 if opts.get("dump"):
2963 numrevs = len(r)
2977 numrevs = len(r)
2964 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2978 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2965 " rawsize totalsize compression heads chainlen\n")
2979 " rawsize totalsize compression heads chainlen\n")
2966 ts = 0
2980 ts = 0
2967 heads = set()
2981 heads = set()
2968
2982
2969 for rev in xrange(numrevs):
2983 for rev in xrange(numrevs):
2970 dbase = r.deltaparent(rev)
2984 dbase = r.deltaparent(rev)
2971 if dbase == -1:
2985 if dbase == -1:
2972 dbase = rev
2986 dbase = rev
2973 cbase = r.chainbase(rev)
2987 cbase = r.chainbase(rev)
2974 clen = r.chainlen(rev)
2988 clen = r.chainlen(rev)
2975 p1, p2 = r.parentrevs(rev)
2989 p1, p2 = r.parentrevs(rev)
2976 rs = r.rawsize(rev)
2990 rs = r.rawsize(rev)
2977 ts = ts + rs
2991 ts = ts + rs
2978 heads -= set(r.parentrevs(rev))
2992 heads -= set(r.parentrevs(rev))
2979 heads.add(rev)
2993 heads.add(rev)
2980 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2994 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2981 "%11d %5d %8d\n" %
2995 "%11d %5d %8d\n" %
2982 (rev, p1, p2, r.start(rev), r.end(rev),
2996 (rev, p1, p2, r.start(rev), r.end(rev),
2983 r.start(dbase), r.start(cbase),
2997 r.start(dbase), r.start(cbase),
2984 r.start(p1), r.start(p2),
2998 r.start(p1), r.start(p2),
2985 rs, ts, ts / r.end(rev), len(heads), clen))
2999 rs, ts, ts / r.end(rev), len(heads), clen))
2986 return 0
3000 return 0
2987
3001
2988 v = r.version
3002 v = r.version
2989 format = v & 0xFFFF
3003 format = v & 0xFFFF
2990 flags = []
3004 flags = []
2991 gdelta = False
3005 gdelta = False
2992 if v & revlog.REVLOGNGINLINEDATA:
3006 if v & revlog.REVLOGNGINLINEDATA:
2993 flags.append('inline')
3007 flags.append('inline')
2994 if v & revlog.REVLOGGENERALDELTA:
3008 if v & revlog.REVLOGGENERALDELTA:
2995 gdelta = True
3009 gdelta = True
2996 flags.append('generaldelta')
3010 flags.append('generaldelta')
2997 if not flags:
3011 if not flags:
2998 flags = ['(none)']
3012 flags = ['(none)']
2999
3013
3000 nummerges = 0
3014 nummerges = 0
3001 numfull = 0
3015 numfull = 0
3002 numprev = 0
3016 numprev = 0
3003 nump1 = 0
3017 nump1 = 0
3004 nump2 = 0
3018 nump2 = 0
3005 numother = 0
3019 numother = 0
3006 nump1prev = 0
3020 nump1prev = 0
3007 nump2prev = 0
3021 nump2prev = 0
3008 chainlengths = []
3022 chainlengths = []
3009
3023
3010 datasize = [None, 0, 0L]
3024 datasize = [None, 0, 0L]
3011 fullsize = [None, 0, 0L]
3025 fullsize = [None, 0, 0L]
3012 deltasize = [None, 0, 0L]
3026 deltasize = [None, 0, 0L]
3013
3027
3014 def addsize(size, l):
3028 def addsize(size, l):
3015 if l[0] is None or size < l[0]:
3029 if l[0] is None or size < l[0]:
3016 l[0] = size
3030 l[0] = size
3017 if size > l[1]:
3031 if size > l[1]:
3018 l[1] = size
3032 l[1] = size
3019 l[2] += size
3033 l[2] += size
3020
3034
3021 numrevs = len(r)
3035 numrevs = len(r)
3022 for rev in xrange(numrevs):
3036 for rev in xrange(numrevs):
3023 p1, p2 = r.parentrevs(rev)
3037 p1, p2 = r.parentrevs(rev)
3024 delta = r.deltaparent(rev)
3038 delta = r.deltaparent(rev)
3025 if format > 0:
3039 if format > 0:
3026 addsize(r.rawsize(rev), datasize)
3040 addsize(r.rawsize(rev), datasize)
3027 if p2 != nullrev:
3041 if p2 != nullrev:
3028 nummerges += 1
3042 nummerges += 1
3029 size = r.length(rev)
3043 size = r.length(rev)
3030 if delta == nullrev:
3044 if delta == nullrev:
3031 chainlengths.append(0)
3045 chainlengths.append(0)
3032 numfull += 1
3046 numfull += 1
3033 addsize(size, fullsize)
3047 addsize(size, fullsize)
3034 else:
3048 else:
3035 chainlengths.append(chainlengths[delta] + 1)
3049 chainlengths.append(chainlengths[delta] + 1)
3036 addsize(size, deltasize)
3050 addsize(size, deltasize)
3037 if delta == rev - 1:
3051 if delta == rev - 1:
3038 numprev += 1
3052 numprev += 1
3039 if delta == p1:
3053 if delta == p1:
3040 nump1prev += 1
3054 nump1prev += 1
3041 elif delta == p2:
3055 elif delta == p2:
3042 nump2prev += 1
3056 nump2prev += 1
3043 elif delta == p1:
3057 elif delta == p1:
3044 nump1 += 1
3058 nump1 += 1
3045 elif delta == p2:
3059 elif delta == p2:
3046 nump2 += 1
3060 nump2 += 1
3047 elif delta != nullrev:
3061 elif delta != nullrev:
3048 numother += 1
3062 numother += 1
3049
3063
3050 # Adjust size min value for empty cases
3064 # Adjust size min value for empty cases
3051 for size in (datasize, fullsize, deltasize):
3065 for size in (datasize, fullsize, deltasize):
3052 if size[0] is None:
3066 if size[0] is None:
3053 size[0] = 0
3067 size[0] = 0
3054
3068
3055 numdeltas = numrevs - numfull
3069 numdeltas = numrevs - numfull
3056 numoprev = numprev - nump1prev - nump2prev
3070 numoprev = numprev - nump1prev - nump2prev
3057 totalrawsize = datasize[2]
3071 totalrawsize = datasize[2]
3058 datasize[2] /= numrevs
3072 datasize[2] /= numrevs
3059 fulltotal = fullsize[2]
3073 fulltotal = fullsize[2]
3060 fullsize[2] /= numfull
3074 fullsize[2] /= numfull
3061 deltatotal = deltasize[2]
3075 deltatotal = deltasize[2]
3062 if numrevs - numfull > 0:
3076 if numrevs - numfull > 0:
3063 deltasize[2] /= numrevs - numfull
3077 deltasize[2] /= numrevs - numfull
3064 totalsize = fulltotal + deltatotal
3078 totalsize = fulltotal + deltatotal
3065 avgchainlen = sum(chainlengths) / numrevs
3079 avgchainlen = sum(chainlengths) / numrevs
3066 maxchainlen = max(chainlengths)
3080 maxchainlen = max(chainlengths)
3067 compratio = 1
3081 compratio = 1
3068 if totalsize:
3082 if totalsize:
3069 compratio = totalrawsize / totalsize
3083 compratio = totalrawsize / totalsize
3070
3084
3071 basedfmtstr = '%%%dd\n'
3085 basedfmtstr = '%%%dd\n'
3072 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3086 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3073
3087
3074 def dfmtstr(max):
3088 def dfmtstr(max):
3075 return basedfmtstr % len(str(max))
3089 return basedfmtstr % len(str(max))
3076 def pcfmtstr(max, padding=0):
3090 def pcfmtstr(max, padding=0):
3077 return basepcfmtstr % (len(str(max)), ' ' * padding)
3091 return basepcfmtstr % (len(str(max)), ' ' * padding)
3078
3092
3079 def pcfmt(value, total):
3093 def pcfmt(value, total):
3080 if total:
3094 if total:
3081 return (value, 100 * float(value) / total)
3095 return (value, 100 * float(value) / total)
3082 else:
3096 else:
3083 return value, 100.0
3097 return value, 100.0
3084
3098
3085 ui.write(('format : %d\n') % format)
3099 ui.write(('format : %d\n') % format)
3086 ui.write(('flags : %s\n') % ', '.join(flags))
3100 ui.write(('flags : %s\n') % ', '.join(flags))
3087
3101
3088 ui.write('\n')
3102 ui.write('\n')
3089 fmt = pcfmtstr(totalsize)
3103 fmt = pcfmtstr(totalsize)
3090 fmt2 = dfmtstr(totalsize)
3104 fmt2 = dfmtstr(totalsize)
3091 ui.write(('revisions : ') + fmt2 % numrevs)
3105 ui.write(('revisions : ') + fmt2 % numrevs)
3092 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3106 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3093 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3107 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3094 ui.write(('revisions : ') + fmt2 % numrevs)
3108 ui.write(('revisions : ') + fmt2 % numrevs)
3095 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3109 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3096 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3110 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3097 ui.write(('revision size : ') + fmt2 % totalsize)
3111 ui.write(('revision size : ') + fmt2 % totalsize)
3098 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3112 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3099 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3113 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3100
3114
3101 ui.write('\n')
3115 ui.write('\n')
3102 fmt = dfmtstr(max(avgchainlen, compratio))
3116 fmt = dfmtstr(max(avgchainlen, compratio))
3103 ui.write(('avg chain length : ') + fmt % avgchainlen)
3117 ui.write(('avg chain length : ') + fmt % avgchainlen)
3104 ui.write(('max chain length : ') + fmt % maxchainlen)
3118 ui.write(('max chain length : ') + fmt % maxchainlen)
3105 ui.write(('compression ratio : ') + fmt % compratio)
3119 ui.write(('compression ratio : ') + fmt % compratio)
3106
3120
3107 if format > 0:
3121 if format > 0:
3108 ui.write('\n')
3122 ui.write('\n')
3109 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3123 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3110 % tuple(datasize))
3124 % tuple(datasize))
3111 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3125 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3112 % tuple(fullsize))
3126 % tuple(fullsize))
3113 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3127 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3114 % tuple(deltasize))
3128 % tuple(deltasize))
3115
3129
3116 if numdeltas > 0:
3130 if numdeltas > 0:
3117 ui.write('\n')
3131 ui.write('\n')
3118 fmt = pcfmtstr(numdeltas)
3132 fmt = pcfmtstr(numdeltas)
3119 fmt2 = pcfmtstr(numdeltas, 4)
3133 fmt2 = pcfmtstr(numdeltas, 4)
3120 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3134 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3121 if numprev > 0:
3135 if numprev > 0:
3122 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3136 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3123 numprev))
3137 numprev))
3124 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3138 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3125 numprev))
3139 numprev))
3126 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3140 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3127 numprev))
3141 numprev))
3128 if gdelta:
3142 if gdelta:
3129 ui.write(('deltas against p1 : ')
3143 ui.write(('deltas against p1 : ')
3130 + fmt % pcfmt(nump1, numdeltas))
3144 + fmt % pcfmt(nump1, numdeltas))
3131 ui.write(('deltas against p2 : ')
3145 ui.write(('deltas against p2 : ')
3132 + fmt % pcfmt(nump2, numdeltas))
3146 + fmt % pcfmt(nump2, numdeltas))
3133 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3147 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3134 numdeltas))
3148 numdeltas))
3135
3149
3136 @command('debugrevspec',
3150 @command('debugrevspec',
3137 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3151 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3138 ('REVSPEC'))
3152 ('REVSPEC'))
3139 def debugrevspec(ui, repo, expr, **opts):
3153 def debugrevspec(ui, repo, expr, **opts):
3140 """parse and apply a revision specification
3154 """parse and apply a revision specification
3141
3155
3142 Use --verbose to print the parsed tree before and after aliases
3156 Use --verbose to print the parsed tree before and after aliases
3143 expansion.
3157 expansion.
3144 """
3158 """
3145 if ui.verbose:
3159 if ui.verbose:
3146 tree = revset.parse(expr, lookup=repo.__contains__)
3160 tree = revset.parse(expr, lookup=repo.__contains__)
3147 ui.note(revset.prettyformat(tree), "\n")
3161 ui.note(revset.prettyformat(tree), "\n")
3148 newtree = revset.findaliases(ui, tree)
3162 newtree = revset.findaliases(ui, tree)
3149 if newtree != tree:
3163 if newtree != tree:
3150 ui.note(revset.prettyformat(newtree), "\n")
3164 ui.note(revset.prettyformat(newtree), "\n")
3151 tree = newtree
3165 tree = newtree
3152 newtree = revset.foldconcat(tree)
3166 newtree = revset.foldconcat(tree)
3153 if newtree != tree:
3167 if newtree != tree:
3154 ui.note(revset.prettyformat(newtree), "\n")
3168 ui.note(revset.prettyformat(newtree), "\n")
3155 if opts["optimize"]:
3169 if opts["optimize"]:
3156 weight, optimizedtree = revset.optimize(newtree, True)
3170 weight, optimizedtree = revset.optimize(newtree, True)
3157 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3171 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3158 func = revset.match(ui, expr, repo)
3172 func = revset.match(ui, expr, repo)
3159 revs = func(repo)
3173 revs = func(repo)
3160 if ui.verbose:
3174 if ui.verbose:
3161 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3175 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3162 for c in revs:
3176 for c in revs:
3163 ui.write("%s\n" % c)
3177 ui.write("%s\n" % c)
3164
3178
3165 @command('debugsetparents', [], _('REV1 [REV2]'))
3179 @command('debugsetparents', [], _('REV1 [REV2]'))
3166 def debugsetparents(ui, repo, rev1, rev2=None):
3180 def debugsetparents(ui, repo, rev1, rev2=None):
3167 """manually set the parents of the current working directory
3181 """manually set the parents of the current working directory
3168
3182
3169 This is useful for writing repository conversion tools, but should
3183 This is useful for writing repository conversion tools, but should
3170 be used with care. For example, neither the working directory nor the
3184 be used with care. For example, neither the working directory nor the
3171 dirstate is updated, so file status may be incorrect after running this
3185 dirstate is updated, so file status may be incorrect after running this
3172 command.
3186 command.
3173
3187
3174 Returns 0 on success.
3188 Returns 0 on success.
3175 """
3189 """
3176
3190
3177 r1 = scmutil.revsingle(repo, rev1).node()
3191 r1 = scmutil.revsingle(repo, rev1).node()
3178 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3192 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3179
3193
3180 wlock = repo.wlock()
3194 wlock = repo.wlock()
3181 try:
3195 try:
3182 repo.dirstate.beginparentchange()
3196 repo.dirstate.beginparentchange()
3183 repo.setparents(r1, r2)
3197 repo.setparents(r1, r2)
3184 repo.dirstate.endparentchange()
3198 repo.dirstate.endparentchange()
3185 finally:
3199 finally:
3186 wlock.release()
3200 wlock.release()
3187
3201
3188 @command('debugdirstate|debugstate',
3202 @command('debugdirstate|debugstate',
3189 [('', 'nodates', None, _('do not display the saved mtime')),
3203 [('', 'nodates', None, _('do not display the saved mtime')),
3190 ('', 'datesort', None, _('sort by saved mtime'))],
3204 ('', 'datesort', None, _('sort by saved mtime'))],
3191 _('[OPTION]...'))
3205 _('[OPTION]...'))
3192 def debugstate(ui, repo, **opts):
3206 def debugstate(ui, repo, **opts):
3193 """show the contents of the current dirstate"""
3207 """show the contents of the current dirstate"""
3194
3208
3195 nodates = opts.get('nodates')
3209 nodates = opts.get('nodates')
3196 datesort = opts.get('datesort')
3210 datesort = opts.get('datesort')
3197
3211
3198 timestr = ""
3212 timestr = ""
3199 if datesort:
3213 if datesort:
3200 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3214 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3201 else:
3215 else:
3202 keyfunc = None # sort by filename
3216 keyfunc = None # sort by filename
3203 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3217 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3204 if ent[3] == -1:
3218 if ent[3] == -1:
3205 timestr = 'unset '
3219 timestr = 'unset '
3206 elif nodates:
3220 elif nodates:
3207 timestr = 'set '
3221 timestr = 'set '
3208 else:
3222 else:
3209 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3223 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3210 time.localtime(ent[3]))
3224 time.localtime(ent[3]))
3211 if ent[1] & 0o20000:
3225 if ent[1] & 0o20000:
3212 mode = 'lnk'
3226 mode = 'lnk'
3213 else:
3227 else:
3214 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3228 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3215 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3229 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3216 for f in repo.dirstate.copies():
3230 for f in repo.dirstate.copies():
3217 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3231 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3218
3232
3219 @command('debugsub',
3233 @command('debugsub',
3220 [('r', 'rev', '',
3234 [('r', 'rev', '',
3221 _('revision to check'), _('REV'))],
3235 _('revision to check'), _('REV'))],
3222 _('[-r REV] [REV]'))
3236 _('[-r REV] [REV]'))
3223 def debugsub(ui, repo, rev=None):
3237 def debugsub(ui, repo, rev=None):
3224 ctx = scmutil.revsingle(repo, rev, None)
3238 ctx = scmutil.revsingle(repo, rev, None)
3225 for k, v in sorted(ctx.substate.items()):
3239 for k, v in sorted(ctx.substate.items()):
3226 ui.write(('path %s\n') % k)
3240 ui.write(('path %s\n') % k)
3227 ui.write((' source %s\n') % v[0])
3241 ui.write((' source %s\n') % v[0])
3228 ui.write((' revision %s\n') % v[1])
3242 ui.write((' revision %s\n') % v[1])
3229
3243
3230 @command('debugsuccessorssets',
3244 @command('debugsuccessorssets',
3231 [],
3245 [],
3232 _('[REV]'))
3246 _('[REV]'))
3233 def debugsuccessorssets(ui, repo, *revs):
3247 def debugsuccessorssets(ui, repo, *revs):
3234 """show set of successors for revision
3248 """show set of successors for revision
3235
3249
3236 A successors set of changeset A is a consistent group of revisions that
3250 A successors set of changeset A is a consistent group of revisions that
3237 succeed A. It contains non-obsolete changesets only.
3251 succeed A. It contains non-obsolete changesets only.
3238
3252
3239 In most cases a changeset A has a single successors set containing a single
3253 In most cases a changeset A has a single successors set containing a single
3240 successor (changeset A replaced by A').
3254 successor (changeset A replaced by A').
3241
3255
3242 A changeset that is made obsolete with no successors are called "pruned".
3256 A changeset that is made obsolete with no successors are called "pruned".
3243 Such changesets have no successors sets at all.
3257 Such changesets have no successors sets at all.
3244
3258
3245 A changeset that has been "split" will have a successors set containing
3259 A changeset that has been "split" will have a successors set containing
3246 more than one successor.
3260 more than one successor.
3247
3261
3248 A changeset that has been rewritten in multiple different ways is called
3262 A changeset that has been rewritten in multiple different ways is called
3249 "divergent". Such changesets have multiple successor sets (each of which
3263 "divergent". Such changesets have multiple successor sets (each of which
3250 may also be split, i.e. have multiple successors).
3264 may also be split, i.e. have multiple successors).
3251
3265
3252 Results are displayed as follows::
3266 Results are displayed as follows::
3253
3267
3254 <rev1>
3268 <rev1>
3255 <successors-1A>
3269 <successors-1A>
3256 <rev2>
3270 <rev2>
3257 <successors-2A>
3271 <successors-2A>
3258 <successors-2B1> <successors-2B2> <successors-2B3>
3272 <successors-2B1> <successors-2B2> <successors-2B3>
3259
3273
3260 Here rev2 has two possible (i.e. divergent) successors sets. The first
3274 Here rev2 has two possible (i.e. divergent) successors sets. The first
3261 holds one element, whereas the second holds three (i.e. the changeset has
3275 holds one element, whereas the second holds three (i.e. the changeset has
3262 been split).
3276 been split).
3263 """
3277 """
3264 # passed to successorssets caching computation from one call to another
3278 # passed to successorssets caching computation from one call to another
3265 cache = {}
3279 cache = {}
3266 ctx2str = str
3280 ctx2str = str
3267 node2str = short
3281 node2str = short
3268 if ui.debug():
3282 if ui.debug():
3269 def ctx2str(ctx):
3283 def ctx2str(ctx):
3270 return ctx.hex()
3284 return ctx.hex()
3271 node2str = hex
3285 node2str = hex
3272 for rev in scmutil.revrange(repo, revs):
3286 for rev in scmutil.revrange(repo, revs):
3273 ctx = repo[rev]
3287 ctx = repo[rev]
3274 ui.write('%s\n'% ctx2str(ctx))
3288 ui.write('%s\n'% ctx2str(ctx))
3275 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3289 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3276 if succsset:
3290 if succsset:
3277 ui.write(' ')
3291 ui.write(' ')
3278 ui.write(node2str(succsset[0]))
3292 ui.write(node2str(succsset[0]))
3279 for node in succsset[1:]:
3293 for node in succsset[1:]:
3280 ui.write(' ')
3294 ui.write(' ')
3281 ui.write(node2str(node))
3295 ui.write(node2str(node))
3282 ui.write('\n')
3296 ui.write('\n')
3283
3297
3284 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3298 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3285 def debugwalk(ui, repo, *pats, **opts):
3299 def debugwalk(ui, repo, *pats, **opts):
3286 """show how files match on given patterns"""
3300 """show how files match on given patterns"""
3287 m = scmutil.match(repo[None], pats, opts)
3301 m = scmutil.match(repo[None], pats, opts)
3288 items = list(repo.walk(m))
3302 items = list(repo.walk(m))
3289 if not items:
3303 if not items:
3290 return
3304 return
3291 f = lambda fn: fn
3305 f = lambda fn: fn
3292 if ui.configbool('ui', 'slash') and os.sep != '/':
3306 if ui.configbool('ui', 'slash') and os.sep != '/':
3293 f = lambda fn: util.normpath(fn)
3307 f = lambda fn: util.normpath(fn)
3294 fmt = 'f %%-%ds %%-%ds %%s' % (
3308 fmt = 'f %%-%ds %%-%ds %%s' % (
3295 max([len(abs) for abs in items]),
3309 max([len(abs) for abs in items]),
3296 max([len(m.rel(abs)) for abs in items]))
3310 max([len(m.rel(abs)) for abs in items]))
3297 for abs in items:
3311 for abs in items:
3298 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3312 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3299 ui.write("%s\n" % line.rstrip())
3313 ui.write("%s\n" % line.rstrip())
3300
3314
3301 @command('debugwireargs',
3315 @command('debugwireargs',
3302 [('', 'three', '', 'three'),
3316 [('', 'three', '', 'three'),
3303 ('', 'four', '', 'four'),
3317 ('', 'four', '', 'four'),
3304 ('', 'five', '', 'five'),
3318 ('', 'five', '', 'five'),
3305 ] + remoteopts,
3319 ] + remoteopts,
3306 _('REPO [OPTIONS]... [ONE [TWO]]'),
3320 _('REPO [OPTIONS]... [ONE [TWO]]'),
3307 norepo=True)
3321 norepo=True)
3308 def debugwireargs(ui, repopath, *vals, **opts):
3322 def debugwireargs(ui, repopath, *vals, **opts):
3309 repo = hg.peer(ui, opts, repopath)
3323 repo = hg.peer(ui, opts, repopath)
3310 for opt in remoteopts:
3324 for opt in remoteopts:
3311 del opts[opt[1]]
3325 del opts[opt[1]]
3312 args = {}
3326 args = {}
3313 for k, v in opts.iteritems():
3327 for k, v in opts.iteritems():
3314 if v:
3328 if v:
3315 args[k] = v
3329 args[k] = v
3316 # run twice to check that we don't mess up the stream for the next command
3330 # run twice to check that we don't mess up the stream for the next command
3317 res1 = repo.debugwireargs(*vals, **args)
3331 res1 = repo.debugwireargs(*vals, **args)
3318 res2 = repo.debugwireargs(*vals, **args)
3332 res2 = repo.debugwireargs(*vals, **args)
3319 ui.write("%s\n" % res1)
3333 ui.write("%s\n" % res1)
3320 if res1 != res2:
3334 if res1 != res2:
3321 ui.warn("%s\n" % res2)
3335 ui.warn("%s\n" % res2)
3322
3336
3323 @command('^diff',
3337 @command('^diff',
3324 [('r', 'rev', [], _('revision'), _('REV')),
3338 [('r', 'rev', [], _('revision'), _('REV')),
3325 ('c', 'change', '', _('change made by revision'), _('REV'))
3339 ('c', 'change', '', _('change made by revision'), _('REV'))
3326 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3340 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3327 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3341 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3328 inferrepo=True)
3342 inferrepo=True)
3329 def diff(ui, repo, *pats, **opts):
3343 def diff(ui, repo, *pats, **opts):
3330 """diff repository (or selected files)
3344 """diff repository (or selected files)
3331
3345
3332 Show differences between revisions for the specified files.
3346 Show differences between revisions for the specified files.
3333
3347
3334 Differences between files are shown using the unified diff format.
3348 Differences between files are shown using the unified diff format.
3335
3349
3336 .. note::
3350 .. note::
3337
3351
3338 diff may generate unexpected results for merges, as it will
3352 diff may generate unexpected results for merges, as it will
3339 default to comparing against the working directory's first
3353 default to comparing against the working directory's first
3340 parent changeset if no revisions are specified.
3354 parent changeset if no revisions are specified.
3341
3355
3342 When two revision arguments are given, then changes are shown
3356 When two revision arguments are given, then changes are shown
3343 between those revisions. If only one revision is specified then
3357 between those revisions. If only one revision is specified then
3344 that revision is compared to the working directory, and, when no
3358 that revision is compared to the working directory, and, when no
3345 revisions are specified, the working directory files are compared
3359 revisions are specified, the working directory files are compared
3346 to its parent.
3360 to its parent.
3347
3361
3348 Alternatively you can specify -c/--change with a revision to see
3362 Alternatively you can specify -c/--change with a revision to see
3349 the changes in that changeset relative to its first parent.
3363 the changes in that changeset relative to its first parent.
3350
3364
3351 Without the -a/--text option, diff will avoid generating diffs of
3365 Without the -a/--text option, diff will avoid generating diffs of
3352 files it detects as binary. With -a, diff will generate a diff
3366 files it detects as binary. With -a, diff will generate a diff
3353 anyway, probably with undesirable results.
3367 anyway, probably with undesirable results.
3354
3368
3355 Use the -g/--git option to generate diffs in the git extended diff
3369 Use the -g/--git option to generate diffs in the git extended diff
3356 format. For more information, read :hg:`help diffs`.
3370 format. For more information, read :hg:`help diffs`.
3357
3371
3358 .. container:: verbose
3372 .. container:: verbose
3359
3373
3360 Examples:
3374 Examples:
3361
3375
3362 - compare a file in the current working directory to its parent::
3376 - compare a file in the current working directory to its parent::
3363
3377
3364 hg diff foo.c
3378 hg diff foo.c
3365
3379
3366 - compare two historical versions of a directory, with rename info::
3380 - compare two historical versions of a directory, with rename info::
3367
3381
3368 hg diff --git -r 1.0:1.2 lib/
3382 hg diff --git -r 1.0:1.2 lib/
3369
3383
3370 - get change stats relative to the last change on some date::
3384 - get change stats relative to the last change on some date::
3371
3385
3372 hg diff --stat -r "date('may 2')"
3386 hg diff --stat -r "date('may 2')"
3373
3387
3374 - diff all newly-added files that contain a keyword::
3388 - diff all newly-added files that contain a keyword::
3375
3389
3376 hg diff "set:added() and grep(GNU)"
3390 hg diff "set:added() and grep(GNU)"
3377
3391
3378 - compare a revision and its parents::
3392 - compare a revision and its parents::
3379
3393
3380 hg diff -c 9353 # compare against first parent
3394 hg diff -c 9353 # compare against first parent
3381 hg diff -r 9353^:9353 # same using revset syntax
3395 hg diff -r 9353^:9353 # same using revset syntax
3382 hg diff -r 9353^2:9353 # compare against the second parent
3396 hg diff -r 9353^2:9353 # compare against the second parent
3383
3397
3384 Returns 0 on success.
3398 Returns 0 on success.
3385 """
3399 """
3386
3400
3387 revs = opts.get('rev')
3401 revs = opts.get('rev')
3388 change = opts.get('change')
3402 change = opts.get('change')
3389 stat = opts.get('stat')
3403 stat = opts.get('stat')
3390 reverse = opts.get('reverse')
3404 reverse = opts.get('reverse')
3391
3405
3392 if revs and change:
3406 if revs and change:
3393 msg = _('cannot specify --rev and --change at the same time')
3407 msg = _('cannot specify --rev and --change at the same time')
3394 raise error.Abort(msg)
3408 raise error.Abort(msg)
3395 elif change:
3409 elif change:
3396 node2 = scmutil.revsingle(repo, change, None).node()
3410 node2 = scmutil.revsingle(repo, change, None).node()
3397 node1 = repo[node2].p1().node()
3411 node1 = repo[node2].p1().node()
3398 else:
3412 else:
3399 node1, node2 = scmutil.revpair(repo, revs)
3413 node1, node2 = scmutil.revpair(repo, revs)
3400
3414
3401 if reverse:
3415 if reverse:
3402 node1, node2 = node2, node1
3416 node1, node2 = node2, node1
3403
3417
3404 diffopts = patch.diffallopts(ui, opts)
3418 diffopts = patch.diffallopts(ui, opts)
3405 m = scmutil.match(repo[node2], pats, opts)
3419 m = scmutil.match(repo[node2], pats, opts)
3406 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3420 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3407 listsubrepos=opts.get('subrepos'),
3421 listsubrepos=opts.get('subrepos'),
3408 root=opts.get('root'))
3422 root=opts.get('root'))
3409
3423
3410 @command('^export',
3424 @command('^export',
3411 [('o', 'output', '',
3425 [('o', 'output', '',
3412 _('print output to file with formatted name'), _('FORMAT')),
3426 _('print output to file with formatted name'), _('FORMAT')),
3413 ('', 'switch-parent', None, _('diff against the second parent')),
3427 ('', 'switch-parent', None, _('diff against the second parent')),
3414 ('r', 'rev', [], _('revisions to export'), _('REV')),
3428 ('r', 'rev', [], _('revisions to export'), _('REV')),
3415 ] + diffopts,
3429 ] + diffopts,
3416 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3430 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3417 def export(ui, repo, *changesets, **opts):
3431 def export(ui, repo, *changesets, **opts):
3418 """dump the header and diffs for one or more changesets
3432 """dump the header and diffs for one or more changesets
3419
3433
3420 Print the changeset header and diffs for one or more revisions.
3434 Print the changeset header and diffs for one or more revisions.
3421 If no revision is given, the parent of the working directory is used.
3435 If no revision is given, the parent of the working directory is used.
3422
3436
3423 The information shown in the changeset header is: author, date,
3437 The information shown in the changeset header is: author, date,
3424 branch name (if non-default), changeset hash, parent(s) and commit
3438 branch name (if non-default), changeset hash, parent(s) and commit
3425 comment.
3439 comment.
3426
3440
3427 .. note::
3441 .. note::
3428
3442
3429 export may generate unexpected diff output for merge
3443 export may generate unexpected diff output for merge
3430 changesets, as it will compare the merge changeset against its
3444 changesets, as it will compare the merge changeset against its
3431 first parent only.
3445 first parent only.
3432
3446
3433 Output may be to a file, in which case the name of the file is
3447 Output may be to a file, in which case the name of the file is
3434 given using a format string. The formatting rules are as follows:
3448 given using a format string. The formatting rules are as follows:
3435
3449
3436 :``%%``: literal "%" character
3450 :``%%``: literal "%" character
3437 :``%H``: changeset hash (40 hexadecimal digits)
3451 :``%H``: changeset hash (40 hexadecimal digits)
3438 :``%N``: number of patches being generated
3452 :``%N``: number of patches being generated
3439 :``%R``: changeset revision number
3453 :``%R``: changeset revision number
3440 :``%b``: basename of the exporting repository
3454 :``%b``: basename of the exporting repository
3441 :``%h``: short-form changeset hash (12 hexadecimal digits)
3455 :``%h``: short-form changeset hash (12 hexadecimal digits)
3442 :``%m``: first line of the commit message (only alphanumeric characters)
3456 :``%m``: first line of the commit message (only alphanumeric characters)
3443 :``%n``: zero-padded sequence number, starting at 1
3457 :``%n``: zero-padded sequence number, starting at 1
3444 :``%r``: zero-padded changeset revision number
3458 :``%r``: zero-padded changeset revision number
3445
3459
3446 Without the -a/--text option, export will avoid generating diffs
3460 Without the -a/--text option, export will avoid generating diffs
3447 of files it detects as binary. With -a, export will generate a
3461 of files it detects as binary. With -a, export will generate a
3448 diff anyway, probably with undesirable results.
3462 diff anyway, probably with undesirable results.
3449
3463
3450 Use the -g/--git option to generate diffs in the git extended diff
3464 Use the -g/--git option to generate diffs in the git extended diff
3451 format. See :hg:`help diffs` for more information.
3465 format. See :hg:`help diffs` for more information.
3452
3466
3453 With the --switch-parent option, the diff will be against the
3467 With the --switch-parent option, the diff will be against the
3454 second parent. It can be useful to review a merge.
3468 second parent. It can be useful to review a merge.
3455
3469
3456 .. container:: verbose
3470 .. container:: verbose
3457
3471
3458 Examples:
3472 Examples:
3459
3473
3460 - use export and import to transplant a bugfix to the current
3474 - use export and import to transplant a bugfix to the current
3461 branch::
3475 branch::
3462
3476
3463 hg export -r 9353 | hg import -
3477 hg export -r 9353 | hg import -
3464
3478
3465 - export all the changesets between two revisions to a file with
3479 - export all the changesets between two revisions to a file with
3466 rename information::
3480 rename information::
3467
3481
3468 hg export --git -r 123:150 > changes.txt
3482 hg export --git -r 123:150 > changes.txt
3469
3483
3470 - split outgoing changes into a series of patches with
3484 - split outgoing changes into a series of patches with
3471 descriptive names::
3485 descriptive names::
3472
3486
3473 hg export -r "outgoing()" -o "%n-%m.patch"
3487 hg export -r "outgoing()" -o "%n-%m.patch"
3474
3488
3475 Returns 0 on success.
3489 Returns 0 on success.
3476 """
3490 """
3477 changesets += tuple(opts.get('rev', []))
3491 changesets += tuple(opts.get('rev', []))
3478 if not changesets:
3492 if not changesets:
3479 changesets = ['.']
3493 changesets = ['.']
3480 revs = scmutil.revrange(repo, changesets)
3494 revs = scmutil.revrange(repo, changesets)
3481 if not revs:
3495 if not revs:
3482 raise error.Abort(_("export requires at least one changeset"))
3496 raise error.Abort(_("export requires at least one changeset"))
3483 if len(revs) > 1:
3497 if len(revs) > 1:
3484 ui.note(_('exporting patches:\n'))
3498 ui.note(_('exporting patches:\n'))
3485 else:
3499 else:
3486 ui.note(_('exporting patch:\n'))
3500 ui.note(_('exporting patch:\n'))
3487 cmdutil.export(repo, revs, template=opts.get('output'),
3501 cmdutil.export(repo, revs, template=opts.get('output'),
3488 switch_parent=opts.get('switch_parent'),
3502 switch_parent=opts.get('switch_parent'),
3489 opts=patch.diffallopts(ui, opts))
3503 opts=patch.diffallopts(ui, opts))
3490
3504
3491 @command('files',
3505 @command('files',
3492 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3506 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3493 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3507 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3494 ] + walkopts + formatteropts + subrepoopts,
3508 ] + walkopts + formatteropts + subrepoopts,
3495 _('[OPTION]... [PATTERN]...'))
3509 _('[OPTION]... [PATTERN]...'))
3496 def files(ui, repo, *pats, **opts):
3510 def files(ui, repo, *pats, **opts):
3497 """list tracked files
3511 """list tracked files
3498
3512
3499 Print files under Mercurial control in the working directory or
3513 Print files under Mercurial control in the working directory or
3500 specified revision whose names match the given patterns (excluding
3514 specified revision whose names match the given patterns (excluding
3501 removed files).
3515 removed files).
3502
3516
3503 If no patterns are given to match, this command prints the names
3517 If no patterns are given to match, this command prints the names
3504 of all files under Mercurial control in the working directory.
3518 of all files under Mercurial control in the working directory.
3505
3519
3506 .. container:: verbose
3520 .. container:: verbose
3507
3521
3508 Examples:
3522 Examples:
3509
3523
3510 - list all files under the current directory::
3524 - list all files under the current directory::
3511
3525
3512 hg files .
3526 hg files .
3513
3527
3514 - shows sizes and flags for current revision::
3528 - shows sizes and flags for current revision::
3515
3529
3516 hg files -vr .
3530 hg files -vr .
3517
3531
3518 - list all files named README::
3532 - list all files named README::
3519
3533
3520 hg files -I "**/README"
3534 hg files -I "**/README"
3521
3535
3522 - list all binary files::
3536 - list all binary files::
3523
3537
3524 hg files "set:binary()"
3538 hg files "set:binary()"
3525
3539
3526 - find files containing a regular expression::
3540 - find files containing a regular expression::
3527
3541
3528 hg files "set:grep('bob')"
3542 hg files "set:grep('bob')"
3529
3543
3530 - search tracked file contents with xargs and grep::
3544 - search tracked file contents with xargs and grep::
3531
3545
3532 hg files -0 | xargs -0 grep foo
3546 hg files -0 | xargs -0 grep foo
3533
3547
3534 See :hg:`help patterns` and :hg:`help filesets` for more information
3548 See :hg:`help patterns` and :hg:`help filesets` for more information
3535 on specifying file patterns.
3549 on specifying file patterns.
3536
3550
3537 Returns 0 if a match is found, 1 otherwise.
3551 Returns 0 if a match is found, 1 otherwise.
3538
3552
3539 """
3553 """
3540 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3554 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3541
3555
3542 end = '\n'
3556 end = '\n'
3543 if opts.get('print0'):
3557 if opts.get('print0'):
3544 end = '\0'
3558 end = '\0'
3545 fm = ui.formatter('files', opts)
3559 fm = ui.formatter('files', opts)
3546 fmt = '%s' + end
3560 fmt = '%s' + end
3547
3561
3548 m = scmutil.match(ctx, pats, opts)
3562 m = scmutil.match(ctx, pats, opts)
3549 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3563 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3550
3564
3551 fm.end()
3565 fm.end()
3552
3566
3553 return ret
3567 return ret
3554
3568
3555 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3569 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3556 def forget(ui, repo, *pats, **opts):
3570 def forget(ui, repo, *pats, **opts):
3557 """forget the specified files on the next commit
3571 """forget the specified files on the next commit
3558
3572
3559 Mark the specified files so they will no longer be tracked
3573 Mark the specified files so they will no longer be tracked
3560 after the next commit.
3574 after the next commit.
3561
3575
3562 This only removes files from the current branch, not from the
3576 This only removes files from the current branch, not from the
3563 entire project history, and it does not delete them from the
3577 entire project history, and it does not delete them from the
3564 working directory.
3578 working directory.
3565
3579
3566 To delete the file from the working directory, see :hg:`remove`.
3580 To delete the file from the working directory, see :hg:`remove`.
3567
3581
3568 To undo a forget before the next commit, see :hg:`add`.
3582 To undo a forget before the next commit, see :hg:`add`.
3569
3583
3570 .. container:: verbose
3584 .. container:: verbose
3571
3585
3572 Examples:
3586 Examples:
3573
3587
3574 - forget newly-added binary files::
3588 - forget newly-added binary files::
3575
3589
3576 hg forget "set:added() and binary()"
3590 hg forget "set:added() and binary()"
3577
3591
3578 - forget files that would be excluded by .hgignore::
3592 - forget files that would be excluded by .hgignore::
3579
3593
3580 hg forget "set:hgignore()"
3594 hg forget "set:hgignore()"
3581
3595
3582 Returns 0 on success.
3596 Returns 0 on success.
3583 """
3597 """
3584
3598
3585 if not pats:
3599 if not pats:
3586 raise error.Abort(_('no files specified'))
3600 raise error.Abort(_('no files specified'))
3587
3601
3588 m = scmutil.match(repo[None], pats, opts)
3602 m = scmutil.match(repo[None], pats, opts)
3589 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3603 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3590 return rejected and 1 or 0
3604 return rejected and 1 or 0
3591
3605
3592 @command(
3606 @command(
3593 'graft',
3607 'graft',
3594 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3608 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3595 ('c', 'continue', False, _('resume interrupted graft')),
3609 ('c', 'continue', False, _('resume interrupted graft')),
3596 ('e', 'edit', False, _('invoke editor on commit messages')),
3610 ('e', 'edit', False, _('invoke editor on commit messages')),
3597 ('', 'log', None, _('append graft info to log message')),
3611 ('', 'log', None, _('append graft info to log message')),
3598 ('f', 'force', False, _('force graft')),
3612 ('f', 'force', False, _('force graft')),
3599 ('D', 'currentdate', False,
3613 ('D', 'currentdate', False,
3600 _('record the current date as commit date')),
3614 _('record the current date as commit date')),
3601 ('U', 'currentuser', False,
3615 ('U', 'currentuser', False,
3602 _('record the current user as committer'), _('DATE'))]
3616 _('record the current user as committer'), _('DATE'))]
3603 + commitopts2 + mergetoolopts + dryrunopts,
3617 + commitopts2 + mergetoolopts + dryrunopts,
3604 _('[OPTION]... [-r] REV...'))
3618 _('[OPTION]... [-r] REV...'))
3605 def graft(ui, repo, *revs, **opts):
3619 def graft(ui, repo, *revs, **opts):
3606 '''copy changes from other branches onto the current branch
3620 '''copy changes from other branches onto the current branch
3607
3621
3608 This command uses Mercurial's merge logic to copy individual
3622 This command uses Mercurial's merge logic to copy individual
3609 changes from other branches without merging branches in the
3623 changes from other branches without merging branches in the
3610 history graph. This is sometimes known as 'backporting' or
3624 history graph. This is sometimes known as 'backporting' or
3611 'cherry-picking'. By default, graft will copy user, date, and
3625 'cherry-picking'. By default, graft will copy user, date, and
3612 description from the source changesets.
3626 description from the source changesets.
3613
3627
3614 Changesets that are ancestors of the current revision, that have
3628 Changesets that are ancestors of the current revision, that have
3615 already been grafted, or that are merges will be skipped.
3629 already been grafted, or that are merges will be skipped.
3616
3630
3617 If --log is specified, log messages will have a comment appended
3631 If --log is specified, log messages will have a comment appended
3618 of the form::
3632 of the form::
3619
3633
3620 (grafted from CHANGESETHASH)
3634 (grafted from CHANGESETHASH)
3621
3635
3622 If --force is specified, revisions will be grafted even if they
3636 If --force is specified, revisions will be grafted even if they
3623 are already ancestors of or have been grafted to the destination.
3637 are already ancestors of or have been grafted to the destination.
3624 This is useful when the revisions have since been backed out.
3638 This is useful when the revisions have since been backed out.
3625
3639
3626 If a graft merge results in conflicts, the graft process is
3640 If a graft merge results in conflicts, the graft process is
3627 interrupted so that the current merge can be manually resolved.
3641 interrupted so that the current merge can be manually resolved.
3628 Once all conflicts are addressed, the graft process can be
3642 Once all conflicts are addressed, the graft process can be
3629 continued with the -c/--continue option.
3643 continued with the -c/--continue option.
3630
3644
3631 .. note::
3645 .. note::
3632
3646
3633 The -c/--continue option does not reapply earlier options, except
3647 The -c/--continue option does not reapply earlier options, except
3634 for --force.
3648 for --force.
3635
3649
3636 .. container:: verbose
3650 .. container:: verbose
3637
3651
3638 Examples:
3652 Examples:
3639
3653
3640 - copy a single change to the stable branch and edit its description::
3654 - copy a single change to the stable branch and edit its description::
3641
3655
3642 hg update stable
3656 hg update stable
3643 hg graft --edit 9393
3657 hg graft --edit 9393
3644
3658
3645 - graft a range of changesets with one exception, updating dates::
3659 - graft a range of changesets with one exception, updating dates::
3646
3660
3647 hg graft -D "2085::2093 and not 2091"
3661 hg graft -D "2085::2093 and not 2091"
3648
3662
3649 - continue a graft after resolving conflicts::
3663 - continue a graft after resolving conflicts::
3650
3664
3651 hg graft -c
3665 hg graft -c
3652
3666
3653 - show the source of a grafted changeset::
3667 - show the source of a grafted changeset::
3654
3668
3655 hg log --debug -r .
3669 hg log --debug -r .
3656
3670
3657 See :hg:`help revisions` and :hg:`help revsets` for more about
3671 See :hg:`help revisions` and :hg:`help revsets` for more about
3658 specifying revisions.
3672 specifying revisions.
3659
3673
3660 Returns 0 on successful completion.
3674 Returns 0 on successful completion.
3661 '''
3675 '''
3662
3676
3663 revs = list(revs)
3677 revs = list(revs)
3664 revs.extend(opts['rev'])
3678 revs.extend(opts['rev'])
3665
3679
3666 if not opts.get('user') and opts.get('currentuser'):
3680 if not opts.get('user') and opts.get('currentuser'):
3667 opts['user'] = ui.username()
3681 opts['user'] = ui.username()
3668 if not opts.get('date') and opts.get('currentdate'):
3682 if not opts.get('date') and opts.get('currentdate'):
3669 opts['date'] = "%d %d" % util.makedate()
3683 opts['date'] = "%d %d" % util.makedate()
3670
3684
3671 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3685 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3672
3686
3673 cont = False
3687 cont = False
3674 if opts['continue']:
3688 if opts['continue']:
3675 cont = True
3689 cont = True
3676 if revs:
3690 if revs:
3677 raise error.Abort(_("can't specify --continue and revisions"))
3691 raise error.Abort(_("can't specify --continue and revisions"))
3678 # read in unfinished revisions
3692 # read in unfinished revisions
3679 try:
3693 try:
3680 nodes = repo.vfs.read('graftstate').splitlines()
3694 nodes = repo.vfs.read('graftstate').splitlines()
3681 revs = [repo[node].rev() for node in nodes]
3695 revs = [repo[node].rev() for node in nodes]
3682 except IOError as inst:
3696 except IOError as inst:
3683 if inst.errno != errno.ENOENT:
3697 if inst.errno != errno.ENOENT:
3684 raise
3698 raise
3685 raise error.Abort(_("no graft state found, can't continue"))
3699 raise error.Abort(_("no graft state found, can't continue"))
3686 else:
3700 else:
3687 cmdutil.checkunfinished(repo)
3701 cmdutil.checkunfinished(repo)
3688 cmdutil.bailifchanged(repo)
3702 cmdutil.bailifchanged(repo)
3689 if not revs:
3703 if not revs:
3690 raise error.Abort(_('no revisions specified'))
3704 raise error.Abort(_('no revisions specified'))
3691 revs = scmutil.revrange(repo, revs)
3705 revs = scmutil.revrange(repo, revs)
3692
3706
3693 skipped = set()
3707 skipped = set()
3694 # check for merges
3708 # check for merges
3695 for rev in repo.revs('%ld and merge()', revs):
3709 for rev in repo.revs('%ld and merge()', revs):
3696 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3710 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3697 skipped.add(rev)
3711 skipped.add(rev)
3698 revs = [r for r in revs if r not in skipped]
3712 revs = [r for r in revs if r not in skipped]
3699 if not revs:
3713 if not revs:
3700 return -1
3714 return -1
3701
3715
3702 # Don't check in the --continue case, in effect retaining --force across
3716 # Don't check in the --continue case, in effect retaining --force across
3703 # --continues. That's because without --force, any revisions we decided to
3717 # --continues. That's because without --force, any revisions we decided to
3704 # skip would have been filtered out here, so they wouldn't have made their
3718 # skip would have been filtered out here, so they wouldn't have made their
3705 # way to the graftstate. With --force, any revisions we would have otherwise
3719 # way to the graftstate. With --force, any revisions we would have otherwise
3706 # skipped would not have been filtered out, and if they hadn't been applied
3720 # skipped would not have been filtered out, and if they hadn't been applied
3707 # already, they'd have been in the graftstate.
3721 # already, they'd have been in the graftstate.
3708 if not (cont or opts.get('force')):
3722 if not (cont or opts.get('force')):
3709 # check for ancestors of dest branch
3723 # check for ancestors of dest branch
3710 crev = repo['.'].rev()
3724 crev = repo['.'].rev()
3711 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3725 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3712 # Cannot use x.remove(y) on smart set, this has to be a list.
3726 # Cannot use x.remove(y) on smart set, this has to be a list.
3713 # XXX make this lazy in the future
3727 # XXX make this lazy in the future
3714 revs = list(revs)
3728 revs = list(revs)
3715 # don't mutate while iterating, create a copy
3729 # don't mutate while iterating, create a copy
3716 for rev in list(revs):
3730 for rev in list(revs):
3717 if rev in ancestors:
3731 if rev in ancestors:
3718 ui.warn(_('skipping ancestor revision %d:%s\n') %
3732 ui.warn(_('skipping ancestor revision %d:%s\n') %
3719 (rev, repo[rev]))
3733 (rev, repo[rev]))
3720 # XXX remove on list is slow
3734 # XXX remove on list is slow
3721 revs.remove(rev)
3735 revs.remove(rev)
3722 if not revs:
3736 if not revs:
3723 return -1
3737 return -1
3724
3738
3725 # analyze revs for earlier grafts
3739 # analyze revs for earlier grafts
3726 ids = {}
3740 ids = {}
3727 for ctx in repo.set("%ld", revs):
3741 for ctx in repo.set("%ld", revs):
3728 ids[ctx.hex()] = ctx.rev()
3742 ids[ctx.hex()] = ctx.rev()
3729 n = ctx.extra().get('source')
3743 n = ctx.extra().get('source')
3730 if n:
3744 if n:
3731 ids[n] = ctx.rev()
3745 ids[n] = ctx.rev()
3732
3746
3733 # check ancestors for earlier grafts
3747 # check ancestors for earlier grafts
3734 ui.debug('scanning for duplicate grafts\n')
3748 ui.debug('scanning for duplicate grafts\n')
3735
3749
3736 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3750 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3737 ctx = repo[rev]
3751 ctx = repo[rev]
3738 n = ctx.extra().get('source')
3752 n = ctx.extra().get('source')
3739 if n in ids:
3753 if n in ids:
3740 try:
3754 try:
3741 r = repo[n].rev()
3755 r = repo[n].rev()
3742 except error.RepoLookupError:
3756 except error.RepoLookupError:
3743 r = None
3757 r = None
3744 if r in revs:
3758 if r in revs:
3745 ui.warn(_('skipping revision %d:%s '
3759 ui.warn(_('skipping revision %d:%s '
3746 '(already grafted to %d:%s)\n')
3760 '(already grafted to %d:%s)\n')
3747 % (r, repo[r], rev, ctx))
3761 % (r, repo[r], rev, ctx))
3748 revs.remove(r)
3762 revs.remove(r)
3749 elif ids[n] in revs:
3763 elif ids[n] in revs:
3750 if r is None:
3764 if r is None:
3751 ui.warn(_('skipping already grafted revision %d:%s '
3765 ui.warn(_('skipping already grafted revision %d:%s '
3752 '(%d:%s also has unknown origin %s)\n')
3766 '(%d:%s also has unknown origin %s)\n')
3753 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3767 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3754 else:
3768 else:
3755 ui.warn(_('skipping already grafted revision %d:%s '
3769 ui.warn(_('skipping already grafted revision %d:%s '
3756 '(%d:%s also has origin %d:%s)\n')
3770 '(%d:%s also has origin %d:%s)\n')
3757 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3771 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3758 revs.remove(ids[n])
3772 revs.remove(ids[n])
3759 elif ctx.hex() in ids:
3773 elif ctx.hex() in ids:
3760 r = ids[ctx.hex()]
3774 r = ids[ctx.hex()]
3761 ui.warn(_('skipping already grafted revision %d:%s '
3775 ui.warn(_('skipping already grafted revision %d:%s '
3762 '(was grafted from %d:%s)\n') %
3776 '(was grafted from %d:%s)\n') %
3763 (r, repo[r], rev, ctx))
3777 (r, repo[r], rev, ctx))
3764 revs.remove(r)
3778 revs.remove(r)
3765 if not revs:
3779 if not revs:
3766 return -1
3780 return -1
3767
3781
3768 wlock = repo.wlock()
3782 wlock = repo.wlock()
3769 try:
3783 try:
3770 for pos, ctx in enumerate(repo.set("%ld", revs)):
3784 for pos, ctx in enumerate(repo.set("%ld", revs)):
3771 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3785 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3772 ctx.description().split('\n', 1)[0])
3786 ctx.description().split('\n', 1)[0])
3773 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3787 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3774 if names:
3788 if names:
3775 desc += ' (%s)' % ' '.join(names)
3789 desc += ' (%s)' % ' '.join(names)
3776 ui.status(_('grafting %s\n') % desc)
3790 ui.status(_('grafting %s\n') % desc)
3777 if opts.get('dry_run'):
3791 if opts.get('dry_run'):
3778 continue
3792 continue
3779
3793
3780 source = ctx.extra().get('source')
3794 source = ctx.extra().get('source')
3781 extra = {}
3795 extra = {}
3782 if source:
3796 if source:
3783 extra['source'] = source
3797 extra['source'] = source
3784 extra['intermediate-source'] = ctx.hex()
3798 extra['intermediate-source'] = ctx.hex()
3785 else:
3799 else:
3786 extra['source'] = ctx.hex()
3800 extra['source'] = ctx.hex()
3787 user = ctx.user()
3801 user = ctx.user()
3788 if opts.get('user'):
3802 if opts.get('user'):
3789 user = opts['user']
3803 user = opts['user']
3790 date = ctx.date()
3804 date = ctx.date()
3791 if opts.get('date'):
3805 if opts.get('date'):
3792 date = opts['date']
3806 date = opts['date']
3793 message = ctx.description()
3807 message = ctx.description()
3794 if opts.get('log'):
3808 if opts.get('log'):
3795 message += '\n(grafted from %s)' % ctx.hex()
3809 message += '\n(grafted from %s)' % ctx.hex()
3796
3810
3797 # we don't merge the first commit when continuing
3811 # we don't merge the first commit when continuing
3798 if not cont:
3812 if not cont:
3799 # perform the graft merge with p1(rev) as 'ancestor'
3813 # perform the graft merge with p1(rev) as 'ancestor'
3800 try:
3814 try:
3801 # ui.forcemerge is an internal variable, do not document
3815 # ui.forcemerge is an internal variable, do not document
3802 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3816 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3803 'graft')
3817 'graft')
3804 stats = mergemod.graft(repo, ctx, ctx.p1(),
3818 stats = mergemod.graft(repo, ctx, ctx.p1(),
3805 ['local', 'graft'])
3819 ['local', 'graft'])
3806 finally:
3820 finally:
3807 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3821 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3808 # report any conflicts
3822 # report any conflicts
3809 if stats and stats[3] > 0:
3823 if stats and stats[3] > 0:
3810 # write out state for --continue
3824 # write out state for --continue
3811 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3825 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3812 repo.vfs.write('graftstate', ''.join(nodelines))
3826 repo.vfs.write('graftstate', ''.join(nodelines))
3813 raise error.Abort(
3827 raise error.Abort(
3814 _("unresolved conflicts, can't continue"),
3828 _("unresolved conflicts, can't continue"),
3815 hint=_('use hg resolve and hg graft --continue'))
3829 hint=_('use hg resolve and hg graft --continue'))
3816 else:
3830 else:
3817 cont = False
3831 cont = False
3818
3832
3819 # commit
3833 # commit
3820 node = repo.commit(text=message, user=user,
3834 node = repo.commit(text=message, user=user,
3821 date=date, extra=extra, editor=editor)
3835 date=date, extra=extra, editor=editor)
3822 if node is None:
3836 if node is None:
3823 ui.warn(
3837 ui.warn(
3824 _('note: graft of %d:%s created no changes to commit\n') %
3838 _('note: graft of %d:%s created no changes to commit\n') %
3825 (ctx.rev(), ctx))
3839 (ctx.rev(), ctx))
3826 finally:
3840 finally:
3827 wlock.release()
3841 wlock.release()
3828
3842
3829 # remove state when we complete successfully
3843 # remove state when we complete successfully
3830 if not opts.get('dry_run'):
3844 if not opts.get('dry_run'):
3831 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3845 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3832
3846
3833 return 0
3847 return 0
3834
3848
3835 @command('grep',
3849 @command('grep',
3836 [('0', 'print0', None, _('end fields with NUL')),
3850 [('0', 'print0', None, _('end fields with NUL')),
3837 ('', 'all', None, _('print all revisions that match')),
3851 ('', 'all', None, _('print all revisions that match')),
3838 ('a', 'text', None, _('treat all files as text')),
3852 ('a', 'text', None, _('treat all files as text')),
3839 ('f', 'follow', None,
3853 ('f', 'follow', None,
3840 _('follow changeset history,'
3854 _('follow changeset history,'
3841 ' or file history across copies and renames')),
3855 ' or file history across copies and renames')),
3842 ('i', 'ignore-case', None, _('ignore case when matching')),
3856 ('i', 'ignore-case', None, _('ignore case when matching')),
3843 ('l', 'files-with-matches', None,
3857 ('l', 'files-with-matches', None,
3844 _('print only filenames and revisions that match')),
3858 _('print only filenames and revisions that match')),
3845 ('n', 'line-number', None, _('print matching line numbers')),
3859 ('n', 'line-number', None, _('print matching line numbers')),
3846 ('r', 'rev', [],
3860 ('r', 'rev', [],
3847 _('only search files changed within revision range'), _('REV')),
3861 _('only search files changed within revision range'), _('REV')),
3848 ('u', 'user', None, _('list the author (long with -v)')),
3862 ('u', 'user', None, _('list the author (long with -v)')),
3849 ('d', 'date', None, _('list the date (short with -q)')),
3863 ('d', 'date', None, _('list the date (short with -q)')),
3850 ] + walkopts,
3864 ] + walkopts,
3851 _('[OPTION]... PATTERN [FILE]...'),
3865 _('[OPTION]... PATTERN [FILE]...'),
3852 inferrepo=True)
3866 inferrepo=True)
3853 def grep(ui, repo, pattern, *pats, **opts):
3867 def grep(ui, repo, pattern, *pats, **opts):
3854 """search for a pattern in specified files and revisions
3868 """search for a pattern in specified files and revisions
3855
3869
3856 Search revisions of files for a regular expression.
3870 Search revisions of files for a regular expression.
3857
3871
3858 This command behaves differently than Unix grep. It only accepts
3872 This command behaves differently than Unix grep. It only accepts
3859 Python/Perl regexps. It searches repository history, not the
3873 Python/Perl regexps. It searches repository history, not the
3860 working directory. It always prints the revision number in which a
3874 working directory. It always prints the revision number in which a
3861 match appears.
3875 match appears.
3862
3876
3863 By default, grep only prints output for the first revision of a
3877 By default, grep only prints output for the first revision of a
3864 file in which it finds a match. To get it to print every revision
3878 file in which it finds a match. To get it to print every revision
3865 that contains a change in match status ("-" for a match that
3879 that contains a change in match status ("-" for a match that
3866 becomes a non-match, or "+" for a non-match that becomes a match),
3880 becomes a non-match, or "+" for a non-match that becomes a match),
3867 use the --all flag.
3881 use the --all flag.
3868
3882
3869 Returns 0 if a match is found, 1 otherwise.
3883 Returns 0 if a match is found, 1 otherwise.
3870 """
3884 """
3871 reflags = re.M
3885 reflags = re.M
3872 if opts.get('ignore_case'):
3886 if opts.get('ignore_case'):
3873 reflags |= re.I
3887 reflags |= re.I
3874 try:
3888 try:
3875 regexp = util.re.compile(pattern, reflags)
3889 regexp = util.re.compile(pattern, reflags)
3876 except re.error as inst:
3890 except re.error as inst:
3877 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3891 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3878 return 1
3892 return 1
3879 sep, eol = ':', '\n'
3893 sep, eol = ':', '\n'
3880 if opts.get('print0'):
3894 if opts.get('print0'):
3881 sep = eol = '\0'
3895 sep = eol = '\0'
3882
3896
3883 getfile = util.lrucachefunc(repo.file)
3897 getfile = util.lrucachefunc(repo.file)
3884
3898
3885 def matchlines(body):
3899 def matchlines(body):
3886 begin = 0
3900 begin = 0
3887 linenum = 0
3901 linenum = 0
3888 while begin < len(body):
3902 while begin < len(body):
3889 match = regexp.search(body, begin)
3903 match = regexp.search(body, begin)
3890 if not match:
3904 if not match:
3891 break
3905 break
3892 mstart, mend = match.span()
3906 mstart, mend = match.span()
3893 linenum += body.count('\n', begin, mstart) + 1
3907 linenum += body.count('\n', begin, mstart) + 1
3894 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3908 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3895 begin = body.find('\n', mend) + 1 or len(body) + 1
3909 begin = body.find('\n', mend) + 1 or len(body) + 1
3896 lend = begin - 1
3910 lend = begin - 1
3897 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3911 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3898
3912
3899 class linestate(object):
3913 class linestate(object):
3900 def __init__(self, line, linenum, colstart, colend):
3914 def __init__(self, line, linenum, colstart, colend):
3901 self.line = line
3915 self.line = line
3902 self.linenum = linenum
3916 self.linenum = linenum
3903 self.colstart = colstart
3917 self.colstart = colstart
3904 self.colend = colend
3918 self.colend = colend
3905
3919
3906 def __hash__(self):
3920 def __hash__(self):
3907 return hash((self.linenum, self.line))
3921 return hash((self.linenum, self.line))
3908
3922
3909 def __eq__(self, other):
3923 def __eq__(self, other):
3910 return self.line == other.line
3924 return self.line == other.line
3911
3925
3912 def __iter__(self):
3926 def __iter__(self):
3913 yield (self.line[:self.colstart], '')
3927 yield (self.line[:self.colstart], '')
3914 yield (self.line[self.colstart:self.colend], 'grep.match')
3928 yield (self.line[self.colstart:self.colend], 'grep.match')
3915 rest = self.line[self.colend:]
3929 rest = self.line[self.colend:]
3916 while rest != '':
3930 while rest != '':
3917 match = regexp.search(rest)
3931 match = regexp.search(rest)
3918 if not match:
3932 if not match:
3919 yield (rest, '')
3933 yield (rest, '')
3920 break
3934 break
3921 mstart, mend = match.span()
3935 mstart, mend = match.span()
3922 yield (rest[:mstart], '')
3936 yield (rest[:mstart], '')
3923 yield (rest[mstart:mend], 'grep.match')
3937 yield (rest[mstart:mend], 'grep.match')
3924 rest = rest[mend:]
3938 rest = rest[mend:]
3925
3939
3926 matches = {}
3940 matches = {}
3927 copies = {}
3941 copies = {}
3928 def grepbody(fn, rev, body):
3942 def grepbody(fn, rev, body):
3929 matches[rev].setdefault(fn, [])
3943 matches[rev].setdefault(fn, [])
3930 m = matches[rev][fn]
3944 m = matches[rev][fn]
3931 for lnum, cstart, cend, line in matchlines(body):
3945 for lnum, cstart, cend, line in matchlines(body):
3932 s = linestate(line, lnum, cstart, cend)
3946 s = linestate(line, lnum, cstart, cend)
3933 m.append(s)
3947 m.append(s)
3934
3948
3935 def difflinestates(a, b):
3949 def difflinestates(a, b):
3936 sm = difflib.SequenceMatcher(None, a, b)
3950 sm = difflib.SequenceMatcher(None, a, b)
3937 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3951 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3938 if tag == 'insert':
3952 if tag == 'insert':
3939 for i in xrange(blo, bhi):
3953 for i in xrange(blo, bhi):
3940 yield ('+', b[i])
3954 yield ('+', b[i])
3941 elif tag == 'delete':
3955 elif tag == 'delete':
3942 for i in xrange(alo, ahi):
3956 for i in xrange(alo, ahi):
3943 yield ('-', a[i])
3957 yield ('-', a[i])
3944 elif tag == 'replace':
3958 elif tag == 'replace':
3945 for i in xrange(alo, ahi):
3959 for i in xrange(alo, ahi):
3946 yield ('-', a[i])
3960 yield ('-', a[i])
3947 for i in xrange(blo, bhi):
3961 for i in xrange(blo, bhi):
3948 yield ('+', b[i])
3962 yield ('+', b[i])
3949
3963
3950 def display(fn, ctx, pstates, states):
3964 def display(fn, ctx, pstates, states):
3951 rev = ctx.rev()
3965 rev = ctx.rev()
3952 if ui.quiet:
3966 if ui.quiet:
3953 datefunc = util.shortdate
3967 datefunc = util.shortdate
3954 else:
3968 else:
3955 datefunc = util.datestr
3969 datefunc = util.datestr
3956 found = False
3970 found = False
3957 @util.cachefunc
3971 @util.cachefunc
3958 def binary():
3972 def binary():
3959 flog = getfile(fn)
3973 flog = getfile(fn)
3960 return util.binary(flog.read(ctx.filenode(fn)))
3974 return util.binary(flog.read(ctx.filenode(fn)))
3961
3975
3962 if opts.get('all'):
3976 if opts.get('all'):
3963 iter = difflinestates(pstates, states)
3977 iter = difflinestates(pstates, states)
3964 else:
3978 else:
3965 iter = [('', l) for l in states]
3979 iter = [('', l) for l in states]
3966 for change, l in iter:
3980 for change, l in iter:
3967 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3981 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3968
3982
3969 if opts.get('line_number'):
3983 if opts.get('line_number'):
3970 cols.append((str(l.linenum), 'grep.linenumber'))
3984 cols.append((str(l.linenum), 'grep.linenumber'))
3971 if opts.get('all'):
3985 if opts.get('all'):
3972 cols.append((change, 'grep.change'))
3986 cols.append((change, 'grep.change'))
3973 if opts.get('user'):
3987 if opts.get('user'):
3974 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3988 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3975 if opts.get('date'):
3989 if opts.get('date'):
3976 cols.append((datefunc(ctx.date()), 'grep.date'))
3990 cols.append((datefunc(ctx.date()), 'grep.date'))
3977 for col, label in cols[:-1]:
3991 for col, label in cols[:-1]:
3978 ui.write(col, label=label)
3992 ui.write(col, label=label)
3979 ui.write(sep, label='grep.sep')
3993 ui.write(sep, label='grep.sep')
3980 ui.write(cols[-1][0], label=cols[-1][1])
3994 ui.write(cols[-1][0], label=cols[-1][1])
3981 if not opts.get('files_with_matches'):
3995 if not opts.get('files_with_matches'):
3982 ui.write(sep, label='grep.sep')
3996 ui.write(sep, label='grep.sep')
3983 if not opts.get('text') and binary():
3997 if not opts.get('text') and binary():
3984 ui.write(" Binary file matches")
3998 ui.write(" Binary file matches")
3985 else:
3999 else:
3986 for s, label in l:
4000 for s, label in l:
3987 ui.write(s, label=label)
4001 ui.write(s, label=label)
3988 ui.write(eol)
4002 ui.write(eol)
3989 found = True
4003 found = True
3990 if opts.get('files_with_matches'):
4004 if opts.get('files_with_matches'):
3991 break
4005 break
3992 return found
4006 return found
3993
4007
3994 skip = {}
4008 skip = {}
3995 revfiles = {}
4009 revfiles = {}
3996 matchfn = scmutil.match(repo[None], pats, opts)
4010 matchfn = scmutil.match(repo[None], pats, opts)
3997 found = False
4011 found = False
3998 follow = opts.get('follow')
4012 follow = opts.get('follow')
3999
4013
4000 def prep(ctx, fns):
4014 def prep(ctx, fns):
4001 rev = ctx.rev()
4015 rev = ctx.rev()
4002 pctx = ctx.p1()
4016 pctx = ctx.p1()
4003 parent = pctx.rev()
4017 parent = pctx.rev()
4004 matches.setdefault(rev, {})
4018 matches.setdefault(rev, {})
4005 matches.setdefault(parent, {})
4019 matches.setdefault(parent, {})
4006 files = revfiles.setdefault(rev, [])
4020 files = revfiles.setdefault(rev, [])
4007 for fn in fns:
4021 for fn in fns:
4008 flog = getfile(fn)
4022 flog = getfile(fn)
4009 try:
4023 try:
4010 fnode = ctx.filenode(fn)
4024 fnode = ctx.filenode(fn)
4011 except error.LookupError:
4025 except error.LookupError:
4012 continue
4026 continue
4013
4027
4014 copied = flog.renamed(fnode)
4028 copied = flog.renamed(fnode)
4015 copy = follow and copied and copied[0]
4029 copy = follow and copied and copied[0]
4016 if copy:
4030 if copy:
4017 copies.setdefault(rev, {})[fn] = copy
4031 copies.setdefault(rev, {})[fn] = copy
4018 if fn in skip:
4032 if fn in skip:
4019 if copy:
4033 if copy:
4020 skip[copy] = True
4034 skip[copy] = True
4021 continue
4035 continue
4022 files.append(fn)
4036 files.append(fn)
4023
4037
4024 if fn not in matches[rev]:
4038 if fn not in matches[rev]:
4025 grepbody(fn, rev, flog.read(fnode))
4039 grepbody(fn, rev, flog.read(fnode))
4026
4040
4027 pfn = copy or fn
4041 pfn = copy or fn
4028 if pfn not in matches[parent]:
4042 if pfn not in matches[parent]:
4029 try:
4043 try:
4030 fnode = pctx.filenode(pfn)
4044 fnode = pctx.filenode(pfn)
4031 grepbody(pfn, parent, flog.read(fnode))
4045 grepbody(pfn, parent, flog.read(fnode))
4032 except error.LookupError:
4046 except error.LookupError:
4033 pass
4047 pass
4034
4048
4035 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4049 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4036 rev = ctx.rev()
4050 rev = ctx.rev()
4037 parent = ctx.p1().rev()
4051 parent = ctx.p1().rev()
4038 for fn in sorted(revfiles.get(rev, [])):
4052 for fn in sorted(revfiles.get(rev, [])):
4039 states = matches[rev][fn]
4053 states = matches[rev][fn]
4040 copy = copies.get(rev, {}).get(fn)
4054 copy = copies.get(rev, {}).get(fn)
4041 if fn in skip:
4055 if fn in skip:
4042 if copy:
4056 if copy:
4043 skip[copy] = True
4057 skip[copy] = True
4044 continue
4058 continue
4045 pstates = matches.get(parent, {}).get(copy or fn, [])
4059 pstates = matches.get(parent, {}).get(copy or fn, [])
4046 if pstates or states:
4060 if pstates or states:
4047 r = display(fn, ctx, pstates, states)
4061 r = display(fn, ctx, pstates, states)
4048 found = found or r
4062 found = found or r
4049 if r and not opts.get('all'):
4063 if r and not opts.get('all'):
4050 skip[fn] = True
4064 skip[fn] = True
4051 if copy:
4065 if copy:
4052 skip[copy] = True
4066 skip[copy] = True
4053 del matches[rev]
4067 del matches[rev]
4054 del revfiles[rev]
4068 del revfiles[rev]
4055
4069
4056 return not found
4070 return not found
4057
4071
4058 @command('heads',
4072 @command('heads',
4059 [('r', 'rev', '',
4073 [('r', 'rev', '',
4060 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
4074 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
4061 ('t', 'topo', False, _('show topological heads only')),
4075 ('t', 'topo', False, _('show topological heads only')),
4062 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
4076 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
4063 ('c', 'closed', False, _('show normal and closed branch heads')),
4077 ('c', 'closed', False, _('show normal and closed branch heads')),
4064 ] + templateopts,
4078 ] + templateopts,
4065 _('[-ct] [-r STARTREV] [REV]...'))
4079 _('[-ct] [-r STARTREV] [REV]...'))
4066 def heads(ui, repo, *branchrevs, **opts):
4080 def heads(ui, repo, *branchrevs, **opts):
4067 """show branch heads
4081 """show branch heads
4068
4082
4069 With no arguments, show all open branch heads in the repository.
4083 With no arguments, show all open branch heads in the repository.
4070 Branch heads are changesets that have no descendants on the
4084 Branch heads are changesets that have no descendants on the
4071 same branch. They are where development generally takes place and
4085 same branch. They are where development generally takes place and
4072 are the usual targets for update and merge operations.
4086 are the usual targets for update and merge operations.
4073
4087
4074 If one or more REVs are given, only open branch heads on the
4088 If one or more REVs are given, only open branch heads on the
4075 branches associated with the specified changesets are shown. This
4089 branches associated with the specified changesets are shown. This
4076 means that you can use :hg:`heads .` to see the heads on the
4090 means that you can use :hg:`heads .` to see the heads on the
4077 currently checked-out branch.
4091 currently checked-out branch.
4078
4092
4079 If -c/--closed is specified, also show branch heads marked closed
4093 If -c/--closed is specified, also show branch heads marked closed
4080 (see :hg:`commit --close-branch`).
4094 (see :hg:`commit --close-branch`).
4081
4095
4082 If STARTREV is specified, only those heads that are descendants of
4096 If STARTREV is specified, only those heads that are descendants of
4083 STARTREV will be displayed.
4097 STARTREV will be displayed.
4084
4098
4085 If -t/--topo is specified, named branch mechanics will be ignored and only
4099 If -t/--topo is specified, named branch mechanics will be ignored and only
4086 topological heads (changesets with no children) will be shown.
4100 topological heads (changesets with no children) will be shown.
4087
4101
4088 Returns 0 if matching heads are found, 1 if not.
4102 Returns 0 if matching heads are found, 1 if not.
4089 """
4103 """
4090
4104
4091 start = None
4105 start = None
4092 if 'rev' in opts:
4106 if 'rev' in opts:
4093 start = scmutil.revsingle(repo, opts['rev'], None).node()
4107 start = scmutil.revsingle(repo, opts['rev'], None).node()
4094
4108
4095 if opts.get('topo'):
4109 if opts.get('topo'):
4096 heads = [repo[h] for h in repo.heads(start)]
4110 heads = [repo[h] for h in repo.heads(start)]
4097 else:
4111 else:
4098 heads = []
4112 heads = []
4099 for branch in repo.branchmap():
4113 for branch in repo.branchmap():
4100 heads += repo.branchheads(branch, start, opts.get('closed'))
4114 heads += repo.branchheads(branch, start, opts.get('closed'))
4101 heads = [repo[h] for h in heads]
4115 heads = [repo[h] for h in heads]
4102
4116
4103 if branchrevs:
4117 if branchrevs:
4104 branches = set(repo[br].branch() for br in branchrevs)
4118 branches = set(repo[br].branch() for br in branchrevs)
4105 heads = [h for h in heads if h.branch() in branches]
4119 heads = [h for h in heads if h.branch() in branches]
4106
4120
4107 if opts.get('active') and branchrevs:
4121 if opts.get('active') and branchrevs:
4108 dagheads = repo.heads(start)
4122 dagheads = repo.heads(start)
4109 heads = [h for h in heads if h.node() in dagheads]
4123 heads = [h for h in heads if h.node() in dagheads]
4110
4124
4111 if branchrevs:
4125 if branchrevs:
4112 haveheads = set(h.branch() for h in heads)
4126 haveheads = set(h.branch() for h in heads)
4113 if branches - haveheads:
4127 if branches - haveheads:
4114 headless = ', '.join(b for b in branches - haveheads)
4128 headless = ', '.join(b for b in branches - haveheads)
4115 msg = _('no open branch heads found on branches %s')
4129 msg = _('no open branch heads found on branches %s')
4116 if opts.get('rev'):
4130 if opts.get('rev'):
4117 msg += _(' (started at %s)') % opts['rev']
4131 msg += _(' (started at %s)') % opts['rev']
4118 ui.warn((msg + '\n') % headless)
4132 ui.warn((msg + '\n') % headless)
4119
4133
4120 if not heads:
4134 if not heads:
4121 return 1
4135 return 1
4122
4136
4123 heads = sorted(heads, key=lambda x: -x.rev())
4137 heads = sorted(heads, key=lambda x: -x.rev())
4124 displayer = cmdutil.show_changeset(ui, repo, opts)
4138 displayer = cmdutil.show_changeset(ui, repo, opts)
4125 for ctx in heads:
4139 for ctx in heads:
4126 displayer.show(ctx)
4140 displayer.show(ctx)
4127 displayer.close()
4141 displayer.close()
4128
4142
4129 @command('help',
4143 @command('help',
4130 [('e', 'extension', None, _('show only help for extensions')),
4144 [('e', 'extension', None, _('show only help for extensions')),
4131 ('c', 'command', None, _('show only help for commands')),
4145 ('c', 'command', None, _('show only help for commands')),
4132 ('k', 'keyword', None, _('show topics matching keyword')),
4146 ('k', 'keyword', None, _('show topics matching keyword')),
4133 ],
4147 ],
4134 _('[-eck] [TOPIC]'),
4148 _('[-eck] [TOPIC]'),
4135 norepo=True)
4149 norepo=True)
4136 def help_(ui, name=None, **opts):
4150 def help_(ui, name=None, **opts):
4137 """show help for a given topic or a help overview
4151 """show help for a given topic or a help overview
4138
4152
4139 With no arguments, print a list of commands with short help messages.
4153 With no arguments, print a list of commands with short help messages.
4140
4154
4141 Given a topic, extension, or command name, print help for that
4155 Given a topic, extension, or command name, print help for that
4142 topic.
4156 topic.
4143
4157
4144 Returns 0 if successful.
4158 Returns 0 if successful.
4145 """
4159 """
4146
4160
4147 textwidth = min(ui.termwidth(), 80) - 2
4161 textwidth = min(ui.termwidth(), 80) - 2
4148
4162
4149 keep = []
4163 keep = []
4150 if ui.verbose:
4164 if ui.verbose:
4151 keep.append('verbose')
4165 keep.append('verbose')
4152 if sys.platform.startswith('win'):
4166 if sys.platform.startswith('win'):
4153 keep.append('windows')
4167 keep.append('windows')
4154 elif sys.platform == 'OpenVMS':
4168 elif sys.platform == 'OpenVMS':
4155 keep.append('vms')
4169 keep.append('vms')
4156 elif sys.platform == 'plan9':
4170 elif sys.platform == 'plan9':
4157 keep.append('plan9')
4171 keep.append('plan9')
4158 else:
4172 else:
4159 keep.append('unix')
4173 keep.append('unix')
4160 keep.append(sys.platform.lower())
4174 keep.append(sys.platform.lower())
4161
4175
4162 section = None
4176 section = None
4163 if name and '.' in name:
4177 if name and '.' in name:
4164 name, section = name.split('.', 1)
4178 name, section = name.split('.', 1)
4165 section = section.lower()
4179 section = section.lower()
4166
4180
4167 text = help.help_(ui, name, **opts)
4181 text = help.help_(ui, name, **opts)
4168
4182
4169 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4183 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4170 section=section)
4184 section=section)
4171
4185
4172 # We could have been given a weird ".foo" section without a name
4186 # We could have been given a weird ".foo" section without a name
4173 # to look for, or we could have simply failed to found "foo.bar"
4187 # to look for, or we could have simply failed to found "foo.bar"
4174 # because bar isn't a section of foo
4188 # because bar isn't a section of foo
4175 if section and not (formatted and name):
4189 if section and not (formatted and name):
4176 raise error.Abort(_("help section not found"))
4190 raise error.Abort(_("help section not found"))
4177
4191
4178 if 'verbose' in pruned:
4192 if 'verbose' in pruned:
4179 keep.append('omitted')
4193 keep.append('omitted')
4180 else:
4194 else:
4181 keep.append('notomitted')
4195 keep.append('notomitted')
4182 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4196 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4183 section=section)
4197 section=section)
4184 ui.write(formatted)
4198 ui.write(formatted)
4185
4199
4186
4200
4187 @command('identify|id',
4201 @command('identify|id',
4188 [('r', 'rev', '',
4202 [('r', 'rev', '',
4189 _('identify the specified revision'), _('REV')),
4203 _('identify the specified revision'), _('REV')),
4190 ('n', 'num', None, _('show local revision number')),
4204 ('n', 'num', None, _('show local revision number')),
4191 ('i', 'id', None, _('show global revision id')),
4205 ('i', 'id', None, _('show global revision id')),
4192 ('b', 'branch', None, _('show branch')),
4206 ('b', 'branch', None, _('show branch')),
4193 ('t', 'tags', None, _('show tags')),
4207 ('t', 'tags', None, _('show tags')),
4194 ('B', 'bookmarks', None, _('show bookmarks')),
4208 ('B', 'bookmarks', None, _('show bookmarks')),
4195 ] + remoteopts,
4209 ] + remoteopts,
4196 _('[-nibtB] [-r REV] [SOURCE]'),
4210 _('[-nibtB] [-r REV] [SOURCE]'),
4197 optionalrepo=True)
4211 optionalrepo=True)
4198 def identify(ui, repo, source=None, rev=None,
4212 def identify(ui, repo, source=None, rev=None,
4199 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4213 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4200 """identify the working directory or specified revision
4214 """identify the working directory or specified revision
4201
4215
4202 Print a summary identifying the repository state at REV using one or
4216 Print a summary identifying the repository state at REV using one or
4203 two parent hash identifiers, followed by a "+" if the working
4217 two parent hash identifiers, followed by a "+" if the working
4204 directory has uncommitted changes, the branch name (if not default),
4218 directory has uncommitted changes, the branch name (if not default),
4205 a list of tags, and a list of bookmarks.
4219 a list of tags, and a list of bookmarks.
4206
4220
4207 When REV is not given, print a summary of the current state of the
4221 When REV is not given, print a summary of the current state of the
4208 repository.
4222 repository.
4209
4223
4210 Specifying a path to a repository root or Mercurial bundle will
4224 Specifying a path to a repository root or Mercurial bundle will
4211 cause lookup to operate on that repository/bundle.
4225 cause lookup to operate on that repository/bundle.
4212
4226
4213 .. container:: verbose
4227 .. container:: verbose
4214
4228
4215 Examples:
4229 Examples:
4216
4230
4217 - generate a build identifier for the working directory::
4231 - generate a build identifier for the working directory::
4218
4232
4219 hg id --id > build-id.dat
4233 hg id --id > build-id.dat
4220
4234
4221 - find the revision corresponding to a tag::
4235 - find the revision corresponding to a tag::
4222
4236
4223 hg id -n -r 1.3
4237 hg id -n -r 1.3
4224
4238
4225 - check the most recent revision of a remote repository::
4239 - check the most recent revision of a remote repository::
4226
4240
4227 hg id -r tip http://selenic.com/hg/
4241 hg id -r tip http://selenic.com/hg/
4228
4242
4229 See :hg:`log` for generating more information about specific revisions,
4243 See :hg:`log` for generating more information about specific revisions,
4230 including full hash identifiers.
4244 including full hash identifiers.
4231
4245
4232 Returns 0 if successful.
4246 Returns 0 if successful.
4233 """
4247 """
4234
4248
4235 if not repo and not source:
4249 if not repo and not source:
4236 raise error.Abort(_("there is no Mercurial repository here "
4250 raise error.Abort(_("there is no Mercurial repository here "
4237 "(.hg not found)"))
4251 "(.hg not found)"))
4238
4252
4239 if ui.debugflag:
4253 if ui.debugflag:
4240 hexfunc = hex
4254 hexfunc = hex
4241 else:
4255 else:
4242 hexfunc = short
4256 hexfunc = short
4243 default = not (num or id or branch or tags or bookmarks)
4257 default = not (num or id or branch or tags or bookmarks)
4244 output = []
4258 output = []
4245 revs = []
4259 revs = []
4246
4260
4247 if source:
4261 if source:
4248 source, branches = hg.parseurl(ui.expandpath(source))
4262 source, branches = hg.parseurl(ui.expandpath(source))
4249 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4263 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4250 repo = peer.local()
4264 repo = peer.local()
4251 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4265 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4252
4266
4253 if not repo:
4267 if not repo:
4254 if num or branch or tags:
4268 if num or branch or tags:
4255 raise error.Abort(
4269 raise error.Abort(
4256 _("can't query remote revision number, branch, or tags"))
4270 _("can't query remote revision number, branch, or tags"))
4257 if not rev and revs:
4271 if not rev and revs:
4258 rev = revs[0]
4272 rev = revs[0]
4259 if not rev:
4273 if not rev:
4260 rev = "tip"
4274 rev = "tip"
4261
4275
4262 remoterev = peer.lookup(rev)
4276 remoterev = peer.lookup(rev)
4263 if default or id:
4277 if default or id:
4264 output = [hexfunc(remoterev)]
4278 output = [hexfunc(remoterev)]
4265
4279
4266 def getbms():
4280 def getbms():
4267 bms = []
4281 bms = []
4268
4282
4269 if 'bookmarks' in peer.listkeys('namespaces'):
4283 if 'bookmarks' in peer.listkeys('namespaces'):
4270 hexremoterev = hex(remoterev)
4284 hexremoterev = hex(remoterev)
4271 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4285 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4272 if bmr == hexremoterev]
4286 if bmr == hexremoterev]
4273
4287
4274 return sorted(bms)
4288 return sorted(bms)
4275
4289
4276 if bookmarks:
4290 if bookmarks:
4277 output.extend(getbms())
4291 output.extend(getbms())
4278 elif default and not ui.quiet:
4292 elif default and not ui.quiet:
4279 # multiple bookmarks for a single parent separated by '/'
4293 # multiple bookmarks for a single parent separated by '/'
4280 bm = '/'.join(getbms())
4294 bm = '/'.join(getbms())
4281 if bm:
4295 if bm:
4282 output.append(bm)
4296 output.append(bm)
4283 else:
4297 else:
4284 ctx = scmutil.revsingle(repo, rev, None)
4298 ctx = scmutil.revsingle(repo, rev, None)
4285
4299
4286 if ctx.rev() is None:
4300 if ctx.rev() is None:
4287 ctx = repo[None]
4301 ctx = repo[None]
4288 parents = ctx.parents()
4302 parents = ctx.parents()
4289 taglist = []
4303 taglist = []
4290 for p in parents:
4304 for p in parents:
4291 taglist.extend(p.tags())
4305 taglist.extend(p.tags())
4292
4306
4293 changed = ""
4307 changed = ""
4294 if default or id or num:
4308 if default or id or num:
4295 if (any(repo.status())
4309 if (any(repo.status())
4296 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4310 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4297 changed = '+'
4311 changed = '+'
4298 if default or id:
4312 if default or id:
4299 output = ["%s%s" %
4313 output = ["%s%s" %
4300 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4314 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4301 if num:
4315 if num:
4302 output.append("%s%s" %
4316 output.append("%s%s" %
4303 ('+'.join([str(p.rev()) for p in parents]), changed))
4317 ('+'.join([str(p.rev()) for p in parents]), changed))
4304 else:
4318 else:
4305 if default or id:
4319 if default or id:
4306 output = [hexfunc(ctx.node())]
4320 output = [hexfunc(ctx.node())]
4307 if num:
4321 if num:
4308 output.append(str(ctx.rev()))
4322 output.append(str(ctx.rev()))
4309 taglist = ctx.tags()
4323 taglist = ctx.tags()
4310
4324
4311 if default and not ui.quiet:
4325 if default and not ui.quiet:
4312 b = ctx.branch()
4326 b = ctx.branch()
4313 if b != 'default':
4327 if b != 'default':
4314 output.append("(%s)" % b)
4328 output.append("(%s)" % b)
4315
4329
4316 # multiple tags for a single parent separated by '/'
4330 # multiple tags for a single parent separated by '/'
4317 t = '/'.join(taglist)
4331 t = '/'.join(taglist)
4318 if t:
4332 if t:
4319 output.append(t)
4333 output.append(t)
4320
4334
4321 # multiple bookmarks for a single parent separated by '/'
4335 # multiple bookmarks for a single parent separated by '/'
4322 bm = '/'.join(ctx.bookmarks())
4336 bm = '/'.join(ctx.bookmarks())
4323 if bm:
4337 if bm:
4324 output.append(bm)
4338 output.append(bm)
4325 else:
4339 else:
4326 if branch:
4340 if branch:
4327 output.append(ctx.branch())
4341 output.append(ctx.branch())
4328
4342
4329 if tags:
4343 if tags:
4330 output.extend(taglist)
4344 output.extend(taglist)
4331
4345
4332 if bookmarks:
4346 if bookmarks:
4333 output.extend(ctx.bookmarks())
4347 output.extend(ctx.bookmarks())
4334
4348
4335 ui.write("%s\n" % ' '.join(output))
4349 ui.write("%s\n" % ' '.join(output))
4336
4350
4337 @command('import|patch',
4351 @command('import|patch',
4338 [('p', 'strip', 1,
4352 [('p', 'strip', 1,
4339 _('directory strip option for patch. This has the same '
4353 _('directory strip option for patch. This has the same '
4340 'meaning as the corresponding patch option'), _('NUM')),
4354 'meaning as the corresponding patch option'), _('NUM')),
4341 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4355 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4342 ('e', 'edit', False, _('invoke editor on commit messages')),
4356 ('e', 'edit', False, _('invoke editor on commit messages')),
4343 ('f', 'force', None,
4357 ('f', 'force', None,
4344 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4358 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4345 ('', 'no-commit', None,
4359 ('', 'no-commit', None,
4346 _("don't commit, just update the working directory")),
4360 _("don't commit, just update the working directory")),
4347 ('', 'bypass', None,
4361 ('', 'bypass', None,
4348 _("apply patch without touching the working directory")),
4362 _("apply patch without touching the working directory")),
4349 ('', 'partial', None,
4363 ('', 'partial', None,
4350 _('commit even if some hunks fail')),
4364 _('commit even if some hunks fail')),
4351 ('', 'exact', None,
4365 ('', 'exact', None,
4352 _('apply patch to the nodes from which it was generated')),
4366 _('apply patch to the nodes from which it was generated')),
4353 ('', 'prefix', '',
4367 ('', 'prefix', '',
4354 _('apply patch to subdirectory'), _('DIR')),
4368 _('apply patch to subdirectory'), _('DIR')),
4355 ('', 'import-branch', None,
4369 ('', 'import-branch', None,
4356 _('use any branch information in patch (implied by --exact)'))] +
4370 _('use any branch information in patch (implied by --exact)'))] +
4357 commitopts + commitopts2 + similarityopts,
4371 commitopts + commitopts2 + similarityopts,
4358 _('[OPTION]... PATCH...'))
4372 _('[OPTION]... PATCH...'))
4359 def import_(ui, repo, patch1=None, *patches, **opts):
4373 def import_(ui, repo, patch1=None, *patches, **opts):
4360 """import an ordered set of patches
4374 """import an ordered set of patches
4361
4375
4362 Import a list of patches and commit them individually (unless
4376 Import a list of patches and commit them individually (unless
4363 --no-commit is specified).
4377 --no-commit is specified).
4364
4378
4365 Because import first applies changes to the working directory,
4379 Because import first applies changes to the working directory,
4366 import will abort if there are outstanding changes.
4380 import will abort if there are outstanding changes.
4367
4381
4368 You can import a patch straight from a mail message. Even patches
4382 You can import a patch straight from a mail message. Even patches
4369 as attachments work (to use the body part, it must have type
4383 as attachments work (to use the body part, it must have type
4370 text/plain or text/x-patch). From and Subject headers of email
4384 text/plain or text/x-patch). From and Subject headers of email
4371 message are used as default committer and commit message. All
4385 message are used as default committer and commit message. All
4372 text/plain body parts before first diff are added to commit
4386 text/plain body parts before first diff are added to commit
4373 message.
4387 message.
4374
4388
4375 If the imported patch was generated by :hg:`export`, user and
4389 If the imported patch was generated by :hg:`export`, user and
4376 description from patch override values from message headers and
4390 description from patch override values from message headers and
4377 body. Values given on command line with -m/--message and -u/--user
4391 body. Values given on command line with -m/--message and -u/--user
4378 override these.
4392 override these.
4379
4393
4380 If --exact is specified, import will set the working directory to
4394 If --exact is specified, import will set the working directory to
4381 the parent of each patch before applying it, and will abort if the
4395 the parent of each patch before applying it, and will abort if the
4382 resulting changeset has a different ID than the one recorded in
4396 resulting changeset has a different ID than the one recorded in
4383 the patch. This may happen due to character set problems or other
4397 the patch. This may happen due to character set problems or other
4384 deficiencies in the text patch format.
4398 deficiencies in the text patch format.
4385
4399
4386 Use --bypass to apply and commit patches directly to the
4400 Use --bypass to apply and commit patches directly to the
4387 repository, not touching the working directory. Without --exact,
4401 repository, not touching the working directory. Without --exact,
4388 patches will be applied on top of the working directory parent
4402 patches will be applied on top of the working directory parent
4389 revision.
4403 revision.
4390
4404
4391 With -s/--similarity, hg will attempt to discover renames and
4405 With -s/--similarity, hg will attempt to discover renames and
4392 copies in the patch in the same way as :hg:`addremove`.
4406 copies in the patch in the same way as :hg:`addremove`.
4393
4407
4394 Use --partial to ensure a changeset will be created from the patch
4408 Use --partial to ensure a changeset will be created from the patch
4395 even if some hunks fail to apply. Hunks that fail to apply will be
4409 even if some hunks fail to apply. Hunks that fail to apply will be
4396 written to a <target-file>.rej file. Conflicts can then be resolved
4410 written to a <target-file>.rej file. Conflicts can then be resolved
4397 by hand before :hg:`commit --amend` is run to update the created
4411 by hand before :hg:`commit --amend` is run to update the created
4398 changeset. This flag exists to let people import patches that
4412 changeset. This flag exists to let people import patches that
4399 partially apply without losing the associated metadata (author,
4413 partially apply without losing the associated metadata (author,
4400 date, description, ...). Note that when none of the hunk applies
4414 date, description, ...). Note that when none of the hunk applies
4401 cleanly, :hg:`import --partial` will create an empty changeset,
4415 cleanly, :hg:`import --partial` will create an empty changeset,
4402 importing only the patch metadata.
4416 importing only the patch metadata.
4403
4417
4404 It is possible to use external patch programs to perform the patch
4418 It is possible to use external patch programs to perform the patch
4405 by setting the ``ui.patch`` configuration option. For the default
4419 by setting the ``ui.patch`` configuration option. For the default
4406 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4420 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4407 See :hg:`help config` for more information about configuration
4421 See :hg:`help config` for more information about configuration
4408 files and how to use these options.
4422 files and how to use these options.
4409
4423
4410 To read a patch from standard input, use "-" as the patch name. If
4424 To read a patch from standard input, use "-" as the patch name. If
4411 a URL is specified, the patch will be downloaded from it.
4425 a URL is specified, the patch will be downloaded from it.
4412 See :hg:`help dates` for a list of formats valid for -d/--date.
4426 See :hg:`help dates` for a list of formats valid for -d/--date.
4413
4427
4414 .. container:: verbose
4428 .. container:: verbose
4415
4429
4416 Examples:
4430 Examples:
4417
4431
4418 - import a traditional patch from a website and detect renames::
4432 - import a traditional patch from a website and detect renames::
4419
4433
4420 hg import -s 80 http://example.com/bugfix.patch
4434 hg import -s 80 http://example.com/bugfix.patch
4421
4435
4422 - import a changeset from an hgweb server::
4436 - import a changeset from an hgweb server::
4423
4437
4424 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4438 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4425
4439
4426 - import all the patches in an Unix-style mbox::
4440 - import all the patches in an Unix-style mbox::
4427
4441
4428 hg import incoming-patches.mbox
4442 hg import incoming-patches.mbox
4429
4443
4430 - attempt to exactly restore an exported changeset (not always
4444 - attempt to exactly restore an exported changeset (not always
4431 possible)::
4445 possible)::
4432
4446
4433 hg import --exact proposed-fix.patch
4447 hg import --exact proposed-fix.patch
4434
4448
4435 - use an external tool to apply a patch which is too fuzzy for
4449 - use an external tool to apply a patch which is too fuzzy for
4436 the default internal tool.
4450 the default internal tool.
4437
4451
4438 hg import --config ui.patch="patch --merge" fuzzy.patch
4452 hg import --config ui.patch="patch --merge" fuzzy.patch
4439
4453
4440 - change the default fuzzing from 2 to a less strict 7
4454 - change the default fuzzing from 2 to a less strict 7
4441
4455
4442 hg import --config ui.fuzz=7 fuzz.patch
4456 hg import --config ui.fuzz=7 fuzz.patch
4443
4457
4444 Returns 0 on success, 1 on partial success (see --partial).
4458 Returns 0 on success, 1 on partial success (see --partial).
4445 """
4459 """
4446
4460
4447 if not patch1:
4461 if not patch1:
4448 raise error.Abort(_('need at least one patch to import'))
4462 raise error.Abort(_('need at least one patch to import'))
4449
4463
4450 patches = (patch1,) + patches
4464 patches = (patch1,) + patches
4451
4465
4452 date = opts.get('date')
4466 date = opts.get('date')
4453 if date:
4467 if date:
4454 opts['date'] = util.parsedate(date)
4468 opts['date'] = util.parsedate(date)
4455
4469
4456 update = not opts.get('bypass')
4470 update = not opts.get('bypass')
4457 if not update and opts.get('no_commit'):
4471 if not update and opts.get('no_commit'):
4458 raise error.Abort(_('cannot use --no-commit with --bypass'))
4472 raise error.Abort(_('cannot use --no-commit with --bypass'))
4459 try:
4473 try:
4460 sim = float(opts.get('similarity') or 0)
4474 sim = float(opts.get('similarity') or 0)
4461 except ValueError:
4475 except ValueError:
4462 raise error.Abort(_('similarity must be a number'))
4476 raise error.Abort(_('similarity must be a number'))
4463 if sim < 0 or sim > 100:
4477 if sim < 0 or sim > 100:
4464 raise error.Abort(_('similarity must be between 0 and 100'))
4478 raise error.Abort(_('similarity must be between 0 and 100'))
4465 if sim and not update:
4479 if sim and not update:
4466 raise error.Abort(_('cannot use --similarity with --bypass'))
4480 raise error.Abort(_('cannot use --similarity with --bypass'))
4467 if opts.get('exact') and opts.get('edit'):
4481 if opts.get('exact') and opts.get('edit'):
4468 raise error.Abort(_('cannot use --exact with --edit'))
4482 raise error.Abort(_('cannot use --exact with --edit'))
4469 if opts.get('exact') and opts.get('prefix'):
4483 if opts.get('exact') and opts.get('prefix'):
4470 raise error.Abort(_('cannot use --exact with --prefix'))
4484 raise error.Abort(_('cannot use --exact with --prefix'))
4471
4485
4472 if update:
4486 if update:
4473 cmdutil.checkunfinished(repo)
4487 cmdutil.checkunfinished(repo)
4474 if (opts.get('exact') or not opts.get('force')) and update:
4488 if (opts.get('exact') or not opts.get('force')) and update:
4475 cmdutil.bailifchanged(repo)
4489 cmdutil.bailifchanged(repo)
4476
4490
4477 base = opts["base"]
4491 base = opts["base"]
4478 wlock = dsguard = lock = tr = None
4492 wlock = dsguard = lock = tr = None
4479 msgs = []
4493 msgs = []
4480 ret = 0
4494 ret = 0
4481
4495
4482
4496
4483 try:
4497 try:
4484 try:
4498 try:
4485 wlock = repo.wlock()
4499 wlock = repo.wlock()
4486 if not opts.get('no_commit'):
4500 if not opts.get('no_commit'):
4487 lock = repo.lock()
4501 lock = repo.lock()
4488 tr = repo.transaction('import')
4502 tr = repo.transaction('import')
4489 else:
4503 else:
4490 dsguard = cmdutil.dirstateguard(repo, 'import')
4504 dsguard = cmdutil.dirstateguard(repo, 'import')
4491 parents = repo.parents()
4505 parents = repo.parents()
4492 for patchurl in patches:
4506 for patchurl in patches:
4493 if patchurl == '-':
4507 if patchurl == '-':
4494 ui.status(_('applying patch from stdin\n'))
4508 ui.status(_('applying patch from stdin\n'))
4495 patchfile = ui.fin
4509 patchfile = ui.fin
4496 patchurl = 'stdin' # for error message
4510 patchurl = 'stdin' # for error message
4497 else:
4511 else:
4498 patchurl = os.path.join(base, patchurl)
4512 patchurl = os.path.join(base, patchurl)
4499 ui.status(_('applying %s\n') % patchurl)
4513 ui.status(_('applying %s\n') % patchurl)
4500 patchfile = hg.openpath(ui, patchurl)
4514 patchfile = hg.openpath(ui, patchurl)
4501
4515
4502 haspatch = False
4516 haspatch = False
4503 for hunk in patch.split(patchfile):
4517 for hunk in patch.split(patchfile):
4504 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4518 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4505 parents, opts,
4519 parents, opts,
4506 msgs, hg.clean)
4520 msgs, hg.clean)
4507 if msg:
4521 if msg:
4508 haspatch = True
4522 haspatch = True
4509 ui.note(msg + '\n')
4523 ui.note(msg + '\n')
4510 if update or opts.get('exact'):
4524 if update or opts.get('exact'):
4511 parents = repo.parents()
4525 parents = repo.parents()
4512 else:
4526 else:
4513 parents = [repo[node]]
4527 parents = [repo[node]]
4514 if rej:
4528 if rej:
4515 ui.write_err(_("patch applied partially\n"))
4529 ui.write_err(_("patch applied partially\n"))
4516 ui.write_err(_("(fix the .rej files and run "
4530 ui.write_err(_("(fix the .rej files and run "
4517 "`hg commit --amend`)\n"))
4531 "`hg commit --amend`)\n"))
4518 ret = 1
4532 ret = 1
4519 break
4533 break
4520
4534
4521 if not haspatch:
4535 if not haspatch:
4522 raise error.Abort(_('%s: no diffs found') % patchurl)
4536 raise error.Abort(_('%s: no diffs found') % patchurl)
4523
4537
4524 if tr:
4538 if tr:
4525 tr.close()
4539 tr.close()
4526 if msgs:
4540 if msgs:
4527 repo.savecommitmessage('\n* * *\n'.join(msgs))
4541 repo.savecommitmessage('\n* * *\n'.join(msgs))
4528 if dsguard:
4542 if dsguard:
4529 dsguard.close()
4543 dsguard.close()
4530 return ret
4544 return ret
4531 finally:
4545 finally:
4532 # TODO: get rid of this meaningless try/finally enclosing.
4546 # TODO: get rid of this meaningless try/finally enclosing.
4533 # this is kept only to reduce changes in a patch.
4547 # this is kept only to reduce changes in a patch.
4534 pass
4548 pass
4535 finally:
4549 finally:
4536 if tr:
4550 if tr:
4537 tr.release()
4551 tr.release()
4538 release(lock, dsguard, wlock)
4552 release(lock, dsguard, wlock)
4539
4553
4540 @command('incoming|in',
4554 @command('incoming|in',
4541 [('f', 'force', None,
4555 [('f', 'force', None,
4542 _('run even if remote repository is unrelated')),
4556 _('run even if remote repository is unrelated')),
4543 ('n', 'newest-first', None, _('show newest record first')),
4557 ('n', 'newest-first', None, _('show newest record first')),
4544 ('', 'bundle', '',
4558 ('', 'bundle', '',
4545 _('file to store the bundles into'), _('FILE')),
4559 _('file to store the bundles into'), _('FILE')),
4546 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4560 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4547 ('B', 'bookmarks', False, _("compare bookmarks")),
4561 ('B', 'bookmarks', False, _("compare bookmarks")),
4548 ('b', 'branch', [],
4562 ('b', 'branch', [],
4549 _('a specific branch you would like to pull'), _('BRANCH')),
4563 _('a specific branch you would like to pull'), _('BRANCH')),
4550 ] + logopts + remoteopts + subrepoopts,
4564 ] + logopts + remoteopts + subrepoopts,
4551 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4565 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4552 def incoming(ui, repo, source="default", **opts):
4566 def incoming(ui, repo, source="default", **opts):
4553 """show new changesets found in source
4567 """show new changesets found in source
4554
4568
4555 Show new changesets found in the specified path/URL or the default
4569 Show new changesets found in the specified path/URL or the default
4556 pull location. These are the changesets that would have been pulled
4570 pull location. These are the changesets that would have been pulled
4557 if a pull at the time you issued this command.
4571 if a pull at the time you issued this command.
4558
4572
4559 See pull for valid source format details.
4573 See pull for valid source format details.
4560
4574
4561 .. container:: verbose
4575 .. container:: verbose
4562
4576
4563 With -B/--bookmarks, the result of bookmark comparison between
4577 With -B/--bookmarks, the result of bookmark comparison between
4564 local and remote repositories is displayed. With -v/--verbose,
4578 local and remote repositories is displayed. With -v/--verbose,
4565 status is also displayed for each bookmark like below::
4579 status is also displayed for each bookmark like below::
4566
4580
4567 BM1 01234567890a added
4581 BM1 01234567890a added
4568 BM2 1234567890ab advanced
4582 BM2 1234567890ab advanced
4569 BM3 234567890abc diverged
4583 BM3 234567890abc diverged
4570 BM4 34567890abcd changed
4584 BM4 34567890abcd changed
4571
4585
4572 The action taken locally when pulling depends on the
4586 The action taken locally when pulling depends on the
4573 status of each bookmark:
4587 status of each bookmark:
4574
4588
4575 :``added``: pull will create it
4589 :``added``: pull will create it
4576 :``advanced``: pull will update it
4590 :``advanced``: pull will update it
4577 :``diverged``: pull will create a divergent bookmark
4591 :``diverged``: pull will create a divergent bookmark
4578 :``changed``: result depends on remote changesets
4592 :``changed``: result depends on remote changesets
4579
4593
4580 From the point of view of pulling behavior, bookmark
4594 From the point of view of pulling behavior, bookmark
4581 existing only in the remote repository are treated as ``added``,
4595 existing only in the remote repository are treated as ``added``,
4582 even if it is in fact locally deleted.
4596 even if it is in fact locally deleted.
4583
4597
4584 .. container:: verbose
4598 .. container:: verbose
4585
4599
4586 For remote repository, using --bundle avoids downloading the
4600 For remote repository, using --bundle avoids downloading the
4587 changesets twice if the incoming is followed by a pull.
4601 changesets twice if the incoming is followed by a pull.
4588
4602
4589 Examples:
4603 Examples:
4590
4604
4591 - show incoming changes with patches and full description::
4605 - show incoming changes with patches and full description::
4592
4606
4593 hg incoming -vp
4607 hg incoming -vp
4594
4608
4595 - show incoming changes excluding merges, store a bundle::
4609 - show incoming changes excluding merges, store a bundle::
4596
4610
4597 hg in -vpM --bundle incoming.hg
4611 hg in -vpM --bundle incoming.hg
4598 hg pull incoming.hg
4612 hg pull incoming.hg
4599
4613
4600 - briefly list changes inside a bundle::
4614 - briefly list changes inside a bundle::
4601
4615
4602 hg in changes.hg -T "{desc|firstline}\\n"
4616 hg in changes.hg -T "{desc|firstline}\\n"
4603
4617
4604 Returns 0 if there are incoming changes, 1 otherwise.
4618 Returns 0 if there are incoming changes, 1 otherwise.
4605 """
4619 """
4606 if opts.get('graph'):
4620 if opts.get('graph'):
4607 cmdutil.checkunsupportedgraphflags([], opts)
4621 cmdutil.checkunsupportedgraphflags([], opts)
4608 def display(other, chlist, displayer):
4622 def display(other, chlist, displayer):
4609 revdag = cmdutil.graphrevs(other, chlist, opts)
4623 revdag = cmdutil.graphrevs(other, chlist, opts)
4610 showparents = [ctx.node() for ctx in repo[None].parents()]
4624 showparents = [ctx.node() for ctx in repo[None].parents()]
4611 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4625 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4612 graphmod.asciiedges)
4626 graphmod.asciiedges)
4613
4627
4614 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4628 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4615 return 0
4629 return 0
4616
4630
4617 if opts.get('bundle') and opts.get('subrepos'):
4631 if opts.get('bundle') and opts.get('subrepos'):
4618 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4632 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4619
4633
4620 if opts.get('bookmarks'):
4634 if opts.get('bookmarks'):
4621 source, branches = hg.parseurl(ui.expandpath(source),
4635 source, branches = hg.parseurl(ui.expandpath(source),
4622 opts.get('branch'))
4636 opts.get('branch'))
4623 other = hg.peer(repo, opts, source)
4637 other = hg.peer(repo, opts, source)
4624 if 'bookmarks' not in other.listkeys('namespaces'):
4638 if 'bookmarks' not in other.listkeys('namespaces'):
4625 ui.warn(_("remote doesn't support bookmarks\n"))
4639 ui.warn(_("remote doesn't support bookmarks\n"))
4626 return 0
4640 return 0
4627 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4641 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4628 return bookmarks.incoming(ui, repo, other)
4642 return bookmarks.incoming(ui, repo, other)
4629
4643
4630 repo._subtoppath = ui.expandpath(source)
4644 repo._subtoppath = ui.expandpath(source)
4631 try:
4645 try:
4632 return hg.incoming(ui, repo, source, opts)
4646 return hg.incoming(ui, repo, source, opts)
4633 finally:
4647 finally:
4634 del repo._subtoppath
4648 del repo._subtoppath
4635
4649
4636
4650
4637 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4651 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4638 norepo=True)
4652 norepo=True)
4639 def init(ui, dest=".", **opts):
4653 def init(ui, dest=".", **opts):
4640 """create a new repository in the given directory
4654 """create a new repository in the given directory
4641
4655
4642 Initialize a new repository in the given directory. If the given
4656 Initialize a new repository in the given directory. If the given
4643 directory does not exist, it will be created.
4657 directory does not exist, it will be created.
4644
4658
4645 If no directory is given, the current directory is used.
4659 If no directory is given, the current directory is used.
4646
4660
4647 It is possible to specify an ``ssh://`` URL as the destination.
4661 It is possible to specify an ``ssh://`` URL as the destination.
4648 See :hg:`help urls` for more information.
4662 See :hg:`help urls` for more information.
4649
4663
4650 Returns 0 on success.
4664 Returns 0 on success.
4651 """
4665 """
4652 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4666 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4653
4667
4654 @command('locate',
4668 @command('locate',
4655 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4669 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4656 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4670 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4657 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4671 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4658 ] + walkopts,
4672 ] + walkopts,
4659 _('[OPTION]... [PATTERN]...'))
4673 _('[OPTION]... [PATTERN]...'))
4660 def locate(ui, repo, *pats, **opts):
4674 def locate(ui, repo, *pats, **opts):
4661 """locate files matching specific patterns (DEPRECATED)
4675 """locate files matching specific patterns (DEPRECATED)
4662
4676
4663 Print files under Mercurial control in the working directory whose
4677 Print files under Mercurial control in the working directory whose
4664 names match the given patterns.
4678 names match the given patterns.
4665
4679
4666 By default, this command searches all directories in the working
4680 By default, this command searches all directories in the working
4667 directory. To search just the current directory and its
4681 directory. To search just the current directory and its
4668 subdirectories, use "--include .".
4682 subdirectories, use "--include .".
4669
4683
4670 If no patterns are given to match, this command prints the names
4684 If no patterns are given to match, this command prints the names
4671 of all files under Mercurial control in the working directory.
4685 of all files under Mercurial control in the working directory.
4672
4686
4673 If you want to feed the output of this command into the "xargs"
4687 If you want to feed the output of this command into the "xargs"
4674 command, use the -0 option to both this command and "xargs". This
4688 command, use the -0 option to both this command and "xargs". This
4675 will avoid the problem of "xargs" treating single filenames that
4689 will avoid the problem of "xargs" treating single filenames that
4676 contain whitespace as multiple filenames.
4690 contain whitespace as multiple filenames.
4677
4691
4678 See :hg:`help files` for a more versatile command.
4692 See :hg:`help files` for a more versatile command.
4679
4693
4680 Returns 0 if a match is found, 1 otherwise.
4694 Returns 0 if a match is found, 1 otherwise.
4681 """
4695 """
4682 if opts.get('print0'):
4696 if opts.get('print0'):
4683 end = '\0'
4697 end = '\0'
4684 else:
4698 else:
4685 end = '\n'
4699 end = '\n'
4686 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4700 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4687
4701
4688 ret = 1
4702 ret = 1
4689 ctx = repo[rev]
4703 ctx = repo[rev]
4690 m = scmutil.match(ctx, pats, opts, default='relglob',
4704 m = scmutil.match(ctx, pats, opts, default='relglob',
4691 badfn=lambda x, y: False)
4705 badfn=lambda x, y: False)
4692
4706
4693 for abs in ctx.matches(m):
4707 for abs in ctx.matches(m):
4694 if opts.get('fullpath'):
4708 if opts.get('fullpath'):
4695 ui.write(repo.wjoin(abs), end)
4709 ui.write(repo.wjoin(abs), end)
4696 else:
4710 else:
4697 ui.write(((pats and m.rel(abs)) or abs), end)
4711 ui.write(((pats and m.rel(abs)) or abs), end)
4698 ret = 0
4712 ret = 0
4699
4713
4700 return ret
4714 return ret
4701
4715
4702 @command('^log|history',
4716 @command('^log|history',
4703 [('f', 'follow', None,
4717 [('f', 'follow', None,
4704 _('follow changeset history, or file history across copies and renames')),
4718 _('follow changeset history, or file history across copies and renames')),
4705 ('', 'follow-first', None,
4719 ('', 'follow-first', None,
4706 _('only follow the first parent of merge changesets (DEPRECATED)')),
4720 _('only follow the first parent of merge changesets (DEPRECATED)')),
4707 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4721 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4708 ('C', 'copies', None, _('show copied files')),
4722 ('C', 'copies', None, _('show copied files')),
4709 ('k', 'keyword', [],
4723 ('k', 'keyword', [],
4710 _('do case-insensitive search for a given text'), _('TEXT')),
4724 _('do case-insensitive search for a given text'), _('TEXT')),
4711 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4725 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4712 ('', 'removed', None, _('include revisions where files were removed')),
4726 ('', 'removed', None, _('include revisions where files were removed')),
4713 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4727 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4714 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4728 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4715 ('', 'only-branch', [],
4729 ('', 'only-branch', [],
4716 _('show only changesets within the given named branch (DEPRECATED)'),
4730 _('show only changesets within the given named branch (DEPRECATED)'),
4717 _('BRANCH')),
4731 _('BRANCH')),
4718 ('b', 'branch', [],
4732 ('b', 'branch', [],
4719 _('show changesets within the given named branch'), _('BRANCH')),
4733 _('show changesets within the given named branch'), _('BRANCH')),
4720 ('P', 'prune', [],
4734 ('P', 'prune', [],
4721 _('do not display revision or any of its ancestors'), _('REV')),
4735 _('do not display revision or any of its ancestors'), _('REV')),
4722 ] + logopts + walkopts,
4736 ] + logopts + walkopts,
4723 _('[OPTION]... [FILE]'),
4737 _('[OPTION]... [FILE]'),
4724 inferrepo=True)
4738 inferrepo=True)
4725 def log(ui, repo, *pats, **opts):
4739 def log(ui, repo, *pats, **opts):
4726 """show revision history of entire repository or files
4740 """show revision history of entire repository or files
4727
4741
4728 Print the revision history of the specified files or the entire
4742 Print the revision history of the specified files or the entire
4729 project.
4743 project.
4730
4744
4731 If no revision range is specified, the default is ``tip:0`` unless
4745 If no revision range is specified, the default is ``tip:0`` unless
4732 --follow is set, in which case the working directory parent is
4746 --follow is set, in which case the working directory parent is
4733 used as the starting revision.
4747 used as the starting revision.
4734
4748
4735 File history is shown without following rename or copy history of
4749 File history is shown without following rename or copy history of
4736 files. Use -f/--follow with a filename to follow history across
4750 files. Use -f/--follow with a filename to follow history across
4737 renames and copies. --follow without a filename will only show
4751 renames and copies. --follow without a filename will only show
4738 ancestors or descendants of the starting revision.
4752 ancestors or descendants of the starting revision.
4739
4753
4740 By default this command prints revision number and changeset id,
4754 By default this command prints revision number and changeset id,
4741 tags, non-trivial parents, user, date and time, and a summary for
4755 tags, non-trivial parents, user, date and time, and a summary for
4742 each commit. When the -v/--verbose switch is used, the list of
4756 each commit. When the -v/--verbose switch is used, the list of
4743 changed files and full commit message are shown.
4757 changed files and full commit message are shown.
4744
4758
4745 With --graph the revisions are shown as an ASCII art DAG with the most
4759 With --graph the revisions are shown as an ASCII art DAG with the most
4746 recent changeset at the top.
4760 recent changeset at the top.
4747 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4761 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4748 and '+' represents a fork where the changeset from the lines below is a
4762 and '+' represents a fork where the changeset from the lines below is a
4749 parent of the 'o' merge on the same line.
4763 parent of the 'o' merge on the same line.
4750
4764
4751 .. note::
4765 .. note::
4752
4766
4753 log -p/--patch may generate unexpected diff output for merge
4767 log -p/--patch may generate unexpected diff output for merge
4754 changesets, as it will only compare the merge changeset against
4768 changesets, as it will only compare the merge changeset against
4755 its first parent. Also, only files different from BOTH parents
4769 its first parent. Also, only files different from BOTH parents
4756 will appear in files:.
4770 will appear in files:.
4757
4771
4758 .. note::
4772 .. note::
4759
4773
4760 for performance reasons, log FILE may omit duplicate changes
4774 for performance reasons, log FILE may omit duplicate changes
4761 made on branches and will not show removals or mode changes. To
4775 made on branches and will not show removals or mode changes. To
4762 see all such changes, use the --removed switch.
4776 see all such changes, use the --removed switch.
4763
4777
4764 .. container:: verbose
4778 .. container:: verbose
4765
4779
4766 Some examples:
4780 Some examples:
4767
4781
4768 - changesets with full descriptions and file lists::
4782 - changesets with full descriptions and file lists::
4769
4783
4770 hg log -v
4784 hg log -v
4771
4785
4772 - changesets ancestral to the working directory::
4786 - changesets ancestral to the working directory::
4773
4787
4774 hg log -f
4788 hg log -f
4775
4789
4776 - last 10 commits on the current branch::
4790 - last 10 commits on the current branch::
4777
4791
4778 hg log -l 10 -b .
4792 hg log -l 10 -b .
4779
4793
4780 - changesets showing all modifications of a file, including removals::
4794 - changesets showing all modifications of a file, including removals::
4781
4795
4782 hg log --removed file.c
4796 hg log --removed file.c
4783
4797
4784 - all changesets that touch a directory, with diffs, excluding merges::
4798 - all changesets that touch a directory, with diffs, excluding merges::
4785
4799
4786 hg log -Mp lib/
4800 hg log -Mp lib/
4787
4801
4788 - all revision numbers that match a keyword::
4802 - all revision numbers that match a keyword::
4789
4803
4790 hg log -k bug --template "{rev}\\n"
4804 hg log -k bug --template "{rev}\\n"
4791
4805
4792 - the full hash identifier of the working directory parent::
4806 - the full hash identifier of the working directory parent::
4793
4807
4794 hg log -r . --template "{node}\\n"
4808 hg log -r . --template "{node}\\n"
4795
4809
4796 - list available log templates::
4810 - list available log templates::
4797
4811
4798 hg log -T list
4812 hg log -T list
4799
4813
4800 - check if a given changeset is included in a tagged release::
4814 - check if a given changeset is included in a tagged release::
4801
4815
4802 hg log -r "a21ccf and ancestor(1.9)"
4816 hg log -r "a21ccf and ancestor(1.9)"
4803
4817
4804 - find all changesets by some user in a date range::
4818 - find all changesets by some user in a date range::
4805
4819
4806 hg log -k alice -d "may 2008 to jul 2008"
4820 hg log -k alice -d "may 2008 to jul 2008"
4807
4821
4808 - summary of all changesets after the last tag::
4822 - summary of all changesets after the last tag::
4809
4823
4810 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4824 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4811
4825
4812 See :hg:`help dates` for a list of formats valid for -d/--date.
4826 See :hg:`help dates` for a list of formats valid for -d/--date.
4813
4827
4814 See :hg:`help revisions` and :hg:`help revsets` for more about
4828 See :hg:`help revisions` and :hg:`help revsets` for more about
4815 specifying revisions.
4829 specifying revisions.
4816
4830
4817 See :hg:`help templates` for more about pre-packaged styles and
4831 See :hg:`help templates` for more about pre-packaged styles and
4818 specifying custom templates.
4832 specifying custom templates.
4819
4833
4820 Returns 0 on success.
4834 Returns 0 on success.
4821
4835
4822 """
4836 """
4823 if opts.get('follow') and opts.get('rev'):
4837 if opts.get('follow') and opts.get('rev'):
4824 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4838 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4825 del opts['follow']
4839 del opts['follow']
4826
4840
4827 if opts.get('graph'):
4841 if opts.get('graph'):
4828 return cmdutil.graphlog(ui, repo, *pats, **opts)
4842 return cmdutil.graphlog(ui, repo, *pats, **opts)
4829
4843
4830 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4844 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4831 limit = cmdutil.loglimit(opts)
4845 limit = cmdutil.loglimit(opts)
4832 count = 0
4846 count = 0
4833
4847
4834 getrenamed = None
4848 getrenamed = None
4835 if opts.get('copies'):
4849 if opts.get('copies'):
4836 endrev = None
4850 endrev = None
4837 if opts.get('rev'):
4851 if opts.get('rev'):
4838 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4852 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4839 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4853 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4840
4854
4841 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4855 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4842 for rev in revs:
4856 for rev in revs:
4843 if count == limit:
4857 if count == limit:
4844 break
4858 break
4845 ctx = repo[rev]
4859 ctx = repo[rev]
4846 copies = None
4860 copies = None
4847 if getrenamed is not None and rev:
4861 if getrenamed is not None and rev:
4848 copies = []
4862 copies = []
4849 for fn in ctx.files():
4863 for fn in ctx.files():
4850 rename = getrenamed(fn, rev)
4864 rename = getrenamed(fn, rev)
4851 if rename:
4865 if rename:
4852 copies.append((fn, rename[0]))
4866 copies.append((fn, rename[0]))
4853 if filematcher:
4867 if filematcher:
4854 revmatchfn = filematcher(ctx.rev())
4868 revmatchfn = filematcher(ctx.rev())
4855 else:
4869 else:
4856 revmatchfn = None
4870 revmatchfn = None
4857 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4871 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4858 if displayer.flush(ctx):
4872 if displayer.flush(ctx):
4859 count += 1
4873 count += 1
4860
4874
4861 displayer.close()
4875 displayer.close()
4862
4876
4863 @command('manifest',
4877 @command('manifest',
4864 [('r', 'rev', '', _('revision to display'), _('REV')),
4878 [('r', 'rev', '', _('revision to display'), _('REV')),
4865 ('', 'all', False, _("list files from all revisions"))]
4879 ('', 'all', False, _("list files from all revisions"))]
4866 + formatteropts,
4880 + formatteropts,
4867 _('[-r REV]'))
4881 _('[-r REV]'))
4868 def manifest(ui, repo, node=None, rev=None, **opts):
4882 def manifest(ui, repo, node=None, rev=None, **opts):
4869 """output the current or given revision of the project manifest
4883 """output the current or given revision of the project manifest
4870
4884
4871 Print a list of version controlled files for the given revision.
4885 Print a list of version controlled files for the given revision.
4872 If no revision is given, the first parent of the working directory
4886 If no revision is given, the first parent of the working directory
4873 is used, or the null revision if no revision is checked out.
4887 is used, or the null revision if no revision is checked out.
4874
4888
4875 With -v, print file permissions, symlink and executable bits.
4889 With -v, print file permissions, symlink and executable bits.
4876 With --debug, print file revision hashes.
4890 With --debug, print file revision hashes.
4877
4891
4878 If option --all is specified, the list of all files from all revisions
4892 If option --all is specified, the list of all files from all revisions
4879 is printed. This includes deleted and renamed files.
4893 is printed. This includes deleted and renamed files.
4880
4894
4881 Returns 0 on success.
4895 Returns 0 on success.
4882 """
4896 """
4883
4897
4884 fm = ui.formatter('manifest', opts)
4898 fm = ui.formatter('manifest', opts)
4885
4899
4886 if opts.get('all'):
4900 if opts.get('all'):
4887 if rev or node:
4901 if rev or node:
4888 raise error.Abort(_("can't specify a revision with --all"))
4902 raise error.Abort(_("can't specify a revision with --all"))
4889
4903
4890 res = []
4904 res = []
4891 prefix = "data/"
4905 prefix = "data/"
4892 suffix = ".i"
4906 suffix = ".i"
4893 plen = len(prefix)
4907 plen = len(prefix)
4894 slen = len(suffix)
4908 slen = len(suffix)
4895 lock = repo.lock()
4909 lock = repo.lock()
4896 try:
4910 try:
4897 for fn, b, size in repo.store.datafiles():
4911 for fn, b, size in repo.store.datafiles():
4898 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4912 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4899 res.append(fn[plen:-slen])
4913 res.append(fn[plen:-slen])
4900 finally:
4914 finally:
4901 lock.release()
4915 lock.release()
4902 for f in res:
4916 for f in res:
4903 fm.startitem()
4917 fm.startitem()
4904 fm.write("path", '%s\n', f)
4918 fm.write("path", '%s\n', f)
4905 fm.end()
4919 fm.end()
4906 return
4920 return
4907
4921
4908 if rev and node:
4922 if rev and node:
4909 raise error.Abort(_("please specify just one revision"))
4923 raise error.Abort(_("please specify just one revision"))
4910
4924
4911 if not node:
4925 if not node:
4912 node = rev
4926 node = rev
4913
4927
4914 char = {'l': '@', 'x': '*', '': ''}
4928 char = {'l': '@', 'x': '*', '': ''}
4915 mode = {'l': '644', 'x': '755', '': '644'}
4929 mode = {'l': '644', 'x': '755', '': '644'}
4916 ctx = scmutil.revsingle(repo, node)
4930 ctx = scmutil.revsingle(repo, node)
4917 mf = ctx.manifest()
4931 mf = ctx.manifest()
4918 for f in ctx:
4932 for f in ctx:
4919 fm.startitem()
4933 fm.startitem()
4920 fl = ctx[f].flags()
4934 fl = ctx[f].flags()
4921 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4935 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4922 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4936 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4923 fm.write('path', '%s\n', f)
4937 fm.write('path', '%s\n', f)
4924 fm.end()
4938 fm.end()
4925
4939
4926 @command('^merge',
4940 @command('^merge',
4927 [('f', 'force', None,
4941 [('f', 'force', None,
4928 _('force a merge including outstanding changes (DEPRECATED)')),
4942 _('force a merge including outstanding changes (DEPRECATED)')),
4929 ('r', 'rev', '', _('revision to merge'), _('REV')),
4943 ('r', 'rev', '', _('revision to merge'), _('REV')),
4930 ('P', 'preview', None,
4944 ('P', 'preview', None,
4931 _('review revisions to merge (no merge is performed)'))
4945 _('review revisions to merge (no merge is performed)'))
4932 ] + mergetoolopts,
4946 ] + mergetoolopts,
4933 _('[-P] [-f] [[-r] REV]'))
4947 _('[-P] [-f] [[-r] REV]'))
4934 def merge(ui, repo, node=None, **opts):
4948 def merge(ui, repo, node=None, **opts):
4935 """merge another revision into working directory
4949 """merge another revision into working directory
4936
4950
4937 The current working directory is updated with all changes made in
4951 The current working directory is updated with all changes made in
4938 the requested revision since the last common predecessor revision.
4952 the requested revision since the last common predecessor revision.
4939
4953
4940 Files that changed between either parent are marked as changed for
4954 Files that changed between either parent are marked as changed for
4941 the next commit and a commit must be performed before any further
4955 the next commit and a commit must be performed before any further
4942 updates to the repository are allowed. The next commit will have
4956 updates to the repository are allowed. The next commit will have
4943 two parents.
4957 two parents.
4944
4958
4945 ``--tool`` can be used to specify the merge tool used for file
4959 ``--tool`` can be used to specify the merge tool used for file
4946 merges. It overrides the HGMERGE environment variable and your
4960 merges. It overrides the HGMERGE environment variable and your
4947 configuration files. See :hg:`help merge-tools` for options.
4961 configuration files. See :hg:`help merge-tools` for options.
4948
4962
4949 If no revision is specified, the working directory's parent is a
4963 If no revision is specified, the working directory's parent is a
4950 head revision, and the current branch contains exactly one other
4964 head revision, and the current branch contains exactly one other
4951 head, the other head is merged with by default. Otherwise, an
4965 head, the other head is merged with by default. Otherwise, an
4952 explicit revision with which to merge with must be provided.
4966 explicit revision with which to merge with must be provided.
4953
4967
4954 :hg:`resolve` must be used to resolve unresolved files.
4968 :hg:`resolve` must be used to resolve unresolved files.
4955
4969
4956 To undo an uncommitted merge, use :hg:`update --clean .` which
4970 To undo an uncommitted merge, use :hg:`update --clean .` which
4957 will check out a clean copy of the original merge parent, losing
4971 will check out a clean copy of the original merge parent, losing
4958 all changes.
4972 all changes.
4959
4973
4960 Returns 0 on success, 1 if there are unresolved files.
4974 Returns 0 on success, 1 if there are unresolved files.
4961 """
4975 """
4962
4976
4963 if opts.get('rev') and node:
4977 if opts.get('rev') and node:
4964 raise error.Abort(_("please specify just one revision"))
4978 raise error.Abort(_("please specify just one revision"))
4965 if not node:
4979 if not node:
4966 node = opts.get('rev')
4980 node = opts.get('rev')
4967
4981
4968 if node:
4982 if node:
4969 node = scmutil.revsingle(repo, node).node()
4983 node = scmutil.revsingle(repo, node).node()
4970
4984
4971 if not node:
4985 if not node:
4972 node = repo[destutil.destmerge(repo)].node()
4986 node = repo[destutil.destmerge(repo)].node()
4973
4987
4974 if opts.get('preview'):
4988 if opts.get('preview'):
4975 # find nodes that are ancestors of p2 but not of p1
4989 # find nodes that are ancestors of p2 but not of p1
4976 p1 = repo.lookup('.')
4990 p1 = repo.lookup('.')
4977 p2 = repo.lookup(node)
4991 p2 = repo.lookup(node)
4978 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4992 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4979
4993
4980 displayer = cmdutil.show_changeset(ui, repo, opts)
4994 displayer = cmdutil.show_changeset(ui, repo, opts)
4981 for node in nodes:
4995 for node in nodes:
4982 displayer.show(repo[node])
4996 displayer.show(repo[node])
4983 displayer.close()
4997 displayer.close()
4984 return 0
4998 return 0
4985
4999
4986 try:
5000 try:
4987 # ui.forcemerge is an internal variable, do not document
5001 # ui.forcemerge is an internal variable, do not document
4988 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
5002 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4989 return hg.merge(repo, node, force=opts.get('force'))
5003 return hg.merge(repo, node, force=opts.get('force'))
4990 finally:
5004 finally:
4991 ui.setconfig('ui', 'forcemerge', '', 'merge')
5005 ui.setconfig('ui', 'forcemerge', '', 'merge')
4992
5006
4993 @command('outgoing|out',
5007 @command('outgoing|out',
4994 [('f', 'force', None, _('run even when the destination is unrelated')),
5008 [('f', 'force', None, _('run even when the destination is unrelated')),
4995 ('r', 'rev', [],
5009 ('r', 'rev', [],
4996 _('a changeset intended to be included in the destination'), _('REV')),
5010 _('a changeset intended to be included in the destination'), _('REV')),
4997 ('n', 'newest-first', None, _('show newest record first')),
5011 ('n', 'newest-first', None, _('show newest record first')),
4998 ('B', 'bookmarks', False, _('compare bookmarks')),
5012 ('B', 'bookmarks', False, _('compare bookmarks')),
4999 ('b', 'branch', [], _('a specific branch you would like to push'),
5013 ('b', 'branch', [], _('a specific branch you would like to push'),
5000 _('BRANCH')),
5014 _('BRANCH')),
5001 ] + logopts + remoteopts + subrepoopts,
5015 ] + logopts + remoteopts + subrepoopts,
5002 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
5016 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
5003 def outgoing(ui, repo, dest=None, **opts):
5017 def outgoing(ui, repo, dest=None, **opts):
5004 """show changesets not found in the destination
5018 """show changesets not found in the destination
5005
5019
5006 Show changesets not found in the specified destination repository
5020 Show changesets not found in the specified destination repository
5007 or the default push location. These are the changesets that would
5021 or the default push location. These are the changesets that would
5008 be pushed if a push was requested.
5022 be pushed if a push was requested.
5009
5023
5010 See pull for details of valid destination formats.
5024 See pull for details of valid destination formats.
5011
5025
5012 .. container:: verbose
5026 .. container:: verbose
5013
5027
5014 With -B/--bookmarks, the result of bookmark comparison between
5028 With -B/--bookmarks, the result of bookmark comparison between
5015 local and remote repositories is displayed. With -v/--verbose,
5029 local and remote repositories is displayed. With -v/--verbose,
5016 status is also displayed for each bookmark like below::
5030 status is also displayed for each bookmark like below::
5017
5031
5018 BM1 01234567890a added
5032 BM1 01234567890a added
5019 BM2 deleted
5033 BM2 deleted
5020 BM3 234567890abc advanced
5034 BM3 234567890abc advanced
5021 BM4 34567890abcd diverged
5035 BM4 34567890abcd diverged
5022 BM5 4567890abcde changed
5036 BM5 4567890abcde changed
5023
5037
5024 The action taken when pushing depends on the
5038 The action taken when pushing depends on the
5025 status of each bookmark:
5039 status of each bookmark:
5026
5040
5027 :``added``: push with ``-B`` will create it
5041 :``added``: push with ``-B`` will create it
5028 :``deleted``: push with ``-B`` will delete it
5042 :``deleted``: push with ``-B`` will delete it
5029 :``advanced``: push will update it
5043 :``advanced``: push will update it
5030 :``diverged``: push with ``-B`` will update it
5044 :``diverged``: push with ``-B`` will update it
5031 :``changed``: push with ``-B`` will update it
5045 :``changed``: push with ``-B`` will update it
5032
5046
5033 From the point of view of pushing behavior, bookmarks
5047 From the point of view of pushing behavior, bookmarks
5034 existing only in the remote repository are treated as
5048 existing only in the remote repository are treated as
5035 ``deleted``, even if it is in fact added remotely.
5049 ``deleted``, even if it is in fact added remotely.
5036
5050
5037 Returns 0 if there are outgoing changes, 1 otherwise.
5051 Returns 0 if there are outgoing changes, 1 otherwise.
5038 """
5052 """
5039 if opts.get('graph'):
5053 if opts.get('graph'):
5040 cmdutil.checkunsupportedgraphflags([], opts)
5054 cmdutil.checkunsupportedgraphflags([], opts)
5041 o, other = hg._outgoing(ui, repo, dest, opts)
5055 o, other = hg._outgoing(ui, repo, dest, opts)
5042 if not o:
5056 if not o:
5043 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5057 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5044 return
5058 return
5045
5059
5046 revdag = cmdutil.graphrevs(repo, o, opts)
5060 revdag = cmdutil.graphrevs(repo, o, opts)
5047 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
5061 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
5048 showparents = [ctx.node() for ctx in repo[None].parents()]
5062 showparents = [ctx.node() for ctx in repo[None].parents()]
5049 cmdutil.displaygraph(ui, revdag, displayer, showparents,
5063 cmdutil.displaygraph(ui, revdag, displayer, showparents,
5050 graphmod.asciiedges)
5064 graphmod.asciiedges)
5051 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5065 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5052 return 0
5066 return 0
5053
5067
5054 if opts.get('bookmarks'):
5068 if opts.get('bookmarks'):
5055 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5069 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5056 dest, branches = hg.parseurl(dest, opts.get('branch'))
5070 dest, branches = hg.parseurl(dest, opts.get('branch'))
5057 other = hg.peer(repo, opts, dest)
5071 other = hg.peer(repo, opts, dest)
5058 if 'bookmarks' not in other.listkeys('namespaces'):
5072 if 'bookmarks' not in other.listkeys('namespaces'):
5059 ui.warn(_("remote doesn't support bookmarks\n"))
5073 ui.warn(_("remote doesn't support bookmarks\n"))
5060 return 0
5074 return 0
5061 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
5075 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
5062 return bookmarks.outgoing(ui, repo, other)
5076 return bookmarks.outgoing(ui, repo, other)
5063
5077
5064 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
5078 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
5065 try:
5079 try:
5066 return hg.outgoing(ui, repo, dest, opts)
5080 return hg.outgoing(ui, repo, dest, opts)
5067 finally:
5081 finally:
5068 del repo._subtoppath
5082 del repo._subtoppath
5069
5083
5070 @command('parents',
5084 @command('parents',
5071 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
5085 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
5072 ] + templateopts,
5086 ] + templateopts,
5073 _('[-r REV] [FILE]'),
5087 _('[-r REV] [FILE]'),
5074 inferrepo=True)
5088 inferrepo=True)
5075 def parents(ui, repo, file_=None, **opts):
5089 def parents(ui, repo, file_=None, **opts):
5076 """show the parents of the working directory or revision (DEPRECATED)
5090 """show the parents of the working directory or revision (DEPRECATED)
5077
5091
5078 Print the working directory's parent revisions. If a revision is
5092 Print the working directory's parent revisions. If a revision is
5079 given via -r/--rev, the parent of that revision will be printed.
5093 given via -r/--rev, the parent of that revision will be printed.
5080 If a file argument is given, the revision in which the file was
5094 If a file argument is given, the revision in which the file was
5081 last changed (before the working directory revision or the
5095 last changed (before the working directory revision or the
5082 argument to --rev if given) is printed.
5096 argument to --rev if given) is printed.
5083
5097
5084 See :hg:`summary` and :hg:`help revsets` for related information.
5098 See :hg:`summary` and :hg:`help revsets` for related information.
5085
5099
5086 Returns 0 on success.
5100 Returns 0 on success.
5087 """
5101 """
5088
5102
5089 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5103 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5090
5104
5091 if file_:
5105 if file_:
5092 m = scmutil.match(ctx, (file_,), opts)
5106 m = scmutil.match(ctx, (file_,), opts)
5093 if m.anypats() or len(m.files()) != 1:
5107 if m.anypats() or len(m.files()) != 1:
5094 raise error.Abort(_('can only specify an explicit filename'))
5108 raise error.Abort(_('can only specify an explicit filename'))
5095 file_ = m.files()[0]
5109 file_ = m.files()[0]
5096 filenodes = []
5110 filenodes = []
5097 for cp in ctx.parents():
5111 for cp in ctx.parents():
5098 if not cp:
5112 if not cp:
5099 continue
5113 continue
5100 try:
5114 try:
5101 filenodes.append(cp.filenode(file_))
5115 filenodes.append(cp.filenode(file_))
5102 except error.LookupError:
5116 except error.LookupError:
5103 pass
5117 pass
5104 if not filenodes:
5118 if not filenodes:
5105 raise error.Abort(_("'%s' not found in manifest!") % file_)
5119 raise error.Abort(_("'%s' not found in manifest!") % file_)
5106 p = []
5120 p = []
5107 for fn in filenodes:
5121 for fn in filenodes:
5108 fctx = repo.filectx(file_, fileid=fn)
5122 fctx = repo.filectx(file_, fileid=fn)
5109 p.append(fctx.node())
5123 p.append(fctx.node())
5110 else:
5124 else:
5111 p = [cp.node() for cp in ctx.parents()]
5125 p = [cp.node() for cp in ctx.parents()]
5112
5126
5113 displayer = cmdutil.show_changeset(ui, repo, opts)
5127 displayer = cmdutil.show_changeset(ui, repo, opts)
5114 for n in p:
5128 for n in p:
5115 if n != nullid:
5129 if n != nullid:
5116 displayer.show(repo[n])
5130 displayer.show(repo[n])
5117 displayer.close()
5131 displayer.close()
5118
5132
5119 @command('paths', [], _('[NAME]'), optionalrepo=True)
5133 @command('paths', [], _('[NAME]'), optionalrepo=True)
5120 def paths(ui, repo, search=None):
5134 def paths(ui, repo, search=None):
5121 """show aliases for remote repositories
5135 """show aliases for remote repositories
5122
5136
5123 Show definition of symbolic path name NAME. If no name is given,
5137 Show definition of symbolic path name NAME. If no name is given,
5124 show definition of all available names.
5138 show definition of all available names.
5125
5139
5126 Option -q/--quiet suppresses all output when searching for NAME
5140 Option -q/--quiet suppresses all output when searching for NAME
5127 and shows only the path names when listing all definitions.
5141 and shows only the path names when listing all definitions.
5128
5142
5129 Path names are defined in the [paths] section of your
5143 Path names are defined in the [paths] section of your
5130 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5144 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5131 repository, ``.hg/hgrc`` is used, too.
5145 repository, ``.hg/hgrc`` is used, too.
5132
5146
5133 The path names ``default`` and ``default-push`` have a special
5147 The path names ``default`` and ``default-push`` have a special
5134 meaning. When performing a push or pull operation, they are used
5148 meaning. When performing a push or pull operation, they are used
5135 as fallbacks if no location is specified on the command-line.
5149 as fallbacks if no location is specified on the command-line.
5136 When ``default-push`` is set, it will be used for push and
5150 When ``default-push`` is set, it will be used for push and
5137 ``default`` will be used for pull; otherwise ``default`` is used
5151 ``default`` will be used for pull; otherwise ``default`` is used
5138 as the fallback for both. When cloning a repository, the clone
5152 as the fallback for both. When cloning a repository, the clone
5139 source is written as ``default`` in ``.hg/hgrc``. Note that
5153 source is written as ``default`` in ``.hg/hgrc``. Note that
5140 ``default`` and ``default-push`` apply to all inbound (e.g.
5154 ``default`` and ``default-push`` apply to all inbound (e.g.
5141 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5155 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5142 :hg:`bundle`) operations.
5156 :hg:`bundle`) operations.
5143
5157
5144 See :hg:`help urls` for more information.
5158 See :hg:`help urls` for more information.
5145
5159
5146 Returns 0 on success.
5160 Returns 0 on success.
5147 """
5161 """
5148 if search:
5162 if search:
5149 for name, path in sorted(ui.paths.iteritems()):
5163 for name, path in sorted(ui.paths.iteritems()):
5150 if name == search:
5164 if name == search:
5151 ui.status("%s\n" % util.hidepassword(path.loc))
5165 ui.status("%s\n" % util.hidepassword(path.loc))
5152 return
5166 return
5153 if not ui.quiet:
5167 if not ui.quiet:
5154 ui.warn(_("not found!\n"))
5168 ui.warn(_("not found!\n"))
5155 return 1
5169 return 1
5156 else:
5170 else:
5157 for name, path in sorted(ui.paths.iteritems()):
5171 for name, path in sorted(ui.paths.iteritems()):
5158 if ui.quiet:
5172 if ui.quiet:
5159 ui.write("%s\n" % name)
5173 ui.write("%s\n" % name)
5160 else:
5174 else:
5161 ui.write("%s = %s\n" % (name,
5175 ui.write("%s = %s\n" % (name,
5162 util.hidepassword(path.loc)))
5176 util.hidepassword(path.loc)))
5163
5177
5164 @command('phase',
5178 @command('phase',
5165 [('p', 'public', False, _('set changeset phase to public')),
5179 [('p', 'public', False, _('set changeset phase to public')),
5166 ('d', 'draft', False, _('set changeset phase to draft')),
5180 ('d', 'draft', False, _('set changeset phase to draft')),
5167 ('s', 'secret', False, _('set changeset phase to secret')),
5181 ('s', 'secret', False, _('set changeset phase to secret')),
5168 ('f', 'force', False, _('allow to move boundary backward')),
5182 ('f', 'force', False, _('allow to move boundary backward')),
5169 ('r', 'rev', [], _('target revision'), _('REV')),
5183 ('r', 'rev', [], _('target revision'), _('REV')),
5170 ],
5184 ],
5171 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5185 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5172 def phase(ui, repo, *revs, **opts):
5186 def phase(ui, repo, *revs, **opts):
5173 """set or show the current phase name
5187 """set or show the current phase name
5174
5188
5175 With no argument, show the phase name of the current revision(s).
5189 With no argument, show the phase name of the current revision(s).
5176
5190
5177 With one of -p/--public, -d/--draft or -s/--secret, change the
5191 With one of -p/--public, -d/--draft or -s/--secret, change the
5178 phase value of the specified revisions.
5192 phase value of the specified revisions.
5179
5193
5180 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5194 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5181 lower phase to an higher phase. Phases are ordered as follows::
5195 lower phase to an higher phase. Phases are ordered as follows::
5182
5196
5183 public < draft < secret
5197 public < draft < secret
5184
5198
5185 Returns 0 on success, 1 if some phases could not be changed.
5199 Returns 0 on success, 1 if some phases could not be changed.
5186
5200
5187 (For more information about the phases concept, see :hg:`help phases`.)
5201 (For more information about the phases concept, see :hg:`help phases`.)
5188 """
5202 """
5189 # search for a unique phase argument
5203 # search for a unique phase argument
5190 targetphase = None
5204 targetphase = None
5191 for idx, name in enumerate(phases.phasenames):
5205 for idx, name in enumerate(phases.phasenames):
5192 if opts[name]:
5206 if opts[name]:
5193 if targetphase is not None:
5207 if targetphase is not None:
5194 raise error.Abort(_('only one phase can be specified'))
5208 raise error.Abort(_('only one phase can be specified'))
5195 targetphase = idx
5209 targetphase = idx
5196
5210
5197 # look for specified revision
5211 # look for specified revision
5198 revs = list(revs)
5212 revs = list(revs)
5199 revs.extend(opts['rev'])
5213 revs.extend(opts['rev'])
5200 if not revs:
5214 if not revs:
5201 # display both parents as the second parent phase can influence
5215 # display both parents as the second parent phase can influence
5202 # the phase of a merge commit
5216 # the phase of a merge commit
5203 revs = [c.rev() for c in repo[None].parents()]
5217 revs = [c.rev() for c in repo[None].parents()]
5204
5218
5205 revs = scmutil.revrange(repo, revs)
5219 revs = scmutil.revrange(repo, revs)
5206
5220
5207 lock = None
5221 lock = None
5208 ret = 0
5222 ret = 0
5209 if targetphase is None:
5223 if targetphase is None:
5210 # display
5224 # display
5211 for r in revs:
5225 for r in revs:
5212 ctx = repo[r]
5226 ctx = repo[r]
5213 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5227 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5214 else:
5228 else:
5215 tr = None
5229 tr = None
5216 lock = repo.lock()
5230 lock = repo.lock()
5217 try:
5231 try:
5218 tr = repo.transaction("phase")
5232 tr = repo.transaction("phase")
5219 # set phase
5233 # set phase
5220 if not revs:
5234 if not revs:
5221 raise error.Abort(_('empty revision set'))
5235 raise error.Abort(_('empty revision set'))
5222 nodes = [repo[r].node() for r in revs]
5236 nodes = [repo[r].node() for r in revs]
5223 # moving revision from public to draft may hide them
5237 # moving revision from public to draft may hide them
5224 # We have to check result on an unfiltered repository
5238 # We have to check result on an unfiltered repository
5225 unfi = repo.unfiltered()
5239 unfi = repo.unfiltered()
5226 getphase = unfi._phasecache.phase
5240 getphase = unfi._phasecache.phase
5227 olddata = [getphase(unfi, r) for r in unfi]
5241 olddata = [getphase(unfi, r) for r in unfi]
5228 phases.advanceboundary(repo, tr, targetphase, nodes)
5242 phases.advanceboundary(repo, tr, targetphase, nodes)
5229 if opts['force']:
5243 if opts['force']:
5230 phases.retractboundary(repo, tr, targetphase, nodes)
5244 phases.retractboundary(repo, tr, targetphase, nodes)
5231 tr.close()
5245 tr.close()
5232 finally:
5246 finally:
5233 if tr is not None:
5247 if tr is not None:
5234 tr.release()
5248 tr.release()
5235 lock.release()
5249 lock.release()
5236 getphase = unfi._phasecache.phase
5250 getphase = unfi._phasecache.phase
5237 newdata = [getphase(unfi, r) for r in unfi]
5251 newdata = [getphase(unfi, r) for r in unfi]
5238 changes = sum(newdata[r] != olddata[r] for r in unfi)
5252 changes = sum(newdata[r] != olddata[r] for r in unfi)
5239 cl = unfi.changelog
5253 cl = unfi.changelog
5240 rejected = [n for n in nodes
5254 rejected = [n for n in nodes
5241 if newdata[cl.rev(n)] < targetphase]
5255 if newdata[cl.rev(n)] < targetphase]
5242 if rejected:
5256 if rejected:
5243 ui.warn(_('cannot move %i changesets to a higher '
5257 ui.warn(_('cannot move %i changesets to a higher '
5244 'phase, use --force\n') % len(rejected))
5258 'phase, use --force\n') % len(rejected))
5245 ret = 1
5259 ret = 1
5246 if changes:
5260 if changes:
5247 msg = _('phase changed for %i changesets\n') % changes
5261 msg = _('phase changed for %i changesets\n') % changes
5248 if ret:
5262 if ret:
5249 ui.status(msg)
5263 ui.status(msg)
5250 else:
5264 else:
5251 ui.note(msg)
5265 ui.note(msg)
5252 else:
5266 else:
5253 ui.warn(_('no phases changed\n'))
5267 ui.warn(_('no phases changed\n'))
5254 return ret
5268 return ret
5255
5269
5256 def postincoming(ui, repo, modheads, optupdate, checkout):
5270 def postincoming(ui, repo, modheads, optupdate, checkout):
5257 if modheads == 0:
5271 if modheads == 0:
5258 return
5272 return
5259 if optupdate:
5273 if optupdate:
5260 try:
5274 try:
5261 brev = checkout
5275 brev = checkout
5262 movemarkfrom = None
5276 movemarkfrom = None
5263 if not checkout:
5277 if not checkout:
5264 updata = destutil.destupdate(repo)
5278 updata = destutil.destupdate(repo)
5265 checkout, movemarkfrom, brev = updata
5279 checkout, movemarkfrom, brev = updata
5266 ret = hg.update(repo, checkout)
5280 ret = hg.update(repo, checkout)
5267 except error.UpdateAbort as inst:
5281 except error.UpdateAbort as inst:
5268 msg = _("not updating: %s") % str(inst)
5282 msg = _("not updating: %s") % str(inst)
5269 hint = inst.hint
5283 hint = inst.hint
5270 raise error.UpdateAbort(msg, hint=hint)
5284 raise error.UpdateAbort(msg, hint=hint)
5271 if not ret and not checkout:
5285 if not ret and not checkout:
5272 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5286 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5273 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5287 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5274 return ret
5288 return ret
5275 if modheads > 1:
5289 if modheads > 1:
5276 currentbranchheads = len(repo.branchheads())
5290 currentbranchheads = len(repo.branchheads())
5277 if currentbranchheads == modheads:
5291 if currentbranchheads == modheads:
5278 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5292 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5279 elif currentbranchheads > 1:
5293 elif currentbranchheads > 1:
5280 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5294 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5281 "merge)\n"))
5295 "merge)\n"))
5282 else:
5296 else:
5283 ui.status(_("(run 'hg heads' to see heads)\n"))
5297 ui.status(_("(run 'hg heads' to see heads)\n"))
5284 else:
5298 else:
5285 ui.status(_("(run 'hg update' to get a working copy)\n"))
5299 ui.status(_("(run 'hg update' to get a working copy)\n"))
5286
5300
5287 @command('^pull',
5301 @command('^pull',
5288 [('u', 'update', None,
5302 [('u', 'update', None,
5289 _('update to new branch head if changesets were pulled')),
5303 _('update to new branch head if changesets were pulled')),
5290 ('f', 'force', None, _('run even when remote repository is unrelated')),
5304 ('f', 'force', None, _('run even when remote repository is unrelated')),
5291 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5305 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5292 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5306 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5293 ('b', 'branch', [], _('a specific branch you would like to pull'),
5307 ('b', 'branch', [], _('a specific branch you would like to pull'),
5294 _('BRANCH')),
5308 _('BRANCH')),
5295 ] + remoteopts,
5309 ] + remoteopts,
5296 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5310 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5297 def pull(ui, repo, source="default", **opts):
5311 def pull(ui, repo, source="default", **opts):
5298 """pull changes from the specified source
5312 """pull changes from the specified source
5299
5313
5300 Pull changes from a remote repository to a local one.
5314 Pull changes from a remote repository to a local one.
5301
5315
5302 This finds all changes from the repository at the specified path
5316 This finds all changes from the repository at the specified path
5303 or URL and adds them to a local repository (the current one unless
5317 or URL and adds them to a local repository (the current one unless
5304 -R is specified). By default, this does not update the copy of the
5318 -R is specified). By default, this does not update the copy of the
5305 project in the working directory.
5319 project in the working directory.
5306
5320
5307 Use :hg:`incoming` if you want to see what would have been added
5321 Use :hg:`incoming` if you want to see what would have been added
5308 by a pull at the time you issued this command. If you then decide
5322 by a pull at the time you issued this command. If you then decide
5309 to add those changes to the repository, you should use :hg:`pull
5323 to add those changes to the repository, you should use :hg:`pull
5310 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5324 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5311
5325
5312 If SOURCE is omitted, the 'default' path will be used.
5326 If SOURCE is omitted, the 'default' path will be used.
5313 See :hg:`help urls` for more information.
5327 See :hg:`help urls` for more information.
5314
5328
5315 Returns 0 on success, 1 if an update had unresolved files.
5329 Returns 0 on success, 1 if an update had unresolved files.
5316 """
5330 """
5317 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5331 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5318 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5332 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5319 other = hg.peer(repo, opts, source)
5333 other = hg.peer(repo, opts, source)
5320 try:
5334 try:
5321 revs, checkout = hg.addbranchrevs(repo, other, branches,
5335 revs, checkout = hg.addbranchrevs(repo, other, branches,
5322 opts.get('rev'))
5336 opts.get('rev'))
5323
5337
5324
5338
5325 pullopargs = {}
5339 pullopargs = {}
5326 if opts.get('bookmark'):
5340 if opts.get('bookmark'):
5327 if not revs:
5341 if not revs:
5328 revs = []
5342 revs = []
5329 # The list of bookmark used here is not the one used to actually
5343 # The list of bookmark used here is not the one used to actually
5330 # update the bookmark name. This can result in the revision pulled
5344 # update the bookmark name. This can result in the revision pulled
5331 # not ending up with the name of the bookmark because of a race
5345 # not ending up with the name of the bookmark because of a race
5332 # condition on the server. (See issue 4689 for details)
5346 # condition on the server. (See issue 4689 for details)
5333 remotebookmarks = other.listkeys('bookmarks')
5347 remotebookmarks = other.listkeys('bookmarks')
5334 pullopargs['remotebookmarks'] = remotebookmarks
5348 pullopargs['remotebookmarks'] = remotebookmarks
5335 for b in opts['bookmark']:
5349 for b in opts['bookmark']:
5336 if b not in remotebookmarks:
5350 if b not in remotebookmarks:
5337 raise error.Abort(_('remote bookmark %s not found!') % b)
5351 raise error.Abort(_('remote bookmark %s not found!') % b)
5338 revs.append(remotebookmarks[b])
5352 revs.append(remotebookmarks[b])
5339
5353
5340 if revs:
5354 if revs:
5341 try:
5355 try:
5342 # When 'rev' is a bookmark name, we cannot guarantee that it
5356 # When 'rev' is a bookmark name, we cannot guarantee that it
5343 # will be updated with that name because of a race condition
5357 # will be updated with that name because of a race condition
5344 # server side. (See issue 4689 for details)
5358 # server side. (See issue 4689 for details)
5345 oldrevs = revs
5359 oldrevs = revs
5346 revs = [] # actually, nodes
5360 revs = [] # actually, nodes
5347 for r in oldrevs:
5361 for r in oldrevs:
5348 node = other.lookup(r)
5362 node = other.lookup(r)
5349 revs.append(node)
5363 revs.append(node)
5350 if r == checkout:
5364 if r == checkout:
5351 checkout = node
5365 checkout = node
5352 except error.CapabilityError:
5366 except error.CapabilityError:
5353 err = _("other repository doesn't support revision lookup, "
5367 err = _("other repository doesn't support revision lookup, "
5354 "so a rev cannot be specified.")
5368 "so a rev cannot be specified.")
5355 raise error.Abort(err)
5369 raise error.Abort(err)
5356
5370
5357 pullopargs.update(opts.get('opargs', {}))
5371 pullopargs.update(opts.get('opargs', {}))
5358 modheads = exchange.pull(repo, other, heads=revs,
5372 modheads = exchange.pull(repo, other, heads=revs,
5359 force=opts.get('force'),
5373 force=opts.get('force'),
5360 bookmarks=opts.get('bookmark', ()),
5374 bookmarks=opts.get('bookmark', ()),
5361 opargs=pullopargs).cgresult
5375 opargs=pullopargs).cgresult
5362 if checkout:
5376 if checkout:
5363 checkout = str(repo.changelog.rev(checkout))
5377 checkout = str(repo.changelog.rev(checkout))
5364 repo._subtoppath = source
5378 repo._subtoppath = source
5365 try:
5379 try:
5366 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5380 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5367
5381
5368 finally:
5382 finally:
5369 del repo._subtoppath
5383 del repo._subtoppath
5370
5384
5371 finally:
5385 finally:
5372 other.close()
5386 other.close()
5373 return ret
5387 return ret
5374
5388
5375 @command('^push',
5389 @command('^push',
5376 [('f', 'force', None, _('force push')),
5390 [('f', 'force', None, _('force push')),
5377 ('r', 'rev', [],
5391 ('r', 'rev', [],
5378 _('a changeset intended to be included in the destination'),
5392 _('a changeset intended to be included in the destination'),
5379 _('REV')),
5393 _('REV')),
5380 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5394 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5381 ('b', 'branch', [],
5395 ('b', 'branch', [],
5382 _('a specific branch you would like to push'), _('BRANCH')),
5396 _('a specific branch you would like to push'), _('BRANCH')),
5383 ('', 'new-branch', False, _('allow pushing a new branch')),
5397 ('', 'new-branch', False, _('allow pushing a new branch')),
5384 ] + remoteopts,
5398 ] + remoteopts,
5385 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5399 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5386 def push(ui, repo, dest=None, **opts):
5400 def push(ui, repo, dest=None, **opts):
5387 """push changes to the specified destination
5401 """push changes to the specified destination
5388
5402
5389 Push changesets from the local repository to the specified
5403 Push changesets from the local repository to the specified
5390 destination.
5404 destination.
5391
5405
5392 This operation is symmetrical to pull: it is identical to a pull
5406 This operation is symmetrical to pull: it is identical to a pull
5393 in the destination repository from the current one.
5407 in the destination repository from the current one.
5394
5408
5395 By default, push will not allow creation of new heads at the
5409 By default, push will not allow creation of new heads at the
5396 destination, since multiple heads would make it unclear which head
5410 destination, since multiple heads would make it unclear which head
5397 to use. In this situation, it is recommended to pull and merge
5411 to use. In this situation, it is recommended to pull and merge
5398 before pushing.
5412 before pushing.
5399
5413
5400 Use --new-branch if you want to allow push to create a new named
5414 Use --new-branch if you want to allow push to create a new named
5401 branch that is not present at the destination. This allows you to
5415 branch that is not present at the destination. This allows you to
5402 only create a new branch without forcing other changes.
5416 only create a new branch without forcing other changes.
5403
5417
5404 .. note::
5418 .. note::
5405
5419
5406 Extra care should be taken with the -f/--force option,
5420 Extra care should be taken with the -f/--force option,
5407 which will push all new heads on all branches, an action which will
5421 which will push all new heads on all branches, an action which will
5408 almost always cause confusion for collaborators.
5422 almost always cause confusion for collaborators.
5409
5423
5410 If -r/--rev is used, the specified revision and all its ancestors
5424 If -r/--rev is used, the specified revision and all its ancestors
5411 will be pushed to the remote repository.
5425 will be pushed to the remote repository.
5412
5426
5413 If -B/--bookmark is used, the specified bookmarked revision, its
5427 If -B/--bookmark is used, the specified bookmarked revision, its
5414 ancestors, and the bookmark will be pushed to the remote
5428 ancestors, and the bookmark will be pushed to the remote
5415 repository.
5429 repository.
5416
5430
5417 Please see :hg:`help urls` for important details about ``ssh://``
5431 Please see :hg:`help urls` for important details about ``ssh://``
5418 URLs. If DESTINATION is omitted, a default path will be used.
5432 URLs. If DESTINATION is omitted, a default path will be used.
5419
5433
5420 Returns 0 if push was successful, 1 if nothing to push.
5434 Returns 0 if push was successful, 1 if nothing to push.
5421 """
5435 """
5422
5436
5423 if opts.get('bookmark'):
5437 if opts.get('bookmark'):
5424 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5438 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5425 for b in opts['bookmark']:
5439 for b in opts['bookmark']:
5426 # translate -B options to -r so changesets get pushed
5440 # translate -B options to -r so changesets get pushed
5427 if b in repo._bookmarks:
5441 if b in repo._bookmarks:
5428 opts.setdefault('rev', []).append(b)
5442 opts.setdefault('rev', []).append(b)
5429 else:
5443 else:
5430 # if we try to push a deleted bookmark, translate it to null
5444 # if we try to push a deleted bookmark, translate it to null
5431 # this lets simultaneous -r, -b options continue working
5445 # this lets simultaneous -r, -b options continue working
5432 opts.setdefault('rev', []).append("null")
5446 opts.setdefault('rev', []).append("null")
5433
5447
5434 path = ui.paths.getpath(dest, default='default')
5448 path = ui.paths.getpath(dest, default='default')
5435 if not path:
5449 if not path:
5436 raise error.Abort(_('default repository not configured!'),
5450 raise error.Abort(_('default repository not configured!'),
5437 hint=_('see the "path" section in "hg help config"'))
5451 hint=_('see the "path" section in "hg help config"'))
5438 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5452 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5439 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5453 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5440 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5454 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5441 other = hg.peer(repo, opts, dest)
5455 other = hg.peer(repo, opts, dest)
5442
5456
5443 if revs:
5457 if revs:
5444 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5458 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5445 if not revs:
5459 if not revs:
5446 raise error.Abort(_("specified revisions evaluate to an empty set"),
5460 raise error.Abort(_("specified revisions evaluate to an empty set"),
5447 hint=_("use different revision arguments"))
5461 hint=_("use different revision arguments"))
5448
5462
5449 repo._subtoppath = dest
5463 repo._subtoppath = dest
5450 try:
5464 try:
5451 # push subrepos depth-first for coherent ordering
5465 # push subrepos depth-first for coherent ordering
5452 c = repo['']
5466 c = repo['']
5453 subs = c.substate # only repos that are committed
5467 subs = c.substate # only repos that are committed
5454 for s in sorted(subs):
5468 for s in sorted(subs):
5455 result = c.sub(s).push(opts)
5469 result = c.sub(s).push(opts)
5456 if result == 0:
5470 if result == 0:
5457 return not result
5471 return not result
5458 finally:
5472 finally:
5459 del repo._subtoppath
5473 del repo._subtoppath
5460 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5474 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5461 newbranch=opts.get('new_branch'),
5475 newbranch=opts.get('new_branch'),
5462 bookmarks=opts.get('bookmark', ()),
5476 bookmarks=opts.get('bookmark', ()),
5463 opargs=opts.get('opargs'))
5477 opargs=opts.get('opargs'))
5464
5478
5465 result = not pushop.cgresult
5479 result = not pushop.cgresult
5466
5480
5467 if pushop.bkresult is not None:
5481 if pushop.bkresult is not None:
5468 if pushop.bkresult == 2:
5482 if pushop.bkresult == 2:
5469 result = 2
5483 result = 2
5470 elif not result and pushop.bkresult:
5484 elif not result and pushop.bkresult:
5471 result = 2
5485 result = 2
5472
5486
5473 return result
5487 return result
5474
5488
5475 @command('recover', [])
5489 @command('recover', [])
5476 def recover(ui, repo):
5490 def recover(ui, repo):
5477 """roll back an interrupted transaction
5491 """roll back an interrupted transaction
5478
5492
5479 Recover from an interrupted commit or pull.
5493 Recover from an interrupted commit or pull.
5480
5494
5481 This command tries to fix the repository status after an
5495 This command tries to fix the repository status after an
5482 interrupted operation. It should only be necessary when Mercurial
5496 interrupted operation. It should only be necessary when Mercurial
5483 suggests it.
5497 suggests it.
5484
5498
5485 Returns 0 if successful, 1 if nothing to recover or verify fails.
5499 Returns 0 if successful, 1 if nothing to recover or verify fails.
5486 """
5500 """
5487 if repo.recover():
5501 if repo.recover():
5488 return hg.verify(repo)
5502 return hg.verify(repo)
5489 return 1
5503 return 1
5490
5504
5491 @command('^remove|rm',
5505 @command('^remove|rm',
5492 [('A', 'after', None, _('record delete for missing files')),
5506 [('A', 'after', None, _('record delete for missing files')),
5493 ('f', 'force', None,
5507 ('f', 'force', None,
5494 _('remove (and delete) file even if added or modified')),
5508 _('remove (and delete) file even if added or modified')),
5495 ] + subrepoopts + walkopts,
5509 ] + subrepoopts + walkopts,
5496 _('[OPTION]... FILE...'),
5510 _('[OPTION]... FILE...'),
5497 inferrepo=True)
5511 inferrepo=True)
5498 def remove(ui, repo, *pats, **opts):
5512 def remove(ui, repo, *pats, **opts):
5499 """remove the specified files on the next commit
5513 """remove the specified files on the next commit
5500
5514
5501 Schedule the indicated files for removal from the current branch.
5515 Schedule the indicated files for removal from the current branch.
5502
5516
5503 This command schedules the files to be removed at the next commit.
5517 This command schedules the files to be removed at the next commit.
5504 To undo a remove before that, see :hg:`revert`. To undo added
5518 To undo a remove before that, see :hg:`revert`. To undo added
5505 files, see :hg:`forget`.
5519 files, see :hg:`forget`.
5506
5520
5507 .. container:: verbose
5521 .. container:: verbose
5508
5522
5509 -A/--after can be used to remove only files that have already
5523 -A/--after can be used to remove only files that have already
5510 been deleted, -f/--force can be used to force deletion, and -Af
5524 been deleted, -f/--force can be used to force deletion, and -Af
5511 can be used to remove files from the next revision without
5525 can be used to remove files from the next revision without
5512 deleting them from the working directory.
5526 deleting them from the working directory.
5513
5527
5514 The following table details the behavior of remove for different
5528 The following table details the behavior of remove for different
5515 file states (columns) and option combinations (rows). The file
5529 file states (columns) and option combinations (rows). The file
5516 states are Added [A], Clean [C], Modified [M] and Missing [!]
5530 states are Added [A], Clean [C], Modified [M] and Missing [!]
5517 (as reported by :hg:`status`). The actions are Warn, Remove
5531 (as reported by :hg:`status`). The actions are Warn, Remove
5518 (from branch) and Delete (from disk):
5532 (from branch) and Delete (from disk):
5519
5533
5520 ========= == == == ==
5534 ========= == == == ==
5521 opt/state A C M !
5535 opt/state A C M !
5522 ========= == == == ==
5536 ========= == == == ==
5523 none W RD W R
5537 none W RD W R
5524 -f R RD RD R
5538 -f R RD RD R
5525 -A W W W R
5539 -A W W W R
5526 -Af R R R R
5540 -Af R R R R
5527 ========= == == == ==
5541 ========= == == == ==
5528
5542
5529 Note that remove never deletes files in Added [A] state from the
5543 Note that remove never deletes files in Added [A] state from the
5530 working directory, not even if option --force is specified.
5544 working directory, not even if option --force is specified.
5531
5545
5532 Returns 0 on success, 1 if any warnings encountered.
5546 Returns 0 on success, 1 if any warnings encountered.
5533 """
5547 """
5534
5548
5535 after, force = opts.get('after'), opts.get('force')
5549 after, force = opts.get('after'), opts.get('force')
5536 if not pats and not after:
5550 if not pats and not after:
5537 raise error.Abort(_('no files specified'))
5551 raise error.Abort(_('no files specified'))
5538
5552
5539 m = scmutil.match(repo[None], pats, opts)
5553 m = scmutil.match(repo[None], pats, opts)
5540 subrepos = opts.get('subrepos')
5554 subrepos = opts.get('subrepos')
5541 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5555 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5542
5556
5543 @command('rename|move|mv',
5557 @command('rename|move|mv',
5544 [('A', 'after', None, _('record a rename that has already occurred')),
5558 [('A', 'after', None, _('record a rename that has already occurred')),
5545 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5559 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5546 ] + walkopts + dryrunopts,
5560 ] + walkopts + dryrunopts,
5547 _('[OPTION]... SOURCE... DEST'))
5561 _('[OPTION]... SOURCE... DEST'))
5548 def rename(ui, repo, *pats, **opts):
5562 def rename(ui, repo, *pats, **opts):
5549 """rename files; equivalent of copy + remove
5563 """rename files; equivalent of copy + remove
5550
5564
5551 Mark dest as copies of sources; mark sources for deletion. If dest
5565 Mark dest as copies of sources; mark sources for deletion. If dest
5552 is a directory, copies are put in that directory. If dest is a
5566 is a directory, copies are put in that directory. If dest is a
5553 file, there can only be one source.
5567 file, there can only be one source.
5554
5568
5555 By default, this command copies the contents of files as they
5569 By default, this command copies the contents of files as they
5556 exist in the working directory. If invoked with -A/--after, the
5570 exist in the working directory. If invoked with -A/--after, the
5557 operation is recorded, but no copying is performed.
5571 operation is recorded, but no copying is performed.
5558
5572
5559 This command takes effect at the next commit. To undo a rename
5573 This command takes effect at the next commit. To undo a rename
5560 before that, see :hg:`revert`.
5574 before that, see :hg:`revert`.
5561
5575
5562 Returns 0 on success, 1 if errors are encountered.
5576 Returns 0 on success, 1 if errors are encountered.
5563 """
5577 """
5564 wlock = repo.wlock(False)
5578 wlock = repo.wlock(False)
5565 try:
5579 try:
5566 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5580 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5567 finally:
5581 finally:
5568 wlock.release()
5582 wlock.release()
5569
5583
5570 @command('resolve',
5584 @command('resolve',
5571 [('a', 'all', None, _('select all unresolved files')),
5585 [('a', 'all', None, _('select all unresolved files')),
5572 ('l', 'list', None, _('list state of files needing merge')),
5586 ('l', 'list', None, _('list state of files needing merge')),
5573 ('m', 'mark', None, _('mark files as resolved')),
5587 ('m', 'mark', None, _('mark files as resolved')),
5574 ('u', 'unmark', None, _('mark files as unresolved')),
5588 ('u', 'unmark', None, _('mark files as unresolved')),
5575 ('n', 'no-status', None, _('hide status prefix'))]
5589 ('n', 'no-status', None, _('hide status prefix'))]
5576 + mergetoolopts + walkopts + formatteropts,
5590 + mergetoolopts + walkopts + formatteropts,
5577 _('[OPTION]... [FILE]...'),
5591 _('[OPTION]... [FILE]...'),
5578 inferrepo=True)
5592 inferrepo=True)
5579 def resolve(ui, repo, *pats, **opts):
5593 def resolve(ui, repo, *pats, **opts):
5580 """redo merges or set/view the merge status of files
5594 """redo merges or set/view the merge status of files
5581
5595
5582 Merges with unresolved conflicts are often the result of
5596 Merges with unresolved conflicts are often the result of
5583 non-interactive merging using the ``internal:merge`` configuration
5597 non-interactive merging using the ``internal:merge`` configuration
5584 setting, or a command-line merge tool like ``diff3``. The resolve
5598 setting, or a command-line merge tool like ``diff3``. The resolve
5585 command is used to manage the files involved in a merge, after
5599 command is used to manage the files involved in a merge, after
5586 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5600 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5587 working directory must have two parents). See :hg:`help
5601 working directory must have two parents). See :hg:`help
5588 merge-tools` for information on configuring merge tools.
5602 merge-tools` for information on configuring merge tools.
5589
5603
5590 The resolve command can be used in the following ways:
5604 The resolve command can be used in the following ways:
5591
5605
5592 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5606 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5593 files, discarding any previous merge attempts. Re-merging is not
5607 files, discarding any previous merge attempts. Re-merging is not
5594 performed for files already marked as resolved. Use ``--all/-a``
5608 performed for files already marked as resolved. Use ``--all/-a``
5595 to select all unresolved files. ``--tool`` can be used to specify
5609 to select all unresolved files. ``--tool`` can be used to specify
5596 the merge tool used for the given files. It overrides the HGMERGE
5610 the merge tool used for the given files. It overrides the HGMERGE
5597 environment variable and your configuration files. Previous file
5611 environment variable and your configuration files. Previous file
5598 contents are saved with a ``.orig`` suffix.
5612 contents are saved with a ``.orig`` suffix.
5599
5613
5600 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5614 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5601 (e.g. after having manually fixed-up the files). The default is
5615 (e.g. after having manually fixed-up the files). The default is
5602 to mark all unresolved files.
5616 to mark all unresolved files.
5603
5617
5604 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5618 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5605 default is to mark all resolved files.
5619 default is to mark all resolved files.
5606
5620
5607 - :hg:`resolve -l`: list files which had or still have conflicts.
5621 - :hg:`resolve -l`: list files which had or still have conflicts.
5608 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5622 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5609
5623
5610 Note that Mercurial will not let you commit files with unresolved
5624 Note that Mercurial will not let you commit files with unresolved
5611 merge conflicts. You must use :hg:`resolve -m ...` before you can
5625 merge conflicts. You must use :hg:`resolve -m ...` before you can
5612 commit after a conflicting merge.
5626 commit after a conflicting merge.
5613
5627
5614 Returns 0 on success, 1 if any files fail a resolve attempt.
5628 Returns 0 on success, 1 if any files fail a resolve attempt.
5615 """
5629 """
5616
5630
5617 all, mark, unmark, show, nostatus = \
5631 all, mark, unmark, show, nostatus = \
5618 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5632 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5619
5633
5620 if (show and (mark or unmark)) or (mark and unmark):
5634 if (show and (mark or unmark)) or (mark and unmark):
5621 raise error.Abort(_("too many options specified"))
5635 raise error.Abort(_("too many options specified"))
5622 if pats and all:
5636 if pats and all:
5623 raise error.Abort(_("can't specify --all and patterns"))
5637 raise error.Abort(_("can't specify --all and patterns"))
5624 if not (all or pats or show or mark or unmark):
5638 if not (all or pats or show or mark or unmark):
5625 raise error.Abort(_('no files or directories specified'),
5639 raise error.Abort(_('no files or directories specified'),
5626 hint=('use --all to re-merge all unresolved files'))
5640 hint=('use --all to re-merge all unresolved files'))
5627
5641
5628 if show:
5642 if show:
5629 fm = ui.formatter('resolve', opts)
5643 fm = ui.formatter('resolve', opts)
5630 ms = mergemod.mergestate.read(repo)
5644 ms = mergemod.mergestate.read(repo)
5631 m = scmutil.match(repo[None], pats, opts)
5645 m = scmutil.match(repo[None], pats, opts)
5632 for f in ms:
5646 for f in ms:
5633 if not m(f):
5647 if not m(f):
5634 continue
5648 continue
5635 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
5649 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
5636 'd': 'driverresolved'}[ms[f]]
5650 'd': 'driverresolved'}[ms[f]]
5637 fm.startitem()
5651 fm.startitem()
5638 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5652 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5639 fm.write('path', '%s\n', f, label=l)
5653 fm.write('path', '%s\n', f, label=l)
5640 fm.end()
5654 fm.end()
5641 return 0
5655 return 0
5642
5656
5643 wlock = repo.wlock()
5657 wlock = repo.wlock()
5644 try:
5658 try:
5645 ms = mergemod.mergestate.read(repo)
5659 ms = mergemod.mergestate.read(repo)
5646
5660
5647 if not (ms.active() or repo.dirstate.p2() != nullid):
5661 if not (ms.active() or repo.dirstate.p2() != nullid):
5648 raise error.Abort(
5662 raise error.Abort(
5649 _('resolve command not applicable when not merging'))
5663 _('resolve command not applicable when not merging'))
5650
5664
5651 wctx = repo[None]
5665 wctx = repo[None]
5652
5666
5653 if ms.mergedriver and ms.mdstate() == 'u':
5667 if ms.mergedriver and ms.mdstate() == 'u':
5654 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5668 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5655 ms.commit()
5669 ms.commit()
5656 # allow mark and unmark to go through
5670 # allow mark and unmark to go through
5657 if not mark and not unmark and not proceed:
5671 if not mark and not unmark and not proceed:
5658 return 1
5672 return 1
5659
5673
5660 m = scmutil.match(wctx, pats, opts)
5674 m = scmutil.match(wctx, pats, opts)
5661 ret = 0
5675 ret = 0
5662 didwork = False
5676 didwork = False
5663 runconclude = False
5677 runconclude = False
5664
5678
5665 tocomplete = []
5679 tocomplete = []
5666 for f in ms:
5680 for f in ms:
5667 if not m(f):
5681 if not m(f):
5668 continue
5682 continue
5669
5683
5670 didwork = True
5684 didwork = True
5671
5685
5672 # don't let driver-resolved files be marked, and run the conclude
5686 # don't let driver-resolved files be marked, and run the conclude
5673 # step if asked to resolve
5687 # step if asked to resolve
5674 if ms[f] == "d":
5688 if ms[f] == "d":
5675 exact = m.exact(f)
5689 exact = m.exact(f)
5676 if mark:
5690 if mark:
5677 if exact:
5691 if exact:
5678 ui.warn(_('not marking %s as it is driver-resolved\n')
5692 ui.warn(_('not marking %s as it is driver-resolved\n')
5679 % f)
5693 % f)
5680 elif unmark:
5694 elif unmark:
5681 if exact:
5695 if exact:
5682 ui.warn(_('not unmarking %s as it is driver-resolved\n')
5696 ui.warn(_('not unmarking %s as it is driver-resolved\n')
5683 % f)
5697 % f)
5684 else:
5698 else:
5685 runconclude = True
5699 runconclude = True
5686 continue
5700 continue
5687
5701
5688 if mark:
5702 if mark:
5689 ms.mark(f, "r")
5703 ms.mark(f, "r")
5690 elif unmark:
5704 elif unmark:
5691 ms.mark(f, "u")
5705 ms.mark(f, "u")
5692 else:
5706 else:
5693 # backup pre-resolve (merge uses .orig for its own purposes)
5707 # backup pre-resolve (merge uses .orig for its own purposes)
5694 a = repo.wjoin(f)
5708 a = repo.wjoin(f)
5695 try:
5709 try:
5696 util.copyfile(a, a + ".resolve")
5710 util.copyfile(a, a + ".resolve")
5697 except (IOError, OSError) as inst:
5711 except (IOError, OSError) as inst:
5698 if inst.errno != errno.ENOENT:
5712 if inst.errno != errno.ENOENT:
5699 raise
5713 raise
5700
5714
5701 try:
5715 try:
5702 # preresolve file
5716 # preresolve file
5703 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5717 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5704 'resolve')
5718 'resolve')
5705 complete, r = ms.preresolve(f, wctx)
5719 complete, r = ms.preresolve(f, wctx)
5706 if not complete:
5720 if not complete:
5707 tocomplete.append(f)
5721 tocomplete.append(f)
5708 elif r:
5722 elif r:
5709 ret = 1
5723 ret = 1
5710 finally:
5724 finally:
5711 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5725 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5712 ms.commit()
5726 ms.commit()
5713
5727
5714 # replace filemerge's .orig file with our resolve file, but only
5728 # replace filemerge's .orig file with our resolve file, but only
5715 # for merges that are complete
5729 # for merges that are complete
5716 if complete:
5730 if complete:
5717 try:
5731 try:
5718 util.rename(a + ".resolve",
5732 util.rename(a + ".resolve",
5719 cmdutil.origpath(ui, repo, a))
5733 cmdutil.origpath(ui, repo, a))
5720 except OSError as inst:
5734 except OSError as inst:
5721 if inst.errno != errno.ENOENT:
5735 if inst.errno != errno.ENOENT:
5722 raise
5736 raise
5723
5737
5724 for f in tocomplete:
5738 for f in tocomplete:
5725 try:
5739 try:
5726 # resolve file
5740 # resolve file
5727 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5741 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5728 'resolve')
5742 'resolve')
5729 r = ms.resolve(f, wctx)
5743 r = ms.resolve(f, wctx)
5730 if r:
5744 if r:
5731 ret = 1
5745 ret = 1
5732 finally:
5746 finally:
5733 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5747 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5734 ms.commit()
5748 ms.commit()
5735
5749
5736 # replace filemerge's .orig file with our resolve file
5750 # replace filemerge's .orig file with our resolve file
5737 a = repo.wjoin(f)
5751 a = repo.wjoin(f)
5738 try:
5752 try:
5739 util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a))
5753 util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a))
5740 except OSError as inst:
5754 except OSError as inst:
5741 if inst.errno != errno.ENOENT:
5755 if inst.errno != errno.ENOENT:
5742 raise
5756 raise
5743
5757
5744 ms.commit()
5758 ms.commit()
5745 ms.recordactions()
5759 ms.recordactions()
5746
5760
5747 if not didwork and pats:
5761 if not didwork and pats:
5748 ui.warn(_("arguments do not match paths that need resolving\n"))
5762 ui.warn(_("arguments do not match paths that need resolving\n"))
5749 elif ms.mergedriver and ms.mdstate() != 's':
5763 elif ms.mergedriver and ms.mdstate() != 's':
5750 # run conclude step when either a driver-resolved file is requested
5764 # run conclude step when either a driver-resolved file is requested
5751 # or there are no driver-resolved files
5765 # or there are no driver-resolved files
5752 # we can't use 'ret' to determine whether any files are unresolved
5766 # we can't use 'ret' to determine whether any files are unresolved
5753 # because we might not have tried to resolve some
5767 # because we might not have tried to resolve some
5754 if ((runconclude or not list(ms.driverresolved()))
5768 if ((runconclude or not list(ms.driverresolved()))
5755 and not list(ms.unresolved())):
5769 and not list(ms.unresolved())):
5756 proceed = mergemod.driverconclude(repo, ms, wctx)
5770 proceed = mergemod.driverconclude(repo, ms, wctx)
5757 ms.commit()
5771 ms.commit()
5758 if not proceed:
5772 if not proceed:
5759 return 1
5773 return 1
5760
5774
5761 finally:
5775 finally:
5762 wlock.release()
5776 wlock.release()
5763
5777
5764 # Nudge users into finishing an unfinished operation
5778 # Nudge users into finishing an unfinished operation
5765 unresolvedf = list(ms.unresolved())
5779 unresolvedf = list(ms.unresolved())
5766 driverresolvedf = list(ms.driverresolved())
5780 driverresolvedf = list(ms.driverresolved())
5767 if not unresolvedf and not driverresolvedf:
5781 if not unresolvedf and not driverresolvedf:
5768 ui.status(_('(no more unresolved files)\n'))
5782 ui.status(_('(no more unresolved files)\n'))
5769 elif not unresolvedf:
5783 elif not unresolvedf:
5770 ui.status(_('(no more unresolved files -- '
5784 ui.status(_('(no more unresolved files -- '
5771 'run "hg resolve --all" to conclude)\n'))
5785 'run "hg resolve --all" to conclude)\n'))
5772
5786
5773 return ret
5787 return ret
5774
5788
5775 @command('revert',
5789 @command('revert',
5776 [('a', 'all', None, _('revert all changes when no arguments given')),
5790 [('a', 'all', None, _('revert all changes when no arguments given')),
5777 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5791 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5778 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5792 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5779 ('C', 'no-backup', None, _('do not save backup copies of files')),
5793 ('C', 'no-backup', None, _('do not save backup copies of files')),
5780 ('i', 'interactive', None,
5794 ('i', 'interactive', None,
5781 _('interactively select the changes (EXPERIMENTAL)')),
5795 _('interactively select the changes (EXPERIMENTAL)')),
5782 ] + walkopts + dryrunopts,
5796 ] + walkopts + dryrunopts,
5783 _('[OPTION]... [-r REV] [NAME]...'))
5797 _('[OPTION]... [-r REV] [NAME]...'))
5784 def revert(ui, repo, *pats, **opts):
5798 def revert(ui, repo, *pats, **opts):
5785 """restore files to their checkout state
5799 """restore files to their checkout state
5786
5800
5787 .. note::
5801 .. note::
5788
5802
5789 To check out earlier revisions, you should use :hg:`update REV`.
5803 To check out earlier revisions, you should use :hg:`update REV`.
5790 To cancel an uncommitted merge (and lose your changes),
5804 To cancel an uncommitted merge (and lose your changes),
5791 use :hg:`update --clean .`.
5805 use :hg:`update --clean .`.
5792
5806
5793 With no revision specified, revert the specified files or directories
5807 With no revision specified, revert the specified files or directories
5794 to the contents they had in the parent of the working directory.
5808 to the contents they had in the parent of the working directory.
5795 This restores the contents of files to an unmodified
5809 This restores the contents of files to an unmodified
5796 state and unschedules adds, removes, copies, and renames. If the
5810 state and unschedules adds, removes, copies, and renames. If the
5797 working directory has two parents, you must explicitly specify a
5811 working directory has two parents, you must explicitly specify a
5798 revision.
5812 revision.
5799
5813
5800 Using the -r/--rev or -d/--date options, revert the given files or
5814 Using the -r/--rev or -d/--date options, revert the given files or
5801 directories to their states as of a specific revision. Because
5815 directories to their states as of a specific revision. Because
5802 revert does not change the working directory parents, this will
5816 revert does not change the working directory parents, this will
5803 cause these files to appear modified. This can be helpful to "back
5817 cause these files to appear modified. This can be helpful to "back
5804 out" some or all of an earlier change. See :hg:`backout` for a
5818 out" some or all of an earlier change. See :hg:`backout` for a
5805 related method.
5819 related method.
5806
5820
5807 Modified files are saved with a .orig suffix before reverting.
5821 Modified files are saved with a .orig suffix before reverting.
5808 To disable these backups, use --no-backup.
5822 To disable these backups, use --no-backup.
5809
5823
5810 See :hg:`help dates` for a list of formats valid for -d/--date.
5824 See :hg:`help dates` for a list of formats valid for -d/--date.
5811
5825
5812 See :hg:`help backout` for a way to reverse the effect of an
5826 See :hg:`help backout` for a way to reverse the effect of an
5813 earlier changeset.
5827 earlier changeset.
5814
5828
5815 Returns 0 on success.
5829 Returns 0 on success.
5816 """
5830 """
5817
5831
5818 if opts.get("date"):
5832 if opts.get("date"):
5819 if opts.get("rev"):
5833 if opts.get("rev"):
5820 raise error.Abort(_("you can't specify a revision and a date"))
5834 raise error.Abort(_("you can't specify a revision and a date"))
5821 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5835 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5822
5836
5823 parent, p2 = repo.dirstate.parents()
5837 parent, p2 = repo.dirstate.parents()
5824 if not opts.get('rev') and p2 != nullid:
5838 if not opts.get('rev') and p2 != nullid:
5825 # revert after merge is a trap for new users (issue2915)
5839 # revert after merge is a trap for new users (issue2915)
5826 raise error.Abort(_('uncommitted merge with no revision specified'),
5840 raise error.Abort(_('uncommitted merge with no revision specified'),
5827 hint=_('use "hg update" or see "hg help revert"'))
5841 hint=_('use "hg update" or see "hg help revert"'))
5828
5842
5829 ctx = scmutil.revsingle(repo, opts.get('rev'))
5843 ctx = scmutil.revsingle(repo, opts.get('rev'))
5830
5844
5831 if (not (pats or opts.get('include') or opts.get('exclude') or
5845 if (not (pats or opts.get('include') or opts.get('exclude') or
5832 opts.get('all') or opts.get('interactive'))):
5846 opts.get('all') or opts.get('interactive'))):
5833 msg = _("no files or directories specified")
5847 msg = _("no files or directories specified")
5834 if p2 != nullid:
5848 if p2 != nullid:
5835 hint = _("uncommitted merge, use --all to discard all changes,"
5849 hint = _("uncommitted merge, use --all to discard all changes,"
5836 " or 'hg update -C .' to abort the merge")
5850 " or 'hg update -C .' to abort the merge")
5837 raise error.Abort(msg, hint=hint)
5851 raise error.Abort(msg, hint=hint)
5838 dirty = any(repo.status())
5852 dirty = any(repo.status())
5839 node = ctx.node()
5853 node = ctx.node()
5840 if node != parent:
5854 if node != parent:
5841 if dirty:
5855 if dirty:
5842 hint = _("uncommitted changes, use --all to discard all"
5856 hint = _("uncommitted changes, use --all to discard all"
5843 " changes, or 'hg update %s' to update") % ctx.rev()
5857 " changes, or 'hg update %s' to update") % ctx.rev()
5844 else:
5858 else:
5845 hint = _("use --all to revert all files,"
5859 hint = _("use --all to revert all files,"
5846 " or 'hg update %s' to update") % ctx.rev()
5860 " or 'hg update %s' to update") % ctx.rev()
5847 elif dirty:
5861 elif dirty:
5848 hint = _("uncommitted changes, use --all to discard all changes")
5862 hint = _("uncommitted changes, use --all to discard all changes")
5849 else:
5863 else:
5850 hint = _("use --all to revert all files")
5864 hint = _("use --all to revert all files")
5851 raise error.Abort(msg, hint=hint)
5865 raise error.Abort(msg, hint=hint)
5852
5866
5853 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5867 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5854
5868
5855 @command('rollback', dryrunopts +
5869 @command('rollback', dryrunopts +
5856 [('f', 'force', False, _('ignore safety measures'))])
5870 [('f', 'force', False, _('ignore safety measures'))])
5857 def rollback(ui, repo, **opts):
5871 def rollback(ui, repo, **opts):
5858 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5872 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5859
5873
5860 Please use :hg:`commit --amend` instead of rollback to correct
5874 Please use :hg:`commit --amend` instead of rollback to correct
5861 mistakes in the last commit.
5875 mistakes in the last commit.
5862
5876
5863 This command should be used with care. There is only one level of
5877 This command should be used with care. There is only one level of
5864 rollback, and there is no way to undo a rollback. It will also
5878 rollback, and there is no way to undo a rollback. It will also
5865 restore the dirstate at the time of the last transaction, losing
5879 restore the dirstate at the time of the last transaction, losing
5866 any dirstate changes since that time. This command does not alter
5880 any dirstate changes since that time. This command does not alter
5867 the working directory.
5881 the working directory.
5868
5882
5869 Transactions are used to encapsulate the effects of all commands
5883 Transactions are used to encapsulate the effects of all commands
5870 that create new changesets or propagate existing changesets into a
5884 that create new changesets or propagate existing changesets into a
5871 repository.
5885 repository.
5872
5886
5873 .. container:: verbose
5887 .. container:: verbose
5874
5888
5875 For example, the following commands are transactional, and their
5889 For example, the following commands are transactional, and their
5876 effects can be rolled back:
5890 effects can be rolled back:
5877
5891
5878 - commit
5892 - commit
5879 - import
5893 - import
5880 - pull
5894 - pull
5881 - push (with this repository as the destination)
5895 - push (with this repository as the destination)
5882 - unbundle
5896 - unbundle
5883
5897
5884 To avoid permanent data loss, rollback will refuse to rollback a
5898 To avoid permanent data loss, rollback will refuse to rollback a
5885 commit transaction if it isn't checked out. Use --force to
5899 commit transaction if it isn't checked out. Use --force to
5886 override this protection.
5900 override this protection.
5887
5901
5888 This command is not intended for use on public repositories. Once
5902 This command is not intended for use on public repositories. Once
5889 changes are visible for pull by other users, rolling a transaction
5903 changes are visible for pull by other users, rolling a transaction
5890 back locally is ineffective (someone else may already have pulled
5904 back locally is ineffective (someone else may already have pulled
5891 the changes). Furthermore, a race is possible with readers of the
5905 the changes). Furthermore, a race is possible with readers of the
5892 repository; for example an in-progress pull from the repository
5906 repository; for example an in-progress pull from the repository
5893 may fail if a rollback is performed.
5907 may fail if a rollback is performed.
5894
5908
5895 Returns 0 on success, 1 if no rollback data is available.
5909 Returns 0 on success, 1 if no rollback data is available.
5896 """
5910 """
5897 return repo.rollback(dryrun=opts.get('dry_run'),
5911 return repo.rollback(dryrun=opts.get('dry_run'),
5898 force=opts.get('force'))
5912 force=opts.get('force'))
5899
5913
5900 @command('root', [])
5914 @command('root', [])
5901 def root(ui, repo):
5915 def root(ui, repo):
5902 """print the root (top) of the current working directory
5916 """print the root (top) of the current working directory
5903
5917
5904 Print the root directory of the current repository.
5918 Print the root directory of the current repository.
5905
5919
5906 Returns 0 on success.
5920 Returns 0 on success.
5907 """
5921 """
5908 ui.write(repo.root + "\n")
5922 ui.write(repo.root + "\n")
5909
5923
5910 @command('^serve',
5924 @command('^serve',
5911 [('A', 'accesslog', '', _('name of access log file to write to'),
5925 [('A', 'accesslog', '', _('name of access log file to write to'),
5912 _('FILE')),
5926 _('FILE')),
5913 ('d', 'daemon', None, _('run server in background')),
5927 ('d', 'daemon', None, _('run server in background')),
5914 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5928 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5915 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5929 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5916 # use string type, then we can check if something was passed
5930 # use string type, then we can check if something was passed
5917 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5931 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5918 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5932 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5919 _('ADDR')),
5933 _('ADDR')),
5920 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5934 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5921 _('PREFIX')),
5935 _('PREFIX')),
5922 ('n', 'name', '',
5936 ('n', 'name', '',
5923 _('name to show in web pages (default: working directory)'), _('NAME')),
5937 _('name to show in web pages (default: working directory)'), _('NAME')),
5924 ('', 'web-conf', '',
5938 ('', 'web-conf', '',
5925 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5939 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5926 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5940 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5927 _('FILE')),
5941 _('FILE')),
5928 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5942 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5929 ('', 'stdio', None, _('for remote clients')),
5943 ('', 'stdio', None, _('for remote clients')),
5930 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5944 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5931 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5945 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5932 ('', 'style', '', _('template style to use'), _('STYLE')),
5946 ('', 'style', '', _('template style to use'), _('STYLE')),
5933 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5947 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5934 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5948 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5935 _('[OPTION]...'),
5949 _('[OPTION]...'),
5936 optionalrepo=True)
5950 optionalrepo=True)
5937 def serve(ui, repo, **opts):
5951 def serve(ui, repo, **opts):
5938 """start stand-alone webserver
5952 """start stand-alone webserver
5939
5953
5940 Start a local HTTP repository browser and pull server. You can use
5954 Start a local HTTP repository browser and pull server. You can use
5941 this for ad-hoc sharing and browsing of repositories. It is
5955 this for ad-hoc sharing and browsing of repositories. It is
5942 recommended to use a real web server to serve a repository for
5956 recommended to use a real web server to serve a repository for
5943 longer periods of time.
5957 longer periods of time.
5944
5958
5945 Please note that the server does not implement access control.
5959 Please note that the server does not implement access control.
5946 This means that, by default, anybody can read from the server and
5960 This means that, by default, anybody can read from the server and
5947 nobody can write to it by default. Set the ``web.allow_push``
5961 nobody can write to it by default. Set the ``web.allow_push``
5948 option to ``*`` to allow everybody to push to the server. You
5962 option to ``*`` to allow everybody to push to the server. You
5949 should use a real web server if you need to authenticate users.
5963 should use a real web server if you need to authenticate users.
5950
5964
5951 By default, the server logs accesses to stdout and errors to
5965 By default, the server logs accesses to stdout and errors to
5952 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5966 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5953 files.
5967 files.
5954
5968
5955 To have the server choose a free port number to listen on, specify
5969 To have the server choose a free port number to listen on, specify
5956 a port number of 0; in this case, the server will print the port
5970 a port number of 0; in this case, the server will print the port
5957 number it uses.
5971 number it uses.
5958
5972
5959 Returns 0 on success.
5973 Returns 0 on success.
5960 """
5974 """
5961
5975
5962 if opts["stdio"] and opts["cmdserver"]:
5976 if opts["stdio"] and opts["cmdserver"]:
5963 raise error.Abort(_("cannot use --stdio with --cmdserver"))
5977 raise error.Abort(_("cannot use --stdio with --cmdserver"))
5964
5978
5965 if opts["stdio"]:
5979 if opts["stdio"]:
5966 if repo is None:
5980 if repo is None:
5967 raise error.RepoError(_("there is no Mercurial repository here"
5981 raise error.RepoError(_("there is no Mercurial repository here"
5968 " (.hg not found)"))
5982 " (.hg not found)"))
5969 s = sshserver.sshserver(ui, repo)
5983 s = sshserver.sshserver(ui, repo)
5970 s.serve_forever()
5984 s.serve_forever()
5971
5985
5972 if opts["cmdserver"]:
5986 if opts["cmdserver"]:
5973 import commandserver
5987 import commandserver
5974 service = commandserver.createservice(ui, repo, opts)
5988 service = commandserver.createservice(ui, repo, opts)
5975 else:
5989 else:
5976 service = hgweb.createservice(ui, repo, opts)
5990 service = hgweb.createservice(ui, repo, opts)
5977 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5991 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5978
5992
5979 @command('^status|st',
5993 @command('^status|st',
5980 [('A', 'all', None, _('show status of all files')),
5994 [('A', 'all', None, _('show status of all files')),
5981 ('m', 'modified', None, _('show only modified files')),
5995 ('m', 'modified', None, _('show only modified files')),
5982 ('a', 'added', None, _('show only added files')),
5996 ('a', 'added', None, _('show only added files')),
5983 ('r', 'removed', None, _('show only removed files')),
5997 ('r', 'removed', None, _('show only removed files')),
5984 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5998 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5985 ('c', 'clean', None, _('show only files without changes')),
5999 ('c', 'clean', None, _('show only files without changes')),
5986 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
6000 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5987 ('i', 'ignored', None, _('show only ignored files')),
6001 ('i', 'ignored', None, _('show only ignored files')),
5988 ('n', 'no-status', None, _('hide status prefix')),
6002 ('n', 'no-status', None, _('hide status prefix')),
5989 ('C', 'copies', None, _('show source of copied files')),
6003 ('C', 'copies', None, _('show source of copied files')),
5990 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
6004 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5991 ('', 'rev', [], _('show difference from revision'), _('REV')),
6005 ('', 'rev', [], _('show difference from revision'), _('REV')),
5992 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
6006 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5993 ] + walkopts + subrepoopts + formatteropts,
6007 ] + walkopts + subrepoopts + formatteropts,
5994 _('[OPTION]... [FILE]...'),
6008 _('[OPTION]... [FILE]...'),
5995 inferrepo=True)
6009 inferrepo=True)
5996 def status(ui, repo, *pats, **opts):
6010 def status(ui, repo, *pats, **opts):
5997 """show changed files in the working directory
6011 """show changed files in the working directory
5998
6012
5999 Show status of files in the repository. If names are given, only
6013 Show status of files in the repository. If names are given, only
6000 files that match are shown. Files that are clean or ignored or
6014 files that match are shown. Files that are clean or ignored or
6001 the source of a copy/move operation, are not listed unless
6015 the source of a copy/move operation, are not listed unless
6002 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6016 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6003 Unless options described with "show only ..." are given, the
6017 Unless options described with "show only ..." are given, the
6004 options -mardu are used.
6018 options -mardu are used.
6005
6019
6006 Option -q/--quiet hides untracked (unknown and ignored) files
6020 Option -q/--quiet hides untracked (unknown and ignored) files
6007 unless explicitly requested with -u/--unknown or -i/--ignored.
6021 unless explicitly requested with -u/--unknown or -i/--ignored.
6008
6022
6009 .. note::
6023 .. note::
6010
6024
6011 status may appear to disagree with diff if permissions have
6025 status may appear to disagree with diff if permissions have
6012 changed or a merge has occurred. The standard diff format does
6026 changed or a merge has occurred. The standard diff format does
6013 not report permission changes and diff only reports changes
6027 not report permission changes and diff only reports changes
6014 relative to one merge parent.
6028 relative to one merge parent.
6015
6029
6016 If one revision is given, it is used as the base revision.
6030 If one revision is given, it is used as the base revision.
6017 If two revisions are given, the differences between them are
6031 If two revisions are given, the differences between them are
6018 shown. The --change option can also be used as a shortcut to list
6032 shown. The --change option can also be used as a shortcut to list
6019 the changed files of a revision from its first parent.
6033 the changed files of a revision from its first parent.
6020
6034
6021 The codes used to show the status of files are::
6035 The codes used to show the status of files are::
6022
6036
6023 M = modified
6037 M = modified
6024 A = added
6038 A = added
6025 R = removed
6039 R = removed
6026 C = clean
6040 C = clean
6027 ! = missing (deleted by non-hg command, but still tracked)
6041 ! = missing (deleted by non-hg command, but still tracked)
6028 ? = not tracked
6042 ? = not tracked
6029 I = ignored
6043 I = ignored
6030 = origin of the previous file (with --copies)
6044 = origin of the previous file (with --copies)
6031
6045
6032 .. container:: verbose
6046 .. container:: verbose
6033
6047
6034 Examples:
6048 Examples:
6035
6049
6036 - show changes in the working directory relative to a
6050 - show changes in the working directory relative to a
6037 changeset::
6051 changeset::
6038
6052
6039 hg status --rev 9353
6053 hg status --rev 9353
6040
6054
6041 - show changes in the working directory relative to the
6055 - show changes in the working directory relative to the
6042 current directory (see :hg:`help patterns` for more information)::
6056 current directory (see :hg:`help patterns` for more information)::
6043
6057
6044 hg status re:
6058 hg status re:
6045
6059
6046 - show all changes including copies in an existing changeset::
6060 - show all changes including copies in an existing changeset::
6047
6061
6048 hg status --copies --change 9353
6062 hg status --copies --change 9353
6049
6063
6050 - get a NUL separated list of added files, suitable for xargs::
6064 - get a NUL separated list of added files, suitable for xargs::
6051
6065
6052 hg status -an0
6066 hg status -an0
6053
6067
6054 Returns 0 on success.
6068 Returns 0 on success.
6055 """
6069 """
6056
6070
6057 revs = opts.get('rev')
6071 revs = opts.get('rev')
6058 change = opts.get('change')
6072 change = opts.get('change')
6059
6073
6060 if revs and change:
6074 if revs and change:
6061 msg = _('cannot specify --rev and --change at the same time')
6075 msg = _('cannot specify --rev and --change at the same time')
6062 raise error.Abort(msg)
6076 raise error.Abort(msg)
6063 elif change:
6077 elif change:
6064 node2 = scmutil.revsingle(repo, change, None).node()
6078 node2 = scmutil.revsingle(repo, change, None).node()
6065 node1 = repo[node2].p1().node()
6079 node1 = repo[node2].p1().node()
6066 else:
6080 else:
6067 node1, node2 = scmutil.revpair(repo, revs)
6081 node1, node2 = scmutil.revpair(repo, revs)
6068
6082
6069 if pats:
6083 if pats:
6070 cwd = repo.getcwd()
6084 cwd = repo.getcwd()
6071 else:
6085 else:
6072 cwd = ''
6086 cwd = ''
6073
6087
6074 if opts.get('print0'):
6088 if opts.get('print0'):
6075 end = '\0'
6089 end = '\0'
6076 else:
6090 else:
6077 end = '\n'
6091 end = '\n'
6078 copy = {}
6092 copy = {}
6079 states = 'modified added removed deleted unknown ignored clean'.split()
6093 states = 'modified added removed deleted unknown ignored clean'.split()
6080 show = [k for k in states if opts.get(k)]
6094 show = [k for k in states if opts.get(k)]
6081 if opts.get('all'):
6095 if opts.get('all'):
6082 show += ui.quiet and (states[:4] + ['clean']) or states
6096 show += ui.quiet and (states[:4] + ['clean']) or states
6083 if not show:
6097 if not show:
6084 if ui.quiet:
6098 if ui.quiet:
6085 show = states[:4]
6099 show = states[:4]
6086 else:
6100 else:
6087 show = states[:5]
6101 show = states[:5]
6088
6102
6089 m = scmutil.match(repo[node2], pats, opts)
6103 m = scmutil.match(repo[node2], pats, opts)
6090 stat = repo.status(node1, node2, m,
6104 stat = repo.status(node1, node2, m,
6091 'ignored' in show, 'clean' in show, 'unknown' in show,
6105 'ignored' in show, 'clean' in show, 'unknown' in show,
6092 opts.get('subrepos'))
6106 opts.get('subrepos'))
6093 changestates = zip(states, 'MAR!?IC', stat)
6107 changestates = zip(states, 'MAR!?IC', stat)
6094
6108
6095 if (opts.get('all') or opts.get('copies')
6109 if (opts.get('all') or opts.get('copies')
6096 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6110 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6097 copy = copies.pathcopies(repo[node1], repo[node2], m)
6111 copy = copies.pathcopies(repo[node1], repo[node2], m)
6098
6112
6099 fm = ui.formatter('status', opts)
6113 fm = ui.formatter('status', opts)
6100 fmt = '%s' + end
6114 fmt = '%s' + end
6101 showchar = not opts.get('no_status')
6115 showchar = not opts.get('no_status')
6102
6116
6103 for state, char, files in changestates:
6117 for state, char, files in changestates:
6104 if state in show:
6118 if state in show:
6105 label = 'status.' + state
6119 label = 'status.' + state
6106 for f in files:
6120 for f in files:
6107 fm.startitem()
6121 fm.startitem()
6108 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6122 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6109 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6123 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6110 if f in copy:
6124 if f in copy:
6111 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6125 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6112 label='status.copied')
6126 label='status.copied')
6113 fm.end()
6127 fm.end()
6114
6128
6115 @command('^summary|sum',
6129 @command('^summary|sum',
6116 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6130 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6117 def summary(ui, repo, **opts):
6131 def summary(ui, repo, **opts):
6118 """summarize working directory state
6132 """summarize working directory state
6119
6133
6120 This generates a brief summary of the working directory state,
6134 This generates a brief summary of the working directory state,
6121 including parents, branch, commit status, phase and available updates.
6135 including parents, branch, commit status, phase and available updates.
6122
6136
6123 With the --remote option, this will check the default paths for
6137 With the --remote option, this will check the default paths for
6124 incoming and outgoing changes. This can be time-consuming.
6138 incoming and outgoing changes. This can be time-consuming.
6125
6139
6126 Returns 0 on success.
6140 Returns 0 on success.
6127 """
6141 """
6128
6142
6129 ctx = repo[None]
6143 ctx = repo[None]
6130 parents = ctx.parents()
6144 parents = ctx.parents()
6131 pnode = parents[0].node()
6145 pnode = parents[0].node()
6132 marks = []
6146 marks = []
6133
6147
6134 for p in parents:
6148 for p in parents:
6135 # label with log.changeset (instead of log.parent) since this
6149 # label with log.changeset (instead of log.parent) since this
6136 # shows a working directory parent *changeset*:
6150 # shows a working directory parent *changeset*:
6137 # i18n: column positioning for "hg summary"
6151 # i18n: column positioning for "hg summary"
6138 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6152 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6139 label='log.changeset changeset.%s' % p.phasestr())
6153 label='log.changeset changeset.%s' % p.phasestr())
6140 ui.write(' '.join(p.tags()), label='log.tag')
6154 ui.write(' '.join(p.tags()), label='log.tag')
6141 if p.bookmarks():
6155 if p.bookmarks():
6142 marks.extend(p.bookmarks())
6156 marks.extend(p.bookmarks())
6143 if p.rev() == -1:
6157 if p.rev() == -1:
6144 if not len(repo):
6158 if not len(repo):
6145 ui.write(_(' (empty repository)'))
6159 ui.write(_(' (empty repository)'))
6146 else:
6160 else:
6147 ui.write(_(' (no revision checked out)'))
6161 ui.write(_(' (no revision checked out)'))
6148 ui.write('\n')
6162 ui.write('\n')
6149 if p.description():
6163 if p.description():
6150 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6164 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6151 label='log.summary')
6165 label='log.summary')
6152
6166
6153 branch = ctx.branch()
6167 branch = ctx.branch()
6154 bheads = repo.branchheads(branch)
6168 bheads = repo.branchheads(branch)
6155 # i18n: column positioning for "hg summary"
6169 # i18n: column positioning for "hg summary"
6156 m = _('branch: %s\n') % branch
6170 m = _('branch: %s\n') % branch
6157 if branch != 'default':
6171 if branch != 'default':
6158 ui.write(m, label='log.branch')
6172 ui.write(m, label='log.branch')
6159 else:
6173 else:
6160 ui.status(m, label='log.branch')
6174 ui.status(m, label='log.branch')
6161
6175
6162 if marks:
6176 if marks:
6163 active = repo._activebookmark
6177 active = repo._activebookmark
6164 # i18n: column positioning for "hg summary"
6178 # i18n: column positioning for "hg summary"
6165 ui.write(_('bookmarks:'), label='log.bookmark')
6179 ui.write(_('bookmarks:'), label='log.bookmark')
6166 if active is not None:
6180 if active is not None:
6167 if active in marks:
6181 if active in marks:
6168 ui.write(' *' + active, label=activebookmarklabel)
6182 ui.write(' *' + active, label=activebookmarklabel)
6169 marks.remove(active)
6183 marks.remove(active)
6170 else:
6184 else:
6171 ui.write(' [%s]' % active, label=activebookmarklabel)
6185 ui.write(' [%s]' % active, label=activebookmarklabel)
6172 for m in marks:
6186 for m in marks:
6173 ui.write(' ' + m, label='log.bookmark')
6187 ui.write(' ' + m, label='log.bookmark')
6174 ui.write('\n', label='log.bookmark')
6188 ui.write('\n', label='log.bookmark')
6175
6189
6176 status = repo.status(unknown=True)
6190 status = repo.status(unknown=True)
6177
6191
6178 c = repo.dirstate.copies()
6192 c = repo.dirstate.copies()
6179 copied, renamed = [], []
6193 copied, renamed = [], []
6180 for d, s in c.iteritems():
6194 for d, s in c.iteritems():
6181 if s in status.removed:
6195 if s in status.removed:
6182 status.removed.remove(s)
6196 status.removed.remove(s)
6183 renamed.append(d)
6197 renamed.append(d)
6184 else:
6198 else:
6185 copied.append(d)
6199 copied.append(d)
6186 if d in status.added:
6200 if d in status.added:
6187 status.added.remove(d)
6201 status.added.remove(d)
6188
6202
6189 try:
6203 try:
6190 ms = mergemod.mergestate.read(repo)
6204 ms = mergemod.mergestate.read(repo)
6191 except error.UnsupportedMergeRecords as e:
6205 except error.UnsupportedMergeRecords as e:
6192 s = ' '.join(e.recordtypes)
6206 s = ' '.join(e.recordtypes)
6193 ui.warn(
6207 ui.warn(
6194 _('warning: merge state has unsupported record types: %s\n') % s)
6208 _('warning: merge state has unsupported record types: %s\n') % s)
6195 unresolved = 0
6209 unresolved = 0
6196 else:
6210 else:
6197 unresolved = [f for f in ms if ms[f] == 'u']
6211 unresolved = [f for f in ms if ms[f] == 'u']
6198
6212
6199 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6213 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6200
6214
6201 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6215 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6202 (ui.label(_('%d added'), 'status.added'), status.added),
6216 (ui.label(_('%d added'), 'status.added'), status.added),
6203 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6217 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6204 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6218 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6205 (ui.label(_('%d copied'), 'status.copied'), copied),
6219 (ui.label(_('%d copied'), 'status.copied'), copied),
6206 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6220 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6207 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6221 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6208 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6222 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6209 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6223 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6210 t = []
6224 t = []
6211 for l, s in labels:
6225 for l, s in labels:
6212 if s:
6226 if s:
6213 t.append(l % len(s))
6227 t.append(l % len(s))
6214
6228
6215 t = ', '.join(t)
6229 t = ', '.join(t)
6216 cleanworkdir = False
6230 cleanworkdir = False
6217
6231
6218 if repo.vfs.exists('updatestate'):
6232 if repo.vfs.exists('updatestate'):
6219 t += _(' (interrupted update)')
6233 t += _(' (interrupted update)')
6220 elif len(parents) > 1:
6234 elif len(parents) > 1:
6221 t += _(' (merge)')
6235 t += _(' (merge)')
6222 elif branch != parents[0].branch():
6236 elif branch != parents[0].branch():
6223 t += _(' (new branch)')
6237 t += _(' (new branch)')
6224 elif (parents[0].closesbranch() and
6238 elif (parents[0].closesbranch() and
6225 pnode in repo.branchheads(branch, closed=True)):
6239 pnode in repo.branchheads(branch, closed=True)):
6226 t += _(' (head closed)')
6240 t += _(' (head closed)')
6227 elif not (status.modified or status.added or status.removed or renamed or
6241 elif not (status.modified or status.added or status.removed or renamed or
6228 copied or subs):
6242 copied or subs):
6229 t += _(' (clean)')
6243 t += _(' (clean)')
6230 cleanworkdir = True
6244 cleanworkdir = True
6231 elif pnode not in bheads:
6245 elif pnode not in bheads:
6232 t += _(' (new branch head)')
6246 t += _(' (new branch head)')
6233
6247
6234 if parents:
6248 if parents:
6235 pendingphase = max(p.phase() for p in parents)
6249 pendingphase = max(p.phase() for p in parents)
6236 else:
6250 else:
6237 pendingphase = phases.public
6251 pendingphase = phases.public
6238
6252
6239 if pendingphase > phases.newcommitphase(ui):
6253 if pendingphase > phases.newcommitphase(ui):
6240 t += ' (%s)' % phases.phasenames[pendingphase]
6254 t += ' (%s)' % phases.phasenames[pendingphase]
6241
6255
6242 if cleanworkdir:
6256 if cleanworkdir:
6243 # i18n: column positioning for "hg summary"
6257 # i18n: column positioning for "hg summary"
6244 ui.status(_('commit: %s\n') % t.strip())
6258 ui.status(_('commit: %s\n') % t.strip())
6245 else:
6259 else:
6246 # i18n: column positioning for "hg summary"
6260 # i18n: column positioning for "hg summary"
6247 ui.write(_('commit: %s\n') % t.strip())
6261 ui.write(_('commit: %s\n') % t.strip())
6248
6262
6249 # all ancestors of branch heads - all ancestors of parent = new csets
6263 # all ancestors of branch heads - all ancestors of parent = new csets
6250 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6264 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6251 bheads))
6265 bheads))
6252
6266
6253 if new == 0:
6267 if new == 0:
6254 # i18n: column positioning for "hg summary"
6268 # i18n: column positioning for "hg summary"
6255 ui.status(_('update: (current)\n'))
6269 ui.status(_('update: (current)\n'))
6256 elif pnode not in bheads:
6270 elif pnode not in bheads:
6257 # i18n: column positioning for "hg summary"
6271 # i18n: column positioning for "hg summary"
6258 ui.write(_('update: %d new changesets (update)\n') % new)
6272 ui.write(_('update: %d new changesets (update)\n') % new)
6259 else:
6273 else:
6260 # i18n: column positioning for "hg summary"
6274 # i18n: column positioning for "hg summary"
6261 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6275 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6262 (new, len(bheads)))
6276 (new, len(bheads)))
6263
6277
6264 t = []
6278 t = []
6265 draft = len(repo.revs('draft()'))
6279 draft = len(repo.revs('draft()'))
6266 if draft:
6280 if draft:
6267 t.append(_('%d draft') % draft)
6281 t.append(_('%d draft') % draft)
6268 secret = len(repo.revs('secret()'))
6282 secret = len(repo.revs('secret()'))
6269 if secret:
6283 if secret:
6270 t.append(_('%d secret') % secret)
6284 t.append(_('%d secret') % secret)
6271
6285
6272 if draft or secret:
6286 if draft or secret:
6273 ui.status(_('phases: %s\n') % ', '.join(t))
6287 ui.status(_('phases: %s\n') % ', '.join(t))
6274
6288
6275 cmdutil.summaryhooks(ui, repo)
6289 cmdutil.summaryhooks(ui, repo)
6276
6290
6277 if opts.get('remote'):
6291 if opts.get('remote'):
6278 needsincoming, needsoutgoing = True, True
6292 needsincoming, needsoutgoing = True, True
6279 else:
6293 else:
6280 needsincoming, needsoutgoing = False, False
6294 needsincoming, needsoutgoing = False, False
6281 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6295 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6282 if i:
6296 if i:
6283 needsincoming = True
6297 needsincoming = True
6284 if o:
6298 if o:
6285 needsoutgoing = True
6299 needsoutgoing = True
6286 if not needsincoming and not needsoutgoing:
6300 if not needsincoming and not needsoutgoing:
6287 return
6301 return
6288
6302
6289 def getincoming():
6303 def getincoming():
6290 source, branches = hg.parseurl(ui.expandpath('default'))
6304 source, branches = hg.parseurl(ui.expandpath('default'))
6291 sbranch = branches[0]
6305 sbranch = branches[0]
6292 try:
6306 try:
6293 other = hg.peer(repo, {}, source)
6307 other = hg.peer(repo, {}, source)
6294 except error.RepoError:
6308 except error.RepoError:
6295 if opts.get('remote'):
6309 if opts.get('remote'):
6296 raise
6310 raise
6297 return source, sbranch, None, None, None
6311 return source, sbranch, None, None, None
6298 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6312 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6299 if revs:
6313 if revs:
6300 revs = [other.lookup(rev) for rev in revs]
6314 revs = [other.lookup(rev) for rev in revs]
6301 ui.debug('comparing with %s\n' % util.hidepassword(source))
6315 ui.debug('comparing with %s\n' % util.hidepassword(source))
6302 repo.ui.pushbuffer()
6316 repo.ui.pushbuffer()
6303 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6317 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6304 repo.ui.popbuffer()
6318 repo.ui.popbuffer()
6305 return source, sbranch, other, commoninc, commoninc[1]
6319 return source, sbranch, other, commoninc, commoninc[1]
6306
6320
6307 if needsincoming:
6321 if needsincoming:
6308 source, sbranch, sother, commoninc, incoming = getincoming()
6322 source, sbranch, sother, commoninc, incoming = getincoming()
6309 else:
6323 else:
6310 source = sbranch = sother = commoninc = incoming = None
6324 source = sbranch = sother = commoninc = incoming = None
6311
6325
6312 def getoutgoing():
6326 def getoutgoing():
6313 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6327 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6314 dbranch = branches[0]
6328 dbranch = branches[0]
6315 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6329 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6316 if source != dest:
6330 if source != dest:
6317 try:
6331 try:
6318 dother = hg.peer(repo, {}, dest)
6332 dother = hg.peer(repo, {}, dest)
6319 except error.RepoError:
6333 except error.RepoError:
6320 if opts.get('remote'):
6334 if opts.get('remote'):
6321 raise
6335 raise
6322 return dest, dbranch, None, None
6336 return dest, dbranch, None, None
6323 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6337 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6324 elif sother is None:
6338 elif sother is None:
6325 # there is no explicit destination peer, but source one is invalid
6339 # there is no explicit destination peer, but source one is invalid
6326 return dest, dbranch, None, None
6340 return dest, dbranch, None, None
6327 else:
6341 else:
6328 dother = sother
6342 dother = sother
6329 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6343 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6330 common = None
6344 common = None
6331 else:
6345 else:
6332 common = commoninc
6346 common = commoninc
6333 if revs:
6347 if revs:
6334 revs = [repo.lookup(rev) for rev in revs]
6348 revs = [repo.lookup(rev) for rev in revs]
6335 repo.ui.pushbuffer()
6349 repo.ui.pushbuffer()
6336 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6350 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6337 commoninc=common)
6351 commoninc=common)
6338 repo.ui.popbuffer()
6352 repo.ui.popbuffer()
6339 return dest, dbranch, dother, outgoing
6353 return dest, dbranch, dother, outgoing
6340
6354
6341 if needsoutgoing:
6355 if needsoutgoing:
6342 dest, dbranch, dother, outgoing = getoutgoing()
6356 dest, dbranch, dother, outgoing = getoutgoing()
6343 else:
6357 else:
6344 dest = dbranch = dother = outgoing = None
6358 dest = dbranch = dother = outgoing = None
6345
6359
6346 if opts.get('remote'):
6360 if opts.get('remote'):
6347 t = []
6361 t = []
6348 if incoming:
6362 if incoming:
6349 t.append(_('1 or more incoming'))
6363 t.append(_('1 or more incoming'))
6350 o = outgoing.missing
6364 o = outgoing.missing
6351 if o:
6365 if o:
6352 t.append(_('%d outgoing') % len(o))
6366 t.append(_('%d outgoing') % len(o))
6353 other = dother or sother
6367 other = dother or sother
6354 if 'bookmarks' in other.listkeys('namespaces'):
6368 if 'bookmarks' in other.listkeys('namespaces'):
6355 counts = bookmarks.summary(repo, other)
6369 counts = bookmarks.summary(repo, other)
6356 if counts[0] > 0:
6370 if counts[0] > 0:
6357 t.append(_('%d incoming bookmarks') % counts[0])
6371 t.append(_('%d incoming bookmarks') % counts[0])
6358 if counts[1] > 0:
6372 if counts[1] > 0:
6359 t.append(_('%d outgoing bookmarks') % counts[1])
6373 t.append(_('%d outgoing bookmarks') % counts[1])
6360
6374
6361 if t:
6375 if t:
6362 # i18n: column positioning for "hg summary"
6376 # i18n: column positioning for "hg summary"
6363 ui.write(_('remote: %s\n') % (', '.join(t)))
6377 ui.write(_('remote: %s\n') % (', '.join(t)))
6364 else:
6378 else:
6365 # i18n: column positioning for "hg summary"
6379 # i18n: column positioning for "hg summary"
6366 ui.status(_('remote: (synced)\n'))
6380 ui.status(_('remote: (synced)\n'))
6367
6381
6368 cmdutil.summaryremotehooks(ui, repo, opts,
6382 cmdutil.summaryremotehooks(ui, repo, opts,
6369 ((source, sbranch, sother, commoninc),
6383 ((source, sbranch, sother, commoninc),
6370 (dest, dbranch, dother, outgoing)))
6384 (dest, dbranch, dother, outgoing)))
6371
6385
6372 @command('tag',
6386 @command('tag',
6373 [('f', 'force', None, _('force tag')),
6387 [('f', 'force', None, _('force tag')),
6374 ('l', 'local', None, _('make the tag local')),
6388 ('l', 'local', None, _('make the tag local')),
6375 ('r', 'rev', '', _('revision to tag'), _('REV')),
6389 ('r', 'rev', '', _('revision to tag'), _('REV')),
6376 ('', 'remove', None, _('remove a tag')),
6390 ('', 'remove', None, _('remove a tag')),
6377 # -l/--local is already there, commitopts cannot be used
6391 # -l/--local is already there, commitopts cannot be used
6378 ('e', 'edit', None, _('invoke editor on commit messages')),
6392 ('e', 'edit', None, _('invoke editor on commit messages')),
6379 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6393 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6380 ] + commitopts2,
6394 ] + commitopts2,
6381 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6395 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6382 def tag(ui, repo, name1, *names, **opts):
6396 def tag(ui, repo, name1, *names, **opts):
6383 """add one or more tags for the current or given revision
6397 """add one or more tags for the current or given revision
6384
6398
6385 Name a particular revision using <name>.
6399 Name a particular revision using <name>.
6386
6400
6387 Tags are used to name particular revisions of the repository and are
6401 Tags are used to name particular revisions of the repository and are
6388 very useful to compare different revisions, to go back to significant
6402 very useful to compare different revisions, to go back to significant
6389 earlier versions or to mark branch points as releases, etc. Changing
6403 earlier versions or to mark branch points as releases, etc. Changing
6390 an existing tag is normally disallowed; use -f/--force to override.
6404 an existing tag is normally disallowed; use -f/--force to override.
6391
6405
6392 If no revision is given, the parent of the working directory is
6406 If no revision is given, the parent of the working directory is
6393 used.
6407 used.
6394
6408
6395 To facilitate version control, distribution, and merging of tags,
6409 To facilitate version control, distribution, and merging of tags,
6396 they are stored as a file named ".hgtags" which is managed similarly
6410 they are stored as a file named ".hgtags" which is managed similarly
6397 to other project files and can be hand-edited if necessary. This
6411 to other project files and can be hand-edited if necessary. This
6398 also means that tagging creates a new commit. The file
6412 also means that tagging creates a new commit. The file
6399 ".hg/localtags" is used for local tags (not shared among
6413 ".hg/localtags" is used for local tags (not shared among
6400 repositories).
6414 repositories).
6401
6415
6402 Tag commits are usually made at the head of a branch. If the parent
6416 Tag commits are usually made at the head of a branch. If the parent
6403 of the working directory is not a branch head, :hg:`tag` aborts; use
6417 of the working directory is not a branch head, :hg:`tag` aborts; use
6404 -f/--force to force the tag commit to be based on a non-head
6418 -f/--force to force the tag commit to be based on a non-head
6405 changeset.
6419 changeset.
6406
6420
6407 See :hg:`help dates` for a list of formats valid for -d/--date.
6421 See :hg:`help dates` for a list of formats valid for -d/--date.
6408
6422
6409 Since tag names have priority over branch names during revision
6423 Since tag names have priority over branch names during revision
6410 lookup, using an existing branch name as a tag name is discouraged.
6424 lookup, using an existing branch name as a tag name is discouraged.
6411
6425
6412 Returns 0 on success.
6426 Returns 0 on success.
6413 """
6427 """
6414 wlock = lock = None
6428 wlock = lock = None
6415 try:
6429 try:
6416 wlock = repo.wlock()
6430 wlock = repo.wlock()
6417 lock = repo.lock()
6431 lock = repo.lock()
6418 rev_ = "."
6432 rev_ = "."
6419 names = [t.strip() for t in (name1,) + names]
6433 names = [t.strip() for t in (name1,) + names]
6420 if len(names) != len(set(names)):
6434 if len(names) != len(set(names)):
6421 raise error.Abort(_('tag names must be unique'))
6435 raise error.Abort(_('tag names must be unique'))
6422 for n in names:
6436 for n in names:
6423 scmutil.checknewlabel(repo, n, 'tag')
6437 scmutil.checknewlabel(repo, n, 'tag')
6424 if not n:
6438 if not n:
6425 raise error.Abort(_('tag names cannot consist entirely of '
6439 raise error.Abort(_('tag names cannot consist entirely of '
6426 'whitespace'))
6440 'whitespace'))
6427 if opts.get('rev') and opts.get('remove'):
6441 if opts.get('rev') and opts.get('remove'):
6428 raise error.Abort(_("--rev and --remove are incompatible"))
6442 raise error.Abort(_("--rev and --remove are incompatible"))
6429 if opts.get('rev'):
6443 if opts.get('rev'):
6430 rev_ = opts['rev']
6444 rev_ = opts['rev']
6431 message = opts.get('message')
6445 message = opts.get('message')
6432 if opts.get('remove'):
6446 if opts.get('remove'):
6433 if opts.get('local'):
6447 if opts.get('local'):
6434 expectedtype = 'local'
6448 expectedtype = 'local'
6435 else:
6449 else:
6436 expectedtype = 'global'
6450 expectedtype = 'global'
6437
6451
6438 for n in names:
6452 for n in names:
6439 if not repo.tagtype(n):
6453 if not repo.tagtype(n):
6440 raise error.Abort(_("tag '%s' does not exist") % n)
6454 raise error.Abort(_("tag '%s' does not exist") % n)
6441 if repo.tagtype(n) != expectedtype:
6455 if repo.tagtype(n) != expectedtype:
6442 if expectedtype == 'global':
6456 if expectedtype == 'global':
6443 raise error.Abort(_("tag '%s' is not a global tag") % n)
6457 raise error.Abort(_("tag '%s' is not a global tag") % n)
6444 else:
6458 else:
6445 raise error.Abort(_("tag '%s' is not a local tag") % n)
6459 raise error.Abort(_("tag '%s' is not a local tag") % n)
6446 rev_ = 'null'
6460 rev_ = 'null'
6447 if not message:
6461 if not message:
6448 # we don't translate commit messages
6462 # we don't translate commit messages
6449 message = 'Removed tag %s' % ', '.join(names)
6463 message = 'Removed tag %s' % ', '.join(names)
6450 elif not opts.get('force'):
6464 elif not opts.get('force'):
6451 for n in names:
6465 for n in names:
6452 if n in repo.tags():
6466 if n in repo.tags():
6453 raise error.Abort(_("tag '%s' already exists "
6467 raise error.Abort(_("tag '%s' already exists "
6454 "(use -f to force)") % n)
6468 "(use -f to force)") % n)
6455 if not opts.get('local'):
6469 if not opts.get('local'):
6456 p1, p2 = repo.dirstate.parents()
6470 p1, p2 = repo.dirstate.parents()
6457 if p2 != nullid:
6471 if p2 != nullid:
6458 raise error.Abort(_('uncommitted merge'))
6472 raise error.Abort(_('uncommitted merge'))
6459 bheads = repo.branchheads()
6473 bheads = repo.branchheads()
6460 if not opts.get('force') and bheads and p1 not in bheads:
6474 if not opts.get('force') and bheads and p1 not in bheads:
6461 raise error.Abort(_('not at a branch head (use -f to force)'))
6475 raise error.Abort(_('not at a branch head (use -f to force)'))
6462 r = scmutil.revsingle(repo, rev_).node()
6476 r = scmutil.revsingle(repo, rev_).node()
6463
6477
6464 if not message:
6478 if not message:
6465 # we don't translate commit messages
6479 # we don't translate commit messages
6466 message = ('Added tag %s for changeset %s' %
6480 message = ('Added tag %s for changeset %s' %
6467 (', '.join(names), short(r)))
6481 (', '.join(names), short(r)))
6468
6482
6469 date = opts.get('date')
6483 date = opts.get('date')
6470 if date:
6484 if date:
6471 date = util.parsedate(date)
6485 date = util.parsedate(date)
6472
6486
6473 if opts.get('remove'):
6487 if opts.get('remove'):
6474 editform = 'tag.remove'
6488 editform = 'tag.remove'
6475 else:
6489 else:
6476 editform = 'tag.add'
6490 editform = 'tag.add'
6477 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6491 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6478
6492
6479 # don't allow tagging the null rev
6493 # don't allow tagging the null rev
6480 if (not opts.get('remove') and
6494 if (not opts.get('remove') and
6481 scmutil.revsingle(repo, rev_).rev() == nullrev):
6495 scmutil.revsingle(repo, rev_).rev() == nullrev):
6482 raise error.Abort(_("cannot tag null revision"))
6496 raise error.Abort(_("cannot tag null revision"))
6483
6497
6484 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6498 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6485 editor=editor)
6499 editor=editor)
6486 finally:
6500 finally:
6487 release(lock, wlock)
6501 release(lock, wlock)
6488
6502
6489 @command('tags', formatteropts, '')
6503 @command('tags', formatteropts, '')
6490 def tags(ui, repo, **opts):
6504 def tags(ui, repo, **opts):
6491 """list repository tags
6505 """list repository tags
6492
6506
6493 This lists both regular and local tags. When the -v/--verbose
6507 This lists both regular and local tags. When the -v/--verbose
6494 switch is used, a third column "local" is printed for local tags.
6508 switch is used, a third column "local" is printed for local tags.
6495
6509
6496 Returns 0 on success.
6510 Returns 0 on success.
6497 """
6511 """
6498
6512
6499 fm = ui.formatter('tags', opts)
6513 fm = ui.formatter('tags', opts)
6500 hexfunc = fm.hexfunc
6514 hexfunc = fm.hexfunc
6501 tagtype = ""
6515 tagtype = ""
6502
6516
6503 for t, n in reversed(repo.tagslist()):
6517 for t, n in reversed(repo.tagslist()):
6504 hn = hexfunc(n)
6518 hn = hexfunc(n)
6505 label = 'tags.normal'
6519 label = 'tags.normal'
6506 tagtype = ''
6520 tagtype = ''
6507 if repo.tagtype(t) == 'local':
6521 if repo.tagtype(t) == 'local':
6508 label = 'tags.local'
6522 label = 'tags.local'
6509 tagtype = 'local'
6523 tagtype = 'local'
6510
6524
6511 fm.startitem()
6525 fm.startitem()
6512 fm.write('tag', '%s', t, label=label)
6526 fm.write('tag', '%s', t, label=label)
6513 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6527 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6514 fm.condwrite(not ui.quiet, 'rev node', fmt,
6528 fm.condwrite(not ui.quiet, 'rev node', fmt,
6515 repo.changelog.rev(n), hn, label=label)
6529 repo.changelog.rev(n), hn, label=label)
6516 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6530 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6517 tagtype, label=label)
6531 tagtype, label=label)
6518 fm.plain('\n')
6532 fm.plain('\n')
6519 fm.end()
6533 fm.end()
6520
6534
6521 @command('tip',
6535 @command('tip',
6522 [('p', 'patch', None, _('show patch')),
6536 [('p', 'patch', None, _('show patch')),
6523 ('g', 'git', None, _('use git extended diff format')),
6537 ('g', 'git', None, _('use git extended diff format')),
6524 ] + templateopts,
6538 ] + templateopts,
6525 _('[-p] [-g]'))
6539 _('[-p] [-g]'))
6526 def tip(ui, repo, **opts):
6540 def tip(ui, repo, **opts):
6527 """show the tip revision (DEPRECATED)
6541 """show the tip revision (DEPRECATED)
6528
6542
6529 The tip revision (usually just called the tip) is the changeset
6543 The tip revision (usually just called the tip) is the changeset
6530 most recently added to the repository (and therefore the most
6544 most recently added to the repository (and therefore the most
6531 recently changed head).
6545 recently changed head).
6532
6546
6533 If you have just made a commit, that commit will be the tip. If
6547 If you have just made a commit, that commit will be the tip. If
6534 you have just pulled changes from another repository, the tip of
6548 you have just pulled changes from another repository, the tip of
6535 that repository becomes the current tip. The "tip" tag is special
6549 that repository becomes the current tip. The "tip" tag is special
6536 and cannot be renamed or assigned to a different changeset.
6550 and cannot be renamed or assigned to a different changeset.
6537
6551
6538 This command is deprecated, please use :hg:`heads` instead.
6552 This command is deprecated, please use :hg:`heads` instead.
6539
6553
6540 Returns 0 on success.
6554 Returns 0 on success.
6541 """
6555 """
6542 displayer = cmdutil.show_changeset(ui, repo, opts)
6556 displayer = cmdutil.show_changeset(ui, repo, opts)
6543 displayer.show(repo['tip'])
6557 displayer.show(repo['tip'])
6544 displayer.close()
6558 displayer.close()
6545
6559
6546 @command('unbundle',
6560 @command('unbundle',
6547 [('u', 'update', None,
6561 [('u', 'update', None,
6548 _('update to new branch head if changesets were unbundled'))],
6562 _('update to new branch head if changesets were unbundled'))],
6549 _('[-u] FILE...'))
6563 _('[-u] FILE...'))
6550 def unbundle(ui, repo, fname1, *fnames, **opts):
6564 def unbundle(ui, repo, fname1, *fnames, **opts):
6551 """apply one or more changegroup files
6565 """apply one or more changegroup files
6552
6566
6553 Apply one or more compressed changegroup files generated by the
6567 Apply one or more compressed changegroup files generated by the
6554 bundle command.
6568 bundle command.
6555
6569
6556 Returns 0 on success, 1 if an update has unresolved files.
6570 Returns 0 on success, 1 if an update has unresolved files.
6557 """
6571 """
6558 fnames = (fname1,) + fnames
6572 fnames = (fname1,) + fnames
6559
6573
6560 lock = repo.lock()
6574 lock = repo.lock()
6561 try:
6575 try:
6562 for fname in fnames:
6576 for fname in fnames:
6563 f = hg.openpath(ui, fname)
6577 f = hg.openpath(ui, fname)
6564 gen = exchange.readbundle(ui, f, fname)
6578 gen = exchange.readbundle(ui, f, fname)
6565 if isinstance(gen, bundle2.unbundle20):
6579 if isinstance(gen, bundle2.unbundle20):
6566 tr = repo.transaction('unbundle')
6580 tr = repo.transaction('unbundle')
6567 try:
6581 try:
6568 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
6582 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
6569 url='bundle:' + fname)
6583 url='bundle:' + fname)
6570 tr.close()
6584 tr.close()
6571 except error.BundleUnknownFeatureError as exc:
6585 except error.BundleUnknownFeatureError as exc:
6572 raise error.Abort(_('%s: unknown bundle feature, %s')
6586 raise error.Abort(_('%s: unknown bundle feature, %s')
6573 % (fname, exc),
6587 % (fname, exc),
6574 hint=_("see https://mercurial-scm.org/"
6588 hint=_("see https://mercurial-scm.org/"
6575 "wiki/BundleFeature for more "
6589 "wiki/BundleFeature for more "
6576 "information"))
6590 "information"))
6577 finally:
6591 finally:
6578 if tr:
6592 if tr:
6579 tr.release()
6593 tr.release()
6580 changes = [r.get('return', 0)
6594 changes = [r.get('return', 0)
6581 for r in op.records['changegroup']]
6595 for r in op.records['changegroup']]
6582 modheads = changegroup.combineresults(changes)
6596 modheads = changegroup.combineresults(changes)
6583 elif isinstance(gen, streamclone.streamcloneapplier):
6597 elif isinstance(gen, streamclone.streamcloneapplier):
6584 raise error.Abort(
6598 raise error.Abort(
6585 _('packed bundles cannot be applied with '
6599 _('packed bundles cannot be applied with '
6586 '"hg unbundle"'),
6600 '"hg unbundle"'),
6587 hint=_('use "hg debugapplystreamclonebundle"'))
6601 hint=_('use "hg debugapplystreamclonebundle"'))
6588 else:
6602 else:
6589 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6603 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6590 finally:
6604 finally:
6591 lock.release()
6605 lock.release()
6592
6606
6593 return postincoming(ui, repo, modheads, opts.get('update'), None)
6607 return postincoming(ui, repo, modheads, opts.get('update'), None)
6594
6608
6595 @command('^update|up|checkout|co',
6609 @command('^update|up|checkout|co',
6596 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6610 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6597 ('c', 'check', None,
6611 ('c', 'check', None,
6598 _('update across branches if no uncommitted changes')),
6612 _('update across branches if no uncommitted changes')),
6599 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6613 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6600 ('r', 'rev', '', _('revision'), _('REV'))
6614 ('r', 'rev', '', _('revision'), _('REV'))
6601 ] + mergetoolopts,
6615 ] + mergetoolopts,
6602 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6616 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6603 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6617 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6604 tool=None):
6618 tool=None):
6605 """update working directory (or switch revisions)
6619 """update working directory (or switch revisions)
6606
6620
6607 Update the repository's working directory to the specified
6621 Update the repository's working directory to the specified
6608 changeset. If no changeset is specified, update to the tip of the
6622 changeset. If no changeset is specified, update to the tip of the
6609 current named branch and move the active bookmark (see :hg:`help
6623 current named branch and move the active bookmark (see :hg:`help
6610 bookmarks`).
6624 bookmarks`).
6611
6625
6612 Update sets the working directory's parent revision to the specified
6626 Update sets the working directory's parent revision to the specified
6613 changeset (see :hg:`help parents`).
6627 changeset (see :hg:`help parents`).
6614
6628
6615 If the changeset is not a descendant or ancestor of the working
6629 If the changeset is not a descendant or ancestor of the working
6616 directory's parent, the update is aborted. With the -c/--check
6630 directory's parent, the update is aborted. With the -c/--check
6617 option, the working directory is checked for uncommitted changes; if
6631 option, the working directory is checked for uncommitted changes; if
6618 none are found, the working directory is updated to the specified
6632 none are found, the working directory is updated to the specified
6619 changeset.
6633 changeset.
6620
6634
6621 .. container:: verbose
6635 .. container:: verbose
6622
6636
6623 The following rules apply when the working directory contains
6637 The following rules apply when the working directory contains
6624 uncommitted changes:
6638 uncommitted changes:
6625
6639
6626 1. If neither -c/--check nor -C/--clean is specified, and if
6640 1. If neither -c/--check nor -C/--clean is specified, and if
6627 the requested changeset is an ancestor or descendant of
6641 the requested changeset is an ancestor or descendant of
6628 the working directory's parent, the uncommitted changes
6642 the working directory's parent, the uncommitted changes
6629 are merged into the requested changeset and the merged
6643 are merged into the requested changeset and the merged
6630 result is left uncommitted. If the requested changeset is
6644 result is left uncommitted. If the requested changeset is
6631 not an ancestor or descendant (that is, it is on another
6645 not an ancestor or descendant (that is, it is on another
6632 branch), the update is aborted and the uncommitted changes
6646 branch), the update is aborted and the uncommitted changes
6633 are preserved.
6647 are preserved.
6634
6648
6635 2. With the -c/--check option, the update is aborted and the
6649 2. With the -c/--check option, the update is aborted and the
6636 uncommitted changes are preserved.
6650 uncommitted changes are preserved.
6637
6651
6638 3. With the -C/--clean option, uncommitted changes are discarded and
6652 3. With the -C/--clean option, uncommitted changes are discarded and
6639 the working directory is updated to the requested changeset.
6653 the working directory is updated to the requested changeset.
6640
6654
6641 To cancel an uncommitted merge (and lose your changes), use
6655 To cancel an uncommitted merge (and lose your changes), use
6642 :hg:`update --clean .`.
6656 :hg:`update --clean .`.
6643
6657
6644 Use null as the changeset to remove the working directory (like
6658 Use null as the changeset to remove the working directory (like
6645 :hg:`clone -U`).
6659 :hg:`clone -U`).
6646
6660
6647 If you want to revert just one file to an older revision, use
6661 If you want to revert just one file to an older revision, use
6648 :hg:`revert [-r REV] NAME`.
6662 :hg:`revert [-r REV] NAME`.
6649
6663
6650 See :hg:`help dates` for a list of formats valid for -d/--date.
6664 See :hg:`help dates` for a list of formats valid for -d/--date.
6651
6665
6652 Returns 0 on success, 1 if there are unresolved files.
6666 Returns 0 on success, 1 if there are unresolved files.
6653 """
6667 """
6654 movemarkfrom = None
6668 movemarkfrom = None
6655 if rev and node:
6669 if rev and node:
6656 raise error.Abort(_("please specify just one revision"))
6670 raise error.Abort(_("please specify just one revision"))
6657
6671
6658 if rev is None or rev == '':
6672 if rev is None or rev == '':
6659 rev = node
6673 rev = node
6660
6674
6661 wlock = repo.wlock()
6675 wlock = repo.wlock()
6662 try:
6676 try:
6663 cmdutil.clearunfinished(repo)
6677 cmdutil.clearunfinished(repo)
6664
6678
6665 if date:
6679 if date:
6666 if rev is not None:
6680 if rev is not None:
6667 raise error.Abort(_("you can't specify a revision and a date"))
6681 raise error.Abort(_("you can't specify a revision and a date"))
6668 rev = cmdutil.finddate(ui, repo, date)
6682 rev = cmdutil.finddate(ui, repo, date)
6669
6683
6670 # if we defined a bookmark, we have to remember the original name
6684 # if we defined a bookmark, we have to remember the original name
6671 brev = rev
6685 brev = rev
6672 rev = scmutil.revsingle(repo, rev, rev).rev()
6686 rev = scmutil.revsingle(repo, rev, rev).rev()
6673
6687
6674 if check and clean:
6688 if check and clean:
6675 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6689 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6676 )
6690 )
6677
6691
6678 if check:
6692 if check:
6679 cmdutil.bailifchanged(repo, merge=False)
6693 cmdutil.bailifchanged(repo, merge=False)
6680 if rev is None:
6694 if rev is None:
6681 updata = destutil.destupdate(repo, clean=clean, check=check)
6695 updata = destutil.destupdate(repo, clean=clean, check=check)
6682 rev, movemarkfrom, brev = updata
6696 rev, movemarkfrom, brev = updata
6683
6697
6684 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6698 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6685
6699
6686 if clean:
6700 if clean:
6687 ret = hg.clean(repo, rev)
6701 ret = hg.clean(repo, rev)
6688 else:
6702 else:
6689 ret = hg.update(repo, rev)
6703 ret = hg.update(repo, rev)
6690
6704
6691 if not ret and movemarkfrom:
6705 if not ret and movemarkfrom:
6692 if movemarkfrom == repo['.'].node():
6706 if movemarkfrom == repo['.'].node():
6693 pass # no-op update
6707 pass # no-op update
6694 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6708 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6695 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6709 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6696 else:
6710 else:
6697 # this can happen with a non-linear update
6711 # this can happen with a non-linear update
6698 ui.status(_("(leaving bookmark %s)\n") %
6712 ui.status(_("(leaving bookmark %s)\n") %
6699 repo._activebookmark)
6713 repo._activebookmark)
6700 bookmarks.deactivate(repo)
6714 bookmarks.deactivate(repo)
6701 elif brev in repo._bookmarks:
6715 elif brev in repo._bookmarks:
6702 bookmarks.activate(repo, brev)
6716 bookmarks.activate(repo, brev)
6703 ui.status(_("(activating bookmark %s)\n") % brev)
6717 ui.status(_("(activating bookmark %s)\n") % brev)
6704 elif brev:
6718 elif brev:
6705 if repo._activebookmark:
6719 if repo._activebookmark:
6706 ui.status(_("(leaving bookmark %s)\n") %
6720 ui.status(_("(leaving bookmark %s)\n") %
6707 repo._activebookmark)
6721 repo._activebookmark)
6708 bookmarks.deactivate(repo)
6722 bookmarks.deactivate(repo)
6709 finally:
6723 finally:
6710 wlock.release()
6724 wlock.release()
6711
6725
6712 return ret
6726 return ret
6713
6727
6714 @command('verify', [])
6728 @command('verify', [])
6715 def verify(ui, repo):
6729 def verify(ui, repo):
6716 """verify the integrity of the repository
6730 """verify the integrity of the repository
6717
6731
6718 Verify the integrity of the current repository.
6732 Verify the integrity of the current repository.
6719
6733
6720 This will perform an extensive check of the repository's
6734 This will perform an extensive check of the repository's
6721 integrity, validating the hashes and checksums of each entry in
6735 integrity, validating the hashes and checksums of each entry in
6722 the changelog, manifest, and tracked files, as well as the
6736 the changelog, manifest, and tracked files, as well as the
6723 integrity of their crosslinks and indices.
6737 integrity of their crosslinks and indices.
6724
6738
6725 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6739 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6726 for more information about recovery from corruption of the
6740 for more information about recovery from corruption of the
6727 repository.
6741 repository.
6728
6742
6729 Returns 0 on success, 1 if errors are encountered.
6743 Returns 0 on success, 1 if errors are encountered.
6730 """
6744 """
6731 return hg.verify(repo)
6745 return hg.verify(repo)
6732
6746
6733 @command('version', [], norepo=True)
6747 @command('version', [], norepo=True)
6734 def version_(ui):
6748 def version_(ui):
6735 """output version and copyright information"""
6749 """output version and copyright information"""
6736 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6750 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6737 % util.version())
6751 % util.version())
6738 ui.status(_(
6752 ui.status(_(
6739 "(see https://mercurial-scm.org for more information)\n"
6753 "(see https://mercurial-scm.org for more information)\n"
6740 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6754 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6741 "This is free software; see the source for copying conditions. "
6755 "This is free software; see the source for copying conditions. "
6742 "There is NO\nwarranty; "
6756 "There is NO\nwarranty; "
6743 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6757 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6744 ))
6758 ))
6745
6759
6746 ui.note(_("\nEnabled extensions:\n\n"))
6760 ui.note(_("\nEnabled extensions:\n\n"))
6747 if ui.verbose:
6761 if ui.verbose:
6748 # format names and versions into columns
6762 # format names and versions into columns
6749 names = []
6763 names = []
6750 vers = []
6764 vers = []
6751 for name, module in extensions.extensions():
6765 for name, module in extensions.extensions():
6752 names.append(name)
6766 names.append(name)
6753 vers.append(extensions.moduleversion(module))
6767 vers.append(extensions.moduleversion(module))
6754 if names:
6768 if names:
6755 maxnamelen = max(len(n) for n in names)
6769 maxnamelen = max(len(n) for n in names)
6756 for i, name in enumerate(names):
6770 for i, name in enumerate(names):
6757 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
6771 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,2386 +1,2413 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge another revision into working directory
17 merge merge another revision into working directory
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use "hg help" for the full list of commands or "hg -v" for details)
26 (use "hg help" for the full list of commands or "hg -v" for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge another revision into working directory
38 merge merge another revision into working directory
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working directory or specified revision
75 identify identify the working directory or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge another revision into working directory
81 merge merge another revision into working directory
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 merge-tools Merge Tools
114 merge-tools Merge Tools
115 multirevs Specifying Multiple Revisions
115 multirevs Specifying Multiple Revisions
116 patterns File Name Patterns
116 patterns File Name Patterns
117 phases Working with Phases
117 phases Working with Phases
118 revisions Specifying Single Revisions
118 revisions Specifying Single Revisions
119 revsets Specifying Revision Sets
119 revsets Specifying Revision Sets
120 scripting Using Mercurial from scripts and automation
120 scripting Using Mercurial from scripts and automation
121 subrepos Subrepositories
121 subrepos Subrepositories
122 templating Template Usage
122 templating Template Usage
123 urls URL Paths
123 urls URL Paths
124
124
125 (use "hg help -v" to show built-in aliases and global options)
125 (use "hg help -v" to show built-in aliases and global options)
126
126
127 $ hg -q help
127 $ hg -q help
128 add add the specified files on the next commit
128 add add the specified files on the next commit
129 addremove add all new files, delete all missing files
129 addremove add all new files, delete all missing files
130 annotate show changeset information by line for each file
130 annotate show changeset information by line for each file
131 archive create an unversioned archive of a repository revision
131 archive create an unversioned archive of a repository revision
132 backout reverse effect of earlier changeset
132 backout reverse effect of earlier changeset
133 bisect subdivision search of changesets
133 bisect subdivision search of changesets
134 bookmarks create a new bookmark or list existing bookmarks
134 bookmarks create a new bookmark or list existing bookmarks
135 branch set or show the current branch name
135 branch set or show the current branch name
136 branches list repository named branches
136 branches list repository named branches
137 bundle create a changegroup file
137 bundle create a changegroup file
138 cat output the current or given revision of files
138 cat output the current or given revision of files
139 clone make a copy of an existing repository
139 clone make a copy of an existing repository
140 commit commit the specified files or all outstanding changes
140 commit commit the specified files or all outstanding changes
141 config show combined config settings from all hgrc files
141 config show combined config settings from all hgrc files
142 copy mark files as copied for the next commit
142 copy mark files as copied for the next commit
143 diff diff repository (or selected files)
143 diff diff repository (or selected files)
144 export dump the header and diffs for one or more changesets
144 export dump the header and diffs for one or more changesets
145 files list tracked files
145 files list tracked files
146 forget forget the specified files on the next commit
146 forget forget the specified files on the next commit
147 graft copy changes from other branches onto the current branch
147 graft copy changes from other branches onto the current branch
148 grep search for a pattern in specified files and revisions
148 grep search for a pattern in specified files and revisions
149 heads show branch heads
149 heads show branch heads
150 help show help for a given topic or a help overview
150 help show help for a given topic or a help overview
151 identify identify the working directory or specified revision
151 identify identify the working directory or specified revision
152 import import an ordered set of patches
152 import import an ordered set of patches
153 incoming show new changesets found in source
153 incoming show new changesets found in source
154 init create a new repository in the given directory
154 init create a new repository in the given directory
155 log show revision history of entire repository or files
155 log show revision history of entire repository or files
156 manifest output the current or given revision of the project manifest
156 manifest output the current or given revision of the project manifest
157 merge merge another revision into working directory
157 merge merge another revision into working directory
158 outgoing show changesets not found in the destination
158 outgoing show changesets not found in the destination
159 paths show aliases for remote repositories
159 paths show aliases for remote repositories
160 phase set or show the current phase name
160 phase set or show the current phase name
161 pull pull changes from the specified source
161 pull pull changes from the specified source
162 push push changes to the specified destination
162 push push changes to the specified destination
163 recover roll back an interrupted transaction
163 recover roll back an interrupted transaction
164 remove remove the specified files on the next commit
164 remove remove the specified files on the next commit
165 rename rename files; equivalent of copy + remove
165 rename rename files; equivalent of copy + remove
166 resolve redo merges or set/view the merge status of files
166 resolve redo merges or set/view the merge status of files
167 revert restore files to their checkout state
167 revert restore files to their checkout state
168 root print the root (top) of the current working directory
168 root print the root (top) of the current working directory
169 serve start stand-alone webserver
169 serve start stand-alone webserver
170 status show changed files in the working directory
170 status show changed files in the working directory
171 summary summarize working directory state
171 summary summarize working directory state
172 tag add one or more tags for the current or given revision
172 tag add one or more tags for the current or given revision
173 tags list repository tags
173 tags list repository tags
174 unbundle apply one or more changegroup files
174 unbundle apply one or more changegroup files
175 update update working directory (or switch revisions)
175 update update working directory (or switch revisions)
176 verify verify the integrity of the repository
176 verify verify the integrity of the repository
177 version output version and copyright information
177 version output version and copyright information
178
178
179 additional help topics:
179 additional help topics:
180
180
181 config Configuration Files
181 config Configuration Files
182 dates Date Formats
182 dates Date Formats
183 diffs Diff Formats
183 diffs Diff Formats
184 environment Environment Variables
184 environment Environment Variables
185 extensions Using Additional Features
185 extensions Using Additional Features
186 filesets Specifying File Sets
186 filesets Specifying File Sets
187 glossary Glossary
187 glossary Glossary
188 hgignore Syntax for Mercurial Ignore Files
188 hgignore Syntax for Mercurial Ignore Files
189 hgweb Configuring hgweb
189 hgweb Configuring hgweb
190 merge-tools Merge Tools
190 merge-tools Merge Tools
191 multirevs Specifying Multiple Revisions
191 multirevs Specifying Multiple Revisions
192 patterns File Name Patterns
192 patterns File Name Patterns
193 phases Working with Phases
193 phases Working with Phases
194 revisions Specifying Single Revisions
194 revisions Specifying Single Revisions
195 revsets Specifying Revision Sets
195 revsets Specifying Revision Sets
196 scripting Using Mercurial from scripts and automation
196 scripting Using Mercurial from scripts and automation
197 subrepos Subrepositories
197 subrepos Subrepositories
198 templating Template Usage
198 templating Template Usage
199 urls URL Paths
199 urls URL Paths
200
200
201 Test extension help:
201 Test extension help:
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 Using Additional Features
203 Using Additional Features
204 """""""""""""""""""""""""
204 """""""""""""""""""""""""
205
205
206 Mercurial has the ability to add new features through the use of
206 Mercurial has the ability to add new features through the use of
207 extensions. Extensions may add new commands, add options to existing
207 extensions. Extensions may add new commands, add options to existing
208 commands, change the default behavior of commands, or implement hooks.
208 commands, change the default behavior of commands, or implement hooks.
209
209
210 To enable the "foo" extension, either shipped with Mercurial or in the
210 To enable the "foo" extension, either shipped with Mercurial or in the
211 Python search path, create an entry for it in your configuration file,
211 Python search path, create an entry for it in your configuration file,
212 like this:
212 like this:
213
213
214 [extensions]
214 [extensions]
215 foo =
215 foo =
216
216
217 You may also specify the full path to an extension:
217 You may also specify the full path to an extension:
218
218
219 [extensions]
219 [extensions]
220 myfeature = ~/.hgext/myfeature.py
220 myfeature = ~/.hgext/myfeature.py
221
221
222 See "hg help config" for more information on configuration files.
222 See "hg help config" for more information on configuration files.
223
223
224 Extensions are not loaded by default for a variety of reasons: they can
224 Extensions are not loaded by default for a variety of reasons: they can
225 increase startup overhead; they may be meant for advanced usage only; they
225 increase startup overhead; they may be meant for advanced usage only; they
226 may provide potentially dangerous abilities (such as letting you destroy
226 may provide potentially dangerous abilities (such as letting you destroy
227 or modify history); they might not be ready for prime time; or they may
227 or modify history); they might not be ready for prime time; or they may
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 to activate extensions as needed.
229 to activate extensions as needed.
230
230
231 To explicitly disable an extension enabled in a configuration file of
231 To explicitly disable an extension enabled in a configuration file of
232 broader scope, prepend its path with !:
232 broader scope, prepend its path with !:
233
233
234 [extensions]
234 [extensions]
235 # disabling extension bar residing in /path/to/extension/bar.py
235 # disabling extension bar residing in /path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
237 # ditto, but no path was supplied for extension baz
237 # ditto, but no path was supplied for extension baz
238 baz = !
238 baz = !
239
239
240 enabled extensions:
240 enabled extensions:
241
241
242 children command to display child changesets (DEPRECATED)
242 children command to display child changesets (DEPRECATED)
243 rebase command to move sets of revisions to a different ancestor
243 rebase command to move sets of revisions to a different ancestor
244
244
245 disabled extensions:
245 disabled extensions:
246
246
247 acl hooks for controlling repository access
247 acl hooks for controlling repository access
248 blackbox log repository events to a blackbox for debugging
248 blackbox log repository events to a blackbox for debugging
249 bugzilla hooks for integrating with the Bugzilla bug tracker
249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 censor erase file content at a given revision
250 censor erase file content at a given revision
251 churn command to display statistics about repository history
251 churn command to display statistics about repository history
252 clonebundles advertise pre-generated bundles to seed clones
252 clonebundles advertise pre-generated bundles to seed clones
253 (experimental)
253 (experimental)
254 color colorize output from some commands
254 color colorize output from some commands
255 convert import revisions from foreign VCS repositories into
255 convert import revisions from foreign VCS repositories into
256 Mercurial
256 Mercurial
257 eol automatically manage newlines in repository files
257 eol automatically manage newlines in repository files
258 extdiff command to allow external programs to compare revisions
258 extdiff command to allow external programs to compare revisions
259 factotum http authentication with factotum
259 factotum http authentication with factotum
260 gpg commands to sign and verify changesets
260 gpg commands to sign and verify changesets
261 hgcia hooks for integrating with the CIA.vc notification service
261 hgcia hooks for integrating with the CIA.vc notification service
262 hgk browse the repository in a graphical way
262 hgk browse the repository in a graphical way
263 highlight syntax highlighting for hgweb (requires Pygments)
263 highlight syntax highlighting for hgweb (requires Pygments)
264 histedit interactive history editing
264 histedit interactive history editing
265 keyword expand keywords in tracked files
265 keyword expand keywords in tracked files
266 largefiles track large binary files
266 largefiles track large binary files
267 mq manage a stack of patches
267 mq manage a stack of patches
268 notify hooks for sending email push notifications
268 notify hooks for sending email push notifications
269 pager browse command output with an external pager
269 pager browse command output with an external pager
270 patchbomb command to send changesets as (a series of) patch emails
270 patchbomb command to send changesets as (a series of) patch emails
271 purge command to delete untracked files from the working
271 purge command to delete untracked files from the working
272 directory
272 directory
273 record commands to interactively select changes for
273 record commands to interactively select changes for
274 commit/qrefresh
274 commit/qrefresh
275 relink recreates hardlinks between repository clones
275 relink recreates hardlinks between repository clones
276 schemes extend schemes with shortcuts to repository swarms
276 schemes extend schemes with shortcuts to repository swarms
277 share share a common history between several working directories
277 share share a common history between several working directories
278 shelve save and restore changes to the working directory
278 shelve save and restore changes to the working directory
279 strip strip changesets and their descendants from history
279 strip strip changesets and their descendants from history
280 transplant command to transplant changesets from another branch
280 transplant command to transplant changesets from another branch
281 win32mbcs allow the use of MBCS paths with problematic encodings
281 win32mbcs allow the use of MBCS paths with problematic encodings
282 zeroconf discover and advertise repositories on the local network
282 zeroconf discover and advertise repositories on the local network
283
283
284 Verify that extension keywords appear in help templates
284 Verify that extension keywords appear in help templates
285
285
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
287
287
288 Test short command list with verbose option
288 Test short command list with verbose option
289
289
290 $ hg -v help shortlist
290 $ hg -v help shortlist
291 Mercurial Distributed SCM
291 Mercurial Distributed SCM
292
292
293 basic commands:
293 basic commands:
294
294
295 add add the specified files on the next commit
295 add add the specified files on the next commit
296 annotate, blame
296 annotate, blame
297 show changeset information by line for each file
297 show changeset information by line for each file
298 clone make a copy of an existing repository
298 clone make a copy of an existing repository
299 commit, ci commit the specified files or all outstanding changes
299 commit, ci commit the specified files or all outstanding changes
300 diff diff repository (or selected files)
300 diff diff repository (or selected files)
301 export dump the header and diffs for one or more changesets
301 export dump the header and diffs for one or more changesets
302 forget forget the specified files on the next commit
302 forget forget the specified files on the next commit
303 init create a new repository in the given directory
303 init create a new repository in the given directory
304 log, history show revision history of entire repository or files
304 log, history show revision history of entire repository or files
305 merge merge another revision into working directory
305 merge merge another revision into working directory
306 pull pull changes from the specified source
306 pull pull changes from the specified source
307 push push changes to the specified destination
307 push push changes to the specified destination
308 remove, rm remove the specified files on the next commit
308 remove, rm remove the specified files on the next commit
309 serve start stand-alone webserver
309 serve start stand-alone webserver
310 status, st show changed files in the working directory
310 status, st show changed files in the working directory
311 summary, sum summarize working directory state
311 summary, sum summarize working directory state
312 update, up, checkout, co
312 update, up, checkout, co
313 update working directory (or switch revisions)
313 update working directory (or switch revisions)
314
314
315 global options ([+] can be repeated):
315 global options ([+] can be repeated):
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 (use "hg help" for the full list of commands)
336 (use "hg help" for the full list of commands)
337
337
338 $ hg add -h
338 $ hg add -h
339 hg add [OPTION]... [FILE]...
339 hg add [OPTION]... [FILE]...
340
340
341 add the specified files on the next commit
341 add the specified files on the next commit
342
342
343 Schedule files to be version controlled and added to the repository.
343 Schedule files to be version controlled and added to the repository.
344
344
345 The files will be added to the repository at the next commit. To undo an
345 The files will be added to the repository at the next commit. To undo an
346 add before that, see "hg forget".
346 add before that, see "hg forget".
347
347
348 If no names are given, add all files to the repository.
348 If no names are given, add all files to the repository.
349
349
350 Returns 0 if all files are successfully added.
350 Returns 0 if all files are successfully added.
351
351
352 options ([+] can be repeated):
352 options ([+] can be repeated):
353
353
354 -I --include PATTERN [+] include names matching the given patterns
354 -I --include PATTERN [+] include names matching the given patterns
355 -X --exclude PATTERN [+] exclude names matching the given patterns
355 -X --exclude PATTERN [+] exclude names matching the given patterns
356 -S --subrepos recurse into subrepositories
356 -S --subrepos recurse into subrepositories
357 -n --dry-run do not perform actions, just print output
357 -n --dry-run do not perform actions, just print output
358
358
359 (some details hidden, use --verbose to show complete help)
359 (some details hidden, use --verbose to show complete help)
360
360
361 Verbose help for add
361 Verbose help for add
362
362
363 $ hg add -hv
363 $ hg add -hv
364 hg add [OPTION]... [FILE]...
364 hg add [OPTION]... [FILE]...
365
365
366 add the specified files on the next commit
366 add the specified files on the next commit
367
367
368 Schedule files to be version controlled and added to the repository.
368 Schedule files to be version controlled and added to the repository.
369
369
370 The files will be added to the repository at the next commit. To undo an
370 The files will be added to the repository at the next commit. To undo an
371 add before that, see "hg forget".
371 add before that, see "hg forget".
372
372
373 If no names are given, add all files to the repository.
373 If no names are given, add all files to the repository.
374
374
375 An example showing how new (unknown) files are added automatically by "hg
375 Examples:
376 add":
376
377 - New (unknown) files are added automatically by "hg add":
377
378
378 $ ls
379 $ ls
379 foo.c
380 foo.c
380 $ hg status
381 $ hg status
381 ? foo.c
382 ? foo.c
382 $ hg add
383 $ hg add
383 adding foo.c
384 adding foo.c
384 $ hg status
385 $ hg status
385 A foo.c
386 A foo.c
386
387
388 - Specific files to be added can be specified:
389
390 $ ls
391 bar.c foo.c
392 $ hg status
393 ? bar.c
394 ? foo.c
395 $ hg add bar.c
396 $ hg status
397 A bar.c
398 ? foo.c
399
387 Returns 0 if all files are successfully added.
400 Returns 0 if all files are successfully added.
388
401
389 options ([+] can be repeated):
402 options ([+] can be repeated):
390
403
391 -I --include PATTERN [+] include names matching the given patterns
404 -I --include PATTERN [+] include names matching the given patterns
392 -X --exclude PATTERN [+] exclude names matching the given patterns
405 -X --exclude PATTERN [+] exclude names matching the given patterns
393 -S --subrepos recurse into subrepositories
406 -S --subrepos recurse into subrepositories
394 -n --dry-run do not perform actions, just print output
407 -n --dry-run do not perform actions, just print output
395
408
396 global options ([+] can be repeated):
409 global options ([+] can be repeated):
397
410
398 -R --repository REPO repository root directory or name of overlay bundle
411 -R --repository REPO repository root directory or name of overlay bundle
399 file
412 file
400 --cwd DIR change working directory
413 --cwd DIR change working directory
401 -y --noninteractive do not prompt, automatically pick the first choice for
414 -y --noninteractive do not prompt, automatically pick the first choice for
402 all prompts
415 all prompts
403 -q --quiet suppress output
416 -q --quiet suppress output
404 -v --verbose enable additional output
417 -v --verbose enable additional output
405 --config CONFIG [+] set/override config option (use 'section.name=value')
418 --config CONFIG [+] set/override config option (use 'section.name=value')
406 --debug enable debugging output
419 --debug enable debugging output
407 --debugger start debugger
420 --debugger start debugger
408 --encoding ENCODE set the charset encoding (default: ascii)
421 --encoding ENCODE set the charset encoding (default: ascii)
409 --encodingmode MODE set the charset encoding mode (default: strict)
422 --encodingmode MODE set the charset encoding mode (default: strict)
410 --traceback always print a traceback on exception
423 --traceback always print a traceback on exception
411 --time time how long the command takes
424 --time time how long the command takes
412 --profile print command execution profile
425 --profile print command execution profile
413 --version output version information and exit
426 --version output version information and exit
414 -h --help display help and exit
427 -h --help display help and exit
415 --hidden consider hidden changesets
428 --hidden consider hidden changesets
416
429
417 Test help option with version option
430 Test help option with version option
418
431
419 $ hg add -h --version
432 $ hg add -h --version
420 Mercurial Distributed SCM (version *) (glob)
433 Mercurial Distributed SCM (version *) (glob)
421 (see https://mercurial-scm.org for more information)
434 (see https://mercurial-scm.org for more information)
422
435
423 Copyright (C) 2005-2015 Matt Mackall and others
436 Copyright (C) 2005-2015 Matt Mackall and others
424 This is free software; see the source for copying conditions. There is NO
437 This is free software; see the source for copying conditions. There is NO
425 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
438 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
426
439
427 $ hg add --skjdfks
440 $ hg add --skjdfks
428 hg add: option --skjdfks not recognized
441 hg add: option --skjdfks not recognized
429 hg add [OPTION]... [FILE]...
442 hg add [OPTION]... [FILE]...
430
443
431 add the specified files on the next commit
444 add the specified files on the next commit
432
445
433 options ([+] can be repeated):
446 options ([+] can be repeated):
434
447
435 -I --include PATTERN [+] include names matching the given patterns
448 -I --include PATTERN [+] include names matching the given patterns
436 -X --exclude PATTERN [+] exclude names matching the given patterns
449 -X --exclude PATTERN [+] exclude names matching the given patterns
437 -S --subrepos recurse into subrepositories
450 -S --subrepos recurse into subrepositories
438 -n --dry-run do not perform actions, just print output
451 -n --dry-run do not perform actions, just print output
439
452
440 (use "hg add -h" to show more help)
453 (use "hg add -h" to show more help)
441 [255]
454 [255]
442
455
443 Test ambiguous command help
456 Test ambiguous command help
444
457
445 $ hg help ad
458 $ hg help ad
446 list of commands:
459 list of commands:
447
460
448 add add the specified files on the next commit
461 add add the specified files on the next commit
449 addremove add all new files, delete all missing files
462 addremove add all new files, delete all missing files
450
463
451 (use "hg help -v ad" to show built-in aliases and global options)
464 (use "hg help -v ad" to show built-in aliases and global options)
452
465
453 Test command without options
466 Test command without options
454
467
455 $ hg help verify
468 $ hg help verify
456 hg verify
469 hg verify
457
470
458 verify the integrity of the repository
471 verify the integrity of the repository
459
472
460 Verify the integrity of the current repository.
473 Verify the integrity of the current repository.
461
474
462 This will perform an extensive check of the repository's integrity,
475 This will perform an extensive check of the repository's integrity,
463 validating the hashes and checksums of each entry in the changelog,
476 validating the hashes and checksums of each entry in the changelog,
464 manifest, and tracked files, as well as the integrity of their crosslinks
477 manifest, and tracked files, as well as the integrity of their crosslinks
465 and indices.
478 and indices.
466
479
467 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
480 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
468 information about recovery from corruption of the repository.
481 information about recovery from corruption of the repository.
469
482
470 Returns 0 on success, 1 if errors are encountered.
483 Returns 0 on success, 1 if errors are encountered.
471
484
472 (some details hidden, use --verbose to show complete help)
485 (some details hidden, use --verbose to show complete help)
473
486
474 $ hg help diff
487 $ hg help diff
475 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
488 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
476
489
477 diff repository (or selected files)
490 diff repository (or selected files)
478
491
479 Show differences between revisions for the specified files.
492 Show differences between revisions for the specified files.
480
493
481 Differences between files are shown using the unified diff format.
494 Differences between files are shown using the unified diff format.
482
495
483 Note:
496 Note:
484 diff may generate unexpected results for merges, as it will default to
497 diff may generate unexpected results for merges, as it will default to
485 comparing against the working directory's first parent changeset if no
498 comparing against the working directory's first parent changeset if no
486 revisions are specified.
499 revisions are specified.
487
500
488 When two revision arguments are given, then changes are shown between
501 When two revision arguments are given, then changes are shown between
489 those revisions. If only one revision is specified then that revision is
502 those revisions. If only one revision is specified then that revision is
490 compared to the working directory, and, when no revisions are specified,
503 compared to the working directory, and, when no revisions are specified,
491 the working directory files are compared to its parent.
504 the working directory files are compared to its parent.
492
505
493 Alternatively you can specify -c/--change with a revision to see the
506 Alternatively you can specify -c/--change with a revision to see the
494 changes in that changeset relative to its first parent.
507 changes in that changeset relative to its first parent.
495
508
496 Without the -a/--text option, diff will avoid generating diffs of files it
509 Without the -a/--text option, diff will avoid generating diffs of files it
497 detects as binary. With -a, diff will generate a diff anyway, probably
510 detects as binary. With -a, diff will generate a diff anyway, probably
498 with undesirable results.
511 with undesirable results.
499
512
500 Use the -g/--git option to generate diffs in the git extended diff format.
513 Use the -g/--git option to generate diffs in the git extended diff format.
501 For more information, read "hg help diffs".
514 For more information, read "hg help diffs".
502
515
503 Returns 0 on success.
516 Returns 0 on success.
504
517
505 options ([+] can be repeated):
518 options ([+] can be repeated):
506
519
507 -r --rev REV [+] revision
520 -r --rev REV [+] revision
508 -c --change REV change made by revision
521 -c --change REV change made by revision
509 -a --text treat all files as text
522 -a --text treat all files as text
510 -g --git use git extended diff format
523 -g --git use git extended diff format
511 --nodates omit dates from diff headers
524 --nodates omit dates from diff headers
512 --noprefix omit a/ and b/ prefixes from filenames
525 --noprefix omit a/ and b/ prefixes from filenames
513 -p --show-function show which function each change is in
526 -p --show-function show which function each change is in
514 --reverse produce a diff that undoes the changes
527 --reverse produce a diff that undoes the changes
515 -w --ignore-all-space ignore white space when comparing lines
528 -w --ignore-all-space ignore white space when comparing lines
516 -b --ignore-space-change ignore changes in the amount of white space
529 -b --ignore-space-change ignore changes in the amount of white space
517 -B --ignore-blank-lines ignore changes whose lines are all blank
530 -B --ignore-blank-lines ignore changes whose lines are all blank
518 -U --unified NUM number of lines of context to show
531 -U --unified NUM number of lines of context to show
519 --stat output diffstat-style summary of changes
532 --stat output diffstat-style summary of changes
520 --root DIR produce diffs relative to subdirectory
533 --root DIR produce diffs relative to subdirectory
521 -I --include PATTERN [+] include names matching the given patterns
534 -I --include PATTERN [+] include names matching the given patterns
522 -X --exclude PATTERN [+] exclude names matching the given patterns
535 -X --exclude PATTERN [+] exclude names matching the given patterns
523 -S --subrepos recurse into subrepositories
536 -S --subrepos recurse into subrepositories
524
537
525 (some details hidden, use --verbose to show complete help)
538 (some details hidden, use --verbose to show complete help)
526
539
527 $ hg help status
540 $ hg help status
528 hg status [OPTION]... [FILE]...
541 hg status [OPTION]... [FILE]...
529
542
530 aliases: st
543 aliases: st
531
544
532 show changed files in the working directory
545 show changed files in the working directory
533
546
534 Show status of files in the repository. If names are given, only files
547 Show status of files in the repository. If names are given, only files
535 that match are shown. Files that are clean or ignored or the source of a
548 that match are shown. Files that are clean or ignored or the source of a
536 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
549 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
537 -C/--copies or -A/--all are given. Unless options described with "show
550 -C/--copies or -A/--all are given. Unless options described with "show
538 only ..." are given, the options -mardu are used.
551 only ..." are given, the options -mardu are used.
539
552
540 Option -q/--quiet hides untracked (unknown and ignored) files unless
553 Option -q/--quiet hides untracked (unknown and ignored) files unless
541 explicitly requested with -u/--unknown or -i/--ignored.
554 explicitly requested with -u/--unknown or -i/--ignored.
542
555
543 Note:
556 Note:
544 status may appear to disagree with diff if permissions have changed or
557 status may appear to disagree with diff if permissions have changed or
545 a merge has occurred. The standard diff format does not report
558 a merge has occurred. The standard diff format does not report
546 permission changes and diff only reports changes relative to one merge
559 permission changes and diff only reports changes relative to one merge
547 parent.
560 parent.
548
561
549 If one revision is given, it is used as the base revision. If two
562 If one revision is given, it is used as the base revision. If two
550 revisions are given, the differences between them are shown. The --change
563 revisions are given, the differences between them are shown. The --change
551 option can also be used as a shortcut to list the changed files of a
564 option can also be used as a shortcut to list the changed files of a
552 revision from its first parent.
565 revision from its first parent.
553
566
554 The codes used to show the status of files are:
567 The codes used to show the status of files are:
555
568
556 M = modified
569 M = modified
557 A = added
570 A = added
558 R = removed
571 R = removed
559 C = clean
572 C = clean
560 ! = missing (deleted by non-hg command, but still tracked)
573 ! = missing (deleted by non-hg command, but still tracked)
561 ? = not tracked
574 ? = not tracked
562 I = ignored
575 I = ignored
563 = origin of the previous file (with --copies)
576 = origin of the previous file (with --copies)
564
577
565 Returns 0 on success.
578 Returns 0 on success.
566
579
567 options ([+] can be repeated):
580 options ([+] can be repeated):
568
581
569 -A --all show status of all files
582 -A --all show status of all files
570 -m --modified show only modified files
583 -m --modified show only modified files
571 -a --added show only added files
584 -a --added show only added files
572 -r --removed show only removed files
585 -r --removed show only removed files
573 -d --deleted show only deleted (but tracked) files
586 -d --deleted show only deleted (but tracked) files
574 -c --clean show only files without changes
587 -c --clean show only files without changes
575 -u --unknown show only unknown (not tracked) files
588 -u --unknown show only unknown (not tracked) files
576 -i --ignored show only ignored files
589 -i --ignored show only ignored files
577 -n --no-status hide status prefix
590 -n --no-status hide status prefix
578 -C --copies show source of copied files
591 -C --copies show source of copied files
579 -0 --print0 end filenames with NUL, for use with xargs
592 -0 --print0 end filenames with NUL, for use with xargs
580 --rev REV [+] show difference from revision
593 --rev REV [+] show difference from revision
581 --change REV list the changed files of a revision
594 --change REV list the changed files of a revision
582 -I --include PATTERN [+] include names matching the given patterns
595 -I --include PATTERN [+] include names matching the given patterns
583 -X --exclude PATTERN [+] exclude names matching the given patterns
596 -X --exclude PATTERN [+] exclude names matching the given patterns
584 -S --subrepos recurse into subrepositories
597 -S --subrepos recurse into subrepositories
585
598
586 (some details hidden, use --verbose to show complete help)
599 (some details hidden, use --verbose to show complete help)
587
600
588 $ hg -q help status
601 $ hg -q help status
589 hg status [OPTION]... [FILE]...
602 hg status [OPTION]... [FILE]...
590
603
591 show changed files in the working directory
604 show changed files in the working directory
592
605
593 $ hg help foo
606 $ hg help foo
594 abort: no such help topic: foo
607 abort: no such help topic: foo
595 (try "hg help --keyword foo")
608 (try "hg help --keyword foo")
596 [255]
609 [255]
597
610
598 $ hg skjdfks
611 $ hg skjdfks
599 hg: unknown command 'skjdfks'
612 hg: unknown command 'skjdfks'
600 Mercurial Distributed SCM
613 Mercurial Distributed SCM
601
614
602 basic commands:
615 basic commands:
603
616
604 add add the specified files on the next commit
617 add add the specified files on the next commit
605 annotate show changeset information by line for each file
618 annotate show changeset information by line for each file
606 clone make a copy of an existing repository
619 clone make a copy of an existing repository
607 commit commit the specified files or all outstanding changes
620 commit commit the specified files or all outstanding changes
608 diff diff repository (or selected files)
621 diff diff repository (or selected files)
609 export dump the header and diffs for one or more changesets
622 export dump the header and diffs for one or more changesets
610 forget forget the specified files on the next commit
623 forget forget the specified files on the next commit
611 init create a new repository in the given directory
624 init create a new repository in the given directory
612 log show revision history of entire repository or files
625 log show revision history of entire repository or files
613 merge merge another revision into working directory
626 merge merge another revision into working directory
614 pull pull changes from the specified source
627 pull pull changes from the specified source
615 push push changes to the specified destination
628 push push changes to the specified destination
616 remove remove the specified files on the next commit
629 remove remove the specified files on the next commit
617 serve start stand-alone webserver
630 serve start stand-alone webserver
618 status show changed files in the working directory
631 status show changed files in the working directory
619 summary summarize working directory state
632 summary summarize working directory state
620 update update working directory (or switch revisions)
633 update update working directory (or switch revisions)
621
634
622 (use "hg help" for the full list of commands or "hg -v" for details)
635 (use "hg help" for the full list of commands or "hg -v" for details)
623 [255]
636 [255]
624
637
625
638
626 Make sure that we don't run afoul of the help system thinking that
639 Make sure that we don't run afoul of the help system thinking that
627 this is a section and erroring out weirdly.
640 this is a section and erroring out weirdly.
628
641
629 $ hg .log
642 $ hg .log
630 hg: unknown command '.log'
643 hg: unknown command '.log'
631 (did you mean one of log?)
644 (did you mean one of log?)
632 [255]
645 [255]
633
646
634 $ hg log.
647 $ hg log.
635 hg: unknown command 'log.'
648 hg: unknown command 'log.'
636 (did you mean one of log?)
649 (did you mean one of log?)
637 [255]
650 [255]
638 $ hg pu.lh
651 $ hg pu.lh
639 hg: unknown command 'pu.lh'
652 hg: unknown command 'pu.lh'
640 (did you mean one of pull, push?)
653 (did you mean one of pull, push?)
641 [255]
654 [255]
642
655
643 $ cat > helpext.py <<EOF
656 $ cat > helpext.py <<EOF
644 > import os
657 > import os
645 > from mercurial import cmdutil, commands
658 > from mercurial import cmdutil, commands
646 >
659 >
647 > cmdtable = {}
660 > cmdtable = {}
648 > command = cmdutil.command(cmdtable)
661 > command = cmdutil.command(cmdtable)
649 >
662 >
650 > @command('nohelp',
663 > @command('nohelp',
651 > [('', 'longdesc', 3, 'x'*90),
664 > [('', 'longdesc', 3, 'x'*90),
652 > ('n', '', None, 'normal desc'),
665 > ('n', '', None, 'normal desc'),
653 > ('', 'newline', '', 'line1\nline2')],
666 > ('', 'newline', '', 'line1\nline2')],
654 > 'hg nohelp',
667 > 'hg nohelp',
655 > norepo=True)
668 > norepo=True)
656 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
669 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
657 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
670 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
658 > def nohelp(ui, *args, **kwargs):
671 > def nohelp(ui, *args, **kwargs):
659 > pass
672 > pass
660 >
673 >
661 > EOF
674 > EOF
662 $ echo '[extensions]' >> $HGRCPATH
675 $ echo '[extensions]' >> $HGRCPATH
663 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
676 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
664
677
665 Test command with no help text
678 Test command with no help text
666
679
667 $ hg help nohelp
680 $ hg help nohelp
668 hg nohelp
681 hg nohelp
669
682
670 (no help text available)
683 (no help text available)
671
684
672 options:
685 options:
673
686
674 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
687 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
675 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
688 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
676 -n -- normal desc
689 -n -- normal desc
677 --newline VALUE line1 line2
690 --newline VALUE line1 line2
678
691
679 (some details hidden, use --verbose to show complete help)
692 (some details hidden, use --verbose to show complete help)
680
693
681 $ hg help -k nohelp
694 $ hg help -k nohelp
682 Commands:
695 Commands:
683
696
684 nohelp hg nohelp
697 nohelp hg nohelp
685
698
686 Extension Commands:
699 Extension Commands:
687
700
688 nohelp (no help text available)
701 nohelp (no help text available)
689
702
690 Test that default list of commands omits extension commands
703 Test that default list of commands omits extension commands
691
704
692 $ hg help
705 $ hg help
693 Mercurial Distributed SCM
706 Mercurial Distributed SCM
694
707
695 list of commands:
708 list of commands:
696
709
697 add add the specified files on the next commit
710 add add the specified files on the next commit
698 addremove add all new files, delete all missing files
711 addremove add all new files, delete all missing files
699 annotate show changeset information by line for each file
712 annotate show changeset information by line for each file
700 archive create an unversioned archive of a repository revision
713 archive create an unversioned archive of a repository revision
701 backout reverse effect of earlier changeset
714 backout reverse effect of earlier changeset
702 bisect subdivision search of changesets
715 bisect subdivision search of changesets
703 bookmarks create a new bookmark or list existing bookmarks
716 bookmarks create a new bookmark or list existing bookmarks
704 branch set or show the current branch name
717 branch set or show the current branch name
705 branches list repository named branches
718 branches list repository named branches
706 bundle create a changegroup file
719 bundle create a changegroup file
707 cat output the current or given revision of files
720 cat output the current or given revision of files
708 clone make a copy of an existing repository
721 clone make a copy of an existing repository
709 commit commit the specified files or all outstanding changes
722 commit commit the specified files or all outstanding changes
710 config show combined config settings from all hgrc files
723 config show combined config settings from all hgrc files
711 copy mark files as copied for the next commit
724 copy mark files as copied for the next commit
712 diff diff repository (or selected files)
725 diff diff repository (or selected files)
713 export dump the header and diffs for one or more changesets
726 export dump the header and diffs for one or more changesets
714 files list tracked files
727 files list tracked files
715 forget forget the specified files on the next commit
728 forget forget the specified files on the next commit
716 graft copy changes from other branches onto the current branch
729 graft copy changes from other branches onto the current branch
717 grep search for a pattern in specified files and revisions
730 grep search for a pattern in specified files and revisions
718 heads show branch heads
731 heads show branch heads
719 help show help for a given topic or a help overview
732 help show help for a given topic or a help overview
720 identify identify the working directory or specified revision
733 identify identify the working directory or specified revision
721 import import an ordered set of patches
734 import import an ordered set of patches
722 incoming show new changesets found in source
735 incoming show new changesets found in source
723 init create a new repository in the given directory
736 init create a new repository in the given directory
724 log show revision history of entire repository or files
737 log show revision history of entire repository or files
725 manifest output the current or given revision of the project manifest
738 manifest output the current or given revision of the project manifest
726 merge merge another revision into working directory
739 merge merge another revision into working directory
727 outgoing show changesets not found in the destination
740 outgoing show changesets not found in the destination
728 paths show aliases for remote repositories
741 paths show aliases for remote repositories
729 phase set or show the current phase name
742 phase set or show the current phase name
730 pull pull changes from the specified source
743 pull pull changes from the specified source
731 push push changes to the specified destination
744 push push changes to the specified destination
732 recover roll back an interrupted transaction
745 recover roll back an interrupted transaction
733 remove remove the specified files on the next commit
746 remove remove the specified files on the next commit
734 rename rename files; equivalent of copy + remove
747 rename rename files; equivalent of copy + remove
735 resolve redo merges or set/view the merge status of files
748 resolve redo merges or set/view the merge status of files
736 revert restore files to their checkout state
749 revert restore files to their checkout state
737 root print the root (top) of the current working directory
750 root print the root (top) of the current working directory
738 serve start stand-alone webserver
751 serve start stand-alone webserver
739 status show changed files in the working directory
752 status show changed files in the working directory
740 summary summarize working directory state
753 summary summarize working directory state
741 tag add one or more tags for the current or given revision
754 tag add one or more tags for the current or given revision
742 tags list repository tags
755 tags list repository tags
743 unbundle apply one or more changegroup files
756 unbundle apply one or more changegroup files
744 update update working directory (or switch revisions)
757 update update working directory (or switch revisions)
745 verify verify the integrity of the repository
758 verify verify the integrity of the repository
746 version output version and copyright information
759 version output version and copyright information
747
760
748 enabled extensions:
761 enabled extensions:
749
762
750 helpext (no help text available)
763 helpext (no help text available)
751
764
752 additional help topics:
765 additional help topics:
753
766
754 config Configuration Files
767 config Configuration Files
755 dates Date Formats
768 dates Date Formats
756 diffs Diff Formats
769 diffs Diff Formats
757 environment Environment Variables
770 environment Environment Variables
758 extensions Using Additional Features
771 extensions Using Additional Features
759 filesets Specifying File Sets
772 filesets Specifying File Sets
760 glossary Glossary
773 glossary Glossary
761 hgignore Syntax for Mercurial Ignore Files
774 hgignore Syntax for Mercurial Ignore Files
762 hgweb Configuring hgweb
775 hgweb Configuring hgweb
763 merge-tools Merge Tools
776 merge-tools Merge Tools
764 multirevs Specifying Multiple Revisions
777 multirevs Specifying Multiple Revisions
765 patterns File Name Patterns
778 patterns File Name Patterns
766 phases Working with Phases
779 phases Working with Phases
767 revisions Specifying Single Revisions
780 revisions Specifying Single Revisions
768 revsets Specifying Revision Sets
781 revsets Specifying Revision Sets
769 scripting Using Mercurial from scripts and automation
782 scripting Using Mercurial from scripts and automation
770 subrepos Subrepositories
783 subrepos Subrepositories
771 templating Template Usage
784 templating Template Usage
772 urls URL Paths
785 urls URL Paths
773
786
774 (use "hg help -v" to show built-in aliases and global options)
787 (use "hg help -v" to show built-in aliases and global options)
775
788
776
789
777 Test list of internal help commands
790 Test list of internal help commands
778
791
779 $ hg help debug
792 $ hg help debug
780 debug commands (internal and unsupported):
793 debug commands (internal and unsupported):
781
794
782 debugancestor
795 debugancestor
783 find the ancestor revision of two revisions in a given index
796 find the ancestor revision of two revisions in a given index
784 debugapplystreamclonebundle
797 debugapplystreamclonebundle
785 apply a stream clone bundle file
798 apply a stream clone bundle file
786 debugbuilddag
799 debugbuilddag
787 builds a repo with a given DAG from scratch in the current
800 builds a repo with a given DAG from scratch in the current
788 empty repo
801 empty repo
789 debugbundle lists the contents of a bundle
802 debugbundle lists the contents of a bundle
790 debugcheckstate
803 debugcheckstate
791 validate the correctness of the current dirstate
804 validate the correctness of the current dirstate
792 debugcommands
805 debugcommands
793 list all available commands and options
806 list all available commands and options
794 debugcomplete
807 debugcomplete
795 returns the completion list associated with the given command
808 returns the completion list associated with the given command
796 debugcreatestreamclonebundle
809 debugcreatestreamclonebundle
797 create a stream clone bundle file
810 create a stream clone bundle file
798 debugdag format the changelog or an index DAG as a concise textual
811 debugdag format the changelog or an index DAG as a concise textual
799 description
812 description
800 debugdata dump the contents of a data file revision
813 debugdata dump the contents of a data file revision
801 debugdate parse and display a date
814 debugdate parse and display a date
802 debugdirstate
815 debugdirstate
803 show the contents of the current dirstate
816 show the contents of the current dirstate
804 debugdiscovery
817 debugdiscovery
805 runs the changeset discovery protocol in isolation
818 runs the changeset discovery protocol in isolation
806 debugextensions
819 debugextensions
807 show information about active extensions
820 show information about active extensions
808 debugfileset parse and apply a fileset specification
821 debugfileset parse and apply a fileset specification
809 debugfsinfo show information detected about current filesystem
822 debugfsinfo show information detected about current filesystem
810 debuggetbundle
823 debuggetbundle
811 retrieves a bundle from a repo
824 retrieves a bundle from a repo
812 debugignore display the combined ignore pattern
825 debugignore display the combined ignore pattern
813 debugindex dump the contents of an index file
826 debugindex dump the contents of an index file
814 debugindexdot
827 debugindexdot
815 dump an index DAG as a graphviz dot file
828 dump an index DAG as a graphviz dot file
816 debuginstall test Mercurial installation
829 debuginstall test Mercurial installation
817 debugknown test whether node ids are known to a repo
830 debugknown test whether node ids are known to a repo
818 debuglocks show or modify state of locks
831 debuglocks show or modify state of locks
819 debugmergestate
832 debugmergestate
820 print merge state
833 print merge state
821 debugnamecomplete
834 debugnamecomplete
822 complete "names" - tags, open branch names, bookmark names
835 complete "names" - tags, open branch names, bookmark names
823 debugobsolete
836 debugobsolete
824 create arbitrary obsolete marker
837 create arbitrary obsolete marker
825 debugoptDEP (no help text available)
838 debugoptDEP (no help text available)
826 debugoptEXP (no help text available)
839 debugoptEXP (no help text available)
827 debugpathcomplete
840 debugpathcomplete
828 complete part or all of a tracked path
841 complete part or all of a tracked path
829 debugpushkey access the pushkey key/value protocol
842 debugpushkey access the pushkey key/value protocol
830 debugpvec (no help text available)
843 debugpvec (no help text available)
831 debugrebuilddirstate
844 debugrebuilddirstate
832 rebuild the dirstate as it would look like for the given
845 rebuild the dirstate as it would look like for the given
833 revision
846 revision
834 debugrebuildfncache
847 debugrebuildfncache
835 rebuild the fncache file
848 rebuild the fncache file
836 debugrename dump rename information
849 debugrename dump rename information
837 debugrevlog show data and statistics about a revlog
850 debugrevlog show data and statistics about a revlog
838 debugrevspec parse and apply a revision specification
851 debugrevspec parse and apply a revision specification
839 debugsetparents
852 debugsetparents
840 manually set the parents of the current working directory
853 manually set the parents of the current working directory
841 debugsub (no help text available)
854 debugsub (no help text available)
842 debugsuccessorssets
855 debugsuccessorssets
843 show set of successors for revision
856 show set of successors for revision
844 debugwalk show how files match on given patterns
857 debugwalk show how files match on given patterns
845 debugwireargs
858 debugwireargs
846 (no help text available)
859 (no help text available)
847
860
848 (use "hg help -v debug" to show built-in aliases and global options)
861 (use "hg help -v debug" to show built-in aliases and global options)
849
862
850
863
851 Test list of commands with command with no help text
864 Test list of commands with command with no help text
852
865
853 $ hg help helpext
866 $ hg help helpext
854 helpext extension - no help text available
867 helpext extension - no help text available
855
868
856 list of commands:
869 list of commands:
857
870
858 nohelp (no help text available)
871 nohelp (no help text available)
859
872
860 (use "hg help -v helpext" to show built-in aliases and global options)
873 (use "hg help -v helpext" to show built-in aliases and global options)
861
874
862
875
863 test deprecated and experimental options are hidden in command help
876 test deprecated and experimental options are hidden in command help
864 $ hg help debugoptDEP
877 $ hg help debugoptDEP
865 hg debugoptDEP
878 hg debugoptDEP
866
879
867 (no help text available)
880 (no help text available)
868
881
869 options:
882 options:
870
883
871 (some details hidden, use --verbose to show complete help)
884 (some details hidden, use --verbose to show complete help)
872
885
873 $ hg help debugoptEXP
886 $ hg help debugoptEXP
874 hg debugoptEXP
887 hg debugoptEXP
875
888
876 (no help text available)
889 (no help text available)
877
890
878 options:
891 options:
879
892
880 (some details hidden, use --verbose to show complete help)
893 (some details hidden, use --verbose to show complete help)
881
894
882 test deprecated and experimental options is shown with -v
895 test deprecated and experimental options is shown with -v
883 $ hg help -v debugoptDEP | grep dopt
896 $ hg help -v debugoptDEP | grep dopt
884 --dopt option is (DEPRECATED)
897 --dopt option is (DEPRECATED)
885 $ hg help -v debugoptEXP | grep eopt
898 $ hg help -v debugoptEXP | grep eopt
886 --eopt option is (EXPERIMENTAL)
899 --eopt option is (EXPERIMENTAL)
887
900
888 #if gettext
901 #if gettext
889 test deprecated option is hidden with translation with untranslated description
902 test deprecated option is hidden with translation with untranslated description
890 (use many globy for not failing on changed transaction)
903 (use many globy for not failing on changed transaction)
891 $ LANGUAGE=sv hg help debugoptDEP
904 $ LANGUAGE=sv hg help debugoptDEP
892 hg debugoptDEP
905 hg debugoptDEP
893
906
894 (*) (glob)
907 (*) (glob)
895
908
896 options:
909 options:
897
910
898 (some details hidden, use --verbose to show complete help)
911 (some details hidden, use --verbose to show complete help)
899 #endif
912 #endif
900
913
901 Test commands that collide with topics (issue4240)
914 Test commands that collide with topics (issue4240)
902
915
903 $ hg config -hq
916 $ hg config -hq
904 hg config [-u] [NAME]...
917 hg config [-u] [NAME]...
905
918
906 show combined config settings from all hgrc files
919 show combined config settings from all hgrc files
907 $ hg showconfig -hq
920 $ hg showconfig -hq
908 hg config [-u] [NAME]...
921 hg config [-u] [NAME]...
909
922
910 show combined config settings from all hgrc files
923 show combined config settings from all hgrc files
911
924
912 Test a help topic
925 Test a help topic
913
926
914 $ hg help revs
927 $ hg help revs
915 Specifying Single Revisions
928 Specifying Single Revisions
916 """""""""""""""""""""""""""
929 """""""""""""""""""""""""""
917
930
918 Mercurial supports several ways to specify individual revisions.
931 Mercurial supports several ways to specify individual revisions.
919
932
920 A plain integer is treated as a revision number. Negative integers are
933 A plain integer is treated as a revision number. Negative integers are
921 treated as sequential offsets from the tip, with -1 denoting the tip, -2
934 treated as sequential offsets from the tip, with -1 denoting the tip, -2
922 denoting the revision prior to the tip, and so forth.
935 denoting the revision prior to the tip, and so forth.
923
936
924 A 40-digit hexadecimal string is treated as a unique revision identifier.
937 A 40-digit hexadecimal string is treated as a unique revision identifier.
925
938
926 A hexadecimal string less than 40 characters long is treated as a unique
939 A hexadecimal string less than 40 characters long is treated as a unique
927 revision identifier and is referred to as a short-form identifier. A
940 revision identifier and is referred to as a short-form identifier. A
928 short-form identifier is only valid if it is the prefix of exactly one
941 short-form identifier is only valid if it is the prefix of exactly one
929 full-length identifier.
942 full-length identifier.
930
943
931 Any other string is treated as a bookmark, tag, or branch name. A bookmark
944 Any other string is treated as a bookmark, tag, or branch name. A bookmark
932 is a movable pointer to a revision. A tag is a permanent name associated
945 is a movable pointer to a revision. A tag is a permanent name associated
933 with a revision. A branch name denotes the tipmost open branch head of
946 with a revision. A branch name denotes the tipmost open branch head of
934 that branch - or if they are all closed, the tipmost closed head of the
947 that branch - or if they are all closed, the tipmost closed head of the
935 branch. Bookmark, tag, and branch names must not contain the ":"
948 branch. Bookmark, tag, and branch names must not contain the ":"
936 character.
949 character.
937
950
938 The reserved name "tip" always identifies the most recent revision.
951 The reserved name "tip" always identifies the most recent revision.
939
952
940 The reserved name "null" indicates the null revision. This is the revision
953 The reserved name "null" indicates the null revision. This is the revision
941 of an empty repository, and the parent of revision 0.
954 of an empty repository, and the parent of revision 0.
942
955
943 The reserved name "." indicates the working directory parent. If no
956 The reserved name "." indicates the working directory parent. If no
944 working directory is checked out, it is equivalent to null. If an
957 working directory is checked out, it is equivalent to null. If an
945 uncommitted merge is in progress, "." is the revision of the first parent.
958 uncommitted merge is in progress, "." is the revision of the first parent.
946
959
947 Test repeated config section name
960 Test repeated config section name
948
961
949 $ hg help config.host
962 $ hg help config.host
950 "http_proxy.host"
963 "http_proxy.host"
951 Host name and (optional) port of the proxy server, for example
964 Host name and (optional) port of the proxy server, for example
952 "myproxy:8000".
965 "myproxy:8000".
953
966
954 "smtp.host"
967 "smtp.host"
955 Host name of mail server, e.g. "mail.example.com".
968 Host name of mail server, e.g. "mail.example.com".
956
969
957 Unrelated trailing paragraphs shouldn't be included
970 Unrelated trailing paragraphs shouldn't be included
958
971
959 $ hg help config.extramsg | grep '^$'
972 $ hg help config.extramsg | grep '^$'
960
973
961
974
962 Test capitalized section name
975 Test capitalized section name
963
976
964 $ hg help scripting.HGPLAIN > /dev/null
977 $ hg help scripting.HGPLAIN > /dev/null
965
978
966 Help subsection:
979 Help subsection:
967
980
968 $ hg help config.charsets |grep "Email example:" > /dev/null
981 $ hg help config.charsets |grep "Email example:" > /dev/null
969 [1]
982 [1]
970
983
971 Show nested definitions
984 Show nested definitions
972 ("profiling.type"[break]"ls"[break]"stat"[break])
985 ("profiling.type"[break]"ls"[break]"stat"[break])
973
986
974 $ hg help config.type | egrep '^$'|wc -l
987 $ hg help config.type | egrep '^$'|wc -l
975 \s*3 (re)
988 \s*3 (re)
976
989
977 Last item in help config.*:
990 Last item in help config.*:
978
991
979 $ hg help config.`hg help config|grep '^ "'| \
992 $ hg help config.`hg help config|grep '^ "'| \
980 > tail -1|sed 's![ "]*!!g'`| \
993 > tail -1|sed 's![ "]*!!g'`| \
981 > grep "hg help -c config" > /dev/null
994 > grep "hg help -c config" > /dev/null
982 [1]
995 [1]
983
996
984 note to use help -c for general hg help config:
997 note to use help -c for general hg help config:
985
998
986 $ hg help config |grep "hg help -c config" > /dev/null
999 $ hg help config |grep "hg help -c config" > /dev/null
987
1000
988 Test templating help
1001 Test templating help
989
1002
990 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1003 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
991 desc String. The text of the changeset description.
1004 desc String. The text of the changeset description.
992 diffstat String. Statistics of changes with the following format:
1005 diffstat String. Statistics of changes with the following format:
993 firstline Any text. Returns the first line of text.
1006 firstline Any text. Returns the first line of text.
994 nonempty Any text. Returns '(none)' if the string is empty.
1007 nonempty Any text. Returns '(none)' if the string is empty.
995
1008
996 Test deprecated items
1009 Test deprecated items
997
1010
998 $ hg help -v templating | grep currentbookmark
1011 $ hg help -v templating | grep currentbookmark
999 currentbookmark
1012 currentbookmark
1000 $ hg help templating | (grep currentbookmark || true)
1013 $ hg help templating | (grep currentbookmark || true)
1001
1014
1002 Test help hooks
1015 Test help hooks
1003
1016
1004 $ cat > helphook1.py <<EOF
1017 $ cat > helphook1.py <<EOF
1005 > from mercurial import help
1018 > from mercurial import help
1006 >
1019 >
1007 > def rewrite(ui, topic, doc):
1020 > def rewrite(ui, topic, doc):
1008 > return doc + '\nhelphook1\n'
1021 > return doc + '\nhelphook1\n'
1009 >
1022 >
1010 > def extsetup(ui):
1023 > def extsetup(ui):
1011 > help.addtopichook('revsets', rewrite)
1024 > help.addtopichook('revsets', rewrite)
1012 > EOF
1025 > EOF
1013 $ cat > helphook2.py <<EOF
1026 $ cat > helphook2.py <<EOF
1014 > from mercurial import help
1027 > from mercurial import help
1015 >
1028 >
1016 > def rewrite(ui, topic, doc):
1029 > def rewrite(ui, topic, doc):
1017 > return doc + '\nhelphook2\n'
1030 > return doc + '\nhelphook2\n'
1018 >
1031 >
1019 > def extsetup(ui):
1032 > def extsetup(ui):
1020 > help.addtopichook('revsets', rewrite)
1033 > help.addtopichook('revsets', rewrite)
1021 > EOF
1034 > EOF
1022 $ echo '[extensions]' >> $HGRCPATH
1035 $ echo '[extensions]' >> $HGRCPATH
1023 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1036 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1024 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1037 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1025 $ hg help revsets | grep helphook
1038 $ hg help revsets | grep helphook
1026 helphook1
1039 helphook1
1027 helphook2
1040 helphook2
1028
1041
1029 Test -e / -c / -k combinations
1042 Test -e / -c / -k combinations
1030
1043
1031 $ hg help -c schemes
1044 $ hg help -c schemes
1032 abort: no such help topic: schemes
1045 abort: no such help topic: schemes
1033 (try "hg help --keyword schemes")
1046 (try "hg help --keyword schemes")
1034 [255]
1047 [255]
1035 $ hg help -e schemes |head -1
1048 $ hg help -e schemes |head -1
1036 schemes extension - extend schemes with shortcuts to repository swarms
1049 schemes extension - extend schemes with shortcuts to repository swarms
1037 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1050 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1038 Commands:
1051 Commands:
1039 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1052 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1040 Extensions:
1053 Extensions:
1041 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1054 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1042 Extensions:
1055 Extensions:
1043 Commands:
1056 Commands:
1044 $ hg help -c commit > /dev/null
1057 $ hg help -c commit > /dev/null
1045 $ hg help -e -c commit > /dev/null
1058 $ hg help -e -c commit > /dev/null
1046 $ hg help -e commit > /dev/null
1059 $ hg help -e commit > /dev/null
1047 abort: no such help topic: commit
1060 abort: no such help topic: commit
1048 (try "hg help --keyword commit")
1061 (try "hg help --keyword commit")
1049 [255]
1062 [255]
1050
1063
1051 Test keyword search help
1064 Test keyword search help
1052
1065
1053 $ cat > prefixedname.py <<EOF
1066 $ cat > prefixedname.py <<EOF
1054 > '''matched against word "clone"
1067 > '''matched against word "clone"
1055 > '''
1068 > '''
1056 > EOF
1069 > EOF
1057 $ echo '[extensions]' >> $HGRCPATH
1070 $ echo '[extensions]' >> $HGRCPATH
1058 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1071 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1059 $ hg help -k clone
1072 $ hg help -k clone
1060 Topics:
1073 Topics:
1061
1074
1062 config Configuration Files
1075 config Configuration Files
1063 extensions Using Additional Features
1076 extensions Using Additional Features
1064 glossary Glossary
1077 glossary Glossary
1065 phases Working with Phases
1078 phases Working with Phases
1066 subrepos Subrepositories
1079 subrepos Subrepositories
1067 urls URL Paths
1080 urls URL Paths
1068
1081
1069 Commands:
1082 Commands:
1070
1083
1071 bookmarks create a new bookmark or list existing bookmarks
1084 bookmarks create a new bookmark or list existing bookmarks
1072 clone make a copy of an existing repository
1085 clone make a copy of an existing repository
1073 debugapplystreamclonebundle apply a stream clone bundle file
1086 debugapplystreamclonebundle apply a stream clone bundle file
1074 debugcreatestreamclonebundle create a stream clone bundle file
1087 debugcreatestreamclonebundle create a stream clone bundle file
1075 paths show aliases for remote repositories
1088 paths show aliases for remote repositories
1076 update update working directory (or switch revisions)
1089 update update working directory (or switch revisions)
1077
1090
1078 Extensions:
1091 Extensions:
1079
1092
1080 clonebundles advertise pre-generated bundles to seed clones (experimental)
1093 clonebundles advertise pre-generated bundles to seed clones (experimental)
1081 prefixedname matched against word "clone"
1094 prefixedname matched against word "clone"
1082 relink recreates hardlinks between repository clones
1095 relink recreates hardlinks between repository clones
1083
1096
1084 Extension Commands:
1097 Extension Commands:
1085
1098
1086 qclone clone main and patch repository at same time
1099 qclone clone main and patch repository at same time
1087
1100
1088 Test unfound topic
1101 Test unfound topic
1089
1102
1090 $ hg help nonexistingtopicthatwillneverexisteverever
1103 $ hg help nonexistingtopicthatwillneverexisteverever
1091 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1104 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1092 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1105 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1093 [255]
1106 [255]
1094
1107
1095 Test unfound keyword
1108 Test unfound keyword
1096
1109
1097 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1110 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1098 abort: no matches
1111 abort: no matches
1099 (try "hg help" for a list of topics)
1112 (try "hg help" for a list of topics)
1100 [255]
1113 [255]
1101
1114
1102 Test omit indicating for help
1115 Test omit indicating for help
1103
1116
1104 $ cat > addverboseitems.py <<EOF
1117 $ cat > addverboseitems.py <<EOF
1105 > '''extension to test omit indicating.
1118 > '''extension to test omit indicating.
1106 >
1119 >
1107 > This paragraph is never omitted (for extension)
1120 > This paragraph is never omitted (for extension)
1108 >
1121 >
1109 > .. container:: verbose
1122 > .. container:: verbose
1110 >
1123 >
1111 > This paragraph is omitted,
1124 > This paragraph is omitted,
1112 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1125 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1113 >
1126 >
1114 > This paragraph is never omitted, too (for extension)
1127 > This paragraph is never omitted, too (for extension)
1115 > '''
1128 > '''
1116 >
1129 >
1117 > from mercurial import help, commands
1130 > from mercurial import help, commands
1118 > testtopic = """This paragraph is never omitted (for topic).
1131 > testtopic = """This paragraph is never omitted (for topic).
1119 >
1132 >
1120 > .. container:: verbose
1133 > .. container:: verbose
1121 >
1134 >
1122 > This paragraph is omitted,
1135 > This paragraph is omitted,
1123 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1136 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1124 >
1137 >
1125 > This paragraph is never omitted, too (for topic)
1138 > This paragraph is never omitted, too (for topic)
1126 > """
1139 > """
1127 > def extsetup(ui):
1140 > def extsetup(ui):
1128 > help.helptable.append((["topic-containing-verbose"],
1141 > help.helptable.append((["topic-containing-verbose"],
1129 > "This is the topic to test omit indicating.",
1142 > "This is the topic to test omit indicating.",
1130 > lambda ui: testtopic))
1143 > lambda ui: testtopic))
1131 > EOF
1144 > EOF
1132 $ echo '[extensions]' >> $HGRCPATH
1145 $ echo '[extensions]' >> $HGRCPATH
1133 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1146 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1134 $ hg help addverboseitems
1147 $ hg help addverboseitems
1135 addverboseitems extension - extension to test omit indicating.
1148 addverboseitems extension - extension to test omit indicating.
1136
1149
1137 This paragraph is never omitted (for extension)
1150 This paragraph is never omitted (for extension)
1138
1151
1139 This paragraph is never omitted, too (for extension)
1152 This paragraph is never omitted, too (for extension)
1140
1153
1141 (some details hidden, use --verbose to show complete help)
1154 (some details hidden, use --verbose to show complete help)
1142
1155
1143 no commands defined
1156 no commands defined
1144 $ hg help -v addverboseitems
1157 $ hg help -v addverboseitems
1145 addverboseitems extension - extension to test omit indicating.
1158 addverboseitems extension - extension to test omit indicating.
1146
1159
1147 This paragraph is never omitted (for extension)
1160 This paragraph is never omitted (for extension)
1148
1161
1149 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1162 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1150 extension)
1163 extension)
1151
1164
1152 This paragraph is never omitted, too (for extension)
1165 This paragraph is never omitted, too (for extension)
1153
1166
1154 no commands defined
1167 no commands defined
1155 $ hg help topic-containing-verbose
1168 $ hg help topic-containing-verbose
1156 This is the topic to test omit indicating.
1169 This is the topic to test omit indicating.
1157 """"""""""""""""""""""""""""""""""""""""""
1170 """"""""""""""""""""""""""""""""""""""""""
1158
1171
1159 This paragraph is never omitted (for topic).
1172 This paragraph is never omitted (for topic).
1160
1173
1161 This paragraph is never omitted, too (for topic)
1174 This paragraph is never omitted, too (for topic)
1162
1175
1163 (some details hidden, use --verbose to show complete help)
1176 (some details hidden, use --verbose to show complete help)
1164 $ hg help -v topic-containing-verbose
1177 $ hg help -v topic-containing-verbose
1165 This is the topic to test omit indicating.
1178 This is the topic to test omit indicating.
1166 """"""""""""""""""""""""""""""""""""""""""
1179 """"""""""""""""""""""""""""""""""""""""""
1167
1180
1168 This paragraph is never omitted (for topic).
1181 This paragraph is never omitted (for topic).
1169
1182
1170 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1183 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1171 topic)
1184 topic)
1172
1185
1173 This paragraph is never omitted, too (for topic)
1186 This paragraph is never omitted, too (for topic)
1174
1187
1175 Test section lookup
1188 Test section lookup
1176
1189
1177 $ hg help revset.merge
1190 $ hg help revset.merge
1178 "merge()"
1191 "merge()"
1179 Changeset is a merge changeset.
1192 Changeset is a merge changeset.
1180
1193
1181 $ hg help glossary.dag
1194 $ hg help glossary.dag
1182 DAG
1195 DAG
1183 The repository of changesets of a distributed version control system
1196 The repository of changesets of a distributed version control system
1184 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1197 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1185 of nodes and edges, where nodes correspond to changesets and edges
1198 of nodes and edges, where nodes correspond to changesets and edges
1186 imply a parent -> child relation. This graph can be visualized by
1199 imply a parent -> child relation. This graph can be visualized by
1187 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1200 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1188 limited by the requirement for children to have at most two parents.
1201 limited by the requirement for children to have at most two parents.
1189
1202
1190
1203
1191 $ hg help hgrc.paths
1204 $ hg help hgrc.paths
1192 "paths"
1205 "paths"
1193 -------
1206 -------
1194
1207
1195 Assigns symbolic names to repositories. The left side is the symbolic
1208 Assigns symbolic names to repositories. The left side is the symbolic
1196 name, and the right gives the directory or URL that is the location of the
1209 name, and the right gives the directory or URL that is the location of the
1197 repository. Default paths can be declared by setting the following
1210 repository. Default paths can be declared by setting the following
1198 entries.
1211 entries.
1199
1212
1200 "default"
1213 "default"
1201 Directory or URL to use when pulling if no source is specified.
1214 Directory or URL to use when pulling if no source is specified.
1202 (default: repository from which the current repository was cloned)
1215 (default: repository from which the current repository was cloned)
1203
1216
1204 "default-push"
1217 "default-push"
1205 Optional. Directory or URL to use when pushing if no destination is
1218 Optional. Directory or URL to use when pushing if no destination is
1206 specified.
1219 specified.
1207
1220
1208 Custom paths can be defined by assigning the path to a name that later can
1221 Custom paths can be defined by assigning the path to a name that later can
1209 be used from the command line. Example:
1222 be used from the command line. Example:
1210
1223
1211 [paths]
1224 [paths]
1212 my_path = http://example.com/path
1225 my_path = http://example.com/path
1213
1226
1214 To push to the path defined in "my_path" run the command:
1227 To push to the path defined in "my_path" run the command:
1215
1228
1216 hg push my_path
1229 hg push my_path
1217
1230
1218 $ hg help glossary.mcguffin
1231 $ hg help glossary.mcguffin
1219 abort: help section not found
1232 abort: help section not found
1220 [255]
1233 [255]
1221
1234
1222 $ hg help glossary.mc.guffin
1235 $ hg help glossary.mc.guffin
1223 abort: help section not found
1236 abort: help section not found
1224 [255]
1237 [255]
1225
1238
1226 $ hg help template.files
1239 $ hg help template.files
1227 files List of strings. All files modified, added, or removed by
1240 files List of strings. All files modified, added, or removed by
1228 this changeset.
1241 this changeset.
1229
1242
1230 Test dynamic list of merge tools only shows up once
1243 Test dynamic list of merge tools only shows up once
1231 $ hg help merge-tools
1244 $ hg help merge-tools
1232 Merge Tools
1245 Merge Tools
1233 """""""""""
1246 """""""""""
1234
1247
1235 To merge files Mercurial uses merge tools.
1248 To merge files Mercurial uses merge tools.
1236
1249
1237 A merge tool combines two different versions of a file into a merged file.
1250 A merge tool combines two different versions of a file into a merged file.
1238 Merge tools are given the two files and the greatest common ancestor of
1251 Merge tools are given the two files and the greatest common ancestor of
1239 the two file versions, so they can determine the changes made on both
1252 the two file versions, so they can determine the changes made on both
1240 branches.
1253 branches.
1241
1254
1242 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1255 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1243 backout" and in several extensions.
1256 backout" and in several extensions.
1244
1257
1245 Usually, the merge tool tries to automatically reconcile the files by
1258 Usually, the merge tool tries to automatically reconcile the files by
1246 combining all non-overlapping changes that occurred separately in the two
1259 combining all non-overlapping changes that occurred separately in the two
1247 different evolutions of the same initial base file. Furthermore, some
1260 different evolutions of the same initial base file. Furthermore, some
1248 interactive merge programs make it easier to manually resolve conflicting
1261 interactive merge programs make it easier to manually resolve conflicting
1249 merges, either in a graphical way, or by inserting some conflict markers.
1262 merges, either in a graphical way, or by inserting some conflict markers.
1250 Mercurial does not include any interactive merge programs but relies on
1263 Mercurial does not include any interactive merge programs but relies on
1251 external tools for that.
1264 external tools for that.
1252
1265
1253 Available merge tools
1266 Available merge tools
1254 =====================
1267 =====================
1255
1268
1256 External merge tools and their properties are configured in the merge-
1269 External merge tools and their properties are configured in the merge-
1257 tools configuration section - see hgrc(5) - but they can often just be
1270 tools configuration section - see hgrc(5) - but they can often just be
1258 named by their executable.
1271 named by their executable.
1259
1272
1260 A merge tool is generally usable if its executable can be found on the
1273 A merge tool is generally usable if its executable can be found on the
1261 system and if it can handle the merge. The executable is found if it is an
1274 system and if it can handle the merge. The executable is found if it is an
1262 absolute or relative executable path or the name of an application in the
1275 absolute or relative executable path or the name of an application in the
1263 executable search path. The tool is assumed to be able to handle the merge
1276 executable search path. The tool is assumed to be able to handle the merge
1264 if it can handle symlinks if the file is a symlink, if it can handle
1277 if it can handle symlinks if the file is a symlink, if it can handle
1265 binary files if the file is binary, and if a GUI is available if the tool
1278 binary files if the file is binary, and if a GUI is available if the tool
1266 requires a GUI.
1279 requires a GUI.
1267
1280
1268 There are some internal merge tools which can be used. The internal merge
1281 There are some internal merge tools which can be used. The internal merge
1269 tools are:
1282 tools are:
1270
1283
1271 ":dump"
1284 ":dump"
1272 Creates three versions of the files to merge, containing the contents of
1285 Creates three versions of the files to merge, containing the contents of
1273 local, other and base. These files can then be used to perform a merge
1286 local, other and base. These files can then be used to perform a merge
1274 manually. If the file to be merged is named "a.txt", these files will
1287 manually. If the file to be merged is named "a.txt", these files will
1275 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1288 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1276 they will be placed in the same directory as "a.txt".
1289 they will be placed in the same directory as "a.txt".
1277
1290
1278 ":fail"
1291 ":fail"
1279 Rather than attempting to merge files that were modified on both
1292 Rather than attempting to merge files that were modified on both
1280 branches, it marks them as unresolved. The resolve command must be used
1293 branches, it marks them as unresolved. The resolve command must be used
1281 to resolve these conflicts.
1294 to resolve these conflicts.
1282
1295
1283 ":local"
1296 ":local"
1284 Uses the local version of files as the merged version.
1297 Uses the local version of files as the merged version.
1285
1298
1286 ":merge"
1299 ":merge"
1287 Uses the internal non-interactive simple merge algorithm for merging
1300 Uses the internal non-interactive simple merge algorithm for merging
1288 files. It will fail if there are any conflicts and leave markers in the
1301 files. It will fail if there are any conflicts and leave markers in the
1289 partially merged file. Markers will have two sections, one for each side
1302 partially merged file. Markers will have two sections, one for each side
1290 of merge.
1303 of merge.
1291
1304
1292 ":merge-local"
1305 ":merge-local"
1293 Like :merge, but resolve all conflicts non-interactively in favor of the
1306 Like :merge, but resolve all conflicts non-interactively in favor of the
1294 local changes.
1307 local changes.
1295
1308
1296 ":merge-other"
1309 ":merge-other"
1297 Like :merge, but resolve all conflicts non-interactively in favor of the
1310 Like :merge, but resolve all conflicts non-interactively in favor of the
1298 other changes.
1311 other changes.
1299
1312
1300 ":merge3"
1313 ":merge3"
1301 Uses the internal non-interactive simple merge algorithm for merging
1314 Uses the internal non-interactive simple merge algorithm for merging
1302 files. It will fail if there are any conflicts and leave markers in the
1315 files. It will fail if there are any conflicts and leave markers in the
1303 partially merged file. Marker will have three sections, one from each
1316 partially merged file. Marker will have three sections, one from each
1304 side of the merge and one for the base content.
1317 side of the merge and one for the base content.
1305
1318
1306 ":other"
1319 ":other"
1307 Uses the other version of files as the merged version.
1320 Uses the other version of files as the merged version.
1308
1321
1309 ":prompt"
1322 ":prompt"
1310 Asks the user which of the local or the other version to keep as the
1323 Asks the user which of the local or the other version to keep as the
1311 merged version.
1324 merged version.
1312
1325
1313 ":tagmerge"
1326 ":tagmerge"
1314 Uses the internal tag merge algorithm (experimental).
1327 Uses the internal tag merge algorithm (experimental).
1315
1328
1316 ":union"
1329 ":union"
1317 Uses the internal non-interactive simple merge algorithm for merging
1330 Uses the internal non-interactive simple merge algorithm for merging
1318 files. It will use both left and right sides for conflict regions. No
1331 files. It will use both left and right sides for conflict regions. No
1319 markers are inserted.
1332 markers are inserted.
1320
1333
1321 Internal tools are always available and do not require a GUI but will by
1334 Internal tools are always available and do not require a GUI but will by
1322 default not handle symlinks or binary files.
1335 default not handle symlinks or binary files.
1323
1336
1324 Choosing a merge tool
1337 Choosing a merge tool
1325 =====================
1338 =====================
1326
1339
1327 Mercurial uses these rules when deciding which merge tool to use:
1340 Mercurial uses these rules when deciding which merge tool to use:
1328
1341
1329 1. If a tool has been specified with the --tool option to merge or
1342 1. If a tool has been specified with the --tool option to merge or
1330 resolve, it is used. If it is the name of a tool in the merge-tools
1343 resolve, it is used. If it is the name of a tool in the merge-tools
1331 configuration, its configuration is used. Otherwise the specified tool
1344 configuration, its configuration is used. Otherwise the specified tool
1332 must be executable by the shell.
1345 must be executable by the shell.
1333 2. If the "HGMERGE" environment variable is present, its value is used and
1346 2. If the "HGMERGE" environment variable is present, its value is used and
1334 must be executable by the shell.
1347 must be executable by the shell.
1335 3. If the filename of the file to be merged matches any of the patterns in
1348 3. If the filename of the file to be merged matches any of the patterns in
1336 the merge-patterns configuration section, the first usable merge tool
1349 the merge-patterns configuration section, the first usable merge tool
1337 corresponding to a matching pattern is used. Here, binary capabilities
1350 corresponding to a matching pattern is used. Here, binary capabilities
1338 of the merge tool are not considered.
1351 of the merge tool are not considered.
1339 4. If ui.merge is set it will be considered next. If the value is not the
1352 4. If ui.merge is set it will be considered next. If the value is not the
1340 name of a configured tool, the specified value is used and must be
1353 name of a configured tool, the specified value is used and must be
1341 executable by the shell. Otherwise the named tool is used if it is
1354 executable by the shell. Otherwise the named tool is used if it is
1342 usable.
1355 usable.
1343 5. If any usable merge tools are present in the merge-tools configuration
1356 5. If any usable merge tools are present in the merge-tools configuration
1344 section, the one with the highest priority is used.
1357 section, the one with the highest priority is used.
1345 6. If a program named "hgmerge" can be found on the system, it is used -
1358 6. If a program named "hgmerge" can be found on the system, it is used -
1346 but it will by default not be used for symlinks and binary files.
1359 but it will by default not be used for symlinks and binary files.
1347 7. If the file to be merged is not binary and is not a symlink, then
1360 7. If the file to be merged is not binary and is not a symlink, then
1348 internal ":merge" is used.
1361 internal ":merge" is used.
1349 8. The merge of the file fails and must be resolved before commit.
1362 8. The merge of the file fails and must be resolved before commit.
1350
1363
1351 Note:
1364 Note:
1352 After selecting a merge program, Mercurial will by default attempt to
1365 After selecting a merge program, Mercurial will by default attempt to
1353 merge the files using a simple merge algorithm first. Only if it
1366 merge the files using a simple merge algorithm first. Only if it
1354 doesn't succeed because of conflicting changes Mercurial will actually
1367 doesn't succeed because of conflicting changes Mercurial will actually
1355 execute the merge program. Whether to use the simple merge algorithm
1368 execute the merge program. Whether to use the simple merge algorithm
1356 first can be controlled by the premerge setting of the merge tool.
1369 first can be controlled by the premerge setting of the merge tool.
1357 Premerge is enabled by default unless the file is binary or a symlink.
1370 Premerge is enabled by default unless the file is binary or a symlink.
1358
1371
1359 See the merge-tools and ui sections of hgrc(5) for details on the
1372 See the merge-tools and ui sections of hgrc(5) for details on the
1360 configuration of merge tools.
1373 configuration of merge tools.
1361
1374
1362 Test usage of section marks in help documents
1375 Test usage of section marks in help documents
1363
1376
1364 $ cd "$TESTDIR"/../doc
1377 $ cd "$TESTDIR"/../doc
1365 $ python check-seclevel.py
1378 $ python check-seclevel.py
1366 $ cd $TESTTMP
1379 $ cd $TESTTMP
1367
1380
1368 #if serve
1381 #if serve
1369
1382
1370 Test the help pages in hgweb.
1383 Test the help pages in hgweb.
1371
1384
1372 Dish up an empty repo; serve it cold.
1385 Dish up an empty repo; serve it cold.
1373
1386
1374 $ hg init "$TESTTMP/test"
1387 $ hg init "$TESTTMP/test"
1375 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1388 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1376 $ cat hg.pid >> $DAEMON_PIDS
1389 $ cat hg.pid >> $DAEMON_PIDS
1377
1390
1378 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1391 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1379 200 Script output follows
1392 200 Script output follows
1380
1393
1381 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1394 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1382 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1395 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1383 <head>
1396 <head>
1384 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1397 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1385 <meta name="robots" content="index, nofollow" />
1398 <meta name="robots" content="index, nofollow" />
1386 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1399 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1387 <script type="text/javascript" src="/static/mercurial.js"></script>
1400 <script type="text/javascript" src="/static/mercurial.js"></script>
1388
1401
1389 <title>Help: Index</title>
1402 <title>Help: Index</title>
1390 </head>
1403 </head>
1391 <body>
1404 <body>
1392
1405
1393 <div class="container">
1406 <div class="container">
1394 <div class="menu">
1407 <div class="menu">
1395 <div class="logo">
1408 <div class="logo">
1396 <a href="https://mercurial-scm.org/">
1409 <a href="https://mercurial-scm.org/">
1397 <img src="/static/hglogo.png" alt="mercurial" /></a>
1410 <img src="/static/hglogo.png" alt="mercurial" /></a>
1398 </div>
1411 </div>
1399 <ul>
1412 <ul>
1400 <li><a href="/shortlog">log</a></li>
1413 <li><a href="/shortlog">log</a></li>
1401 <li><a href="/graph">graph</a></li>
1414 <li><a href="/graph">graph</a></li>
1402 <li><a href="/tags">tags</a></li>
1415 <li><a href="/tags">tags</a></li>
1403 <li><a href="/bookmarks">bookmarks</a></li>
1416 <li><a href="/bookmarks">bookmarks</a></li>
1404 <li><a href="/branches">branches</a></li>
1417 <li><a href="/branches">branches</a></li>
1405 </ul>
1418 </ul>
1406 <ul>
1419 <ul>
1407 <li class="active">help</li>
1420 <li class="active">help</li>
1408 </ul>
1421 </ul>
1409 </div>
1422 </div>
1410
1423
1411 <div class="main">
1424 <div class="main">
1412 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1425 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1413 <form class="search" action="/log">
1426 <form class="search" action="/log">
1414
1427
1415 <p><input name="rev" id="search1" type="text" size="30" /></p>
1428 <p><input name="rev" id="search1" type="text" size="30" /></p>
1416 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1429 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1417 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1430 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1418 </form>
1431 </form>
1419 <table class="bigtable">
1432 <table class="bigtable">
1420 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1433 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1421
1434
1422 <tr><td>
1435 <tr><td>
1423 <a href="/help/config">
1436 <a href="/help/config">
1424 config
1437 config
1425 </a>
1438 </a>
1426 </td><td>
1439 </td><td>
1427 Configuration Files
1440 Configuration Files
1428 </td></tr>
1441 </td></tr>
1429 <tr><td>
1442 <tr><td>
1430 <a href="/help/dates">
1443 <a href="/help/dates">
1431 dates
1444 dates
1432 </a>
1445 </a>
1433 </td><td>
1446 </td><td>
1434 Date Formats
1447 Date Formats
1435 </td></tr>
1448 </td></tr>
1436 <tr><td>
1449 <tr><td>
1437 <a href="/help/diffs">
1450 <a href="/help/diffs">
1438 diffs
1451 diffs
1439 </a>
1452 </a>
1440 </td><td>
1453 </td><td>
1441 Diff Formats
1454 Diff Formats
1442 </td></tr>
1455 </td></tr>
1443 <tr><td>
1456 <tr><td>
1444 <a href="/help/environment">
1457 <a href="/help/environment">
1445 environment
1458 environment
1446 </a>
1459 </a>
1447 </td><td>
1460 </td><td>
1448 Environment Variables
1461 Environment Variables
1449 </td></tr>
1462 </td></tr>
1450 <tr><td>
1463 <tr><td>
1451 <a href="/help/extensions">
1464 <a href="/help/extensions">
1452 extensions
1465 extensions
1453 </a>
1466 </a>
1454 </td><td>
1467 </td><td>
1455 Using Additional Features
1468 Using Additional Features
1456 </td></tr>
1469 </td></tr>
1457 <tr><td>
1470 <tr><td>
1458 <a href="/help/filesets">
1471 <a href="/help/filesets">
1459 filesets
1472 filesets
1460 </a>
1473 </a>
1461 </td><td>
1474 </td><td>
1462 Specifying File Sets
1475 Specifying File Sets
1463 </td></tr>
1476 </td></tr>
1464 <tr><td>
1477 <tr><td>
1465 <a href="/help/glossary">
1478 <a href="/help/glossary">
1466 glossary
1479 glossary
1467 </a>
1480 </a>
1468 </td><td>
1481 </td><td>
1469 Glossary
1482 Glossary
1470 </td></tr>
1483 </td></tr>
1471 <tr><td>
1484 <tr><td>
1472 <a href="/help/hgignore">
1485 <a href="/help/hgignore">
1473 hgignore
1486 hgignore
1474 </a>
1487 </a>
1475 </td><td>
1488 </td><td>
1476 Syntax for Mercurial Ignore Files
1489 Syntax for Mercurial Ignore Files
1477 </td></tr>
1490 </td></tr>
1478 <tr><td>
1491 <tr><td>
1479 <a href="/help/hgweb">
1492 <a href="/help/hgweb">
1480 hgweb
1493 hgweb
1481 </a>
1494 </a>
1482 </td><td>
1495 </td><td>
1483 Configuring hgweb
1496 Configuring hgweb
1484 </td></tr>
1497 </td></tr>
1485 <tr><td>
1498 <tr><td>
1486 <a href="/help/merge-tools">
1499 <a href="/help/merge-tools">
1487 merge-tools
1500 merge-tools
1488 </a>
1501 </a>
1489 </td><td>
1502 </td><td>
1490 Merge Tools
1503 Merge Tools
1491 </td></tr>
1504 </td></tr>
1492 <tr><td>
1505 <tr><td>
1493 <a href="/help/multirevs">
1506 <a href="/help/multirevs">
1494 multirevs
1507 multirevs
1495 </a>
1508 </a>
1496 </td><td>
1509 </td><td>
1497 Specifying Multiple Revisions
1510 Specifying Multiple Revisions
1498 </td></tr>
1511 </td></tr>
1499 <tr><td>
1512 <tr><td>
1500 <a href="/help/patterns">
1513 <a href="/help/patterns">
1501 patterns
1514 patterns
1502 </a>
1515 </a>
1503 </td><td>
1516 </td><td>
1504 File Name Patterns
1517 File Name Patterns
1505 </td></tr>
1518 </td></tr>
1506 <tr><td>
1519 <tr><td>
1507 <a href="/help/phases">
1520 <a href="/help/phases">
1508 phases
1521 phases
1509 </a>
1522 </a>
1510 </td><td>
1523 </td><td>
1511 Working with Phases
1524 Working with Phases
1512 </td></tr>
1525 </td></tr>
1513 <tr><td>
1526 <tr><td>
1514 <a href="/help/revisions">
1527 <a href="/help/revisions">
1515 revisions
1528 revisions
1516 </a>
1529 </a>
1517 </td><td>
1530 </td><td>
1518 Specifying Single Revisions
1531 Specifying Single Revisions
1519 </td></tr>
1532 </td></tr>
1520 <tr><td>
1533 <tr><td>
1521 <a href="/help/revsets">
1534 <a href="/help/revsets">
1522 revsets
1535 revsets
1523 </a>
1536 </a>
1524 </td><td>
1537 </td><td>
1525 Specifying Revision Sets
1538 Specifying Revision Sets
1526 </td></tr>
1539 </td></tr>
1527 <tr><td>
1540 <tr><td>
1528 <a href="/help/scripting">
1541 <a href="/help/scripting">
1529 scripting
1542 scripting
1530 </a>
1543 </a>
1531 </td><td>
1544 </td><td>
1532 Using Mercurial from scripts and automation
1545 Using Mercurial from scripts and automation
1533 </td></tr>
1546 </td></tr>
1534 <tr><td>
1547 <tr><td>
1535 <a href="/help/subrepos">
1548 <a href="/help/subrepos">
1536 subrepos
1549 subrepos
1537 </a>
1550 </a>
1538 </td><td>
1551 </td><td>
1539 Subrepositories
1552 Subrepositories
1540 </td></tr>
1553 </td></tr>
1541 <tr><td>
1554 <tr><td>
1542 <a href="/help/templating">
1555 <a href="/help/templating">
1543 templating
1556 templating
1544 </a>
1557 </a>
1545 </td><td>
1558 </td><td>
1546 Template Usage
1559 Template Usage
1547 </td></tr>
1560 </td></tr>
1548 <tr><td>
1561 <tr><td>
1549 <a href="/help/urls">
1562 <a href="/help/urls">
1550 urls
1563 urls
1551 </a>
1564 </a>
1552 </td><td>
1565 </td><td>
1553 URL Paths
1566 URL Paths
1554 </td></tr>
1567 </td></tr>
1555 <tr><td>
1568 <tr><td>
1556 <a href="/help/topic-containing-verbose">
1569 <a href="/help/topic-containing-verbose">
1557 topic-containing-verbose
1570 topic-containing-verbose
1558 </a>
1571 </a>
1559 </td><td>
1572 </td><td>
1560 This is the topic to test omit indicating.
1573 This is the topic to test omit indicating.
1561 </td></tr>
1574 </td></tr>
1562
1575
1563 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1576 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1564
1577
1565 <tr><td>
1578 <tr><td>
1566 <a href="/help/add">
1579 <a href="/help/add">
1567 add
1580 add
1568 </a>
1581 </a>
1569 </td><td>
1582 </td><td>
1570 add the specified files on the next commit
1583 add the specified files on the next commit
1571 </td></tr>
1584 </td></tr>
1572 <tr><td>
1585 <tr><td>
1573 <a href="/help/annotate">
1586 <a href="/help/annotate">
1574 annotate
1587 annotate
1575 </a>
1588 </a>
1576 </td><td>
1589 </td><td>
1577 show changeset information by line for each file
1590 show changeset information by line for each file
1578 </td></tr>
1591 </td></tr>
1579 <tr><td>
1592 <tr><td>
1580 <a href="/help/clone">
1593 <a href="/help/clone">
1581 clone
1594 clone
1582 </a>
1595 </a>
1583 </td><td>
1596 </td><td>
1584 make a copy of an existing repository
1597 make a copy of an existing repository
1585 </td></tr>
1598 </td></tr>
1586 <tr><td>
1599 <tr><td>
1587 <a href="/help/commit">
1600 <a href="/help/commit">
1588 commit
1601 commit
1589 </a>
1602 </a>
1590 </td><td>
1603 </td><td>
1591 commit the specified files or all outstanding changes
1604 commit the specified files or all outstanding changes
1592 </td></tr>
1605 </td></tr>
1593 <tr><td>
1606 <tr><td>
1594 <a href="/help/diff">
1607 <a href="/help/diff">
1595 diff
1608 diff
1596 </a>
1609 </a>
1597 </td><td>
1610 </td><td>
1598 diff repository (or selected files)
1611 diff repository (or selected files)
1599 </td></tr>
1612 </td></tr>
1600 <tr><td>
1613 <tr><td>
1601 <a href="/help/export">
1614 <a href="/help/export">
1602 export
1615 export
1603 </a>
1616 </a>
1604 </td><td>
1617 </td><td>
1605 dump the header and diffs for one or more changesets
1618 dump the header and diffs for one or more changesets
1606 </td></tr>
1619 </td></tr>
1607 <tr><td>
1620 <tr><td>
1608 <a href="/help/forget">
1621 <a href="/help/forget">
1609 forget
1622 forget
1610 </a>
1623 </a>
1611 </td><td>
1624 </td><td>
1612 forget the specified files on the next commit
1625 forget the specified files on the next commit
1613 </td></tr>
1626 </td></tr>
1614 <tr><td>
1627 <tr><td>
1615 <a href="/help/init">
1628 <a href="/help/init">
1616 init
1629 init
1617 </a>
1630 </a>
1618 </td><td>
1631 </td><td>
1619 create a new repository in the given directory
1632 create a new repository in the given directory
1620 </td></tr>
1633 </td></tr>
1621 <tr><td>
1634 <tr><td>
1622 <a href="/help/log">
1635 <a href="/help/log">
1623 log
1636 log
1624 </a>
1637 </a>
1625 </td><td>
1638 </td><td>
1626 show revision history of entire repository or files
1639 show revision history of entire repository or files
1627 </td></tr>
1640 </td></tr>
1628 <tr><td>
1641 <tr><td>
1629 <a href="/help/merge">
1642 <a href="/help/merge">
1630 merge
1643 merge
1631 </a>
1644 </a>
1632 </td><td>
1645 </td><td>
1633 merge another revision into working directory
1646 merge another revision into working directory
1634 </td></tr>
1647 </td></tr>
1635 <tr><td>
1648 <tr><td>
1636 <a href="/help/pull">
1649 <a href="/help/pull">
1637 pull
1650 pull
1638 </a>
1651 </a>
1639 </td><td>
1652 </td><td>
1640 pull changes from the specified source
1653 pull changes from the specified source
1641 </td></tr>
1654 </td></tr>
1642 <tr><td>
1655 <tr><td>
1643 <a href="/help/push">
1656 <a href="/help/push">
1644 push
1657 push
1645 </a>
1658 </a>
1646 </td><td>
1659 </td><td>
1647 push changes to the specified destination
1660 push changes to the specified destination
1648 </td></tr>
1661 </td></tr>
1649 <tr><td>
1662 <tr><td>
1650 <a href="/help/remove">
1663 <a href="/help/remove">
1651 remove
1664 remove
1652 </a>
1665 </a>
1653 </td><td>
1666 </td><td>
1654 remove the specified files on the next commit
1667 remove the specified files on the next commit
1655 </td></tr>
1668 </td></tr>
1656 <tr><td>
1669 <tr><td>
1657 <a href="/help/serve">
1670 <a href="/help/serve">
1658 serve
1671 serve
1659 </a>
1672 </a>
1660 </td><td>
1673 </td><td>
1661 start stand-alone webserver
1674 start stand-alone webserver
1662 </td></tr>
1675 </td></tr>
1663 <tr><td>
1676 <tr><td>
1664 <a href="/help/status">
1677 <a href="/help/status">
1665 status
1678 status
1666 </a>
1679 </a>
1667 </td><td>
1680 </td><td>
1668 show changed files in the working directory
1681 show changed files in the working directory
1669 </td></tr>
1682 </td></tr>
1670 <tr><td>
1683 <tr><td>
1671 <a href="/help/summary">
1684 <a href="/help/summary">
1672 summary
1685 summary
1673 </a>
1686 </a>
1674 </td><td>
1687 </td><td>
1675 summarize working directory state
1688 summarize working directory state
1676 </td></tr>
1689 </td></tr>
1677 <tr><td>
1690 <tr><td>
1678 <a href="/help/update">
1691 <a href="/help/update">
1679 update
1692 update
1680 </a>
1693 </a>
1681 </td><td>
1694 </td><td>
1682 update working directory (or switch revisions)
1695 update working directory (or switch revisions)
1683 </td></tr>
1696 </td></tr>
1684
1697
1685 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1698 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1686
1699
1687 <tr><td>
1700 <tr><td>
1688 <a href="/help/addremove">
1701 <a href="/help/addremove">
1689 addremove
1702 addremove
1690 </a>
1703 </a>
1691 </td><td>
1704 </td><td>
1692 add all new files, delete all missing files
1705 add all new files, delete all missing files
1693 </td></tr>
1706 </td></tr>
1694 <tr><td>
1707 <tr><td>
1695 <a href="/help/archive">
1708 <a href="/help/archive">
1696 archive
1709 archive
1697 </a>
1710 </a>
1698 </td><td>
1711 </td><td>
1699 create an unversioned archive of a repository revision
1712 create an unversioned archive of a repository revision
1700 </td></tr>
1713 </td></tr>
1701 <tr><td>
1714 <tr><td>
1702 <a href="/help/backout">
1715 <a href="/help/backout">
1703 backout
1716 backout
1704 </a>
1717 </a>
1705 </td><td>
1718 </td><td>
1706 reverse effect of earlier changeset
1719 reverse effect of earlier changeset
1707 </td></tr>
1720 </td></tr>
1708 <tr><td>
1721 <tr><td>
1709 <a href="/help/bisect">
1722 <a href="/help/bisect">
1710 bisect
1723 bisect
1711 </a>
1724 </a>
1712 </td><td>
1725 </td><td>
1713 subdivision search of changesets
1726 subdivision search of changesets
1714 </td></tr>
1727 </td></tr>
1715 <tr><td>
1728 <tr><td>
1716 <a href="/help/bookmarks">
1729 <a href="/help/bookmarks">
1717 bookmarks
1730 bookmarks
1718 </a>
1731 </a>
1719 </td><td>
1732 </td><td>
1720 create a new bookmark or list existing bookmarks
1733 create a new bookmark or list existing bookmarks
1721 </td></tr>
1734 </td></tr>
1722 <tr><td>
1735 <tr><td>
1723 <a href="/help/branch">
1736 <a href="/help/branch">
1724 branch
1737 branch
1725 </a>
1738 </a>
1726 </td><td>
1739 </td><td>
1727 set or show the current branch name
1740 set or show the current branch name
1728 </td></tr>
1741 </td></tr>
1729 <tr><td>
1742 <tr><td>
1730 <a href="/help/branches">
1743 <a href="/help/branches">
1731 branches
1744 branches
1732 </a>
1745 </a>
1733 </td><td>
1746 </td><td>
1734 list repository named branches
1747 list repository named branches
1735 </td></tr>
1748 </td></tr>
1736 <tr><td>
1749 <tr><td>
1737 <a href="/help/bundle">
1750 <a href="/help/bundle">
1738 bundle
1751 bundle
1739 </a>
1752 </a>
1740 </td><td>
1753 </td><td>
1741 create a changegroup file
1754 create a changegroup file
1742 </td></tr>
1755 </td></tr>
1743 <tr><td>
1756 <tr><td>
1744 <a href="/help/cat">
1757 <a href="/help/cat">
1745 cat
1758 cat
1746 </a>
1759 </a>
1747 </td><td>
1760 </td><td>
1748 output the current or given revision of files
1761 output the current or given revision of files
1749 </td></tr>
1762 </td></tr>
1750 <tr><td>
1763 <tr><td>
1751 <a href="/help/config">
1764 <a href="/help/config">
1752 config
1765 config
1753 </a>
1766 </a>
1754 </td><td>
1767 </td><td>
1755 show combined config settings from all hgrc files
1768 show combined config settings from all hgrc files
1756 </td></tr>
1769 </td></tr>
1757 <tr><td>
1770 <tr><td>
1758 <a href="/help/copy">
1771 <a href="/help/copy">
1759 copy
1772 copy
1760 </a>
1773 </a>
1761 </td><td>
1774 </td><td>
1762 mark files as copied for the next commit
1775 mark files as copied for the next commit
1763 </td></tr>
1776 </td></tr>
1764 <tr><td>
1777 <tr><td>
1765 <a href="/help/files">
1778 <a href="/help/files">
1766 files
1779 files
1767 </a>
1780 </a>
1768 </td><td>
1781 </td><td>
1769 list tracked files
1782 list tracked files
1770 </td></tr>
1783 </td></tr>
1771 <tr><td>
1784 <tr><td>
1772 <a href="/help/graft">
1785 <a href="/help/graft">
1773 graft
1786 graft
1774 </a>
1787 </a>
1775 </td><td>
1788 </td><td>
1776 copy changes from other branches onto the current branch
1789 copy changes from other branches onto the current branch
1777 </td></tr>
1790 </td></tr>
1778 <tr><td>
1791 <tr><td>
1779 <a href="/help/grep">
1792 <a href="/help/grep">
1780 grep
1793 grep
1781 </a>
1794 </a>
1782 </td><td>
1795 </td><td>
1783 search for a pattern in specified files and revisions
1796 search for a pattern in specified files and revisions
1784 </td></tr>
1797 </td></tr>
1785 <tr><td>
1798 <tr><td>
1786 <a href="/help/heads">
1799 <a href="/help/heads">
1787 heads
1800 heads
1788 </a>
1801 </a>
1789 </td><td>
1802 </td><td>
1790 show branch heads
1803 show branch heads
1791 </td></tr>
1804 </td></tr>
1792 <tr><td>
1805 <tr><td>
1793 <a href="/help/help">
1806 <a href="/help/help">
1794 help
1807 help
1795 </a>
1808 </a>
1796 </td><td>
1809 </td><td>
1797 show help for a given topic or a help overview
1810 show help for a given topic or a help overview
1798 </td></tr>
1811 </td></tr>
1799 <tr><td>
1812 <tr><td>
1800 <a href="/help/identify">
1813 <a href="/help/identify">
1801 identify
1814 identify
1802 </a>
1815 </a>
1803 </td><td>
1816 </td><td>
1804 identify the working directory or specified revision
1817 identify the working directory or specified revision
1805 </td></tr>
1818 </td></tr>
1806 <tr><td>
1819 <tr><td>
1807 <a href="/help/import">
1820 <a href="/help/import">
1808 import
1821 import
1809 </a>
1822 </a>
1810 </td><td>
1823 </td><td>
1811 import an ordered set of patches
1824 import an ordered set of patches
1812 </td></tr>
1825 </td></tr>
1813 <tr><td>
1826 <tr><td>
1814 <a href="/help/incoming">
1827 <a href="/help/incoming">
1815 incoming
1828 incoming
1816 </a>
1829 </a>
1817 </td><td>
1830 </td><td>
1818 show new changesets found in source
1831 show new changesets found in source
1819 </td></tr>
1832 </td></tr>
1820 <tr><td>
1833 <tr><td>
1821 <a href="/help/manifest">
1834 <a href="/help/manifest">
1822 manifest
1835 manifest
1823 </a>
1836 </a>
1824 </td><td>
1837 </td><td>
1825 output the current or given revision of the project manifest
1838 output the current or given revision of the project manifest
1826 </td></tr>
1839 </td></tr>
1827 <tr><td>
1840 <tr><td>
1828 <a href="/help/nohelp">
1841 <a href="/help/nohelp">
1829 nohelp
1842 nohelp
1830 </a>
1843 </a>
1831 </td><td>
1844 </td><td>
1832 (no help text available)
1845 (no help text available)
1833 </td></tr>
1846 </td></tr>
1834 <tr><td>
1847 <tr><td>
1835 <a href="/help/outgoing">
1848 <a href="/help/outgoing">
1836 outgoing
1849 outgoing
1837 </a>
1850 </a>
1838 </td><td>
1851 </td><td>
1839 show changesets not found in the destination
1852 show changesets not found in the destination
1840 </td></tr>
1853 </td></tr>
1841 <tr><td>
1854 <tr><td>
1842 <a href="/help/paths">
1855 <a href="/help/paths">
1843 paths
1856 paths
1844 </a>
1857 </a>
1845 </td><td>
1858 </td><td>
1846 show aliases for remote repositories
1859 show aliases for remote repositories
1847 </td></tr>
1860 </td></tr>
1848 <tr><td>
1861 <tr><td>
1849 <a href="/help/phase">
1862 <a href="/help/phase">
1850 phase
1863 phase
1851 </a>
1864 </a>
1852 </td><td>
1865 </td><td>
1853 set or show the current phase name
1866 set or show the current phase name
1854 </td></tr>
1867 </td></tr>
1855 <tr><td>
1868 <tr><td>
1856 <a href="/help/recover">
1869 <a href="/help/recover">
1857 recover
1870 recover
1858 </a>
1871 </a>
1859 </td><td>
1872 </td><td>
1860 roll back an interrupted transaction
1873 roll back an interrupted transaction
1861 </td></tr>
1874 </td></tr>
1862 <tr><td>
1875 <tr><td>
1863 <a href="/help/rename">
1876 <a href="/help/rename">
1864 rename
1877 rename
1865 </a>
1878 </a>
1866 </td><td>
1879 </td><td>
1867 rename files; equivalent of copy + remove
1880 rename files; equivalent of copy + remove
1868 </td></tr>
1881 </td></tr>
1869 <tr><td>
1882 <tr><td>
1870 <a href="/help/resolve">
1883 <a href="/help/resolve">
1871 resolve
1884 resolve
1872 </a>
1885 </a>
1873 </td><td>
1886 </td><td>
1874 redo merges or set/view the merge status of files
1887 redo merges or set/view the merge status of files
1875 </td></tr>
1888 </td></tr>
1876 <tr><td>
1889 <tr><td>
1877 <a href="/help/revert">
1890 <a href="/help/revert">
1878 revert
1891 revert
1879 </a>
1892 </a>
1880 </td><td>
1893 </td><td>
1881 restore files to their checkout state
1894 restore files to their checkout state
1882 </td></tr>
1895 </td></tr>
1883 <tr><td>
1896 <tr><td>
1884 <a href="/help/root">
1897 <a href="/help/root">
1885 root
1898 root
1886 </a>
1899 </a>
1887 </td><td>
1900 </td><td>
1888 print the root (top) of the current working directory
1901 print the root (top) of the current working directory
1889 </td></tr>
1902 </td></tr>
1890 <tr><td>
1903 <tr><td>
1891 <a href="/help/tag">
1904 <a href="/help/tag">
1892 tag
1905 tag
1893 </a>
1906 </a>
1894 </td><td>
1907 </td><td>
1895 add one or more tags for the current or given revision
1908 add one or more tags for the current or given revision
1896 </td></tr>
1909 </td></tr>
1897 <tr><td>
1910 <tr><td>
1898 <a href="/help/tags">
1911 <a href="/help/tags">
1899 tags
1912 tags
1900 </a>
1913 </a>
1901 </td><td>
1914 </td><td>
1902 list repository tags
1915 list repository tags
1903 </td></tr>
1916 </td></tr>
1904 <tr><td>
1917 <tr><td>
1905 <a href="/help/unbundle">
1918 <a href="/help/unbundle">
1906 unbundle
1919 unbundle
1907 </a>
1920 </a>
1908 </td><td>
1921 </td><td>
1909 apply one or more changegroup files
1922 apply one or more changegroup files
1910 </td></tr>
1923 </td></tr>
1911 <tr><td>
1924 <tr><td>
1912 <a href="/help/verify">
1925 <a href="/help/verify">
1913 verify
1926 verify
1914 </a>
1927 </a>
1915 </td><td>
1928 </td><td>
1916 verify the integrity of the repository
1929 verify the integrity of the repository
1917 </td></tr>
1930 </td></tr>
1918 <tr><td>
1931 <tr><td>
1919 <a href="/help/version">
1932 <a href="/help/version">
1920 version
1933 version
1921 </a>
1934 </a>
1922 </td><td>
1935 </td><td>
1923 output version and copyright information
1936 output version and copyright information
1924 </td></tr>
1937 </td></tr>
1925 </table>
1938 </table>
1926 </div>
1939 </div>
1927 </div>
1940 </div>
1928
1941
1929 <script type="text/javascript">process_dates()</script>
1942 <script type="text/javascript">process_dates()</script>
1930
1943
1931
1944
1932 </body>
1945 </body>
1933 </html>
1946 </html>
1934
1947
1935
1948
1936 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1949 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1937 200 Script output follows
1950 200 Script output follows
1938
1951
1939 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1952 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1940 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1953 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1941 <head>
1954 <head>
1942 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1955 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1943 <meta name="robots" content="index, nofollow" />
1956 <meta name="robots" content="index, nofollow" />
1944 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1957 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1945 <script type="text/javascript" src="/static/mercurial.js"></script>
1958 <script type="text/javascript" src="/static/mercurial.js"></script>
1946
1959
1947 <title>Help: add</title>
1960 <title>Help: add</title>
1948 </head>
1961 </head>
1949 <body>
1962 <body>
1950
1963
1951 <div class="container">
1964 <div class="container">
1952 <div class="menu">
1965 <div class="menu">
1953 <div class="logo">
1966 <div class="logo">
1954 <a href="https://mercurial-scm.org/">
1967 <a href="https://mercurial-scm.org/">
1955 <img src="/static/hglogo.png" alt="mercurial" /></a>
1968 <img src="/static/hglogo.png" alt="mercurial" /></a>
1956 </div>
1969 </div>
1957 <ul>
1970 <ul>
1958 <li><a href="/shortlog">log</a></li>
1971 <li><a href="/shortlog">log</a></li>
1959 <li><a href="/graph">graph</a></li>
1972 <li><a href="/graph">graph</a></li>
1960 <li><a href="/tags">tags</a></li>
1973 <li><a href="/tags">tags</a></li>
1961 <li><a href="/bookmarks">bookmarks</a></li>
1974 <li><a href="/bookmarks">bookmarks</a></li>
1962 <li><a href="/branches">branches</a></li>
1975 <li><a href="/branches">branches</a></li>
1963 </ul>
1976 </ul>
1964 <ul>
1977 <ul>
1965 <li class="active"><a href="/help">help</a></li>
1978 <li class="active"><a href="/help">help</a></li>
1966 </ul>
1979 </ul>
1967 </div>
1980 </div>
1968
1981
1969 <div class="main">
1982 <div class="main">
1970 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1983 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1971 <h3>Help: add</h3>
1984 <h3>Help: add</h3>
1972
1985
1973 <form class="search" action="/log">
1986 <form class="search" action="/log">
1974
1987
1975 <p><input name="rev" id="search1" type="text" size="30" /></p>
1988 <p><input name="rev" id="search1" type="text" size="30" /></p>
1976 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1989 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1977 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1990 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1978 </form>
1991 </form>
1979 <div id="doc">
1992 <div id="doc">
1980 <p>
1993 <p>
1981 hg add [OPTION]... [FILE]...
1994 hg add [OPTION]... [FILE]...
1982 </p>
1995 </p>
1983 <p>
1996 <p>
1984 add the specified files on the next commit
1997 add the specified files on the next commit
1985 </p>
1998 </p>
1986 <p>
1999 <p>
1987 Schedule files to be version controlled and added to the
2000 Schedule files to be version controlled and added to the
1988 repository.
2001 repository.
1989 </p>
2002 </p>
1990 <p>
2003 <p>
1991 The files will be added to the repository at the next commit. To
2004 The files will be added to the repository at the next commit. To
1992 undo an add before that, see &quot;hg forget&quot;.
2005 undo an add before that, see &quot;hg forget&quot;.
1993 </p>
2006 </p>
1994 <p>
2007 <p>
1995 If no names are given, add all files to the repository.
2008 If no names are given, add all files to the repository.
1996 </p>
2009 </p>
1997 <p>
2010 <p>
1998 An example showing how new (unknown) files are added
2011 Examples:
1999 automatically by &quot;hg add&quot;:
2000 </p>
2012 </p>
2013 <ul>
2014 <li> New (unknown) files are added automatically by &quot;hg add&quot;:
2001 <pre>
2015 <pre>
2002 \$ ls (re)
2016 \$ ls (re)
2003 foo.c
2017 foo.c
2004 \$ hg status (re)
2018 \$ hg status (re)
2005 ? foo.c
2019 ? foo.c
2006 \$ hg add (re)
2020 \$ hg add (re)
2007 adding foo.c
2021 adding foo.c
2008 \$ hg status (re)
2022 \$ hg status (re)
2009 A foo.c
2023 A foo.c
2010 </pre>
2024 </pre>
2025 <li> Specific files to be added can be specified:
2026 <pre>
2027 \$ ls (re)
2028 bar.c foo.c
2029 \$ hg status (re)
2030 ? bar.c
2031 ? foo.c
2032 \$ hg add bar.c (re)
2033 \$ hg status (re)
2034 A bar.c
2035 ? foo.c
2036 </pre>
2037 </ul>
2011 <p>
2038 <p>
2012 Returns 0 if all files are successfully added.
2039 Returns 0 if all files are successfully added.
2013 </p>
2040 </p>
2014 <p>
2041 <p>
2015 options ([+] can be repeated):
2042 options ([+] can be repeated):
2016 </p>
2043 </p>
2017 <table>
2044 <table>
2018 <tr><td>-I</td>
2045 <tr><td>-I</td>
2019 <td>--include PATTERN [+]</td>
2046 <td>--include PATTERN [+]</td>
2020 <td>include names matching the given patterns</td></tr>
2047 <td>include names matching the given patterns</td></tr>
2021 <tr><td>-X</td>
2048 <tr><td>-X</td>
2022 <td>--exclude PATTERN [+]</td>
2049 <td>--exclude PATTERN [+]</td>
2023 <td>exclude names matching the given patterns</td></tr>
2050 <td>exclude names matching the given patterns</td></tr>
2024 <tr><td>-S</td>
2051 <tr><td>-S</td>
2025 <td>--subrepos</td>
2052 <td>--subrepos</td>
2026 <td>recurse into subrepositories</td></tr>
2053 <td>recurse into subrepositories</td></tr>
2027 <tr><td>-n</td>
2054 <tr><td>-n</td>
2028 <td>--dry-run</td>
2055 <td>--dry-run</td>
2029 <td>do not perform actions, just print output</td></tr>
2056 <td>do not perform actions, just print output</td></tr>
2030 </table>
2057 </table>
2031 <p>
2058 <p>
2032 global options ([+] can be repeated):
2059 global options ([+] can be repeated):
2033 </p>
2060 </p>
2034 <table>
2061 <table>
2035 <tr><td>-R</td>
2062 <tr><td>-R</td>
2036 <td>--repository REPO</td>
2063 <td>--repository REPO</td>
2037 <td>repository root directory or name of overlay bundle file</td></tr>
2064 <td>repository root directory or name of overlay bundle file</td></tr>
2038 <tr><td></td>
2065 <tr><td></td>
2039 <td>--cwd DIR</td>
2066 <td>--cwd DIR</td>
2040 <td>change working directory</td></tr>
2067 <td>change working directory</td></tr>
2041 <tr><td>-y</td>
2068 <tr><td>-y</td>
2042 <td>--noninteractive</td>
2069 <td>--noninteractive</td>
2043 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2070 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2044 <tr><td>-q</td>
2071 <tr><td>-q</td>
2045 <td>--quiet</td>
2072 <td>--quiet</td>
2046 <td>suppress output</td></tr>
2073 <td>suppress output</td></tr>
2047 <tr><td>-v</td>
2074 <tr><td>-v</td>
2048 <td>--verbose</td>
2075 <td>--verbose</td>
2049 <td>enable additional output</td></tr>
2076 <td>enable additional output</td></tr>
2050 <tr><td></td>
2077 <tr><td></td>
2051 <td>--config CONFIG [+]</td>
2078 <td>--config CONFIG [+]</td>
2052 <td>set/override config option (use 'section.name=value')</td></tr>
2079 <td>set/override config option (use 'section.name=value')</td></tr>
2053 <tr><td></td>
2080 <tr><td></td>
2054 <td>--debug</td>
2081 <td>--debug</td>
2055 <td>enable debugging output</td></tr>
2082 <td>enable debugging output</td></tr>
2056 <tr><td></td>
2083 <tr><td></td>
2057 <td>--debugger</td>
2084 <td>--debugger</td>
2058 <td>start debugger</td></tr>
2085 <td>start debugger</td></tr>
2059 <tr><td></td>
2086 <tr><td></td>
2060 <td>--encoding ENCODE</td>
2087 <td>--encoding ENCODE</td>
2061 <td>set the charset encoding (default: ascii)</td></tr>
2088 <td>set the charset encoding (default: ascii)</td></tr>
2062 <tr><td></td>
2089 <tr><td></td>
2063 <td>--encodingmode MODE</td>
2090 <td>--encodingmode MODE</td>
2064 <td>set the charset encoding mode (default: strict)</td></tr>
2091 <td>set the charset encoding mode (default: strict)</td></tr>
2065 <tr><td></td>
2092 <tr><td></td>
2066 <td>--traceback</td>
2093 <td>--traceback</td>
2067 <td>always print a traceback on exception</td></tr>
2094 <td>always print a traceback on exception</td></tr>
2068 <tr><td></td>
2095 <tr><td></td>
2069 <td>--time</td>
2096 <td>--time</td>
2070 <td>time how long the command takes</td></tr>
2097 <td>time how long the command takes</td></tr>
2071 <tr><td></td>
2098 <tr><td></td>
2072 <td>--profile</td>
2099 <td>--profile</td>
2073 <td>print command execution profile</td></tr>
2100 <td>print command execution profile</td></tr>
2074 <tr><td></td>
2101 <tr><td></td>
2075 <td>--version</td>
2102 <td>--version</td>
2076 <td>output version information and exit</td></tr>
2103 <td>output version information and exit</td></tr>
2077 <tr><td>-h</td>
2104 <tr><td>-h</td>
2078 <td>--help</td>
2105 <td>--help</td>
2079 <td>display help and exit</td></tr>
2106 <td>display help and exit</td></tr>
2080 <tr><td></td>
2107 <tr><td></td>
2081 <td>--hidden</td>
2108 <td>--hidden</td>
2082 <td>consider hidden changesets</td></tr>
2109 <td>consider hidden changesets</td></tr>
2083 </table>
2110 </table>
2084
2111
2085 </div>
2112 </div>
2086 </div>
2113 </div>
2087 </div>
2114 </div>
2088
2115
2089 <script type="text/javascript">process_dates()</script>
2116 <script type="text/javascript">process_dates()</script>
2090
2117
2091
2118
2092 </body>
2119 </body>
2093 </html>
2120 </html>
2094
2121
2095
2122
2096 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2123 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2097 200 Script output follows
2124 200 Script output follows
2098
2125
2099 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2126 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2100 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2127 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2101 <head>
2128 <head>
2102 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2129 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2103 <meta name="robots" content="index, nofollow" />
2130 <meta name="robots" content="index, nofollow" />
2104 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2131 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2105 <script type="text/javascript" src="/static/mercurial.js"></script>
2132 <script type="text/javascript" src="/static/mercurial.js"></script>
2106
2133
2107 <title>Help: remove</title>
2134 <title>Help: remove</title>
2108 </head>
2135 </head>
2109 <body>
2136 <body>
2110
2137
2111 <div class="container">
2138 <div class="container">
2112 <div class="menu">
2139 <div class="menu">
2113 <div class="logo">
2140 <div class="logo">
2114 <a href="https://mercurial-scm.org/">
2141 <a href="https://mercurial-scm.org/">
2115 <img src="/static/hglogo.png" alt="mercurial" /></a>
2142 <img src="/static/hglogo.png" alt="mercurial" /></a>
2116 </div>
2143 </div>
2117 <ul>
2144 <ul>
2118 <li><a href="/shortlog">log</a></li>
2145 <li><a href="/shortlog">log</a></li>
2119 <li><a href="/graph">graph</a></li>
2146 <li><a href="/graph">graph</a></li>
2120 <li><a href="/tags">tags</a></li>
2147 <li><a href="/tags">tags</a></li>
2121 <li><a href="/bookmarks">bookmarks</a></li>
2148 <li><a href="/bookmarks">bookmarks</a></li>
2122 <li><a href="/branches">branches</a></li>
2149 <li><a href="/branches">branches</a></li>
2123 </ul>
2150 </ul>
2124 <ul>
2151 <ul>
2125 <li class="active"><a href="/help">help</a></li>
2152 <li class="active"><a href="/help">help</a></li>
2126 </ul>
2153 </ul>
2127 </div>
2154 </div>
2128
2155
2129 <div class="main">
2156 <div class="main">
2130 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2157 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2131 <h3>Help: remove</h3>
2158 <h3>Help: remove</h3>
2132
2159
2133 <form class="search" action="/log">
2160 <form class="search" action="/log">
2134
2161
2135 <p><input name="rev" id="search1" type="text" size="30" /></p>
2162 <p><input name="rev" id="search1" type="text" size="30" /></p>
2136 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2163 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2137 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2164 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2138 </form>
2165 </form>
2139 <div id="doc">
2166 <div id="doc">
2140 <p>
2167 <p>
2141 hg remove [OPTION]... FILE...
2168 hg remove [OPTION]... FILE...
2142 </p>
2169 </p>
2143 <p>
2170 <p>
2144 aliases: rm
2171 aliases: rm
2145 </p>
2172 </p>
2146 <p>
2173 <p>
2147 remove the specified files on the next commit
2174 remove the specified files on the next commit
2148 </p>
2175 </p>
2149 <p>
2176 <p>
2150 Schedule the indicated files for removal from the current branch.
2177 Schedule the indicated files for removal from the current branch.
2151 </p>
2178 </p>
2152 <p>
2179 <p>
2153 This command schedules the files to be removed at the next commit.
2180 This command schedules the files to be removed at the next commit.
2154 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2181 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2155 files, see &quot;hg forget&quot;.
2182 files, see &quot;hg forget&quot;.
2156 </p>
2183 </p>
2157 <p>
2184 <p>
2158 -A/--after can be used to remove only files that have already
2185 -A/--after can be used to remove only files that have already
2159 been deleted, -f/--force can be used to force deletion, and -Af
2186 been deleted, -f/--force can be used to force deletion, and -Af
2160 can be used to remove files from the next revision without
2187 can be used to remove files from the next revision without
2161 deleting them from the working directory.
2188 deleting them from the working directory.
2162 </p>
2189 </p>
2163 <p>
2190 <p>
2164 The following table details the behavior of remove for different
2191 The following table details the behavior of remove for different
2165 file states (columns) and option combinations (rows). The file
2192 file states (columns) and option combinations (rows). The file
2166 states are Added [A], Clean [C], Modified [M] and Missing [!]
2193 states are Added [A], Clean [C], Modified [M] and Missing [!]
2167 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2194 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2168 (from branch) and Delete (from disk):
2195 (from branch) and Delete (from disk):
2169 </p>
2196 </p>
2170 <table>
2197 <table>
2171 <tr><td>opt/state</td>
2198 <tr><td>opt/state</td>
2172 <td>A</td>
2199 <td>A</td>
2173 <td>C</td>
2200 <td>C</td>
2174 <td>M</td>
2201 <td>M</td>
2175 <td>!</td></tr>
2202 <td>!</td></tr>
2176 <tr><td>none</td>
2203 <tr><td>none</td>
2177 <td>W</td>
2204 <td>W</td>
2178 <td>RD</td>
2205 <td>RD</td>
2179 <td>W</td>
2206 <td>W</td>
2180 <td>R</td></tr>
2207 <td>R</td></tr>
2181 <tr><td>-f</td>
2208 <tr><td>-f</td>
2182 <td>R</td>
2209 <td>R</td>
2183 <td>RD</td>
2210 <td>RD</td>
2184 <td>RD</td>
2211 <td>RD</td>
2185 <td>R</td></tr>
2212 <td>R</td></tr>
2186 <tr><td>-A</td>
2213 <tr><td>-A</td>
2187 <td>W</td>
2214 <td>W</td>
2188 <td>W</td>
2215 <td>W</td>
2189 <td>W</td>
2216 <td>W</td>
2190 <td>R</td></tr>
2217 <td>R</td></tr>
2191 <tr><td>-Af</td>
2218 <tr><td>-Af</td>
2192 <td>R</td>
2219 <td>R</td>
2193 <td>R</td>
2220 <td>R</td>
2194 <td>R</td>
2221 <td>R</td>
2195 <td>R</td></tr>
2222 <td>R</td></tr>
2196 </table>
2223 </table>
2197 <p>
2224 <p>
2198 Note that remove never deletes files in Added [A] state from the
2225 Note that remove never deletes files in Added [A] state from the
2199 working directory, not even if option --force is specified.
2226 working directory, not even if option --force is specified.
2200 </p>
2227 </p>
2201 <p>
2228 <p>
2202 Returns 0 on success, 1 if any warnings encountered.
2229 Returns 0 on success, 1 if any warnings encountered.
2203 </p>
2230 </p>
2204 <p>
2231 <p>
2205 options ([+] can be repeated):
2232 options ([+] can be repeated):
2206 </p>
2233 </p>
2207 <table>
2234 <table>
2208 <tr><td>-A</td>
2235 <tr><td>-A</td>
2209 <td>--after</td>
2236 <td>--after</td>
2210 <td>record delete for missing files</td></tr>
2237 <td>record delete for missing files</td></tr>
2211 <tr><td>-f</td>
2238 <tr><td>-f</td>
2212 <td>--force</td>
2239 <td>--force</td>
2213 <td>remove (and delete) file even if added or modified</td></tr>
2240 <td>remove (and delete) file even if added or modified</td></tr>
2214 <tr><td>-S</td>
2241 <tr><td>-S</td>
2215 <td>--subrepos</td>
2242 <td>--subrepos</td>
2216 <td>recurse into subrepositories</td></tr>
2243 <td>recurse into subrepositories</td></tr>
2217 <tr><td>-I</td>
2244 <tr><td>-I</td>
2218 <td>--include PATTERN [+]</td>
2245 <td>--include PATTERN [+]</td>
2219 <td>include names matching the given patterns</td></tr>
2246 <td>include names matching the given patterns</td></tr>
2220 <tr><td>-X</td>
2247 <tr><td>-X</td>
2221 <td>--exclude PATTERN [+]</td>
2248 <td>--exclude PATTERN [+]</td>
2222 <td>exclude names matching the given patterns</td></tr>
2249 <td>exclude names matching the given patterns</td></tr>
2223 </table>
2250 </table>
2224 <p>
2251 <p>
2225 global options ([+] can be repeated):
2252 global options ([+] can be repeated):
2226 </p>
2253 </p>
2227 <table>
2254 <table>
2228 <tr><td>-R</td>
2255 <tr><td>-R</td>
2229 <td>--repository REPO</td>
2256 <td>--repository REPO</td>
2230 <td>repository root directory or name of overlay bundle file</td></tr>
2257 <td>repository root directory or name of overlay bundle file</td></tr>
2231 <tr><td></td>
2258 <tr><td></td>
2232 <td>--cwd DIR</td>
2259 <td>--cwd DIR</td>
2233 <td>change working directory</td></tr>
2260 <td>change working directory</td></tr>
2234 <tr><td>-y</td>
2261 <tr><td>-y</td>
2235 <td>--noninteractive</td>
2262 <td>--noninteractive</td>
2236 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2263 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2237 <tr><td>-q</td>
2264 <tr><td>-q</td>
2238 <td>--quiet</td>
2265 <td>--quiet</td>
2239 <td>suppress output</td></tr>
2266 <td>suppress output</td></tr>
2240 <tr><td>-v</td>
2267 <tr><td>-v</td>
2241 <td>--verbose</td>
2268 <td>--verbose</td>
2242 <td>enable additional output</td></tr>
2269 <td>enable additional output</td></tr>
2243 <tr><td></td>
2270 <tr><td></td>
2244 <td>--config CONFIG [+]</td>
2271 <td>--config CONFIG [+]</td>
2245 <td>set/override config option (use 'section.name=value')</td></tr>
2272 <td>set/override config option (use 'section.name=value')</td></tr>
2246 <tr><td></td>
2273 <tr><td></td>
2247 <td>--debug</td>
2274 <td>--debug</td>
2248 <td>enable debugging output</td></tr>
2275 <td>enable debugging output</td></tr>
2249 <tr><td></td>
2276 <tr><td></td>
2250 <td>--debugger</td>
2277 <td>--debugger</td>
2251 <td>start debugger</td></tr>
2278 <td>start debugger</td></tr>
2252 <tr><td></td>
2279 <tr><td></td>
2253 <td>--encoding ENCODE</td>
2280 <td>--encoding ENCODE</td>
2254 <td>set the charset encoding (default: ascii)</td></tr>
2281 <td>set the charset encoding (default: ascii)</td></tr>
2255 <tr><td></td>
2282 <tr><td></td>
2256 <td>--encodingmode MODE</td>
2283 <td>--encodingmode MODE</td>
2257 <td>set the charset encoding mode (default: strict)</td></tr>
2284 <td>set the charset encoding mode (default: strict)</td></tr>
2258 <tr><td></td>
2285 <tr><td></td>
2259 <td>--traceback</td>
2286 <td>--traceback</td>
2260 <td>always print a traceback on exception</td></tr>
2287 <td>always print a traceback on exception</td></tr>
2261 <tr><td></td>
2288 <tr><td></td>
2262 <td>--time</td>
2289 <td>--time</td>
2263 <td>time how long the command takes</td></tr>
2290 <td>time how long the command takes</td></tr>
2264 <tr><td></td>
2291 <tr><td></td>
2265 <td>--profile</td>
2292 <td>--profile</td>
2266 <td>print command execution profile</td></tr>
2293 <td>print command execution profile</td></tr>
2267 <tr><td></td>
2294 <tr><td></td>
2268 <td>--version</td>
2295 <td>--version</td>
2269 <td>output version information and exit</td></tr>
2296 <td>output version information and exit</td></tr>
2270 <tr><td>-h</td>
2297 <tr><td>-h</td>
2271 <td>--help</td>
2298 <td>--help</td>
2272 <td>display help and exit</td></tr>
2299 <td>display help and exit</td></tr>
2273 <tr><td></td>
2300 <tr><td></td>
2274 <td>--hidden</td>
2301 <td>--hidden</td>
2275 <td>consider hidden changesets</td></tr>
2302 <td>consider hidden changesets</td></tr>
2276 </table>
2303 </table>
2277
2304
2278 </div>
2305 </div>
2279 </div>
2306 </div>
2280 </div>
2307 </div>
2281
2308
2282 <script type="text/javascript">process_dates()</script>
2309 <script type="text/javascript">process_dates()</script>
2283
2310
2284
2311
2285 </body>
2312 </body>
2286 </html>
2313 </html>
2287
2314
2288
2315
2289 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2316 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2290 200 Script output follows
2317 200 Script output follows
2291
2318
2292 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2319 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2293 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2320 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2294 <head>
2321 <head>
2295 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2322 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2296 <meta name="robots" content="index, nofollow" />
2323 <meta name="robots" content="index, nofollow" />
2297 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2324 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2298 <script type="text/javascript" src="/static/mercurial.js"></script>
2325 <script type="text/javascript" src="/static/mercurial.js"></script>
2299
2326
2300 <title>Help: revisions</title>
2327 <title>Help: revisions</title>
2301 </head>
2328 </head>
2302 <body>
2329 <body>
2303
2330
2304 <div class="container">
2331 <div class="container">
2305 <div class="menu">
2332 <div class="menu">
2306 <div class="logo">
2333 <div class="logo">
2307 <a href="https://mercurial-scm.org/">
2334 <a href="https://mercurial-scm.org/">
2308 <img src="/static/hglogo.png" alt="mercurial" /></a>
2335 <img src="/static/hglogo.png" alt="mercurial" /></a>
2309 </div>
2336 </div>
2310 <ul>
2337 <ul>
2311 <li><a href="/shortlog">log</a></li>
2338 <li><a href="/shortlog">log</a></li>
2312 <li><a href="/graph">graph</a></li>
2339 <li><a href="/graph">graph</a></li>
2313 <li><a href="/tags">tags</a></li>
2340 <li><a href="/tags">tags</a></li>
2314 <li><a href="/bookmarks">bookmarks</a></li>
2341 <li><a href="/bookmarks">bookmarks</a></li>
2315 <li><a href="/branches">branches</a></li>
2342 <li><a href="/branches">branches</a></li>
2316 </ul>
2343 </ul>
2317 <ul>
2344 <ul>
2318 <li class="active"><a href="/help">help</a></li>
2345 <li class="active"><a href="/help">help</a></li>
2319 </ul>
2346 </ul>
2320 </div>
2347 </div>
2321
2348
2322 <div class="main">
2349 <div class="main">
2323 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2350 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2324 <h3>Help: revisions</h3>
2351 <h3>Help: revisions</h3>
2325
2352
2326 <form class="search" action="/log">
2353 <form class="search" action="/log">
2327
2354
2328 <p><input name="rev" id="search1" type="text" size="30" /></p>
2355 <p><input name="rev" id="search1" type="text" size="30" /></p>
2329 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2356 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2330 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2357 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2331 </form>
2358 </form>
2332 <div id="doc">
2359 <div id="doc">
2333 <h1>Specifying Single Revisions</h1>
2360 <h1>Specifying Single Revisions</h1>
2334 <p>
2361 <p>
2335 Mercurial supports several ways to specify individual revisions.
2362 Mercurial supports several ways to specify individual revisions.
2336 </p>
2363 </p>
2337 <p>
2364 <p>
2338 A plain integer is treated as a revision number. Negative integers are
2365 A plain integer is treated as a revision number. Negative integers are
2339 treated as sequential offsets from the tip, with -1 denoting the tip,
2366 treated as sequential offsets from the tip, with -1 denoting the tip,
2340 -2 denoting the revision prior to the tip, and so forth.
2367 -2 denoting the revision prior to the tip, and so forth.
2341 </p>
2368 </p>
2342 <p>
2369 <p>
2343 A 40-digit hexadecimal string is treated as a unique revision
2370 A 40-digit hexadecimal string is treated as a unique revision
2344 identifier.
2371 identifier.
2345 </p>
2372 </p>
2346 <p>
2373 <p>
2347 A hexadecimal string less than 40 characters long is treated as a
2374 A hexadecimal string less than 40 characters long is treated as a
2348 unique revision identifier and is referred to as a short-form
2375 unique revision identifier and is referred to as a short-form
2349 identifier. A short-form identifier is only valid if it is the prefix
2376 identifier. A short-form identifier is only valid if it is the prefix
2350 of exactly one full-length identifier.
2377 of exactly one full-length identifier.
2351 </p>
2378 </p>
2352 <p>
2379 <p>
2353 Any other string is treated as a bookmark, tag, or branch name. A
2380 Any other string is treated as a bookmark, tag, or branch name. A
2354 bookmark is a movable pointer to a revision. A tag is a permanent name
2381 bookmark is a movable pointer to a revision. A tag is a permanent name
2355 associated with a revision. A branch name denotes the tipmost open branch head
2382 associated with a revision. A branch name denotes the tipmost open branch head
2356 of that branch - or if they are all closed, the tipmost closed head of the
2383 of that branch - or if they are all closed, the tipmost closed head of the
2357 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2384 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2358 </p>
2385 </p>
2359 <p>
2386 <p>
2360 The reserved name &quot;tip&quot; always identifies the most recent revision.
2387 The reserved name &quot;tip&quot; always identifies the most recent revision.
2361 </p>
2388 </p>
2362 <p>
2389 <p>
2363 The reserved name &quot;null&quot; indicates the null revision. This is the
2390 The reserved name &quot;null&quot; indicates the null revision. This is the
2364 revision of an empty repository, and the parent of revision 0.
2391 revision of an empty repository, and the parent of revision 0.
2365 </p>
2392 </p>
2366 <p>
2393 <p>
2367 The reserved name &quot;.&quot; indicates the working directory parent. If no
2394 The reserved name &quot;.&quot; indicates the working directory parent. If no
2368 working directory is checked out, it is equivalent to null. If an
2395 working directory is checked out, it is equivalent to null. If an
2369 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2396 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2370 parent.
2397 parent.
2371 </p>
2398 </p>
2372
2399
2373 </div>
2400 </div>
2374 </div>
2401 </div>
2375 </div>
2402 </div>
2376
2403
2377 <script type="text/javascript">process_dates()</script>
2404 <script type="text/javascript">process_dates()</script>
2378
2405
2379
2406
2380 </body>
2407 </body>
2381 </html>
2408 </html>
2382
2409
2383
2410
2384 $ killdaemons.py
2411 $ killdaemons.py
2385
2412
2386 #endif
2413 #endif
General Comments 0
You need to be logged in to leave comments. Login now