Mercurial > hg
annotate mercurial/debugcommands.py @ 42523:49998d5ba66a
pycompat: make fewer assumptions about sys.executable
There are many Python "bundlers" which create an archive to run a Python binary
from, and they may not set sys.executable at all - handle that case properly,
especially to run tests.
Differential Revision: https://phab.mercurial-scm.org/D6575
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Tue, 25 Jun 2019 19:28:41 -0700 |
parents | 810f66b468cd |
children | eb7bd7d64a9d |
rev | line source |
---|---|
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # debugcommands.py - command processing for debug* commands |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com> |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
34129
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
10 import codecs |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
11 import collections |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
12 import difflib |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
13 import errno |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
14 import operator |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
15 import os |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
16 import random |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
17 import re |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
18 import socket |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
19 import ssl |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36778
diff
changeset
|
20 import stat |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
21 import string |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
22 import subprocess |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
23 import sys |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
24 import time |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 from .i18n import _ |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
27 from .node import ( |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
28 bin, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
29 hex, |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
30 nullhex, |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
31 nullid, |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
32 nullrev, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
33 short, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
34 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 from . import ( |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
36 bundle2, |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
37 changegroup, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 cmdutil, |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
39 color, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
40 context, |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
41 copies, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
42 dagparser, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
43 encoding, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 error, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
45 exchange, |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
46 extensions, |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
47 filemerge, |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38802
diff
changeset
|
48 filesetlang, |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
49 formatter, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
50 hg, |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
51 httppeer, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
52 localrepo, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
53 lock as lockmod, |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
54 logcmdutil, |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
55 merge as mergemod, |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
56 obsolete, |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33107
diff
changeset
|
57 obsutil, |
32745
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
58 phases, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
59 policy, |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
60 pvec, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30518
diff
changeset
|
61 pycompat, |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32315
diff
changeset
|
62 registrar, |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
63 repair, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 revlog, |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
65 revset, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
66 revsetlang, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 scmutil, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
68 setdiscovery, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
69 simplemerge, |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
70 sshpeer, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
71 sslutil, |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
72 streamclone, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
73 templater, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
74 treediscovery, |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31689
diff
changeset
|
75 upgrade, |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
76 url as urlmod, |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
77 util, |
31239
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
78 vfs as vfsmod, |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
79 wireprotoframing, |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
80 wireprotoserver, |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
81 wireprotov2peer, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
83 from .utils import ( |
39449
e5eb67dea6e8
debugcommands: use our CBOR decoder
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39378
diff
changeset
|
84 cborutil, |
42041
3e47d1ec9da5
util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42035
diff
changeset
|
85 compression, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
86 dateutil, |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
87 procutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
88 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
89 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 |
39330
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
91 from .revlogutils import ( |
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
92 deltas as deltautil |
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
93 ) |
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
94 |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
95 release = lockmod.release |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
96 |
32377
c942c83ac2ec
debugcommands: use temporary dict for its command table
Yuya Nishihara <yuya@tcha.org>
parents:
32376
diff
changeset
|
97 command = registrar.command() |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 def debugancestor(ui, repo, *args): |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 """find the ancestor revision of two revisions in a given index""" |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 if len(args) == 3: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 index, rev1, rev2 = args |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39760
diff
changeset
|
104 r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 lookup = r.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 elif len(args) == 2: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 if not repo: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 raise error.Abort(_('there is no Mercurial repository here ' |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 '(.hg not found)')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 rev1, rev2 = args |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 r = repo.changelog |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 lookup = repo.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 else: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 raise error.Abort(_('either two or three arguments required')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 a = r.ancestor(lookup(rev1), lookup(rev2)) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 ui.write('%d:%s\n' % (r.rev(a), hex(a))) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
117 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
118 @command('debugapplystreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
119 def debugapplystreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
120 """apply a stream clone bundle file""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
121 f = hg.openpath(ui, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
122 gen = exchange.readbundle(ui, f, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
123 gen.apply(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
124 |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
125 @command('debugbuilddag', |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
126 [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
127 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
128 ('n', 'new-file', None, _('add new file at each rev'))], |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
129 _('[OPTION]... [TEXT]')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
130 def debugbuilddag(ui, repo, text=None, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
131 mergeable_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
132 overwritten_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
133 new_file=False): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
134 """builds a repo with a given DAG from scratch in the current empty repo |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
135 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
136 The description of the DAG is read from stdin if not given on the |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
137 command line. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
138 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
139 Elements: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
140 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
141 - "+n" is a linear run of n nodes based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
142 - "." is a single node based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
143 - "$" resets the default parent to null (implied at the start); |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
144 otherwise the default parent is always the last node created |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
145 - "<p" sets the default parent to the backref p |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
146 - "*p" is a fork at parent p, which is a backref |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
147 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
148 - "/p2" is a merge of the preceding node and p2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
149 - ":tag" defines a local tag for the preceding node |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
150 - "@branch" sets the named branch for subsequent nodes |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
151 - "#...\\n" is a comment up to the end of the line |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
152 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
153 Whitespace between the above elements is ignored. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
154 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
155 A backref is either |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
156 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
157 - a number n, which references the node curr-n, where curr is the current |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
158 node, or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
159 - the name of a local tag you placed earlier using ":tag", or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
160 - empty to denote the default parent. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
161 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
162 All string valued-elements are either strictly alphanumeric, or must |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
163 be enclosed in double quotes ("..."), with "\\" as escape character. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
164 """ |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
165 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
166 if text is None: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
167 ui.status(_("reading DAG from stdin\n")) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
168 text = ui.fin.read() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
169 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
170 cl = repo.changelog |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
171 if len(cl) > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
172 raise error.Abort(_('repository is not empty')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
173 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
174 # determine number of revs in DAG |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
175 total = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
176 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
177 if type == 'n': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
178 total += 1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
179 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
180 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
181 linesperrev = 2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
182 # make a file with k lines per rev |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38781
diff
changeset
|
183 initialmergedlines = ['%d' % i |
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38781
diff
changeset
|
184 for i in pycompat.xrange(0, total * linesperrev)] |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
185 initialmergedlines.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
186 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
187 tags = [] |
38375
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
188 progress = ui.makeprogress(_('building'), unit=_('revisions'), |
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
189 total=total) |
38376
0d7ec620faef
debugbuilddag: use context manager for progress, locks, transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
38375
diff
changeset
|
190 with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"): |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
191 at = -1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
192 atbranch = 'default' |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
193 nodeids = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
194 id = 0 |
38375
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
195 progress.update(id) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
196 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
197 if type == 'n': |
35585
35fb3367f72d
py3: use pycompat.bytestr() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35562
diff
changeset
|
198 ui.note(('node %s\n' % pycompat.bytestr(data))) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
199 id, ps = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
200 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
201 files = [] |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
202 filecontent = {} |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
203 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
204 p2 = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
205 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
206 fn = "mf" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
207 p1 = repo[ps[0]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
208 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
209 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
210 pa = p1.ancestor(p2) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
211 base, local, other = [x[fn].data() for x in (pa, p1, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
212 p2)] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
213 m3 = simplemerge.Merge3Text(base, local, other) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
214 ml = [l.strip() for l in m3.merge_lines()] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
215 ml.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
216 elif at > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
217 ml = p1[fn].data().split("\n") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
218 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
219 ml = initialmergedlines |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
220 ml[id * linesperrev] += " r%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
221 mergedtext = "\n".join(ml) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
222 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
223 filecontent[fn] = mergedtext |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
224 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
225 if overwritten_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
226 fn = "of" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
227 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
228 filecontent[fn] = "r%i\n" % id |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
229 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
230 if new_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
231 fn = "nf%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
232 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
233 filecontent[fn] = "r%i\n" % id |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
234 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
235 if not p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
236 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
237 for fn in p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
238 if fn.startswith("nf"): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
239 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
240 filecontent[fn] = p2[fn].data() |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
241 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
242 def fctxfn(repo, cx, path): |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
243 if path in filecontent: |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35399
diff
changeset
|
244 return context.memfilectx(repo, cx, path, |
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35399
diff
changeset
|
245 filecontent[path]) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
246 return None |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
247 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
248 if len(ps) == 0 or ps[0] < 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
249 pars = [None, None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
250 elif len(ps) == 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
251 pars = [nodeids[ps[0]], None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
252 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
253 pars = [nodeids[p] for p in ps] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
254 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
255 date=(id, 0), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
256 user="debugbuilddag", |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
257 extra={'branch': atbranch}) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
258 nodeid = repo.commitctx(cx) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
259 nodeids.append(nodeid) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
260 at = id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
261 elif type == 'l': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
262 id, name = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
263 ui.note(('tag %s\n' % name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
264 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
265 elif type == 'a': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
266 ui.note(('branch %s\n' % data)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
267 atbranch = data |
38375
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
268 progress.update(id) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
269 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
270 if tags: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
271 repo.vfs.write("localtags", "".join(tags)) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
272 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
273 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
274 indent_string = ' ' * indent |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
275 if all: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
276 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
277 % indent_string) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
278 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
279 def showchunks(named): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
280 ui.write("\n%s%s\n" % (indent_string, named)) |
34292
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34130
diff
changeset
|
281 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34130
diff
changeset
|
282 node, p1, p2, cs, deltabase, delta, flags = deltadata |
36459
580f75f70f39
py3: use '%d' to convert integers to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36415
diff
changeset
|
283 ui.write("%s%s %s %s %s %s %d\n" % |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
284 (indent_string, hex(node), hex(p1), hex(p2), |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
285 hex(cs), hex(deltabase), len(delta))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
286 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
287 chunkdata = gen.changelogheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
288 showchunks("changelog") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
289 chunkdata = gen.manifestheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
290 showchunks("manifest") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
291 for chunkdata in iter(gen.filelogheader, {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
292 fname = chunkdata['filename'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
293 showchunks(fname) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
294 else: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
295 if isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
296 raise error.Abort(_('use debugbundle2 for this file')) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
297 chunkdata = gen.changelogheader() |
34292
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34130
diff
changeset
|
298 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34130
diff
changeset
|
299 node, p1, p2, cs, deltabase, delta, flags = deltadata |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
300 ui.write("%s%s\n" % (indent_string, hex(node))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
301 |
33029
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33028
diff
changeset
|
302 def _debugobsmarkers(ui, part, indent=0, **opts): |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
303 """display version and markers contained in 'data'""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
304 opts = pycompat.byteskwargs(opts) |
33029
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33028
diff
changeset
|
305 data = part.read() |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
306 indent_string = ' ' * indent |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
307 try: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
308 version, markers = obsolete._readmarkers(data) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
309 except error.UnknownVersion as exc: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
310 msg = "%sunsupported version: %s (%d bytes)\n" |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
311 msg %= indent_string, exc.version, len(data) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
312 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
313 else: |
35144
8f6641fa7c89
py3: use '%d' for integers rather than '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35059
diff
changeset
|
314 msg = "%sversion: %d (%d bytes)\n" |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
315 msg %= indent_string, version, len(data) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
316 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
317 fm = ui.formatter('debugobsolete', opts) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
318 for rawmarker in sorted(markers): |
33148
4e30168d7939
obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33142
diff
changeset
|
319 m = obsutil.marker(None, rawmarker) |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
320 fm.startitem() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
321 fm.plain(indent_string) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
322 cmdutil.showmarker(fm, m) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
323 fm.end() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
324 |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
325 def _debugphaseheads(ui, data, indent=0): |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
326 """display version and markers contained in 'data'""" |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
327 indent_string = ' ' * indent |
34320
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
328 headsbyphase = phases.binarydecode(data) |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
329 for phase in phases.allphases: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
330 for head in headsbyphase[phase]: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
331 ui.write(indent_string) |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
332 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase])) |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
333 |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
334 def _quasirepr(thing): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
335 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
336 return '{%s}' % ( |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
337 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing))) |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
338 return pycompat.bytestr(repr(thing)) |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
339 |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
340 def _debugbundle2(ui, gen, all=None, **opts): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
341 """lists the contents of a bundle2""" |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
342 if not isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
343 raise error.Abort(_('not a bundle2 file')) |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
344 ui.write(('Stream params: %s\n' % _quasirepr(gen.params))) |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
345 parttypes = opts.get(r'part_type', []) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
346 for part in gen.iterparts(): |
32694
3ef319e9505f
debugbundle: add --part-type flag to emit only named part types
Danek Duvall <danek.duvall@oracle.com>
parents:
32626
diff
changeset
|
347 if parttypes and part.type not in parttypes: |
3ef319e9505f
debugbundle: add --part-type flag to emit only named part types
Danek Duvall <danek.duvall@oracle.com>
parents:
32626
diff
changeset
|
348 continue |
37841
d618558e4e8b
debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents:
37823
diff
changeset
|
349 msg = '%s -- %s (mandatory: %r)\n' |
d618558e4e8b
debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents:
37823
diff
changeset
|
350 ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory))) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
351 if part.type == 'changegroup': |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
352 version = part.params.get('version', '01') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
353 cg = changegroup.getunbundler(version, part, 'UN') |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
354 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
355 _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
356 if part.type == 'obsmarkers': |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
357 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
358 _debugobsmarkers(ui, part, indent=4, **opts) |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
359 if part.type == 'phase-heads': |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
360 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
361 _debugphaseheads(ui, part, indent=4) |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
362 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
363 @command('debugbundle', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
364 [('a', 'all', None, _('show all details')), |
32694
3ef319e9505f
debugbundle: add --part-type flag to emit only named part types
Danek Duvall <danek.duvall@oracle.com>
parents:
32626
diff
changeset
|
365 ('', 'part-type', [], _('show only the named part type')), |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
366 ('', 'spec', None, _('print the bundlespec of the bundle'))], |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
367 _('FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
368 norepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
369 def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
370 """lists the contents of a bundle""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
371 with hg.openpath(ui, bundlepath) as f: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
372 if spec: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
373 spec = exchange.getbundlespec(ui, f) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
374 ui.write('%s\n' % spec) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
375 return |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
376 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
377 gen = exchange.readbundle(ui, f, bundlepath) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
378 if isinstance(gen, bundle2.unbundle20): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
379 return _debugbundle2(ui, gen, all=all, **opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
380 _debugchangegroup(ui, gen, all=all, **opts) |
30503
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
381 |
34959
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
382 @command('debugcapabilities', |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
383 [], _('PATH'), |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
384 norepo=True) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
385 def debugcapabilities(ui, path, **opts): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
386 """lists the capabilities of a remote peer""" |
35401
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35400
diff
changeset
|
387 opts = pycompat.byteskwargs(opts) |
34959
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
388 peer = hg.peer(ui, opts, path) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
389 caps = peer.capabilities() |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
390 ui.write(('Main capabilities:\n')) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
391 for c in sorted(caps): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
392 ui.write((' %s\n') % c) |
34960
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
393 b2caps = bundle2.bundle2caps(peer) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
394 if b2caps: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
395 ui.write(('Bundle2 capabilities:\n')) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
396 for key, values in sorted(b2caps.iteritems()): |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
397 ui.write((' %s\n') % key) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
398 for v in values: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
399 ui.write((' %s\n') % v) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
34959
diff
changeset
|
400 |
30503
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
401 @command('debugcheckstate', [], '') |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
402 def debugcheckstate(ui, repo): |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
403 """validate the correctness of the current dirstate""" |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
404 parent1, parent2 = repo.dirstate.parents() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
405 m1 = repo[parent1].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
406 m2 = repo[parent2].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
407 errors = 0 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
408 for f in repo.dirstate: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
409 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
410 if state in "nr" and f not in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
411 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
412 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
413 if state in "a" and f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
414 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
415 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
416 if state in "m" and f not in m1 and f not in m2: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
417 ui.warn(_("%s in state %s, but not in either manifest\n") % |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
418 (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
419 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
420 for f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
421 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
422 if state not in "nrm": |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
423 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
424 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
425 if errors: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
426 error = _(".hg/dirstate inconsistent with current parent's manifest") |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
427 raise error.Abort(error) |
30504
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
428 |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
429 @command('debugcolor', |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
430 [('', 'style', None, _('show all configured styles'))], |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
431 'hg debugcolor') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
432 def debugcolor(ui, repo, **opts): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
433 """show available color, effects or style""" |
38444
a0c3d83d5f04
py3: use stringutil.pprint() to print NoneType
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38376
diff
changeset
|
434 ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode)) |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
435 if opts.get(r'style'): |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
436 return _debugdisplaystyle(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
437 else: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
438 return _debugdisplaycolor(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
439 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
440 def _debugdisplaycolor(ui): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
441 ui = ui.copy() |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
442 ui._styles.clear() |
31689
57a22f699179
color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents:
31634
diff
changeset
|
443 for effect in color._activeeffects(ui).keys(): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
444 ui._styles[effect] = effect |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
445 if ui._terminfoparams: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
446 for k, v in ui.configitems('color'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
447 if k.startswith('color.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
448 ui._styles[k] = k[6:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
449 elif k.startswith('terminfo.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
450 ui._styles[k] = k[9:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
451 ui.write(_('available colors:\n')) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
452 # sort label with a '_' after the other to group '_background' entry. |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
453 items = sorted(ui._styles.items(), |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
454 key=lambda i: ('_' in i[0], i[0], i[1])) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
455 for colorname, label in items: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
456 ui.write(('%s\n') % colorname, label=label) |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
457 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
458 def _debugdisplaystyle(ui): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
459 ui.write(_('available style:\n')) |
37823
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
460 if not ui._styles: |
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
461 return |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
462 width = max(len(s) for s in ui._styles) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
463 for label, effects in sorted(ui._styles.items()): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
464 ui.write('%s' % label, label=label) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
465 if effects: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
466 # 50 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
467 ui.write(': ') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
468 ui.write(' ' * (max(0, width - len(label)))) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
469 ui.write(', '.join(ui.label(e, e) for e in effects.split())) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
470 ui.write('\n') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
471 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
472 @command('debugcreatestreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
473 def debugcreatestreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
474 """create a stream clone bundle file |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
475 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
476 Stream bundles are special bundles that are essentially archives of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
477 revlog files. They are commonly used for cloning very quickly. |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
478 """ |
32745
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
479 # TODO we may want to turn this into an abort when this functionality |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
480 # is moved into `hg bundle`. |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
481 if phases.hassecret(repo): |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
482 ui.warn(_('(warning: stream clone bundle will contain secret ' |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
483 'revisions)\n')) |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
484 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
485 requirements, gen = streamclone.generatebundlev1(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
486 changegroup.writechunks(ui, gen, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
487 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
488 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
489 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
490 @command('debugdag', |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
491 [('t', 'tags', None, _('use tags as labels')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
492 ('b', 'branches', None, _('annotate with branch names')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
493 ('', 'dots', None, _('use dots for runs')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
494 ('s', 'spaces', None, _('separate elements by spaces'))], |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
495 _('[OPTION]... [FILE [REV]...]'), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
496 optionalrepo=True) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
497 def debugdag(ui, repo, file_=None, *revs, **opts): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
498 """format the changelog or an index DAG as a concise textual description |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
499 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
500 If you pass a revlog index, the revlog's DAG is emitted. If you list |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
501 revision numbers, they get labeled in the output as rN. |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
502 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
503 Otherwise, the changelog DAG of the current repo is emitted. |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
504 """ |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
505 spaces = opts.get(r'spaces') |
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
506 dots = opts.get(r'dots') |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
507 if file_: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39760
diff
changeset
|
508 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30518
diff
changeset
|
509 file_) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
510 revs = set((int(r) for r in revs)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
511 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
512 for r in rlog: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
513 yield 'n', (r, list(p for p in rlog.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
514 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
515 if r in revs: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
516 yield 'l', (r, "r%i" % r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
517 elif repo: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
518 cl = repo.changelog |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
519 tags = opts.get(r'tags') |
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
520 branches = opts.get(r'branches') |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
521 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
522 labels = {} |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
523 for l, n in repo.tags().items(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
524 labels.setdefault(cl.rev(n), []).append(l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
525 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
526 b = "default" |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
527 for r in cl: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
528 if branches: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
529 newb = cl.read(cl.node(r))[5]['branch'] |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
530 if newb != b: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
531 yield 'a', newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
532 b = newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
533 yield 'n', (r, list(p for p in cl.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
534 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
535 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
536 ls = labels.get(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
537 if ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
538 for l in ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
539 yield 'l', (r, l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
540 else: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
541 raise error.Abort(_('need repo for changelog dag')) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
542 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
543 for line in dagparser.dagtextlines(events(), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
544 addspaces=spaces, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
545 wraplabels=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
546 wrapannotations=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
547 wrapnonlinear=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
548 usedots=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
549 maxlinewidth=70): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
550 ui.write(line) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
551 ui.write("\n") |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
552 |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
553 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
554 def debugdata(ui, repo, file_, rev=None, **opts): |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
555 """dump the contents of a data file revision""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
556 opts = pycompat.byteskwargs(opts) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
557 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
558 if rev is not None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
559 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
560 file_, rev = None, file_ |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
561 elif rev is None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
562 raise error.CommandError('debugdata', _('invalid arguments')) |
39281
dd6bc2509bdc
debugcommands: use openstorage() in debugdata (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39279
diff
changeset
|
563 r = cmdutil.openstorage(repo, 'debugdata', file_, opts) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
564 try: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30541
diff
changeset
|
565 ui.write(r.revision(r.lookup(rev), raw=True)) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
566 except KeyError: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
567 raise error.Abort(_('invalid revision identifier %s') % rev) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
568 |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
569 @command('debugdate', |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
570 [('e', 'extended', None, _('try extended date formats'))], |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
571 _('[-e] DATE [RANGE]'), |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
572 norepo=True, optionalrepo=True) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
573 def debugdate(ui, date, range=None, **opts): |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
574 """parse and display a date""" |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
575 if opts[r"extended"]: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
576 d = dateutil.parsedate(date, util.extendeddateformats) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
577 else: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
578 d = dateutil.parsedate(date) |
36399
a24c57f1f5c3
py3: use '%d' for integers instead of '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36335
diff
changeset
|
579 ui.write(("internal: %d %d\n") % d) |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
580 ui.write(("standard: %s\n") % dateutil.datestr(d)) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
581 if range: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
582 m = dateutil.matchdate(range) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
583 ui.write(("match: %s\n") % m(d[0])) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
584 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
585 @command('debugdeltachain', |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
586 cmdutil.debugrevlogopts + cmdutil.formatteropts, |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
587 _('-c|-m|FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
588 optionalrepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
589 def debugdeltachain(ui, repo, file_=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
590 """dump information about delta chains in a revlog |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
591 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
592 Output can be templatized. Available template keywords are: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
593 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
594 :``rev``: revision number |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
595 :``chainid``: delta chain identifier (numbered by unique base) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
596 :``chainlen``: delta chain length to this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
597 :``prevrev``: previous revision in delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
598 :``deltatype``: role of delta / how it was computed |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
599 :``compsize``: compressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
600 :``uncompsize``: uncompressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
601 :``chainsize``: total size of compressed revisions in chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
602 :``chainratio``: total chain size divided by uncompressed revision size |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
603 (new delta chains typically start at ratio 2.00) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
604 :``lindist``: linear distance from base revision in delta chain to end |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
605 of this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
606 :``extradist``: total size of revisions not part of this delta chain from |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
607 base of delta chain to end of this revision; a measurement |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
608 of how much extra data we need to read/seek across to read |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
609 the delta chain for this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
610 :``extraratio``: extradist divided by chainsize; another representation of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
611 how much unrelated data is needed to load this delta chain |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
612 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
613 If the repository is configured to use the sparse read, additional keywords |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
614 are available: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
615 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
616 :``readsize``: total size of data read from the disk for a revision |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
617 (sum of the sizes of all the blocks) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
618 :``largestblock``: size of the largest block of data read from the disk |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
619 :``readdensity``: density of useful bytes in the data read from the disk |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
620 :``srchunks``: in how many data hunks the whole revision would be read |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
621 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
622 The sparse read can be enabled with experimental.sparse-read = True |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
623 """ |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
624 opts = pycompat.byteskwargs(opts) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
625 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
626 index = r.index |
38115
b17fa9041695
debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents:
37977
diff
changeset
|
627 start = r.start |
b17fa9041695
debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents:
37977
diff
changeset
|
628 length = r.length |
32315
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
629 generaldelta = r.version & revlog.FLAG_GENERALDELTA |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
630 withsparseread = getattr(r, '_withsparseread', False) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
631 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
632 def revinfo(rev): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
633 e = index[rev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
634 compsize = e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
635 uncompsize = e[2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
636 chainsize = 0 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
637 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
638 if generaldelta: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
639 if e[3] == e[5]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
640 deltatype = 'p1' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
641 elif e[3] == e[6]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
642 deltatype = 'p2' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
643 elif e[3] == rev - 1: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
644 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
645 elif e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
646 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
647 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
648 deltatype = 'other' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
649 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
650 if e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
651 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
652 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
653 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
654 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
655 chain = r._deltachain(rev)[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
656 for iterrev in chain: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
657 e = index[iterrev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
658 chainsize += e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
659 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
660 return compsize, uncompsize, deltatype, chain, chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
661 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
662 fm = ui.formatter('debugdeltachain', opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
663 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
664 fm.plain(' rev chain# chainlen prev delta ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
665 'size rawsize chainsize ratio lindist extradist ' |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
666 'extraratio') |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
667 if withsparseread: |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
668 fm.plain(' readsize largestblk rddensity srchunks') |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
669 fm.plain('\n') |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
670 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
671 chainbases = {} |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
672 for rev in r: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
673 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
674 chainbase = chain[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
675 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
676 basestart = start(chainbase) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
677 revstart = start(rev) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
678 lineardist = revstart + comp - basestart |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
679 extradist = lineardist - chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
680 try: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
681 prevrev = chain[-2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
682 except IndexError: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
683 prevrev = -1 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
684 |
38646
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
685 if uncomp != 0: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
686 chainratio = float(chainsize) / float(uncomp) |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
687 else: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
688 chainratio = chainsize |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
689 |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
690 if chainsize != 0: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
691 extraratio = float(extradist) / float(chainsize) |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
692 else: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38612
diff
changeset
|
693 extraratio = extradist |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
694 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
695 fm.startitem() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
696 fm.write('rev chainid chainlen prevrev deltatype compsize ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
697 'uncompsize chainsize chainratio lindist extradist ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
698 'extraratio', |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
699 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f', |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
700 rev, chainid, len(chain), prevrev, deltatype, comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
701 uncomp, chainsize, chainratio, lineardist, extradist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
702 extraratio, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
703 rev=rev, chainid=chainid, chainlen=len(chain), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
704 prevrev=prevrev, deltatype=deltatype, compsize=comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
705 uncompsize=uncomp, chainsize=chainsize, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
706 chainratio=chainratio, lindist=lineardist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
707 extradist=extradist, extraratio=extraratio) |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
708 if withsparseread: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
709 readsize = 0 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
710 largestblock = 0 |
35728
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
711 srchunks = 0 |
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
712 |
39330
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
713 for revschunk in deltautil.slicechunk(r, chain): |
35728
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
714 srchunks += 1 |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
715 blkend = start(revschunk[-1]) + length(revschunk[-1]) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
716 blksize = blkend - start(revschunk[0]) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
717 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
718 readsize += blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
719 if largestblock < blksize: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
720 largestblock = blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
721 |
38647
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
722 if readsize: |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
723 readdensity = float(chainsize) / float(readsize) |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
724 else: |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
725 readdensity = 1 |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
726 |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
727 fm.write('readsize largestblock readdensity srchunks', |
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
728 ' %10d %10d %9.5f %8d', |
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
729 readsize, largestblock, readdensity, srchunks, |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
730 readsize=readsize, largestblock=largestblock, |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
731 readdensity=readdensity, srchunks=srchunks) |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
732 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
733 fm.plain('\n') |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
734 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
735 fm.end() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
736 |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
737 @command('debugdirstate|debugstate', |
39760
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
738 [('', 'nodates', None, _('do not display the saved mtime (DEPRECATED)')), |
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
739 ('', 'dates', True, _('display the saved mtime')), |
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
740 ('', 'datesort', None, _('sort by saved mtime'))], |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
741 _('[OPTION]...')) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
742 def debugstate(ui, repo, **opts): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
743 """show the contents of the current dirstate""" |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
744 |
39760
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
745 nodates = not opts[r'dates'] |
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
746 if opts.get(r'nodates') is not None: |
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
747 nodates = True |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
748 datesort = opts.get(r'datesort') |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
749 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
750 if datesort: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
751 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
752 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
753 keyfunc = None # sort by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
754 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
755 if ent[3] == -1: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
756 timestr = 'unset ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
757 elif nodates: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
758 timestr = 'set ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
759 else: |
35151
b45a9d121b53
py3: make sure the first argument of time.strftime() is str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35144
diff
changeset
|
760 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ", |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
761 time.localtime(ent[3])) |
35204
d4b108fdf423
py3: use encoding.strtolocal() to convert string to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35151
diff
changeset
|
762 timestr = encoding.strtolocal(timestr) |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
763 if ent[1] & 0o20000: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
764 mode = 'lnk' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
765 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
766 mode = '%3o' % (ent[1] & 0o777 & ~util.umask) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
767 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
768 for f in repo.dirstate.copies(): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
769 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
770 |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
771 @command('debugdiscovery', |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
772 [('', 'old', None, _('use old-style discovery')), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
773 ('', 'nonheads', None, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
774 _('use old-style discovery with non-heads included')), |
35304
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
775 ('', 'rev', [], 'restrict discovery to this set of revs'), |
42030
6ae1a776dd1a
debugdiscovery: allow to select random seed during debugdiscovery run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41964
diff
changeset
|
776 ('', 'seed', '12323', 'specify the random seed use for discovery'), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
777 ] + cmdutil.remoteopts, |
35424
702e6d2642e7
debugdiscovery: correct and clean up command synopsis
Martin von Zweigbergk <martinvonz@google.com>
parents:
35419
diff
changeset
|
778 _('[--rev REV] [OTHER]')) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
779 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
780 """runs the changeset discovery protocol in isolation""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
781 opts = pycompat.byteskwargs(opts) |
35417
2105bdd9462a
debugdiscovery: drop reference to invalid --branch option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35401
diff
changeset
|
782 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
783 remote = hg.peer(repo, opts, remoteurl) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
784 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
785 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
786 # make sure tests are repeatable |
42030
6ae1a776dd1a
debugdiscovery: allow to select random seed during debugdiscovery run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41964
diff
changeset
|
787 random.seed(int(opts['seed'])) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
788 |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
789 |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
790 |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
791 if opts.get('old'): |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
792 def doit(pushedrevs, remoteheads, remote=remote): |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
793 if not util.safehasattr(remote, 'branches'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
794 # enable in-client legacy support |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
795 remote = localrepo.locallegacypeer(remote.local()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
796 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
797 force=True) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
798 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
799 if not opts.get('nonheads'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
800 ui.write(("unpruned common: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
801 " ".join(sorted(short(n) for n in common))) |
39163
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
802 |
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
803 clnode = repo.changelog.node |
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
804 common = repo.revs('heads(::%ln)', common) |
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
805 common = {clnode(r) for r in common} |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
806 return common, hds |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
807 else: |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
808 def doit(pushedrevs, remoteheads, remote=remote): |
35304
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
809 nodes = None |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
810 if pushedrevs: |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
811 revs = scmutil.revrange(repo, pushedrevs) |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
812 nodes = [repo[r].node() for r in revs] |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
813 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
814 ancestorsof=nodes) |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
815 return common, hds |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
816 |
35419
fed2c040764e
debugdiscovery: drop reference to non-existent --remote-head option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35418
diff
changeset
|
817 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
35418
c73d23cbb129
debugdiscovery: drop reference to non-existent --serverlog option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35417
diff
changeset
|
818 localrevs = opts['rev'] |
42035
eec20025ada3
debugdiscovery: display time elapsed during the discovery step
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42034
diff
changeset
|
819 with util.timedcm('debug-discovery') as t: |
eec20025ada3
debugdiscovery: display time elapsed during the discovery step
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42034
diff
changeset
|
820 common, hds = doit(localrevs, remoterevs) |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
821 |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
822 # compute all statistics |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
823 common = set(common) |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
824 rheads = set(hds) |
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
825 lheads = set(repo.heads()) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
826 |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
827 data = {} |
42035
eec20025ada3
debugdiscovery: display time elapsed during the discovery step
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42034
diff
changeset
|
828 data['elapsed'] = t.elapsed |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
829 data['nb-common'] = len(common) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
830 data['nb-common-local'] = len(common & lheads) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
831 data['nb-common-remote'] = len(common & rheads) |
42145
607a0de9bae3
debugdiscovery: include the number of heads in all sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42100
diff
changeset
|
832 data['nb-common-both'] = len(common & rheads & lheads) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
833 data['nb-local'] = len(lheads) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
834 data['nb-local-missing'] = data['nb-local'] - data['nb-common-local'] |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
835 data['nb-remote'] = len(rheads) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
836 data['nb-remote-unknown'] = data['nb-remote'] - data['nb-common-remote'] |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
837 data['nb-revs'] = len(repo.revs('all()')) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
838 data['nb-revs-common'] = len(repo.revs('::%ln', common)) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
839 data['nb-revs-missing'] = data['nb-revs'] - data['nb-revs-common'] |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
840 |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
841 # display discovery summary |
42035
eec20025ada3
debugdiscovery: display time elapsed during the discovery step
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42034
diff
changeset
|
842 ui.write(("elapsed time: %(elapsed)f seconds\n") % data) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
843 ui.write(("heads summary:\n")) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
844 ui.write((" total common heads: %(nb-common)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
845 ui.write((" also local heads: %(nb-common-local)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
846 ui.write((" also remote heads: %(nb-common-remote)9d\n") % data) |
42145
607a0de9bae3
debugdiscovery: include the number of heads in all sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42100
diff
changeset
|
847 ui.write((" both: %(nb-common-both)9d\n") % data) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
848 ui.write((" local heads: %(nb-local)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
849 ui.write((" common: %(nb-common-local)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
850 ui.write((" missing: %(nb-local-missing)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
851 ui.write((" remote heads: %(nb-remote)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
852 ui.write((" common: %(nb-common-remote)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
853 ui.write((" unknown: %(nb-remote-unknown)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
854 ui.write(("local changesets: %(nb-revs)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
855 ui.write((" common: %(nb-revs-common)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
856 ui.write((" missing: %(nb-revs-missing)9d\n") % data) |
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
857 |
42034
fd8d13ea1bcc
debugdiscovery: only list common heads on verbose
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42033
diff
changeset
|
858 if ui.verbose: |
fd8d13ea1bcc
debugdiscovery: only list common heads on verbose
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42033
diff
changeset
|
859 ui.write(("common heads: %s\n") % |
fd8d13ea1bcc
debugdiscovery: only list common heads on verbose
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42033
diff
changeset
|
860 " ".join(sorted(short(n) for n in common))) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
861 |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
862 _chunksize = 4 << 10 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
863 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
864 @command('debugdownload', |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
865 [ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
866 ('o', 'output', '', _('path')), |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
867 ], |
35730
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
868 optionalrepo=True) |
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
869 def debugdownload(ui, repo, url, output=None, **opts): |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
870 """download a resource using Mercurial logic and config |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
871 """ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
872 fh = urlmod.open(ui, url, output) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
873 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
874 dest = ui |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
875 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
876 dest = open(output, "wb", _chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
877 try: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
878 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
879 while data: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
880 dest.write(data) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
881 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
882 finally: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
883 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
884 dest.close() |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
885 |
37977
8ba0344f9fb1
debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
886 @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True) |
8ba0344f9fb1
debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
887 def debugextensions(ui, repo, **opts): |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
888 '''show information about active extensions''' |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
889 opts = pycompat.byteskwargs(opts) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
890 exts = extensions.extensions(ui) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
891 hgver = util.version() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
892 fm = ui.formatter('debugextensions', opts) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
893 for extname, extmod in sorted(exts, key=operator.itemgetter(0)): |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
894 isinternal = extensions.ismoduleinternal(extmod) |
31074
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31024
diff
changeset
|
895 extsource = pycompat.fsencode(extmod.__file__) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
896 if isinternal: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
897 exttestedwith = [] # never expose magic string to users |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
898 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
899 exttestedwith = getattr(extmod, 'testedwith', '').split() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
900 extbuglink = getattr(extmod, 'buglink', None) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
901 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
902 fm.startitem() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
903 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
904 if ui.quiet or ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
905 fm.write('name', '%s\n', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
906 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
907 fm.write('name', '%s', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
908 if isinternal or hgver in exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
909 fm.plain('\n') |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
910 elif not exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
911 fm.plain(_(' (untested!)\n')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
912 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
913 lasttestedversion = exttestedwith[-1] |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
914 fm.plain(' (%s!)\n' % lasttestedversion) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
915 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
916 fm.condwrite(ui.verbose and extsource, 'source', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
917 _(' location: %s\n'), extsource or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
918 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
919 if ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
920 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
921 fm.data(bundled=isinternal) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
922 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
923 fm.condwrite(ui.verbose and exttestedwith, 'testedwith', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
924 _(' tested with: %s\n'), |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
925 fm.formatlist(exttestedwith, name='ver')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
926 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
927 fm.condwrite(ui.verbose and extbuglink, 'buglink', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
928 _(' bug reporting: %s\n'), extbuglink or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
929 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
930 fm.end() |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
931 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
932 @command('debugfileset', |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
933 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
934 ('', 'all-files', False, |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
935 _('test files from all revisions and working directory')), |
38802
f0a574dbfae9
debugfileset: add option to show matcher representation
Yuya Nishihara <yuya@tcha.org>
parents:
38801
diff
changeset
|
936 ('s', 'show-matcher', None, |
f0a574dbfae9
debugfileset: add option to show matcher representation
Yuya Nishihara <yuya@tcha.org>
parents:
38801
diff
changeset
|
937 _('print internal representation of matcher')), |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
938 ('p', 'show-stage', [], |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
939 _('print parsed tree at the given stage'), _('NAME'))], |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
940 _('[-r REV] [--all-files] [OPTION]... FILESPEC')) |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
941 def debugfileset(ui, repo, expr, **opts): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
942 '''parse and apply a fileset specification''' |
38972
4d992e3f10ba
debugcommands: force import of fileset in debugfileset
Augie Fackler <augie@google.com>
parents:
38829
diff
changeset
|
943 from . import fileset |
4d992e3f10ba
debugcommands: force import of fileset in debugfileset
Augie Fackler <augie@google.com>
parents:
38829
diff
changeset
|
944 fileset.symbols # force import of fileset so we have predicates to optimize |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
945 opts = pycompat.byteskwargs(opts) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
946 ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
947 |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
948 stages = [ |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
949 ('parsed', pycompat.identity), |
38826
6371ab78c3b3
fileset: add phase to transform parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
38814
diff
changeset
|
950 ('analyzed', filesetlang.analyze), |
38829
7e7e2b2ff284
fileset: add stub for weight-based optimization
Yuya Nishihara <yuya@tcha.org>
parents:
38826
diff
changeset
|
951 ('optimized', filesetlang.optimize), |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
952 ] |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
953 stagenames = set(n for n, f in stages) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
954 |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
955 showalways = set() |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
956 if ui.verbose and not opts['show_stage']: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
957 # show parsed tree by --verbose (deprecated) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
958 showalways.add('parsed') |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
959 if opts['show_stage'] == ['all']: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
960 showalways.update(stagenames) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
961 else: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
962 for n in opts['show_stage']: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
963 if n not in stagenames: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
964 raise error.Abort(_('invalid stage name: %s') % n) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
965 showalways.update(opts['show_stage']) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
966 |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38802
diff
changeset
|
967 tree = filesetlang.parse(expr) |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
968 for n, f in stages: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
969 tree = f(tree) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
970 if n in showalways: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
971 if opts['show_stage'] or n != 'parsed': |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
972 ui.write(("* %s:\n") % n) |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38802
diff
changeset
|
973 ui.write(filesetlang.prettyformat(tree), "\n") |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
974 |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
975 files = set() |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
976 if opts['all_files']: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
977 for r in repo: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
978 c = repo[r] |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
979 files.update(c.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
980 files.update(c.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
981 if opts['all_files'] or ctx.rev() is None: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
982 wctx = repo[None] |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
983 files.update(repo.dirstate.walk(scmutil.matchall(repo), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
984 subrepos=list(wctx.substate), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
985 unknown=True, ignored=True)) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
986 files.update(wctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
987 else: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
988 files.update(ctx.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
989 files.update(ctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
990 |
38612
760cc5dc01e8
fileset: restrict getfileset() to not return a computed set (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38610
diff
changeset
|
991 m = ctx.matchfileset(expr) |
38802
f0a574dbfae9
debugfileset: add option to show matcher representation
Yuya Nishihara <yuya@tcha.org>
parents:
38801
diff
changeset
|
992 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): |
f0a574dbfae9
debugfileset: add option to show matcher representation
Yuya Nishihara <yuya@tcha.org>
parents:
38801
diff
changeset
|
993 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
994 for f in sorted(files): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
995 if not m(f): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
996 continue |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
997 ui.write("%s\n" % f) |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
998 |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
999 @command('debugformat', |
38814
96b2e66dfa74
i18n: omit redundant translatable synopsis text to avoid xgettext warning
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
38805
diff
changeset
|
1000 [] + cmdutil.formatteropts) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1001 def debugformat(ui, repo, **opts): |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1002 """display format information about the current repository |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1003 |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1004 Use --verbose to get extra information about current config value and |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1005 Mercurial default.""" |
35401
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35400
diff
changeset
|
1006 opts = pycompat.byteskwargs(opts) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1007 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1008 maxvariantlength = max(len('format-variant'), maxvariantlength) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1009 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1010 def makeformatname(name): |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1011 return '%s:' + (' ' * (maxvariantlength - len(name))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1012 |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1013 fm = ui.formatter('debugformat', opts) |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1014 if fm.isplain(): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1015 def formatvalue(value): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1016 if util.safehasattr(value, 'startswith'): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1017 return value |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1018 if value: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1019 return 'yes' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1020 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1021 return 'no' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1022 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1023 formatvalue = pycompat.identity |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1024 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1025 fm.plain('format-variant') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1026 fm.plain(' ' * (maxvariantlength - len('format-variant'))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1027 fm.plain(' repo') |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1028 if ui.verbose: |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1029 fm.plain(' config default') |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1030 fm.plain('\n') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1031 for fv in upgrade.allformatvariant: |
35377
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35339
diff
changeset
|
1032 fm.startitem() |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1033 repovalue = fv.fromrepo(repo) |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1034 configvalue = fv.fromconfig(repo) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1035 |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1036 if repovalue != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1037 namelabel = 'formatvariant.name.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1038 repolabel = 'formatvariant.repo.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1039 elif repovalue != fv.default: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1040 namelabel = 'formatvariant.name.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1041 repolabel = 'formatvariant.repo.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1042 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1043 namelabel = 'formatvariant.name.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1044 repolabel = 'formatvariant.repo.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1045 |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1046 fm.write('name', makeformatname(fv.name), fv.name, |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1047 label=namelabel) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1048 fm.write('repo', ' %3s', formatvalue(repovalue), |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1049 label=repolabel) |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1050 if fv.default != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1051 configlabel = 'formatvariant.config.special' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1052 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1053 configlabel = 'formatvariant.config.default' |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1054 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue), |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1055 label=configlabel) |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1056 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default), |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1057 label='formatvariant.default') |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1058 fm.plain('\n') |
35377
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35339
diff
changeset
|
1059 fm.end() |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1060 |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1061 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1062 def debugfsinfo(ui, path="."): |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1063 """show information detected about current filesystem""" |
35514
5880318624c9
debugfs: display the tested path and mount point of the filesystem, if known
Matt Harbison <matt_harbison@yahoo.com>
parents:
35469
diff
changeset
|
1064 ui.write(('path: %s\n') % path) |
5880318624c9
debugfs: display the tested path and mount point of the filesystem, if known
Matt Harbison <matt_harbison@yahoo.com>
parents:
35469
diff
changeset
|
1065 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)')) |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1066 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
31633
5b3d55a6821f
debugfsinfo: show fstype for given path
Jun Wu <quark@fb.com>
parents:
31595
diff
changeset
|
1067 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1068 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1069 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
31634
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1070 casesensitive = '(unknown)' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1071 try: |
38166
cc9aa88792fe
py3: wrap tempfile.NamedTemporaryFile() to return bytes fp.name
Yuya Nishihara <yuya@tcha.org>
parents:
38164
diff
changeset
|
1072 with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: |
31634
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1073 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1074 except OSError: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1075 pass |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1076 ui.write(('case-sensitive: %s\n') % casesensitive) |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1077 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1078 @command('debuggetbundle', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1079 [('H', 'head', [], _('id of head node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1080 ('C', 'common', [], _('id of common node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1081 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1082 _('REPO FILE [-H|-C ID]...'), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1083 norepo=True) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1084 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1085 """retrieves a bundle from a repo |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1086 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1087 Every ID must be a full-length hex node id string. Saves the bundle to the |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1088 given file. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1089 """ |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1090 opts = pycompat.byteskwargs(opts) |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1091 repo = hg.peer(ui, opts, repopath) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1092 if not repo.capable('getbundle'): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1093 raise error.Abort("getbundle() not supported by target repository") |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1094 args = {} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1095 if common: |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1096 args[r'common'] = [bin(s) for s in common] |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1097 if head: |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1098 args[r'heads'] = [bin(s) for s in head] |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1099 # TODO: get desired bundlecaps from command line. |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1100 args[r'bundlecaps'] = None |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1101 bundle = repo.getbundle('debug', **args) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1102 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1103 bundletype = opts.get('type', 'bzip2').lower() |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1104 btypes = {'none': 'HG10UN', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1105 'bzip2': 'HG10BZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1106 'gzip': 'HG10GZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1107 'bundle2': 'HG20'} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1108 bundletype = btypes.get(bundletype) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1109 if bundletype not in bundle2.bundletypes: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1110 raise error.Abort(_('unknown bundle type specified with --type')) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1111 bundle2.writebundle(ui, bundle, bundlepath, bundletype) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1112 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1113 @command('debugignore', [], '[FILE]') |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1114 def debugignore(ui, repo, *files, **opts): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1115 """display the combined ignore pattern and information about ignored files |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1116 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1117 With no argument display the combined ignore pattern. |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1118 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1119 Given space separated file names, shows if the given file is ignored and |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1120 if so, show the ignore rule (file and line number) that matched it. |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1121 """ |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1122 ignore = repo.dirstate._ignore |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1123 if not files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1124 # Show all the patterns |
36578
149fd142f498
debugcommands: fix repr in debugignore print with pycompat.bytestr
Augie Fackler <augie@google.com>
parents:
36534
diff
changeset
|
1125 ui.write("%s\n" % pycompat.byterepr(ignore)) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1126 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1127 m = scmutil.match(repo[None], pats=files) |
41636
be8741d42836
debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41515
diff
changeset
|
1128 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1129 for f in m.files(): |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1130 nf = util.normpath(f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1131 ignored = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1132 ignoredata = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1133 if nf != '.': |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1134 if ignore(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1135 ignored = nf |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1136 ignoredata = repo.dirstate._ignorefileandline(nf) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1137 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1138 for p in util.finddirs(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1139 if ignore(p): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1140 ignored = p |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1141 ignoredata = repo.dirstate._ignorefileandline(p) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1142 break |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1143 if ignored: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1144 if ignored == nf: |
41636
be8741d42836
debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41515
diff
changeset
|
1145 ui.write(_("%s is ignored\n") % uipathfn(f)) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1146 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1147 ui.write(_("%s is ignored because of " |
42100
b63b8b7ca5fa
messages: replace some instances of "folder" by "directory"
Martin von Zweigbergk <martinvonz@google.com>
parents:
42041
diff
changeset
|
1148 "containing directory %s\n") |
41636
be8741d42836
debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41515
diff
changeset
|
1149 % (uipathfn(f), ignored)) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1150 ignorefile, lineno, line = ignoredata |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1151 ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1152 % (ignorefile, lineno, line)) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1153 else: |
41636
be8741d42836
debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41515
diff
changeset
|
1154 ui.write(_("%s is not ignored\n") % uipathfn(f)) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1155 |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1156 @command('debugindex', cmdutil.debugrevlogopts + cmdutil.formatteropts, |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1157 _('-c|-m|FILE')) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1158 def debugindex(ui, repo, file_=None, **opts): |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1159 """dump index data for a storage primitive""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1160 opts = pycompat.byteskwargs(opts) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1161 store = cmdutil.openstorage(repo, 'debugindex', file_, opts) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1162 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1163 if ui.debugflag: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1164 shortfn = hex |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1165 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1166 shortfn = short |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1167 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1168 idlen = 12 |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1169 for i in store: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1170 idlen = len(shortfn(store.node(i))) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1171 break |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1172 |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1173 fm = ui.formatter('debugindex', opts) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1174 fm.plain(b' rev linkrev %s %s p2\n' % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1175 b'nodeid'.ljust(idlen), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1176 b'p1'.ljust(idlen))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1177 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1178 for rev in store: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1179 node = store.node(rev) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1180 parents = store.parents(node) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1181 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1182 fm.startitem() |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1183 fm.write(b'rev', b'%6d ', rev) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1184 fm.write(b'linkrev', '%7d ', store.linkrev(rev)) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1185 fm.write(b'node', '%s ', shortfn(node)) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1186 fm.write(b'p1', '%s ', shortfn(parents[0])) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1187 fm.write(b'p2', '%s', shortfn(parents[1])) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1188 fm.plain(b'\n') |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1189 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1190 fm.end() |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1191 |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
1192 @command('debugindexdot', cmdutil.debugrevlogopts, |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1193 _('-c|-m|FILE'), optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1194 def debugindexdot(ui, repo, file_=None, **opts): |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1195 """dump an index DAG as a graphviz dot file""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1196 opts = pycompat.byteskwargs(opts) |
39279
cb9cf42c902f
debugcommands: use openstorage() in debugindexdot
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1197 r = cmdutil.openstorage(repo, 'debugindexdot', file_, opts) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1198 ui.write(("digraph G {\n")) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1199 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1200 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1201 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1202 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1203 if pp[1] != nullid: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1204 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1205 ui.write("}\n") |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
1206 |
39980
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1207 @command('debugindexstats', []) |
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1208 def debugindexstats(ui, repo): |
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1209 """show stats related to the changelog index""" |
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1210 repo.changelog.shortest(nullid, 1) |
40365
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1211 index = repo.changelog.index |
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1212 if not util.safehasattr(index, 'stats'): |
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1213 raise error.Abort(_('debugindexstats only works with native code')) |
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1214 for k, v in sorted(index.stats().items()): |
40456
24cb8a6d4c20
py3: do not stringify integers in revlog stats by '%s'
Yuya Nishihara <yuya@tcha.org>
parents:
40365
diff
changeset
|
1215 ui.write('%s: %d\n' % (k, v)) |
39980
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1216 |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
1217 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1218 def debuginstall(ui, **opts): |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1219 '''test Mercurial installation |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1220 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1221 Returns 0 on success. |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1222 ''' |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1223 opts = pycompat.byteskwargs(opts) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1224 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1225 problems = 0 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1226 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1227 fm = ui.formatter('debuginstall', opts) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1228 fm.startitem() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1229 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1230 # encoding |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1231 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1232 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1233 try: |
34129
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
1234 codecs.lookup(pycompat.sysstr(encoding.encoding)) |
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
1235 except LookupError as inst: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
1236 err = stringutil.forcebytestr(inst) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1237 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1238 fm.condwrite(err, 'encodingerror', _(" %s\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1239 " (check that your locale is properly set)\n"), err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1240 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1241 # Python |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1242 fm.write('pythonexe', _("checking Python executable (%s)\n"), |
42523
49998d5ba66a
pycompat: make fewer assumptions about sys.executable
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
42451
diff
changeset
|
1243 pycompat.sysexecutable or _("unknown")) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1244 fm.write('pythonver', _("checking Python version (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1245 ("%d.%d.%d" % sys.version_info[:3])) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1246 fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1247 os.path.dirname(pycompat.fsencode(os.__file__))) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1248 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1249 security = set(sslutil.supportedprotocols) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1250 if sslutil.hassni: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1251 security.add('sni') |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1252 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1253 fm.write('pythonsecurity', _("checking Python security support (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1254 fm.formatlist(sorted(security), name='protocol', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1255 fmt='%s', sep=',')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1256 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1257 # These are warnings, not errors. So don't increment problem count. This |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1258 # may change in the future. |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1259 if 'tls1.2' not in security: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1260 fm.plain(_(' TLS 1.2 not supported by Python install; ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1261 'network connections lack modern security\n')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1262 if 'sni' not in security: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1263 fm.plain(_(' SNI not supported by Python install; may have ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1264 'connectivity issues with some servers\n')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1265 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1266 # TODO print CA cert info |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1267 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1268 # hg version |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1269 hgver = util.version() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1270 fm.write('hgver', _("checking Mercurial version (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1271 hgver.split('+')[0]) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1272 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1273 '+'.join(hgver.split('+')[1:])) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1274 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1275 # compiled modules |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1276 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1277 policy.policy) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1278 fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
31074
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31024
diff
changeset
|
1279 os.path.dirname(pycompat.fsencode(__file__))) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1280 |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1281 rustandc = policy.policy in ('rust+c', 'rust+c-allow') |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1282 rustext = rustandc # for now, that's the only case |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1283 cext = policy.policy in ('c', 'allow') or rustandc |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1284 nopure = cext or rustext |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1285 if nopure: |
32209
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1286 err = None |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1287 try: |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1288 if cext: |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1289 from .cext import ( |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1290 base85, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1291 bdiff, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1292 mpatch, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1293 osutil, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1294 ) |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1295 # quiet pyflakes |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1296 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1297 if rustext: |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1298 from .rustext import ( |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1299 ancestor, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1300 dirstate, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1301 ) |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
1302 dir(ancestor), dir(dirstate) # quiet pyflakes |
32209
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1303 except Exception as inst: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
1304 err = stringutil.forcebytestr(inst) |
32209
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1305 problems += 1 |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1306 fm.condwrite(err, 'extensionserror', " %s\n", err) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1307 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1308 compengines = util.compengines._engines.values() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1309 fm.write('compengines', _('checking registered compression engines (%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1310 fm.formatlist(sorted(e.name() for e in compengines), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1311 name='compengine', fmt='%s', sep=', ')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1312 fm.write('compenginesavail', _('checking available compression engines ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1313 '(%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1314 fm.formatlist(sorted(e.name() for e in compengines |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1315 if e.available()), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1316 name='compengine', fmt='%s', sep=', ')) |
42041
3e47d1ec9da5
util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42035
diff
changeset
|
1317 wirecompengines = compression.compengines.supportedwireengines( |
3e47d1ec9da5
util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42035
diff
changeset
|
1318 compression.SERVERROLE) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1319 fm.write('compenginesserver', _('checking available compression engines ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1320 'for wire protocol (%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1321 fm.formatlist([e.name() for e in wirecompengines |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1322 if e.wireprotosupport()], |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1323 name='compengine', fmt='%s', sep=', ')) |
35448
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
1324 re2 = 'missing' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
1325 if util._re2: |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
1326 re2 = 'available' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
1327 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2) |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
1328 fm.data(re2=bool(util._re2)) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1329 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1330 # templates |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1331 p = templater.templatepaths() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1332 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1333 fm.condwrite(not p, '', _(" no template directories found\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1334 if p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1335 m = templater.templatepath("map-cmdline.default") |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1336 if m: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1337 # template found, check if it is working |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1338 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1339 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1340 templater.templater.frommapfile(m) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1341 except Exception as inst: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
1342 err = stringutil.forcebytestr(inst) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1343 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1344 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1345 else: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1346 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1347 fm.condwrite(p, 'defaulttemplate', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1348 _("checking default template (%s)\n"), m) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1349 fm.condwrite(not m, 'defaulttemplatenotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1350 _(" template '%s' not found\n"), "default") |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1351 if not p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1352 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1353 fm.condwrite(not p, '', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1354 _(" (templates seem to have been installed incorrectly)\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1355 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1356 # editor |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1357 editor = ui.geteditor() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1358 editor = util.expandpath(editor) |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
1359 editorbin = procutil.shellsplit(editor)[0] |
36236
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36153
diff
changeset
|
1360 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
1361 cmdpath = procutil.findexe(editorbin) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1362 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1363 _(" No commit editor set and can't find %s in PATH\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1364 " (specify a commit editor in your configuration" |
36236
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36153
diff
changeset
|
1365 " file)\n"), not cmdpath and editor == 'vi' and editorbin) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1366 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1367 _(" Can't find editor '%s' in PATH\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1368 " (specify a commit editor in your configuration" |
36236
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36153
diff
changeset
|
1369 " file)\n"), not cmdpath and editorbin) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1370 if not cmdpath and editor != 'vi': |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1371 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1372 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1373 # check username |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1374 username = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1375 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1376 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1377 username = ui.username() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1378 except error.Abort as e: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
1379 err = stringutil.forcebytestr(e) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1380 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1381 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1382 fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1383 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1384 " (specify a username in your configuration file)\n"), err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1385 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1386 fm.condwrite(not problems, '', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1387 _("no problems detected\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1388 if not problems: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1389 fm.data(problems=problems) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1390 fm.condwrite(problems, 'problems', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1391 _("%d problems detected," |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1392 " please check your install!\n"), problems) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1393 fm.end() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1394 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1395 return problems |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1396 |
30919
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1397 @command('debugknown', [], _('REPO ID...'), norepo=True) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1398 def debugknown(ui, repopath, *ids, **opts): |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1399 """test whether node ids are known to a repo |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1400 |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1401 Every ID must be a full-length hex node id string. Returns a list of 0s |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1402 and 1s indicating unknown/known. |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1403 """ |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1404 opts = pycompat.byteskwargs(opts) |
30919
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1405 repo = hg.peer(ui, opts, repopath) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1406 if not repo.capable('known'): |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1407 raise error.Abort("known() not supported by target repository") |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1408 flags = repo.known([bin(s) for s in ids]) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1409 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1410 |
30935
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1411 @command('debuglabelcomplete', [], _('LABEL...')) |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1412 def debuglabelcomplete(ui, repo, *args): |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1413 '''backwards compatibility with old bash completion scripts (DEPRECATED)''' |
31402
ea0395eec67b
debuglabelcomplete: fix to call debugnamecomplete in new location
Kyle Lippincott <spectral@google.com>
parents:
31239
diff
changeset
|
1414 debugnamecomplete(ui, repo, *args) |
30935
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1415 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1416 @command('debuglocks', |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1417 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1418 ('W', 'force-wlock', None, |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1419 _('free the working state lock (DANGEROUS)')), |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1420 ('s', 'set-lock', None, _('set the store lock until stopped')), |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1421 ('S', 'set-wlock', None, |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1422 _('set the working state lock until stopped'))], |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1423 _('[OPTION]...')) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1424 def debuglocks(ui, repo, **opts): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1425 """show or modify state of locks |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1426 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1427 By default, this command will show which locks are held. This |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1428 includes the user and process holding the lock, the amount of time |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1429 the lock has been held, and the machine name where the process is |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1430 running if it's not local. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1431 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1432 Locks protect the integrity of Mercurial's data, so should be |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1433 treated with care. System crashes or other interruptions may cause |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1434 locks to not be properly released, though Mercurial will usually |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1435 detect and remove such stale locks automatically. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1436 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1437 However, detecting stale locks may not always be possible (for |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1438 instance, on a shared filesystem). Removing locks may also be |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1439 blocked by filesystem permissions. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1440 |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1441 Setting a lock will prevent other commands from changing the data. |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1442 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs. |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1443 The set locks are removed when the command exits. |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1444 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1445 Returns 0 if no locks are held. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1446 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1447 """ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1448 |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1449 if opts.get(r'force_lock'): |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1450 repo.svfs.unlink('lock') |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1451 if opts.get(r'force_wlock'): |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1452 repo.vfs.unlink('wlock') |
35394
a43b2dd95e4f
debuglocks: add tests (and fix typo in early return)
Paul Morelle <paul.morelle@octobus.net>
parents:
35378
diff
changeset
|
1453 if opts.get(r'force_lock') or opts.get(r'force_wlock'): |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1454 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1455 |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1456 locks = [] |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1457 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1458 if opts.get(r'set_wlock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1459 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1460 locks.append(repo.wlock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1461 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1462 raise error.Abort(_('wlock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1463 if opts.get(r'set_lock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1464 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1465 locks.append(repo.lock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1466 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1467 raise error.Abort(_('lock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1468 if len(locks): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1469 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes")) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1470 return 0 |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1471 finally: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1472 release(*locks) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
1473 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1474 now = time.time() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1475 held = 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1476 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1477 def report(vfs, name, method): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1478 # this causes stale locks to get reaped for more accurate reporting |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1479 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1480 l = method(False) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1481 except error.LockHeld: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1482 l = None |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1483 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1484 if l: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1485 l.release() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1486 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1487 try: |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36778
diff
changeset
|
1488 st = vfs.lstat(name) |
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36778
diff
changeset
|
1489 age = now - st[stat.ST_MTIME] |
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36778
diff
changeset
|
1490 user = util.username(st.st_uid) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1491 locker = vfs.readlock(name) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1492 if ":" in locker: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1493 host, pid = locker.split(':') |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1494 if host == socket.gethostname(): |
39884
9c8eff5cfa1b
py3: mask out None type when printing in `debuglocks`
Matt Harbison <matt_harbison@yahoo.com>
parents:
39826
diff
changeset
|
1495 locker = 'user %s, process %s' % (user or b'None', pid) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1496 else: |
41759
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41755
diff
changeset
|
1497 locker = ('user %s, process %s, host %s' |
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41755
diff
changeset
|
1498 % (user or b'None', pid, host)) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1499 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1500 return 1 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1501 except OSError as e: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1502 if e.errno != errno.ENOENT: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1503 raise |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1504 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1505 ui.write(("%-6s free\n") % (name + ":")) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1506 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1507 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1508 held += report(repo.svfs, "lock", repo.lock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1509 held += report(repo.vfs, "wlock", repo.wlock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1510 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1511 return held |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1512 |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1513 @command('debugmanifestfulltextcache', [ |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1514 ('', 'clear', False, _('clear the cache')), |
41958
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1515 ('a', 'add', [], _('add the given manifest nodes to the cache'), |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1516 _('NODE')) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1517 ], '') |
41958
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1518 def debugmanifestfulltextcache(ui, repo, add=(), **opts): |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1519 """show, clear or amend the contents of the manifest fulltext cache""" |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1520 |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1521 def getcache(): |
39244
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39163
diff
changeset
|
1522 r = repo.manifestlog.getstorage(b'') |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1523 try: |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1524 return r._fulltextcache |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1525 except AttributeError: |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1526 msg = _("Current revlog implementation doesn't appear to have a " |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1527 "manifest fulltext cache\n") |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1528 raise error.Abort(msg) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1529 |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1530 if opts.get(r'clear'): |
41964
d121823072b8
manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41959
diff
changeset
|
1531 with repo.wlock(): |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1532 cache = getcache() |
41947
b74ef67573e5
manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41943
diff
changeset
|
1533 cache.clear(clear_persisted_data=True) |
b74ef67573e5
manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41943
diff
changeset
|
1534 return |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1535 |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1536 if add: |
41964
d121823072b8
manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41959
diff
changeset
|
1537 with repo.wlock(): |
41958
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1538 m = repo.manifestlog |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1539 store = m.getstorage(b'') |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1540 for n in add: |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1541 try: |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1542 manifest = m[store.lookup(n)] |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1543 except error.LookupError as e: |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1544 raise error.Abort(e, hint="Check your manifest node id") |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
1545 manifest.read() # stores revisision in cache too |
41943
1e75311d78f7
manifestcache: do not display data when using --add
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41942
diff
changeset
|
1546 return |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1547 |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1548 cache = getcache() |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1549 if not len(cache): |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1550 ui.write(_('cache empty\n')) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1551 else: |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1552 ui.write( |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1553 _('cache contains %d manifest entries, in order of most to ' |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1554 'least recent:\n') % (len(cache),)) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1555 totalsize = 0 |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1556 for nodeid in cache: |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1557 # Use cache.get to not update the LRU order |
41959
e3307243d188
manifestcache: stop altering the lru cache order while displaying it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41958
diff
changeset
|
1558 data = cache.peek(nodeid) |
41942
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1559 size = len(data) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1560 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1561 ui.write(_('id: %s, size %s\n') % ( |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1562 hex(nodeid), util.bytecount(size))) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1563 ondisk = cache._opener.stat('manifestfulltextcache').st_size |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1564 ui.write( |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1565 _('total cache data size %s, on-disk %s\n') % ( |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1566 util.bytecount(totalsize), util.bytecount(ondisk)) |
fbee66c90cef
manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41941
diff
changeset
|
1567 ) |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1568 |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1569 @command('debugmergestate', [], '') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1570 def debugmergestate(ui, repo, *args): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1571 """print merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1572 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1573 Use --verbose to print out information about whether v1 or v2 merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1574 was chosen.""" |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1575 def _hashornull(h): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1576 if h == nullhex: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1577 return 'null' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1578 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1579 return h |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1580 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1581 def printrecords(version): |
36153
72d155a792b1
debugcommands: mergestate version is an int, use %d on it
Augie Fackler <augie@google.com>
parents:
36123
diff
changeset
|
1582 ui.write(('* version %d records\n') % version) |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1583 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1584 records = v1records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1585 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1586 records = v2records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1587 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1588 for rtype, record in records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1589 # pretty print some record types |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1590 if rtype == 'L': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1591 ui.write(('local: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1592 elif rtype == 'O': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1593 ui.write(('other: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1594 elif rtype == 'm': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1595 driver, mdstate = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1596 ui.write(('merge driver: %s (state "%s")\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1597 % (driver, mdstate)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1598 elif rtype in 'FDC': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1599 r = record.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1600 f, state, hash, lfile, afile, anode, ofile = r[0:7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1601 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1602 onode = 'not stored in v1 format' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1603 flags = r[7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1604 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1605 onode, flags = r[7:9] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1606 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1607 % (f, rtype, state, _hashornull(hash))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1608 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1609 ui.write((' ancestor path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1610 % (afile, _hashornull(anode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1611 ui.write((' other path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1612 % (ofile, _hashornull(onode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1613 elif rtype == 'f': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1614 filename, rawextras = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1615 extras = rawextras.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1616 i = 0 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1617 extrastrings = [] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1618 while i < len(extras): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1619 extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1620 i += 2 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1621 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1622 ui.write(('file extras: %s (%s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1623 % (filename, ', '.join(extrastrings))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1624 elif rtype == 'l': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1625 labels = record.split('\0', 2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1626 labels = [l for l in labels if len(l) > 0] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1627 ui.write(('labels:\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1628 ui.write((' local: %s\n' % labels[0])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1629 ui.write((' other: %s\n' % labels[1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1630 if len(labels) > 2: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1631 ui.write((' base: %s\n' % labels[2])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1632 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1633 ui.write(('unrecognized entry: %s\t%s\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1634 % (rtype, record.replace('\0', '\t'))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1635 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1636 # Avoid mergestate.read() since it may raise an exception for unsupported |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1637 # merge state records. We shouldn't be doing this, but this is OK since this |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1638 # command is pretty low-level. |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1639 ms = mergemod.mergestate(repo) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1640 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1641 # sort so that reasonable information is on top |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1642 v1records = ms._readrecordsv1() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1643 v2records = ms._readrecordsv2() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1644 order = 'LOml' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1645 def key(r): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1646 idx = order.find(r[0]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1647 if idx == -1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1648 return (1, r[1]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1649 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1650 return (0, idx) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1651 v1records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1652 v2records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1653 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1654 if not v1records and not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1655 ui.write(('no merge state found\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1656 elif not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1657 ui.note(('no version 2 merge state\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1658 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1659 elif ms._v1v2match(v1records, v2records): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1660 ui.note(('v1 and v2 states match: using v2\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1661 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1662 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1663 ui.note(('v1 and v2 states mismatch: using v1\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1664 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1665 if ui.verbose: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1666 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1667 |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1668 @command('debugnamecomplete', [], _('NAME...')) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1669 def debugnamecomplete(ui, repo, *args): |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1670 '''complete "names" - tags, open branch names, bookmark names''' |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1671 |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1672 names = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1673 # since we previously only listed open branches, we will handle that |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1674 # specially (after this for loop) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1675 for name, ns in repo.names.iteritems(): |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1676 if name != 'branches': |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1677 names.update(ns.listnames(repo)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1678 names.update(tag for (tag, heads, tip, closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1679 in repo.branchmap().iterbranches() if not closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1680 completions = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1681 if not args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1682 args = [''] |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1683 for a in args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1684 completions.update(n for n in names if n.startswith(a)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1685 ui.write('\n'.join(sorted(completions))) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1686 ui.write('\n') |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1687 |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1688 @command('debugobsolete', |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1689 [('', 'flags', 0, _('markers flag')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1690 ('', 'record-parents', False, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1691 _('record parent information for the precursor')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1692 ('r', 'rev', [], _('display markers relevant to REV')), |
32626
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32517
diff
changeset
|
1693 ('', 'exclusive', False, _('restrict display to markers only ' |
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32517
diff
changeset
|
1694 'relevant to REV')), |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1695 ('', 'index', False, _('display index of the marker')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1696 ('', 'delete', [], _('delete markers specified by indices')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
1697 ] + cmdutil.commitopts2 + cmdutil.formatteropts, |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1698 _('[OBSOLETED [REPLACEMENT ...]]')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1699 def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1700 """create arbitrary obsolete marker |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1701 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1702 With no arguments, displays the list of obsolescence markers.""" |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1703 |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1704 opts = pycompat.byteskwargs(opts) |
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1705 |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1706 def parsenodeid(s): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1707 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1708 # We do not use revsingle/revrange functions here to accept |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1709 # arbitrary node identifiers, possibly not present in the |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1710 # local repository. |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1711 n = bin(s) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1712 if len(n) != len(nullid): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1713 raise TypeError() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1714 return n |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1715 except TypeError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1716 raise error.Abort('changeset references must be full hexadecimal ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1717 'node identifiers') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1718 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1719 if opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1720 indices = [] |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1721 for v in opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1722 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1723 indices.append(int(v)) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1724 except ValueError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1725 raise error.Abort(_('invalid index value: %r') % v, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1726 hint=_('use integers for indices')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1727 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1728 if repo.currenttransaction(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1729 raise error.Abort(_('cannot delete obsmarkers in the middle ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1730 'of transaction.')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1731 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1732 with repo.lock(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1733 n = repair.deleteobsmarkers(repo.obsstore, indices) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1734 ui.write(_('deleted %i obsolescence markers\n') % n) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1735 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1736 return |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1737 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1738 if precursor is not None: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1739 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1740 raise error.Abort('cannot select revision when creating marker') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1741 metadata = {} |
38707
6b5ca1d0aa1e
obsolete: store user name and note in UTF-8 (issue5754) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38647
diff
changeset
|
1742 metadata['user'] = encoding.fromlocal(opts['user'] or ui.username()) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1743 succs = tuple(parsenodeid(succ) for succ in successors) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1744 l = repo.lock() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1745 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1746 tr = repo.transaction('debugobsolete') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1747 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1748 date = opts.get('date') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1749 if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
1750 date = dateutil.parsedate(date) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1751 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1752 date = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1753 prec = parsenodeid(precursor) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1754 parents = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1755 if opts['record_parents']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1756 if prec not in repo.unfiltered(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1757 raise error.Abort('cannot used --record-parents on ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1758 'unknown changesets') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1759 parents = repo.unfiltered()[prec].parents() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1760 parents = tuple(p.node() for p in parents) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1761 repo.obsstore.create(tr, prec, succs, opts['flags'], |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1762 parents=parents, date=date, |
32411
08d02c1d7e67
devel: use default-date config field when creating obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
32406
diff
changeset
|
1763 metadata=metadata, ui=ui) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1764 tr.close() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1765 except ValueError as exc: |
36492
6e90c59b6da1
py3: use pycompat.bytestr() to convert error instances to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36459
diff
changeset
|
1766 raise error.Abort(_('bad obsmarker input: %s') % |
6e90c59b6da1
py3: use pycompat.bytestr() to convert error instances to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36459
diff
changeset
|
1767 pycompat.bytestr(exc)) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1768 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1769 tr.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1770 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1771 l.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1772 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1773 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1774 revs = scmutil.revrange(repo, opts['rev']) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1775 nodes = [repo[r].node() for r in revs] |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
1776 markers = list(obsutil.getmarkers(repo, nodes=nodes, |
32626
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32517
diff
changeset
|
1777 exclusive=opts['exclusive'])) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1778 markers.sort(key=lambda x: x._data) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1779 else: |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
1780 markers = obsutil.getmarkers(repo) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1781 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1782 markerstoiter = markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1783 isrelevant = lambda m: True |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1784 if opts.get('rev') and opts.get('index'): |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
1785 markerstoiter = obsutil.getmarkers(repo) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1786 markerset = set(markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1787 isrelevant = lambda m: m in markerset |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1788 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1789 fm = ui.formatter('debugobsolete', opts) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1790 for i, m in enumerate(markerstoiter): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1791 if not isrelevant(m): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1792 # marker can be irrelevant when we're iterating over a set |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1793 # of markers (markerstoiter) which is bigger than the set |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1794 # of markers we want to display (markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1795 # this can happen if both --index and --rev options are |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1796 # provided and thus we need to iterate over all of the markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1797 # to get the correct indices, but only display the ones that |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1798 # are relevant to --rev value |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1799 continue |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1800 fm.startitem() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1801 ind = i if opts.get('index') else None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1802 cmdutil.showmarker(fm, m, index=ind) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1803 fm.end() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1804 |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1805 @command('debugp1copies', |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1806 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1807 _('[-r REV]')) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1808 def debugp1copies(ui, repo, **opts): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1809 """dump copy information compared to p1""" |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1810 |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1811 opts = pycompat.byteskwargs(opts) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1812 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1813 for dst, src in ctx.p1copies().items(): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1814 ui.write('%s -> %s\n' % (src, dst)) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1815 |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1816 @command('debugp2copies', |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1817 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1818 _('[-r REV]')) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1819 def debugp1copies(ui, repo, **opts): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1820 """dump copy information compared to p2""" |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1821 |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1822 opts = pycompat.byteskwargs(opts) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1823 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1824 for dst, src in ctx.p2copies().items(): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1825 ui.write('%s -> %s\n' % (src, dst)) |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
1826 |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1827 @command('debugpathcomplete', |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1828 [('f', 'full', None, _('complete an entire path')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1829 ('n', 'normal', None, _('show only normal files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1830 ('a', 'added', None, _('show only added files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1831 ('r', 'removed', None, _('show only removed files'))], |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1832 _('FILESPEC...')) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1833 def debugpathcomplete(ui, repo, *specs, **opts): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1834 '''complete part or all of a tracked path |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1835 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1836 This command supports shells that offer path name completion. It |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1837 currently completes only files already known to the dirstate. |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1838 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1839 Completion extends only to the next path segment unless |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1840 --full is specified, in which case entire paths are used.''' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1841 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1842 def complete(path, acceptable): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1843 dirstate = repo.dirstate |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39760
diff
changeset
|
1844 spec = os.path.normpath(os.path.join(encoding.getcwd(), path)) |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1845 rootdir = repo.root + pycompat.ossep |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1846 if spec != repo.root and not spec.startswith(rootdir): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1847 return [], [] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1848 if os.path.isdir(spec): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1849 spec += '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1850 spec = spec[len(rootdir):] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1851 fixpaths = pycompat.ossep != '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1852 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1853 spec = spec.replace(pycompat.ossep, '/') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1854 speclen = len(spec) |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1855 fullpaths = opts[r'full'] |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1856 files, dirs = set(), set() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1857 adddir, addfile = dirs.add, files.add |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1858 for f, st in dirstate.iteritems(): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1859 if f.startswith(spec) and st[0] in acceptable: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1860 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1861 f = f.replace('/', pycompat.ossep) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1862 if fullpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1863 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1864 continue |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1865 s = f.find(pycompat.ossep, speclen) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1866 if s >= 0: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1867 adddir(f[:s]) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1868 else: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1869 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1870 return files, dirs |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1871 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1872 acceptable = '' |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1873 if opts[r'normal']: |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1874 acceptable += 'nm' |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1875 if opts[r'added']: |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1876 acceptable += 'a' |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
1877 if opts[r'removed']: |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1878 acceptable += 'r' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1879 cwd = repo.getcwd() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1880 if not specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1881 specs = ['.'] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1882 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1883 files, dirs = set(), set() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1884 for spec in specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1885 f, d = complete(spec, acceptable or 'nmar') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1886 files.update(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1887 dirs.update(d) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1888 files.update(dirs) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1889 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1890 ui.write('\n') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1891 |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1892 @command('debugpathcopies', |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1893 cmdutil.walkopts, |
41691
09814946cc6a
debugpathcopies: fix typo in synopsis
Martin von Zweigbergk <martinvonz@google.com>
parents:
41690
diff
changeset
|
1894 'hg debugpathcopies REV1 REV2 [FILE]', |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1895 inferrepo=True) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1896 def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts): |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1897 """show copies between two revisions""" |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1898 ctx1 = scmutil.revsingle(repo, rev1) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1899 ctx2 = scmutil.revsingle(repo, rev2) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1900 m = scmutil.match(ctx1, pats, opts) |
41749
f96988680afe
debugpathcopies: sort output so it's deterministic
Martin von Zweigbergk <martinvonz@google.com>
parents:
41691
diff
changeset
|
1901 for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()): |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1902 ui.write('%s -> %s\n' % (src, dst)) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1903 |
35929
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1904 @command('debugpeer', [], _('PATH'), norepo=True) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1905 def debugpeer(ui, path): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1906 """establish a connection to a peer repository""" |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1907 # Always enable peer request logging. Requires --debug to display |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1908 # though. |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1909 overrides = { |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1910 ('devel', 'debug.peer-request'): True, |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1911 } |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1912 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1913 with ui.configoverride(overrides): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1914 peer = hg.peer(ui, {}, path) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1915 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1916 local = peer.local() is not None |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1917 canpush = peer.canpush() |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1918 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1919 ui.write(_('url: %s\n') % peer.url()) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1920 ui.write(_('local: %s\n') % (_('yes') if local else _('no'))) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1921 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no'))) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
1922 |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1923 @command('debugpickmergetool', |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1924 [('r', 'rev', '', _('check for files in this revision'), _('REV')), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1925 ('', 'changedelete', None, _('emulate merging change and delete')), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
1926 ] + cmdutil.walkopts + cmdutil.mergetoolopts, |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1927 _('[PATTERN]...'), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1928 inferrepo=True) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1929 def debugpickmergetool(ui, repo, *pats, **opts): |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1930 """examine which merge tool is chosen for specified file |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1931 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1932 As described in :hg:`help merge-tools`, Mercurial examines |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1933 configurations below in this order to decide which merge tool is |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1934 chosen for specified file. |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1935 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1936 1. ``--tool`` option |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1937 2. ``HGMERGE`` environment variable |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1938 3. configurations in ``merge-patterns`` section |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1939 4. configuration of ``ui.merge`` |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1940 5. configurations in ``merge-tools`` section |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1941 6. ``hgmerge`` tool (for historical reason only) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1942 7. default tool for fallback (``:merge`` or ``:prompt``) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1943 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1944 This command writes out examination result in the style below:: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1945 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1946 FILE = MERGETOOL |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1947 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1948 By default, all files known in the first parent context of the |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1949 working directory are examined. Use file patterns and/or -I/-X |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1950 options to limit target files. -r/--rev is also useful to examine |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1951 files in another context without actual updating to it. |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1952 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1953 With --debug, this command shows warning messages while matching |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1954 against ``merge-patterns`` and so on, too. It is recommended to |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1955 use this option with explicit file patterns and/or -I/-X options, |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1956 because this option increases amount of output per file according |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1957 to configurations in hgrc. |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1958 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1959 With -v/--verbose, this command shows configurations below at |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1960 first (only if specified). |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1961 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1962 - ``--tool`` option |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1963 - ``HGMERGE`` environment variable |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1964 - configuration of ``ui.merge`` |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1965 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1966 If merge tool is chosen before matching against |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1967 ``merge-patterns``, this command can't show any helpful |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1968 information, even with --debug. In such case, information above is |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1969 useful to know why a merge tool is chosen. |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1970 """ |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1971 opts = pycompat.byteskwargs(opts) |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1972 overrides = {} |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1973 if opts['tool']: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1974 overrides[('ui', 'forcemerge')] = opts['tool'] |
36778
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36741
diff
changeset
|
1975 ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool']))) |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1976 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1977 with ui.configoverride(overrides, 'debugmergepatterns'): |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1978 hgmerge = encoding.environ.get("HGMERGE") |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1979 if hgmerge is not None: |
36778
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36741
diff
changeset
|
1980 ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge))) |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1981 uimerge = ui.config("ui", "merge") |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1982 if uimerge: |
36778
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36741
diff
changeset
|
1983 ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge))) |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1984 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1985 ctx = scmutil.revsingle(repo, opts.get('rev')) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1986 m = scmutil.match(ctx, pats, opts) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1987 changedelete = opts['changedelete'] |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1988 for path in ctx.walk(m): |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1989 fctx = ctx[path] |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1990 try: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1991 if not ui.debugflag: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1992 ui.pushbuffer(error=True) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1993 tool, toolpath = filemerge._picktool(repo, ui, path, |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1994 fctx.isbinary(), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1995 'l' in fctx.flags(), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1996 changedelete) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1997 finally: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1998 if not ui.debugflag: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
1999 ui.popbuffer() |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2000 ui.write(('%s = %s\n') % (path, tool)) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2001 |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2002 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2003 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2004 '''access the pushkey key/value protocol |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2005 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2006 With two args, list the keys in the given namespace. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2007 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2008 With five args, set a key to new if it currently is set to old. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2009 Reports success or failure. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2010 ''' |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2011 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2012 target = hg.peer(ui, {}, repopath) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2013 if keyinfo: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2014 key, old, new = keyinfo |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2015 with target.commandexecutor() as e: |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2016 r = e.callcommand('pushkey', { |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2017 'namespace': namespace, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2018 'key': key, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2019 'old': old, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2020 'new': new, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2021 }).result() |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
2022 |
36719
390d16ea7c76
py3: use pycompat.bytestr instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36607
diff
changeset
|
2023 ui.status(pycompat.bytestr(r) + '\n') |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2024 return not r |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2025 else: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2026 for k, v in sorted(target.listkeys(namespace).iteritems()): |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
2027 ui.write("%s\t%s\n" % (stringutil.escapestr(k), |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
2028 stringutil.escapestr(v))) |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2029 |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2030 @command('debugpvec', [], _('A B')) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2031 def debugpvec(ui, repo, a, b=None): |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2032 ca = scmutil.revsingle(repo, a) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2033 cb = scmutil.revsingle(repo, b) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2034 pa = pvec.ctxpvec(ca) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2035 pb = pvec.ctxpvec(cb) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2036 if pa == pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2037 rel = "=" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2038 elif pa > pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2039 rel = ">" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2040 elif pa < pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2041 rel = "<" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2042 elif pa | pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2043 rel = "|" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2044 ui.write(_("a: %s\n") % pa) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2045 ui.write(_("b: %s\n") % pb) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2046 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2047 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2048 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2049 pa.distance(pb), rel)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
2050 |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2051 @command('debugrebuilddirstate|debugrebuildstate', |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2052 [('r', 'rev', '', _('revision to rebuild to'), _('REV')), |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2053 ('', 'minimal', None, _('only rebuild files that are inconsistent with ' |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2054 'the working copy parent')), |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2055 ], |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2056 _('[-r REV]')) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2057 def debugrebuilddirstate(ui, repo, rev, **opts): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2058 """rebuild the dirstate as it would look like for the given revision |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2059 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2060 If no revision is specified the first current parent will be used. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2061 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2062 The dirstate will be set to the files of the given revision. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2063 The actual working directory content or existing dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2064 information such as adds or removes is not considered. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2065 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2066 ``minimal`` will only rebuild the dirstate status for files that claim to be |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2067 tracked but are not in the parent manifest, or that exist in the parent |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2068 manifest but are not in the dirstate. It will not change adds, removes, or |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2069 modified files that are in the working copy parent. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2070 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2071 One use of this command is to make the next :hg:`status` invocation |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2072 check the actual file content. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2073 """ |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2074 ctx = scmutil.revsingle(repo, rev) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2075 with repo.wlock(): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2076 dirstate = repo.dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2077 changedfiles = None |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2078 # See command doc for what minimal does. |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
2079 if opts.get(r'minimal'): |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2080 manifestfiles = set(ctx.manifest().keys()) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2081 dirstatefiles = set(dirstate) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2082 manifestonly = manifestfiles - dirstatefiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2083 dsonly = dirstatefiles - manifestfiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2084 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2085 changedfiles = manifestonly | dsnotadded |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2086 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2087 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
2088 |
30949
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
2089 @command('debugrebuildfncache', [], '') |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
2090 def debugrebuildfncache(ui, repo): |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
2091 """rebuild the fncache file""" |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
2092 repair.rebuildfncache(ui, repo) |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
2093 |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2094 @command('debugrename', |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2095 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
41690
ea72da71ad69
debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents:
41671
diff
changeset
|
2096 _('[-r REV] [FILE]...')) |
ea72da71ad69
debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents:
41671
diff
changeset
|
2097 def debugrename(ui, repo, *pats, **opts): |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2098 """dump rename information""" |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2099 |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
2100 opts = pycompat.byteskwargs(opts) |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2101 ctx = scmutil.revsingle(repo, opts.get('rev')) |
41690
ea72da71ad69
debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents:
41671
diff
changeset
|
2102 m = scmutil.match(ctx, pats, opts) |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2103 for abs in ctx.walk(m): |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2104 fctx = ctx[abs] |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2105 o = fctx.filelog().renamed(fctx.filenode()) |
41659
ecf7f4ef52fb
debugwalk: avoid match.rel() and use repo.pathto() instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
41636
diff
changeset
|
2106 rel = repo.pathto(abs) |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2107 if o: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2108 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2109 else: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2110 ui.write(_("%s not renamed\n") % rel) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
2111 |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
2112 @command('debugrevlog', cmdutil.debugrevlogopts + |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2113 [('d', 'dump', False, _('dump index data'))], |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2114 _('-c|-m|FILE'), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2115 optionalrepo=True) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2116 def debugrevlog(ui, repo, file_=None, **opts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2117 """show data and statistics about a revlog""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
2118 opts = pycompat.byteskwargs(opts) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2119 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2120 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2121 if opts.get("dump"): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2122 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2123 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2124 " rawsize totalsize compression heads chainlen\n")) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2125 ts = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2126 heads = set() |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2127 |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38781
diff
changeset
|
2128 for rev in pycompat.xrange(numrevs): |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2129 dbase = r.deltaparent(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2130 if dbase == -1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2131 dbase = rev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2132 cbase = r.chainbase(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2133 clen = r.chainlen(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2134 p1, p2 = r.parentrevs(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2135 rs = r.rawsize(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2136 ts = ts + rs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2137 heads -= set(r.parentrevs(rev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2138 heads.add(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2139 try: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2140 compression = ts / r.end(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2141 except ZeroDivisionError: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2142 compression = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2143 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2144 "%11d %5d %8d\n" % |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2145 (rev, p1, p2, r.start(rev), r.end(rev), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2146 r.start(dbase), r.start(cbase), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2147 r.start(p1), r.start(p2), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2148 rs, ts, compression, len(heads), clen)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2149 return 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2150 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2151 v = r.version |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2152 format = v & 0xFFFF |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2153 flags = [] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2154 gdelta = False |
32315
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
2155 if v & revlog.FLAG_INLINE_DATA: |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2156 flags.append('inline') |
32315
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32265
diff
changeset
|
2157 if v & revlog.FLAG_GENERALDELTA: |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2158 gdelta = True |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2159 flags.append('generaldelta') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2160 if not flags: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2161 flags = ['(none)'] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2162 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2163 ### tracks merge vs single parent |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2164 nummerges = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2165 |
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2166 ### tracks ways the "delta" are build |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2167 # nodelta |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2168 numempty = 0 |
39082
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2169 numemptytext = 0 |
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2170 numemptydelta = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2171 # full file content |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2172 numfull = 0 |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2173 # intermediate snapshot against a prior snapshot |
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2174 numsemi = 0 |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2175 # snapshot count per depth |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2176 numsnapdepth = collections.defaultdict(lambda: 0) |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2177 # delta against previous revision |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2178 numprev = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2179 # delta against first or second parent (not prev) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2180 nump1 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2181 nump2 = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2182 # delta against neither prev nor parents |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2183 numother = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2184 # delta against prev that are also first or second parent |
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2185 # (details of `numprev`) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2186 nump1prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2187 nump2prev = 0 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2188 |
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2189 # data about delta chain of each revs |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2190 chainlengths = [] |
33057
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2191 chainbases = [] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2192 chainspans = [] |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2193 |
39080
5c99486fcfe1
debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents:
39065
diff
changeset
|
2194 # data about each revision |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2195 datasize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2196 fullsize = [None, 0, 0] |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2197 semisize = [None, 0, 0] |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2198 # snapshot count per depth |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2199 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0]) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2200 deltasize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2201 chunktypecounts = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2202 chunktypesizes = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2203 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2204 def addsize(size, l): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2205 if l[0] is None or size < l[0]: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2206 l[0] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2207 if size > l[1]: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2208 l[1] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2209 l[2] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2210 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2211 numrevs = len(r) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38781
diff
changeset
|
2212 for rev in pycompat.xrange(numrevs): |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2213 p1, p2 = r.parentrevs(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2214 delta = r.deltaparent(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2215 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2216 addsize(r.rawsize(rev), datasize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2217 if p2 != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2218 nummerges += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2219 size = r.length(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2220 if delta == nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2221 chainlengths.append(0) |
33057
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2222 chainbases.append(r.start(rev)) |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2223 chainspans.append(size) |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2224 if size == 0: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2225 numempty += 1 |
39082
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2226 numemptytext += 1 |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2227 else: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2228 numfull += 1 |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2229 numsnapdepth[0] += 1 |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2230 addsize(size, fullsize) |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2231 addsize(size, snapsizedepth[0]) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2232 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2233 chainlengths.append(chainlengths[delta] + 1) |
33057
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2234 baseaddr = chainbases[delta] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2235 revaddr = r.start(rev) |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2236 chainbases.append(baseaddr) |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2237 chainspans.append((revaddr - baseaddr) + size) |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2238 if size == 0: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2239 numempty += 1 |
39082
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2240 numemptydelta += 1 |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2241 elif r.issnapshot(rev): |
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2242 addsize(size, semisize) |
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2243 numsemi += 1 |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2244 depth = r.snapshotdepth(rev) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2245 numsnapdepth[depth] += 1 |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2246 addsize(size, snapsizedepth[depth]) |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2247 else: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2248 addsize(size, deltasize) |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2249 if delta == rev - 1: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2250 numprev += 1 |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2251 if delta == p1: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2252 nump1prev += 1 |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2253 elif delta == p2: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2254 nump2prev += 1 |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2255 elif delta == p1: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2256 nump1 += 1 |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2257 elif delta == p2: |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2258 nump2 += 1 |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2259 elif delta != nullrev: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2260 numother += 1 |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2261 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2262 # Obtain data on the raw chunks in the revlog. |
39148
1464183343b3
debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents:
39082
diff
changeset
|
2263 if util.safehasattr(r, '_getsegmentforrevs'): |
1464183343b3
debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents:
39082
diff
changeset
|
2264 segment = r._getsegmentforrevs(rev, rev)[1] |
1464183343b3
debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents:
39082
diff
changeset
|
2265 else: |
1464183343b3
debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents:
39082
diff
changeset
|
2266 segment = r._revlog._getsegmentforrevs(rev, rev)[1] |
32229
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32209
diff
changeset
|
2267 if segment: |
33106
2f812b0d1936
py3: pass the memoryview object into bytes() to get the value
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33102
diff
changeset
|
2268 chunktype = bytes(segment[0:1]) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2269 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2270 chunktype = 'empty' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2271 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2272 if chunktype not in chunktypecounts: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2273 chunktypecounts[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2274 chunktypesizes[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2275 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2276 chunktypecounts[chunktype] += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2277 chunktypesizes[chunktype] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2278 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2279 # Adjust size min value for empty cases |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2280 for size in (datasize, fullsize, semisize, deltasize): |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2281 if size[0] is None: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2282 size[0] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2283 |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2284 numdeltas = numrevs - numfull - numempty - numsemi |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2285 numoprev = numprev - nump1prev - nump2prev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2286 totalrawsize = datasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2287 datasize[2] /= numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2288 fulltotal = fullsize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2289 fullsize[2] /= numfull |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2290 semitotal = semisize[2] |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2291 snaptotal = {} |
40029
e2697acd9381
cleanup: some Yoda conditions, this patch removes
Martin von Zweigbergk <martinvonz@google.com>
parents:
40017
diff
changeset
|
2292 if numsemi > 0: |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2293 semisize[2] /= numsemi |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2294 for depth in snapsizedepth: |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2295 snaptotal[depth] = snapsizedepth[depth][2] |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2296 snapsizedepth[depth][2] /= numsnapdepth[depth] |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2297 |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2298 deltatotal = deltasize[2] |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2299 if numdeltas > 0: |
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2300 deltasize[2] /= numdeltas |
39151
07b82f55f351
debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents:
39148
diff
changeset
|
2301 totalsize = fulltotal + semitotal + deltatotal |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2302 avgchainlen = sum(chainlengths) / numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2303 maxchainlen = max(chainlengths) |
33057
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33031
diff
changeset
|
2304 maxchainspan = max(chainspans) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2305 compratio = 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2306 if totalsize: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2307 compratio = totalrawsize / totalsize |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2308 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2309 basedfmtstr = '%%%dd\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2310 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2311 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2312 def dfmtstr(max): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2313 return basedfmtstr % len(str(max)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2314 def pcfmtstr(max, padding=0): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2315 return basepcfmtstr % (len(str(max)), ' ' * padding) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2316 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2317 def pcfmt(value, total): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2318 if total: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2319 return (value, 100 * float(value) / total) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2320 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2321 return value, 100.0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2322 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2323 ui.write(('format : %d\n') % format) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2324 ui.write(('flags : %s\n') % ', '.join(flags)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2325 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2326 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2327 fmt = pcfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2328 fmt2 = dfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2329 ui.write(('revisions : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2330 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2331 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2332 ui.write(('revisions : ') + fmt2 % numrevs) |
39081
195ed920653e
debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents:
39080
diff
changeset
|
2333 ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs)) |
39082
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2334 ui.write((' text : ') |
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2335 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)) |
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2336 ui.write((' delta : ') |
a456c603a83d
debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents:
39081
diff
changeset
|
2337 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)) |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2338 ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs)) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2339 for depth in sorted(numsnapdepth): |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2340 ui.write((' lvl-%-3d : ' % depth) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2341 + fmt % pcfmt(numsnapdepth[depth], numrevs)) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2342 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2343 ui.write(('revision size : ') + fmt2 % totalsize) |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2344 ui.write((' snapshot : ') |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2345 + fmt % pcfmt(fulltotal + semitotal, totalsize)) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2346 for depth in sorted(numsnapdepth): |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2347 ui.write((' lvl-%-3d : ' % depth) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2348 + fmt % pcfmt(snaptotal[depth], totalsize)) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2349 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2350 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2351 def fmtchunktype(chunktype): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2352 if chunktype == 'empty': |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2353 return ' %s : ' % chunktype |
33107
e88fdec9cb9e
py3: use pycompat.bytestr() to convert str to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33106
diff
changeset
|
2354 elif chunktype in pycompat.bytestr(string.ascii_letters): |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2355 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2356 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2357 return ' 0x%s : ' % hex(chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2358 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2359 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2360 ui.write(('chunks : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2361 for chunktype in sorted(chunktypecounts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2362 ui.write(fmtchunktype(chunktype)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2363 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2364 ui.write(('chunks size : ') + fmt2 % totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2365 for chunktype in sorted(chunktypecounts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2366 ui.write(fmtchunktype(chunktype)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2367 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2368 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2369 ui.write('\n') |
33062
e21b750c9b9e
debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents:
33057
diff
changeset
|
2370 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2371 ui.write(('avg chain length : ') + fmt % avgchainlen) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2372 ui.write(('max chain length : ') + fmt % maxchainlen) |
33062
e21b750c9b9e
debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents:
33057
diff
changeset
|
2373 ui.write(('max chain reach : ') + fmt % maxchainspan) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2374 ui.write(('compression ratio : ') + fmt % compratio) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2375 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2376 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2377 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2378 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2379 % tuple(datasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2380 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2381 % tuple(fullsize)) |
39153
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2382 ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n') |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2383 % tuple(semisize)) |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2384 for depth in sorted(snapsizedepth): |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2385 if depth == 0: |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2386 continue |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2387 ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n') |
9d6fab487c13
debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents:
39151
diff
changeset
|
2388 % ((depth,) + tuple(snapsizedepth[depth]))) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2389 ui.write(('delta size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2390 % tuple(deltasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2391 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2392 if numdeltas > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2393 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2394 fmt = pcfmtstr(numdeltas) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2395 fmt2 = pcfmtstr(numdeltas, 4) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2396 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2397 if numprev > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2398 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2399 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2400 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2401 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2402 ui.write((' other : ') + fmt2 % pcfmt(numoprev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2403 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2404 if gdelta: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2405 ui.write(('deltas against p1 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2406 + fmt % pcfmt(nump1, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2407 ui.write(('deltas against p2 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2408 + fmt % pcfmt(nump2, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2409 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2410 numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
2411 |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2412 @command('debugrevlogindex', cmdutil.debugrevlogopts + |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2413 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2414 _('[-f FORMAT] -c|-m|FILE'), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2415 optionalrepo=True) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2416 def debugrevlogindex(ui, repo, file_=None, **opts): |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2417 """dump the contents of a revlog index""" |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2418 opts = pycompat.byteskwargs(opts) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2419 r = cmdutil.openrevlog(repo, 'debugrevlogindex', file_, opts) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2420 format = opts.get('format', 0) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2421 if format not in (0, 1): |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2422 raise error.Abort(_("unknown format %d") % format) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2423 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2424 if ui.debugflag: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2425 shortfn = hex |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2426 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2427 shortfn = short |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2428 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2429 # There might not be anything in r, so have a sane default |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2430 idlen = 12 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2431 for i in r: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2432 idlen = len(shortfn(r.node(i))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2433 break |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2434 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2435 if format == 0: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2436 if ui.verbose: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2437 ui.write((" rev offset length linkrev" |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2438 " %s %s p2\n") % ("nodeid".ljust(idlen), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2439 "p1".ljust(idlen))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2440 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2441 ui.write((" rev linkrev %s %s p2\n") % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2442 "nodeid".ljust(idlen), "p1".ljust(idlen))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2443 elif format == 1: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2444 if ui.verbose: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2445 ui.write((" rev flag offset length size link p1" |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2446 " p2 %s\n") % "nodeid".rjust(idlen)) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2447 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2448 ui.write((" rev flag size link p1 p2 %s\n") % |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2449 "nodeid".rjust(idlen)) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2450 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2451 for i in r: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2452 node = r.node(i) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2453 if format == 0: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2454 try: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2455 pp = r.parents(node) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2456 except Exception: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2457 pp = [nullid, nullid] |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2458 if ui.verbose: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2459 ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2460 i, r.start(i), r.length(i), r.linkrev(i), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2461 shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2462 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2463 ui.write("% 6d % 7d %s %s %s\n" % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2464 i, r.linkrev(i), shortfn(node), shortfn(pp[0]), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2465 shortfn(pp[1]))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2466 elif format == 1: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2467 pr = r.parentrevs(i) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2468 if ui.verbose: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2469 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2470 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2471 r.linkrev(i), pr[0], pr[1], shortfn(node))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2472 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2473 ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % ( |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2474 i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1], |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2475 shortfn(node))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
2476 |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2477 @command('debugrevspec', |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2478 [('', 'optimize', None, |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2479 _('print parsed tree after optimizing (DEPRECATED)')), |
32797
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2480 ('', 'show-revs', True, _('print list of result revisions (default)')), |
32796
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32745
diff
changeset
|
2481 ('s', 'show-set', None, _('print internal representation of result set')), |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2482 ('p', 'show-stage', [], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2483 _('print parsed tree at the given stage'), _('NAME')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2484 ('', 'no-optimized', False, _('evaluate tree without optimization')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2485 ('', 'verify-optimized', False, _('verify optimized result')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2486 ], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2487 ('REVSPEC')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2488 def debugrevspec(ui, repo, expr, **opts): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2489 """parse and apply a revision specification |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2490 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2491 Use -p/--show-stage option to print the parsed tree at the given stages. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2492 Use -p all to print tree at every stage. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2493 |
32797
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2494 Use --no-show-revs option with -s or -p to print only the set |
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2495 representation or the parsed tree respectively. |
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2496 |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2497 Use --verify-optimized to compare the optimized result with the unoptimized |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2498 one. Returns 1 if the optimized result differs. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2499 """ |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
2500 opts = pycompat.byteskwargs(opts) |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2501 aliases = ui.configitems('revsetalias') |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2502 stages = [ |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2503 ('parsed', lambda tree: tree), |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2504 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases, |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2505 ui.warn)), |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
2506 ('concatenated', revsetlang.foldconcat), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
2507 ('analyzed', revsetlang.analyze), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
2508 ('optimized', revsetlang.optimize), |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2509 ] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2510 if opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2511 stages = stages[:-1] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2512 if opts['verify_optimized'] and opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2513 raise error.Abort(_('cannot use --verify-optimized with ' |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2514 '--no-optimized')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2515 stagenames = set(n for n, f in stages) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2516 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2517 showalways = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2518 showchanged = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2519 if ui.verbose and not opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2520 # show parsed tree by --verbose (deprecated) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2521 showalways.add('parsed') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2522 showchanged.update(['expanded', 'concatenated']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2523 if opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2524 showalways.add('optimized') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2525 if opts['show_stage'] and opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2526 raise error.Abort(_('cannot use --optimize with --show-stage')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2527 if opts['show_stage'] == ['all']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2528 showalways.update(stagenames) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2529 else: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2530 for n in opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2531 if n not in stagenames: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2532 raise error.Abort(_('invalid stage name: %s') % n) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2533 showalways.update(opts['show_stage']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2534 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2535 treebystage = {} |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2536 printedtree = None |
37350
e32dfff71529
revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37322
diff
changeset
|
2537 tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2538 for n, f in stages: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2539 treebystage[n] = tree = f(tree) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2540 if n in showalways or (n in showchanged and tree != printedtree): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2541 if opts['show_stage'] or n != 'parsed': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2542 ui.write(("* %s:\n") % n) |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
2543 ui.write(revsetlang.prettyformat(tree), "\n") |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2544 printedtree = tree |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2545 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2546 if opts['verify_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2547 arevs = revset.makematcher(treebystage['analyzed'])(repo) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2548 brevs = revset.makematcher(treebystage['optimized'])(repo) |
32796
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32745
diff
changeset
|
2549 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
38261
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
2550 ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n") |
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
2551 ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n") |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2552 arevs = list(arevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2553 brevs = list(brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2554 if arevs == brevs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2555 return 0 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2556 ui.write(('--- analyzed\n'), label='diff.file_a') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2557 ui.write(('+++ optimized\n'), label='diff.file_b') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2558 sm = difflib.SequenceMatcher(None, arevs, brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2559 for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
41671
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2560 if tag in (r'delete', r'replace'): |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2561 for c in arevs[alo:ahi]: |
41671
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2562 ui.write('-%d\n' % c, label='diff.deleted') |
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2563 if tag in (r'insert', r'replace'): |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2564 for c in brevs[blo:bhi]: |
41671
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2565 ui.write('+%d\n' % c, label='diff.inserted') |
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2566 if tag == r'equal': |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2567 for c in arevs[alo:ahi]: |
41671
34ae00a14783
py3: use raw strings and %d for formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41659
diff
changeset
|
2568 ui.write(' %d\n' % c) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2569 return 1 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2570 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2571 func = revset.makematcher(tree) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2572 revs = func(repo) |
32796
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32745
diff
changeset
|
2573 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
38261
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
2574 ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n") |
32797
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2575 if not opts['show_revs']: |
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
2576 return |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2577 for c in revs: |
35902
2da4144e6716
py3: format revision number as '%d' in debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
35888
diff
changeset
|
2578 ui.write("%d\n" % c) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
2579 |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2580 @command('debugserve', [ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2581 ('', 'sshstdio', False, _('run an SSH server bound to process handles')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2582 ('', 'logiofd', '', _('file descriptor to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2583 ('', 'logiofile', '', _('file to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2584 ], '') |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2585 def debugserve(ui, repo, **opts): |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2586 """run a server with advanced settings |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2587 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2588 This command is similar to :hg:`serve`. It exists partially as a |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2589 workaround to the fact that ``hg serve --stdio`` must have specific |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2590 arguments for security reasons. |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2591 """ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2592 opts = pycompat.byteskwargs(opts) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2593 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2594 if not opts['sshstdio']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2595 raise error.Abort(_('only --sshstdio is currently supported')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2596 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2597 logfh = None |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2598 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2599 if opts['logiofd'] and opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2600 raise error.Abort(_('cannot use both --logiofd and --logiofile')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2601 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2602 if opts['logiofd']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2603 # Line buffered because output is line based. |
38313
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2604 try: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2605 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2606 except OSError as e: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2607 if e.errno != errno.ESPIPE: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2608 raise |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2609 # can't seek a pipe, so `ab` mode fails on py3 |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
2610 logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2611 elif opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2612 logfh = open(opts['logiofile'], 'ab', 1) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2613 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2614 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2615 s.serve_forever() |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
2616 |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2617 @command('debugsetparents', [], _('REV1 [REV2]')) |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2618 def debugsetparents(ui, repo, rev1, rev2=None): |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2619 """manually set the parents of the current working directory |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2620 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2621 This is useful for writing repository conversion tools, but should |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2622 be used with care. For example, neither the working directory nor the |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2623 dirstate is updated, so file status may be incorrect after running this |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2624 command. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2625 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2626 Returns 0 on success. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2627 """ |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2628 |
37143
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37120
diff
changeset
|
2629 node1 = scmutil.revsingle(repo, rev1).node() |
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37120
diff
changeset
|
2630 node2 = scmutil.revsingle(repo, rev2, 'null').node() |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2631 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2632 with repo.wlock(): |
37143
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37120
diff
changeset
|
2633 repo.setparents(node1, node2) |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
2634 |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2635 @command('debugssl', [], '[SOURCE]', optionalrepo=True) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2636 def debugssl(ui, repo, source=None, **opts): |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2637 '''test a secure connection to a server |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2638 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2639 This builds the certificate chain for the server on Windows, installing the |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2640 missing intermediates and trusted root via Windows Update if necessary. It |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2641 does nothing on other platforms. |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2642 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2643 If SOURCE is omitted, the 'default' path will be used. If a URL is given, |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2644 that server is used. See :hg:`help urls` for more information. |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2645 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2646 If the update succeeds, retry the original operation. Otherwise, the cause |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2647 of the SSL error is likely another issue. |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2648 ''' |
34645 | 2649 if not pycompat.iswindows: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2650 raise error.Abort(_('certificate chain building is only possible on ' |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2651 'Windows')) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2652 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2653 if not source: |
34027
3c3066367d72
debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
33553
diff
changeset
|
2654 if not repo: |
3c3066367d72
debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
33553
diff
changeset
|
2655 raise error.Abort(_("there is no Mercurial repository here, and no " |
3c3066367d72
debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
33553
diff
changeset
|
2656 "server specified")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2657 source = "default" |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2658 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2659 source, branches = hg.parseurl(ui.expandpath(source)) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2660 url = util.url(source) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2661 |
35425
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2662 defaultport = {'https': 443, 'ssh': 22} |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2663 if url.scheme in defaultport: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2664 try: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2665 addr = (url.host, int(url.port or defaultport[url.scheme])) |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2666 except ValueError: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2667 raise error.Abort(_("malformed port number in URL")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2668 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2669 raise error.Abort(_("only https and ssh connections are supported")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2670 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2671 from . import win32 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2672 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2673 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS, |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2674 cert_reqs=ssl.CERT_NONE, ca_certs=None) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2675 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2676 try: |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2677 s.connect(addr) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2678 cert = s.getpeercert(True) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2679 |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2680 ui.status(_('checking the certificate chain for %s\n') % url.host) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2681 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2682 complete = win32.checkcertificatechain(cert, build=False) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2683 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2684 if not complete: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2685 ui.status(_('certificate chain is incomplete, updating... ')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2686 |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2687 if not win32.checkcertificatechain(cert): |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2688 ui.status(_('failed.\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2689 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2690 ui.status(_('done.\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2691 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2692 ui.status(_('full certificate chain is available\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2693 finally: |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2694 s.close() |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2695 |
30955
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2696 @command('debugsub', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2697 [('r', 'rev', '', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2698 _('revision to check'), _('REV'))], |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2699 _('[-r REV] [REV]')) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2700 def debugsub(ui, repo, rev=None): |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2701 ctx = scmutil.revsingle(repo, rev, None) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2702 for k, v in sorted(ctx.substate.items()): |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2703 ui.write(('path %s\n') % k) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2704 ui.write((' source %s\n') % v[0]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2705 ui.write((' revision %s\n') % v[1]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
2706 |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2707 @command('debugsuccessorssets', |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2708 [('', 'closest', False, _('return closest successors sets only'))], |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2709 _('[REV]')) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2710 def debugsuccessorssets(ui, repo, *revs, **opts): |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2711 """show set of successors for revision |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2712 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2713 A successors set of changeset A is a consistent group of revisions that |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2714 succeed A. It contains non-obsolete changesets only unless closests |
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2715 successors set is set. |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2716 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2717 In most cases a changeset A has a single successors set containing a single |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2718 successor (changeset A replaced by A'). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2719 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2720 A changeset that is made obsolete with no successors are called "pruned". |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2721 Such changesets have no successors sets at all. |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2722 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2723 A changeset that has been "split" will have a successors set containing |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2724 more than one successor. |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2725 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2726 A changeset that has been rewritten in multiple different ways is called |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2727 "divergent". Such changesets have multiple successor sets (each of which |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2728 may also be split, i.e. have multiple successors). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2729 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2730 Results are displayed as follows:: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2731 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2732 <rev1> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2733 <successors-1A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2734 <rev2> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2735 <successors-2A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2736 <successors-2B1> <successors-2B2> <successors-2B3> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2737 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2738 Here rev2 has two possible (i.e. divergent) successors sets. The first |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2739 holds one element, whereas the second holds three (i.e. the changeset has |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2740 been split). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2741 """ |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2742 # passed to successorssets caching computation from one call to another |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2743 cache = {} |
36123
8eb13f5d5d3f
py3: convert context to bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35929
diff
changeset
|
2744 ctx2str = bytes |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2745 node2str = short |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2746 for rev in scmutil.revrange(repo, revs): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2747 ctx = repo[rev] |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2748 ui.write('%s\n'% ctx2str(ctx)) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2749 for succsset in obsutil.successorssets(repo, ctx.node(), |
35401
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35400
diff
changeset
|
2750 closest=opts[r'closest'], |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2751 cache=cache): |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2752 if succsset: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2753 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2754 ui.write(node2str(succsset[0])) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2755 for node in succsset[1:]: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2756 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2757 ui.write(node2str(node)) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2758 ui.write('\n') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2759 |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2760 @command('debugtemplate', |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2761 [('r', 'rev', [], _('apply template on changesets'), _('REV')), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2762 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2763 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2764 optionalrepo=True) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2765 def debugtemplate(ui, repo, tmpl, **opts): |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2766 """parse and apply a template |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2767 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2768 If -r/--rev is given, the template is processed as a log template and |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2769 applied to the given changesets. Otherwise, it is processed as a generic |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2770 template. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2771 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2772 Use --verbose to print the parsed tree. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2773 """ |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2774 revs = None |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
2775 if opts[r'rev']: |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2776 if repo is None: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2777 raise error.RepoError(_('there is no Mercurial repository here ' |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2778 '(.hg not found)')) |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
2779 revs = scmutil.revrange(repo, opts[r'rev']) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2780 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2781 props = {} |
33101
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33100
diff
changeset
|
2782 for d in opts[r'define']: |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2783 try: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2784 k, v = (e.strip() for e in d.split('=', 1)) |
31517
468bc8a1863d
debugtemplate: pass ui to templater so label() works
Yuya Nishihara <yuya@tcha.org>
parents:
31451
diff
changeset
|
2785 if not k or k == 'ui': |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2786 raise ValueError |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2787 props[k] = v |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2788 except ValueError: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2789 raise error.Abort(_('malformed keyword definition: %s') % d) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2790 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2791 if ui.verbose: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2792 aliases = ui.configitems('templatealias') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2793 tree = templater.parse(tmpl) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2794 ui.note(templater.prettyformat(tree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2795 newtree = templater.expandaliases(tree, aliases) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2796 if newtree != tree: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2797 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2798 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2799 if revs is None: |
35469
f1c54d003327
templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents:
35465
diff
changeset
|
2800 tres = formatter.templateresources(ui, repo) |
f1c54d003327
templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents:
35465
diff
changeset
|
2801 t = formatter.maketemplater(ui, tmpl, resources=tres) |
38355
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2802 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2803 kwds, funcs = t.symbolsuseddefault() |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2804 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2805 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
36988
317382151ac3
templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36954
diff
changeset
|
2806 ui.write(t.renderdefault(props)) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2807 else: |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
2808 displayer = logcmdutil.maketemplater(ui, repo, tmpl) |
38355
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2809 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2810 kwds, funcs = displayer.t.symbolsuseddefault() |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2811 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
2812 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2813 for r in revs: |
33102
1b6946f87c50
py3: use pycompat.strkwargs() to convert kwargs keys to str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33101
diff
changeset
|
2814 displayer.show(repo[r], **pycompat.strkwargs(props)) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2815 displayer.close() |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2816 |
36792
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2817 @command('debuguigetpass', [ |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2818 ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2819 ], _('[-p TEXT]'), norepo=True) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2820 def debuguigetpass(ui, prompt=''): |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2821 """show prompt to type password""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2822 r = ui.getpass(prompt) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2823 ui.write(('respose: %s\n') % r) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2824 |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2825 @command('debuguiprompt', [ |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2826 ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2827 ], _('[-p TEXT]'), norepo=True) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2828 def debuguiprompt(ui, prompt=''): |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2829 """show plain prompt""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2830 r = ui.prompt(prompt) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2831 ui.write(('response: %s\n') % r) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
2832 |
32265
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
2833 @command('debugupdatecaches', []) |
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
2834 def debugupdatecaches(ui, repo, *pats, **opts): |
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
2835 """warm all known caches in the repository""" |
33438 | 2836 with repo.wlock(), repo.lock(): |
36952
b24cde12061b
debugupdatecache: also warm rev branch cache
Boris Feld <boris.feld@octobus.net>
parents:
36951
diff
changeset
|
2837 repo.updatecaches(full=True) |
32265
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
2838 |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2839 @command('debugupgraderepo', [ |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2840 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2841 ('', 'run', False, _('performs an upgrade')), |
41089
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
40456
diff
changeset
|
2842 ('', 'backup', True, _('keep the old repository content around')), |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2843 ]) |
41089
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
40456
diff
changeset
|
2844 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True): |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2845 """upgrade a repository to use different features |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2846 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2847 If no arguments are specified, the repository is evaluated for upgrade |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2848 and a list of problems and potential optimizations is printed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2849 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2850 With ``--run``, a repository upgrade is performed. Behavior of the upgrade |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2851 can be influenced via additional arguments. More details will be provided |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2852 by the command output when run without ``--run``. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2853 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2854 During the upgrade, the repository will be locked and no writes will be |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2855 allowed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2856 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2857 At the end of the upgrade, the repository may not be readable while new |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2858 repository data is swapped in. This window will be as long as it takes to |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2859 rename some directories inside the ``.hg`` directory. On most machines, this |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2860 should complete almost instantaneously and the chances of a consumer being |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2861 unable to access the repository should be low. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2862 """ |
41089
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
40456
diff
changeset
|
2863 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize, |
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
40456
diff
changeset
|
2864 backup=backup) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2865 |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
2866 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2867 inferrepo=True) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2868 def debugwalk(ui, repo, *pats, **opts): |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2869 """show how files match on given patterns""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
2870 opts = pycompat.byteskwargs(opts) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2871 m = scmutil.match(repo[None], pats, opts) |
38262
7c3a59e2971b
debugwalk: show matcher output only if -v/--verbose
Yuya Nishihara <yuya@tcha.org>
parents:
38261
diff
changeset
|
2872 if ui.verbose: |
38263
dbf31732ef64
debugwalk: pretty-print nested matcher
Yuya Nishihara <yuya@tcha.org>
parents:
38262
diff
changeset
|
2873 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') |
32363
a275186b989a
debugcommands: use repo[None].walk instead of repo.walk
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
2874 items = list(repo[None].walk(m)) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2875 if not items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2876 return |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2877 f = lambda fn: fn |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2878 if ui.configbool('ui', 'slash') and pycompat.ossep != '/': |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2879 f = lambda fn: util.normpath(fn) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2880 fmt = 'f %%-%ds %%-%ds %%s' % ( |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2881 max([len(abs) for abs in items]), |
41659
ecf7f4ef52fb
debugwalk: avoid match.rel() and use repo.pathto() instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
41636
diff
changeset
|
2882 max([len(repo.pathto(abs)) for abs in items])) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2883 for abs in items: |
41659
ecf7f4ef52fb
debugwalk: avoid match.rel() and use repo.pathto() instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
41636
diff
changeset
|
2884 line = fmt % (abs, f(repo.pathto(abs)), m.exact(abs) and 'exact' or '') |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2885 ui.write("%s\n" % line.rstrip()) |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2886 |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2887 @command('debugwhyunstable', [], _('REV')) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2888 def debugwhyunstable(ui, repo, rev): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2889 """explain instabilities of a changeset""" |
37396
9966f44ecab4
debugwhyunstable: add support for revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37350
diff
changeset
|
2890 for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)): |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2891 dnodes = '' |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2892 if entry.get('divergentnodes'): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2893 dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr()) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2894 for ctx in entry['divergentnodes']) + ' ' |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2895 ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes, |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2896 entry['reason'], entry['node'])) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
2897 |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2898 @command('debugwireargs', |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2899 [('', 'three', '', 'three'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2900 ('', 'four', '', 'four'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2901 ('', 'five', '', 'five'), |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
2902 ] + cmdutil.remoteopts, |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2903 _('REPO [OPTIONS]... [ONE [TWO]]'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2904 norepo=True) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2905 def debugwireargs(ui, repopath, *vals, **opts): |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
2906 opts = pycompat.byteskwargs(opts) |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2907 repo = hg.peer(ui, opts, repopath) |
32375
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32371
diff
changeset
|
2908 for opt in cmdutil.remoteopts: |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2909 del opts[opt[1]] |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2910 args = {} |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2911 for k, v in opts.iteritems(): |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2912 if v: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2913 args[k] = v |
35401
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35400
diff
changeset
|
2914 args = pycompat.strkwargs(args) |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2915 # run twice to check that we don't mess up the stream for the next command |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2916 res1 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2917 res2 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2918 ui.write("%s\n" % res1) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2919 if res1 != res2: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2920 ui.warn("%s\n" % res2) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2921 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2922 def _parsewirelangblocks(fh): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2923 activeaction = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2924 blocklines = [] |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2925 lastindent = 0 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2926 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2927 for line in fh: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2928 line = line.rstrip() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2929 if not line: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2930 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2931 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2932 if line.startswith(b'#'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2933 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2934 |
39062
efeeb73f54c3
debugcommands: fix a missing b prefix
Augie Fackler <augie@google.com>
parents:
38972
diff
changeset
|
2935 if not line.startswith(b' '): |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2936 # New block. Flush previous one. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2937 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2938 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2939 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2940 activeaction = line |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2941 blocklines = [] |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2942 lastindent = 0 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2943 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2944 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2945 # Else we start with an indent. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2946 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2947 if not activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2948 raise error.Abort(_('indented line outside of block')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2949 |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2950 indent = len(line) - len(line.lstrip()) |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2951 |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2952 # If this line is indented more than the last line, concatenate it. |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2953 if indent > lastindent and blocklines: |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2954 blocklines[-1] += line.lstrip() |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2955 else: |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2956 blocklines.append(line) |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
2957 lastindent = indent |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2958 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2959 # Flush last block. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2960 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2961 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2962 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2963 @command('debugwireproto', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2964 [ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2965 ('', 'localssh', False, _('start an SSH server for this repo')), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2966 ('', 'peer', '', _('construct a specific version of the peer')), |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
2967 ('', 'noreadstderr', False, _('do not read from stderr of the remote')), |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
2968 ('', 'nologhandshake', False, |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
2969 _('do not log I/O related to the peer handshake')), |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2970 ] + cmdutil.remoteopts, |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
2971 _('[PATH]'), |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2972 optionalrepo=True) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
2973 def debugwireproto(ui, repo, path=None, **opts): |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2974 """send wire protocol commands to a server |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2975 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2976 This command can be used to issue wire protocol commands to remote |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2977 peers and to debug the raw data being exchanged. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2978 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2979 ``--localssh`` will start an SSH server against the current repository |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2980 and connect to that. By default, the connection will perform a handshake |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2981 and establish an appropriate peer instance. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2982 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2983 ``--peer`` can be used to bypass the handshake protocol and construct a |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2984 peer instance using the specified class type. Valid values are ``raw``, |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2985 ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2986 raw data payloads and don't support higher-level command actions. |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2987 |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
2988 ``--noreadstderr`` can be used to disable automatic reading from stderr |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
2989 of the peer (for SSH connections only). Disabling automatic reading of |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
2990 stderr is useful for making output more deterministic. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
2991 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2992 Commands are issued via a mini language which is specified via stdin. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2993 The language consists of individual actions to perform. An action is |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2994 defined by a block. A block is defined as a line with no leading |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2995 space followed by 0 or more lines with leading space. Blocks are |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2996 effectively a high-level command with additional metadata. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2997 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2998 Lines beginning with ``#`` are ignored. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
2999 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3000 The following sections denote available actions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3001 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3002 raw |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3003 --- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3004 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3005 Send raw data to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3006 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3007 The block payload contains the raw data to send as one atomic send |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3008 operation. The data may not actually be delivered in a single system |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3009 call: it depends on the abilities of the transport being used. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3010 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3011 Each line in the block is de-indented and concatenated. Then, that |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3012 value is evaluated as a Python b'' literal. This allows the use of |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3013 backslash escaping, etc. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3014 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3015 raw+ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3016 ---- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3017 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3018 Behaves like ``raw`` except flushes output afterwards. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3019 |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3020 command <X> |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3021 ----------- |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3022 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3023 Send a request to run a named command, whose name follows the ``command`` |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3024 string. |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3025 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3026 Arguments to the command are defined as lines in this block. The format of |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3027 each line is ``<key> <value>``. e.g.:: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3028 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3029 command listkeys |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3030 namespace bookmarks |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3031 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3032 If the value begins with ``eval:``, it will be interpreted as a Python |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3033 literal expression. Otherwise values are interpreted as Python b'' literals. |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3034 This allows sending complex types and encoding special byte sequences via |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3035 backslash escaping. |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3036 |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3037 The following arguments have special meaning: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3038 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3039 ``PUSHFILE`` |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3040 When defined, the *push* mechanism of the peer will be used instead |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3041 of the static request-response mechanism and the content of the |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3042 file specified in the value of this argument will be sent as the |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3043 command payload. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3044 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3045 This can be used to submit a local bundle file to the remote. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3046 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3047 batchbegin |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3048 ---------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3049 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3050 Instruct the peer to begin a batched send. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3051 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3052 All ``command`` blocks are queued for execution until the next |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3053 ``batchsubmit`` block. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3054 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3055 batchsubmit |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3056 ----------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3057 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3058 Submit previously queued ``command`` blocks as a batch request. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3059 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3060 This action MUST be paired with a ``batchbegin`` action. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3061 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3062 httprequest <method> <path> |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3063 --------------------------- |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3064 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3065 (HTTP peer only) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3066 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3067 Send an HTTP request to the peer. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3068 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3069 The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3070 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3071 Arguments of the form ``<key>: <value>`` are interpreted as HTTP request |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3072 headers to add to the request. e.g. ``Accept: foo``. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3073 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3074 The following arguments are special: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3075 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3076 ``BODYFILE`` |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3077 The content of the file defined as the value to this argument will be |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3078 transferred verbatim as the HTTP request body. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3079 |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3080 ``frame <type> <flags> <payload>`` |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3081 Send a unified protocol frame as part of the request body. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3082 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3083 All frames will be collected and sent as the body to the HTTP |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3084 request. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3085 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3086 close |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3087 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3088 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3089 Close the connection to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3090 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3091 flush |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3092 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3093 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3094 Flush data written to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3095 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3096 readavailable |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3097 ------------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3098 |
36843
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
3099 Close the write end of the connection and read all available data from |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
3100 the server. |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3101 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3102 If the connection to the server encompasses multiple pipes, we poll both |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3103 pipes and read available data. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3104 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3105 readline |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3106 -------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3107 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3108 Read a line of output from the server. If there are multiple output |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3109 pipes, reads only the main pipe. |
37007
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3110 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3111 ereadline |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3112 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3113 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3114 Like ``readline``, but read from the stderr pipe, if available. |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3115 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3116 read <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3117 -------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3118 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3119 ``read()`` N bytes from the server's main output pipe. |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3120 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3121 eread <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3122 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3123 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3124 ``read()`` N bytes from the server's stderr pipe, if available. |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3125 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3126 Specifying Unified Frame-Based Protocol Frames |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3127 ---------------------------------------------- |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3128 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3129 It is possible to emit a *Unified Frame-Based Protocol* by using special |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3130 syntax. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3131 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3132 A frame is composed as a type, flags, and payload. These can be parsed |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3133 from a string of the form: |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3134 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3135 <request-id> <stream-id> <stream-flags> <type> <flags> <payload> |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3136 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3137 ``request-id`` and ``stream-id`` are integers defining the request and |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3138 stream identifiers. |
37057
2ec1fb9de638
wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37051
diff
changeset
|
3139 |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3140 ``type`` can be an integer value for the frame type or the string name |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3141 of the type. The strings are defined in ``wireprotoframing.py``. e.g. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3142 ``command-name``. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3143 |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3144 ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3145 components. Each component (and there can be just one) can be an integer |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3146 or a flag name for stream flags or frame flags, respectively. Values are |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3147 resolved to integers and then bitwise OR'd together. |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
3148 |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
3149 ``payload`` represents the raw frame payload. If it begins with |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
3150 ``cbor:``, the following string is evaluated as Python code and the |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
3151 resulting object is fed into a CBOR encoder. Otherwise it is interpreted |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
3152 as a Python byte string literal. |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3153 """ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3154 opts = pycompat.byteskwargs(opts) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3155 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3156 if opts['localssh'] and not repo: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3157 raise error.Abort(_('--localssh requires a repository')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3158 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3159 if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'): |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3160 raise error.Abort(_('invalid value for --peer'), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3161 hint=_('valid values are "raw", "ssh1", and "ssh2"')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3162 |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3163 if path and opts['localssh']: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3164 raise error.Abort(_('cannot specify --localssh with an explicit ' |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3165 'path')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3166 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3167 if ui.interactive(): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3168 ui.write(_('(waiting for commands on stdin)\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3169 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3170 blocks = list(_parsewirelangblocks(ui.fin)) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3171 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3172 proc = None |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3173 stdin = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3174 stdout = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3175 stderr = None |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3176 opener = None |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3177 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3178 if opts['localssh']: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3179 # We start the SSH server in its own process so there is process |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3180 # separation. This prevents a whole class of potential bugs around |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3181 # shared state from interfering with server operation. |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
3182 args = procutil.hgcmd() + [ |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3183 '-R', repo.root, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3184 'debugserve', '--sshstdio', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3185 ] |
39826
c31ce080eb75
py3: convert arguments, cwd and env to native strings when spawning subprocess
Matt Harbison <matt_harbison@yahoo.com>
parents:
39818
diff
changeset
|
3186 proc = subprocess.Popen(pycompat.rapply(procutil.tonativestr, args), |
c31ce080eb75
py3: convert arguments, cwd and env to native strings when spawning subprocess
Matt Harbison <matt_harbison@yahoo.com>
parents:
39818
diff
changeset
|
3187 stdin=subprocess.PIPE, |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3188 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3189 bufsize=0) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3190 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3191 stdin = proc.stdin |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3192 stdout = proc.stdout |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3193 stderr = proc.stderr |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3194 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3195 # We turn the pipes into observers so we can log I/O. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3196 if ui.verbose or opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3197 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3198 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3199 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3200 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3201 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3202 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3203 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3204 # --localssh also implies the peer connection settings. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3205 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3206 url = 'ssh://localserver' |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3207 autoreadstderr = not opts['noreadstderr'] |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3208 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3209 if opts['peer'] == 'ssh1': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3210 ui.write(_('creating ssh peer for wire protocol version 1\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3211 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr, |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3212 None, autoreadstderr=autoreadstderr) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3213 elif opts['peer'] == 'ssh2': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3214 ui.write(_('creating ssh peer for wire protocol version 2\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3215 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr, |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3216 None, autoreadstderr=autoreadstderr) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3217 elif opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3218 ui.write(_('using raw connection to peer\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3219 peer = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3220 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3221 ui.write(_('creating ssh peer from handshake results\n')) |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3222 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr, |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3223 autoreadstderr=autoreadstderr) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3224 |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3225 elif path: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3226 # We bypass hg.peer() so we can proxy the sockets. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3227 # TODO consider not doing this because we skip |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3228 # ``hg.wirepeersetupfuncs`` and potentially other useful functionality. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3229 u = util.url(path) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3230 if u.scheme != 'http': |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3231 raise error.Abort(_('only http:// paths are currently supported')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3232 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3233 url, authinfo = u.authinfo() |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3234 openerargs = { |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3235 r'useragent': b'Mercurial debugwireproto', |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3236 } |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3237 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3238 # Turn pipes/sockets into observers so we can log I/O. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3239 if ui.verbose: |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3240 openerargs.update({ |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3241 r'loggingfh': ui, |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3242 r'loggingname': b's', |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3243 r'loggingopts': { |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3244 r'logdata': True, |
37044
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37013
diff
changeset
|
3245 r'logdataapis': False, |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3246 }, |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3247 }) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3248 |
37044
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37013
diff
changeset
|
3249 if ui.debugflag: |
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37013
diff
changeset
|
3250 openerargs[r'loggingopts'][r'logdataapis'] = True |
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37013
diff
changeset
|
3251 |
37045
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3252 # Don't send default headers when in raw mode. This allows us to |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3253 # bypass most of the behavior of our URL handling code so we can |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3254 # have near complete control over what's sent on the wire. |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3255 if opts['peer'] == 'raw': |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3256 openerargs[r'sendaccept'] = False |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
3257 |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3258 opener = urlmod.opener(ui, authinfo, **openerargs) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3259 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3260 if opts['peer'] == 'http2': |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3261 ui.write(_('creating http peer for wire protocol version 2\n')) |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3262 # We go through makepeer() because we need an API descriptor for |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3263 # the peer instance to be useful. |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3264 with ui.configoverride({ |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3265 ('experimental', 'httppeer.advertise-v2'): True}): |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3266 if opts['nologhandshake']: |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3267 ui.pushbuffer() |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3268 |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3269 peer = httppeer.makepeer(ui, path, opener=opener) |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3270 |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3271 if opts['nologhandshake']: |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3272 ui.popbuffer() |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3273 |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3274 if not isinstance(peer, httppeer.httpv2peer): |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3275 raise error.Abort(_('could not instantiate HTTP peer for ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3276 'wire protocol version 2'), |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3277 hint=_('the server may not have the feature ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3278 'enabled or is not allowing this ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3279 'client version')) |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3280 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3281 elif opts['peer'] == 'raw': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3282 ui.write(_('using raw connection to peer\n')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3283 peer = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3284 elif opts['peer']: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3285 raise error.Abort(_('--peer %s not supported with HTTP peers') % |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3286 opts['peer']) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3287 else: |
37553
6b08cf6b900f
httppeer: allow opener to be passed to makepeer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37552
diff
changeset
|
3288 peer = httppeer.makepeer(ui, path, opener=opener) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3289 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3290 # We /could/ populate stdin/stdout with sock.makefile()... |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3291 else: |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3292 raise error.Abort(_('unsupported connection configuration')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3293 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3294 batchedcommands = None |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3295 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3296 # Now perform actions based on the parsed wire language instructions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3297 for action, lines in blocks: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3298 if action in ('raw', 'raw+'): |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3299 if not stdin: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3300 raise error.Abort(_('cannot call raw/raw+ on this peer')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3301 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3302 # Concatenate the data together. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3303 data = ''.join(l.lstrip() for l in lines) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
3304 data = stringutil.unescapestr(data) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3305 stdin.write(data) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3306 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3307 if action == 'raw+': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3308 stdin.flush() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3309 elif action == 'flush': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3310 if not stdin: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3311 raise error.Abort(_('cannot call flush on this peer')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3312 stdin.flush() |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3313 elif action.startswith('command'): |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3314 if not peer: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3315 raise error.Abort(_('cannot send commands unless peer instance ' |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3316 'is available')) |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3317 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3318 command = action.split(' ', 1)[1] |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3319 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3320 args = {} |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3321 for line in lines: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3322 # We need to allow empty values. |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3323 fields = line.lstrip().split(' ', 1) |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3324 if len(fields) == 1: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3325 key = fields[0] |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3326 value = '' |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3327 else: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3328 key, value = fields |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3329 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3330 if value.startswith('eval:'): |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3331 value = stringutil.evalpythonliteral(value[5:]) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3332 else: |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3333 value = stringutil.unescapestr(value) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3334 |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3335 args[key] = value |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3336 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3337 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3338 batchedcommands.append((command, args)) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3339 continue |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3340 |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3341 ui.status(_('sending %s command\n') % command) |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3342 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3343 if 'PUSHFILE' in args: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3344 with open(args['PUSHFILE'], r'rb') as fh: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3345 del args['PUSHFILE'] |
36587
dfcf589a4031
debugcommands: add some strkwargs love to some **args calls
Augie Fackler <augie@google.com>
parents:
36586
diff
changeset
|
3346 res, output = peer._callpush(command, fh, |
dfcf589a4031
debugcommands: add some strkwargs love to some **args calls
Augie Fackler <augie@google.com>
parents:
36586
diff
changeset
|
3347 **pycompat.strkwargs(args)) |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3348 ui.status(_('result: %s\n') % stringutil.escapestr(res)) |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3349 ui.status(_('remote output: %s\n') % |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3350 stringutil.escapestr(output)) |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
3351 else: |
37652
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3352 with peer.commandexecutor() as e: |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3353 res = e.callcommand(command, args).result() |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3354 |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
3355 if isinstance(res, wireprotov2peer.commandresponse): |
39561
d06834e0f48e
wireprotov2peer: stream decoded responses
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39449
diff
changeset
|
3356 val = res.objects() |
37942
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3357 ui.status(_('response: %s\n') % |
39378
0f549da54379
stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39330
diff
changeset
|
3358 stringutil.pprint(val, bprefix=True, indent=2)) |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
3359 else: |
37942
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3360 ui.status(_('response: %s\n') % |
39378
0f549da54379
stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39330
diff
changeset
|
3361 stringutil.pprint(res, bprefix=True, indent=2)) |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
3362 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3363 elif action == 'batchbegin': |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3364 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3365 raise error.Abort(_('nested batchbegin not allowed')) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3366 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3367 batchedcommands = [] |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3368 elif action == 'batchsubmit': |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3369 # There is a batching API we could go through. But it would be |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3370 # difficult to normalize requests into function calls. It is easier |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3371 # to bypass this layer and normalize to commands + args. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3372 ui.status(_('sending batch with %d sub-commands\n') % |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3373 len(batchedcommands)) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3374 for i, chunk in enumerate(peer._submitbatch(batchedcommands)): |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
3375 ui.status(_('response #%d: %s\n') % |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3376 (i, stringutil.escapestr(chunk))) |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3377 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3378 batchedcommands = None |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3379 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3380 elif action.startswith('httprequest '): |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3381 if not opener: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3382 raise error.Abort(_('cannot use httprequest without an HTTP ' |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3383 'peer')) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3384 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3385 request = action.split(' ', 2) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3386 if len(request) != 3: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3387 raise error.Abort(_('invalid httprequest: expected format is ' |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3388 '"httprequest <method> <path>')) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3389 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3390 method, httppath = request[1:] |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3391 headers = {} |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3392 body = None |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3393 frames = [] |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3394 for line in lines: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3395 line = line.lstrip() |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3396 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3397 if m: |
39955
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
3398 # Headers need to use native strings. |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
3399 key = pycompat.strurl(m.group(1)) |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
3400 value = pycompat.strurl(m.group(2)) |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
3401 headers[key] = value |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3402 continue |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3403 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3404 if line.startswith(b'BODYFILE '): |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3405 with open(line.split(b' ', 1), 'rb') as fh: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3406 body = fh.read() |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3407 elif line.startswith(b'frame '): |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3408 frame = wireprotoframing.makeframefromhumanstring( |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3409 line[len(b'frame '):]) |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3410 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3411 frames.append(frame) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3412 else: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3413 raise error.Abort(_('unknown argument to httprequest: %s') % |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3414 line) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3415 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3416 url = path + httppath |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3417 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3418 if frames: |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3419 body = b''.join(bytes(f) for f in frames) |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3420 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3421 req = urlmod.urlreq.request(pycompat.strurl(url), body, headers) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3422 |
37047
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37045
diff
changeset
|
3423 # urllib.Request insists on using has_data() as a proxy for |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37045
diff
changeset
|
3424 # determining the request method. Override that to use our |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37045
diff
changeset
|
3425 # explicitly requested method. |
39064
a2fa7247ca70
debugcommands: get_method should always return a sysstr
Augie Fackler <augie@google.com>
parents:
39062
diff
changeset
|
3426 req.get_method = lambda: pycompat.sysstr(method) |
37047
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37045
diff
changeset
|
3427 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3428 try: |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3429 res = opener.open(req) |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3430 body = res.read() |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3431 except util.urlerr.urlerror as e: |
39065
730e7d92a023
debugcommands: urlerror only has a read() method in Python 2
Augie Fackler <augie@google.com>
parents:
39064
diff
changeset
|
3432 # read() method must be called, but only exists in Python 2 |
730e7d92a023
debugcommands: urlerror only has a read() method in Python 2
Augie Fackler <augie@google.com>
parents:
39064
diff
changeset
|
3433 getattr(e, 'read', lambda: None)() |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3434 continue |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3435 |
39956
36e9d2c60837
py3: use system strings for HTTP response header comparison
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39955
diff
changeset
|
3436 ct = res.headers.get(r'Content-Type') |
36e9d2c60837
py3: use system strings for HTTP response header comparison
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39955
diff
changeset
|
3437 if ct == r'application/mercurial-cbor': |
37942
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3438 ui.write(_('cbor> %s\n') % |
40017
426cb2859013
debugcommands: print all CBOR objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39980
diff
changeset
|
3439 stringutil.pprint(cborutil.decodeall(body), |
39449
e5eb67dea6e8
debugcommands: use our CBOR decoder
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39378
diff
changeset
|
3440 bprefix=True, |
39378
0f549da54379
stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39330
diff
changeset
|
3441 indent=2)) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
3442 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3443 elif action == 'close': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3444 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3445 elif action == 'readavailable': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3446 if not stdout or not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3447 raise error.Abort(_('readavailable not available on this peer')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3448 |
36843
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
3449 stdin.close() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
3450 stdout.read() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
3451 stderr.read() |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3452 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3453 elif action == 'readline': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3454 if not stdout: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3455 raise error.Abort(_('readline not available on this peer')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3456 stdout.readline() |
37007
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3457 elif action == 'ereadline': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3458 if not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3459 raise error.Abort(_('ereadline not available on this peer')) |
37007
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3460 stderr.readline() |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3461 elif action.startswith('read '): |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3462 count = int(action.split(' ', 1)[1]) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3463 if not stdout: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3464 raise error.Abort(_('read not available on this peer')) |
37007
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3465 stdout.read(count) |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3466 elif action.startswith('eread '): |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3467 count = int(action.split(' ', 1)[1]) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3468 if not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
3469 raise error.Abort(_('eread not available on this peer')) |
37007
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
3470 stderr.read(count) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3471 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3472 raise error.Abort(_('unknown action: %s') % action) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3473 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3474 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3475 raise error.Abort(_('unclosed "batchbegin" request')) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
3476 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3477 if peer: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3478 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3479 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3480 if proc: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
3481 proc.kill() |