##// END OF EJS Templates
sidedata: add a debugsidedata command...
marmoute -
r43309:559ac841 default
parent child Browse files
Show More
@@ -1,3499 +1,3524 b''
1 # debugcommands.py - command processing for debug* commands
1 # debugcommands.py - command processing for debug* commands
2 #
2 #
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import codecs
10 import codecs
11 import collections
11 import collections
12 import difflib
12 import difflib
13 import errno
13 import errno
14 import operator
14 import operator
15 import os
15 import os
16 import random
16 import random
17 import re
17 import re
18 import socket
18 import socket
19 import ssl
19 import ssl
20 import stat
20 import stat
21 import string
21 import string
22 import subprocess
22 import subprocess
23 import sys
23 import sys
24 import time
24 import time
25
25
26 from .i18n import _
26 from .i18n import _
27 from .node import (
27 from .node import (
28 bin,
28 bin,
29 hex,
29 hex,
30 nullhex,
30 nullhex,
31 nullid,
31 nullid,
32 nullrev,
32 nullrev,
33 short,
33 short,
34 )
34 )
35 from . import (
35 from . import (
36 bundle2,
36 bundle2,
37 changegroup,
37 changegroup,
38 cmdutil,
38 cmdutil,
39 color,
39 color,
40 context,
40 context,
41 copies,
41 copies,
42 dagparser,
42 dagparser,
43 encoding,
43 encoding,
44 error,
44 error,
45 exchange,
45 exchange,
46 extensions,
46 extensions,
47 filemerge,
47 filemerge,
48 filesetlang,
48 filesetlang,
49 formatter,
49 formatter,
50 hg,
50 hg,
51 httppeer,
51 httppeer,
52 localrepo,
52 localrepo,
53 lock as lockmod,
53 lock as lockmod,
54 logcmdutil,
54 logcmdutil,
55 merge as mergemod,
55 merge as mergemod,
56 obsolete,
56 obsolete,
57 obsutil,
57 obsutil,
58 phases,
58 phases,
59 policy,
59 policy,
60 pvec,
60 pvec,
61 pycompat,
61 pycompat,
62 registrar,
62 registrar,
63 repair,
63 repair,
64 revlog,
64 revlog,
65 revset,
65 revset,
66 revsetlang,
66 revsetlang,
67 scmutil,
67 scmutil,
68 setdiscovery,
68 setdiscovery,
69 simplemerge,
69 simplemerge,
70 sshpeer,
70 sshpeer,
71 sslutil,
71 sslutil,
72 streamclone,
72 streamclone,
73 templater,
73 templater,
74 treediscovery,
74 treediscovery,
75 upgrade,
75 upgrade,
76 url as urlmod,
76 url as urlmod,
77 util,
77 util,
78 vfs as vfsmod,
78 vfs as vfsmod,
79 wireprotoframing,
79 wireprotoframing,
80 wireprotoserver,
80 wireprotoserver,
81 wireprotov2peer,
81 wireprotov2peer,
82 )
82 )
83 from .utils import (
83 from .utils import (
84 cborutil,
84 cborutil,
85 compression,
85 compression,
86 dateutil,
86 dateutil,
87 procutil,
87 procutil,
88 stringutil,
88 stringutil,
89 )
89 )
90
90
91 from .revlogutils import (
91 from .revlogutils import (
92 deltas as deltautil
92 deltas as deltautil
93 )
93 )
94
94
95 release = lockmod.release
95 release = lockmod.release
96
96
97 command = registrar.command()
97 command = registrar.command()
98
98
99 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
99 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
100 def debugancestor(ui, repo, *args):
100 def debugancestor(ui, repo, *args):
101 """find the ancestor revision of two revisions in a given index"""
101 """find the ancestor revision of two revisions in a given index"""
102 if len(args) == 3:
102 if len(args) == 3:
103 index, rev1, rev2 = args
103 index, rev1, rev2 = args
104 r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index)
104 r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index)
105 lookup = r.lookup
105 lookup = r.lookup
106 elif len(args) == 2:
106 elif len(args) == 2:
107 if not repo:
107 if not repo:
108 raise error.Abort(_('there is no Mercurial repository here '
108 raise error.Abort(_('there is no Mercurial repository here '
109 '(.hg not found)'))
109 '(.hg not found)'))
110 rev1, rev2 = args
110 rev1, rev2 = args
111 r = repo.changelog
111 r = repo.changelog
112 lookup = repo.lookup
112 lookup = repo.lookup
113 else:
113 else:
114 raise error.Abort(_('either two or three arguments required'))
114 raise error.Abort(_('either two or three arguments required'))
115 a = r.ancestor(lookup(rev1), lookup(rev2))
115 a = r.ancestor(lookup(rev1), lookup(rev2))
116 ui.write('%d:%s\n' % (r.rev(a), hex(a)))
116 ui.write('%d:%s\n' % (r.rev(a), hex(a)))
117
117
118 @command('debugapplystreamclonebundle', [], 'FILE')
118 @command('debugapplystreamclonebundle', [], 'FILE')
119 def debugapplystreamclonebundle(ui, repo, fname):
119 def debugapplystreamclonebundle(ui, repo, fname):
120 """apply a stream clone bundle file"""
120 """apply a stream clone bundle file"""
121 f = hg.openpath(ui, fname)
121 f = hg.openpath(ui, fname)
122 gen = exchange.readbundle(ui, f, fname)
122 gen = exchange.readbundle(ui, f, fname)
123 gen.apply(repo)
123 gen.apply(repo)
124
124
125 @command('debugbuilddag',
125 @command('debugbuilddag',
126 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
126 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
127 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
127 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
128 ('n', 'new-file', None, _('add new file at each rev'))],
128 ('n', 'new-file', None, _('add new file at each rev'))],
129 _('[OPTION]... [TEXT]'))
129 _('[OPTION]... [TEXT]'))
130 def debugbuilddag(ui, repo, text=None,
130 def debugbuilddag(ui, repo, text=None,
131 mergeable_file=False,
131 mergeable_file=False,
132 overwritten_file=False,
132 overwritten_file=False,
133 new_file=False):
133 new_file=False):
134 """builds a repo with a given DAG from scratch in the current empty repo
134 """builds a repo with a given DAG from scratch in the current empty repo
135
135
136 The description of the DAG is read from stdin if not given on the
136 The description of the DAG is read from stdin if not given on the
137 command line.
137 command line.
138
138
139 Elements:
139 Elements:
140
140
141 - "+n" is a linear run of n nodes based on the current default parent
141 - "+n" is a linear run of n nodes based on the current default parent
142 - "." is a single node based on the current default parent
142 - "." is a single node based on the current default parent
143 - "$" resets the default parent to null (implied at the start);
143 - "$" resets the default parent to null (implied at the start);
144 otherwise the default parent is always the last node created
144 otherwise the default parent is always the last node created
145 - "<p" sets the default parent to the backref p
145 - "<p" sets the default parent to the backref p
146 - "*p" is a fork at parent p, which is a backref
146 - "*p" is a fork at parent p, which is a backref
147 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
147 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
148 - "/p2" is a merge of the preceding node and p2
148 - "/p2" is a merge of the preceding node and p2
149 - ":tag" defines a local tag for the preceding node
149 - ":tag" defines a local tag for the preceding node
150 - "@branch" sets the named branch for subsequent nodes
150 - "@branch" sets the named branch for subsequent nodes
151 - "#...\\n" is a comment up to the end of the line
151 - "#...\\n" is a comment up to the end of the line
152
152
153 Whitespace between the above elements is ignored.
153 Whitespace between the above elements is ignored.
154
154
155 A backref is either
155 A backref is either
156
156
157 - a number n, which references the node curr-n, where curr is the current
157 - a number n, which references the node curr-n, where curr is the current
158 node, or
158 node, or
159 - the name of a local tag you placed earlier using ":tag", or
159 - the name of a local tag you placed earlier using ":tag", or
160 - empty to denote the default parent.
160 - empty to denote the default parent.
161
161
162 All string valued-elements are either strictly alphanumeric, or must
162 All string valued-elements are either strictly alphanumeric, or must
163 be enclosed in double quotes ("..."), with "\\" as escape character.
163 be enclosed in double quotes ("..."), with "\\" as escape character.
164 """
164 """
165
165
166 if text is None:
166 if text is None:
167 ui.status(_("reading DAG from stdin\n"))
167 ui.status(_("reading DAG from stdin\n"))
168 text = ui.fin.read()
168 text = ui.fin.read()
169
169
170 cl = repo.changelog
170 cl = repo.changelog
171 if len(cl) > 0:
171 if len(cl) > 0:
172 raise error.Abort(_('repository is not empty'))
172 raise error.Abort(_('repository is not empty'))
173
173
174 # determine number of revs in DAG
174 # determine number of revs in DAG
175 total = 0
175 total = 0
176 for type, data in dagparser.parsedag(text):
176 for type, data in dagparser.parsedag(text):
177 if type == 'n':
177 if type == 'n':
178 total += 1
178 total += 1
179
179
180 if mergeable_file:
180 if mergeable_file:
181 linesperrev = 2
181 linesperrev = 2
182 # make a file with k lines per rev
182 # make a file with k lines per rev
183 initialmergedlines = ['%d' % i
183 initialmergedlines = ['%d' % i
184 for i in pycompat.xrange(0, total * linesperrev)]
184 for i in pycompat.xrange(0, total * linesperrev)]
185 initialmergedlines.append("")
185 initialmergedlines.append("")
186
186
187 tags = []
187 tags = []
188 progress = ui.makeprogress(_('building'), unit=_('revisions'),
188 progress = ui.makeprogress(_('building'), unit=_('revisions'),
189 total=total)
189 total=total)
190 with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"):
190 with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"):
191 at = -1
191 at = -1
192 atbranch = 'default'
192 atbranch = 'default'
193 nodeids = []
193 nodeids = []
194 id = 0
194 id = 0
195 progress.update(id)
195 progress.update(id)
196 for type, data in dagparser.parsedag(text):
196 for type, data in dagparser.parsedag(text):
197 if type == 'n':
197 if type == 'n':
198 ui.note(('node %s\n' % pycompat.bytestr(data)))
198 ui.note(('node %s\n' % pycompat.bytestr(data)))
199 id, ps = data
199 id, ps = data
200
200
201 files = []
201 files = []
202 filecontent = {}
202 filecontent = {}
203
203
204 p2 = None
204 p2 = None
205 if mergeable_file:
205 if mergeable_file:
206 fn = "mf"
206 fn = "mf"
207 p1 = repo[ps[0]]
207 p1 = repo[ps[0]]
208 if len(ps) > 1:
208 if len(ps) > 1:
209 p2 = repo[ps[1]]
209 p2 = repo[ps[1]]
210 pa = p1.ancestor(p2)
210 pa = p1.ancestor(p2)
211 base, local, other = [x[fn].data() for x in (pa, p1,
211 base, local, other = [x[fn].data() for x in (pa, p1,
212 p2)]
212 p2)]
213 m3 = simplemerge.Merge3Text(base, local, other)
213 m3 = simplemerge.Merge3Text(base, local, other)
214 ml = [l.strip() for l in m3.merge_lines()]
214 ml = [l.strip() for l in m3.merge_lines()]
215 ml.append("")
215 ml.append("")
216 elif at > 0:
216 elif at > 0:
217 ml = p1[fn].data().split("\n")
217 ml = p1[fn].data().split("\n")
218 else:
218 else:
219 ml = initialmergedlines
219 ml = initialmergedlines
220 ml[id * linesperrev] += " r%i" % id
220 ml[id * linesperrev] += " r%i" % id
221 mergedtext = "\n".join(ml)
221 mergedtext = "\n".join(ml)
222 files.append(fn)
222 files.append(fn)
223 filecontent[fn] = mergedtext
223 filecontent[fn] = mergedtext
224
224
225 if overwritten_file:
225 if overwritten_file:
226 fn = "of"
226 fn = "of"
227 files.append(fn)
227 files.append(fn)
228 filecontent[fn] = "r%i\n" % id
228 filecontent[fn] = "r%i\n" % id
229
229
230 if new_file:
230 if new_file:
231 fn = "nf%i" % id
231 fn = "nf%i" % id
232 files.append(fn)
232 files.append(fn)
233 filecontent[fn] = "r%i\n" % id
233 filecontent[fn] = "r%i\n" % id
234 if len(ps) > 1:
234 if len(ps) > 1:
235 if not p2:
235 if not p2:
236 p2 = repo[ps[1]]
236 p2 = repo[ps[1]]
237 for fn in p2:
237 for fn in p2:
238 if fn.startswith("nf"):
238 if fn.startswith("nf"):
239 files.append(fn)
239 files.append(fn)
240 filecontent[fn] = p2[fn].data()
240 filecontent[fn] = p2[fn].data()
241
241
242 def fctxfn(repo, cx, path):
242 def fctxfn(repo, cx, path):
243 if path in filecontent:
243 if path in filecontent:
244 return context.memfilectx(repo, cx, path,
244 return context.memfilectx(repo, cx, path,
245 filecontent[path])
245 filecontent[path])
246 return None
246 return None
247
247
248 if len(ps) == 0 or ps[0] < 0:
248 if len(ps) == 0 or ps[0] < 0:
249 pars = [None, None]
249 pars = [None, None]
250 elif len(ps) == 1:
250 elif len(ps) == 1:
251 pars = [nodeids[ps[0]], None]
251 pars = [nodeids[ps[0]], None]
252 else:
252 else:
253 pars = [nodeids[p] for p in ps]
253 pars = [nodeids[p] for p in ps]
254 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
254 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
255 date=(id, 0),
255 date=(id, 0),
256 user="debugbuilddag",
256 user="debugbuilddag",
257 extra={'branch': atbranch})
257 extra={'branch': atbranch})
258 nodeid = repo.commitctx(cx)
258 nodeid = repo.commitctx(cx)
259 nodeids.append(nodeid)
259 nodeids.append(nodeid)
260 at = id
260 at = id
261 elif type == 'l':
261 elif type == 'l':
262 id, name = data
262 id, name = data
263 ui.note(('tag %s\n' % name))
263 ui.note(('tag %s\n' % name))
264 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
264 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
265 elif type == 'a':
265 elif type == 'a':
266 ui.note(('branch %s\n' % data))
266 ui.note(('branch %s\n' % data))
267 atbranch = data
267 atbranch = data
268 progress.update(id)
268 progress.update(id)
269
269
270 if tags:
270 if tags:
271 repo.vfs.write("localtags", "".join(tags))
271 repo.vfs.write("localtags", "".join(tags))
272
272
273 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
273 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
274 indent_string = ' ' * indent
274 indent_string = ' ' * indent
275 if all:
275 if all:
276 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n")
276 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n")
277 % indent_string)
277 % indent_string)
278
278
279 def showchunks(named):
279 def showchunks(named):
280 ui.write("\n%s%s\n" % (indent_string, named))
280 ui.write("\n%s%s\n" % (indent_string, named))
281 for deltadata in gen.deltaiter():
281 for deltadata in gen.deltaiter():
282 node, p1, p2, cs, deltabase, delta, flags = deltadata
282 node, p1, p2, cs, deltabase, delta, flags = deltadata
283 ui.write("%s%s %s %s %s %s %d\n" %
283 ui.write("%s%s %s %s %s %s %d\n" %
284 (indent_string, hex(node), hex(p1), hex(p2),
284 (indent_string, hex(node), hex(p1), hex(p2),
285 hex(cs), hex(deltabase), len(delta)))
285 hex(cs), hex(deltabase), len(delta)))
286
286
287 chunkdata = gen.changelogheader()
287 chunkdata = gen.changelogheader()
288 showchunks("changelog")
288 showchunks("changelog")
289 chunkdata = gen.manifestheader()
289 chunkdata = gen.manifestheader()
290 showchunks("manifest")
290 showchunks("manifest")
291 for chunkdata in iter(gen.filelogheader, {}):
291 for chunkdata in iter(gen.filelogheader, {}):
292 fname = chunkdata['filename']
292 fname = chunkdata['filename']
293 showchunks(fname)
293 showchunks(fname)
294 else:
294 else:
295 if isinstance(gen, bundle2.unbundle20):
295 if isinstance(gen, bundle2.unbundle20):
296 raise error.Abort(_('use debugbundle2 for this file'))
296 raise error.Abort(_('use debugbundle2 for this file'))
297 chunkdata = gen.changelogheader()
297 chunkdata = gen.changelogheader()
298 for deltadata in gen.deltaiter():
298 for deltadata in gen.deltaiter():
299 node, p1, p2, cs, deltabase, delta, flags = deltadata
299 node, p1, p2, cs, deltabase, delta, flags = deltadata
300 ui.write("%s%s\n" % (indent_string, hex(node)))
300 ui.write("%s%s\n" % (indent_string, hex(node)))
301
301
302 def _debugobsmarkers(ui, part, indent=0, **opts):
302 def _debugobsmarkers(ui, part, indent=0, **opts):
303 """display version and markers contained in 'data'"""
303 """display version and markers contained in 'data'"""
304 opts = pycompat.byteskwargs(opts)
304 opts = pycompat.byteskwargs(opts)
305 data = part.read()
305 data = part.read()
306 indent_string = ' ' * indent
306 indent_string = ' ' * indent
307 try:
307 try:
308 version, markers = obsolete._readmarkers(data)
308 version, markers = obsolete._readmarkers(data)
309 except error.UnknownVersion as exc:
309 except error.UnknownVersion as exc:
310 msg = "%sunsupported version: %s (%d bytes)\n"
310 msg = "%sunsupported version: %s (%d bytes)\n"
311 msg %= indent_string, exc.version, len(data)
311 msg %= indent_string, exc.version, len(data)
312 ui.write(msg)
312 ui.write(msg)
313 else:
313 else:
314 msg = "%sversion: %d (%d bytes)\n"
314 msg = "%sversion: %d (%d bytes)\n"
315 msg %= indent_string, version, len(data)
315 msg %= indent_string, version, len(data)
316 ui.write(msg)
316 ui.write(msg)
317 fm = ui.formatter('debugobsolete', opts)
317 fm = ui.formatter('debugobsolete', opts)
318 for rawmarker in sorted(markers):
318 for rawmarker in sorted(markers):
319 m = obsutil.marker(None, rawmarker)
319 m = obsutil.marker(None, rawmarker)
320 fm.startitem()
320 fm.startitem()
321 fm.plain(indent_string)
321 fm.plain(indent_string)
322 cmdutil.showmarker(fm, m)
322 cmdutil.showmarker(fm, m)
323 fm.end()
323 fm.end()
324
324
325 def _debugphaseheads(ui, data, indent=0):
325 def _debugphaseheads(ui, data, indent=0):
326 """display version and markers contained in 'data'"""
326 """display version and markers contained in 'data'"""
327 indent_string = ' ' * indent
327 indent_string = ' ' * indent
328 headsbyphase = phases.binarydecode(data)
328 headsbyphase = phases.binarydecode(data)
329 for phase in phases.allphases:
329 for phase in phases.allphases:
330 for head in headsbyphase[phase]:
330 for head in headsbyphase[phase]:
331 ui.write(indent_string)
331 ui.write(indent_string)
332 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
332 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
333
333
334 def _quasirepr(thing):
334 def _quasirepr(thing):
335 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)):
335 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)):
336 return '{%s}' % (
336 return '{%s}' % (
337 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)))
337 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)))
338 return pycompat.bytestr(repr(thing))
338 return pycompat.bytestr(repr(thing))
339
339
340 def _debugbundle2(ui, gen, all=None, **opts):
340 def _debugbundle2(ui, gen, all=None, **opts):
341 """lists the contents of a bundle2"""
341 """lists the contents of a bundle2"""
342 if not isinstance(gen, bundle2.unbundle20):
342 if not isinstance(gen, bundle2.unbundle20):
343 raise error.Abort(_('not a bundle2 file'))
343 raise error.Abort(_('not a bundle2 file'))
344 ui.write(('Stream params: %s\n' % _quasirepr(gen.params)))
344 ui.write(('Stream params: %s\n' % _quasirepr(gen.params)))
345 parttypes = opts.get(r'part_type', [])
345 parttypes = opts.get(r'part_type', [])
346 for part in gen.iterparts():
346 for part in gen.iterparts():
347 if parttypes and part.type not in parttypes:
347 if parttypes and part.type not in parttypes:
348 continue
348 continue
349 msg = '%s -- %s (mandatory: %r)\n'
349 msg = '%s -- %s (mandatory: %r)\n'
350 ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory)))
350 ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory)))
351 if part.type == 'changegroup':
351 if part.type == 'changegroup':
352 version = part.params.get('version', '01')
352 version = part.params.get('version', '01')
353 cg = changegroup.getunbundler(version, part, 'UN')
353 cg = changegroup.getunbundler(version, part, 'UN')
354 if not ui.quiet:
354 if not ui.quiet:
355 _debugchangegroup(ui, cg, all=all, indent=4, **opts)
355 _debugchangegroup(ui, cg, all=all, indent=4, **opts)
356 if part.type == 'obsmarkers':
356 if part.type == 'obsmarkers':
357 if not ui.quiet:
357 if not ui.quiet:
358 _debugobsmarkers(ui, part, indent=4, **opts)
358 _debugobsmarkers(ui, part, indent=4, **opts)
359 if part.type == 'phase-heads':
359 if part.type == 'phase-heads':
360 if not ui.quiet:
360 if not ui.quiet:
361 _debugphaseheads(ui, part, indent=4)
361 _debugphaseheads(ui, part, indent=4)
362
362
363 @command('debugbundle',
363 @command('debugbundle',
364 [('a', 'all', None, _('show all details')),
364 [('a', 'all', None, _('show all details')),
365 ('', 'part-type', [], _('show only the named part type')),
365 ('', 'part-type', [], _('show only the named part type')),
366 ('', 'spec', None, _('print the bundlespec of the bundle'))],
366 ('', 'spec', None, _('print the bundlespec of the bundle'))],
367 _('FILE'),
367 _('FILE'),
368 norepo=True)
368 norepo=True)
369 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
369 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
370 """lists the contents of a bundle"""
370 """lists the contents of a bundle"""
371 with hg.openpath(ui, bundlepath) as f:
371 with hg.openpath(ui, bundlepath) as f:
372 if spec:
372 if spec:
373 spec = exchange.getbundlespec(ui, f)
373 spec = exchange.getbundlespec(ui, f)
374 ui.write('%s\n' % spec)
374 ui.write('%s\n' % spec)
375 return
375 return
376
376
377 gen = exchange.readbundle(ui, f, bundlepath)
377 gen = exchange.readbundle(ui, f, bundlepath)
378 if isinstance(gen, bundle2.unbundle20):
378 if isinstance(gen, bundle2.unbundle20):
379 return _debugbundle2(ui, gen, all=all, **opts)
379 return _debugbundle2(ui, gen, all=all, **opts)
380 _debugchangegroup(ui, gen, all=all, **opts)
380 _debugchangegroup(ui, gen, all=all, **opts)
381
381
382 @command('debugcapabilities',
382 @command('debugcapabilities',
383 [], _('PATH'),
383 [], _('PATH'),
384 norepo=True)
384 norepo=True)
385 def debugcapabilities(ui, path, **opts):
385 def debugcapabilities(ui, path, **opts):
386 """lists the capabilities of a remote peer"""
386 """lists the capabilities of a remote peer"""
387 opts = pycompat.byteskwargs(opts)
387 opts = pycompat.byteskwargs(opts)
388 peer = hg.peer(ui, opts, path)
388 peer = hg.peer(ui, opts, path)
389 caps = peer.capabilities()
389 caps = peer.capabilities()
390 ui.write(('Main capabilities:\n'))
390 ui.write(('Main capabilities:\n'))
391 for c in sorted(caps):
391 for c in sorted(caps):
392 ui.write((' %s\n') % c)
392 ui.write((' %s\n') % c)
393 b2caps = bundle2.bundle2caps(peer)
393 b2caps = bundle2.bundle2caps(peer)
394 if b2caps:
394 if b2caps:
395 ui.write(('Bundle2 capabilities:\n'))
395 ui.write(('Bundle2 capabilities:\n'))
396 for key, values in sorted(b2caps.iteritems()):
396 for key, values in sorted(b2caps.iteritems()):
397 ui.write((' %s\n') % key)
397 ui.write((' %s\n') % key)
398 for v in values:
398 for v in values:
399 ui.write((' %s\n') % v)
399 ui.write((' %s\n') % v)
400
400
401 @command('debugcheckstate', [], '')
401 @command('debugcheckstate', [], '')
402 def debugcheckstate(ui, repo):
402 def debugcheckstate(ui, repo):
403 """validate the correctness of the current dirstate"""
403 """validate the correctness of the current dirstate"""
404 parent1, parent2 = repo.dirstate.parents()
404 parent1, parent2 = repo.dirstate.parents()
405 m1 = repo[parent1].manifest()
405 m1 = repo[parent1].manifest()
406 m2 = repo[parent2].manifest()
406 m2 = repo[parent2].manifest()
407 errors = 0
407 errors = 0
408 for f in repo.dirstate:
408 for f in repo.dirstate:
409 state = repo.dirstate[f]
409 state = repo.dirstate[f]
410 if state in "nr" and f not in m1:
410 if state in "nr" and f not in m1:
411 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
411 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
412 errors += 1
412 errors += 1
413 if state in "a" and f in m1:
413 if state in "a" and f in m1:
414 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
414 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
415 errors += 1
415 errors += 1
416 if state in "m" and f not in m1 and f not in m2:
416 if state in "m" and f not in m1 and f not in m2:
417 ui.warn(_("%s in state %s, but not in either manifest\n") %
417 ui.warn(_("%s in state %s, but not in either manifest\n") %
418 (f, state))
418 (f, state))
419 errors += 1
419 errors += 1
420 for f in m1:
420 for f in m1:
421 state = repo.dirstate[f]
421 state = repo.dirstate[f]
422 if state not in "nrm":
422 if state not in "nrm":
423 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
423 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
424 errors += 1
424 errors += 1
425 if errors:
425 if errors:
426 error = _(".hg/dirstate inconsistent with current parent's manifest")
426 error = _(".hg/dirstate inconsistent with current parent's manifest")
427 raise error.Abort(error)
427 raise error.Abort(error)
428
428
429 @command('debugcolor',
429 @command('debugcolor',
430 [('', 'style', None, _('show all configured styles'))],
430 [('', 'style', None, _('show all configured styles'))],
431 'hg debugcolor')
431 'hg debugcolor')
432 def debugcolor(ui, repo, **opts):
432 def debugcolor(ui, repo, **opts):
433 """show available color, effects or style"""
433 """show available color, effects or style"""
434 ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode))
434 ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode))
435 if opts.get(r'style'):
435 if opts.get(r'style'):
436 return _debugdisplaystyle(ui)
436 return _debugdisplaystyle(ui)
437 else:
437 else:
438 return _debugdisplaycolor(ui)
438 return _debugdisplaycolor(ui)
439
439
440 def _debugdisplaycolor(ui):
440 def _debugdisplaycolor(ui):
441 ui = ui.copy()
441 ui = ui.copy()
442 ui._styles.clear()
442 ui._styles.clear()
443 for effect in color._activeeffects(ui).keys():
443 for effect in color._activeeffects(ui).keys():
444 ui._styles[effect] = effect
444 ui._styles[effect] = effect
445 if ui._terminfoparams:
445 if ui._terminfoparams:
446 for k, v in ui.configitems('color'):
446 for k, v in ui.configitems('color'):
447 if k.startswith('color.'):
447 if k.startswith('color.'):
448 ui._styles[k] = k[6:]
448 ui._styles[k] = k[6:]
449 elif k.startswith('terminfo.'):
449 elif k.startswith('terminfo.'):
450 ui._styles[k] = k[9:]
450 ui._styles[k] = k[9:]
451 ui.write(_('available colors:\n'))
451 ui.write(_('available colors:\n'))
452 # sort label with a '_' after the other to group '_background' entry.
452 # sort label with a '_' after the other to group '_background' entry.
453 items = sorted(ui._styles.items(),
453 items = sorted(ui._styles.items(),
454 key=lambda i: ('_' in i[0], i[0], i[1]))
454 key=lambda i: ('_' in i[0], i[0], i[1]))
455 for colorname, label in items:
455 for colorname, label in items:
456 ui.write(('%s\n') % colorname, label=label)
456 ui.write(('%s\n') % colorname, label=label)
457
457
458 def _debugdisplaystyle(ui):
458 def _debugdisplaystyle(ui):
459 ui.write(_('available style:\n'))
459 ui.write(_('available style:\n'))
460 if not ui._styles:
460 if not ui._styles:
461 return
461 return
462 width = max(len(s) for s in ui._styles)
462 width = max(len(s) for s in ui._styles)
463 for label, effects in sorted(ui._styles.items()):
463 for label, effects in sorted(ui._styles.items()):
464 ui.write('%s' % label, label=label)
464 ui.write('%s' % label, label=label)
465 if effects:
465 if effects:
466 # 50
466 # 50
467 ui.write(': ')
467 ui.write(': ')
468 ui.write(' ' * (max(0, width - len(label))))
468 ui.write(' ' * (max(0, width - len(label))))
469 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
469 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
470 ui.write('\n')
470 ui.write('\n')
471
471
472 @command('debugcreatestreamclonebundle', [], 'FILE')
472 @command('debugcreatestreamclonebundle', [], 'FILE')
473 def debugcreatestreamclonebundle(ui, repo, fname):
473 def debugcreatestreamclonebundle(ui, repo, fname):
474 """create a stream clone bundle file
474 """create a stream clone bundle file
475
475
476 Stream bundles are special bundles that are essentially archives of
476 Stream bundles are special bundles that are essentially archives of
477 revlog files. They are commonly used for cloning very quickly.
477 revlog files. They are commonly used for cloning very quickly.
478 """
478 """
479 # TODO we may want to turn this into an abort when this functionality
479 # TODO we may want to turn this into an abort when this functionality
480 # is moved into `hg bundle`.
480 # is moved into `hg bundle`.
481 if phases.hassecret(repo):
481 if phases.hassecret(repo):
482 ui.warn(_('(warning: stream clone bundle will contain secret '
482 ui.warn(_('(warning: stream clone bundle will contain secret '
483 'revisions)\n'))
483 'revisions)\n'))
484
484
485 requirements, gen = streamclone.generatebundlev1(repo)
485 requirements, gen = streamclone.generatebundlev1(repo)
486 changegroup.writechunks(ui, gen, fname)
486 changegroup.writechunks(ui, gen, fname)
487
487
488 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
488 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
489
489
490 @command('debugdag',
490 @command('debugdag',
491 [('t', 'tags', None, _('use tags as labels')),
491 [('t', 'tags', None, _('use tags as labels')),
492 ('b', 'branches', None, _('annotate with branch names')),
492 ('b', 'branches', None, _('annotate with branch names')),
493 ('', 'dots', None, _('use dots for runs')),
493 ('', 'dots', None, _('use dots for runs')),
494 ('s', 'spaces', None, _('separate elements by spaces'))],
494 ('s', 'spaces', None, _('separate elements by spaces'))],
495 _('[OPTION]... [FILE [REV]...]'),
495 _('[OPTION]... [FILE [REV]...]'),
496 optionalrepo=True)
496 optionalrepo=True)
497 def debugdag(ui, repo, file_=None, *revs, **opts):
497 def debugdag(ui, repo, file_=None, *revs, **opts):
498 """format the changelog or an index DAG as a concise textual description
498 """format the changelog or an index DAG as a concise textual description
499
499
500 If you pass a revlog index, the revlog's DAG is emitted. If you list
500 If you pass a revlog index, the revlog's DAG is emitted. If you list
501 revision numbers, they get labeled in the output as rN.
501 revision numbers, they get labeled in the output as rN.
502
502
503 Otherwise, the changelog DAG of the current repo is emitted.
503 Otherwise, the changelog DAG of the current repo is emitted.
504 """
504 """
505 spaces = opts.get(r'spaces')
505 spaces = opts.get(r'spaces')
506 dots = opts.get(r'dots')
506 dots = opts.get(r'dots')
507 if file_:
507 if file_:
508 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False),
508 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False),
509 file_)
509 file_)
510 revs = set((int(r) for r in revs))
510 revs = set((int(r) for r in revs))
511 def events():
511 def events():
512 for r in rlog:
512 for r in rlog:
513 yield 'n', (r, list(p for p in rlog.parentrevs(r)
513 yield 'n', (r, list(p for p in rlog.parentrevs(r)
514 if p != -1))
514 if p != -1))
515 if r in revs:
515 if r in revs:
516 yield 'l', (r, "r%i" % r)
516 yield 'l', (r, "r%i" % r)
517 elif repo:
517 elif repo:
518 cl = repo.changelog
518 cl = repo.changelog
519 tags = opts.get(r'tags')
519 tags = opts.get(r'tags')
520 branches = opts.get(r'branches')
520 branches = opts.get(r'branches')
521 if tags:
521 if tags:
522 labels = {}
522 labels = {}
523 for l, n in repo.tags().items():
523 for l, n in repo.tags().items():
524 labels.setdefault(cl.rev(n), []).append(l)
524 labels.setdefault(cl.rev(n), []).append(l)
525 def events():
525 def events():
526 b = "default"
526 b = "default"
527 for r in cl:
527 for r in cl:
528 if branches:
528 if branches:
529 newb = cl.read(cl.node(r))[5]['branch']
529 newb = cl.read(cl.node(r))[5]['branch']
530 if newb != b:
530 if newb != b:
531 yield 'a', newb
531 yield 'a', newb
532 b = newb
532 b = newb
533 yield 'n', (r, list(p for p in cl.parentrevs(r)
533 yield 'n', (r, list(p for p in cl.parentrevs(r)
534 if p != -1))
534 if p != -1))
535 if tags:
535 if tags:
536 ls = labels.get(r)
536 ls = labels.get(r)
537 if ls:
537 if ls:
538 for l in ls:
538 for l in ls:
539 yield 'l', (r, l)
539 yield 'l', (r, l)
540 else:
540 else:
541 raise error.Abort(_('need repo for changelog dag'))
541 raise error.Abort(_('need repo for changelog dag'))
542
542
543 for line in dagparser.dagtextlines(events(),
543 for line in dagparser.dagtextlines(events(),
544 addspaces=spaces,
544 addspaces=spaces,
545 wraplabels=True,
545 wraplabels=True,
546 wrapannotations=True,
546 wrapannotations=True,
547 wrapnonlinear=dots,
547 wrapnonlinear=dots,
548 usedots=dots,
548 usedots=dots,
549 maxlinewidth=70):
549 maxlinewidth=70):
550 ui.write(line)
550 ui.write(line)
551 ui.write("\n")
551 ui.write("\n")
552
552
553 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
553 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
554 def debugdata(ui, repo, file_, rev=None, **opts):
554 def debugdata(ui, repo, file_, rev=None, **opts):
555 """dump the contents of a data file revision"""
555 """dump the contents of a data file revision"""
556 opts = pycompat.byteskwargs(opts)
556 opts = pycompat.byteskwargs(opts)
557 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
557 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
558 if rev is not None:
558 if rev is not None:
559 raise error.CommandError('debugdata', _('invalid arguments'))
559 raise error.CommandError('debugdata', _('invalid arguments'))
560 file_, rev = None, file_
560 file_, rev = None, file_
561 elif rev is None:
561 elif rev is None:
562 raise error.CommandError('debugdata', _('invalid arguments'))
562 raise error.CommandError('debugdata', _('invalid arguments'))
563 r = cmdutil.openstorage(repo, 'debugdata', file_, opts)
563 r = cmdutil.openstorage(repo, 'debugdata', file_, opts)
564 try:
564 try:
565 ui.write(r.rawdata(r.lookup(rev)))
565 ui.write(r.rawdata(r.lookup(rev)))
566 except KeyError:
566 except KeyError:
567 raise error.Abort(_('invalid revision identifier %s') % rev)
567 raise error.Abort(_('invalid revision identifier %s') % rev)
568
568
569 @command('debugdate',
569 @command('debugdate',
570 [('e', 'extended', None, _('try extended date formats'))],
570 [('e', 'extended', None, _('try extended date formats'))],
571 _('[-e] DATE [RANGE]'),
571 _('[-e] DATE [RANGE]'),
572 norepo=True, optionalrepo=True)
572 norepo=True, optionalrepo=True)
573 def debugdate(ui, date, range=None, **opts):
573 def debugdate(ui, date, range=None, **opts):
574 """parse and display a date"""
574 """parse and display a date"""
575 if opts[r"extended"]:
575 if opts[r"extended"]:
576 d = dateutil.parsedate(date, util.extendeddateformats)
576 d = dateutil.parsedate(date, util.extendeddateformats)
577 else:
577 else:
578 d = dateutil.parsedate(date)
578 d = dateutil.parsedate(date)
579 ui.write(("internal: %d %d\n") % d)
579 ui.write(("internal: %d %d\n") % d)
580 ui.write(("standard: %s\n") % dateutil.datestr(d))
580 ui.write(("standard: %s\n") % dateutil.datestr(d))
581 if range:
581 if range:
582 m = dateutil.matchdate(range)
582 m = dateutil.matchdate(range)
583 ui.write(("match: %s\n") % m(d[0]))
583 ui.write(("match: %s\n") % m(d[0]))
584
584
585 @command('debugdeltachain',
585 @command('debugdeltachain',
586 cmdutil.debugrevlogopts + cmdutil.formatteropts,
586 cmdutil.debugrevlogopts + cmdutil.formatteropts,
587 _('-c|-m|FILE'),
587 _('-c|-m|FILE'),
588 optionalrepo=True)
588 optionalrepo=True)
589 def debugdeltachain(ui, repo, file_=None, **opts):
589 def debugdeltachain(ui, repo, file_=None, **opts):
590 """dump information about delta chains in a revlog
590 """dump information about delta chains in a revlog
591
591
592 Output can be templatized. Available template keywords are:
592 Output can be templatized. Available template keywords are:
593
593
594 :``rev``: revision number
594 :``rev``: revision number
595 :``chainid``: delta chain identifier (numbered by unique base)
595 :``chainid``: delta chain identifier (numbered by unique base)
596 :``chainlen``: delta chain length to this revision
596 :``chainlen``: delta chain length to this revision
597 :``prevrev``: previous revision in delta chain
597 :``prevrev``: previous revision in delta chain
598 :``deltatype``: role of delta / how it was computed
598 :``deltatype``: role of delta / how it was computed
599 :``compsize``: compressed size of revision
599 :``compsize``: compressed size of revision
600 :``uncompsize``: uncompressed size of revision
600 :``uncompsize``: uncompressed size of revision
601 :``chainsize``: total size of compressed revisions in chain
601 :``chainsize``: total size of compressed revisions in chain
602 :``chainratio``: total chain size divided by uncompressed revision size
602 :``chainratio``: total chain size divided by uncompressed revision size
603 (new delta chains typically start at ratio 2.00)
603 (new delta chains typically start at ratio 2.00)
604 :``lindist``: linear distance from base revision in delta chain to end
604 :``lindist``: linear distance from base revision in delta chain to end
605 of this revision
605 of this revision
606 :``extradist``: total size of revisions not part of this delta chain from
606 :``extradist``: total size of revisions not part of this delta chain from
607 base of delta chain to end of this revision; a measurement
607 base of delta chain to end of this revision; a measurement
608 of how much extra data we need to read/seek across to read
608 of how much extra data we need to read/seek across to read
609 the delta chain for this revision
609 the delta chain for this revision
610 :``extraratio``: extradist divided by chainsize; another representation of
610 :``extraratio``: extradist divided by chainsize; another representation of
611 how much unrelated data is needed to load this delta chain
611 how much unrelated data is needed to load this delta chain
612
612
613 If the repository is configured to use the sparse read, additional keywords
613 If the repository is configured to use the sparse read, additional keywords
614 are available:
614 are available:
615
615
616 :``readsize``: total size of data read from the disk for a revision
616 :``readsize``: total size of data read from the disk for a revision
617 (sum of the sizes of all the blocks)
617 (sum of the sizes of all the blocks)
618 :``largestblock``: size of the largest block of data read from the disk
618 :``largestblock``: size of the largest block of data read from the disk
619 :``readdensity``: density of useful bytes in the data read from the disk
619 :``readdensity``: density of useful bytes in the data read from the disk
620 :``srchunks``: in how many data hunks the whole revision would be read
620 :``srchunks``: in how many data hunks the whole revision would be read
621
621
622 The sparse read can be enabled with experimental.sparse-read = True
622 The sparse read can be enabled with experimental.sparse-read = True
623 """
623 """
624 opts = pycompat.byteskwargs(opts)
624 opts = pycompat.byteskwargs(opts)
625 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
625 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
626 index = r.index
626 index = r.index
627 start = r.start
627 start = r.start
628 length = r.length
628 length = r.length
629 generaldelta = r.version & revlog.FLAG_GENERALDELTA
629 generaldelta = r.version & revlog.FLAG_GENERALDELTA
630 withsparseread = getattr(r, '_withsparseread', False)
630 withsparseread = getattr(r, '_withsparseread', False)
631
631
632 def revinfo(rev):
632 def revinfo(rev):
633 e = index[rev]
633 e = index[rev]
634 compsize = e[1]
634 compsize = e[1]
635 uncompsize = e[2]
635 uncompsize = e[2]
636 chainsize = 0
636 chainsize = 0
637
637
638 if generaldelta:
638 if generaldelta:
639 if e[3] == e[5]:
639 if e[3] == e[5]:
640 deltatype = 'p1'
640 deltatype = 'p1'
641 elif e[3] == e[6]:
641 elif e[3] == e[6]:
642 deltatype = 'p2'
642 deltatype = 'p2'
643 elif e[3] == rev - 1:
643 elif e[3] == rev - 1:
644 deltatype = 'prev'
644 deltatype = 'prev'
645 elif e[3] == rev:
645 elif e[3] == rev:
646 deltatype = 'base'
646 deltatype = 'base'
647 else:
647 else:
648 deltatype = 'other'
648 deltatype = 'other'
649 else:
649 else:
650 if e[3] == rev:
650 if e[3] == rev:
651 deltatype = 'base'
651 deltatype = 'base'
652 else:
652 else:
653 deltatype = 'prev'
653 deltatype = 'prev'
654
654
655 chain = r._deltachain(rev)[0]
655 chain = r._deltachain(rev)[0]
656 for iterrev in chain:
656 for iterrev in chain:
657 e = index[iterrev]
657 e = index[iterrev]
658 chainsize += e[1]
658 chainsize += e[1]
659
659
660 return compsize, uncompsize, deltatype, chain, chainsize
660 return compsize, uncompsize, deltatype, chain, chainsize
661
661
662 fm = ui.formatter('debugdeltachain', opts)
662 fm = ui.formatter('debugdeltachain', opts)
663
663
664 fm.plain(' rev chain# chainlen prev delta '
664 fm.plain(' rev chain# chainlen prev delta '
665 'size rawsize chainsize ratio lindist extradist '
665 'size rawsize chainsize ratio lindist extradist '
666 'extraratio')
666 'extraratio')
667 if withsparseread:
667 if withsparseread:
668 fm.plain(' readsize largestblk rddensity srchunks')
668 fm.plain(' readsize largestblk rddensity srchunks')
669 fm.plain('\n')
669 fm.plain('\n')
670
670
671 chainbases = {}
671 chainbases = {}
672 for rev in r:
672 for rev in r:
673 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
673 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
674 chainbase = chain[0]
674 chainbase = chain[0]
675 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
675 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
676 basestart = start(chainbase)
676 basestart = start(chainbase)
677 revstart = start(rev)
677 revstart = start(rev)
678 lineardist = revstart + comp - basestart
678 lineardist = revstart + comp - basestart
679 extradist = lineardist - chainsize
679 extradist = lineardist - chainsize
680 try:
680 try:
681 prevrev = chain[-2]
681 prevrev = chain[-2]
682 except IndexError:
682 except IndexError:
683 prevrev = -1
683 prevrev = -1
684
684
685 if uncomp != 0:
685 if uncomp != 0:
686 chainratio = float(chainsize) / float(uncomp)
686 chainratio = float(chainsize) / float(uncomp)
687 else:
687 else:
688 chainratio = chainsize
688 chainratio = chainsize
689
689
690 if chainsize != 0:
690 if chainsize != 0:
691 extraratio = float(extradist) / float(chainsize)
691 extraratio = float(extradist) / float(chainsize)
692 else:
692 else:
693 extraratio = extradist
693 extraratio = extradist
694
694
695 fm.startitem()
695 fm.startitem()
696 fm.write('rev chainid chainlen prevrev deltatype compsize '
696 fm.write('rev chainid chainlen prevrev deltatype compsize '
697 'uncompsize chainsize chainratio lindist extradist '
697 'uncompsize chainsize chainratio lindist extradist '
698 'extraratio',
698 'extraratio',
699 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
699 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
700 rev, chainid, len(chain), prevrev, deltatype, comp,
700 rev, chainid, len(chain), prevrev, deltatype, comp,
701 uncomp, chainsize, chainratio, lineardist, extradist,
701 uncomp, chainsize, chainratio, lineardist, extradist,
702 extraratio,
702 extraratio,
703 rev=rev, chainid=chainid, chainlen=len(chain),
703 rev=rev, chainid=chainid, chainlen=len(chain),
704 prevrev=prevrev, deltatype=deltatype, compsize=comp,
704 prevrev=prevrev, deltatype=deltatype, compsize=comp,
705 uncompsize=uncomp, chainsize=chainsize,
705 uncompsize=uncomp, chainsize=chainsize,
706 chainratio=chainratio, lindist=lineardist,
706 chainratio=chainratio, lindist=lineardist,
707 extradist=extradist, extraratio=extraratio)
707 extradist=extradist, extraratio=extraratio)
708 if withsparseread:
708 if withsparseread:
709 readsize = 0
709 readsize = 0
710 largestblock = 0
710 largestblock = 0
711 srchunks = 0
711 srchunks = 0
712
712
713 for revschunk in deltautil.slicechunk(r, chain):
713 for revschunk in deltautil.slicechunk(r, chain):
714 srchunks += 1
714 srchunks += 1
715 blkend = start(revschunk[-1]) + length(revschunk[-1])
715 blkend = start(revschunk[-1]) + length(revschunk[-1])
716 blksize = blkend - start(revschunk[0])
716 blksize = blkend - start(revschunk[0])
717
717
718 readsize += blksize
718 readsize += blksize
719 if largestblock < blksize:
719 if largestblock < blksize:
720 largestblock = blksize
720 largestblock = blksize
721
721
722 if readsize:
722 if readsize:
723 readdensity = float(chainsize) / float(readsize)
723 readdensity = float(chainsize) / float(readsize)
724 else:
724 else:
725 readdensity = 1
725 readdensity = 1
726
726
727 fm.write('readsize largestblock readdensity srchunks',
727 fm.write('readsize largestblock readdensity srchunks',
728 ' %10d %10d %9.5f %8d',
728 ' %10d %10d %9.5f %8d',
729 readsize, largestblock, readdensity, srchunks,
729 readsize, largestblock, readdensity, srchunks,
730 readsize=readsize, largestblock=largestblock,
730 readsize=readsize, largestblock=largestblock,
731 readdensity=readdensity, srchunks=srchunks)
731 readdensity=readdensity, srchunks=srchunks)
732
732
733 fm.plain('\n')
733 fm.plain('\n')
734
734
735 fm.end()
735 fm.end()
736
736
737 @command('debugdirstate|debugstate',
737 @command('debugdirstate|debugstate',
738 [('', 'nodates', None, _('do not display the saved mtime (DEPRECATED)')),
738 [('', 'nodates', None, _('do not display the saved mtime (DEPRECATED)')),
739 ('', 'dates', True, _('display the saved mtime')),
739 ('', 'dates', True, _('display the saved mtime')),
740 ('', 'datesort', None, _('sort by saved mtime'))],
740 ('', 'datesort', None, _('sort by saved mtime'))],
741 _('[OPTION]...'))
741 _('[OPTION]...'))
742 def debugstate(ui, repo, **opts):
742 def debugstate(ui, repo, **opts):
743 """show the contents of the current dirstate"""
743 """show the contents of the current dirstate"""
744
744
745 nodates = not opts[r'dates']
745 nodates = not opts[r'dates']
746 if opts.get(r'nodates') is not None:
746 if opts.get(r'nodates') is not None:
747 nodates = True
747 nodates = True
748 datesort = opts.get(r'datesort')
748 datesort = opts.get(r'datesort')
749
749
750 if datesort:
750 if datesort:
751 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
751 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
752 else:
752 else:
753 keyfunc = None # sort by filename
753 keyfunc = None # sort by filename
754 for file_, ent in sorted(repo.dirstate.iteritems(), key=keyfunc):
754 for file_, ent in sorted(repo.dirstate.iteritems(), key=keyfunc):
755 if ent[3] == -1:
755 if ent[3] == -1:
756 timestr = 'unset '
756 timestr = 'unset '
757 elif nodates:
757 elif nodates:
758 timestr = 'set '
758 timestr = 'set '
759 else:
759 else:
760 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ",
760 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ",
761 time.localtime(ent[3]))
761 time.localtime(ent[3]))
762 timestr = encoding.strtolocal(timestr)
762 timestr = encoding.strtolocal(timestr)
763 if ent[1] & 0o20000:
763 if ent[1] & 0o20000:
764 mode = 'lnk'
764 mode = 'lnk'
765 else:
765 else:
766 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
766 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
767 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
767 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
768 for f in repo.dirstate.copies():
768 for f in repo.dirstate.copies():
769 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
769 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
770
770
771 @command('debugdiscovery',
771 @command('debugdiscovery',
772 [('', 'old', None, _('use old-style discovery')),
772 [('', 'old', None, _('use old-style discovery')),
773 ('', 'nonheads', None,
773 ('', 'nonheads', None,
774 _('use old-style discovery with non-heads included')),
774 _('use old-style discovery with non-heads included')),
775 ('', 'rev', [], 'restrict discovery to this set of revs'),
775 ('', 'rev', [], 'restrict discovery to this set of revs'),
776 ('', 'seed', '12323', 'specify the random seed use for discovery'),
776 ('', 'seed', '12323', 'specify the random seed use for discovery'),
777 ] + cmdutil.remoteopts,
777 ] + cmdutil.remoteopts,
778 _('[--rev REV] [OTHER]'))
778 _('[--rev REV] [OTHER]'))
779 def debugdiscovery(ui, repo, remoteurl="default", **opts):
779 def debugdiscovery(ui, repo, remoteurl="default", **opts):
780 """runs the changeset discovery protocol in isolation"""
780 """runs the changeset discovery protocol in isolation"""
781 opts = pycompat.byteskwargs(opts)
781 opts = pycompat.byteskwargs(opts)
782 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl))
782 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl))
783 remote = hg.peer(repo, opts, remoteurl)
783 remote = hg.peer(repo, opts, remoteurl)
784 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
784 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
785
785
786 # make sure tests are repeatable
786 # make sure tests are repeatable
787 random.seed(int(opts['seed']))
787 random.seed(int(opts['seed']))
788
788
789
789
790
790
791 if opts.get('old'):
791 if opts.get('old'):
792 def doit(pushedrevs, remoteheads, remote=remote):
792 def doit(pushedrevs, remoteheads, remote=remote):
793 if not util.safehasattr(remote, 'branches'):
793 if not util.safehasattr(remote, 'branches'):
794 # enable in-client legacy support
794 # enable in-client legacy support
795 remote = localrepo.locallegacypeer(remote.local())
795 remote = localrepo.locallegacypeer(remote.local())
796 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
796 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
797 force=True)
797 force=True)
798 common = set(common)
798 common = set(common)
799 if not opts.get('nonheads'):
799 if not opts.get('nonheads'):
800 ui.write(("unpruned common: %s\n") %
800 ui.write(("unpruned common: %s\n") %
801 " ".join(sorted(short(n) for n in common)))
801 " ".join(sorted(short(n) for n in common)))
802
802
803 clnode = repo.changelog.node
803 clnode = repo.changelog.node
804 common = repo.revs('heads(::%ln)', common)
804 common = repo.revs('heads(::%ln)', common)
805 common = {clnode(r) for r in common}
805 common = {clnode(r) for r in common}
806 return common, hds
806 return common, hds
807 else:
807 else:
808 def doit(pushedrevs, remoteheads, remote=remote):
808 def doit(pushedrevs, remoteheads, remote=remote):
809 nodes = None
809 nodes = None
810 if pushedrevs:
810 if pushedrevs:
811 revs = scmutil.revrange(repo, pushedrevs)
811 revs = scmutil.revrange(repo, pushedrevs)
812 nodes = [repo[r].node() for r in revs]
812 nodes = [repo[r].node() for r in revs]
813 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
813 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
814 ancestorsof=nodes)
814 ancestorsof=nodes)
815 return common, hds
815 return common, hds
816
816
817 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
817 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
818 localrevs = opts['rev']
818 localrevs = opts['rev']
819 with util.timedcm('debug-discovery') as t:
819 with util.timedcm('debug-discovery') as t:
820 common, hds = doit(localrevs, remoterevs)
820 common, hds = doit(localrevs, remoterevs)
821
821
822 # compute all statistics
822 # compute all statistics
823 common = set(common)
823 common = set(common)
824 rheads = set(hds)
824 rheads = set(hds)
825 lheads = set(repo.heads())
825 lheads = set(repo.heads())
826
826
827 data = {}
827 data = {}
828 data['elapsed'] = t.elapsed
828 data['elapsed'] = t.elapsed
829 data['nb-common'] = len(common)
829 data['nb-common'] = len(common)
830 data['nb-common-local'] = len(common & lheads)
830 data['nb-common-local'] = len(common & lheads)
831 data['nb-common-remote'] = len(common & rheads)
831 data['nb-common-remote'] = len(common & rheads)
832 data['nb-common-both'] = len(common & rheads & lheads)
832 data['nb-common-both'] = len(common & rheads & lheads)
833 data['nb-local'] = len(lheads)
833 data['nb-local'] = len(lheads)
834 data['nb-local-missing'] = data['nb-local'] - data['nb-common-local']
834 data['nb-local-missing'] = data['nb-local'] - data['nb-common-local']
835 data['nb-remote'] = len(rheads)
835 data['nb-remote'] = len(rheads)
836 data['nb-remote-unknown'] = data['nb-remote'] - data['nb-common-remote']
836 data['nb-remote-unknown'] = data['nb-remote'] - data['nb-common-remote']
837 data['nb-revs'] = len(repo.revs('all()'))
837 data['nb-revs'] = len(repo.revs('all()'))
838 data['nb-revs-common'] = len(repo.revs('::%ln', common))
838 data['nb-revs-common'] = len(repo.revs('::%ln', common))
839 data['nb-revs-missing'] = data['nb-revs'] - data['nb-revs-common']
839 data['nb-revs-missing'] = data['nb-revs'] - data['nb-revs-common']
840
840
841 # display discovery summary
841 # display discovery summary
842 ui.write(("elapsed time: %(elapsed)f seconds\n") % data)
842 ui.write(("elapsed time: %(elapsed)f seconds\n") % data)
843 ui.write(("heads summary:\n"))
843 ui.write(("heads summary:\n"))
844 ui.write((" total common heads: %(nb-common)9d\n") % data)
844 ui.write((" total common heads: %(nb-common)9d\n") % data)
845 ui.write((" also local heads: %(nb-common-local)9d\n") % data)
845 ui.write((" also local heads: %(nb-common-local)9d\n") % data)
846 ui.write((" also remote heads: %(nb-common-remote)9d\n") % data)
846 ui.write((" also remote heads: %(nb-common-remote)9d\n") % data)
847 ui.write((" both: %(nb-common-both)9d\n") % data)
847 ui.write((" both: %(nb-common-both)9d\n") % data)
848 ui.write((" local heads: %(nb-local)9d\n") % data)
848 ui.write((" local heads: %(nb-local)9d\n") % data)
849 ui.write((" common: %(nb-common-local)9d\n") % data)
849 ui.write((" common: %(nb-common-local)9d\n") % data)
850 ui.write((" missing: %(nb-local-missing)9d\n") % data)
850 ui.write((" missing: %(nb-local-missing)9d\n") % data)
851 ui.write((" remote heads: %(nb-remote)9d\n") % data)
851 ui.write((" remote heads: %(nb-remote)9d\n") % data)
852 ui.write((" common: %(nb-common-remote)9d\n") % data)
852 ui.write((" common: %(nb-common-remote)9d\n") % data)
853 ui.write((" unknown: %(nb-remote-unknown)9d\n") % data)
853 ui.write((" unknown: %(nb-remote-unknown)9d\n") % data)
854 ui.write(("local changesets: %(nb-revs)9d\n") % data)
854 ui.write(("local changesets: %(nb-revs)9d\n") % data)
855 ui.write((" common: %(nb-revs-common)9d\n") % data)
855 ui.write((" common: %(nb-revs-common)9d\n") % data)
856 ui.write((" missing: %(nb-revs-missing)9d\n") % data)
856 ui.write((" missing: %(nb-revs-missing)9d\n") % data)
857
857
858 if ui.verbose:
858 if ui.verbose:
859 ui.write(("common heads: %s\n") %
859 ui.write(("common heads: %s\n") %
860 " ".join(sorted(short(n) for n in common)))
860 " ".join(sorted(short(n) for n in common)))
861
861
862 _chunksize = 4 << 10
862 _chunksize = 4 << 10
863
863
864 @command('debugdownload',
864 @command('debugdownload',
865 [
865 [
866 ('o', 'output', '', _('path')),
866 ('o', 'output', '', _('path')),
867 ],
867 ],
868 optionalrepo=True)
868 optionalrepo=True)
869 def debugdownload(ui, repo, url, output=None, **opts):
869 def debugdownload(ui, repo, url, output=None, **opts):
870 """download a resource using Mercurial logic and config
870 """download a resource using Mercurial logic and config
871 """
871 """
872 fh = urlmod.open(ui, url, output)
872 fh = urlmod.open(ui, url, output)
873
873
874 dest = ui
874 dest = ui
875 if output:
875 if output:
876 dest = open(output, "wb", _chunksize)
876 dest = open(output, "wb", _chunksize)
877 try:
877 try:
878 data = fh.read(_chunksize)
878 data = fh.read(_chunksize)
879 while data:
879 while data:
880 dest.write(data)
880 dest.write(data)
881 data = fh.read(_chunksize)
881 data = fh.read(_chunksize)
882 finally:
882 finally:
883 if output:
883 if output:
884 dest.close()
884 dest.close()
885
885
886 @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True)
886 @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True)
887 def debugextensions(ui, repo, **opts):
887 def debugextensions(ui, repo, **opts):
888 '''show information about active extensions'''
888 '''show information about active extensions'''
889 opts = pycompat.byteskwargs(opts)
889 opts = pycompat.byteskwargs(opts)
890 exts = extensions.extensions(ui)
890 exts = extensions.extensions(ui)
891 hgver = util.version()
891 hgver = util.version()
892 fm = ui.formatter('debugextensions', opts)
892 fm = ui.formatter('debugextensions', opts)
893 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
893 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
894 isinternal = extensions.ismoduleinternal(extmod)
894 isinternal = extensions.ismoduleinternal(extmod)
895 extsource = pycompat.fsencode(extmod.__file__)
895 extsource = pycompat.fsencode(extmod.__file__)
896 if isinternal:
896 if isinternal:
897 exttestedwith = [] # never expose magic string to users
897 exttestedwith = [] # never expose magic string to users
898 else:
898 else:
899 exttestedwith = getattr(extmod, 'testedwith', '').split()
899 exttestedwith = getattr(extmod, 'testedwith', '').split()
900 extbuglink = getattr(extmod, 'buglink', None)
900 extbuglink = getattr(extmod, 'buglink', None)
901
901
902 fm.startitem()
902 fm.startitem()
903
903
904 if ui.quiet or ui.verbose:
904 if ui.quiet or ui.verbose:
905 fm.write('name', '%s\n', extname)
905 fm.write('name', '%s\n', extname)
906 else:
906 else:
907 fm.write('name', '%s', extname)
907 fm.write('name', '%s', extname)
908 if isinternal or hgver in exttestedwith:
908 if isinternal or hgver in exttestedwith:
909 fm.plain('\n')
909 fm.plain('\n')
910 elif not exttestedwith:
910 elif not exttestedwith:
911 fm.plain(_(' (untested!)\n'))
911 fm.plain(_(' (untested!)\n'))
912 else:
912 else:
913 lasttestedversion = exttestedwith[-1]
913 lasttestedversion = exttestedwith[-1]
914 fm.plain(' (%s!)\n' % lasttestedversion)
914 fm.plain(' (%s!)\n' % lasttestedversion)
915
915
916 fm.condwrite(ui.verbose and extsource, 'source',
916 fm.condwrite(ui.verbose and extsource, 'source',
917 _(' location: %s\n'), extsource or "")
917 _(' location: %s\n'), extsource or "")
918
918
919 if ui.verbose:
919 if ui.verbose:
920 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal])
920 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal])
921 fm.data(bundled=isinternal)
921 fm.data(bundled=isinternal)
922
922
923 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
923 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
924 _(' tested with: %s\n'),
924 _(' tested with: %s\n'),
925 fm.formatlist(exttestedwith, name='ver'))
925 fm.formatlist(exttestedwith, name='ver'))
926
926
927 fm.condwrite(ui.verbose and extbuglink, 'buglink',
927 fm.condwrite(ui.verbose and extbuglink, 'buglink',
928 _(' bug reporting: %s\n'), extbuglink or "")
928 _(' bug reporting: %s\n'), extbuglink or "")
929
929
930 fm.end()
930 fm.end()
931
931
932 @command('debugfileset',
932 @command('debugfileset',
933 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')),
933 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')),
934 ('', 'all-files', False,
934 ('', 'all-files', False,
935 _('test files from all revisions and working directory')),
935 _('test files from all revisions and working directory')),
936 ('s', 'show-matcher', None,
936 ('s', 'show-matcher', None,
937 _('print internal representation of matcher')),
937 _('print internal representation of matcher')),
938 ('p', 'show-stage', [],
938 ('p', 'show-stage', [],
939 _('print parsed tree at the given stage'), _('NAME'))],
939 _('print parsed tree at the given stage'), _('NAME'))],
940 _('[-r REV] [--all-files] [OPTION]... FILESPEC'))
940 _('[-r REV] [--all-files] [OPTION]... FILESPEC'))
941 def debugfileset(ui, repo, expr, **opts):
941 def debugfileset(ui, repo, expr, **opts):
942 '''parse and apply a fileset specification'''
942 '''parse and apply a fileset specification'''
943 from . import fileset
943 from . import fileset
944 fileset.symbols # force import of fileset so we have predicates to optimize
944 fileset.symbols # force import of fileset so we have predicates to optimize
945 opts = pycompat.byteskwargs(opts)
945 opts = pycompat.byteskwargs(opts)
946 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
946 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
947
947
948 stages = [
948 stages = [
949 ('parsed', pycompat.identity),
949 ('parsed', pycompat.identity),
950 ('analyzed', filesetlang.analyze),
950 ('analyzed', filesetlang.analyze),
951 ('optimized', filesetlang.optimize),
951 ('optimized', filesetlang.optimize),
952 ]
952 ]
953 stagenames = set(n for n, f in stages)
953 stagenames = set(n for n, f in stages)
954
954
955 showalways = set()
955 showalways = set()
956 if ui.verbose and not opts['show_stage']:
956 if ui.verbose and not opts['show_stage']:
957 # show parsed tree by --verbose (deprecated)
957 # show parsed tree by --verbose (deprecated)
958 showalways.add('parsed')
958 showalways.add('parsed')
959 if opts['show_stage'] == ['all']:
959 if opts['show_stage'] == ['all']:
960 showalways.update(stagenames)
960 showalways.update(stagenames)
961 else:
961 else:
962 for n in opts['show_stage']:
962 for n in opts['show_stage']:
963 if n not in stagenames:
963 if n not in stagenames:
964 raise error.Abort(_('invalid stage name: %s') % n)
964 raise error.Abort(_('invalid stage name: %s') % n)
965 showalways.update(opts['show_stage'])
965 showalways.update(opts['show_stage'])
966
966
967 tree = filesetlang.parse(expr)
967 tree = filesetlang.parse(expr)
968 for n, f in stages:
968 for n, f in stages:
969 tree = f(tree)
969 tree = f(tree)
970 if n in showalways:
970 if n in showalways:
971 if opts['show_stage'] or n != 'parsed':
971 if opts['show_stage'] or n != 'parsed':
972 ui.write(("* %s:\n") % n)
972 ui.write(("* %s:\n") % n)
973 ui.write(filesetlang.prettyformat(tree), "\n")
973 ui.write(filesetlang.prettyformat(tree), "\n")
974
974
975 files = set()
975 files = set()
976 if opts['all_files']:
976 if opts['all_files']:
977 for r in repo:
977 for r in repo:
978 c = repo[r]
978 c = repo[r]
979 files.update(c.files())
979 files.update(c.files())
980 files.update(c.substate)
980 files.update(c.substate)
981 if opts['all_files'] or ctx.rev() is None:
981 if opts['all_files'] or ctx.rev() is None:
982 wctx = repo[None]
982 wctx = repo[None]
983 files.update(repo.dirstate.walk(scmutil.matchall(repo),
983 files.update(repo.dirstate.walk(scmutil.matchall(repo),
984 subrepos=list(wctx.substate),
984 subrepos=list(wctx.substate),
985 unknown=True, ignored=True))
985 unknown=True, ignored=True))
986 files.update(wctx.substate)
986 files.update(wctx.substate)
987 else:
987 else:
988 files.update(ctx.files())
988 files.update(ctx.files())
989 files.update(ctx.substate)
989 files.update(ctx.substate)
990
990
991 m = ctx.matchfileset(expr)
991 m = ctx.matchfileset(expr)
992 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose):
992 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose):
993 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n')
993 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n')
994 for f in sorted(files):
994 for f in sorted(files):
995 if not m(f):
995 if not m(f):
996 continue
996 continue
997 ui.write("%s\n" % f)
997 ui.write("%s\n" % f)
998
998
999 @command('debugformat',
999 @command('debugformat',
1000 [] + cmdutil.formatteropts)
1000 [] + cmdutil.formatteropts)
1001 def debugformat(ui, repo, **opts):
1001 def debugformat(ui, repo, **opts):
1002 """display format information about the current repository
1002 """display format information about the current repository
1003
1003
1004 Use --verbose to get extra information about current config value and
1004 Use --verbose to get extra information about current config value and
1005 Mercurial default."""
1005 Mercurial default."""
1006 opts = pycompat.byteskwargs(opts)
1006 opts = pycompat.byteskwargs(opts)
1007 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant)
1007 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant)
1008 maxvariantlength = max(len('format-variant'), maxvariantlength)
1008 maxvariantlength = max(len('format-variant'), maxvariantlength)
1009
1009
1010 def makeformatname(name):
1010 def makeformatname(name):
1011 return '%s:' + (' ' * (maxvariantlength - len(name)))
1011 return '%s:' + (' ' * (maxvariantlength - len(name)))
1012
1012
1013 fm = ui.formatter('debugformat', opts)
1013 fm = ui.formatter('debugformat', opts)
1014 if fm.isplain():
1014 if fm.isplain():
1015 def formatvalue(value):
1015 def formatvalue(value):
1016 if util.safehasattr(value, 'startswith'):
1016 if util.safehasattr(value, 'startswith'):
1017 return value
1017 return value
1018 if value:
1018 if value:
1019 return 'yes'
1019 return 'yes'
1020 else:
1020 else:
1021 return 'no'
1021 return 'no'
1022 else:
1022 else:
1023 formatvalue = pycompat.identity
1023 formatvalue = pycompat.identity
1024
1024
1025 fm.plain('format-variant')
1025 fm.plain('format-variant')
1026 fm.plain(' ' * (maxvariantlength - len('format-variant')))
1026 fm.plain(' ' * (maxvariantlength - len('format-variant')))
1027 fm.plain(' repo')
1027 fm.plain(' repo')
1028 if ui.verbose:
1028 if ui.verbose:
1029 fm.plain(' config default')
1029 fm.plain(' config default')
1030 fm.plain('\n')
1030 fm.plain('\n')
1031 for fv in upgrade.allformatvariant:
1031 for fv in upgrade.allformatvariant:
1032 fm.startitem()
1032 fm.startitem()
1033 repovalue = fv.fromrepo(repo)
1033 repovalue = fv.fromrepo(repo)
1034 configvalue = fv.fromconfig(repo)
1034 configvalue = fv.fromconfig(repo)
1035
1035
1036 if repovalue != configvalue:
1036 if repovalue != configvalue:
1037 namelabel = 'formatvariant.name.mismatchconfig'
1037 namelabel = 'formatvariant.name.mismatchconfig'
1038 repolabel = 'formatvariant.repo.mismatchconfig'
1038 repolabel = 'formatvariant.repo.mismatchconfig'
1039 elif repovalue != fv.default:
1039 elif repovalue != fv.default:
1040 namelabel = 'formatvariant.name.mismatchdefault'
1040 namelabel = 'formatvariant.name.mismatchdefault'
1041 repolabel = 'formatvariant.repo.mismatchdefault'
1041 repolabel = 'formatvariant.repo.mismatchdefault'
1042 else:
1042 else:
1043 namelabel = 'formatvariant.name.uptodate'
1043 namelabel = 'formatvariant.name.uptodate'
1044 repolabel = 'formatvariant.repo.uptodate'
1044 repolabel = 'formatvariant.repo.uptodate'
1045
1045
1046 fm.write('name', makeformatname(fv.name), fv.name,
1046 fm.write('name', makeformatname(fv.name), fv.name,
1047 label=namelabel)
1047 label=namelabel)
1048 fm.write('repo', ' %3s', formatvalue(repovalue),
1048 fm.write('repo', ' %3s', formatvalue(repovalue),
1049 label=repolabel)
1049 label=repolabel)
1050 if fv.default != configvalue:
1050 if fv.default != configvalue:
1051 configlabel = 'formatvariant.config.special'
1051 configlabel = 'formatvariant.config.special'
1052 else:
1052 else:
1053 configlabel = 'formatvariant.config.default'
1053 configlabel = 'formatvariant.config.default'
1054 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
1054 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue),
1055 label=configlabel)
1055 label=configlabel)
1056 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
1056 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
1057 label='formatvariant.default')
1057 label='formatvariant.default')
1058 fm.plain('\n')
1058 fm.plain('\n')
1059 fm.end()
1059 fm.end()
1060
1060
1061 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
1061 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
1062 def debugfsinfo(ui, path="."):
1062 def debugfsinfo(ui, path="."):
1063 """show information detected about current filesystem"""
1063 """show information detected about current filesystem"""
1064 ui.write(('path: %s\n') % path)
1064 ui.write(('path: %s\n') % path)
1065 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)'))
1065 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)'))
1066 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
1066 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
1067 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)'))
1067 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)'))
1068 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
1068 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
1069 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
1069 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
1070 casesensitive = '(unknown)'
1070 casesensitive = '(unknown)'
1071 try:
1071 try:
1072 with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f:
1072 with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f:
1073 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no'
1073 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no'
1074 except OSError:
1074 except OSError:
1075 pass
1075 pass
1076 ui.write(('case-sensitive: %s\n') % casesensitive)
1076 ui.write(('case-sensitive: %s\n') % casesensitive)
1077
1077
1078 @command('debuggetbundle',
1078 @command('debuggetbundle',
1079 [('H', 'head', [], _('id of head node'), _('ID')),
1079 [('H', 'head', [], _('id of head node'), _('ID')),
1080 ('C', 'common', [], _('id of common node'), _('ID')),
1080 ('C', 'common', [], _('id of common node'), _('ID')),
1081 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
1081 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
1082 _('REPO FILE [-H|-C ID]...'),
1082 _('REPO FILE [-H|-C ID]...'),
1083 norepo=True)
1083 norepo=True)
1084 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1084 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1085 """retrieves a bundle from a repo
1085 """retrieves a bundle from a repo
1086
1086
1087 Every ID must be a full-length hex node id string. Saves the bundle to the
1087 Every ID must be a full-length hex node id string. Saves the bundle to the
1088 given file.
1088 given file.
1089 """
1089 """
1090 opts = pycompat.byteskwargs(opts)
1090 opts = pycompat.byteskwargs(opts)
1091 repo = hg.peer(ui, opts, repopath)
1091 repo = hg.peer(ui, opts, repopath)
1092 if not repo.capable('getbundle'):
1092 if not repo.capable('getbundle'):
1093 raise error.Abort("getbundle() not supported by target repository")
1093 raise error.Abort("getbundle() not supported by target repository")
1094 args = {}
1094 args = {}
1095 if common:
1095 if common:
1096 args[r'common'] = [bin(s) for s in common]
1096 args[r'common'] = [bin(s) for s in common]
1097 if head:
1097 if head:
1098 args[r'heads'] = [bin(s) for s in head]
1098 args[r'heads'] = [bin(s) for s in head]
1099 # TODO: get desired bundlecaps from command line.
1099 # TODO: get desired bundlecaps from command line.
1100 args[r'bundlecaps'] = None
1100 args[r'bundlecaps'] = None
1101 bundle = repo.getbundle('debug', **args)
1101 bundle = repo.getbundle('debug', **args)
1102
1102
1103 bundletype = opts.get('type', 'bzip2').lower()
1103 bundletype = opts.get('type', 'bzip2').lower()
1104 btypes = {'none': 'HG10UN',
1104 btypes = {'none': 'HG10UN',
1105 'bzip2': 'HG10BZ',
1105 'bzip2': 'HG10BZ',
1106 'gzip': 'HG10GZ',
1106 'gzip': 'HG10GZ',
1107 'bundle2': 'HG20'}
1107 'bundle2': 'HG20'}
1108 bundletype = btypes.get(bundletype)
1108 bundletype = btypes.get(bundletype)
1109 if bundletype not in bundle2.bundletypes:
1109 if bundletype not in bundle2.bundletypes:
1110 raise error.Abort(_('unknown bundle type specified with --type'))
1110 raise error.Abort(_('unknown bundle type specified with --type'))
1111 bundle2.writebundle(ui, bundle, bundlepath, bundletype)
1111 bundle2.writebundle(ui, bundle, bundlepath, bundletype)
1112
1112
1113 @command('debugignore', [], '[FILE]')
1113 @command('debugignore', [], '[FILE]')
1114 def debugignore(ui, repo, *files, **opts):
1114 def debugignore(ui, repo, *files, **opts):
1115 """display the combined ignore pattern and information about ignored files
1115 """display the combined ignore pattern and information about ignored files
1116
1116
1117 With no argument display the combined ignore pattern.
1117 With no argument display the combined ignore pattern.
1118
1118
1119 Given space separated file names, shows if the given file is ignored and
1119 Given space separated file names, shows if the given file is ignored and
1120 if so, show the ignore rule (file and line number) that matched it.
1120 if so, show the ignore rule (file and line number) that matched it.
1121 """
1121 """
1122 ignore = repo.dirstate._ignore
1122 ignore = repo.dirstate._ignore
1123 if not files:
1123 if not files:
1124 # Show all the patterns
1124 # Show all the patterns
1125 ui.write("%s\n" % pycompat.byterepr(ignore))
1125 ui.write("%s\n" % pycompat.byterepr(ignore))
1126 else:
1126 else:
1127 m = scmutil.match(repo[None], pats=files)
1127 m = scmutil.match(repo[None], pats=files)
1128 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
1128 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
1129 for f in m.files():
1129 for f in m.files():
1130 nf = util.normpath(f)
1130 nf = util.normpath(f)
1131 ignored = None
1131 ignored = None
1132 ignoredata = None
1132 ignoredata = None
1133 if nf != '.':
1133 if nf != '.':
1134 if ignore(nf):
1134 if ignore(nf):
1135 ignored = nf
1135 ignored = nf
1136 ignoredata = repo.dirstate._ignorefileandline(nf)
1136 ignoredata = repo.dirstate._ignorefileandline(nf)
1137 else:
1137 else:
1138 for p in util.finddirs(nf):
1138 for p in util.finddirs(nf):
1139 if ignore(p):
1139 if ignore(p):
1140 ignored = p
1140 ignored = p
1141 ignoredata = repo.dirstate._ignorefileandline(p)
1141 ignoredata = repo.dirstate._ignorefileandline(p)
1142 break
1142 break
1143 if ignored:
1143 if ignored:
1144 if ignored == nf:
1144 if ignored == nf:
1145 ui.write(_("%s is ignored\n") % uipathfn(f))
1145 ui.write(_("%s is ignored\n") % uipathfn(f))
1146 else:
1146 else:
1147 ui.write(_("%s is ignored because of "
1147 ui.write(_("%s is ignored because of "
1148 "containing directory %s\n")
1148 "containing directory %s\n")
1149 % (uipathfn(f), ignored))
1149 % (uipathfn(f), ignored))
1150 ignorefile, lineno, line = ignoredata
1150 ignorefile, lineno, line = ignoredata
1151 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
1151 ui.write(_("(ignore rule in %s, line %d: '%s')\n")
1152 % (ignorefile, lineno, line))
1152 % (ignorefile, lineno, line))
1153 else:
1153 else:
1154 ui.write(_("%s is not ignored\n") % uipathfn(f))
1154 ui.write(_("%s is not ignored\n") % uipathfn(f))
1155
1155
1156 @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts,
1156 @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts,
1157 _('-c|-m|FILE'))
1157 _('-c|-m|FILE'))
1158 def debugindex(ui, repo, file_=None, **opts):
1158 def debugindex(ui, repo, file_=None, **opts):
1159 """dump index data for a storage primitive"""
1159 """dump index data for a storage primitive"""
1160 opts = pycompat.byteskwargs(opts)
1160 opts = pycompat.byteskwargs(opts)
1161 store = cmdutil.openstorage(repo, 'debugindex', file_, opts)
1161 store = cmdutil.openstorage(repo, 'debugindex', file_, opts)
1162
1162
1163 if ui.debugflag:
1163 if ui.debugflag:
1164 shortfn = hex
1164 shortfn = hex
1165 else:
1165 else:
1166 shortfn = short
1166 shortfn = short
1167
1167
1168 idlen = 12
1168 idlen = 12
1169 for i in store:
1169 for i in store:
1170 idlen = len(shortfn(store.node(i)))
1170 idlen = len(shortfn(store.node(i)))
1171 break
1171 break
1172
1172
1173 fm = ui.formatter('debugindex', opts)
1173 fm = ui.formatter('debugindex', opts)
1174 fm.plain(b' rev linkrev %s %s p2\n' % (
1174 fm.plain(b' rev linkrev %s %s p2\n' % (
1175 b'nodeid'.ljust(idlen),
1175 b'nodeid'.ljust(idlen),
1176 b'p1'.ljust(idlen)))
1176 b'p1'.ljust(idlen)))
1177
1177
1178 for rev in store:
1178 for rev in store:
1179 node = store.node(rev)
1179 node = store.node(rev)
1180 parents = store.parents(node)
1180 parents = store.parents(node)
1181
1181
1182 fm.startitem()
1182 fm.startitem()
1183 fm.write(b'rev', b'%6d ', rev)
1183 fm.write(b'rev', b'%6d ', rev)
1184 fm.write(b'linkrev', '%7d ', store.linkrev(rev))
1184 fm.write(b'linkrev', '%7d ', store.linkrev(rev))
1185 fm.write(b'node', '%s ', shortfn(node))
1185 fm.write(b'node', '%s ', shortfn(node))
1186 fm.write(b'p1', '%s ', shortfn(parents[0]))
1186 fm.write(b'p1', '%s ', shortfn(parents[0]))
1187 fm.write(b'p2', '%s', shortfn(parents[1]))
1187 fm.write(b'p2', '%s', shortfn(parents[1]))
1188 fm.plain(b'\n')
1188 fm.plain(b'\n')
1189
1189
1190 fm.end()
1190 fm.end()
1191
1191
1192 @command('debugindexdot', cmdutil.debugrevlogopts,
1192 @command('debugindexdot', cmdutil.debugrevlogopts,
1193 _('-c|-m|FILE'), optionalrepo=True)
1193 _('-c|-m|FILE'), optionalrepo=True)
1194 def debugindexdot(ui, repo, file_=None, **opts):
1194 def debugindexdot(ui, repo, file_=None, **opts):
1195 """dump an index DAG as a graphviz dot file"""
1195 """dump an index DAG as a graphviz dot file"""
1196 opts = pycompat.byteskwargs(opts)
1196 opts = pycompat.byteskwargs(opts)
1197 r = cmdutil.openstorage(repo, 'debugindexdot', file_, opts)
1197 r = cmdutil.openstorage(repo, 'debugindexdot', file_, opts)
1198 ui.write(("digraph G {\n"))
1198 ui.write(("digraph G {\n"))
1199 for i in r:
1199 for i in r:
1200 node = r.node(i)
1200 node = r.node(i)
1201 pp = r.parents(node)
1201 pp = r.parents(node)
1202 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1202 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1203 if pp[1] != nullid:
1203 if pp[1] != nullid:
1204 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1204 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1205 ui.write("}\n")
1205 ui.write("}\n")
1206
1206
1207 @command('debugindexstats', [])
1207 @command('debugindexstats', [])
1208 def debugindexstats(ui, repo):
1208 def debugindexstats(ui, repo):
1209 """show stats related to the changelog index"""
1209 """show stats related to the changelog index"""
1210 repo.changelog.shortest(nullid, 1)
1210 repo.changelog.shortest(nullid, 1)
1211 index = repo.changelog.index
1211 index = repo.changelog.index
1212 if not util.safehasattr(index, 'stats'):
1212 if not util.safehasattr(index, 'stats'):
1213 raise error.Abort(_('debugindexstats only works with native code'))
1213 raise error.Abort(_('debugindexstats only works with native code'))
1214 for k, v in sorted(index.stats().items()):
1214 for k, v in sorted(index.stats().items()):
1215 ui.write('%s: %d\n' % (k, v))
1215 ui.write('%s: %d\n' % (k, v))
1216
1216
1217 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True)
1217 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True)
1218 def debuginstall(ui, **opts):
1218 def debuginstall(ui, **opts):
1219 '''test Mercurial installation
1219 '''test Mercurial installation
1220
1220
1221 Returns 0 on success.
1221 Returns 0 on success.
1222 '''
1222 '''
1223 opts = pycompat.byteskwargs(opts)
1223 opts = pycompat.byteskwargs(opts)
1224
1224
1225 problems = 0
1225 problems = 0
1226
1226
1227 fm = ui.formatter('debuginstall', opts)
1227 fm = ui.formatter('debuginstall', opts)
1228 fm.startitem()
1228 fm.startitem()
1229
1229
1230 # encoding
1230 # encoding
1231 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
1231 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
1232 err = None
1232 err = None
1233 try:
1233 try:
1234 codecs.lookup(pycompat.sysstr(encoding.encoding))
1234 codecs.lookup(pycompat.sysstr(encoding.encoding))
1235 except LookupError as inst:
1235 except LookupError as inst:
1236 err = stringutil.forcebytestr(inst)
1236 err = stringutil.forcebytestr(inst)
1237 problems += 1
1237 problems += 1
1238 fm.condwrite(err, 'encodingerror', _(" %s\n"
1238 fm.condwrite(err, 'encodingerror', _(" %s\n"
1239 " (check that your locale is properly set)\n"), err)
1239 " (check that your locale is properly set)\n"), err)
1240
1240
1241 # Python
1241 # Python
1242 fm.write('pythonexe', _("checking Python executable (%s)\n"),
1242 fm.write('pythonexe', _("checking Python executable (%s)\n"),
1243 pycompat.sysexecutable or _("unknown"))
1243 pycompat.sysexecutable or _("unknown"))
1244 fm.write('pythonver', _("checking Python version (%s)\n"),
1244 fm.write('pythonver', _("checking Python version (%s)\n"),
1245 ("%d.%d.%d" % sys.version_info[:3]))
1245 ("%d.%d.%d" % sys.version_info[:3]))
1246 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
1246 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
1247 os.path.dirname(pycompat.fsencode(os.__file__)))
1247 os.path.dirname(pycompat.fsencode(os.__file__)))
1248
1248
1249 security = set(sslutil.supportedprotocols)
1249 security = set(sslutil.supportedprotocols)
1250 if sslutil.hassni:
1250 if sslutil.hassni:
1251 security.add('sni')
1251 security.add('sni')
1252
1252
1253 fm.write('pythonsecurity', _("checking Python security support (%s)\n"),
1253 fm.write('pythonsecurity', _("checking Python security support (%s)\n"),
1254 fm.formatlist(sorted(security), name='protocol',
1254 fm.formatlist(sorted(security), name='protocol',
1255 fmt='%s', sep=','))
1255 fmt='%s', sep=','))
1256
1256
1257 # These are warnings, not errors. So don't increment problem count. This
1257 # These are warnings, not errors. So don't increment problem count. This
1258 # may change in the future.
1258 # may change in the future.
1259 if 'tls1.2' not in security:
1259 if 'tls1.2' not in security:
1260 fm.plain(_(' TLS 1.2 not supported by Python install; '
1260 fm.plain(_(' TLS 1.2 not supported by Python install; '
1261 'network connections lack modern security\n'))
1261 'network connections lack modern security\n'))
1262 if 'sni' not in security:
1262 if 'sni' not in security:
1263 fm.plain(_(' SNI not supported by Python install; may have '
1263 fm.plain(_(' SNI not supported by Python install; may have '
1264 'connectivity issues with some servers\n'))
1264 'connectivity issues with some servers\n'))
1265
1265
1266 # TODO print CA cert info
1266 # TODO print CA cert info
1267
1267
1268 # hg version
1268 # hg version
1269 hgver = util.version()
1269 hgver = util.version()
1270 fm.write('hgver', _("checking Mercurial version (%s)\n"),
1270 fm.write('hgver', _("checking Mercurial version (%s)\n"),
1271 hgver.split('+')[0])
1271 hgver.split('+')[0])
1272 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"),
1272 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"),
1273 '+'.join(hgver.split('+')[1:]))
1273 '+'.join(hgver.split('+')[1:]))
1274
1274
1275 # compiled modules
1275 # compiled modules
1276 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
1276 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
1277 policy.policy)
1277 policy.policy)
1278 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
1278 fm.write('hgmodules', _("checking installed modules (%s)...\n"),
1279 os.path.dirname(pycompat.fsencode(__file__)))
1279 os.path.dirname(pycompat.fsencode(__file__)))
1280
1280
1281 rustandc = policy.policy in ('rust+c', 'rust+c-allow')
1281 rustandc = policy.policy in ('rust+c', 'rust+c-allow')
1282 rustext = rustandc # for now, that's the only case
1282 rustext = rustandc # for now, that's the only case
1283 cext = policy.policy in ('c', 'allow') or rustandc
1283 cext = policy.policy in ('c', 'allow') or rustandc
1284 nopure = cext or rustext
1284 nopure = cext or rustext
1285 if nopure:
1285 if nopure:
1286 err = None
1286 err = None
1287 try:
1287 try:
1288 if cext:
1288 if cext:
1289 from .cext import (
1289 from .cext import (
1290 base85,
1290 base85,
1291 bdiff,
1291 bdiff,
1292 mpatch,
1292 mpatch,
1293 osutil,
1293 osutil,
1294 )
1294 )
1295 # quiet pyflakes
1295 # quiet pyflakes
1296 dir(bdiff), dir(mpatch), dir(base85), dir(osutil)
1296 dir(bdiff), dir(mpatch), dir(base85), dir(osutil)
1297 if rustext:
1297 if rustext:
1298 from .rustext import (
1298 from .rustext import (
1299 ancestor,
1299 ancestor,
1300 dirstate,
1300 dirstate,
1301 )
1301 )
1302 dir(ancestor), dir(dirstate) # quiet pyflakes
1302 dir(ancestor), dir(dirstate) # quiet pyflakes
1303 except Exception as inst:
1303 except Exception as inst:
1304 err = stringutil.forcebytestr(inst)
1304 err = stringutil.forcebytestr(inst)
1305 problems += 1
1305 problems += 1
1306 fm.condwrite(err, 'extensionserror', " %s\n", err)
1306 fm.condwrite(err, 'extensionserror', " %s\n", err)
1307
1307
1308 compengines = util.compengines._engines.values()
1308 compengines = util.compengines._engines.values()
1309 fm.write('compengines', _('checking registered compression engines (%s)\n'),
1309 fm.write('compengines', _('checking registered compression engines (%s)\n'),
1310 fm.formatlist(sorted(e.name() for e in compengines),
1310 fm.formatlist(sorted(e.name() for e in compengines),
1311 name='compengine', fmt='%s', sep=', '))
1311 name='compengine', fmt='%s', sep=', '))
1312 fm.write('compenginesavail', _('checking available compression engines '
1312 fm.write('compenginesavail', _('checking available compression engines '
1313 '(%s)\n'),
1313 '(%s)\n'),
1314 fm.formatlist(sorted(e.name() for e in compengines
1314 fm.formatlist(sorted(e.name() for e in compengines
1315 if e.available()),
1315 if e.available()),
1316 name='compengine', fmt='%s', sep=', '))
1316 name='compengine', fmt='%s', sep=', '))
1317 wirecompengines = compression.compengines.supportedwireengines(
1317 wirecompengines = compression.compengines.supportedwireengines(
1318 compression.SERVERROLE)
1318 compression.SERVERROLE)
1319 fm.write('compenginesserver', _('checking available compression engines '
1319 fm.write('compenginesserver', _('checking available compression engines '
1320 'for wire protocol (%s)\n'),
1320 'for wire protocol (%s)\n'),
1321 fm.formatlist([e.name() for e in wirecompengines
1321 fm.formatlist([e.name() for e in wirecompengines
1322 if e.wireprotosupport()],
1322 if e.wireprotosupport()],
1323 name='compengine', fmt='%s', sep=', '))
1323 name='compengine', fmt='%s', sep=', '))
1324 re2 = 'missing'
1324 re2 = 'missing'
1325 if util._re2:
1325 if util._re2:
1326 re2 = 'available'
1326 re2 = 'available'
1327 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2)
1327 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2)
1328 fm.data(re2=bool(util._re2))
1328 fm.data(re2=bool(util._re2))
1329
1329
1330 # templates
1330 # templates
1331 p = templater.templatepaths()
1331 p = templater.templatepaths()
1332 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p))
1332 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p))
1333 fm.condwrite(not p, '', _(" no template directories found\n"))
1333 fm.condwrite(not p, '', _(" no template directories found\n"))
1334 if p:
1334 if p:
1335 m = templater.templatepath("map-cmdline.default")
1335 m = templater.templatepath("map-cmdline.default")
1336 if m:
1336 if m:
1337 # template found, check if it is working
1337 # template found, check if it is working
1338 err = None
1338 err = None
1339 try:
1339 try:
1340 templater.templater.frommapfile(m)
1340 templater.templater.frommapfile(m)
1341 except Exception as inst:
1341 except Exception as inst:
1342 err = stringutil.forcebytestr(inst)
1342 err = stringutil.forcebytestr(inst)
1343 p = None
1343 p = None
1344 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
1344 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
1345 else:
1345 else:
1346 p = None
1346 p = None
1347 fm.condwrite(p, 'defaulttemplate',
1347 fm.condwrite(p, 'defaulttemplate',
1348 _("checking default template (%s)\n"), m)
1348 _("checking default template (%s)\n"), m)
1349 fm.condwrite(not m, 'defaulttemplatenotfound',
1349 fm.condwrite(not m, 'defaulttemplatenotfound',
1350 _(" template '%s' not found\n"), "default")
1350 _(" template '%s' not found\n"), "default")
1351 if not p:
1351 if not p:
1352 problems += 1
1352 problems += 1
1353 fm.condwrite(not p, '',
1353 fm.condwrite(not p, '',
1354 _(" (templates seem to have been installed incorrectly)\n"))
1354 _(" (templates seem to have been installed incorrectly)\n"))
1355
1355
1356 # editor
1356 # editor
1357 editor = ui.geteditor()
1357 editor = ui.geteditor()
1358 editor = util.expandpath(editor)
1358 editor = util.expandpath(editor)
1359 editorbin = procutil.shellsplit(editor)[0]
1359 editorbin = procutil.shellsplit(editor)[0]
1360 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1360 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1361 cmdpath = procutil.findexe(editorbin)
1361 cmdpath = procutil.findexe(editorbin)
1362 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1362 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1363 _(" No commit editor set and can't find %s in PATH\n"
1363 _(" No commit editor set and can't find %s in PATH\n"
1364 " (specify a commit editor in your configuration"
1364 " (specify a commit editor in your configuration"
1365 " file)\n"), not cmdpath and editor == 'vi' and editorbin)
1365 " file)\n"), not cmdpath and editor == 'vi' and editorbin)
1366 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound',
1366 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound',
1367 _(" Can't find editor '%s' in PATH\n"
1367 _(" Can't find editor '%s' in PATH\n"
1368 " (specify a commit editor in your configuration"
1368 " (specify a commit editor in your configuration"
1369 " file)\n"), not cmdpath and editorbin)
1369 " file)\n"), not cmdpath and editorbin)
1370 if not cmdpath and editor != 'vi':
1370 if not cmdpath and editor != 'vi':
1371 problems += 1
1371 problems += 1
1372
1372
1373 # check username
1373 # check username
1374 username = None
1374 username = None
1375 err = None
1375 err = None
1376 try:
1376 try:
1377 username = ui.username()
1377 username = ui.username()
1378 except error.Abort as e:
1378 except error.Abort as e:
1379 err = stringutil.forcebytestr(e)
1379 err = stringutil.forcebytestr(e)
1380 problems += 1
1380 problems += 1
1381
1381
1382 fm.condwrite(username, 'username', _("checking username (%s)\n"), username)
1382 fm.condwrite(username, 'username', _("checking username (%s)\n"), username)
1383 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
1383 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
1384 " (specify a username in your configuration file)\n"), err)
1384 " (specify a username in your configuration file)\n"), err)
1385
1385
1386 for name, mod in extensions.extensions():
1386 for name, mod in extensions.extensions():
1387 handler = getattr(mod, 'debuginstall', None)
1387 handler = getattr(mod, 'debuginstall', None)
1388 if handler is not None:
1388 if handler is not None:
1389 problems += handler(ui, fm)
1389 problems += handler(ui, fm)
1390
1390
1391 fm.condwrite(not problems, '',
1391 fm.condwrite(not problems, '',
1392 _("no problems detected\n"))
1392 _("no problems detected\n"))
1393 if not problems:
1393 if not problems:
1394 fm.data(problems=problems)
1394 fm.data(problems=problems)
1395 fm.condwrite(problems, 'problems',
1395 fm.condwrite(problems, 'problems',
1396 _("%d problems detected,"
1396 _("%d problems detected,"
1397 " please check your install!\n"), problems)
1397 " please check your install!\n"), problems)
1398 fm.end()
1398 fm.end()
1399
1399
1400 return problems
1400 return problems
1401
1401
1402 @command('debugknown', [], _('REPO ID...'), norepo=True)
1402 @command('debugknown', [], _('REPO ID...'), norepo=True)
1403 def debugknown(ui, repopath, *ids, **opts):
1403 def debugknown(ui, repopath, *ids, **opts):
1404 """test whether node ids are known to a repo
1404 """test whether node ids are known to a repo
1405
1405
1406 Every ID must be a full-length hex node id string. Returns a list of 0s
1406 Every ID must be a full-length hex node id string. Returns a list of 0s
1407 and 1s indicating unknown/known.
1407 and 1s indicating unknown/known.
1408 """
1408 """
1409 opts = pycompat.byteskwargs(opts)
1409 opts = pycompat.byteskwargs(opts)
1410 repo = hg.peer(ui, opts, repopath)
1410 repo = hg.peer(ui, opts, repopath)
1411 if not repo.capable('known'):
1411 if not repo.capable('known'):
1412 raise error.Abort("known() not supported by target repository")
1412 raise error.Abort("known() not supported by target repository")
1413 flags = repo.known([bin(s) for s in ids])
1413 flags = repo.known([bin(s) for s in ids])
1414 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1414 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1415
1415
1416 @command('debuglabelcomplete', [], _('LABEL...'))
1416 @command('debuglabelcomplete', [], _('LABEL...'))
1417 def debuglabelcomplete(ui, repo, *args):
1417 def debuglabelcomplete(ui, repo, *args):
1418 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
1418 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
1419 debugnamecomplete(ui, repo, *args)
1419 debugnamecomplete(ui, repo, *args)
1420
1420
1421 @command('debuglocks',
1421 @command('debuglocks',
1422 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
1422 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
1423 ('W', 'force-wlock', None,
1423 ('W', 'force-wlock', None,
1424 _('free the working state lock (DANGEROUS)')),
1424 _('free the working state lock (DANGEROUS)')),
1425 ('s', 'set-lock', None, _('set the store lock until stopped')),
1425 ('s', 'set-lock', None, _('set the store lock until stopped')),
1426 ('S', 'set-wlock', None,
1426 ('S', 'set-wlock', None,
1427 _('set the working state lock until stopped'))],
1427 _('set the working state lock until stopped'))],
1428 _('[OPTION]...'))
1428 _('[OPTION]...'))
1429 def debuglocks(ui, repo, **opts):
1429 def debuglocks(ui, repo, **opts):
1430 """show or modify state of locks
1430 """show or modify state of locks
1431
1431
1432 By default, this command will show which locks are held. This
1432 By default, this command will show which locks are held. This
1433 includes the user and process holding the lock, the amount of time
1433 includes the user and process holding the lock, the amount of time
1434 the lock has been held, and the machine name where the process is
1434 the lock has been held, and the machine name where the process is
1435 running if it's not local.
1435 running if it's not local.
1436
1436
1437 Locks protect the integrity of Mercurial's data, so should be
1437 Locks protect the integrity of Mercurial's data, so should be
1438 treated with care. System crashes or other interruptions may cause
1438 treated with care. System crashes or other interruptions may cause
1439 locks to not be properly released, though Mercurial will usually
1439 locks to not be properly released, though Mercurial will usually
1440 detect and remove such stale locks automatically.
1440 detect and remove such stale locks automatically.
1441
1441
1442 However, detecting stale locks may not always be possible (for
1442 However, detecting stale locks may not always be possible (for
1443 instance, on a shared filesystem). Removing locks may also be
1443 instance, on a shared filesystem). Removing locks may also be
1444 blocked by filesystem permissions.
1444 blocked by filesystem permissions.
1445
1445
1446 Setting a lock will prevent other commands from changing the data.
1446 Setting a lock will prevent other commands from changing the data.
1447 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
1447 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
1448 The set locks are removed when the command exits.
1448 The set locks are removed when the command exits.
1449
1449
1450 Returns 0 if no locks are held.
1450 Returns 0 if no locks are held.
1451
1451
1452 """
1452 """
1453
1453
1454 if opts.get(r'force_lock'):
1454 if opts.get(r'force_lock'):
1455 repo.svfs.unlink('lock')
1455 repo.svfs.unlink('lock')
1456 if opts.get(r'force_wlock'):
1456 if opts.get(r'force_wlock'):
1457 repo.vfs.unlink('wlock')
1457 repo.vfs.unlink('wlock')
1458 if opts.get(r'force_lock') or opts.get(r'force_wlock'):
1458 if opts.get(r'force_lock') or opts.get(r'force_wlock'):
1459 return 0
1459 return 0
1460
1460
1461 locks = []
1461 locks = []
1462 try:
1462 try:
1463 if opts.get(r'set_wlock'):
1463 if opts.get(r'set_wlock'):
1464 try:
1464 try:
1465 locks.append(repo.wlock(False))
1465 locks.append(repo.wlock(False))
1466 except error.LockHeld:
1466 except error.LockHeld:
1467 raise error.Abort(_('wlock is already held'))
1467 raise error.Abort(_('wlock is already held'))
1468 if opts.get(r'set_lock'):
1468 if opts.get(r'set_lock'):
1469 try:
1469 try:
1470 locks.append(repo.lock(False))
1470 locks.append(repo.lock(False))
1471 except error.LockHeld:
1471 except error.LockHeld:
1472 raise error.Abort(_('lock is already held'))
1472 raise error.Abort(_('lock is already held'))
1473 if len(locks):
1473 if len(locks):
1474 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes"))
1474 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes"))
1475 return 0
1475 return 0
1476 finally:
1476 finally:
1477 release(*locks)
1477 release(*locks)
1478
1478
1479 now = time.time()
1479 now = time.time()
1480 held = 0
1480 held = 0
1481
1481
1482 def report(vfs, name, method):
1482 def report(vfs, name, method):
1483 # this causes stale locks to get reaped for more accurate reporting
1483 # this causes stale locks to get reaped for more accurate reporting
1484 try:
1484 try:
1485 l = method(False)
1485 l = method(False)
1486 except error.LockHeld:
1486 except error.LockHeld:
1487 l = None
1487 l = None
1488
1488
1489 if l:
1489 if l:
1490 l.release()
1490 l.release()
1491 else:
1491 else:
1492 try:
1492 try:
1493 st = vfs.lstat(name)
1493 st = vfs.lstat(name)
1494 age = now - st[stat.ST_MTIME]
1494 age = now - st[stat.ST_MTIME]
1495 user = util.username(st.st_uid)
1495 user = util.username(st.st_uid)
1496 locker = vfs.readlock(name)
1496 locker = vfs.readlock(name)
1497 if ":" in locker:
1497 if ":" in locker:
1498 host, pid = locker.split(':')
1498 host, pid = locker.split(':')
1499 if host == socket.gethostname():
1499 if host == socket.gethostname():
1500 locker = 'user %s, process %s' % (user or b'None', pid)
1500 locker = 'user %s, process %s' % (user or b'None', pid)
1501 else:
1501 else:
1502 locker = ('user %s, process %s, host %s'
1502 locker = ('user %s, process %s, host %s'
1503 % (user or b'None', pid, host))
1503 % (user or b'None', pid, host))
1504 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age))
1504 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age))
1505 return 1
1505 return 1
1506 except OSError as e:
1506 except OSError as e:
1507 if e.errno != errno.ENOENT:
1507 if e.errno != errno.ENOENT:
1508 raise
1508 raise
1509
1509
1510 ui.write(("%-6s free\n") % (name + ":"))
1510 ui.write(("%-6s free\n") % (name + ":"))
1511 return 0
1511 return 0
1512
1512
1513 held += report(repo.svfs, "lock", repo.lock)
1513 held += report(repo.svfs, "lock", repo.lock)
1514 held += report(repo.vfs, "wlock", repo.wlock)
1514 held += report(repo.vfs, "wlock", repo.wlock)
1515
1515
1516 return held
1516 return held
1517
1517
1518 @command('debugmanifestfulltextcache', [
1518 @command('debugmanifestfulltextcache', [
1519 ('', 'clear', False, _('clear the cache')),
1519 ('', 'clear', False, _('clear the cache')),
1520 ('a', 'add', [], _('add the given manifest nodes to the cache'),
1520 ('a', 'add', [], _('add the given manifest nodes to the cache'),
1521 _('NODE'))
1521 _('NODE'))
1522 ], '')
1522 ], '')
1523 def debugmanifestfulltextcache(ui, repo, add=(), **opts):
1523 def debugmanifestfulltextcache(ui, repo, add=(), **opts):
1524 """show, clear or amend the contents of the manifest fulltext cache"""
1524 """show, clear or amend the contents of the manifest fulltext cache"""
1525
1525
1526 def getcache():
1526 def getcache():
1527 r = repo.manifestlog.getstorage(b'')
1527 r = repo.manifestlog.getstorage(b'')
1528 try:
1528 try:
1529 return r._fulltextcache
1529 return r._fulltextcache
1530 except AttributeError:
1530 except AttributeError:
1531 msg = _("Current revlog implementation doesn't appear to have a "
1531 msg = _("Current revlog implementation doesn't appear to have a "
1532 "manifest fulltext cache\n")
1532 "manifest fulltext cache\n")
1533 raise error.Abort(msg)
1533 raise error.Abort(msg)
1534
1534
1535 if opts.get(r'clear'):
1535 if opts.get(r'clear'):
1536 with repo.wlock():
1536 with repo.wlock():
1537 cache = getcache()
1537 cache = getcache()
1538 cache.clear(clear_persisted_data=True)
1538 cache.clear(clear_persisted_data=True)
1539 return
1539 return
1540
1540
1541 if add:
1541 if add:
1542 with repo.wlock():
1542 with repo.wlock():
1543 m = repo.manifestlog
1543 m = repo.manifestlog
1544 store = m.getstorage(b'')
1544 store = m.getstorage(b'')
1545 for n in add:
1545 for n in add:
1546 try:
1546 try:
1547 manifest = m[store.lookup(n)]
1547 manifest = m[store.lookup(n)]
1548 except error.LookupError as e:
1548 except error.LookupError as e:
1549 raise error.Abort(e, hint="Check your manifest node id")
1549 raise error.Abort(e, hint="Check your manifest node id")
1550 manifest.read() # stores revisision in cache too
1550 manifest.read() # stores revisision in cache too
1551 return
1551 return
1552
1552
1553 cache = getcache()
1553 cache = getcache()
1554 if not len(cache):
1554 if not len(cache):
1555 ui.write(_('cache empty\n'))
1555 ui.write(_('cache empty\n'))
1556 else:
1556 else:
1557 ui.write(
1557 ui.write(
1558 _('cache contains %d manifest entries, in order of most to '
1558 _('cache contains %d manifest entries, in order of most to '
1559 'least recent:\n') % (len(cache),))
1559 'least recent:\n') % (len(cache),))
1560 totalsize = 0
1560 totalsize = 0
1561 for nodeid in cache:
1561 for nodeid in cache:
1562 # Use cache.get to not update the LRU order
1562 # Use cache.get to not update the LRU order
1563 data = cache.peek(nodeid)
1563 data = cache.peek(nodeid)
1564 size = len(data)
1564 size = len(data)
1565 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1565 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1566 ui.write(_('id: %s, size %s\n') % (
1566 ui.write(_('id: %s, size %s\n') % (
1567 hex(nodeid), util.bytecount(size)))
1567 hex(nodeid), util.bytecount(size)))
1568 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1568 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1569 ui.write(
1569 ui.write(
1570 _('total cache data size %s, on-disk %s\n') % (
1570 _('total cache data size %s, on-disk %s\n') % (
1571 util.bytecount(totalsize), util.bytecount(ondisk))
1571 util.bytecount(totalsize), util.bytecount(ondisk))
1572 )
1572 )
1573
1573
1574 @command('debugmergestate', [], '')
1574 @command('debugmergestate', [], '')
1575 def debugmergestate(ui, repo, *args):
1575 def debugmergestate(ui, repo, *args):
1576 """print merge state
1576 """print merge state
1577
1577
1578 Use --verbose to print out information about whether v1 or v2 merge state
1578 Use --verbose to print out information about whether v1 or v2 merge state
1579 was chosen."""
1579 was chosen."""
1580 def _hashornull(h):
1580 def _hashornull(h):
1581 if h == nullhex:
1581 if h == nullhex:
1582 return 'null'
1582 return 'null'
1583 else:
1583 else:
1584 return h
1584 return h
1585
1585
1586 def printrecords(version):
1586 def printrecords(version):
1587 ui.write(('* version %d records\n') % version)
1587 ui.write(('* version %d records\n') % version)
1588 if version == 1:
1588 if version == 1:
1589 records = v1records
1589 records = v1records
1590 else:
1590 else:
1591 records = v2records
1591 records = v2records
1592
1592
1593 for rtype, record in records:
1593 for rtype, record in records:
1594 # pretty print some record types
1594 # pretty print some record types
1595 if rtype == 'L':
1595 if rtype == 'L':
1596 ui.write(('local: %s\n') % record)
1596 ui.write(('local: %s\n') % record)
1597 elif rtype == 'O':
1597 elif rtype == 'O':
1598 ui.write(('other: %s\n') % record)
1598 ui.write(('other: %s\n') % record)
1599 elif rtype == 'm':
1599 elif rtype == 'm':
1600 driver, mdstate = record.split('\0', 1)
1600 driver, mdstate = record.split('\0', 1)
1601 ui.write(('merge driver: %s (state "%s")\n')
1601 ui.write(('merge driver: %s (state "%s")\n')
1602 % (driver, mdstate))
1602 % (driver, mdstate))
1603 elif rtype in 'FDC':
1603 elif rtype in 'FDC':
1604 r = record.split('\0')
1604 r = record.split('\0')
1605 f, state, hash, lfile, afile, anode, ofile = r[0:7]
1605 f, state, hash, lfile, afile, anode, ofile = r[0:7]
1606 if version == 1:
1606 if version == 1:
1607 onode = 'not stored in v1 format'
1607 onode = 'not stored in v1 format'
1608 flags = r[7]
1608 flags = r[7]
1609 else:
1609 else:
1610 onode, flags = r[7:9]
1610 onode, flags = r[7:9]
1611 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
1611 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
1612 % (f, rtype, state, _hashornull(hash)))
1612 % (f, rtype, state, _hashornull(hash)))
1613 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
1613 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
1614 ui.write((' ancestor path: %s (node %s)\n')
1614 ui.write((' ancestor path: %s (node %s)\n')
1615 % (afile, _hashornull(anode)))
1615 % (afile, _hashornull(anode)))
1616 ui.write((' other path: %s (node %s)\n')
1616 ui.write((' other path: %s (node %s)\n')
1617 % (ofile, _hashornull(onode)))
1617 % (ofile, _hashornull(onode)))
1618 elif rtype == 'f':
1618 elif rtype == 'f':
1619 filename, rawextras = record.split('\0', 1)
1619 filename, rawextras = record.split('\0', 1)
1620 extras = rawextras.split('\0')
1620 extras = rawextras.split('\0')
1621 i = 0
1621 i = 0
1622 extrastrings = []
1622 extrastrings = []
1623 while i < len(extras):
1623 while i < len(extras):
1624 extrastrings.append('%s = %s' % (extras[i], extras[i + 1]))
1624 extrastrings.append('%s = %s' % (extras[i], extras[i + 1]))
1625 i += 2
1625 i += 2
1626
1626
1627 ui.write(('file extras: %s (%s)\n')
1627 ui.write(('file extras: %s (%s)\n')
1628 % (filename, ', '.join(extrastrings)))
1628 % (filename, ', '.join(extrastrings)))
1629 elif rtype == 'l':
1629 elif rtype == 'l':
1630 labels = record.split('\0', 2)
1630 labels = record.split('\0', 2)
1631 labels = [l for l in labels if len(l) > 0]
1631 labels = [l for l in labels if len(l) > 0]
1632 ui.write(('labels:\n'))
1632 ui.write(('labels:\n'))
1633 ui.write((' local: %s\n' % labels[0]))
1633 ui.write((' local: %s\n' % labels[0]))
1634 ui.write((' other: %s\n' % labels[1]))
1634 ui.write((' other: %s\n' % labels[1]))
1635 if len(labels) > 2:
1635 if len(labels) > 2:
1636 ui.write((' base: %s\n' % labels[2]))
1636 ui.write((' base: %s\n' % labels[2]))
1637 else:
1637 else:
1638 ui.write(('unrecognized entry: %s\t%s\n')
1638 ui.write(('unrecognized entry: %s\t%s\n')
1639 % (rtype, record.replace('\0', '\t')))
1639 % (rtype, record.replace('\0', '\t')))
1640
1640
1641 # Avoid mergestate.read() since it may raise an exception for unsupported
1641 # Avoid mergestate.read() since it may raise an exception for unsupported
1642 # merge state records. We shouldn't be doing this, but this is OK since this
1642 # merge state records. We shouldn't be doing this, but this is OK since this
1643 # command is pretty low-level.
1643 # command is pretty low-level.
1644 ms = mergemod.mergestate(repo)
1644 ms = mergemod.mergestate(repo)
1645
1645
1646 # sort so that reasonable information is on top
1646 # sort so that reasonable information is on top
1647 v1records = ms._readrecordsv1()
1647 v1records = ms._readrecordsv1()
1648 v2records = ms._readrecordsv2()
1648 v2records = ms._readrecordsv2()
1649 order = 'LOml'
1649 order = 'LOml'
1650 def key(r):
1650 def key(r):
1651 idx = order.find(r[0])
1651 idx = order.find(r[0])
1652 if idx == -1:
1652 if idx == -1:
1653 return (1, r[1])
1653 return (1, r[1])
1654 else:
1654 else:
1655 return (0, idx)
1655 return (0, idx)
1656 v1records.sort(key=key)
1656 v1records.sort(key=key)
1657 v2records.sort(key=key)
1657 v2records.sort(key=key)
1658
1658
1659 if not v1records and not v2records:
1659 if not v1records and not v2records:
1660 ui.write(('no merge state found\n'))
1660 ui.write(('no merge state found\n'))
1661 elif not v2records:
1661 elif not v2records:
1662 ui.note(('no version 2 merge state\n'))
1662 ui.note(('no version 2 merge state\n'))
1663 printrecords(1)
1663 printrecords(1)
1664 elif ms._v1v2match(v1records, v2records):
1664 elif ms._v1v2match(v1records, v2records):
1665 ui.note(('v1 and v2 states match: using v2\n'))
1665 ui.note(('v1 and v2 states match: using v2\n'))
1666 printrecords(2)
1666 printrecords(2)
1667 else:
1667 else:
1668 ui.note(('v1 and v2 states mismatch: using v1\n'))
1668 ui.note(('v1 and v2 states mismatch: using v1\n'))
1669 printrecords(1)
1669 printrecords(1)
1670 if ui.verbose:
1670 if ui.verbose:
1671 printrecords(2)
1671 printrecords(2)
1672
1672
1673 @command('debugnamecomplete', [], _('NAME...'))
1673 @command('debugnamecomplete', [], _('NAME...'))
1674 def debugnamecomplete(ui, repo, *args):
1674 def debugnamecomplete(ui, repo, *args):
1675 '''complete "names" - tags, open branch names, bookmark names'''
1675 '''complete "names" - tags, open branch names, bookmark names'''
1676
1676
1677 names = set()
1677 names = set()
1678 # since we previously only listed open branches, we will handle that
1678 # since we previously only listed open branches, we will handle that
1679 # specially (after this for loop)
1679 # specially (after this for loop)
1680 for name, ns in repo.names.iteritems():
1680 for name, ns in repo.names.iteritems():
1681 if name != 'branches':
1681 if name != 'branches':
1682 names.update(ns.listnames(repo))
1682 names.update(ns.listnames(repo))
1683 names.update(tag for (tag, heads, tip, closed)
1683 names.update(tag for (tag, heads, tip, closed)
1684 in repo.branchmap().iterbranches() if not closed)
1684 in repo.branchmap().iterbranches() if not closed)
1685 completions = set()
1685 completions = set()
1686 if not args:
1686 if not args:
1687 args = ['']
1687 args = ['']
1688 for a in args:
1688 for a in args:
1689 completions.update(n for n in names if n.startswith(a))
1689 completions.update(n for n in names if n.startswith(a))
1690 ui.write('\n'.join(sorted(completions)))
1690 ui.write('\n'.join(sorted(completions)))
1691 ui.write('\n')
1691 ui.write('\n')
1692
1692
1693 @command('debugobsolete',
1693 @command('debugobsolete',
1694 [('', 'flags', 0, _('markers flag')),
1694 [('', 'flags', 0, _('markers flag')),
1695 ('', 'record-parents', False,
1695 ('', 'record-parents', False,
1696 _('record parent information for the precursor')),
1696 _('record parent information for the precursor')),
1697 ('r', 'rev', [], _('display markers relevant to REV')),
1697 ('r', 'rev', [], _('display markers relevant to REV')),
1698 ('', 'exclusive', False, _('restrict display to markers only '
1698 ('', 'exclusive', False, _('restrict display to markers only '
1699 'relevant to REV')),
1699 'relevant to REV')),
1700 ('', 'index', False, _('display index of the marker')),
1700 ('', 'index', False, _('display index of the marker')),
1701 ('', 'delete', [], _('delete markers specified by indices')),
1701 ('', 'delete', [], _('delete markers specified by indices')),
1702 ] + cmdutil.commitopts2 + cmdutil.formatteropts,
1702 ] + cmdutil.commitopts2 + cmdutil.formatteropts,
1703 _('[OBSOLETED [REPLACEMENT ...]]'))
1703 _('[OBSOLETED [REPLACEMENT ...]]'))
1704 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
1704 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
1705 """create arbitrary obsolete marker
1705 """create arbitrary obsolete marker
1706
1706
1707 With no arguments, displays the list of obsolescence markers."""
1707 With no arguments, displays the list of obsolescence markers."""
1708
1708
1709 opts = pycompat.byteskwargs(opts)
1709 opts = pycompat.byteskwargs(opts)
1710
1710
1711 def parsenodeid(s):
1711 def parsenodeid(s):
1712 try:
1712 try:
1713 # We do not use revsingle/revrange functions here to accept
1713 # We do not use revsingle/revrange functions here to accept
1714 # arbitrary node identifiers, possibly not present in the
1714 # arbitrary node identifiers, possibly not present in the
1715 # local repository.
1715 # local repository.
1716 n = bin(s)
1716 n = bin(s)
1717 if len(n) != len(nullid):
1717 if len(n) != len(nullid):
1718 raise TypeError()
1718 raise TypeError()
1719 return n
1719 return n
1720 except TypeError:
1720 except TypeError:
1721 raise error.Abort('changeset references must be full hexadecimal '
1721 raise error.Abort('changeset references must be full hexadecimal '
1722 'node identifiers')
1722 'node identifiers')
1723
1723
1724 if opts.get('delete'):
1724 if opts.get('delete'):
1725 indices = []
1725 indices = []
1726 for v in opts.get('delete'):
1726 for v in opts.get('delete'):
1727 try:
1727 try:
1728 indices.append(int(v))
1728 indices.append(int(v))
1729 except ValueError:
1729 except ValueError:
1730 raise error.Abort(_('invalid index value: %r') % v,
1730 raise error.Abort(_('invalid index value: %r') % v,
1731 hint=_('use integers for indices'))
1731 hint=_('use integers for indices'))
1732
1732
1733 if repo.currenttransaction():
1733 if repo.currenttransaction():
1734 raise error.Abort(_('cannot delete obsmarkers in the middle '
1734 raise error.Abort(_('cannot delete obsmarkers in the middle '
1735 'of transaction.'))
1735 'of transaction.'))
1736
1736
1737 with repo.lock():
1737 with repo.lock():
1738 n = repair.deleteobsmarkers(repo.obsstore, indices)
1738 n = repair.deleteobsmarkers(repo.obsstore, indices)
1739 ui.write(_('deleted %i obsolescence markers\n') % n)
1739 ui.write(_('deleted %i obsolescence markers\n') % n)
1740
1740
1741 return
1741 return
1742
1742
1743 if precursor is not None:
1743 if precursor is not None:
1744 if opts['rev']:
1744 if opts['rev']:
1745 raise error.Abort('cannot select revision when creating marker')
1745 raise error.Abort('cannot select revision when creating marker')
1746 metadata = {}
1746 metadata = {}
1747 metadata['user'] = encoding.fromlocal(opts['user'] or ui.username())
1747 metadata['user'] = encoding.fromlocal(opts['user'] or ui.username())
1748 succs = tuple(parsenodeid(succ) for succ in successors)
1748 succs = tuple(parsenodeid(succ) for succ in successors)
1749 l = repo.lock()
1749 l = repo.lock()
1750 try:
1750 try:
1751 tr = repo.transaction('debugobsolete')
1751 tr = repo.transaction('debugobsolete')
1752 try:
1752 try:
1753 date = opts.get('date')
1753 date = opts.get('date')
1754 if date:
1754 if date:
1755 date = dateutil.parsedate(date)
1755 date = dateutil.parsedate(date)
1756 else:
1756 else:
1757 date = None
1757 date = None
1758 prec = parsenodeid(precursor)
1758 prec = parsenodeid(precursor)
1759 parents = None
1759 parents = None
1760 if opts['record_parents']:
1760 if opts['record_parents']:
1761 if prec not in repo.unfiltered():
1761 if prec not in repo.unfiltered():
1762 raise error.Abort('cannot used --record-parents on '
1762 raise error.Abort('cannot used --record-parents on '
1763 'unknown changesets')
1763 'unknown changesets')
1764 parents = repo.unfiltered()[prec].parents()
1764 parents = repo.unfiltered()[prec].parents()
1765 parents = tuple(p.node() for p in parents)
1765 parents = tuple(p.node() for p in parents)
1766 repo.obsstore.create(tr, prec, succs, opts['flags'],
1766 repo.obsstore.create(tr, prec, succs, opts['flags'],
1767 parents=parents, date=date,
1767 parents=parents, date=date,
1768 metadata=metadata, ui=ui)
1768 metadata=metadata, ui=ui)
1769 tr.close()
1769 tr.close()
1770 except ValueError as exc:
1770 except ValueError as exc:
1771 raise error.Abort(_('bad obsmarker input: %s') %
1771 raise error.Abort(_('bad obsmarker input: %s') %
1772 pycompat.bytestr(exc))
1772 pycompat.bytestr(exc))
1773 finally:
1773 finally:
1774 tr.release()
1774 tr.release()
1775 finally:
1775 finally:
1776 l.release()
1776 l.release()
1777 else:
1777 else:
1778 if opts['rev']:
1778 if opts['rev']:
1779 revs = scmutil.revrange(repo, opts['rev'])
1779 revs = scmutil.revrange(repo, opts['rev'])
1780 nodes = [repo[r].node() for r in revs]
1780 nodes = [repo[r].node() for r in revs]
1781 markers = list(obsutil.getmarkers(repo, nodes=nodes,
1781 markers = list(obsutil.getmarkers(repo, nodes=nodes,
1782 exclusive=opts['exclusive']))
1782 exclusive=opts['exclusive']))
1783 markers.sort(key=lambda x: x._data)
1783 markers.sort(key=lambda x: x._data)
1784 else:
1784 else:
1785 markers = obsutil.getmarkers(repo)
1785 markers = obsutil.getmarkers(repo)
1786
1786
1787 markerstoiter = markers
1787 markerstoiter = markers
1788 isrelevant = lambda m: True
1788 isrelevant = lambda m: True
1789 if opts.get('rev') and opts.get('index'):
1789 if opts.get('rev') and opts.get('index'):
1790 markerstoiter = obsutil.getmarkers(repo)
1790 markerstoiter = obsutil.getmarkers(repo)
1791 markerset = set(markers)
1791 markerset = set(markers)
1792 isrelevant = lambda m: m in markerset
1792 isrelevant = lambda m: m in markerset
1793
1793
1794 fm = ui.formatter('debugobsolete', opts)
1794 fm = ui.formatter('debugobsolete', opts)
1795 for i, m in enumerate(markerstoiter):
1795 for i, m in enumerate(markerstoiter):
1796 if not isrelevant(m):
1796 if not isrelevant(m):
1797 # marker can be irrelevant when we're iterating over a set
1797 # marker can be irrelevant when we're iterating over a set
1798 # of markers (markerstoiter) which is bigger than the set
1798 # of markers (markerstoiter) which is bigger than the set
1799 # of markers we want to display (markers)
1799 # of markers we want to display (markers)
1800 # this can happen if both --index and --rev options are
1800 # this can happen if both --index and --rev options are
1801 # provided and thus we need to iterate over all of the markers
1801 # provided and thus we need to iterate over all of the markers
1802 # to get the correct indices, but only display the ones that
1802 # to get the correct indices, but only display the ones that
1803 # are relevant to --rev value
1803 # are relevant to --rev value
1804 continue
1804 continue
1805 fm.startitem()
1805 fm.startitem()
1806 ind = i if opts.get('index') else None
1806 ind = i if opts.get('index') else None
1807 cmdutil.showmarker(fm, m, index=ind)
1807 cmdutil.showmarker(fm, m, index=ind)
1808 fm.end()
1808 fm.end()
1809
1809
1810 @command('debugp1copies',
1810 @command('debugp1copies',
1811 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1811 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1812 _('[-r REV]'))
1812 _('[-r REV]'))
1813 def debugp1copies(ui, repo, **opts):
1813 def debugp1copies(ui, repo, **opts):
1814 """dump copy information compared to p1"""
1814 """dump copy information compared to p1"""
1815
1815
1816 opts = pycompat.byteskwargs(opts)
1816 opts = pycompat.byteskwargs(opts)
1817 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1817 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1818 for dst, src in ctx.p1copies().items():
1818 for dst, src in ctx.p1copies().items():
1819 ui.write('%s -> %s\n' % (src, dst))
1819 ui.write('%s -> %s\n' % (src, dst))
1820
1820
1821 @command('debugp2copies',
1821 @command('debugp2copies',
1822 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1822 [('r', 'rev', '', _('revision to debug'), _('REV'))],
1823 _('[-r REV]'))
1823 _('[-r REV]'))
1824 def debugp1copies(ui, repo, **opts):
1824 def debugp1copies(ui, repo, **opts):
1825 """dump copy information compared to p2"""
1825 """dump copy information compared to p2"""
1826
1826
1827 opts = pycompat.byteskwargs(opts)
1827 opts = pycompat.byteskwargs(opts)
1828 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1828 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None)
1829 for dst, src in ctx.p2copies().items():
1829 for dst, src in ctx.p2copies().items():
1830 ui.write('%s -> %s\n' % (src, dst))
1830 ui.write('%s -> %s\n' % (src, dst))
1831
1831
1832 @command('debugpathcomplete',
1832 @command('debugpathcomplete',
1833 [('f', 'full', None, _('complete an entire path')),
1833 [('f', 'full', None, _('complete an entire path')),
1834 ('n', 'normal', None, _('show only normal files')),
1834 ('n', 'normal', None, _('show only normal files')),
1835 ('a', 'added', None, _('show only added files')),
1835 ('a', 'added', None, _('show only added files')),
1836 ('r', 'removed', None, _('show only removed files'))],
1836 ('r', 'removed', None, _('show only removed files'))],
1837 _('FILESPEC...'))
1837 _('FILESPEC...'))
1838 def debugpathcomplete(ui, repo, *specs, **opts):
1838 def debugpathcomplete(ui, repo, *specs, **opts):
1839 '''complete part or all of a tracked path
1839 '''complete part or all of a tracked path
1840
1840
1841 This command supports shells that offer path name completion. It
1841 This command supports shells that offer path name completion. It
1842 currently completes only files already known to the dirstate.
1842 currently completes only files already known to the dirstate.
1843
1843
1844 Completion extends only to the next path segment unless
1844 Completion extends only to the next path segment unless
1845 --full is specified, in which case entire paths are used.'''
1845 --full is specified, in which case entire paths are used.'''
1846
1846
1847 def complete(path, acceptable):
1847 def complete(path, acceptable):
1848 dirstate = repo.dirstate
1848 dirstate = repo.dirstate
1849 spec = os.path.normpath(os.path.join(encoding.getcwd(), path))
1849 spec = os.path.normpath(os.path.join(encoding.getcwd(), path))
1850 rootdir = repo.root + pycompat.ossep
1850 rootdir = repo.root + pycompat.ossep
1851 if spec != repo.root and not spec.startswith(rootdir):
1851 if spec != repo.root and not spec.startswith(rootdir):
1852 return [], []
1852 return [], []
1853 if os.path.isdir(spec):
1853 if os.path.isdir(spec):
1854 spec += '/'
1854 spec += '/'
1855 spec = spec[len(rootdir):]
1855 spec = spec[len(rootdir):]
1856 fixpaths = pycompat.ossep != '/'
1856 fixpaths = pycompat.ossep != '/'
1857 if fixpaths:
1857 if fixpaths:
1858 spec = spec.replace(pycompat.ossep, '/')
1858 spec = spec.replace(pycompat.ossep, '/')
1859 speclen = len(spec)
1859 speclen = len(spec)
1860 fullpaths = opts[r'full']
1860 fullpaths = opts[r'full']
1861 files, dirs = set(), set()
1861 files, dirs = set(), set()
1862 adddir, addfile = dirs.add, files.add
1862 adddir, addfile = dirs.add, files.add
1863 for f, st in dirstate.iteritems():
1863 for f, st in dirstate.iteritems():
1864 if f.startswith(spec) and st[0] in acceptable:
1864 if f.startswith(spec) and st[0] in acceptable:
1865 if fixpaths:
1865 if fixpaths:
1866 f = f.replace('/', pycompat.ossep)
1866 f = f.replace('/', pycompat.ossep)
1867 if fullpaths:
1867 if fullpaths:
1868 addfile(f)
1868 addfile(f)
1869 continue
1869 continue
1870 s = f.find(pycompat.ossep, speclen)
1870 s = f.find(pycompat.ossep, speclen)
1871 if s >= 0:
1871 if s >= 0:
1872 adddir(f[:s])
1872 adddir(f[:s])
1873 else:
1873 else:
1874 addfile(f)
1874 addfile(f)
1875 return files, dirs
1875 return files, dirs
1876
1876
1877 acceptable = ''
1877 acceptable = ''
1878 if opts[r'normal']:
1878 if opts[r'normal']:
1879 acceptable += 'nm'
1879 acceptable += 'nm'
1880 if opts[r'added']:
1880 if opts[r'added']:
1881 acceptable += 'a'
1881 acceptable += 'a'
1882 if opts[r'removed']:
1882 if opts[r'removed']:
1883 acceptable += 'r'
1883 acceptable += 'r'
1884 cwd = repo.getcwd()
1884 cwd = repo.getcwd()
1885 if not specs:
1885 if not specs:
1886 specs = ['.']
1886 specs = ['.']
1887
1887
1888 files, dirs = set(), set()
1888 files, dirs = set(), set()
1889 for spec in specs:
1889 for spec in specs:
1890 f, d = complete(spec, acceptable or 'nmar')
1890 f, d = complete(spec, acceptable or 'nmar')
1891 files.update(f)
1891 files.update(f)
1892 dirs.update(d)
1892 dirs.update(d)
1893 files.update(dirs)
1893 files.update(dirs)
1894 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
1894 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
1895 ui.write('\n')
1895 ui.write('\n')
1896
1896
1897 @command('debugpathcopies',
1897 @command('debugpathcopies',
1898 cmdutil.walkopts,
1898 cmdutil.walkopts,
1899 'hg debugpathcopies REV1 REV2 [FILE]',
1899 'hg debugpathcopies REV1 REV2 [FILE]',
1900 inferrepo=True)
1900 inferrepo=True)
1901 def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts):
1901 def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts):
1902 """show copies between two revisions"""
1902 """show copies between two revisions"""
1903 ctx1 = scmutil.revsingle(repo, rev1)
1903 ctx1 = scmutil.revsingle(repo, rev1)
1904 ctx2 = scmutil.revsingle(repo, rev2)
1904 ctx2 = scmutil.revsingle(repo, rev2)
1905 m = scmutil.match(ctx1, pats, opts)
1905 m = scmutil.match(ctx1, pats, opts)
1906 for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()):
1906 for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()):
1907 ui.write('%s -> %s\n' % (src, dst))
1907 ui.write('%s -> %s\n' % (src, dst))
1908
1908
1909 @command('debugpeer', [], _('PATH'), norepo=True)
1909 @command('debugpeer', [], _('PATH'), norepo=True)
1910 def debugpeer(ui, path):
1910 def debugpeer(ui, path):
1911 """establish a connection to a peer repository"""
1911 """establish a connection to a peer repository"""
1912 # Always enable peer request logging. Requires --debug to display
1912 # Always enable peer request logging. Requires --debug to display
1913 # though.
1913 # though.
1914 overrides = {
1914 overrides = {
1915 ('devel', 'debug.peer-request'): True,
1915 ('devel', 'debug.peer-request'): True,
1916 }
1916 }
1917
1917
1918 with ui.configoverride(overrides):
1918 with ui.configoverride(overrides):
1919 peer = hg.peer(ui, {}, path)
1919 peer = hg.peer(ui, {}, path)
1920
1920
1921 local = peer.local() is not None
1921 local = peer.local() is not None
1922 canpush = peer.canpush()
1922 canpush = peer.canpush()
1923
1923
1924 ui.write(_('url: %s\n') % peer.url())
1924 ui.write(_('url: %s\n') % peer.url())
1925 ui.write(_('local: %s\n') % (_('yes') if local else _('no')))
1925 ui.write(_('local: %s\n') % (_('yes') if local else _('no')))
1926 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no')))
1926 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no')))
1927
1927
1928 @command('debugpickmergetool',
1928 @command('debugpickmergetool',
1929 [('r', 'rev', '', _('check for files in this revision'), _('REV')),
1929 [('r', 'rev', '', _('check for files in this revision'), _('REV')),
1930 ('', 'changedelete', None, _('emulate merging change and delete')),
1930 ('', 'changedelete', None, _('emulate merging change and delete')),
1931 ] + cmdutil.walkopts + cmdutil.mergetoolopts,
1931 ] + cmdutil.walkopts + cmdutil.mergetoolopts,
1932 _('[PATTERN]...'),
1932 _('[PATTERN]...'),
1933 inferrepo=True)
1933 inferrepo=True)
1934 def debugpickmergetool(ui, repo, *pats, **opts):
1934 def debugpickmergetool(ui, repo, *pats, **opts):
1935 """examine which merge tool is chosen for specified file
1935 """examine which merge tool is chosen for specified file
1936
1936
1937 As described in :hg:`help merge-tools`, Mercurial examines
1937 As described in :hg:`help merge-tools`, Mercurial examines
1938 configurations below in this order to decide which merge tool is
1938 configurations below in this order to decide which merge tool is
1939 chosen for specified file.
1939 chosen for specified file.
1940
1940
1941 1. ``--tool`` option
1941 1. ``--tool`` option
1942 2. ``HGMERGE`` environment variable
1942 2. ``HGMERGE`` environment variable
1943 3. configurations in ``merge-patterns`` section
1943 3. configurations in ``merge-patterns`` section
1944 4. configuration of ``ui.merge``
1944 4. configuration of ``ui.merge``
1945 5. configurations in ``merge-tools`` section
1945 5. configurations in ``merge-tools`` section
1946 6. ``hgmerge`` tool (for historical reason only)
1946 6. ``hgmerge`` tool (for historical reason only)
1947 7. default tool for fallback (``:merge`` or ``:prompt``)
1947 7. default tool for fallback (``:merge`` or ``:prompt``)
1948
1948
1949 This command writes out examination result in the style below::
1949 This command writes out examination result in the style below::
1950
1950
1951 FILE = MERGETOOL
1951 FILE = MERGETOOL
1952
1952
1953 By default, all files known in the first parent context of the
1953 By default, all files known in the first parent context of the
1954 working directory are examined. Use file patterns and/or -I/-X
1954 working directory are examined. Use file patterns and/or -I/-X
1955 options to limit target files. -r/--rev is also useful to examine
1955 options to limit target files. -r/--rev is also useful to examine
1956 files in another context without actual updating to it.
1956 files in another context without actual updating to it.
1957
1957
1958 With --debug, this command shows warning messages while matching
1958 With --debug, this command shows warning messages while matching
1959 against ``merge-patterns`` and so on, too. It is recommended to
1959 against ``merge-patterns`` and so on, too. It is recommended to
1960 use this option with explicit file patterns and/or -I/-X options,
1960 use this option with explicit file patterns and/or -I/-X options,
1961 because this option increases amount of output per file according
1961 because this option increases amount of output per file according
1962 to configurations in hgrc.
1962 to configurations in hgrc.
1963
1963
1964 With -v/--verbose, this command shows configurations below at
1964 With -v/--verbose, this command shows configurations below at
1965 first (only if specified).
1965 first (only if specified).
1966
1966
1967 - ``--tool`` option
1967 - ``--tool`` option
1968 - ``HGMERGE`` environment variable
1968 - ``HGMERGE`` environment variable
1969 - configuration of ``ui.merge``
1969 - configuration of ``ui.merge``
1970
1970
1971 If merge tool is chosen before matching against
1971 If merge tool is chosen before matching against
1972 ``merge-patterns``, this command can't show any helpful
1972 ``merge-patterns``, this command can't show any helpful
1973 information, even with --debug. In such case, information above is
1973 information, even with --debug. In such case, information above is
1974 useful to know why a merge tool is chosen.
1974 useful to know why a merge tool is chosen.
1975 """
1975 """
1976 opts = pycompat.byteskwargs(opts)
1976 opts = pycompat.byteskwargs(opts)
1977 overrides = {}
1977 overrides = {}
1978 if opts['tool']:
1978 if opts['tool']:
1979 overrides[('ui', 'forcemerge')] = opts['tool']
1979 overrides[('ui', 'forcemerge')] = opts['tool']
1980 ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool'])))
1980 ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool'])))
1981
1981
1982 with ui.configoverride(overrides, 'debugmergepatterns'):
1982 with ui.configoverride(overrides, 'debugmergepatterns'):
1983 hgmerge = encoding.environ.get("HGMERGE")
1983 hgmerge = encoding.environ.get("HGMERGE")
1984 if hgmerge is not None:
1984 if hgmerge is not None:
1985 ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge)))
1985 ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge)))
1986 uimerge = ui.config("ui", "merge")
1986 uimerge = ui.config("ui", "merge")
1987 if uimerge:
1987 if uimerge:
1988 ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge)))
1988 ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge)))
1989
1989
1990 ctx = scmutil.revsingle(repo, opts.get('rev'))
1990 ctx = scmutil.revsingle(repo, opts.get('rev'))
1991 m = scmutil.match(ctx, pats, opts)
1991 m = scmutil.match(ctx, pats, opts)
1992 changedelete = opts['changedelete']
1992 changedelete = opts['changedelete']
1993 for path in ctx.walk(m):
1993 for path in ctx.walk(m):
1994 fctx = ctx[path]
1994 fctx = ctx[path]
1995 try:
1995 try:
1996 if not ui.debugflag:
1996 if not ui.debugflag:
1997 ui.pushbuffer(error=True)
1997 ui.pushbuffer(error=True)
1998 tool, toolpath = filemerge._picktool(repo, ui, path,
1998 tool, toolpath = filemerge._picktool(repo, ui, path,
1999 fctx.isbinary(),
1999 fctx.isbinary(),
2000 'l' in fctx.flags(),
2000 'l' in fctx.flags(),
2001 changedelete)
2001 changedelete)
2002 finally:
2002 finally:
2003 if not ui.debugflag:
2003 if not ui.debugflag:
2004 ui.popbuffer()
2004 ui.popbuffer()
2005 ui.write(('%s = %s\n') % (path, tool))
2005 ui.write(('%s = %s\n') % (path, tool))
2006
2006
2007 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2007 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2008 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2008 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2009 '''access the pushkey key/value protocol
2009 '''access the pushkey key/value protocol
2010
2010
2011 With two args, list the keys in the given namespace.
2011 With two args, list the keys in the given namespace.
2012
2012
2013 With five args, set a key to new if it currently is set to old.
2013 With five args, set a key to new if it currently is set to old.
2014 Reports success or failure.
2014 Reports success or failure.
2015 '''
2015 '''
2016
2016
2017 target = hg.peer(ui, {}, repopath)
2017 target = hg.peer(ui, {}, repopath)
2018 if keyinfo:
2018 if keyinfo:
2019 key, old, new = keyinfo
2019 key, old, new = keyinfo
2020 with target.commandexecutor() as e:
2020 with target.commandexecutor() as e:
2021 r = e.callcommand('pushkey', {
2021 r = e.callcommand('pushkey', {
2022 'namespace': namespace,
2022 'namespace': namespace,
2023 'key': key,
2023 'key': key,
2024 'old': old,
2024 'old': old,
2025 'new': new,
2025 'new': new,
2026 }).result()
2026 }).result()
2027
2027
2028 ui.status(pycompat.bytestr(r) + '\n')
2028 ui.status(pycompat.bytestr(r) + '\n')
2029 return not r
2029 return not r
2030 else:
2030 else:
2031 for k, v in sorted(target.listkeys(namespace).iteritems()):
2031 for k, v in sorted(target.listkeys(namespace).iteritems()):
2032 ui.write("%s\t%s\n" % (stringutil.escapestr(k),
2032 ui.write("%s\t%s\n" % (stringutil.escapestr(k),
2033 stringutil.escapestr(v)))
2033 stringutil.escapestr(v)))
2034
2034
2035 @command('debugpvec', [], _('A B'))
2035 @command('debugpvec', [], _('A B'))
2036 def debugpvec(ui, repo, a, b=None):
2036 def debugpvec(ui, repo, a, b=None):
2037 ca = scmutil.revsingle(repo, a)
2037 ca = scmutil.revsingle(repo, a)
2038 cb = scmutil.revsingle(repo, b)
2038 cb = scmutil.revsingle(repo, b)
2039 pa = pvec.ctxpvec(ca)
2039 pa = pvec.ctxpvec(ca)
2040 pb = pvec.ctxpvec(cb)
2040 pb = pvec.ctxpvec(cb)
2041 if pa == pb:
2041 if pa == pb:
2042 rel = "="
2042 rel = "="
2043 elif pa > pb:
2043 elif pa > pb:
2044 rel = ">"
2044 rel = ">"
2045 elif pa < pb:
2045 elif pa < pb:
2046 rel = "<"
2046 rel = "<"
2047 elif pa | pb:
2047 elif pa | pb:
2048 rel = "|"
2048 rel = "|"
2049 ui.write(_("a: %s\n") % pa)
2049 ui.write(_("a: %s\n") % pa)
2050 ui.write(_("b: %s\n") % pb)
2050 ui.write(_("b: %s\n") % pb)
2051 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2051 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2052 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2052 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2053 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2053 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2054 pa.distance(pb), rel))
2054 pa.distance(pb), rel))
2055
2055
2056 @command('debugrebuilddirstate|debugrebuildstate',
2056 @command('debugrebuilddirstate|debugrebuildstate',
2057 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2057 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2058 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2058 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2059 'the working copy parent')),
2059 'the working copy parent')),
2060 ],
2060 ],
2061 _('[-r REV]'))
2061 _('[-r REV]'))
2062 def debugrebuilddirstate(ui, repo, rev, **opts):
2062 def debugrebuilddirstate(ui, repo, rev, **opts):
2063 """rebuild the dirstate as it would look like for the given revision
2063 """rebuild the dirstate as it would look like for the given revision
2064
2064
2065 If no revision is specified the first current parent will be used.
2065 If no revision is specified the first current parent will be used.
2066
2066
2067 The dirstate will be set to the files of the given revision.
2067 The dirstate will be set to the files of the given revision.
2068 The actual working directory content or existing dirstate
2068 The actual working directory content or existing dirstate
2069 information such as adds or removes is not considered.
2069 information such as adds or removes is not considered.
2070
2070
2071 ``minimal`` will only rebuild the dirstate status for files that claim to be
2071 ``minimal`` will only rebuild the dirstate status for files that claim to be
2072 tracked but are not in the parent manifest, or that exist in the parent
2072 tracked but are not in the parent manifest, or that exist in the parent
2073 manifest but are not in the dirstate. It will not change adds, removes, or
2073 manifest but are not in the dirstate. It will not change adds, removes, or
2074 modified files that are in the working copy parent.
2074 modified files that are in the working copy parent.
2075
2075
2076 One use of this command is to make the next :hg:`status` invocation
2076 One use of this command is to make the next :hg:`status` invocation
2077 check the actual file content.
2077 check the actual file content.
2078 """
2078 """
2079 ctx = scmutil.revsingle(repo, rev)
2079 ctx = scmutil.revsingle(repo, rev)
2080 with repo.wlock():
2080 with repo.wlock():
2081 dirstate = repo.dirstate
2081 dirstate = repo.dirstate
2082 changedfiles = None
2082 changedfiles = None
2083 # See command doc for what minimal does.
2083 # See command doc for what minimal does.
2084 if opts.get(r'minimal'):
2084 if opts.get(r'minimal'):
2085 manifestfiles = set(ctx.manifest().keys())
2085 manifestfiles = set(ctx.manifest().keys())
2086 dirstatefiles = set(dirstate)
2086 dirstatefiles = set(dirstate)
2087 manifestonly = manifestfiles - dirstatefiles
2087 manifestonly = manifestfiles - dirstatefiles
2088 dsonly = dirstatefiles - manifestfiles
2088 dsonly = dirstatefiles - manifestfiles
2089 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
2089 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
2090 changedfiles = manifestonly | dsnotadded
2090 changedfiles = manifestonly | dsnotadded
2091
2091
2092 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
2092 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
2093
2093
2094 @command('debugrebuildfncache', [], '')
2094 @command('debugrebuildfncache', [], '')
2095 def debugrebuildfncache(ui, repo):
2095 def debugrebuildfncache(ui, repo):
2096 """rebuild the fncache file"""
2096 """rebuild the fncache file"""
2097 repair.rebuildfncache(ui, repo)
2097 repair.rebuildfncache(ui, repo)
2098
2098
2099 @command('debugrename',
2099 @command('debugrename',
2100 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2100 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2101 _('[-r REV] [FILE]...'))
2101 _('[-r REV] [FILE]...'))
2102 def debugrename(ui, repo, *pats, **opts):
2102 def debugrename(ui, repo, *pats, **opts):
2103 """dump rename information"""
2103 """dump rename information"""
2104
2104
2105 opts = pycompat.byteskwargs(opts)
2105 opts = pycompat.byteskwargs(opts)
2106 ctx = scmutil.revsingle(repo, opts.get('rev'))
2106 ctx = scmutil.revsingle(repo, opts.get('rev'))
2107 m = scmutil.match(ctx, pats, opts)
2107 m = scmutil.match(ctx, pats, opts)
2108 for abs in ctx.walk(m):
2108 for abs in ctx.walk(m):
2109 fctx = ctx[abs]
2109 fctx = ctx[abs]
2110 o = fctx.filelog().renamed(fctx.filenode())
2110 o = fctx.filelog().renamed(fctx.filenode())
2111 rel = repo.pathto(abs)
2111 rel = repo.pathto(abs)
2112 if o:
2112 if o:
2113 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2113 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2114 else:
2114 else:
2115 ui.write(_("%s not renamed\n") % rel)
2115 ui.write(_("%s not renamed\n") % rel)
2116
2116
2117 @command('debugrevlog', cmdutil.debugrevlogopts +
2117 @command('debugrevlog', cmdutil.debugrevlogopts +
2118 [('d', 'dump', False, _('dump index data'))],
2118 [('d', 'dump', False, _('dump index data'))],
2119 _('-c|-m|FILE'),
2119 _('-c|-m|FILE'),
2120 optionalrepo=True)
2120 optionalrepo=True)
2121 def debugrevlog(ui, repo, file_=None, **opts):
2121 def debugrevlog(ui, repo, file_=None, **opts):
2122 """show data and statistics about a revlog"""
2122 """show data and statistics about a revlog"""
2123 opts = pycompat.byteskwargs(opts)
2123 opts = pycompat.byteskwargs(opts)
2124 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2124 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2125
2125
2126 if opts.get("dump"):
2126 if opts.get("dump"):
2127 numrevs = len(r)
2127 numrevs = len(r)
2128 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2"
2128 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2"
2129 " rawsize totalsize compression heads chainlen\n"))
2129 " rawsize totalsize compression heads chainlen\n"))
2130 ts = 0
2130 ts = 0
2131 heads = set()
2131 heads = set()
2132
2132
2133 for rev in pycompat.xrange(numrevs):
2133 for rev in pycompat.xrange(numrevs):
2134 dbase = r.deltaparent(rev)
2134 dbase = r.deltaparent(rev)
2135 if dbase == -1:
2135 if dbase == -1:
2136 dbase = rev
2136 dbase = rev
2137 cbase = r.chainbase(rev)
2137 cbase = r.chainbase(rev)
2138 clen = r.chainlen(rev)
2138 clen = r.chainlen(rev)
2139 p1, p2 = r.parentrevs(rev)
2139 p1, p2 = r.parentrevs(rev)
2140 rs = r.rawsize(rev)
2140 rs = r.rawsize(rev)
2141 ts = ts + rs
2141 ts = ts + rs
2142 heads -= set(r.parentrevs(rev))
2142 heads -= set(r.parentrevs(rev))
2143 heads.add(rev)
2143 heads.add(rev)
2144 try:
2144 try:
2145 compression = ts / r.end(rev)
2145 compression = ts / r.end(rev)
2146 except ZeroDivisionError:
2146 except ZeroDivisionError:
2147 compression = 0
2147 compression = 0
2148 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2148 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2149 "%11d %5d %8d\n" %
2149 "%11d %5d %8d\n" %
2150 (rev, p1, p2, r.start(rev), r.end(rev),
2150 (rev, p1, p2, r.start(rev), r.end(rev),
2151 r.start(dbase), r.start(cbase),
2151 r.start(dbase), r.start(cbase),
2152 r.start(p1), r.start(p2),
2152 r.start(p1), r.start(p2),
2153 rs, ts, compression, len(heads), clen))
2153 rs, ts, compression, len(heads), clen))
2154 return 0
2154 return 0
2155
2155
2156 v = r.version
2156 v = r.version
2157 format = v & 0xFFFF
2157 format = v & 0xFFFF
2158 flags = []
2158 flags = []
2159 gdelta = False
2159 gdelta = False
2160 if v & revlog.FLAG_INLINE_DATA:
2160 if v & revlog.FLAG_INLINE_DATA:
2161 flags.append('inline')
2161 flags.append('inline')
2162 if v & revlog.FLAG_GENERALDELTA:
2162 if v & revlog.FLAG_GENERALDELTA:
2163 gdelta = True
2163 gdelta = True
2164 flags.append('generaldelta')
2164 flags.append('generaldelta')
2165 if not flags:
2165 if not flags:
2166 flags = ['(none)']
2166 flags = ['(none)']
2167
2167
2168 ### tracks merge vs single parent
2168 ### tracks merge vs single parent
2169 nummerges = 0
2169 nummerges = 0
2170
2170
2171 ### tracks ways the "delta" are build
2171 ### tracks ways the "delta" are build
2172 # nodelta
2172 # nodelta
2173 numempty = 0
2173 numempty = 0
2174 numemptytext = 0
2174 numemptytext = 0
2175 numemptydelta = 0
2175 numemptydelta = 0
2176 # full file content
2176 # full file content
2177 numfull = 0
2177 numfull = 0
2178 # intermediate snapshot against a prior snapshot
2178 # intermediate snapshot against a prior snapshot
2179 numsemi = 0
2179 numsemi = 0
2180 # snapshot count per depth
2180 # snapshot count per depth
2181 numsnapdepth = collections.defaultdict(lambda: 0)
2181 numsnapdepth = collections.defaultdict(lambda: 0)
2182 # delta against previous revision
2182 # delta against previous revision
2183 numprev = 0
2183 numprev = 0
2184 # delta against first or second parent (not prev)
2184 # delta against first or second parent (not prev)
2185 nump1 = 0
2185 nump1 = 0
2186 nump2 = 0
2186 nump2 = 0
2187 # delta against neither prev nor parents
2187 # delta against neither prev nor parents
2188 numother = 0
2188 numother = 0
2189 # delta against prev that are also first or second parent
2189 # delta against prev that are also first or second parent
2190 # (details of `numprev`)
2190 # (details of `numprev`)
2191 nump1prev = 0
2191 nump1prev = 0
2192 nump2prev = 0
2192 nump2prev = 0
2193
2193
2194 # data about delta chain of each revs
2194 # data about delta chain of each revs
2195 chainlengths = []
2195 chainlengths = []
2196 chainbases = []
2196 chainbases = []
2197 chainspans = []
2197 chainspans = []
2198
2198
2199 # data about each revision
2199 # data about each revision
2200 datasize = [None, 0, 0]
2200 datasize = [None, 0, 0]
2201 fullsize = [None, 0, 0]
2201 fullsize = [None, 0, 0]
2202 semisize = [None, 0, 0]
2202 semisize = [None, 0, 0]
2203 # snapshot count per depth
2203 # snapshot count per depth
2204 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
2204 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
2205 deltasize = [None, 0, 0]
2205 deltasize = [None, 0, 0]
2206 chunktypecounts = {}
2206 chunktypecounts = {}
2207 chunktypesizes = {}
2207 chunktypesizes = {}
2208
2208
2209 def addsize(size, l):
2209 def addsize(size, l):
2210 if l[0] is None or size < l[0]:
2210 if l[0] is None or size < l[0]:
2211 l[0] = size
2211 l[0] = size
2212 if size > l[1]:
2212 if size > l[1]:
2213 l[1] = size
2213 l[1] = size
2214 l[2] += size
2214 l[2] += size
2215
2215
2216 numrevs = len(r)
2216 numrevs = len(r)
2217 for rev in pycompat.xrange(numrevs):
2217 for rev in pycompat.xrange(numrevs):
2218 p1, p2 = r.parentrevs(rev)
2218 p1, p2 = r.parentrevs(rev)
2219 delta = r.deltaparent(rev)
2219 delta = r.deltaparent(rev)
2220 if format > 0:
2220 if format > 0:
2221 addsize(r.rawsize(rev), datasize)
2221 addsize(r.rawsize(rev), datasize)
2222 if p2 != nullrev:
2222 if p2 != nullrev:
2223 nummerges += 1
2223 nummerges += 1
2224 size = r.length(rev)
2224 size = r.length(rev)
2225 if delta == nullrev:
2225 if delta == nullrev:
2226 chainlengths.append(0)
2226 chainlengths.append(0)
2227 chainbases.append(r.start(rev))
2227 chainbases.append(r.start(rev))
2228 chainspans.append(size)
2228 chainspans.append(size)
2229 if size == 0:
2229 if size == 0:
2230 numempty += 1
2230 numempty += 1
2231 numemptytext += 1
2231 numemptytext += 1
2232 else:
2232 else:
2233 numfull += 1
2233 numfull += 1
2234 numsnapdepth[0] += 1
2234 numsnapdepth[0] += 1
2235 addsize(size, fullsize)
2235 addsize(size, fullsize)
2236 addsize(size, snapsizedepth[0])
2236 addsize(size, snapsizedepth[0])
2237 else:
2237 else:
2238 chainlengths.append(chainlengths[delta] + 1)
2238 chainlengths.append(chainlengths[delta] + 1)
2239 baseaddr = chainbases[delta]
2239 baseaddr = chainbases[delta]
2240 revaddr = r.start(rev)
2240 revaddr = r.start(rev)
2241 chainbases.append(baseaddr)
2241 chainbases.append(baseaddr)
2242 chainspans.append((revaddr - baseaddr) + size)
2242 chainspans.append((revaddr - baseaddr) + size)
2243 if size == 0:
2243 if size == 0:
2244 numempty += 1
2244 numempty += 1
2245 numemptydelta += 1
2245 numemptydelta += 1
2246 elif r.issnapshot(rev):
2246 elif r.issnapshot(rev):
2247 addsize(size, semisize)
2247 addsize(size, semisize)
2248 numsemi += 1
2248 numsemi += 1
2249 depth = r.snapshotdepth(rev)
2249 depth = r.snapshotdepth(rev)
2250 numsnapdepth[depth] += 1
2250 numsnapdepth[depth] += 1
2251 addsize(size, snapsizedepth[depth])
2251 addsize(size, snapsizedepth[depth])
2252 else:
2252 else:
2253 addsize(size, deltasize)
2253 addsize(size, deltasize)
2254 if delta == rev - 1:
2254 if delta == rev - 1:
2255 numprev += 1
2255 numprev += 1
2256 if delta == p1:
2256 if delta == p1:
2257 nump1prev += 1
2257 nump1prev += 1
2258 elif delta == p2:
2258 elif delta == p2:
2259 nump2prev += 1
2259 nump2prev += 1
2260 elif delta == p1:
2260 elif delta == p1:
2261 nump1 += 1
2261 nump1 += 1
2262 elif delta == p2:
2262 elif delta == p2:
2263 nump2 += 1
2263 nump2 += 1
2264 elif delta != nullrev:
2264 elif delta != nullrev:
2265 numother += 1
2265 numother += 1
2266
2266
2267 # Obtain data on the raw chunks in the revlog.
2267 # Obtain data on the raw chunks in the revlog.
2268 if util.safehasattr(r, '_getsegmentforrevs'):
2268 if util.safehasattr(r, '_getsegmentforrevs'):
2269 segment = r._getsegmentforrevs(rev, rev)[1]
2269 segment = r._getsegmentforrevs(rev, rev)[1]
2270 else:
2270 else:
2271 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
2271 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
2272 if segment:
2272 if segment:
2273 chunktype = bytes(segment[0:1])
2273 chunktype = bytes(segment[0:1])
2274 else:
2274 else:
2275 chunktype = 'empty'
2275 chunktype = 'empty'
2276
2276
2277 if chunktype not in chunktypecounts:
2277 if chunktype not in chunktypecounts:
2278 chunktypecounts[chunktype] = 0
2278 chunktypecounts[chunktype] = 0
2279 chunktypesizes[chunktype] = 0
2279 chunktypesizes[chunktype] = 0
2280
2280
2281 chunktypecounts[chunktype] += 1
2281 chunktypecounts[chunktype] += 1
2282 chunktypesizes[chunktype] += size
2282 chunktypesizes[chunktype] += size
2283
2283
2284 # Adjust size min value for empty cases
2284 # Adjust size min value for empty cases
2285 for size in (datasize, fullsize, semisize, deltasize):
2285 for size in (datasize, fullsize, semisize, deltasize):
2286 if size[0] is None:
2286 if size[0] is None:
2287 size[0] = 0
2287 size[0] = 0
2288
2288
2289 numdeltas = numrevs - numfull - numempty - numsemi
2289 numdeltas = numrevs - numfull - numempty - numsemi
2290 numoprev = numprev - nump1prev - nump2prev
2290 numoprev = numprev - nump1prev - nump2prev
2291 totalrawsize = datasize[2]
2291 totalrawsize = datasize[2]
2292 datasize[2] /= numrevs
2292 datasize[2] /= numrevs
2293 fulltotal = fullsize[2]
2293 fulltotal = fullsize[2]
2294 if numfull == 0:
2294 if numfull == 0:
2295 fullsize[2] = 0
2295 fullsize[2] = 0
2296 else:
2296 else:
2297 fullsize[2] /= numfull
2297 fullsize[2] /= numfull
2298 semitotal = semisize[2]
2298 semitotal = semisize[2]
2299 snaptotal = {}
2299 snaptotal = {}
2300 if numsemi > 0:
2300 if numsemi > 0:
2301 semisize[2] /= numsemi
2301 semisize[2] /= numsemi
2302 for depth in snapsizedepth:
2302 for depth in snapsizedepth:
2303 snaptotal[depth] = snapsizedepth[depth][2]
2303 snaptotal[depth] = snapsizedepth[depth][2]
2304 snapsizedepth[depth][2] /= numsnapdepth[depth]
2304 snapsizedepth[depth][2] /= numsnapdepth[depth]
2305
2305
2306 deltatotal = deltasize[2]
2306 deltatotal = deltasize[2]
2307 if numdeltas > 0:
2307 if numdeltas > 0:
2308 deltasize[2] /= numdeltas
2308 deltasize[2] /= numdeltas
2309 totalsize = fulltotal + semitotal + deltatotal
2309 totalsize = fulltotal + semitotal + deltatotal
2310 avgchainlen = sum(chainlengths) / numrevs
2310 avgchainlen = sum(chainlengths) / numrevs
2311 maxchainlen = max(chainlengths)
2311 maxchainlen = max(chainlengths)
2312 maxchainspan = max(chainspans)
2312 maxchainspan = max(chainspans)
2313 compratio = 1
2313 compratio = 1
2314 if totalsize:
2314 if totalsize:
2315 compratio = totalrawsize / totalsize
2315 compratio = totalrawsize / totalsize
2316
2316
2317 basedfmtstr = '%%%dd\n'
2317 basedfmtstr = '%%%dd\n'
2318 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2318 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2319
2319
2320 def dfmtstr(max):
2320 def dfmtstr(max):
2321 return basedfmtstr % len(str(max))
2321 return basedfmtstr % len(str(max))
2322 def pcfmtstr(max, padding=0):
2322 def pcfmtstr(max, padding=0):
2323 return basepcfmtstr % (len(str(max)), ' ' * padding)
2323 return basepcfmtstr % (len(str(max)), ' ' * padding)
2324
2324
2325 def pcfmt(value, total):
2325 def pcfmt(value, total):
2326 if total:
2326 if total:
2327 return (value, 100 * float(value) / total)
2327 return (value, 100 * float(value) / total)
2328 else:
2328 else:
2329 return value, 100.0
2329 return value, 100.0
2330
2330
2331 ui.write(('format : %d\n') % format)
2331 ui.write(('format : %d\n') % format)
2332 ui.write(('flags : %s\n') % ', '.join(flags))
2332 ui.write(('flags : %s\n') % ', '.join(flags))
2333
2333
2334 ui.write('\n')
2334 ui.write('\n')
2335 fmt = pcfmtstr(totalsize)
2335 fmt = pcfmtstr(totalsize)
2336 fmt2 = dfmtstr(totalsize)
2336 fmt2 = dfmtstr(totalsize)
2337 ui.write(('revisions : ') + fmt2 % numrevs)
2337 ui.write(('revisions : ') + fmt2 % numrevs)
2338 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2338 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2339 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2339 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2340 ui.write(('revisions : ') + fmt2 % numrevs)
2340 ui.write(('revisions : ') + fmt2 % numrevs)
2341 ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs))
2341 ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs))
2342 ui.write((' text : ')
2342 ui.write((' text : ')
2343 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta))
2343 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta))
2344 ui.write((' delta : ')
2344 ui.write((' delta : ')
2345 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta))
2345 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta))
2346 ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs))
2346 ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs))
2347 for depth in sorted(numsnapdepth):
2347 for depth in sorted(numsnapdepth):
2348 ui.write((' lvl-%-3d : ' % depth)
2348 ui.write((' lvl-%-3d : ' % depth)
2349 + fmt % pcfmt(numsnapdepth[depth], numrevs))
2349 + fmt % pcfmt(numsnapdepth[depth], numrevs))
2350 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2350 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2351 ui.write(('revision size : ') + fmt2 % totalsize)
2351 ui.write(('revision size : ') + fmt2 % totalsize)
2352 ui.write((' snapshot : ')
2352 ui.write((' snapshot : ')
2353 + fmt % pcfmt(fulltotal + semitotal, totalsize))
2353 + fmt % pcfmt(fulltotal + semitotal, totalsize))
2354 for depth in sorted(numsnapdepth):
2354 for depth in sorted(numsnapdepth):
2355 ui.write((' lvl-%-3d : ' % depth)
2355 ui.write((' lvl-%-3d : ' % depth)
2356 + fmt % pcfmt(snaptotal[depth], totalsize))
2356 + fmt % pcfmt(snaptotal[depth], totalsize))
2357 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2357 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2358
2358
2359 def fmtchunktype(chunktype):
2359 def fmtchunktype(chunktype):
2360 if chunktype == 'empty':
2360 if chunktype == 'empty':
2361 return ' %s : ' % chunktype
2361 return ' %s : ' % chunktype
2362 elif chunktype in pycompat.bytestr(string.ascii_letters):
2362 elif chunktype in pycompat.bytestr(string.ascii_letters):
2363 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype)
2363 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype)
2364 else:
2364 else:
2365 return ' 0x%s : ' % hex(chunktype)
2365 return ' 0x%s : ' % hex(chunktype)
2366
2366
2367 ui.write('\n')
2367 ui.write('\n')
2368 ui.write(('chunks : ') + fmt2 % numrevs)
2368 ui.write(('chunks : ') + fmt2 % numrevs)
2369 for chunktype in sorted(chunktypecounts):
2369 for chunktype in sorted(chunktypecounts):
2370 ui.write(fmtchunktype(chunktype))
2370 ui.write(fmtchunktype(chunktype))
2371 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
2371 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
2372 ui.write(('chunks size : ') + fmt2 % totalsize)
2372 ui.write(('chunks size : ') + fmt2 % totalsize)
2373 for chunktype in sorted(chunktypecounts):
2373 for chunktype in sorted(chunktypecounts):
2374 ui.write(fmtchunktype(chunktype))
2374 ui.write(fmtchunktype(chunktype))
2375 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
2375 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
2376
2376
2377 ui.write('\n')
2377 ui.write('\n')
2378 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
2378 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
2379 ui.write(('avg chain length : ') + fmt % avgchainlen)
2379 ui.write(('avg chain length : ') + fmt % avgchainlen)
2380 ui.write(('max chain length : ') + fmt % maxchainlen)
2380 ui.write(('max chain length : ') + fmt % maxchainlen)
2381 ui.write(('max chain reach : ') + fmt % maxchainspan)
2381 ui.write(('max chain reach : ') + fmt % maxchainspan)
2382 ui.write(('compression ratio : ') + fmt % compratio)
2382 ui.write(('compression ratio : ') + fmt % compratio)
2383
2383
2384 if format > 0:
2384 if format > 0:
2385 ui.write('\n')
2385 ui.write('\n')
2386 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2386 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2387 % tuple(datasize))
2387 % tuple(datasize))
2388 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2388 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2389 % tuple(fullsize))
2389 % tuple(fullsize))
2390 ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n')
2390 ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n')
2391 % tuple(semisize))
2391 % tuple(semisize))
2392 for depth in sorted(snapsizedepth):
2392 for depth in sorted(snapsizedepth):
2393 if depth == 0:
2393 if depth == 0:
2394 continue
2394 continue
2395 ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n')
2395 ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n')
2396 % ((depth,) + tuple(snapsizedepth[depth])))
2396 % ((depth,) + tuple(snapsizedepth[depth])))
2397 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2397 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2398 % tuple(deltasize))
2398 % tuple(deltasize))
2399
2399
2400 if numdeltas > 0:
2400 if numdeltas > 0:
2401 ui.write('\n')
2401 ui.write('\n')
2402 fmt = pcfmtstr(numdeltas)
2402 fmt = pcfmtstr(numdeltas)
2403 fmt2 = pcfmtstr(numdeltas, 4)
2403 fmt2 = pcfmtstr(numdeltas, 4)
2404 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2404 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2405 if numprev > 0:
2405 if numprev > 0:
2406 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2406 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2407 numprev))
2407 numprev))
2408 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2408 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2409 numprev))
2409 numprev))
2410 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2410 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2411 numprev))
2411 numprev))
2412 if gdelta:
2412 if gdelta:
2413 ui.write(('deltas against p1 : ')
2413 ui.write(('deltas against p1 : ')
2414 + fmt % pcfmt(nump1, numdeltas))
2414 + fmt % pcfmt(nump1, numdeltas))
2415 ui.write(('deltas against p2 : ')
2415 ui.write(('deltas against p2 : ')
2416 + fmt % pcfmt(nump2, numdeltas))
2416 + fmt % pcfmt(nump2, numdeltas))
2417 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2417 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2418 numdeltas))
2418 numdeltas))
2419
2419
2420 @command('debugrevlogindex', cmdutil.debugrevlogopts +
2420 @command('debugrevlogindex', cmdutil.debugrevlogopts +
2421 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2421 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2422 _('[-f FORMAT] -c|-m|FILE'),
2422 _('[-f FORMAT] -c|-m|FILE'),
2423 optionalrepo=True)
2423 optionalrepo=True)
2424 def debugrevlogindex(ui, repo, file_=None, **opts):
2424 def debugrevlogindex(ui, repo, file_=None, **opts):
2425 """dump the contents of a revlog index"""
2425 """dump the contents of a revlog index"""
2426 opts = pycompat.byteskwargs(opts)
2426 opts = pycompat.byteskwargs(opts)
2427 r = cmdutil.openrevlog(repo, 'debugrevlogindex', file_, opts)
2427 r = cmdutil.openrevlog(repo, 'debugrevlogindex', file_, opts)
2428 format = opts.get('format', 0)
2428 format = opts.get('format', 0)
2429 if format not in (0, 1):
2429 if format not in (0, 1):
2430 raise error.Abort(_("unknown format %d") % format)
2430 raise error.Abort(_("unknown format %d") % format)
2431
2431
2432 if ui.debugflag:
2432 if ui.debugflag:
2433 shortfn = hex
2433 shortfn = hex
2434 else:
2434 else:
2435 shortfn = short
2435 shortfn = short
2436
2436
2437 # There might not be anything in r, so have a sane default
2437 # There might not be anything in r, so have a sane default
2438 idlen = 12
2438 idlen = 12
2439 for i in r:
2439 for i in r:
2440 idlen = len(shortfn(r.node(i)))
2440 idlen = len(shortfn(r.node(i)))
2441 break
2441 break
2442
2442
2443 if format == 0:
2443 if format == 0:
2444 if ui.verbose:
2444 if ui.verbose:
2445 ui.write((" rev offset length linkrev"
2445 ui.write((" rev offset length linkrev"
2446 " %s %s p2\n") % ("nodeid".ljust(idlen),
2446 " %s %s p2\n") % ("nodeid".ljust(idlen),
2447 "p1".ljust(idlen)))
2447 "p1".ljust(idlen)))
2448 else:
2448 else:
2449 ui.write((" rev linkrev %s %s p2\n") % (
2449 ui.write((" rev linkrev %s %s p2\n") % (
2450 "nodeid".ljust(idlen), "p1".ljust(idlen)))
2450 "nodeid".ljust(idlen), "p1".ljust(idlen)))
2451 elif format == 1:
2451 elif format == 1:
2452 if ui.verbose:
2452 if ui.verbose:
2453 ui.write((" rev flag offset length size link p1"
2453 ui.write((" rev flag offset length size link p1"
2454 " p2 %s\n") % "nodeid".rjust(idlen))
2454 " p2 %s\n") % "nodeid".rjust(idlen))
2455 else:
2455 else:
2456 ui.write((" rev flag size link p1 p2 %s\n") %
2456 ui.write((" rev flag size link p1 p2 %s\n") %
2457 "nodeid".rjust(idlen))
2457 "nodeid".rjust(idlen))
2458
2458
2459 for i in r:
2459 for i in r:
2460 node = r.node(i)
2460 node = r.node(i)
2461 if format == 0:
2461 if format == 0:
2462 try:
2462 try:
2463 pp = r.parents(node)
2463 pp = r.parents(node)
2464 except Exception:
2464 except Exception:
2465 pp = [nullid, nullid]
2465 pp = [nullid, nullid]
2466 if ui.verbose:
2466 if ui.verbose:
2467 ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % (
2467 ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % (
2468 i, r.start(i), r.length(i), r.linkrev(i),
2468 i, r.start(i), r.length(i), r.linkrev(i),
2469 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2469 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2470 else:
2470 else:
2471 ui.write("% 6d % 7d %s %s %s\n" % (
2471 ui.write("% 6d % 7d %s %s %s\n" % (
2472 i, r.linkrev(i), shortfn(node), shortfn(pp[0]),
2472 i, r.linkrev(i), shortfn(node), shortfn(pp[0]),
2473 shortfn(pp[1])))
2473 shortfn(pp[1])))
2474 elif format == 1:
2474 elif format == 1:
2475 pr = r.parentrevs(i)
2475 pr = r.parentrevs(i)
2476 if ui.verbose:
2476 if ui.verbose:
2477 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % (
2477 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % (
2478 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2478 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2479 r.linkrev(i), pr[0], pr[1], shortfn(node)))
2479 r.linkrev(i), pr[0], pr[1], shortfn(node)))
2480 else:
2480 else:
2481 ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % (
2481 ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % (
2482 i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1],
2482 i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1],
2483 shortfn(node)))
2483 shortfn(node)))
2484
2484
2485 @command('debugrevspec',
2485 @command('debugrevspec',
2486 [('', 'optimize', None,
2486 [('', 'optimize', None,
2487 _('print parsed tree after optimizing (DEPRECATED)')),
2487 _('print parsed tree after optimizing (DEPRECATED)')),
2488 ('', 'show-revs', True, _('print list of result revisions (default)')),
2488 ('', 'show-revs', True, _('print list of result revisions (default)')),
2489 ('s', 'show-set', None, _('print internal representation of result set')),
2489 ('s', 'show-set', None, _('print internal representation of result set')),
2490 ('p', 'show-stage', [],
2490 ('p', 'show-stage', [],
2491 _('print parsed tree at the given stage'), _('NAME')),
2491 _('print parsed tree at the given stage'), _('NAME')),
2492 ('', 'no-optimized', False, _('evaluate tree without optimization')),
2492 ('', 'no-optimized', False, _('evaluate tree without optimization')),
2493 ('', 'verify-optimized', False, _('verify optimized result')),
2493 ('', 'verify-optimized', False, _('verify optimized result')),
2494 ],
2494 ],
2495 ('REVSPEC'))
2495 ('REVSPEC'))
2496 def debugrevspec(ui, repo, expr, **opts):
2496 def debugrevspec(ui, repo, expr, **opts):
2497 """parse and apply a revision specification
2497 """parse and apply a revision specification
2498
2498
2499 Use -p/--show-stage option to print the parsed tree at the given stages.
2499 Use -p/--show-stage option to print the parsed tree at the given stages.
2500 Use -p all to print tree at every stage.
2500 Use -p all to print tree at every stage.
2501
2501
2502 Use --no-show-revs option with -s or -p to print only the set
2502 Use --no-show-revs option with -s or -p to print only the set
2503 representation or the parsed tree respectively.
2503 representation or the parsed tree respectively.
2504
2504
2505 Use --verify-optimized to compare the optimized result with the unoptimized
2505 Use --verify-optimized to compare the optimized result with the unoptimized
2506 one. Returns 1 if the optimized result differs.
2506 one. Returns 1 if the optimized result differs.
2507 """
2507 """
2508 opts = pycompat.byteskwargs(opts)
2508 opts = pycompat.byteskwargs(opts)
2509 aliases = ui.configitems('revsetalias')
2509 aliases = ui.configitems('revsetalias')
2510 stages = [
2510 stages = [
2511 ('parsed', lambda tree: tree),
2511 ('parsed', lambda tree: tree),
2512 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases,
2512 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases,
2513 ui.warn)),
2513 ui.warn)),
2514 ('concatenated', revsetlang.foldconcat),
2514 ('concatenated', revsetlang.foldconcat),
2515 ('analyzed', revsetlang.analyze),
2515 ('analyzed', revsetlang.analyze),
2516 ('optimized', revsetlang.optimize),
2516 ('optimized', revsetlang.optimize),
2517 ]
2517 ]
2518 if opts['no_optimized']:
2518 if opts['no_optimized']:
2519 stages = stages[:-1]
2519 stages = stages[:-1]
2520 if opts['verify_optimized'] and opts['no_optimized']:
2520 if opts['verify_optimized'] and opts['no_optimized']:
2521 raise error.Abort(_('cannot use --verify-optimized with '
2521 raise error.Abort(_('cannot use --verify-optimized with '
2522 '--no-optimized'))
2522 '--no-optimized'))
2523 stagenames = set(n for n, f in stages)
2523 stagenames = set(n for n, f in stages)
2524
2524
2525 showalways = set()
2525 showalways = set()
2526 showchanged = set()
2526 showchanged = set()
2527 if ui.verbose and not opts['show_stage']:
2527 if ui.verbose and not opts['show_stage']:
2528 # show parsed tree by --verbose (deprecated)
2528 # show parsed tree by --verbose (deprecated)
2529 showalways.add('parsed')
2529 showalways.add('parsed')
2530 showchanged.update(['expanded', 'concatenated'])
2530 showchanged.update(['expanded', 'concatenated'])
2531 if opts['optimize']:
2531 if opts['optimize']:
2532 showalways.add('optimized')
2532 showalways.add('optimized')
2533 if opts['show_stage'] and opts['optimize']:
2533 if opts['show_stage'] and opts['optimize']:
2534 raise error.Abort(_('cannot use --optimize with --show-stage'))
2534 raise error.Abort(_('cannot use --optimize with --show-stage'))
2535 if opts['show_stage'] == ['all']:
2535 if opts['show_stage'] == ['all']:
2536 showalways.update(stagenames)
2536 showalways.update(stagenames)
2537 else:
2537 else:
2538 for n in opts['show_stage']:
2538 for n in opts['show_stage']:
2539 if n not in stagenames:
2539 if n not in stagenames:
2540 raise error.Abort(_('invalid stage name: %s') % n)
2540 raise error.Abort(_('invalid stage name: %s') % n)
2541 showalways.update(opts['show_stage'])
2541 showalways.update(opts['show_stage'])
2542
2542
2543 treebystage = {}
2543 treebystage = {}
2544 printedtree = None
2544 printedtree = None
2545 tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
2545 tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
2546 for n, f in stages:
2546 for n, f in stages:
2547 treebystage[n] = tree = f(tree)
2547 treebystage[n] = tree = f(tree)
2548 if n in showalways or (n in showchanged and tree != printedtree):
2548 if n in showalways or (n in showchanged and tree != printedtree):
2549 if opts['show_stage'] or n != 'parsed':
2549 if opts['show_stage'] or n != 'parsed':
2550 ui.write(("* %s:\n") % n)
2550 ui.write(("* %s:\n") % n)
2551 ui.write(revsetlang.prettyformat(tree), "\n")
2551 ui.write(revsetlang.prettyformat(tree), "\n")
2552 printedtree = tree
2552 printedtree = tree
2553
2553
2554 if opts['verify_optimized']:
2554 if opts['verify_optimized']:
2555 arevs = revset.makematcher(treebystage['analyzed'])(repo)
2555 arevs = revset.makematcher(treebystage['analyzed'])(repo)
2556 brevs = revset.makematcher(treebystage['optimized'])(repo)
2556 brevs = revset.makematcher(treebystage['optimized'])(repo)
2557 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2557 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2558 ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n")
2558 ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n")
2559 ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n")
2559 ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n")
2560 arevs = list(arevs)
2560 arevs = list(arevs)
2561 brevs = list(brevs)
2561 brevs = list(brevs)
2562 if arevs == brevs:
2562 if arevs == brevs:
2563 return 0
2563 return 0
2564 ui.write(('--- analyzed\n'), label='diff.file_a')
2564 ui.write(('--- analyzed\n'), label='diff.file_a')
2565 ui.write(('+++ optimized\n'), label='diff.file_b')
2565 ui.write(('+++ optimized\n'), label='diff.file_b')
2566 sm = difflib.SequenceMatcher(None, arevs, brevs)
2566 sm = difflib.SequenceMatcher(None, arevs, brevs)
2567 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2567 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2568 if tag in (r'delete', r'replace'):
2568 if tag in (r'delete', r'replace'):
2569 for c in arevs[alo:ahi]:
2569 for c in arevs[alo:ahi]:
2570 ui.write('-%d\n' % c, label='diff.deleted')
2570 ui.write('-%d\n' % c, label='diff.deleted')
2571 if tag in (r'insert', r'replace'):
2571 if tag in (r'insert', r'replace'):
2572 for c in brevs[blo:bhi]:
2572 for c in brevs[blo:bhi]:
2573 ui.write('+%d\n' % c, label='diff.inserted')
2573 ui.write('+%d\n' % c, label='diff.inserted')
2574 if tag == r'equal':
2574 if tag == r'equal':
2575 for c in arevs[alo:ahi]:
2575 for c in arevs[alo:ahi]:
2576 ui.write(' %d\n' % c)
2576 ui.write(' %d\n' % c)
2577 return 1
2577 return 1
2578
2578
2579 func = revset.makematcher(tree)
2579 func = revset.makematcher(tree)
2580 revs = func(repo)
2580 revs = func(repo)
2581 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2581 if opts['show_set'] or (opts['show_set'] is None and ui.verbose):
2582 ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n")
2582 ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n")
2583 if not opts['show_revs']:
2583 if not opts['show_revs']:
2584 return
2584 return
2585 for c in revs:
2585 for c in revs:
2586 ui.write("%d\n" % c)
2586 ui.write("%d\n" % c)
2587
2587
2588 @command('debugserve', [
2588 @command('debugserve', [
2589 ('', 'sshstdio', False, _('run an SSH server bound to process handles')),
2589 ('', 'sshstdio', False, _('run an SSH server bound to process handles')),
2590 ('', 'logiofd', '', _('file descriptor to log server I/O to')),
2590 ('', 'logiofd', '', _('file descriptor to log server I/O to')),
2591 ('', 'logiofile', '', _('file to log server I/O to')),
2591 ('', 'logiofile', '', _('file to log server I/O to')),
2592 ], '')
2592 ], '')
2593 def debugserve(ui, repo, **opts):
2593 def debugserve(ui, repo, **opts):
2594 """run a server with advanced settings
2594 """run a server with advanced settings
2595
2595
2596 This command is similar to :hg:`serve`. It exists partially as a
2596 This command is similar to :hg:`serve`. It exists partially as a
2597 workaround to the fact that ``hg serve --stdio`` must have specific
2597 workaround to the fact that ``hg serve --stdio`` must have specific
2598 arguments for security reasons.
2598 arguments for security reasons.
2599 """
2599 """
2600 opts = pycompat.byteskwargs(opts)
2600 opts = pycompat.byteskwargs(opts)
2601
2601
2602 if not opts['sshstdio']:
2602 if not opts['sshstdio']:
2603 raise error.Abort(_('only --sshstdio is currently supported'))
2603 raise error.Abort(_('only --sshstdio is currently supported'))
2604
2604
2605 logfh = None
2605 logfh = None
2606
2606
2607 if opts['logiofd'] and opts['logiofile']:
2607 if opts['logiofd'] and opts['logiofile']:
2608 raise error.Abort(_('cannot use both --logiofd and --logiofile'))
2608 raise error.Abort(_('cannot use both --logiofd and --logiofile'))
2609
2609
2610 if opts['logiofd']:
2610 if opts['logiofd']:
2611 # Line buffered because output is line based.
2611 # Line buffered because output is line based.
2612 try:
2612 try:
2613 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1)
2613 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1)
2614 except OSError as e:
2614 except OSError as e:
2615 if e.errno != errno.ESPIPE:
2615 if e.errno != errno.ESPIPE:
2616 raise
2616 raise
2617 # can't seek a pipe, so `ab` mode fails on py3
2617 # can't seek a pipe, so `ab` mode fails on py3
2618 logfh = os.fdopen(int(opts['logiofd']), r'wb', 1)
2618 logfh = os.fdopen(int(opts['logiofd']), r'wb', 1)
2619 elif opts['logiofile']:
2619 elif opts['logiofile']:
2620 logfh = open(opts['logiofile'], 'ab', 1)
2620 logfh = open(opts['logiofile'], 'ab', 1)
2621
2621
2622 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
2622 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
2623 s.serve_forever()
2623 s.serve_forever()
2624
2624
2625 @command('debugsetparents', [], _('REV1 [REV2]'))
2625 @command('debugsetparents', [], _('REV1 [REV2]'))
2626 def debugsetparents(ui, repo, rev1, rev2=None):
2626 def debugsetparents(ui, repo, rev1, rev2=None):
2627 """manually set the parents of the current working directory
2627 """manually set the parents of the current working directory
2628
2628
2629 This is useful for writing repository conversion tools, but should
2629 This is useful for writing repository conversion tools, but should
2630 be used with care. For example, neither the working directory nor the
2630 be used with care. For example, neither the working directory nor the
2631 dirstate is updated, so file status may be incorrect after running this
2631 dirstate is updated, so file status may be incorrect after running this
2632 command.
2632 command.
2633
2633
2634 Returns 0 on success.
2634 Returns 0 on success.
2635 """
2635 """
2636
2636
2637 node1 = scmutil.revsingle(repo, rev1).node()
2637 node1 = scmutil.revsingle(repo, rev1).node()
2638 node2 = scmutil.revsingle(repo, rev2, 'null').node()
2638 node2 = scmutil.revsingle(repo, rev2, 'null').node()
2639
2639
2640 with repo.wlock():
2640 with repo.wlock():
2641 repo.setparents(node1, node2)
2641 repo.setparents(node1, node2)
2642
2642
2643 @command('debugsidedata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV'))
2644 def debugsidedata(ui, repo, file_, rev=None, **opts):
2645 """dump the side data for a cl/manifest/file revision"""
2646 opts = pycompat.byteskwargs(opts)
2647 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
2648 if rev is not None:
2649 raise error.CommandError('debugdata', _('invalid arguments'))
2650 file_, rev = None, file_
2651 elif rev is None:
2652 raise error.CommandError('debugdata', _('invalid arguments'))
2653 r = cmdutil.openstorage(repo, 'debugdata', file_, opts)
2654 r = getattr(r, '_revlog', r)
2655 try:
2656 sidedata = r.sidedata(r.lookup(rev))
2657 except KeyError:
2658 raise error.Abort(_('invalid revision identifier %s') % rev)
2659 if sidedata:
2660 sidedata = list(sidedata.items())
2661 sidedata.sort()
2662 ui.write(('%d sidedata entries\n' % len(sidedata)))
2663 for key, value in sidedata:
2664 ui.write((' entry-%04o size %d\n' % (key, len(value))))
2665 if ui.verbose:
2666 ui.write((' %s\n' % repr(value)))
2667
2643 @command('debugssl', [], '[SOURCE]', optionalrepo=True)
2668 @command('debugssl', [], '[SOURCE]', optionalrepo=True)
2644 def debugssl(ui, repo, source=None, **opts):
2669 def debugssl(ui, repo, source=None, **opts):
2645 '''test a secure connection to a server
2670 '''test a secure connection to a server
2646
2671
2647 This builds the certificate chain for the server on Windows, installing the
2672 This builds the certificate chain for the server on Windows, installing the
2648 missing intermediates and trusted root via Windows Update if necessary. It
2673 missing intermediates and trusted root via Windows Update if necessary. It
2649 does nothing on other platforms.
2674 does nothing on other platforms.
2650
2675
2651 If SOURCE is omitted, the 'default' path will be used. If a URL is given,
2676 If SOURCE is omitted, the 'default' path will be used. If a URL is given,
2652 that server is used. See :hg:`help urls` for more information.
2677 that server is used. See :hg:`help urls` for more information.
2653
2678
2654 If the update succeeds, retry the original operation. Otherwise, the cause
2679 If the update succeeds, retry the original operation. Otherwise, the cause
2655 of the SSL error is likely another issue.
2680 of the SSL error is likely another issue.
2656 '''
2681 '''
2657 if not pycompat.iswindows:
2682 if not pycompat.iswindows:
2658 raise error.Abort(_('certificate chain building is only possible on '
2683 raise error.Abort(_('certificate chain building is only possible on '
2659 'Windows'))
2684 'Windows'))
2660
2685
2661 if not source:
2686 if not source:
2662 if not repo:
2687 if not repo:
2663 raise error.Abort(_("there is no Mercurial repository here, and no "
2688 raise error.Abort(_("there is no Mercurial repository here, and no "
2664 "server specified"))
2689 "server specified"))
2665 source = "default"
2690 source = "default"
2666
2691
2667 source, branches = hg.parseurl(ui.expandpath(source))
2692 source, branches = hg.parseurl(ui.expandpath(source))
2668 url = util.url(source)
2693 url = util.url(source)
2669
2694
2670 defaultport = {'https': 443, 'ssh': 22}
2695 defaultport = {'https': 443, 'ssh': 22}
2671 if url.scheme in defaultport:
2696 if url.scheme in defaultport:
2672 try:
2697 try:
2673 addr = (url.host, int(url.port or defaultport[url.scheme]))
2698 addr = (url.host, int(url.port or defaultport[url.scheme]))
2674 except ValueError:
2699 except ValueError:
2675 raise error.Abort(_("malformed port number in URL"))
2700 raise error.Abort(_("malformed port number in URL"))
2676 else:
2701 else:
2677 raise error.Abort(_("only https and ssh connections are supported"))
2702 raise error.Abort(_("only https and ssh connections are supported"))
2678
2703
2679 from . import win32
2704 from . import win32
2680
2705
2681 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
2706 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
2682 cert_reqs=ssl.CERT_NONE, ca_certs=None)
2707 cert_reqs=ssl.CERT_NONE, ca_certs=None)
2683
2708
2684 try:
2709 try:
2685 s.connect(addr)
2710 s.connect(addr)
2686 cert = s.getpeercert(True)
2711 cert = s.getpeercert(True)
2687
2712
2688 ui.status(_('checking the certificate chain for %s\n') % url.host)
2713 ui.status(_('checking the certificate chain for %s\n') % url.host)
2689
2714
2690 complete = win32.checkcertificatechain(cert, build=False)
2715 complete = win32.checkcertificatechain(cert, build=False)
2691
2716
2692 if not complete:
2717 if not complete:
2693 ui.status(_('certificate chain is incomplete, updating... '))
2718 ui.status(_('certificate chain is incomplete, updating... '))
2694
2719
2695 if not win32.checkcertificatechain(cert):
2720 if not win32.checkcertificatechain(cert):
2696 ui.status(_('failed.\n'))
2721 ui.status(_('failed.\n'))
2697 else:
2722 else:
2698 ui.status(_('done.\n'))
2723 ui.status(_('done.\n'))
2699 else:
2724 else:
2700 ui.status(_('full certificate chain is available\n'))
2725 ui.status(_('full certificate chain is available\n'))
2701 finally:
2726 finally:
2702 s.close()
2727 s.close()
2703
2728
2704 @command('debugsub',
2729 @command('debugsub',
2705 [('r', 'rev', '',
2730 [('r', 'rev', '',
2706 _('revision to check'), _('REV'))],
2731 _('revision to check'), _('REV'))],
2707 _('[-r REV] [REV]'))
2732 _('[-r REV] [REV]'))
2708 def debugsub(ui, repo, rev=None):
2733 def debugsub(ui, repo, rev=None):
2709 ctx = scmutil.revsingle(repo, rev, None)
2734 ctx = scmutil.revsingle(repo, rev, None)
2710 for k, v in sorted(ctx.substate.items()):
2735 for k, v in sorted(ctx.substate.items()):
2711 ui.write(('path %s\n') % k)
2736 ui.write(('path %s\n') % k)
2712 ui.write((' source %s\n') % v[0])
2737 ui.write((' source %s\n') % v[0])
2713 ui.write((' revision %s\n') % v[1])
2738 ui.write((' revision %s\n') % v[1])
2714
2739
2715 @command('debugsuccessorssets',
2740 @command('debugsuccessorssets',
2716 [('', 'closest', False, _('return closest successors sets only'))],
2741 [('', 'closest', False, _('return closest successors sets only'))],
2717 _('[REV]'))
2742 _('[REV]'))
2718 def debugsuccessorssets(ui, repo, *revs, **opts):
2743 def debugsuccessorssets(ui, repo, *revs, **opts):
2719 """show set of successors for revision
2744 """show set of successors for revision
2720
2745
2721 A successors set of changeset A is a consistent group of revisions that
2746 A successors set of changeset A is a consistent group of revisions that
2722 succeed A. It contains non-obsolete changesets only unless closests
2747 succeed A. It contains non-obsolete changesets only unless closests
2723 successors set is set.
2748 successors set is set.
2724
2749
2725 In most cases a changeset A has a single successors set containing a single
2750 In most cases a changeset A has a single successors set containing a single
2726 successor (changeset A replaced by A').
2751 successor (changeset A replaced by A').
2727
2752
2728 A changeset that is made obsolete with no successors are called "pruned".
2753 A changeset that is made obsolete with no successors are called "pruned".
2729 Such changesets have no successors sets at all.
2754 Such changesets have no successors sets at all.
2730
2755
2731 A changeset that has been "split" will have a successors set containing
2756 A changeset that has been "split" will have a successors set containing
2732 more than one successor.
2757 more than one successor.
2733
2758
2734 A changeset that has been rewritten in multiple different ways is called
2759 A changeset that has been rewritten in multiple different ways is called
2735 "divergent". Such changesets have multiple successor sets (each of which
2760 "divergent". Such changesets have multiple successor sets (each of which
2736 may also be split, i.e. have multiple successors).
2761 may also be split, i.e. have multiple successors).
2737
2762
2738 Results are displayed as follows::
2763 Results are displayed as follows::
2739
2764
2740 <rev1>
2765 <rev1>
2741 <successors-1A>
2766 <successors-1A>
2742 <rev2>
2767 <rev2>
2743 <successors-2A>
2768 <successors-2A>
2744 <successors-2B1> <successors-2B2> <successors-2B3>
2769 <successors-2B1> <successors-2B2> <successors-2B3>
2745
2770
2746 Here rev2 has two possible (i.e. divergent) successors sets. The first
2771 Here rev2 has two possible (i.e. divergent) successors sets. The first
2747 holds one element, whereas the second holds three (i.e. the changeset has
2772 holds one element, whereas the second holds three (i.e. the changeset has
2748 been split).
2773 been split).
2749 """
2774 """
2750 # passed to successorssets caching computation from one call to another
2775 # passed to successorssets caching computation from one call to another
2751 cache = {}
2776 cache = {}
2752 ctx2str = bytes
2777 ctx2str = bytes
2753 node2str = short
2778 node2str = short
2754 for rev in scmutil.revrange(repo, revs):
2779 for rev in scmutil.revrange(repo, revs):
2755 ctx = repo[rev]
2780 ctx = repo[rev]
2756 ui.write('%s\n'% ctx2str(ctx))
2781 ui.write('%s\n'% ctx2str(ctx))
2757 for succsset in obsutil.successorssets(repo, ctx.node(),
2782 for succsset in obsutil.successorssets(repo, ctx.node(),
2758 closest=opts[r'closest'],
2783 closest=opts[r'closest'],
2759 cache=cache):
2784 cache=cache):
2760 if succsset:
2785 if succsset:
2761 ui.write(' ')
2786 ui.write(' ')
2762 ui.write(node2str(succsset[0]))
2787 ui.write(node2str(succsset[0]))
2763 for node in succsset[1:]:
2788 for node in succsset[1:]:
2764 ui.write(' ')
2789 ui.write(' ')
2765 ui.write(node2str(node))
2790 ui.write(node2str(node))
2766 ui.write('\n')
2791 ui.write('\n')
2767
2792
2768 @command('debugtemplate',
2793 @command('debugtemplate',
2769 [('r', 'rev', [], _('apply template on changesets'), _('REV')),
2794 [('r', 'rev', [], _('apply template on changesets'), _('REV')),
2770 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))],
2795 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))],
2771 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'),
2796 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'),
2772 optionalrepo=True)
2797 optionalrepo=True)
2773 def debugtemplate(ui, repo, tmpl, **opts):
2798 def debugtemplate(ui, repo, tmpl, **opts):
2774 """parse and apply a template
2799 """parse and apply a template
2775
2800
2776 If -r/--rev is given, the template is processed as a log template and
2801 If -r/--rev is given, the template is processed as a log template and
2777 applied to the given changesets. Otherwise, it is processed as a generic
2802 applied to the given changesets. Otherwise, it is processed as a generic
2778 template.
2803 template.
2779
2804
2780 Use --verbose to print the parsed tree.
2805 Use --verbose to print the parsed tree.
2781 """
2806 """
2782 revs = None
2807 revs = None
2783 if opts[r'rev']:
2808 if opts[r'rev']:
2784 if repo is None:
2809 if repo is None:
2785 raise error.RepoError(_('there is no Mercurial repository here '
2810 raise error.RepoError(_('there is no Mercurial repository here '
2786 '(.hg not found)'))
2811 '(.hg not found)'))
2787 revs = scmutil.revrange(repo, opts[r'rev'])
2812 revs = scmutil.revrange(repo, opts[r'rev'])
2788
2813
2789 props = {}
2814 props = {}
2790 for d in opts[r'define']:
2815 for d in opts[r'define']:
2791 try:
2816 try:
2792 k, v = (e.strip() for e in d.split('=', 1))
2817 k, v = (e.strip() for e in d.split('=', 1))
2793 if not k or k == 'ui':
2818 if not k or k == 'ui':
2794 raise ValueError
2819 raise ValueError
2795 props[k] = v
2820 props[k] = v
2796 except ValueError:
2821 except ValueError:
2797 raise error.Abort(_('malformed keyword definition: %s') % d)
2822 raise error.Abort(_('malformed keyword definition: %s') % d)
2798
2823
2799 if ui.verbose:
2824 if ui.verbose:
2800 aliases = ui.configitems('templatealias')
2825 aliases = ui.configitems('templatealias')
2801 tree = templater.parse(tmpl)
2826 tree = templater.parse(tmpl)
2802 ui.note(templater.prettyformat(tree), '\n')
2827 ui.note(templater.prettyformat(tree), '\n')
2803 newtree = templater.expandaliases(tree, aliases)
2828 newtree = templater.expandaliases(tree, aliases)
2804 if newtree != tree:
2829 if newtree != tree:
2805 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2830 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2806
2831
2807 if revs is None:
2832 if revs is None:
2808 tres = formatter.templateresources(ui, repo)
2833 tres = formatter.templateresources(ui, repo)
2809 t = formatter.maketemplater(ui, tmpl, resources=tres)
2834 t = formatter.maketemplater(ui, tmpl, resources=tres)
2810 if ui.verbose:
2835 if ui.verbose:
2811 kwds, funcs = t.symbolsuseddefault()
2836 kwds, funcs = t.symbolsuseddefault()
2812 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds)))
2837 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds)))
2813 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs)))
2838 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs)))
2814 ui.write(t.renderdefault(props))
2839 ui.write(t.renderdefault(props))
2815 else:
2840 else:
2816 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2841 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2817 if ui.verbose:
2842 if ui.verbose:
2818 kwds, funcs = displayer.t.symbolsuseddefault()
2843 kwds, funcs = displayer.t.symbolsuseddefault()
2819 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds)))
2844 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds)))
2820 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs)))
2845 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs)))
2821 for r in revs:
2846 for r in revs:
2822 displayer.show(repo[r], **pycompat.strkwargs(props))
2847 displayer.show(repo[r], **pycompat.strkwargs(props))
2823 displayer.close()
2848 displayer.close()
2824
2849
2825 @command('debuguigetpass', [
2850 @command('debuguigetpass', [
2826 ('p', 'prompt', '', _('prompt text'), _('TEXT')),
2851 ('p', 'prompt', '', _('prompt text'), _('TEXT')),
2827 ], _('[-p TEXT]'), norepo=True)
2852 ], _('[-p TEXT]'), norepo=True)
2828 def debuguigetpass(ui, prompt=''):
2853 def debuguigetpass(ui, prompt=''):
2829 """show prompt to type password"""
2854 """show prompt to type password"""
2830 r = ui.getpass(prompt)
2855 r = ui.getpass(prompt)
2831 ui.write(('respose: %s\n') % r)
2856 ui.write(('respose: %s\n') % r)
2832
2857
2833 @command('debuguiprompt', [
2858 @command('debuguiprompt', [
2834 ('p', 'prompt', '', _('prompt text'), _('TEXT')),
2859 ('p', 'prompt', '', _('prompt text'), _('TEXT')),
2835 ], _('[-p TEXT]'), norepo=True)
2860 ], _('[-p TEXT]'), norepo=True)
2836 def debuguiprompt(ui, prompt=''):
2861 def debuguiprompt(ui, prompt=''):
2837 """show plain prompt"""
2862 """show plain prompt"""
2838 r = ui.prompt(prompt)
2863 r = ui.prompt(prompt)
2839 ui.write(('response: %s\n') % r)
2864 ui.write(('response: %s\n') % r)
2840
2865
2841 @command('debugupdatecaches', [])
2866 @command('debugupdatecaches', [])
2842 def debugupdatecaches(ui, repo, *pats, **opts):
2867 def debugupdatecaches(ui, repo, *pats, **opts):
2843 """warm all known caches in the repository"""
2868 """warm all known caches in the repository"""
2844 with repo.wlock(), repo.lock():
2869 with repo.wlock(), repo.lock():
2845 repo.updatecaches(full=True)
2870 repo.updatecaches(full=True)
2846
2871
2847 @command('debugupgraderepo', [
2872 @command('debugupgraderepo', [
2848 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
2873 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
2849 ('', 'run', False, _('performs an upgrade')),
2874 ('', 'run', False, _('performs an upgrade')),
2850 ('', 'backup', True, _('keep the old repository content around')),
2875 ('', 'backup', True, _('keep the old repository content around')),
2851 ('', 'changelog', None, _('select the changelog for upgrade')),
2876 ('', 'changelog', None, _('select the changelog for upgrade')),
2852 ('', 'manifest', None, _('select the manifest for upgrade')),
2877 ('', 'manifest', None, _('select the manifest for upgrade')),
2853 ])
2878 ])
2854 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts):
2879 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts):
2855 """upgrade a repository to use different features
2880 """upgrade a repository to use different features
2856
2881
2857 If no arguments are specified, the repository is evaluated for upgrade
2882 If no arguments are specified, the repository is evaluated for upgrade
2858 and a list of problems and potential optimizations is printed.
2883 and a list of problems and potential optimizations is printed.
2859
2884
2860 With ``--run``, a repository upgrade is performed. Behavior of the upgrade
2885 With ``--run``, a repository upgrade is performed. Behavior of the upgrade
2861 can be influenced via additional arguments. More details will be provided
2886 can be influenced via additional arguments. More details will be provided
2862 by the command output when run without ``--run``.
2887 by the command output when run without ``--run``.
2863
2888
2864 During the upgrade, the repository will be locked and no writes will be
2889 During the upgrade, the repository will be locked and no writes will be
2865 allowed.
2890 allowed.
2866
2891
2867 At the end of the upgrade, the repository may not be readable while new
2892 At the end of the upgrade, the repository may not be readable while new
2868 repository data is swapped in. This window will be as long as it takes to
2893 repository data is swapped in. This window will be as long as it takes to
2869 rename some directories inside the ``.hg`` directory. On most machines, this
2894 rename some directories inside the ``.hg`` directory. On most machines, this
2870 should complete almost instantaneously and the chances of a consumer being
2895 should complete almost instantaneously and the chances of a consumer being
2871 unable to access the repository should be low.
2896 unable to access the repository should be low.
2872
2897
2873 By default, all revlog will be upgraded. You can restrict this using flag
2898 By default, all revlog will be upgraded. You can restrict this using flag
2874 such as `--manifest`:
2899 such as `--manifest`:
2875
2900
2876 * `--manifest`: only optimize the manifest
2901 * `--manifest`: only optimize the manifest
2877 * `--no-manifest`: optimize all revlog but the manifest
2902 * `--no-manifest`: optimize all revlog but the manifest
2878 * `--changelog`: optimize the changelog only
2903 * `--changelog`: optimize the changelog only
2879 * `--no-changelog --no-manifest`: optimize filelogs only
2904 * `--no-changelog --no-manifest`: optimize filelogs only
2880 """
2905 """
2881 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize,
2906 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize,
2882 backup=backup, **opts)
2907 backup=backup, **opts)
2883
2908
2884 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'),
2909 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'),
2885 inferrepo=True)
2910 inferrepo=True)
2886 def debugwalk(ui, repo, *pats, **opts):
2911 def debugwalk(ui, repo, *pats, **opts):
2887 """show how files match on given patterns"""
2912 """show how files match on given patterns"""
2888 opts = pycompat.byteskwargs(opts)
2913 opts = pycompat.byteskwargs(opts)
2889 m = scmutil.match(repo[None], pats, opts)
2914 m = scmutil.match(repo[None], pats, opts)
2890 if ui.verbose:
2915 if ui.verbose:
2891 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n')
2916 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n')
2892 items = list(repo[None].walk(m))
2917 items = list(repo[None].walk(m))
2893 if not items:
2918 if not items:
2894 return
2919 return
2895 f = lambda fn: fn
2920 f = lambda fn: fn
2896 if ui.configbool('ui', 'slash') and pycompat.ossep != '/':
2921 if ui.configbool('ui', 'slash') and pycompat.ossep != '/':
2897 f = lambda fn: util.normpath(fn)
2922 f = lambda fn: util.normpath(fn)
2898 fmt = 'f %%-%ds %%-%ds %%s' % (
2923 fmt = 'f %%-%ds %%-%ds %%s' % (
2899 max([len(abs) for abs in items]),
2924 max([len(abs) for abs in items]),
2900 max([len(repo.pathto(abs)) for abs in items]))
2925 max([len(repo.pathto(abs)) for abs in items]))
2901 for abs in items:
2926 for abs in items:
2902 line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '')
2927 line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '')
2903 ui.write("%s\n" % line.rstrip())
2928 ui.write("%s\n" % line.rstrip())
2904
2929
2905 @command('debugwhyunstable', [], _('REV'))
2930 @command('debugwhyunstable', [], _('REV'))
2906 def debugwhyunstable(ui, repo, rev):
2931 def debugwhyunstable(ui, repo, rev):
2907 """explain instabilities of a changeset"""
2932 """explain instabilities of a changeset"""
2908 for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)):
2933 for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)):
2909 dnodes = ''
2934 dnodes = ''
2910 if entry.get('divergentnodes'):
2935 if entry.get('divergentnodes'):
2911 dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr())
2936 dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr())
2912 for ctx in entry['divergentnodes']) + ' '
2937 for ctx in entry['divergentnodes']) + ' '
2913 ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes,
2938 ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes,
2914 entry['reason'], entry['node']))
2939 entry['reason'], entry['node']))
2915
2940
2916 @command('debugwireargs',
2941 @command('debugwireargs',
2917 [('', 'three', '', 'three'),
2942 [('', 'three', '', 'three'),
2918 ('', 'four', '', 'four'),
2943 ('', 'four', '', 'four'),
2919 ('', 'five', '', 'five'),
2944 ('', 'five', '', 'five'),
2920 ] + cmdutil.remoteopts,
2945 ] + cmdutil.remoteopts,
2921 _('REPO [OPTIONS]... [ONE [TWO]]'),
2946 _('REPO [OPTIONS]... [ONE [TWO]]'),
2922 norepo=True)
2947 norepo=True)
2923 def debugwireargs(ui, repopath, *vals, **opts):
2948 def debugwireargs(ui, repopath, *vals, **opts):
2924 opts = pycompat.byteskwargs(opts)
2949 opts = pycompat.byteskwargs(opts)
2925 repo = hg.peer(ui, opts, repopath)
2950 repo = hg.peer(ui, opts, repopath)
2926 for opt in cmdutil.remoteopts:
2951 for opt in cmdutil.remoteopts:
2927 del opts[opt[1]]
2952 del opts[opt[1]]
2928 args = {}
2953 args = {}
2929 for k, v in opts.iteritems():
2954 for k, v in opts.iteritems():
2930 if v:
2955 if v:
2931 args[k] = v
2956 args[k] = v
2932 args = pycompat.strkwargs(args)
2957 args = pycompat.strkwargs(args)
2933 # run twice to check that we don't mess up the stream for the next command
2958 # run twice to check that we don't mess up the stream for the next command
2934 res1 = repo.debugwireargs(*vals, **args)
2959 res1 = repo.debugwireargs(*vals, **args)
2935 res2 = repo.debugwireargs(*vals, **args)
2960 res2 = repo.debugwireargs(*vals, **args)
2936 ui.write("%s\n" % res1)
2961 ui.write("%s\n" % res1)
2937 if res1 != res2:
2962 if res1 != res2:
2938 ui.warn("%s\n" % res2)
2963 ui.warn("%s\n" % res2)
2939
2964
2940 def _parsewirelangblocks(fh):
2965 def _parsewirelangblocks(fh):
2941 activeaction = None
2966 activeaction = None
2942 blocklines = []
2967 blocklines = []
2943 lastindent = 0
2968 lastindent = 0
2944
2969
2945 for line in fh:
2970 for line in fh:
2946 line = line.rstrip()
2971 line = line.rstrip()
2947 if not line:
2972 if not line:
2948 continue
2973 continue
2949
2974
2950 if line.startswith(b'#'):
2975 if line.startswith(b'#'):
2951 continue
2976 continue
2952
2977
2953 if not line.startswith(b' '):
2978 if not line.startswith(b' '):
2954 # New block. Flush previous one.
2979 # New block. Flush previous one.
2955 if activeaction:
2980 if activeaction:
2956 yield activeaction, blocklines
2981 yield activeaction, blocklines
2957
2982
2958 activeaction = line
2983 activeaction = line
2959 blocklines = []
2984 blocklines = []
2960 lastindent = 0
2985 lastindent = 0
2961 continue
2986 continue
2962
2987
2963 # Else we start with an indent.
2988 # Else we start with an indent.
2964
2989
2965 if not activeaction:
2990 if not activeaction:
2966 raise error.Abort(_('indented line outside of block'))
2991 raise error.Abort(_('indented line outside of block'))
2967
2992
2968 indent = len(line) - len(line.lstrip())
2993 indent = len(line) - len(line.lstrip())
2969
2994
2970 # If this line is indented more than the last line, concatenate it.
2995 # If this line is indented more than the last line, concatenate it.
2971 if indent > lastindent and blocklines:
2996 if indent > lastindent and blocklines:
2972 blocklines[-1] += line.lstrip()
2997 blocklines[-1] += line.lstrip()
2973 else:
2998 else:
2974 blocklines.append(line)
2999 blocklines.append(line)
2975 lastindent = indent
3000 lastindent = indent
2976
3001
2977 # Flush last block.
3002 # Flush last block.
2978 if activeaction:
3003 if activeaction:
2979 yield activeaction, blocklines
3004 yield activeaction, blocklines
2980
3005
2981 @command('debugwireproto',
3006 @command('debugwireproto',
2982 [
3007 [
2983 ('', 'localssh', False, _('start an SSH server for this repo')),
3008 ('', 'localssh', False, _('start an SSH server for this repo')),
2984 ('', 'peer', '', _('construct a specific version of the peer')),
3009 ('', 'peer', '', _('construct a specific version of the peer')),
2985 ('', 'noreadstderr', False, _('do not read from stderr of the remote')),
3010 ('', 'noreadstderr', False, _('do not read from stderr of the remote')),
2986 ('', 'nologhandshake', False,
3011 ('', 'nologhandshake', False,
2987 _('do not log I/O related to the peer handshake')),
3012 _('do not log I/O related to the peer handshake')),
2988 ] + cmdutil.remoteopts,
3013 ] + cmdutil.remoteopts,
2989 _('[PATH]'),
3014 _('[PATH]'),
2990 optionalrepo=True)
3015 optionalrepo=True)
2991 def debugwireproto(ui, repo, path=None, **opts):
3016 def debugwireproto(ui, repo, path=None, **opts):
2992 """send wire protocol commands to a server
3017 """send wire protocol commands to a server
2993
3018
2994 This command can be used to issue wire protocol commands to remote
3019 This command can be used to issue wire protocol commands to remote
2995 peers and to debug the raw data being exchanged.
3020 peers and to debug the raw data being exchanged.
2996
3021
2997 ``--localssh`` will start an SSH server against the current repository
3022 ``--localssh`` will start an SSH server against the current repository
2998 and connect to that. By default, the connection will perform a handshake
3023 and connect to that. By default, the connection will perform a handshake
2999 and establish an appropriate peer instance.
3024 and establish an appropriate peer instance.
3000
3025
3001 ``--peer`` can be used to bypass the handshake protocol and construct a
3026 ``--peer`` can be used to bypass the handshake protocol and construct a
3002 peer instance using the specified class type. Valid values are ``raw``,
3027 peer instance using the specified class type. Valid values are ``raw``,
3003 ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending
3028 ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending
3004 raw data payloads and don't support higher-level command actions.
3029 raw data payloads and don't support higher-level command actions.
3005
3030
3006 ``--noreadstderr`` can be used to disable automatic reading from stderr
3031 ``--noreadstderr`` can be used to disable automatic reading from stderr
3007 of the peer (for SSH connections only). Disabling automatic reading of
3032 of the peer (for SSH connections only). Disabling automatic reading of
3008 stderr is useful for making output more deterministic.
3033 stderr is useful for making output more deterministic.
3009
3034
3010 Commands are issued via a mini language which is specified via stdin.
3035 Commands are issued via a mini language which is specified via stdin.
3011 The language consists of individual actions to perform. An action is
3036 The language consists of individual actions to perform. An action is
3012 defined by a block. A block is defined as a line with no leading
3037 defined by a block. A block is defined as a line with no leading
3013 space followed by 0 or more lines with leading space. Blocks are
3038 space followed by 0 or more lines with leading space. Blocks are
3014 effectively a high-level command with additional metadata.
3039 effectively a high-level command with additional metadata.
3015
3040
3016 Lines beginning with ``#`` are ignored.
3041 Lines beginning with ``#`` are ignored.
3017
3042
3018 The following sections denote available actions.
3043 The following sections denote available actions.
3019
3044
3020 raw
3045 raw
3021 ---
3046 ---
3022
3047
3023 Send raw data to the server.
3048 Send raw data to the server.
3024
3049
3025 The block payload contains the raw data to send as one atomic send
3050 The block payload contains the raw data to send as one atomic send
3026 operation. The data may not actually be delivered in a single system
3051 operation. The data may not actually be delivered in a single system
3027 call: it depends on the abilities of the transport being used.
3052 call: it depends on the abilities of the transport being used.
3028
3053
3029 Each line in the block is de-indented and concatenated. Then, that
3054 Each line in the block is de-indented and concatenated. Then, that
3030 value is evaluated as a Python b'' literal. This allows the use of
3055 value is evaluated as a Python b'' literal. This allows the use of
3031 backslash escaping, etc.
3056 backslash escaping, etc.
3032
3057
3033 raw+
3058 raw+
3034 ----
3059 ----
3035
3060
3036 Behaves like ``raw`` except flushes output afterwards.
3061 Behaves like ``raw`` except flushes output afterwards.
3037
3062
3038 command <X>
3063 command <X>
3039 -----------
3064 -----------
3040
3065
3041 Send a request to run a named command, whose name follows the ``command``
3066 Send a request to run a named command, whose name follows the ``command``
3042 string.
3067 string.
3043
3068
3044 Arguments to the command are defined as lines in this block. The format of
3069 Arguments to the command are defined as lines in this block. The format of
3045 each line is ``<key> <value>``. e.g.::
3070 each line is ``<key> <value>``. e.g.::
3046
3071
3047 command listkeys
3072 command listkeys
3048 namespace bookmarks
3073 namespace bookmarks
3049
3074
3050 If the value begins with ``eval:``, it will be interpreted as a Python
3075 If the value begins with ``eval:``, it will be interpreted as a Python
3051 literal expression. Otherwise values are interpreted as Python b'' literals.
3076 literal expression. Otherwise values are interpreted as Python b'' literals.
3052 This allows sending complex types and encoding special byte sequences via
3077 This allows sending complex types and encoding special byte sequences via
3053 backslash escaping.
3078 backslash escaping.
3054
3079
3055 The following arguments have special meaning:
3080 The following arguments have special meaning:
3056
3081
3057 ``PUSHFILE``
3082 ``PUSHFILE``
3058 When defined, the *push* mechanism of the peer will be used instead
3083 When defined, the *push* mechanism of the peer will be used instead
3059 of the static request-response mechanism and the content of the
3084 of the static request-response mechanism and the content of the
3060 file specified in the value of this argument will be sent as the
3085 file specified in the value of this argument will be sent as the
3061 command payload.
3086 command payload.
3062
3087
3063 This can be used to submit a local bundle file to the remote.
3088 This can be used to submit a local bundle file to the remote.
3064
3089
3065 batchbegin
3090 batchbegin
3066 ----------
3091 ----------
3067
3092
3068 Instruct the peer to begin a batched send.
3093 Instruct the peer to begin a batched send.
3069
3094
3070 All ``command`` blocks are queued for execution until the next
3095 All ``command`` blocks are queued for execution until the next
3071 ``batchsubmit`` block.
3096 ``batchsubmit`` block.
3072
3097
3073 batchsubmit
3098 batchsubmit
3074 -----------
3099 -----------
3075
3100
3076 Submit previously queued ``command`` blocks as a batch request.
3101 Submit previously queued ``command`` blocks as a batch request.
3077
3102
3078 This action MUST be paired with a ``batchbegin`` action.
3103 This action MUST be paired with a ``batchbegin`` action.
3079
3104
3080 httprequest <method> <path>
3105 httprequest <method> <path>
3081 ---------------------------
3106 ---------------------------
3082
3107
3083 (HTTP peer only)
3108 (HTTP peer only)
3084
3109
3085 Send an HTTP request to the peer.
3110 Send an HTTP request to the peer.
3086
3111
3087 The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``.
3112 The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``.
3088
3113
3089 Arguments of the form ``<key>: <value>`` are interpreted as HTTP request
3114 Arguments of the form ``<key>: <value>`` are interpreted as HTTP request
3090 headers to add to the request. e.g. ``Accept: foo``.
3115 headers to add to the request. e.g. ``Accept: foo``.
3091
3116
3092 The following arguments are special:
3117 The following arguments are special:
3093
3118
3094 ``BODYFILE``
3119 ``BODYFILE``
3095 The content of the file defined as the value to this argument will be
3120 The content of the file defined as the value to this argument will be
3096 transferred verbatim as the HTTP request body.
3121 transferred verbatim as the HTTP request body.
3097
3122
3098 ``frame <type> <flags> <payload>``
3123 ``frame <type> <flags> <payload>``
3099 Send a unified protocol frame as part of the request body.
3124 Send a unified protocol frame as part of the request body.
3100
3125
3101 All frames will be collected and sent as the body to the HTTP
3126 All frames will be collected and sent as the body to the HTTP
3102 request.
3127 request.
3103
3128
3104 close
3129 close
3105 -----
3130 -----
3106
3131
3107 Close the connection to the server.
3132 Close the connection to the server.
3108
3133
3109 flush
3134 flush
3110 -----
3135 -----
3111
3136
3112 Flush data written to the server.
3137 Flush data written to the server.
3113
3138
3114 readavailable
3139 readavailable
3115 -------------
3140 -------------
3116
3141
3117 Close the write end of the connection and read all available data from
3142 Close the write end of the connection and read all available data from
3118 the server.
3143 the server.
3119
3144
3120 If the connection to the server encompasses multiple pipes, we poll both
3145 If the connection to the server encompasses multiple pipes, we poll both
3121 pipes and read available data.
3146 pipes and read available data.
3122
3147
3123 readline
3148 readline
3124 --------
3149 --------
3125
3150
3126 Read a line of output from the server. If there are multiple output
3151 Read a line of output from the server. If there are multiple output
3127 pipes, reads only the main pipe.
3152 pipes, reads only the main pipe.
3128
3153
3129 ereadline
3154 ereadline
3130 ---------
3155 ---------
3131
3156
3132 Like ``readline``, but read from the stderr pipe, if available.
3157 Like ``readline``, but read from the stderr pipe, if available.
3133
3158
3134 read <X>
3159 read <X>
3135 --------
3160 --------
3136
3161
3137 ``read()`` N bytes from the server's main output pipe.
3162 ``read()`` N bytes from the server's main output pipe.
3138
3163
3139 eread <X>
3164 eread <X>
3140 ---------
3165 ---------
3141
3166
3142 ``read()`` N bytes from the server's stderr pipe, if available.
3167 ``read()`` N bytes from the server's stderr pipe, if available.
3143
3168
3144 Specifying Unified Frame-Based Protocol Frames
3169 Specifying Unified Frame-Based Protocol Frames
3145 ----------------------------------------------
3170 ----------------------------------------------
3146
3171
3147 It is possible to emit a *Unified Frame-Based Protocol* by using special
3172 It is possible to emit a *Unified Frame-Based Protocol* by using special
3148 syntax.
3173 syntax.
3149
3174
3150 A frame is composed as a type, flags, and payload. These can be parsed
3175 A frame is composed as a type, flags, and payload. These can be parsed
3151 from a string of the form:
3176 from a string of the form:
3152
3177
3153 <request-id> <stream-id> <stream-flags> <type> <flags> <payload>
3178 <request-id> <stream-id> <stream-flags> <type> <flags> <payload>
3154
3179
3155 ``request-id`` and ``stream-id`` are integers defining the request and
3180 ``request-id`` and ``stream-id`` are integers defining the request and
3156 stream identifiers.
3181 stream identifiers.
3157
3182
3158 ``type`` can be an integer value for the frame type or the string name
3183 ``type`` can be an integer value for the frame type or the string name
3159 of the type. The strings are defined in ``wireprotoframing.py``. e.g.
3184 of the type. The strings are defined in ``wireprotoframing.py``. e.g.
3160 ``command-name``.
3185 ``command-name``.
3161
3186
3162 ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag
3187 ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag
3163 components. Each component (and there can be just one) can be an integer
3188 components. Each component (and there can be just one) can be an integer
3164 or a flag name for stream flags or frame flags, respectively. Values are
3189 or a flag name for stream flags or frame flags, respectively. Values are
3165 resolved to integers and then bitwise OR'd together.
3190 resolved to integers and then bitwise OR'd together.
3166
3191
3167 ``payload`` represents the raw frame payload. If it begins with
3192 ``payload`` represents the raw frame payload. If it begins with
3168 ``cbor:``, the following string is evaluated as Python code and the
3193 ``cbor:``, the following string is evaluated as Python code and the
3169 resulting object is fed into a CBOR encoder. Otherwise it is interpreted
3194 resulting object is fed into a CBOR encoder. Otherwise it is interpreted
3170 as a Python byte string literal.
3195 as a Python byte string literal.
3171 """
3196 """
3172 opts = pycompat.byteskwargs(opts)
3197 opts = pycompat.byteskwargs(opts)
3173
3198
3174 if opts['localssh'] and not repo:
3199 if opts['localssh'] and not repo:
3175 raise error.Abort(_('--localssh requires a repository'))
3200 raise error.Abort(_('--localssh requires a repository'))
3176
3201
3177 if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'):
3202 if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'):
3178 raise error.Abort(_('invalid value for --peer'),
3203 raise error.Abort(_('invalid value for --peer'),
3179 hint=_('valid values are "raw", "ssh1", and "ssh2"'))
3204 hint=_('valid values are "raw", "ssh1", and "ssh2"'))
3180
3205
3181 if path and opts['localssh']:
3206 if path and opts['localssh']:
3182 raise error.Abort(_('cannot specify --localssh with an explicit '
3207 raise error.Abort(_('cannot specify --localssh with an explicit '
3183 'path'))
3208 'path'))
3184
3209
3185 if ui.interactive():
3210 if ui.interactive():
3186 ui.write(_('(waiting for commands on stdin)\n'))
3211 ui.write(_('(waiting for commands on stdin)\n'))
3187
3212
3188 blocks = list(_parsewirelangblocks(ui.fin))
3213 blocks = list(_parsewirelangblocks(ui.fin))
3189
3214
3190 proc = None
3215 proc = None
3191 stdin = None
3216 stdin = None
3192 stdout = None
3217 stdout = None
3193 stderr = None
3218 stderr = None
3194 opener = None
3219 opener = None
3195
3220
3196 if opts['localssh']:
3221 if opts['localssh']:
3197 # We start the SSH server in its own process so there is process
3222 # We start the SSH server in its own process so there is process
3198 # separation. This prevents a whole class of potential bugs around
3223 # separation. This prevents a whole class of potential bugs around
3199 # shared state from interfering with server operation.
3224 # shared state from interfering with server operation.
3200 args = procutil.hgcmd() + [
3225 args = procutil.hgcmd() + [
3201 '-R', repo.root,
3226 '-R', repo.root,
3202 'debugserve', '--sshstdio',
3227 'debugserve', '--sshstdio',
3203 ]
3228 ]
3204 proc = subprocess.Popen(pycompat.rapply(procutil.tonativestr, args),
3229 proc = subprocess.Popen(pycompat.rapply(procutil.tonativestr, args),
3205 stdin=subprocess.PIPE,
3230 stdin=subprocess.PIPE,
3206 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
3231 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
3207 bufsize=0)
3232 bufsize=0)
3208
3233
3209 stdin = proc.stdin
3234 stdin = proc.stdin
3210 stdout = proc.stdout
3235 stdout = proc.stdout
3211 stderr = proc.stderr
3236 stderr = proc.stderr
3212
3237
3213 # We turn the pipes into observers so we can log I/O.
3238 # We turn the pipes into observers so we can log I/O.
3214 if ui.verbose or opts['peer'] == 'raw':
3239 if ui.verbose or opts['peer'] == 'raw':
3215 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i',
3240 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i',
3216 logdata=True)
3241 logdata=True)
3217 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o',
3242 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o',
3218 logdata=True)
3243 logdata=True)
3219 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e',
3244 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e',
3220 logdata=True)
3245 logdata=True)
3221
3246
3222 # --localssh also implies the peer connection settings.
3247 # --localssh also implies the peer connection settings.
3223
3248
3224 url = 'ssh://localserver'
3249 url = 'ssh://localserver'
3225 autoreadstderr = not opts['noreadstderr']
3250 autoreadstderr = not opts['noreadstderr']
3226
3251
3227 if opts['peer'] == 'ssh1':
3252 if opts['peer'] == 'ssh1':
3228 ui.write(_('creating ssh peer for wire protocol version 1\n'))
3253 ui.write(_('creating ssh peer for wire protocol version 1\n'))
3229 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr,
3254 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr,
3230 None, autoreadstderr=autoreadstderr)
3255 None, autoreadstderr=autoreadstderr)
3231 elif opts['peer'] == 'ssh2':
3256 elif opts['peer'] == 'ssh2':
3232 ui.write(_('creating ssh peer for wire protocol version 2\n'))
3257 ui.write(_('creating ssh peer for wire protocol version 2\n'))
3233 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr,
3258 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr,
3234 None, autoreadstderr=autoreadstderr)
3259 None, autoreadstderr=autoreadstderr)
3235 elif opts['peer'] == 'raw':
3260 elif opts['peer'] == 'raw':
3236 ui.write(_('using raw connection to peer\n'))
3261 ui.write(_('using raw connection to peer\n'))
3237 peer = None
3262 peer = None
3238 else:
3263 else:
3239 ui.write(_('creating ssh peer from handshake results\n'))
3264 ui.write(_('creating ssh peer from handshake results\n'))
3240 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr,
3265 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr,
3241 autoreadstderr=autoreadstderr)
3266 autoreadstderr=autoreadstderr)
3242
3267
3243 elif path:
3268 elif path:
3244 # We bypass hg.peer() so we can proxy the sockets.
3269 # We bypass hg.peer() so we can proxy the sockets.
3245 # TODO consider not doing this because we skip
3270 # TODO consider not doing this because we skip
3246 # ``hg.wirepeersetupfuncs`` and potentially other useful functionality.
3271 # ``hg.wirepeersetupfuncs`` and potentially other useful functionality.
3247 u = util.url(path)
3272 u = util.url(path)
3248 if u.scheme != 'http':
3273 if u.scheme != 'http':
3249 raise error.Abort(_('only http:// paths are currently supported'))
3274 raise error.Abort(_('only http:// paths are currently supported'))
3250
3275
3251 url, authinfo = u.authinfo()
3276 url, authinfo = u.authinfo()
3252 openerargs = {
3277 openerargs = {
3253 r'useragent': b'Mercurial debugwireproto',
3278 r'useragent': b'Mercurial debugwireproto',
3254 }
3279 }
3255
3280
3256 # Turn pipes/sockets into observers so we can log I/O.
3281 # Turn pipes/sockets into observers so we can log I/O.
3257 if ui.verbose:
3282 if ui.verbose:
3258 openerargs.update({
3283 openerargs.update({
3259 r'loggingfh': ui,
3284 r'loggingfh': ui,
3260 r'loggingname': b's',
3285 r'loggingname': b's',
3261 r'loggingopts': {
3286 r'loggingopts': {
3262 r'logdata': True,
3287 r'logdata': True,
3263 r'logdataapis': False,
3288 r'logdataapis': False,
3264 },
3289 },
3265 })
3290 })
3266
3291
3267 if ui.debugflag:
3292 if ui.debugflag:
3268 openerargs[r'loggingopts'][r'logdataapis'] = True
3293 openerargs[r'loggingopts'][r'logdataapis'] = True
3269
3294
3270 # Don't send default headers when in raw mode. This allows us to
3295 # Don't send default headers when in raw mode. This allows us to
3271 # bypass most of the behavior of our URL handling code so we can
3296 # bypass most of the behavior of our URL handling code so we can
3272 # have near complete control over what's sent on the wire.
3297 # have near complete control over what's sent on the wire.
3273 if opts['peer'] == 'raw':
3298 if opts['peer'] == 'raw':
3274 openerargs[r'sendaccept'] = False
3299 openerargs[r'sendaccept'] = False
3275
3300
3276 opener = urlmod.opener(ui, authinfo, **openerargs)
3301 opener = urlmod.opener(ui, authinfo, **openerargs)
3277
3302
3278 if opts['peer'] == 'http2':
3303 if opts['peer'] == 'http2':
3279 ui.write(_('creating http peer for wire protocol version 2\n'))
3304 ui.write(_('creating http peer for wire protocol version 2\n'))
3280 # We go through makepeer() because we need an API descriptor for
3305 # We go through makepeer() because we need an API descriptor for
3281 # the peer instance to be useful.
3306 # the peer instance to be useful.
3282 with ui.configoverride({
3307 with ui.configoverride({
3283 ('experimental', 'httppeer.advertise-v2'): True}):
3308 ('experimental', 'httppeer.advertise-v2'): True}):
3284 if opts['nologhandshake']:
3309 if opts['nologhandshake']:
3285 ui.pushbuffer()
3310 ui.pushbuffer()
3286
3311
3287 peer = httppeer.makepeer(ui, path, opener=opener)
3312 peer = httppeer.makepeer(ui, path, opener=opener)
3288
3313
3289 if opts['nologhandshake']:
3314 if opts['nologhandshake']:
3290 ui.popbuffer()
3315 ui.popbuffer()
3291
3316
3292 if not isinstance(peer, httppeer.httpv2peer):
3317 if not isinstance(peer, httppeer.httpv2peer):
3293 raise error.Abort(_('could not instantiate HTTP peer for '
3318 raise error.Abort(_('could not instantiate HTTP peer for '
3294 'wire protocol version 2'),
3319 'wire protocol version 2'),
3295 hint=_('the server may not have the feature '
3320 hint=_('the server may not have the feature '
3296 'enabled or is not allowing this '
3321 'enabled or is not allowing this '
3297 'client version'))
3322 'client version'))
3298
3323
3299 elif opts['peer'] == 'raw':
3324 elif opts['peer'] == 'raw':
3300 ui.write(_('using raw connection to peer\n'))
3325 ui.write(_('using raw connection to peer\n'))
3301 peer = None
3326 peer = None
3302 elif opts['peer']:
3327 elif opts['peer']:
3303 raise error.Abort(_('--peer %s not supported with HTTP peers') %
3328 raise error.Abort(_('--peer %s not supported with HTTP peers') %
3304 opts['peer'])
3329 opts['peer'])
3305 else:
3330 else:
3306 peer = httppeer.makepeer(ui, path, opener=opener)
3331 peer = httppeer.makepeer(ui, path, opener=opener)
3307
3332
3308 # We /could/ populate stdin/stdout with sock.makefile()...
3333 # We /could/ populate stdin/stdout with sock.makefile()...
3309 else:
3334 else:
3310 raise error.Abort(_('unsupported connection configuration'))
3335 raise error.Abort(_('unsupported connection configuration'))
3311
3336
3312 batchedcommands = None
3337 batchedcommands = None
3313
3338
3314 # Now perform actions based on the parsed wire language instructions.
3339 # Now perform actions based on the parsed wire language instructions.
3315 for action, lines in blocks:
3340 for action, lines in blocks:
3316 if action in ('raw', 'raw+'):
3341 if action in ('raw', 'raw+'):
3317 if not stdin:
3342 if not stdin:
3318 raise error.Abort(_('cannot call raw/raw+ on this peer'))
3343 raise error.Abort(_('cannot call raw/raw+ on this peer'))
3319
3344
3320 # Concatenate the data together.
3345 # Concatenate the data together.
3321 data = ''.join(l.lstrip() for l in lines)
3346 data = ''.join(l.lstrip() for l in lines)
3322 data = stringutil.unescapestr(data)
3347 data = stringutil.unescapestr(data)
3323 stdin.write(data)
3348 stdin.write(data)
3324
3349
3325 if action == 'raw+':
3350 if action == 'raw+':
3326 stdin.flush()
3351 stdin.flush()
3327 elif action == 'flush':
3352 elif action == 'flush':
3328 if not stdin:
3353 if not stdin:
3329 raise error.Abort(_('cannot call flush on this peer'))
3354 raise error.Abort(_('cannot call flush on this peer'))
3330 stdin.flush()
3355 stdin.flush()
3331 elif action.startswith('command'):
3356 elif action.startswith('command'):
3332 if not peer:
3357 if not peer:
3333 raise error.Abort(_('cannot send commands unless peer instance '
3358 raise error.Abort(_('cannot send commands unless peer instance '
3334 'is available'))
3359 'is available'))
3335
3360
3336 command = action.split(' ', 1)[1]
3361 command = action.split(' ', 1)[1]
3337
3362
3338 args = {}
3363 args = {}
3339 for line in lines:
3364 for line in lines:
3340 # We need to allow empty values.
3365 # We need to allow empty values.
3341 fields = line.lstrip().split(' ', 1)
3366 fields = line.lstrip().split(' ', 1)
3342 if len(fields) == 1:
3367 if len(fields) == 1:
3343 key = fields[0]
3368 key = fields[0]
3344 value = ''
3369 value = ''
3345 else:
3370 else:
3346 key, value = fields
3371 key, value = fields
3347
3372
3348 if value.startswith('eval:'):
3373 if value.startswith('eval:'):
3349 value = stringutil.evalpythonliteral(value[5:])
3374 value = stringutil.evalpythonliteral(value[5:])
3350 else:
3375 else:
3351 value = stringutil.unescapestr(value)
3376 value = stringutil.unescapestr(value)
3352
3377
3353 args[key] = value
3378 args[key] = value
3354
3379
3355 if batchedcommands is not None:
3380 if batchedcommands is not None:
3356 batchedcommands.append((command, args))
3381 batchedcommands.append((command, args))
3357 continue
3382 continue
3358
3383
3359 ui.status(_('sending %s command\n') % command)
3384 ui.status(_('sending %s command\n') % command)
3360
3385
3361 if 'PUSHFILE' in args:
3386 if 'PUSHFILE' in args:
3362 with open(args['PUSHFILE'], r'rb') as fh:
3387 with open(args['PUSHFILE'], r'rb') as fh:
3363 del args['PUSHFILE']
3388 del args['PUSHFILE']
3364 res, output = peer._callpush(command, fh,
3389 res, output = peer._callpush(command, fh,
3365 **pycompat.strkwargs(args))
3390 **pycompat.strkwargs(args))
3366 ui.status(_('result: %s\n') % stringutil.escapestr(res))
3391 ui.status(_('result: %s\n') % stringutil.escapestr(res))
3367 ui.status(_('remote output: %s\n') %
3392 ui.status(_('remote output: %s\n') %
3368 stringutil.escapestr(output))
3393 stringutil.escapestr(output))
3369 else:
3394 else:
3370 with peer.commandexecutor() as e:
3395 with peer.commandexecutor() as e:
3371 res = e.callcommand(command, args).result()
3396 res = e.callcommand(command, args).result()
3372
3397
3373 if isinstance(res, wireprotov2peer.commandresponse):
3398 if isinstance(res, wireprotov2peer.commandresponse):
3374 val = res.objects()
3399 val = res.objects()
3375 ui.status(_('response: %s\n') %
3400 ui.status(_('response: %s\n') %
3376 stringutil.pprint(val, bprefix=True, indent=2))
3401 stringutil.pprint(val, bprefix=True, indent=2))
3377 else:
3402 else:
3378 ui.status(_('response: %s\n') %
3403 ui.status(_('response: %s\n') %
3379 stringutil.pprint(res, bprefix=True, indent=2))
3404 stringutil.pprint(res, bprefix=True, indent=2))
3380
3405
3381 elif action == 'batchbegin':
3406 elif action == 'batchbegin':
3382 if batchedcommands is not None:
3407 if batchedcommands is not None:
3383 raise error.Abort(_('nested batchbegin not allowed'))
3408 raise error.Abort(_('nested batchbegin not allowed'))
3384
3409
3385 batchedcommands = []
3410 batchedcommands = []
3386 elif action == 'batchsubmit':
3411 elif action == 'batchsubmit':
3387 # There is a batching API we could go through. But it would be
3412 # There is a batching API we could go through. But it would be
3388 # difficult to normalize requests into function calls. It is easier
3413 # difficult to normalize requests into function calls. It is easier
3389 # to bypass this layer and normalize to commands + args.
3414 # to bypass this layer and normalize to commands + args.
3390 ui.status(_('sending batch with %d sub-commands\n') %
3415 ui.status(_('sending batch with %d sub-commands\n') %
3391 len(batchedcommands))
3416 len(batchedcommands))
3392 for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
3417 for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
3393 ui.status(_('response #%d: %s\n') %
3418 ui.status(_('response #%d: %s\n') %
3394 (i, stringutil.escapestr(chunk)))
3419 (i, stringutil.escapestr(chunk)))
3395
3420
3396 batchedcommands = None
3421 batchedcommands = None
3397
3422
3398 elif action.startswith('httprequest '):
3423 elif action.startswith('httprequest '):
3399 if not opener:
3424 if not opener:
3400 raise error.Abort(_('cannot use httprequest without an HTTP '
3425 raise error.Abort(_('cannot use httprequest without an HTTP '
3401 'peer'))
3426 'peer'))
3402
3427
3403 request = action.split(' ', 2)
3428 request = action.split(' ', 2)
3404 if len(request) != 3:
3429 if len(request) != 3:
3405 raise error.Abort(_('invalid httprequest: expected format is '
3430 raise error.Abort(_('invalid httprequest: expected format is '
3406 '"httprequest <method> <path>'))
3431 '"httprequest <method> <path>'))
3407
3432
3408 method, httppath = request[1:]
3433 method, httppath = request[1:]
3409 headers = {}
3434 headers = {}
3410 body = None
3435 body = None
3411 frames = []
3436 frames = []
3412 for line in lines:
3437 for line in lines:
3413 line = line.lstrip()
3438 line = line.lstrip()
3414 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line)
3439 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line)
3415 if m:
3440 if m:
3416 # Headers need to use native strings.
3441 # Headers need to use native strings.
3417 key = pycompat.strurl(m.group(1))
3442 key = pycompat.strurl(m.group(1))
3418 value = pycompat.strurl(m.group(2))
3443 value = pycompat.strurl(m.group(2))
3419 headers[key] = value
3444 headers[key] = value
3420 continue
3445 continue
3421
3446
3422 if line.startswith(b'BODYFILE '):
3447 if line.startswith(b'BODYFILE '):
3423 with open(line.split(b' ', 1), 'rb') as fh:
3448 with open(line.split(b' ', 1), 'rb') as fh:
3424 body = fh.read()
3449 body = fh.read()
3425 elif line.startswith(b'frame '):
3450 elif line.startswith(b'frame '):
3426 frame = wireprotoframing.makeframefromhumanstring(
3451 frame = wireprotoframing.makeframefromhumanstring(
3427 line[len(b'frame '):])
3452 line[len(b'frame '):])
3428
3453
3429 frames.append(frame)
3454 frames.append(frame)
3430 else:
3455 else:
3431 raise error.Abort(_('unknown argument to httprequest: %s') %
3456 raise error.Abort(_('unknown argument to httprequest: %s') %
3432 line)
3457 line)
3433
3458
3434 url = path + httppath
3459 url = path + httppath
3435
3460
3436 if frames:
3461 if frames:
3437 body = b''.join(bytes(f) for f in frames)
3462 body = b''.join(bytes(f) for f in frames)
3438
3463
3439 req = urlmod.urlreq.request(pycompat.strurl(url), body, headers)
3464 req = urlmod.urlreq.request(pycompat.strurl(url), body, headers)
3440
3465
3441 # urllib.Request insists on using has_data() as a proxy for
3466 # urllib.Request insists on using has_data() as a proxy for
3442 # determining the request method. Override that to use our
3467 # determining the request method. Override that to use our
3443 # explicitly requested method.
3468 # explicitly requested method.
3444 req.get_method = lambda: pycompat.sysstr(method)
3469 req.get_method = lambda: pycompat.sysstr(method)
3445
3470
3446 try:
3471 try:
3447 res = opener.open(req)
3472 res = opener.open(req)
3448 body = res.read()
3473 body = res.read()
3449 except util.urlerr.urlerror as e:
3474 except util.urlerr.urlerror as e:
3450 # read() method must be called, but only exists in Python 2
3475 # read() method must be called, but only exists in Python 2
3451 getattr(e, 'read', lambda: None)()
3476 getattr(e, 'read', lambda: None)()
3452 continue
3477 continue
3453
3478
3454 ct = res.headers.get(r'Content-Type')
3479 ct = res.headers.get(r'Content-Type')
3455 if ct == r'application/mercurial-cbor':
3480 if ct == r'application/mercurial-cbor':
3456 ui.write(_('cbor> %s\n') %
3481 ui.write(_('cbor> %s\n') %
3457 stringutil.pprint(cborutil.decodeall(body),
3482 stringutil.pprint(cborutil.decodeall(body),
3458 bprefix=True,
3483 bprefix=True,
3459 indent=2))
3484 indent=2))
3460
3485
3461 elif action == 'close':
3486 elif action == 'close':
3462 peer.close()
3487 peer.close()
3463 elif action == 'readavailable':
3488 elif action == 'readavailable':
3464 if not stdout or not stderr:
3489 if not stdout or not stderr:
3465 raise error.Abort(_('readavailable not available on this peer'))
3490 raise error.Abort(_('readavailable not available on this peer'))
3466
3491
3467 stdin.close()
3492 stdin.close()
3468 stdout.read()
3493 stdout.read()
3469 stderr.read()
3494 stderr.read()
3470
3495
3471 elif action == 'readline':
3496 elif action == 'readline':
3472 if not stdout:
3497 if not stdout:
3473 raise error.Abort(_('readline not available on this peer'))
3498 raise error.Abort(_('readline not available on this peer'))
3474 stdout.readline()
3499 stdout.readline()
3475 elif action == 'ereadline':
3500 elif action == 'ereadline':
3476 if not stderr:
3501 if not stderr:
3477 raise error.Abort(_('ereadline not available on this peer'))
3502 raise error.Abort(_('ereadline not available on this peer'))
3478 stderr.readline()
3503 stderr.readline()
3479 elif action.startswith('read '):
3504 elif action.startswith('read '):
3480 count = int(action.split(' ', 1)[1])
3505 count = int(action.split(' ', 1)[1])
3481 if not stdout:
3506 if not stdout:
3482 raise error.Abort(_('read not available on this peer'))
3507 raise error.Abort(_('read not available on this peer'))
3483 stdout.read(count)
3508 stdout.read(count)
3484 elif action.startswith('eread '):
3509 elif action.startswith('eread '):
3485 count = int(action.split(' ', 1)[1])
3510 count = int(action.split(' ', 1)[1])
3486 if not stderr:
3511 if not stderr:
3487 raise error.Abort(_('eread not available on this peer'))
3512 raise error.Abort(_('eread not available on this peer'))
3488 stderr.read(count)
3513 stderr.read(count)
3489 else:
3514 else:
3490 raise error.Abort(_('unknown action: %s') % action)
3515 raise error.Abort(_('unknown action: %s') % action)
3491
3516
3492 if batchedcommands is not None:
3517 if batchedcommands is not None:
3493 raise error.Abort(_('unclosed "batchbegin" request'))
3518 raise error.Abort(_('unclosed "batchbegin" request'))
3494
3519
3495 if peer:
3520 if peer:
3496 peer.close()
3521 peer.close()
3497
3522
3498 if proc:
3523 if proc:
3499 proc.kill()
3524 proc.kill()
@@ -1,423 +1,425 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 abort
3 abort
4 add
4 add
5 addremove
5 addremove
6 annotate
6 annotate
7 archive
7 archive
8 backout
8 backout
9 bisect
9 bisect
10 bookmarks
10 bookmarks
11 branch
11 branch
12 branches
12 branches
13 bundle
13 bundle
14 cat
14 cat
15 clone
15 clone
16 commit
16 commit
17 config
17 config
18 continue
18 continue
19 copy
19 copy
20 diff
20 diff
21 export
21 export
22 files
22 files
23 forget
23 forget
24 graft
24 graft
25 grep
25 grep
26 heads
26 heads
27 help
27 help
28 identify
28 identify
29 import
29 import
30 incoming
30 incoming
31 init
31 init
32 locate
32 locate
33 log
33 log
34 manifest
34 manifest
35 merge
35 merge
36 outgoing
36 outgoing
37 parents
37 parents
38 paths
38 paths
39 phase
39 phase
40 pull
40 pull
41 push
41 push
42 recover
42 recover
43 remove
43 remove
44 rename
44 rename
45 resolve
45 resolve
46 revert
46 revert
47 rollback
47 rollback
48 root
48 root
49 serve
49 serve
50 shelve
50 shelve
51 status
51 status
52 summary
52 summary
53 tag
53 tag
54 tags
54 tags
55 tip
55 tip
56 unbundle
56 unbundle
57 unshelve
57 unshelve
58 update
58 update
59 verify
59 verify
60 version
60 version
61
61
62 Show all commands that start with "a"
62 Show all commands that start with "a"
63 $ hg debugcomplete a
63 $ hg debugcomplete a
64 abort
64 abort
65 add
65 add
66 addremove
66 addremove
67 annotate
67 annotate
68 archive
68 archive
69
69
70 Do not show debug commands if there are other candidates
70 Do not show debug commands if there are other candidates
71 $ hg debugcomplete d
71 $ hg debugcomplete d
72 diff
72 diff
73
73
74 Show debug commands if there are no other candidates
74 Show debug commands if there are no other candidates
75 $ hg debugcomplete debug
75 $ hg debugcomplete debug
76 debugancestor
76 debugancestor
77 debugapplystreamclonebundle
77 debugapplystreamclonebundle
78 debugbuilddag
78 debugbuilddag
79 debugbundle
79 debugbundle
80 debugcapabilities
80 debugcapabilities
81 debugcheckstate
81 debugcheckstate
82 debugcolor
82 debugcolor
83 debugcommands
83 debugcommands
84 debugcomplete
84 debugcomplete
85 debugconfig
85 debugconfig
86 debugcreatestreamclonebundle
86 debugcreatestreamclonebundle
87 debugdag
87 debugdag
88 debugdata
88 debugdata
89 debugdate
89 debugdate
90 debugdeltachain
90 debugdeltachain
91 debugdirstate
91 debugdirstate
92 debugdiscovery
92 debugdiscovery
93 debugdownload
93 debugdownload
94 debugextensions
94 debugextensions
95 debugfileset
95 debugfileset
96 debugformat
96 debugformat
97 debugfsinfo
97 debugfsinfo
98 debuggetbundle
98 debuggetbundle
99 debugignore
99 debugignore
100 debugindex
100 debugindex
101 debugindexdot
101 debugindexdot
102 debugindexstats
102 debugindexstats
103 debuginstall
103 debuginstall
104 debugknown
104 debugknown
105 debuglabelcomplete
105 debuglabelcomplete
106 debuglocks
106 debuglocks
107 debugmanifestfulltextcache
107 debugmanifestfulltextcache
108 debugmergestate
108 debugmergestate
109 debugnamecomplete
109 debugnamecomplete
110 debugobsolete
110 debugobsolete
111 debugp1copies
111 debugp1copies
112 debugp2copies
112 debugp2copies
113 debugpathcomplete
113 debugpathcomplete
114 debugpathcopies
114 debugpathcopies
115 debugpeer
115 debugpeer
116 debugpickmergetool
116 debugpickmergetool
117 debugpushkey
117 debugpushkey
118 debugpvec
118 debugpvec
119 debugrebuilddirstate
119 debugrebuilddirstate
120 debugrebuildfncache
120 debugrebuildfncache
121 debugrename
121 debugrename
122 debugrevlog
122 debugrevlog
123 debugrevlogindex
123 debugrevlogindex
124 debugrevspec
124 debugrevspec
125 debugserve
125 debugserve
126 debugsetparents
126 debugsetparents
127 debugsidedata
127 debugssl
128 debugssl
128 debugsub
129 debugsub
129 debugsuccessorssets
130 debugsuccessorssets
130 debugtemplate
131 debugtemplate
131 debuguigetpass
132 debuguigetpass
132 debuguiprompt
133 debuguiprompt
133 debugupdatecaches
134 debugupdatecaches
134 debugupgraderepo
135 debugupgraderepo
135 debugwalk
136 debugwalk
136 debugwhyunstable
137 debugwhyunstable
137 debugwireargs
138 debugwireargs
138 debugwireproto
139 debugwireproto
139
140
140 Do not show the alias of a debug command if there are other candidates
141 Do not show the alias of a debug command if there are other candidates
141 (this should hide rawcommit)
142 (this should hide rawcommit)
142 $ hg debugcomplete r
143 $ hg debugcomplete r
143 recover
144 recover
144 remove
145 remove
145 rename
146 rename
146 resolve
147 resolve
147 revert
148 revert
148 rollback
149 rollback
149 root
150 root
150 Show the alias of a debug command if there are no other candidates
151 Show the alias of a debug command if there are no other candidates
151 $ hg debugcomplete rawc
152 $ hg debugcomplete rawc
152
153
153
154
154 Show the global options
155 Show the global options
155 $ hg debugcomplete --options | sort
156 $ hg debugcomplete --options | sort
156 --color
157 --color
157 --config
158 --config
158 --cwd
159 --cwd
159 --debug
160 --debug
160 --debugger
161 --debugger
161 --encoding
162 --encoding
162 --encodingmode
163 --encodingmode
163 --help
164 --help
164 --hidden
165 --hidden
165 --noninteractive
166 --noninteractive
166 --pager
167 --pager
167 --profile
168 --profile
168 --quiet
169 --quiet
169 --repository
170 --repository
170 --time
171 --time
171 --traceback
172 --traceback
172 --verbose
173 --verbose
173 --version
174 --version
174 -R
175 -R
175 -h
176 -h
176 -q
177 -q
177 -v
178 -v
178 -y
179 -y
179
180
180 Show the options for the "serve" command
181 Show the options for the "serve" command
181 $ hg debugcomplete --options serve | sort
182 $ hg debugcomplete --options serve | sort
182 --accesslog
183 --accesslog
183 --address
184 --address
184 --certificate
185 --certificate
185 --cmdserver
186 --cmdserver
186 --color
187 --color
187 --config
188 --config
188 --cwd
189 --cwd
189 --daemon
190 --daemon
190 --daemon-postexec
191 --daemon-postexec
191 --debug
192 --debug
192 --debugger
193 --debugger
193 --encoding
194 --encoding
194 --encodingmode
195 --encodingmode
195 --errorlog
196 --errorlog
196 --help
197 --help
197 --hidden
198 --hidden
198 --ipv6
199 --ipv6
199 --name
200 --name
200 --noninteractive
201 --noninteractive
201 --pager
202 --pager
202 --pid-file
203 --pid-file
203 --port
204 --port
204 --prefix
205 --prefix
205 --print-url
206 --print-url
206 --profile
207 --profile
207 --quiet
208 --quiet
208 --repository
209 --repository
209 --stdio
210 --stdio
210 --style
211 --style
211 --subrepos
212 --subrepos
212 --templates
213 --templates
213 --time
214 --time
214 --traceback
215 --traceback
215 --verbose
216 --verbose
216 --version
217 --version
217 --web-conf
218 --web-conf
218 -6
219 -6
219 -A
220 -A
220 -E
221 -E
221 -R
222 -R
222 -S
223 -S
223 -a
224 -a
224 -d
225 -d
225 -h
226 -h
226 -n
227 -n
227 -p
228 -p
228 -q
229 -q
229 -t
230 -t
230 -v
231 -v
231 -y
232 -y
232
233
233 Show an error if we use --options with an ambiguous abbreviation
234 Show an error if we use --options with an ambiguous abbreviation
234 $ hg debugcomplete --options s
235 $ hg debugcomplete --options s
235 hg: command 's' is ambiguous:
236 hg: command 's' is ambiguous:
236 serve shelve showconfig status summary
237 serve shelve showconfig status summary
237 [255]
238 [255]
238
239
239 Show all commands + options
240 Show all commands + options
240 $ hg debugcommands
241 $ hg debugcommands
241 abort: dry-run
242 abort: dry-run
242 add: include, exclude, subrepos, dry-run
243 add: include, exclude, subrepos, dry-run
243 addremove: similarity, subrepos, include, exclude, dry-run
244 addremove: similarity, subrepos, include, exclude, dry-run
244 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
245 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
245 archive: no-decode, prefix, rev, type, subrepos, include, exclude
246 archive: no-decode, prefix, rev, type, subrepos, include, exclude
246 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
247 backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
247 bisect: reset, good, bad, skip, extend, command, noupdate
248 bisect: reset, good, bad, skip, extend, command, noupdate
248 bookmarks: force, rev, delete, rename, inactive, list, template
249 bookmarks: force, rev, delete, rename, inactive, list, template
249 branch: force, clean, rev
250 branch: force, clean, rev
250 branches: active, closed, rev, template
251 branches: active, closed, rev, template
251 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
252 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
252 cat: output, rev, decode, include, exclude, template
253 cat: output, rev, decode, include, exclude, template
253 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
254 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
254 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
255 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
255 config: untrusted, edit, local, global, template
256 config: untrusted, edit, local, global, template
256 continue: dry-run
257 continue: dry-run
257 copy: after, force, include, exclude, dry-run
258 copy: after, force, include, exclude, dry-run
258 debugancestor:
259 debugancestor:
259 debugapplystreamclonebundle:
260 debugapplystreamclonebundle:
260 debugbuilddag: mergeable-file, overwritten-file, new-file
261 debugbuilddag: mergeable-file, overwritten-file, new-file
261 debugbundle: all, part-type, spec
262 debugbundle: all, part-type, spec
262 debugcapabilities:
263 debugcapabilities:
263 debugcheckstate:
264 debugcheckstate:
264 debugcolor: style
265 debugcolor: style
265 debugcommands:
266 debugcommands:
266 debugcomplete: options
267 debugcomplete: options
267 debugcreatestreamclonebundle:
268 debugcreatestreamclonebundle:
268 debugdag: tags, branches, dots, spaces
269 debugdag: tags, branches, dots, spaces
269 debugdata: changelog, manifest, dir
270 debugdata: changelog, manifest, dir
270 debugdate: extended
271 debugdate: extended
271 debugdeltachain: changelog, manifest, dir, template
272 debugdeltachain: changelog, manifest, dir, template
272 debugdirstate: nodates, dates, datesort
273 debugdirstate: nodates, dates, datesort
273 debugdiscovery: old, nonheads, rev, seed, ssh, remotecmd, insecure
274 debugdiscovery: old, nonheads, rev, seed, ssh, remotecmd, insecure
274 debugdownload: output
275 debugdownload: output
275 debugextensions: template
276 debugextensions: template
276 debugfileset: rev, all-files, show-matcher, show-stage
277 debugfileset: rev, all-files, show-matcher, show-stage
277 debugformat: template
278 debugformat: template
278 debugfsinfo:
279 debugfsinfo:
279 debuggetbundle: head, common, type
280 debuggetbundle: head, common, type
280 debugignore:
281 debugignore:
281 debugindex: changelog, manifest, dir, template
282 debugindex: changelog, manifest, dir, template
282 debugindexdot: changelog, manifest, dir
283 debugindexdot: changelog, manifest, dir
283 debugindexstats:
284 debugindexstats:
284 debuginstall: template
285 debuginstall: template
285 debugknown:
286 debugknown:
286 debuglabelcomplete:
287 debuglabelcomplete:
287 debuglocks: force-lock, force-wlock, set-lock, set-wlock
288 debuglocks: force-lock, force-wlock, set-lock, set-wlock
288 debugmanifestfulltextcache: clear, add
289 debugmanifestfulltextcache: clear, add
289 debugmergestate:
290 debugmergestate:
290 debugnamecomplete:
291 debugnamecomplete:
291 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
292 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
292 debugp1copies: rev
293 debugp1copies: rev
293 debugp2copies: rev
294 debugp2copies: rev
294 debugpathcomplete: full, normal, added, removed
295 debugpathcomplete: full, normal, added, removed
295 debugpathcopies: include, exclude
296 debugpathcopies: include, exclude
296 debugpeer:
297 debugpeer:
297 debugpickmergetool: rev, changedelete, include, exclude, tool
298 debugpickmergetool: rev, changedelete, include, exclude, tool
298 debugpushkey:
299 debugpushkey:
299 debugpvec:
300 debugpvec:
300 debugrebuilddirstate: rev, minimal
301 debugrebuilddirstate: rev, minimal
301 debugrebuildfncache:
302 debugrebuildfncache:
302 debugrename: rev
303 debugrename: rev
303 debugrevlog: changelog, manifest, dir, dump
304 debugrevlog: changelog, manifest, dir, dump
304 debugrevlogindex: changelog, manifest, dir, format
305 debugrevlogindex: changelog, manifest, dir, format
305 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
306 debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized
306 debugserve: sshstdio, logiofd, logiofile
307 debugserve: sshstdio, logiofd, logiofile
307 debugsetparents:
308 debugsetparents:
309 debugsidedata: changelog, manifest, dir
308 debugssl:
310 debugssl:
309 debugsub: rev
311 debugsub: rev
310 debugsuccessorssets: closest
312 debugsuccessorssets: closest
311 debugtemplate: rev, define
313 debugtemplate: rev, define
312 debuguigetpass: prompt
314 debuguigetpass: prompt
313 debuguiprompt: prompt
315 debuguiprompt: prompt
314 debugupdatecaches:
316 debugupdatecaches:
315 debugupgraderepo: optimize, run, backup, changelog, manifest
317 debugupgraderepo: optimize, run, backup, changelog, manifest
316 debugwalk: include, exclude
318 debugwalk: include, exclude
317 debugwhyunstable:
319 debugwhyunstable:
318 debugwireargs: three, four, five, ssh, remotecmd, insecure
320 debugwireargs: three, four, five, ssh, remotecmd, insecure
319 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
321 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
320 diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
322 diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
321 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
323 export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
322 files: rev, print0, include, exclude, template, subrepos
324 files: rev, print0, include, exclude, template, subrepos
323 forget: interactive, include, exclude, dry-run
325 forget: interactive, include, exclude, dry-run
324 graft: rev, base, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run
326 graft: rev, base, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run
325 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude
327 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude
326 heads: rev, topo, active, closed, style, template
328 heads: rev, topo, active, closed, style, template
327 help: extension, command, keyword, system
329 help: extension, command, keyword, system
328 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
330 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
329 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
331 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
330 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
332 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
331 init: ssh, remotecmd, insecure
333 init: ssh, remotecmd, insecure
332 locate: rev, print0, fullpath, include, exclude
334 locate: rev, print0, fullpath, include, exclude
333 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
335 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
334 manifest: rev, all, template
336 manifest: rev, all, template
335 merge: force, rev, preview, abort, tool
337 merge: force, rev, preview, abort, tool
336 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
338 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
337 parents: rev, style, template
339 parents: rev, style, template
338 paths: template
340 paths: template
339 phase: public, draft, secret, force, rev
341 phase: public, draft, secret, force, rev
340 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
342 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
341 push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
343 push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
342 recover: verify
344 recover: verify
343 remove: after, force, subrepos, include, exclude, dry-run
345 remove: after, force, subrepos, include, exclude, dry-run
344 rename: after, force, include, exclude, dry-run
346 rename: after, force, include, exclude, dry-run
345 resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
347 resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
346 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
348 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
347 rollback: dry-run, force
349 rollback: dry-run, force
348 root: template
350 root: template
349 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos
351 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos
350 shelve: addremove, unknown, cleanup, date, delete, edit, keep, list, message, name, patch, interactive, stat, include, exclude
352 shelve: addremove, unknown, cleanup, date, delete, edit, keep, list, message, name, patch, interactive, stat, include, exclude
351 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
353 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
352 summary: remote
354 summary: remote
353 tag: force, local, rev, remove, edit, message, date, user
355 tag: force, local, rev, remove, edit, message, date, user
354 tags: template
356 tags: template
355 tip: patch, git, style, template
357 tip: patch, git, style, template
356 unbundle: update
358 unbundle: update
357 unshelve: abort, continue, interactive, keep, name, tool, date
359 unshelve: abort, continue, interactive, keep, name, tool, date
358 update: clean, check, merge, date, rev, tool
360 update: clean, check, merge, date, rev, tool
359 verify: full
361 verify: full
360 version: template
362 version: template
361
363
362 $ hg init a
364 $ hg init a
363 $ cd a
365 $ cd a
364 $ echo fee > fee
366 $ echo fee > fee
365 $ hg ci -q -Amfee
367 $ hg ci -q -Amfee
366 $ hg tag fee
368 $ hg tag fee
367 $ mkdir fie
369 $ mkdir fie
368 $ echo dead > fie/dead
370 $ echo dead > fie/dead
369 $ echo live > fie/live
371 $ echo live > fie/live
370 $ hg bookmark fo
372 $ hg bookmark fo
371 $ hg branch -q fie
373 $ hg branch -q fie
372 $ hg ci -q -Amfie
374 $ hg ci -q -Amfie
373 $ echo fo > fo
375 $ echo fo > fo
374 $ hg branch -qf default
376 $ hg branch -qf default
375 $ hg ci -q -Amfo
377 $ hg ci -q -Amfo
376 $ echo Fum > Fum
378 $ echo Fum > Fum
377 $ hg ci -q -AmFum
379 $ hg ci -q -AmFum
378 $ hg bookmark Fum
380 $ hg bookmark Fum
379
381
380 Test debugpathcomplete
382 Test debugpathcomplete
381
383
382 $ hg debugpathcomplete f
384 $ hg debugpathcomplete f
383 fee
385 fee
384 fie
386 fie
385 fo
387 fo
386 $ hg debugpathcomplete -f f
388 $ hg debugpathcomplete -f f
387 fee
389 fee
388 fie/dead
390 fie/dead
389 fie/live
391 fie/live
390 fo
392 fo
391
393
392 $ hg rm Fum
394 $ hg rm Fum
393 $ hg debugpathcomplete -r F
395 $ hg debugpathcomplete -r F
394 Fum
396 Fum
395
397
396 Test debugnamecomplete
398 Test debugnamecomplete
397
399
398 $ hg debugnamecomplete
400 $ hg debugnamecomplete
399 Fum
401 Fum
400 default
402 default
401 fee
403 fee
402 fie
404 fie
403 fo
405 fo
404 tip
406 tip
405 $ hg debugnamecomplete f
407 $ hg debugnamecomplete f
406 fee
408 fee
407 fie
409 fie
408 fo
410 fo
409
411
410 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
412 Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still
411 used for completions in some shells.
413 used for completions in some shells.
412
414
413 $ hg debuglabelcomplete
415 $ hg debuglabelcomplete
414 Fum
416 Fum
415 default
417 default
416 fee
418 fee
417 fie
419 fie
418 fo
420 fo
419 tip
421 tip
420 $ hg debuglabelcomplete f
422 $ hg debuglabelcomplete f
421 fee
423 fee
422 fie
424 fie
423 fo
425 fo
@@ -1,3891 +1,3893 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 Extra extensions will be printed in help output in a non-reliable order since
47 Extra extensions will be printed in help output in a non-reliable order since
48 the extension is unknown.
48 the extension is unknown.
49 #if no-extraextensions
49 #if no-extraextensions
50
50
51 $ hg help
51 $ hg help
52 Mercurial Distributed SCM
52 Mercurial Distributed SCM
53
53
54 list of commands:
54 list of commands:
55
55
56 Repository creation:
56 Repository creation:
57
57
58 clone make a copy of an existing repository
58 clone make a copy of an existing repository
59 init create a new repository in the given directory
59 init create a new repository in the given directory
60
60
61 Remote repository management:
61 Remote repository management:
62
62
63 incoming show new changesets found in source
63 incoming show new changesets found in source
64 outgoing show changesets not found in the destination
64 outgoing show changesets not found in the destination
65 paths show aliases for remote repositories
65 paths show aliases for remote repositories
66 pull pull changes from the specified source
66 pull pull changes from the specified source
67 push push changes to the specified destination
67 push push changes to the specified destination
68 serve start stand-alone webserver
68 serve start stand-alone webserver
69
69
70 Change creation:
70 Change creation:
71
71
72 commit commit the specified files or all outstanding changes
72 commit commit the specified files or all outstanding changes
73
73
74 Change manipulation:
74 Change manipulation:
75
75
76 backout reverse effect of earlier changeset
76 backout reverse effect of earlier changeset
77 graft copy changes from other branches onto the current branch
77 graft copy changes from other branches onto the current branch
78 merge merge another revision into working directory
78 merge merge another revision into working directory
79
79
80 Change organization:
80 Change organization:
81
81
82 bookmarks create a new bookmark or list existing bookmarks
82 bookmarks create a new bookmark or list existing bookmarks
83 branch set or show the current branch name
83 branch set or show the current branch name
84 branches list repository named branches
84 branches list repository named branches
85 phase set or show the current phase name
85 phase set or show the current phase name
86 tag add one or more tags for the current or given revision
86 tag add one or more tags for the current or given revision
87 tags list repository tags
87 tags list repository tags
88
88
89 File content management:
89 File content management:
90
90
91 annotate show changeset information by line for each file
91 annotate show changeset information by line for each file
92 cat output the current or given revision of files
92 cat output the current or given revision of files
93 copy mark files as copied for the next commit
93 copy mark files as copied for the next commit
94 diff diff repository (or selected files)
94 diff diff repository (or selected files)
95 grep search revision history for a pattern in specified files
95 grep search revision history for a pattern in specified files
96
96
97 Change navigation:
97 Change navigation:
98
98
99 bisect subdivision search of changesets
99 bisect subdivision search of changesets
100 heads show branch heads
100 heads show branch heads
101 identify identify the working directory or specified revision
101 identify identify the working directory or specified revision
102 log show revision history of entire repository or files
102 log show revision history of entire repository or files
103
103
104 Working directory management:
104 Working directory management:
105
105
106 add add the specified files on the next commit
106 add add the specified files on the next commit
107 addremove add all new files, delete all missing files
107 addremove add all new files, delete all missing files
108 files list tracked files
108 files list tracked files
109 forget forget the specified files on the next commit
109 forget forget the specified files on the next commit
110 remove remove the specified files on the next commit
110 remove remove the specified files on the next commit
111 rename rename files; equivalent of copy + remove
111 rename rename files; equivalent of copy + remove
112 resolve redo merges or set/view the merge status of files
112 resolve redo merges or set/view the merge status of files
113 revert restore files to their checkout state
113 revert restore files to their checkout state
114 root print the root (top) of the current working directory
114 root print the root (top) of the current working directory
115 shelve save and set aside changes from the working directory
115 shelve save and set aside changes from the working directory
116 status show changed files in the working directory
116 status show changed files in the working directory
117 summary summarize working directory state
117 summary summarize working directory state
118 unshelve restore a shelved change to the working directory
118 unshelve restore a shelved change to the working directory
119 update update working directory (or switch revisions)
119 update update working directory (or switch revisions)
120
120
121 Change import/export:
121 Change import/export:
122
122
123 archive create an unversioned archive of a repository revision
123 archive create an unversioned archive of a repository revision
124 bundle create a bundle file
124 bundle create a bundle file
125 export dump the header and diffs for one or more changesets
125 export dump the header and diffs for one or more changesets
126 import import an ordered set of patches
126 import import an ordered set of patches
127 unbundle apply one or more bundle files
127 unbundle apply one or more bundle files
128
128
129 Repository maintenance:
129 Repository maintenance:
130
130
131 manifest output the current or given revision of the project manifest
131 manifest output the current or given revision of the project manifest
132 recover roll back an interrupted transaction
132 recover roll back an interrupted transaction
133 verify verify the integrity of the repository
133 verify verify the integrity of the repository
134
134
135 Help:
135 Help:
136
136
137 config show combined config settings from all hgrc files
137 config show combined config settings from all hgrc files
138 help show help for a given topic or a help overview
138 help show help for a given topic or a help overview
139 version output version and copyright information
139 version output version and copyright information
140
140
141 additional help topics:
141 additional help topics:
142
142
143 Mercurial identifiers:
143 Mercurial identifiers:
144
144
145 filesets Specifying File Sets
145 filesets Specifying File Sets
146 hgignore Syntax for Mercurial Ignore Files
146 hgignore Syntax for Mercurial Ignore Files
147 patterns File Name Patterns
147 patterns File Name Patterns
148 revisions Specifying Revisions
148 revisions Specifying Revisions
149 urls URL Paths
149 urls URL Paths
150
150
151 Mercurial output:
151 Mercurial output:
152
152
153 color Colorizing Outputs
153 color Colorizing Outputs
154 dates Date Formats
154 dates Date Formats
155 diffs Diff Formats
155 diffs Diff Formats
156 templating Template Usage
156 templating Template Usage
157
157
158 Mercurial configuration:
158 Mercurial configuration:
159
159
160 config Configuration Files
160 config Configuration Files
161 environment Environment Variables
161 environment Environment Variables
162 extensions Using Additional Features
162 extensions Using Additional Features
163 flags Command-line flags
163 flags Command-line flags
164 hgweb Configuring hgweb
164 hgweb Configuring hgweb
165 merge-tools Merge Tools
165 merge-tools Merge Tools
166 pager Pager Support
166 pager Pager Support
167
167
168 Concepts:
168 Concepts:
169
169
170 bundlespec Bundle File Formats
170 bundlespec Bundle File Formats
171 glossary Glossary
171 glossary Glossary
172 phases Working with Phases
172 phases Working with Phases
173 subrepos Subrepositories
173 subrepos Subrepositories
174
174
175 Miscellaneous:
175 Miscellaneous:
176
176
177 deprecated Deprecated Features
177 deprecated Deprecated Features
178 internals Technical implementation topics
178 internals Technical implementation topics
179 scripting Using Mercurial from scripts and automation
179 scripting Using Mercurial from scripts and automation
180
180
181 (use 'hg help -v' to show built-in aliases and global options)
181 (use 'hg help -v' to show built-in aliases and global options)
182
182
183 $ hg -q help
183 $ hg -q help
184 Repository creation:
184 Repository creation:
185
185
186 clone make a copy of an existing repository
186 clone make a copy of an existing repository
187 init create a new repository in the given directory
187 init create a new repository in the given directory
188
188
189 Remote repository management:
189 Remote repository management:
190
190
191 incoming show new changesets found in source
191 incoming show new changesets found in source
192 outgoing show changesets not found in the destination
192 outgoing show changesets not found in the destination
193 paths show aliases for remote repositories
193 paths show aliases for remote repositories
194 pull pull changes from the specified source
194 pull pull changes from the specified source
195 push push changes to the specified destination
195 push push changes to the specified destination
196 serve start stand-alone webserver
196 serve start stand-alone webserver
197
197
198 Change creation:
198 Change creation:
199
199
200 commit commit the specified files or all outstanding changes
200 commit commit the specified files or all outstanding changes
201
201
202 Change manipulation:
202 Change manipulation:
203
203
204 backout reverse effect of earlier changeset
204 backout reverse effect of earlier changeset
205 graft copy changes from other branches onto the current branch
205 graft copy changes from other branches onto the current branch
206 merge merge another revision into working directory
206 merge merge another revision into working directory
207
207
208 Change organization:
208 Change organization:
209
209
210 bookmarks create a new bookmark or list existing bookmarks
210 bookmarks create a new bookmark or list existing bookmarks
211 branch set or show the current branch name
211 branch set or show the current branch name
212 branches list repository named branches
212 branches list repository named branches
213 phase set or show the current phase name
213 phase set or show the current phase name
214 tag add one or more tags for the current or given revision
214 tag add one or more tags for the current or given revision
215 tags list repository tags
215 tags list repository tags
216
216
217 File content management:
217 File content management:
218
218
219 annotate show changeset information by line for each file
219 annotate show changeset information by line for each file
220 cat output the current or given revision of files
220 cat output the current or given revision of files
221 copy mark files as copied for the next commit
221 copy mark files as copied for the next commit
222 diff diff repository (or selected files)
222 diff diff repository (or selected files)
223 grep search revision history for a pattern in specified files
223 grep search revision history for a pattern in specified files
224
224
225 Change navigation:
225 Change navigation:
226
226
227 bisect subdivision search of changesets
227 bisect subdivision search of changesets
228 heads show branch heads
228 heads show branch heads
229 identify identify the working directory or specified revision
229 identify identify the working directory or specified revision
230 log show revision history of entire repository or files
230 log show revision history of entire repository or files
231
231
232 Working directory management:
232 Working directory management:
233
233
234 add add the specified files on the next commit
234 add add the specified files on the next commit
235 addremove add all new files, delete all missing files
235 addremove add all new files, delete all missing files
236 files list tracked files
236 files list tracked files
237 forget forget the specified files on the next commit
237 forget forget the specified files on the next commit
238 remove remove the specified files on the next commit
238 remove remove the specified files on the next commit
239 rename rename files; equivalent of copy + remove
239 rename rename files; equivalent of copy + remove
240 resolve redo merges or set/view the merge status of files
240 resolve redo merges or set/view the merge status of files
241 revert restore files to their checkout state
241 revert restore files to their checkout state
242 root print the root (top) of the current working directory
242 root print the root (top) of the current working directory
243 shelve save and set aside changes from the working directory
243 shelve save and set aside changes from the working directory
244 status show changed files in the working directory
244 status show changed files in the working directory
245 summary summarize working directory state
245 summary summarize working directory state
246 unshelve restore a shelved change to the working directory
246 unshelve restore a shelved change to the working directory
247 update update working directory (or switch revisions)
247 update update working directory (or switch revisions)
248
248
249 Change import/export:
249 Change import/export:
250
250
251 archive create an unversioned archive of a repository revision
251 archive create an unversioned archive of a repository revision
252 bundle create a bundle file
252 bundle create a bundle file
253 export dump the header and diffs for one or more changesets
253 export dump the header and diffs for one or more changesets
254 import import an ordered set of patches
254 import import an ordered set of patches
255 unbundle apply one or more bundle files
255 unbundle apply one or more bundle files
256
256
257 Repository maintenance:
257 Repository maintenance:
258
258
259 manifest output the current or given revision of the project manifest
259 manifest output the current or given revision of the project manifest
260 recover roll back an interrupted transaction
260 recover roll back an interrupted transaction
261 verify verify the integrity of the repository
261 verify verify the integrity of the repository
262
262
263 Help:
263 Help:
264
264
265 config show combined config settings from all hgrc files
265 config show combined config settings from all hgrc files
266 help show help for a given topic or a help overview
266 help show help for a given topic or a help overview
267 version output version and copyright information
267 version output version and copyright information
268
268
269 additional help topics:
269 additional help topics:
270
270
271 Mercurial identifiers:
271 Mercurial identifiers:
272
272
273 filesets Specifying File Sets
273 filesets Specifying File Sets
274 hgignore Syntax for Mercurial Ignore Files
274 hgignore Syntax for Mercurial Ignore Files
275 patterns File Name Patterns
275 patterns File Name Patterns
276 revisions Specifying Revisions
276 revisions Specifying Revisions
277 urls URL Paths
277 urls URL Paths
278
278
279 Mercurial output:
279 Mercurial output:
280
280
281 color Colorizing Outputs
281 color Colorizing Outputs
282 dates Date Formats
282 dates Date Formats
283 diffs Diff Formats
283 diffs Diff Formats
284 templating Template Usage
284 templating Template Usage
285
285
286 Mercurial configuration:
286 Mercurial configuration:
287
287
288 config Configuration Files
288 config Configuration Files
289 environment Environment Variables
289 environment Environment Variables
290 extensions Using Additional Features
290 extensions Using Additional Features
291 flags Command-line flags
291 flags Command-line flags
292 hgweb Configuring hgweb
292 hgweb Configuring hgweb
293 merge-tools Merge Tools
293 merge-tools Merge Tools
294 pager Pager Support
294 pager Pager Support
295
295
296 Concepts:
296 Concepts:
297
297
298 bundlespec Bundle File Formats
298 bundlespec Bundle File Formats
299 glossary Glossary
299 glossary Glossary
300 phases Working with Phases
300 phases Working with Phases
301 subrepos Subrepositories
301 subrepos Subrepositories
302
302
303 Miscellaneous:
303 Miscellaneous:
304
304
305 deprecated Deprecated Features
305 deprecated Deprecated Features
306 internals Technical implementation topics
306 internals Technical implementation topics
307 scripting Using Mercurial from scripts and automation
307 scripting Using Mercurial from scripts and automation
308
308
309 Test extension help:
309 Test extension help:
310 $ hg help extensions --config extensions.rebase= --config extensions.children=
310 $ hg help extensions --config extensions.rebase= --config extensions.children=
311 Using Additional Features
311 Using Additional Features
312 """""""""""""""""""""""""
312 """""""""""""""""""""""""
313
313
314 Mercurial has the ability to add new features through the use of
314 Mercurial has the ability to add new features through the use of
315 extensions. Extensions may add new commands, add options to existing
315 extensions. Extensions may add new commands, add options to existing
316 commands, change the default behavior of commands, or implement hooks.
316 commands, change the default behavior of commands, or implement hooks.
317
317
318 To enable the "foo" extension, either shipped with Mercurial or in the
318 To enable the "foo" extension, either shipped with Mercurial or in the
319 Python search path, create an entry for it in your configuration file,
319 Python search path, create an entry for it in your configuration file,
320 like this:
320 like this:
321
321
322 [extensions]
322 [extensions]
323 foo =
323 foo =
324
324
325 You may also specify the full path to an extension:
325 You may also specify the full path to an extension:
326
326
327 [extensions]
327 [extensions]
328 myfeature = ~/.hgext/myfeature.py
328 myfeature = ~/.hgext/myfeature.py
329
329
330 See 'hg help config' for more information on configuration files.
330 See 'hg help config' for more information on configuration files.
331
331
332 Extensions are not loaded by default for a variety of reasons: they can
332 Extensions are not loaded by default for a variety of reasons: they can
333 increase startup overhead; they may be meant for advanced usage only; they
333 increase startup overhead; they may be meant for advanced usage only; they
334 may provide potentially dangerous abilities (such as letting you destroy
334 may provide potentially dangerous abilities (such as letting you destroy
335 or modify history); they might not be ready for prime time; or they may
335 or modify history); they might not be ready for prime time; or they may
336 alter some usual behaviors of stock Mercurial. It is thus up to the user
336 alter some usual behaviors of stock Mercurial. It is thus up to the user
337 to activate extensions as needed.
337 to activate extensions as needed.
338
338
339 To explicitly disable an extension enabled in a configuration file of
339 To explicitly disable an extension enabled in a configuration file of
340 broader scope, prepend its path with !:
340 broader scope, prepend its path with !:
341
341
342 [extensions]
342 [extensions]
343 # disabling extension bar residing in /path/to/extension/bar.py
343 # disabling extension bar residing in /path/to/extension/bar.py
344 bar = !/path/to/extension/bar.py
344 bar = !/path/to/extension/bar.py
345 # ditto, but no path was supplied for extension baz
345 # ditto, but no path was supplied for extension baz
346 baz = !
346 baz = !
347
347
348 enabled extensions:
348 enabled extensions:
349
349
350 children command to display child changesets (DEPRECATED)
350 children command to display child changesets (DEPRECATED)
351 rebase command to move sets of revisions to a different ancestor
351 rebase command to move sets of revisions to a different ancestor
352
352
353 disabled extensions:
353 disabled extensions:
354
354
355 acl hooks for controlling repository access
355 acl hooks for controlling repository access
356 blackbox log repository events to a blackbox for debugging
356 blackbox log repository events to a blackbox for debugging
357 bugzilla hooks for integrating with the Bugzilla bug tracker
357 bugzilla hooks for integrating with the Bugzilla bug tracker
358 censor erase file content at a given revision
358 censor erase file content at a given revision
359 churn command to display statistics about repository history
359 churn command to display statistics about repository history
360 clonebundles advertise pre-generated bundles to seed clones
360 clonebundles advertise pre-generated bundles to seed clones
361 closehead close arbitrary heads without checking them out first
361 closehead close arbitrary heads without checking them out first
362 convert import revisions from foreign VCS repositories into
362 convert import revisions from foreign VCS repositories into
363 Mercurial
363 Mercurial
364 eol automatically manage newlines in repository files
364 eol automatically manage newlines in repository files
365 extdiff command to allow external programs to compare revisions
365 extdiff command to allow external programs to compare revisions
366 factotum http authentication with factotum
366 factotum http authentication with factotum
367 githelp try mapping git commands to Mercurial commands
367 githelp try mapping git commands to Mercurial commands
368 gpg commands to sign and verify changesets
368 gpg commands to sign and verify changesets
369 hgk browse the repository in a graphical way
369 hgk browse the repository in a graphical way
370 highlight syntax highlighting for hgweb (requires Pygments)
370 highlight syntax highlighting for hgweb (requires Pygments)
371 histedit interactive history editing
371 histedit interactive history editing
372 keyword expand keywords in tracked files
372 keyword expand keywords in tracked files
373 largefiles track large binary files
373 largefiles track large binary files
374 mq manage a stack of patches
374 mq manage a stack of patches
375 notify hooks for sending email push notifications
375 notify hooks for sending email push notifications
376 patchbomb command to send changesets as (a series of) patch emails
376 patchbomb command to send changesets as (a series of) patch emails
377 purge command to delete untracked files from the working
377 purge command to delete untracked files from the working
378 directory
378 directory
379 relink recreates hardlinks between repository clones
379 relink recreates hardlinks between repository clones
380 schemes extend schemes with shortcuts to repository swarms
380 schemes extend schemes with shortcuts to repository swarms
381 share share a common history between several working directories
381 share share a common history between several working directories
382 strip strip changesets and their descendants from history
382 strip strip changesets and their descendants from history
383 transplant command to transplant changesets from another branch
383 transplant command to transplant changesets from another branch
384 win32mbcs allow the use of MBCS paths with problematic encodings
384 win32mbcs allow the use of MBCS paths with problematic encodings
385 zeroconf discover and advertise repositories on the local network
385 zeroconf discover and advertise repositories on the local network
386
386
387 #endif
387 #endif
388
388
389 Verify that deprecated extensions are included if --verbose:
389 Verify that deprecated extensions are included if --verbose:
390
390
391 $ hg -v help extensions | grep children
391 $ hg -v help extensions | grep children
392 children command to display child changesets (DEPRECATED)
392 children command to display child changesets (DEPRECATED)
393
393
394 Verify that extension keywords appear in help templates
394 Verify that extension keywords appear in help templates
395
395
396 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
396 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
397
397
398 Test short command list with verbose option
398 Test short command list with verbose option
399
399
400 $ hg -v help shortlist
400 $ hg -v help shortlist
401 Mercurial Distributed SCM
401 Mercurial Distributed SCM
402
402
403 basic commands:
403 basic commands:
404
404
405 abort abort an unfinished operation (EXPERIMENTAL)
405 abort abort an unfinished operation (EXPERIMENTAL)
406 add add the specified files on the next commit
406 add add the specified files on the next commit
407 annotate, blame
407 annotate, blame
408 show changeset information by line for each file
408 show changeset information by line for each file
409 clone make a copy of an existing repository
409 clone make a copy of an existing repository
410 commit, ci commit the specified files or all outstanding changes
410 commit, ci commit the specified files or all outstanding changes
411 continue resumes an interrupted operation (EXPERIMENTAL)
411 continue resumes an interrupted operation (EXPERIMENTAL)
412 diff diff repository (or selected files)
412 diff diff repository (or selected files)
413 export dump the header and diffs for one or more changesets
413 export dump the header and diffs for one or more changesets
414 forget forget the specified files on the next commit
414 forget forget the specified files on the next commit
415 init create a new repository in the given directory
415 init create a new repository in the given directory
416 log, history show revision history of entire repository or files
416 log, history show revision history of entire repository or files
417 merge merge another revision into working directory
417 merge merge another revision into working directory
418 pull pull changes from the specified source
418 pull pull changes from the specified source
419 push push changes to the specified destination
419 push push changes to the specified destination
420 remove, rm remove the specified files on the next commit
420 remove, rm remove the specified files on the next commit
421 serve start stand-alone webserver
421 serve start stand-alone webserver
422 status, st show changed files in the working directory
422 status, st show changed files in the working directory
423 summary, sum summarize working directory state
423 summary, sum summarize working directory state
424 update, up, checkout, co
424 update, up, checkout, co
425 update working directory (or switch revisions)
425 update working directory (or switch revisions)
426
426
427 global options ([+] can be repeated):
427 global options ([+] can be repeated):
428
428
429 -R --repository REPO repository root directory or name of overlay bundle
429 -R --repository REPO repository root directory or name of overlay bundle
430 file
430 file
431 --cwd DIR change working directory
431 --cwd DIR change working directory
432 -y --noninteractive do not prompt, automatically pick the first choice for
432 -y --noninteractive do not prompt, automatically pick the first choice for
433 all prompts
433 all prompts
434 -q --quiet suppress output
434 -q --quiet suppress output
435 -v --verbose enable additional output
435 -v --verbose enable additional output
436 --color TYPE when to colorize (boolean, always, auto, never, or
436 --color TYPE when to colorize (boolean, always, auto, never, or
437 debug)
437 debug)
438 --config CONFIG [+] set/override config option (use 'section.name=value')
438 --config CONFIG [+] set/override config option (use 'section.name=value')
439 --debug enable debugging output
439 --debug enable debugging output
440 --debugger start debugger
440 --debugger start debugger
441 --encoding ENCODE set the charset encoding (default: ascii)
441 --encoding ENCODE set the charset encoding (default: ascii)
442 --encodingmode MODE set the charset encoding mode (default: strict)
442 --encodingmode MODE set the charset encoding mode (default: strict)
443 --traceback always print a traceback on exception
443 --traceback always print a traceback on exception
444 --time time how long the command takes
444 --time time how long the command takes
445 --profile print command execution profile
445 --profile print command execution profile
446 --version output version information and exit
446 --version output version information and exit
447 -h --help display help and exit
447 -h --help display help and exit
448 --hidden consider hidden changesets
448 --hidden consider hidden changesets
449 --pager TYPE when to paginate (boolean, always, auto, or never)
449 --pager TYPE when to paginate (boolean, always, auto, or never)
450 (default: auto)
450 (default: auto)
451
451
452 (use 'hg help' for the full list of commands)
452 (use 'hg help' for the full list of commands)
453
453
454 $ hg add -h
454 $ hg add -h
455 hg add [OPTION]... [FILE]...
455 hg add [OPTION]... [FILE]...
456
456
457 add the specified files on the next commit
457 add the specified files on the next commit
458
458
459 Schedule files to be version controlled and added to the repository.
459 Schedule files to be version controlled and added to the repository.
460
460
461 The files will be added to the repository at the next commit. To undo an
461 The files will be added to the repository at the next commit. To undo an
462 add before that, see 'hg forget'.
462 add before that, see 'hg forget'.
463
463
464 If no names are given, add all files to the repository (except files
464 If no names are given, add all files to the repository (except files
465 matching ".hgignore").
465 matching ".hgignore").
466
466
467 Returns 0 if all files are successfully added.
467 Returns 0 if all files are successfully added.
468
468
469 options ([+] can be repeated):
469 options ([+] can be repeated):
470
470
471 -I --include PATTERN [+] include names matching the given patterns
471 -I --include PATTERN [+] include names matching the given patterns
472 -X --exclude PATTERN [+] exclude names matching the given patterns
472 -X --exclude PATTERN [+] exclude names matching the given patterns
473 -S --subrepos recurse into subrepositories
473 -S --subrepos recurse into subrepositories
474 -n --dry-run do not perform actions, just print output
474 -n --dry-run do not perform actions, just print output
475
475
476 (some details hidden, use --verbose to show complete help)
476 (some details hidden, use --verbose to show complete help)
477
477
478 Verbose help for add
478 Verbose help for add
479
479
480 $ hg add -hv
480 $ hg add -hv
481 hg add [OPTION]... [FILE]...
481 hg add [OPTION]... [FILE]...
482
482
483 add the specified files on the next commit
483 add the specified files on the next commit
484
484
485 Schedule files to be version controlled and added to the repository.
485 Schedule files to be version controlled and added to the repository.
486
486
487 The files will be added to the repository at the next commit. To undo an
487 The files will be added to the repository at the next commit. To undo an
488 add before that, see 'hg forget'.
488 add before that, see 'hg forget'.
489
489
490 If no names are given, add all files to the repository (except files
490 If no names are given, add all files to the repository (except files
491 matching ".hgignore").
491 matching ".hgignore").
492
492
493 Examples:
493 Examples:
494
494
495 - New (unknown) files are added automatically by 'hg add':
495 - New (unknown) files are added automatically by 'hg add':
496
496
497 $ ls
497 $ ls
498 foo.c
498 foo.c
499 $ hg status
499 $ hg status
500 ? foo.c
500 ? foo.c
501 $ hg add
501 $ hg add
502 adding foo.c
502 adding foo.c
503 $ hg status
503 $ hg status
504 A foo.c
504 A foo.c
505
505
506 - Specific files to be added can be specified:
506 - Specific files to be added can be specified:
507
507
508 $ ls
508 $ ls
509 bar.c foo.c
509 bar.c foo.c
510 $ hg status
510 $ hg status
511 ? bar.c
511 ? bar.c
512 ? foo.c
512 ? foo.c
513 $ hg add bar.c
513 $ hg add bar.c
514 $ hg status
514 $ hg status
515 A bar.c
515 A bar.c
516 ? foo.c
516 ? foo.c
517
517
518 Returns 0 if all files are successfully added.
518 Returns 0 if all files are successfully added.
519
519
520 options ([+] can be repeated):
520 options ([+] can be repeated):
521
521
522 -I --include PATTERN [+] include names matching the given patterns
522 -I --include PATTERN [+] include names matching the given patterns
523 -X --exclude PATTERN [+] exclude names matching the given patterns
523 -X --exclude PATTERN [+] exclude names matching the given patterns
524 -S --subrepos recurse into subrepositories
524 -S --subrepos recurse into subrepositories
525 -n --dry-run do not perform actions, just print output
525 -n --dry-run do not perform actions, just print output
526
526
527 global options ([+] can be repeated):
527 global options ([+] can be repeated):
528
528
529 -R --repository REPO repository root directory or name of overlay bundle
529 -R --repository REPO repository root directory or name of overlay bundle
530 file
530 file
531 --cwd DIR change working directory
531 --cwd DIR change working directory
532 -y --noninteractive do not prompt, automatically pick the first choice for
532 -y --noninteractive do not prompt, automatically pick the first choice for
533 all prompts
533 all prompts
534 -q --quiet suppress output
534 -q --quiet suppress output
535 -v --verbose enable additional output
535 -v --verbose enable additional output
536 --color TYPE when to colorize (boolean, always, auto, never, or
536 --color TYPE when to colorize (boolean, always, auto, never, or
537 debug)
537 debug)
538 --config CONFIG [+] set/override config option (use 'section.name=value')
538 --config CONFIG [+] set/override config option (use 'section.name=value')
539 --debug enable debugging output
539 --debug enable debugging output
540 --debugger start debugger
540 --debugger start debugger
541 --encoding ENCODE set the charset encoding (default: ascii)
541 --encoding ENCODE set the charset encoding (default: ascii)
542 --encodingmode MODE set the charset encoding mode (default: strict)
542 --encodingmode MODE set the charset encoding mode (default: strict)
543 --traceback always print a traceback on exception
543 --traceback always print a traceback on exception
544 --time time how long the command takes
544 --time time how long the command takes
545 --profile print command execution profile
545 --profile print command execution profile
546 --version output version information and exit
546 --version output version information and exit
547 -h --help display help and exit
547 -h --help display help and exit
548 --hidden consider hidden changesets
548 --hidden consider hidden changesets
549 --pager TYPE when to paginate (boolean, always, auto, or never)
549 --pager TYPE when to paginate (boolean, always, auto, or never)
550 (default: auto)
550 (default: auto)
551
551
552 Test the textwidth config option
552 Test the textwidth config option
553
553
554 $ hg root -h --config ui.textwidth=50
554 $ hg root -h --config ui.textwidth=50
555 hg root
555 hg root
556
556
557 print the root (top) of the current working
557 print the root (top) of the current working
558 directory
558 directory
559
559
560 Print the root directory of the current
560 Print the root directory of the current
561 repository.
561 repository.
562
562
563 Returns 0 on success.
563 Returns 0 on success.
564
564
565 options:
565 options:
566
566
567 -T --template TEMPLATE display with template
567 -T --template TEMPLATE display with template
568
568
569 (some details hidden, use --verbose to show
569 (some details hidden, use --verbose to show
570 complete help)
570 complete help)
571
571
572 Test help option with version option
572 Test help option with version option
573
573
574 $ hg add -h --version
574 $ hg add -h --version
575 Mercurial Distributed SCM (version *) (glob)
575 Mercurial Distributed SCM (version *) (glob)
576 (see https://mercurial-scm.org for more information)
576 (see https://mercurial-scm.org for more information)
577
577
578 Copyright (C) 2005-* Matt Mackall and others (glob)
578 Copyright (C) 2005-* Matt Mackall and others (glob)
579 This is free software; see the source for copying conditions. There is NO
579 This is free software; see the source for copying conditions. There is NO
580 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
580 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
581
581
582 $ hg add --skjdfks
582 $ hg add --skjdfks
583 hg add: option --skjdfks not recognized
583 hg add: option --skjdfks not recognized
584 hg add [OPTION]... [FILE]...
584 hg add [OPTION]... [FILE]...
585
585
586 add the specified files on the next commit
586 add the specified files on the next commit
587
587
588 options ([+] can be repeated):
588 options ([+] can be repeated):
589
589
590 -I --include PATTERN [+] include names matching the given patterns
590 -I --include PATTERN [+] include names matching the given patterns
591 -X --exclude PATTERN [+] exclude names matching the given patterns
591 -X --exclude PATTERN [+] exclude names matching the given patterns
592 -S --subrepos recurse into subrepositories
592 -S --subrepos recurse into subrepositories
593 -n --dry-run do not perform actions, just print output
593 -n --dry-run do not perform actions, just print output
594
594
595 (use 'hg add -h' to show more help)
595 (use 'hg add -h' to show more help)
596 [255]
596 [255]
597
597
598 Test ambiguous command help
598 Test ambiguous command help
599
599
600 $ hg help ad
600 $ hg help ad
601 list of commands:
601 list of commands:
602
602
603 add add the specified files on the next commit
603 add add the specified files on the next commit
604 addremove add all new files, delete all missing files
604 addremove add all new files, delete all missing files
605
605
606 (use 'hg help -v ad' to show built-in aliases and global options)
606 (use 'hg help -v ad' to show built-in aliases and global options)
607
607
608 Test command without options
608 Test command without options
609
609
610 $ hg help verify
610 $ hg help verify
611 hg verify
611 hg verify
612
612
613 verify the integrity of the repository
613 verify the integrity of the repository
614
614
615 Verify the integrity of the current repository.
615 Verify the integrity of the current repository.
616
616
617 This will perform an extensive check of the repository's integrity,
617 This will perform an extensive check of the repository's integrity,
618 validating the hashes and checksums of each entry in the changelog,
618 validating the hashes and checksums of each entry in the changelog,
619 manifest, and tracked files, as well as the integrity of their crosslinks
619 manifest, and tracked files, as well as the integrity of their crosslinks
620 and indices.
620 and indices.
621
621
622 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
622 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
623 information about recovery from corruption of the repository.
623 information about recovery from corruption of the repository.
624
624
625 Returns 0 on success, 1 if errors are encountered.
625 Returns 0 on success, 1 if errors are encountered.
626
626
627 options:
627 options:
628
628
629 (some details hidden, use --verbose to show complete help)
629 (some details hidden, use --verbose to show complete help)
630
630
631 $ hg help diff
631 $ hg help diff
632 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
632 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
633
633
634 diff repository (or selected files)
634 diff repository (or selected files)
635
635
636 Show differences between revisions for the specified files.
636 Show differences between revisions for the specified files.
637
637
638 Differences between files are shown using the unified diff format.
638 Differences between files are shown using the unified diff format.
639
639
640 Note:
640 Note:
641 'hg diff' may generate unexpected results for merges, as it will
641 'hg diff' may generate unexpected results for merges, as it will
642 default to comparing against the working directory's first parent
642 default to comparing against the working directory's first parent
643 changeset if no revisions are specified.
643 changeset if no revisions are specified.
644
644
645 When two revision arguments are given, then changes are shown between
645 When two revision arguments are given, then changes are shown between
646 those revisions. If only one revision is specified then that revision is
646 those revisions. If only one revision is specified then that revision is
647 compared to the working directory, and, when no revisions are specified,
647 compared to the working directory, and, when no revisions are specified,
648 the working directory files are compared to its first parent.
648 the working directory files are compared to its first parent.
649
649
650 Alternatively you can specify -c/--change with a revision to see the
650 Alternatively you can specify -c/--change with a revision to see the
651 changes in that changeset relative to its first parent.
651 changes in that changeset relative to its first parent.
652
652
653 Without the -a/--text option, diff will avoid generating diffs of files it
653 Without the -a/--text option, diff will avoid generating diffs of files it
654 detects as binary. With -a, diff will generate a diff anyway, probably
654 detects as binary. With -a, diff will generate a diff anyway, probably
655 with undesirable results.
655 with undesirable results.
656
656
657 Use the -g/--git option to generate diffs in the git extended diff format.
657 Use the -g/--git option to generate diffs in the git extended diff format.
658 For more information, read 'hg help diffs'.
658 For more information, read 'hg help diffs'.
659
659
660 Returns 0 on success.
660 Returns 0 on success.
661
661
662 options ([+] can be repeated):
662 options ([+] can be repeated):
663
663
664 -r --rev REV [+] revision
664 -r --rev REV [+] revision
665 -c --change REV change made by revision
665 -c --change REV change made by revision
666 -a --text treat all files as text
666 -a --text treat all files as text
667 -g --git use git extended diff format
667 -g --git use git extended diff format
668 --binary generate binary diffs in git mode (default)
668 --binary generate binary diffs in git mode (default)
669 --nodates omit dates from diff headers
669 --nodates omit dates from diff headers
670 --noprefix omit a/ and b/ prefixes from filenames
670 --noprefix omit a/ and b/ prefixes from filenames
671 -p --show-function show which function each change is in
671 -p --show-function show which function each change is in
672 --reverse produce a diff that undoes the changes
672 --reverse produce a diff that undoes the changes
673 -w --ignore-all-space ignore white space when comparing lines
673 -w --ignore-all-space ignore white space when comparing lines
674 -b --ignore-space-change ignore changes in the amount of white space
674 -b --ignore-space-change ignore changes in the amount of white space
675 -B --ignore-blank-lines ignore changes whose lines are all blank
675 -B --ignore-blank-lines ignore changes whose lines are all blank
676 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
676 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
677 -U --unified NUM number of lines of context to show
677 -U --unified NUM number of lines of context to show
678 --stat output diffstat-style summary of changes
678 --stat output diffstat-style summary of changes
679 --root DIR produce diffs relative to subdirectory
679 --root DIR produce diffs relative to subdirectory
680 -I --include PATTERN [+] include names matching the given patterns
680 -I --include PATTERN [+] include names matching the given patterns
681 -X --exclude PATTERN [+] exclude names matching the given patterns
681 -X --exclude PATTERN [+] exclude names matching the given patterns
682 -S --subrepos recurse into subrepositories
682 -S --subrepos recurse into subrepositories
683
683
684 (some details hidden, use --verbose to show complete help)
684 (some details hidden, use --verbose to show complete help)
685
685
686 $ hg help status
686 $ hg help status
687 hg status [OPTION]... [FILE]...
687 hg status [OPTION]... [FILE]...
688
688
689 aliases: st
689 aliases: st
690
690
691 show changed files in the working directory
691 show changed files in the working directory
692
692
693 Show status of files in the repository. If names are given, only files
693 Show status of files in the repository. If names are given, only files
694 that match are shown. Files that are clean or ignored or the source of a
694 that match are shown. Files that are clean or ignored or the source of a
695 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
695 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
696 -C/--copies or -A/--all are given. Unless options described with "show
696 -C/--copies or -A/--all are given. Unless options described with "show
697 only ..." are given, the options -mardu are used.
697 only ..." are given, the options -mardu are used.
698
698
699 Option -q/--quiet hides untracked (unknown and ignored) files unless
699 Option -q/--quiet hides untracked (unknown and ignored) files unless
700 explicitly requested with -u/--unknown or -i/--ignored.
700 explicitly requested with -u/--unknown or -i/--ignored.
701
701
702 Note:
702 Note:
703 'hg status' may appear to disagree with diff if permissions have
703 'hg status' may appear to disagree with diff if permissions have
704 changed or a merge has occurred. The standard diff format does not
704 changed or a merge has occurred. The standard diff format does not
705 report permission changes and diff only reports changes relative to one
705 report permission changes and diff only reports changes relative to one
706 merge parent.
706 merge parent.
707
707
708 If one revision is given, it is used as the base revision. If two
708 If one revision is given, it is used as the base revision. If two
709 revisions are given, the differences between them are shown. The --change
709 revisions are given, the differences between them are shown. The --change
710 option can also be used as a shortcut to list the changed files of a
710 option can also be used as a shortcut to list the changed files of a
711 revision from its first parent.
711 revision from its first parent.
712
712
713 The codes used to show the status of files are:
713 The codes used to show the status of files are:
714
714
715 M = modified
715 M = modified
716 A = added
716 A = added
717 R = removed
717 R = removed
718 C = clean
718 C = clean
719 ! = missing (deleted by non-hg command, but still tracked)
719 ! = missing (deleted by non-hg command, but still tracked)
720 ? = not tracked
720 ? = not tracked
721 I = ignored
721 I = ignored
722 = origin of the previous file (with --copies)
722 = origin of the previous file (with --copies)
723
723
724 Returns 0 on success.
724 Returns 0 on success.
725
725
726 options ([+] can be repeated):
726 options ([+] can be repeated):
727
727
728 -A --all show status of all files
728 -A --all show status of all files
729 -m --modified show only modified files
729 -m --modified show only modified files
730 -a --added show only added files
730 -a --added show only added files
731 -r --removed show only removed files
731 -r --removed show only removed files
732 -d --deleted show only deleted (but tracked) files
732 -d --deleted show only deleted (but tracked) files
733 -c --clean show only files without changes
733 -c --clean show only files without changes
734 -u --unknown show only unknown (not tracked) files
734 -u --unknown show only unknown (not tracked) files
735 -i --ignored show only ignored files
735 -i --ignored show only ignored files
736 -n --no-status hide status prefix
736 -n --no-status hide status prefix
737 -C --copies show source of copied files
737 -C --copies show source of copied files
738 -0 --print0 end filenames with NUL, for use with xargs
738 -0 --print0 end filenames with NUL, for use with xargs
739 --rev REV [+] show difference from revision
739 --rev REV [+] show difference from revision
740 --change REV list the changed files of a revision
740 --change REV list the changed files of a revision
741 -I --include PATTERN [+] include names matching the given patterns
741 -I --include PATTERN [+] include names matching the given patterns
742 -X --exclude PATTERN [+] exclude names matching the given patterns
742 -X --exclude PATTERN [+] exclude names matching the given patterns
743 -S --subrepos recurse into subrepositories
743 -S --subrepos recurse into subrepositories
744 -T --template TEMPLATE display with template
744 -T --template TEMPLATE display with template
745
745
746 (some details hidden, use --verbose to show complete help)
746 (some details hidden, use --verbose to show complete help)
747
747
748 $ hg -q help status
748 $ hg -q help status
749 hg status [OPTION]... [FILE]...
749 hg status [OPTION]... [FILE]...
750
750
751 show changed files in the working directory
751 show changed files in the working directory
752
752
753 $ hg help foo
753 $ hg help foo
754 abort: no such help topic: foo
754 abort: no such help topic: foo
755 (try 'hg help --keyword foo')
755 (try 'hg help --keyword foo')
756 [255]
756 [255]
757
757
758 $ hg skjdfks
758 $ hg skjdfks
759 hg: unknown command 'skjdfks'
759 hg: unknown command 'skjdfks'
760 (use 'hg help' for a list of commands)
760 (use 'hg help' for a list of commands)
761 [255]
761 [255]
762
762
763 Typoed command gives suggestion
763 Typoed command gives suggestion
764 $ hg puls
764 $ hg puls
765 hg: unknown command 'puls'
765 hg: unknown command 'puls'
766 (did you mean one of pull, push?)
766 (did you mean one of pull, push?)
767 [255]
767 [255]
768
768
769 Not enabled extension gets suggested
769 Not enabled extension gets suggested
770
770
771 $ hg rebase
771 $ hg rebase
772 hg: unknown command 'rebase'
772 hg: unknown command 'rebase'
773 'rebase' is provided by the following extension:
773 'rebase' is provided by the following extension:
774
774
775 rebase command to move sets of revisions to a different ancestor
775 rebase command to move sets of revisions to a different ancestor
776
776
777 (use 'hg help extensions' for information on enabling extensions)
777 (use 'hg help extensions' for information on enabling extensions)
778 [255]
778 [255]
779
779
780 Disabled extension gets suggested
780 Disabled extension gets suggested
781 $ hg --config extensions.rebase=! rebase
781 $ hg --config extensions.rebase=! rebase
782 hg: unknown command 'rebase'
782 hg: unknown command 'rebase'
783 'rebase' is provided by the following extension:
783 'rebase' is provided by the following extension:
784
784
785 rebase command to move sets of revisions to a different ancestor
785 rebase command to move sets of revisions to a different ancestor
786
786
787 (use 'hg help extensions' for information on enabling extensions)
787 (use 'hg help extensions' for information on enabling extensions)
788 [255]
788 [255]
789
789
790 Make sure that we don't run afoul of the help system thinking that
790 Make sure that we don't run afoul of the help system thinking that
791 this is a section and erroring out weirdly.
791 this is a section and erroring out weirdly.
792
792
793 $ hg .log
793 $ hg .log
794 hg: unknown command '.log'
794 hg: unknown command '.log'
795 (did you mean log?)
795 (did you mean log?)
796 [255]
796 [255]
797
797
798 $ hg log.
798 $ hg log.
799 hg: unknown command 'log.'
799 hg: unknown command 'log.'
800 (did you mean log?)
800 (did you mean log?)
801 [255]
801 [255]
802 $ hg pu.lh
802 $ hg pu.lh
803 hg: unknown command 'pu.lh'
803 hg: unknown command 'pu.lh'
804 (did you mean one of pull, push?)
804 (did you mean one of pull, push?)
805 [255]
805 [255]
806
806
807 $ cat > helpext.py <<EOF
807 $ cat > helpext.py <<EOF
808 > import os
808 > import os
809 > from mercurial import commands, fancyopts, registrar
809 > from mercurial import commands, fancyopts, registrar
810 >
810 >
811 > def func(arg):
811 > def func(arg):
812 > return '%sfoo' % arg
812 > return '%sfoo' % arg
813 > class customopt(fancyopts.customopt):
813 > class customopt(fancyopts.customopt):
814 > def newstate(self, oldstate, newparam, abort):
814 > def newstate(self, oldstate, newparam, abort):
815 > return '%sbar' % oldstate
815 > return '%sbar' % oldstate
816 > cmdtable = {}
816 > cmdtable = {}
817 > command = registrar.command(cmdtable)
817 > command = registrar.command(cmdtable)
818 >
818 >
819 > @command(b'nohelp',
819 > @command(b'nohelp',
820 > [(b'', b'longdesc', 3, b'x'*67),
820 > [(b'', b'longdesc', 3, b'x'*67),
821 > (b'n', b'', None, b'normal desc'),
821 > (b'n', b'', None, b'normal desc'),
822 > (b'', b'newline', b'', b'line1\nline2'),
822 > (b'', b'newline', b'', b'line1\nline2'),
823 > (b'', b'default-off', False, b'enable X'),
823 > (b'', b'default-off', False, b'enable X'),
824 > (b'', b'default-on', True, b'enable Y'),
824 > (b'', b'default-on', True, b'enable Y'),
825 > (b'', b'callableopt', func, b'adds foo'),
825 > (b'', b'callableopt', func, b'adds foo'),
826 > (b'', b'customopt', customopt(''), b'adds bar'),
826 > (b'', b'customopt', customopt(''), b'adds bar'),
827 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
827 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
828 > b'hg nohelp',
828 > b'hg nohelp',
829 > norepo=True)
829 > norepo=True)
830 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
830 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
831 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
831 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
832 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
832 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
833 > def nohelp(ui, *args, **kwargs):
833 > def nohelp(ui, *args, **kwargs):
834 > pass
834 > pass
835 >
835 >
836 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
836 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
837 > def hashelp(ui, *args, **kwargs):
837 > def hashelp(ui, *args, **kwargs):
838 > """Extension command's help"""
838 > """Extension command's help"""
839 >
839 >
840 > def uisetup(ui):
840 > def uisetup(ui):
841 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
841 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
842 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
842 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
843 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
843 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
844 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
844 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
845 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
845 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
846 >
846 >
847 > EOF
847 > EOF
848 $ echo '[extensions]' >> $HGRCPATH
848 $ echo '[extensions]' >> $HGRCPATH
849 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
849 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
850
850
851 Test for aliases
851 Test for aliases
852
852
853 $ hg help | grep hgalias
853 $ hg help | grep hgalias
854 hgalias My doc
854 hgalias My doc
855
855
856 $ hg help hgalias
856 $ hg help hgalias
857 hg hgalias [--remote]
857 hg hgalias [--remote]
858
858
859 alias for: hg summary
859 alias for: hg summary
860
860
861 My doc
861 My doc
862
862
863 defined by: helpext
863 defined by: helpext
864
864
865 options:
865 options:
866
866
867 --remote check for push and pull
867 --remote check for push and pull
868
868
869 (some details hidden, use --verbose to show complete help)
869 (some details hidden, use --verbose to show complete help)
870 $ hg help hgaliasnodoc
870 $ hg help hgaliasnodoc
871 hg hgaliasnodoc [--remote]
871 hg hgaliasnodoc [--remote]
872
872
873 alias for: hg summary
873 alias for: hg summary
874
874
875 summarize working directory state
875 summarize working directory state
876
876
877 This generates a brief summary of the working directory state, including
877 This generates a brief summary of the working directory state, including
878 parents, branch, commit status, phase and available updates.
878 parents, branch, commit status, phase and available updates.
879
879
880 With the --remote option, this will check the default paths for incoming
880 With the --remote option, this will check the default paths for incoming
881 and outgoing changes. This can be time-consuming.
881 and outgoing changes. This can be time-consuming.
882
882
883 Returns 0 on success.
883 Returns 0 on success.
884
884
885 defined by: helpext
885 defined by: helpext
886
886
887 options:
887 options:
888
888
889 --remote check for push and pull
889 --remote check for push and pull
890
890
891 (some details hidden, use --verbose to show complete help)
891 (some details hidden, use --verbose to show complete help)
892
892
893 $ hg help shellalias
893 $ hg help shellalias
894 hg shellalias
894 hg shellalias
895
895
896 shell alias for: echo hi
896 shell alias for: echo hi
897
897
898 (no help text available)
898 (no help text available)
899
899
900 defined by: helpext
900 defined by: helpext
901
901
902 (some details hidden, use --verbose to show complete help)
902 (some details hidden, use --verbose to show complete help)
903
903
904 Test command with no help text
904 Test command with no help text
905
905
906 $ hg help nohelp
906 $ hg help nohelp
907 hg nohelp
907 hg nohelp
908
908
909 (no help text available)
909 (no help text available)
910
910
911 options:
911 options:
912
912
913 --longdesc VALUE
913 --longdesc VALUE
914 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
914 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
915 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
915 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
916 -n -- normal desc
916 -n -- normal desc
917 --newline VALUE line1 line2
917 --newline VALUE line1 line2
918 --default-off enable X
918 --default-off enable X
919 --[no-]default-on enable Y (default: on)
919 --[no-]default-on enable Y (default: on)
920 --callableopt VALUE adds foo
920 --callableopt VALUE adds foo
921 --customopt VALUE adds bar
921 --customopt VALUE adds bar
922 --customopt-withdefault VALUE adds bar (default: foo)
922 --customopt-withdefault VALUE adds bar (default: foo)
923
923
924 (some details hidden, use --verbose to show complete help)
924 (some details hidden, use --verbose to show complete help)
925
925
926 Test that default list of commands includes extension commands that have help,
926 Test that default list of commands includes extension commands that have help,
927 but not those that don't, except in verbose mode, when a keyword is passed, or
927 but not those that don't, except in verbose mode, when a keyword is passed, or
928 when help about the extension is requested.
928 when help about the extension is requested.
929
929
930 #if no-extraextensions
930 #if no-extraextensions
931
931
932 $ hg help | grep hashelp
932 $ hg help | grep hashelp
933 hashelp Extension command's help
933 hashelp Extension command's help
934 $ hg help | grep nohelp
934 $ hg help | grep nohelp
935 [1]
935 [1]
936 $ hg help -v | grep nohelp
936 $ hg help -v | grep nohelp
937 nohelp (no help text available)
937 nohelp (no help text available)
938
938
939 $ hg help -k nohelp
939 $ hg help -k nohelp
940 Commands:
940 Commands:
941
941
942 nohelp hg nohelp
942 nohelp hg nohelp
943
943
944 Extension Commands:
944 Extension Commands:
945
945
946 nohelp (no help text available)
946 nohelp (no help text available)
947
947
948 $ hg help helpext
948 $ hg help helpext
949 helpext extension - no help text available
949 helpext extension - no help text available
950
950
951 list of commands:
951 list of commands:
952
952
953 hashelp Extension command's help
953 hashelp Extension command's help
954 nohelp (no help text available)
954 nohelp (no help text available)
955
955
956 (use 'hg help -v helpext' to show built-in aliases and global options)
956 (use 'hg help -v helpext' to show built-in aliases and global options)
957
957
958 #endif
958 #endif
959
959
960 Test list of internal help commands
960 Test list of internal help commands
961
961
962 $ hg help debug
962 $ hg help debug
963 debug commands (internal and unsupported):
963 debug commands (internal and unsupported):
964
964
965 debugancestor
965 debugancestor
966 find the ancestor revision of two revisions in a given index
966 find the ancestor revision of two revisions in a given index
967 debugapplystreamclonebundle
967 debugapplystreamclonebundle
968 apply a stream clone bundle file
968 apply a stream clone bundle file
969 debugbuilddag
969 debugbuilddag
970 builds a repo with a given DAG from scratch in the current
970 builds a repo with a given DAG from scratch in the current
971 empty repo
971 empty repo
972 debugbundle lists the contents of a bundle
972 debugbundle lists the contents of a bundle
973 debugcapabilities
973 debugcapabilities
974 lists the capabilities of a remote peer
974 lists the capabilities of a remote peer
975 debugcheckstate
975 debugcheckstate
976 validate the correctness of the current dirstate
976 validate the correctness of the current dirstate
977 debugcolor show available color, effects or style
977 debugcolor show available color, effects or style
978 debugcommands
978 debugcommands
979 list all available commands and options
979 list all available commands and options
980 debugcomplete
980 debugcomplete
981 returns the completion list associated with the given command
981 returns the completion list associated with the given command
982 debugcreatestreamclonebundle
982 debugcreatestreamclonebundle
983 create a stream clone bundle file
983 create a stream clone bundle file
984 debugdag format the changelog or an index DAG as a concise textual
984 debugdag format the changelog or an index DAG as a concise textual
985 description
985 description
986 debugdata dump the contents of a data file revision
986 debugdata dump the contents of a data file revision
987 debugdate parse and display a date
987 debugdate parse and display a date
988 debugdeltachain
988 debugdeltachain
989 dump information about delta chains in a revlog
989 dump information about delta chains in a revlog
990 debugdirstate
990 debugdirstate
991 show the contents of the current dirstate
991 show the contents of the current dirstate
992 debugdiscovery
992 debugdiscovery
993 runs the changeset discovery protocol in isolation
993 runs the changeset discovery protocol in isolation
994 debugdownload
994 debugdownload
995 download a resource using Mercurial logic and config
995 download a resource using Mercurial logic and config
996 debugextensions
996 debugextensions
997 show information about active extensions
997 show information about active extensions
998 debugfileset parse and apply a fileset specification
998 debugfileset parse and apply a fileset specification
999 debugformat display format information about the current repository
999 debugformat display format information about the current repository
1000 debugfsinfo show information detected about current filesystem
1000 debugfsinfo show information detected about current filesystem
1001 debuggetbundle
1001 debuggetbundle
1002 retrieves a bundle from a repo
1002 retrieves a bundle from a repo
1003 debugignore display the combined ignore pattern and information about
1003 debugignore display the combined ignore pattern and information about
1004 ignored files
1004 ignored files
1005 debugindex dump index data for a storage primitive
1005 debugindex dump index data for a storage primitive
1006 debugindexdot
1006 debugindexdot
1007 dump an index DAG as a graphviz dot file
1007 dump an index DAG as a graphviz dot file
1008 debugindexstats
1008 debugindexstats
1009 show stats related to the changelog index
1009 show stats related to the changelog index
1010 debuginstall test Mercurial installation
1010 debuginstall test Mercurial installation
1011 debugknown test whether node ids are known to a repo
1011 debugknown test whether node ids are known to a repo
1012 debuglocks show or modify state of locks
1012 debuglocks show or modify state of locks
1013 debugmanifestfulltextcache
1013 debugmanifestfulltextcache
1014 show, clear or amend the contents of the manifest fulltext
1014 show, clear or amend the contents of the manifest fulltext
1015 cache
1015 cache
1016 debugmergestate
1016 debugmergestate
1017 print merge state
1017 print merge state
1018 debugnamecomplete
1018 debugnamecomplete
1019 complete "names" - tags, open branch names, bookmark names
1019 complete "names" - tags, open branch names, bookmark names
1020 debugobsolete
1020 debugobsolete
1021 create arbitrary obsolete marker
1021 create arbitrary obsolete marker
1022 debugoptADV (no help text available)
1022 debugoptADV (no help text available)
1023 debugoptDEP (no help text available)
1023 debugoptDEP (no help text available)
1024 debugoptEXP (no help text available)
1024 debugoptEXP (no help text available)
1025 debugp1copies
1025 debugp1copies
1026 dump copy information compared to p1
1026 dump copy information compared to p1
1027 debugp2copies
1027 debugp2copies
1028 dump copy information compared to p2
1028 dump copy information compared to p2
1029 debugpathcomplete
1029 debugpathcomplete
1030 complete part or all of a tracked path
1030 complete part or all of a tracked path
1031 debugpathcopies
1031 debugpathcopies
1032 show copies between two revisions
1032 show copies between two revisions
1033 debugpeer establish a connection to a peer repository
1033 debugpeer establish a connection to a peer repository
1034 debugpickmergetool
1034 debugpickmergetool
1035 examine which merge tool is chosen for specified file
1035 examine which merge tool is chosen for specified file
1036 debugpushkey access the pushkey key/value protocol
1036 debugpushkey access the pushkey key/value protocol
1037 debugpvec (no help text available)
1037 debugpvec (no help text available)
1038 debugrebuilddirstate
1038 debugrebuilddirstate
1039 rebuild the dirstate as it would look like for the given
1039 rebuild the dirstate as it would look like for the given
1040 revision
1040 revision
1041 debugrebuildfncache
1041 debugrebuildfncache
1042 rebuild the fncache file
1042 rebuild the fncache file
1043 debugrename dump rename information
1043 debugrename dump rename information
1044 debugrevlog show data and statistics about a revlog
1044 debugrevlog show data and statistics about a revlog
1045 debugrevlogindex
1045 debugrevlogindex
1046 dump the contents of a revlog index
1046 dump the contents of a revlog index
1047 debugrevspec parse and apply a revision specification
1047 debugrevspec parse and apply a revision specification
1048 debugserve run a server with advanced settings
1048 debugserve run a server with advanced settings
1049 debugsetparents
1049 debugsetparents
1050 manually set the parents of the current working directory
1050 manually set the parents of the current working directory
1051 debugsidedata
1052 dump the side data for a cl/manifest/file revision
1051 debugssl test a secure connection to a server
1053 debugssl test a secure connection to a server
1052 debugsub (no help text available)
1054 debugsub (no help text available)
1053 debugsuccessorssets
1055 debugsuccessorssets
1054 show set of successors for revision
1056 show set of successors for revision
1055 debugtemplate
1057 debugtemplate
1056 parse and apply a template
1058 parse and apply a template
1057 debuguigetpass
1059 debuguigetpass
1058 show prompt to type password
1060 show prompt to type password
1059 debuguiprompt
1061 debuguiprompt
1060 show plain prompt
1062 show plain prompt
1061 debugupdatecaches
1063 debugupdatecaches
1062 warm all known caches in the repository
1064 warm all known caches in the repository
1063 debugupgraderepo
1065 debugupgraderepo
1064 upgrade a repository to use different features
1066 upgrade a repository to use different features
1065 debugwalk show how files match on given patterns
1067 debugwalk show how files match on given patterns
1066 debugwhyunstable
1068 debugwhyunstable
1067 explain instabilities of a changeset
1069 explain instabilities of a changeset
1068 debugwireargs
1070 debugwireargs
1069 (no help text available)
1071 (no help text available)
1070 debugwireproto
1072 debugwireproto
1071 send wire protocol commands to a server
1073 send wire protocol commands to a server
1072
1074
1073 (use 'hg help -v debug' to show built-in aliases and global options)
1075 (use 'hg help -v debug' to show built-in aliases and global options)
1074
1076
1075 internals topic renders index of available sub-topics
1077 internals topic renders index of available sub-topics
1076
1078
1077 $ hg help internals
1079 $ hg help internals
1078 Technical implementation topics
1080 Technical implementation topics
1079 """""""""""""""""""""""""""""""
1081 """""""""""""""""""""""""""""""
1080
1082
1081 To access a subtopic, use "hg help internals.{subtopic-name}"
1083 To access a subtopic, use "hg help internals.{subtopic-name}"
1082
1084
1083 bundle2 Bundle2
1085 bundle2 Bundle2
1084 bundles Bundles
1086 bundles Bundles
1085 cbor CBOR
1087 cbor CBOR
1086 censor Censor
1088 censor Censor
1087 changegroups Changegroups
1089 changegroups Changegroups
1088 config Config Registrar
1090 config Config Registrar
1089 extensions Extension API
1091 extensions Extension API
1090 mergestate Mergestate
1092 mergestate Mergestate
1091 requirements Repository Requirements
1093 requirements Repository Requirements
1092 revlogs Revision Logs
1094 revlogs Revision Logs
1093 wireprotocol Wire Protocol
1095 wireprotocol Wire Protocol
1094 wireprotocolrpc
1096 wireprotocolrpc
1095 Wire Protocol RPC
1097 Wire Protocol RPC
1096 wireprotocolv2
1098 wireprotocolv2
1097 Wire Protocol Version 2
1099 Wire Protocol Version 2
1098
1100
1099 sub-topics can be accessed
1101 sub-topics can be accessed
1100
1102
1101 $ hg help internals.changegroups
1103 $ hg help internals.changegroups
1102 Changegroups
1104 Changegroups
1103 """"""""""""
1105 """"""""""""
1104
1106
1105 Changegroups are representations of repository revlog data, specifically
1107 Changegroups are representations of repository revlog data, specifically
1106 the changelog data, root/flat manifest data, treemanifest data, and
1108 the changelog data, root/flat manifest data, treemanifest data, and
1107 filelogs.
1109 filelogs.
1108
1110
1109 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1111 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1110 level, versions "1" and "2" are almost exactly the same, with the only
1112 level, versions "1" and "2" are almost exactly the same, with the only
1111 difference being an additional item in the *delta header*. Version "3"
1113 difference being an additional item in the *delta header*. Version "3"
1112 adds support for storage flags in the *delta header* and optionally
1114 adds support for storage flags in the *delta header* and optionally
1113 exchanging treemanifests (enabled by setting an option on the
1115 exchanging treemanifests (enabled by setting an option on the
1114 "changegroup" part in the bundle2).
1116 "changegroup" part in the bundle2).
1115
1117
1116 Changegroups when not exchanging treemanifests consist of 3 logical
1118 Changegroups when not exchanging treemanifests consist of 3 logical
1117 segments:
1119 segments:
1118
1120
1119 +---------------------------------+
1121 +---------------------------------+
1120 | | | |
1122 | | | |
1121 | changeset | manifest | filelogs |
1123 | changeset | manifest | filelogs |
1122 | | | |
1124 | | | |
1123 | | | |
1125 | | | |
1124 +---------------------------------+
1126 +---------------------------------+
1125
1127
1126 When exchanging treemanifests, there are 4 logical segments:
1128 When exchanging treemanifests, there are 4 logical segments:
1127
1129
1128 +-------------------------------------------------+
1130 +-------------------------------------------------+
1129 | | | | |
1131 | | | | |
1130 | changeset | root | treemanifests | filelogs |
1132 | changeset | root | treemanifests | filelogs |
1131 | | manifest | | |
1133 | | manifest | | |
1132 | | | | |
1134 | | | | |
1133 +-------------------------------------------------+
1135 +-------------------------------------------------+
1134
1136
1135 The principle building block of each segment is a *chunk*. A *chunk* is a
1137 The principle building block of each segment is a *chunk*. A *chunk* is a
1136 framed piece of data:
1138 framed piece of data:
1137
1139
1138 +---------------------------------------+
1140 +---------------------------------------+
1139 | | |
1141 | | |
1140 | length | data |
1142 | length | data |
1141 | (4 bytes) | (<length - 4> bytes) |
1143 | (4 bytes) | (<length - 4> bytes) |
1142 | | |
1144 | | |
1143 +---------------------------------------+
1145 +---------------------------------------+
1144
1146
1145 All integers are big-endian signed integers. Each chunk starts with a
1147 All integers are big-endian signed integers. Each chunk starts with a
1146 32-bit integer indicating the length of the entire chunk (including the
1148 32-bit integer indicating the length of the entire chunk (including the
1147 length field itself).
1149 length field itself).
1148
1150
1149 There is a special case chunk that has a value of 0 for the length
1151 There is a special case chunk that has a value of 0 for the length
1150 ("0x00000000"). We call this an *empty chunk*.
1152 ("0x00000000"). We call this an *empty chunk*.
1151
1153
1152 Delta Groups
1154 Delta Groups
1153 ============
1155 ============
1154
1156
1155 A *delta group* expresses the content of a revlog as a series of deltas,
1157 A *delta group* expresses the content of a revlog as a series of deltas,
1156 or patches against previous revisions.
1158 or patches against previous revisions.
1157
1159
1158 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1160 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1159 to signal the end of the delta group:
1161 to signal the end of the delta group:
1160
1162
1161 +------------------------------------------------------------------------+
1163 +------------------------------------------------------------------------+
1162 | | | | | |
1164 | | | | | |
1163 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1165 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1164 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1166 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1165 | | | | | |
1167 | | | | | |
1166 +------------------------------------------------------------------------+
1168 +------------------------------------------------------------------------+
1167
1169
1168 Each *chunk*'s data consists of the following:
1170 Each *chunk*'s data consists of the following:
1169
1171
1170 +---------------------------------------+
1172 +---------------------------------------+
1171 | | |
1173 | | |
1172 | delta header | delta data |
1174 | delta header | delta data |
1173 | (various by version) | (various) |
1175 | (various by version) | (various) |
1174 | | |
1176 | | |
1175 +---------------------------------------+
1177 +---------------------------------------+
1176
1178
1177 The *delta data* is a series of *delta*s that describe a diff from an
1179 The *delta data* is a series of *delta*s that describe a diff from an
1178 existing entry (either that the recipient already has, or previously
1180 existing entry (either that the recipient already has, or previously
1179 specified in the bundle/changegroup).
1181 specified in the bundle/changegroup).
1180
1182
1181 The *delta header* is different between versions "1", "2", and "3" of the
1183 The *delta header* is different between versions "1", "2", and "3" of the
1182 changegroup format.
1184 changegroup format.
1183
1185
1184 Version 1 (headerlen=80):
1186 Version 1 (headerlen=80):
1185
1187
1186 +------------------------------------------------------+
1188 +------------------------------------------------------+
1187 | | | | |
1189 | | | | |
1188 | node | p1 node | p2 node | link node |
1190 | node | p1 node | p2 node | link node |
1189 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1191 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1190 | | | | |
1192 | | | | |
1191 +------------------------------------------------------+
1193 +------------------------------------------------------+
1192
1194
1193 Version 2 (headerlen=100):
1195 Version 2 (headerlen=100):
1194
1196
1195 +------------------------------------------------------------------+
1197 +------------------------------------------------------------------+
1196 | | | | | |
1198 | | | | | |
1197 | node | p1 node | p2 node | base node | link node |
1199 | node | p1 node | p2 node | base node | link node |
1198 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1200 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1199 | | | | | |
1201 | | | | | |
1200 +------------------------------------------------------------------+
1202 +------------------------------------------------------------------+
1201
1203
1202 Version 3 (headerlen=102):
1204 Version 3 (headerlen=102):
1203
1205
1204 +------------------------------------------------------------------------------+
1206 +------------------------------------------------------------------------------+
1205 | | | | | | |
1207 | | | | | | |
1206 | node | p1 node | p2 node | base node | link node | flags |
1208 | node | p1 node | p2 node | base node | link node | flags |
1207 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1209 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1208 | | | | | | |
1210 | | | | | | |
1209 +------------------------------------------------------------------------------+
1211 +------------------------------------------------------------------------------+
1210
1212
1211 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1213 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1212 contain a series of *delta*s, densely packed (no separators). These deltas
1214 contain a series of *delta*s, densely packed (no separators). These deltas
1213 describe a diff from an existing entry (either that the recipient already
1215 describe a diff from an existing entry (either that the recipient already
1214 has, or previously specified in the bundle/changegroup). The format is
1216 has, or previously specified in the bundle/changegroup). The format is
1215 described more fully in "hg help internals.bdiff", but briefly:
1217 described more fully in "hg help internals.bdiff", but briefly:
1216
1218
1217 +---------------------------------------------------------------+
1219 +---------------------------------------------------------------+
1218 | | | | |
1220 | | | | |
1219 | start offset | end offset | new length | content |
1221 | start offset | end offset | new length | content |
1220 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1222 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1221 | | | | |
1223 | | | | |
1222 +---------------------------------------------------------------+
1224 +---------------------------------------------------------------+
1223
1225
1224 Please note that the length field in the delta data does *not* include
1226 Please note that the length field in the delta data does *not* include
1225 itself.
1227 itself.
1226
1228
1227 In version 1, the delta is always applied against the previous node from
1229 In version 1, the delta is always applied against the previous node from
1228 the changegroup or the first parent if this is the first entry in the
1230 the changegroup or the first parent if this is the first entry in the
1229 changegroup.
1231 changegroup.
1230
1232
1231 In version 2 and up, the delta base node is encoded in the entry in the
1233 In version 2 and up, the delta base node is encoded in the entry in the
1232 changegroup. This allows the delta to be expressed against any parent,
1234 changegroup. This allows the delta to be expressed against any parent,
1233 which can result in smaller deltas and more efficient encoding of data.
1235 which can result in smaller deltas and more efficient encoding of data.
1234
1236
1235 The *flags* field holds bitwise flags affecting the processing of revision
1237 The *flags* field holds bitwise flags affecting the processing of revision
1236 data. The following flags are defined:
1238 data. The following flags are defined:
1237
1239
1238 32768
1240 32768
1239 Censored revision. The revision's fulltext has been replaced by censor
1241 Censored revision. The revision's fulltext has been replaced by censor
1240 metadata. May only occur on file revisions.
1242 metadata. May only occur on file revisions.
1241
1243
1242 16384
1244 16384
1243 Ellipsis revision. Revision hash does not match data (likely due to
1245 Ellipsis revision. Revision hash does not match data (likely due to
1244 rewritten parents).
1246 rewritten parents).
1245
1247
1246 8192
1248 8192
1247 Externally stored. The revision fulltext contains "key:value" "\n"
1249 Externally stored. The revision fulltext contains "key:value" "\n"
1248 delimited metadata defining an object stored elsewhere. Used by the LFS
1250 delimited metadata defining an object stored elsewhere. Used by the LFS
1249 extension.
1251 extension.
1250
1252
1251 For historical reasons, the integer values are identical to revlog version
1253 For historical reasons, the integer values are identical to revlog version
1252 1 per-revision storage flags and correspond to bits being set in this
1254 1 per-revision storage flags and correspond to bits being set in this
1253 2-byte field. Bits were allocated starting from the most-significant bit,
1255 2-byte field. Bits were allocated starting from the most-significant bit,
1254 hence the reverse ordering and allocation of these flags.
1256 hence the reverse ordering and allocation of these flags.
1255
1257
1256 Changeset Segment
1258 Changeset Segment
1257 =================
1259 =================
1258
1260
1259 The *changeset segment* consists of a single *delta group* holding
1261 The *changeset segment* consists of a single *delta group* holding
1260 changelog data. The *empty chunk* at the end of the *delta group* denotes
1262 changelog data. The *empty chunk* at the end of the *delta group* denotes
1261 the boundary to the *manifest segment*.
1263 the boundary to the *manifest segment*.
1262
1264
1263 Manifest Segment
1265 Manifest Segment
1264 ================
1266 ================
1265
1267
1266 The *manifest segment* consists of a single *delta group* holding manifest
1268 The *manifest segment* consists of a single *delta group* holding manifest
1267 data. If treemanifests are in use, it contains only the manifest for the
1269 data. If treemanifests are in use, it contains only the manifest for the
1268 root directory of the repository. Otherwise, it contains the entire
1270 root directory of the repository. Otherwise, it contains the entire
1269 manifest data. The *empty chunk* at the end of the *delta group* denotes
1271 manifest data. The *empty chunk* at the end of the *delta group* denotes
1270 the boundary to the next segment (either the *treemanifests segment* or
1272 the boundary to the next segment (either the *treemanifests segment* or
1271 the *filelogs segment*, depending on version and the request options).
1273 the *filelogs segment*, depending on version and the request options).
1272
1274
1273 Treemanifests Segment
1275 Treemanifests Segment
1274 ---------------------
1276 ---------------------
1275
1277
1276 The *treemanifests segment* only exists in changegroup version "3", and
1278 The *treemanifests segment* only exists in changegroup version "3", and
1277 only if the 'treemanifest' param is part of the bundle2 changegroup part
1279 only if the 'treemanifest' param is part of the bundle2 changegroup part
1278 (it is not possible to use changegroup version 3 outside of bundle2).
1280 (it is not possible to use changegroup version 3 outside of bundle2).
1279 Aside from the filenames in the *treemanifests segment* containing a
1281 Aside from the filenames in the *treemanifests segment* containing a
1280 trailing "/" character, it behaves identically to the *filelogs segment*
1282 trailing "/" character, it behaves identically to the *filelogs segment*
1281 (see below). The final sub-segment is followed by an *empty chunk*
1283 (see below). The final sub-segment is followed by an *empty chunk*
1282 (logically, a sub-segment with filename size 0). This denotes the boundary
1284 (logically, a sub-segment with filename size 0). This denotes the boundary
1283 to the *filelogs segment*.
1285 to the *filelogs segment*.
1284
1286
1285 Filelogs Segment
1287 Filelogs Segment
1286 ================
1288 ================
1287
1289
1288 The *filelogs segment* consists of multiple sub-segments, each
1290 The *filelogs segment* consists of multiple sub-segments, each
1289 corresponding to an individual file whose data is being described:
1291 corresponding to an individual file whose data is being described:
1290
1292
1291 +--------------------------------------------------+
1293 +--------------------------------------------------+
1292 | | | | | |
1294 | | | | | |
1293 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1295 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1294 | | | | | (4 bytes) |
1296 | | | | | (4 bytes) |
1295 | | | | | |
1297 | | | | | |
1296 +--------------------------------------------------+
1298 +--------------------------------------------------+
1297
1299
1298 The final filelog sub-segment is followed by an *empty chunk* (logically,
1300 The final filelog sub-segment is followed by an *empty chunk* (logically,
1299 a sub-segment with filename size 0). This denotes the end of the segment
1301 a sub-segment with filename size 0). This denotes the end of the segment
1300 and of the overall changegroup.
1302 and of the overall changegroup.
1301
1303
1302 Each filelog sub-segment consists of the following:
1304 Each filelog sub-segment consists of the following:
1303
1305
1304 +------------------------------------------------------+
1306 +------------------------------------------------------+
1305 | | | |
1307 | | | |
1306 | filename length | filename | delta group |
1308 | filename length | filename | delta group |
1307 | (4 bytes) | (<length - 4> bytes) | (various) |
1309 | (4 bytes) | (<length - 4> bytes) | (various) |
1308 | | | |
1310 | | | |
1309 +------------------------------------------------------+
1311 +------------------------------------------------------+
1310
1312
1311 That is, a *chunk* consisting of the filename (not terminated or padded)
1313 That is, a *chunk* consisting of the filename (not terminated or padded)
1312 followed by N chunks constituting the *delta group* for this file. The
1314 followed by N chunks constituting the *delta group* for this file. The
1313 *empty chunk* at the end of each *delta group* denotes the boundary to the
1315 *empty chunk* at the end of each *delta group* denotes the boundary to the
1314 next filelog sub-segment.
1316 next filelog sub-segment.
1315
1317
1316 non-existent subtopics print an error
1318 non-existent subtopics print an error
1317
1319
1318 $ hg help internals.foo
1320 $ hg help internals.foo
1319 abort: no such help topic: internals.foo
1321 abort: no such help topic: internals.foo
1320 (try 'hg help --keyword foo')
1322 (try 'hg help --keyword foo')
1321 [255]
1323 [255]
1322
1324
1323 test advanced, deprecated and experimental options are hidden in command help
1325 test advanced, deprecated and experimental options are hidden in command help
1324 $ hg help debugoptADV
1326 $ hg help debugoptADV
1325 hg debugoptADV
1327 hg debugoptADV
1326
1328
1327 (no help text available)
1329 (no help text available)
1328
1330
1329 options:
1331 options:
1330
1332
1331 (some details hidden, use --verbose to show complete help)
1333 (some details hidden, use --verbose to show complete help)
1332 $ hg help debugoptDEP
1334 $ hg help debugoptDEP
1333 hg debugoptDEP
1335 hg debugoptDEP
1334
1336
1335 (no help text available)
1337 (no help text available)
1336
1338
1337 options:
1339 options:
1338
1340
1339 (some details hidden, use --verbose to show complete help)
1341 (some details hidden, use --verbose to show complete help)
1340
1342
1341 $ hg help debugoptEXP
1343 $ hg help debugoptEXP
1342 hg debugoptEXP
1344 hg debugoptEXP
1343
1345
1344 (no help text available)
1346 (no help text available)
1345
1347
1346 options:
1348 options:
1347
1349
1348 (some details hidden, use --verbose to show complete help)
1350 (some details hidden, use --verbose to show complete help)
1349
1351
1350 test advanced, deprecated and experimental options are shown with -v
1352 test advanced, deprecated and experimental options are shown with -v
1351 $ hg help -v debugoptADV | grep aopt
1353 $ hg help -v debugoptADV | grep aopt
1352 --aopt option is (ADVANCED)
1354 --aopt option is (ADVANCED)
1353 $ hg help -v debugoptDEP | grep dopt
1355 $ hg help -v debugoptDEP | grep dopt
1354 --dopt option is (DEPRECATED)
1356 --dopt option is (DEPRECATED)
1355 $ hg help -v debugoptEXP | grep eopt
1357 $ hg help -v debugoptEXP | grep eopt
1356 --eopt option is (EXPERIMENTAL)
1358 --eopt option is (EXPERIMENTAL)
1357
1359
1358 #if gettext
1360 #if gettext
1359 test deprecated option is hidden with translation with untranslated description
1361 test deprecated option is hidden with translation with untranslated description
1360 (use many globy for not failing on changed transaction)
1362 (use many globy for not failing on changed transaction)
1361 $ LANGUAGE=sv hg help debugoptDEP
1363 $ LANGUAGE=sv hg help debugoptDEP
1362 hg debugoptDEP
1364 hg debugoptDEP
1363
1365
1364 (*) (glob)
1366 (*) (glob)
1365
1367
1366 options:
1368 options:
1367
1369
1368 (some details hidden, use --verbose to show complete help)
1370 (some details hidden, use --verbose to show complete help)
1369 #endif
1371 #endif
1370
1372
1371 Test commands that collide with topics (issue4240)
1373 Test commands that collide with topics (issue4240)
1372
1374
1373 $ hg config -hq
1375 $ hg config -hq
1374 hg config [-u] [NAME]...
1376 hg config [-u] [NAME]...
1375
1377
1376 show combined config settings from all hgrc files
1378 show combined config settings from all hgrc files
1377 $ hg showconfig -hq
1379 $ hg showconfig -hq
1378 hg config [-u] [NAME]...
1380 hg config [-u] [NAME]...
1379
1381
1380 show combined config settings from all hgrc files
1382 show combined config settings from all hgrc files
1381
1383
1382 Test a help topic
1384 Test a help topic
1383
1385
1384 $ hg help dates
1386 $ hg help dates
1385 Date Formats
1387 Date Formats
1386 """"""""""""
1388 """"""""""""
1387
1389
1388 Some commands allow the user to specify a date, e.g.:
1390 Some commands allow the user to specify a date, e.g.:
1389
1391
1390 - backout, commit, import, tag: Specify the commit date.
1392 - backout, commit, import, tag: Specify the commit date.
1391 - log, revert, update: Select revision(s) by date.
1393 - log, revert, update: Select revision(s) by date.
1392
1394
1393 Many date formats are valid. Here are some examples:
1395 Many date formats are valid. Here are some examples:
1394
1396
1395 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1397 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1396 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1398 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1397 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1399 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1398 - "Dec 6" (midnight)
1400 - "Dec 6" (midnight)
1399 - "13:18" (today assumed)
1401 - "13:18" (today assumed)
1400 - "3:39" (3:39AM assumed)
1402 - "3:39" (3:39AM assumed)
1401 - "3:39pm" (15:39)
1403 - "3:39pm" (15:39)
1402 - "2006-12-06 13:18:29" (ISO 8601 format)
1404 - "2006-12-06 13:18:29" (ISO 8601 format)
1403 - "2006-12-6 13:18"
1405 - "2006-12-6 13:18"
1404 - "2006-12-6"
1406 - "2006-12-6"
1405 - "12-6"
1407 - "12-6"
1406 - "12/6"
1408 - "12/6"
1407 - "12/6/6" (Dec 6 2006)
1409 - "12/6/6" (Dec 6 2006)
1408 - "today" (midnight)
1410 - "today" (midnight)
1409 - "yesterday" (midnight)
1411 - "yesterday" (midnight)
1410 - "now" - right now
1412 - "now" - right now
1411
1413
1412 Lastly, there is Mercurial's internal format:
1414 Lastly, there is Mercurial's internal format:
1413
1415
1414 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1416 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1415
1417
1416 This is the internal representation format for dates. The first number is
1418 This is the internal representation format for dates. The first number is
1417 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1419 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1418 is the offset of the local timezone, in seconds west of UTC (negative if
1420 is the offset of the local timezone, in seconds west of UTC (negative if
1419 the timezone is east of UTC).
1421 the timezone is east of UTC).
1420
1422
1421 The log command also accepts date ranges:
1423 The log command also accepts date ranges:
1422
1424
1423 - "<DATE" - at or before a given date/time
1425 - "<DATE" - at or before a given date/time
1424 - ">DATE" - on or after a given date/time
1426 - ">DATE" - on or after a given date/time
1425 - "DATE to DATE" - a date range, inclusive
1427 - "DATE to DATE" - a date range, inclusive
1426 - "-DAYS" - within a given number of days of today
1428 - "-DAYS" - within a given number of days of today
1427
1429
1428 Test repeated config section name
1430 Test repeated config section name
1429
1431
1430 $ hg help config.host
1432 $ hg help config.host
1431 "http_proxy.host"
1433 "http_proxy.host"
1432 Host name and (optional) port of the proxy server, for example
1434 Host name and (optional) port of the proxy server, for example
1433 "myproxy:8000".
1435 "myproxy:8000".
1434
1436
1435 "smtp.host"
1437 "smtp.host"
1436 Host name of mail server, e.g. "mail.example.com".
1438 Host name of mail server, e.g. "mail.example.com".
1437
1439
1438
1440
1439 Test section name with dot
1441 Test section name with dot
1440
1442
1441 $ hg help config.ui.username
1443 $ hg help config.ui.username
1442 "ui.username"
1444 "ui.username"
1443 The committer of a changeset created when running "commit". Typically
1445 The committer of a changeset created when running "commit". Typically
1444 a person's name and email address, e.g. "Fred Widget
1446 a person's name and email address, e.g. "Fred Widget
1445 <fred@example.com>". Environment variables in the username are
1447 <fred@example.com>". Environment variables in the username are
1446 expanded.
1448 expanded.
1447
1449
1448 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1450 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1449 empty, e.g. if the system admin set "username =" in the system hgrc,
1451 empty, e.g. if the system admin set "username =" in the system hgrc,
1450 it has to be specified manually or in a different hgrc file)
1452 it has to be specified manually or in a different hgrc file)
1451
1453
1452
1454
1453 $ hg help config.annotate.git
1455 $ hg help config.annotate.git
1454 abort: help section not found: config.annotate.git
1456 abort: help section not found: config.annotate.git
1455 [255]
1457 [255]
1456
1458
1457 $ hg help config.update.check
1459 $ hg help config.update.check
1458 "commands.update.check"
1460 "commands.update.check"
1459 Determines what level of checking 'hg update' will perform before
1461 Determines what level of checking 'hg update' will perform before
1460 moving to a destination revision. Valid values are "abort", "none",
1462 moving to a destination revision. Valid values are "abort", "none",
1461 "linear", and "noconflict". "abort" always fails if the working
1463 "linear", and "noconflict". "abort" always fails if the working
1462 directory has uncommitted changes. "none" performs no checking, and
1464 directory has uncommitted changes. "none" performs no checking, and
1463 may result in a merge with uncommitted changes. "linear" allows any
1465 may result in a merge with uncommitted changes. "linear" allows any
1464 update as long as it follows a straight line in the revision history,
1466 update as long as it follows a straight line in the revision history,
1465 and may trigger a merge with uncommitted changes. "noconflict" will
1467 and may trigger a merge with uncommitted changes. "noconflict" will
1466 allow any update which would not trigger a merge with uncommitted
1468 allow any update which would not trigger a merge with uncommitted
1467 changes, if any are present. (default: "linear")
1469 changes, if any are present. (default: "linear")
1468
1470
1469
1471
1470 $ hg help config.commands.update.check
1472 $ hg help config.commands.update.check
1471 "commands.update.check"
1473 "commands.update.check"
1472 Determines what level of checking 'hg update' will perform before
1474 Determines what level of checking 'hg update' will perform before
1473 moving to a destination revision. Valid values are "abort", "none",
1475 moving to a destination revision. Valid values are "abort", "none",
1474 "linear", and "noconflict". "abort" always fails if the working
1476 "linear", and "noconflict". "abort" always fails if the working
1475 directory has uncommitted changes. "none" performs no checking, and
1477 directory has uncommitted changes. "none" performs no checking, and
1476 may result in a merge with uncommitted changes. "linear" allows any
1478 may result in a merge with uncommitted changes. "linear" allows any
1477 update as long as it follows a straight line in the revision history,
1479 update as long as it follows a straight line in the revision history,
1478 and may trigger a merge with uncommitted changes. "noconflict" will
1480 and may trigger a merge with uncommitted changes. "noconflict" will
1479 allow any update which would not trigger a merge with uncommitted
1481 allow any update which would not trigger a merge with uncommitted
1480 changes, if any are present. (default: "linear")
1482 changes, if any are present. (default: "linear")
1481
1483
1482
1484
1483 $ hg help config.ommands.update.check
1485 $ hg help config.ommands.update.check
1484 abort: help section not found: config.ommands.update.check
1486 abort: help section not found: config.ommands.update.check
1485 [255]
1487 [255]
1486
1488
1487 Unrelated trailing paragraphs shouldn't be included
1489 Unrelated trailing paragraphs shouldn't be included
1488
1490
1489 $ hg help config.extramsg | grep '^$'
1491 $ hg help config.extramsg | grep '^$'
1490
1492
1491
1493
1492 Test capitalized section name
1494 Test capitalized section name
1493
1495
1494 $ hg help scripting.HGPLAIN > /dev/null
1496 $ hg help scripting.HGPLAIN > /dev/null
1495
1497
1496 Help subsection:
1498 Help subsection:
1497
1499
1498 $ hg help config.charsets |grep "Email example:" > /dev/null
1500 $ hg help config.charsets |grep "Email example:" > /dev/null
1499 [1]
1501 [1]
1500
1502
1501 Show nested definitions
1503 Show nested definitions
1502 ("profiling.type"[break]"ls"[break]"stat"[break])
1504 ("profiling.type"[break]"ls"[break]"stat"[break])
1503
1505
1504 $ hg help config.type | egrep '^$'|wc -l
1506 $ hg help config.type | egrep '^$'|wc -l
1505 \s*3 (re)
1507 \s*3 (re)
1506
1508
1507 $ hg help config.profiling.type.ls
1509 $ hg help config.profiling.type.ls
1508 "profiling.type.ls"
1510 "profiling.type.ls"
1509 Use Python's built-in instrumenting profiler. This profiler works on
1511 Use Python's built-in instrumenting profiler. This profiler works on
1510 all platforms, but each line number it reports is the first line of
1512 all platforms, but each line number it reports is the first line of
1511 a function. This restriction makes it difficult to identify the
1513 a function. This restriction makes it difficult to identify the
1512 expensive parts of a non-trivial function.
1514 expensive parts of a non-trivial function.
1513
1515
1514
1516
1515 Separate sections from subsections
1517 Separate sections from subsections
1516
1518
1517 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1519 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1518 "format"
1520 "format"
1519 --------
1521 --------
1520
1522
1521 "usegeneraldelta"
1523 "usegeneraldelta"
1522
1524
1523 "dotencode"
1525 "dotencode"
1524
1526
1525 "usefncache"
1527 "usefncache"
1526
1528
1527 "usestore"
1529 "usestore"
1528
1530
1529 "sparse-revlog"
1531 "sparse-revlog"
1530
1532
1531 "revlog-compression"
1533 "revlog-compression"
1532
1534
1533 "bookmarks-in-store"
1535 "bookmarks-in-store"
1534
1536
1535 "profiling"
1537 "profiling"
1536 -----------
1538 -----------
1537
1539
1538 "format"
1540 "format"
1539
1541
1540 "progress"
1542 "progress"
1541 ----------
1543 ----------
1542
1544
1543 "format"
1545 "format"
1544
1546
1545
1547
1546 Last item in help config.*:
1548 Last item in help config.*:
1547
1549
1548 $ hg help config.`hg help config|grep '^ "'| \
1550 $ hg help config.`hg help config|grep '^ "'| \
1549 > tail -1|sed 's![ "]*!!g'`| \
1551 > tail -1|sed 's![ "]*!!g'`| \
1550 > grep 'hg help -c config' > /dev/null
1552 > grep 'hg help -c config' > /dev/null
1551 [1]
1553 [1]
1552
1554
1553 note to use help -c for general hg help config:
1555 note to use help -c for general hg help config:
1554
1556
1555 $ hg help config |grep 'hg help -c config' > /dev/null
1557 $ hg help config |grep 'hg help -c config' > /dev/null
1556
1558
1557 Test templating help
1559 Test templating help
1558
1560
1559 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1561 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1560 desc String. The text of the changeset description.
1562 desc String. The text of the changeset description.
1561 diffstat String. Statistics of changes with the following format:
1563 diffstat String. Statistics of changes with the following format:
1562 firstline Any text. Returns the first line of text.
1564 firstline Any text. Returns the first line of text.
1563 nonempty Any text. Returns '(none)' if the string is empty.
1565 nonempty Any text. Returns '(none)' if the string is empty.
1564
1566
1565 Test deprecated items
1567 Test deprecated items
1566
1568
1567 $ hg help -v templating | grep currentbookmark
1569 $ hg help -v templating | grep currentbookmark
1568 currentbookmark
1570 currentbookmark
1569 $ hg help templating | (grep currentbookmark || true)
1571 $ hg help templating | (grep currentbookmark || true)
1570
1572
1571 Test help hooks
1573 Test help hooks
1572
1574
1573 $ cat > helphook1.py <<EOF
1575 $ cat > helphook1.py <<EOF
1574 > from mercurial import help
1576 > from mercurial import help
1575 >
1577 >
1576 > def rewrite(ui, topic, doc):
1578 > def rewrite(ui, topic, doc):
1577 > return doc + b'\nhelphook1\n'
1579 > return doc + b'\nhelphook1\n'
1578 >
1580 >
1579 > def extsetup(ui):
1581 > def extsetup(ui):
1580 > help.addtopichook(b'revisions', rewrite)
1582 > help.addtopichook(b'revisions', rewrite)
1581 > EOF
1583 > EOF
1582 $ cat > helphook2.py <<EOF
1584 $ cat > helphook2.py <<EOF
1583 > from mercurial import help
1585 > from mercurial import help
1584 >
1586 >
1585 > def rewrite(ui, topic, doc):
1587 > def rewrite(ui, topic, doc):
1586 > return doc + b'\nhelphook2\n'
1588 > return doc + b'\nhelphook2\n'
1587 >
1589 >
1588 > def extsetup(ui):
1590 > def extsetup(ui):
1589 > help.addtopichook(b'revisions', rewrite)
1591 > help.addtopichook(b'revisions', rewrite)
1590 > EOF
1592 > EOF
1591 $ echo '[extensions]' >> $HGRCPATH
1593 $ echo '[extensions]' >> $HGRCPATH
1592 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1594 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1593 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1595 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1594 $ hg help revsets | grep helphook
1596 $ hg help revsets | grep helphook
1595 helphook1
1597 helphook1
1596 helphook2
1598 helphook2
1597
1599
1598 help -c should only show debug --debug
1600 help -c should only show debug --debug
1599
1601
1600 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1602 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1601 [1]
1603 [1]
1602
1604
1603 help -c should only show deprecated for -v
1605 help -c should only show deprecated for -v
1604
1606
1605 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1607 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1606 [1]
1608 [1]
1607
1609
1608 Test -s / --system
1610 Test -s / --system
1609
1611
1610 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1612 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1611 > wc -l | sed -e 's/ //g'
1613 > wc -l | sed -e 's/ //g'
1612 0
1614 0
1613 $ hg help config.files --system unix | grep 'USER' | \
1615 $ hg help config.files --system unix | grep 'USER' | \
1614 > wc -l | sed -e 's/ //g'
1616 > wc -l | sed -e 's/ //g'
1615 0
1617 0
1616
1618
1617 Test -e / -c / -k combinations
1619 Test -e / -c / -k combinations
1618
1620
1619 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1621 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1620 Commands:
1622 Commands:
1621 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1623 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1622 Extensions:
1624 Extensions:
1623 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1625 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1624 Topics:
1626 Topics:
1625 Commands:
1627 Commands:
1626 Extensions:
1628 Extensions:
1627 Extension Commands:
1629 Extension Commands:
1628 $ hg help -c schemes
1630 $ hg help -c schemes
1629 abort: no such help topic: schemes
1631 abort: no such help topic: schemes
1630 (try 'hg help --keyword schemes')
1632 (try 'hg help --keyword schemes')
1631 [255]
1633 [255]
1632 $ hg help -e schemes |head -1
1634 $ hg help -e schemes |head -1
1633 schemes extension - extend schemes with shortcuts to repository swarms
1635 schemes extension - extend schemes with shortcuts to repository swarms
1634 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1636 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1635 Commands:
1637 Commands:
1636 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1638 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1637 Extensions:
1639 Extensions:
1638 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1640 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1639 Extensions:
1641 Extensions:
1640 Commands:
1642 Commands:
1641 $ hg help -c commit > /dev/null
1643 $ hg help -c commit > /dev/null
1642 $ hg help -e -c commit > /dev/null
1644 $ hg help -e -c commit > /dev/null
1643 $ hg help -e commit
1645 $ hg help -e commit
1644 abort: no such help topic: commit
1646 abort: no such help topic: commit
1645 (try 'hg help --keyword commit')
1647 (try 'hg help --keyword commit')
1646 [255]
1648 [255]
1647
1649
1648 Test keyword search help
1650 Test keyword search help
1649
1651
1650 $ cat > prefixedname.py <<EOF
1652 $ cat > prefixedname.py <<EOF
1651 > '''matched against word "clone"
1653 > '''matched against word "clone"
1652 > '''
1654 > '''
1653 > EOF
1655 > EOF
1654 $ echo '[extensions]' >> $HGRCPATH
1656 $ echo '[extensions]' >> $HGRCPATH
1655 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1657 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1656 $ hg help -k clone
1658 $ hg help -k clone
1657 Topics:
1659 Topics:
1658
1660
1659 config Configuration Files
1661 config Configuration Files
1660 extensions Using Additional Features
1662 extensions Using Additional Features
1661 glossary Glossary
1663 glossary Glossary
1662 phases Working with Phases
1664 phases Working with Phases
1663 subrepos Subrepositories
1665 subrepos Subrepositories
1664 urls URL Paths
1666 urls URL Paths
1665
1667
1666 Commands:
1668 Commands:
1667
1669
1668 bookmarks create a new bookmark or list existing bookmarks
1670 bookmarks create a new bookmark or list existing bookmarks
1669 clone make a copy of an existing repository
1671 clone make a copy of an existing repository
1670 paths show aliases for remote repositories
1672 paths show aliases for remote repositories
1671 pull pull changes from the specified source
1673 pull pull changes from the specified source
1672 update update working directory (or switch revisions)
1674 update update working directory (or switch revisions)
1673
1675
1674 Extensions:
1676 Extensions:
1675
1677
1676 clonebundles advertise pre-generated bundles to seed clones
1678 clonebundles advertise pre-generated bundles to seed clones
1677 narrow create clones which fetch history data for subset of files
1679 narrow create clones which fetch history data for subset of files
1678 (EXPERIMENTAL)
1680 (EXPERIMENTAL)
1679 prefixedname matched against word "clone"
1681 prefixedname matched against word "clone"
1680 relink recreates hardlinks between repository clones
1682 relink recreates hardlinks between repository clones
1681
1683
1682 Extension Commands:
1684 Extension Commands:
1683
1685
1684 qclone clone main and patch repository at same time
1686 qclone clone main and patch repository at same time
1685
1687
1686 Test unfound topic
1688 Test unfound topic
1687
1689
1688 $ hg help nonexistingtopicthatwillneverexisteverever
1690 $ hg help nonexistingtopicthatwillneverexisteverever
1689 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1691 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1690 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1692 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1691 [255]
1693 [255]
1692
1694
1693 Test unfound keyword
1695 Test unfound keyword
1694
1696
1695 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1697 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1696 abort: no matches
1698 abort: no matches
1697 (try 'hg help' for a list of topics)
1699 (try 'hg help' for a list of topics)
1698 [255]
1700 [255]
1699
1701
1700 Test omit indicating for help
1702 Test omit indicating for help
1701
1703
1702 $ cat > addverboseitems.py <<EOF
1704 $ cat > addverboseitems.py <<EOF
1703 > r'''extension to test omit indicating.
1705 > r'''extension to test omit indicating.
1704 >
1706 >
1705 > This paragraph is never omitted (for extension)
1707 > This paragraph is never omitted (for extension)
1706 >
1708 >
1707 > .. container:: verbose
1709 > .. container:: verbose
1708 >
1710 >
1709 > This paragraph is omitted,
1711 > This paragraph is omitted,
1710 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1712 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1711 >
1713 >
1712 > This paragraph is never omitted, too (for extension)
1714 > This paragraph is never omitted, too (for extension)
1713 > '''
1715 > '''
1714 > from __future__ import absolute_import
1716 > from __future__ import absolute_import
1715 > from mercurial import commands, help
1717 > from mercurial import commands, help
1716 > testtopic = br"""This paragraph is never omitted (for topic).
1718 > testtopic = br"""This paragraph is never omitted (for topic).
1717 >
1719 >
1718 > .. container:: verbose
1720 > .. container:: verbose
1719 >
1721 >
1720 > This paragraph is omitted,
1722 > This paragraph is omitted,
1721 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1723 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1722 >
1724 >
1723 > This paragraph is never omitted, too (for topic)
1725 > This paragraph is never omitted, too (for topic)
1724 > """
1726 > """
1725 > def extsetup(ui):
1727 > def extsetup(ui):
1726 > help.helptable.append(([b"topic-containing-verbose"],
1728 > help.helptable.append(([b"topic-containing-verbose"],
1727 > b"This is the topic to test omit indicating.",
1729 > b"This is the topic to test omit indicating.",
1728 > lambda ui: testtopic))
1730 > lambda ui: testtopic))
1729 > EOF
1731 > EOF
1730 $ echo '[extensions]' >> $HGRCPATH
1732 $ echo '[extensions]' >> $HGRCPATH
1731 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1733 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1732 $ hg help addverboseitems
1734 $ hg help addverboseitems
1733 addverboseitems extension - extension to test omit indicating.
1735 addverboseitems extension - extension to test omit indicating.
1734
1736
1735 This paragraph is never omitted (for extension)
1737 This paragraph is never omitted (for extension)
1736
1738
1737 This paragraph is never omitted, too (for extension)
1739 This paragraph is never omitted, too (for extension)
1738
1740
1739 (some details hidden, use --verbose to show complete help)
1741 (some details hidden, use --verbose to show complete help)
1740
1742
1741 no commands defined
1743 no commands defined
1742 $ hg help -v addverboseitems
1744 $ hg help -v addverboseitems
1743 addverboseitems extension - extension to test omit indicating.
1745 addverboseitems extension - extension to test omit indicating.
1744
1746
1745 This paragraph is never omitted (for extension)
1747 This paragraph is never omitted (for extension)
1746
1748
1747 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1749 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1748 extension)
1750 extension)
1749
1751
1750 This paragraph is never omitted, too (for extension)
1752 This paragraph is never omitted, too (for extension)
1751
1753
1752 no commands defined
1754 no commands defined
1753 $ hg help topic-containing-verbose
1755 $ hg help topic-containing-verbose
1754 This is the topic to test omit indicating.
1756 This is the topic to test omit indicating.
1755 """"""""""""""""""""""""""""""""""""""""""
1757 """"""""""""""""""""""""""""""""""""""""""
1756
1758
1757 This paragraph is never omitted (for topic).
1759 This paragraph is never omitted (for topic).
1758
1760
1759 This paragraph is never omitted, too (for topic)
1761 This paragraph is never omitted, too (for topic)
1760
1762
1761 (some details hidden, use --verbose to show complete help)
1763 (some details hidden, use --verbose to show complete help)
1762 $ hg help -v topic-containing-verbose
1764 $ hg help -v topic-containing-verbose
1763 This is the topic to test omit indicating.
1765 This is the topic to test omit indicating.
1764 """"""""""""""""""""""""""""""""""""""""""
1766 """"""""""""""""""""""""""""""""""""""""""
1765
1767
1766 This paragraph is never omitted (for topic).
1768 This paragraph is never omitted (for topic).
1767
1769
1768 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1770 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1769 topic)
1771 topic)
1770
1772
1771 This paragraph is never omitted, too (for topic)
1773 This paragraph is never omitted, too (for topic)
1772
1774
1773 Test section lookup
1775 Test section lookup
1774
1776
1775 $ hg help revset.merge
1777 $ hg help revset.merge
1776 "merge()"
1778 "merge()"
1777 Changeset is a merge changeset.
1779 Changeset is a merge changeset.
1778
1780
1779 $ hg help glossary.dag
1781 $ hg help glossary.dag
1780 DAG
1782 DAG
1781 The repository of changesets of a distributed version control system
1783 The repository of changesets of a distributed version control system
1782 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1784 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1783 of nodes and edges, where nodes correspond to changesets and edges
1785 of nodes and edges, where nodes correspond to changesets and edges
1784 imply a parent -> child relation. This graph can be visualized by
1786 imply a parent -> child relation. This graph can be visualized by
1785 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1787 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1786 limited by the requirement for children to have at most two parents.
1788 limited by the requirement for children to have at most two parents.
1787
1789
1788
1790
1789 $ hg help hgrc.paths
1791 $ hg help hgrc.paths
1790 "paths"
1792 "paths"
1791 -------
1793 -------
1792
1794
1793 Assigns symbolic names and behavior to repositories.
1795 Assigns symbolic names and behavior to repositories.
1794
1796
1795 Options are symbolic names defining the URL or directory that is the
1797 Options are symbolic names defining the URL or directory that is the
1796 location of the repository. Example:
1798 location of the repository. Example:
1797
1799
1798 [paths]
1800 [paths]
1799 my_server = https://example.com/my_repo
1801 my_server = https://example.com/my_repo
1800 local_path = /home/me/repo
1802 local_path = /home/me/repo
1801
1803
1802 These symbolic names can be used from the command line. To pull from
1804 These symbolic names can be used from the command line. To pull from
1803 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1805 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1804 local_path'.
1806 local_path'.
1805
1807
1806 Options containing colons (":") denote sub-options that can influence
1808 Options containing colons (":") denote sub-options that can influence
1807 behavior for that specific path. Example:
1809 behavior for that specific path. Example:
1808
1810
1809 [paths]
1811 [paths]
1810 my_server = https://example.com/my_path
1812 my_server = https://example.com/my_path
1811 my_server:pushurl = ssh://example.com/my_path
1813 my_server:pushurl = ssh://example.com/my_path
1812
1814
1813 The following sub-options can be defined:
1815 The following sub-options can be defined:
1814
1816
1815 "pushurl"
1817 "pushurl"
1816 The URL to use for push operations. If not defined, the location
1818 The URL to use for push operations. If not defined, the location
1817 defined by the path's main entry is used.
1819 defined by the path's main entry is used.
1818
1820
1819 "pushrev"
1821 "pushrev"
1820 A revset defining which revisions to push by default.
1822 A revset defining which revisions to push by default.
1821
1823
1822 When 'hg push' is executed without a "-r" argument, the revset defined
1824 When 'hg push' is executed without a "-r" argument, the revset defined
1823 by this sub-option is evaluated to determine what to push.
1825 by this sub-option is evaluated to determine what to push.
1824
1826
1825 For example, a value of "." will push the working directory's revision
1827 For example, a value of "." will push the working directory's revision
1826 by default.
1828 by default.
1827
1829
1828 Revsets specifying bookmarks will not result in the bookmark being
1830 Revsets specifying bookmarks will not result in the bookmark being
1829 pushed.
1831 pushed.
1830
1832
1831 The following special named paths exist:
1833 The following special named paths exist:
1832
1834
1833 "default"
1835 "default"
1834 The URL or directory to use when no source or remote is specified.
1836 The URL or directory to use when no source or remote is specified.
1835
1837
1836 'hg clone' will automatically define this path to the location the
1838 'hg clone' will automatically define this path to the location the
1837 repository was cloned from.
1839 repository was cloned from.
1838
1840
1839 "default-push"
1841 "default-push"
1840 (deprecated) The URL or directory for the default 'hg push' location.
1842 (deprecated) The URL or directory for the default 'hg push' location.
1841 "default:pushurl" should be used instead.
1843 "default:pushurl" should be used instead.
1842
1844
1843 $ hg help glossary.mcguffin
1845 $ hg help glossary.mcguffin
1844 abort: help section not found: glossary.mcguffin
1846 abort: help section not found: glossary.mcguffin
1845 [255]
1847 [255]
1846
1848
1847 $ hg help glossary.mc.guffin
1849 $ hg help glossary.mc.guffin
1848 abort: help section not found: glossary.mc.guffin
1850 abort: help section not found: glossary.mc.guffin
1849 [255]
1851 [255]
1850
1852
1851 $ hg help template.files
1853 $ hg help template.files
1852 files List of strings. All files modified, added, or removed by
1854 files List of strings. All files modified, added, or removed by
1853 this changeset.
1855 this changeset.
1854 files(pattern)
1856 files(pattern)
1855 All files of the current changeset matching the pattern. See
1857 All files of the current changeset matching the pattern. See
1856 'hg help patterns'.
1858 'hg help patterns'.
1857
1859
1858 Test section lookup by translated message
1860 Test section lookup by translated message
1859
1861
1860 str.lower() instead of encoding.lower(str) on translated message might
1862 str.lower() instead of encoding.lower(str) on translated message might
1861 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1863 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1862 as the second or later byte of multi-byte character.
1864 as the second or later byte of multi-byte character.
1863
1865
1864 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1866 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1865 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1867 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1866 replacement makes message meaningless.
1868 replacement makes message meaningless.
1867
1869
1868 This tests that section lookup by translated string isn't broken by
1870 This tests that section lookup by translated string isn't broken by
1869 such str.lower().
1871 such str.lower().
1870
1872
1871 $ "$PYTHON" <<EOF
1873 $ "$PYTHON" <<EOF
1872 > def escape(s):
1874 > def escape(s):
1873 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1875 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1874 > # translation of "record" in ja_JP.cp932
1876 > # translation of "record" in ja_JP.cp932
1875 > upper = b"\x8bL\x98^"
1877 > upper = b"\x8bL\x98^"
1876 > # str.lower()-ed section name should be treated as different one
1878 > # str.lower()-ed section name should be treated as different one
1877 > lower = b"\x8bl\x98^"
1879 > lower = b"\x8bl\x98^"
1878 > with open('ambiguous.py', 'wb') as fp:
1880 > with open('ambiguous.py', 'wb') as fp:
1879 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1881 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1880 > u'''summary of extension
1882 > u'''summary of extension
1881 >
1883 >
1882 > %s
1884 > %s
1883 > ----
1885 > ----
1884 >
1886 >
1885 > Upper name should show only this message
1887 > Upper name should show only this message
1886 >
1888 >
1887 > %s
1889 > %s
1888 > ----
1890 > ----
1889 >
1891 >
1890 > Lower name should show only this message
1892 > Lower name should show only this message
1891 >
1893 >
1892 > subsequent section
1894 > subsequent section
1893 > ------------------
1895 > ------------------
1894 >
1896 >
1895 > This should be hidden at 'hg help ambiguous' with section name.
1897 > This should be hidden at 'hg help ambiguous' with section name.
1896 > '''
1898 > '''
1897 > """ % (escape(upper), escape(lower)))
1899 > """ % (escape(upper), escape(lower)))
1898 > EOF
1900 > EOF
1899
1901
1900 $ cat >> $HGRCPATH <<EOF
1902 $ cat >> $HGRCPATH <<EOF
1901 > [extensions]
1903 > [extensions]
1902 > ambiguous = ./ambiguous.py
1904 > ambiguous = ./ambiguous.py
1903 > EOF
1905 > EOF
1904
1906
1905 $ "$PYTHON" <<EOF | sh
1907 $ "$PYTHON" <<EOF | sh
1906 > from mercurial import pycompat
1908 > from mercurial import pycompat
1907 > upper = b"\x8bL\x98^"
1909 > upper = b"\x8bL\x98^"
1908 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1910 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1909 > EOF
1911 > EOF
1910 \x8bL\x98^ (esc)
1912 \x8bL\x98^ (esc)
1911 ----
1913 ----
1912
1914
1913 Upper name should show only this message
1915 Upper name should show only this message
1914
1916
1915
1917
1916 $ "$PYTHON" <<EOF | sh
1918 $ "$PYTHON" <<EOF | sh
1917 > from mercurial import pycompat
1919 > from mercurial import pycompat
1918 > lower = b"\x8bl\x98^"
1920 > lower = b"\x8bl\x98^"
1919 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1921 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1920 > EOF
1922 > EOF
1921 \x8bl\x98^ (esc)
1923 \x8bl\x98^ (esc)
1922 ----
1924 ----
1923
1925
1924 Lower name should show only this message
1926 Lower name should show only this message
1925
1927
1926
1928
1927 $ cat >> $HGRCPATH <<EOF
1929 $ cat >> $HGRCPATH <<EOF
1928 > [extensions]
1930 > [extensions]
1929 > ambiguous = !
1931 > ambiguous = !
1930 > EOF
1932 > EOF
1931
1933
1932 Show help content of disabled extensions
1934 Show help content of disabled extensions
1933
1935
1934 $ cat >> $HGRCPATH <<EOF
1936 $ cat >> $HGRCPATH <<EOF
1935 > [extensions]
1937 > [extensions]
1936 > ambiguous = !./ambiguous.py
1938 > ambiguous = !./ambiguous.py
1937 > EOF
1939 > EOF
1938 $ hg help -e ambiguous
1940 $ hg help -e ambiguous
1939 ambiguous extension - (no help text available)
1941 ambiguous extension - (no help text available)
1940
1942
1941 (use 'hg help extensions' for information on enabling extensions)
1943 (use 'hg help extensions' for information on enabling extensions)
1942
1944
1943 Test dynamic list of merge tools only shows up once
1945 Test dynamic list of merge tools only shows up once
1944 $ hg help merge-tools
1946 $ hg help merge-tools
1945 Merge Tools
1947 Merge Tools
1946 """""""""""
1948 """""""""""
1947
1949
1948 To merge files Mercurial uses merge tools.
1950 To merge files Mercurial uses merge tools.
1949
1951
1950 A merge tool combines two different versions of a file into a merged file.
1952 A merge tool combines two different versions of a file into a merged file.
1951 Merge tools are given the two files and the greatest common ancestor of
1953 Merge tools are given the two files and the greatest common ancestor of
1952 the two file versions, so they can determine the changes made on both
1954 the two file versions, so they can determine the changes made on both
1953 branches.
1955 branches.
1954
1956
1955 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1957 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1956 backout' and in several extensions.
1958 backout' and in several extensions.
1957
1959
1958 Usually, the merge tool tries to automatically reconcile the files by
1960 Usually, the merge tool tries to automatically reconcile the files by
1959 combining all non-overlapping changes that occurred separately in the two
1961 combining all non-overlapping changes that occurred separately in the two
1960 different evolutions of the same initial base file. Furthermore, some
1962 different evolutions of the same initial base file. Furthermore, some
1961 interactive merge programs make it easier to manually resolve conflicting
1963 interactive merge programs make it easier to manually resolve conflicting
1962 merges, either in a graphical way, or by inserting some conflict markers.
1964 merges, either in a graphical way, or by inserting some conflict markers.
1963 Mercurial does not include any interactive merge programs but relies on
1965 Mercurial does not include any interactive merge programs but relies on
1964 external tools for that.
1966 external tools for that.
1965
1967
1966 Available merge tools
1968 Available merge tools
1967 =====================
1969 =====================
1968
1970
1969 External merge tools and their properties are configured in the merge-
1971 External merge tools and their properties are configured in the merge-
1970 tools configuration section - see hgrc(5) - but they can often just be
1972 tools configuration section - see hgrc(5) - but they can often just be
1971 named by their executable.
1973 named by their executable.
1972
1974
1973 A merge tool is generally usable if its executable can be found on the
1975 A merge tool is generally usable if its executable can be found on the
1974 system and if it can handle the merge. The executable is found if it is an
1976 system and if it can handle the merge. The executable is found if it is an
1975 absolute or relative executable path or the name of an application in the
1977 absolute or relative executable path or the name of an application in the
1976 executable search path. The tool is assumed to be able to handle the merge
1978 executable search path. The tool is assumed to be able to handle the merge
1977 if it can handle symlinks if the file is a symlink, if it can handle
1979 if it can handle symlinks if the file is a symlink, if it can handle
1978 binary files if the file is binary, and if a GUI is available if the tool
1980 binary files if the file is binary, and if a GUI is available if the tool
1979 requires a GUI.
1981 requires a GUI.
1980
1982
1981 There are some internal merge tools which can be used. The internal merge
1983 There are some internal merge tools which can be used. The internal merge
1982 tools are:
1984 tools are:
1983
1985
1984 ":dump"
1986 ":dump"
1985 Creates three versions of the files to merge, containing the contents of
1987 Creates three versions of the files to merge, containing the contents of
1986 local, other and base. These files can then be used to perform a merge
1988 local, other and base. These files can then be used to perform a merge
1987 manually. If the file to be merged is named "a.txt", these files will
1989 manually. If the file to be merged is named "a.txt", these files will
1988 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1990 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1989 they will be placed in the same directory as "a.txt".
1991 they will be placed in the same directory as "a.txt".
1990
1992
1991 This implies premerge. Therefore, files aren't dumped, if premerge runs
1993 This implies premerge. Therefore, files aren't dumped, if premerge runs
1992 successfully. Use :forcedump to forcibly write files out.
1994 successfully. Use :forcedump to forcibly write files out.
1993
1995
1994 (actual capabilities: binary, symlink)
1996 (actual capabilities: binary, symlink)
1995
1997
1996 ":fail"
1998 ":fail"
1997 Rather than attempting to merge files that were modified on both
1999 Rather than attempting to merge files that were modified on both
1998 branches, it marks them as unresolved. The resolve command must be used
2000 branches, it marks them as unresolved. The resolve command must be used
1999 to resolve these conflicts.
2001 to resolve these conflicts.
2000
2002
2001 (actual capabilities: binary, symlink)
2003 (actual capabilities: binary, symlink)
2002
2004
2003 ":forcedump"
2005 ":forcedump"
2004 Creates three versions of the files as same as :dump, but omits
2006 Creates three versions of the files as same as :dump, but omits
2005 premerge.
2007 premerge.
2006
2008
2007 (actual capabilities: binary, symlink)
2009 (actual capabilities: binary, symlink)
2008
2010
2009 ":local"
2011 ":local"
2010 Uses the local 'p1()' version of files as the merged version.
2012 Uses the local 'p1()' version of files as the merged version.
2011
2013
2012 (actual capabilities: binary, symlink)
2014 (actual capabilities: binary, symlink)
2013
2015
2014 ":merge"
2016 ":merge"
2015 Uses the internal non-interactive simple merge algorithm for merging
2017 Uses the internal non-interactive simple merge algorithm for merging
2016 files. It will fail if there are any conflicts and leave markers in the
2018 files. It will fail if there are any conflicts and leave markers in the
2017 partially merged file. Markers will have two sections, one for each side
2019 partially merged file. Markers will have two sections, one for each side
2018 of merge.
2020 of merge.
2019
2021
2020 ":merge-local"
2022 ":merge-local"
2021 Like :merge, but resolve all conflicts non-interactively in favor of the
2023 Like :merge, but resolve all conflicts non-interactively in favor of the
2022 local 'p1()' changes.
2024 local 'p1()' changes.
2023
2025
2024 ":merge-other"
2026 ":merge-other"
2025 Like :merge, but resolve all conflicts non-interactively in favor of the
2027 Like :merge, but resolve all conflicts non-interactively in favor of the
2026 other 'p2()' changes.
2028 other 'p2()' changes.
2027
2029
2028 ":merge3"
2030 ":merge3"
2029 Uses the internal non-interactive simple merge algorithm for merging
2031 Uses the internal non-interactive simple merge algorithm for merging
2030 files. It will fail if there are any conflicts and leave markers in the
2032 files. It will fail if there are any conflicts and leave markers in the
2031 partially merged file. Marker will have three sections, one from each
2033 partially merged file. Marker will have three sections, one from each
2032 side of the merge and one for the base content.
2034 side of the merge and one for the base content.
2033
2035
2034 ":other"
2036 ":other"
2035 Uses the other 'p2()' version of files as the merged version.
2037 Uses the other 'p2()' version of files as the merged version.
2036
2038
2037 (actual capabilities: binary, symlink)
2039 (actual capabilities: binary, symlink)
2038
2040
2039 ":prompt"
2041 ":prompt"
2040 Asks the user which of the local 'p1()' or the other 'p2()' version to
2042 Asks the user which of the local 'p1()' or the other 'p2()' version to
2041 keep as the merged version.
2043 keep as the merged version.
2042
2044
2043 (actual capabilities: binary, symlink)
2045 (actual capabilities: binary, symlink)
2044
2046
2045 ":tagmerge"
2047 ":tagmerge"
2046 Uses the internal tag merge algorithm (experimental).
2048 Uses the internal tag merge algorithm (experimental).
2047
2049
2048 ":union"
2050 ":union"
2049 Uses the internal non-interactive simple merge algorithm for merging
2051 Uses the internal non-interactive simple merge algorithm for merging
2050 files. It will use both left and right sides for conflict regions. No
2052 files. It will use both left and right sides for conflict regions. No
2051 markers are inserted.
2053 markers are inserted.
2052
2054
2053 Internal tools are always available and do not require a GUI but will by
2055 Internal tools are always available and do not require a GUI but will by
2054 default not handle symlinks or binary files. See next section for detail
2056 default not handle symlinks or binary files. See next section for detail
2055 about "actual capabilities" described above.
2057 about "actual capabilities" described above.
2056
2058
2057 Choosing a merge tool
2059 Choosing a merge tool
2058 =====================
2060 =====================
2059
2061
2060 Mercurial uses these rules when deciding which merge tool to use:
2062 Mercurial uses these rules when deciding which merge tool to use:
2061
2063
2062 1. If a tool has been specified with the --tool option to merge or
2064 1. If a tool has been specified with the --tool option to merge or
2063 resolve, it is used. If it is the name of a tool in the merge-tools
2065 resolve, it is used. If it is the name of a tool in the merge-tools
2064 configuration, its configuration is used. Otherwise the specified tool
2066 configuration, its configuration is used. Otherwise the specified tool
2065 must be executable by the shell.
2067 must be executable by the shell.
2066 2. If the "HGMERGE" environment variable is present, its value is used and
2068 2. If the "HGMERGE" environment variable is present, its value is used and
2067 must be executable by the shell.
2069 must be executable by the shell.
2068 3. If the filename of the file to be merged matches any of the patterns in
2070 3. If the filename of the file to be merged matches any of the patterns in
2069 the merge-patterns configuration section, the first usable merge tool
2071 the merge-patterns configuration section, the first usable merge tool
2070 corresponding to a matching pattern is used.
2072 corresponding to a matching pattern is used.
2071 4. If ui.merge is set it will be considered next. If the value is not the
2073 4. If ui.merge is set it will be considered next. If the value is not the
2072 name of a configured tool, the specified value is used and must be
2074 name of a configured tool, the specified value is used and must be
2073 executable by the shell. Otherwise the named tool is used if it is
2075 executable by the shell. Otherwise the named tool is used if it is
2074 usable.
2076 usable.
2075 5. If any usable merge tools are present in the merge-tools configuration
2077 5. If any usable merge tools are present in the merge-tools configuration
2076 section, the one with the highest priority is used.
2078 section, the one with the highest priority is used.
2077 6. If a program named "hgmerge" can be found on the system, it is used -
2079 6. If a program named "hgmerge" can be found on the system, it is used -
2078 but it will by default not be used for symlinks and binary files.
2080 but it will by default not be used for symlinks and binary files.
2079 7. If the file to be merged is not binary and is not a symlink, then
2081 7. If the file to be merged is not binary and is not a symlink, then
2080 internal ":merge" is used.
2082 internal ":merge" is used.
2081 8. Otherwise, ":prompt" is used.
2083 8. Otherwise, ":prompt" is used.
2082
2084
2083 For historical reason, Mercurial treats merge tools as below while
2085 For historical reason, Mercurial treats merge tools as below while
2084 examining rules above.
2086 examining rules above.
2085
2087
2086 step specified via binary symlink
2088 step specified via binary symlink
2087 ----------------------------------
2089 ----------------------------------
2088 1. --tool o/o o/o
2090 1. --tool o/o o/o
2089 2. HGMERGE o/o o/o
2091 2. HGMERGE o/o o/o
2090 3. merge-patterns o/o(*) x/?(*)
2092 3. merge-patterns o/o(*) x/?(*)
2091 4. ui.merge x/?(*) x/?(*)
2093 4. ui.merge x/?(*) x/?(*)
2092
2094
2093 Each capability column indicates Mercurial behavior for internal/external
2095 Each capability column indicates Mercurial behavior for internal/external
2094 merge tools at examining each rule.
2096 merge tools at examining each rule.
2095
2097
2096 - "o": "assume that a tool has capability"
2098 - "o": "assume that a tool has capability"
2097 - "x": "assume that a tool does not have capability"
2099 - "x": "assume that a tool does not have capability"
2098 - "?": "check actual capability of a tool"
2100 - "?": "check actual capability of a tool"
2099
2101
2100 If "merge.strict-capability-check" configuration is true, Mercurial checks
2102 If "merge.strict-capability-check" configuration is true, Mercurial checks
2101 capabilities of merge tools strictly in (*) cases above (= each capability
2103 capabilities of merge tools strictly in (*) cases above (= each capability
2102 column becomes "?/?"). It is false by default for backward compatibility.
2104 column becomes "?/?"). It is false by default for backward compatibility.
2103
2105
2104 Note:
2106 Note:
2105 After selecting a merge program, Mercurial will by default attempt to
2107 After selecting a merge program, Mercurial will by default attempt to
2106 merge the files using a simple merge algorithm first. Only if it
2108 merge the files using a simple merge algorithm first. Only if it
2107 doesn't succeed because of conflicting changes will Mercurial actually
2109 doesn't succeed because of conflicting changes will Mercurial actually
2108 execute the merge program. Whether to use the simple merge algorithm
2110 execute the merge program. Whether to use the simple merge algorithm
2109 first can be controlled by the premerge setting of the merge tool.
2111 first can be controlled by the premerge setting of the merge tool.
2110 Premerge is enabled by default unless the file is binary or a symlink.
2112 Premerge is enabled by default unless the file is binary or a symlink.
2111
2113
2112 See the merge-tools and ui sections of hgrc(5) for details on the
2114 See the merge-tools and ui sections of hgrc(5) for details on the
2113 configuration of merge tools.
2115 configuration of merge tools.
2114
2116
2115 Compression engines listed in `hg help bundlespec`
2117 Compression engines listed in `hg help bundlespec`
2116
2118
2117 $ hg help bundlespec | grep gzip
2119 $ hg help bundlespec | grep gzip
2118 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2120 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2119 An algorithm that produces smaller bundles than "gzip".
2121 An algorithm that produces smaller bundles than "gzip".
2120 This engine will likely produce smaller bundles than "gzip" but will be
2122 This engine will likely produce smaller bundles than "gzip" but will be
2121 "gzip"
2123 "gzip"
2122 better compression than "gzip". It also frequently yields better (?)
2124 better compression than "gzip". It also frequently yields better (?)
2123
2125
2124 Test usage of section marks in help documents
2126 Test usage of section marks in help documents
2125
2127
2126 $ cd "$TESTDIR"/../doc
2128 $ cd "$TESTDIR"/../doc
2127 $ "$PYTHON" check-seclevel.py
2129 $ "$PYTHON" check-seclevel.py
2128 $ cd $TESTTMP
2130 $ cd $TESTTMP
2129
2131
2130 #if serve
2132 #if serve
2131
2133
2132 Test the help pages in hgweb.
2134 Test the help pages in hgweb.
2133
2135
2134 Dish up an empty repo; serve it cold.
2136 Dish up an empty repo; serve it cold.
2135
2137
2136 $ hg init "$TESTTMP/test"
2138 $ hg init "$TESTTMP/test"
2137 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2139 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2138 $ cat hg.pid >> $DAEMON_PIDS
2140 $ cat hg.pid >> $DAEMON_PIDS
2139
2141
2140 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2142 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2141 200 Script output follows
2143 200 Script output follows
2142
2144
2143 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2145 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2144 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2146 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2145 <head>
2147 <head>
2146 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2148 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2147 <meta name="robots" content="index, nofollow" />
2149 <meta name="robots" content="index, nofollow" />
2148 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2150 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2149 <script type="text/javascript" src="/static/mercurial.js"></script>
2151 <script type="text/javascript" src="/static/mercurial.js"></script>
2150
2152
2151 <title>Help: Index</title>
2153 <title>Help: Index</title>
2152 </head>
2154 </head>
2153 <body>
2155 <body>
2154
2156
2155 <div class="container">
2157 <div class="container">
2156 <div class="menu">
2158 <div class="menu">
2157 <div class="logo">
2159 <div class="logo">
2158 <a href="https://mercurial-scm.org/">
2160 <a href="https://mercurial-scm.org/">
2159 <img src="/static/hglogo.png" alt="mercurial" /></a>
2161 <img src="/static/hglogo.png" alt="mercurial" /></a>
2160 </div>
2162 </div>
2161 <ul>
2163 <ul>
2162 <li><a href="/shortlog">log</a></li>
2164 <li><a href="/shortlog">log</a></li>
2163 <li><a href="/graph">graph</a></li>
2165 <li><a href="/graph">graph</a></li>
2164 <li><a href="/tags">tags</a></li>
2166 <li><a href="/tags">tags</a></li>
2165 <li><a href="/bookmarks">bookmarks</a></li>
2167 <li><a href="/bookmarks">bookmarks</a></li>
2166 <li><a href="/branches">branches</a></li>
2168 <li><a href="/branches">branches</a></li>
2167 </ul>
2169 </ul>
2168 <ul>
2170 <ul>
2169 <li class="active">help</li>
2171 <li class="active">help</li>
2170 </ul>
2172 </ul>
2171 </div>
2173 </div>
2172
2174
2173 <div class="main">
2175 <div class="main">
2174 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2176 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2175
2177
2176 <form class="search" action="/log">
2178 <form class="search" action="/log">
2177
2179
2178 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2180 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2179 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2181 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2180 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2182 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2181 </form>
2183 </form>
2182 <table class="bigtable">
2184 <table class="bigtable">
2183 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2185 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2184
2186
2185 <tr><td>
2187 <tr><td>
2186 <a href="/help/bundlespec">
2188 <a href="/help/bundlespec">
2187 bundlespec
2189 bundlespec
2188 </a>
2190 </a>
2189 </td><td>
2191 </td><td>
2190 Bundle File Formats
2192 Bundle File Formats
2191 </td></tr>
2193 </td></tr>
2192 <tr><td>
2194 <tr><td>
2193 <a href="/help/color">
2195 <a href="/help/color">
2194 color
2196 color
2195 </a>
2197 </a>
2196 </td><td>
2198 </td><td>
2197 Colorizing Outputs
2199 Colorizing Outputs
2198 </td></tr>
2200 </td></tr>
2199 <tr><td>
2201 <tr><td>
2200 <a href="/help/config">
2202 <a href="/help/config">
2201 config
2203 config
2202 </a>
2204 </a>
2203 </td><td>
2205 </td><td>
2204 Configuration Files
2206 Configuration Files
2205 </td></tr>
2207 </td></tr>
2206 <tr><td>
2208 <tr><td>
2207 <a href="/help/dates">
2209 <a href="/help/dates">
2208 dates
2210 dates
2209 </a>
2211 </a>
2210 </td><td>
2212 </td><td>
2211 Date Formats
2213 Date Formats
2212 </td></tr>
2214 </td></tr>
2213 <tr><td>
2215 <tr><td>
2214 <a href="/help/deprecated">
2216 <a href="/help/deprecated">
2215 deprecated
2217 deprecated
2216 </a>
2218 </a>
2217 </td><td>
2219 </td><td>
2218 Deprecated Features
2220 Deprecated Features
2219 </td></tr>
2221 </td></tr>
2220 <tr><td>
2222 <tr><td>
2221 <a href="/help/diffs">
2223 <a href="/help/diffs">
2222 diffs
2224 diffs
2223 </a>
2225 </a>
2224 </td><td>
2226 </td><td>
2225 Diff Formats
2227 Diff Formats
2226 </td></tr>
2228 </td></tr>
2227 <tr><td>
2229 <tr><td>
2228 <a href="/help/environment">
2230 <a href="/help/environment">
2229 environment
2231 environment
2230 </a>
2232 </a>
2231 </td><td>
2233 </td><td>
2232 Environment Variables
2234 Environment Variables
2233 </td></tr>
2235 </td></tr>
2234 <tr><td>
2236 <tr><td>
2235 <a href="/help/extensions">
2237 <a href="/help/extensions">
2236 extensions
2238 extensions
2237 </a>
2239 </a>
2238 </td><td>
2240 </td><td>
2239 Using Additional Features
2241 Using Additional Features
2240 </td></tr>
2242 </td></tr>
2241 <tr><td>
2243 <tr><td>
2242 <a href="/help/filesets">
2244 <a href="/help/filesets">
2243 filesets
2245 filesets
2244 </a>
2246 </a>
2245 </td><td>
2247 </td><td>
2246 Specifying File Sets
2248 Specifying File Sets
2247 </td></tr>
2249 </td></tr>
2248 <tr><td>
2250 <tr><td>
2249 <a href="/help/flags">
2251 <a href="/help/flags">
2250 flags
2252 flags
2251 </a>
2253 </a>
2252 </td><td>
2254 </td><td>
2253 Command-line flags
2255 Command-line flags
2254 </td></tr>
2256 </td></tr>
2255 <tr><td>
2257 <tr><td>
2256 <a href="/help/glossary">
2258 <a href="/help/glossary">
2257 glossary
2259 glossary
2258 </a>
2260 </a>
2259 </td><td>
2261 </td><td>
2260 Glossary
2262 Glossary
2261 </td></tr>
2263 </td></tr>
2262 <tr><td>
2264 <tr><td>
2263 <a href="/help/hgignore">
2265 <a href="/help/hgignore">
2264 hgignore
2266 hgignore
2265 </a>
2267 </a>
2266 </td><td>
2268 </td><td>
2267 Syntax for Mercurial Ignore Files
2269 Syntax for Mercurial Ignore Files
2268 </td></tr>
2270 </td></tr>
2269 <tr><td>
2271 <tr><td>
2270 <a href="/help/hgweb">
2272 <a href="/help/hgweb">
2271 hgweb
2273 hgweb
2272 </a>
2274 </a>
2273 </td><td>
2275 </td><td>
2274 Configuring hgweb
2276 Configuring hgweb
2275 </td></tr>
2277 </td></tr>
2276 <tr><td>
2278 <tr><td>
2277 <a href="/help/internals">
2279 <a href="/help/internals">
2278 internals
2280 internals
2279 </a>
2281 </a>
2280 </td><td>
2282 </td><td>
2281 Technical implementation topics
2283 Technical implementation topics
2282 </td></tr>
2284 </td></tr>
2283 <tr><td>
2285 <tr><td>
2284 <a href="/help/merge-tools">
2286 <a href="/help/merge-tools">
2285 merge-tools
2287 merge-tools
2286 </a>
2288 </a>
2287 </td><td>
2289 </td><td>
2288 Merge Tools
2290 Merge Tools
2289 </td></tr>
2291 </td></tr>
2290 <tr><td>
2292 <tr><td>
2291 <a href="/help/pager">
2293 <a href="/help/pager">
2292 pager
2294 pager
2293 </a>
2295 </a>
2294 </td><td>
2296 </td><td>
2295 Pager Support
2297 Pager Support
2296 </td></tr>
2298 </td></tr>
2297 <tr><td>
2299 <tr><td>
2298 <a href="/help/patterns">
2300 <a href="/help/patterns">
2299 patterns
2301 patterns
2300 </a>
2302 </a>
2301 </td><td>
2303 </td><td>
2302 File Name Patterns
2304 File Name Patterns
2303 </td></tr>
2305 </td></tr>
2304 <tr><td>
2306 <tr><td>
2305 <a href="/help/phases">
2307 <a href="/help/phases">
2306 phases
2308 phases
2307 </a>
2309 </a>
2308 </td><td>
2310 </td><td>
2309 Working with Phases
2311 Working with Phases
2310 </td></tr>
2312 </td></tr>
2311 <tr><td>
2313 <tr><td>
2312 <a href="/help/revisions">
2314 <a href="/help/revisions">
2313 revisions
2315 revisions
2314 </a>
2316 </a>
2315 </td><td>
2317 </td><td>
2316 Specifying Revisions
2318 Specifying Revisions
2317 </td></tr>
2319 </td></tr>
2318 <tr><td>
2320 <tr><td>
2319 <a href="/help/scripting">
2321 <a href="/help/scripting">
2320 scripting
2322 scripting
2321 </a>
2323 </a>
2322 </td><td>
2324 </td><td>
2323 Using Mercurial from scripts and automation
2325 Using Mercurial from scripts and automation
2324 </td></tr>
2326 </td></tr>
2325 <tr><td>
2327 <tr><td>
2326 <a href="/help/subrepos">
2328 <a href="/help/subrepos">
2327 subrepos
2329 subrepos
2328 </a>
2330 </a>
2329 </td><td>
2331 </td><td>
2330 Subrepositories
2332 Subrepositories
2331 </td></tr>
2333 </td></tr>
2332 <tr><td>
2334 <tr><td>
2333 <a href="/help/templating">
2335 <a href="/help/templating">
2334 templating
2336 templating
2335 </a>
2337 </a>
2336 </td><td>
2338 </td><td>
2337 Template Usage
2339 Template Usage
2338 </td></tr>
2340 </td></tr>
2339 <tr><td>
2341 <tr><td>
2340 <a href="/help/urls">
2342 <a href="/help/urls">
2341 urls
2343 urls
2342 </a>
2344 </a>
2343 </td><td>
2345 </td><td>
2344 URL Paths
2346 URL Paths
2345 </td></tr>
2347 </td></tr>
2346 <tr><td>
2348 <tr><td>
2347 <a href="/help/topic-containing-verbose">
2349 <a href="/help/topic-containing-verbose">
2348 topic-containing-verbose
2350 topic-containing-verbose
2349 </a>
2351 </a>
2350 </td><td>
2352 </td><td>
2351 This is the topic to test omit indicating.
2353 This is the topic to test omit indicating.
2352 </td></tr>
2354 </td></tr>
2353
2355
2354
2356
2355 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2357 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2356
2358
2357 <tr><td>
2359 <tr><td>
2358 <a href="/help/abort">
2360 <a href="/help/abort">
2359 abort
2361 abort
2360 </a>
2362 </a>
2361 </td><td>
2363 </td><td>
2362 abort an unfinished operation (EXPERIMENTAL)
2364 abort an unfinished operation (EXPERIMENTAL)
2363 </td></tr>
2365 </td></tr>
2364 <tr><td>
2366 <tr><td>
2365 <a href="/help/add">
2367 <a href="/help/add">
2366 add
2368 add
2367 </a>
2369 </a>
2368 </td><td>
2370 </td><td>
2369 add the specified files on the next commit
2371 add the specified files on the next commit
2370 </td></tr>
2372 </td></tr>
2371 <tr><td>
2373 <tr><td>
2372 <a href="/help/annotate">
2374 <a href="/help/annotate">
2373 annotate
2375 annotate
2374 </a>
2376 </a>
2375 </td><td>
2377 </td><td>
2376 show changeset information by line for each file
2378 show changeset information by line for each file
2377 </td></tr>
2379 </td></tr>
2378 <tr><td>
2380 <tr><td>
2379 <a href="/help/clone">
2381 <a href="/help/clone">
2380 clone
2382 clone
2381 </a>
2383 </a>
2382 </td><td>
2384 </td><td>
2383 make a copy of an existing repository
2385 make a copy of an existing repository
2384 </td></tr>
2386 </td></tr>
2385 <tr><td>
2387 <tr><td>
2386 <a href="/help/commit">
2388 <a href="/help/commit">
2387 commit
2389 commit
2388 </a>
2390 </a>
2389 </td><td>
2391 </td><td>
2390 commit the specified files or all outstanding changes
2392 commit the specified files or all outstanding changes
2391 </td></tr>
2393 </td></tr>
2392 <tr><td>
2394 <tr><td>
2393 <a href="/help/continue">
2395 <a href="/help/continue">
2394 continue
2396 continue
2395 </a>
2397 </a>
2396 </td><td>
2398 </td><td>
2397 resumes an interrupted operation (EXPERIMENTAL)
2399 resumes an interrupted operation (EXPERIMENTAL)
2398 </td></tr>
2400 </td></tr>
2399 <tr><td>
2401 <tr><td>
2400 <a href="/help/diff">
2402 <a href="/help/diff">
2401 diff
2403 diff
2402 </a>
2404 </a>
2403 </td><td>
2405 </td><td>
2404 diff repository (or selected files)
2406 diff repository (or selected files)
2405 </td></tr>
2407 </td></tr>
2406 <tr><td>
2408 <tr><td>
2407 <a href="/help/export">
2409 <a href="/help/export">
2408 export
2410 export
2409 </a>
2411 </a>
2410 </td><td>
2412 </td><td>
2411 dump the header and diffs for one or more changesets
2413 dump the header and diffs for one or more changesets
2412 </td></tr>
2414 </td></tr>
2413 <tr><td>
2415 <tr><td>
2414 <a href="/help/forget">
2416 <a href="/help/forget">
2415 forget
2417 forget
2416 </a>
2418 </a>
2417 </td><td>
2419 </td><td>
2418 forget the specified files on the next commit
2420 forget the specified files on the next commit
2419 </td></tr>
2421 </td></tr>
2420 <tr><td>
2422 <tr><td>
2421 <a href="/help/init">
2423 <a href="/help/init">
2422 init
2424 init
2423 </a>
2425 </a>
2424 </td><td>
2426 </td><td>
2425 create a new repository in the given directory
2427 create a new repository in the given directory
2426 </td></tr>
2428 </td></tr>
2427 <tr><td>
2429 <tr><td>
2428 <a href="/help/log">
2430 <a href="/help/log">
2429 log
2431 log
2430 </a>
2432 </a>
2431 </td><td>
2433 </td><td>
2432 show revision history of entire repository or files
2434 show revision history of entire repository or files
2433 </td></tr>
2435 </td></tr>
2434 <tr><td>
2436 <tr><td>
2435 <a href="/help/merge">
2437 <a href="/help/merge">
2436 merge
2438 merge
2437 </a>
2439 </a>
2438 </td><td>
2440 </td><td>
2439 merge another revision into working directory
2441 merge another revision into working directory
2440 </td></tr>
2442 </td></tr>
2441 <tr><td>
2443 <tr><td>
2442 <a href="/help/pull">
2444 <a href="/help/pull">
2443 pull
2445 pull
2444 </a>
2446 </a>
2445 </td><td>
2447 </td><td>
2446 pull changes from the specified source
2448 pull changes from the specified source
2447 </td></tr>
2449 </td></tr>
2448 <tr><td>
2450 <tr><td>
2449 <a href="/help/push">
2451 <a href="/help/push">
2450 push
2452 push
2451 </a>
2453 </a>
2452 </td><td>
2454 </td><td>
2453 push changes to the specified destination
2455 push changes to the specified destination
2454 </td></tr>
2456 </td></tr>
2455 <tr><td>
2457 <tr><td>
2456 <a href="/help/remove">
2458 <a href="/help/remove">
2457 remove
2459 remove
2458 </a>
2460 </a>
2459 </td><td>
2461 </td><td>
2460 remove the specified files on the next commit
2462 remove the specified files on the next commit
2461 </td></tr>
2463 </td></tr>
2462 <tr><td>
2464 <tr><td>
2463 <a href="/help/serve">
2465 <a href="/help/serve">
2464 serve
2466 serve
2465 </a>
2467 </a>
2466 </td><td>
2468 </td><td>
2467 start stand-alone webserver
2469 start stand-alone webserver
2468 </td></tr>
2470 </td></tr>
2469 <tr><td>
2471 <tr><td>
2470 <a href="/help/status">
2472 <a href="/help/status">
2471 status
2473 status
2472 </a>
2474 </a>
2473 </td><td>
2475 </td><td>
2474 show changed files in the working directory
2476 show changed files in the working directory
2475 </td></tr>
2477 </td></tr>
2476 <tr><td>
2478 <tr><td>
2477 <a href="/help/summary">
2479 <a href="/help/summary">
2478 summary
2480 summary
2479 </a>
2481 </a>
2480 </td><td>
2482 </td><td>
2481 summarize working directory state
2483 summarize working directory state
2482 </td></tr>
2484 </td></tr>
2483 <tr><td>
2485 <tr><td>
2484 <a href="/help/update">
2486 <a href="/help/update">
2485 update
2487 update
2486 </a>
2488 </a>
2487 </td><td>
2489 </td><td>
2488 update working directory (or switch revisions)
2490 update working directory (or switch revisions)
2489 </td></tr>
2491 </td></tr>
2490
2492
2491
2493
2492
2494
2493 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2495 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2494
2496
2495 <tr><td>
2497 <tr><td>
2496 <a href="/help/addremove">
2498 <a href="/help/addremove">
2497 addremove
2499 addremove
2498 </a>
2500 </a>
2499 </td><td>
2501 </td><td>
2500 add all new files, delete all missing files
2502 add all new files, delete all missing files
2501 </td></tr>
2503 </td></tr>
2502 <tr><td>
2504 <tr><td>
2503 <a href="/help/archive">
2505 <a href="/help/archive">
2504 archive
2506 archive
2505 </a>
2507 </a>
2506 </td><td>
2508 </td><td>
2507 create an unversioned archive of a repository revision
2509 create an unversioned archive of a repository revision
2508 </td></tr>
2510 </td></tr>
2509 <tr><td>
2511 <tr><td>
2510 <a href="/help/backout">
2512 <a href="/help/backout">
2511 backout
2513 backout
2512 </a>
2514 </a>
2513 </td><td>
2515 </td><td>
2514 reverse effect of earlier changeset
2516 reverse effect of earlier changeset
2515 </td></tr>
2517 </td></tr>
2516 <tr><td>
2518 <tr><td>
2517 <a href="/help/bisect">
2519 <a href="/help/bisect">
2518 bisect
2520 bisect
2519 </a>
2521 </a>
2520 </td><td>
2522 </td><td>
2521 subdivision search of changesets
2523 subdivision search of changesets
2522 </td></tr>
2524 </td></tr>
2523 <tr><td>
2525 <tr><td>
2524 <a href="/help/bookmarks">
2526 <a href="/help/bookmarks">
2525 bookmarks
2527 bookmarks
2526 </a>
2528 </a>
2527 </td><td>
2529 </td><td>
2528 create a new bookmark or list existing bookmarks
2530 create a new bookmark or list existing bookmarks
2529 </td></tr>
2531 </td></tr>
2530 <tr><td>
2532 <tr><td>
2531 <a href="/help/branch">
2533 <a href="/help/branch">
2532 branch
2534 branch
2533 </a>
2535 </a>
2534 </td><td>
2536 </td><td>
2535 set or show the current branch name
2537 set or show the current branch name
2536 </td></tr>
2538 </td></tr>
2537 <tr><td>
2539 <tr><td>
2538 <a href="/help/branches">
2540 <a href="/help/branches">
2539 branches
2541 branches
2540 </a>
2542 </a>
2541 </td><td>
2543 </td><td>
2542 list repository named branches
2544 list repository named branches
2543 </td></tr>
2545 </td></tr>
2544 <tr><td>
2546 <tr><td>
2545 <a href="/help/bundle">
2547 <a href="/help/bundle">
2546 bundle
2548 bundle
2547 </a>
2549 </a>
2548 </td><td>
2550 </td><td>
2549 create a bundle file
2551 create a bundle file
2550 </td></tr>
2552 </td></tr>
2551 <tr><td>
2553 <tr><td>
2552 <a href="/help/cat">
2554 <a href="/help/cat">
2553 cat
2555 cat
2554 </a>
2556 </a>
2555 </td><td>
2557 </td><td>
2556 output the current or given revision of files
2558 output the current or given revision of files
2557 </td></tr>
2559 </td></tr>
2558 <tr><td>
2560 <tr><td>
2559 <a href="/help/config">
2561 <a href="/help/config">
2560 config
2562 config
2561 </a>
2563 </a>
2562 </td><td>
2564 </td><td>
2563 show combined config settings from all hgrc files
2565 show combined config settings from all hgrc files
2564 </td></tr>
2566 </td></tr>
2565 <tr><td>
2567 <tr><td>
2566 <a href="/help/copy">
2568 <a href="/help/copy">
2567 copy
2569 copy
2568 </a>
2570 </a>
2569 </td><td>
2571 </td><td>
2570 mark files as copied for the next commit
2572 mark files as copied for the next commit
2571 </td></tr>
2573 </td></tr>
2572 <tr><td>
2574 <tr><td>
2573 <a href="/help/files">
2575 <a href="/help/files">
2574 files
2576 files
2575 </a>
2577 </a>
2576 </td><td>
2578 </td><td>
2577 list tracked files
2579 list tracked files
2578 </td></tr>
2580 </td></tr>
2579 <tr><td>
2581 <tr><td>
2580 <a href="/help/graft">
2582 <a href="/help/graft">
2581 graft
2583 graft
2582 </a>
2584 </a>
2583 </td><td>
2585 </td><td>
2584 copy changes from other branches onto the current branch
2586 copy changes from other branches onto the current branch
2585 </td></tr>
2587 </td></tr>
2586 <tr><td>
2588 <tr><td>
2587 <a href="/help/grep">
2589 <a href="/help/grep">
2588 grep
2590 grep
2589 </a>
2591 </a>
2590 </td><td>
2592 </td><td>
2591 search revision history for a pattern in specified files
2593 search revision history for a pattern in specified files
2592 </td></tr>
2594 </td></tr>
2593 <tr><td>
2595 <tr><td>
2594 <a href="/help/hashelp">
2596 <a href="/help/hashelp">
2595 hashelp
2597 hashelp
2596 </a>
2598 </a>
2597 </td><td>
2599 </td><td>
2598 Extension command's help
2600 Extension command's help
2599 </td></tr>
2601 </td></tr>
2600 <tr><td>
2602 <tr><td>
2601 <a href="/help/heads">
2603 <a href="/help/heads">
2602 heads
2604 heads
2603 </a>
2605 </a>
2604 </td><td>
2606 </td><td>
2605 show branch heads
2607 show branch heads
2606 </td></tr>
2608 </td></tr>
2607 <tr><td>
2609 <tr><td>
2608 <a href="/help/help">
2610 <a href="/help/help">
2609 help
2611 help
2610 </a>
2612 </a>
2611 </td><td>
2613 </td><td>
2612 show help for a given topic or a help overview
2614 show help for a given topic or a help overview
2613 </td></tr>
2615 </td></tr>
2614 <tr><td>
2616 <tr><td>
2615 <a href="/help/hgalias">
2617 <a href="/help/hgalias">
2616 hgalias
2618 hgalias
2617 </a>
2619 </a>
2618 </td><td>
2620 </td><td>
2619 My doc
2621 My doc
2620 </td></tr>
2622 </td></tr>
2621 <tr><td>
2623 <tr><td>
2622 <a href="/help/hgaliasnodoc">
2624 <a href="/help/hgaliasnodoc">
2623 hgaliasnodoc
2625 hgaliasnodoc
2624 </a>
2626 </a>
2625 </td><td>
2627 </td><td>
2626 summarize working directory state
2628 summarize working directory state
2627 </td></tr>
2629 </td></tr>
2628 <tr><td>
2630 <tr><td>
2629 <a href="/help/identify">
2631 <a href="/help/identify">
2630 identify
2632 identify
2631 </a>
2633 </a>
2632 </td><td>
2634 </td><td>
2633 identify the working directory or specified revision
2635 identify the working directory or specified revision
2634 </td></tr>
2636 </td></tr>
2635 <tr><td>
2637 <tr><td>
2636 <a href="/help/import">
2638 <a href="/help/import">
2637 import
2639 import
2638 </a>
2640 </a>
2639 </td><td>
2641 </td><td>
2640 import an ordered set of patches
2642 import an ordered set of patches
2641 </td></tr>
2643 </td></tr>
2642 <tr><td>
2644 <tr><td>
2643 <a href="/help/incoming">
2645 <a href="/help/incoming">
2644 incoming
2646 incoming
2645 </a>
2647 </a>
2646 </td><td>
2648 </td><td>
2647 show new changesets found in source
2649 show new changesets found in source
2648 </td></tr>
2650 </td></tr>
2649 <tr><td>
2651 <tr><td>
2650 <a href="/help/manifest">
2652 <a href="/help/manifest">
2651 manifest
2653 manifest
2652 </a>
2654 </a>
2653 </td><td>
2655 </td><td>
2654 output the current or given revision of the project manifest
2656 output the current or given revision of the project manifest
2655 </td></tr>
2657 </td></tr>
2656 <tr><td>
2658 <tr><td>
2657 <a href="/help/nohelp">
2659 <a href="/help/nohelp">
2658 nohelp
2660 nohelp
2659 </a>
2661 </a>
2660 </td><td>
2662 </td><td>
2661 (no help text available)
2663 (no help text available)
2662 </td></tr>
2664 </td></tr>
2663 <tr><td>
2665 <tr><td>
2664 <a href="/help/outgoing">
2666 <a href="/help/outgoing">
2665 outgoing
2667 outgoing
2666 </a>
2668 </a>
2667 </td><td>
2669 </td><td>
2668 show changesets not found in the destination
2670 show changesets not found in the destination
2669 </td></tr>
2671 </td></tr>
2670 <tr><td>
2672 <tr><td>
2671 <a href="/help/paths">
2673 <a href="/help/paths">
2672 paths
2674 paths
2673 </a>
2675 </a>
2674 </td><td>
2676 </td><td>
2675 show aliases for remote repositories
2677 show aliases for remote repositories
2676 </td></tr>
2678 </td></tr>
2677 <tr><td>
2679 <tr><td>
2678 <a href="/help/phase">
2680 <a href="/help/phase">
2679 phase
2681 phase
2680 </a>
2682 </a>
2681 </td><td>
2683 </td><td>
2682 set or show the current phase name
2684 set or show the current phase name
2683 </td></tr>
2685 </td></tr>
2684 <tr><td>
2686 <tr><td>
2685 <a href="/help/recover">
2687 <a href="/help/recover">
2686 recover
2688 recover
2687 </a>
2689 </a>
2688 </td><td>
2690 </td><td>
2689 roll back an interrupted transaction
2691 roll back an interrupted transaction
2690 </td></tr>
2692 </td></tr>
2691 <tr><td>
2693 <tr><td>
2692 <a href="/help/rename">
2694 <a href="/help/rename">
2693 rename
2695 rename
2694 </a>
2696 </a>
2695 </td><td>
2697 </td><td>
2696 rename files; equivalent of copy + remove
2698 rename files; equivalent of copy + remove
2697 </td></tr>
2699 </td></tr>
2698 <tr><td>
2700 <tr><td>
2699 <a href="/help/resolve">
2701 <a href="/help/resolve">
2700 resolve
2702 resolve
2701 </a>
2703 </a>
2702 </td><td>
2704 </td><td>
2703 redo merges or set/view the merge status of files
2705 redo merges or set/view the merge status of files
2704 </td></tr>
2706 </td></tr>
2705 <tr><td>
2707 <tr><td>
2706 <a href="/help/revert">
2708 <a href="/help/revert">
2707 revert
2709 revert
2708 </a>
2710 </a>
2709 </td><td>
2711 </td><td>
2710 restore files to their checkout state
2712 restore files to their checkout state
2711 </td></tr>
2713 </td></tr>
2712 <tr><td>
2714 <tr><td>
2713 <a href="/help/root">
2715 <a href="/help/root">
2714 root
2716 root
2715 </a>
2717 </a>
2716 </td><td>
2718 </td><td>
2717 print the root (top) of the current working directory
2719 print the root (top) of the current working directory
2718 </td></tr>
2720 </td></tr>
2719 <tr><td>
2721 <tr><td>
2720 <a href="/help/shellalias">
2722 <a href="/help/shellalias">
2721 shellalias
2723 shellalias
2722 </a>
2724 </a>
2723 </td><td>
2725 </td><td>
2724 (no help text available)
2726 (no help text available)
2725 </td></tr>
2727 </td></tr>
2726 <tr><td>
2728 <tr><td>
2727 <a href="/help/shelve">
2729 <a href="/help/shelve">
2728 shelve
2730 shelve
2729 </a>
2731 </a>
2730 </td><td>
2732 </td><td>
2731 save and set aside changes from the working directory
2733 save and set aside changes from the working directory
2732 </td></tr>
2734 </td></tr>
2733 <tr><td>
2735 <tr><td>
2734 <a href="/help/tag">
2736 <a href="/help/tag">
2735 tag
2737 tag
2736 </a>
2738 </a>
2737 </td><td>
2739 </td><td>
2738 add one or more tags for the current or given revision
2740 add one or more tags for the current or given revision
2739 </td></tr>
2741 </td></tr>
2740 <tr><td>
2742 <tr><td>
2741 <a href="/help/tags">
2743 <a href="/help/tags">
2742 tags
2744 tags
2743 </a>
2745 </a>
2744 </td><td>
2746 </td><td>
2745 list repository tags
2747 list repository tags
2746 </td></tr>
2748 </td></tr>
2747 <tr><td>
2749 <tr><td>
2748 <a href="/help/unbundle">
2750 <a href="/help/unbundle">
2749 unbundle
2751 unbundle
2750 </a>
2752 </a>
2751 </td><td>
2753 </td><td>
2752 apply one or more bundle files
2754 apply one or more bundle files
2753 </td></tr>
2755 </td></tr>
2754 <tr><td>
2756 <tr><td>
2755 <a href="/help/unshelve">
2757 <a href="/help/unshelve">
2756 unshelve
2758 unshelve
2757 </a>
2759 </a>
2758 </td><td>
2760 </td><td>
2759 restore a shelved change to the working directory
2761 restore a shelved change to the working directory
2760 </td></tr>
2762 </td></tr>
2761 <tr><td>
2763 <tr><td>
2762 <a href="/help/verify">
2764 <a href="/help/verify">
2763 verify
2765 verify
2764 </a>
2766 </a>
2765 </td><td>
2767 </td><td>
2766 verify the integrity of the repository
2768 verify the integrity of the repository
2767 </td></tr>
2769 </td></tr>
2768 <tr><td>
2770 <tr><td>
2769 <a href="/help/version">
2771 <a href="/help/version">
2770 version
2772 version
2771 </a>
2773 </a>
2772 </td><td>
2774 </td><td>
2773 output version and copyright information
2775 output version and copyright information
2774 </td></tr>
2776 </td></tr>
2775
2777
2776
2778
2777 </table>
2779 </table>
2778 </div>
2780 </div>
2779 </div>
2781 </div>
2780
2782
2781
2783
2782
2784
2783 </body>
2785 </body>
2784 </html>
2786 </html>
2785
2787
2786
2788
2787 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2789 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2788 200 Script output follows
2790 200 Script output follows
2789
2791
2790 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2792 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2791 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2793 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2792 <head>
2794 <head>
2793 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2795 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2794 <meta name="robots" content="index, nofollow" />
2796 <meta name="robots" content="index, nofollow" />
2795 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2797 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2796 <script type="text/javascript" src="/static/mercurial.js"></script>
2798 <script type="text/javascript" src="/static/mercurial.js"></script>
2797
2799
2798 <title>Help: add</title>
2800 <title>Help: add</title>
2799 </head>
2801 </head>
2800 <body>
2802 <body>
2801
2803
2802 <div class="container">
2804 <div class="container">
2803 <div class="menu">
2805 <div class="menu">
2804 <div class="logo">
2806 <div class="logo">
2805 <a href="https://mercurial-scm.org/">
2807 <a href="https://mercurial-scm.org/">
2806 <img src="/static/hglogo.png" alt="mercurial" /></a>
2808 <img src="/static/hglogo.png" alt="mercurial" /></a>
2807 </div>
2809 </div>
2808 <ul>
2810 <ul>
2809 <li><a href="/shortlog">log</a></li>
2811 <li><a href="/shortlog">log</a></li>
2810 <li><a href="/graph">graph</a></li>
2812 <li><a href="/graph">graph</a></li>
2811 <li><a href="/tags">tags</a></li>
2813 <li><a href="/tags">tags</a></li>
2812 <li><a href="/bookmarks">bookmarks</a></li>
2814 <li><a href="/bookmarks">bookmarks</a></li>
2813 <li><a href="/branches">branches</a></li>
2815 <li><a href="/branches">branches</a></li>
2814 </ul>
2816 </ul>
2815 <ul>
2817 <ul>
2816 <li class="active"><a href="/help">help</a></li>
2818 <li class="active"><a href="/help">help</a></li>
2817 </ul>
2819 </ul>
2818 </div>
2820 </div>
2819
2821
2820 <div class="main">
2822 <div class="main">
2821 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2823 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2822 <h3>Help: add</h3>
2824 <h3>Help: add</h3>
2823
2825
2824 <form class="search" action="/log">
2826 <form class="search" action="/log">
2825
2827
2826 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2828 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2827 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2829 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2828 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2830 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2829 </form>
2831 </form>
2830 <div id="doc">
2832 <div id="doc">
2831 <p>
2833 <p>
2832 hg add [OPTION]... [FILE]...
2834 hg add [OPTION]... [FILE]...
2833 </p>
2835 </p>
2834 <p>
2836 <p>
2835 add the specified files on the next commit
2837 add the specified files on the next commit
2836 </p>
2838 </p>
2837 <p>
2839 <p>
2838 Schedule files to be version controlled and added to the
2840 Schedule files to be version controlled and added to the
2839 repository.
2841 repository.
2840 </p>
2842 </p>
2841 <p>
2843 <p>
2842 The files will be added to the repository at the next commit. To
2844 The files will be added to the repository at the next commit. To
2843 undo an add before that, see 'hg forget'.
2845 undo an add before that, see 'hg forget'.
2844 </p>
2846 </p>
2845 <p>
2847 <p>
2846 If no names are given, add all files to the repository (except
2848 If no names are given, add all files to the repository (except
2847 files matching &quot;.hgignore&quot;).
2849 files matching &quot;.hgignore&quot;).
2848 </p>
2850 </p>
2849 <p>
2851 <p>
2850 Examples:
2852 Examples:
2851 </p>
2853 </p>
2852 <ul>
2854 <ul>
2853 <li> New (unknown) files are added automatically by 'hg add':
2855 <li> New (unknown) files are added automatically by 'hg add':
2854 <pre>
2856 <pre>
2855 \$ ls (re)
2857 \$ ls (re)
2856 foo.c
2858 foo.c
2857 \$ hg status (re)
2859 \$ hg status (re)
2858 ? foo.c
2860 ? foo.c
2859 \$ hg add (re)
2861 \$ hg add (re)
2860 adding foo.c
2862 adding foo.c
2861 \$ hg status (re)
2863 \$ hg status (re)
2862 A foo.c
2864 A foo.c
2863 </pre>
2865 </pre>
2864 <li> Specific files to be added can be specified:
2866 <li> Specific files to be added can be specified:
2865 <pre>
2867 <pre>
2866 \$ ls (re)
2868 \$ ls (re)
2867 bar.c foo.c
2869 bar.c foo.c
2868 \$ hg status (re)
2870 \$ hg status (re)
2869 ? bar.c
2871 ? bar.c
2870 ? foo.c
2872 ? foo.c
2871 \$ hg add bar.c (re)
2873 \$ hg add bar.c (re)
2872 \$ hg status (re)
2874 \$ hg status (re)
2873 A bar.c
2875 A bar.c
2874 ? foo.c
2876 ? foo.c
2875 </pre>
2877 </pre>
2876 </ul>
2878 </ul>
2877 <p>
2879 <p>
2878 Returns 0 if all files are successfully added.
2880 Returns 0 if all files are successfully added.
2879 </p>
2881 </p>
2880 <p>
2882 <p>
2881 options ([+] can be repeated):
2883 options ([+] can be repeated):
2882 </p>
2884 </p>
2883 <table>
2885 <table>
2884 <tr><td>-I</td>
2886 <tr><td>-I</td>
2885 <td>--include PATTERN [+]</td>
2887 <td>--include PATTERN [+]</td>
2886 <td>include names matching the given patterns</td></tr>
2888 <td>include names matching the given patterns</td></tr>
2887 <tr><td>-X</td>
2889 <tr><td>-X</td>
2888 <td>--exclude PATTERN [+]</td>
2890 <td>--exclude PATTERN [+]</td>
2889 <td>exclude names matching the given patterns</td></tr>
2891 <td>exclude names matching the given patterns</td></tr>
2890 <tr><td>-S</td>
2892 <tr><td>-S</td>
2891 <td>--subrepos</td>
2893 <td>--subrepos</td>
2892 <td>recurse into subrepositories</td></tr>
2894 <td>recurse into subrepositories</td></tr>
2893 <tr><td>-n</td>
2895 <tr><td>-n</td>
2894 <td>--dry-run</td>
2896 <td>--dry-run</td>
2895 <td>do not perform actions, just print output</td></tr>
2897 <td>do not perform actions, just print output</td></tr>
2896 </table>
2898 </table>
2897 <p>
2899 <p>
2898 global options ([+] can be repeated):
2900 global options ([+] can be repeated):
2899 </p>
2901 </p>
2900 <table>
2902 <table>
2901 <tr><td>-R</td>
2903 <tr><td>-R</td>
2902 <td>--repository REPO</td>
2904 <td>--repository REPO</td>
2903 <td>repository root directory or name of overlay bundle file</td></tr>
2905 <td>repository root directory or name of overlay bundle file</td></tr>
2904 <tr><td></td>
2906 <tr><td></td>
2905 <td>--cwd DIR</td>
2907 <td>--cwd DIR</td>
2906 <td>change working directory</td></tr>
2908 <td>change working directory</td></tr>
2907 <tr><td>-y</td>
2909 <tr><td>-y</td>
2908 <td>--noninteractive</td>
2910 <td>--noninteractive</td>
2909 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2911 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2910 <tr><td>-q</td>
2912 <tr><td>-q</td>
2911 <td>--quiet</td>
2913 <td>--quiet</td>
2912 <td>suppress output</td></tr>
2914 <td>suppress output</td></tr>
2913 <tr><td>-v</td>
2915 <tr><td>-v</td>
2914 <td>--verbose</td>
2916 <td>--verbose</td>
2915 <td>enable additional output</td></tr>
2917 <td>enable additional output</td></tr>
2916 <tr><td></td>
2918 <tr><td></td>
2917 <td>--color TYPE</td>
2919 <td>--color TYPE</td>
2918 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2920 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2919 <tr><td></td>
2921 <tr><td></td>
2920 <td>--config CONFIG [+]</td>
2922 <td>--config CONFIG [+]</td>
2921 <td>set/override config option (use 'section.name=value')</td></tr>
2923 <td>set/override config option (use 'section.name=value')</td></tr>
2922 <tr><td></td>
2924 <tr><td></td>
2923 <td>--debug</td>
2925 <td>--debug</td>
2924 <td>enable debugging output</td></tr>
2926 <td>enable debugging output</td></tr>
2925 <tr><td></td>
2927 <tr><td></td>
2926 <td>--debugger</td>
2928 <td>--debugger</td>
2927 <td>start debugger</td></tr>
2929 <td>start debugger</td></tr>
2928 <tr><td></td>
2930 <tr><td></td>
2929 <td>--encoding ENCODE</td>
2931 <td>--encoding ENCODE</td>
2930 <td>set the charset encoding (default: ascii)</td></tr>
2932 <td>set the charset encoding (default: ascii)</td></tr>
2931 <tr><td></td>
2933 <tr><td></td>
2932 <td>--encodingmode MODE</td>
2934 <td>--encodingmode MODE</td>
2933 <td>set the charset encoding mode (default: strict)</td></tr>
2935 <td>set the charset encoding mode (default: strict)</td></tr>
2934 <tr><td></td>
2936 <tr><td></td>
2935 <td>--traceback</td>
2937 <td>--traceback</td>
2936 <td>always print a traceback on exception</td></tr>
2938 <td>always print a traceback on exception</td></tr>
2937 <tr><td></td>
2939 <tr><td></td>
2938 <td>--time</td>
2940 <td>--time</td>
2939 <td>time how long the command takes</td></tr>
2941 <td>time how long the command takes</td></tr>
2940 <tr><td></td>
2942 <tr><td></td>
2941 <td>--profile</td>
2943 <td>--profile</td>
2942 <td>print command execution profile</td></tr>
2944 <td>print command execution profile</td></tr>
2943 <tr><td></td>
2945 <tr><td></td>
2944 <td>--version</td>
2946 <td>--version</td>
2945 <td>output version information and exit</td></tr>
2947 <td>output version information and exit</td></tr>
2946 <tr><td>-h</td>
2948 <tr><td>-h</td>
2947 <td>--help</td>
2949 <td>--help</td>
2948 <td>display help and exit</td></tr>
2950 <td>display help and exit</td></tr>
2949 <tr><td></td>
2951 <tr><td></td>
2950 <td>--hidden</td>
2952 <td>--hidden</td>
2951 <td>consider hidden changesets</td></tr>
2953 <td>consider hidden changesets</td></tr>
2952 <tr><td></td>
2954 <tr><td></td>
2953 <td>--pager TYPE</td>
2955 <td>--pager TYPE</td>
2954 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2956 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2955 </table>
2957 </table>
2956
2958
2957 </div>
2959 </div>
2958 </div>
2960 </div>
2959 </div>
2961 </div>
2960
2962
2961
2963
2962
2964
2963 </body>
2965 </body>
2964 </html>
2966 </html>
2965
2967
2966
2968
2967 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2969 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2968 200 Script output follows
2970 200 Script output follows
2969
2971
2970 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2972 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2971 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2973 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2972 <head>
2974 <head>
2973 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2975 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2974 <meta name="robots" content="index, nofollow" />
2976 <meta name="robots" content="index, nofollow" />
2975 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2977 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2976 <script type="text/javascript" src="/static/mercurial.js"></script>
2978 <script type="text/javascript" src="/static/mercurial.js"></script>
2977
2979
2978 <title>Help: remove</title>
2980 <title>Help: remove</title>
2979 </head>
2981 </head>
2980 <body>
2982 <body>
2981
2983
2982 <div class="container">
2984 <div class="container">
2983 <div class="menu">
2985 <div class="menu">
2984 <div class="logo">
2986 <div class="logo">
2985 <a href="https://mercurial-scm.org/">
2987 <a href="https://mercurial-scm.org/">
2986 <img src="/static/hglogo.png" alt="mercurial" /></a>
2988 <img src="/static/hglogo.png" alt="mercurial" /></a>
2987 </div>
2989 </div>
2988 <ul>
2990 <ul>
2989 <li><a href="/shortlog">log</a></li>
2991 <li><a href="/shortlog">log</a></li>
2990 <li><a href="/graph">graph</a></li>
2992 <li><a href="/graph">graph</a></li>
2991 <li><a href="/tags">tags</a></li>
2993 <li><a href="/tags">tags</a></li>
2992 <li><a href="/bookmarks">bookmarks</a></li>
2994 <li><a href="/bookmarks">bookmarks</a></li>
2993 <li><a href="/branches">branches</a></li>
2995 <li><a href="/branches">branches</a></li>
2994 </ul>
2996 </ul>
2995 <ul>
2997 <ul>
2996 <li class="active"><a href="/help">help</a></li>
2998 <li class="active"><a href="/help">help</a></li>
2997 </ul>
2999 </ul>
2998 </div>
3000 </div>
2999
3001
3000 <div class="main">
3002 <div class="main">
3001 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3003 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3002 <h3>Help: remove</h3>
3004 <h3>Help: remove</h3>
3003
3005
3004 <form class="search" action="/log">
3006 <form class="search" action="/log">
3005
3007
3006 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3008 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3007 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3009 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3008 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3010 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3009 </form>
3011 </form>
3010 <div id="doc">
3012 <div id="doc">
3011 <p>
3013 <p>
3012 hg remove [OPTION]... FILE...
3014 hg remove [OPTION]... FILE...
3013 </p>
3015 </p>
3014 <p>
3016 <p>
3015 aliases: rm
3017 aliases: rm
3016 </p>
3018 </p>
3017 <p>
3019 <p>
3018 remove the specified files on the next commit
3020 remove the specified files on the next commit
3019 </p>
3021 </p>
3020 <p>
3022 <p>
3021 Schedule the indicated files for removal from the current branch.
3023 Schedule the indicated files for removal from the current branch.
3022 </p>
3024 </p>
3023 <p>
3025 <p>
3024 This command schedules the files to be removed at the next commit.
3026 This command schedules the files to be removed at the next commit.
3025 To undo a remove before that, see 'hg revert'. To undo added
3027 To undo a remove before that, see 'hg revert'. To undo added
3026 files, see 'hg forget'.
3028 files, see 'hg forget'.
3027 </p>
3029 </p>
3028 <p>
3030 <p>
3029 -A/--after can be used to remove only files that have already
3031 -A/--after can be used to remove only files that have already
3030 been deleted, -f/--force can be used to force deletion, and -Af
3032 been deleted, -f/--force can be used to force deletion, and -Af
3031 can be used to remove files from the next revision without
3033 can be used to remove files from the next revision without
3032 deleting them from the working directory.
3034 deleting them from the working directory.
3033 </p>
3035 </p>
3034 <p>
3036 <p>
3035 The following table details the behavior of remove for different
3037 The following table details the behavior of remove for different
3036 file states (columns) and option combinations (rows). The file
3038 file states (columns) and option combinations (rows). The file
3037 states are Added [A], Clean [C], Modified [M] and Missing [!]
3039 states are Added [A], Clean [C], Modified [M] and Missing [!]
3038 (as reported by 'hg status'). The actions are Warn, Remove
3040 (as reported by 'hg status'). The actions are Warn, Remove
3039 (from branch) and Delete (from disk):
3041 (from branch) and Delete (from disk):
3040 </p>
3042 </p>
3041 <table>
3043 <table>
3042 <tr><td>opt/state</td>
3044 <tr><td>opt/state</td>
3043 <td>A</td>
3045 <td>A</td>
3044 <td>C</td>
3046 <td>C</td>
3045 <td>M</td>
3047 <td>M</td>
3046 <td>!</td></tr>
3048 <td>!</td></tr>
3047 <tr><td>none</td>
3049 <tr><td>none</td>
3048 <td>W</td>
3050 <td>W</td>
3049 <td>RD</td>
3051 <td>RD</td>
3050 <td>W</td>
3052 <td>W</td>
3051 <td>R</td></tr>
3053 <td>R</td></tr>
3052 <tr><td>-f</td>
3054 <tr><td>-f</td>
3053 <td>R</td>
3055 <td>R</td>
3054 <td>RD</td>
3056 <td>RD</td>
3055 <td>RD</td>
3057 <td>RD</td>
3056 <td>R</td></tr>
3058 <td>R</td></tr>
3057 <tr><td>-A</td>
3059 <tr><td>-A</td>
3058 <td>W</td>
3060 <td>W</td>
3059 <td>W</td>
3061 <td>W</td>
3060 <td>W</td>
3062 <td>W</td>
3061 <td>R</td></tr>
3063 <td>R</td></tr>
3062 <tr><td>-Af</td>
3064 <tr><td>-Af</td>
3063 <td>R</td>
3065 <td>R</td>
3064 <td>R</td>
3066 <td>R</td>
3065 <td>R</td>
3067 <td>R</td>
3066 <td>R</td></tr>
3068 <td>R</td></tr>
3067 </table>
3069 </table>
3068 <p>
3070 <p>
3069 <b>Note:</b>
3071 <b>Note:</b>
3070 </p>
3072 </p>
3071 <p>
3073 <p>
3072 'hg remove' never deletes files in Added [A] state from the
3074 'hg remove' never deletes files in Added [A] state from the
3073 working directory, not even if &quot;--force&quot; is specified.
3075 working directory, not even if &quot;--force&quot; is specified.
3074 </p>
3076 </p>
3075 <p>
3077 <p>
3076 Returns 0 on success, 1 if any warnings encountered.
3078 Returns 0 on success, 1 if any warnings encountered.
3077 </p>
3079 </p>
3078 <p>
3080 <p>
3079 options ([+] can be repeated):
3081 options ([+] can be repeated):
3080 </p>
3082 </p>
3081 <table>
3083 <table>
3082 <tr><td>-A</td>
3084 <tr><td>-A</td>
3083 <td>--after</td>
3085 <td>--after</td>
3084 <td>record delete for missing files</td></tr>
3086 <td>record delete for missing files</td></tr>
3085 <tr><td>-f</td>
3087 <tr><td>-f</td>
3086 <td>--force</td>
3088 <td>--force</td>
3087 <td>forget added files, delete modified files</td></tr>
3089 <td>forget added files, delete modified files</td></tr>
3088 <tr><td>-S</td>
3090 <tr><td>-S</td>
3089 <td>--subrepos</td>
3091 <td>--subrepos</td>
3090 <td>recurse into subrepositories</td></tr>
3092 <td>recurse into subrepositories</td></tr>
3091 <tr><td>-I</td>
3093 <tr><td>-I</td>
3092 <td>--include PATTERN [+]</td>
3094 <td>--include PATTERN [+]</td>
3093 <td>include names matching the given patterns</td></tr>
3095 <td>include names matching the given patterns</td></tr>
3094 <tr><td>-X</td>
3096 <tr><td>-X</td>
3095 <td>--exclude PATTERN [+]</td>
3097 <td>--exclude PATTERN [+]</td>
3096 <td>exclude names matching the given patterns</td></tr>
3098 <td>exclude names matching the given patterns</td></tr>
3097 <tr><td>-n</td>
3099 <tr><td>-n</td>
3098 <td>--dry-run</td>
3100 <td>--dry-run</td>
3099 <td>do not perform actions, just print output</td></tr>
3101 <td>do not perform actions, just print output</td></tr>
3100 </table>
3102 </table>
3101 <p>
3103 <p>
3102 global options ([+] can be repeated):
3104 global options ([+] can be repeated):
3103 </p>
3105 </p>
3104 <table>
3106 <table>
3105 <tr><td>-R</td>
3107 <tr><td>-R</td>
3106 <td>--repository REPO</td>
3108 <td>--repository REPO</td>
3107 <td>repository root directory or name of overlay bundle file</td></tr>
3109 <td>repository root directory or name of overlay bundle file</td></tr>
3108 <tr><td></td>
3110 <tr><td></td>
3109 <td>--cwd DIR</td>
3111 <td>--cwd DIR</td>
3110 <td>change working directory</td></tr>
3112 <td>change working directory</td></tr>
3111 <tr><td>-y</td>
3113 <tr><td>-y</td>
3112 <td>--noninteractive</td>
3114 <td>--noninteractive</td>
3113 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3115 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3114 <tr><td>-q</td>
3116 <tr><td>-q</td>
3115 <td>--quiet</td>
3117 <td>--quiet</td>
3116 <td>suppress output</td></tr>
3118 <td>suppress output</td></tr>
3117 <tr><td>-v</td>
3119 <tr><td>-v</td>
3118 <td>--verbose</td>
3120 <td>--verbose</td>
3119 <td>enable additional output</td></tr>
3121 <td>enable additional output</td></tr>
3120 <tr><td></td>
3122 <tr><td></td>
3121 <td>--color TYPE</td>
3123 <td>--color TYPE</td>
3122 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3124 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3123 <tr><td></td>
3125 <tr><td></td>
3124 <td>--config CONFIG [+]</td>
3126 <td>--config CONFIG [+]</td>
3125 <td>set/override config option (use 'section.name=value')</td></tr>
3127 <td>set/override config option (use 'section.name=value')</td></tr>
3126 <tr><td></td>
3128 <tr><td></td>
3127 <td>--debug</td>
3129 <td>--debug</td>
3128 <td>enable debugging output</td></tr>
3130 <td>enable debugging output</td></tr>
3129 <tr><td></td>
3131 <tr><td></td>
3130 <td>--debugger</td>
3132 <td>--debugger</td>
3131 <td>start debugger</td></tr>
3133 <td>start debugger</td></tr>
3132 <tr><td></td>
3134 <tr><td></td>
3133 <td>--encoding ENCODE</td>
3135 <td>--encoding ENCODE</td>
3134 <td>set the charset encoding (default: ascii)</td></tr>
3136 <td>set the charset encoding (default: ascii)</td></tr>
3135 <tr><td></td>
3137 <tr><td></td>
3136 <td>--encodingmode MODE</td>
3138 <td>--encodingmode MODE</td>
3137 <td>set the charset encoding mode (default: strict)</td></tr>
3139 <td>set the charset encoding mode (default: strict)</td></tr>
3138 <tr><td></td>
3140 <tr><td></td>
3139 <td>--traceback</td>
3141 <td>--traceback</td>
3140 <td>always print a traceback on exception</td></tr>
3142 <td>always print a traceback on exception</td></tr>
3141 <tr><td></td>
3143 <tr><td></td>
3142 <td>--time</td>
3144 <td>--time</td>
3143 <td>time how long the command takes</td></tr>
3145 <td>time how long the command takes</td></tr>
3144 <tr><td></td>
3146 <tr><td></td>
3145 <td>--profile</td>
3147 <td>--profile</td>
3146 <td>print command execution profile</td></tr>
3148 <td>print command execution profile</td></tr>
3147 <tr><td></td>
3149 <tr><td></td>
3148 <td>--version</td>
3150 <td>--version</td>
3149 <td>output version information and exit</td></tr>
3151 <td>output version information and exit</td></tr>
3150 <tr><td>-h</td>
3152 <tr><td>-h</td>
3151 <td>--help</td>
3153 <td>--help</td>
3152 <td>display help and exit</td></tr>
3154 <td>display help and exit</td></tr>
3153 <tr><td></td>
3155 <tr><td></td>
3154 <td>--hidden</td>
3156 <td>--hidden</td>
3155 <td>consider hidden changesets</td></tr>
3157 <td>consider hidden changesets</td></tr>
3156 <tr><td></td>
3158 <tr><td></td>
3157 <td>--pager TYPE</td>
3159 <td>--pager TYPE</td>
3158 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3160 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3159 </table>
3161 </table>
3160
3162
3161 </div>
3163 </div>
3162 </div>
3164 </div>
3163 </div>
3165 </div>
3164
3166
3165
3167
3166
3168
3167 </body>
3169 </body>
3168 </html>
3170 </html>
3169
3171
3170
3172
3171 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3173 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3172 200 Script output follows
3174 200 Script output follows
3173
3175
3174 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3176 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3175 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3177 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3176 <head>
3178 <head>
3177 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3179 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3178 <meta name="robots" content="index, nofollow" />
3180 <meta name="robots" content="index, nofollow" />
3179 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3181 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3180 <script type="text/javascript" src="/static/mercurial.js"></script>
3182 <script type="text/javascript" src="/static/mercurial.js"></script>
3181
3183
3182 <title>Help: dates</title>
3184 <title>Help: dates</title>
3183 </head>
3185 </head>
3184 <body>
3186 <body>
3185
3187
3186 <div class="container">
3188 <div class="container">
3187 <div class="menu">
3189 <div class="menu">
3188 <div class="logo">
3190 <div class="logo">
3189 <a href="https://mercurial-scm.org/">
3191 <a href="https://mercurial-scm.org/">
3190 <img src="/static/hglogo.png" alt="mercurial" /></a>
3192 <img src="/static/hglogo.png" alt="mercurial" /></a>
3191 </div>
3193 </div>
3192 <ul>
3194 <ul>
3193 <li><a href="/shortlog">log</a></li>
3195 <li><a href="/shortlog">log</a></li>
3194 <li><a href="/graph">graph</a></li>
3196 <li><a href="/graph">graph</a></li>
3195 <li><a href="/tags">tags</a></li>
3197 <li><a href="/tags">tags</a></li>
3196 <li><a href="/bookmarks">bookmarks</a></li>
3198 <li><a href="/bookmarks">bookmarks</a></li>
3197 <li><a href="/branches">branches</a></li>
3199 <li><a href="/branches">branches</a></li>
3198 </ul>
3200 </ul>
3199 <ul>
3201 <ul>
3200 <li class="active"><a href="/help">help</a></li>
3202 <li class="active"><a href="/help">help</a></li>
3201 </ul>
3203 </ul>
3202 </div>
3204 </div>
3203
3205
3204 <div class="main">
3206 <div class="main">
3205 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3207 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3206 <h3>Help: dates</h3>
3208 <h3>Help: dates</h3>
3207
3209
3208 <form class="search" action="/log">
3210 <form class="search" action="/log">
3209
3211
3210 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3212 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3211 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3213 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3212 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3214 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3213 </form>
3215 </form>
3214 <div id="doc">
3216 <div id="doc">
3215 <h1>Date Formats</h1>
3217 <h1>Date Formats</h1>
3216 <p>
3218 <p>
3217 Some commands allow the user to specify a date, e.g.:
3219 Some commands allow the user to specify a date, e.g.:
3218 </p>
3220 </p>
3219 <ul>
3221 <ul>
3220 <li> backout, commit, import, tag: Specify the commit date.
3222 <li> backout, commit, import, tag: Specify the commit date.
3221 <li> log, revert, update: Select revision(s) by date.
3223 <li> log, revert, update: Select revision(s) by date.
3222 </ul>
3224 </ul>
3223 <p>
3225 <p>
3224 Many date formats are valid. Here are some examples:
3226 Many date formats are valid. Here are some examples:
3225 </p>
3227 </p>
3226 <ul>
3228 <ul>
3227 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3229 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3228 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3230 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3229 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3231 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3230 <li> &quot;Dec 6&quot; (midnight)
3232 <li> &quot;Dec 6&quot; (midnight)
3231 <li> &quot;13:18&quot; (today assumed)
3233 <li> &quot;13:18&quot; (today assumed)
3232 <li> &quot;3:39&quot; (3:39AM assumed)
3234 <li> &quot;3:39&quot; (3:39AM assumed)
3233 <li> &quot;3:39pm&quot; (15:39)
3235 <li> &quot;3:39pm&quot; (15:39)
3234 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3236 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3235 <li> &quot;2006-12-6 13:18&quot;
3237 <li> &quot;2006-12-6 13:18&quot;
3236 <li> &quot;2006-12-6&quot;
3238 <li> &quot;2006-12-6&quot;
3237 <li> &quot;12-6&quot;
3239 <li> &quot;12-6&quot;
3238 <li> &quot;12/6&quot;
3240 <li> &quot;12/6&quot;
3239 <li> &quot;12/6/6&quot; (Dec 6 2006)
3241 <li> &quot;12/6/6&quot; (Dec 6 2006)
3240 <li> &quot;today&quot; (midnight)
3242 <li> &quot;today&quot; (midnight)
3241 <li> &quot;yesterday&quot; (midnight)
3243 <li> &quot;yesterday&quot; (midnight)
3242 <li> &quot;now&quot; - right now
3244 <li> &quot;now&quot; - right now
3243 </ul>
3245 </ul>
3244 <p>
3246 <p>
3245 Lastly, there is Mercurial's internal format:
3247 Lastly, there is Mercurial's internal format:
3246 </p>
3248 </p>
3247 <ul>
3249 <ul>
3248 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3250 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3249 </ul>
3251 </ul>
3250 <p>
3252 <p>
3251 This is the internal representation format for dates. The first number
3253 This is the internal representation format for dates. The first number
3252 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3254 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3253 second is the offset of the local timezone, in seconds west of UTC
3255 second is the offset of the local timezone, in seconds west of UTC
3254 (negative if the timezone is east of UTC).
3256 (negative if the timezone is east of UTC).
3255 </p>
3257 </p>
3256 <p>
3258 <p>
3257 The log command also accepts date ranges:
3259 The log command also accepts date ranges:
3258 </p>
3260 </p>
3259 <ul>
3261 <ul>
3260 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3262 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3261 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3263 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3262 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3264 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3263 <li> &quot;-DAYS&quot; - within a given number of days of today
3265 <li> &quot;-DAYS&quot; - within a given number of days of today
3264 </ul>
3266 </ul>
3265
3267
3266 </div>
3268 </div>
3267 </div>
3269 </div>
3268 </div>
3270 </div>
3269
3271
3270
3272
3271
3273
3272 </body>
3274 </body>
3273 </html>
3275 </html>
3274
3276
3275
3277
3276 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3278 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3277 200 Script output follows
3279 200 Script output follows
3278
3280
3279 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3281 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3280 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3282 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3281 <head>
3283 <head>
3282 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3284 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3283 <meta name="robots" content="index, nofollow" />
3285 <meta name="robots" content="index, nofollow" />
3284 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3286 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3285 <script type="text/javascript" src="/static/mercurial.js"></script>
3287 <script type="text/javascript" src="/static/mercurial.js"></script>
3286
3288
3287 <title>Help: pager</title>
3289 <title>Help: pager</title>
3288 </head>
3290 </head>
3289 <body>
3291 <body>
3290
3292
3291 <div class="container">
3293 <div class="container">
3292 <div class="menu">
3294 <div class="menu">
3293 <div class="logo">
3295 <div class="logo">
3294 <a href="https://mercurial-scm.org/">
3296 <a href="https://mercurial-scm.org/">
3295 <img src="/static/hglogo.png" alt="mercurial" /></a>
3297 <img src="/static/hglogo.png" alt="mercurial" /></a>
3296 </div>
3298 </div>
3297 <ul>
3299 <ul>
3298 <li><a href="/shortlog">log</a></li>
3300 <li><a href="/shortlog">log</a></li>
3299 <li><a href="/graph">graph</a></li>
3301 <li><a href="/graph">graph</a></li>
3300 <li><a href="/tags">tags</a></li>
3302 <li><a href="/tags">tags</a></li>
3301 <li><a href="/bookmarks">bookmarks</a></li>
3303 <li><a href="/bookmarks">bookmarks</a></li>
3302 <li><a href="/branches">branches</a></li>
3304 <li><a href="/branches">branches</a></li>
3303 </ul>
3305 </ul>
3304 <ul>
3306 <ul>
3305 <li class="active"><a href="/help">help</a></li>
3307 <li class="active"><a href="/help">help</a></li>
3306 </ul>
3308 </ul>
3307 </div>
3309 </div>
3308
3310
3309 <div class="main">
3311 <div class="main">
3310 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3312 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3311 <h3>Help: pager</h3>
3313 <h3>Help: pager</h3>
3312
3314
3313 <form class="search" action="/log">
3315 <form class="search" action="/log">
3314
3316
3315 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3317 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3316 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3318 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3317 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3319 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3318 </form>
3320 </form>
3319 <div id="doc">
3321 <div id="doc">
3320 <h1>Pager Support</h1>
3322 <h1>Pager Support</h1>
3321 <p>
3323 <p>
3322 Some Mercurial commands can produce a lot of output, and Mercurial will
3324 Some Mercurial commands can produce a lot of output, and Mercurial will
3323 attempt to use a pager to make those commands more pleasant.
3325 attempt to use a pager to make those commands more pleasant.
3324 </p>
3326 </p>
3325 <p>
3327 <p>
3326 To set the pager that should be used, set the application variable:
3328 To set the pager that should be used, set the application variable:
3327 </p>
3329 </p>
3328 <pre>
3330 <pre>
3329 [pager]
3331 [pager]
3330 pager = less -FRX
3332 pager = less -FRX
3331 </pre>
3333 </pre>
3332 <p>
3334 <p>
3333 If no pager is set in the user or repository configuration, Mercurial uses the
3335 If no pager is set in the user or repository configuration, Mercurial uses the
3334 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3336 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3335 or system configuration is used. If none of these are set, a default pager will
3337 or system configuration is used. If none of these are set, a default pager will
3336 be used, typically 'less' on Unix and 'more' on Windows.
3338 be used, typically 'less' on Unix and 'more' on Windows.
3337 </p>
3339 </p>
3338 <p>
3340 <p>
3339 You can disable the pager for certain commands by adding them to the
3341 You can disable the pager for certain commands by adding them to the
3340 pager.ignore list:
3342 pager.ignore list:
3341 </p>
3343 </p>
3342 <pre>
3344 <pre>
3343 [pager]
3345 [pager]
3344 ignore = version, help, update
3346 ignore = version, help, update
3345 </pre>
3347 </pre>
3346 <p>
3348 <p>
3347 To ignore global commands like 'hg version' or 'hg help', you have
3349 To ignore global commands like 'hg version' or 'hg help', you have
3348 to specify them in your user configuration file.
3350 to specify them in your user configuration file.
3349 </p>
3351 </p>
3350 <p>
3352 <p>
3351 To control whether the pager is used at all for an individual command,
3353 To control whether the pager is used at all for an individual command,
3352 you can use --pager=&lt;value&gt;:
3354 you can use --pager=&lt;value&gt;:
3353 </p>
3355 </p>
3354 <ul>
3356 <ul>
3355 <li> use as needed: 'auto'.
3357 <li> use as needed: 'auto'.
3356 <li> require the pager: 'yes' or 'on'.
3358 <li> require the pager: 'yes' or 'on'.
3357 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3359 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3358 </ul>
3360 </ul>
3359 <p>
3361 <p>
3360 To globally turn off all attempts to use a pager, set:
3362 To globally turn off all attempts to use a pager, set:
3361 </p>
3363 </p>
3362 <pre>
3364 <pre>
3363 [ui]
3365 [ui]
3364 paginate = never
3366 paginate = never
3365 </pre>
3367 </pre>
3366 <p>
3368 <p>
3367 which will prevent the pager from running.
3369 which will prevent the pager from running.
3368 </p>
3370 </p>
3369
3371
3370 </div>
3372 </div>
3371 </div>
3373 </div>
3372 </div>
3374 </div>
3373
3375
3374
3376
3375
3377
3376 </body>
3378 </body>
3377 </html>
3379 </html>
3378
3380
3379
3381
3380 Sub-topic indexes rendered properly
3382 Sub-topic indexes rendered properly
3381
3383
3382 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3384 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3383 200 Script output follows
3385 200 Script output follows
3384
3386
3385 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3387 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3386 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3388 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3387 <head>
3389 <head>
3388 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3390 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3389 <meta name="robots" content="index, nofollow" />
3391 <meta name="robots" content="index, nofollow" />
3390 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3392 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3391 <script type="text/javascript" src="/static/mercurial.js"></script>
3393 <script type="text/javascript" src="/static/mercurial.js"></script>
3392
3394
3393 <title>Help: internals</title>
3395 <title>Help: internals</title>
3394 </head>
3396 </head>
3395 <body>
3397 <body>
3396
3398
3397 <div class="container">
3399 <div class="container">
3398 <div class="menu">
3400 <div class="menu">
3399 <div class="logo">
3401 <div class="logo">
3400 <a href="https://mercurial-scm.org/">
3402 <a href="https://mercurial-scm.org/">
3401 <img src="/static/hglogo.png" alt="mercurial" /></a>
3403 <img src="/static/hglogo.png" alt="mercurial" /></a>
3402 </div>
3404 </div>
3403 <ul>
3405 <ul>
3404 <li><a href="/shortlog">log</a></li>
3406 <li><a href="/shortlog">log</a></li>
3405 <li><a href="/graph">graph</a></li>
3407 <li><a href="/graph">graph</a></li>
3406 <li><a href="/tags">tags</a></li>
3408 <li><a href="/tags">tags</a></li>
3407 <li><a href="/bookmarks">bookmarks</a></li>
3409 <li><a href="/bookmarks">bookmarks</a></li>
3408 <li><a href="/branches">branches</a></li>
3410 <li><a href="/branches">branches</a></li>
3409 </ul>
3411 </ul>
3410 <ul>
3412 <ul>
3411 <li><a href="/help">help</a></li>
3413 <li><a href="/help">help</a></li>
3412 </ul>
3414 </ul>
3413 </div>
3415 </div>
3414
3416
3415 <div class="main">
3417 <div class="main">
3416 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3418 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3417
3419
3418 <form class="search" action="/log">
3420 <form class="search" action="/log">
3419
3421
3420 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3422 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3421 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3423 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3422 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3424 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3423 </form>
3425 </form>
3424 <table class="bigtable">
3426 <table class="bigtable">
3425 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3427 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3426
3428
3427 <tr><td>
3429 <tr><td>
3428 <a href="/help/internals.bundle2">
3430 <a href="/help/internals.bundle2">
3429 bundle2
3431 bundle2
3430 </a>
3432 </a>
3431 </td><td>
3433 </td><td>
3432 Bundle2
3434 Bundle2
3433 </td></tr>
3435 </td></tr>
3434 <tr><td>
3436 <tr><td>
3435 <a href="/help/internals.bundles">
3437 <a href="/help/internals.bundles">
3436 bundles
3438 bundles
3437 </a>
3439 </a>
3438 </td><td>
3440 </td><td>
3439 Bundles
3441 Bundles
3440 </td></tr>
3442 </td></tr>
3441 <tr><td>
3443 <tr><td>
3442 <a href="/help/internals.cbor">
3444 <a href="/help/internals.cbor">
3443 cbor
3445 cbor
3444 </a>
3446 </a>
3445 </td><td>
3447 </td><td>
3446 CBOR
3448 CBOR
3447 </td></tr>
3449 </td></tr>
3448 <tr><td>
3450 <tr><td>
3449 <a href="/help/internals.censor">
3451 <a href="/help/internals.censor">
3450 censor
3452 censor
3451 </a>
3453 </a>
3452 </td><td>
3454 </td><td>
3453 Censor
3455 Censor
3454 </td></tr>
3456 </td></tr>
3455 <tr><td>
3457 <tr><td>
3456 <a href="/help/internals.changegroups">
3458 <a href="/help/internals.changegroups">
3457 changegroups
3459 changegroups
3458 </a>
3460 </a>
3459 </td><td>
3461 </td><td>
3460 Changegroups
3462 Changegroups
3461 </td></tr>
3463 </td></tr>
3462 <tr><td>
3464 <tr><td>
3463 <a href="/help/internals.config">
3465 <a href="/help/internals.config">
3464 config
3466 config
3465 </a>
3467 </a>
3466 </td><td>
3468 </td><td>
3467 Config Registrar
3469 Config Registrar
3468 </td></tr>
3470 </td></tr>
3469 <tr><td>
3471 <tr><td>
3470 <a href="/help/internals.extensions">
3472 <a href="/help/internals.extensions">
3471 extensions
3473 extensions
3472 </a>
3474 </a>
3473 </td><td>
3475 </td><td>
3474 Extension API
3476 Extension API
3475 </td></tr>
3477 </td></tr>
3476 <tr><td>
3478 <tr><td>
3477 <a href="/help/internals.mergestate">
3479 <a href="/help/internals.mergestate">
3478 mergestate
3480 mergestate
3479 </a>
3481 </a>
3480 </td><td>
3482 </td><td>
3481 Mergestate
3483 Mergestate
3482 </td></tr>
3484 </td></tr>
3483 <tr><td>
3485 <tr><td>
3484 <a href="/help/internals.requirements">
3486 <a href="/help/internals.requirements">
3485 requirements
3487 requirements
3486 </a>
3488 </a>
3487 </td><td>
3489 </td><td>
3488 Repository Requirements
3490 Repository Requirements
3489 </td></tr>
3491 </td></tr>
3490 <tr><td>
3492 <tr><td>
3491 <a href="/help/internals.revlogs">
3493 <a href="/help/internals.revlogs">
3492 revlogs
3494 revlogs
3493 </a>
3495 </a>
3494 </td><td>
3496 </td><td>
3495 Revision Logs
3497 Revision Logs
3496 </td></tr>
3498 </td></tr>
3497 <tr><td>
3499 <tr><td>
3498 <a href="/help/internals.wireprotocol">
3500 <a href="/help/internals.wireprotocol">
3499 wireprotocol
3501 wireprotocol
3500 </a>
3502 </a>
3501 </td><td>
3503 </td><td>
3502 Wire Protocol
3504 Wire Protocol
3503 </td></tr>
3505 </td></tr>
3504 <tr><td>
3506 <tr><td>
3505 <a href="/help/internals.wireprotocolrpc">
3507 <a href="/help/internals.wireprotocolrpc">
3506 wireprotocolrpc
3508 wireprotocolrpc
3507 </a>
3509 </a>
3508 </td><td>
3510 </td><td>
3509 Wire Protocol RPC
3511 Wire Protocol RPC
3510 </td></tr>
3512 </td></tr>
3511 <tr><td>
3513 <tr><td>
3512 <a href="/help/internals.wireprotocolv2">
3514 <a href="/help/internals.wireprotocolv2">
3513 wireprotocolv2
3515 wireprotocolv2
3514 </a>
3516 </a>
3515 </td><td>
3517 </td><td>
3516 Wire Protocol Version 2
3518 Wire Protocol Version 2
3517 </td></tr>
3519 </td></tr>
3518
3520
3519
3521
3520
3522
3521
3523
3522
3524
3523 </table>
3525 </table>
3524 </div>
3526 </div>
3525 </div>
3527 </div>
3526
3528
3527
3529
3528
3530
3529 </body>
3531 </body>
3530 </html>
3532 </html>
3531
3533
3532
3534
3533 Sub-topic topics rendered properly
3535 Sub-topic topics rendered properly
3534
3536
3535 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3537 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3536 200 Script output follows
3538 200 Script output follows
3537
3539
3538 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3540 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3539 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3541 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3540 <head>
3542 <head>
3541 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3543 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3542 <meta name="robots" content="index, nofollow" />
3544 <meta name="robots" content="index, nofollow" />
3543 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3545 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3544 <script type="text/javascript" src="/static/mercurial.js"></script>
3546 <script type="text/javascript" src="/static/mercurial.js"></script>
3545
3547
3546 <title>Help: internals.changegroups</title>
3548 <title>Help: internals.changegroups</title>
3547 </head>
3549 </head>
3548 <body>
3550 <body>
3549
3551
3550 <div class="container">
3552 <div class="container">
3551 <div class="menu">
3553 <div class="menu">
3552 <div class="logo">
3554 <div class="logo">
3553 <a href="https://mercurial-scm.org/">
3555 <a href="https://mercurial-scm.org/">
3554 <img src="/static/hglogo.png" alt="mercurial" /></a>
3556 <img src="/static/hglogo.png" alt="mercurial" /></a>
3555 </div>
3557 </div>
3556 <ul>
3558 <ul>
3557 <li><a href="/shortlog">log</a></li>
3559 <li><a href="/shortlog">log</a></li>
3558 <li><a href="/graph">graph</a></li>
3560 <li><a href="/graph">graph</a></li>
3559 <li><a href="/tags">tags</a></li>
3561 <li><a href="/tags">tags</a></li>
3560 <li><a href="/bookmarks">bookmarks</a></li>
3562 <li><a href="/bookmarks">bookmarks</a></li>
3561 <li><a href="/branches">branches</a></li>
3563 <li><a href="/branches">branches</a></li>
3562 </ul>
3564 </ul>
3563 <ul>
3565 <ul>
3564 <li class="active"><a href="/help">help</a></li>
3566 <li class="active"><a href="/help">help</a></li>
3565 </ul>
3567 </ul>
3566 </div>
3568 </div>
3567
3569
3568 <div class="main">
3570 <div class="main">
3569 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3571 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3570 <h3>Help: internals.changegroups</h3>
3572 <h3>Help: internals.changegroups</h3>
3571
3573
3572 <form class="search" action="/log">
3574 <form class="search" action="/log">
3573
3575
3574 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3576 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3575 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3577 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3576 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3578 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3577 </form>
3579 </form>
3578 <div id="doc">
3580 <div id="doc">
3579 <h1>Changegroups</h1>
3581 <h1>Changegroups</h1>
3580 <p>
3582 <p>
3581 Changegroups are representations of repository revlog data, specifically
3583 Changegroups are representations of repository revlog data, specifically
3582 the changelog data, root/flat manifest data, treemanifest data, and
3584 the changelog data, root/flat manifest data, treemanifest data, and
3583 filelogs.
3585 filelogs.
3584 </p>
3586 </p>
3585 <p>
3587 <p>
3586 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3588 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3587 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3589 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3588 only difference being an additional item in the *delta header*. Version
3590 only difference being an additional item in the *delta header*. Version
3589 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3591 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3590 exchanging treemanifests (enabled by setting an option on the
3592 exchanging treemanifests (enabled by setting an option on the
3591 &quot;changegroup&quot; part in the bundle2).
3593 &quot;changegroup&quot; part in the bundle2).
3592 </p>
3594 </p>
3593 <p>
3595 <p>
3594 Changegroups when not exchanging treemanifests consist of 3 logical
3596 Changegroups when not exchanging treemanifests consist of 3 logical
3595 segments:
3597 segments:
3596 </p>
3598 </p>
3597 <pre>
3599 <pre>
3598 +---------------------------------+
3600 +---------------------------------+
3599 | | | |
3601 | | | |
3600 | changeset | manifest | filelogs |
3602 | changeset | manifest | filelogs |
3601 | | | |
3603 | | | |
3602 | | | |
3604 | | | |
3603 +---------------------------------+
3605 +---------------------------------+
3604 </pre>
3606 </pre>
3605 <p>
3607 <p>
3606 When exchanging treemanifests, there are 4 logical segments:
3608 When exchanging treemanifests, there are 4 logical segments:
3607 </p>
3609 </p>
3608 <pre>
3610 <pre>
3609 +-------------------------------------------------+
3611 +-------------------------------------------------+
3610 | | | | |
3612 | | | | |
3611 | changeset | root | treemanifests | filelogs |
3613 | changeset | root | treemanifests | filelogs |
3612 | | manifest | | |
3614 | | manifest | | |
3613 | | | | |
3615 | | | | |
3614 +-------------------------------------------------+
3616 +-------------------------------------------------+
3615 </pre>
3617 </pre>
3616 <p>
3618 <p>
3617 The principle building block of each segment is a *chunk*. A *chunk*
3619 The principle building block of each segment is a *chunk*. A *chunk*
3618 is a framed piece of data:
3620 is a framed piece of data:
3619 </p>
3621 </p>
3620 <pre>
3622 <pre>
3621 +---------------------------------------+
3623 +---------------------------------------+
3622 | | |
3624 | | |
3623 | length | data |
3625 | length | data |
3624 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3626 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3625 | | |
3627 | | |
3626 +---------------------------------------+
3628 +---------------------------------------+
3627 </pre>
3629 </pre>
3628 <p>
3630 <p>
3629 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3631 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3630 integer indicating the length of the entire chunk (including the length field
3632 integer indicating the length of the entire chunk (including the length field
3631 itself).
3633 itself).
3632 </p>
3634 </p>
3633 <p>
3635 <p>
3634 There is a special case chunk that has a value of 0 for the length
3636 There is a special case chunk that has a value of 0 for the length
3635 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3637 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3636 </p>
3638 </p>
3637 <h2>Delta Groups</h2>
3639 <h2>Delta Groups</h2>
3638 <p>
3640 <p>
3639 A *delta group* expresses the content of a revlog as a series of deltas,
3641 A *delta group* expresses the content of a revlog as a series of deltas,
3640 or patches against previous revisions.
3642 or patches against previous revisions.
3641 </p>
3643 </p>
3642 <p>
3644 <p>
3643 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3645 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3644 to signal the end of the delta group:
3646 to signal the end of the delta group:
3645 </p>
3647 </p>
3646 <pre>
3648 <pre>
3647 +------------------------------------------------------------------------+
3649 +------------------------------------------------------------------------+
3648 | | | | | |
3650 | | | | | |
3649 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3651 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3650 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3652 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3651 | | | | | |
3653 | | | | | |
3652 +------------------------------------------------------------------------+
3654 +------------------------------------------------------------------------+
3653 </pre>
3655 </pre>
3654 <p>
3656 <p>
3655 Each *chunk*'s data consists of the following:
3657 Each *chunk*'s data consists of the following:
3656 </p>
3658 </p>
3657 <pre>
3659 <pre>
3658 +---------------------------------------+
3660 +---------------------------------------+
3659 | | |
3661 | | |
3660 | delta header | delta data |
3662 | delta header | delta data |
3661 | (various by version) | (various) |
3663 | (various by version) | (various) |
3662 | | |
3664 | | |
3663 +---------------------------------------+
3665 +---------------------------------------+
3664 </pre>
3666 </pre>
3665 <p>
3667 <p>
3666 The *delta data* is a series of *delta*s that describe a diff from an existing
3668 The *delta data* is a series of *delta*s that describe a diff from an existing
3667 entry (either that the recipient already has, or previously specified in the
3669 entry (either that the recipient already has, or previously specified in the
3668 bundle/changegroup).
3670 bundle/changegroup).
3669 </p>
3671 </p>
3670 <p>
3672 <p>
3671 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3673 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3672 &quot;3&quot; of the changegroup format.
3674 &quot;3&quot; of the changegroup format.
3673 </p>
3675 </p>
3674 <p>
3676 <p>
3675 Version 1 (headerlen=80):
3677 Version 1 (headerlen=80):
3676 </p>
3678 </p>
3677 <pre>
3679 <pre>
3678 +------------------------------------------------------+
3680 +------------------------------------------------------+
3679 | | | | |
3681 | | | | |
3680 | node | p1 node | p2 node | link node |
3682 | node | p1 node | p2 node | link node |
3681 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3683 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3682 | | | | |
3684 | | | | |
3683 +------------------------------------------------------+
3685 +------------------------------------------------------+
3684 </pre>
3686 </pre>
3685 <p>
3687 <p>
3686 Version 2 (headerlen=100):
3688 Version 2 (headerlen=100):
3687 </p>
3689 </p>
3688 <pre>
3690 <pre>
3689 +------------------------------------------------------------------+
3691 +------------------------------------------------------------------+
3690 | | | | | |
3692 | | | | | |
3691 | node | p1 node | p2 node | base node | link node |
3693 | node | p1 node | p2 node | base node | link node |
3692 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3694 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3693 | | | | | |
3695 | | | | | |
3694 +------------------------------------------------------------------+
3696 +------------------------------------------------------------------+
3695 </pre>
3697 </pre>
3696 <p>
3698 <p>
3697 Version 3 (headerlen=102):
3699 Version 3 (headerlen=102):
3698 </p>
3700 </p>
3699 <pre>
3701 <pre>
3700 +------------------------------------------------------------------------------+
3702 +------------------------------------------------------------------------------+
3701 | | | | | | |
3703 | | | | | | |
3702 | node | p1 node | p2 node | base node | link node | flags |
3704 | node | p1 node | p2 node | base node | link node | flags |
3703 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3705 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3704 | | | | | | |
3706 | | | | | | |
3705 +------------------------------------------------------------------------------+
3707 +------------------------------------------------------------------------------+
3706 </pre>
3708 </pre>
3707 <p>
3709 <p>
3708 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3710 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3709 series of *delta*s, densely packed (no separators). These deltas describe a diff
3711 series of *delta*s, densely packed (no separators). These deltas describe a diff
3710 from an existing entry (either that the recipient already has, or previously
3712 from an existing entry (either that the recipient already has, or previously
3711 specified in the bundle/changegroup). The format is described more fully in
3713 specified in the bundle/changegroup). The format is described more fully in
3712 &quot;hg help internals.bdiff&quot;, but briefly:
3714 &quot;hg help internals.bdiff&quot;, but briefly:
3713 </p>
3715 </p>
3714 <pre>
3716 <pre>
3715 +---------------------------------------------------------------+
3717 +---------------------------------------------------------------+
3716 | | | | |
3718 | | | | |
3717 | start offset | end offset | new length | content |
3719 | start offset | end offset | new length | content |
3718 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3720 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3719 | | | | |
3721 | | | | |
3720 +---------------------------------------------------------------+
3722 +---------------------------------------------------------------+
3721 </pre>
3723 </pre>
3722 <p>
3724 <p>
3723 Please note that the length field in the delta data does *not* include itself.
3725 Please note that the length field in the delta data does *not* include itself.
3724 </p>
3726 </p>
3725 <p>
3727 <p>
3726 In version 1, the delta is always applied against the previous node from
3728 In version 1, the delta is always applied against the previous node from
3727 the changegroup or the first parent if this is the first entry in the
3729 the changegroup or the first parent if this is the first entry in the
3728 changegroup.
3730 changegroup.
3729 </p>
3731 </p>
3730 <p>
3732 <p>
3731 In version 2 and up, the delta base node is encoded in the entry in the
3733 In version 2 and up, the delta base node is encoded in the entry in the
3732 changegroup. This allows the delta to be expressed against any parent,
3734 changegroup. This allows the delta to be expressed against any parent,
3733 which can result in smaller deltas and more efficient encoding of data.
3735 which can result in smaller deltas and more efficient encoding of data.
3734 </p>
3736 </p>
3735 <p>
3737 <p>
3736 The *flags* field holds bitwise flags affecting the processing of revision
3738 The *flags* field holds bitwise flags affecting the processing of revision
3737 data. The following flags are defined:
3739 data. The following flags are defined:
3738 </p>
3740 </p>
3739 <dl>
3741 <dl>
3740 <dt>32768
3742 <dt>32768
3741 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3743 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3742 <dt>16384
3744 <dt>16384
3743 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3745 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3744 <dt>8192
3746 <dt>8192
3745 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3747 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3746 </dl>
3748 </dl>
3747 <p>
3749 <p>
3748 For historical reasons, the integer values are identical to revlog version 1
3750 For historical reasons, the integer values are identical to revlog version 1
3749 per-revision storage flags and correspond to bits being set in this 2-byte
3751 per-revision storage flags and correspond to bits being set in this 2-byte
3750 field. Bits were allocated starting from the most-significant bit, hence the
3752 field. Bits were allocated starting from the most-significant bit, hence the
3751 reverse ordering and allocation of these flags.
3753 reverse ordering and allocation of these flags.
3752 </p>
3754 </p>
3753 <h2>Changeset Segment</h2>
3755 <h2>Changeset Segment</h2>
3754 <p>
3756 <p>
3755 The *changeset segment* consists of a single *delta group* holding
3757 The *changeset segment* consists of a single *delta group* holding
3756 changelog data. The *empty chunk* at the end of the *delta group* denotes
3758 changelog data. The *empty chunk* at the end of the *delta group* denotes
3757 the boundary to the *manifest segment*.
3759 the boundary to the *manifest segment*.
3758 </p>
3760 </p>
3759 <h2>Manifest Segment</h2>
3761 <h2>Manifest Segment</h2>
3760 <p>
3762 <p>
3761 The *manifest segment* consists of a single *delta group* holding manifest
3763 The *manifest segment* consists of a single *delta group* holding manifest
3762 data. If treemanifests are in use, it contains only the manifest for the
3764 data. If treemanifests are in use, it contains only the manifest for the
3763 root directory of the repository. Otherwise, it contains the entire
3765 root directory of the repository. Otherwise, it contains the entire
3764 manifest data. The *empty chunk* at the end of the *delta group* denotes
3766 manifest data. The *empty chunk* at the end of the *delta group* denotes
3765 the boundary to the next segment (either the *treemanifests segment* or the
3767 the boundary to the next segment (either the *treemanifests segment* or the
3766 *filelogs segment*, depending on version and the request options).
3768 *filelogs segment*, depending on version and the request options).
3767 </p>
3769 </p>
3768 <h3>Treemanifests Segment</h3>
3770 <h3>Treemanifests Segment</h3>
3769 <p>
3771 <p>
3770 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3772 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3771 only if the 'treemanifest' param is part of the bundle2 changegroup part
3773 only if the 'treemanifest' param is part of the bundle2 changegroup part
3772 (it is not possible to use changegroup version 3 outside of bundle2).
3774 (it is not possible to use changegroup version 3 outside of bundle2).
3773 Aside from the filenames in the *treemanifests segment* containing a
3775 Aside from the filenames in the *treemanifests segment* containing a
3774 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3776 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3775 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3777 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3776 a sub-segment with filename size 0). This denotes the boundary to the
3778 a sub-segment with filename size 0). This denotes the boundary to the
3777 *filelogs segment*.
3779 *filelogs segment*.
3778 </p>
3780 </p>
3779 <h2>Filelogs Segment</h2>
3781 <h2>Filelogs Segment</h2>
3780 <p>
3782 <p>
3781 The *filelogs segment* consists of multiple sub-segments, each
3783 The *filelogs segment* consists of multiple sub-segments, each
3782 corresponding to an individual file whose data is being described:
3784 corresponding to an individual file whose data is being described:
3783 </p>
3785 </p>
3784 <pre>
3786 <pre>
3785 +--------------------------------------------------+
3787 +--------------------------------------------------+
3786 | | | | | |
3788 | | | | | |
3787 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3789 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3788 | | | | | (4 bytes) |
3790 | | | | | (4 bytes) |
3789 | | | | | |
3791 | | | | | |
3790 +--------------------------------------------------+
3792 +--------------------------------------------------+
3791 </pre>
3793 </pre>
3792 <p>
3794 <p>
3793 The final filelog sub-segment is followed by an *empty chunk* (logically,
3795 The final filelog sub-segment is followed by an *empty chunk* (logically,
3794 a sub-segment with filename size 0). This denotes the end of the segment
3796 a sub-segment with filename size 0). This denotes the end of the segment
3795 and of the overall changegroup.
3797 and of the overall changegroup.
3796 </p>
3798 </p>
3797 <p>
3799 <p>
3798 Each filelog sub-segment consists of the following:
3800 Each filelog sub-segment consists of the following:
3799 </p>
3801 </p>
3800 <pre>
3802 <pre>
3801 +------------------------------------------------------+
3803 +------------------------------------------------------+
3802 | | | |
3804 | | | |
3803 | filename length | filename | delta group |
3805 | filename length | filename | delta group |
3804 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3806 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3805 | | | |
3807 | | | |
3806 +------------------------------------------------------+
3808 +------------------------------------------------------+
3807 </pre>
3809 </pre>
3808 <p>
3810 <p>
3809 That is, a *chunk* consisting of the filename (not terminated or padded)
3811 That is, a *chunk* consisting of the filename (not terminated or padded)
3810 followed by N chunks constituting the *delta group* for this file. The
3812 followed by N chunks constituting the *delta group* for this file. The
3811 *empty chunk* at the end of each *delta group* denotes the boundary to the
3813 *empty chunk* at the end of each *delta group* denotes the boundary to the
3812 next filelog sub-segment.
3814 next filelog sub-segment.
3813 </p>
3815 </p>
3814
3816
3815 </div>
3817 </div>
3816 </div>
3818 </div>
3817 </div>
3819 </div>
3818
3820
3819
3821
3820
3822
3821 </body>
3823 </body>
3822 </html>
3824 </html>
3823
3825
3824
3826
3825 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3827 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3826 404 Not Found
3828 404 Not Found
3827
3829
3828 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3830 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3829 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3831 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3830 <head>
3832 <head>
3831 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3833 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3832 <meta name="robots" content="index, nofollow" />
3834 <meta name="robots" content="index, nofollow" />
3833 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3835 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3834 <script type="text/javascript" src="/static/mercurial.js"></script>
3836 <script type="text/javascript" src="/static/mercurial.js"></script>
3835
3837
3836 <title>test: error</title>
3838 <title>test: error</title>
3837 </head>
3839 </head>
3838 <body>
3840 <body>
3839
3841
3840 <div class="container">
3842 <div class="container">
3841 <div class="menu">
3843 <div class="menu">
3842 <div class="logo">
3844 <div class="logo">
3843 <a href="https://mercurial-scm.org/">
3845 <a href="https://mercurial-scm.org/">
3844 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3846 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3845 </div>
3847 </div>
3846 <ul>
3848 <ul>
3847 <li><a href="/shortlog">log</a></li>
3849 <li><a href="/shortlog">log</a></li>
3848 <li><a href="/graph">graph</a></li>
3850 <li><a href="/graph">graph</a></li>
3849 <li><a href="/tags">tags</a></li>
3851 <li><a href="/tags">tags</a></li>
3850 <li><a href="/bookmarks">bookmarks</a></li>
3852 <li><a href="/bookmarks">bookmarks</a></li>
3851 <li><a href="/branches">branches</a></li>
3853 <li><a href="/branches">branches</a></li>
3852 </ul>
3854 </ul>
3853 <ul>
3855 <ul>
3854 <li><a href="/help">help</a></li>
3856 <li><a href="/help">help</a></li>
3855 </ul>
3857 </ul>
3856 </div>
3858 </div>
3857
3859
3858 <div class="main">
3860 <div class="main">
3859
3861
3860 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3862 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3861 <h3>error</h3>
3863 <h3>error</h3>
3862
3864
3863
3865
3864 <form class="search" action="/log">
3866 <form class="search" action="/log">
3865
3867
3866 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3868 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3867 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3869 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3868 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3870 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3869 </form>
3871 </form>
3870
3872
3871 <div class="description">
3873 <div class="description">
3872 <p>
3874 <p>
3873 An error occurred while processing your request:
3875 An error occurred while processing your request:
3874 </p>
3876 </p>
3875 <p>
3877 <p>
3876 Not Found
3878 Not Found
3877 </p>
3879 </p>
3878 </div>
3880 </div>
3879 </div>
3881 </div>
3880 </div>
3882 </div>
3881
3883
3882
3884
3883
3885
3884 </body>
3886 </body>
3885 </html>
3887 </html>
3886
3888
3887 [1]
3889 [1]
3888
3890
3889 $ killdaemons.py
3891 $ killdaemons.py
3890
3892
3891 #endif
3893 #endif
@@ -1,83 +1,102 b''
1 ==========================================================
1 ==========================================================
2 Test file dedicated to checking side-data related behavior
2 Test file dedicated to checking side-data related behavior
3 ==========================================================
3 ==========================================================
4
4
5 Check data can be written/read from sidedata
5 Check data can be written/read from sidedata
6 ============================================
6 ============================================
7
7
8 $ cat << EOF >> $HGRCPATH
8 $ cat << EOF >> $HGRCPATH
9 > [extensions]
9 > [extensions]
10 > testsidedata=$TESTDIR/testlib/ext-sidedata.py
10 > testsidedata=$TESTDIR/testlib/ext-sidedata.py
11 > EOF
11 > EOF
12
12
13 $ hg init test-sidedata --config format.use-side-data=yes
13 $ hg init test-sidedata --config format.use-side-data=yes
14 $ cd test-sidedata
14 $ cd test-sidedata
15 $ echo aaa > a
15 $ echo aaa > a
16 $ hg add a
16 $ hg add a
17 $ hg commit -m a --traceback
17 $ hg commit -m a --traceback
18 $ echo aaa > b
18 $ echo aaa > b
19 $ hg add b
19 $ hg add b
20 $ hg commit -m b
20 $ hg commit -m b
21 $ echo xxx >> a
21 $ echo xxx >> a
22 $ hg commit -m aa
22 $ hg commit -m aa
23
23
24 $ hg debugsidedata -c 0
25 2 sidedata entries
26 entry-0001 size 4
27 entry-0002 size 32
28 $ hg debugsidedata -c 1 -v
29 2 sidedata entries
30 entry-0001 size 4
31 '\x00\x00\x006'
32 entry-0002 size 32
33 '\x98\t\xf9\xc4v\xf0\xc5P\x90\xf7wRf\xe8\xe27e\xfc\xc1\x93\xa4\x96\xd0\x1d\x97\xaaG\x1d\xd7t\xfa\xde'
34 $ hg debugsidedata -m 2
35 2 sidedata entries
36 entry-0001 size 4
37 entry-0002 size 32
38 $ hg debugsidedata a 1
39 2 sidedata entries
40 entry-0001 size 4
41 entry-0002 size 32
42
24 Check upgrade behavior
43 Check upgrade behavior
25 ======================
44 ======================
26
45
27 Right now, sidedata has not upgrade support
46 Right now, sidedata has not upgrade support
28
47
29 Check that we cannot upgrade to sidedata
48 Check that we cannot upgrade to sidedata
30 ----------------------------------------
49 ----------------------------------------
31
50
32 $ hg init up-no-side-data --config format.use-side-data=no
51 $ hg init up-no-side-data --config format.use-side-data=no
33 $ hg debugformat -v -R up-no-side-data
52 $ hg debugformat -v -R up-no-side-data
34 format-variant repo config default
53 format-variant repo config default
35 fncache: yes yes yes
54 fncache: yes yes yes
36 dotencode: yes yes yes
55 dotencode: yes yes yes
37 generaldelta: yes yes yes
56 generaldelta: yes yes yes
38 sparserevlog: yes yes yes
57 sparserevlog: yes yes yes
39 sidedata: no no no
58 sidedata: no no no
40 plain-cl-delta: yes yes yes
59 plain-cl-delta: yes yes yes
41 compression: zlib zlib zlib
60 compression: zlib zlib zlib
42 compression-level: default default default
61 compression-level: default default default
43 $ hg debugformat -v -R up-no-side-data --config format.use-side-data=yes
62 $ hg debugformat -v -R up-no-side-data --config format.use-side-data=yes
44 format-variant repo config default
63 format-variant repo config default
45 fncache: yes yes yes
64 fncache: yes yes yes
46 dotencode: yes yes yes
65 dotencode: yes yes yes
47 generaldelta: yes yes yes
66 generaldelta: yes yes yes
48 sparserevlog: yes yes yes
67 sparserevlog: yes yes yes
49 sidedata: no yes no
68 sidedata: no yes no
50 plain-cl-delta: yes yes yes
69 plain-cl-delta: yes yes yes
51 compression: zlib zlib zlib
70 compression: zlib zlib zlib
52 compression-level: default default default
71 compression-level: default default default
53 $ hg debugupgraderepo -R up-no-side-data --config format.use-side-data=yes
72 $ hg debugupgraderepo -R up-no-side-data --config format.use-side-data=yes
54 abort: cannot upgrade repository; do not support adding requirement: exp-sidedata-flag
73 abort: cannot upgrade repository; do not support adding requirement: exp-sidedata-flag
55 [255]
74 [255]
56
75
57 Check that we cannot upgrade to sidedata
76 Check that we cannot upgrade to sidedata
58 ----------------------------------------
77 ----------------------------------------
59
78
60 $ hg init up-side-data --config format.use-side-data=yes
79 $ hg init up-side-data --config format.use-side-data=yes
61 $ hg debugformat -v -R up-side-data
80 $ hg debugformat -v -R up-side-data
62 format-variant repo config default
81 format-variant repo config default
63 fncache: yes yes yes
82 fncache: yes yes yes
64 dotencode: yes yes yes
83 dotencode: yes yes yes
65 generaldelta: yes yes yes
84 generaldelta: yes yes yes
66 sparserevlog: yes yes yes
85 sparserevlog: yes yes yes
67 sidedata: yes no no
86 sidedata: yes no no
68 plain-cl-delta: yes yes yes
87 plain-cl-delta: yes yes yes
69 compression: zlib zlib zlib
88 compression: zlib zlib zlib
70 compression-level: default default default
89 compression-level: default default default
71 $ hg debugformat -v -R up-side-data --config format.use-side-data=no
90 $ hg debugformat -v -R up-side-data --config format.use-side-data=no
72 format-variant repo config default
91 format-variant repo config default
73 fncache: yes yes yes
92 fncache: yes yes yes
74 dotencode: yes yes yes
93 dotencode: yes yes yes
75 generaldelta: yes yes yes
94 generaldelta: yes yes yes
76 sparserevlog: yes yes yes
95 sparserevlog: yes yes yes
77 sidedata: yes no no
96 sidedata: yes no no
78 plain-cl-delta: yes yes yes
97 plain-cl-delta: yes yes yes
79 compression: zlib zlib zlib
98 compression: zlib zlib zlib
80 compression-level: default default default
99 compression-level: default default default
81 $ hg debugupgraderepo -R up-side-data --config format.use-side-data=no
100 $ hg debugupgraderepo -R up-side-data --config format.use-side-data=no
82 abort: cannot upgrade repository; requirement would be removed: exp-sidedata-flag
101 abort: cannot upgrade repository; requirement would be removed: exp-sidedata-flag
83 [255]
102 [255]
General Comments 0
You need to be logged in to leave comments. Login now