Show More
@@ -1,3420 +1,3420 | |||||
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 | dateutil, |
|
85 | dateutil, | |
86 | procutil, |
|
86 | procutil, | |
87 | stringutil, |
|
87 | stringutil, | |
88 | ) |
|
88 | ) | |
89 |
|
89 | |||
90 | from .revlogutils import ( |
|
90 | from .revlogutils import ( | |
91 | deltas as deltautil |
|
91 | deltas as deltautil | |
92 | ) |
|
92 | ) | |
93 |
|
93 | |||
94 | release = lockmod.release |
|
94 | release = lockmod.release | |
95 |
|
95 | |||
96 | command = registrar.command() |
|
96 | command = registrar.command() | |
97 |
|
97 | |||
98 | @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
|
98 | @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) | |
99 | def debugancestor(ui, repo, *args): |
|
99 | def debugancestor(ui, repo, *args): | |
100 | """find the ancestor revision of two revisions in a given index""" |
|
100 | """find the ancestor revision of two revisions in a given index""" | |
101 | if len(args) == 3: |
|
101 | if len(args) == 3: | |
102 | index, rev1, rev2 = args |
|
102 | index, rev1, rev2 = args | |
103 | r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index) |
|
103 | r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index) | |
104 | lookup = r.lookup |
|
104 | lookup = r.lookup | |
105 | elif len(args) == 2: |
|
105 | elif len(args) == 2: | |
106 | if not repo: |
|
106 | if not repo: | |
107 | raise error.Abort(_('there is no Mercurial repository here ' |
|
107 | raise error.Abort(_('there is no Mercurial repository here ' | |
108 | '(.hg not found)')) |
|
108 | '(.hg not found)')) | |
109 | rev1, rev2 = args |
|
109 | rev1, rev2 = args | |
110 | r = repo.changelog |
|
110 | r = repo.changelog | |
111 | lookup = repo.lookup |
|
111 | lookup = repo.lookup | |
112 | else: |
|
112 | else: | |
113 | raise error.Abort(_('either two or three arguments required')) |
|
113 | raise error.Abort(_('either two or three arguments required')) | |
114 | a = r.ancestor(lookup(rev1), lookup(rev2)) |
|
114 | a = r.ancestor(lookup(rev1), lookup(rev2)) | |
115 | ui.write('%d:%s\n' % (r.rev(a), hex(a))) |
|
115 | ui.write('%d:%s\n' % (r.rev(a), hex(a))) | |
116 |
|
116 | |||
117 | @command('debugapplystreamclonebundle', [], 'FILE') |
|
117 | @command('debugapplystreamclonebundle', [], 'FILE') | |
118 | def debugapplystreamclonebundle(ui, repo, fname): |
|
118 | def debugapplystreamclonebundle(ui, repo, fname): | |
119 | """apply a stream clone bundle file""" |
|
119 | """apply a stream clone bundle file""" | |
120 | f = hg.openpath(ui, fname) |
|
120 | f = hg.openpath(ui, fname) | |
121 | gen = exchange.readbundle(ui, f, fname) |
|
121 | gen = exchange.readbundle(ui, f, fname) | |
122 | gen.apply(repo) |
|
122 | gen.apply(repo) | |
123 |
|
123 | |||
124 | @command('debugbuilddag', |
|
124 | @command('debugbuilddag', | |
125 | [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
|
125 | [('m', 'mergeable-file', None, _('add single file mergeable changes')), | |
126 | ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
|
126 | ('o', 'overwritten-file', None, _('add single file all revs overwrite')), | |
127 | ('n', 'new-file', None, _('add new file at each rev'))], |
|
127 | ('n', 'new-file', None, _('add new file at each rev'))], | |
128 | _('[OPTION]... [TEXT]')) |
|
128 | _('[OPTION]... [TEXT]')) | |
129 | def debugbuilddag(ui, repo, text=None, |
|
129 | def debugbuilddag(ui, repo, text=None, | |
130 | mergeable_file=False, |
|
130 | mergeable_file=False, | |
131 | overwritten_file=False, |
|
131 | overwritten_file=False, | |
132 | new_file=False): |
|
132 | new_file=False): | |
133 | """builds a repo with a given DAG from scratch in the current empty repo |
|
133 | """builds a repo with a given DAG from scratch in the current empty repo | |
134 |
|
134 | |||
135 | The description of the DAG is read from stdin if not given on the |
|
135 | The description of the DAG is read from stdin if not given on the | |
136 | command line. |
|
136 | command line. | |
137 |
|
137 | |||
138 | Elements: |
|
138 | Elements: | |
139 |
|
139 | |||
140 | - "+n" is a linear run of n nodes based on the current default parent |
|
140 | - "+n" is a linear run of n nodes based on the current default parent | |
141 | - "." is a single node based on the current default parent |
|
141 | - "." is a single node based on the current default parent | |
142 | - "$" resets the default parent to null (implied at the start); |
|
142 | - "$" resets the default parent to null (implied at the start); | |
143 | otherwise the default parent is always the last node created |
|
143 | otherwise the default parent is always the last node created | |
144 | - "<p" sets the default parent to the backref p |
|
144 | - "<p" sets the default parent to the backref p | |
145 | - "*p" is a fork at parent p, which is a backref |
|
145 | - "*p" is a fork at parent p, which is a backref | |
146 | - "*p1/p2" is a merge of parents p1 and p2, which are backrefs |
|
146 | - "*p1/p2" is a merge of parents p1 and p2, which are backrefs | |
147 | - "/p2" is a merge of the preceding node and p2 |
|
147 | - "/p2" is a merge of the preceding node and p2 | |
148 | - ":tag" defines a local tag for the preceding node |
|
148 | - ":tag" defines a local tag for the preceding node | |
149 | - "@branch" sets the named branch for subsequent nodes |
|
149 | - "@branch" sets the named branch for subsequent nodes | |
150 | - "#...\\n" is a comment up to the end of the line |
|
150 | - "#...\\n" is a comment up to the end of the line | |
151 |
|
151 | |||
152 | Whitespace between the above elements is ignored. |
|
152 | Whitespace between the above elements is ignored. | |
153 |
|
153 | |||
154 | A backref is either |
|
154 | A backref is either | |
155 |
|
155 | |||
156 | - a number n, which references the node curr-n, where curr is the current |
|
156 | - a number n, which references the node curr-n, where curr is the current | |
157 | node, or |
|
157 | node, or | |
158 | - the name of a local tag you placed earlier using ":tag", or |
|
158 | - the name of a local tag you placed earlier using ":tag", or | |
159 | - empty to denote the default parent. |
|
159 | - empty to denote the default parent. | |
160 |
|
160 | |||
161 | All string valued-elements are either strictly alphanumeric, or must |
|
161 | All string valued-elements are either strictly alphanumeric, or must | |
162 | be enclosed in double quotes ("..."), with "\\" as escape character. |
|
162 | be enclosed in double quotes ("..."), with "\\" as escape character. | |
163 | """ |
|
163 | """ | |
164 |
|
164 | |||
165 | if text is None: |
|
165 | if text is None: | |
166 | ui.status(_("reading DAG from stdin\n")) |
|
166 | ui.status(_("reading DAG from stdin\n")) | |
167 | text = ui.fin.read() |
|
167 | text = ui.fin.read() | |
168 |
|
168 | |||
169 | cl = repo.changelog |
|
169 | cl = repo.changelog | |
170 | if len(cl) > 0: |
|
170 | if len(cl) > 0: | |
171 | raise error.Abort(_('repository is not empty')) |
|
171 | raise error.Abort(_('repository is not empty')) | |
172 |
|
172 | |||
173 | # determine number of revs in DAG |
|
173 | # determine number of revs in DAG | |
174 | total = 0 |
|
174 | total = 0 | |
175 | for type, data in dagparser.parsedag(text): |
|
175 | for type, data in dagparser.parsedag(text): | |
176 | if type == 'n': |
|
176 | if type == 'n': | |
177 | total += 1 |
|
177 | total += 1 | |
178 |
|
178 | |||
179 | if mergeable_file: |
|
179 | if mergeable_file: | |
180 | linesperrev = 2 |
|
180 | linesperrev = 2 | |
181 | # make a file with k lines per rev |
|
181 | # make a file with k lines per rev | |
182 | initialmergedlines = ['%d' % i |
|
182 | initialmergedlines = ['%d' % i | |
183 | for i in pycompat.xrange(0, total * linesperrev)] |
|
183 | for i in pycompat.xrange(0, total * linesperrev)] | |
184 | initialmergedlines.append("") |
|
184 | initialmergedlines.append("") | |
185 |
|
185 | |||
186 | tags = [] |
|
186 | tags = [] | |
187 | progress = ui.makeprogress(_('building'), unit=_('revisions'), |
|
187 | progress = ui.makeprogress(_('building'), unit=_('revisions'), | |
188 | total=total) |
|
188 | total=total) | |
189 | with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"): |
|
189 | with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"): | |
190 | at = -1 |
|
190 | at = -1 | |
191 | atbranch = 'default' |
|
191 | atbranch = 'default' | |
192 | nodeids = [] |
|
192 | nodeids = [] | |
193 | id = 0 |
|
193 | id = 0 | |
194 | progress.update(id) |
|
194 | progress.update(id) | |
195 | for type, data in dagparser.parsedag(text): |
|
195 | for type, data in dagparser.parsedag(text): | |
196 | if type == 'n': |
|
196 | if type == 'n': | |
197 | ui.note(('node %s\n' % pycompat.bytestr(data))) |
|
197 | ui.note(('node %s\n' % pycompat.bytestr(data))) | |
198 | id, ps = data |
|
198 | id, ps = data | |
199 |
|
199 | |||
200 | files = [] |
|
200 | files = [] | |
201 | filecontent = {} |
|
201 | filecontent = {} | |
202 |
|
202 | |||
203 | p2 = None |
|
203 | p2 = None | |
204 | if mergeable_file: |
|
204 | if mergeable_file: | |
205 | fn = "mf" |
|
205 | fn = "mf" | |
206 | p1 = repo[ps[0]] |
|
206 | p1 = repo[ps[0]] | |
207 | if len(ps) > 1: |
|
207 | if len(ps) > 1: | |
208 | p2 = repo[ps[1]] |
|
208 | p2 = repo[ps[1]] | |
209 | pa = p1.ancestor(p2) |
|
209 | pa = p1.ancestor(p2) | |
210 | base, local, other = [x[fn].data() for x in (pa, p1, |
|
210 | base, local, other = [x[fn].data() for x in (pa, p1, | |
211 | p2)] |
|
211 | p2)] | |
212 | m3 = simplemerge.Merge3Text(base, local, other) |
|
212 | m3 = simplemerge.Merge3Text(base, local, other) | |
213 | ml = [l.strip() for l in m3.merge_lines()] |
|
213 | ml = [l.strip() for l in m3.merge_lines()] | |
214 | ml.append("") |
|
214 | ml.append("") | |
215 | elif at > 0: |
|
215 | elif at > 0: | |
216 | ml = p1[fn].data().split("\n") |
|
216 | ml = p1[fn].data().split("\n") | |
217 | else: |
|
217 | else: | |
218 | ml = initialmergedlines |
|
218 | ml = initialmergedlines | |
219 | ml[id * linesperrev] += " r%i" % id |
|
219 | ml[id * linesperrev] += " r%i" % id | |
220 | mergedtext = "\n".join(ml) |
|
220 | mergedtext = "\n".join(ml) | |
221 | files.append(fn) |
|
221 | files.append(fn) | |
222 | filecontent[fn] = mergedtext |
|
222 | filecontent[fn] = mergedtext | |
223 |
|
223 | |||
224 | if overwritten_file: |
|
224 | if overwritten_file: | |
225 | fn = "of" |
|
225 | fn = "of" | |
226 | files.append(fn) |
|
226 | files.append(fn) | |
227 | filecontent[fn] = "r%i\n" % id |
|
227 | filecontent[fn] = "r%i\n" % id | |
228 |
|
228 | |||
229 | if new_file: |
|
229 | if new_file: | |
230 | fn = "nf%i" % id |
|
230 | fn = "nf%i" % id | |
231 | files.append(fn) |
|
231 | files.append(fn) | |
232 | filecontent[fn] = "r%i\n" % id |
|
232 | filecontent[fn] = "r%i\n" % id | |
233 | if len(ps) > 1: |
|
233 | if len(ps) > 1: | |
234 | if not p2: |
|
234 | if not p2: | |
235 | p2 = repo[ps[1]] |
|
235 | p2 = repo[ps[1]] | |
236 | for fn in p2: |
|
236 | for fn in p2: | |
237 | if fn.startswith("nf"): |
|
237 | if fn.startswith("nf"): | |
238 | files.append(fn) |
|
238 | files.append(fn) | |
239 | filecontent[fn] = p2[fn].data() |
|
239 | filecontent[fn] = p2[fn].data() | |
240 |
|
240 | |||
241 | def fctxfn(repo, cx, path): |
|
241 | def fctxfn(repo, cx, path): | |
242 | if path in filecontent: |
|
242 | if path in filecontent: | |
243 | return context.memfilectx(repo, cx, path, |
|
243 | return context.memfilectx(repo, cx, path, | |
244 | filecontent[path]) |
|
244 | filecontent[path]) | |
245 | return None |
|
245 | return None | |
246 |
|
246 | |||
247 | if len(ps) == 0 or ps[0] < 0: |
|
247 | if len(ps) == 0 or ps[0] < 0: | |
248 | pars = [None, None] |
|
248 | pars = [None, None] | |
249 | elif len(ps) == 1: |
|
249 | elif len(ps) == 1: | |
250 | pars = [nodeids[ps[0]], None] |
|
250 | pars = [nodeids[ps[0]], None] | |
251 | else: |
|
251 | else: | |
252 | pars = [nodeids[p] for p in ps] |
|
252 | pars = [nodeids[p] for p in ps] | |
253 | cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
|
253 | cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, | |
254 | date=(id, 0), |
|
254 | date=(id, 0), | |
255 | user="debugbuilddag", |
|
255 | user="debugbuilddag", | |
256 | extra={'branch': atbranch}) |
|
256 | extra={'branch': atbranch}) | |
257 | nodeid = repo.commitctx(cx) |
|
257 | nodeid = repo.commitctx(cx) | |
258 | nodeids.append(nodeid) |
|
258 | nodeids.append(nodeid) | |
259 | at = id |
|
259 | at = id | |
260 | elif type == 'l': |
|
260 | elif type == 'l': | |
261 | id, name = data |
|
261 | id, name = data | |
262 | ui.note(('tag %s\n' % name)) |
|
262 | ui.note(('tag %s\n' % name)) | |
263 | tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) |
|
263 | tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) | |
264 | elif type == 'a': |
|
264 | elif type == 'a': | |
265 | ui.note(('branch %s\n' % data)) |
|
265 | ui.note(('branch %s\n' % data)) | |
266 | atbranch = data |
|
266 | atbranch = data | |
267 | progress.update(id) |
|
267 | progress.update(id) | |
268 |
|
268 | |||
269 | if tags: |
|
269 | if tags: | |
270 | repo.vfs.write("localtags", "".join(tags)) |
|
270 | repo.vfs.write("localtags", "".join(tags)) | |
271 |
|
271 | |||
272 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
|
272 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): | |
273 | indent_string = ' ' * indent |
|
273 | indent_string = ' ' * indent | |
274 | if all: |
|
274 | if all: | |
275 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
|
275 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") | |
276 | % indent_string) |
|
276 | % indent_string) | |
277 |
|
277 | |||
278 | def showchunks(named): |
|
278 | def showchunks(named): | |
279 | ui.write("\n%s%s\n" % (indent_string, named)) |
|
279 | ui.write("\n%s%s\n" % (indent_string, named)) | |
280 | for deltadata in gen.deltaiter(): |
|
280 | for deltadata in gen.deltaiter(): | |
281 | node, p1, p2, cs, deltabase, delta, flags = deltadata |
|
281 | node, p1, p2, cs, deltabase, delta, flags = deltadata | |
282 | ui.write("%s%s %s %s %s %s %d\n" % |
|
282 | ui.write("%s%s %s %s %s %s %d\n" % | |
283 | (indent_string, hex(node), hex(p1), hex(p2), |
|
283 | (indent_string, hex(node), hex(p1), hex(p2), | |
284 | hex(cs), hex(deltabase), len(delta))) |
|
284 | hex(cs), hex(deltabase), len(delta))) | |
285 |
|
285 | |||
286 | chunkdata = gen.changelogheader() |
|
286 | chunkdata = gen.changelogheader() | |
287 | showchunks("changelog") |
|
287 | showchunks("changelog") | |
288 | chunkdata = gen.manifestheader() |
|
288 | chunkdata = gen.manifestheader() | |
289 | showchunks("manifest") |
|
289 | showchunks("manifest") | |
290 | for chunkdata in iter(gen.filelogheader, {}): |
|
290 | for chunkdata in iter(gen.filelogheader, {}): | |
291 | fname = chunkdata['filename'] |
|
291 | fname = chunkdata['filename'] | |
292 | showchunks(fname) |
|
292 | showchunks(fname) | |
293 | else: |
|
293 | else: | |
294 | if isinstance(gen, bundle2.unbundle20): |
|
294 | if isinstance(gen, bundle2.unbundle20): | |
295 | raise error.Abort(_('use debugbundle2 for this file')) |
|
295 | raise error.Abort(_('use debugbundle2 for this file')) | |
296 | chunkdata = gen.changelogheader() |
|
296 | chunkdata = gen.changelogheader() | |
297 | for deltadata in gen.deltaiter(): |
|
297 | for deltadata in gen.deltaiter(): | |
298 | node, p1, p2, cs, deltabase, delta, flags = deltadata |
|
298 | node, p1, p2, cs, deltabase, delta, flags = deltadata | |
299 | ui.write("%s%s\n" % (indent_string, hex(node))) |
|
299 | ui.write("%s%s\n" % (indent_string, hex(node))) | |
300 |
|
300 | |||
301 | def _debugobsmarkers(ui, part, indent=0, **opts): |
|
301 | def _debugobsmarkers(ui, part, indent=0, **opts): | |
302 | """display version and markers contained in 'data'""" |
|
302 | """display version and markers contained in 'data'""" | |
303 | opts = pycompat.byteskwargs(opts) |
|
303 | opts = pycompat.byteskwargs(opts) | |
304 | data = part.read() |
|
304 | data = part.read() | |
305 | indent_string = ' ' * indent |
|
305 | indent_string = ' ' * indent | |
306 | try: |
|
306 | try: | |
307 | version, markers = obsolete._readmarkers(data) |
|
307 | version, markers = obsolete._readmarkers(data) | |
308 | except error.UnknownVersion as exc: |
|
308 | except error.UnknownVersion as exc: | |
309 | msg = "%sunsupported version: %s (%d bytes)\n" |
|
309 | msg = "%sunsupported version: %s (%d bytes)\n" | |
310 | msg %= indent_string, exc.version, len(data) |
|
310 | msg %= indent_string, exc.version, len(data) | |
311 | ui.write(msg) |
|
311 | ui.write(msg) | |
312 | else: |
|
312 | else: | |
313 | msg = "%sversion: %d (%d bytes)\n" |
|
313 | msg = "%sversion: %d (%d bytes)\n" | |
314 | msg %= indent_string, version, len(data) |
|
314 | msg %= indent_string, version, len(data) | |
315 | ui.write(msg) |
|
315 | ui.write(msg) | |
316 | fm = ui.formatter('debugobsolete', opts) |
|
316 | fm = ui.formatter('debugobsolete', opts) | |
317 | for rawmarker in sorted(markers): |
|
317 | for rawmarker in sorted(markers): | |
318 | m = obsutil.marker(None, rawmarker) |
|
318 | m = obsutil.marker(None, rawmarker) | |
319 | fm.startitem() |
|
319 | fm.startitem() | |
320 | fm.plain(indent_string) |
|
320 | fm.plain(indent_string) | |
321 | cmdutil.showmarker(fm, m) |
|
321 | cmdutil.showmarker(fm, m) | |
322 | fm.end() |
|
322 | fm.end() | |
323 |
|
323 | |||
324 | def _debugphaseheads(ui, data, indent=0): |
|
324 | def _debugphaseheads(ui, data, indent=0): | |
325 | """display version and markers contained in 'data'""" |
|
325 | """display version and markers contained in 'data'""" | |
326 | indent_string = ' ' * indent |
|
326 | indent_string = ' ' * indent | |
327 | headsbyphase = phases.binarydecode(data) |
|
327 | headsbyphase = phases.binarydecode(data) | |
328 | for phase in phases.allphases: |
|
328 | for phase in phases.allphases: | |
329 | for head in headsbyphase[phase]: |
|
329 | for head in headsbyphase[phase]: | |
330 | ui.write(indent_string) |
|
330 | ui.write(indent_string) | |
331 | ui.write('%s %s\n' % (hex(head), phases.phasenames[phase])) |
|
331 | ui.write('%s %s\n' % (hex(head), phases.phasenames[phase])) | |
332 |
|
332 | |||
333 | def _quasirepr(thing): |
|
333 | def _quasirepr(thing): | |
334 | if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): |
|
334 | if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): | |
335 | return '{%s}' % ( |
|
335 | return '{%s}' % ( | |
336 | b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing))) |
|
336 | b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing))) | |
337 | return pycompat.bytestr(repr(thing)) |
|
337 | return pycompat.bytestr(repr(thing)) | |
338 |
|
338 | |||
339 | def _debugbundle2(ui, gen, all=None, **opts): |
|
339 | def _debugbundle2(ui, gen, all=None, **opts): | |
340 | """lists the contents of a bundle2""" |
|
340 | """lists the contents of a bundle2""" | |
341 | if not isinstance(gen, bundle2.unbundle20): |
|
341 | if not isinstance(gen, bundle2.unbundle20): | |
342 | raise error.Abort(_('not a bundle2 file')) |
|
342 | raise error.Abort(_('not a bundle2 file')) | |
343 | ui.write(('Stream params: %s\n' % _quasirepr(gen.params))) |
|
343 | ui.write(('Stream params: %s\n' % _quasirepr(gen.params))) | |
344 | parttypes = opts.get(r'part_type', []) |
|
344 | parttypes = opts.get(r'part_type', []) | |
345 | for part in gen.iterparts(): |
|
345 | for part in gen.iterparts(): | |
346 | if parttypes and part.type not in parttypes: |
|
346 | if parttypes and part.type not in parttypes: | |
347 | continue |
|
347 | continue | |
348 | msg = '%s -- %s (mandatory: %r)\n' |
|
348 | msg = '%s -- %s (mandatory: %r)\n' | |
349 | ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory))) |
|
349 | ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory))) | |
350 | if part.type == 'changegroup': |
|
350 | if part.type == 'changegroup': | |
351 | version = part.params.get('version', '01') |
|
351 | version = part.params.get('version', '01') | |
352 | cg = changegroup.getunbundler(version, part, 'UN') |
|
352 | cg = changegroup.getunbundler(version, part, 'UN') | |
353 | if not ui.quiet: |
|
353 | if not ui.quiet: | |
354 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
|
354 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) | |
355 | if part.type == 'obsmarkers': |
|
355 | if part.type == 'obsmarkers': | |
356 | if not ui.quiet: |
|
356 | if not ui.quiet: | |
357 | _debugobsmarkers(ui, part, indent=4, **opts) |
|
357 | _debugobsmarkers(ui, part, indent=4, **opts) | |
358 | if part.type == 'phase-heads': |
|
358 | if part.type == 'phase-heads': | |
359 | if not ui.quiet: |
|
359 | if not ui.quiet: | |
360 | _debugphaseheads(ui, part, indent=4) |
|
360 | _debugphaseheads(ui, part, indent=4) | |
361 |
|
361 | |||
362 | @command('debugbundle', |
|
362 | @command('debugbundle', | |
363 | [('a', 'all', None, _('show all details')), |
|
363 | [('a', 'all', None, _('show all details')), | |
364 | ('', 'part-type', [], _('show only the named part type')), |
|
364 | ('', 'part-type', [], _('show only the named part type')), | |
365 | ('', 'spec', None, _('print the bundlespec of the bundle'))], |
|
365 | ('', 'spec', None, _('print the bundlespec of the bundle'))], | |
366 | _('FILE'), |
|
366 | _('FILE'), | |
367 | norepo=True) |
|
367 | norepo=True) | |
368 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
|
368 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): | |
369 | """lists the contents of a bundle""" |
|
369 | """lists the contents of a bundle""" | |
370 | with hg.openpath(ui, bundlepath) as f: |
|
370 | with hg.openpath(ui, bundlepath) as f: | |
371 | if spec: |
|
371 | if spec: | |
372 | spec = exchange.getbundlespec(ui, f) |
|
372 | spec = exchange.getbundlespec(ui, f) | |
373 | ui.write('%s\n' % spec) |
|
373 | ui.write('%s\n' % spec) | |
374 | return |
|
374 | return | |
375 |
|
375 | |||
376 | gen = exchange.readbundle(ui, f, bundlepath) |
|
376 | gen = exchange.readbundle(ui, f, bundlepath) | |
377 | if isinstance(gen, bundle2.unbundle20): |
|
377 | if isinstance(gen, bundle2.unbundle20): | |
378 | return _debugbundle2(ui, gen, all=all, **opts) |
|
378 | return _debugbundle2(ui, gen, all=all, **opts) | |
379 | _debugchangegroup(ui, gen, all=all, **opts) |
|
379 | _debugchangegroup(ui, gen, all=all, **opts) | |
380 |
|
380 | |||
381 | @command('debugcapabilities', |
|
381 | @command('debugcapabilities', | |
382 | [], _('PATH'), |
|
382 | [], _('PATH'), | |
383 | norepo=True) |
|
383 | norepo=True) | |
384 | def debugcapabilities(ui, path, **opts): |
|
384 | def debugcapabilities(ui, path, **opts): | |
385 | """lists the capabilities of a remote peer""" |
|
385 | """lists the capabilities of a remote peer""" | |
386 | opts = pycompat.byteskwargs(opts) |
|
386 | opts = pycompat.byteskwargs(opts) | |
387 | peer = hg.peer(ui, opts, path) |
|
387 | peer = hg.peer(ui, opts, path) | |
388 | caps = peer.capabilities() |
|
388 | caps = peer.capabilities() | |
389 | ui.write(('Main capabilities:\n')) |
|
389 | ui.write(('Main capabilities:\n')) | |
390 | for c in sorted(caps): |
|
390 | for c in sorted(caps): | |
391 | ui.write((' %s\n') % c) |
|
391 | ui.write((' %s\n') % c) | |
392 | b2caps = bundle2.bundle2caps(peer) |
|
392 | b2caps = bundle2.bundle2caps(peer) | |
393 | if b2caps: |
|
393 | if b2caps: | |
394 | ui.write(('Bundle2 capabilities:\n')) |
|
394 | ui.write(('Bundle2 capabilities:\n')) | |
395 | for key, values in sorted(b2caps.iteritems()): |
|
395 | for key, values in sorted(b2caps.iteritems()): | |
396 | ui.write((' %s\n') % key) |
|
396 | ui.write((' %s\n') % key) | |
397 | for v in values: |
|
397 | for v in values: | |
398 | ui.write((' %s\n') % v) |
|
398 | ui.write((' %s\n') % v) | |
399 |
|
399 | |||
400 | @command('debugcheckstate', [], '') |
|
400 | @command('debugcheckstate', [], '') | |
401 | def debugcheckstate(ui, repo): |
|
401 | def debugcheckstate(ui, repo): | |
402 | """validate the correctness of the current dirstate""" |
|
402 | """validate the correctness of the current dirstate""" | |
403 | parent1, parent2 = repo.dirstate.parents() |
|
403 | parent1, parent2 = repo.dirstate.parents() | |
404 | m1 = repo[parent1].manifest() |
|
404 | m1 = repo[parent1].manifest() | |
405 | m2 = repo[parent2].manifest() |
|
405 | m2 = repo[parent2].manifest() | |
406 | errors = 0 |
|
406 | errors = 0 | |
407 | for f in repo.dirstate: |
|
407 | for f in repo.dirstate: | |
408 | state = repo.dirstate[f] |
|
408 | state = repo.dirstate[f] | |
409 | if state in "nr" and f not in m1: |
|
409 | if state in "nr" and f not in m1: | |
410 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
410 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | |
411 | errors += 1 |
|
411 | errors += 1 | |
412 | if state in "a" and f in m1: |
|
412 | if state in "a" and f in m1: | |
413 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
|
413 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) | |
414 | errors += 1 |
|
414 | errors += 1 | |
415 | if state in "m" and f not in m1 and f not in m2: |
|
415 | if state in "m" and f not in m1 and f not in m2: | |
416 | ui.warn(_("%s in state %s, but not in either manifest\n") % |
|
416 | ui.warn(_("%s in state %s, but not in either manifest\n") % | |
417 | (f, state)) |
|
417 | (f, state)) | |
418 | errors += 1 |
|
418 | errors += 1 | |
419 | for f in m1: |
|
419 | for f in m1: | |
420 | state = repo.dirstate[f] |
|
420 | state = repo.dirstate[f] | |
421 | if state not in "nrm": |
|
421 | if state not in "nrm": | |
422 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
422 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | |
423 | errors += 1 |
|
423 | errors += 1 | |
424 | if errors: |
|
424 | if errors: | |
425 | error = _(".hg/dirstate inconsistent with current parent's manifest") |
|
425 | error = _(".hg/dirstate inconsistent with current parent's manifest") | |
426 | raise error.Abort(error) |
|
426 | raise error.Abort(error) | |
427 |
|
427 | |||
428 | @command('debugcolor', |
|
428 | @command('debugcolor', | |
429 | [('', 'style', None, _('show all configured styles'))], |
|
429 | [('', 'style', None, _('show all configured styles'))], | |
430 | 'hg debugcolor') |
|
430 | 'hg debugcolor') | |
431 | def debugcolor(ui, repo, **opts): |
|
431 | def debugcolor(ui, repo, **opts): | |
432 | """show available color, effects or style""" |
|
432 | """show available color, effects or style""" | |
433 | ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode)) |
|
433 | ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode)) | |
434 | if opts.get(r'style'): |
|
434 | if opts.get(r'style'): | |
435 | return _debugdisplaystyle(ui) |
|
435 | return _debugdisplaystyle(ui) | |
436 | else: |
|
436 | else: | |
437 | return _debugdisplaycolor(ui) |
|
437 | return _debugdisplaycolor(ui) | |
438 |
|
438 | |||
439 | def _debugdisplaycolor(ui): |
|
439 | def _debugdisplaycolor(ui): | |
440 | ui = ui.copy() |
|
440 | ui = ui.copy() | |
441 | ui._styles.clear() |
|
441 | ui._styles.clear() | |
442 | for effect in color._activeeffects(ui).keys(): |
|
442 | for effect in color._activeeffects(ui).keys(): | |
443 | ui._styles[effect] = effect |
|
443 | ui._styles[effect] = effect | |
444 | if ui._terminfoparams: |
|
444 | if ui._terminfoparams: | |
445 | for k, v in ui.configitems('color'): |
|
445 | for k, v in ui.configitems('color'): | |
446 | if k.startswith('color.'): |
|
446 | if k.startswith('color.'): | |
447 | ui._styles[k] = k[6:] |
|
447 | ui._styles[k] = k[6:] | |
448 | elif k.startswith('terminfo.'): |
|
448 | elif k.startswith('terminfo.'): | |
449 | ui._styles[k] = k[9:] |
|
449 | ui._styles[k] = k[9:] | |
450 | ui.write(_('available colors:\n')) |
|
450 | ui.write(_('available colors:\n')) | |
451 | # sort label with a '_' after the other to group '_background' entry. |
|
451 | # sort label with a '_' after the other to group '_background' entry. | |
452 | items = sorted(ui._styles.items(), |
|
452 | items = sorted(ui._styles.items(), | |
453 | key=lambda i: ('_' in i[0], i[0], i[1])) |
|
453 | key=lambda i: ('_' in i[0], i[0], i[1])) | |
454 | for colorname, label in items: |
|
454 | for colorname, label in items: | |
455 | ui.write(('%s\n') % colorname, label=label) |
|
455 | ui.write(('%s\n') % colorname, label=label) | |
456 |
|
456 | |||
457 | def _debugdisplaystyle(ui): |
|
457 | def _debugdisplaystyle(ui): | |
458 | ui.write(_('available style:\n')) |
|
458 | ui.write(_('available style:\n')) | |
459 | if not ui._styles: |
|
459 | if not ui._styles: | |
460 | return |
|
460 | return | |
461 | width = max(len(s) for s in ui._styles) |
|
461 | width = max(len(s) for s in ui._styles) | |
462 | for label, effects in sorted(ui._styles.items()): |
|
462 | for label, effects in sorted(ui._styles.items()): | |
463 | ui.write('%s' % label, label=label) |
|
463 | ui.write('%s' % label, label=label) | |
464 | if effects: |
|
464 | if effects: | |
465 | # 50 |
|
465 | # 50 | |
466 | ui.write(': ') |
|
466 | ui.write(': ') | |
467 | ui.write(' ' * (max(0, width - len(label)))) |
|
467 | ui.write(' ' * (max(0, width - len(label)))) | |
468 | ui.write(', '.join(ui.label(e, e) for e in effects.split())) |
|
468 | ui.write(', '.join(ui.label(e, e) for e in effects.split())) | |
469 | ui.write('\n') |
|
469 | ui.write('\n') | |
470 |
|
470 | |||
471 | @command('debugcreatestreamclonebundle', [], 'FILE') |
|
471 | @command('debugcreatestreamclonebundle', [], 'FILE') | |
472 | def debugcreatestreamclonebundle(ui, repo, fname): |
|
472 | def debugcreatestreamclonebundle(ui, repo, fname): | |
473 | """create a stream clone bundle file |
|
473 | """create a stream clone bundle file | |
474 |
|
474 | |||
475 | Stream bundles are special bundles that are essentially archives of |
|
475 | Stream bundles are special bundles that are essentially archives of | |
476 | revlog files. They are commonly used for cloning very quickly. |
|
476 | revlog files. They are commonly used for cloning very quickly. | |
477 | """ |
|
477 | """ | |
478 | # TODO we may want to turn this into an abort when this functionality |
|
478 | # TODO we may want to turn this into an abort when this functionality | |
479 | # is moved into `hg bundle`. |
|
479 | # is moved into `hg bundle`. | |
480 | if phases.hassecret(repo): |
|
480 | if phases.hassecret(repo): | |
481 | ui.warn(_('(warning: stream clone bundle will contain secret ' |
|
481 | ui.warn(_('(warning: stream clone bundle will contain secret ' | |
482 | 'revisions)\n')) |
|
482 | 'revisions)\n')) | |
483 |
|
483 | |||
484 | requirements, gen = streamclone.generatebundlev1(repo) |
|
484 | requirements, gen = streamclone.generatebundlev1(repo) | |
485 | changegroup.writechunks(ui, gen, fname) |
|
485 | changegroup.writechunks(ui, gen, fname) | |
486 |
|
486 | |||
487 | ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
|
487 | ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) | |
488 |
|
488 | |||
489 | @command('debugdag', |
|
489 | @command('debugdag', | |
490 | [('t', 'tags', None, _('use tags as labels')), |
|
490 | [('t', 'tags', None, _('use tags as labels')), | |
491 | ('b', 'branches', None, _('annotate with branch names')), |
|
491 | ('b', 'branches', None, _('annotate with branch names')), | |
492 | ('', 'dots', None, _('use dots for runs')), |
|
492 | ('', 'dots', None, _('use dots for runs')), | |
493 | ('s', 'spaces', None, _('separate elements by spaces'))], |
|
493 | ('s', 'spaces', None, _('separate elements by spaces'))], | |
494 | _('[OPTION]... [FILE [REV]...]'), |
|
494 | _('[OPTION]... [FILE [REV]...]'), | |
495 | optionalrepo=True) |
|
495 | optionalrepo=True) | |
496 | def debugdag(ui, repo, file_=None, *revs, **opts): |
|
496 | def debugdag(ui, repo, file_=None, *revs, **opts): | |
497 | """format the changelog or an index DAG as a concise textual description |
|
497 | """format the changelog or an index DAG as a concise textual description | |
498 |
|
498 | |||
499 | If you pass a revlog index, the revlog's DAG is emitted. If you list |
|
499 | If you pass a revlog index, the revlog's DAG is emitted. If you list | |
500 | revision numbers, they get labeled in the output as rN. |
|
500 | revision numbers, they get labeled in the output as rN. | |
501 |
|
501 | |||
502 | Otherwise, the changelog DAG of the current repo is emitted. |
|
502 | Otherwise, the changelog DAG of the current repo is emitted. | |
503 | """ |
|
503 | """ | |
504 | spaces = opts.get(r'spaces') |
|
504 | spaces = opts.get(r'spaces') | |
505 | dots = opts.get(r'dots') |
|
505 | dots = opts.get(r'dots') | |
506 | if file_: |
|
506 | if file_: | |
507 | rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), |
|
507 | rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), | |
508 | file_) |
|
508 | file_) | |
509 | revs = set((int(r) for r in revs)) |
|
509 | revs = set((int(r) for r in revs)) | |
510 | def events(): |
|
510 | def events(): | |
511 | for r in rlog: |
|
511 | for r in rlog: | |
512 | yield 'n', (r, list(p for p in rlog.parentrevs(r) |
|
512 | yield 'n', (r, list(p for p in rlog.parentrevs(r) | |
513 | if p != -1)) |
|
513 | if p != -1)) | |
514 | if r in revs: |
|
514 | if r in revs: | |
515 | yield 'l', (r, "r%i" % r) |
|
515 | yield 'l', (r, "r%i" % r) | |
516 | elif repo: |
|
516 | elif repo: | |
517 | cl = repo.changelog |
|
517 | cl = repo.changelog | |
518 | tags = opts.get(r'tags') |
|
518 | tags = opts.get(r'tags') | |
519 | branches = opts.get(r'branches') |
|
519 | branches = opts.get(r'branches') | |
520 | if tags: |
|
520 | if tags: | |
521 | labels = {} |
|
521 | labels = {} | |
522 | for l, n in repo.tags().items(): |
|
522 | for l, n in repo.tags().items(): | |
523 | labels.setdefault(cl.rev(n), []).append(l) |
|
523 | labels.setdefault(cl.rev(n), []).append(l) | |
524 | def events(): |
|
524 | def events(): | |
525 | b = "default" |
|
525 | b = "default" | |
526 | for r in cl: |
|
526 | for r in cl: | |
527 | if branches: |
|
527 | if branches: | |
528 | newb = cl.read(cl.node(r))[5]['branch'] |
|
528 | newb = cl.read(cl.node(r))[5]['branch'] | |
529 | if newb != b: |
|
529 | if newb != b: | |
530 | yield 'a', newb |
|
530 | yield 'a', newb | |
531 | b = newb |
|
531 | b = newb | |
532 | yield 'n', (r, list(p for p in cl.parentrevs(r) |
|
532 | yield 'n', (r, list(p for p in cl.parentrevs(r) | |
533 | if p != -1)) |
|
533 | if p != -1)) | |
534 | if tags: |
|
534 | if tags: | |
535 | ls = labels.get(r) |
|
535 | ls = labels.get(r) | |
536 | if ls: |
|
536 | if ls: | |
537 | for l in ls: |
|
537 | for l in ls: | |
538 | yield 'l', (r, l) |
|
538 | yield 'l', (r, l) | |
539 | else: |
|
539 | else: | |
540 | raise error.Abort(_('need repo for changelog dag')) |
|
540 | raise error.Abort(_('need repo for changelog dag')) | |
541 |
|
541 | |||
542 | for line in dagparser.dagtextlines(events(), |
|
542 | for line in dagparser.dagtextlines(events(), | |
543 | addspaces=spaces, |
|
543 | addspaces=spaces, | |
544 | wraplabels=True, |
|
544 | wraplabels=True, | |
545 | wrapannotations=True, |
|
545 | wrapannotations=True, | |
546 | wrapnonlinear=dots, |
|
546 | wrapnonlinear=dots, | |
547 | usedots=dots, |
|
547 | usedots=dots, | |
548 | maxlinewidth=70): |
|
548 | maxlinewidth=70): | |
549 | ui.write(line) |
|
549 | ui.write(line) | |
550 | ui.write("\n") |
|
550 | ui.write("\n") | |
551 |
|
551 | |||
552 | @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) |
|
552 | @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) | |
553 | def debugdata(ui, repo, file_, rev=None, **opts): |
|
553 | def debugdata(ui, repo, file_, rev=None, **opts): | |
554 | """dump the contents of a data file revision""" |
|
554 | """dump the contents of a data file revision""" | |
555 | opts = pycompat.byteskwargs(opts) |
|
555 | opts = pycompat.byteskwargs(opts) | |
556 | if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
|
556 | if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): | |
557 | if rev is not None: |
|
557 | if rev is not None: | |
558 | raise error.CommandError('debugdata', _('invalid arguments')) |
|
558 | raise error.CommandError('debugdata', _('invalid arguments')) | |
559 | file_, rev = None, file_ |
|
559 | file_, rev = None, file_ | |
560 | elif rev is None: |
|
560 | elif rev is None: | |
561 | raise error.CommandError('debugdata', _('invalid arguments')) |
|
561 | raise error.CommandError('debugdata', _('invalid arguments')) | |
562 | r = cmdutil.openstorage(repo, 'debugdata', file_, opts) |
|
562 | r = cmdutil.openstorage(repo, 'debugdata', file_, opts) | |
563 | try: |
|
563 | try: | |
564 | ui.write(r.revision(r.lookup(rev), raw=True)) |
|
564 | ui.write(r.revision(r.lookup(rev), raw=True)) | |
565 | except KeyError: |
|
565 | except KeyError: | |
566 | raise error.Abort(_('invalid revision identifier %s') % rev) |
|
566 | raise error.Abort(_('invalid revision identifier %s') % rev) | |
567 |
|
567 | |||
568 | @command('debugdate', |
|
568 | @command('debugdate', | |
569 | [('e', 'extended', None, _('try extended date formats'))], |
|
569 | [('e', 'extended', None, _('try extended date formats'))], | |
570 | _('[-e] DATE [RANGE]'), |
|
570 | _('[-e] DATE [RANGE]'), | |
571 | norepo=True, optionalrepo=True) |
|
571 | norepo=True, optionalrepo=True) | |
572 | def debugdate(ui, date, range=None, **opts): |
|
572 | def debugdate(ui, date, range=None, **opts): | |
573 | """parse and display a date""" |
|
573 | """parse and display a date""" | |
574 | if opts[r"extended"]: |
|
574 | if opts[r"extended"]: | |
575 | d = dateutil.parsedate(date, util.extendeddateformats) |
|
575 | d = dateutil.parsedate(date, util.extendeddateformats) | |
576 | else: |
|
576 | else: | |
577 | d = dateutil.parsedate(date) |
|
577 | d = dateutil.parsedate(date) | |
578 | ui.write(("internal: %d %d\n") % d) |
|
578 | ui.write(("internal: %d %d\n") % d) | |
579 | ui.write(("standard: %s\n") % dateutil.datestr(d)) |
|
579 | ui.write(("standard: %s\n") % dateutil.datestr(d)) | |
580 | if range: |
|
580 | if range: | |
581 | m = dateutil.matchdate(range) |
|
581 | m = dateutil.matchdate(range) | |
582 | ui.write(("match: %s\n") % m(d[0])) |
|
582 | ui.write(("match: %s\n") % m(d[0])) | |
583 |
|
583 | |||
584 | @command('debugdeltachain', |
|
584 | @command('debugdeltachain', | |
585 | cmdutil.debugrevlogopts + cmdutil.formatteropts, |
|
585 | cmdutil.debugrevlogopts + cmdutil.formatteropts, | |
586 | _('-c|-m|FILE'), |
|
586 | _('-c|-m|FILE'), | |
587 | optionalrepo=True) |
|
587 | optionalrepo=True) | |
588 | def debugdeltachain(ui, repo, file_=None, **opts): |
|
588 | def debugdeltachain(ui, repo, file_=None, **opts): | |
589 | """dump information about delta chains in a revlog |
|
589 | """dump information about delta chains in a revlog | |
590 |
|
590 | |||
591 | Output can be templatized. Available template keywords are: |
|
591 | Output can be templatized. Available template keywords are: | |
592 |
|
592 | |||
593 | :``rev``: revision number |
|
593 | :``rev``: revision number | |
594 | :``chainid``: delta chain identifier (numbered by unique base) |
|
594 | :``chainid``: delta chain identifier (numbered by unique base) | |
595 | :``chainlen``: delta chain length to this revision |
|
595 | :``chainlen``: delta chain length to this revision | |
596 | :``prevrev``: previous revision in delta chain |
|
596 | :``prevrev``: previous revision in delta chain | |
597 | :``deltatype``: role of delta / how it was computed |
|
597 | :``deltatype``: role of delta / how it was computed | |
598 | :``compsize``: compressed size of revision |
|
598 | :``compsize``: compressed size of revision | |
599 | :``uncompsize``: uncompressed size of revision |
|
599 | :``uncompsize``: uncompressed size of revision | |
600 | :``chainsize``: total size of compressed revisions in chain |
|
600 | :``chainsize``: total size of compressed revisions in chain | |
601 | :``chainratio``: total chain size divided by uncompressed revision size |
|
601 | :``chainratio``: total chain size divided by uncompressed revision size | |
602 | (new delta chains typically start at ratio 2.00) |
|
602 | (new delta chains typically start at ratio 2.00) | |
603 | :``lindist``: linear distance from base revision in delta chain to end |
|
603 | :``lindist``: linear distance from base revision in delta chain to end | |
604 | of this revision |
|
604 | of this revision | |
605 | :``extradist``: total size of revisions not part of this delta chain from |
|
605 | :``extradist``: total size of revisions not part of this delta chain from | |
606 | base of delta chain to end of this revision; a measurement |
|
606 | base of delta chain to end of this revision; a measurement | |
607 | of how much extra data we need to read/seek across to read |
|
607 | of how much extra data we need to read/seek across to read | |
608 | the delta chain for this revision |
|
608 | the delta chain for this revision | |
609 | :``extraratio``: extradist divided by chainsize; another representation of |
|
609 | :``extraratio``: extradist divided by chainsize; another representation of | |
610 | how much unrelated data is needed to load this delta chain |
|
610 | how much unrelated data is needed to load this delta chain | |
611 |
|
611 | |||
612 | If the repository is configured to use the sparse read, additional keywords |
|
612 | If the repository is configured to use the sparse read, additional keywords | |
613 | are available: |
|
613 | are available: | |
614 |
|
614 | |||
615 | :``readsize``: total size of data read from the disk for a revision |
|
615 | :``readsize``: total size of data read from the disk for a revision | |
616 | (sum of the sizes of all the blocks) |
|
616 | (sum of the sizes of all the blocks) | |
617 | :``largestblock``: size of the largest block of data read from the disk |
|
617 | :``largestblock``: size of the largest block of data read from the disk | |
618 | :``readdensity``: density of useful bytes in the data read from the disk |
|
618 | :``readdensity``: density of useful bytes in the data read from the disk | |
619 | :``srchunks``: in how many data hunks the whole revision would be read |
|
619 | :``srchunks``: in how many data hunks the whole revision would be read | |
620 |
|
620 | |||
621 | The sparse read can be enabled with experimental.sparse-read = True |
|
621 | The sparse read can be enabled with experimental.sparse-read = True | |
622 | """ |
|
622 | """ | |
623 | opts = pycompat.byteskwargs(opts) |
|
623 | opts = pycompat.byteskwargs(opts) | |
624 | r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
|
624 | r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) | |
625 | index = r.index |
|
625 | index = r.index | |
626 | start = r.start |
|
626 | start = r.start | |
627 | length = r.length |
|
627 | length = r.length | |
628 | generaldelta = r.version & revlog.FLAG_GENERALDELTA |
|
628 | generaldelta = r.version & revlog.FLAG_GENERALDELTA | |
629 | withsparseread = getattr(r, '_withsparseread', False) |
|
629 | withsparseread = getattr(r, '_withsparseread', False) | |
630 |
|
630 | |||
631 | def revinfo(rev): |
|
631 | def revinfo(rev): | |
632 | e = index[rev] |
|
632 | e = index[rev] | |
633 | compsize = e[1] |
|
633 | compsize = e[1] | |
634 | uncompsize = e[2] |
|
634 | uncompsize = e[2] | |
635 | chainsize = 0 |
|
635 | chainsize = 0 | |
636 |
|
636 | |||
637 | if generaldelta: |
|
637 | if generaldelta: | |
638 | if e[3] == e[5]: |
|
638 | if e[3] == e[5]: | |
639 | deltatype = 'p1' |
|
639 | deltatype = 'p1' | |
640 | elif e[3] == e[6]: |
|
640 | elif e[3] == e[6]: | |
641 | deltatype = 'p2' |
|
641 | deltatype = 'p2' | |
642 | elif e[3] == rev - 1: |
|
642 | elif e[3] == rev - 1: | |
643 | deltatype = 'prev' |
|
643 | deltatype = 'prev' | |
644 | elif e[3] == rev: |
|
644 | elif e[3] == rev: | |
645 | deltatype = 'base' |
|
645 | deltatype = 'base' | |
646 | else: |
|
646 | else: | |
647 | deltatype = 'other' |
|
647 | deltatype = 'other' | |
648 | else: |
|
648 | else: | |
649 | if e[3] == rev: |
|
649 | if e[3] == rev: | |
650 | deltatype = 'base' |
|
650 | deltatype = 'base' | |
651 | else: |
|
651 | else: | |
652 | deltatype = 'prev' |
|
652 | deltatype = 'prev' | |
653 |
|
653 | |||
654 | chain = r._deltachain(rev)[0] |
|
654 | chain = r._deltachain(rev)[0] | |
655 | for iterrev in chain: |
|
655 | for iterrev in chain: | |
656 | e = index[iterrev] |
|
656 | e = index[iterrev] | |
657 | chainsize += e[1] |
|
657 | chainsize += e[1] | |
658 |
|
658 | |||
659 | return compsize, uncompsize, deltatype, chain, chainsize |
|
659 | return compsize, uncompsize, deltatype, chain, chainsize | |
660 |
|
660 | |||
661 | fm = ui.formatter('debugdeltachain', opts) |
|
661 | fm = ui.formatter('debugdeltachain', opts) | |
662 |
|
662 | |||
663 | fm.plain(' rev chain# chainlen prev delta ' |
|
663 | fm.plain(' rev chain# chainlen prev delta ' | |
664 | 'size rawsize chainsize ratio lindist extradist ' |
|
664 | 'size rawsize chainsize ratio lindist extradist ' | |
665 | 'extraratio') |
|
665 | 'extraratio') | |
666 | if withsparseread: |
|
666 | if withsparseread: | |
667 | fm.plain(' readsize largestblk rddensity srchunks') |
|
667 | fm.plain(' readsize largestblk rddensity srchunks') | |
668 | fm.plain('\n') |
|
668 | fm.plain('\n') | |
669 |
|
669 | |||
670 | chainbases = {} |
|
670 | chainbases = {} | |
671 | for rev in r: |
|
671 | for rev in r: | |
672 | comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
|
672 | comp, uncomp, deltatype, chain, chainsize = revinfo(rev) | |
673 | chainbase = chain[0] |
|
673 | chainbase = chain[0] | |
674 | chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) |
|
674 | chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) | |
675 | basestart = start(chainbase) |
|
675 | basestart = start(chainbase) | |
676 | revstart = start(rev) |
|
676 | revstart = start(rev) | |
677 | lineardist = revstart + comp - basestart |
|
677 | lineardist = revstart + comp - basestart | |
678 | extradist = lineardist - chainsize |
|
678 | extradist = lineardist - chainsize | |
679 | try: |
|
679 | try: | |
680 | prevrev = chain[-2] |
|
680 | prevrev = chain[-2] | |
681 | except IndexError: |
|
681 | except IndexError: | |
682 | prevrev = -1 |
|
682 | prevrev = -1 | |
683 |
|
683 | |||
684 | if uncomp != 0: |
|
684 | if uncomp != 0: | |
685 | chainratio = float(chainsize) / float(uncomp) |
|
685 | chainratio = float(chainsize) / float(uncomp) | |
686 | else: |
|
686 | else: | |
687 | chainratio = chainsize |
|
687 | chainratio = chainsize | |
688 |
|
688 | |||
689 | if chainsize != 0: |
|
689 | if chainsize != 0: | |
690 | extraratio = float(extradist) / float(chainsize) |
|
690 | extraratio = float(extradist) / float(chainsize) | |
691 | else: |
|
691 | else: | |
692 | extraratio = extradist |
|
692 | extraratio = extradist | |
693 |
|
693 | |||
694 | fm.startitem() |
|
694 | fm.startitem() | |
695 | fm.write('rev chainid chainlen prevrev deltatype compsize ' |
|
695 | fm.write('rev chainid chainlen prevrev deltatype compsize ' | |
696 | 'uncompsize chainsize chainratio lindist extradist ' |
|
696 | 'uncompsize chainsize chainratio lindist extradist ' | |
697 | 'extraratio', |
|
697 | 'extraratio', | |
698 | '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f', |
|
698 | '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f', | |
699 | rev, chainid, len(chain), prevrev, deltatype, comp, |
|
699 | rev, chainid, len(chain), prevrev, deltatype, comp, | |
700 | uncomp, chainsize, chainratio, lineardist, extradist, |
|
700 | uncomp, chainsize, chainratio, lineardist, extradist, | |
701 | extraratio, |
|
701 | extraratio, | |
702 | rev=rev, chainid=chainid, chainlen=len(chain), |
|
702 | rev=rev, chainid=chainid, chainlen=len(chain), | |
703 | prevrev=prevrev, deltatype=deltatype, compsize=comp, |
|
703 | prevrev=prevrev, deltatype=deltatype, compsize=comp, | |
704 | uncompsize=uncomp, chainsize=chainsize, |
|
704 | uncompsize=uncomp, chainsize=chainsize, | |
705 | chainratio=chainratio, lindist=lineardist, |
|
705 | chainratio=chainratio, lindist=lineardist, | |
706 | extradist=extradist, extraratio=extraratio) |
|
706 | extradist=extradist, extraratio=extraratio) | |
707 | if withsparseread: |
|
707 | if withsparseread: | |
708 | readsize = 0 |
|
708 | readsize = 0 | |
709 | largestblock = 0 |
|
709 | largestblock = 0 | |
710 | srchunks = 0 |
|
710 | srchunks = 0 | |
711 |
|
711 | |||
712 | for revschunk in deltautil.slicechunk(r, chain): |
|
712 | for revschunk in deltautil.slicechunk(r, chain): | |
713 | srchunks += 1 |
|
713 | srchunks += 1 | |
714 | blkend = start(revschunk[-1]) + length(revschunk[-1]) |
|
714 | blkend = start(revschunk[-1]) + length(revschunk[-1]) | |
715 | blksize = blkend - start(revschunk[0]) |
|
715 | blksize = blkend - start(revschunk[0]) | |
716 |
|
716 | |||
717 | readsize += blksize |
|
717 | readsize += blksize | |
718 | if largestblock < blksize: |
|
718 | if largestblock < blksize: | |
719 | largestblock = blksize |
|
719 | largestblock = blksize | |
720 |
|
720 | |||
721 | if readsize: |
|
721 | if readsize: | |
722 | readdensity = float(chainsize) / float(readsize) |
|
722 | readdensity = float(chainsize) / float(readsize) | |
723 | else: |
|
723 | else: | |
724 | readdensity = 1 |
|
724 | readdensity = 1 | |
725 |
|
725 | |||
726 | fm.write('readsize largestblock readdensity srchunks', |
|
726 | fm.write('readsize largestblock readdensity srchunks', | |
727 | ' %10d %10d %9.5f %8d', |
|
727 | ' %10d %10d %9.5f %8d', | |
728 | readsize, largestblock, readdensity, srchunks, |
|
728 | readsize, largestblock, readdensity, srchunks, | |
729 | readsize=readsize, largestblock=largestblock, |
|
729 | readsize=readsize, largestblock=largestblock, | |
730 | readdensity=readdensity, srchunks=srchunks) |
|
730 | readdensity=readdensity, srchunks=srchunks) | |
731 |
|
731 | |||
732 | fm.plain('\n') |
|
732 | fm.plain('\n') | |
733 |
|
733 | |||
734 | fm.end() |
|
734 | fm.end() | |
735 |
|
735 | |||
736 | @command('debugdirstate|debugstate', |
|
736 | @command('debugdirstate|debugstate', | |
737 | [('', 'nodates', None, _('do not display the saved mtime (DEPRECATED)')), |
|
737 | [('', 'nodates', None, _('do not display the saved mtime (DEPRECATED)')), | |
738 | ('', 'dates', True, _('display the saved mtime')), |
|
738 | ('', 'dates', True, _('display the saved mtime')), | |
739 | ('', 'datesort', None, _('sort by saved mtime'))], |
|
739 | ('', 'datesort', None, _('sort by saved mtime'))], | |
740 | _('[OPTION]...')) |
|
740 | _('[OPTION]...')) | |
741 | def debugstate(ui, repo, **opts): |
|
741 | def debugstate(ui, repo, **opts): | |
742 | """show the contents of the current dirstate""" |
|
742 | """show the contents of the current dirstate""" | |
743 |
|
743 | |||
744 | nodates = not opts[r'dates'] |
|
744 | nodates = not opts[r'dates'] | |
745 | if opts.get(r'nodates') is not None: |
|
745 | if opts.get(r'nodates') is not None: | |
746 | nodates = True |
|
746 | nodates = True | |
747 | datesort = opts.get(r'datesort') |
|
747 | datesort = opts.get(r'datesort') | |
748 |
|
748 | |||
749 | if datesort: |
|
749 | if datesort: | |
750 | keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
|
750 | keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename | |
751 | else: |
|
751 | else: | |
752 | keyfunc = None # sort by filename |
|
752 | keyfunc = None # sort by filename | |
753 | for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
|
753 | for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): | |
754 | if ent[3] == -1: |
|
754 | if ent[3] == -1: | |
755 | timestr = 'unset ' |
|
755 | timestr = 'unset ' | |
756 | elif nodates: |
|
756 | elif nodates: | |
757 | timestr = 'set ' |
|
757 | timestr = 'set ' | |
758 | else: |
|
758 | else: | |
759 | timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ", |
|
759 | timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ", | |
760 | time.localtime(ent[3])) |
|
760 | time.localtime(ent[3])) | |
761 | timestr = encoding.strtolocal(timestr) |
|
761 | timestr = encoding.strtolocal(timestr) | |
762 | if ent[1] & 0o20000: |
|
762 | if ent[1] & 0o20000: | |
763 | mode = 'lnk' |
|
763 | mode = 'lnk' | |
764 | else: |
|
764 | else: | |
765 | mode = '%3o' % (ent[1] & 0o777 & ~util.umask) |
|
765 | mode = '%3o' % (ent[1] & 0o777 & ~util.umask) | |
766 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
766 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | |
767 | for f in repo.dirstate.copies(): |
|
767 | for f in repo.dirstate.copies(): | |
768 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
768 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | |
769 |
|
769 | |||
770 | @command('debugdiscovery', |
|
770 | @command('debugdiscovery', | |
771 | [('', 'old', None, _('use old-style discovery')), |
|
771 | [('', 'old', None, _('use old-style discovery')), | |
772 | ('', 'nonheads', None, |
|
772 | ('', 'nonheads', None, | |
773 | _('use old-style discovery with non-heads included')), |
|
773 | _('use old-style discovery with non-heads included')), | |
774 | ('', 'rev', [], 'restrict discovery to this set of revs'), |
|
774 | ('', 'rev', [], 'restrict discovery to this set of revs'), | |
775 | ] + cmdutil.remoteopts, |
|
775 | ] + cmdutil.remoteopts, | |
776 | _('[--rev REV] [OTHER]')) |
|
776 | _('[--rev REV] [OTHER]')) | |
777 | def debugdiscovery(ui, repo, remoteurl="default", **opts): |
|
777 | def debugdiscovery(ui, repo, remoteurl="default", **opts): | |
778 | """runs the changeset discovery protocol in isolation""" |
|
778 | """runs the changeset discovery protocol in isolation""" | |
779 | opts = pycompat.byteskwargs(opts) |
|
779 | opts = pycompat.byteskwargs(opts) | |
780 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) |
|
780 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) | |
781 | remote = hg.peer(repo, opts, remoteurl) |
|
781 | remote = hg.peer(repo, opts, remoteurl) | |
782 | ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
|
782 | ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | |
783 |
|
783 | |||
784 | # make sure tests are repeatable |
|
784 | # make sure tests are repeatable | |
785 | random.seed(12323) |
|
785 | random.seed(12323) | |
786 |
|
786 | |||
787 | def doit(pushedrevs, remoteheads, remote=remote): |
|
787 | def doit(pushedrevs, remoteheads, remote=remote): | |
788 | if opts.get('old'): |
|
788 | if opts.get('old'): | |
789 | if not util.safehasattr(remote, 'branches'): |
|
789 | if not util.safehasattr(remote, 'branches'): | |
790 | # enable in-client legacy support |
|
790 | # enable in-client legacy support | |
791 | remote = localrepo.locallegacypeer(remote.local()) |
|
791 | remote = localrepo.locallegacypeer(remote.local()) | |
792 | common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
|
792 | common, _in, hds = treediscovery.findcommonincoming(repo, remote, | |
793 | force=True) |
|
793 | force=True) | |
794 | common = set(common) |
|
794 | common = set(common) | |
795 | if not opts.get('nonheads'): |
|
795 | if not opts.get('nonheads'): | |
796 | ui.write(("unpruned common: %s\n") % |
|
796 | ui.write(("unpruned common: %s\n") % | |
797 | " ".join(sorted(short(n) for n in common))) |
|
797 | " ".join(sorted(short(n) for n in common))) | |
798 |
|
798 | |||
799 | clnode = repo.changelog.node |
|
799 | clnode = repo.changelog.node | |
800 | common = repo.revs('heads(::%ln)', common) |
|
800 | common = repo.revs('heads(::%ln)', common) | |
801 | common = {clnode(r) for r in common} |
|
801 | common = {clnode(r) for r in common} | |
802 | else: |
|
802 | else: | |
803 | nodes = None |
|
803 | nodes = None | |
804 | if pushedrevs: |
|
804 | if pushedrevs: | |
805 | revs = scmutil.revrange(repo, pushedrevs) |
|
805 | revs = scmutil.revrange(repo, pushedrevs) | |
806 | nodes = [repo[r].node() for r in revs] |
|
806 | nodes = [repo[r].node() for r in revs] | |
807 | common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, |
|
807 | common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, | |
808 | ancestorsof=nodes) |
|
808 | ancestorsof=nodes) | |
809 | common = set(common) |
|
809 | common = set(common) | |
810 | rheads = set(hds) |
|
810 | rheads = set(hds) | |
811 | lheads = set(repo.heads()) |
|
811 | lheads = set(repo.heads()) | |
812 | ui.write(("common heads: %s\n") % |
|
812 | ui.write(("common heads: %s\n") % | |
813 | " ".join(sorted(short(n) for n in common))) |
|
813 | " ".join(sorted(short(n) for n in common))) | |
814 | if lheads <= common: |
|
814 | if lheads <= common: | |
815 | ui.write(("local is subset\n")) |
|
815 | ui.write(("local is subset\n")) | |
816 | elif rheads <= common: |
|
816 | elif rheads <= common: | |
817 | ui.write(("remote is subset\n")) |
|
817 | ui.write(("remote is subset\n")) | |
818 |
|
818 | |||
819 | remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
|
819 | remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) | |
820 | localrevs = opts['rev'] |
|
820 | localrevs = opts['rev'] | |
821 | doit(localrevs, remoterevs) |
|
821 | doit(localrevs, remoterevs) | |
822 |
|
822 | |||
823 | _chunksize = 4 << 10 |
|
823 | _chunksize = 4 << 10 | |
824 |
|
824 | |||
825 | @command('debugdownload', |
|
825 | @command('debugdownload', | |
826 | [ |
|
826 | [ | |
827 | ('o', 'output', '', _('path')), |
|
827 | ('o', 'output', '', _('path')), | |
828 | ], |
|
828 | ], | |
829 | optionalrepo=True) |
|
829 | optionalrepo=True) | |
830 | def debugdownload(ui, repo, url, output=None, **opts): |
|
830 | def debugdownload(ui, repo, url, output=None, **opts): | |
831 | """download a resource using Mercurial logic and config |
|
831 | """download a resource using Mercurial logic and config | |
832 | """ |
|
832 | """ | |
833 | fh = urlmod.open(ui, url, output) |
|
833 | fh = urlmod.open(ui, url, output) | |
834 |
|
834 | |||
835 | dest = ui |
|
835 | dest = ui | |
836 | if output: |
|
836 | if output: | |
837 | dest = open(output, "wb", _chunksize) |
|
837 | dest = open(output, "wb", _chunksize) | |
838 | try: |
|
838 | try: | |
839 | data = fh.read(_chunksize) |
|
839 | data = fh.read(_chunksize) | |
840 | while data: |
|
840 | while data: | |
841 | dest.write(data) |
|
841 | dest.write(data) | |
842 | data = fh.read(_chunksize) |
|
842 | data = fh.read(_chunksize) | |
843 | finally: |
|
843 | finally: | |
844 | if output: |
|
844 | if output: | |
845 | dest.close() |
|
845 | dest.close() | |
846 |
|
846 | |||
847 | @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True) |
|
847 | @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True) | |
848 | def debugextensions(ui, repo, **opts): |
|
848 | def debugextensions(ui, repo, **opts): | |
849 | '''show information about active extensions''' |
|
849 | '''show information about active extensions''' | |
850 | opts = pycompat.byteskwargs(opts) |
|
850 | opts = pycompat.byteskwargs(opts) | |
851 | exts = extensions.extensions(ui) |
|
851 | exts = extensions.extensions(ui) | |
852 | hgver = util.version() |
|
852 | hgver = util.version() | |
853 | fm = ui.formatter('debugextensions', opts) |
|
853 | fm = ui.formatter('debugextensions', opts) | |
854 | for extname, extmod in sorted(exts, key=operator.itemgetter(0)): |
|
854 | for extname, extmod in sorted(exts, key=operator.itemgetter(0)): | |
855 | isinternal = extensions.ismoduleinternal(extmod) |
|
855 | isinternal = extensions.ismoduleinternal(extmod) | |
856 | extsource = pycompat.fsencode(extmod.__file__) |
|
856 | extsource = pycompat.fsencode(extmod.__file__) | |
857 | if isinternal: |
|
857 | if isinternal: | |
858 | exttestedwith = [] # never expose magic string to users |
|
858 | exttestedwith = [] # never expose magic string to users | |
859 | else: |
|
859 | else: | |
860 | exttestedwith = getattr(extmod, 'testedwith', '').split() |
|
860 | exttestedwith = getattr(extmod, 'testedwith', '').split() | |
861 | extbuglink = getattr(extmod, 'buglink', None) |
|
861 | extbuglink = getattr(extmod, 'buglink', None) | |
862 |
|
862 | |||
863 | fm.startitem() |
|
863 | fm.startitem() | |
864 |
|
864 | |||
865 | if ui.quiet or ui.verbose: |
|
865 | if ui.quiet or ui.verbose: | |
866 | fm.write('name', '%s\n', extname) |
|
866 | fm.write('name', '%s\n', extname) | |
867 | else: |
|
867 | else: | |
868 | fm.write('name', '%s', extname) |
|
868 | fm.write('name', '%s', extname) | |
869 | if isinternal or hgver in exttestedwith: |
|
869 | if isinternal or hgver in exttestedwith: | |
870 | fm.plain('\n') |
|
870 | fm.plain('\n') | |
871 | elif not exttestedwith: |
|
871 | elif not exttestedwith: | |
872 | fm.plain(_(' (untested!)\n')) |
|
872 | fm.plain(_(' (untested!)\n')) | |
873 | else: |
|
873 | else: | |
874 | lasttestedversion = exttestedwith[-1] |
|
874 | lasttestedversion = exttestedwith[-1] | |
875 | fm.plain(' (%s!)\n' % lasttestedversion) |
|
875 | fm.plain(' (%s!)\n' % lasttestedversion) | |
876 |
|
876 | |||
877 | fm.condwrite(ui.verbose and extsource, 'source', |
|
877 | fm.condwrite(ui.verbose and extsource, 'source', | |
878 | _(' location: %s\n'), extsource or "") |
|
878 | _(' location: %s\n'), extsource or "") | |
879 |
|
879 | |||
880 | if ui.verbose: |
|
880 | if ui.verbose: | |
881 | fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) |
|
881 | fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) | |
882 | fm.data(bundled=isinternal) |
|
882 | fm.data(bundled=isinternal) | |
883 |
|
883 | |||
884 | fm.condwrite(ui.verbose and exttestedwith, 'testedwith', |
|
884 | fm.condwrite(ui.verbose and exttestedwith, 'testedwith', | |
885 | _(' tested with: %s\n'), |
|
885 | _(' tested with: %s\n'), | |
886 | fm.formatlist(exttestedwith, name='ver')) |
|
886 | fm.formatlist(exttestedwith, name='ver')) | |
887 |
|
887 | |||
888 | fm.condwrite(ui.verbose and extbuglink, 'buglink', |
|
888 | fm.condwrite(ui.verbose and extbuglink, 'buglink', | |
889 | _(' bug reporting: %s\n'), extbuglink or "") |
|
889 | _(' bug reporting: %s\n'), extbuglink or "") | |
890 |
|
890 | |||
891 | fm.end() |
|
891 | fm.end() | |
892 |
|
892 | |||
893 | @command('debugfileset', |
|
893 | @command('debugfileset', | |
894 | [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), |
|
894 | [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), | |
895 | ('', 'all-files', False, |
|
895 | ('', 'all-files', False, | |
896 | _('test files from all revisions and working directory')), |
|
896 | _('test files from all revisions and working directory')), | |
897 | ('s', 'show-matcher', None, |
|
897 | ('s', 'show-matcher', None, | |
898 | _('print internal representation of matcher')), |
|
898 | _('print internal representation of matcher')), | |
899 | ('p', 'show-stage', [], |
|
899 | ('p', 'show-stage', [], | |
900 | _('print parsed tree at the given stage'), _('NAME'))], |
|
900 | _('print parsed tree at the given stage'), _('NAME'))], | |
901 | _('[-r REV] [--all-files] [OPTION]... FILESPEC')) |
|
901 | _('[-r REV] [--all-files] [OPTION]... FILESPEC')) | |
902 | def debugfileset(ui, repo, expr, **opts): |
|
902 | def debugfileset(ui, repo, expr, **opts): | |
903 | '''parse and apply a fileset specification''' |
|
903 | '''parse and apply a fileset specification''' | |
904 | from . import fileset |
|
904 | from . import fileset | |
905 | fileset.symbols # force import of fileset so we have predicates to optimize |
|
905 | fileset.symbols # force import of fileset so we have predicates to optimize | |
906 | opts = pycompat.byteskwargs(opts) |
|
906 | opts = pycompat.byteskwargs(opts) | |
907 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
907 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) | |
908 |
|
908 | |||
909 | stages = [ |
|
909 | stages = [ | |
910 | ('parsed', pycompat.identity), |
|
910 | ('parsed', pycompat.identity), | |
911 | ('analyzed', filesetlang.analyze), |
|
911 | ('analyzed', filesetlang.analyze), | |
912 | ('optimized', filesetlang.optimize), |
|
912 | ('optimized', filesetlang.optimize), | |
913 | ] |
|
913 | ] | |
914 | stagenames = set(n for n, f in stages) |
|
914 | stagenames = set(n for n, f in stages) | |
915 |
|
915 | |||
916 | showalways = set() |
|
916 | showalways = set() | |
917 | if ui.verbose and not opts['show_stage']: |
|
917 | if ui.verbose and not opts['show_stage']: | |
918 | # show parsed tree by --verbose (deprecated) |
|
918 | # show parsed tree by --verbose (deprecated) | |
919 | showalways.add('parsed') |
|
919 | showalways.add('parsed') | |
920 | if opts['show_stage'] == ['all']: |
|
920 | if opts['show_stage'] == ['all']: | |
921 | showalways.update(stagenames) |
|
921 | showalways.update(stagenames) | |
922 | else: |
|
922 | else: | |
923 | for n in opts['show_stage']: |
|
923 | for n in opts['show_stage']: | |
924 | if n not in stagenames: |
|
924 | if n not in stagenames: | |
925 | raise error.Abort(_('invalid stage name: %s') % n) |
|
925 | raise error.Abort(_('invalid stage name: %s') % n) | |
926 | showalways.update(opts['show_stage']) |
|
926 | showalways.update(opts['show_stage']) | |
927 |
|
927 | |||
928 | tree = filesetlang.parse(expr) |
|
928 | tree = filesetlang.parse(expr) | |
929 | for n, f in stages: |
|
929 | for n, f in stages: | |
930 | tree = f(tree) |
|
930 | tree = f(tree) | |
931 | if n in showalways: |
|
931 | if n in showalways: | |
932 | if opts['show_stage'] or n != 'parsed': |
|
932 | if opts['show_stage'] or n != 'parsed': | |
933 | ui.write(("* %s:\n") % n) |
|
933 | ui.write(("* %s:\n") % n) | |
934 | ui.write(filesetlang.prettyformat(tree), "\n") |
|
934 | ui.write(filesetlang.prettyformat(tree), "\n") | |
935 |
|
935 | |||
936 | files = set() |
|
936 | files = set() | |
937 | if opts['all_files']: |
|
937 | if opts['all_files']: | |
938 | for r in repo: |
|
938 | for r in repo: | |
939 | c = repo[r] |
|
939 | c = repo[r] | |
940 | files.update(c.files()) |
|
940 | files.update(c.files()) | |
941 | files.update(c.substate) |
|
941 | files.update(c.substate) | |
942 | if opts['all_files'] or ctx.rev() is None: |
|
942 | if opts['all_files'] or ctx.rev() is None: | |
943 | wctx = repo[None] |
|
943 | wctx = repo[None] | |
944 | files.update(repo.dirstate.walk(scmutil.matchall(repo), |
|
944 | files.update(repo.dirstate.walk(scmutil.matchall(repo), | |
945 | subrepos=list(wctx.substate), |
|
945 | subrepos=list(wctx.substate), | |
946 | unknown=True, ignored=True)) |
|
946 | unknown=True, ignored=True)) | |
947 | files.update(wctx.substate) |
|
947 | files.update(wctx.substate) | |
948 | else: |
|
948 | else: | |
949 | files.update(ctx.files()) |
|
949 | files.update(ctx.files()) | |
950 | files.update(ctx.substate) |
|
950 | files.update(ctx.substate) | |
951 |
|
951 | |||
952 | m = ctx.matchfileset(expr) |
|
952 | m = ctx.matchfileset(expr) | |
953 | if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): |
|
953 | if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): | |
954 | ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') |
|
954 | ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') | |
955 | for f in sorted(files): |
|
955 | for f in sorted(files): | |
956 | if not m(f): |
|
956 | if not m(f): | |
957 | continue |
|
957 | continue | |
958 | ui.write("%s\n" % f) |
|
958 | ui.write("%s\n" % f) | |
959 |
|
959 | |||
960 | @command('debugformat', |
|
960 | @command('debugformat', | |
961 | [] + cmdutil.formatteropts) |
|
961 | [] + cmdutil.formatteropts) | |
962 | def debugformat(ui, repo, **opts): |
|
962 | def debugformat(ui, repo, **opts): | |
963 | """display format information about the current repository |
|
963 | """display format information about the current repository | |
964 |
|
964 | |||
965 | Use --verbose to get extra information about current config value and |
|
965 | Use --verbose to get extra information about current config value and | |
966 | Mercurial default.""" |
|
966 | Mercurial default.""" | |
967 | opts = pycompat.byteskwargs(opts) |
|
967 | opts = pycompat.byteskwargs(opts) | |
968 | maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) |
|
968 | maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) | |
969 | maxvariantlength = max(len('format-variant'), maxvariantlength) |
|
969 | maxvariantlength = max(len('format-variant'), maxvariantlength) | |
970 |
|
970 | |||
971 | def makeformatname(name): |
|
971 | def makeformatname(name): | |
972 | return '%s:' + (' ' * (maxvariantlength - len(name))) |
|
972 | return '%s:' + (' ' * (maxvariantlength - len(name))) | |
973 |
|
973 | |||
974 | fm = ui.formatter('debugformat', opts) |
|
974 | fm = ui.formatter('debugformat', opts) | |
975 | if fm.isplain(): |
|
975 | if fm.isplain(): | |
976 | def formatvalue(value): |
|
976 | def formatvalue(value): | |
977 | if util.safehasattr(value, 'startswith'): |
|
977 | if util.safehasattr(value, 'startswith'): | |
978 | return value |
|
978 | return value | |
979 | if value: |
|
979 | if value: | |
980 | return 'yes' |
|
980 | return 'yes' | |
981 | else: |
|
981 | else: | |
982 | return 'no' |
|
982 | return 'no' | |
983 | else: |
|
983 | else: | |
984 | formatvalue = pycompat.identity |
|
984 | formatvalue = pycompat.identity | |
985 |
|
985 | |||
986 | fm.plain('format-variant') |
|
986 | fm.plain('format-variant') | |
987 | fm.plain(' ' * (maxvariantlength - len('format-variant'))) |
|
987 | fm.plain(' ' * (maxvariantlength - len('format-variant'))) | |
988 | fm.plain(' repo') |
|
988 | fm.plain(' repo') | |
989 | if ui.verbose: |
|
989 | if ui.verbose: | |
990 | fm.plain(' config default') |
|
990 | fm.plain(' config default') | |
991 | fm.plain('\n') |
|
991 | fm.plain('\n') | |
992 | for fv in upgrade.allformatvariant: |
|
992 | for fv in upgrade.allformatvariant: | |
993 | fm.startitem() |
|
993 | fm.startitem() | |
994 | repovalue = fv.fromrepo(repo) |
|
994 | repovalue = fv.fromrepo(repo) | |
995 | configvalue = fv.fromconfig(repo) |
|
995 | configvalue = fv.fromconfig(repo) | |
996 |
|
996 | |||
997 | if repovalue != configvalue: |
|
997 | if repovalue != configvalue: | |
998 | namelabel = 'formatvariant.name.mismatchconfig' |
|
998 | namelabel = 'formatvariant.name.mismatchconfig' | |
999 | repolabel = 'formatvariant.repo.mismatchconfig' |
|
999 | repolabel = 'formatvariant.repo.mismatchconfig' | |
1000 | elif repovalue != fv.default: |
|
1000 | elif repovalue != fv.default: | |
1001 | namelabel = 'formatvariant.name.mismatchdefault' |
|
1001 | namelabel = 'formatvariant.name.mismatchdefault' | |
1002 | repolabel = 'formatvariant.repo.mismatchdefault' |
|
1002 | repolabel = 'formatvariant.repo.mismatchdefault' | |
1003 | else: |
|
1003 | else: | |
1004 | namelabel = 'formatvariant.name.uptodate' |
|
1004 | namelabel = 'formatvariant.name.uptodate' | |
1005 | repolabel = 'formatvariant.repo.uptodate' |
|
1005 | repolabel = 'formatvariant.repo.uptodate' | |
1006 |
|
1006 | |||
1007 | fm.write('name', makeformatname(fv.name), fv.name, |
|
1007 | fm.write('name', makeformatname(fv.name), fv.name, | |
1008 | label=namelabel) |
|
1008 | label=namelabel) | |
1009 | fm.write('repo', ' %3s', formatvalue(repovalue), |
|
1009 | fm.write('repo', ' %3s', formatvalue(repovalue), | |
1010 | label=repolabel) |
|
1010 | label=repolabel) | |
1011 | if fv.default != configvalue: |
|
1011 | if fv.default != configvalue: | |
1012 | configlabel = 'formatvariant.config.special' |
|
1012 | configlabel = 'formatvariant.config.special' | |
1013 | else: |
|
1013 | else: | |
1014 | configlabel = 'formatvariant.config.default' |
|
1014 | configlabel = 'formatvariant.config.default' | |
1015 | fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue), |
|
1015 | fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue), | |
1016 | label=configlabel) |
|
1016 | label=configlabel) | |
1017 | fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default), |
|
1017 | fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default), | |
1018 | label='formatvariant.default') |
|
1018 | label='formatvariant.default') | |
1019 | fm.plain('\n') |
|
1019 | fm.plain('\n') | |
1020 | fm.end() |
|
1020 | fm.end() | |
1021 |
|
1021 | |||
1022 | @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
|
1022 | @command('debugfsinfo', [], _('[PATH]'), norepo=True) | |
1023 | def debugfsinfo(ui, path="."): |
|
1023 | def debugfsinfo(ui, path="."): | |
1024 | """show information detected about current filesystem""" |
|
1024 | """show information detected about current filesystem""" | |
1025 | ui.write(('path: %s\n') % path) |
|
1025 | ui.write(('path: %s\n') % path) | |
1026 | ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)')) |
|
1026 | ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)')) | |
1027 | ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
|
1027 | ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) | |
1028 | ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
|
1028 | ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) | |
1029 | ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
|
1029 | ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) | |
1030 | ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
|
1030 | ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) | |
1031 | casesensitive = '(unknown)' |
|
1031 | casesensitive = '(unknown)' | |
1032 | try: |
|
1032 | try: | |
1033 | with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: |
|
1033 | with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: | |
1034 | casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
|
1034 | casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' | |
1035 | except OSError: |
|
1035 | except OSError: | |
1036 | pass |
|
1036 | pass | |
1037 | ui.write(('case-sensitive: %s\n') % casesensitive) |
|
1037 | ui.write(('case-sensitive: %s\n') % casesensitive) | |
1038 |
|
1038 | |||
1039 | @command('debuggetbundle', |
|
1039 | @command('debuggetbundle', | |
1040 | [('H', 'head', [], _('id of head node'), _('ID')), |
|
1040 | [('H', 'head', [], _('id of head node'), _('ID')), | |
1041 | ('C', 'common', [], _('id of common node'), _('ID')), |
|
1041 | ('C', 'common', [], _('id of common node'), _('ID')), | |
1042 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
|
1042 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], | |
1043 | _('REPO FILE [-H|-C ID]...'), |
|
1043 | _('REPO FILE [-H|-C ID]...'), | |
1044 | norepo=True) |
|
1044 | norepo=True) | |
1045 | def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
|
1045 | def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): | |
1046 | """retrieves a bundle from a repo |
|
1046 | """retrieves a bundle from a repo | |
1047 |
|
1047 | |||
1048 | Every ID must be a full-length hex node id string. Saves the bundle to the |
|
1048 | Every ID must be a full-length hex node id string. Saves the bundle to the | |
1049 | given file. |
|
1049 | given file. | |
1050 | """ |
|
1050 | """ | |
1051 | opts = pycompat.byteskwargs(opts) |
|
1051 | opts = pycompat.byteskwargs(opts) | |
1052 | repo = hg.peer(ui, opts, repopath) |
|
1052 | repo = hg.peer(ui, opts, repopath) | |
1053 | if not repo.capable('getbundle'): |
|
1053 | if not repo.capable('getbundle'): | |
1054 | raise error.Abort("getbundle() not supported by target repository") |
|
1054 | raise error.Abort("getbundle() not supported by target repository") | |
1055 | args = {} |
|
1055 | args = {} | |
1056 | if common: |
|
1056 | if common: | |
1057 | args[r'common'] = [bin(s) for s in common] |
|
1057 | args[r'common'] = [bin(s) for s in common] | |
1058 | if head: |
|
1058 | if head: | |
1059 | args[r'heads'] = [bin(s) for s in head] |
|
1059 | args[r'heads'] = [bin(s) for s in head] | |
1060 | # TODO: get desired bundlecaps from command line. |
|
1060 | # TODO: get desired bundlecaps from command line. | |
1061 | args[r'bundlecaps'] = None |
|
1061 | args[r'bundlecaps'] = None | |
1062 | bundle = repo.getbundle('debug', **args) |
|
1062 | bundle = repo.getbundle('debug', **args) | |
1063 |
|
1063 | |||
1064 | bundletype = opts.get('type', 'bzip2').lower() |
|
1064 | bundletype = opts.get('type', 'bzip2').lower() | |
1065 | btypes = {'none': 'HG10UN', |
|
1065 | btypes = {'none': 'HG10UN', | |
1066 | 'bzip2': 'HG10BZ', |
|
1066 | 'bzip2': 'HG10BZ', | |
1067 | 'gzip': 'HG10GZ', |
|
1067 | 'gzip': 'HG10GZ', | |
1068 | 'bundle2': 'HG20'} |
|
1068 | 'bundle2': 'HG20'} | |
1069 | bundletype = btypes.get(bundletype) |
|
1069 | bundletype = btypes.get(bundletype) | |
1070 | if bundletype not in bundle2.bundletypes: |
|
1070 | if bundletype not in bundle2.bundletypes: | |
1071 | raise error.Abort(_('unknown bundle type specified with --type')) |
|
1071 | raise error.Abort(_('unknown bundle type specified with --type')) | |
1072 | bundle2.writebundle(ui, bundle, bundlepath, bundletype) |
|
1072 | bundle2.writebundle(ui, bundle, bundlepath, bundletype) | |
1073 |
|
1073 | |||
1074 | @command('debugignore', [], '[FILE]') |
|
1074 | @command('debugignore', [], '[FILE]') | |
1075 | def debugignore(ui, repo, *files, **opts): |
|
1075 | def debugignore(ui, repo, *files, **opts): | |
1076 | """display the combined ignore pattern and information about ignored files |
|
1076 | """display the combined ignore pattern and information about ignored files | |
1077 |
|
1077 | |||
1078 | With no argument display the combined ignore pattern. |
|
1078 | With no argument display the combined ignore pattern. | |
1079 |
|
1079 | |||
1080 | Given space separated file names, shows if the given file is ignored and |
|
1080 | Given space separated file names, shows if the given file is ignored and | |
1081 | if so, show the ignore rule (file and line number) that matched it. |
|
1081 | if so, show the ignore rule (file and line number) that matched it. | |
1082 | """ |
|
1082 | """ | |
1083 | ignore = repo.dirstate._ignore |
|
1083 | ignore = repo.dirstate._ignore | |
1084 | if not files: |
|
1084 | if not files: | |
1085 | # Show all the patterns |
|
1085 | # Show all the patterns | |
1086 | ui.write("%s\n" % pycompat.byterepr(ignore)) |
|
1086 | ui.write("%s\n" % pycompat.byterepr(ignore)) | |
1087 | else: |
|
1087 | else: | |
1088 | m = scmutil.match(repo[None], pats=files) |
|
1088 | m = scmutil.match(repo[None], pats=files) | |
1089 | uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) |
|
1089 | uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) | |
1090 | for f in m.files(): |
|
1090 | for f in m.files(): | |
1091 | nf = util.normpath(f) |
|
1091 | nf = util.normpath(f) | |
1092 | ignored = None |
|
1092 | ignored = None | |
1093 | ignoredata = None |
|
1093 | ignoredata = None | |
1094 | if nf != '.': |
|
1094 | if nf != '.': | |
1095 | if ignore(nf): |
|
1095 | if ignore(nf): | |
1096 | ignored = nf |
|
1096 | ignored = nf | |
1097 | ignoredata = repo.dirstate._ignorefileandline(nf) |
|
1097 | ignoredata = repo.dirstate._ignorefileandline(nf) | |
1098 | else: |
|
1098 | else: | |
1099 | for p in util.finddirs(nf): |
|
1099 | for p in util.finddirs(nf): | |
1100 | if ignore(p): |
|
1100 | if ignore(p): | |
1101 | ignored = p |
|
1101 | ignored = p | |
1102 | ignoredata = repo.dirstate._ignorefileandline(p) |
|
1102 | ignoredata = repo.dirstate._ignorefileandline(p) | |
1103 | break |
|
1103 | break | |
1104 | if ignored: |
|
1104 | if ignored: | |
1105 | if ignored == nf: |
|
1105 | if ignored == nf: | |
1106 | ui.write(_("%s is ignored\n") % uipathfn(f)) |
|
1106 | ui.write(_("%s is ignored\n") % uipathfn(f)) | |
1107 | else: |
|
1107 | else: | |
1108 | ui.write(_("%s is ignored because of " |
|
1108 | ui.write(_("%s is ignored because of " | |
1109 | "containing folder %s\n") |
|
1109 | "containing folder %s\n") | |
1110 | % (uipathfn(f), ignored)) |
|
1110 | % (uipathfn(f), ignored)) | |
1111 | ignorefile, lineno, line = ignoredata |
|
1111 | ignorefile, lineno, line = ignoredata | |
1112 | ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
|
1112 | ui.write(_("(ignore rule in %s, line %d: '%s')\n") | |
1113 | % (ignorefile, lineno, line)) |
|
1113 | % (ignorefile, lineno, line)) | |
1114 | else: |
|
1114 | else: | |
1115 | ui.write(_("%s is not ignored\n") % uipathfn(f)) |
|
1115 | ui.write(_("%s is not ignored\n") % uipathfn(f)) | |
1116 |
|
1116 | |||
1117 | @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts, |
|
1117 | @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts, | |
1118 | _('-c|-m|FILE')) |
|
1118 | _('-c|-m|FILE')) | |
1119 | def debugindex(ui, repo, file_=None, **opts): |
|
1119 | def debugindex(ui, repo, file_=None, **opts): | |
1120 | """dump index data for a storage primitive""" |
|
1120 | """dump index data for a storage primitive""" | |
1121 | opts = pycompat.byteskwargs(opts) |
|
1121 | opts = pycompat.byteskwargs(opts) | |
1122 | store = cmdutil.openstorage(repo, 'debugindex', file_, opts) |
|
1122 | store = cmdutil.openstorage(repo, 'debugindex', file_, opts) | |
1123 |
|
1123 | |||
1124 | if ui.debugflag: |
|
1124 | if ui.debugflag: | |
1125 | shortfn = hex |
|
1125 | shortfn = hex | |
1126 | else: |
|
1126 | else: | |
1127 | shortfn = short |
|
1127 | shortfn = short | |
1128 |
|
1128 | |||
1129 | idlen = 12 |
|
1129 | idlen = 12 | |
1130 | for i in store: |
|
1130 | for i in store: | |
1131 | idlen = len(shortfn(store.node(i))) |
|
1131 | idlen = len(shortfn(store.node(i))) | |
1132 | break |
|
1132 | break | |
1133 |
|
1133 | |||
1134 | fm = ui.formatter('debugindex', opts) |
|
1134 | fm = ui.formatter('debugindex', opts) | |
1135 | fm.plain(b' rev linkrev %s %s p2\n' % ( |
|
1135 | fm.plain(b' rev linkrev %s %s p2\n' % ( | |
1136 | b'nodeid'.ljust(idlen), |
|
1136 | b'nodeid'.ljust(idlen), | |
1137 | b'p1'.ljust(idlen))) |
|
1137 | b'p1'.ljust(idlen))) | |
1138 |
|
1138 | |||
1139 | for rev in store: |
|
1139 | for rev in store: | |
1140 | node = store.node(rev) |
|
1140 | node = store.node(rev) | |
1141 | parents = store.parents(node) |
|
1141 | parents = store.parents(node) | |
1142 |
|
1142 | |||
1143 | fm.startitem() |
|
1143 | fm.startitem() | |
1144 | fm.write(b'rev', b'%6d ', rev) |
|
1144 | fm.write(b'rev', b'%6d ', rev) | |
1145 | fm.write(b'linkrev', '%7d ', store.linkrev(rev)) |
|
1145 | fm.write(b'linkrev', '%7d ', store.linkrev(rev)) | |
1146 | fm.write(b'node', '%s ', shortfn(node)) |
|
1146 | fm.write(b'node', '%s ', shortfn(node)) | |
1147 | fm.write(b'p1', '%s ', shortfn(parents[0])) |
|
1147 | fm.write(b'p1', '%s ', shortfn(parents[0])) | |
1148 | fm.write(b'p2', '%s', shortfn(parents[1])) |
|
1148 | fm.write(b'p2', '%s', shortfn(parents[1])) | |
1149 | fm.plain(b'\n') |
|
1149 | fm.plain(b'\n') | |
1150 |
|
1150 | |||
1151 | fm.end() |
|
1151 | fm.end() | |
1152 |
|
1152 | |||
1153 | @command('debugindexdot', cmdutil.debugrevlogopts, |
|
1153 | @command('debugindexdot', cmdutil.debugrevlogopts, | |
1154 | _('-c|-m|FILE'), optionalrepo=True) |
|
1154 | _('-c|-m|FILE'), optionalrepo=True) | |
1155 | def debugindexdot(ui, repo, file_=None, **opts): |
|
1155 | def debugindexdot(ui, repo, file_=None, **opts): | |
1156 | """dump an index DAG as a graphviz dot file""" |
|
1156 | """dump an index DAG as a graphviz dot file""" | |
1157 | opts = pycompat.byteskwargs(opts) |
|
1157 | opts = pycompat.byteskwargs(opts) | |
1158 | r = cmdutil.openstorage(repo, 'debugindexdot', file_, opts) |
|
1158 | r = cmdutil.openstorage(repo, 'debugindexdot', file_, opts) | |
1159 | ui.write(("digraph G {\n")) |
|
1159 | ui.write(("digraph G {\n")) | |
1160 | for i in r: |
|
1160 | for i in r: | |
1161 | node = r.node(i) |
|
1161 | node = r.node(i) | |
1162 | pp = r.parents(node) |
|
1162 | pp = r.parents(node) | |
1163 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
|
1163 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | |
1164 | if pp[1] != nullid: |
|
1164 | if pp[1] != nullid: | |
1165 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
|
1165 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | |
1166 | ui.write("}\n") |
|
1166 | ui.write("}\n") | |
1167 |
|
1167 | |||
1168 | @command('debugindexstats', []) |
|
1168 | @command('debugindexstats', []) | |
1169 | def debugindexstats(ui, repo): |
|
1169 | def debugindexstats(ui, repo): | |
1170 | """show stats related to the changelog index""" |
|
1170 | """show stats related to the changelog index""" | |
1171 | repo.changelog.shortest(nullid, 1) |
|
1171 | repo.changelog.shortest(nullid, 1) | |
1172 | index = repo.changelog.index |
|
1172 | index = repo.changelog.index | |
1173 | if not util.safehasattr(index, 'stats'): |
|
1173 | if not util.safehasattr(index, 'stats'): | |
1174 | raise error.Abort(_('debugindexstats only works with native code')) |
|
1174 | raise error.Abort(_('debugindexstats only works with native code')) | |
1175 | for k, v in sorted(index.stats().items()): |
|
1175 | for k, v in sorted(index.stats().items()): | |
1176 | ui.write('%s: %d\n' % (k, v)) |
|
1176 | ui.write('%s: %d\n' % (k, v)) | |
1177 |
|
1177 | |||
1178 | @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True) |
|
1178 | @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True) | |
1179 | def debuginstall(ui, **opts): |
|
1179 | def debuginstall(ui, **opts): | |
1180 | '''test Mercurial installation |
|
1180 | '''test Mercurial installation | |
1181 |
|
1181 | |||
1182 | Returns 0 on success. |
|
1182 | Returns 0 on success. | |
1183 | ''' |
|
1183 | ''' | |
1184 | opts = pycompat.byteskwargs(opts) |
|
1184 | opts = pycompat.byteskwargs(opts) | |
1185 |
|
1185 | |||
1186 | problems = 0 |
|
1186 | problems = 0 | |
1187 |
|
1187 | |||
1188 | fm = ui.formatter('debuginstall', opts) |
|
1188 | fm = ui.formatter('debuginstall', opts) | |
1189 | fm.startitem() |
|
1189 | fm.startitem() | |
1190 |
|
1190 | |||
1191 | # encoding |
|
1191 | # encoding | |
1192 | fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
|
1192 | fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) | |
1193 | err = None |
|
1193 | err = None | |
1194 | try: |
|
1194 | try: | |
1195 | codecs.lookup(pycompat.sysstr(encoding.encoding)) |
|
1195 | codecs.lookup(pycompat.sysstr(encoding.encoding)) | |
1196 | except LookupError as inst: |
|
1196 | except LookupError as inst: | |
1197 | err = stringutil.forcebytestr(inst) |
|
1197 | err = stringutil.forcebytestr(inst) | |
1198 | problems += 1 |
|
1198 | problems += 1 | |
1199 | fm.condwrite(err, 'encodingerror', _(" %s\n" |
|
1199 | fm.condwrite(err, 'encodingerror', _(" %s\n" | |
1200 | " (check that your locale is properly set)\n"), err) |
|
1200 | " (check that your locale is properly set)\n"), err) | |
1201 |
|
1201 | |||
1202 | # Python |
|
1202 | # Python | |
1203 | fm.write('pythonexe', _("checking Python executable (%s)\n"), |
|
1203 | fm.write('pythonexe', _("checking Python executable (%s)\n"), | |
1204 | pycompat.sysexecutable) |
|
1204 | pycompat.sysexecutable) | |
1205 | fm.write('pythonver', _("checking Python version (%s)\n"), |
|
1205 | fm.write('pythonver', _("checking Python version (%s)\n"), | |
1206 | ("%d.%d.%d" % sys.version_info[:3])) |
|
1206 | ("%d.%d.%d" % sys.version_info[:3])) | |
1207 | fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
|
1207 | fm.write('pythonlib', _("checking Python lib (%s)...\n"), | |
1208 | os.path.dirname(pycompat.fsencode(os.__file__))) |
|
1208 | os.path.dirname(pycompat.fsencode(os.__file__))) | |
1209 |
|
1209 | |||
1210 | security = set(sslutil.supportedprotocols) |
|
1210 | security = set(sslutil.supportedprotocols) | |
1211 | if sslutil.hassni: |
|
1211 | if sslutil.hassni: | |
1212 | security.add('sni') |
|
1212 | security.add('sni') | |
1213 |
|
1213 | |||
1214 | fm.write('pythonsecurity', _("checking Python security support (%s)\n"), |
|
1214 | fm.write('pythonsecurity', _("checking Python security support (%s)\n"), | |
1215 | fm.formatlist(sorted(security), name='protocol', |
|
1215 | fm.formatlist(sorted(security), name='protocol', | |
1216 | fmt='%s', sep=',')) |
|
1216 | fmt='%s', sep=',')) | |
1217 |
|
1217 | |||
1218 | # These are warnings, not errors. So don't increment problem count. This |
|
1218 | # These are warnings, not errors. So don't increment problem count. This | |
1219 | # may change in the future. |
|
1219 | # may change in the future. | |
1220 | if 'tls1.2' not in security: |
|
1220 | if 'tls1.2' not in security: | |
1221 | fm.plain(_(' TLS 1.2 not supported by Python install; ' |
|
1221 | fm.plain(_(' TLS 1.2 not supported by Python install; ' | |
1222 | 'network connections lack modern security\n')) |
|
1222 | 'network connections lack modern security\n')) | |
1223 | if 'sni' not in security: |
|
1223 | if 'sni' not in security: | |
1224 | fm.plain(_(' SNI not supported by Python install; may have ' |
|
1224 | fm.plain(_(' SNI not supported by Python install; may have ' | |
1225 | 'connectivity issues with some servers\n')) |
|
1225 | 'connectivity issues with some servers\n')) | |
1226 |
|
1226 | |||
1227 | # TODO print CA cert info |
|
1227 | # TODO print CA cert info | |
1228 |
|
1228 | |||
1229 | # hg version |
|
1229 | # hg version | |
1230 | hgver = util.version() |
|
1230 | hgver = util.version() | |
1231 | fm.write('hgver', _("checking Mercurial version (%s)\n"), |
|
1231 | fm.write('hgver', _("checking Mercurial version (%s)\n"), | |
1232 | hgver.split('+')[0]) |
|
1232 | hgver.split('+')[0]) | |
1233 | fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), |
|
1233 | fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), | |
1234 | '+'.join(hgver.split('+')[1:])) |
|
1234 | '+'.join(hgver.split('+')[1:])) | |
1235 |
|
1235 | |||
1236 | # compiled modules |
|
1236 | # compiled modules | |
1237 | fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), |
|
1237 | fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), | |
1238 | policy.policy) |
|
1238 | policy.policy) | |
1239 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
|
1239 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), | |
1240 | os.path.dirname(pycompat.fsencode(__file__))) |
|
1240 | os.path.dirname(pycompat.fsencode(__file__))) | |
1241 |
|
1241 | |||
1242 | if policy.policy in ('c', 'allow'): |
|
1242 | if policy.policy in ('c', 'allow'): | |
1243 | err = None |
|
1243 | err = None | |
1244 | try: |
|
1244 | try: | |
1245 | from .cext import ( |
|
1245 | from .cext import ( | |
1246 | base85, |
|
1246 | base85, | |
1247 | bdiff, |
|
1247 | bdiff, | |
1248 | mpatch, |
|
1248 | mpatch, | |
1249 | osutil, |
|
1249 | osutil, | |
1250 | ) |
|
1250 | ) | |
1251 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
|
1251 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes | |
1252 | except Exception as inst: |
|
1252 | except Exception as inst: | |
1253 | err = stringutil.forcebytestr(inst) |
|
1253 | err = stringutil.forcebytestr(inst) | |
1254 | problems += 1 |
|
1254 | problems += 1 | |
1255 | fm.condwrite(err, 'extensionserror', " %s\n", err) |
|
1255 | fm.condwrite(err, 'extensionserror', " %s\n", err) | |
1256 |
|
1256 | |||
1257 | compengines = util.compengines._engines.values() |
|
1257 | compengines = util.compengines._engines.values() | |
1258 | fm.write('compengines', _('checking registered compression engines (%s)\n'), |
|
1258 | fm.write('compengines', _('checking registered compression engines (%s)\n'), | |
1259 | fm.formatlist(sorted(e.name() for e in compengines), |
|
1259 | fm.formatlist(sorted(e.name() for e in compengines), | |
1260 | name='compengine', fmt='%s', sep=', ')) |
|
1260 | name='compengine', fmt='%s', sep=', ')) | |
1261 | fm.write('compenginesavail', _('checking available compression engines ' |
|
1261 | fm.write('compenginesavail', _('checking available compression engines ' | |
1262 | '(%s)\n'), |
|
1262 | '(%s)\n'), | |
1263 | fm.formatlist(sorted(e.name() for e in compengines |
|
1263 | fm.formatlist(sorted(e.name() for e in compengines | |
1264 | if e.available()), |
|
1264 | if e.available()), | |
1265 | name='compengine', fmt='%s', sep=', ')) |
|
1265 | name='compengine', fmt='%s', sep=', ')) | |
1266 | wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE) |
|
1266 | wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE) | |
1267 | fm.write('compenginesserver', _('checking available compression engines ' |
|
1267 | fm.write('compenginesserver', _('checking available compression engines ' | |
1268 | 'for wire protocol (%s)\n'), |
|
1268 | 'for wire protocol (%s)\n'), | |
1269 | fm.formatlist([e.name() for e in wirecompengines |
|
1269 | fm.formatlist([e.name() for e in wirecompengines | |
1270 | if e.wireprotosupport()], |
|
1270 | if e.wireprotosupport()], | |
1271 | name='compengine', fmt='%s', sep=', ')) |
|
1271 | name='compengine', fmt='%s', sep=', ')) | |
1272 | re2 = 'missing' |
|
1272 | re2 = 'missing' | |
1273 | if util._re2: |
|
1273 | if util._re2: | |
1274 | re2 = 'available' |
|
1274 | re2 = 'available' | |
1275 | fm.plain(_('checking "re2" regexp engine (%s)\n') % re2) |
|
1275 | fm.plain(_('checking "re2" regexp engine (%s)\n') % re2) | |
1276 | fm.data(re2=bool(util._re2)) |
|
1276 | fm.data(re2=bool(util._re2)) | |
1277 |
|
1277 | |||
1278 | # templates |
|
1278 | # templates | |
1279 | p = templater.templatepaths() |
|
1279 | p = templater.templatepaths() | |
1280 | fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
|
1280 | fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) | |
1281 | fm.condwrite(not p, '', _(" no template directories found\n")) |
|
1281 | fm.condwrite(not p, '', _(" no template directories found\n")) | |
1282 | if p: |
|
1282 | if p: | |
1283 | m = templater.templatepath("map-cmdline.default") |
|
1283 | m = templater.templatepath("map-cmdline.default") | |
1284 | if m: |
|
1284 | if m: | |
1285 | # template found, check if it is working |
|
1285 | # template found, check if it is working | |
1286 | err = None |
|
1286 | err = None | |
1287 | try: |
|
1287 | try: | |
1288 | templater.templater.frommapfile(m) |
|
1288 | templater.templater.frommapfile(m) | |
1289 | except Exception as inst: |
|
1289 | except Exception as inst: | |
1290 | err = stringutil.forcebytestr(inst) |
|
1290 | err = stringutil.forcebytestr(inst) | |
1291 | p = None |
|
1291 | p = None | |
1292 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
|
1292 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) | |
1293 | else: |
|
1293 | else: | |
1294 | p = None |
|
1294 | p = None | |
1295 | fm.condwrite(p, 'defaulttemplate', |
|
1295 | fm.condwrite(p, 'defaulttemplate', | |
1296 | _("checking default template (%s)\n"), m) |
|
1296 | _("checking default template (%s)\n"), m) | |
1297 | fm.condwrite(not m, 'defaulttemplatenotfound', |
|
1297 | fm.condwrite(not m, 'defaulttemplatenotfound', | |
1298 | _(" template '%s' not found\n"), "default") |
|
1298 | _(" template '%s' not found\n"), "default") | |
1299 | if not p: |
|
1299 | if not p: | |
1300 | problems += 1 |
|
1300 | problems += 1 | |
1301 | fm.condwrite(not p, '', |
|
1301 | fm.condwrite(not p, '', | |
1302 | _(" (templates seem to have been installed incorrectly)\n")) |
|
1302 | _(" (templates seem to have been installed incorrectly)\n")) | |
1303 |
|
1303 | |||
1304 | # editor |
|
1304 | # editor | |
1305 | editor = ui.geteditor() |
|
1305 | editor = ui.geteditor() | |
1306 | editor = util.expandpath(editor) |
|
1306 | editor = util.expandpath(editor) | |
1307 | editorbin = procutil.shellsplit(editor)[0] |
|
1307 | editorbin = procutil.shellsplit(editor)[0] | |
1308 | fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) |
|
1308 | fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) | |
1309 | cmdpath = procutil.findexe(editorbin) |
|
1309 | cmdpath = procutil.findexe(editorbin) | |
1310 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
|
1310 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', | |
1311 | _(" No commit editor set and can't find %s in PATH\n" |
|
1311 | _(" No commit editor set and can't find %s in PATH\n" | |
1312 | " (specify a commit editor in your configuration" |
|
1312 | " (specify a commit editor in your configuration" | |
1313 | " file)\n"), not cmdpath and editor == 'vi' and editorbin) |
|
1313 | " file)\n"), not cmdpath and editor == 'vi' and editorbin) | |
1314 | fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
|
1314 | fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', | |
1315 | _(" Can't find editor '%s' in PATH\n" |
|
1315 | _(" Can't find editor '%s' in PATH\n" | |
1316 | " (specify a commit editor in your configuration" |
|
1316 | " (specify a commit editor in your configuration" | |
1317 | " file)\n"), not cmdpath and editorbin) |
|
1317 | " file)\n"), not cmdpath and editorbin) | |
1318 | if not cmdpath and editor != 'vi': |
|
1318 | if not cmdpath and editor != 'vi': | |
1319 | problems += 1 |
|
1319 | problems += 1 | |
1320 |
|
1320 | |||
1321 | # check username |
|
1321 | # check username | |
1322 | username = None |
|
1322 | username = None | |
1323 | err = None |
|
1323 | err = None | |
1324 | try: |
|
1324 | try: | |
1325 | username = ui.username() |
|
1325 | username = ui.username() | |
1326 | except error.Abort as e: |
|
1326 | except error.Abort as e: | |
1327 | err = stringutil.forcebytestr(e) |
|
1327 | err = stringutil.forcebytestr(e) | |
1328 | problems += 1 |
|
1328 | problems += 1 | |
1329 |
|
1329 | |||
1330 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
|
1330 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) | |
1331 | fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
|
1331 | fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" | |
1332 | " (specify a username in your configuration file)\n"), err) |
|
1332 | " (specify a username in your configuration file)\n"), err) | |
1333 |
|
1333 | |||
1334 | fm.condwrite(not problems, '', |
|
1334 | fm.condwrite(not problems, '', | |
1335 | _("no problems detected\n")) |
|
1335 | _("no problems detected\n")) | |
1336 | if not problems: |
|
1336 | if not problems: | |
1337 | fm.data(problems=problems) |
|
1337 | fm.data(problems=problems) | |
1338 | fm.condwrite(problems, 'problems', |
|
1338 | fm.condwrite(problems, 'problems', | |
1339 | _("%d problems detected," |
|
1339 | _("%d problems detected," | |
1340 | " please check your install!\n"), problems) |
|
1340 | " please check your install!\n"), problems) | |
1341 | fm.end() |
|
1341 | fm.end() | |
1342 |
|
1342 | |||
1343 | return problems |
|
1343 | return problems | |
1344 |
|
1344 | |||
1345 | @command('debugknown', [], _('REPO ID...'), norepo=True) |
|
1345 | @command('debugknown', [], _('REPO ID...'), norepo=True) | |
1346 | def debugknown(ui, repopath, *ids, **opts): |
|
1346 | def debugknown(ui, repopath, *ids, **opts): | |
1347 | """test whether node ids are known to a repo |
|
1347 | """test whether node ids are known to a repo | |
1348 |
|
1348 | |||
1349 | Every ID must be a full-length hex node id string. Returns a list of 0s |
|
1349 | Every ID must be a full-length hex node id string. Returns a list of 0s | |
1350 | and 1s indicating unknown/known. |
|
1350 | and 1s indicating unknown/known. | |
1351 | """ |
|
1351 | """ | |
1352 | opts = pycompat.byteskwargs(opts) |
|
1352 | opts = pycompat.byteskwargs(opts) | |
1353 | repo = hg.peer(ui, opts, repopath) |
|
1353 | repo = hg.peer(ui, opts, repopath) | |
1354 | if not repo.capable('known'): |
|
1354 | if not repo.capable('known'): | |
1355 | raise error.Abort("known() not supported by target repository") |
|
1355 | raise error.Abort("known() not supported by target repository") | |
1356 | flags = repo.known([bin(s) for s in ids]) |
|
1356 | flags = repo.known([bin(s) for s in ids]) | |
1357 | ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
|
1357 | ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) | |
1358 |
|
1358 | |||
1359 | @command('debuglabelcomplete', [], _('LABEL...')) |
|
1359 | @command('debuglabelcomplete', [], _('LABEL...')) | |
1360 | def debuglabelcomplete(ui, repo, *args): |
|
1360 | def debuglabelcomplete(ui, repo, *args): | |
1361 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' |
|
1361 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' | |
1362 | debugnamecomplete(ui, repo, *args) |
|
1362 | debugnamecomplete(ui, repo, *args) | |
1363 |
|
1363 | |||
1364 | @command('debuglocks', |
|
1364 | @command('debuglocks', | |
1365 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
|
1365 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), | |
1366 | ('W', 'force-wlock', None, |
|
1366 | ('W', 'force-wlock', None, | |
1367 | _('free the working state lock (DANGEROUS)')), |
|
1367 | _('free the working state lock (DANGEROUS)')), | |
1368 | ('s', 'set-lock', None, _('set the store lock until stopped')), |
|
1368 | ('s', 'set-lock', None, _('set the store lock until stopped')), | |
1369 | ('S', 'set-wlock', None, |
|
1369 | ('S', 'set-wlock', None, | |
1370 | _('set the working state lock until stopped'))], |
|
1370 | _('set the working state lock until stopped'))], | |
1371 | _('[OPTION]...')) |
|
1371 | _('[OPTION]...')) | |
1372 | def debuglocks(ui, repo, **opts): |
|
1372 | def debuglocks(ui, repo, **opts): | |
1373 | """show or modify state of locks |
|
1373 | """show or modify state of locks | |
1374 |
|
1374 | |||
1375 | By default, this command will show which locks are held. This |
|
1375 | By default, this command will show which locks are held. This | |
1376 | includes the user and process holding the lock, the amount of time |
|
1376 | includes the user and process holding the lock, the amount of time | |
1377 | the lock has been held, and the machine name where the process is |
|
1377 | the lock has been held, and the machine name where the process is | |
1378 | running if it's not local. |
|
1378 | running if it's not local. | |
1379 |
|
1379 | |||
1380 | Locks protect the integrity of Mercurial's data, so should be |
|
1380 | Locks protect the integrity of Mercurial's data, so should be | |
1381 | treated with care. System crashes or other interruptions may cause |
|
1381 | treated with care. System crashes or other interruptions may cause | |
1382 | locks to not be properly released, though Mercurial will usually |
|
1382 | locks to not be properly released, though Mercurial will usually | |
1383 | detect and remove such stale locks automatically. |
|
1383 | detect and remove such stale locks automatically. | |
1384 |
|
1384 | |||
1385 | However, detecting stale locks may not always be possible (for |
|
1385 | However, detecting stale locks may not always be possible (for | |
1386 | instance, on a shared filesystem). Removing locks may also be |
|
1386 | instance, on a shared filesystem). Removing locks may also be | |
1387 | blocked by filesystem permissions. |
|
1387 | blocked by filesystem permissions. | |
1388 |
|
1388 | |||
1389 | Setting a lock will prevent other commands from changing the data. |
|
1389 | Setting a lock will prevent other commands from changing the data. | |
1390 | The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs. |
|
1390 | The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs. | |
1391 | The set locks are removed when the command exits. |
|
1391 | The set locks are removed when the command exits. | |
1392 |
|
1392 | |||
1393 | Returns 0 if no locks are held. |
|
1393 | Returns 0 if no locks are held. | |
1394 |
|
1394 | |||
1395 | """ |
|
1395 | """ | |
1396 |
|
1396 | |||
1397 | if opts.get(r'force_lock'): |
|
1397 | if opts.get(r'force_lock'): | |
1398 | repo.svfs.unlink('lock') |
|
1398 | repo.svfs.unlink('lock') | |
1399 | if opts.get(r'force_wlock'): |
|
1399 | if opts.get(r'force_wlock'): | |
1400 | repo.vfs.unlink('wlock') |
|
1400 | repo.vfs.unlink('wlock') | |
1401 | if opts.get(r'force_lock') or opts.get(r'force_wlock'): |
|
1401 | if opts.get(r'force_lock') or opts.get(r'force_wlock'): | |
1402 | return 0 |
|
1402 | return 0 | |
1403 |
|
1403 | |||
1404 | locks = [] |
|
1404 | locks = [] | |
1405 | try: |
|
1405 | try: | |
1406 | if opts.get(r'set_wlock'): |
|
1406 | if opts.get(r'set_wlock'): | |
1407 | try: |
|
1407 | try: | |
1408 | locks.append(repo.wlock(False)) |
|
1408 | locks.append(repo.wlock(False)) | |
1409 | except error.LockHeld: |
|
1409 | except error.LockHeld: | |
1410 | raise error.Abort(_('wlock is already held')) |
|
1410 | raise error.Abort(_('wlock is already held')) | |
1411 | if opts.get(r'set_lock'): |
|
1411 | if opts.get(r'set_lock'): | |
1412 | try: |
|
1412 | try: | |
1413 | locks.append(repo.lock(False)) |
|
1413 | locks.append(repo.lock(False)) | |
1414 | except error.LockHeld: |
|
1414 | except error.LockHeld: | |
1415 | raise error.Abort(_('lock is already held')) |
|
1415 | raise error.Abort(_('lock is already held')) | |
1416 | if len(locks): |
|
1416 | if len(locks): | |
1417 | ui.promptchoice(_("ready to release the lock (y)? $$ &Yes")) |
|
1417 | ui.promptchoice(_("ready to release the lock (y)? $$ &Yes")) | |
1418 | return 0 |
|
1418 | return 0 | |
1419 | finally: |
|
1419 | finally: | |
1420 | release(*locks) |
|
1420 | release(*locks) | |
1421 |
|
1421 | |||
1422 | now = time.time() |
|
1422 | now = time.time() | |
1423 | held = 0 |
|
1423 | held = 0 | |
1424 |
|
1424 | |||
1425 | def report(vfs, name, method): |
|
1425 | def report(vfs, name, method): | |
1426 | # this causes stale locks to get reaped for more accurate reporting |
|
1426 | # this causes stale locks to get reaped for more accurate reporting | |
1427 | try: |
|
1427 | try: | |
1428 | l = method(False) |
|
1428 | l = method(False) | |
1429 | except error.LockHeld: |
|
1429 | except error.LockHeld: | |
1430 | l = None |
|
1430 | l = None | |
1431 |
|
1431 | |||
1432 | if l: |
|
1432 | if l: | |
1433 | l.release() |
|
1433 | l.release() | |
1434 | else: |
|
1434 | else: | |
1435 | try: |
|
1435 | try: | |
1436 | st = vfs.lstat(name) |
|
1436 | st = vfs.lstat(name) | |
1437 | age = now - st[stat.ST_MTIME] |
|
1437 | age = now - st[stat.ST_MTIME] | |
1438 | user = util.username(st.st_uid) |
|
1438 | user = util.username(st.st_uid) | |
1439 | locker = vfs.readlock(name) |
|
1439 | locker = vfs.readlock(name) | |
1440 | if ":" in locker: |
|
1440 | if ":" in locker: | |
1441 | host, pid = locker.split(':') |
|
1441 | host, pid = locker.split(':') | |
1442 | if host == socket.gethostname(): |
|
1442 | if host == socket.gethostname(): | |
1443 | locker = 'user %s, process %s' % (user or b'None', pid) |
|
1443 | locker = 'user %s, process %s' % (user or b'None', pid) | |
1444 | else: |
|
1444 | else: | |
1445 | locker = ('user %s, process %s, host %s' |
|
1445 | locker = ('user %s, process %s, host %s' | |
1446 | % (user or b'None', pid, host)) |
|
1446 | % (user or b'None', pid, host)) | |
1447 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
|
1447 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) | |
1448 | return 1 |
|
1448 | return 1 | |
1449 | except OSError as e: |
|
1449 | except OSError as e: | |
1450 | if e.errno != errno.ENOENT: |
|
1450 | if e.errno != errno.ENOENT: | |
1451 | raise |
|
1451 | raise | |
1452 |
|
1452 | |||
1453 | ui.write(("%-6s free\n") % (name + ":")) |
|
1453 | ui.write(("%-6s free\n") % (name + ":")) | |
1454 | return 0 |
|
1454 | return 0 | |
1455 |
|
1455 | |||
1456 | held += report(repo.svfs, "lock", repo.lock) |
|
1456 | held += report(repo.svfs, "lock", repo.lock) | |
1457 | held += report(repo.vfs, "wlock", repo.wlock) |
|
1457 | held += report(repo.vfs, "wlock", repo.wlock) | |
1458 |
|
1458 | |||
1459 | return held |
|
1459 | return held | |
1460 |
|
1460 | |||
1461 | @command('debugmanifestfulltextcache', [ |
|
1461 | @command('debugmanifestfulltextcache', [ | |
1462 | ('', 'clear', False, _('clear the cache')), |
|
1462 | ('', 'clear', False, _('clear the cache')), | |
1463 | ('a', 'add', '', _('add the given manifest node to the cache'), |
|
1463 | ('a', 'add', '', _('add the given manifest node to the cache'), | |
1464 | _('NODE')) |
|
1464 | _('NODE')) | |
1465 | ], '') |
|
1465 | ], '') | |
1466 | def debugmanifestfulltextcache(ui, repo, add=None, **opts): |
|
1466 | def debugmanifestfulltextcache(ui, repo, add=None, **opts): | |
1467 | """show, clear or amend the contents of the manifest fulltext cache""" |
|
1467 | """show, clear or amend the contents of the manifest fulltext cache""" | |
1468 | with repo.lock(): |
|
1468 | with repo.lock(): | |
1469 | r = repo.manifestlog.getstorage(b'') |
|
1469 | r = repo.manifestlog.getstorage(b'') | |
1470 | try: |
|
1470 | try: | |
1471 | cache = r._fulltextcache |
|
1471 | cache = r._fulltextcache | |
1472 | except AttributeError: |
|
1472 | except AttributeError: | |
1473 | ui.warn(_( |
|
1473 | ui.warn(_( | |
1474 | "Current revlog implementation doesn't appear to have a " |
|
1474 | "Current revlog implementation doesn't appear to have a " | |
1475 | 'manifest fulltext cache\n')) |
|
1475 | 'manifest fulltext cache\n')) | |
1476 | return |
|
1476 | return | |
1477 |
|
1477 | |||
1478 | if opts.get(r'clear'): |
|
1478 | if opts.get(r'clear'): | |
1479 | cache.clear() |
|
1479 | cache.clear() | |
1480 |
|
1480 | |||
1481 | if add: |
|
1481 | if add: | |
1482 | try: |
|
1482 | try: | |
1483 | manifest = repo.manifestlog[r.lookup(add)] |
|
1483 | manifest = repo.manifestlog[r.lookup(add)] | |
1484 | except error.LookupError as e: |
|
1484 | except error.LookupError as e: | |
1485 | raise error.Abort(e, hint="Check your manifest node id") |
|
1485 | raise error.Abort(e, hint="Check your manifest node id") | |
1486 | manifest.read() # stores revisision in cache too |
|
1486 | manifest.read() # stores revisision in cache too | |
1487 |
|
1487 | |||
1488 | if not len(cache): |
|
1488 | if not len(cache): | |
1489 | ui.write(_('cache empty\n')) |
|
1489 | ui.write(_('cache empty\n')) | |
1490 | else: |
|
1490 | else: | |
1491 | ui.write( |
|
1491 | ui.write( | |
1492 |
_(' |
|
1492 | _('cache contains %d manifest entries, in order of most to ' | |
1493 | 'least recent:\n') % (len(cache),)) |
|
1493 | 'least recent:\n') % (len(cache),)) | |
1494 | totalsize = 0 |
|
1494 | totalsize = 0 | |
1495 | for nodeid in cache: |
|
1495 | for nodeid in cache: | |
1496 | # Use cache.get to not update the LRU order |
|
1496 | # Use cache.get to not update the LRU order | |
1497 | data = cache.get(nodeid) |
|
1497 | data = cache.get(nodeid) | |
1498 | size = len(data) |
|
1498 | size = len(data) | |
1499 | totalsize += size + 24 # 20 bytes nodeid, 4 bytes size |
|
1499 | totalsize += size + 24 # 20 bytes nodeid, 4 bytes size | |
1500 | ui.write(_('id: %s, size %s\n') % ( |
|
1500 | ui.write(_('id: %s, size %s\n') % ( | |
1501 | hex(nodeid), util.bytecount(size))) |
|
1501 | hex(nodeid), util.bytecount(size))) | |
1502 | ondisk = cache._opener.stat('manifestfulltextcache').st_size |
|
1502 | ondisk = cache._opener.stat('manifestfulltextcache').st_size | |
1503 | ui.write( |
|
1503 | ui.write( | |
1504 |
_(' |
|
1504 | _('total cache data size %s, on-disk %s\n') % ( | |
1505 | util.bytecount(totalsize), util.bytecount(ondisk)) |
|
1505 | util.bytecount(totalsize), util.bytecount(ondisk)) | |
1506 | ) |
|
1506 | ) | |
1507 |
|
1507 | |||
1508 | @command('debugmergestate', [], '') |
|
1508 | @command('debugmergestate', [], '') | |
1509 | def debugmergestate(ui, repo, *args): |
|
1509 | def debugmergestate(ui, repo, *args): | |
1510 | """print merge state |
|
1510 | """print merge state | |
1511 |
|
1511 | |||
1512 | Use --verbose to print out information about whether v1 or v2 merge state |
|
1512 | Use --verbose to print out information about whether v1 or v2 merge state | |
1513 | was chosen.""" |
|
1513 | was chosen.""" | |
1514 | def _hashornull(h): |
|
1514 | def _hashornull(h): | |
1515 | if h == nullhex: |
|
1515 | if h == nullhex: | |
1516 | return 'null' |
|
1516 | return 'null' | |
1517 | else: |
|
1517 | else: | |
1518 | return h |
|
1518 | return h | |
1519 |
|
1519 | |||
1520 | def printrecords(version): |
|
1520 | def printrecords(version): | |
1521 | ui.write(('* version %d records\n') % version) |
|
1521 | ui.write(('* version %d records\n') % version) | |
1522 | if version == 1: |
|
1522 | if version == 1: | |
1523 | records = v1records |
|
1523 | records = v1records | |
1524 | else: |
|
1524 | else: | |
1525 | records = v2records |
|
1525 | records = v2records | |
1526 |
|
1526 | |||
1527 | for rtype, record in records: |
|
1527 | for rtype, record in records: | |
1528 | # pretty print some record types |
|
1528 | # pretty print some record types | |
1529 | if rtype == 'L': |
|
1529 | if rtype == 'L': | |
1530 | ui.write(('local: %s\n') % record) |
|
1530 | ui.write(('local: %s\n') % record) | |
1531 | elif rtype == 'O': |
|
1531 | elif rtype == 'O': | |
1532 | ui.write(('other: %s\n') % record) |
|
1532 | ui.write(('other: %s\n') % record) | |
1533 | elif rtype == 'm': |
|
1533 | elif rtype == 'm': | |
1534 | driver, mdstate = record.split('\0', 1) |
|
1534 | driver, mdstate = record.split('\0', 1) | |
1535 | ui.write(('merge driver: %s (state "%s")\n') |
|
1535 | ui.write(('merge driver: %s (state "%s")\n') | |
1536 | % (driver, mdstate)) |
|
1536 | % (driver, mdstate)) | |
1537 | elif rtype in 'FDC': |
|
1537 | elif rtype in 'FDC': | |
1538 | r = record.split('\0') |
|
1538 | r = record.split('\0') | |
1539 | f, state, hash, lfile, afile, anode, ofile = r[0:7] |
|
1539 | f, state, hash, lfile, afile, anode, ofile = r[0:7] | |
1540 | if version == 1: |
|
1540 | if version == 1: | |
1541 | onode = 'not stored in v1 format' |
|
1541 | onode = 'not stored in v1 format' | |
1542 | flags = r[7] |
|
1542 | flags = r[7] | |
1543 | else: |
|
1543 | else: | |
1544 | onode, flags = r[7:9] |
|
1544 | onode, flags = r[7:9] | |
1545 | ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') |
|
1545 | ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') | |
1546 | % (f, rtype, state, _hashornull(hash))) |
|
1546 | % (f, rtype, state, _hashornull(hash))) | |
1547 | ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) |
|
1547 | ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) | |
1548 | ui.write((' ancestor path: %s (node %s)\n') |
|
1548 | ui.write((' ancestor path: %s (node %s)\n') | |
1549 | % (afile, _hashornull(anode))) |
|
1549 | % (afile, _hashornull(anode))) | |
1550 | ui.write((' other path: %s (node %s)\n') |
|
1550 | ui.write((' other path: %s (node %s)\n') | |
1551 | % (ofile, _hashornull(onode))) |
|
1551 | % (ofile, _hashornull(onode))) | |
1552 | elif rtype == 'f': |
|
1552 | elif rtype == 'f': | |
1553 | filename, rawextras = record.split('\0', 1) |
|
1553 | filename, rawextras = record.split('\0', 1) | |
1554 | extras = rawextras.split('\0') |
|
1554 | extras = rawextras.split('\0') | |
1555 | i = 0 |
|
1555 | i = 0 | |
1556 | extrastrings = [] |
|
1556 | extrastrings = [] | |
1557 | while i < len(extras): |
|
1557 | while i < len(extras): | |
1558 | extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) |
|
1558 | extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) | |
1559 | i += 2 |
|
1559 | i += 2 | |
1560 |
|
1560 | |||
1561 | ui.write(('file extras: %s (%s)\n') |
|
1561 | ui.write(('file extras: %s (%s)\n') | |
1562 | % (filename, ', '.join(extrastrings))) |
|
1562 | % (filename, ', '.join(extrastrings))) | |
1563 | elif rtype == 'l': |
|
1563 | elif rtype == 'l': | |
1564 | labels = record.split('\0', 2) |
|
1564 | labels = record.split('\0', 2) | |
1565 | labels = [l for l in labels if len(l) > 0] |
|
1565 | labels = [l for l in labels if len(l) > 0] | |
1566 | ui.write(('labels:\n')) |
|
1566 | ui.write(('labels:\n')) | |
1567 | ui.write((' local: %s\n' % labels[0])) |
|
1567 | ui.write((' local: %s\n' % labels[0])) | |
1568 | ui.write((' other: %s\n' % labels[1])) |
|
1568 | ui.write((' other: %s\n' % labels[1])) | |
1569 | if len(labels) > 2: |
|
1569 | if len(labels) > 2: | |
1570 | ui.write((' base: %s\n' % labels[2])) |
|
1570 | ui.write((' base: %s\n' % labels[2])) | |
1571 | else: |
|
1571 | else: | |
1572 | ui.write(('unrecognized entry: %s\t%s\n') |
|
1572 | ui.write(('unrecognized entry: %s\t%s\n') | |
1573 | % (rtype, record.replace('\0', '\t'))) |
|
1573 | % (rtype, record.replace('\0', '\t'))) | |
1574 |
|
1574 | |||
1575 | # Avoid mergestate.read() since it may raise an exception for unsupported |
|
1575 | # Avoid mergestate.read() since it may raise an exception for unsupported | |
1576 | # merge state records. We shouldn't be doing this, but this is OK since this |
|
1576 | # merge state records. We shouldn't be doing this, but this is OK since this | |
1577 | # command is pretty low-level. |
|
1577 | # command is pretty low-level. | |
1578 | ms = mergemod.mergestate(repo) |
|
1578 | ms = mergemod.mergestate(repo) | |
1579 |
|
1579 | |||
1580 | # sort so that reasonable information is on top |
|
1580 | # sort so that reasonable information is on top | |
1581 | v1records = ms._readrecordsv1() |
|
1581 | v1records = ms._readrecordsv1() | |
1582 | v2records = ms._readrecordsv2() |
|
1582 | v2records = ms._readrecordsv2() | |
1583 | order = 'LOml' |
|
1583 | order = 'LOml' | |
1584 | def key(r): |
|
1584 | def key(r): | |
1585 | idx = order.find(r[0]) |
|
1585 | idx = order.find(r[0]) | |
1586 | if idx == -1: |
|
1586 | if idx == -1: | |
1587 | return (1, r[1]) |
|
1587 | return (1, r[1]) | |
1588 | else: |
|
1588 | else: | |
1589 | return (0, idx) |
|
1589 | return (0, idx) | |
1590 | v1records.sort(key=key) |
|
1590 | v1records.sort(key=key) | |
1591 | v2records.sort(key=key) |
|
1591 | v2records.sort(key=key) | |
1592 |
|
1592 | |||
1593 | if not v1records and not v2records: |
|
1593 | if not v1records and not v2records: | |
1594 | ui.write(('no merge state found\n')) |
|
1594 | ui.write(('no merge state found\n')) | |
1595 | elif not v2records: |
|
1595 | elif not v2records: | |
1596 | ui.note(('no version 2 merge state\n')) |
|
1596 | ui.note(('no version 2 merge state\n')) | |
1597 | printrecords(1) |
|
1597 | printrecords(1) | |
1598 | elif ms._v1v2match(v1records, v2records): |
|
1598 | elif ms._v1v2match(v1records, v2records): | |
1599 | ui.note(('v1 and v2 states match: using v2\n')) |
|
1599 | ui.note(('v1 and v2 states match: using v2\n')) | |
1600 | printrecords(2) |
|
1600 | printrecords(2) | |
1601 | else: |
|
1601 | else: | |
1602 | ui.note(('v1 and v2 states mismatch: using v1\n')) |
|
1602 | ui.note(('v1 and v2 states mismatch: using v1\n')) | |
1603 | printrecords(1) |
|
1603 | printrecords(1) | |
1604 | if ui.verbose: |
|
1604 | if ui.verbose: | |
1605 | printrecords(2) |
|
1605 | printrecords(2) | |
1606 |
|
1606 | |||
1607 | @command('debugnamecomplete', [], _('NAME...')) |
|
1607 | @command('debugnamecomplete', [], _('NAME...')) | |
1608 | def debugnamecomplete(ui, repo, *args): |
|
1608 | def debugnamecomplete(ui, repo, *args): | |
1609 | '''complete "names" - tags, open branch names, bookmark names''' |
|
1609 | '''complete "names" - tags, open branch names, bookmark names''' | |
1610 |
|
1610 | |||
1611 | names = set() |
|
1611 | names = set() | |
1612 | # since we previously only listed open branches, we will handle that |
|
1612 | # since we previously only listed open branches, we will handle that | |
1613 | # specially (after this for loop) |
|
1613 | # specially (after this for loop) | |
1614 | for name, ns in repo.names.iteritems(): |
|
1614 | for name, ns in repo.names.iteritems(): | |
1615 | if name != 'branches': |
|
1615 | if name != 'branches': | |
1616 | names.update(ns.listnames(repo)) |
|
1616 | names.update(ns.listnames(repo)) | |
1617 | names.update(tag for (tag, heads, tip, closed) |
|
1617 | names.update(tag for (tag, heads, tip, closed) | |
1618 | in repo.branchmap().iterbranches() if not closed) |
|
1618 | in repo.branchmap().iterbranches() if not closed) | |
1619 | completions = set() |
|
1619 | completions = set() | |
1620 | if not args: |
|
1620 | if not args: | |
1621 | args = [''] |
|
1621 | args = [''] | |
1622 | for a in args: |
|
1622 | for a in args: | |
1623 | completions.update(n for n in names if n.startswith(a)) |
|
1623 | completions.update(n for n in names if n.startswith(a)) | |
1624 | ui.write('\n'.join(sorted(completions))) |
|
1624 | ui.write('\n'.join(sorted(completions))) | |
1625 | ui.write('\n') |
|
1625 | ui.write('\n') | |
1626 |
|
1626 | |||
1627 | @command('debugobsolete', |
|
1627 | @command('debugobsolete', | |
1628 | [('', 'flags', 0, _('markers flag')), |
|
1628 | [('', 'flags', 0, _('markers flag')), | |
1629 | ('', 'record-parents', False, |
|
1629 | ('', 'record-parents', False, | |
1630 | _('record parent information for the precursor')), |
|
1630 | _('record parent information for the precursor')), | |
1631 | ('r', 'rev', [], _('display markers relevant to REV')), |
|
1631 | ('r', 'rev', [], _('display markers relevant to REV')), | |
1632 | ('', 'exclusive', False, _('restrict display to markers only ' |
|
1632 | ('', 'exclusive', False, _('restrict display to markers only ' | |
1633 | 'relevant to REV')), |
|
1633 | 'relevant to REV')), | |
1634 | ('', 'index', False, _('display index of the marker')), |
|
1634 | ('', 'index', False, _('display index of the marker')), | |
1635 | ('', 'delete', [], _('delete markers specified by indices')), |
|
1635 | ('', 'delete', [], _('delete markers specified by indices')), | |
1636 | ] + cmdutil.commitopts2 + cmdutil.formatteropts, |
|
1636 | ] + cmdutil.commitopts2 + cmdutil.formatteropts, | |
1637 | _('[OBSOLETED [REPLACEMENT ...]]')) |
|
1637 | _('[OBSOLETED [REPLACEMENT ...]]')) | |
1638 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
|
1638 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): | |
1639 | """create arbitrary obsolete marker |
|
1639 | """create arbitrary obsolete marker | |
1640 |
|
1640 | |||
1641 | With no arguments, displays the list of obsolescence markers.""" |
|
1641 | With no arguments, displays the list of obsolescence markers.""" | |
1642 |
|
1642 | |||
1643 | opts = pycompat.byteskwargs(opts) |
|
1643 | opts = pycompat.byteskwargs(opts) | |
1644 |
|
1644 | |||
1645 | def parsenodeid(s): |
|
1645 | def parsenodeid(s): | |
1646 | try: |
|
1646 | try: | |
1647 | # We do not use revsingle/revrange functions here to accept |
|
1647 | # We do not use revsingle/revrange functions here to accept | |
1648 | # arbitrary node identifiers, possibly not present in the |
|
1648 | # arbitrary node identifiers, possibly not present in the | |
1649 | # local repository. |
|
1649 | # local repository. | |
1650 | n = bin(s) |
|
1650 | n = bin(s) | |
1651 | if len(n) != len(nullid): |
|
1651 | if len(n) != len(nullid): | |
1652 | raise TypeError() |
|
1652 | raise TypeError() | |
1653 | return n |
|
1653 | return n | |
1654 | except TypeError: |
|
1654 | except TypeError: | |
1655 | raise error.Abort('changeset references must be full hexadecimal ' |
|
1655 | raise error.Abort('changeset references must be full hexadecimal ' | |
1656 | 'node identifiers') |
|
1656 | 'node identifiers') | |
1657 |
|
1657 | |||
1658 | if opts.get('delete'): |
|
1658 | if opts.get('delete'): | |
1659 | indices = [] |
|
1659 | indices = [] | |
1660 | for v in opts.get('delete'): |
|
1660 | for v in opts.get('delete'): | |
1661 | try: |
|
1661 | try: | |
1662 | indices.append(int(v)) |
|
1662 | indices.append(int(v)) | |
1663 | except ValueError: |
|
1663 | except ValueError: | |
1664 | raise error.Abort(_('invalid index value: %r') % v, |
|
1664 | raise error.Abort(_('invalid index value: %r') % v, | |
1665 | hint=_('use integers for indices')) |
|
1665 | hint=_('use integers for indices')) | |
1666 |
|
1666 | |||
1667 | if repo.currenttransaction(): |
|
1667 | if repo.currenttransaction(): | |
1668 | raise error.Abort(_('cannot delete obsmarkers in the middle ' |
|
1668 | raise error.Abort(_('cannot delete obsmarkers in the middle ' | |
1669 | 'of transaction.')) |
|
1669 | 'of transaction.')) | |
1670 |
|
1670 | |||
1671 | with repo.lock(): |
|
1671 | with repo.lock(): | |
1672 | n = repair.deleteobsmarkers(repo.obsstore, indices) |
|
1672 | n = repair.deleteobsmarkers(repo.obsstore, indices) | |
1673 | ui.write(_('deleted %i obsolescence markers\n') % n) |
|
1673 | ui.write(_('deleted %i obsolescence markers\n') % n) | |
1674 |
|
1674 | |||
1675 | return |
|
1675 | return | |
1676 |
|
1676 | |||
1677 | if precursor is not None: |
|
1677 | if precursor is not None: | |
1678 | if opts['rev']: |
|
1678 | if opts['rev']: | |
1679 | raise error.Abort('cannot select revision when creating marker') |
|
1679 | raise error.Abort('cannot select revision when creating marker') | |
1680 | metadata = {} |
|
1680 | metadata = {} | |
1681 | metadata['user'] = encoding.fromlocal(opts['user'] or ui.username()) |
|
1681 | metadata['user'] = encoding.fromlocal(opts['user'] or ui.username()) | |
1682 | succs = tuple(parsenodeid(succ) for succ in successors) |
|
1682 | succs = tuple(parsenodeid(succ) for succ in successors) | |
1683 | l = repo.lock() |
|
1683 | l = repo.lock() | |
1684 | try: |
|
1684 | try: | |
1685 | tr = repo.transaction('debugobsolete') |
|
1685 | tr = repo.transaction('debugobsolete') | |
1686 | try: |
|
1686 | try: | |
1687 | date = opts.get('date') |
|
1687 | date = opts.get('date') | |
1688 | if date: |
|
1688 | if date: | |
1689 | date = dateutil.parsedate(date) |
|
1689 | date = dateutil.parsedate(date) | |
1690 | else: |
|
1690 | else: | |
1691 | date = None |
|
1691 | date = None | |
1692 | prec = parsenodeid(precursor) |
|
1692 | prec = parsenodeid(precursor) | |
1693 | parents = None |
|
1693 | parents = None | |
1694 | if opts['record_parents']: |
|
1694 | if opts['record_parents']: | |
1695 | if prec not in repo.unfiltered(): |
|
1695 | if prec not in repo.unfiltered(): | |
1696 | raise error.Abort('cannot used --record-parents on ' |
|
1696 | raise error.Abort('cannot used --record-parents on ' | |
1697 | 'unknown changesets') |
|
1697 | 'unknown changesets') | |
1698 | parents = repo.unfiltered()[prec].parents() |
|
1698 | parents = repo.unfiltered()[prec].parents() | |
1699 | parents = tuple(p.node() for p in parents) |
|
1699 | parents = tuple(p.node() for p in parents) | |
1700 | repo.obsstore.create(tr, prec, succs, opts['flags'], |
|
1700 | repo.obsstore.create(tr, prec, succs, opts['flags'], | |
1701 | parents=parents, date=date, |
|
1701 | parents=parents, date=date, | |
1702 | metadata=metadata, ui=ui) |
|
1702 | metadata=metadata, ui=ui) | |
1703 | tr.close() |
|
1703 | tr.close() | |
1704 | except ValueError as exc: |
|
1704 | except ValueError as exc: | |
1705 | raise error.Abort(_('bad obsmarker input: %s') % |
|
1705 | raise error.Abort(_('bad obsmarker input: %s') % | |
1706 | pycompat.bytestr(exc)) |
|
1706 | pycompat.bytestr(exc)) | |
1707 | finally: |
|
1707 | finally: | |
1708 | tr.release() |
|
1708 | tr.release() | |
1709 | finally: |
|
1709 | finally: | |
1710 | l.release() |
|
1710 | l.release() | |
1711 | else: |
|
1711 | else: | |
1712 | if opts['rev']: |
|
1712 | if opts['rev']: | |
1713 | revs = scmutil.revrange(repo, opts['rev']) |
|
1713 | revs = scmutil.revrange(repo, opts['rev']) | |
1714 | nodes = [repo[r].node() for r in revs] |
|
1714 | nodes = [repo[r].node() for r in revs] | |
1715 | markers = list(obsutil.getmarkers(repo, nodes=nodes, |
|
1715 | markers = list(obsutil.getmarkers(repo, nodes=nodes, | |
1716 | exclusive=opts['exclusive'])) |
|
1716 | exclusive=opts['exclusive'])) | |
1717 | markers.sort(key=lambda x: x._data) |
|
1717 | markers.sort(key=lambda x: x._data) | |
1718 | else: |
|
1718 | else: | |
1719 | markers = obsutil.getmarkers(repo) |
|
1719 | markers = obsutil.getmarkers(repo) | |
1720 |
|
1720 | |||
1721 | markerstoiter = markers |
|
1721 | markerstoiter = markers | |
1722 | isrelevant = lambda m: True |
|
1722 | isrelevant = lambda m: True | |
1723 | if opts.get('rev') and opts.get('index'): |
|
1723 | if opts.get('rev') and opts.get('index'): | |
1724 | markerstoiter = obsutil.getmarkers(repo) |
|
1724 | markerstoiter = obsutil.getmarkers(repo) | |
1725 | markerset = set(markers) |
|
1725 | markerset = set(markers) | |
1726 | isrelevant = lambda m: m in markerset |
|
1726 | isrelevant = lambda m: m in markerset | |
1727 |
|
1727 | |||
1728 | fm = ui.formatter('debugobsolete', opts) |
|
1728 | fm = ui.formatter('debugobsolete', opts) | |
1729 | for i, m in enumerate(markerstoiter): |
|
1729 | for i, m in enumerate(markerstoiter): | |
1730 | if not isrelevant(m): |
|
1730 | if not isrelevant(m): | |
1731 | # marker can be irrelevant when we're iterating over a set |
|
1731 | # marker can be irrelevant when we're iterating over a set | |
1732 | # of markers (markerstoiter) which is bigger than the set |
|
1732 | # of markers (markerstoiter) which is bigger than the set | |
1733 | # of markers we want to display (markers) |
|
1733 | # of markers we want to display (markers) | |
1734 | # this can happen if both --index and --rev options are |
|
1734 | # this can happen if both --index and --rev options are | |
1735 | # provided and thus we need to iterate over all of the markers |
|
1735 | # provided and thus we need to iterate over all of the markers | |
1736 | # to get the correct indices, but only display the ones that |
|
1736 | # to get the correct indices, but only display the ones that | |
1737 | # are relevant to --rev value |
|
1737 | # are relevant to --rev value | |
1738 | continue |
|
1738 | continue | |
1739 | fm.startitem() |
|
1739 | fm.startitem() | |
1740 | ind = i if opts.get('index') else None |
|
1740 | ind = i if opts.get('index') else None | |
1741 | cmdutil.showmarker(fm, m, index=ind) |
|
1741 | cmdutil.showmarker(fm, m, index=ind) | |
1742 | fm.end() |
|
1742 | fm.end() | |
1743 |
|
1743 | |||
1744 | @command('debugp1copies', |
|
1744 | @command('debugp1copies', | |
1745 | [('r', 'rev', '', _('revision to debug'), _('REV'))], |
|
1745 | [('r', 'rev', '', _('revision to debug'), _('REV'))], | |
1746 | _('[-r REV]')) |
|
1746 | _('[-r REV]')) | |
1747 | def debugp1copies(ui, repo, **opts): |
|
1747 | def debugp1copies(ui, repo, **opts): | |
1748 | """dump copy information compared to p1""" |
|
1748 | """dump copy information compared to p1""" | |
1749 |
|
1749 | |||
1750 | opts = pycompat.byteskwargs(opts) |
|
1750 | opts = pycompat.byteskwargs(opts) | |
1751 | ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
|
1751 | ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) | |
1752 | for dst, src in ctx.p1copies().items(): |
|
1752 | for dst, src in ctx.p1copies().items(): | |
1753 | ui.write('%s -> %s\n' % (src, dst)) |
|
1753 | ui.write('%s -> %s\n' % (src, dst)) | |
1754 |
|
1754 | |||
1755 | @command('debugp2copies', |
|
1755 | @command('debugp2copies', | |
1756 | [('r', 'rev', '', _('revision to debug'), _('REV'))], |
|
1756 | [('r', 'rev', '', _('revision to debug'), _('REV'))], | |
1757 | _('[-r REV]')) |
|
1757 | _('[-r REV]')) | |
1758 | def debugp1copies(ui, repo, **opts): |
|
1758 | def debugp1copies(ui, repo, **opts): | |
1759 | """dump copy information compared to p2""" |
|
1759 | """dump copy information compared to p2""" | |
1760 |
|
1760 | |||
1761 | opts = pycompat.byteskwargs(opts) |
|
1761 | opts = pycompat.byteskwargs(opts) | |
1762 | ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
|
1762 | ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) | |
1763 | for dst, src in ctx.p2copies().items(): |
|
1763 | for dst, src in ctx.p2copies().items(): | |
1764 | ui.write('%s -> %s\n' % (src, dst)) |
|
1764 | ui.write('%s -> %s\n' % (src, dst)) | |
1765 |
|
1765 | |||
1766 | @command('debugpathcomplete', |
|
1766 | @command('debugpathcomplete', | |
1767 | [('f', 'full', None, _('complete an entire path')), |
|
1767 | [('f', 'full', None, _('complete an entire path')), | |
1768 | ('n', 'normal', None, _('show only normal files')), |
|
1768 | ('n', 'normal', None, _('show only normal files')), | |
1769 | ('a', 'added', None, _('show only added files')), |
|
1769 | ('a', 'added', None, _('show only added files')), | |
1770 | ('r', 'removed', None, _('show only removed files'))], |
|
1770 | ('r', 'removed', None, _('show only removed files'))], | |
1771 | _('FILESPEC...')) |
|
1771 | _('FILESPEC...')) | |
1772 | def debugpathcomplete(ui, repo, *specs, **opts): |
|
1772 | def debugpathcomplete(ui, repo, *specs, **opts): | |
1773 | '''complete part or all of a tracked path |
|
1773 | '''complete part or all of a tracked path | |
1774 |
|
1774 | |||
1775 | This command supports shells that offer path name completion. It |
|
1775 | This command supports shells that offer path name completion. It | |
1776 | currently completes only files already known to the dirstate. |
|
1776 | currently completes only files already known to the dirstate. | |
1777 |
|
1777 | |||
1778 | Completion extends only to the next path segment unless |
|
1778 | Completion extends only to the next path segment unless | |
1779 | --full is specified, in which case entire paths are used.''' |
|
1779 | --full is specified, in which case entire paths are used.''' | |
1780 |
|
1780 | |||
1781 | def complete(path, acceptable): |
|
1781 | def complete(path, acceptable): | |
1782 | dirstate = repo.dirstate |
|
1782 | dirstate = repo.dirstate | |
1783 | spec = os.path.normpath(os.path.join(encoding.getcwd(), path)) |
|
1783 | spec = os.path.normpath(os.path.join(encoding.getcwd(), path)) | |
1784 | rootdir = repo.root + pycompat.ossep |
|
1784 | rootdir = repo.root + pycompat.ossep | |
1785 | if spec != repo.root and not spec.startswith(rootdir): |
|
1785 | if spec != repo.root and not spec.startswith(rootdir): | |
1786 | return [], [] |
|
1786 | return [], [] | |
1787 | if os.path.isdir(spec): |
|
1787 | if os.path.isdir(spec): | |
1788 | spec += '/' |
|
1788 | spec += '/' | |
1789 | spec = spec[len(rootdir):] |
|
1789 | spec = spec[len(rootdir):] | |
1790 | fixpaths = pycompat.ossep != '/' |
|
1790 | fixpaths = pycompat.ossep != '/' | |
1791 | if fixpaths: |
|
1791 | if fixpaths: | |
1792 | spec = spec.replace(pycompat.ossep, '/') |
|
1792 | spec = spec.replace(pycompat.ossep, '/') | |
1793 | speclen = len(spec) |
|
1793 | speclen = len(spec) | |
1794 | fullpaths = opts[r'full'] |
|
1794 | fullpaths = opts[r'full'] | |
1795 | files, dirs = set(), set() |
|
1795 | files, dirs = set(), set() | |
1796 | adddir, addfile = dirs.add, files.add |
|
1796 | adddir, addfile = dirs.add, files.add | |
1797 | for f, st in dirstate.iteritems(): |
|
1797 | for f, st in dirstate.iteritems(): | |
1798 | if f.startswith(spec) and st[0] in acceptable: |
|
1798 | if f.startswith(spec) and st[0] in acceptable: | |
1799 | if fixpaths: |
|
1799 | if fixpaths: | |
1800 | f = f.replace('/', pycompat.ossep) |
|
1800 | f = f.replace('/', pycompat.ossep) | |
1801 | if fullpaths: |
|
1801 | if fullpaths: | |
1802 | addfile(f) |
|
1802 | addfile(f) | |
1803 | continue |
|
1803 | continue | |
1804 | s = f.find(pycompat.ossep, speclen) |
|
1804 | s = f.find(pycompat.ossep, speclen) | |
1805 | if s >= 0: |
|
1805 | if s >= 0: | |
1806 | adddir(f[:s]) |
|
1806 | adddir(f[:s]) | |
1807 | else: |
|
1807 | else: | |
1808 | addfile(f) |
|
1808 | addfile(f) | |
1809 | return files, dirs |
|
1809 | return files, dirs | |
1810 |
|
1810 | |||
1811 | acceptable = '' |
|
1811 | acceptable = '' | |
1812 | if opts[r'normal']: |
|
1812 | if opts[r'normal']: | |
1813 | acceptable += 'nm' |
|
1813 | acceptable += 'nm' | |
1814 | if opts[r'added']: |
|
1814 | if opts[r'added']: | |
1815 | acceptable += 'a' |
|
1815 | acceptable += 'a' | |
1816 | if opts[r'removed']: |
|
1816 | if opts[r'removed']: | |
1817 | acceptable += 'r' |
|
1817 | acceptable += 'r' | |
1818 | cwd = repo.getcwd() |
|
1818 | cwd = repo.getcwd() | |
1819 | if not specs: |
|
1819 | if not specs: | |
1820 | specs = ['.'] |
|
1820 | specs = ['.'] | |
1821 |
|
1821 | |||
1822 | files, dirs = set(), set() |
|
1822 | files, dirs = set(), set() | |
1823 | for spec in specs: |
|
1823 | for spec in specs: | |
1824 | f, d = complete(spec, acceptable or 'nmar') |
|
1824 | f, d = complete(spec, acceptable or 'nmar') | |
1825 | files.update(f) |
|
1825 | files.update(f) | |
1826 | dirs.update(d) |
|
1826 | dirs.update(d) | |
1827 | files.update(dirs) |
|
1827 | files.update(dirs) | |
1828 | ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
|
1828 | ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) | |
1829 | ui.write('\n') |
|
1829 | ui.write('\n') | |
1830 |
|
1830 | |||
1831 | @command('debugpathcopies', |
|
1831 | @command('debugpathcopies', | |
1832 | cmdutil.walkopts, |
|
1832 | cmdutil.walkopts, | |
1833 | 'hg debugpathcopies REV1 REV2 [FILE]', |
|
1833 | 'hg debugpathcopies REV1 REV2 [FILE]', | |
1834 | inferrepo=True) |
|
1834 | inferrepo=True) | |
1835 | def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts): |
|
1835 | def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts): | |
1836 | """show copies between two revisions""" |
|
1836 | """show copies between two revisions""" | |
1837 | ctx1 = scmutil.revsingle(repo, rev1) |
|
1837 | ctx1 = scmutil.revsingle(repo, rev1) | |
1838 | ctx2 = scmutil.revsingle(repo, rev2) |
|
1838 | ctx2 = scmutil.revsingle(repo, rev2) | |
1839 | m = scmutil.match(ctx1, pats, opts) |
|
1839 | m = scmutil.match(ctx1, pats, opts) | |
1840 | for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()): |
|
1840 | for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()): | |
1841 | ui.write('%s -> %s\n' % (src, dst)) |
|
1841 | ui.write('%s -> %s\n' % (src, dst)) | |
1842 |
|
1842 | |||
1843 | @command('debugpeer', [], _('PATH'), norepo=True) |
|
1843 | @command('debugpeer', [], _('PATH'), norepo=True) | |
1844 | def debugpeer(ui, path): |
|
1844 | def debugpeer(ui, path): | |
1845 | """establish a connection to a peer repository""" |
|
1845 | """establish a connection to a peer repository""" | |
1846 | # Always enable peer request logging. Requires --debug to display |
|
1846 | # Always enable peer request logging. Requires --debug to display | |
1847 | # though. |
|
1847 | # though. | |
1848 | overrides = { |
|
1848 | overrides = { | |
1849 | ('devel', 'debug.peer-request'): True, |
|
1849 | ('devel', 'debug.peer-request'): True, | |
1850 | } |
|
1850 | } | |
1851 |
|
1851 | |||
1852 | with ui.configoverride(overrides): |
|
1852 | with ui.configoverride(overrides): | |
1853 | peer = hg.peer(ui, {}, path) |
|
1853 | peer = hg.peer(ui, {}, path) | |
1854 |
|
1854 | |||
1855 | local = peer.local() is not None |
|
1855 | local = peer.local() is not None | |
1856 | canpush = peer.canpush() |
|
1856 | canpush = peer.canpush() | |
1857 |
|
1857 | |||
1858 | ui.write(_('url: %s\n') % peer.url()) |
|
1858 | ui.write(_('url: %s\n') % peer.url()) | |
1859 | ui.write(_('local: %s\n') % (_('yes') if local else _('no'))) |
|
1859 | ui.write(_('local: %s\n') % (_('yes') if local else _('no'))) | |
1860 | ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no'))) |
|
1860 | ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no'))) | |
1861 |
|
1861 | |||
1862 | @command('debugpickmergetool', |
|
1862 | @command('debugpickmergetool', | |
1863 | [('r', 'rev', '', _('check for files in this revision'), _('REV')), |
|
1863 | [('r', 'rev', '', _('check for files in this revision'), _('REV')), | |
1864 | ('', 'changedelete', None, _('emulate merging change and delete')), |
|
1864 | ('', 'changedelete', None, _('emulate merging change and delete')), | |
1865 | ] + cmdutil.walkopts + cmdutil.mergetoolopts, |
|
1865 | ] + cmdutil.walkopts + cmdutil.mergetoolopts, | |
1866 | _('[PATTERN]...'), |
|
1866 | _('[PATTERN]...'), | |
1867 | inferrepo=True) |
|
1867 | inferrepo=True) | |
1868 | def debugpickmergetool(ui, repo, *pats, **opts): |
|
1868 | def debugpickmergetool(ui, repo, *pats, **opts): | |
1869 | """examine which merge tool is chosen for specified file |
|
1869 | """examine which merge tool is chosen for specified file | |
1870 |
|
1870 | |||
1871 | As described in :hg:`help merge-tools`, Mercurial examines |
|
1871 | As described in :hg:`help merge-tools`, Mercurial examines | |
1872 | configurations below in this order to decide which merge tool is |
|
1872 | configurations below in this order to decide which merge tool is | |
1873 | chosen for specified file. |
|
1873 | chosen for specified file. | |
1874 |
|
1874 | |||
1875 | 1. ``--tool`` option |
|
1875 | 1. ``--tool`` option | |
1876 | 2. ``HGMERGE`` environment variable |
|
1876 | 2. ``HGMERGE`` environment variable | |
1877 | 3. configurations in ``merge-patterns`` section |
|
1877 | 3. configurations in ``merge-patterns`` section | |
1878 | 4. configuration of ``ui.merge`` |
|
1878 | 4. configuration of ``ui.merge`` | |
1879 | 5. configurations in ``merge-tools`` section |
|
1879 | 5. configurations in ``merge-tools`` section | |
1880 | 6. ``hgmerge`` tool (for historical reason only) |
|
1880 | 6. ``hgmerge`` tool (for historical reason only) | |
1881 | 7. default tool for fallback (``:merge`` or ``:prompt``) |
|
1881 | 7. default tool for fallback (``:merge`` or ``:prompt``) | |
1882 |
|
1882 | |||
1883 | This command writes out examination result in the style below:: |
|
1883 | This command writes out examination result in the style below:: | |
1884 |
|
1884 | |||
1885 | FILE = MERGETOOL |
|
1885 | FILE = MERGETOOL | |
1886 |
|
1886 | |||
1887 | By default, all files known in the first parent context of the |
|
1887 | By default, all files known in the first parent context of the | |
1888 | working directory are examined. Use file patterns and/or -I/-X |
|
1888 | working directory are examined. Use file patterns and/or -I/-X | |
1889 | options to limit target files. -r/--rev is also useful to examine |
|
1889 | options to limit target files. -r/--rev is also useful to examine | |
1890 | files in another context without actual updating to it. |
|
1890 | files in another context without actual updating to it. | |
1891 |
|
1891 | |||
1892 | With --debug, this command shows warning messages while matching |
|
1892 | With --debug, this command shows warning messages while matching | |
1893 | against ``merge-patterns`` and so on, too. It is recommended to |
|
1893 | against ``merge-patterns`` and so on, too. It is recommended to | |
1894 | use this option with explicit file patterns and/or -I/-X options, |
|
1894 | use this option with explicit file patterns and/or -I/-X options, | |
1895 | because this option increases amount of output per file according |
|
1895 | because this option increases amount of output per file according | |
1896 | to configurations in hgrc. |
|
1896 | to configurations in hgrc. | |
1897 |
|
1897 | |||
1898 | With -v/--verbose, this command shows configurations below at |
|
1898 | With -v/--verbose, this command shows configurations below at | |
1899 | first (only if specified). |
|
1899 | first (only if specified). | |
1900 |
|
1900 | |||
1901 | - ``--tool`` option |
|
1901 | - ``--tool`` option | |
1902 | - ``HGMERGE`` environment variable |
|
1902 | - ``HGMERGE`` environment variable | |
1903 | - configuration of ``ui.merge`` |
|
1903 | - configuration of ``ui.merge`` | |
1904 |
|
1904 | |||
1905 | If merge tool is chosen before matching against |
|
1905 | If merge tool is chosen before matching against | |
1906 | ``merge-patterns``, this command can't show any helpful |
|
1906 | ``merge-patterns``, this command can't show any helpful | |
1907 | information, even with --debug. In such case, information above is |
|
1907 | information, even with --debug. In such case, information above is | |
1908 | useful to know why a merge tool is chosen. |
|
1908 | useful to know why a merge tool is chosen. | |
1909 | """ |
|
1909 | """ | |
1910 | opts = pycompat.byteskwargs(opts) |
|
1910 | opts = pycompat.byteskwargs(opts) | |
1911 | overrides = {} |
|
1911 | overrides = {} | |
1912 | if opts['tool']: |
|
1912 | if opts['tool']: | |
1913 | overrides[('ui', 'forcemerge')] = opts['tool'] |
|
1913 | overrides[('ui', 'forcemerge')] = opts['tool'] | |
1914 | ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool']))) |
|
1914 | ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool']))) | |
1915 |
|
1915 | |||
1916 | with ui.configoverride(overrides, 'debugmergepatterns'): |
|
1916 | with ui.configoverride(overrides, 'debugmergepatterns'): | |
1917 | hgmerge = encoding.environ.get("HGMERGE") |
|
1917 | hgmerge = encoding.environ.get("HGMERGE") | |
1918 | if hgmerge is not None: |
|
1918 | if hgmerge is not None: | |
1919 | ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge))) |
|
1919 | ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge))) | |
1920 | uimerge = ui.config("ui", "merge") |
|
1920 | uimerge = ui.config("ui", "merge") | |
1921 | if uimerge: |
|
1921 | if uimerge: | |
1922 | ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge))) |
|
1922 | ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge))) | |
1923 |
|
1923 | |||
1924 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
1924 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
1925 | m = scmutil.match(ctx, pats, opts) |
|
1925 | m = scmutil.match(ctx, pats, opts) | |
1926 | changedelete = opts['changedelete'] |
|
1926 | changedelete = opts['changedelete'] | |
1927 | for path in ctx.walk(m): |
|
1927 | for path in ctx.walk(m): | |
1928 | fctx = ctx[path] |
|
1928 | fctx = ctx[path] | |
1929 | try: |
|
1929 | try: | |
1930 | if not ui.debugflag: |
|
1930 | if not ui.debugflag: | |
1931 | ui.pushbuffer(error=True) |
|
1931 | ui.pushbuffer(error=True) | |
1932 | tool, toolpath = filemerge._picktool(repo, ui, path, |
|
1932 | tool, toolpath = filemerge._picktool(repo, ui, path, | |
1933 | fctx.isbinary(), |
|
1933 | fctx.isbinary(), | |
1934 | 'l' in fctx.flags(), |
|
1934 | 'l' in fctx.flags(), | |
1935 | changedelete) |
|
1935 | changedelete) | |
1936 | finally: |
|
1936 | finally: | |
1937 | if not ui.debugflag: |
|
1937 | if not ui.debugflag: | |
1938 | ui.popbuffer() |
|
1938 | ui.popbuffer() | |
1939 | ui.write(('%s = %s\n') % (path, tool)) |
|
1939 | ui.write(('%s = %s\n') % (path, tool)) | |
1940 |
|
1940 | |||
1941 | @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
|
1941 | @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) | |
1942 | def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
|
1942 | def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): | |
1943 | '''access the pushkey key/value protocol |
|
1943 | '''access the pushkey key/value protocol | |
1944 |
|
1944 | |||
1945 | With two args, list the keys in the given namespace. |
|
1945 | With two args, list the keys in the given namespace. | |
1946 |
|
1946 | |||
1947 | With five args, set a key to new if it currently is set to old. |
|
1947 | With five args, set a key to new if it currently is set to old. | |
1948 | Reports success or failure. |
|
1948 | Reports success or failure. | |
1949 | ''' |
|
1949 | ''' | |
1950 |
|
1950 | |||
1951 | target = hg.peer(ui, {}, repopath) |
|
1951 | target = hg.peer(ui, {}, repopath) | |
1952 | if keyinfo: |
|
1952 | if keyinfo: | |
1953 | key, old, new = keyinfo |
|
1953 | key, old, new = keyinfo | |
1954 | with target.commandexecutor() as e: |
|
1954 | with target.commandexecutor() as e: | |
1955 | r = e.callcommand('pushkey', { |
|
1955 | r = e.callcommand('pushkey', { | |
1956 | 'namespace': namespace, |
|
1956 | 'namespace': namespace, | |
1957 | 'key': key, |
|
1957 | 'key': key, | |
1958 | 'old': old, |
|
1958 | 'old': old, | |
1959 | 'new': new, |
|
1959 | 'new': new, | |
1960 | }).result() |
|
1960 | }).result() | |
1961 |
|
1961 | |||
1962 | ui.status(pycompat.bytestr(r) + '\n') |
|
1962 | ui.status(pycompat.bytestr(r) + '\n') | |
1963 | return not r |
|
1963 | return not r | |
1964 | else: |
|
1964 | else: | |
1965 | for k, v in sorted(target.listkeys(namespace).iteritems()): |
|
1965 | for k, v in sorted(target.listkeys(namespace).iteritems()): | |
1966 | ui.write("%s\t%s\n" % (stringutil.escapestr(k), |
|
1966 | ui.write("%s\t%s\n" % (stringutil.escapestr(k), | |
1967 | stringutil.escapestr(v))) |
|
1967 | stringutil.escapestr(v))) | |
1968 |
|
1968 | |||
1969 | @command('debugpvec', [], _('A B')) |
|
1969 | @command('debugpvec', [], _('A B')) | |
1970 | def debugpvec(ui, repo, a, b=None): |
|
1970 | def debugpvec(ui, repo, a, b=None): | |
1971 | ca = scmutil.revsingle(repo, a) |
|
1971 | ca = scmutil.revsingle(repo, a) | |
1972 | cb = scmutil.revsingle(repo, b) |
|
1972 | cb = scmutil.revsingle(repo, b) | |
1973 | pa = pvec.ctxpvec(ca) |
|
1973 | pa = pvec.ctxpvec(ca) | |
1974 | pb = pvec.ctxpvec(cb) |
|
1974 | pb = pvec.ctxpvec(cb) | |
1975 | if pa == pb: |
|
1975 | if pa == pb: | |
1976 | rel = "=" |
|
1976 | rel = "=" | |
1977 | elif pa > pb: |
|
1977 | elif pa > pb: | |
1978 | rel = ">" |
|
1978 | rel = ">" | |
1979 | elif pa < pb: |
|
1979 | elif pa < pb: | |
1980 | rel = "<" |
|
1980 | rel = "<" | |
1981 | elif pa | pb: |
|
1981 | elif pa | pb: | |
1982 | rel = "|" |
|
1982 | rel = "|" | |
1983 | ui.write(_("a: %s\n") % pa) |
|
1983 | ui.write(_("a: %s\n") % pa) | |
1984 | ui.write(_("b: %s\n") % pb) |
|
1984 | ui.write(_("b: %s\n") % pb) | |
1985 | ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
|
1985 | ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) | |
1986 | ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % |
|
1986 | ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % | |
1987 | (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), |
|
1987 | (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), | |
1988 | pa.distance(pb), rel)) |
|
1988 | pa.distance(pb), rel)) | |
1989 |
|
1989 | |||
1990 | @command('debugrebuilddirstate|debugrebuildstate', |
|
1990 | @command('debugrebuilddirstate|debugrebuildstate', | |
1991 | [('r', 'rev', '', _('revision to rebuild to'), _('REV')), |
|
1991 | [('r', 'rev', '', _('revision to rebuild to'), _('REV')), | |
1992 | ('', 'minimal', None, _('only rebuild files that are inconsistent with ' |
|
1992 | ('', 'minimal', None, _('only rebuild files that are inconsistent with ' | |
1993 | 'the working copy parent')), |
|
1993 | 'the working copy parent')), | |
1994 | ], |
|
1994 | ], | |
1995 | _('[-r REV]')) |
|
1995 | _('[-r REV]')) | |
1996 | def debugrebuilddirstate(ui, repo, rev, **opts): |
|
1996 | def debugrebuilddirstate(ui, repo, rev, **opts): | |
1997 | """rebuild the dirstate as it would look like for the given revision |
|
1997 | """rebuild the dirstate as it would look like for the given revision | |
1998 |
|
1998 | |||
1999 | If no revision is specified the first current parent will be used. |
|
1999 | If no revision is specified the first current parent will be used. | |
2000 |
|
2000 | |||
2001 | The dirstate will be set to the files of the given revision. |
|
2001 | The dirstate will be set to the files of the given revision. | |
2002 | The actual working directory content or existing dirstate |
|
2002 | The actual working directory content or existing dirstate | |
2003 | information such as adds or removes is not considered. |
|
2003 | information such as adds or removes is not considered. | |
2004 |
|
2004 | |||
2005 | ``minimal`` will only rebuild the dirstate status for files that claim to be |
|
2005 | ``minimal`` will only rebuild the dirstate status for files that claim to be | |
2006 | tracked but are not in the parent manifest, or that exist in the parent |
|
2006 | tracked but are not in the parent manifest, or that exist in the parent | |
2007 | manifest but are not in the dirstate. It will not change adds, removes, or |
|
2007 | manifest but are not in the dirstate. It will not change adds, removes, or | |
2008 | modified files that are in the working copy parent. |
|
2008 | modified files that are in the working copy parent. | |
2009 |
|
2009 | |||
2010 | One use of this command is to make the next :hg:`status` invocation |
|
2010 | One use of this command is to make the next :hg:`status` invocation | |
2011 | check the actual file content. |
|
2011 | check the actual file content. | |
2012 | """ |
|
2012 | """ | |
2013 | ctx = scmutil.revsingle(repo, rev) |
|
2013 | ctx = scmutil.revsingle(repo, rev) | |
2014 | with repo.wlock(): |
|
2014 | with repo.wlock(): | |
2015 | dirstate = repo.dirstate |
|
2015 | dirstate = repo.dirstate | |
2016 | changedfiles = None |
|
2016 | changedfiles = None | |
2017 | # See command doc for what minimal does. |
|
2017 | # See command doc for what minimal does. | |
2018 | if opts.get(r'minimal'): |
|
2018 | if opts.get(r'minimal'): | |
2019 | manifestfiles = set(ctx.manifest().keys()) |
|
2019 | manifestfiles = set(ctx.manifest().keys()) | |
2020 | dirstatefiles = set(dirstate) |
|
2020 | dirstatefiles = set(dirstate) | |
2021 | manifestonly = manifestfiles - dirstatefiles |
|
2021 | manifestonly = manifestfiles - dirstatefiles | |
2022 | dsonly = dirstatefiles - manifestfiles |
|
2022 | dsonly = dirstatefiles - manifestfiles | |
2023 | dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
|
2023 | dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') | |
2024 | changedfiles = manifestonly | dsnotadded |
|
2024 | changedfiles = manifestonly | dsnotadded | |
2025 |
|
2025 | |||
2026 | dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) |
|
2026 | dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) | |
2027 |
|
2027 | |||
2028 | @command('debugrebuildfncache', [], '') |
|
2028 | @command('debugrebuildfncache', [], '') | |
2029 | def debugrebuildfncache(ui, repo): |
|
2029 | def debugrebuildfncache(ui, repo): | |
2030 | """rebuild the fncache file""" |
|
2030 | """rebuild the fncache file""" | |
2031 | repair.rebuildfncache(ui, repo) |
|
2031 | repair.rebuildfncache(ui, repo) | |
2032 |
|
2032 | |||
2033 | @command('debugrename', |
|
2033 | @command('debugrename', | |
2034 | [('r', 'rev', '', _('revision to debug'), _('REV'))], |
|
2034 | [('r', 'rev', '', _('revision to debug'), _('REV'))], | |
2035 | _('[-r REV] [FILE]...')) |
|
2035 | _('[-r REV] [FILE]...')) | |
2036 | def debugrename(ui, repo, *pats, **opts): |
|
2036 | def debugrename(ui, repo, *pats, **opts): | |
2037 | """dump rename information""" |
|
2037 | """dump rename information""" | |
2038 |
|
2038 | |||
2039 | opts = pycompat.byteskwargs(opts) |
|
2039 | opts = pycompat.byteskwargs(opts) | |
2040 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
2040 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
2041 | m = scmutil.match(ctx, pats, opts) |
|
2041 | m = scmutil.match(ctx, pats, opts) | |
2042 | for abs in ctx.walk(m): |
|
2042 | for abs in ctx.walk(m): | |
2043 | fctx = ctx[abs] |
|
2043 | fctx = ctx[abs] | |
2044 | o = fctx.filelog().renamed(fctx.filenode()) |
|
2044 | o = fctx.filelog().renamed(fctx.filenode()) | |
2045 | rel = repo.pathto(abs) |
|
2045 | rel = repo.pathto(abs) | |
2046 | if o: |
|
2046 | if o: | |
2047 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
|
2047 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | |
2048 | else: |
|
2048 | else: | |
2049 | ui.write(_("%s not renamed\n") % rel) |
|
2049 | ui.write(_("%s not renamed\n") % rel) | |
2050 |
|
2050 | |||
2051 | @command('debugrevlog', cmdutil.debugrevlogopts + |
|
2051 | @command('debugrevlog', cmdutil.debugrevlogopts + | |
2052 | [('d', 'dump', False, _('dump index data'))], |
|
2052 | [('d', 'dump', False, _('dump index data'))], | |
2053 | _('-c|-m|FILE'), |
|
2053 | _('-c|-m|FILE'), | |
2054 | optionalrepo=True) |
|
2054 | optionalrepo=True) | |
2055 | def debugrevlog(ui, repo, file_=None, **opts): |
|
2055 | def debugrevlog(ui, repo, file_=None, **opts): | |
2056 | """show data and statistics about a revlog""" |
|
2056 | """show data and statistics about a revlog""" | |
2057 | opts = pycompat.byteskwargs(opts) |
|
2057 | opts = pycompat.byteskwargs(opts) | |
2058 | r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
|
2058 | r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) | |
2059 |
|
2059 | |||
2060 | if opts.get("dump"): |
|
2060 | if opts.get("dump"): | |
2061 | numrevs = len(r) |
|
2061 | numrevs = len(r) | |
2062 | ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
|
2062 | ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" | |
2063 | " rawsize totalsize compression heads chainlen\n")) |
|
2063 | " rawsize totalsize compression heads chainlen\n")) | |
2064 | ts = 0 |
|
2064 | ts = 0 | |
2065 | heads = set() |
|
2065 | heads = set() | |
2066 |
|
2066 | |||
2067 | for rev in pycompat.xrange(numrevs): |
|
2067 | for rev in pycompat.xrange(numrevs): | |
2068 | dbase = r.deltaparent(rev) |
|
2068 | dbase = r.deltaparent(rev) | |
2069 | if dbase == -1: |
|
2069 | if dbase == -1: | |
2070 | dbase = rev |
|
2070 | dbase = rev | |
2071 | cbase = r.chainbase(rev) |
|
2071 | cbase = r.chainbase(rev) | |
2072 | clen = r.chainlen(rev) |
|
2072 | clen = r.chainlen(rev) | |
2073 | p1, p2 = r.parentrevs(rev) |
|
2073 | p1, p2 = r.parentrevs(rev) | |
2074 | rs = r.rawsize(rev) |
|
2074 | rs = r.rawsize(rev) | |
2075 | ts = ts + rs |
|
2075 | ts = ts + rs | |
2076 | heads -= set(r.parentrevs(rev)) |
|
2076 | heads -= set(r.parentrevs(rev)) | |
2077 | heads.add(rev) |
|
2077 | heads.add(rev) | |
2078 | try: |
|
2078 | try: | |
2079 | compression = ts / r.end(rev) |
|
2079 | compression = ts / r.end(rev) | |
2080 | except ZeroDivisionError: |
|
2080 | except ZeroDivisionError: | |
2081 | compression = 0 |
|
2081 | compression = 0 | |
2082 | ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
|
2082 | ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " | |
2083 | "%11d %5d %8d\n" % |
|
2083 | "%11d %5d %8d\n" % | |
2084 | (rev, p1, p2, r.start(rev), r.end(rev), |
|
2084 | (rev, p1, p2, r.start(rev), r.end(rev), | |
2085 | r.start(dbase), r.start(cbase), |
|
2085 | r.start(dbase), r.start(cbase), | |
2086 | r.start(p1), r.start(p2), |
|
2086 | r.start(p1), r.start(p2), | |
2087 | rs, ts, compression, len(heads), clen)) |
|
2087 | rs, ts, compression, len(heads), clen)) | |
2088 | return 0 |
|
2088 | return 0 | |
2089 |
|
2089 | |||
2090 | v = r.version |
|
2090 | v = r.version | |
2091 | format = v & 0xFFFF |
|
2091 | format = v & 0xFFFF | |
2092 | flags = [] |
|
2092 | flags = [] | |
2093 | gdelta = False |
|
2093 | gdelta = False | |
2094 | if v & revlog.FLAG_INLINE_DATA: |
|
2094 | if v & revlog.FLAG_INLINE_DATA: | |
2095 | flags.append('inline') |
|
2095 | flags.append('inline') | |
2096 | if v & revlog.FLAG_GENERALDELTA: |
|
2096 | if v & revlog.FLAG_GENERALDELTA: | |
2097 | gdelta = True |
|
2097 | gdelta = True | |
2098 | flags.append('generaldelta') |
|
2098 | flags.append('generaldelta') | |
2099 | if not flags: |
|
2099 | if not flags: | |
2100 | flags = ['(none)'] |
|
2100 | flags = ['(none)'] | |
2101 |
|
2101 | |||
2102 | ### tracks merge vs single parent |
|
2102 | ### tracks merge vs single parent | |
2103 | nummerges = 0 |
|
2103 | nummerges = 0 | |
2104 |
|
2104 | |||
2105 | ### tracks ways the "delta" are build |
|
2105 | ### tracks ways the "delta" are build | |
2106 | # nodelta |
|
2106 | # nodelta | |
2107 | numempty = 0 |
|
2107 | numempty = 0 | |
2108 | numemptytext = 0 |
|
2108 | numemptytext = 0 | |
2109 | numemptydelta = 0 |
|
2109 | numemptydelta = 0 | |
2110 | # full file content |
|
2110 | # full file content | |
2111 | numfull = 0 |
|
2111 | numfull = 0 | |
2112 | # intermediate snapshot against a prior snapshot |
|
2112 | # intermediate snapshot against a prior snapshot | |
2113 | numsemi = 0 |
|
2113 | numsemi = 0 | |
2114 | # snapshot count per depth |
|
2114 | # snapshot count per depth | |
2115 | numsnapdepth = collections.defaultdict(lambda: 0) |
|
2115 | numsnapdepth = collections.defaultdict(lambda: 0) | |
2116 | # delta against previous revision |
|
2116 | # delta against previous revision | |
2117 | numprev = 0 |
|
2117 | numprev = 0 | |
2118 | # delta against first or second parent (not prev) |
|
2118 | # delta against first or second parent (not prev) | |
2119 | nump1 = 0 |
|
2119 | nump1 = 0 | |
2120 | nump2 = 0 |
|
2120 | nump2 = 0 | |
2121 | # delta against neither prev nor parents |
|
2121 | # delta against neither prev nor parents | |
2122 | numother = 0 |
|
2122 | numother = 0 | |
2123 | # delta against prev that are also first or second parent |
|
2123 | # delta against prev that are also first or second parent | |
2124 | # (details of `numprev`) |
|
2124 | # (details of `numprev`) | |
2125 | nump1prev = 0 |
|
2125 | nump1prev = 0 | |
2126 | nump2prev = 0 |
|
2126 | nump2prev = 0 | |
2127 |
|
2127 | |||
2128 | # data about delta chain of each revs |
|
2128 | # data about delta chain of each revs | |
2129 | chainlengths = [] |
|
2129 | chainlengths = [] | |
2130 | chainbases = [] |
|
2130 | chainbases = [] | |
2131 | chainspans = [] |
|
2131 | chainspans = [] | |
2132 |
|
2132 | |||
2133 | # data about each revision |
|
2133 | # data about each revision | |
2134 | datasize = [None, 0, 0] |
|
2134 | datasize = [None, 0, 0] | |
2135 | fullsize = [None, 0, 0] |
|
2135 | fullsize = [None, 0, 0] | |
2136 | semisize = [None, 0, 0] |
|
2136 | semisize = [None, 0, 0] | |
2137 | # snapshot count per depth |
|
2137 | # snapshot count per depth | |
2138 | snapsizedepth = collections.defaultdict(lambda: [None, 0, 0]) |
|
2138 | snapsizedepth = collections.defaultdict(lambda: [None, 0, 0]) | |
2139 | deltasize = [None, 0, 0] |
|
2139 | deltasize = [None, 0, 0] | |
2140 | chunktypecounts = {} |
|
2140 | chunktypecounts = {} | |
2141 | chunktypesizes = {} |
|
2141 | chunktypesizes = {} | |
2142 |
|
2142 | |||
2143 | def addsize(size, l): |
|
2143 | def addsize(size, l): | |
2144 | if l[0] is None or size < l[0]: |
|
2144 | if l[0] is None or size < l[0]: | |
2145 | l[0] = size |
|
2145 | l[0] = size | |
2146 | if size > l[1]: |
|
2146 | if size > l[1]: | |
2147 | l[1] = size |
|
2147 | l[1] = size | |
2148 | l[2] += size |
|
2148 | l[2] += size | |
2149 |
|
2149 | |||
2150 | numrevs = len(r) |
|
2150 | numrevs = len(r) | |
2151 | for rev in pycompat.xrange(numrevs): |
|
2151 | for rev in pycompat.xrange(numrevs): | |
2152 | p1, p2 = r.parentrevs(rev) |
|
2152 | p1, p2 = r.parentrevs(rev) | |
2153 | delta = r.deltaparent(rev) |
|
2153 | delta = r.deltaparent(rev) | |
2154 | if format > 0: |
|
2154 | if format > 0: | |
2155 | addsize(r.rawsize(rev), datasize) |
|
2155 | addsize(r.rawsize(rev), datasize) | |
2156 | if p2 != nullrev: |
|
2156 | if p2 != nullrev: | |
2157 | nummerges += 1 |
|
2157 | nummerges += 1 | |
2158 | size = r.length(rev) |
|
2158 | size = r.length(rev) | |
2159 | if delta == nullrev: |
|
2159 | if delta == nullrev: | |
2160 | chainlengths.append(0) |
|
2160 | chainlengths.append(0) | |
2161 | chainbases.append(r.start(rev)) |
|
2161 | chainbases.append(r.start(rev)) | |
2162 | chainspans.append(size) |
|
2162 | chainspans.append(size) | |
2163 | if size == 0: |
|
2163 | if size == 0: | |
2164 | numempty += 1 |
|
2164 | numempty += 1 | |
2165 | numemptytext += 1 |
|
2165 | numemptytext += 1 | |
2166 | else: |
|
2166 | else: | |
2167 | numfull += 1 |
|
2167 | numfull += 1 | |
2168 | numsnapdepth[0] += 1 |
|
2168 | numsnapdepth[0] += 1 | |
2169 | addsize(size, fullsize) |
|
2169 | addsize(size, fullsize) | |
2170 | addsize(size, snapsizedepth[0]) |
|
2170 | addsize(size, snapsizedepth[0]) | |
2171 | else: |
|
2171 | else: | |
2172 | chainlengths.append(chainlengths[delta] + 1) |
|
2172 | chainlengths.append(chainlengths[delta] + 1) | |
2173 | baseaddr = chainbases[delta] |
|
2173 | baseaddr = chainbases[delta] | |
2174 | revaddr = r.start(rev) |
|
2174 | revaddr = r.start(rev) | |
2175 | chainbases.append(baseaddr) |
|
2175 | chainbases.append(baseaddr) | |
2176 | chainspans.append((revaddr - baseaddr) + size) |
|
2176 | chainspans.append((revaddr - baseaddr) + size) | |
2177 | if size == 0: |
|
2177 | if size == 0: | |
2178 | numempty += 1 |
|
2178 | numempty += 1 | |
2179 | numemptydelta += 1 |
|
2179 | numemptydelta += 1 | |
2180 | elif r.issnapshot(rev): |
|
2180 | elif r.issnapshot(rev): | |
2181 | addsize(size, semisize) |
|
2181 | addsize(size, semisize) | |
2182 | numsemi += 1 |
|
2182 | numsemi += 1 | |
2183 | depth = r.snapshotdepth(rev) |
|
2183 | depth = r.snapshotdepth(rev) | |
2184 | numsnapdepth[depth] += 1 |
|
2184 | numsnapdepth[depth] += 1 | |
2185 | addsize(size, snapsizedepth[depth]) |
|
2185 | addsize(size, snapsizedepth[depth]) | |
2186 | else: |
|
2186 | else: | |
2187 | addsize(size, deltasize) |
|
2187 | addsize(size, deltasize) | |
2188 | if delta == rev - 1: |
|
2188 | if delta == rev - 1: | |
2189 | numprev += 1 |
|
2189 | numprev += 1 | |
2190 | if delta == p1: |
|
2190 | if delta == p1: | |
2191 | nump1prev += 1 |
|
2191 | nump1prev += 1 | |
2192 | elif delta == p2: |
|
2192 | elif delta == p2: | |
2193 | nump2prev += 1 |
|
2193 | nump2prev += 1 | |
2194 | elif delta == p1: |
|
2194 | elif delta == p1: | |
2195 | nump1 += 1 |
|
2195 | nump1 += 1 | |
2196 | elif delta == p2: |
|
2196 | elif delta == p2: | |
2197 | nump2 += 1 |
|
2197 | nump2 += 1 | |
2198 | elif delta != nullrev: |
|
2198 | elif delta != nullrev: | |
2199 | numother += 1 |
|
2199 | numother += 1 | |
2200 |
|
2200 | |||
2201 | # Obtain data on the raw chunks in the revlog. |
|
2201 | # Obtain data on the raw chunks in the revlog. | |
2202 | if util.safehasattr(r, '_getsegmentforrevs'): |
|
2202 | if util.safehasattr(r, '_getsegmentforrevs'): | |
2203 | segment = r._getsegmentforrevs(rev, rev)[1] |
|
2203 | segment = r._getsegmentforrevs(rev, rev)[1] | |
2204 | else: |
|
2204 | else: | |
2205 | segment = r._revlog._getsegmentforrevs(rev, rev)[1] |
|
2205 | segment = r._revlog._getsegmentforrevs(rev, rev)[1] | |
2206 | if segment: |
|
2206 | if segment: | |
2207 | chunktype = bytes(segment[0:1]) |
|
2207 | chunktype = bytes(segment[0:1]) | |
2208 | else: |
|
2208 | else: | |
2209 | chunktype = 'empty' |
|
2209 | chunktype = 'empty' | |
2210 |
|
2210 | |||
2211 | if chunktype not in chunktypecounts: |
|
2211 | if chunktype not in chunktypecounts: | |
2212 | chunktypecounts[chunktype] = 0 |
|
2212 | chunktypecounts[chunktype] = 0 | |
2213 | chunktypesizes[chunktype] = 0 |
|
2213 | chunktypesizes[chunktype] = 0 | |
2214 |
|
2214 | |||
2215 | chunktypecounts[chunktype] += 1 |
|
2215 | chunktypecounts[chunktype] += 1 | |
2216 | chunktypesizes[chunktype] += size |
|
2216 | chunktypesizes[chunktype] += size | |
2217 |
|
2217 | |||
2218 | # Adjust size min value for empty cases |
|
2218 | # Adjust size min value for empty cases | |
2219 | for size in (datasize, fullsize, semisize, deltasize): |
|
2219 | for size in (datasize, fullsize, semisize, deltasize): | |
2220 | if size[0] is None: |
|
2220 | if size[0] is None: | |
2221 | size[0] = 0 |
|
2221 | size[0] = 0 | |
2222 |
|
2222 | |||
2223 | numdeltas = numrevs - numfull - numempty - numsemi |
|
2223 | numdeltas = numrevs - numfull - numempty - numsemi | |
2224 | numoprev = numprev - nump1prev - nump2prev |
|
2224 | numoprev = numprev - nump1prev - nump2prev | |
2225 | totalrawsize = datasize[2] |
|
2225 | totalrawsize = datasize[2] | |
2226 | datasize[2] /= numrevs |
|
2226 | datasize[2] /= numrevs | |
2227 | fulltotal = fullsize[2] |
|
2227 | fulltotal = fullsize[2] | |
2228 | fullsize[2] /= numfull |
|
2228 | fullsize[2] /= numfull | |
2229 | semitotal = semisize[2] |
|
2229 | semitotal = semisize[2] | |
2230 | snaptotal = {} |
|
2230 | snaptotal = {} | |
2231 | if numsemi > 0: |
|
2231 | if numsemi > 0: | |
2232 | semisize[2] /= numsemi |
|
2232 | semisize[2] /= numsemi | |
2233 | for depth in snapsizedepth: |
|
2233 | for depth in snapsizedepth: | |
2234 | snaptotal[depth] = snapsizedepth[depth][2] |
|
2234 | snaptotal[depth] = snapsizedepth[depth][2] | |
2235 | snapsizedepth[depth][2] /= numsnapdepth[depth] |
|
2235 | snapsizedepth[depth][2] /= numsnapdepth[depth] | |
2236 |
|
2236 | |||
2237 | deltatotal = deltasize[2] |
|
2237 | deltatotal = deltasize[2] | |
2238 | if numdeltas > 0: |
|
2238 | if numdeltas > 0: | |
2239 | deltasize[2] /= numdeltas |
|
2239 | deltasize[2] /= numdeltas | |
2240 | totalsize = fulltotal + semitotal + deltatotal |
|
2240 | totalsize = fulltotal + semitotal + deltatotal | |
2241 | avgchainlen = sum(chainlengths) / numrevs |
|
2241 | avgchainlen = sum(chainlengths) / numrevs | |
2242 | maxchainlen = max(chainlengths) |
|
2242 | maxchainlen = max(chainlengths) | |
2243 | maxchainspan = max(chainspans) |
|
2243 | maxchainspan = max(chainspans) | |
2244 | compratio = 1 |
|
2244 | compratio = 1 | |
2245 | if totalsize: |
|
2245 | if totalsize: | |
2246 | compratio = totalrawsize / totalsize |
|
2246 | compratio = totalrawsize / totalsize | |
2247 |
|
2247 | |||
2248 | basedfmtstr = '%%%dd\n' |
|
2248 | basedfmtstr = '%%%dd\n' | |
2249 | basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
|
2249 | basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' | |
2250 |
|
2250 | |||
2251 | def dfmtstr(max): |
|
2251 | def dfmtstr(max): | |
2252 | return basedfmtstr % len(str(max)) |
|
2252 | return basedfmtstr % len(str(max)) | |
2253 | def pcfmtstr(max, padding=0): |
|
2253 | def pcfmtstr(max, padding=0): | |
2254 | return basepcfmtstr % (len(str(max)), ' ' * padding) |
|
2254 | return basepcfmtstr % (len(str(max)), ' ' * padding) | |
2255 |
|
2255 | |||
2256 | def pcfmt(value, total): |
|
2256 | def pcfmt(value, total): | |
2257 | if total: |
|
2257 | if total: | |
2258 | return (value, 100 * float(value) / total) |
|
2258 | return (value, 100 * float(value) / total) | |
2259 | else: |
|
2259 | else: | |
2260 | return value, 100.0 |
|
2260 | return value, 100.0 | |
2261 |
|
2261 | |||
2262 | ui.write(('format : %d\n') % format) |
|
2262 | ui.write(('format : %d\n') % format) | |
2263 | ui.write(('flags : %s\n') % ', '.join(flags)) |
|
2263 | ui.write(('flags : %s\n') % ', '.join(flags)) | |
2264 |
|
2264 | |||
2265 | ui.write('\n') |
|
2265 | ui.write('\n') | |
2266 | fmt = pcfmtstr(totalsize) |
|
2266 | fmt = pcfmtstr(totalsize) | |
2267 | fmt2 = dfmtstr(totalsize) |
|
2267 | fmt2 = dfmtstr(totalsize) | |
2268 | ui.write(('revisions : ') + fmt2 % numrevs) |
|
2268 | ui.write(('revisions : ') + fmt2 % numrevs) | |
2269 | ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) |
|
2269 | ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) | |
2270 | ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) |
|
2270 | ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) | |
2271 | ui.write(('revisions : ') + fmt2 % numrevs) |
|
2271 | ui.write(('revisions : ') + fmt2 % numrevs) | |
2272 | ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs)) |
|
2272 | ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs)) | |
2273 | ui.write((' text : ') |
|
2273 | ui.write((' text : ') | |
2274 | + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)) |
|
2274 | + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)) | |
2275 | ui.write((' delta : ') |
|
2275 | ui.write((' delta : ') | |
2276 | + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)) |
|
2276 | + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)) | |
2277 | ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs)) |
|
2277 | ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs)) | |
2278 | for depth in sorted(numsnapdepth): |
|
2278 | for depth in sorted(numsnapdepth): | |
2279 | ui.write((' lvl-%-3d : ' % depth) |
|
2279 | ui.write((' lvl-%-3d : ' % depth) | |
2280 | + fmt % pcfmt(numsnapdepth[depth], numrevs)) |
|
2280 | + fmt % pcfmt(numsnapdepth[depth], numrevs)) | |
2281 | ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
|
2281 | ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) | |
2282 | ui.write(('revision size : ') + fmt2 % totalsize) |
|
2282 | ui.write(('revision size : ') + fmt2 % totalsize) | |
2283 | ui.write((' snapshot : ') |
|
2283 | ui.write((' snapshot : ') | |
2284 | + fmt % pcfmt(fulltotal + semitotal, totalsize)) |
|
2284 | + fmt % pcfmt(fulltotal + semitotal, totalsize)) | |
2285 | for depth in sorted(numsnapdepth): |
|
2285 | for depth in sorted(numsnapdepth): | |
2286 | ui.write((' lvl-%-3d : ' % depth) |
|
2286 | ui.write((' lvl-%-3d : ' % depth) | |
2287 | + fmt % pcfmt(snaptotal[depth], totalsize)) |
|
2287 | + fmt % pcfmt(snaptotal[depth], totalsize)) | |
2288 | ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
|
2288 | ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) | |
2289 |
|
2289 | |||
2290 | def fmtchunktype(chunktype): |
|
2290 | def fmtchunktype(chunktype): | |
2291 | if chunktype == 'empty': |
|
2291 | if chunktype == 'empty': | |
2292 | return ' %s : ' % chunktype |
|
2292 | return ' %s : ' % chunktype | |
2293 | elif chunktype in pycompat.bytestr(string.ascii_letters): |
|
2293 | elif chunktype in pycompat.bytestr(string.ascii_letters): | |
2294 | return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) |
|
2294 | return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) | |
2295 | else: |
|
2295 | else: | |
2296 | return ' 0x%s : ' % hex(chunktype) |
|
2296 | return ' 0x%s : ' % hex(chunktype) | |
2297 |
|
2297 | |||
2298 | ui.write('\n') |
|
2298 | ui.write('\n') | |
2299 | ui.write(('chunks : ') + fmt2 % numrevs) |
|
2299 | ui.write(('chunks : ') + fmt2 % numrevs) | |
2300 | for chunktype in sorted(chunktypecounts): |
|
2300 | for chunktype in sorted(chunktypecounts): | |
2301 | ui.write(fmtchunktype(chunktype)) |
|
2301 | ui.write(fmtchunktype(chunktype)) | |
2302 | ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
|
2302 | ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) | |
2303 | ui.write(('chunks size : ') + fmt2 % totalsize) |
|
2303 | ui.write(('chunks size : ') + fmt2 % totalsize) | |
2304 | for chunktype in sorted(chunktypecounts): |
|
2304 | for chunktype in sorted(chunktypecounts): | |
2305 | ui.write(fmtchunktype(chunktype)) |
|
2305 | ui.write(fmtchunktype(chunktype)) | |
2306 | ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) |
|
2306 | ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) | |
2307 |
|
2307 | |||
2308 | ui.write('\n') |
|
2308 | ui.write('\n') | |
2309 | fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) |
|
2309 | fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) | |
2310 | ui.write(('avg chain length : ') + fmt % avgchainlen) |
|
2310 | ui.write(('avg chain length : ') + fmt % avgchainlen) | |
2311 | ui.write(('max chain length : ') + fmt % maxchainlen) |
|
2311 | ui.write(('max chain length : ') + fmt % maxchainlen) | |
2312 | ui.write(('max chain reach : ') + fmt % maxchainspan) |
|
2312 | ui.write(('max chain reach : ') + fmt % maxchainspan) | |
2313 | ui.write(('compression ratio : ') + fmt % compratio) |
|
2313 | ui.write(('compression ratio : ') + fmt % compratio) | |
2314 |
|
2314 | |||
2315 | if format > 0: |
|
2315 | if format > 0: | |
2316 | ui.write('\n') |
|
2316 | ui.write('\n') | |
2317 | ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
|
2317 | ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') | |
2318 | % tuple(datasize)) |
|
2318 | % tuple(datasize)) | |
2319 | ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') |
|
2319 | ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') | |
2320 | % tuple(fullsize)) |
|
2320 | % tuple(fullsize)) | |
2321 | ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n') |
|
2321 | ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n') | |
2322 | % tuple(semisize)) |
|
2322 | % tuple(semisize)) | |
2323 | for depth in sorted(snapsizedepth): |
|
2323 | for depth in sorted(snapsizedepth): | |
2324 | if depth == 0: |
|
2324 | if depth == 0: | |
2325 | continue |
|
2325 | continue | |
2326 | ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n') |
|
2326 | ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n') | |
2327 | % ((depth,) + tuple(snapsizedepth[depth]))) |
|
2327 | % ((depth,) + tuple(snapsizedepth[depth]))) | |
2328 | ui.write(('delta size (min/max/avg) : %d / %d / %d\n') |
|
2328 | ui.write(('delta size (min/max/avg) : %d / %d / %d\n') | |
2329 | % tuple(deltasize)) |
|
2329 | % tuple(deltasize)) | |
2330 |
|
2330 | |||
2331 | if numdeltas > 0: |
|
2331 | if numdeltas > 0: | |
2332 | ui.write('\n') |
|
2332 | ui.write('\n') | |
2333 | fmt = pcfmtstr(numdeltas) |
|
2333 | fmt = pcfmtstr(numdeltas) | |
2334 | fmt2 = pcfmtstr(numdeltas, 4) |
|
2334 | fmt2 = pcfmtstr(numdeltas, 4) | |
2335 | ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) |
|
2335 | ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) | |
2336 | if numprev > 0: |
|
2336 | if numprev > 0: | |
2337 | ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, |
|
2337 | ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, | |
2338 | numprev)) |
|
2338 | numprev)) | |
2339 | ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, |
|
2339 | ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, | |
2340 | numprev)) |
|
2340 | numprev)) | |
2341 | ui.write((' other : ') + fmt2 % pcfmt(numoprev, |
|
2341 | ui.write((' other : ') + fmt2 % pcfmt(numoprev, | |
2342 | numprev)) |
|
2342 | numprev)) | |
2343 | if gdelta: |
|
2343 | if gdelta: | |
2344 | ui.write(('deltas against p1 : ') |
|
2344 | ui.write(('deltas against p1 : ') | |
2345 | + fmt % pcfmt(nump1, numdeltas)) |
|
2345 | + fmt % pcfmt(nump1, numdeltas)) | |
2346 | ui.write(('deltas against p2 : ') |
|
2346 | ui.write(('deltas against p2 : ') | |
2347 | + fmt % pcfmt(nump2, numdeltas)) |
|
2347 | + fmt % pcfmt(nump2, numdeltas)) | |
2348 | ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
|
2348 | ui.write(('deltas against other : ') + fmt % pcfmt(numother, | |
2349 | numdeltas)) |
|
2349 | numdeltas)) | |
2350 |
|
2350 | |||
2351 | @command('debugrevlogindex', cmdutil.debugrevlogopts + |
|
2351 | @command('debugrevlogindex', cmdutil.debugrevlogopts + | |
2352 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
|
2352 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | |
2353 | _('[-f FORMAT] -c|-m|FILE'), |
|
2353 | _('[-f FORMAT] -c|-m|FILE'), | |
2354 | optionalrepo=True) |
|
2354 | optionalrepo=True) | |
2355 | def debugrevlogindex(ui, repo, file_=None, **opts): |
|
2355 | def debugrevlogindex(ui, repo, file_=None, **opts): | |
2356 | """dump the contents of a revlog index""" |
|
2356 | """dump the contents of a revlog index""" | |
2357 | opts = pycompat.byteskwargs(opts) |
|
2357 | opts = pycompat.byteskwargs(opts) | |
2358 | r = cmdutil.openrevlog(repo, 'debugrevlogindex', file_, opts) |
|
2358 | r = cmdutil.openrevlog(repo, 'debugrevlogindex', file_, opts) | |
2359 | format = opts.get('format', 0) |
|
2359 | format = opts.get('format', 0) | |
2360 | if format not in (0, 1): |
|
2360 | if format not in (0, 1): | |
2361 | raise error.Abort(_("unknown format %d") % format) |
|
2361 | raise error.Abort(_("unknown format %d") % format) | |
2362 |
|
2362 | |||
2363 | if ui.debugflag: |
|
2363 | if ui.debugflag: | |
2364 | shortfn = hex |
|
2364 | shortfn = hex | |
2365 | else: |
|
2365 | else: | |
2366 | shortfn = short |
|
2366 | shortfn = short | |
2367 |
|
2367 | |||
2368 | # There might not be anything in r, so have a sane default |
|
2368 | # There might not be anything in r, so have a sane default | |
2369 | idlen = 12 |
|
2369 | idlen = 12 | |
2370 | for i in r: |
|
2370 | for i in r: | |
2371 | idlen = len(shortfn(r.node(i))) |
|
2371 | idlen = len(shortfn(r.node(i))) | |
2372 | break |
|
2372 | break | |
2373 |
|
2373 | |||
2374 | if format == 0: |
|
2374 | if format == 0: | |
2375 | if ui.verbose: |
|
2375 | if ui.verbose: | |
2376 | ui.write((" rev offset length linkrev" |
|
2376 | ui.write((" rev offset length linkrev" | |
2377 | " %s %s p2\n") % ("nodeid".ljust(idlen), |
|
2377 | " %s %s p2\n") % ("nodeid".ljust(idlen), | |
2378 | "p1".ljust(idlen))) |
|
2378 | "p1".ljust(idlen))) | |
2379 | else: |
|
2379 | else: | |
2380 | ui.write((" rev linkrev %s %s p2\n") % ( |
|
2380 | ui.write((" rev linkrev %s %s p2\n") % ( | |
2381 | "nodeid".ljust(idlen), "p1".ljust(idlen))) |
|
2381 | "nodeid".ljust(idlen), "p1".ljust(idlen))) | |
2382 | elif format == 1: |
|
2382 | elif format == 1: | |
2383 | if ui.verbose: |
|
2383 | if ui.verbose: | |
2384 | ui.write((" rev flag offset length size link p1" |
|
2384 | ui.write((" rev flag offset length size link p1" | |
2385 | " p2 %s\n") % "nodeid".rjust(idlen)) |
|
2385 | " p2 %s\n") % "nodeid".rjust(idlen)) | |
2386 | else: |
|
2386 | else: | |
2387 | ui.write((" rev flag size link p1 p2 %s\n") % |
|
2387 | ui.write((" rev flag size link p1 p2 %s\n") % | |
2388 | "nodeid".rjust(idlen)) |
|
2388 | "nodeid".rjust(idlen)) | |
2389 |
|
2389 | |||
2390 | for i in r: |
|
2390 | for i in r: | |
2391 | node = r.node(i) |
|
2391 | node = r.node(i) | |
2392 | if format == 0: |
|
2392 | if format == 0: | |
2393 | try: |
|
2393 | try: | |
2394 | pp = r.parents(node) |
|
2394 | pp = r.parents(node) | |
2395 | except Exception: |
|
2395 | except Exception: | |
2396 | pp = [nullid, nullid] |
|
2396 | pp = [nullid, nullid] | |
2397 | if ui.verbose: |
|
2397 | if ui.verbose: | |
2398 | ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % ( |
|
2398 | ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % ( | |
2399 | i, r.start(i), r.length(i), r.linkrev(i), |
|
2399 | i, r.start(i), r.length(i), r.linkrev(i), | |
2400 | shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
|
2400 | shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) | |
2401 | else: |
|
2401 | else: | |
2402 | ui.write("% 6d % 7d %s %s %s\n" % ( |
|
2402 | ui.write("% 6d % 7d %s %s %s\n" % ( | |
2403 | i, r.linkrev(i), shortfn(node), shortfn(pp[0]), |
|
2403 | i, r.linkrev(i), shortfn(node), shortfn(pp[0]), | |
2404 | shortfn(pp[1]))) |
|
2404 | shortfn(pp[1]))) | |
2405 | elif format == 1: |
|
2405 | elif format == 1: | |
2406 | pr = r.parentrevs(i) |
|
2406 | pr = r.parentrevs(i) | |
2407 | if ui.verbose: |
|
2407 | if ui.verbose: | |
2408 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % ( |
|
2408 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % ( | |
2409 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
|
2409 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), | |
2410 | r.linkrev(i), pr[0], pr[1], shortfn(node))) |
|
2410 | r.linkrev(i), pr[0], pr[1], shortfn(node))) | |
2411 | else: |
|
2411 | else: | |
2412 | ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % ( |
|
2412 | ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % ( | |
2413 | i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1], |
|
2413 | i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1], | |
2414 | shortfn(node))) |
|
2414 | shortfn(node))) | |
2415 |
|
2415 | |||
2416 | @command('debugrevspec', |
|
2416 | @command('debugrevspec', | |
2417 | [('', 'optimize', None, |
|
2417 | [('', 'optimize', None, | |
2418 | _('print parsed tree after optimizing (DEPRECATED)')), |
|
2418 | _('print parsed tree after optimizing (DEPRECATED)')), | |
2419 | ('', 'show-revs', True, _('print list of result revisions (default)')), |
|
2419 | ('', 'show-revs', True, _('print list of result revisions (default)')), | |
2420 | ('s', 'show-set', None, _('print internal representation of result set')), |
|
2420 | ('s', 'show-set', None, _('print internal representation of result set')), | |
2421 | ('p', 'show-stage', [], |
|
2421 | ('p', 'show-stage', [], | |
2422 | _('print parsed tree at the given stage'), _('NAME')), |
|
2422 | _('print parsed tree at the given stage'), _('NAME')), | |
2423 | ('', 'no-optimized', False, _('evaluate tree without optimization')), |
|
2423 | ('', 'no-optimized', False, _('evaluate tree without optimization')), | |
2424 | ('', 'verify-optimized', False, _('verify optimized result')), |
|
2424 | ('', 'verify-optimized', False, _('verify optimized result')), | |
2425 | ], |
|
2425 | ], | |
2426 | ('REVSPEC')) |
|
2426 | ('REVSPEC')) | |
2427 | def debugrevspec(ui, repo, expr, **opts): |
|
2427 | def debugrevspec(ui, repo, expr, **opts): | |
2428 | """parse and apply a revision specification |
|
2428 | """parse and apply a revision specification | |
2429 |
|
2429 | |||
2430 | Use -p/--show-stage option to print the parsed tree at the given stages. |
|
2430 | Use -p/--show-stage option to print the parsed tree at the given stages. | |
2431 | Use -p all to print tree at every stage. |
|
2431 | Use -p all to print tree at every stage. | |
2432 |
|
2432 | |||
2433 | Use --no-show-revs option with -s or -p to print only the set |
|
2433 | Use --no-show-revs option with -s or -p to print only the set | |
2434 | representation or the parsed tree respectively. |
|
2434 | representation or the parsed tree respectively. | |
2435 |
|
2435 | |||
2436 | Use --verify-optimized to compare the optimized result with the unoptimized |
|
2436 | Use --verify-optimized to compare the optimized result with the unoptimized | |
2437 | one. Returns 1 if the optimized result differs. |
|
2437 | one. Returns 1 if the optimized result differs. | |
2438 | """ |
|
2438 | """ | |
2439 | opts = pycompat.byteskwargs(opts) |
|
2439 | opts = pycompat.byteskwargs(opts) | |
2440 | aliases = ui.configitems('revsetalias') |
|
2440 | aliases = ui.configitems('revsetalias') | |
2441 | stages = [ |
|
2441 | stages = [ | |
2442 | ('parsed', lambda tree: tree), |
|
2442 | ('parsed', lambda tree: tree), | |
2443 | ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases, |
|
2443 | ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases, | |
2444 | ui.warn)), |
|
2444 | ui.warn)), | |
2445 | ('concatenated', revsetlang.foldconcat), |
|
2445 | ('concatenated', revsetlang.foldconcat), | |
2446 | ('analyzed', revsetlang.analyze), |
|
2446 | ('analyzed', revsetlang.analyze), | |
2447 | ('optimized', revsetlang.optimize), |
|
2447 | ('optimized', revsetlang.optimize), | |
2448 | ] |
|
2448 | ] | |
2449 | if opts['no_optimized']: |
|
2449 | if opts['no_optimized']: | |
2450 | stages = stages[:-1] |
|
2450 | stages = stages[:-1] | |
2451 | if opts['verify_optimized'] and opts['no_optimized']: |
|
2451 | if opts['verify_optimized'] and opts['no_optimized']: | |
2452 | raise error.Abort(_('cannot use --verify-optimized with ' |
|
2452 | raise error.Abort(_('cannot use --verify-optimized with ' | |
2453 | '--no-optimized')) |
|
2453 | '--no-optimized')) | |
2454 | stagenames = set(n for n, f in stages) |
|
2454 | stagenames = set(n for n, f in stages) | |
2455 |
|
2455 | |||
2456 | showalways = set() |
|
2456 | showalways = set() | |
2457 | showchanged = set() |
|
2457 | showchanged = set() | |
2458 | if ui.verbose and not opts['show_stage']: |
|
2458 | if ui.verbose and not opts['show_stage']: | |
2459 | # show parsed tree by --verbose (deprecated) |
|
2459 | # show parsed tree by --verbose (deprecated) | |
2460 | showalways.add('parsed') |
|
2460 | showalways.add('parsed') | |
2461 | showchanged.update(['expanded', 'concatenated']) |
|
2461 | showchanged.update(['expanded', 'concatenated']) | |
2462 | if opts['optimize']: |
|
2462 | if opts['optimize']: | |
2463 | showalways.add('optimized') |
|
2463 | showalways.add('optimized') | |
2464 | if opts['show_stage'] and opts['optimize']: |
|
2464 | if opts['show_stage'] and opts['optimize']: | |
2465 | raise error.Abort(_('cannot use --optimize with --show-stage')) |
|
2465 | raise error.Abort(_('cannot use --optimize with --show-stage')) | |
2466 | if opts['show_stage'] == ['all']: |
|
2466 | if opts['show_stage'] == ['all']: | |
2467 | showalways.update(stagenames) |
|
2467 | showalways.update(stagenames) | |
2468 | else: |
|
2468 | else: | |
2469 | for n in opts['show_stage']: |
|
2469 | for n in opts['show_stage']: | |
2470 | if n not in stagenames: |
|
2470 | if n not in stagenames: | |
2471 | raise error.Abort(_('invalid stage name: %s') % n) |
|
2471 | raise error.Abort(_('invalid stage name: %s') % n) | |
2472 | showalways.update(opts['show_stage']) |
|
2472 | showalways.update(opts['show_stage']) | |
2473 |
|
2473 | |||
2474 | treebystage = {} |
|
2474 | treebystage = {} | |
2475 | printedtree = None |
|
2475 | printedtree = None | |
2476 | tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) |
|
2476 | tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) | |
2477 | for n, f in stages: |
|
2477 | for n, f in stages: | |
2478 | treebystage[n] = tree = f(tree) |
|
2478 | treebystage[n] = tree = f(tree) | |
2479 | if n in showalways or (n in showchanged and tree != printedtree): |
|
2479 | if n in showalways or (n in showchanged and tree != printedtree): | |
2480 | if opts['show_stage'] or n != 'parsed': |
|
2480 | if opts['show_stage'] or n != 'parsed': | |
2481 | ui.write(("* %s:\n") % n) |
|
2481 | ui.write(("* %s:\n") % n) | |
2482 | ui.write(revsetlang.prettyformat(tree), "\n") |
|
2482 | ui.write(revsetlang.prettyformat(tree), "\n") | |
2483 | printedtree = tree |
|
2483 | printedtree = tree | |
2484 |
|
2484 | |||
2485 | if opts['verify_optimized']: |
|
2485 | if opts['verify_optimized']: | |
2486 | arevs = revset.makematcher(treebystage['analyzed'])(repo) |
|
2486 | arevs = revset.makematcher(treebystage['analyzed'])(repo) | |
2487 | brevs = revset.makematcher(treebystage['optimized'])(repo) |
|
2487 | brevs = revset.makematcher(treebystage['optimized'])(repo) | |
2488 | if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
|
2488 | if opts['show_set'] or (opts['show_set'] is None and ui.verbose): | |
2489 | ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n") |
|
2489 | ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n") | |
2490 | ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n") |
|
2490 | ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n") | |
2491 | arevs = list(arevs) |
|
2491 | arevs = list(arevs) | |
2492 | brevs = list(brevs) |
|
2492 | brevs = list(brevs) | |
2493 | if arevs == brevs: |
|
2493 | if arevs == brevs: | |
2494 | return 0 |
|
2494 | return 0 | |
2495 | ui.write(('--- analyzed\n'), label='diff.file_a') |
|
2495 | ui.write(('--- analyzed\n'), label='diff.file_a') | |
2496 | ui.write(('+++ optimized\n'), label='diff.file_b') |
|
2496 | ui.write(('+++ optimized\n'), label='diff.file_b') | |
2497 | sm = difflib.SequenceMatcher(None, arevs, brevs) |
|
2497 | sm = difflib.SequenceMatcher(None, arevs, brevs) | |
2498 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
2498 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | |
2499 | if tag in (r'delete', r'replace'): |
|
2499 | if tag in (r'delete', r'replace'): | |
2500 | for c in arevs[alo:ahi]: |
|
2500 | for c in arevs[alo:ahi]: | |
2501 | ui.write('-%d\n' % c, label='diff.deleted') |
|
2501 | ui.write('-%d\n' % c, label='diff.deleted') | |
2502 | if tag in (r'insert', r'replace'): |
|
2502 | if tag in (r'insert', r'replace'): | |
2503 | for c in brevs[blo:bhi]: |
|
2503 | for c in brevs[blo:bhi]: | |
2504 | ui.write('+%d\n' % c, label='diff.inserted') |
|
2504 | ui.write('+%d\n' % c, label='diff.inserted') | |
2505 | if tag == r'equal': |
|
2505 | if tag == r'equal': | |
2506 | for c in arevs[alo:ahi]: |
|
2506 | for c in arevs[alo:ahi]: | |
2507 | ui.write(' %d\n' % c) |
|
2507 | ui.write(' %d\n' % c) | |
2508 | return 1 |
|
2508 | return 1 | |
2509 |
|
2509 | |||
2510 | func = revset.makematcher(tree) |
|
2510 | func = revset.makematcher(tree) | |
2511 | revs = func(repo) |
|
2511 | revs = func(repo) | |
2512 | if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
|
2512 | if opts['show_set'] or (opts['show_set'] is None and ui.verbose): | |
2513 | ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n") |
|
2513 | ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n") | |
2514 | if not opts['show_revs']: |
|
2514 | if not opts['show_revs']: | |
2515 | return |
|
2515 | return | |
2516 | for c in revs: |
|
2516 | for c in revs: | |
2517 | ui.write("%d\n" % c) |
|
2517 | ui.write("%d\n" % c) | |
2518 |
|
2518 | |||
2519 | @command('debugserve', [ |
|
2519 | @command('debugserve', [ | |
2520 | ('', 'sshstdio', False, _('run an SSH server bound to process handles')), |
|
2520 | ('', 'sshstdio', False, _('run an SSH server bound to process handles')), | |
2521 | ('', 'logiofd', '', _('file descriptor to log server I/O to')), |
|
2521 | ('', 'logiofd', '', _('file descriptor to log server I/O to')), | |
2522 | ('', 'logiofile', '', _('file to log server I/O to')), |
|
2522 | ('', 'logiofile', '', _('file to log server I/O to')), | |
2523 | ], '') |
|
2523 | ], '') | |
2524 | def debugserve(ui, repo, **opts): |
|
2524 | def debugserve(ui, repo, **opts): | |
2525 | """run a server with advanced settings |
|
2525 | """run a server with advanced settings | |
2526 |
|
2526 | |||
2527 | This command is similar to :hg:`serve`. It exists partially as a |
|
2527 | This command is similar to :hg:`serve`. It exists partially as a | |
2528 | workaround to the fact that ``hg serve --stdio`` must have specific |
|
2528 | workaround to the fact that ``hg serve --stdio`` must have specific | |
2529 | arguments for security reasons. |
|
2529 | arguments for security reasons. | |
2530 | """ |
|
2530 | """ | |
2531 | opts = pycompat.byteskwargs(opts) |
|
2531 | opts = pycompat.byteskwargs(opts) | |
2532 |
|
2532 | |||
2533 | if not opts['sshstdio']: |
|
2533 | if not opts['sshstdio']: | |
2534 | raise error.Abort(_('only --sshstdio is currently supported')) |
|
2534 | raise error.Abort(_('only --sshstdio is currently supported')) | |
2535 |
|
2535 | |||
2536 | logfh = None |
|
2536 | logfh = None | |
2537 |
|
2537 | |||
2538 | if opts['logiofd'] and opts['logiofile']: |
|
2538 | if opts['logiofd'] and opts['logiofile']: | |
2539 | raise error.Abort(_('cannot use both --logiofd and --logiofile')) |
|
2539 | raise error.Abort(_('cannot use both --logiofd and --logiofile')) | |
2540 |
|
2540 | |||
2541 | if opts['logiofd']: |
|
2541 | if opts['logiofd']: | |
2542 | # Line buffered because output is line based. |
|
2542 | # Line buffered because output is line based. | |
2543 | try: |
|
2543 | try: | |
2544 | logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) |
|
2544 | logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) | |
2545 | except OSError as e: |
|
2545 | except OSError as e: | |
2546 | if e.errno != errno.ESPIPE: |
|
2546 | if e.errno != errno.ESPIPE: | |
2547 | raise |
|
2547 | raise | |
2548 | # can't seek a pipe, so `ab` mode fails on py3 |
|
2548 | # can't seek a pipe, so `ab` mode fails on py3 | |
2549 | logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) |
|
2549 | logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) | |
2550 | elif opts['logiofile']: |
|
2550 | elif opts['logiofile']: | |
2551 | logfh = open(opts['logiofile'], 'ab', 1) |
|
2551 | logfh = open(opts['logiofile'], 'ab', 1) | |
2552 |
|
2552 | |||
2553 | s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
|
2553 | s = wireprotoserver.sshserver(ui, repo, logfh=logfh) | |
2554 | s.serve_forever() |
|
2554 | s.serve_forever() | |
2555 |
|
2555 | |||
2556 | @command('debugsetparents', [], _('REV1 [REV2]')) |
|
2556 | @command('debugsetparents', [], _('REV1 [REV2]')) | |
2557 | def debugsetparents(ui, repo, rev1, rev2=None): |
|
2557 | def debugsetparents(ui, repo, rev1, rev2=None): | |
2558 | """manually set the parents of the current working directory |
|
2558 | """manually set the parents of the current working directory | |
2559 |
|
2559 | |||
2560 | This is useful for writing repository conversion tools, but should |
|
2560 | This is useful for writing repository conversion tools, but should | |
2561 | be used with care. For example, neither the working directory nor the |
|
2561 | be used with care. For example, neither the working directory nor the | |
2562 | dirstate is updated, so file status may be incorrect after running this |
|
2562 | dirstate is updated, so file status may be incorrect after running this | |
2563 | command. |
|
2563 | command. | |
2564 |
|
2564 | |||
2565 | Returns 0 on success. |
|
2565 | Returns 0 on success. | |
2566 | """ |
|
2566 | """ | |
2567 |
|
2567 | |||
2568 | node1 = scmutil.revsingle(repo, rev1).node() |
|
2568 | node1 = scmutil.revsingle(repo, rev1).node() | |
2569 | node2 = scmutil.revsingle(repo, rev2, 'null').node() |
|
2569 | node2 = scmutil.revsingle(repo, rev2, 'null').node() | |
2570 |
|
2570 | |||
2571 | with repo.wlock(): |
|
2571 | with repo.wlock(): | |
2572 | repo.setparents(node1, node2) |
|
2572 | repo.setparents(node1, node2) | |
2573 |
|
2573 | |||
2574 | @command('debugssl', [], '[SOURCE]', optionalrepo=True) |
|
2574 | @command('debugssl', [], '[SOURCE]', optionalrepo=True) | |
2575 | def debugssl(ui, repo, source=None, **opts): |
|
2575 | def debugssl(ui, repo, source=None, **opts): | |
2576 | '''test a secure connection to a server |
|
2576 | '''test a secure connection to a server | |
2577 |
|
2577 | |||
2578 | This builds the certificate chain for the server on Windows, installing the |
|
2578 | This builds the certificate chain for the server on Windows, installing the | |
2579 | missing intermediates and trusted root via Windows Update if necessary. It |
|
2579 | missing intermediates and trusted root via Windows Update if necessary. It | |
2580 | does nothing on other platforms. |
|
2580 | does nothing on other platforms. | |
2581 |
|
2581 | |||
2582 | If SOURCE is omitted, the 'default' path will be used. If a URL is given, |
|
2582 | If SOURCE is omitted, the 'default' path will be used. If a URL is given, | |
2583 | that server is used. See :hg:`help urls` for more information. |
|
2583 | that server is used. See :hg:`help urls` for more information. | |
2584 |
|
2584 | |||
2585 | If the update succeeds, retry the original operation. Otherwise, the cause |
|
2585 | If the update succeeds, retry the original operation. Otherwise, the cause | |
2586 | of the SSL error is likely another issue. |
|
2586 | of the SSL error is likely another issue. | |
2587 | ''' |
|
2587 | ''' | |
2588 | if not pycompat.iswindows: |
|
2588 | if not pycompat.iswindows: | |
2589 | raise error.Abort(_('certificate chain building is only possible on ' |
|
2589 | raise error.Abort(_('certificate chain building is only possible on ' | |
2590 | 'Windows')) |
|
2590 | 'Windows')) | |
2591 |
|
2591 | |||
2592 | if not source: |
|
2592 | if not source: | |
2593 | if not repo: |
|
2593 | if not repo: | |
2594 | raise error.Abort(_("there is no Mercurial repository here, and no " |
|
2594 | raise error.Abort(_("there is no Mercurial repository here, and no " | |
2595 | "server specified")) |
|
2595 | "server specified")) | |
2596 | source = "default" |
|
2596 | source = "default" | |
2597 |
|
2597 | |||
2598 | source, branches = hg.parseurl(ui.expandpath(source)) |
|
2598 | source, branches = hg.parseurl(ui.expandpath(source)) | |
2599 | url = util.url(source) |
|
2599 | url = util.url(source) | |
2600 |
|
2600 | |||
2601 | defaultport = {'https': 443, 'ssh': 22} |
|
2601 | defaultport = {'https': 443, 'ssh': 22} | |
2602 | if url.scheme in defaultport: |
|
2602 | if url.scheme in defaultport: | |
2603 | try: |
|
2603 | try: | |
2604 | addr = (url.host, int(url.port or defaultport[url.scheme])) |
|
2604 | addr = (url.host, int(url.port or defaultport[url.scheme])) | |
2605 | except ValueError: |
|
2605 | except ValueError: | |
2606 | raise error.Abort(_("malformed port number in URL")) |
|
2606 | raise error.Abort(_("malformed port number in URL")) | |
2607 | else: |
|
2607 | else: | |
2608 | raise error.Abort(_("only https and ssh connections are supported")) |
|
2608 | raise error.Abort(_("only https and ssh connections are supported")) | |
2609 |
|
2609 | |||
2610 | from . import win32 |
|
2610 | from . import win32 | |
2611 |
|
2611 | |||
2612 | s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS, |
|
2612 | s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS, | |
2613 | cert_reqs=ssl.CERT_NONE, ca_certs=None) |
|
2613 | cert_reqs=ssl.CERT_NONE, ca_certs=None) | |
2614 |
|
2614 | |||
2615 | try: |
|
2615 | try: | |
2616 | s.connect(addr) |
|
2616 | s.connect(addr) | |
2617 | cert = s.getpeercert(True) |
|
2617 | cert = s.getpeercert(True) | |
2618 |
|
2618 | |||
2619 | ui.status(_('checking the certificate chain for %s\n') % url.host) |
|
2619 | ui.status(_('checking the certificate chain for %s\n') % url.host) | |
2620 |
|
2620 | |||
2621 | complete = win32.checkcertificatechain(cert, build=False) |
|
2621 | complete = win32.checkcertificatechain(cert, build=False) | |
2622 |
|
2622 | |||
2623 | if not complete: |
|
2623 | if not complete: | |
2624 | ui.status(_('certificate chain is incomplete, updating... ')) |
|
2624 | ui.status(_('certificate chain is incomplete, updating... ')) | |
2625 |
|
2625 | |||
2626 | if not win32.checkcertificatechain(cert): |
|
2626 | if not win32.checkcertificatechain(cert): | |
2627 | ui.status(_('failed.\n')) |
|
2627 | ui.status(_('failed.\n')) | |
2628 | else: |
|
2628 | else: | |
2629 | ui.status(_('done.\n')) |
|
2629 | ui.status(_('done.\n')) | |
2630 | else: |
|
2630 | else: | |
2631 | ui.status(_('full certificate chain is available\n')) |
|
2631 | ui.status(_('full certificate chain is available\n')) | |
2632 | finally: |
|
2632 | finally: | |
2633 | s.close() |
|
2633 | s.close() | |
2634 |
|
2634 | |||
2635 | @command('debugsub', |
|
2635 | @command('debugsub', | |
2636 | [('r', 'rev', '', |
|
2636 | [('r', 'rev', '', | |
2637 | _('revision to check'), _('REV'))], |
|
2637 | _('revision to check'), _('REV'))], | |
2638 | _('[-r REV] [REV]')) |
|
2638 | _('[-r REV] [REV]')) | |
2639 | def debugsub(ui, repo, rev=None): |
|
2639 | def debugsub(ui, repo, rev=None): | |
2640 | ctx = scmutil.revsingle(repo, rev, None) |
|
2640 | ctx = scmutil.revsingle(repo, rev, None) | |
2641 | for k, v in sorted(ctx.substate.items()): |
|
2641 | for k, v in sorted(ctx.substate.items()): | |
2642 | ui.write(('path %s\n') % k) |
|
2642 | ui.write(('path %s\n') % k) | |
2643 | ui.write((' source %s\n') % v[0]) |
|
2643 | ui.write((' source %s\n') % v[0]) | |
2644 | ui.write((' revision %s\n') % v[1]) |
|
2644 | ui.write((' revision %s\n') % v[1]) | |
2645 |
|
2645 | |||
2646 | @command('debugsuccessorssets', |
|
2646 | @command('debugsuccessorssets', | |
2647 | [('', 'closest', False, _('return closest successors sets only'))], |
|
2647 | [('', 'closest', False, _('return closest successors sets only'))], | |
2648 | _('[REV]')) |
|
2648 | _('[REV]')) | |
2649 | def debugsuccessorssets(ui, repo, *revs, **opts): |
|
2649 | def debugsuccessorssets(ui, repo, *revs, **opts): | |
2650 | """show set of successors for revision |
|
2650 | """show set of successors for revision | |
2651 |
|
2651 | |||
2652 | A successors set of changeset A is a consistent group of revisions that |
|
2652 | A successors set of changeset A is a consistent group of revisions that | |
2653 | succeed A. It contains non-obsolete changesets only unless closests |
|
2653 | succeed A. It contains non-obsolete changesets only unless closests | |
2654 | successors set is set. |
|
2654 | successors set is set. | |
2655 |
|
2655 | |||
2656 | In most cases a changeset A has a single successors set containing a single |
|
2656 | In most cases a changeset A has a single successors set containing a single | |
2657 | successor (changeset A replaced by A'). |
|
2657 | successor (changeset A replaced by A'). | |
2658 |
|
2658 | |||
2659 | A changeset that is made obsolete with no successors are called "pruned". |
|
2659 | A changeset that is made obsolete with no successors are called "pruned". | |
2660 | Such changesets have no successors sets at all. |
|
2660 | Such changesets have no successors sets at all. | |
2661 |
|
2661 | |||
2662 | A changeset that has been "split" will have a successors set containing |
|
2662 | A changeset that has been "split" will have a successors set containing | |
2663 | more than one successor. |
|
2663 | more than one successor. | |
2664 |
|
2664 | |||
2665 | A changeset that has been rewritten in multiple different ways is called |
|
2665 | A changeset that has been rewritten in multiple different ways is called | |
2666 | "divergent". Such changesets have multiple successor sets (each of which |
|
2666 | "divergent". Such changesets have multiple successor sets (each of which | |
2667 | may also be split, i.e. have multiple successors). |
|
2667 | may also be split, i.e. have multiple successors). | |
2668 |
|
2668 | |||
2669 | Results are displayed as follows:: |
|
2669 | Results are displayed as follows:: | |
2670 |
|
2670 | |||
2671 | <rev1> |
|
2671 | <rev1> | |
2672 | <successors-1A> |
|
2672 | <successors-1A> | |
2673 | <rev2> |
|
2673 | <rev2> | |
2674 | <successors-2A> |
|
2674 | <successors-2A> | |
2675 | <successors-2B1> <successors-2B2> <successors-2B3> |
|
2675 | <successors-2B1> <successors-2B2> <successors-2B3> | |
2676 |
|
2676 | |||
2677 | Here rev2 has two possible (i.e. divergent) successors sets. The first |
|
2677 | Here rev2 has two possible (i.e. divergent) successors sets. The first | |
2678 | holds one element, whereas the second holds three (i.e. the changeset has |
|
2678 | holds one element, whereas the second holds three (i.e. the changeset has | |
2679 | been split). |
|
2679 | been split). | |
2680 | """ |
|
2680 | """ | |
2681 | # passed to successorssets caching computation from one call to another |
|
2681 | # passed to successorssets caching computation from one call to another | |
2682 | cache = {} |
|
2682 | cache = {} | |
2683 | ctx2str = bytes |
|
2683 | ctx2str = bytes | |
2684 | node2str = short |
|
2684 | node2str = short | |
2685 | for rev in scmutil.revrange(repo, revs): |
|
2685 | for rev in scmutil.revrange(repo, revs): | |
2686 | ctx = repo[rev] |
|
2686 | ctx = repo[rev] | |
2687 | ui.write('%s\n'% ctx2str(ctx)) |
|
2687 | ui.write('%s\n'% ctx2str(ctx)) | |
2688 | for succsset in obsutil.successorssets(repo, ctx.node(), |
|
2688 | for succsset in obsutil.successorssets(repo, ctx.node(), | |
2689 | closest=opts[r'closest'], |
|
2689 | closest=opts[r'closest'], | |
2690 | cache=cache): |
|
2690 | cache=cache): | |
2691 | if succsset: |
|
2691 | if succsset: | |
2692 | ui.write(' ') |
|
2692 | ui.write(' ') | |
2693 | ui.write(node2str(succsset[0])) |
|
2693 | ui.write(node2str(succsset[0])) | |
2694 | for node in succsset[1:]: |
|
2694 | for node in succsset[1:]: | |
2695 | ui.write(' ') |
|
2695 | ui.write(' ') | |
2696 | ui.write(node2str(node)) |
|
2696 | ui.write(node2str(node)) | |
2697 | ui.write('\n') |
|
2697 | ui.write('\n') | |
2698 |
|
2698 | |||
2699 | @command('debugtemplate', |
|
2699 | @command('debugtemplate', | |
2700 | [('r', 'rev', [], _('apply template on changesets'), _('REV')), |
|
2700 | [('r', 'rev', [], _('apply template on changesets'), _('REV')), | |
2701 | ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], |
|
2701 | ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], | |
2702 | _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
|
2702 | _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), | |
2703 | optionalrepo=True) |
|
2703 | optionalrepo=True) | |
2704 | def debugtemplate(ui, repo, tmpl, **opts): |
|
2704 | def debugtemplate(ui, repo, tmpl, **opts): | |
2705 | """parse and apply a template |
|
2705 | """parse and apply a template | |
2706 |
|
2706 | |||
2707 | If -r/--rev is given, the template is processed as a log template and |
|
2707 | If -r/--rev is given, the template is processed as a log template and | |
2708 | applied to the given changesets. Otherwise, it is processed as a generic |
|
2708 | applied to the given changesets. Otherwise, it is processed as a generic | |
2709 | template. |
|
2709 | template. | |
2710 |
|
2710 | |||
2711 | Use --verbose to print the parsed tree. |
|
2711 | Use --verbose to print the parsed tree. | |
2712 | """ |
|
2712 | """ | |
2713 | revs = None |
|
2713 | revs = None | |
2714 | if opts[r'rev']: |
|
2714 | if opts[r'rev']: | |
2715 | if repo is None: |
|
2715 | if repo is None: | |
2716 | raise error.RepoError(_('there is no Mercurial repository here ' |
|
2716 | raise error.RepoError(_('there is no Mercurial repository here ' | |
2717 | '(.hg not found)')) |
|
2717 | '(.hg not found)')) | |
2718 | revs = scmutil.revrange(repo, opts[r'rev']) |
|
2718 | revs = scmutil.revrange(repo, opts[r'rev']) | |
2719 |
|
2719 | |||
2720 | props = {} |
|
2720 | props = {} | |
2721 | for d in opts[r'define']: |
|
2721 | for d in opts[r'define']: | |
2722 | try: |
|
2722 | try: | |
2723 | k, v = (e.strip() for e in d.split('=', 1)) |
|
2723 | k, v = (e.strip() for e in d.split('=', 1)) | |
2724 | if not k or k == 'ui': |
|
2724 | if not k or k == 'ui': | |
2725 | raise ValueError |
|
2725 | raise ValueError | |
2726 | props[k] = v |
|
2726 | props[k] = v | |
2727 | except ValueError: |
|
2727 | except ValueError: | |
2728 | raise error.Abort(_('malformed keyword definition: %s') % d) |
|
2728 | raise error.Abort(_('malformed keyword definition: %s') % d) | |
2729 |
|
2729 | |||
2730 | if ui.verbose: |
|
2730 | if ui.verbose: | |
2731 | aliases = ui.configitems('templatealias') |
|
2731 | aliases = ui.configitems('templatealias') | |
2732 | tree = templater.parse(tmpl) |
|
2732 | tree = templater.parse(tmpl) | |
2733 | ui.note(templater.prettyformat(tree), '\n') |
|
2733 | ui.note(templater.prettyformat(tree), '\n') | |
2734 | newtree = templater.expandaliases(tree, aliases) |
|
2734 | newtree = templater.expandaliases(tree, aliases) | |
2735 | if newtree != tree: |
|
2735 | if newtree != tree: | |
2736 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
|
2736 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') | |
2737 |
|
2737 | |||
2738 | if revs is None: |
|
2738 | if revs is None: | |
2739 | tres = formatter.templateresources(ui, repo) |
|
2739 | tres = formatter.templateresources(ui, repo) | |
2740 | t = formatter.maketemplater(ui, tmpl, resources=tres) |
|
2740 | t = formatter.maketemplater(ui, tmpl, resources=tres) | |
2741 | if ui.verbose: |
|
2741 | if ui.verbose: | |
2742 | kwds, funcs = t.symbolsuseddefault() |
|
2742 | kwds, funcs = t.symbolsuseddefault() | |
2743 | ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
|
2743 | ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) | |
2744 | ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
|
2744 | ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) | |
2745 | ui.write(t.renderdefault(props)) |
|
2745 | ui.write(t.renderdefault(props)) | |
2746 | else: |
|
2746 | else: | |
2747 | displayer = logcmdutil.maketemplater(ui, repo, tmpl) |
|
2747 | displayer = logcmdutil.maketemplater(ui, repo, tmpl) | |
2748 | if ui.verbose: |
|
2748 | if ui.verbose: | |
2749 | kwds, funcs = displayer.t.symbolsuseddefault() |
|
2749 | kwds, funcs = displayer.t.symbolsuseddefault() | |
2750 | ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
|
2750 | ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) | |
2751 | ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
|
2751 | ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) | |
2752 | for r in revs: |
|
2752 | for r in revs: | |
2753 | displayer.show(repo[r], **pycompat.strkwargs(props)) |
|
2753 | displayer.show(repo[r], **pycompat.strkwargs(props)) | |
2754 | displayer.close() |
|
2754 | displayer.close() | |
2755 |
|
2755 | |||
2756 | @command('debuguigetpass', [ |
|
2756 | @command('debuguigetpass', [ | |
2757 | ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
|
2757 | ('p', 'prompt', '', _('prompt text'), _('TEXT')), | |
2758 | ], _('[-p TEXT]'), norepo=True) |
|
2758 | ], _('[-p TEXT]'), norepo=True) | |
2759 | def debuguigetpass(ui, prompt=''): |
|
2759 | def debuguigetpass(ui, prompt=''): | |
2760 | """show prompt to type password""" |
|
2760 | """show prompt to type password""" | |
2761 | r = ui.getpass(prompt) |
|
2761 | r = ui.getpass(prompt) | |
2762 | ui.write(('respose: %s\n') % r) |
|
2762 | ui.write(('respose: %s\n') % r) | |
2763 |
|
2763 | |||
2764 | @command('debuguiprompt', [ |
|
2764 | @command('debuguiprompt', [ | |
2765 | ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
|
2765 | ('p', 'prompt', '', _('prompt text'), _('TEXT')), | |
2766 | ], _('[-p TEXT]'), norepo=True) |
|
2766 | ], _('[-p TEXT]'), norepo=True) | |
2767 | def debuguiprompt(ui, prompt=''): |
|
2767 | def debuguiprompt(ui, prompt=''): | |
2768 | """show plain prompt""" |
|
2768 | """show plain prompt""" | |
2769 | r = ui.prompt(prompt) |
|
2769 | r = ui.prompt(prompt) | |
2770 | ui.write(('response: %s\n') % r) |
|
2770 | ui.write(('response: %s\n') % r) | |
2771 |
|
2771 | |||
2772 | @command('debugupdatecaches', []) |
|
2772 | @command('debugupdatecaches', []) | |
2773 | def debugupdatecaches(ui, repo, *pats, **opts): |
|
2773 | def debugupdatecaches(ui, repo, *pats, **opts): | |
2774 | """warm all known caches in the repository""" |
|
2774 | """warm all known caches in the repository""" | |
2775 | with repo.wlock(), repo.lock(): |
|
2775 | with repo.wlock(), repo.lock(): | |
2776 | repo.updatecaches(full=True) |
|
2776 | repo.updatecaches(full=True) | |
2777 |
|
2777 | |||
2778 | @command('debugupgraderepo', [ |
|
2778 | @command('debugupgraderepo', [ | |
2779 | ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
|
2779 | ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), | |
2780 | ('', 'run', False, _('performs an upgrade')), |
|
2780 | ('', 'run', False, _('performs an upgrade')), | |
2781 | ('', 'backup', True, _('keep the old repository content around')), |
|
2781 | ('', 'backup', True, _('keep the old repository content around')), | |
2782 | ]) |
|
2782 | ]) | |
2783 | def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True): |
|
2783 | def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True): | |
2784 | """upgrade a repository to use different features |
|
2784 | """upgrade a repository to use different features | |
2785 |
|
2785 | |||
2786 | If no arguments are specified, the repository is evaluated for upgrade |
|
2786 | If no arguments are specified, the repository is evaluated for upgrade | |
2787 | and a list of problems and potential optimizations is printed. |
|
2787 | and a list of problems and potential optimizations is printed. | |
2788 |
|
2788 | |||
2789 | With ``--run``, a repository upgrade is performed. Behavior of the upgrade |
|
2789 | With ``--run``, a repository upgrade is performed. Behavior of the upgrade | |
2790 | can be influenced via additional arguments. More details will be provided |
|
2790 | can be influenced via additional arguments. More details will be provided | |
2791 | by the command output when run without ``--run``. |
|
2791 | by the command output when run without ``--run``. | |
2792 |
|
2792 | |||
2793 | During the upgrade, the repository will be locked and no writes will be |
|
2793 | During the upgrade, the repository will be locked and no writes will be | |
2794 | allowed. |
|
2794 | allowed. | |
2795 |
|
2795 | |||
2796 | At the end of the upgrade, the repository may not be readable while new |
|
2796 | At the end of the upgrade, the repository may not be readable while new | |
2797 | repository data is swapped in. This window will be as long as it takes to |
|
2797 | repository data is swapped in. This window will be as long as it takes to | |
2798 | rename some directories inside the ``.hg`` directory. On most machines, this |
|
2798 | rename some directories inside the ``.hg`` directory. On most machines, this | |
2799 | should complete almost instantaneously and the chances of a consumer being |
|
2799 | should complete almost instantaneously and the chances of a consumer being | |
2800 | unable to access the repository should be low. |
|
2800 | unable to access the repository should be low. | |
2801 | """ |
|
2801 | """ | |
2802 | return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize, |
|
2802 | return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize, | |
2803 | backup=backup) |
|
2803 | backup=backup) | |
2804 |
|
2804 | |||
2805 | @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), |
|
2805 | @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), | |
2806 | inferrepo=True) |
|
2806 | inferrepo=True) | |
2807 | def debugwalk(ui, repo, *pats, **opts): |
|
2807 | def debugwalk(ui, repo, *pats, **opts): | |
2808 | """show how files match on given patterns""" |
|
2808 | """show how files match on given patterns""" | |
2809 | opts = pycompat.byteskwargs(opts) |
|
2809 | opts = pycompat.byteskwargs(opts) | |
2810 | m = scmutil.match(repo[None], pats, opts) |
|
2810 | m = scmutil.match(repo[None], pats, opts) | |
2811 | if ui.verbose: |
|
2811 | if ui.verbose: | |
2812 | ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') |
|
2812 | ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') | |
2813 | items = list(repo[None].walk(m)) |
|
2813 | items = list(repo[None].walk(m)) | |
2814 | if not items: |
|
2814 | if not items: | |
2815 | return |
|
2815 | return | |
2816 | f = lambda fn: fn |
|
2816 | f = lambda fn: fn | |
2817 | if ui.configbool('ui', 'slash') and pycompat.ossep != '/': |
|
2817 | if ui.configbool('ui', 'slash') and pycompat.ossep != '/': | |
2818 | f = lambda fn: util.normpath(fn) |
|
2818 | f = lambda fn: util.normpath(fn) | |
2819 | fmt = 'f %%-%ds %%-%ds %%s' % ( |
|
2819 | fmt = 'f %%-%ds %%-%ds %%s' % ( | |
2820 | max([len(abs) for abs in items]), |
|
2820 | max([len(abs) for abs in items]), | |
2821 | max([len(repo.pathto(abs)) for abs in items])) |
|
2821 | max([len(repo.pathto(abs)) for abs in items])) | |
2822 | for abs in items: |
|
2822 | for abs in items: | |
2823 | line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '') |
|
2823 | line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '') | |
2824 | ui.write("%s\n" % line.rstrip()) |
|
2824 | ui.write("%s\n" % line.rstrip()) | |
2825 |
|
2825 | |||
2826 | @command('debugwhyunstable', [], _('REV')) |
|
2826 | @command('debugwhyunstable', [], _('REV')) | |
2827 | def debugwhyunstable(ui, repo, rev): |
|
2827 | def debugwhyunstable(ui, repo, rev): | |
2828 | """explain instabilities of a changeset""" |
|
2828 | """explain instabilities of a changeset""" | |
2829 | for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)): |
|
2829 | for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)): | |
2830 | dnodes = '' |
|
2830 | dnodes = '' | |
2831 | if entry.get('divergentnodes'): |
|
2831 | if entry.get('divergentnodes'): | |
2832 | dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr()) |
|
2832 | dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr()) | |
2833 | for ctx in entry['divergentnodes']) + ' ' |
|
2833 | for ctx in entry['divergentnodes']) + ' ' | |
2834 | ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes, |
|
2834 | ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes, | |
2835 | entry['reason'], entry['node'])) |
|
2835 | entry['reason'], entry['node'])) | |
2836 |
|
2836 | |||
2837 | @command('debugwireargs', |
|
2837 | @command('debugwireargs', | |
2838 | [('', 'three', '', 'three'), |
|
2838 | [('', 'three', '', 'three'), | |
2839 | ('', 'four', '', 'four'), |
|
2839 | ('', 'four', '', 'four'), | |
2840 | ('', 'five', '', 'five'), |
|
2840 | ('', 'five', '', 'five'), | |
2841 | ] + cmdutil.remoteopts, |
|
2841 | ] + cmdutil.remoteopts, | |
2842 | _('REPO [OPTIONS]... [ONE [TWO]]'), |
|
2842 | _('REPO [OPTIONS]... [ONE [TWO]]'), | |
2843 | norepo=True) |
|
2843 | norepo=True) | |
2844 | def debugwireargs(ui, repopath, *vals, **opts): |
|
2844 | def debugwireargs(ui, repopath, *vals, **opts): | |
2845 | opts = pycompat.byteskwargs(opts) |
|
2845 | opts = pycompat.byteskwargs(opts) | |
2846 | repo = hg.peer(ui, opts, repopath) |
|
2846 | repo = hg.peer(ui, opts, repopath) | |
2847 | for opt in cmdutil.remoteopts: |
|
2847 | for opt in cmdutil.remoteopts: | |
2848 | del opts[opt[1]] |
|
2848 | del opts[opt[1]] | |
2849 | args = {} |
|
2849 | args = {} | |
2850 | for k, v in opts.iteritems(): |
|
2850 | for k, v in opts.iteritems(): | |
2851 | if v: |
|
2851 | if v: | |
2852 | args[k] = v |
|
2852 | args[k] = v | |
2853 | args = pycompat.strkwargs(args) |
|
2853 | args = pycompat.strkwargs(args) | |
2854 | # run twice to check that we don't mess up the stream for the next command |
|
2854 | # run twice to check that we don't mess up the stream for the next command | |
2855 | res1 = repo.debugwireargs(*vals, **args) |
|
2855 | res1 = repo.debugwireargs(*vals, **args) | |
2856 | res2 = repo.debugwireargs(*vals, **args) |
|
2856 | res2 = repo.debugwireargs(*vals, **args) | |
2857 | ui.write("%s\n" % res1) |
|
2857 | ui.write("%s\n" % res1) | |
2858 | if res1 != res2: |
|
2858 | if res1 != res2: | |
2859 | ui.warn("%s\n" % res2) |
|
2859 | ui.warn("%s\n" % res2) | |
2860 |
|
2860 | |||
2861 | def _parsewirelangblocks(fh): |
|
2861 | def _parsewirelangblocks(fh): | |
2862 | activeaction = None |
|
2862 | activeaction = None | |
2863 | blocklines = [] |
|
2863 | blocklines = [] | |
2864 | lastindent = 0 |
|
2864 | lastindent = 0 | |
2865 |
|
2865 | |||
2866 | for line in fh: |
|
2866 | for line in fh: | |
2867 | line = line.rstrip() |
|
2867 | line = line.rstrip() | |
2868 | if not line: |
|
2868 | if not line: | |
2869 | continue |
|
2869 | continue | |
2870 |
|
2870 | |||
2871 | if line.startswith(b'#'): |
|
2871 | if line.startswith(b'#'): | |
2872 | continue |
|
2872 | continue | |
2873 |
|
2873 | |||
2874 | if not line.startswith(b' '): |
|
2874 | if not line.startswith(b' '): | |
2875 | # New block. Flush previous one. |
|
2875 | # New block. Flush previous one. | |
2876 | if activeaction: |
|
2876 | if activeaction: | |
2877 | yield activeaction, blocklines |
|
2877 | yield activeaction, blocklines | |
2878 |
|
2878 | |||
2879 | activeaction = line |
|
2879 | activeaction = line | |
2880 | blocklines = [] |
|
2880 | blocklines = [] | |
2881 | lastindent = 0 |
|
2881 | lastindent = 0 | |
2882 | continue |
|
2882 | continue | |
2883 |
|
2883 | |||
2884 | # Else we start with an indent. |
|
2884 | # Else we start with an indent. | |
2885 |
|
2885 | |||
2886 | if not activeaction: |
|
2886 | if not activeaction: | |
2887 | raise error.Abort(_('indented line outside of block')) |
|
2887 | raise error.Abort(_('indented line outside of block')) | |
2888 |
|
2888 | |||
2889 | indent = len(line) - len(line.lstrip()) |
|
2889 | indent = len(line) - len(line.lstrip()) | |
2890 |
|
2890 | |||
2891 | # If this line is indented more than the last line, concatenate it. |
|
2891 | # If this line is indented more than the last line, concatenate it. | |
2892 | if indent > lastindent and blocklines: |
|
2892 | if indent > lastindent and blocklines: | |
2893 | blocklines[-1] += line.lstrip() |
|
2893 | blocklines[-1] += line.lstrip() | |
2894 | else: |
|
2894 | else: | |
2895 | blocklines.append(line) |
|
2895 | blocklines.append(line) | |
2896 | lastindent = indent |
|
2896 | lastindent = indent | |
2897 |
|
2897 | |||
2898 | # Flush last block. |
|
2898 | # Flush last block. | |
2899 | if activeaction: |
|
2899 | if activeaction: | |
2900 | yield activeaction, blocklines |
|
2900 | yield activeaction, blocklines | |
2901 |
|
2901 | |||
2902 | @command('debugwireproto', |
|
2902 | @command('debugwireproto', | |
2903 | [ |
|
2903 | [ | |
2904 | ('', 'localssh', False, _('start an SSH server for this repo')), |
|
2904 | ('', 'localssh', False, _('start an SSH server for this repo')), | |
2905 | ('', 'peer', '', _('construct a specific version of the peer')), |
|
2905 | ('', 'peer', '', _('construct a specific version of the peer')), | |
2906 | ('', 'noreadstderr', False, _('do not read from stderr of the remote')), |
|
2906 | ('', 'noreadstderr', False, _('do not read from stderr of the remote')), | |
2907 | ('', 'nologhandshake', False, |
|
2907 | ('', 'nologhandshake', False, | |
2908 | _('do not log I/O related to the peer handshake')), |
|
2908 | _('do not log I/O related to the peer handshake')), | |
2909 | ] + cmdutil.remoteopts, |
|
2909 | ] + cmdutil.remoteopts, | |
2910 | _('[PATH]'), |
|
2910 | _('[PATH]'), | |
2911 | optionalrepo=True) |
|
2911 | optionalrepo=True) | |
2912 | def debugwireproto(ui, repo, path=None, **opts): |
|
2912 | def debugwireproto(ui, repo, path=None, **opts): | |
2913 | """send wire protocol commands to a server |
|
2913 | """send wire protocol commands to a server | |
2914 |
|
2914 | |||
2915 | This command can be used to issue wire protocol commands to remote |
|
2915 | This command can be used to issue wire protocol commands to remote | |
2916 | peers and to debug the raw data being exchanged. |
|
2916 | peers and to debug the raw data being exchanged. | |
2917 |
|
2917 | |||
2918 | ``--localssh`` will start an SSH server against the current repository |
|
2918 | ``--localssh`` will start an SSH server against the current repository | |
2919 | and connect to that. By default, the connection will perform a handshake |
|
2919 | and connect to that. By default, the connection will perform a handshake | |
2920 | and establish an appropriate peer instance. |
|
2920 | and establish an appropriate peer instance. | |
2921 |
|
2921 | |||
2922 | ``--peer`` can be used to bypass the handshake protocol and construct a |
|
2922 | ``--peer`` can be used to bypass the handshake protocol and construct a | |
2923 | peer instance using the specified class type. Valid values are ``raw``, |
|
2923 | peer instance using the specified class type. Valid values are ``raw``, | |
2924 | ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending |
|
2924 | ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending | |
2925 | raw data payloads and don't support higher-level command actions. |
|
2925 | raw data payloads and don't support higher-level command actions. | |
2926 |
|
2926 | |||
2927 | ``--noreadstderr`` can be used to disable automatic reading from stderr |
|
2927 | ``--noreadstderr`` can be used to disable automatic reading from stderr | |
2928 | of the peer (for SSH connections only). Disabling automatic reading of |
|
2928 | of the peer (for SSH connections only). Disabling automatic reading of | |
2929 | stderr is useful for making output more deterministic. |
|
2929 | stderr is useful for making output more deterministic. | |
2930 |
|
2930 | |||
2931 | Commands are issued via a mini language which is specified via stdin. |
|
2931 | Commands are issued via a mini language which is specified via stdin. | |
2932 | The language consists of individual actions to perform. An action is |
|
2932 | The language consists of individual actions to perform. An action is | |
2933 | defined by a block. A block is defined as a line with no leading |
|
2933 | defined by a block. A block is defined as a line with no leading | |
2934 | space followed by 0 or more lines with leading space. Blocks are |
|
2934 | space followed by 0 or more lines with leading space. Blocks are | |
2935 | effectively a high-level command with additional metadata. |
|
2935 | effectively a high-level command with additional metadata. | |
2936 |
|
2936 | |||
2937 | Lines beginning with ``#`` are ignored. |
|
2937 | Lines beginning with ``#`` are ignored. | |
2938 |
|
2938 | |||
2939 | The following sections denote available actions. |
|
2939 | The following sections denote available actions. | |
2940 |
|
2940 | |||
2941 | raw |
|
2941 | raw | |
2942 | --- |
|
2942 | --- | |
2943 |
|
2943 | |||
2944 | Send raw data to the server. |
|
2944 | Send raw data to the server. | |
2945 |
|
2945 | |||
2946 | The block payload contains the raw data to send as one atomic send |
|
2946 | The block payload contains the raw data to send as one atomic send | |
2947 | operation. The data may not actually be delivered in a single system |
|
2947 | operation. The data may not actually be delivered in a single system | |
2948 | call: it depends on the abilities of the transport being used. |
|
2948 | call: it depends on the abilities of the transport being used. | |
2949 |
|
2949 | |||
2950 | Each line in the block is de-indented and concatenated. Then, that |
|
2950 | Each line in the block is de-indented and concatenated. Then, that | |
2951 | value is evaluated as a Python b'' literal. This allows the use of |
|
2951 | value is evaluated as a Python b'' literal. This allows the use of | |
2952 | backslash escaping, etc. |
|
2952 | backslash escaping, etc. | |
2953 |
|
2953 | |||
2954 | raw+ |
|
2954 | raw+ | |
2955 | ---- |
|
2955 | ---- | |
2956 |
|
2956 | |||
2957 | Behaves like ``raw`` except flushes output afterwards. |
|
2957 | Behaves like ``raw`` except flushes output afterwards. | |
2958 |
|
2958 | |||
2959 | command <X> |
|
2959 | command <X> | |
2960 | ----------- |
|
2960 | ----------- | |
2961 |
|
2961 | |||
2962 | Send a request to run a named command, whose name follows the ``command`` |
|
2962 | Send a request to run a named command, whose name follows the ``command`` | |
2963 | string. |
|
2963 | string. | |
2964 |
|
2964 | |||
2965 | Arguments to the command are defined as lines in this block. The format of |
|
2965 | Arguments to the command are defined as lines in this block. The format of | |
2966 | each line is ``<key> <value>``. e.g.:: |
|
2966 | each line is ``<key> <value>``. e.g.:: | |
2967 |
|
2967 | |||
2968 | command listkeys |
|
2968 | command listkeys | |
2969 | namespace bookmarks |
|
2969 | namespace bookmarks | |
2970 |
|
2970 | |||
2971 | If the value begins with ``eval:``, it will be interpreted as a Python |
|
2971 | If the value begins with ``eval:``, it will be interpreted as a Python | |
2972 | literal expression. Otherwise values are interpreted as Python b'' literals. |
|
2972 | literal expression. Otherwise values are interpreted as Python b'' literals. | |
2973 | This allows sending complex types and encoding special byte sequences via |
|
2973 | This allows sending complex types and encoding special byte sequences via | |
2974 | backslash escaping. |
|
2974 | backslash escaping. | |
2975 |
|
2975 | |||
2976 | The following arguments have special meaning: |
|
2976 | The following arguments have special meaning: | |
2977 |
|
2977 | |||
2978 | ``PUSHFILE`` |
|
2978 | ``PUSHFILE`` | |
2979 | When defined, the *push* mechanism of the peer will be used instead |
|
2979 | When defined, the *push* mechanism of the peer will be used instead | |
2980 | of the static request-response mechanism and the content of the |
|
2980 | of the static request-response mechanism and the content of the | |
2981 | file specified in the value of this argument will be sent as the |
|
2981 | file specified in the value of this argument will be sent as the | |
2982 | command payload. |
|
2982 | command payload. | |
2983 |
|
2983 | |||
2984 | This can be used to submit a local bundle file to the remote. |
|
2984 | This can be used to submit a local bundle file to the remote. | |
2985 |
|
2985 | |||
2986 | batchbegin |
|
2986 | batchbegin | |
2987 | ---------- |
|
2987 | ---------- | |
2988 |
|
2988 | |||
2989 | Instruct the peer to begin a batched send. |
|
2989 | Instruct the peer to begin a batched send. | |
2990 |
|
2990 | |||
2991 | All ``command`` blocks are queued for execution until the next |
|
2991 | All ``command`` blocks are queued for execution until the next | |
2992 | ``batchsubmit`` block. |
|
2992 | ``batchsubmit`` block. | |
2993 |
|
2993 | |||
2994 | batchsubmit |
|
2994 | batchsubmit | |
2995 | ----------- |
|
2995 | ----------- | |
2996 |
|
2996 | |||
2997 | Submit previously queued ``command`` blocks as a batch request. |
|
2997 | Submit previously queued ``command`` blocks as a batch request. | |
2998 |
|
2998 | |||
2999 | This action MUST be paired with a ``batchbegin`` action. |
|
2999 | This action MUST be paired with a ``batchbegin`` action. | |
3000 |
|
3000 | |||
3001 | httprequest <method> <path> |
|
3001 | httprequest <method> <path> | |
3002 | --------------------------- |
|
3002 | --------------------------- | |
3003 |
|
3003 | |||
3004 | (HTTP peer only) |
|
3004 | (HTTP peer only) | |
3005 |
|
3005 | |||
3006 | Send an HTTP request to the peer. |
|
3006 | Send an HTTP request to the peer. | |
3007 |
|
3007 | |||
3008 | The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``. |
|
3008 | The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``. | |
3009 |
|
3009 | |||
3010 | Arguments of the form ``<key>: <value>`` are interpreted as HTTP request |
|
3010 | Arguments of the form ``<key>: <value>`` are interpreted as HTTP request | |
3011 | headers to add to the request. e.g. ``Accept: foo``. |
|
3011 | headers to add to the request. e.g. ``Accept: foo``. | |
3012 |
|
3012 | |||
3013 | The following arguments are special: |
|
3013 | The following arguments are special: | |
3014 |
|
3014 | |||
3015 | ``BODYFILE`` |
|
3015 | ``BODYFILE`` | |
3016 | The content of the file defined as the value to this argument will be |
|
3016 | The content of the file defined as the value to this argument will be | |
3017 | transferred verbatim as the HTTP request body. |
|
3017 | transferred verbatim as the HTTP request body. | |
3018 |
|
3018 | |||
3019 | ``frame <type> <flags> <payload>`` |
|
3019 | ``frame <type> <flags> <payload>`` | |
3020 | Send a unified protocol frame as part of the request body. |
|
3020 | Send a unified protocol frame as part of the request body. | |
3021 |
|
3021 | |||
3022 | All frames will be collected and sent as the body to the HTTP |
|
3022 | All frames will be collected and sent as the body to the HTTP | |
3023 | request. |
|
3023 | request. | |
3024 |
|
3024 | |||
3025 | close |
|
3025 | close | |
3026 | ----- |
|
3026 | ----- | |
3027 |
|
3027 | |||
3028 | Close the connection to the server. |
|
3028 | Close the connection to the server. | |
3029 |
|
3029 | |||
3030 | flush |
|
3030 | flush | |
3031 | ----- |
|
3031 | ----- | |
3032 |
|
3032 | |||
3033 | Flush data written to the server. |
|
3033 | Flush data written to the server. | |
3034 |
|
3034 | |||
3035 | readavailable |
|
3035 | readavailable | |
3036 | ------------- |
|
3036 | ------------- | |
3037 |
|
3037 | |||
3038 | Close the write end of the connection and read all available data from |
|
3038 | Close the write end of the connection and read all available data from | |
3039 | the server. |
|
3039 | the server. | |
3040 |
|
3040 | |||
3041 | If the connection to the server encompasses multiple pipes, we poll both |
|
3041 | If the connection to the server encompasses multiple pipes, we poll both | |
3042 | pipes and read available data. |
|
3042 | pipes and read available data. | |
3043 |
|
3043 | |||
3044 | readline |
|
3044 | readline | |
3045 | -------- |
|
3045 | -------- | |
3046 |
|
3046 | |||
3047 | Read a line of output from the server. If there are multiple output |
|
3047 | Read a line of output from the server. If there are multiple output | |
3048 | pipes, reads only the main pipe. |
|
3048 | pipes, reads only the main pipe. | |
3049 |
|
3049 | |||
3050 | ereadline |
|
3050 | ereadline | |
3051 | --------- |
|
3051 | --------- | |
3052 |
|
3052 | |||
3053 | Like ``readline``, but read from the stderr pipe, if available. |
|
3053 | Like ``readline``, but read from the stderr pipe, if available. | |
3054 |
|
3054 | |||
3055 | read <X> |
|
3055 | read <X> | |
3056 | -------- |
|
3056 | -------- | |
3057 |
|
3057 | |||
3058 | ``read()`` N bytes from the server's main output pipe. |
|
3058 | ``read()`` N bytes from the server's main output pipe. | |
3059 |
|
3059 | |||
3060 | eread <X> |
|
3060 | eread <X> | |
3061 | --------- |
|
3061 | --------- | |
3062 |
|
3062 | |||
3063 | ``read()`` N bytes from the server's stderr pipe, if available. |
|
3063 | ``read()`` N bytes from the server's stderr pipe, if available. | |
3064 |
|
3064 | |||
3065 | Specifying Unified Frame-Based Protocol Frames |
|
3065 | Specifying Unified Frame-Based Protocol Frames | |
3066 | ---------------------------------------------- |
|
3066 | ---------------------------------------------- | |
3067 |
|
3067 | |||
3068 | It is possible to emit a *Unified Frame-Based Protocol* by using special |
|
3068 | It is possible to emit a *Unified Frame-Based Protocol* by using special | |
3069 | syntax. |
|
3069 | syntax. | |
3070 |
|
3070 | |||
3071 | A frame is composed as a type, flags, and payload. These can be parsed |
|
3071 | A frame is composed as a type, flags, and payload. These can be parsed | |
3072 | from a string of the form: |
|
3072 | from a string of the form: | |
3073 |
|
3073 | |||
3074 | <request-id> <stream-id> <stream-flags> <type> <flags> <payload> |
|
3074 | <request-id> <stream-id> <stream-flags> <type> <flags> <payload> | |
3075 |
|
3075 | |||
3076 | ``request-id`` and ``stream-id`` are integers defining the request and |
|
3076 | ``request-id`` and ``stream-id`` are integers defining the request and | |
3077 | stream identifiers. |
|
3077 | stream identifiers. | |
3078 |
|
3078 | |||
3079 | ``type`` can be an integer value for the frame type or the string name |
|
3079 | ``type`` can be an integer value for the frame type or the string name | |
3080 | of the type. The strings are defined in ``wireprotoframing.py``. e.g. |
|
3080 | of the type. The strings are defined in ``wireprotoframing.py``. e.g. | |
3081 | ``command-name``. |
|
3081 | ``command-name``. | |
3082 |
|
3082 | |||
3083 | ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag |
|
3083 | ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag | |
3084 | components. Each component (and there can be just one) can be an integer |
|
3084 | components. Each component (and there can be just one) can be an integer | |
3085 | or a flag name for stream flags or frame flags, respectively. Values are |
|
3085 | or a flag name for stream flags or frame flags, respectively. Values are | |
3086 | resolved to integers and then bitwise OR'd together. |
|
3086 | resolved to integers and then bitwise OR'd together. | |
3087 |
|
3087 | |||
3088 | ``payload`` represents the raw frame payload. If it begins with |
|
3088 | ``payload`` represents the raw frame payload. If it begins with | |
3089 | ``cbor:``, the following string is evaluated as Python code and the |
|
3089 | ``cbor:``, the following string is evaluated as Python code and the | |
3090 | resulting object is fed into a CBOR encoder. Otherwise it is interpreted |
|
3090 | resulting object is fed into a CBOR encoder. Otherwise it is interpreted | |
3091 | as a Python byte string literal. |
|
3091 | as a Python byte string literal. | |
3092 | """ |
|
3092 | """ | |
3093 | opts = pycompat.byteskwargs(opts) |
|
3093 | opts = pycompat.byteskwargs(opts) | |
3094 |
|
3094 | |||
3095 | if opts['localssh'] and not repo: |
|
3095 | if opts['localssh'] and not repo: | |
3096 | raise error.Abort(_('--localssh requires a repository')) |
|
3096 | raise error.Abort(_('--localssh requires a repository')) | |
3097 |
|
3097 | |||
3098 | if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'): |
|
3098 | if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'): | |
3099 | raise error.Abort(_('invalid value for --peer'), |
|
3099 | raise error.Abort(_('invalid value for --peer'), | |
3100 | hint=_('valid values are "raw", "ssh1", and "ssh2"')) |
|
3100 | hint=_('valid values are "raw", "ssh1", and "ssh2"')) | |
3101 |
|
3101 | |||
3102 | if path and opts['localssh']: |
|
3102 | if path and opts['localssh']: | |
3103 | raise error.Abort(_('cannot specify --localssh with an explicit ' |
|
3103 | raise error.Abort(_('cannot specify --localssh with an explicit ' | |
3104 | 'path')) |
|
3104 | 'path')) | |
3105 |
|
3105 | |||
3106 | if ui.interactive(): |
|
3106 | if ui.interactive(): | |
3107 | ui.write(_('(waiting for commands on stdin)\n')) |
|
3107 | ui.write(_('(waiting for commands on stdin)\n')) | |
3108 |
|
3108 | |||
3109 | blocks = list(_parsewirelangblocks(ui.fin)) |
|
3109 | blocks = list(_parsewirelangblocks(ui.fin)) | |
3110 |
|
3110 | |||
3111 | proc = None |
|
3111 | proc = None | |
3112 | stdin = None |
|
3112 | stdin = None | |
3113 | stdout = None |
|
3113 | stdout = None | |
3114 | stderr = None |
|
3114 | stderr = None | |
3115 | opener = None |
|
3115 | opener = None | |
3116 |
|
3116 | |||
3117 | if opts['localssh']: |
|
3117 | if opts['localssh']: | |
3118 | # We start the SSH server in its own process so there is process |
|
3118 | # We start the SSH server in its own process so there is process | |
3119 | # separation. This prevents a whole class of potential bugs around |
|
3119 | # separation. This prevents a whole class of potential bugs around | |
3120 | # shared state from interfering with server operation. |
|
3120 | # shared state from interfering with server operation. | |
3121 | args = procutil.hgcmd() + [ |
|
3121 | args = procutil.hgcmd() + [ | |
3122 | '-R', repo.root, |
|
3122 | '-R', repo.root, | |
3123 | 'debugserve', '--sshstdio', |
|
3123 | 'debugserve', '--sshstdio', | |
3124 | ] |
|
3124 | ] | |
3125 | proc = subprocess.Popen(pycompat.rapply(procutil.tonativestr, args), |
|
3125 | proc = subprocess.Popen(pycompat.rapply(procutil.tonativestr, args), | |
3126 | stdin=subprocess.PIPE, |
|
3126 | stdin=subprocess.PIPE, | |
3127 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
|
3127 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
3128 | bufsize=0) |
|
3128 | bufsize=0) | |
3129 |
|
3129 | |||
3130 | stdin = proc.stdin |
|
3130 | stdin = proc.stdin | |
3131 | stdout = proc.stdout |
|
3131 | stdout = proc.stdout | |
3132 | stderr = proc.stderr |
|
3132 | stderr = proc.stderr | |
3133 |
|
3133 | |||
3134 | # We turn the pipes into observers so we can log I/O. |
|
3134 | # We turn the pipes into observers so we can log I/O. | |
3135 | if ui.verbose or opts['peer'] == 'raw': |
|
3135 | if ui.verbose or opts['peer'] == 'raw': | |
3136 | stdin = util.makeloggingfileobject(ui, proc.stdin, b'i', |
|
3136 | stdin = util.makeloggingfileobject(ui, proc.stdin, b'i', | |
3137 | logdata=True) |
|
3137 | logdata=True) | |
3138 | stdout = util.makeloggingfileobject(ui, proc.stdout, b'o', |
|
3138 | stdout = util.makeloggingfileobject(ui, proc.stdout, b'o', | |
3139 | logdata=True) |
|
3139 | logdata=True) | |
3140 | stderr = util.makeloggingfileobject(ui, proc.stderr, b'e', |
|
3140 | stderr = util.makeloggingfileobject(ui, proc.stderr, b'e', | |
3141 | logdata=True) |
|
3141 | logdata=True) | |
3142 |
|
3142 | |||
3143 | # --localssh also implies the peer connection settings. |
|
3143 | # --localssh also implies the peer connection settings. | |
3144 |
|
3144 | |||
3145 | url = 'ssh://localserver' |
|
3145 | url = 'ssh://localserver' | |
3146 | autoreadstderr = not opts['noreadstderr'] |
|
3146 | autoreadstderr = not opts['noreadstderr'] | |
3147 |
|
3147 | |||
3148 | if opts['peer'] == 'ssh1': |
|
3148 | if opts['peer'] == 'ssh1': | |
3149 | ui.write(_('creating ssh peer for wire protocol version 1\n')) |
|
3149 | ui.write(_('creating ssh peer for wire protocol version 1\n')) | |
3150 | peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr, |
|
3150 | peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr, | |
3151 | None, autoreadstderr=autoreadstderr) |
|
3151 | None, autoreadstderr=autoreadstderr) | |
3152 | elif opts['peer'] == 'ssh2': |
|
3152 | elif opts['peer'] == 'ssh2': | |
3153 | ui.write(_('creating ssh peer for wire protocol version 2\n')) |
|
3153 | ui.write(_('creating ssh peer for wire protocol version 2\n')) | |
3154 | peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr, |
|
3154 | peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr, | |
3155 | None, autoreadstderr=autoreadstderr) |
|
3155 | None, autoreadstderr=autoreadstderr) | |
3156 | elif opts['peer'] == 'raw': |
|
3156 | elif opts['peer'] == 'raw': | |
3157 | ui.write(_('using raw connection to peer\n')) |
|
3157 | ui.write(_('using raw connection to peer\n')) | |
3158 | peer = None |
|
3158 | peer = None | |
3159 | else: |
|
3159 | else: | |
3160 | ui.write(_('creating ssh peer from handshake results\n')) |
|
3160 | ui.write(_('creating ssh peer from handshake results\n')) | |
3161 | peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr, |
|
3161 | peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr, | |
3162 | autoreadstderr=autoreadstderr) |
|
3162 | autoreadstderr=autoreadstderr) | |
3163 |
|
3163 | |||
3164 | elif path: |
|
3164 | elif path: | |
3165 | # We bypass hg.peer() so we can proxy the sockets. |
|
3165 | # We bypass hg.peer() so we can proxy the sockets. | |
3166 | # TODO consider not doing this because we skip |
|
3166 | # TODO consider not doing this because we skip | |
3167 | # ``hg.wirepeersetupfuncs`` and potentially other useful functionality. |
|
3167 | # ``hg.wirepeersetupfuncs`` and potentially other useful functionality. | |
3168 | u = util.url(path) |
|
3168 | u = util.url(path) | |
3169 | if u.scheme != 'http': |
|
3169 | if u.scheme != 'http': | |
3170 | raise error.Abort(_('only http:// paths are currently supported')) |
|
3170 | raise error.Abort(_('only http:// paths are currently supported')) | |
3171 |
|
3171 | |||
3172 | url, authinfo = u.authinfo() |
|
3172 | url, authinfo = u.authinfo() | |
3173 | openerargs = { |
|
3173 | openerargs = { | |
3174 | r'useragent': b'Mercurial debugwireproto', |
|
3174 | r'useragent': b'Mercurial debugwireproto', | |
3175 | } |
|
3175 | } | |
3176 |
|
3176 | |||
3177 | # Turn pipes/sockets into observers so we can log I/O. |
|
3177 | # Turn pipes/sockets into observers so we can log I/O. | |
3178 | if ui.verbose: |
|
3178 | if ui.verbose: | |
3179 | openerargs.update({ |
|
3179 | openerargs.update({ | |
3180 | r'loggingfh': ui, |
|
3180 | r'loggingfh': ui, | |
3181 | r'loggingname': b's', |
|
3181 | r'loggingname': b's', | |
3182 | r'loggingopts': { |
|
3182 | r'loggingopts': { | |
3183 | r'logdata': True, |
|
3183 | r'logdata': True, | |
3184 | r'logdataapis': False, |
|
3184 | r'logdataapis': False, | |
3185 | }, |
|
3185 | }, | |
3186 | }) |
|
3186 | }) | |
3187 |
|
3187 | |||
3188 | if ui.debugflag: |
|
3188 | if ui.debugflag: | |
3189 | openerargs[r'loggingopts'][r'logdataapis'] = True |
|
3189 | openerargs[r'loggingopts'][r'logdataapis'] = True | |
3190 |
|
3190 | |||
3191 | # Don't send default headers when in raw mode. This allows us to |
|
3191 | # Don't send default headers when in raw mode. This allows us to | |
3192 | # bypass most of the behavior of our URL handling code so we can |
|
3192 | # bypass most of the behavior of our URL handling code so we can | |
3193 | # have near complete control over what's sent on the wire. |
|
3193 | # have near complete control over what's sent on the wire. | |
3194 | if opts['peer'] == 'raw': |
|
3194 | if opts['peer'] == 'raw': | |
3195 | openerargs[r'sendaccept'] = False |
|
3195 | openerargs[r'sendaccept'] = False | |
3196 |
|
3196 | |||
3197 | opener = urlmod.opener(ui, authinfo, **openerargs) |
|
3197 | opener = urlmod.opener(ui, authinfo, **openerargs) | |
3198 |
|
3198 | |||
3199 | if opts['peer'] == 'http2': |
|
3199 | if opts['peer'] == 'http2': | |
3200 | ui.write(_('creating http peer for wire protocol version 2\n')) |
|
3200 | ui.write(_('creating http peer for wire protocol version 2\n')) | |
3201 | # We go through makepeer() because we need an API descriptor for |
|
3201 | # We go through makepeer() because we need an API descriptor for | |
3202 | # the peer instance to be useful. |
|
3202 | # the peer instance to be useful. | |
3203 | with ui.configoverride({ |
|
3203 | with ui.configoverride({ | |
3204 | ('experimental', 'httppeer.advertise-v2'): True}): |
|
3204 | ('experimental', 'httppeer.advertise-v2'): True}): | |
3205 | if opts['nologhandshake']: |
|
3205 | if opts['nologhandshake']: | |
3206 | ui.pushbuffer() |
|
3206 | ui.pushbuffer() | |
3207 |
|
3207 | |||
3208 | peer = httppeer.makepeer(ui, path, opener=opener) |
|
3208 | peer = httppeer.makepeer(ui, path, opener=opener) | |
3209 |
|
3209 | |||
3210 | if opts['nologhandshake']: |
|
3210 | if opts['nologhandshake']: | |
3211 | ui.popbuffer() |
|
3211 | ui.popbuffer() | |
3212 |
|
3212 | |||
3213 | if not isinstance(peer, httppeer.httpv2peer): |
|
3213 | if not isinstance(peer, httppeer.httpv2peer): | |
3214 | raise error.Abort(_('could not instantiate HTTP peer for ' |
|
3214 | raise error.Abort(_('could not instantiate HTTP peer for ' | |
3215 | 'wire protocol version 2'), |
|
3215 | 'wire protocol version 2'), | |
3216 | hint=_('the server may not have the feature ' |
|
3216 | hint=_('the server may not have the feature ' | |
3217 | 'enabled or is not allowing this ' |
|
3217 | 'enabled or is not allowing this ' | |
3218 | 'client version')) |
|
3218 | 'client version')) | |
3219 |
|
3219 | |||
3220 | elif opts['peer'] == 'raw': |
|
3220 | elif opts['peer'] == 'raw': | |
3221 | ui.write(_('using raw connection to peer\n')) |
|
3221 | ui.write(_('using raw connection to peer\n')) | |
3222 | peer = None |
|
3222 | peer = None | |
3223 | elif opts['peer']: |
|
3223 | elif opts['peer']: | |
3224 | raise error.Abort(_('--peer %s not supported with HTTP peers') % |
|
3224 | raise error.Abort(_('--peer %s not supported with HTTP peers') % | |
3225 | opts['peer']) |
|
3225 | opts['peer']) | |
3226 | else: |
|
3226 | else: | |
3227 | peer = httppeer.makepeer(ui, path, opener=opener) |
|
3227 | peer = httppeer.makepeer(ui, path, opener=opener) | |
3228 |
|
3228 | |||
3229 | # We /could/ populate stdin/stdout with sock.makefile()... |
|
3229 | # We /could/ populate stdin/stdout with sock.makefile()... | |
3230 | else: |
|
3230 | else: | |
3231 | raise error.Abort(_('unsupported connection configuration')) |
|
3231 | raise error.Abort(_('unsupported connection configuration')) | |
3232 |
|
3232 | |||
3233 | batchedcommands = None |
|
3233 | batchedcommands = None | |
3234 |
|
3234 | |||
3235 | # Now perform actions based on the parsed wire language instructions. |
|
3235 | # Now perform actions based on the parsed wire language instructions. | |
3236 | for action, lines in blocks: |
|
3236 | for action, lines in blocks: | |
3237 | if action in ('raw', 'raw+'): |
|
3237 | if action in ('raw', 'raw+'): | |
3238 | if not stdin: |
|
3238 | if not stdin: | |
3239 | raise error.Abort(_('cannot call raw/raw+ on this peer')) |
|
3239 | raise error.Abort(_('cannot call raw/raw+ on this peer')) | |
3240 |
|
3240 | |||
3241 | # Concatenate the data together. |
|
3241 | # Concatenate the data together. | |
3242 | data = ''.join(l.lstrip() for l in lines) |
|
3242 | data = ''.join(l.lstrip() for l in lines) | |
3243 | data = stringutil.unescapestr(data) |
|
3243 | data = stringutil.unescapestr(data) | |
3244 | stdin.write(data) |
|
3244 | stdin.write(data) | |
3245 |
|
3245 | |||
3246 | if action == 'raw+': |
|
3246 | if action == 'raw+': | |
3247 | stdin.flush() |
|
3247 | stdin.flush() | |
3248 | elif action == 'flush': |
|
3248 | elif action == 'flush': | |
3249 | if not stdin: |
|
3249 | if not stdin: | |
3250 | raise error.Abort(_('cannot call flush on this peer')) |
|
3250 | raise error.Abort(_('cannot call flush on this peer')) | |
3251 | stdin.flush() |
|
3251 | stdin.flush() | |
3252 | elif action.startswith('command'): |
|
3252 | elif action.startswith('command'): | |
3253 | if not peer: |
|
3253 | if not peer: | |
3254 | raise error.Abort(_('cannot send commands unless peer instance ' |
|
3254 | raise error.Abort(_('cannot send commands unless peer instance ' | |
3255 | 'is available')) |
|
3255 | 'is available')) | |
3256 |
|
3256 | |||
3257 | command = action.split(' ', 1)[1] |
|
3257 | command = action.split(' ', 1)[1] | |
3258 |
|
3258 | |||
3259 | args = {} |
|
3259 | args = {} | |
3260 | for line in lines: |
|
3260 | for line in lines: | |
3261 | # We need to allow empty values. |
|
3261 | # We need to allow empty values. | |
3262 | fields = line.lstrip().split(' ', 1) |
|
3262 | fields = line.lstrip().split(' ', 1) | |
3263 | if len(fields) == 1: |
|
3263 | if len(fields) == 1: | |
3264 | key = fields[0] |
|
3264 | key = fields[0] | |
3265 | value = '' |
|
3265 | value = '' | |
3266 | else: |
|
3266 | else: | |
3267 | key, value = fields |
|
3267 | key, value = fields | |
3268 |
|
3268 | |||
3269 | if value.startswith('eval:'): |
|
3269 | if value.startswith('eval:'): | |
3270 | value = stringutil.evalpythonliteral(value[5:]) |
|
3270 | value = stringutil.evalpythonliteral(value[5:]) | |
3271 | else: |
|
3271 | else: | |
3272 | value = stringutil.unescapestr(value) |
|
3272 | value = stringutil.unescapestr(value) | |
3273 |
|
3273 | |||
3274 | args[key] = value |
|
3274 | args[key] = value | |
3275 |
|
3275 | |||
3276 | if batchedcommands is not None: |
|
3276 | if batchedcommands is not None: | |
3277 | batchedcommands.append((command, args)) |
|
3277 | batchedcommands.append((command, args)) | |
3278 | continue |
|
3278 | continue | |
3279 |
|
3279 | |||
3280 | ui.status(_('sending %s command\n') % command) |
|
3280 | ui.status(_('sending %s command\n') % command) | |
3281 |
|
3281 | |||
3282 | if 'PUSHFILE' in args: |
|
3282 | if 'PUSHFILE' in args: | |
3283 | with open(args['PUSHFILE'], r'rb') as fh: |
|
3283 | with open(args['PUSHFILE'], r'rb') as fh: | |
3284 | del args['PUSHFILE'] |
|
3284 | del args['PUSHFILE'] | |
3285 | res, output = peer._callpush(command, fh, |
|
3285 | res, output = peer._callpush(command, fh, | |
3286 | **pycompat.strkwargs(args)) |
|
3286 | **pycompat.strkwargs(args)) | |
3287 | ui.status(_('result: %s\n') % stringutil.escapestr(res)) |
|
3287 | ui.status(_('result: %s\n') % stringutil.escapestr(res)) | |
3288 | ui.status(_('remote output: %s\n') % |
|
3288 | ui.status(_('remote output: %s\n') % | |
3289 | stringutil.escapestr(output)) |
|
3289 | stringutil.escapestr(output)) | |
3290 | else: |
|
3290 | else: | |
3291 | with peer.commandexecutor() as e: |
|
3291 | with peer.commandexecutor() as e: | |
3292 | res = e.callcommand(command, args).result() |
|
3292 | res = e.callcommand(command, args).result() | |
3293 |
|
3293 | |||
3294 | if isinstance(res, wireprotov2peer.commandresponse): |
|
3294 | if isinstance(res, wireprotov2peer.commandresponse): | |
3295 | val = res.objects() |
|
3295 | val = res.objects() | |
3296 | ui.status(_('response: %s\n') % |
|
3296 | ui.status(_('response: %s\n') % | |
3297 | stringutil.pprint(val, bprefix=True, indent=2)) |
|
3297 | stringutil.pprint(val, bprefix=True, indent=2)) | |
3298 | else: |
|
3298 | else: | |
3299 | ui.status(_('response: %s\n') % |
|
3299 | ui.status(_('response: %s\n') % | |
3300 | stringutil.pprint(res, bprefix=True, indent=2)) |
|
3300 | stringutil.pprint(res, bprefix=True, indent=2)) | |
3301 |
|
3301 | |||
3302 | elif action == 'batchbegin': |
|
3302 | elif action == 'batchbegin': | |
3303 | if batchedcommands is not None: |
|
3303 | if batchedcommands is not None: | |
3304 | raise error.Abort(_('nested batchbegin not allowed')) |
|
3304 | raise error.Abort(_('nested batchbegin not allowed')) | |
3305 |
|
3305 | |||
3306 | batchedcommands = [] |
|
3306 | batchedcommands = [] | |
3307 | elif action == 'batchsubmit': |
|
3307 | elif action == 'batchsubmit': | |
3308 | # There is a batching API we could go through. But it would be |
|
3308 | # There is a batching API we could go through. But it would be | |
3309 | # difficult to normalize requests into function calls. It is easier |
|
3309 | # difficult to normalize requests into function calls. It is easier | |
3310 | # to bypass this layer and normalize to commands + args. |
|
3310 | # to bypass this layer and normalize to commands + args. | |
3311 | ui.status(_('sending batch with %d sub-commands\n') % |
|
3311 | ui.status(_('sending batch with %d sub-commands\n') % | |
3312 | len(batchedcommands)) |
|
3312 | len(batchedcommands)) | |
3313 | for i, chunk in enumerate(peer._submitbatch(batchedcommands)): |
|
3313 | for i, chunk in enumerate(peer._submitbatch(batchedcommands)): | |
3314 | ui.status(_('response #%d: %s\n') % |
|
3314 | ui.status(_('response #%d: %s\n') % | |
3315 | (i, stringutil.escapestr(chunk))) |
|
3315 | (i, stringutil.escapestr(chunk))) | |
3316 |
|
3316 | |||
3317 | batchedcommands = None |
|
3317 | batchedcommands = None | |
3318 |
|
3318 | |||
3319 | elif action.startswith('httprequest '): |
|
3319 | elif action.startswith('httprequest '): | |
3320 | if not opener: |
|
3320 | if not opener: | |
3321 | raise error.Abort(_('cannot use httprequest without an HTTP ' |
|
3321 | raise error.Abort(_('cannot use httprequest without an HTTP ' | |
3322 | 'peer')) |
|
3322 | 'peer')) | |
3323 |
|
3323 | |||
3324 | request = action.split(' ', 2) |
|
3324 | request = action.split(' ', 2) | |
3325 | if len(request) != 3: |
|
3325 | if len(request) != 3: | |
3326 | raise error.Abort(_('invalid httprequest: expected format is ' |
|
3326 | raise error.Abort(_('invalid httprequest: expected format is ' | |
3327 | '"httprequest <method> <path>')) |
|
3327 | '"httprequest <method> <path>')) | |
3328 |
|
3328 | |||
3329 | method, httppath = request[1:] |
|
3329 | method, httppath = request[1:] | |
3330 | headers = {} |
|
3330 | headers = {} | |
3331 | body = None |
|
3331 | body = None | |
3332 | frames = [] |
|
3332 | frames = [] | |
3333 | for line in lines: |
|
3333 | for line in lines: | |
3334 | line = line.lstrip() |
|
3334 | line = line.lstrip() | |
3335 | m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) |
|
3335 | m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) | |
3336 | if m: |
|
3336 | if m: | |
3337 | # Headers need to use native strings. |
|
3337 | # Headers need to use native strings. | |
3338 | key = pycompat.strurl(m.group(1)) |
|
3338 | key = pycompat.strurl(m.group(1)) | |
3339 | value = pycompat.strurl(m.group(2)) |
|
3339 | value = pycompat.strurl(m.group(2)) | |
3340 | headers[key] = value |
|
3340 | headers[key] = value | |
3341 | continue |
|
3341 | continue | |
3342 |
|
3342 | |||
3343 | if line.startswith(b'BODYFILE '): |
|
3343 | if line.startswith(b'BODYFILE '): | |
3344 | with open(line.split(b' ', 1), 'rb') as fh: |
|
3344 | with open(line.split(b' ', 1), 'rb') as fh: | |
3345 | body = fh.read() |
|
3345 | body = fh.read() | |
3346 | elif line.startswith(b'frame '): |
|
3346 | elif line.startswith(b'frame '): | |
3347 | frame = wireprotoframing.makeframefromhumanstring( |
|
3347 | frame = wireprotoframing.makeframefromhumanstring( | |
3348 | line[len(b'frame '):]) |
|
3348 | line[len(b'frame '):]) | |
3349 |
|
3349 | |||
3350 | frames.append(frame) |
|
3350 | frames.append(frame) | |
3351 | else: |
|
3351 | else: | |
3352 | raise error.Abort(_('unknown argument to httprequest: %s') % |
|
3352 | raise error.Abort(_('unknown argument to httprequest: %s') % | |
3353 | line) |
|
3353 | line) | |
3354 |
|
3354 | |||
3355 | url = path + httppath |
|
3355 | url = path + httppath | |
3356 |
|
3356 | |||
3357 | if frames: |
|
3357 | if frames: | |
3358 | body = b''.join(bytes(f) for f in frames) |
|
3358 | body = b''.join(bytes(f) for f in frames) | |
3359 |
|
3359 | |||
3360 | req = urlmod.urlreq.request(pycompat.strurl(url), body, headers) |
|
3360 | req = urlmod.urlreq.request(pycompat.strurl(url), body, headers) | |
3361 |
|
3361 | |||
3362 | # urllib.Request insists on using has_data() as a proxy for |
|
3362 | # urllib.Request insists on using has_data() as a proxy for | |
3363 | # determining the request method. Override that to use our |
|
3363 | # determining the request method. Override that to use our | |
3364 | # explicitly requested method. |
|
3364 | # explicitly requested method. | |
3365 | req.get_method = lambda: pycompat.sysstr(method) |
|
3365 | req.get_method = lambda: pycompat.sysstr(method) | |
3366 |
|
3366 | |||
3367 | try: |
|
3367 | try: | |
3368 | res = opener.open(req) |
|
3368 | res = opener.open(req) | |
3369 | body = res.read() |
|
3369 | body = res.read() | |
3370 | except util.urlerr.urlerror as e: |
|
3370 | except util.urlerr.urlerror as e: | |
3371 | # read() method must be called, but only exists in Python 2 |
|
3371 | # read() method must be called, but only exists in Python 2 | |
3372 | getattr(e, 'read', lambda: None)() |
|
3372 | getattr(e, 'read', lambda: None)() | |
3373 | continue |
|
3373 | continue | |
3374 |
|
3374 | |||
3375 | ct = res.headers.get(r'Content-Type') |
|
3375 | ct = res.headers.get(r'Content-Type') | |
3376 | if ct == r'application/mercurial-cbor': |
|
3376 | if ct == r'application/mercurial-cbor': | |
3377 | ui.write(_('cbor> %s\n') % |
|
3377 | ui.write(_('cbor> %s\n') % | |
3378 | stringutil.pprint(cborutil.decodeall(body), |
|
3378 | stringutil.pprint(cborutil.decodeall(body), | |
3379 | bprefix=True, |
|
3379 | bprefix=True, | |
3380 | indent=2)) |
|
3380 | indent=2)) | |
3381 |
|
3381 | |||
3382 | elif action == 'close': |
|
3382 | elif action == 'close': | |
3383 | peer.close() |
|
3383 | peer.close() | |
3384 | elif action == 'readavailable': |
|
3384 | elif action == 'readavailable': | |
3385 | if not stdout or not stderr: |
|
3385 | if not stdout or not stderr: | |
3386 | raise error.Abort(_('readavailable not available on this peer')) |
|
3386 | raise error.Abort(_('readavailable not available on this peer')) | |
3387 |
|
3387 | |||
3388 | stdin.close() |
|
3388 | stdin.close() | |
3389 | stdout.read() |
|
3389 | stdout.read() | |
3390 | stderr.read() |
|
3390 | stderr.read() | |
3391 |
|
3391 | |||
3392 | elif action == 'readline': |
|
3392 | elif action == 'readline': | |
3393 | if not stdout: |
|
3393 | if not stdout: | |
3394 | raise error.Abort(_('readline not available on this peer')) |
|
3394 | raise error.Abort(_('readline not available on this peer')) | |
3395 | stdout.readline() |
|
3395 | stdout.readline() | |
3396 | elif action == 'ereadline': |
|
3396 | elif action == 'ereadline': | |
3397 | if not stderr: |
|
3397 | if not stderr: | |
3398 | raise error.Abort(_('ereadline not available on this peer')) |
|
3398 | raise error.Abort(_('ereadline not available on this peer')) | |
3399 | stderr.readline() |
|
3399 | stderr.readline() | |
3400 | elif action.startswith('read '): |
|
3400 | elif action.startswith('read '): | |
3401 | count = int(action.split(' ', 1)[1]) |
|
3401 | count = int(action.split(' ', 1)[1]) | |
3402 | if not stdout: |
|
3402 | if not stdout: | |
3403 | raise error.Abort(_('read not available on this peer')) |
|
3403 | raise error.Abort(_('read not available on this peer')) | |
3404 | stdout.read(count) |
|
3404 | stdout.read(count) | |
3405 | elif action.startswith('eread '): |
|
3405 | elif action.startswith('eread '): | |
3406 | count = int(action.split(' ', 1)[1]) |
|
3406 | count = int(action.split(' ', 1)[1]) | |
3407 | if not stderr: |
|
3407 | if not stderr: | |
3408 | raise error.Abort(_('eread not available on this peer')) |
|
3408 | raise error.Abort(_('eread not available on this peer')) | |
3409 | stderr.read(count) |
|
3409 | stderr.read(count) | |
3410 | else: |
|
3410 | else: | |
3411 | raise error.Abort(_('unknown action: %s') % action) |
|
3411 | raise error.Abort(_('unknown action: %s') % action) | |
3412 |
|
3412 | |||
3413 | if batchedcommands is not None: |
|
3413 | if batchedcommands is not None: | |
3414 | raise error.Abort(_('unclosed "batchbegin" request')) |
|
3414 | raise error.Abort(_('unclosed "batchbegin" request')) | |
3415 |
|
3415 | |||
3416 | if peer: |
|
3416 | if peer: | |
3417 | peer.close() |
|
3417 | peer.close() | |
3418 |
|
3418 | |||
3419 | if proc: |
|
3419 | if proc: | |
3420 | proc.kill() |
|
3420 | proc.kill() |
General Comments 0
You need to be logged in to leave comments.
Login now