Mercurial > hg
annotate mercurial/debugcommands.py @ 52164:e01e84e5e426
rust-revlog: add a Rust-only `InnerRevlog`
This mirrors the Python `InnerRevlog` and will be used in a future patch
to replace said Python implementation. This allows us to start doing more
things in pure Rust, in particular reading and writing operations.
A lot of changes have to be introduced all at once, it wouldn't be very
useful to separate this patch IMO since all of them are either interlocked
or only useful with the rest.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 10 Oct 2024 10:34:51 +0200 |
parents | a021da4ec509 |
children |
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 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46805
diff
changeset
|
3 # Copyright 2005-2016 Olivia Mackall <olivia@selenic.com> |
30401
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 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51828
diff
changeset
|
8 from __future__ import annotations |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47568
diff
changeset
|
10 import binascii |
34129
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
11 import codecs |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
12 import collections |
46769
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
13 import contextlib |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
14 import difflib |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
15 import errno |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
16 import glob |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
17 import operator |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
18 import os |
44145
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
19 import platform |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
20 import random |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
21 import re |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
22 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
|
23 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
|
24 import stat |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
25 import subprocess |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
26 import sys |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
27 import time |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 from .i18n import _ |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
30 from .node import ( |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
31 bin, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
32 hex, |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
33 nullrev, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
34 short, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
35 ) |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
36 from .pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
37 open, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
38 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 from . import ( |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
40 bundle2, |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
41 bundlerepo, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
42 changegroup, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 cmdutil, |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
44 color, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
45 context, |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
46 copies, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
47 dagparser, |
49152
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
48 dirstateutils, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
49 encoding, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 error, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
51 exchange, |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
52 extensions, |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
53 filelog, |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
54 filemerge, |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38802
diff
changeset
|
55 filesetlang, |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
56 formatter, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
57 hg, |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
58 httppeer, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
59 localrepo, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
60 lock as lockmod, |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
61 logcmdutil, |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
62 manifest, |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
63 mergestate as mergestatemod, |
45665
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
64 metadata, |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
65 obsolete, |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33107
diff
changeset
|
66 obsutil, |
43633
0b7733719d21
utils: move finddirs() to pathutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43506
diff
changeset
|
67 pathutil, |
32745
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
68 phases, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
69 policy, |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
70 pvec, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30518
diff
changeset
|
71 pycompat, |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32315
diff
changeset
|
72 registrar, |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
73 repair, |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
74 repoview, |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
75 requirements, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 revlog, |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
77 revset, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
78 revsetlang, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 scmutil, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
80 setdiscovery, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
81 simplemerge, |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
82 sshpeer, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
83 sslutil, |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
84 streamclone, |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45819
diff
changeset
|
85 strip, |
44290
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
86 tags as tagsmod, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
87 templater, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
88 treediscovery, |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31689
diff
changeset
|
89 upgrade, |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
90 url as urlmod, |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
91 util, |
49826
c84844cd523a
verify: also check dirstate
Raphaël Gomès <rgomes@octobus.net>
parents:
49824
diff
changeset
|
92 verify, |
31239
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
93 vfs as vfsmod, |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
94 wireprotoframing, |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
95 wireprotoserver, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 ) |
47298
e96f75857361
updatecaches: use the caches argument in `hg debugupdatecaches`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47139
diff
changeset
|
97 from .interfaces import repository |
50426
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
98 from .stabletailgraph import stabletailsort |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
99 from .utils import ( |
39449
e5eb67dea6e8
debugcommands: use our CBOR decoder
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39378
diff
changeset
|
100 cborutil, |
42041
3e47d1ec9da5
util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42035
diff
changeset
|
101 compression, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
102 dateutil, |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
103 procutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
104 stringutil, |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
105 urlutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37057
diff
changeset
|
106 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
108 from .revlogutils import ( |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
109 debug as revlog_debug, |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
110 nodemap, |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
111 rewrite, |
45665
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
112 sidedata, |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
113 ) |
39330
655b5b465953
revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents:
39282
diff
changeset
|
114 |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
115 release = lockmod.release |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
116 |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45819
diff
changeset
|
117 table = {} |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45819
diff
changeset
|
118 table.update(strip.command._table) |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45819
diff
changeset
|
119 command = registrar.command(table) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
121 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 @command(b'debugancestor', [], _(b'[INDEX] REV1 REV2'), optionalrepo=True) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 def debugancestor(ui, repo, *args): |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 """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
|
125 if len(args) == 3: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 index, rev1, rev2 = args |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39760
diff
changeset
|
127 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
|
128 lookup = r.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 elif len(args) == 2: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 if not repo: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
131 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
132 _(b'there is no Mercurial repository here (.hg not found)') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
133 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 rev1, rev2 = args |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 r = repo.changelog |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 lookup = repo.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 raise error.Abort(_(b'either two or three arguments required')) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 a = r.ancestor(lookup(rev1), lookup(rev2)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 ui.write(b'%d:%s\n' % (r.rev(a), hex(a))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
141 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
142 |
45149
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
143 @command(b'debugantivirusrunning', []) |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
144 def debugantivirusrunning(ui, repo): |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
145 """attempt to trigger an antivirus scanner to see if one is active""" |
51939
8d9767bf4adb
debugantivirusrunning: use bytes when opening a vfs file
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
146 with repo.cachevfs.open(b'eicar-test-file.com', b'wb') as f: |
45149
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
147 f.write( |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
148 util.b85decode( |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
149 # This is a base85-armored version of the EICAR test file. See |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
150 # https://en.wikipedia.org/wiki/EICAR_test_file for details. |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
151 b'ST#=}P$fV?P+K%yP+C|uG$>GBDK|qyDK~v2MM*<JQY}+dK~6+LQba95P' |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
152 b'E<)&Nm5l)EmTEQR4qnHOhq9iNGnJx' |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
153 ) |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
154 ) |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
155 # Give an AV engine time to scan the file. |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
156 time.sleep(2) |
51939
8d9767bf4adb
debugantivirusrunning: use bytes when opening a vfs file
Matt Harbison <matt_harbison@yahoo.com>
parents:
51863
diff
changeset
|
157 util.unlink(repo.cachevfs.join(b'eicar-test-file.com')) |
45149
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
158 |
87047efbc6a6
debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents:
45107
diff
changeset
|
159 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
160 @command(b'debugapplystreamclonebundle', [], b'FILE') |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
161 def debugapplystreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
162 """apply a stream clone bundle file""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
163 f = hg.openpath(ui, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
164 gen = exchange.readbundle(ui, f, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
165 gen.apply(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
166 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
167 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
168 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
169 b'debugbuilddag', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
170 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
171 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
172 b'm', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
173 b'mergeable-file', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
174 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
175 _(b'add single file mergeable changes'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
176 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
177 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
178 b'o', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
179 b'overwritten-file', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
180 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
181 _(b'add single file all revs overwrite'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
182 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
183 (b'n', b'new-file', None, _(b'add new file at each rev')), |
48691
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
184 ( |
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
185 b'', |
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
186 b'from-existing', |
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
187 None, |
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
188 _(b'continue from a non-empty repository'), |
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
189 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
190 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 _(b'[OPTION]... [TEXT]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
192 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
193 def debugbuilddag( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
194 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
195 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
196 text=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
197 mergeable_file=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
198 overwritten_file=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
199 new_file=False, |
48691
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
200 from_existing=False, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
201 ): |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
202 """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
|
203 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
204 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
|
205 command line. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
206 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
207 Elements: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
208 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
209 - "+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
|
210 - "." is a single node based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
211 - "$" resets the default parent to null (implied at the start); |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
212 otherwise the default parent is always the last node created |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
213 - "<p" sets the default parent to the backref p |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
214 - "*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
|
215 - "*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
|
216 - "/p2" is a merge of the preceding node and p2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
217 - ":tag" defines a local tag for the preceding node |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
218 - "@branch" sets the named branch for subsequent nodes |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
219 - "#...\\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
|
220 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
221 Whitespace between the above elements is ignored. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
222 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
223 A backref is either |
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 - 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
|
226 node, or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
227 - 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
|
228 - empty to denote the default parent. |
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 All string valued-elements are either strictly alphanumeric, or must |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
231 be enclosed in double quotes ("..."), with "\\" as escape character. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
232 """ |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
233 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
234 if text is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
235 ui.status(_(b"reading DAG from stdin\n")) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
236 text = ui.fin.read() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
237 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
238 cl = repo.changelog |
48691
b4bc9c4f925d
debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48562
diff
changeset
|
239 if len(cl) > 0 and not from_existing: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
240 raise error.Abort(_(b'repository is not empty')) |
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 # determine number of revs in DAG |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
243 total = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
244 for type, data in dagparser.parsedag(text): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
245 if type == b'n': |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
246 total += 1 |
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 mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
249 linesperrev = 2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
250 # make a file with k lines per rev |
49284
d44e3c45f0e4
py3: replace `pycompat.xrange` by `range`
Manuel Jacob <me@manueljacob.de>
parents:
49281
diff
changeset
|
251 initialmergedlines = [b'%d' % i for i in range(0, total * linesperrev)] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 initialmergedlines.append(b"") |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
253 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
254 tags = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
255 progress = ui.makeprogress( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
256 _(b'building'), unit=_(b'revisions'), total=total |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
257 ) |
52081
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
258 merge_relaxed_sync = ui.configbool( |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
259 b'experimental', |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
260 b'relaxed-block-sync-merge', |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
261 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 with progress, repo.wlock(), repo.lock(), repo.transaction(b"builddag"): |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
263 at = -1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
264 atbranch = b'default' |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
265 nodeids = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
266 id = 0 |
38375
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
267 progress.update(id) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
268 for type, data in dagparser.parsedag(text): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
269 if type == b'n': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
270 ui.note((b'node %s\n' % pycompat.bytestr(data))) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
271 id, ps = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
272 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
273 files = [] |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
274 filecontent = {} |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
275 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
276 p2 = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
277 if mergeable_file: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 fn = b"mf" |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
279 p1 = repo[ps[0]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
280 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
281 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
282 pa = p1.ancestor(p2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
283 base, local, other = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
284 x[fn].data() for x in (pa, p1, p2) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
285 ] |
52081
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
286 m3 = simplemerge.Merge3Text( |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
287 base, |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
288 local, |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
289 other, |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
290 relaxed_sync=merge_relaxed_sync, |
a021da4ec509
merge: add a config to allow conflict-free merge of changes on adjacent lines
Arseniy Alekseyev <aalekseyev@janestreet.com
parents:
51949
diff
changeset
|
291 ) |
48558
2dbee604a4f0
simplemerge: clarify names of functions that render conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
48557
diff
changeset
|
292 ml = [ |
48562
12ac4401ff7d
simplemerge: simplify and rename `render_markers()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48558
diff
changeset
|
293 l.strip() |
12ac4401ff7d
simplemerge: simplify and rename `render_markers()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48558
diff
changeset
|
294 for l in simplemerge.render_minimized(m3)[0] |
48558
2dbee604a4f0
simplemerge: clarify names of functions that render conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
48557
diff
changeset
|
295 ] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
296 ml.append(b"") |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
297 elif at > 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
298 ml = p1[fn].data().split(b"\n") |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
299 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
300 ml = initialmergedlines |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
301 ml[id * linesperrev] += b" r%i" % id |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
302 mergedtext = b"\n".join(ml) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
303 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
304 filecontent[fn] = mergedtext |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
305 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
306 if overwritten_file: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 fn = b"of" |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
308 files.append(fn) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
309 filecontent[fn] = b"r%i\n" % id |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
310 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
311 if new_file: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
312 fn = b"nf%i" % id |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
313 files.append(fn) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
314 filecontent[fn] = b"r%i\n" % id |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
315 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
316 if not p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
317 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
318 for fn in p2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
319 if fn.startswith(b"nf"): |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
320 files.append(fn) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
321 filecontent[fn] = p2[fn].data() |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
322 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
323 def fctxfn(repo, cx, path): |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
324 if path in filecontent: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
325 return context.memfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
326 repo, cx, path, filecontent[path] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
327 ) |
35399
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35395
diff
changeset
|
328 return None |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
329 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
330 if len(ps) == 0 or ps[0] < 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
331 pars = [None, None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
332 elif len(ps) == 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
333 pars = [nodeids[ps[0]], None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
334 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
335 pars = [nodeids[p] for p in ps] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
336 cx = context.memctx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
337 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
338 pars, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 b"r%i" % id, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
340 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
341 fctxfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
342 date=(id, 0), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
343 user=b"debugbuilddag", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
344 extra={b'branch': atbranch}, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
345 ) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
346 nodeid = repo.commitctx(cx) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
347 nodeids.append(nodeid) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
348 at = id |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
349 elif type == b'l': |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
350 id, name = data |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
351 ui.note((b'tag %s\n' % name)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
352 tags.append(b"%s %s\n" % (hex(repo.changelog.node(id)), name)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
353 elif type == b'a': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 ui.note((b'branch %s\n' % data)) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
355 atbranch = data |
38375
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38355
diff
changeset
|
356 progress.update(id) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
357 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
358 if tags: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
359 repo.vfs.write(b"localtags", b"".join(tags)) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
360 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
361 |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
362 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
363 indent_string = b' ' * indent |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
364 if all: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
365 ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
366 b"%sformat: id, p1, p2, cset, delta base, len(delta)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
367 % indent_string |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
368 ) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
369 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
370 def showchunks(named): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
371 ui.write(b"\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
|
372 for deltadata in gen.deltaiter(): |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46663
diff
changeset
|
373 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
374 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
375 b"%s%s %s %s %s %s %d\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
376 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
377 indent_string, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
378 hex(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
379 hex(p1), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
380 hex(p2), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
381 hex(cs), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
382 hex(deltabase), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
383 len(delta), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
384 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
385 ) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
386 |
43972
7a2c49a3cbae
debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents:
43878
diff
changeset
|
387 gen.changelogheader() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
388 showchunks(b"changelog") |
43972
7a2c49a3cbae
debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents:
43878
diff
changeset
|
389 gen.manifestheader() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 showchunks(b"manifest") |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
391 for chunkdata in iter(gen.filelogheader, {}): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 fname = chunkdata[b'filename'] |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
393 showchunks(fname) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
394 else: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
395 if isinstance(gen, bundle2.unbundle20): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 raise error.Abort(_(b'use debugbundle2 for this file')) |
43972
7a2c49a3cbae
debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents:
43878
diff
changeset
|
397 gen.changelogheader() |
34292
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34130
diff
changeset
|
398 for deltadata in gen.deltaiter(): |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46663
diff
changeset
|
399 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
400 ui.write(b"%s%s\n" % (indent_string, hex(node))) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
401 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
402 |
33029
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33028
diff
changeset
|
403 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
|
404 """display version and markers contained in 'data'""" |
33029
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33028
diff
changeset
|
405 data = part.read() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
406 indent_string = b' ' * indent |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
407 try: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
408 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
|
409 except error.UnknownVersion as exc: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
410 msg = b"%sunsupported version: %s (%d bytes)\n" |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
411 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
|
412 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
413 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 msg = b"%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
|
415 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
|
416 ui.write(msg) |
50944
2a7dba8658a7
debugbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50929
diff
changeset
|
417 fm = ui.formatter(b'debugobsolete', pycompat.byteskwargs(opts)) |
32517
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
418 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
|
419 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
|
420 fm.startitem() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
421 fm.plain(indent_string) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
422 cmdutil.showmarker(fm, m) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
423 fm.end() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32457
diff
changeset
|
424 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
425 |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
426 def _debugphaseheads(ui, data, indent=0): |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
427 """display version and markers contained in 'data'""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
428 indent_string = b' ' * indent |
34320
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
429 headsbyphase = phases.binarydecode(data) |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
430 for phase in phases.allphases: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
431 for head in headsbyphase[phase]: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
432 ui.write(indent_string) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 ui.write(b'%s %s\n' % (hex(head), phases.phasenames[phase])) |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33029
diff
changeset
|
434 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
435 |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
436 def _quasirepr(thing): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
437 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
438 return b'{%s}' % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
439 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
440 ) |
34025
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
441 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
|
442 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
443 |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
444 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
|
445 """lists the contents of a bundle2""" |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
446 if not isinstance(gen, bundle2.unbundle20): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
447 raise error.Abort(_(b'not a bundle2 file')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
448 ui.write((b'Stream params: %s\n' % _quasirepr(gen.params))) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
449 parttypes = opts.get('part_type', []) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
450 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
|
451 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
|
452 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
453 msg = b'%s -- %s (mandatory: %r)\n' |
37841
d618558e4e8b
debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents:
37823
diff
changeset
|
454 ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory))) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
455 if part.type == b'changegroup': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
456 version = part.params.get(b'version', b'01') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
457 cg = changegroup.getunbundler(version, part, b'UN') |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
458 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
|
459 _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
460 if part.type == b'obsmarkers': |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
461 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
|
462 _debugobsmarkers(ui, part, indent=4, **opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
463 if part.type == b'phase-heads': |
36951
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36843
diff
changeset
|
464 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
|
465 _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
|
466 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
467 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
468 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
469 b'debugbundle', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
470 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
471 (b'a', b'all', None, _(b'show all details')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 (b'', b'part-type', [], _(b'show only the named part type')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
473 (b'', b'spec', None, _(b'print the bundlespec of the bundle')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
474 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
475 _(b'FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
476 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
477 ) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
478 def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
479 """lists the contents of a bundle""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
480 with hg.openpath(ui, bundlepath) as f: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
481 if spec: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
482 spec = exchange.getbundlespec(ui, f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 ui.write(b'%s\n' % spec) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
484 return |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
485 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
486 gen = exchange.readbundle(ui, f, bundlepath) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
487 if isinstance(gen, bundle2.unbundle20): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
488 return _debugbundle2(ui, gen, all=all, **opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
489 _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
|
490 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
491 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
492 @command(b'debugcapabilities', [], _(b'PATH'), norepo=True) |
34959
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
493 def debugcapabilities(ui, path, **opts): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
494 """lists the capabilities of a remote peer""" |
50945
ad9b7017ca22
debugcapabilities: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50944
diff
changeset
|
495 peer = hg.peer(ui, pycompat.byteskwargs(opts), path) |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
496 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
497 caps = peer.capabilities() |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
498 ui.writenoi18n(b'Main capabilities:\n') |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
499 for c in sorted(caps): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
500 ui.write(b' %s\n' % c) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
501 b2caps = bundle2.bundle2caps(peer) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
502 if b2caps: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
503 ui.writenoi18n(b'Bundle2 capabilities:\n') |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
504 for key, values in sorted(b2caps.items()): |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
505 ui.write(b' %s\n' % key) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
506 for v in values: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
507 ui.write(b' %s\n' % v) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
508 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
509 peer.close() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
510 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
511 |
46479
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
512 @command( |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
513 b'debugchangedfiles', |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
514 [ |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
515 ( |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
516 b'', |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
517 b'compute', |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
518 False, |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
519 b"compute information instead of reading it from storage", |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
520 ), |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
521 ], |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
522 b'REV', |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
523 ) |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
524 def debugchangedfiles(ui, repo, rev, **opts): |
45665
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
525 """list the stored files changes for a revision""" |
48118
5105a9975407
errors: raise InputError from revsingle() iff revset provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48116
diff
changeset
|
526 ctx = logcmdutil.revsingle(repo, rev, None) |
46479
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
527 files = None |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
528 |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
529 if opts['compute']: |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
530 files = metadata.compute_all_files_changes(ctx) |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
531 else: |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
532 sd = repo.changelog.sidedata(ctx.rev()) |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
533 files_block = sd.get(sidedata.SD_FILES) |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
534 if files_block is not None: |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
535 files = metadata.decode_files_sidedata(sd) |
c2435280ca63
copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46476
diff
changeset
|
536 if files is not None: |
45665
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
537 for f in sorted(files.touched): |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
538 if f in files.added: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
539 action = b"added" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
540 elif f in files.removed: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
541 action = b"removed" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
542 elif f in files.merged: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
543 action = b"merged" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
544 elif f in files.salvaged: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
545 action = b"salvaged" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
546 else: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
547 action = b"touched" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
548 |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
549 copy_parent = b"" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
550 copy_source = b"" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
551 if f in files.copied_from_p1: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
552 copy_parent = b"p1" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
553 copy_source = files.copied_from_p1[f] |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
554 elif f in files.copied_from_p2: |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
555 copy_parent = b"p2" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
556 copy_source = files.copied_from_p2[f] |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
557 |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
558 data = (action, copy_parent, f, copy_source) |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
559 template = b"%-8s %2s: %s, %s;\n" |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
560 ui.write(template % data) |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
561 |
308ca5528ee6
changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45446
diff
changeset
|
562 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
563 @command(b'debugcheckstate', [], b'') |
30503
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
564 def debugcheckstate(ui, repo): |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
565 """validate the correctness of the current dirstate""" |
49826
c84844cd523a
verify: also check dirstate
Raphaël Gomès <rgomes@octobus.net>
parents:
49824
diff
changeset
|
566 errors = verify.verifier(repo)._verify_dirstate() |
30503
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
567 if errors: |
49826
c84844cd523a
verify: also check dirstate
Raphaël Gomès <rgomes@octobus.net>
parents:
49824
diff
changeset
|
568 errstr = _(b"dirstate inconsistent with current parent's manifest") |
43635
72b454fae92e
debugcommands: don't shadow the error module
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
569 raise error.Abort(errstr) |
30504
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
570 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
571 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
572 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
573 b'debugcolor', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
574 [(b'', b'style', None, _(b'show all configured styles'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
575 b'hg debugcolor', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
576 ) |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
577 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
|
578 """show available color, effects or style""" |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
579 ui.writenoi18n(b'color mode: %s\n' % stringutil.pprint(ui._colormode)) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
580 if opts.get('style'): |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
581 return _debugdisplaystyle(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
582 else: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
583 return _debugdisplaycolor(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
584 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
585 |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
586 def _debugdisplaycolor(ui): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
587 ui = ui.copy() |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
588 ui._styles.clear() |
31689
57a22f699179
color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents:
31634
diff
changeset
|
589 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
|
590 ui._styles[effect] = effect |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
591 if ui._terminfoparams: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
592 for k, v in ui.configitems(b'color'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
593 if k.startswith(b'color.'): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
594 ui._styles[k] = k[6:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
595 elif k.startswith(b'terminfo.'): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
596 ui._styles[k] = k[9:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
597 ui.write(_(b'available colors:\n')) |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
598 # sort label with a '_' after the other to group '_background' entry. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
599 items = sorted(ui._styles.items(), key=lambda i: (b'_' in i[0], i[0], i[1])) |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
600 for colorname, label in items: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
601 ui.write(b'%s\n' % colorname, label=label) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
602 |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
603 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
604 def _debugdisplaystyle(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
605 ui.write(_(b'available style:\n')) |
37823
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
606 if not ui._styles: |
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
607 return |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
608 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
|
609 for label, effects in sorted(ui._styles.items()): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
610 ui.write(b'%s' % label, label=label) |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
611 if effects: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
612 # 50 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
613 ui.write(b': ') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
614 ui.write(b' ' * (max(0, width - len(label)))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
615 ui.write(b', '.join(ui.label(e, e) for e in effects.split())) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
616 ui.write(b'\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
617 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
618 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
619 @command(b'debugcreatestreamclonebundle', [], b'FILE') |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
620 def debugcreatestreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
621 """create a stream clone bundle file |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
622 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
623 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
|
624 revlog files. They are commonly used for cloning very quickly. |
50644
89556caf3c66
stream-clone: update debugcreatestreamclonebundle helps
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50619
diff
changeset
|
625 |
89556caf3c66
stream-clone: update debugcreatestreamclonebundle helps
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50619
diff
changeset
|
626 This command creates a "version 1" stream clone, which is deprecated in |
89556caf3c66
stream-clone: update debugcreatestreamclonebundle helps
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50619
diff
changeset
|
627 favor of newer versions of the stream protocol. Bundles using such newer |
89556caf3c66
stream-clone: update debugcreatestreamclonebundle helps
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50619
diff
changeset
|
628 versions can be generated using the `hg bundle` command. |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
629 """ |
32745
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
630 # 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
|
631 # 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
|
632 if phases.hassecret(repo): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
633 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
634 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
635 b'(warning: stream clone bundle will contain secret ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
636 b'revisions)\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
637 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
638 ) |
32745
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32694
diff
changeset
|
639 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
640 requirements, gen = streamclone.generatebundlev1(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
641 changegroup.writechunks(ui, gen, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
642 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
643 ui.write(_(b'bundle requirements: %s\n') % b', '.join(sorted(requirements))) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
644 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
645 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
646 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
647 b'debugdag', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
648 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
649 (b't', b'tags', None, _(b'use tags as labels')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
650 (b'b', b'branches', None, _(b'annotate with branch names')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
651 (b'', b'dots', None, _(b'use dots for runs')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
652 (b's', b'spaces', None, _(b'separate elements by spaces')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
653 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
654 _(b'[OPTION]... [FILE [REV]...]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
655 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
656 ) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
657 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
|
658 """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
|
659 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
660 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
|
661 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
|
662 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
663 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
|
664 """ |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
665 spaces = opts.get('spaces') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
666 dots = opts.get('dots') |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
667 if file_: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
668 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), file_) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44433
diff
changeset
|
669 revs = {int(r) for r in revs} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
670 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
671 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
672 for r in rlog: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
673 yield b'n', (r, list(p for p in rlog.parentrevs(r) if p != -1)) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
674 if r in revs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
675 yield b'l', (r, b"r%i" % r) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
676 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
677 elif repo: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
678 cl = repo.changelog |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
679 tags = opts.get('tags') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
680 branches = opts.get('branches') |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
681 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
682 labels = {} |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
683 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
|
684 labels.setdefault(cl.rev(n), []).append(l) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
685 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
686 def events(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
687 b = b"default" |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
688 for r in cl: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
689 if branches: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
690 newb = cl.read(cl.node(r))[5][b'branch'] |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
691 if newb != b: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
692 yield b'a', newb |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
693 b = newb |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
694 yield b'n', (r, list(p for p in cl.parentrevs(r) if p != -1)) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
695 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
696 ls = labels.get(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
697 if ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
698 for l in ls: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
699 yield b'l', (r, l) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
700 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
701 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
702 raise error.Abort(_(b'need repo for changelog dag')) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
703 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
704 for line in dagparser.dagtextlines( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
705 events(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
706 addspaces=spaces, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
707 wraplabels=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
708 wrapannotations=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
709 wrapnonlinear=dots, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
710 usedots=dots, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
711 maxlinewidth=70, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
712 ): |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
713 ui.write(line) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
714 ui.write(b"\n") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
716 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
717 @command(b'debugdata', cmdutil.debugrevlogopts, _(b'-c|-m|FILE REV')) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
718 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
|
719 """dump the contents of a data file revision""" |
50946
4135e7271b9e
debugdata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50945
diff
changeset
|
720 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
721 if rev is not None: |
50547
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
722 raise error.InputError( |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
723 _(b'cannot specify a revision with other arguments') |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
724 ) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
725 file_, rev = None, file_ |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
726 elif rev is None: |
50547
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
727 raise error.InputError(_(b'please specify a revision')) |
50946
4135e7271b9e
debugdata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50945
diff
changeset
|
728 r = cmdutil.openstorage( |
4135e7271b9e
debugdata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50945
diff
changeset
|
729 repo, b'debugdata', file_, pycompat.byteskwargs(opts) |
4135e7271b9e
debugdata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50945
diff
changeset
|
730 ) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
731 try: |
42773
127d57e950e0
rawdata: update callers in debugcommands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42651
diff
changeset
|
732 ui.write(r.rawdata(r.lookup(rev))) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
733 except KeyError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
734 raise error.Abort(_(b'invalid revision identifier %s') % rev) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
735 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
736 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
737 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
738 b'debugdate', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
739 [(b'e', b'extended', None, _(b'try extended date formats'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
740 _(b'[-e] DATE [RANGE]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
741 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
742 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
743 ) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
744 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
|
745 """parse and display a date""" |
43503
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43238
diff
changeset
|
746 if opts["extended"]: |
43878
38d6aa768310
debugcommands: finish moving `extendeddateformats` from util to dateutil
Matt Harbison <matt_harbison@yahoo.com>
parents:
43704
diff
changeset
|
747 d = dateutil.parsedate(date, dateutil.extendeddateformats) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
748 else: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
749 d = dateutil.parsedate(date) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
750 ui.writenoi18n(b"internal: %d %d\n" % d) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
751 ui.writenoi18n(b"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
|
752 if range: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
753 m = dateutil.matchdate(range) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
754 ui.writenoi18n(b"match: %s\n" % m(d[0])) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
755 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
756 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
757 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
758 b'debugdeltachain', |
51072
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
759 [ |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
760 ( |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
761 b'r', |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
762 b'rev', |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
763 [], |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
764 _('restrict processing to these revlog revisions'), |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
765 ), |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
766 ( |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
767 b'', |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
768 b'all-info', |
51076
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51075
diff
changeset
|
769 False, |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
770 _('compute all information unless specified otherwise'), |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
771 ), |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
772 ( |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
773 b'', |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
774 b'size-info', |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
775 None, |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
776 _('compute information related to deltas size'), |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
777 ), |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
778 ( |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
779 b'', |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
780 b'dist-info', |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
781 None, |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
782 _('compute information related to base distance'), |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
783 ), |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
784 ( |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
785 b'', |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
786 b'sparse-info', |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
787 None, |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
788 _('compute information related to sparse read'), |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
789 ), |
51072
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
790 ] |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
791 + cmdutil.debugrevlogopts |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
792 + cmdutil.formatteropts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
793 _(b'-c|-m|FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
794 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
795 ) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
796 def debugdeltachain(ui, repo, file_=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
797 """dump information about delta chains in a revlog |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
798 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
799 Output can be templatized. Available template keywords are: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
800 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
801 :``rev``: revision number |
49221
75d0775dce7f
debugdeltachain: also display p1/p2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49219
diff
changeset
|
802 :``p1``: parent 1 revision number (for reference) |
75d0775dce7f
debugdeltachain: also display p1/p2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49219
diff
changeset
|
803 :``p2``: parent 2 revision number (for reference) |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
804 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
805 :``chainid``: delta chain identifier (numbered by unique base) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
806 :``chainlen``: delta chain length to this revision |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
807 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
808 :``prevrev``: previous revision in delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
809 :``deltatype``: role of delta / how it was computed |
49222
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
810 - base: a full snapshot |
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
811 - snap: an intermediate snapshot |
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
812 - p1: a delta against the first parent |
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
813 - p2: a delta against the second parent |
49223
13e523228623
debugdeltachain: detect a special case where parents are "skipped"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49222
diff
changeset
|
814 - skip1: a delta against the same base as p1 |
13e523228623
debugdeltachain: detect a special case where parents are "skipped"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49222
diff
changeset
|
815 (when p1 has empty delta |
13e523228623
debugdeltachain: detect a special case where parents are "skipped"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49222
diff
changeset
|
816 - skip2: a delta against the same base as p2 |
13e523228623
debugdeltachain: detect a special case where parents are "skipped"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49222
diff
changeset
|
817 (when p2 has empty delta |
49222
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
818 - prev: a delta against the previous revision |
e7d23c512d3d
debugdeltachain: document the possible value for deltatype
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49221
diff
changeset
|
819 - other: a delta against an arbitrary revision |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
820 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
821 :``compsize``: compressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
822 :``uncompsize``: uncompressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
823 :``chainsize``: total size of compressed revisions in chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
824 :``chainratio``: total chain size divided by uncompressed revision size |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
825 (new delta chains typically start at ratio 2.00) |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
826 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
827 :``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
|
828 of this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
829 :``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
|
830 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
|
831 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
|
832 the delta chain for this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
833 :``extraratio``: extradist divided by chainsize; another representation of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
834 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
|
835 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
836 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
|
837 are available: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
838 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
839 :``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
|
840 (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
|
841 :``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
|
842 :``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
|
843 :``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
|
844 |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
845 It is possible to select the information to be computed, this can provide a |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
846 noticeable speedup to the command in some cases. |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
847 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
848 Always computed: |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
849 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
850 - ``rev`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
851 - ``p1`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
852 - ``p2`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
853 - ``chainid`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
854 - ``chainlen`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
855 - ``prevrev`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
856 - ``deltatype`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
857 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
858 Computed with --no-size-info |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
859 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
860 - ``compsize`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
861 - ``uncompsize`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
862 - ``chainsize`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
863 - ``chainratio`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
864 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
865 Computed with --no-dist-info |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
866 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
867 - ``lindist`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
868 - ``extradist`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
869 - ``extraratio`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
870 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
871 Skipped with --no-sparse-info |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
872 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
873 - ``readsize`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
874 - ``largestblock`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
875 - ``readdensity`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
876 - ``srchunks`` |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
877 |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
878 -- |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
879 |
35059
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
34960
diff
changeset
|
880 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
|
881 """ |
51072
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
882 revs = None |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
883 revs_opt = opts.pop('rev', []) |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
884 if revs_opt: |
810446d2d5ef
debug-delta-chaing: add a parameter to select revision to look at
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51070
diff
changeset
|
885 revs = [int(r) for r in revs_opt] |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
886 |
51076
786b6225793a
debug-delta-chain: print less data by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51075
diff
changeset
|
887 all_info = opts.pop('all_info', False) |
51075
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
888 size_info = opts.pop('size_info', None) |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
889 if size_info is None: |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
890 size_info = all_info |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
891 dist_info = opts.pop('dist_info', None) |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
892 if dist_info is None: |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
893 dist_info = all_info |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
894 sparse_info = opts.pop('sparse_info', None) |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
895 if sparse_info is None: |
2d30d1ba0371
debugdeltachain: add a parameter to display all info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51073
diff
changeset
|
896 sparse_info = all_info |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
897 |
51070
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
898 revlog = cmdutil.openrevlog( |
50947
32fe4af9971d
debugdeltachain: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50946
diff
changeset
|
899 repo, b'debugdeltachain', file_, pycompat.byteskwargs(opts) |
32fe4af9971d
debugdeltachain: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50946
diff
changeset
|
900 ) |
32fe4af9971d
debugdeltachain: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50946
diff
changeset
|
901 fm = ui.formatter(b'debugdeltachain', pycompat.byteskwargs(opts)) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
902 |
51073
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
903 lines = revlog_debug.debug_delta_chain( |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
904 revlog, |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
905 revs=revs, |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
906 size_info=size_info, |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
907 dist_info=dist_info, |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
908 sparse_info=sparse_info, |
752e380c5702
debug-delta-chain: add options to control what we compute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51072
diff
changeset
|
909 ) |
51070
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
910 # first entry is the header |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
911 header = next(lines) |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
912 fm.plain(header) |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
913 for entry in lines: |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
914 label = b' '.join(e[0] for e in entry) |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
915 format = b' '.join(e[1] for e in entry) |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
916 values = [e[3] for e in entry] |
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
917 data = dict((e[2], e[3]) for e in entry) |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
918 fm.startitem() |
51070
d7f975e49f20
delta-chain: move the debugdeltachain command in revlogutils
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51059
diff
changeset
|
919 fm.write(label, format, *values, **data) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
920 fm.plain(b'\n') |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
921 fm.end() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
922 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
923 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
924 @command( |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
925 b'debug-delta-find', |
49589
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
926 cmdutil.debugrevlogopts |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
927 + cmdutil.formatteropts |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
928 + [ |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
929 ( |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
930 b'', |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
931 b'source', |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
932 b'full', |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
933 _(b'input data feed to the process (full, storage, p1, p2, prev)'), |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
934 ), |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
935 ], |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
936 _(b'-c|-m|FILE REV'), |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
937 optionalrepo=True, |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
938 ) |
49589
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
939 def debugdeltafind(ui, repo, arg_1, arg_2=None, source=b'full', **opts): |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
940 """display the computation to get to a valid delta for storing REV |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
941 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
942 This command will replay the process used to find the "best" delta to store |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
943 a revision and display information about all the steps used to get to that |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
944 result. |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
945 |
49589
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
946 By default, the process is fed with a the full-text for the revision. This |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
947 can be controlled with the --source flag. |
266bb5c86f4b
debug-delta-find: add a --source option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49473
diff
changeset
|
948 |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
949 The revision use the revision number of the target storage (not changelog |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
950 revision number). |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
951 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
952 note: the process is initiated from a full text of the revision to store. |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
953 """ |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
954 if arg_2 is None: |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
955 file_ = None |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
956 rev = arg_1 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
957 else: |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
958 file_ = arg_1 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
959 rev = arg_2 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
960 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
961 rev = int(rev) |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
962 |
50948
f7c35a645c2e
debugdeltafind: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50947
diff
changeset
|
963 revlog = cmdutil.openrevlog( |
f7c35a645c2e
debugdeltafind: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50947
diff
changeset
|
964 repo, b'debugdeltachain', file_, pycompat.byteskwargs(opts) |
f7c35a645c2e
debugdeltafind: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50947
diff
changeset
|
965 ) |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
966 p1r, p2r = revlog.parentrevs(rev) |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
967 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
968 if source == b'full': |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
969 base_rev = nullrev |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
970 elif source == b'storage': |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
971 base_rev = revlog.deltaparent(rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
972 elif source == b'p1': |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
973 base_rev = p1r |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
974 elif source == b'p2': |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
975 base_rev = p2r |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
976 elif source == b'prev': |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
977 base_rev = rev - 1 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
978 else: |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
979 raise error.InputError(b"invalid --source value: %s" % source) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
980 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
981 revlog_debug.debug_delta_find(ui, revlog, rev, base_rev=base_rev) |
49228
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
982 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
983 |
b909dd35d9ab
deltas: add a debug-delta-find command to analyse delta search
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49223
diff
changeset
|
984 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
985 b'debugdirstate|debugstate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
986 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
987 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
988 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
989 b'nodates', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
990 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
991 _(b'do not display the saved mtime (DEPRECATED)'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
992 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
993 (b'', b'dates', True, _(b'display the saved mtime')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
994 (b'', b'datesort', None, _(b'sort by saved mtime')), |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
995 ( |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
996 b'', |
49152
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
997 b'docket', |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
998 False, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
999 _(b'display the docket (metadata file) instead'), |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1000 ), |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1001 ( |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1002 b'', |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
1003 b'all', |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
1004 False, |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
1005 _(b'display dirstate-v2 tree nodes that would not exist in v1'), |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
1006 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1007 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1008 _(b'[OPTION]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1009 ) |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1010 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
|
1011 """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
|
1012 |
49152
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1013 if opts.get("docket"): |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1014 if not repo.dirstate._use_dirstate_v2: |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1015 raise error.Abort(_(b'dirstate v1 does not have a docket')) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1016 |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1017 docket = repo.dirstate._map.docket |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1018 ( |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1019 start_offset, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1020 root_nodes, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1021 nodes_with_entry, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1022 nodes_with_copy, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1023 unused_bytes, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1024 _unused, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1025 ignore_pattern, |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1026 ) = dirstateutils.v2.TREE_METADATA.unpack(docket.tree_metadata) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1027 |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1028 ui.write(_(b"size of dirstate data: %d\n") % docket.data_size) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1029 ui.write(_(b"data file uuid: %s\n") % docket.uuid) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1030 ui.write(_(b"start offset of root nodes: %d\n") % start_offset) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1031 ui.write(_(b"number of root nodes: %d\n") % root_nodes) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1032 ui.write(_(b"nodes with entries: %d\n") % nodes_with_entry) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1033 ui.write(_(b"nodes with copies: %d\n") % nodes_with_copy) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1034 ui.write(_(b"number of unused bytes: %d\n") % unused_bytes) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1035 ui.write( |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1036 _(b"ignore pattern hash: %s\n") % binascii.hexlify(ignore_pattern) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1037 ) |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1038 return |
eaaf4f98c9f1
dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents:
49048
diff
changeset
|
1039 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1040 nodates = not opts['dates'] |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1041 if opts.get('nodates') is not None: |
39760
7e99b02768ef
debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents:
39561
diff
changeset
|
1042 nodates = True |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1043 datesort = opts.get('datesort') |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1044 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1045 if datesort: |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1046 |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1047 def keyfunc(entry): |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1048 filename, _state, _mode, _size, mtime = entry |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1049 return (mtime, filename) |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1050 |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1051 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1052 keyfunc = None # sort by filename |
48023
357307feaf61
debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents:
47875
diff
changeset
|
1053 entries = list(repo.dirstate._map.debug_iter(all=opts['all'])) |
47351
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47298
diff
changeset
|
1054 entries.sort(key=keyfunc) |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1055 for entry in entries: |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1056 filename, state, mode, size, mtime = entry |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1057 if mtime == -1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1058 timestr = b'unset ' |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1059 elif nodates: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1060 timestr = b'set ' |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1061 else: |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1062 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(mtime)) |
35204
d4b108fdf423
py3: use encoding.strtolocal() to convert string to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35151
diff
changeset
|
1063 timestr = encoding.strtolocal(timestr) |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1064 if mode & 0o20000: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1065 mode = b'lnk' |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1066 else: |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1067 mode = b'%3o' % (mode & 0o777 & ~util.umask) |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
1068 ui.write(b"%c %s %10d %s%s\n" % (state, mode, size, timestr, filename)) |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1069 for f in repo.dirstate.copies(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1070 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
1071 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1072 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1073 @command( |
49183
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1074 b'debugdirstateignorepatternshash', |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1075 [], |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1076 _(b''), |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1077 ) |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1078 def debugdirstateignorepatternshash(ui, repo, **opts): |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1079 """show the hash of ignore patterns stored in dirstate if v2, |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1080 or nothing for dirstate-v2 |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1081 """ |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1082 if repo.dirstate._use_dirstate_v2: |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1083 docket = repo.dirstate._map.docket |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1084 hash_len = 20 # 160 bits for SHA-1 |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1085 hash_bytes = docket.tree_metadata[-hash_len:] |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1086 ui.write(binascii.hexlify(hash_bytes) + b'\n') |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1087 |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1088 |
22279b604a88
fix-ci: backed out changeset 308e45f7b455
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
1089 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1090 b'debugdiscovery', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1091 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1092 (b'', b'old', None, _(b'use old-style discovery')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1093 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1094 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1095 b'nonheads', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1096 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1097 _(b'use old-style discovery with non-heads included'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1098 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1099 (b'', b'rev', [], b'restrict discovery to this set of revs'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1100 (b'', b'seed', b'12323', b'specify the random seed use for discovery'), |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1101 ( |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1102 b'', |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1103 b'local-as-revs', |
46770
b6ac612445e0
debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46769
diff
changeset
|
1104 b"", |
b6ac612445e0
debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46769
diff
changeset
|
1105 b'treat local has having these revisions only', |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1106 ), |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1107 ( |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1108 b'', |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1109 b'remote-as-revs', |
46770
b6ac612445e0
debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46769
diff
changeset
|
1110 b"", |
48955
db960032d522
debugdiscovery: fix a typo in the help
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48921
diff
changeset
|
1111 b'use local as remote, with only these revisions', |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1112 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1113 ] |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1114 + cmdutil.remoteopts |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1115 + cmdutil.formatteropts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1116 _(b'[--rev REV] [OTHER]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1117 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1118 def debugdiscovery(ui, repo, remoteurl=b"default", **opts): |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1119 """runs the changeset discovery protocol in isolation |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1120 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1121 The local peer can be "replaced" by a subset of the local repository by |
49406
f69bffd00abe
debug-discovery: apply spelling fixes from Raphaël
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49404
diff
changeset
|
1122 using the `--local-as-revs` flag. In the same way, the usual `remote` peer |
f69bffd00abe
debug-discovery: apply spelling fixes from Raphaël
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49404
diff
changeset
|
1123 can be "replaced" by a subset of the local repository using the |
49399
a3fdc4fcb7d2
debug-discovery: fix a typo in the doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49306
diff
changeset
|
1124 `--remote-as-revs` flag. This is useful to efficiently debug pathological |
49406
f69bffd00abe
debug-discovery: apply spelling fixes from Raphaël
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49404
diff
changeset
|
1125 discovery situations. |
46803
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1126 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1127 The following developer oriented config are relevant for people playing with this command: |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1128 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1129 * devel.discovery.exchange-heads=True |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1130 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1131 If False, the discovery will not start with |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1132 remote head fetching and local head querying. |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1133 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1134 * devel.discovery.grow-sample=True |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1135 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1136 If False, the sample size used in set discovery will not be increased |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1137 through the process |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1138 |
46805
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1139 * devel.discovery.grow-sample.dynamic=True |
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1140 |
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1141 When discovery.grow-sample.dynamic is True, the default, the sample size is |
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1142 adapted to the shape of the undecided set (it is set to the max of: |
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1143 <target-size>, len(roots(undecided)), len(heads(undecided) |
2b1b8f3e6510
setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46803
diff
changeset
|
1144 |
46803
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1145 * devel.discovery.grow-sample.rate=1.05 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1146 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1147 the rate at which the sample grow |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1148 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1149 * devel.discovery.randomize=True |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1150 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1151 If andom sampling during discovery are deterministic. It is meant for |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1152 integration tests. |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1153 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1154 * devel.discovery.sample-size=200 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1155 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1156 Control the initial size of the discovery sample |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1157 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1158 * devel.discovery.sample-size.initial=100 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1159 |
13d973690ecd
debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46794
diff
changeset
|
1160 Control the initial size of the discovery for initial change |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1161 """ |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1162 unfi = repo.unfiltered() |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1163 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1164 # setup potential extra filtering |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1165 local_revs = opts["local_as_revs"] |
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1166 remote_revs = opts["remote_as_revs"] |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1167 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1168 # make sure tests are repeatable |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1169 random.seed(int(opts['seed'])) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1170 |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1171 if not remote_revs: |
49726
4303fa8f4232
path: pass `path` to `peer` in `hg debugdiscovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49676
diff
changeset
|
1172 path = urlutil.get_unique_pull_path_obj( |
4303fa8f4232
path: pass `path` to `peer` in `hg debugdiscovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49676
diff
changeset
|
1173 b'debugdiscovery', ui, remoteurl |
46959
9e021cffb356
debugdiscovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1174 ) |
49726
4303fa8f4232
path: pass `path` to `peer` in `hg debugdiscovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49676
diff
changeset
|
1175 branches = (path.branch, []) |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1176 remote = hg.peer(repo, pycompat.byteskwargs(opts), path) |
49726
4303fa8f4232
path: pass `path` to `peer` in `hg debugdiscovery`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49676
diff
changeset
|
1177 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc)) |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1178 else: |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1179 branches = (None, []) |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48101
diff
changeset
|
1180 remote_filtered_revs = logcmdutil.revrange( |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1181 unfi, [b"not (::(%s))" % remote_revs] |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1182 ) |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1183 remote_filtered_revs = frozenset(remote_filtered_revs) |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1184 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1185 def remote_func(x): |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1186 return remote_filtered_revs |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1187 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1188 repoview.filtertable[b'debug-discovery-remote-filter'] = remote_func |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1189 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1190 remote = repo.peer() |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1191 remote._repo = remote._repo.filtered(b'debug-discovery-remote-filter') |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1192 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1193 if local_revs: |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48101
diff
changeset
|
1194 local_filtered_revs = logcmdutil.revrange( |
46476
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1195 unfi, [b"not (::(%s))" % local_revs] |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1196 ) |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1197 local_filtered_revs = frozenset(local_filtered_revs) |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1198 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1199 def local_func(x): |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1200 return local_filtered_revs |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1201 |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1202 repoview.filtertable[b'debug-discovery-local-filter'] = local_func |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1203 repo = repo.filtered(b'debug-discovery-local-filter') |
4f5e9a77ff7a
debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46466
diff
changeset
|
1204 |
46110
d90f439ff19f
debugdiscovery: display the number of roundtrip used
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46076
diff
changeset
|
1205 data = {} |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1206 if opts.get('old'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1207 |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
1208 def doit(pushedrevs, remoteheads, remote=remote): |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1209 if not hasattr(remote, 'branches'): |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1210 # enable in-client legacy support |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1211 remote = localrepo.locallegacypeer(remote.local()) |
49400
a1bb21542ab0
debug-discovery: properly apply remote filtering in "old" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49399
diff
changeset
|
1212 if remote_revs: |
a1bb21542ab0
debug-discovery: properly apply remote filtering in "old" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49399
diff
changeset
|
1213 r = remote._repo.filtered(b'debug-discovery-remote-filter') |
a1bb21542ab0
debug-discovery: properly apply remote filtering in "old" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49399
diff
changeset
|
1214 remote._repo = r |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1215 common, _in, hds = treediscovery.findcommonincoming( |
46110
d90f439ff19f
debugdiscovery: display the number of roundtrip used
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46076
diff
changeset
|
1216 repo, remote, force=True, audit=data |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1217 ) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1218 common = set(common) |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1219 if not opts.get('nonheads'): |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1220 ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1221 b"unpruned common: %s\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1222 % b" ".join(sorted(short(n) for n in common)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1223 ) |
39163
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
1224 |
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
1225 clnode = repo.changelog.node |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1226 common = repo.revs(b'heads(::%ln)', common) |
39163
26f3d075f36e
debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39161
diff
changeset
|
1227 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
|
1228 return common, hds |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1229 |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
1230 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1231 |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
1232 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
|
1233 nodes = None |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
1234 if pushedrevs: |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48101
diff
changeset
|
1235 revs = logcmdutil.revrange(repo, pushedrevs) |
35304
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35204
diff
changeset
|
1236 nodes = [repo[r].node() for r in revs] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1237 common, any, hds = setdiscovery.findcommonheads( |
49403
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1238 ui, |
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1239 repo, |
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1240 remote, |
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1241 ancestorsof=nodes, |
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1242 audit=data, |
ac4fda5d3ccd
debug-discovery: do not abort on unrelated repositories
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49402
diff
changeset
|
1243 abortwhenunrelated=False, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1244 ) |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
1245 return common, hds |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
1246 |
35419
fed2c040764e
debugdiscovery: drop reference to non-existent --remote-head option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35418
diff
changeset
|
1247 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
50949
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1248 localrevs = opts['rev'] |
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1249 |
8e5083590cfe
debugdiscovery: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50948
diff
changeset
|
1250 fm = ui.formatter(b'debugdiscovery', pycompat.byteskwargs(opts)) |
46769
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1251 if fm.strict_format: |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1252 |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1253 @contextlib.contextmanager |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1254 def may_capture_output(): |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1255 ui.pushbuffer() |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1256 yield |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1257 data[b'output'] = ui.popbuffer() |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1258 |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1259 else: |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1260 may_capture_output = util.nullcontextmanager |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1261 with may_capture_output(): |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1262 with util.timedcm('debug-discovery') as t: |
67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46768
diff
changeset
|
1263 common, hds = doit(localrevs, remoterevs) |
42031
d31d8c5279c6
debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42030
diff
changeset
|
1264 |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
1265 # compute all statistics |
49404
c6aac50038bb
debug-discovery: deal with case where common is empty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49403
diff
changeset
|
1266 if len(common) == 1 and repo.nullid in common: |
c6aac50038bb
debug-discovery: deal with case where common is empty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49403
diff
changeset
|
1267 common = set() |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1268 heads_common = set(common) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1269 heads_remote = set(hds) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1270 heads_local = set(repo.heads()) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1271 # note: they cannot be a local or remote head that is in common and not |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1272 # itself a head of common. |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1273 heads_common_local = heads_common & heads_local |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1274 heads_common_remote = heads_common & heads_remote |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1275 heads_common_both = heads_common & heads_remote & heads_local |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1276 |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1277 all = repo.revs(b'all()') |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1278 common = repo.revs(b'::%ln', common) |
46075
3ca9d26c5984
debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46061
diff
changeset
|
1279 roots_common = repo.revs(b'roots(::%ld)', common) |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1280 missing = repo.revs(b'not ::%ld', common) |
46075
3ca9d26c5984
debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46061
diff
changeset
|
1281 heads_missing = repo.revs(b'heads(%ld)', missing) |
3ca9d26c5984
debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46061
diff
changeset
|
1282 roots_missing = repo.revs(b'roots(%ld)', missing) |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1283 assert len(common) + len(missing) == len(all) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
1284 |
46076
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1285 initial_undecided = repo.revs( |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1286 b'not (::%ln or %ln::)', heads_common_remote, heads_common_local |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1287 ) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1288 heads_initial_undecided = repo.revs(b'heads(%ld)', initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1289 roots_initial_undecided = repo.revs(b'roots(%ld)', initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1290 common_initial_undecided = initial_undecided & common |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1291 missing_initial_undecided = initial_undecided & missing |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1292 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1293 data[b'elapsed'] = t.elapsed |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1294 data[b'nb-common-heads'] = len(heads_common) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1295 data[b'nb-common-heads-local'] = len(heads_common_local) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1296 data[b'nb-common-heads-remote'] = len(heads_common_remote) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1297 data[b'nb-common-heads-both'] = len(heads_common_both) |
46075
3ca9d26c5984
debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46061
diff
changeset
|
1298 data[b'nb-common-roots'] = len(roots_common) |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1299 data[b'nb-head-local'] = len(heads_local) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1300 data[b'nb-head-local-missing'] = len(heads_local) - len(heads_common_local) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1301 data[b'nb-head-remote'] = len(heads_remote) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1302 data[b'nb-head-remote-unknown'] = len(heads_remote) - len( |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1303 heads_common_remote |
46060
24751551fe64
debugdiscovery: clarify internal key name in debugobsolete
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46030
diff
changeset
|
1304 ) |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1305 data[b'nb-revs'] = len(all) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1306 data[b'nb-revs-common'] = len(common) |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1307 data[b'nb-revs-missing'] = len(missing) |
46111
9e24b3d8e896
debugdiscovery: fix swapped heads and roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46110
diff
changeset
|
1308 data[b'nb-missing-heads'] = len(heads_missing) |
9e24b3d8e896
debugdiscovery: fix swapped heads and roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46110
diff
changeset
|
1309 data[b'nb-missing-roots'] = len(roots_missing) |
46076
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1310 data[b'nb-ini_und'] = len(initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1311 data[b'nb-ini_und-heads'] = len(heads_initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1312 data[b'nb-ini_und-roots'] = len(roots_initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1313 data[b'nb-ini_und-common'] = len(common_initial_undecided) |
0e5065b6baa0
debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46075
diff
changeset
|
1314 data[b'nb-ini_und-missing'] = len(missing_initial_undecided) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
1315 |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1316 fm.startitem() |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1317 fm.data(**pycompat.strkwargs(data)) |
42032
63165e4a76da
debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42031
diff
changeset
|
1318 # display discovery summary |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1319 fm.plain(b"elapsed time: %(elapsed)f seconds\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1320 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data) |
49402
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1321 if b'total-round-trips-heads' in data: |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1322 fm.plain( |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1323 b" round-trips-heads: %(total-round-trips-heads)9d\n" % data |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1324 ) |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1325 if b'total-round-trips-branches' in data: |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1326 fm.plain( |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1327 b" round-trips-branches: %(total-round-trips-branches)9d\n" |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1328 % data |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1329 ) |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1330 if b'total-round-trips-between' in data: |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1331 fm.plain( |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1332 b" round-trips-between: %(total-round-trips-between)9d\n" % data |
236702592ff0
debug-discovery: gather the right number of roundtrips for tree discovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49401
diff
changeset
|
1333 ) |
49017
f054a557aab8
discovery: also audit the number of queries done
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48955
diff
changeset
|
1334 fm.plain(b"queries: %(total-queries)9d\n" % data) |
49401
362c0026a977
debug-discovery: also gather details on tree-discovery queries type
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49400
diff
changeset
|
1335 if b'total-queries-branches' in data: |
362c0026a977
debug-discovery: also gather details on tree-discovery queries type
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49400
diff
changeset
|
1336 fm.plain(b" queries-branches: %(total-queries-branches)9d\n" % data) |
362c0026a977
debug-discovery: also gather details on tree-discovery queries type
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49400
diff
changeset
|
1337 if b'total-queries-between' in data: |
362c0026a977
debug-discovery: also gather details on tree-discovery queries type
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49400
diff
changeset
|
1338 fm.plain(b" queries-between: %(total-queries-between)9d\n" % data) |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1339 fm.plain(b"heads summary:\n") |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1340 fm.plain(b" total common heads: %(nb-common-heads)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1341 fm.plain(b" also local heads: %(nb-common-heads-local)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1342 fm.plain(b" also remote heads: %(nb-common-heads-remote)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1343 fm.plain(b" both: %(nb-common-heads-both)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1344 fm.plain(b" local heads: %(nb-head-local)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1345 fm.plain(b" common: %(nb-common-heads-local)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1346 fm.plain(b" missing: %(nb-head-local-missing)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1347 fm.plain(b" remote heads: %(nb-head-remote)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1348 fm.plain(b" common: %(nb-common-heads-remote)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1349 fm.plain(b" unknown: %(nb-head-remote-unknown)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1350 fm.plain(b"local changesets: %(nb-revs)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1351 fm.plain(b" common: %(nb-revs-common)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1352 fm.plain(b" heads: %(nb-common-heads)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1353 fm.plain(b" roots: %(nb-common-roots)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1354 fm.plain(b" missing: %(nb-revs-missing)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1355 fm.plain(b" heads: %(nb-missing-heads)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1356 fm.plain(b" roots: %(nb-missing-roots)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1357 fm.plain(b" first undecided set: %(nb-ini_und)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1358 fm.plain(b" heads: %(nb-ini_und-heads)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1359 fm.plain(b" roots: %(nb-ini_und-roots)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1360 fm.plain(b" common: %(nb-ini_und-common)9d\n" % data) |
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1361 fm.plain(b" missing: %(nb-ini_und-missing)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
|
1362 |
42034
fd8d13ea1bcc
debugdiscovery: only list common heads on verbose
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42033
diff
changeset
|
1363 if ui.verbose: |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1364 fm.plain( |
46061
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1365 b"common heads: %s\n" |
44a52048c6d6
debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46060
diff
changeset
|
1366 % b" ".join(sorted(short(n) for n in heads_common)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1367 ) |
46768
3a8cf5b9c820
debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46711
diff
changeset
|
1368 fm.end() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1369 |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1370 |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1371 _chunksize = 4 << 10 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1372 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1373 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1374 @command( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1375 b'debugdownload', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1376 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1377 (b'o', b'output', b'', _(b'path')), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1378 ], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1379 optionalrepo=True, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1380 ) |
35730
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
1381 def debugdownload(ui, repo, url, output=None, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1382 """download a resource using Mercurial logic and config""" |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1383 fh = urlmod.open(ui, url, output) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1384 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1385 dest = ui |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1386 if output: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1387 dest = open(output, b"wb", _chunksize) |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1388 try: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1389 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1390 while data: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1391 dest.write(data) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1392 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1393 finally: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1394 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1395 dest.close() |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35514
diff
changeset
|
1396 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1397 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1398 @command(b'debugextensions', cmdutil.formatteropts, [], optionalrepo=True) |
37977
8ba0344f9fb1
debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
1399 def debugextensions(ui, repo, **opts): |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1400 '''show information about active extensions''' |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1401 exts = extensions.extensions(ui) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1402 hgver = util.version() |
50950
5dc20e1f0518
debugextensions: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50949
diff
changeset
|
1403 fm = ui.formatter(b'debugextensions', pycompat.byteskwargs(opts)) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1404 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
|
1405 isinternal = extensions.ismoduleinternal(extmod) |
43687
f1dabf99db17
debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43686
diff
changeset
|
1406 extsource = None |
f1dabf99db17
debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43686
diff
changeset
|
1407 |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1408 if hasattr(extmod, '__file__'): |
43687
f1dabf99db17
debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43686
diff
changeset
|
1409 extsource = pycompat.fsencode(extmod.__file__) |
f1dabf99db17
debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43686
diff
changeset
|
1410 elif getattr(sys, 'oxidized', False): |
f1dabf99db17
debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43686
diff
changeset
|
1411 extsource = pycompat.sysexecutable |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1412 if isinternal: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1413 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
|
1414 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1415 exttestedwith = getattr(extmod, 'testedwith', b'').split() |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1416 extbuglink = getattr(extmod, 'buglink', None) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1417 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1418 fm.startitem() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1419 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1420 if ui.quiet or ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1421 fm.write(b'name', b'%s\n', extname) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1422 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1423 fm.write(b'name', b'%s', extname) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1424 if isinternal or hgver in exttestedwith: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1425 fm.plain(b'\n') |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1426 elif not exttestedwith: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1427 fm.plain(_(b' (untested!)\n')) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1428 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1429 lasttestedversion = exttestedwith[-1] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1430 fm.plain(b' (%s!)\n' % lasttestedversion) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1431 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1432 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1433 ui.verbose and extsource, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1434 b'source', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1435 _(b' location: %s\n'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1436 extsource or b"", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1437 ) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1438 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1439 if ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1440 fm.plain(_(b' bundled: %s\n') % [b'no', b'yes'][isinternal]) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1441 fm.data(bundled=isinternal) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1442 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1443 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1444 ui.verbose and exttestedwith, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1445 b'testedwith', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1446 _(b' tested with: %s\n'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1447 fm.formatlist(exttestedwith, name=b'ver'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1448 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1449 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1450 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1451 ui.verbose and extbuglink, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1452 b'buglink', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1453 _(b' bug reporting: %s\n'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1454 extbuglink or b"", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1455 ) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1456 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
1457 fm.end() |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
1458 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1459 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1460 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1461 b'debugfileset', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1462 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1463 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1464 b'r', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1465 b'rev', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1466 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1467 _(b'apply the filespec on this revision'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1468 _(b'REV'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1469 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1470 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1471 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1472 b'all-files', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1473 False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1474 _(b'test files from all revisions and working directory'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1475 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1476 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1477 b's', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1478 b'show-matcher', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1479 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1480 _(b'print internal representation of matcher'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1481 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1482 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1483 b'p', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1484 b'show-stage', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1485 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1486 _(b'print parsed tree at the given stage'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1487 _(b'NAME'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1488 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1489 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1490 _(b'[-r REV] [--all-files] [OPTION]... FILESPEC'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1491 ) |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
1492 def debugfileset(ui, repo, expr, **opts): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
1493 '''parse and apply a fileset specification''' |
38972
4d992e3f10ba
debugcommands: force import of fileset in debugfileset
Augie Fackler <augie@google.com>
parents:
38829
diff
changeset
|
1494 from . import fileset |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1495 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1496 fileset.symbols # force import of fileset so we have predicates to optimize |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1497 |
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1498 ctx = logcmdutil.revsingle(repo, opts.get('rev'), None) |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1499 |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1500 stages = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1501 (b'parsed', pycompat.identity), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1502 (b'analyzed', filesetlang.analyze), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1503 (b'optimized', filesetlang.optimize), |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1504 ] |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44433
diff
changeset
|
1505 stagenames = {n for n, f in stages} |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1506 |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1507 showalways = set() |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1508 if ui.verbose and not opts['show_stage']: |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1509 # show parsed tree by --verbose (deprecated) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1510 showalways.add(b'parsed') |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1511 if opts['show_stage'] == [b'all']: |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1512 showalways.update(stagenames) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1513 else: |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1514 for n in opts['show_stage']: |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1515 if n not in stagenames: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1516 raise error.Abort(_(b'invalid stage name: %s') % n) |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1517 showalways.update(opts['show_stage']) |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1518 |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38802
diff
changeset
|
1519 tree = filesetlang.parse(expr) |
38801
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1520 for n, f in stages: |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1521 tree = f(tree) |
1d1c1645d7b9
debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
38783
diff
changeset
|
1522 if n in showalways: |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1523 if opts['show_stage'] or n != b'parsed': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1524 ui.write(b"* %s:\n" % n) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1525 ui.write(filesetlang.prettyformat(tree), b"\n") |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
1526 |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1527 files = set() |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1528 if opts['all_files']: |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1529 for r in repo: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1530 c = repo[r] |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1531 files.update(c.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1532 files.update(c.substate) |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1533 if opts['all_files'] or ctx.rev() is None: |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1534 wctx = repo[None] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1535 files.update( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1536 repo.dirstate.walk( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1537 scmutil.matchall(repo), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1538 subrepos=list(wctx.substate), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1539 unknown=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1540 ignored=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1541 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1542 ) |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1543 files.update(wctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1544 else: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1545 files.update(ctx.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1546 files.update(ctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1547 |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43972
diff
changeset
|
1548 m = ctx.matchfileset(repo.getcwd(), expr) |
50951
44c29568898f
debugfileset: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50950
diff
changeset
|
1549 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1550 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') |
38610
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1551 for f in sorted(files): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1552 if not m(f): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38599
diff
changeset
|
1553 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1554 ui.write(b"%s\n" % f) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1555 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1556 |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1557 @command( |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1558 b"debug-repair-issue6528", |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1559 [ |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1560 ( |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1561 b'', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1562 b'to-report', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1563 b'', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1564 _(b'build a report of affected revisions to this file'), |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1565 _(b'FILE'), |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1566 ), |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1567 ( |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1568 b'', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1569 b'from-report', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1570 b'', |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1571 _(b'repair revisions listed in this report file'), |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1572 _(b'FILE'), |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1573 ), |
47817
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1574 ( |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1575 b'', |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1576 b'paranoid', |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1577 False, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1578 _(b'check that both detection methods do the same thing'), |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1579 ), |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1580 ] |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1581 + cmdutil.dryrunopts, |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1582 ) |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1583 def debug_repair_issue6528(ui, repo, **opts): |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1584 """find affected revisions and repair them. See issue6528 for more details. |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1585 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1586 The `--to-report` and `--from-report` flags allow you to cache and reuse the |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1587 computation of affected revisions for a given repository across clones. |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1588 The report format is line-based (with empty lines ignored): |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1589 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1590 ``` |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1591 <ascii-hex of the affected revision>,... <unencoded filelog index filename> |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1592 ``` |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1593 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1594 There can be multiple broken revisions per filelog, they are separated by |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1595 a comma with no spaces. The only space is between the revision(s) and the |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1596 filename. |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1597 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1598 Note that this does *not* mean that this repairs future affected revisions, |
48187
b669e40fbbd6
help: update help text for debug-repair-issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
48118
diff
changeset
|
1599 that needs a separate fix at the exchange level that was introduced in |
b669e40fbbd6
help: update help text for debug-repair-issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
48118
diff
changeset
|
1600 Mercurial 5.9.1. |
47817
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1601 |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1602 There is a `--paranoid` flag to test that the fast implementation is correct |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1603 by checking it against the slow implementation. Since this matter is quite |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1604 urgent and testing every edge-case is probably quite costly, we use this |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1605 method to test on large repositories as a fuzzing method of sorts. |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1606 """ |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1607 cmdutil.check_incompatible_arguments( |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1608 opts, 'to_report', ['from_report', 'dry_run'] |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1609 ) |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1610 dry_run = opts.get('dry_run') |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1611 to_report = opts.get('to_report') |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1612 from_report = opts.get('from_report') |
47817
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1613 paranoid = opts.get('paranoid') |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1614 # TODO maybe add filelog pattern and revision pattern parameters to help |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1615 # narrow down the search for users that know what they're looking for? |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1616 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1617 if requirements.REVLOGV1_REQUIREMENT not in repo.requirements: |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1618 msg = b"can only repair revlogv1 repositories, v2 is not affected" |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1619 raise error.Abort(_(msg)) |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1620 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1621 rewrite.repair_issue6528( |
47817
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1622 ui, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1623 repo, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1624 dry_run=dry_run, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1625 to_report=to_report, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1626 from_report=from_report, |
855463b5fe49
debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents:
47815
diff
changeset
|
1627 paranoid=paranoid, |
47815
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1628 ) |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1629 |
b30a53ffbf9b
debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents:
47683
diff
changeset
|
1630 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1631 @command(b'debugformat', [] + cmdutil.formatteropts) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1632 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
|
1633 """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
|
1634 |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1635 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
|
1636 Mercurial default.""" |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1637 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1638 maxvariantlength = max(len(b'format-variant'), maxvariantlength) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1639 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1640 def makeformatname(name): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1641 return b'%s:' + (b' ' * (maxvariantlength - len(name))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1642 |
50952
45381a1dd367
debugformat: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50951
diff
changeset
|
1643 fm = ui.formatter(b'debugformat', pycompat.byteskwargs(opts)) |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1644 if fm.isplain(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1645 |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1646 def formatvalue(value): |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1647 if hasattr(value, 'startswith'): |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1648 return value |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1649 if value: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1650 return b'yes' |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1651 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1652 return b'no' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1653 |
35378
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1654 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35377
diff
changeset
|
1655 formatvalue = pycompat.identity |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1656 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1657 fm.plain(b'format-variant') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1658 fm.plain(b' ' * (maxvariantlength - len(b'format-variant'))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1659 fm.plain(b' repo') |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1660 if ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1661 fm.plain(b' config default') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1662 fm.plain(b'\n') |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1663 for fv in upgrade.allformatvariant: |
35377
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35339
diff
changeset
|
1664 fm.startitem() |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1665 repovalue = fv.fromrepo(repo) |
35337
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35336
diff
changeset
|
1666 configvalue = fv.fromconfig(repo) |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1667 |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1668 if repovalue != configvalue: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1669 namelabel = b'formatvariant.name.mismatchconfig' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1670 repolabel = b'formatvariant.repo.mismatchconfig' |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1671 elif repovalue != fv.default: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1672 namelabel = b'formatvariant.name.mismatchdefault' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1673 repolabel = b'formatvariant.repo.mismatchdefault' |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1674 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1675 namelabel = b'formatvariant.name.uptodate' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1676 repolabel = b'formatvariant.repo.uptodate' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1677 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1678 fm.write(b'name', makeformatname(fv.name), fv.name, label=namelabel) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1679 fm.write(b'repo', b' %3s', formatvalue(repovalue), label=repolabel) |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1680 if fv.default != configvalue: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1681 configlabel = b'formatvariant.config.special' |
35338
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35337
diff
changeset
|
1682 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1683 configlabel = b'formatvariant.config.default' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1684 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1685 ui.verbose, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1686 b'config', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1687 b' %6s', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1688 formatvalue(configvalue), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1689 label=configlabel, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1690 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1691 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1692 ui.verbose, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1693 b'default', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1694 b' %7s', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1695 formatvalue(fv.default), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1696 label=b'formatvariant.default', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1697 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1698 fm.plain(b'\n') |
35377
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35339
diff
changeset
|
1699 fm.end() |
35336
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35304
diff
changeset
|
1700 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1701 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1702 @command(b'debugfsinfo', [], _(b'[PATH]'), norepo=True) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1703 def debugfsinfo(ui, path=b"."): |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
1704 """show information detected about current filesystem""" |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1705 ui.writenoi18n(b'path: %s\n' % path) |
43094
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1706 ui.writenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1707 b'mounted on: %s\n' % (util.getfsmountpoint(path) or b'(unknown)') |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1708 ) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1709 ui.writenoi18n(b'exec: %s\n' % (util.checkexec(path) and b'yes' or b'no')) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1710 ui.writenoi18n(b'fstype: %s\n' % (util.getfstype(path) or b'(unknown)')) |
43094
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1711 ui.writenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1712 b'symlink: %s\n' % (util.checklink(path) and b'yes' or b'no') |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1713 ) |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1714 ui.writenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1715 b'hardlink: %s\n' % (util.checknlink(path) and b'yes' or b'no') |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
1716 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1717 casesensitive = b'(unknown)' |
31634
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1718 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1719 with pycompat.namedtempfile(prefix=b'.debugfsinfo', dir=path) as f: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1720 casesensitive = util.fscasesensitive(f.name) and b'yes' or b'no' |
31634
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1721 except OSError: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
1722 pass |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1723 ui.writenoi18n(b'case-sensitive: %s\n' % casesensitive) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1724 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1725 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1726 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1727 b'debuggetbundle', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1728 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1729 (b'H', b'head', [], _(b'id of head node'), _(b'ID')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1730 (b'C', b'common', [], _(b'id of common node'), _(b'ID')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1731 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1732 b't', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1733 b'type', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1734 b'bzip2', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1735 _(b'bundle compression type to use'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1736 _(b'TYPE'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1737 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1738 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1739 _(b'REPO FILE [-H|-C ID]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1740 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1741 ) |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1742 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
|
1743 """retrieves a bundle from a repo |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1744 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1745 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
|
1746 given file. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1747 """ |
50953
7825175d5ad5
debuggetbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50952
diff
changeset
|
1748 repo = hg.peer(ui, pycompat.byteskwargs(opts), repopath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1749 if not repo.capable(b'getbundle'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1750 raise error.Abort(b"getbundle() not supported by target repository") |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1751 args = {} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1752 if common: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1753 args['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
|
1754 if head: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1755 args['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
|
1756 # TODO: get desired bundlecaps from command line. |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1757 args['bundlecaps'] = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1758 bundle = repo.getbundle(b'debug', **args) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1759 |
50953
7825175d5ad5
debuggetbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50952
diff
changeset
|
1760 bundletype = opts.get('type', b'bzip2').lower() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1761 btypes = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1762 b'none': b'HG10UN', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1763 b'bzip2': b'HG10BZ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1764 b'gzip': b'HG10GZ', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1765 b'bundle2': b'HG20', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1766 } |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1767 bundletype = btypes.get(bundletype) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1768 if bundletype not in bundle2.bundletypes: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1769 raise error.Abort(_(b'unknown bundle type specified with --type')) |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
1770 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
|
1771 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1772 |
50548
720a23405fe9
debug: update usage strings of debugignore and debugnodemap
Anton Shestakov <av6@dwimlabs.net>
parents:
50547
diff
changeset
|
1773 @command(b'debugignore', [], b'[FILE]...') |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1774 def debugignore(ui, repo, *files, **opts): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1775 """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
|
1776 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1777 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
|
1778 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1779 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
|
1780 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
|
1781 """ |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1782 ignore = repo.dirstate._ignore |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1783 if not files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1784 # Show all the patterns |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1785 ui.write(b"%s\n" % pycompat.byterepr(ignore)) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1786 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1787 m = scmutil.match(repo[None], pats=files) |
41636
be8741d42836
debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41515
diff
changeset
|
1788 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
|
1789 for f in m.files(): |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1790 nf = util.normpath(f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1791 ignored = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1792 ignoredata = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1793 if nf != b'.': |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1794 if ignore(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1795 ignored = nf |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1796 ignoredata = repo.dirstate._ignorefileandline(nf) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1797 else: |
43633
0b7733719d21
utils: move finddirs() to pathutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43506
diff
changeset
|
1798 for p in pathutil.finddirs(nf): |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1799 if ignore(p): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1800 ignored = p |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1801 ignoredata = repo.dirstate._ignorefileandline(p) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1802 break |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1803 if ignored: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1804 if ignored == nf: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1805 ui.write(_(b"%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
|
1806 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1807 ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1808 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1809 b"%s is ignored because of " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1810 b"containing directory %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1811 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1812 % (uipathfn(f), ignored) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1813 ) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1814 ignorefile, lineno, line = ignoredata |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1815 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1816 _(b"(ignore rule in %s, line %d: '%s')\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1817 % (ignorefile, lineno, line) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1818 ) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
1819 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1820 ui.write(_(b"%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
|
1821 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1822 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1823 @command( |
49249
db19f6be0442
debugindex: rename to debugindex debug-revlog-index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49248
diff
changeset
|
1824 b'debug-revlog-index|debugindex', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1825 cmdutil.debugrevlogopts + cmdutil.formatteropts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1826 _(b'-c|-m|FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1827 ) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1828 def debugindex(ui, repo, file_=None, **opts): |
49249
db19f6be0442
debugindex: rename to debugindex debug-revlog-index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49248
diff
changeset
|
1829 """dump index data for a revlog""" |
33100
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33062
diff
changeset
|
1830 opts = pycompat.byteskwargs(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1831 store = cmdutil.openstorage(repo, b'debugindex', file_, opts) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1832 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1833 fm = ui.formatter(b'debugindex', opts) |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1834 |
50617
88362b8bc476
safehasattr: pass attribute name as string instead of bytes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50564
diff
changeset
|
1835 revlog = getattr(store, '_revlog', store) |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49250
diff
changeset
|
1836 |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1837 return revlog_debug.debug_index( |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1838 ui, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1839 repo, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1840 formatter=fm, |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49250
diff
changeset
|
1841 revlog=revlog, |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49249
diff
changeset
|
1842 full_node=ui.debugflag, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1843 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
1844 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1845 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1846 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1847 b'debugindexdot', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1848 cmdutil.debugrevlogopts, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1849 _(b'-c|-m|FILE'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1850 optionalrepo=True, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1851 ) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1852 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
|
1853 """dump an index DAG as a graphviz dot file""" |
50954
1cfc49e342c3
debugindexdot: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50953
diff
changeset
|
1854 r = cmdutil.openstorage( |
1cfc49e342c3
debugindexdot: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50953
diff
changeset
|
1855 repo, b'debugindexdot', file_, pycompat.byteskwargs(opts) |
1cfc49e342c3
debugindexdot: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50953
diff
changeset
|
1856 ) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
1857 ui.writenoi18n(b"digraph G {\n") |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1858 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1859 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
1860 pp = r.parents(node) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1861 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i)) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
1862 if pp[1] != repo.nullid: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1863 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1864 ui.write(b"}\n") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1865 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1866 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1867 @command(b'debugindexstats', []) |
39980
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1868 def debugindexstats(ui, repo): |
d71e0ba34d9b
debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents:
39956
diff
changeset
|
1869 """show stats related to the changelog index""" |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
1870 repo.changelog.shortest(repo.nullid, 1) |
40365
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1871 index = repo.changelog.index |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1872 if not hasattr(index, 'stats'): |
51232
3551f2a1c963
debugindexstats: handle the lack of Rust support better
Raphaël Gomès <rgomes@octobus.net>
parents:
51076
diff
changeset
|
1873 raise error.Abort(_(b'debugindexstats only works with native C code')) |
40365
4f37af86d5d5
debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents:
40174
diff
changeset
|
1874 for k, v in sorted(index.stats().items()): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1875 ui.write(b'%s: %d\n' % (k, v)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1876 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1877 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1878 @command(b'debuginstall', [] + cmdutil.formatteropts, b'', norepo=True) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1879 def debuginstall(ui, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1880 """test Mercurial installation |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1881 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1882 Returns 0 on success. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
1883 """ |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1884 problems = 0 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1885 |
50955
45a53fc82ab2
debuginstall: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50954
diff
changeset
|
1886 fm = ui.formatter(b'debuginstall', 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
|
1887 fm.startitem() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1888 |
45100
d50d922ca02b
debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents:
44870
diff
changeset
|
1889 # encoding might be unknown or wrong. don't translate these messages. |
d50d922ca02b
debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents:
44870
diff
changeset
|
1890 fm.write(b'encoding', b"checking encoding (%s)...\n", encoding.encoding) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1891 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1892 try: |
34129
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
1893 codecs.lookup(pycompat.sysstr(encoding.encoding)) |
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34120
diff
changeset
|
1894 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
|
1895 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
|
1896 problems += 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1897 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1898 err, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1899 b'encodingerror', |
45100
d50d922ca02b
debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents:
44870
diff
changeset
|
1900 b" %s\n (check that your locale is properly set)\n", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1901 err, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1902 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1903 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1904 # Python |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1905 pythonlib = None |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1906 if hasattr(os, '__file__'): |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1907 pythonlib = os.path.dirname(pycompat.fsencode(os.__file__)) |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1908 elif getattr(sys, 'oxidized', False): |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1909 pythonlib = pycompat.sysexecutable |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1910 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1911 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1912 b'pythonexe', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1913 _(b"checking Python executable (%s)\n"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1914 pycompat.sysexecutable or _(b"unknown"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1915 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1916 fm.write( |
44145
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
1917 b'pythonimplementation', |
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
1918 _(b"checking Python implementation (%s)\n"), |
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
1919 pycompat.sysbytes(platform.python_implementation()), |
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
1920 ) |
0b475b0b0344
debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44123
diff
changeset
|
1921 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1922 b'pythonver', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1923 _(b"checking Python version (%s)\n"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1924 (b"%d.%d.%d" % sys.version_info[:3]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1925 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1926 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1927 b'pythonlib', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1928 _(b"checking Python lib (%s)...\n"), |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1929 pythonlib or _(b"unknown"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1930 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1931 |
44463
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1932 try: |
46785
521ac0d7047f
typing: disable import error warnings that are already handled
Matt Harbison <matt_harbison@yahoo.com>
parents:
46689
diff
changeset
|
1933 from . import rustext # pytype: disable=import-error |
44463
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1934 |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1935 rustext.__doc__ # trigger lazy import |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1936 except ImportError: |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1937 rustext = None |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1938 |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1939 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
|
1940 if sslutil.hassni: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1941 security.add(b'sni') |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1942 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1943 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1944 b'pythonsecurity', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1945 _(b"checking Python security support (%s)\n"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1946 fm.formatlist(sorted(security), name=b'protocol', fmt=b'%s', sep=b','), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1947 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1948 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1949 # 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
|
1950 # may change in the future. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1951 if b'tls1.2' not in security: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1952 fm.plain( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1953 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1954 b' TLS 1.2 not supported by Python install; ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1955 b'network connections lack modern security\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1956 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1957 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1958 if b'sni' not in security: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1959 fm.plain( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1960 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1961 b' SNI not supported by Python install; may have ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1962 b'connectivity issues with some servers\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1963 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1964 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1965 |
44463
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1966 fm.plain( |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1967 _( |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1968 b"checking Rust extensions (%s)\n" |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1969 % (b'missing' if rustext is None else b'installed') |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1970 ), |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1971 ) |
295417387769
debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents:
44452
diff
changeset
|
1972 |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1973 # 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
|
1974 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1975 # hg version |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1976 hgver = util.version() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1977 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1978 b'hgver', _(b"checking Mercurial version (%s)\n"), hgver.split(b'+')[0] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1979 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1980 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1981 b'hgverextra', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1982 _(b"checking Mercurial custom build (%s)\n"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1983 b'+'.join(hgver.split(b'+')[1:]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1984 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1985 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1986 # compiled modules |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1987 hgmodules = None |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
1988 if hasattr(sys.modules[__name__], '__file__'): |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1989 hgmodules = os.path.dirname(pycompat.fsencode(__file__)) |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1990 elif getattr(sys, 'oxidized', False): |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1991 hgmodules = pycompat.sysexecutable |
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1992 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1993 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1994 b'hgmodulepolicy', _(b"checking module policy (%s)\n"), policy.policy |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1995 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
1996 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1997 b'hgmodules', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1998 _(b"checking installed modules (%s)...\n"), |
43686
1fb19665c166
debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43635
diff
changeset
|
1999 hgmodules or _(b"unknown"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2000 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2001 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2002 rustandc = policy.policy in (b'rust+c', b'rust+c-allow') |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2003 rustext = rustandc # for now, that's the only case |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2004 cext = policy.policy in (b'c', b'allow') or rustandc |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2005 nopure = cext or rustext |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2006 if nopure: |
32209
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
2007 err = None |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
2008 try: |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2009 if cext: |
43703
a9b14ef701d1
debugcommands: suppress import errors for pytype
Augie Fackler <augie@google.com>
parents:
43687
diff
changeset
|
2010 from .cext import ( # pytype: disable=import-error |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2011 base85, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2012 bdiff, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2013 mpatch, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2014 osutil, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2015 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2016 |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2017 # quiet pyflakes |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2018 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2019 if rustext: |
43703
a9b14ef701d1
debugcommands: suppress import errors for pytype
Augie Fackler <augie@google.com>
parents:
43687
diff
changeset
|
2020 from .rustext import ( # pytype: disable=import-error |
42451
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2021 ancestor, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2022 dirstate, |
810f66b468cd
rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents:
42145
diff
changeset
|
2023 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2024 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2025 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
|
2026 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
|
2027 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
|
2028 problems += 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2029 fm.condwrite(err, b'extensionserror', b" %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
|
2030 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2031 compengines = util.compengines._engines.values() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2032 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2033 b'compengines', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2034 _(b'checking registered compression engines (%s)\n'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2035 fm.formatlist( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2036 sorted(e.name() for e in compengines), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2037 name=b'compengine', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2038 fmt=b'%s', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2039 sep=b', ', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2040 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2041 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2042 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2043 b'compenginesavail', |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
2044 _(b'checking available compression engines (%s)\n'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2045 fm.formatlist( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2046 sorted(e.name() for e in compengines if e.available()), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2047 name=b'compengine', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2048 fmt=b'%s', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2049 sep=b', ', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2050 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2051 ) |
42041
3e47d1ec9da5
util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42035
diff
changeset
|
2052 wirecompengines = compression.compengines.supportedwireengines( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2053 compression.SERVERROLE |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2054 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2055 fm.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2056 b'compenginesserver', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2057 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2058 b'checking available compression engines ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2059 b'for wire protocol (%s)\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2060 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2061 fm.formatlist( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2062 [e.name() for e in wirecompengines if e.wireprotosupport()], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2063 name=b'compengine', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2064 fmt=b'%s', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2065 sep=b', ', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2066 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2067 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2068 re2 = b'missing' |
50689
a45460e235a2
re2: fix reporting of availability in `hg debuginstall`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50317
diff
changeset
|
2069 if util.has_re2(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2070 re2 = b'available' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2071 fm.plain(_(b'checking "re2" regexp engine (%s)\n') % re2) |
35448
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35424
diff
changeset
|
2072 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
|
2073 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2074 # templates |
45199
91aa9bba3dc9
templater: make templatepaths() return a single path, or None
Martin von Zweigbergk <martinvonz@google.com>
parents:
45149
diff
changeset
|
2075 p = templater.templatedir() |
45213
d5ccc059fbcd
templater: handle None returned from templatedir()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45199
diff
changeset
|
2076 fm.write(b'templatedirs', b'checking templates (%s)...\n', p or b'') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2077 fm.condwrite(not p, b'', _(b" no template directories found\n")) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2078 if p: |
45320
4aa484efc926
templater: add exception-raising version of open_template()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45309
diff
changeset
|
2079 (m, fp) = templater.try_open_template(b"map-cmdline.default") |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2080 if m: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2081 # 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
|
2082 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2083 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2084 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
|
2085 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
|
2086 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
|
2087 p = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2088 fm.condwrite(err, b'defaulttemplateerror', b" %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
|
2089 else: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2090 p = None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2091 fm.condwrite( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2092 p, b'defaulttemplate', _(b"checking default template (%s)\n"), m |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2093 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2094 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2095 not m, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2096 b'defaulttemplatenotfound', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2097 _(b" template '%s' not found\n"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2098 b"default", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2099 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2100 if not p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2101 problems += 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2102 fm.condwrite( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2103 not p, b'', _(b" (templates seem to have been installed incorrectly)\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2104 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2105 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2106 # editor |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2107 editor = ui.geteditor() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2108 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
|
2109 editorbin = procutil.shellsplit(editor)[0] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2110 fm.write(b'editor', _(b"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
|
2111 cmdpath = procutil.findexe(editorbin) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2112 fm.condwrite( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2113 not cmdpath and editor == b'vi', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2114 b'vinotfound', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2115 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2116 b" No commit editor set and can't find %s in PATH\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2117 b" (specify a commit editor in your configuration" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2118 b" file)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2119 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2120 not cmdpath and editor == b'vi' and editorbin, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2121 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2122 fm.condwrite( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2123 not cmdpath and editor != b'vi', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2124 b'editornotfound', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2125 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2126 b" Can't find editor '%s' in PATH\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2127 b" (specify a commit editor in your configuration" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2128 b" file)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2129 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2130 not cmdpath and editorbin, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2131 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2132 if not cmdpath and editor != b'vi': |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2133 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2134 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2135 # check username |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2136 username = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2137 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2138 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2139 username = ui.username() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2140 except error.Abort as e: |
45682
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45665
diff
changeset
|
2141 err = e.message |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2142 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2143 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2144 fm.condwrite( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2145 username, b'username', _(b"checking username (%s)\n"), username |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2146 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2147 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2148 err, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2149 b'usernameerror', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2150 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2151 b"checking username...\n %s\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2152 b" (specify a username in your configuration file)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2153 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2154 err, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2155 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2156 |
42651
7f1df7019497
debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents:
42580
diff
changeset
|
2157 for name, mod in extensions.extensions(): |
7f1df7019497
debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents:
42580
diff
changeset
|
2158 handler = getattr(mod, 'debuginstall', None) |
7f1df7019497
debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents:
42580
diff
changeset
|
2159 if handler is not None: |
7f1df7019497
debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents:
42580
diff
changeset
|
2160 problems += handler(ui, fm) |
7f1df7019497
debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents:
42580
diff
changeset
|
2161 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2162 fm.condwrite(not problems, b'', _(b"no problems detected\n")) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2163 if not problems: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2164 fm.data(problems=problems) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2165 fm.condwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2166 problems, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2167 b'problems', |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
2168 _(b"%d problems detected, please check your install!\n"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2169 problems, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2170 ) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2171 fm.end() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2172 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2173 return problems |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
2174 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2175 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2176 @command(b'debugknown', [], _(b'REPO ID...'), norepo=True) |
30919
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
2177 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
|
2178 """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
|
2179 |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
2180 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
|
2181 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
|
2182 """ |
50956
0cf89b099d42
debugknown: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50955
diff
changeset
|
2183 repo = hg.peer(ui, pycompat.byteskwargs(opts), repopath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2184 if not repo.capable(b'known'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2185 raise error.Abort(b"known() not supported by target repository") |
30919
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
2186 flags = repo.known([bin(s) for s in ids]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2187 ui.write(b"%s\n" % (b"".join([f and b"1" or b"0" for f in flags]))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2188 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2189 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2190 @command(b'debuglabelcomplete', [], _(b'LABEL...')) |
30935
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
2191 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
|
2192 '''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
|
2193 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
|
2194 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2195 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2196 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2197 b'debuglocks', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2198 [ |
46237
bc884e31b8c8
debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46211
diff
changeset
|
2199 (b'L', b'force-free-lock', None, _(b'free the store lock (DANGEROUS)')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2200 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2201 b'W', |
46237
bc884e31b8c8
debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46211
diff
changeset
|
2202 b'force-free-wlock', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2203 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2204 _(b'free the working state lock (DANGEROUS)'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2205 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2206 (b's', b'set-lock', None, _(b'set the store lock until stopped')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2207 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2208 b'S', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2209 b'set-wlock', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2210 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2211 _(b'set the working state lock until stopped'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2212 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2213 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2214 _(b'[OPTION]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2215 ) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2216 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
|
2217 """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
|
2218 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2219 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
|
2220 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
|
2221 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
|
2222 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
|
2223 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2224 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
|
2225 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
|
2226 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
|
2227 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
|
2228 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2229 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
|
2230 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
|
2231 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
|
2232 |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2233 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
|
2234 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
|
2235 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
|
2236 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2237 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
|
2238 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2239 """ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2240 |
46237
bc884e31b8c8
debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46211
diff
changeset
|
2241 if opts.get('force_free_lock'): |
49048
020378f32d57
debuglock: ignore ENOENT error when unlocking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48691
diff
changeset
|
2242 repo.svfs.tryunlink(b'lock') |
46237
bc884e31b8c8
debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46211
diff
changeset
|
2243 if opts.get('force_free_wlock'): |
49048
020378f32d57
debuglock: ignore ENOENT error when unlocking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48691
diff
changeset
|
2244 repo.vfs.tryunlink(b'wlock') |
46237
bc884e31b8c8
debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46211
diff
changeset
|
2245 if opts.get('force_free_lock') or opts.get('force_free_wlock'): |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2246 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2247 |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2248 locks = [] |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2249 try: |
51949
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2250 # Help the tests out on Windows by writing the correct PID when |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2251 # invoked by the test harness, before creating the lock. |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2252 pids = encoding.environ.get(b'DAEMON_PIDS') |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2253 if pids: |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2254 with open(pids, "ab") as fp: |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2255 fp.write(b'%d\n' % os.getpid()) |
a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
Matt Harbison <matt_harbison@yahoo.com>
parents:
51939
diff
changeset
|
2256 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2257 if opts.get('set_wlock'): |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2258 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2259 locks.append(repo.wlock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2260 except error.LockHeld: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2261 raise error.Abort(_(b'wlock is already held')) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2262 if opts.get('set_lock'): |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2263 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2264 locks.append(repo.lock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2265 except error.LockHeld: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2266 raise error.Abort(_(b'lock is already held')) |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2267 if len(locks): |
49197
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2268 try: |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2269 if ui.interactive(): |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2270 prompt = _(b"ready to release the lock (y)? $$ &Yes") |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2271 ui.promptchoice(prompt) |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2272 else: |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2273 msg = b"%d locks held, waiting for signal\n" |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2274 msg %= len(locks) |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2275 ui.status(msg) |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2276 while True: # XXX wait for a signal |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2277 time.sleep(0.1) |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2278 except KeyboardInterrupt: |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2279 msg = b"signal-received releasing locks\n" |
883be4c74d54
debuglock: make the command more useful in non-interactive mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49183
diff
changeset
|
2280 ui.status(msg) |
35395
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2281 return 0 |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2282 finally: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2283 release(*locks) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35394
diff
changeset
|
2284 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2285 now = time.time() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2286 held = 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2287 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2288 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
|
2289 # 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
|
2290 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2291 l = method(False) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2292 except error.LockHeld: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2293 l = None |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2294 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2295 if l: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2296 l.release() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2297 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2298 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
|
2299 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
|
2300 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
|
2301 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
|
2302 locker = vfs.readlock(name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2303 if b":" in locker: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2304 host, pid = locker.split(b':') |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2305 if host == socket.gethostname(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2306 locker = b'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
|
2307 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2308 locker = b'user %s, process %s, host %s' % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2309 user or b'None', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2310 pid, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2311 host, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2312 ) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
2313 ui.writenoi18n(b"%-6s %s (%ds)\n" % (name + b":", locker, age)) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2314 return 1 |
49306
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
49284
diff
changeset
|
2315 except FileNotFoundError: |
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
49284
diff
changeset
|
2316 pass |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2317 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
2318 ui.writenoi18n(b"%-6s free\n" % (name + b":")) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2319 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2320 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2321 held += report(repo.svfs, b"lock", repo.lock) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2322 held += report(repo.vfs, b"wlock", repo.wlock) |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2323 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2324 return held |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
2325 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2326 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2327 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2328 b'debugmanifestfulltextcache', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2329 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2330 (b'', b'clear', False, _(b'clear the cache')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2331 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2332 b'a', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2333 b'add', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2334 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2335 _(b'add the given manifest nodes to the cache'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2336 _(b'NODE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2337 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2338 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2339 b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2340 ) |
41958
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
2341 def debugmanifestfulltextcache(ui, repo, add=(), **opts): |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2342 """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
|
2343 |
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
|
2344 def getcache(): |
39244
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39163
diff
changeset
|
2345 r = repo.manifestlog.getstorage(b'') |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2346 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
|
2347 return r._fulltextcache |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2348 except AttributeError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2349 msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2350 b"Current revlog implementation doesn't appear to have a " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2351 b"manifest fulltext cache\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2352 ) |
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
|
2353 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
|
2354 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2355 if opts.get('clear'): |
41964
d121823072b8
manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41959
diff
changeset
|
2356 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
|
2357 cache = getcache() |
41947
b74ef67573e5
manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41943
diff
changeset
|
2358 cache.clear(clear_persisted_data=True) |
b74ef67573e5
manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41943
diff
changeset
|
2359 return |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2360 |
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
|
2361 if add: |
41964
d121823072b8
manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41959
diff
changeset
|
2362 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
|
2363 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
|
2364 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
|
2365 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
|
2366 try: |
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
2367 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
|
2368 except error.LookupError as e: |
46689
8408c3198ec1
debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents:
46237
diff
changeset
|
2369 raise error.Abort( |
8408c3198ec1
debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents:
46237
diff
changeset
|
2370 bytes(e), hint=b"Check your manifest node id" |
8408c3198ec1
debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents:
46237
diff
changeset
|
2371 ) |
41958
1fe278aa4ad5
manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41947
diff
changeset
|
2372 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
|
2373 return |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2374 |
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
|
2375 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
|
2376 if not len(cache): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2377 ui.write(_(b'cache empty\n')) |
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
|
2378 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
|
2379 ui.write( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2380 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2381 b'cache contains %d manifest entries, in order of most to ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2382 b'least recent:\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2383 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2384 % (len(cache),) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2385 ) |
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
|
2386 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
|
2387 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
|
2388 # 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
|
2389 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
|
2390 size = len(data) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2391 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2392 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2393 _(b'id: %s, size %s\n') % (hex(nodeid), util.bytecount(size)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2394 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2395 ondisk = cache._opener.stat(b'manifestfulltextcache').st_size |
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
|
2396 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2397 _(b'total cache data size %s, on-disk %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2398 % (util.bytecount(totalsize), util.bytecount(ondisk)) |
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
|
2399 ) |
38781
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
2400 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2401 |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2402 @command(b'debugmergestate', [] + cmdutil.templateopts, b'') |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2403 def debugmergestate(ui, repo, *args, **opts): |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
2404 """print merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
2405 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
2406 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
|
2407 was chosen.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2408 |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2409 if ui.verbose: |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2410 ms = mergestatemod.mergestate(repo) |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2411 |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2412 # sort so that reasonable information is on top |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2413 v1records = ms._readrecordsv1() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2414 v2records = ms._readrecordsv2() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2415 |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2416 if not v1records and not v2records: |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2417 pass |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2418 elif not v2records: |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2419 ui.writenoi18n(b'no version 2 merge state\n') |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2420 elif ms._v1v2match(v1records, v2records): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2421 ui.writenoi18n(b'v1 and v2 states match: using v2\n') |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
2422 else: |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2423 ui.writenoi18n(b'v1 and v2 states mismatch: using v1\n') |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2424 |
50957
81801dc55819
debugmergestate: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50956
diff
changeset
|
2425 if not opts['template']: |
81801dc55819
debugmergestate: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50956
diff
changeset
|
2426 opts['template'] = ( |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2427 b'{if(commits, "", "no merge state found\n")}' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2428 b'{commits % "{name}{if(label, " ({label})")}: {node}\n"}' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2429 b'{files % "file: {path} (state \\"{state}\\")\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2430 b'{if(local_path, "' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2431 b' local path: {local_path} (hash {local_key}, flags \\"{local_flags}\\")\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2432 b' ancestor path: {ancestor_path} (node {ancestor_node})\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2433 b' other path: {other_path} (node {other_node})\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2434 b'")}' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2435 b'{if(rename_side, "' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2436 b' rename side: {rename_side}\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2437 b' renamed path: {renamed_path}\n' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2438 b'")}' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2439 b'{extras % " extra: {key} = {value}\n"}' |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2440 b'"}' |
45445
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2441 b'{extras % "extra: {file} ({key} = {value})\n"}' |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2442 ) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2443 |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2444 ms = mergestatemod.mergestate.read(repo) |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2445 |
50957
81801dc55819
debugmergestate: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50956
diff
changeset
|
2446 fm = ui.formatter(b'debugmergestate', pycompat.byteskwargs(opts)) |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2447 fm.startitem() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2448 |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2449 fm_commits = fm.nested(b'commits') |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2450 if ms.active(): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2451 for name, node, label_index in ( |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2452 (b'local', ms.local, 0), |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2453 (b'other', ms.other, 1), |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2454 ): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2455 fm_commits.startitem() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2456 fm_commits.data(name=name) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2457 fm_commits.data(node=hex(node)) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2458 if ms._labels and len(ms._labels) > label_index: |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2459 fm_commits.data(label=ms._labels[label_index]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2460 fm_commits.end() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2461 |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2462 fm_files = fm.nested(b'files') |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2463 if ms.active(): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2464 for f in ms: |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2465 fm_files.startitem() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2466 fm_files.data(path=f) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2467 state = ms._state[f] |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2468 fm_files.data(state=state[0]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2469 if state[0] in ( |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2470 mergestatemod.MERGE_RECORD_UNRESOLVED, |
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2471 mergestatemod.MERGE_RECORD_RESOLVED, |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2472 ): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2473 fm_files.data(local_key=state[1]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2474 fm_files.data(local_path=state[2]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2475 fm_files.data(ancestor_path=state[3]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2476 fm_files.data(ancestor_node=state[4]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2477 fm_files.data(other_path=state[5]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2478 fm_files.data(other_node=state[6]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2479 fm_files.data(local_flags=state[7]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2480 elif state[0] in ( |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2481 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH, |
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44660
diff
changeset
|
2482 mergestatemod.MERGE_RECORD_RESOLVED_PATH, |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2483 ): |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2484 fm_files.data(renamed_path=state[1]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2485 fm_files.data(rename_side=state[2]) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2486 fm_extras = fm_files.nested(b'extras') |
45446
00e4e97c6bc8
debugmergestate: sort extras before printing
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45445
diff
changeset
|
2487 for k, v in sorted(ms.extras(f).items()): |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2488 fm_extras.startitem() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2489 fm_extras.data(key=k) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2490 fm_extras.data(value=v) |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2491 fm_extras.end() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2492 |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2493 fm_files.end() |
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2494 |
45445
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2495 fm_extras = fm.nested(b'extras') |
48921
c9774f5fa729
debugcommands: remove pycompat.iteritems()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
2496 for f, d in sorted(ms.allextras().items()): |
45445
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2497 if f in ms: |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2498 # If file is in mergestate, we have already processed it's extras |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2499 continue |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
2500 for k, v in d.items(): |
45445
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2501 fm_extras.startitem() |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2502 fm_extras.data(file=f) |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2503 fm_extras.data(key=k) |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2504 fm_extras.data(value=v) |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2505 fm_extras.end() |
766797f23f77
debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45320
diff
changeset
|
2506 |
44396
acbfa31cfaf2
debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents:
44363
diff
changeset
|
2507 fm.end() |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
2508 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2509 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2510 @command(b'debugnamecomplete', [], _(b'NAME...')) |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2511 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
|
2512 '''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
|
2513 |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2514 names = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2515 # 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
|
2516 # specially (after this for loop) |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
2517 for name, ns in repo.names.items(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2518 if name != b'branches': |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2519 names.update(ns.listnames(repo)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2520 names.update( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2521 tag |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2522 for (tag, heads, tip, closed) in repo.branchmap().iterbranches() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2523 if not closed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2524 ) |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2525 completions = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2526 if not args: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2527 args = [b''] |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2528 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
|
2529 completions.update(n for n in names if n.startswith(a)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2530 ui.write(b'\n'.join(sorted(completions))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2531 ui.write(b'\n') |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
2532 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2533 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2534 @command( |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2535 b'debugnodemap', |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2536 ( |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2537 cmdutil.debugrevlogopts |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2538 + [ |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2539 ( |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2540 b'', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2541 b'dump-new', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2542 False, |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2543 _(b'write a (new) persistent binary nodemap on stdout'), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2544 ), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2545 (b'', b'dump-disk', False, _(b'dump on-disk data on stdout')), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2546 ( |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2547 b'', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2548 b'check', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2549 False, |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2550 _(b'check that the data on disk data are correct.'), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2551 ), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2552 ( |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2553 b'', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2554 b'metadata', |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2555 False, |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2556 _(b'display the on disk meta data for the nodemap'), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2557 ), |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2558 ] |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2559 ), |
50548
720a23405fe9
debug: update usage strings of debugignore and debugnodemap
Anton Shestakov <av6@dwimlabs.net>
parents:
50547
diff
changeset
|
2560 _(b'-c|-m|FILE'), |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2561 ) |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2562 def debugnodemap(ui, repo, file_=None, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
2563 """write and inspect on disk nodemap""" |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2564 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2565 if file_ is not None: |
50547
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
2566 raise error.InputError( |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
2567 _(b'cannot specify a file with other arguments') |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
2568 ) |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2569 elif file_ is None: |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2570 opts['changelog'] = True |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2571 r = cmdutil.openstorage( |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2572 repo.unfiltered(), b'debugnodemap', file_, pycompat.byteskwargs(opts) |
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2573 ) |
50549
9dcb00842769
debug: `isinstance(a, x) or isinstance(a, y)` is `isinstance(a, (x, y))`
Anton Shestakov <av6@dwimlabs.net>
parents:
50548
diff
changeset
|
2574 if isinstance(r, (manifest.manifestrevlog, filelog.filelog)): |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2575 r = r._revlog |
44309
6c07480d6659
nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44307
diff
changeset
|
2576 if opts['dump_new']: |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50718
diff
changeset
|
2577 if hasattr(r.index, "nodemap_data_all"): |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2578 data = r.index.nodemap_data_all() |
44512
febe88a6f7f7
nodemap: use data from the index in debugnodemap --dump-new
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44463
diff
changeset
|
2579 else: |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2580 data = nodemap.persistent_data(r.index) |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2581 ui.write(data) |
44309
6c07480d6659
nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44307
diff
changeset
|
2582 elif opts['dump_disk']: |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2583 nm_data = nodemap.persisted_data(r) |
44323
76a96e3a2bbb
nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44318
diff
changeset
|
2584 if nm_data is not None: |
76a96e3a2bbb
nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44318
diff
changeset
|
2585 docket, data = nm_data |
44363
f7459da77f23
nodemap: introduce an option to use mmap to read the nodemap mapping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44350
diff
changeset
|
2586 ui.write(data[:]) |
44318
20e125cdd719
nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44309
diff
changeset
|
2587 elif opts['check']: |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2588 nm_data = nodemap.persisted_data(r) |
44323
76a96e3a2bbb
nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44318
diff
changeset
|
2589 if nm_data is not None: |
76a96e3a2bbb
nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44318
diff
changeset
|
2590 docket, data = nm_data |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2591 return nodemap.check_data(ui, r.index, data) |
44334
6614b301ea58
nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44323
diff
changeset
|
2592 elif opts['metadata']: |
50509
1b73868d17cf
cli: make debugnodemap capable of inspecting an arbitrary nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50426
diff
changeset
|
2593 nm_data = nodemap.persisted_data(r) |
44334
6614b301ea58
nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44323
diff
changeset
|
2594 if nm_data is not None: |
6614b301ea58
nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44323
diff
changeset
|
2595 docket, data = nm_data |
6614b301ea58
nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44323
diff
changeset
|
2596 ui.write((b"uid: %s\n") % docket.uid) |
44335
e41a164db7a9
nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44334
diff
changeset
|
2597 ui.write((b"tip-rev: %d\n") % docket.tip_rev) |
44515
6c906eaedd0d
nodemap: track the tip_node for validation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44512
diff
changeset
|
2598 ui.write((b"tip-node: %s\n") % hex(docket.tip_node)) |
44336
8374b69aef75
nodemap: track the total and unused amount of data in the rawdata file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44335
diff
changeset
|
2599 ui.write((b"data-length: %d\n") % docket.data_length) |
8374b69aef75
nodemap: track the total and unused amount of data in the rawdata file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44335
diff
changeset
|
2600 ui.write((b"data-unused: %d\n") % docket.data_unused) |
44635
99ea74cbed74
nodemap: display percentage of unused in `hg debugnodemap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44532
diff
changeset
|
2601 unused_perc = docket.data_unused * 100.0 / docket.data_length |
99ea74cbed74
nodemap: display percentage of unused in `hg debugnodemap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44532
diff
changeset
|
2602 ui.write((b"data-unused: %2.3f%%\n") % unused_perc) |
44307
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2603 |
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2604 |
c577bb4a04d4
nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44306
diff
changeset
|
2605 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2606 b'debugobsolete', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2607 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2608 (b'', b'flags', 0, _(b'markers flag')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2609 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2610 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2611 b'record-parents', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2612 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2613 _(b'record parent information for the precursor'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2614 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2615 (b'r', b'rev', [], _(b'display markers relevant to REV')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2616 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2617 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2618 b'exclusive', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2619 False, |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
2620 _(b'restrict display to markers only relevant to REV'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2621 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2622 (b'', b'index', False, _(b'display index of the marker')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2623 (b'', b'delete', [], _(b'delete markers specified by indices')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2624 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2625 + cmdutil.commitopts2 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2626 + cmdutil.formatteropts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2627 _(b'[OBSOLETED [REPLACEMENT ...]]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2628 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2629 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
|
2630 """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
|
2631 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2632 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
|
2633 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2634 def parsenodeid(s): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2635 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2636 # 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
|
2637 # 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
|
2638 # local repository. |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2639 n = bin(s) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
2640 if len(n) != repo.nodeconstants.nodelen: |
49248
63fd0282ad40
node: stop converting binascii.Error to TypeError in bin()
Manuel Jacob <me@manueljacob.de>
parents:
49228
diff
changeset
|
2641 raise ValueError |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2642 return n |
49248
63fd0282ad40
node: stop converting binascii.Error to TypeError in bin()
Manuel Jacob <me@manueljacob.de>
parents:
49228
diff
changeset
|
2643 except ValueError: |
45874
1a72e4839795
errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45865
diff
changeset
|
2644 raise error.InputError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2645 b'changeset references must be full hexadecimal ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2646 b'node identifiers' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2647 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2648 |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2649 if opts.get('delete'): |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2650 indices = [] |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2651 for v in opts.get('delete'): |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2652 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2653 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
|
2654 except ValueError: |
45874
1a72e4839795
errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45865
diff
changeset
|
2655 raise error.InputError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2656 _(b'invalid index value: %r') % v, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2657 hint=_(b'use integers for indices'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2658 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2659 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2660 if repo.currenttransaction(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2661 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
2662 _(b'cannot delete obsmarkers in the middle of transaction.') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2663 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2664 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2665 with repo.lock(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2666 n = repair.deleteobsmarkers(repo.obsstore, indices) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2667 ui.write(_(b'deleted %i obsolescence markers\n') % n) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2668 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2669 return |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2670 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2671 if precursor is not None: |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2672 if opts['rev']: |
45874
1a72e4839795
errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45865
diff
changeset
|
2673 raise error.InputError( |
1a72e4839795
errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45865
diff
changeset
|
2674 b'cannot select revision when creating marker' |
1a72e4839795
errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45865
diff
changeset
|
2675 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2676 metadata = {} |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2677 metadata[b'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
|
2678 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
|
2679 l = repo.lock() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2680 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2681 tr = repo.transaction(b'debugobsolete') |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2682 try: |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2683 date = opts.get('date') |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2684 if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36587
diff
changeset
|
2685 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
|
2686 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2687 date = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2688 prec = parsenodeid(precursor) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2689 parents = None |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2690 if opts['record_parents']: |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2691 if prec not in repo.unfiltered(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2692 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2693 b'cannot used --record-parents on ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2694 b'unknown changesets' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2695 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2696 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
|
2697 parents = tuple(p.node() for p in parents) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2698 repo.obsstore.create( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2699 tr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2700 prec, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2701 succs, |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2702 opts['flags'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2703 parents=parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2704 date=date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2705 metadata=metadata, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2706 ui=ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2707 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2708 tr.close() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2709 except ValueError as exc: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2710 raise error.Abort( |
46689
8408c3198ec1
debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents:
46237
diff
changeset
|
2711 _(b'bad obsmarker input: %s') % stringutil.forcebytestr(exc) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2712 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2713 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2714 tr.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2715 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2716 l.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2717 else: |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2718 if opts['rev']: |
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2719 revs = logcmdutil.revrange(repo, opts['rev']) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2720 nodes = [repo[r].node() for r in revs] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2721 markers = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2722 obsutil.getmarkers( |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2723 repo, nodes=nodes, exclusive=opts['exclusive'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2724 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2725 ) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2726 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
|
2727 else: |
33149
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33148
diff
changeset
|
2728 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
|
2729 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2730 markerstoiter = markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2731 isrelevant = lambda m: True |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2732 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
|
2733 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
|
2734 markerset = set(markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2735 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
|
2736 |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2737 fm = ui.formatter(b'debugobsolete', pycompat.byteskwargs(opts)) |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2738 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
|
2739 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
|
2740 # 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
|
2741 # 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
|
2742 # 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
|
2743 # 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
|
2744 # 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
|
2745 # 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
|
2746 # 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
|
2747 continue |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2748 fm.startitem() |
50958
55c28ffadb14
debugobsolete: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50957
diff
changeset
|
2749 ind = i if opts.get('index') else None |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2750 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
|
2751 fm.end() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
2752 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2753 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2754 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2755 b'debugp1copies', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2756 [(b'r', b'rev', b'', _(b'revision to debug'), _(b'REV'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2757 _(b'[-r REV]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2758 ) |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2759 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
|
2760 """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
|
2761 |
50959
91c32fccd282
debugp1copies: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50958
diff
changeset
|
2762 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2763 for dst, src in ctx.p1copies().items(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2764 ui.write(b'%s -> %s\n' % (src, dst)) |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2765 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2766 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2767 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2768 b'debugp2copies', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2769 [(b'r', b'rev', b'', _(b'revision to debug'), _(b'REV'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2770 _(b'[-r REV]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2771 ) |
49281
223d55086d7c
cleanup: rename some functions to avoid redefinitions
Manuel Jacob <me@manueljacob.de>
parents:
49253
diff
changeset
|
2772 def debugp2copies(ui, repo, **opts): |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2773 """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
|
2774 |
50960
1e2be2c9a74d
debugp2copies: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50959
diff
changeset
|
2775 ctx = scmutil.revsingle(repo, opts.get('rev'), default=None) |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2776 for dst, src in ctx.p2copies().items(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2777 ui.write(b'%s -> %s\n' % (src, dst)) |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41749
diff
changeset
|
2778 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2779 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2780 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2781 b'debugpathcomplete', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2782 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2783 (b'f', b'full', None, _(b'complete an entire path')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2784 (b'n', b'normal', None, _(b'show only normal files')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2785 (b'a', b'added', None, _(b'show only added files')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2786 (b'r', b'removed', None, _(b'show only removed files')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2787 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2788 _(b'FILESPEC...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2789 ) |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2790 def debugpathcomplete(ui, repo, *specs, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
2791 """complete part or all of a tracked path |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2792 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2793 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
|
2794 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
|
2795 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2796 Completion extends only to the next path segment unless |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
2797 --full is specified, in which case entire paths are used.""" |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2798 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2799 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
|
2800 dirstate = repo.dirstate |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39760
diff
changeset
|
2801 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
|
2802 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
|
2803 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
|
2804 return [], [] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2805 if os.path.isdir(spec): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2806 spec += b'/' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2807 spec = spec[len(rootdir) :] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2808 fixpaths = pycompat.ossep != b'/' |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2809 if fixpaths: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2810 spec = spec.replace(pycompat.ossep, b'/') |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2811 speclen = len(spec) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2812 fullpaths = opts['full'] |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2813 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
|
2814 adddir, addfile = dirs.add, files.add |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
2815 for f, st in dirstate.items(): |
47544
5363610f61ef
dirstate-item: use the `state` property in debugpathcomplete
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47438
diff
changeset
|
2816 if f.startswith(spec) and st.state in acceptable: |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2817 if fixpaths: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2818 f = f.replace(b'/', pycompat.ossep) |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2819 if fullpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2820 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2821 continue |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2822 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
|
2823 if s >= 0: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2824 adddir(f[:s]) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2825 else: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2826 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2827 return files, dirs |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2828 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2829 acceptable = b'' |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2830 if opts['normal']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2831 acceptable += b'nm' |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2832 if opts['added']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2833 acceptable += b'a' |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
2834 if opts['removed']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2835 acceptable += b'r' |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2836 cwd = repo.getcwd() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2837 if not specs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2838 specs = [b'.'] |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2839 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2840 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
|
2841 for spec in specs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2842 f, d = complete(spec, acceptable or b'nmar') |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2843 files.update(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2844 dirs.update(d) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2845 files.update(dirs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2846 ui.write(b'\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2847 ui.write(b'\n') |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
2848 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2849 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2850 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2851 b'debugpathcopies', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2852 cmdutil.walkopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2853 b'hg debugpathcopies REV1 REV2 [FILE]', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2854 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2855 ) |
41515
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
2856 def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts): |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
2857 """show copies between two revisions""" |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
2858 ctx1 = scmutil.revsingle(repo, rev1) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
2859 ctx2 = scmutil.revsingle(repo, rev2) |
7dc160a57025
debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
2860 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
|
2861 for dst, src in sorted(copies.pathcopies(ctx1, ctx2, m).items()): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2862 ui.write(b'%s -> %s\n' % (src, dst)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2863 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2864 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2865 @command(b'debugpeer', [], _(b'PATH'), norepo=True) |
35929
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2866 def debugpeer(ui, path): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2867 """establish a connection to a peer repository""" |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2868 # Always enable peer request logging. Requires --debug to display |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2869 # though. |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2870 overrides = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2871 (b'devel', b'debug.peer-request'): True, |
35929
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2872 } |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2873 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2874 with ui.configoverride(overrides): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2875 peer = hg.peer(ui, {}, path) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2876 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2877 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2878 local = peer.local() is not None |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2879 canpush = peer.canpush() |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2880 |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2881 ui.write(_(b'url: %s\n') % peer.url()) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2882 ui.write(_(b'local: %s\n') % (_(b'yes') if local else _(b'no'))) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2883 ui.write( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2884 _(b'pushable: %s\n') % (_(b'yes') if canpush else _(b'no')) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2885 ) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2886 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2887 peer.close() |
35929
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35902
diff
changeset
|
2888 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2889 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2890 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2891 b'debugpickmergetool', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2892 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2893 (b'r', b'rev', b'', _(b'check for files in this revision'), _(b'REV')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2894 (b'', b'changedelete', None, _(b'emulate merging change and delete')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2895 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2896 + cmdutil.walkopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2897 + cmdutil.mergetoolopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2898 _(b'[PATTERN]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2899 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2900 ) |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2901 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
|
2902 """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
|
2903 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2904 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
|
2905 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
|
2906 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
|
2907 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2908 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
|
2909 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
|
2910 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
|
2911 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
|
2912 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
|
2913 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
|
2914 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
|
2915 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2916 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
|
2917 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2918 FILE = MERGETOOL |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2919 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2920 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
|
2921 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
|
2922 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
|
2923 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
|
2924 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2925 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
|
2926 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
|
2927 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
|
2928 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
|
2929 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
|
2930 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2931 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
|
2932 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
|
2933 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2934 - ``--tool`` option |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2935 - ``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
|
2936 - 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
|
2937 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2938 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
|
2939 ``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
|
2940 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
|
2941 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
|
2942 """ |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2943 overrides = {} |
50961
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2944 if opts['tool']: |
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2945 overrides[(b'ui', b'forcemerge')] = opts['tool'] |
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2946 ui.notenoi18n(b'with --tool %r\n' % (pycompat.bytestr(opts['tool']))) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2947 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2948 with ui.configoverride(overrides, b'debugmergepatterns'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2949 hgmerge = encoding.environ.get(b"HGMERGE") |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2950 if hgmerge is not None: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
2951 ui.notenoi18n(b'with HGMERGE=%r\n' % (pycompat.bytestr(hgmerge))) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2952 uimerge = ui.config(b"ui", b"merge") |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2953 if uimerge: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
2954 ui.notenoi18n(b'with ui.merge=%r\n' % (pycompat.bytestr(uimerge))) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2955 |
50961
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2956 ctx = scmutil.revsingle(repo, opts.get('rev')) |
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2957 m = scmutil.match(ctx, pats, pycompat.byteskwargs(opts)) |
206d7fad2a1c
debugpickmergetool: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50960
diff
changeset
|
2958 changedelete = opts['changedelete'] |
32256
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32229
diff
changeset
|
2959 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
|
2960 fctx = ctx[path] |
47437
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47351
diff
changeset
|
2961 with ui.silent( |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47351
diff
changeset
|
2962 error=True |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47351
diff
changeset
|
2963 ) if not ui.debugflag else util.nullcontextmanager(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2964 tool, toolpath = filemerge._picktool( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2965 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2966 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2967 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2968 fctx.isbinary(), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2969 b'l' in fctx.flags(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2970 changedelete, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
2971 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2972 ui.write(b'%s = %s\n' % (path, tool)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2973 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2974 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2975 @command(b'debugpushkey', [], _(b'REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2976 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
2977 """access the pushkey key/value protocol |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2978 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2979 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
|
2980 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2981 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
|
2982 Reports success or failure. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
2983 """ |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2984 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
2985 target = hg.peer(ui, {}, repopath) |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2986 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2987 if keyinfo: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2988 key, old, new = keyinfo |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2989 with target.commandexecutor() as e: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2990 r = e.callcommand( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2991 b'pushkey', |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2992 { |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2993 b'namespace': namespace, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2994 b'key': key, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2995 b'old': old, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2996 b'new': new, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2997 }, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2998 ).result() |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
2999 |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3000 ui.status(pycompat.bytestr(r) + b'\n') |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3001 return not r |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3002 else: |
48921
c9774f5fa729
debugcommands: remove pycompat.iteritems()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
3003 for k, v in sorted(target.listkeys(namespace).items()): |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3004 ui.write( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3005 b"%s\t%s\n" |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3006 % (stringutil.escapestr(k), stringutil.escapestr(v)) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3007 ) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3008 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
3009 target.close() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3010 |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
3011 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3012 @command(b'debugpvec', [], _(b'A B')) |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
3013 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
|
3014 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
|
3015 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
|
3016 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
|
3017 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
|
3018 if pa == pb: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3019 rel = b"=" |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
3020 elif pa > pb: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3021 rel = b">" |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
3022 elif pa < pb: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3023 rel = b"<" |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
3024 elif pa | pb: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3025 rel = b"|" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3026 ui.write(_(b"a: %s\n") % pa) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3027 ui.write(_(b"b: %s\n") % pb) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3028 ui.write(_(b"depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3029 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3030 _(b"delta: %d hdist: %d distance: %d relation: %s\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3031 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3032 abs(pa._depth - pb._depth), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3033 pvec._hamming(pa._vec, pb._vec), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3034 pa.distance(pb), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3035 rel, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3036 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3037 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3038 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3039 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3040 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3041 b'debugrebuilddirstate|debugrebuildstate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3042 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3043 (b'r', b'rev', b'', _(b'revision to rebuild to'), _(b'REV')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3044 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3045 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3046 b'minimal', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3047 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3048 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3049 b'only rebuild files that are inconsistent with ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3050 b'the working copy parent' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3051 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3052 ), |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3053 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3054 _(b'[-r REV]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3055 ) |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3056 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
|
3057 """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
|
3058 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3059 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
|
3060 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3061 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
|
3062 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
|
3063 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
|
3064 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3065 ``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
|
3066 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
|
3067 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
|
3068 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
|
3069 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3070 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
|
3071 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
|
3072 """ |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3073 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
|
3074 with repo.wlock(): |
50000
1f28172cfce9
debugrebuilddirstate: double check that no transaction is open
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49999
diff
changeset
|
3075 if repo.currenttransaction() is not None: |
1f28172cfce9
debugrebuilddirstate: double check that no transaction is open
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49999
diff
changeset
|
3076 msg = b'rebuild the dirstate outside of a transaction' |
1f28172cfce9
debugrebuilddirstate: double check that no transaction is open
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49999
diff
changeset
|
3077 raise error.ProgrammingError(msg) |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3078 dirstate = repo.dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3079 changedfiles = None |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3080 # See command doc for what minimal does. |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3081 if opts.get('minimal'): |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3082 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
|
3083 dirstatefiles = set(dirstate) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3084 manifestonly = manifestfiles - dirstatefiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3085 dsonly = dirstatefiles - manifestfiles |
48101
78e66649cdb3
dirstate-item: use `added` in debugrebuilddirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48089
diff
changeset
|
3086 dsnotadded = {f for f in dsonly if not dirstate.get_entry(f).added} |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3087 changedfiles = manifestonly | dsnotadded |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3088 |
50113
dae8dda6f582
debugrebuildstate: wrap the operation in a `changing_parents` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50000
diff
changeset
|
3089 with dirstate.changing_parents(repo): |
dae8dda6f582
debugrebuildstate: wrap the operation in a `changing_parents` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50000
diff
changeset
|
3090 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
3091 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3092 |
47875
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3093 @command( |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3094 b'debugrebuildfncache', |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3095 [ |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3096 ( |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3097 b'', |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3098 b'only-data', |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3099 False, |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3100 _(b'only look for wrong .d files (much faster)'), |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3101 ) |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3102 ], |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3103 b'', |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3104 ) |
0fb328bb2459
debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
47817
diff
changeset
|
3105 def debugrebuildfncache(ui, repo, **opts): |
30949
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
3106 """rebuild the fncache file""" |
50962
a0fcdcc53618
debugrebuildfncache: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50961
diff
changeset
|
3107 repair.rebuildfncache(ui, repo, opts.get("only_data")) |
30949
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
3108 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3109 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3110 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3111 b'debugrename', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3112 [(b'r', b'rev', b'', _(b'revision to debug'), _(b'REV'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3113 _(b'[-r REV] [FILE]...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3114 ) |
41690
ea72da71ad69
debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents:
41671
diff
changeset
|
3115 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
|
3116 """dump rename information""" |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
3117 |
50963
7ef74fc79900
debugrename: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50962
diff
changeset
|
3118 ctx = scmutil.revsingle(repo, opts.get('rev')) |
7ef74fc79900
debugrename: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50962
diff
changeset
|
3119 m = scmutil.match(ctx, pats, 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
|
3120 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
|
3121 fctx = ctx[abs] |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
3122 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
|
3123 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
|
3124 if o: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3125 ui.write(_(b"%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
3126 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3127 ui.write(_(b"%s not renamed\n") % rel) |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
3128 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3129 |
45107
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3130 @command(b'debugrequires|debugrequirements', [], b'') |
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3131 def debugrequirements(ui, repo): |
47062
f38bf44e077f
black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents:
47061
diff
changeset
|
3132 """print the current repo requirements""" |
45107
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3133 for r in sorted(repo.requirements): |
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3134 ui.write(b"%s\n" % r) |
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3135 |
4a28f5e8408e
debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45100
diff
changeset
|
3136 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3137 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3138 b'debugrevlog', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3139 cmdutil.debugrevlogopts + [(b'd', b'dump', False, _(b'dump index data'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3140 _(b'-c|-m|FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3141 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3142 ) |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
3143 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
|
3144 """show data and statistics about a revlog""" |
50964
8f25df137282
debugrevlog: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50963
diff
changeset
|
3145 r = cmdutil.openrevlog( |
8f25df137282
debugrevlog: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50963
diff
changeset
|
3146 repo, b'debugrevlog', file_, pycompat.byteskwargs(opts) |
8f25df137282
debugrevlog: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50963
diff
changeset
|
3147 ) |
8f25df137282
debugrevlog: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50963
diff
changeset
|
3148 |
8f25df137282
debugrevlog: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50963
diff
changeset
|
3149 if opts.get("dump"): |
49659
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49589
diff
changeset
|
3150 revlog_debug.dump(ui, r) |
42554
30033d56758f
debugrevlog: fix average size computation for empty data (issue6167)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42145
diff
changeset
|
3151 else: |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
3152 revlog_debug.debug_revlog(ui, r) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
3153 return 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3154 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3155 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3156 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3157 b'debugrevlogindex', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3158 cmdutil.debugrevlogopts |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3159 + [(b'f', b'format', 0, _(b'revlog format'), _(b'FORMAT'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3160 _(b'[-f FORMAT] -c|-m|FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3161 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3162 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3163 def debugrevlogindex(ui, repo, file_=None, **opts): |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3164 """dump the contents of a revlog index""" |
50965
56a966bc6b1a
debugrevlogindex: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50964
diff
changeset
|
3165 r = cmdutil.openrevlog( |
56a966bc6b1a
debugrevlogindex: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50964
diff
changeset
|
3166 repo, b'debugrevlogindex', file_, pycompat.byteskwargs(opts) |
56a966bc6b1a
debugrevlogindex: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50964
diff
changeset
|
3167 ) |
56a966bc6b1a
debugrevlogindex: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50964
diff
changeset
|
3168 format = opts.get('format', 0) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3169 if format not in (0, 1): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3170 raise error.Abort(_(b"unknown format %d") % format) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3171 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3172 if ui.debugflag: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3173 shortfn = hex |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3174 else: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3175 shortfn = short |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3176 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3177 # 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
|
3178 idlen = 12 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3179 for i in r: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3180 idlen = len(shortfn(r.node(i))) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3181 break |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3182 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3183 if format == 0: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3184 if ui.verbose: |
43116
defabf63e969
debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
3185 ui.writenoi18n( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
3186 b" rev offset length linkrev %s %s p2\n" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3187 % (b"nodeid".ljust(idlen), b"p1".ljust(idlen)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3188 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3189 else: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3190 ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3191 b" rev linkrev %s %s p2\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3192 % (b"nodeid".ljust(idlen), b"p1".ljust(idlen)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3193 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3194 elif format == 1: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3195 if ui.verbose: |
43116
defabf63e969
debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
3196 ui.writenoi18n( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3197 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3198 b" rev flag offset length size link p1" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3199 b" p2 %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3200 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3201 % b"nodeid".rjust(idlen) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3202 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3203 else: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3204 ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3205 b" rev flag size link p1 p2 %s\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3206 % b"nodeid".rjust(idlen) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3207 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3208 |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3209 for i in r: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3210 node = r.node(i) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3211 if format == 0: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3212 try: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3213 pp = r.parents(node) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3214 except Exception: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
3215 pp = [repo.nullid, repo.nullid] |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3216 if ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3217 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3218 b"% 6d % 9d % 7d % 7d %s %s %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3219 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3220 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3221 r.start(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3222 r.length(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3223 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3224 shortfn(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3225 shortfn(pp[0]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3226 shortfn(pp[1]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3227 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3228 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3229 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3230 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3231 b"% 6d % 7d %s %s %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3232 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3233 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3234 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3235 shortfn(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3236 shortfn(pp[0]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3237 shortfn(pp[1]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3238 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3239 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3240 elif format == 1: |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3241 pr = r.parentrevs(i) |
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3242 if ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3243 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3244 b"% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3245 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3246 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3247 r.flags(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3248 r.start(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3249 r.length(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3250 r.rawsize(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3251 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3252 pr[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3253 pr[1], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3254 shortfn(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3255 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3256 ) |
39282
828a45233036
debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39281
diff
changeset
|
3257 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3258 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3259 b"% 6d %04x % 8d % 6d % 6d % 6d %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3260 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3261 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3262 r.flags(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3263 r.rawsize(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3264 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3265 pr[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3266 pr[1], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3267 shortfn(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3268 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3269 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3270 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3271 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3272 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3273 b'debugrevspec', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3274 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3275 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3276 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3277 b'optimize', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3278 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3279 _(b'print parsed tree after optimizing (DEPRECATED)'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3280 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3281 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3282 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3283 b'show-revs', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3284 True, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3285 _(b'print list of result revisions (default)'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3286 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3287 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3288 b's', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3289 b'show-set', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3290 None, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3291 _(b'print internal representation of result set'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3292 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3293 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3294 b'p', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3295 b'show-stage', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3296 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3297 _(b'print parsed tree at the given stage'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3298 _(b'NAME'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3299 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3300 (b'', b'no-optimized', False, _(b'evaluate tree without optimization')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3301 (b'', b'verify-optimized', False, _(b'verify optimized result')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3302 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3303 b'REVSPEC', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3304 ) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3305 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
|
3306 """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
|
3307 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3308 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
|
3309 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
|
3310 |
32797
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
3311 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
|
3312 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
|
3313 |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3314 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
|
3315 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
|
3316 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3317 aliases = ui.configitems(b'revsetalias') |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3318 stages = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3319 (b'parsed', lambda tree: tree), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3320 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3321 b'expanded', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3322 lambda tree: revsetlang.expandaliases(tree, aliases, ui.warn), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3323 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3324 (b'concatenated', revsetlang.foldconcat), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3325 (b'analyzed', revsetlang.analyze), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3326 (b'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
|
3327 ] |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3328 if opts['no_optimized']: |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3329 stages = stages[:-1] |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3330 if opts['verify_optimized'] and opts['no_optimized']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3331 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
3332 _(b'cannot use --verify-optimized with --no-optimized') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3333 ) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44433
diff
changeset
|
3334 stagenames = {n for n, f in stages} |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3335 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3336 showalways = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3337 showchanged = set() |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3338 if ui.verbose and not opts['show_stage']: |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3339 # show parsed tree by --verbose (deprecated) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3340 showalways.add(b'parsed') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3341 showchanged.update([b'expanded', b'concatenated']) |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3342 if opts['optimize']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3343 showalways.add(b'optimized') |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3344 if opts['show_stage'] and opts['optimize']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3345 raise error.Abort(_(b'cannot use --optimize with --show-stage')) |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3346 if opts['show_stage'] == [b'all']: |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3347 showalways.update(stagenames) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3348 else: |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3349 for n in opts['show_stage']: |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3350 if n not in stagenames: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3351 raise error.Abort(_(b'invalid stage name: %s') % n) |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3352 showalways.update(opts['show_stage']) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3353 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3354 treebystage = {} |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3355 printedtree = None |
37350
e32dfff71529
revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37322
diff
changeset
|
3356 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
|
3357 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
|
3358 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
|
3359 if n in showalways or (n in showchanged and tree != printedtree): |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3360 if opts['show_stage'] or n != b'parsed': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3361 ui.write(b"* %s:\n" % n) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3362 ui.write(revsetlang.prettyformat(tree), b"\n") |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3363 printedtree = tree |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3364 |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3365 if opts['verify_optimized']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3366 arevs = revset.makematcher(treebystage[b'analyzed'])(repo) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3367 brevs = revset.makematcher(treebystage[b'optimized'])(repo) |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3368 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
43094
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3369 ui.writenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3370 b"* analyzed set:\n", stringutil.prettyrepr(arevs), b"\n" |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3371 ) |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3372 ui.writenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3373 b"* optimized set:\n", stringutil.prettyrepr(brevs), b"\n" |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3374 ) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3375 arevs = list(arevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3376 brevs = list(brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3377 if arevs == brevs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3378 return 0 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3379 ui.writenoi18n(b'--- analyzed\n', label=b'diff.file_a') |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3380 ui.writenoi18n(b'+++ optimized\n', label=b'diff.file_b') |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3381 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
|
3382 for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3383 if tag in ('delete', 'replace'): |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3384 for c in arevs[alo:ahi]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3385 ui.write(b'-%d\n' % c, label=b'diff.deleted') |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3386 if tag in ('insert', 'replace'): |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3387 for c in brevs[blo:bhi]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3388 ui.write(b'+%d\n' % c, label=b'diff.inserted') |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3389 if tag == 'equal': |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3390 for c in arevs[alo:ahi]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3391 ui.write(b' %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
|
3392 return 1 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3393 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3394 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
|
3395 revs = func(repo) |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3396 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3397 ui.writenoi18n(b"* set:\n", stringutil.prettyrepr(revs), b"\n") |
50966
98d1117dc904
debugrevspec: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50965
diff
changeset
|
3398 if not opts['show_revs']: |
32797
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32796
diff
changeset
|
3399 return |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
3400 for c in revs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3401 ui.write(b"%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
|
3402 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3403 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3404 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3405 b'debugserve', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3406 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3407 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3408 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3409 b'sshstdio', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3410 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3411 _(b'run an SSH server bound to process handles'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3412 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3413 (b'', b'logiofd', b'', _(b'file descriptor to log server I/O to')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3414 (b'', b'logiofile', b'', _(b'file to log server I/O to')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3415 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3416 b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3417 ) |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3418 def debugserve(ui, repo, **opts): |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3419 """run a server with advanced settings |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3420 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3421 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
|
3422 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
|
3423 arguments for security reasons. |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3424 """ |
50967
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3425 if not opts['sshstdio']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3426 raise error.Abort(_(b'only --sshstdio is currently supported')) |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3427 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3428 logfh = None |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3429 |
50967
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3430 if opts['logiofd'] and opts['logiofile']: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3431 raise error.Abort(_(b'cannot use both --logiofd and --logiofile')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3432 |
50967
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3433 if opts['logiofd']: |
44123
52f8b07ad2f9
debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44009
diff
changeset
|
3434 # Ideally we would be line buffered. But line buffering in binary |
52f8b07ad2f9
debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44009
diff
changeset
|
3435 # mode isn't supported and emits a warning in Python 3.8+. Disabling |
52f8b07ad2f9
debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44009
diff
changeset
|
3436 # buffering could have performance impacts. But since this isn't |
52f8b07ad2f9
debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44009
diff
changeset
|
3437 # performance critical code, it should be fine. |
38313
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
3438 try: |
50967
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3439 logfh = os.fdopen(int(opts['logiofd']), 'ab', 0) |
38313
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
3440 except OSError as e: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
3441 if e.errno != errno.ESPIPE: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
3442 raise |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38263
diff
changeset
|
3443 # can't seek a pipe, so `ab` mode fails on py3 |
50967
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3444 logfh = os.fdopen(int(opts['logiofd']), 'wb', 0) |
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3445 elif opts['logiofile']: |
36f116820853
debugserve: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50966
diff
changeset
|
3446 logfh = open(opts['logiofile'], b'ab', 0) |
36527
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3447 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3448 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3449 s.serve_forever() |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36492
diff
changeset
|
3450 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3451 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3452 @command(b'debugsetparents', [], _(b'REV1 [REV2]')) |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3453 def debugsetparents(ui, repo, rev1, rev2=None): |
46201
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3454 """manually set the parents of the current working directory (DANGEROUS) |
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3455 |
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3456 This command is not what you are looking for and should not be used. Using |
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3457 this command will most certainly results in slight corruption of the file |
51377
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3458 level histories within your repository. DO NOT USE THIS COMMAND. |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3459 |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3460 The command updates the p1 and p2 fields in the dirstate, without touching |
46201
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3461 anything else. This useful for writing repository conversion tools, but |
b986e3342827
debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46112
diff
changeset
|
3462 should be used with extreme care. For example, neither the working |
51377
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3463 directory nor the dirstate is updated, so file statuses may be incorrect |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3464 after running this command. Use it only if you are one of the few people who |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3465 deeply understands both conversion tools and file level histories. If you are |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3466 reading this help, you are not one of those people (most of them sailed west |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3467 from Mithlond anyway). |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3468 |
39f349391898
debugsetparents: fix Marmoutian docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
51232
diff
changeset
|
3469 So, one more time, DO NOT USE THIS COMMAND. |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3470 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3471 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
|
3472 """ |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3473 |
37143
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37120
diff
changeset
|
3474 node1 = scmutil.revsingle(repo, rev1).node() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3475 node2 = scmutil.revsingle(repo, rev2, b'null').node() |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3476 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
3477 with repo.wlock(): |
37143
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37120
diff
changeset
|
3478 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
|
3479 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3480 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3481 @command(b'debugsidedata', cmdutil.debugrevlogopts, _(b'-c|-m|FILE REV')) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3482 def debugsidedata(ui, repo, file_, rev=None, **opts): |
43136
ba5b062a1388
debugsidedata: small doc improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
3483 """dump the side data for a cl/manifest/file revision |
ba5b062a1388
debugsidedata: small doc improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
3484 |
ba5b062a1388
debugsidedata: small doc improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
3485 Use --verbose to dump the sidedata content.""" |
50968
e6ae6573b400
debugsidedata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50967
diff
changeset
|
3486 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3487 if rev is not None: |
50547
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
3488 raise error.InputError( |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
3489 _(b'cannot specify a revision with other arguments') |
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
3490 ) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3491 file_, rev = None, file_ |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3492 elif rev is None: |
50547
003418163195
debug: slightly improve wording on the InputErrors from the previous patch
Anton Shestakov <av6@dwimlabs.net>
parents:
50546
diff
changeset
|
3493 raise error.InputError(_(b'please specify a revision')) |
50968
e6ae6573b400
debugsidedata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50967
diff
changeset
|
3494 r = cmdutil.openstorage( |
e6ae6573b400
debugsidedata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50967
diff
changeset
|
3495 repo, b'debugdata', file_, pycompat.byteskwargs(opts) |
e6ae6573b400
debugsidedata: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50967
diff
changeset
|
3496 ) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3497 r = getattr(r, '_revlog', r) |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3498 try: |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3499 sidedata = r.sidedata(r.lookup(rev)) |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3500 except KeyError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3501 raise error.Abort(_(b'invalid revision identifier %s') % rev) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3502 if sidedata: |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3503 sidedata = list(sidedata.items()) |
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3504 sidedata.sort() |
43116
defabf63e969
debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
3505 ui.writenoi18n(b'%d sidedata entries\n' % len(sidedata)) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3506 for key, value in sidedata: |
43116
defabf63e969
debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
3507 ui.writenoi18n(b' entry-%04o size %d\n' % (key, len(value))) |
43041
559ac8411f12
sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42926
diff
changeset
|
3508 if ui.verbose: |
43116
defabf63e969
debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
3509 ui.writenoi18n(b' %s\n' % stringutil.pprint(value)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3510 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3511 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3512 @command(b'debugssl', [], b'[SOURCE]', optionalrepo=True) |
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
|
3513 def debugssl(ui, repo, source=None, **opts): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
3514 """test a secure connection to a server |
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
|
3515 |
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
|
3516 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
|
3517 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
|
3518 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
|
3519 |
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
|
3520 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
|
3521 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
|
3522 |
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
|
3523 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
|
3524 of the SSL error is likely another issue. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
3525 """ |
34645 | 3526 if not pycompat.iswindows: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3527 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
3528 _(b'certificate chain building is only possible on Windows') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3529 ) |
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
|
3530 |
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
|
3531 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
|
3532 if not repo: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3533 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3534 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3535 b"there is no Mercurial repository here, and no " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3536 b"server specified" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3537 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3538 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3539 source = b"default" |
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
|
3540 |
49727
aae6b10d93f2
path: pass `path` to `peer` in `hg debugssl`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49726
diff
changeset
|
3541 path = urlutil.get_unique_pull_path_obj(b'debugssl', ui, source) |
aae6b10d93f2
path: pass `path` to `peer` in `hg debugssl`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49726
diff
changeset
|
3542 url = path.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
|
3543 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3544 defaultport = {b'https': 443, b'ssh': 22} |
35425
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
3545 if url.scheme in defaultport: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
3546 try: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
3547 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
|
3548 except ValueError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3549 raise error.Abort(_(b"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
|
3550 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3551 raise error.Abort(_(b"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
|
3552 |
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
|
3553 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
|
3554 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3555 s = ssl.wrap_socket( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3556 socket.socket(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3557 ssl_version=ssl.PROTOCOL_TLS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3558 cert_reqs=ssl.CERT_NONE, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3559 ca_certs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3560 ) |
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
|
3561 |
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
|
3562 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
|
3563 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
|
3564 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
|
3565 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3566 ui.status(_(b'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
|
3567 |
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
|
3568 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
|
3569 |
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
|
3570 if not complete: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3571 ui.status(_(b'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
|
3572 |
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
|
3573 if not win32.checkcertificatechain(cert): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3574 ui.status(_(b'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
|
3575 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3576 ui.status(_(b'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
|
3577 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3578 ui.status(_(b'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
|
3579 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
|
3580 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
|
3581 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3582 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3583 @command( |
50426
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3584 b'debug::stable-tail-sort', |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3585 [ |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3586 ( |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3587 b'T', |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3588 b'template', |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3589 b'{rev}\n', |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3590 _(b'display with template'), |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3591 _(b'TEMPLATE'), |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3592 ), |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3593 ], |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3594 b'REV', |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3595 ) |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3596 def debug_stable_tail_sort(ui, repo, revspec, template, **opts): |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3597 """display the stable-tail sort of the ancestors of a given node""" |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3598 rev = logcmdutil.revsingle(repo, revspec).rev() |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3599 cl = repo.changelog |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3600 |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3601 displayer = logcmdutil.maketemplater(ui, repo, template) |
50525
1a4f54574e3d
stabletailgraph: clarify naiveness of current implementation
pacien <pacien.trangirard@pacien.net>
parents:
50509
diff
changeset
|
3602 sorted_revs = stabletailsort._stable_tail_sort_naive(cl, rev) |
50426
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3603 for ancestor_rev in sorted_revs: |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3604 displayer.show(repo[ancestor_rev]) |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3605 |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3606 |
f0d2b18f0274
stabletailgraph: implement stable-tail sort
pacien <pacien.trangirard@pacien.net>
parents:
50424
diff
changeset
|
3607 @command( |
50528
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3608 b'debug::stable-tail-sort-leaps', |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3609 [ |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3610 ( |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3611 b'T', |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3612 b'template', |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3613 b'{rev}', |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3614 _(b'display with template'), |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3615 _(b'TEMPLATE'), |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3616 ), |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3617 (b's', b'specific', False, _(b'restrict to specific leaps')), |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3618 ], |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3619 b'REV', |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3620 ) |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3621 def debug_stable_tail_sort_leaps(ui, repo, rspec, template, specific, **opts): |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3622 """display the leaps in the stable-tail sort of a node, one per line""" |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3623 rev = logcmdutil.revsingle(repo, rspec).rev() |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3624 |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3625 if specific: |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3626 get_leaps = stabletailsort._find_specific_leaps_naive |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3627 else: |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3628 get_leaps = stabletailsort._find_all_leaps_naive |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3629 |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3630 displayer = logcmdutil.maketemplater(ui, repo, template) |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3631 for source, target in get_leaps(repo.changelog, rev): |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3632 displayer.show(repo[source]) |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3633 displayer.show(repo[target]) |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3634 ui.write(b'\n') |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3635 |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3636 |
8fb3e942473a
stabletailgraph: naive version of leap computation
pacien <pacien.trangirard@pacien.net>
parents:
50525
diff
changeset
|
3637 @command( |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3638 b"debugbackupbundle", |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3639 [ |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3640 ( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3641 b"", |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3642 b"recover", |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3643 b"", |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3644 b"brings the specified changeset back into the repository", |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3645 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3646 ] |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3647 + cmdutil.logopts, |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3648 _(b"hg debugbackupbundle [--recover HASH]"), |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3649 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3650 def debugbackupbundle(ui, repo, *pats, **opts): |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3651 """lists the changesets available in backup bundles |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3652 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3653 Without any arguments, this command prints a list of the changesets in each |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3654 backup bundle. |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3655 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3656 --recover takes a changeset hash and unbundles the first bundle that |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3657 contains that hash, which puts that changeset back in your repository. |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3658 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3659 --verbose will print the entire commit message and the bundle path for that |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3660 backup. |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3661 """ |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3662 backups = list( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3663 filter( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3664 os.path.isfile, glob.glob(repo.vfs.join(b"strip-backup") + b"/*.hg") |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3665 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3666 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3667 backups.sort(key=lambda x: os.path.getmtime(x), reverse=True) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3668 |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3669 opts["bundle"] = b"" |
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3670 opts["force"] = None |
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3671 limit = logcmdutil.getlimit(pycompat.byteskwargs(opts)) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3672 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3673 def display(other, chlist, displayer): |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3674 if opts.get("newest_first"): |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3675 chlist.reverse() |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3676 count = 0 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3677 for n in chlist: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3678 if limit is not None and count >= limit: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3679 break |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
3680 parents = [ |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
3681 True for p in other.changelog.parents(n) if p != repo.nullid |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46961
diff
changeset
|
3682 ] |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3683 if opts.get("no_merges") and len(parents) == 2: |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3684 continue |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3685 count += 1 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3686 displayer.show(other[n]) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3687 |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3688 recovernode = opts.get("recover") |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3689 if recovernode: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3690 if scmutil.isrevsymbol(repo, recovernode): |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3691 ui.warn(_(b"%s already exists in the repo\n") % recovernode) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3692 return |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3693 elif backups: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3694 msg = _( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3695 b"Recover changesets using: hg debugbackupbundle --recover " |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3696 b"<changeset hash>\n\nAvailable backup changesets:" |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3697 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3698 ui.status(msg, label=b"status.removed") |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3699 else: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3700 ui.status(_(b"no backup changesets found\n")) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3701 return |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3702 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3703 for backup in backups: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3704 # Much of this is copied from the hg incoming logic |
46961
d7b36a4e03de
debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46960
diff
changeset
|
3705 source = os.path.relpath(backup, encoding.getcwd()) |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3706 path = urlutil.get_unique_pull_path_obj( |
46961
d7b36a4e03de
debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46960
diff
changeset
|
3707 b'debugbackupbundle', |
d7b36a4e03de
debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46960
diff
changeset
|
3708 ui, |
d7b36a4e03de
debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46960
diff
changeset
|
3709 source, |
d7b36a4e03de
debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46960
diff
changeset
|
3710 ) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3711 try: |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3712 other = hg.peer(repo, pycompat.byteskwargs(opts), path) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3713 except error.LookupError as ex: |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3714 msg = _(b"\nwarning: unable to open bundle %s") % path.loc |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3715 hint = _(b"\n(missing parent rev %s)\n") % short(ex.name) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3716 ui.warn(msg, hint=hint) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3717 continue |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3718 branches = (path.branch, opts.get('branch', [])) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3719 revs, checkout = hg.addbranchrevs( |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3720 repo, other, branches, opts.get("rev") |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3721 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3722 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3723 if revs: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3724 revs = [other.lookup(rev) for rev in revs] |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3725 |
47438
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3726 with ui.silent(): |
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3727 try: |
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3728 other, chlist, cleanupfn = bundlerepo.getremotechanges( |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3729 ui, repo, other, revs, opts["bundle"], opts["force"] |
47438
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3730 ) |
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3731 except error.LookupError: |
1be9bf3669cb
debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents:
47437
diff
changeset
|
3732 continue |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3733 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3734 try: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3735 if not chlist: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3736 continue |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3737 if recovernode: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3738 with repo.lock(), repo.transaction(b"unbundle") as tr: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3739 if scmutil.isrevsymbol(other, recovernode): |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3740 ui.status(_(b"Unbundling %s\n") % (recovernode)) |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3741 f = hg.openpath(ui, path.loc) |
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3742 gen = exchange.readbundle(ui, f, path.loc) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3743 if isinstance(gen, bundle2.unbundle20): |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3744 bundle2.applybundle( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3745 repo, |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3746 gen, |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3747 tr, |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3748 source=b"unbundle", |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3749 url=b"bundle:" + path.loc, |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3750 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3751 else: |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3752 gen.apply(repo, b"unbundle", b"bundle:" + path.loc) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3753 break |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3754 else: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3755 backupdate = encoding.strtolocal( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3756 time.strftime( |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3757 "%a %H:%M, %Y-%m-%d", |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3758 time.localtime(os.path.getmtime(path.loc)), |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3759 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3760 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3761 ui.status(b"\n%s\n" % (backupdate.ljust(50))) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3762 if ui.verbose: |
49728
5177be2b4387
path: pass `path` to `peer` in `hg debugbackupbundle`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49727
diff
changeset
|
3763 ui.status(b"%s%s\n" % (b"bundle:".ljust(13), path.loc)) |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3764 else: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3765 opts[ |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3766 "template" |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3767 ] = b"{label('status.modified', node|short)} {desc|firstline}\n" |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3768 displayer = logcmdutil.changesetdisplayer( |
50969
b28f794fe10a
debugbackupbundle: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50968
diff
changeset
|
3769 ui, other, pycompat.byteskwargs(opts), False |
44433
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3770 ) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3771 display(other, chlist, displayer) |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3772 displayer.close() |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3773 finally: |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3774 cleanupfn() |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3775 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3776 |
f82d2d4e71db
debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44396
diff
changeset
|
3777 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3778 b'debugsub', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3779 [(b'r', b'rev', b'', _(b'revision to check'), _(b'REV'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3780 _(b'[-r REV] [REV]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3781 ) |
30955
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
3782 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
|
3783 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
|
3784 for k, v in sorted(ctx.substate.items()): |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3785 ui.writenoi18n(b'path %s\n' % k) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3786 ui.writenoi18n(b' source %s\n' % v[0]) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3787 ui.writenoi18n(b' revision %s\n' % v[1]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3788 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3789 |
49944
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3790 @command( |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3791 b'debugshell', |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3792 [ |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3793 ( |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3794 b'c', |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3795 b'command', |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3796 b'', |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3797 _(b'program passed in as a string'), |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3798 _(b'COMMAND'), |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3799 ) |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3800 ], |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3801 _(b'[-c COMMAND]'), |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3802 optionalrepo=True, |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3803 ) |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3804 def debugshell(ui, repo, **opts): |
46392
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3805 """run an interactive Python interpreter |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3806 |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3807 The local namespace is provided with a reference to the ui and |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3808 the repo instance (if available). |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3809 """ |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3810 import code |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3811 |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3812 imported_objects = { |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3813 'ui': ui, |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3814 'repo': repo, |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3815 } |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3816 |
49896
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3817 # py2exe disables initialization of the site module, which is responsible |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3818 # for arranging for ``quit()`` to exit the interpreter. Manually initialize |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3819 # the stuff that site normally does here, so that the interpreter can be |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3820 # quit in a consistent manner, whether run with pyoxidizer, exewrapper.c, |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3821 # py.exe, or py2exe. |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3822 if getattr(sys, "frozen", None) == 'console_exe': |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3823 try: |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3824 import site |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3825 |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3826 site.setcopyright() |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3827 site.sethelper() |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3828 site.setquit() |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3829 except ImportError: |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3830 site = None # Keep PyCharm happy |
88b81dc2d82b
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command
Matt Harbison <matt_harbison@yahoo.com>
parents:
49826
diff
changeset
|
3831 |
49944
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3832 command = opts.get('command') |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3833 if command: |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3834 compiled = code.compile_command(encoding.strfromlocal(command)) |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3835 code.InteractiveInterpreter(locals=imported_objects).runcode(compiled) |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3836 return |
8f76a41ee465
debugshell: allow commands to be specified as a CLI argument
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents:
49896
diff
changeset
|
3837 |
46392
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3838 code.interact(local=imported_objects) |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3839 |
f25c770c217b
debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents:
46237
diff
changeset
|
3840 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3841 @command( |
49819
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3842 b'debug-revlog-stats', |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3843 [ |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3844 (b'c', b'changelog', None, _(b'Display changelog statistics')), |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3845 (b'm', b'manifest', None, _(b'Display manifest statistics')), |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3846 (b'f', b'filelogs', None, _(b'Display filelogs statistics')), |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3847 ] |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3848 + cmdutil.formatteropts, |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3849 ) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3850 def debug_revlog_stats(ui, repo, **opts): |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3851 """display statistics about revlogs in the store""" |
50970
f04568add4ee
debug_revlog_stats: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50969
diff
changeset
|
3852 changelog = opts["changelog"] |
f04568add4ee
debug_revlog_stats: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50969
diff
changeset
|
3853 manifest = opts["manifest"] |
f04568add4ee
debug_revlog_stats: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50969
diff
changeset
|
3854 filelogs = opts["filelogs"] |
49819
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3855 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3856 if changelog is None and manifest is None and filelogs is None: |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3857 changelog = True |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3858 manifest = True |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3859 filelogs = True |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3860 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3861 repo = repo.unfiltered() |
50970
f04568add4ee
debug_revlog_stats: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50969
diff
changeset
|
3862 fm = ui.formatter(b'debug-revlog-stats', pycompat.byteskwargs(opts)) |
49819
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3863 revlog_debug.debug_revlog_stats(repo, fm, changelog, manifest, filelogs) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3864 fm.end() |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3865 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3866 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49759
diff
changeset
|
3867 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3868 b'debugsuccessorssets', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3869 [(b'', b'closest', False, _(b'return closest successors sets only'))], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3870 _(b'[REV]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3871 ) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
3872 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
|
3873 """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
|
3874 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3875 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
|
3876 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
|
3877 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
|
3878 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3879 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
|
3880 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
|
3881 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3882 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
|
3883 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
|
3884 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3885 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
|
3886 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
|
3887 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3888 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
|
3889 "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
|
3890 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
|
3891 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3892 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
|
3893 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3894 <rev1> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3895 <successors-1A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3896 <rev2> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3897 <successors-2A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3898 <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
|
3899 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3900 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
|
3901 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
|
3902 been split). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3903 """ |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3904 # 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
|
3905 cache = {} |
36123
8eb13f5d5d3f
py3: convert context to bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35929
diff
changeset
|
3906 ctx2str = bytes |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3907 node2str = short |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48101
diff
changeset
|
3908 for rev in logcmdutil.revrange(repo, revs): |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3909 ctx = repo[rev] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3910 ui.write(b'%s\n' % ctx2str(ctx)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3911 for succsset in obsutil.successorssets( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3912 repo, ctx.node(), closest=opts['closest'], cache=cache |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3913 ): |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3914 if succsset: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3915 ui.write(b' ') |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3916 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
|
3917 for node in succsset[1:]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3918 ui.write(b' ') |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3919 ui.write(node2str(node)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3920 ui.write(b'\n') |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
3921 |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44290
diff
changeset
|
3922 |
44290
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3923 @command(b'debugtagscache', []) |
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3924 def debugtagscache(ui, repo): |
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3925 """display the contents of .hg/cache/hgtagsfnodes1""" |
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3926 cache = tagsmod.hgtagsfnodescache(repo.unfiltered()) |
46655
e4e971abb6a3
debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46653
diff
changeset
|
3927 flog = repo.file(b'.hgtags') |
44290
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3928 for r in repo: |
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3929 node = repo[r].node() |
d8b53385b1bc
tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
44145
diff
changeset
|
3930 tagsnode = cache.getfnode(node, computemissing=False) |
46495
5aac1a1a5beb
tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents:
46479
diff
changeset
|
3931 if tagsnode: |
5aac1a1a5beb
tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents:
46479
diff
changeset
|
3932 tagsnodedisplay = hex(tagsnode) |
46655
e4e971abb6a3
debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46653
diff
changeset
|
3933 if not flog.hasnode(tagsnode): |
e4e971abb6a3
debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46653
diff
changeset
|
3934 tagsnodedisplay += b' (unknown node)' |
46653
9306a16ca964
debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46495
diff
changeset
|
3935 elif tagsnode is None: |
9306a16ca964
debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46495
diff
changeset
|
3936 tagsnodedisplay = b'missing' |
9306a16ca964
debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46495
diff
changeset
|
3937 else: |
46495
5aac1a1a5beb
tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents:
46479
diff
changeset
|
3938 tagsnodedisplay = b'invalid' |
5aac1a1a5beb
tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents:
46479
diff
changeset
|
3939 |
44350
e80da7a63264
tags: fix some type confusion exposed in python 3
Augie Fackler <augie@google.com>
parents:
44336
diff
changeset
|
3940 ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3941 |
44306
a0ec05d93c8e
cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents:
44290
diff
changeset
|
3942 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3943 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3944 b'debugtemplate', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3945 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3946 (b'r', b'rev', [], _(b'apply template on changesets'), _(b'REV')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3947 (b'D', b'define', [], _(b'define template keyword'), _(b'KEY=VALUE')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3948 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3949 _(b'[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3950 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3951 ) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3952 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
|
3953 """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
|
3954 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3955 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
|
3956 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
|
3957 template. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3958 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3959 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
|
3960 """ |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3961 revs = None |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3962 if opts['rev']: |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3963 if repo is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3964 raise error.RepoError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
3965 _(b'there is no Mercurial repository here (.hg not found)') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
3966 ) |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48101
diff
changeset
|
3967 revs = logcmdutil.revrange(repo, opts['rev']) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3968 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3969 props = {} |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
3970 for d in opts['define']: |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3971 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3972 k, v = (e.strip() for e in d.split(b'=', 1)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3973 if not k or k == b'ui': |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3974 raise ValueError |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3975 props[k] = v |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3976 except ValueError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3977 raise error.Abort(_(b'malformed keyword definition: %s') % d) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3978 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3979 if ui.verbose: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3980 aliases = ui.configitems(b'templatealias') |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3981 tree = templater.parse(tmpl) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3982 ui.note(templater.prettyformat(tree), b'\n') |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3983 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
|
3984 if newtree != tree: |
43094
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3985 ui.notenoi18n( |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3986 b"* expanded:\n", templater.prettyformat(newtree), b'\n' |
e8cf9ad52a78
formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43089
diff
changeset
|
3987 ) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3988 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
3989 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
|
3990 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
|
3991 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
|
3992 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
3993 kwds, funcs = t.symbolsuseddefault() |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3994 ui.writenoi18n(b"* keywords: %s\n" % b', '.join(sorted(kwds))) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
3995 ui.writenoi18n(b"* functions: %s\n" % b', '.join(sorted(funcs))) |
36988
317382151ac3
templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36954
diff
changeset
|
3996 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
|
3997 else: |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
3998 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
|
3999 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38313
diff
changeset
|
4000 kwds, funcs = displayer.t.symbolsuseddefault() |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
4001 ui.writenoi18n(b"* keywords: %s\n" % b', '.join(sorted(kwds))) |
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
4002 ui.writenoi18n(b"* functions: %s\n" % b', '.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
|
4003 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
|
4004 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
|
4005 displayer.close() |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
4006 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4007 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4008 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4009 b'debuguigetpass', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4010 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4011 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4012 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4013 _(b'[-p TEXT]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4014 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4015 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4016 def debuguigetpass(ui, prompt=b''): |
36792
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
4017 """show prompt to type password""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
4018 r = ui.getpass(prompt) |
46079
e614eeb794f9
ui: remove excessive strtolocal() from debuguigetpass
Yuya Nishihara <yuya@tcha.org>
parents:
46024
diff
changeset
|
4019 if r is None: |
46024
07b0a687c01a
ui: ensure `getpass()` returns bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45715
diff
changeset
|
4020 r = b"<default response>" |
44660
649fd6c3ed33
debugcommands: fix typo in debuguigetpass
Yuya Nishihara <yuya@tcha.org>
parents:
44635
diff
changeset
|
4021 ui.writenoi18n(b'response: %s\n' % r) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4022 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4023 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4024 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4025 b'debuguiprompt', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4026 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4027 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4028 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4029 _(b'[-p TEXT]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4030 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4031 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4032 def debuguiprompt(ui, prompt=b''): |
36792
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
4033 """show plain prompt""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
4034 r = ui.prompt(prompt) |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
4035 ui.writenoi18n(b'response: %s\n' % r) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4036 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4037 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4038 @command(b'debugupdatecaches', []) |
32265
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
4039 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
|
4040 """warm all known caches in the repository""" |
33438 | 4041 with repo.wlock(), repo.lock(): |
47298
e96f75857361
updatecaches: use the caches argument in `hg debugupdatecaches`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47139
diff
changeset
|
4042 repo.updatecaches(caches=repository.CACHES_ALL) |
32265
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32256
diff
changeset
|
4043 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4044 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4045 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4046 b'debugupgraderepo', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4047 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4048 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4049 b'o', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4050 b'optimize', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4051 [], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4052 _(b'extra optimization to perform'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4053 _(b'NAME'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4054 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4055 (b'', b'run', False, _(b'performs an upgrade')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4056 (b'', b'backup', True, _(b'keep the old repository content around')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4057 (b'', b'changelog', None, _(b'select the changelog for upgrade')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4058 (b'', b'manifest', None, _(b'select the manifest for upgrade')), |
45997
7c539f0febbe
upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45942
diff
changeset
|
4059 (b'', b'filelogs', None, _(b'select all filelogs for upgrade')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4060 ], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4061 ) |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4062 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts): |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4063 """upgrade a repository to use different features |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4064 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4065 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
|
4066 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
|
4067 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4068 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
|
4069 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
|
4070 by the command output when run without ``--run``. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4071 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4072 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
|
4073 allowed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4074 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4075 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
|
4076 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
|
4077 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
|
4078 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
|
4079 unable to access the repository should be low. |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4080 |
47061
bd2ed1032b4e
debugcommands: fix some plural-agreements I noticed
Augie Fackler <augie@google.com>
parents:
46961
diff
changeset
|
4081 By default, all revlogs will be upgraded. You can restrict this using flags |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4082 such as `--manifest`: |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4083 |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4084 * `--manifest`: only optimize the manifest |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42773
diff
changeset
|
4085 * `--no-manifest`: optimize all revlog but the manifest |
42831
908ff446590e
upgrade: add an argument to control changelog upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42830
diff
changeset
|
4086 * `--changelog`: optimize the changelog only |
908ff446590e
upgrade: add an argument to control changelog upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42830
diff
changeset
|
4087 * `--no-changelog --no-manifest`: optimize filelogs only |
45997
7c539f0febbe
upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45942
diff
changeset
|
4088 * `--filelogs`: optimize the filelogs only |
46211
2dbe6053d49a
debugupgraderepo: minor documentation fix
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46208
diff
changeset
|
4089 * `--no-changelog --no-manifest --no-filelogs`: skip all revlog optimizations |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
4090 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4091 return upgrade.upgraderepo( |
46208
083438d6f403
upgrade: drop support for old style optimization names
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46201
diff
changeset
|
4092 ui, repo, run=run, optimize=set(optimize), backup=backup, **opts |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4093 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4094 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4095 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4096 @command( |
51400
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4097 b'debug::unbundle', |
51555
15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51400
diff
changeset
|
4098 [], |
15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51400
diff
changeset
|
4099 _(b'FILE...'), |
51400
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4100 helpcategory=command.CATEGORY_IMPORT_EXPORT, |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4101 ) |
51555
15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51400
diff
changeset
|
4102 def debugunbundle(ui, repo, fname1, *fnames): |
51400
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4103 """same as `hg unbundle`, but pretent to come from a push |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4104 |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4105 This is useful to debug behavior and performance change in this case. |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4106 """ |
51555
15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51400
diff
changeset
|
4107 fnames = (fname1,) + fnames |
15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51400
diff
changeset
|
4108 cmdutil.unbundle_files(ui, repo, fnames) |
51400
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4109 |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4110 |
e2dfa403452d
debug: add a debug::unbundle command that simulate the unbundle from a push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51377
diff
changeset
|
4111 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4112 b'debugwalk', cmdutil.walkopts, _(b'[OPTION]... [FILE]...'), inferrepo=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4113 ) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4114 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
|
4115 """show how files match on given patterns""" |
50971
e032f47f5166
debugwalk: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50970
diff
changeset
|
4116 m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts)) |
38262
7c3a59e2971b
debugwalk: show matcher output only if -v/--verbose
Yuya Nishihara <yuya@tcha.org>
parents:
38261
diff
changeset
|
4117 if ui.verbose: |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
4118 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') |
32363
a275186b989a
debugcommands: use repo[None].walk instead of repo.walk
Augie Fackler <augie@google.com>
parents:
32337
diff
changeset
|
4119 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
|
4120 if not items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4121 return |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4122 f = lambda fn: fn |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4123 if ui.configbool(b'ui', b'slash') and pycompat.ossep != b'/': |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4124 f = lambda fn: util.normpath(fn) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4125 fmt = b'f %%-%ds %%-%ds %%s' % ( |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4126 max([len(abs) for abs in items]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4127 max([len(repo.pathto(abs)) for abs in items]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4128 ) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
4129 for abs in items: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4130 line = fmt % ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4131 abs, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4132 f(repo.pathto(abs)), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4133 m.exact(abs) and b'exact' or b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4134 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4135 ui.write(b"%s\n" % line.rstrip()) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4136 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4137 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4138 @command(b'debugwhyunstable', [], _(b'REV')) |
36954
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
4139 def debugwhyunstable(ui, repo, rev): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36952
diff
changeset
|
4140 """explain instabilities of a changeset""" |
37396
9966f44ecab4
debugwhyunstable: add support for revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37350
diff
changeset
|
4141 for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4142 dnodes = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4143 if entry.get(b'divergentnodes'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4144 dnodes = ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4145 b' '.join( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4146 b'%s (%s)' % (ctx.hex(), ctx.phasestr()) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4147 for ctx in entry[b'divergentnodes'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4148 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4149 + b' ' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4150 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4151 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4152 b'%s: %s%s %s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4153 % (entry[b'instability'], dnodes, entry[b'reason'], entry[b'node']) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4154 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4155 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4156 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4157 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4158 b'debugwireargs', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4159 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4160 (b'', b'three', b'', b'three'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4161 (b'', b'four', b'', b'four'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4162 (b'', b'five', b'', b'five'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4163 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4164 + cmdutil.remoteopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4165 _(b'REPO [OPTIONS]... [ONE [TWO]]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4166 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4167 ) |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
4168 def debugwireargs(ui, repopath, *vals, **opts): |
50972
a4d21089bec7
debugwireargs: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50971
diff
changeset
|
4169 repo = hg.peer(ui, pycompat.byteskwargs(opts), repopath) |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4170 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4171 for opt in cmdutil.remoteopts: |
50972
a4d21089bec7
debugwireargs: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50971
diff
changeset
|
4172 del opts[pycompat.sysstr(opt[1])] |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4173 args = {} |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
4174 for k, v in opts.items(): |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4175 if v: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4176 args[k] = v |
50972
a4d21089bec7
debugwireargs: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50971
diff
changeset
|
4177 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4178 # run twice to check that we don't mess up the stream for the next command |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4179 res1 = repo.debugwireargs(*vals, **args) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4180 res2 = repo.debugwireargs(*vals, **args) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4181 ui.write(b"%s\n" % res1) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4182 if res1 != res2: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4183 ui.warn(b"%s\n" % res2) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4184 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46655
diff
changeset
|
4185 repo.close() |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4186 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4187 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4188 def _parsewirelangblocks(fh): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4189 activeaction = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4190 blocklines = [] |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4191 lastindent = 0 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4192 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4193 for line in fh: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4194 line = line.rstrip() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4195 if not line: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4196 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4197 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4198 if line.startswith(b'#'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4199 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4200 |
39062
efeeb73f54c3
debugcommands: fix a missing b prefix
Augie Fackler <augie@google.com>
parents:
38972
diff
changeset
|
4201 if not line.startswith(b' '): |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4202 # New block. Flush previous one. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4203 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4204 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4205 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4206 activeaction = line |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4207 blocklines = [] |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4208 lastindent = 0 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4209 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4210 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4211 # Else we start with an indent. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4212 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4213 if not activeaction: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4214 raise error.Abort(_(b'indented line outside of block')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4215 |
40174
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4216 indent = len(line) - len(line.lstrip()) |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4217 |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4218 # 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
|
4219 if indent > lastindent and blocklines: |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4220 blocklines[-1] += line.lstrip() |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4221 else: |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4222 blocklines.append(line) |
64360202d5b2
debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40029
diff
changeset
|
4223 lastindent = indent |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4224 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4225 # Flush last block. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4226 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4227 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4228 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4229 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4230 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4231 b'debugwireproto', |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4232 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4233 (b'', b'localssh', False, _(b'start an SSH server for this repo')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4234 (b'', b'peer', b'', _(b'construct a specific version of the peer')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4235 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4236 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4237 b'noreadstderr', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4238 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4239 _(b'do not read from stderr of the remote'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4240 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4241 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4242 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4243 b'nologhandshake', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4244 False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4245 _(b'do not log I/O related to the peer handshake'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4246 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4247 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4248 + cmdutil.remoteopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4249 _(b'[PATH]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4250 optionalrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4251 ) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4252 def debugwireproto(ui, repo, path=None, **opts): |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4253 """send wire protocol commands to a server |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4254 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4255 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
|
4256 peers and to debug the raw data being exchanged. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4257 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4258 ``--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
|
4259 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
|
4260 and establish an appropriate peer instance. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4261 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4262 ``--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
|
4263 peer instance using the specified class type. Valid values are ``raw``, |
48526 | 4264 ``ssh1``. ``raw`` instances only allow sending raw data payloads and |
4265 don't support higher-level command actions. | |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4266 |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4267 ``--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
|
4268 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
|
4269 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
|
4270 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4271 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
|
4272 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
|
4273 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
|
4274 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
|
4275 effectively a high-level command with additional metadata. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4276 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4277 Lines beginning with ``#`` are ignored. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4278 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4279 The following sections denote available actions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4280 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4281 raw |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4282 --- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4283 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4284 Send raw data to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4285 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4286 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
|
4287 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
|
4288 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
|
4289 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4290 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
|
4291 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
|
4292 backslash escaping, etc. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4293 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4294 raw+ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4295 ---- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4296 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4297 Behaves like ``raw`` except flushes output afterwards. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4298 |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4299 command <X> |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4300 ----------- |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4301 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4302 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
|
4303 string. |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4304 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4305 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
|
4306 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
|
4307 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4308 command listkeys |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4309 namespace bookmarks |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4310 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4311 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
|
4312 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
|
4313 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
|
4314 backslash escaping. |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4315 |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4316 The following arguments have special meaning: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4317 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4318 ``PUSHFILE`` |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4319 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
|
4320 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
|
4321 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
|
4322 command payload. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4323 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4324 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
|
4325 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4326 batchbegin |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4327 ---------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4328 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4329 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
|
4330 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4331 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
|
4332 ``batchsubmit`` block. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4333 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4334 batchsubmit |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4335 ----------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4336 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4337 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
|
4338 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4339 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
|
4340 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4341 httprequest <method> <path> |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4342 --------------------------- |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4343 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4344 (HTTP peer only) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4345 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4346 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
|
4347 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4348 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
|
4349 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4350 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
|
4351 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
|
4352 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4353 The following arguments are special: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4354 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4355 ``BODYFILE`` |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4356 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
|
4357 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
|
4358 |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4359 ``frame <type> <flags> <payload>`` |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4360 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
|
4361 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4362 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
|
4363 request. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4364 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4365 close |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4366 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4367 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4368 Close the connection to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4369 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4370 flush |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4371 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4372 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4373 Flush data written to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4374 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4375 readavailable |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4376 ------------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4377 |
36843
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
4378 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
|
4379 the server. |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4380 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4381 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
|
4382 pipes and read available data. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4383 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4384 readline |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4385 -------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4386 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4387 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
|
4388 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
|
4389 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4390 ereadline |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4391 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4392 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4393 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
|
4394 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4395 read <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4396 -------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4397 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4398 ``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
|
4399 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4400 eread <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4401 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4402 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36988
diff
changeset
|
4403 ``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
|
4404 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4405 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
|
4406 ---------------------------------------------- |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4407 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4408 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
|
4409 syntax. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4410 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4411 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
|
4412 from a string of the form: |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
4413 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
4414 <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
|
4415 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
4416 ``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
|
4417 stream identifiers. |
37057
2ec1fb9de638
wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37051
diff
changeset
|
4418 |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4419 ``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
|
4420 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
|
4421 ``command-name``. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4422 |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37283
diff
changeset
|
4423 ``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
|
4424 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
|
4425 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
|
4426 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
|
4427 |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
4428 ``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
|
4429 ``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
|
4430 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
|
4431 as a Python byte string literal. |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4432 """ |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4433 if opts['localssh'] and not repo: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4434 raise error.Abort(_(b'--localssh requires a repository')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4435 |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4436 if opts['peer'] and opts['peer'] not in ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4437 b'raw', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4438 b'ssh1', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4439 ): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4440 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4441 _(b'invalid value for --peer'), |
48526 | 4442 hint=_(b'valid values are "raw" and "ssh1"'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4443 ) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4444 |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4445 if path and opts['localssh']: |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
4446 raise error.Abort(_(b'cannot specify --localssh with an explicit path')) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4447 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4448 if ui.interactive(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4449 ui.write(_(b'(waiting for commands on stdin)\n')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4450 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4451 blocks = list(_parsewirelangblocks(ui.fin)) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4452 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4453 proc = None |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4454 stdin = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4455 stdout = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4456 stderr = None |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4457 opener = None |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4458 |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4459 if opts['localssh']: |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4460 # 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
|
4461 # 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
|
4462 # 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
|
4463 args = procutil.hgcmd() + [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4464 b'-R', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4465 repo.root, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4466 b'debugserve', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4467 b'--sshstdio', |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4468 ] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4469 proc = subprocess.Popen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4470 pycompat.rapply(procutil.tonativestr, args), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4471 stdin=subprocess.PIPE, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4472 stdout=subprocess.PIPE, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4473 stderr=subprocess.PIPE, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4474 bufsize=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4475 ) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4476 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4477 stdin = proc.stdin |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4478 stdout = proc.stdout |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4479 stderr = proc.stderr |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4480 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4481 # We turn the pipes into observers so we can log I/O. |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4482 if ui.verbose or opts['peer'] == b'raw': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4483 stdin = util.makeloggingfileobject( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4484 ui, proc.stdin, b'i', logdata=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4485 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4486 stdout = util.makeloggingfileobject( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4487 ui, proc.stdout, b'o', logdata=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4488 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4489 stderr = util.makeloggingfileobject( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4490 ui, proc.stderr, b'e', logdata=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4491 ) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4492 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4493 # --localssh also implies the peer connection settings. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4494 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4495 url = b'ssh://localserver' |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4496 autoreadstderr = not opts['noreadstderr'] |
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4497 |
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4498 if opts['peer'] == b'ssh1': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4499 ui.write(_(b'creating ssh peer for wire protocol version 1\n')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4500 peer = sshpeer.sshv1peer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4501 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4502 url, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4503 proc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4504 stdin, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4505 stdout, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4506 stderr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4507 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4508 autoreadstderr=autoreadstderr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4509 ) |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4510 elif opts['peer'] == b'raw': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4511 ui.write(_(b'using raw connection to peer\n')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4512 peer = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4513 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4514 ui.write(_(b'creating ssh peer from handshake results\n')) |
50424
ed052780ad5e
peer: rename makepeer() → _make_peer()
Manuel Jacob <me@manueljacob.de>
parents:
50317
diff
changeset
|
4515 peer = sshpeer._make_peer( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4516 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4517 url, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4518 proc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4519 stdin, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4520 stdout, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4521 stderr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4522 autoreadstderr=autoreadstderr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4523 ) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4524 |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4525 elif path: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4526 # 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
|
4527 # 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
|
4528 # ``hg.wirepeersetupfuncs`` and potentially other useful functionality. |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
4529 u = urlutil.url(path) |
51828
b08de326bee4
debugwireproto: redo logging to also work for https
Joerg Sonnenberger <joerg@bec.de>
parents:
51555
diff
changeset
|
4530 if u.scheme not in (b'http', b'https'): |
b08de326bee4
debugwireproto: redo logging to also work for https
Joerg Sonnenberger <joerg@bec.de>
parents:
51555
diff
changeset
|
4531 raise error.Abort( |
b08de326bee4
debugwireproto: redo logging to also work for https
Joerg Sonnenberger <joerg@bec.de>
parents:
51555
diff
changeset
|
4532 _(b'only http:// and https:// paths are currently supported') |
b08de326bee4
debugwireproto: redo logging to also work for https
Joerg Sonnenberger <joerg@bec.de>
parents:
51555
diff
changeset
|
4533 ) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4534 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4535 url, authinfo = u.authinfo() |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4536 openerargs = { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4537 'useragent': b'Mercurial debugwireproto', |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4538 } |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4539 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4540 # 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
|
4541 if ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4542 openerargs.update( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4543 { |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4544 'loggingfh': ui, |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4545 'loggingname': b's', |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4546 'loggingopts': { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4547 'logdata': True, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4548 'logdataapis': False, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45929
diff
changeset
|
4549 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4550 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4551 ) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4552 |
37044
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37013
diff
changeset
|
4553 if ui.debugflag: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4554 openerargs['loggingopts']['logdataapis'] = 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
|
4555 |
37045
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
4556 # 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
|
4557 # 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
|
4558 # have near complete control over what's sent on the wire. |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4559 if opts['peer'] == b'raw': |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4560 openerargs['sendaccept'] = False |
37045
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37044
diff
changeset
|
4561 |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4562 opener = urlmod.opener(ui, authinfo, **openerargs) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4563 |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4564 if opts['peer'] == b'raw': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4565 ui.write(_(b'using raw connection to peer\n')) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4566 peer = None |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4567 elif opts['peer']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4568 raise error.Abort( |
50973
fd6c748eb8a6
debugwireproto: migrate `opts` to native kwargs
Matt Harbison <matt_harbison@yahoo.com>
parents:
50972
diff
changeset
|
4569 _(b'--peer %s not supported with HTTP peers') % opts['peer'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4570 ) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4571 else: |
49759
cfe8d88a453e
peer: get the `path` object down to the httppeer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49728
diff
changeset
|
4572 peer_path = urlutil.try_path(ui, path) |
50424
ed052780ad5e
peer: rename makepeer() → _make_peer()
Manuel Jacob <me@manueljacob.de>
parents:
50317
diff
changeset
|
4573 peer = httppeer._make_peer(ui, peer_path, opener=opener) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4574 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4575 # We /could/ populate stdin/stdout with sock.makefile()... |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4576 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4577 raise error.Abort(_(b'unsupported connection configuration')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4578 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4579 batchedcommands = None |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4580 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4581 # 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
|
4582 for action, lines in blocks: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4583 if action in (b'raw', b'raw+'): |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4584 if not stdin: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4585 raise error.Abort(_(b'cannot call raw/raw+ on this peer')) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4586 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4587 # Concatenate the data together. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4588 data = b''.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
|
4589 data = stringutil.unescapestr(data) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4590 stdin.write(data) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4591 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4592 if action == b'raw+': |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4593 stdin.flush() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4594 elif action == b'flush': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4595 if not stdin: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4596 raise error.Abort(_(b'cannot call flush on this peer')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4597 stdin.flush() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4598 elif action.startswith(b'command'): |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4599 if not peer: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4600 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4601 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4602 b'cannot send commands unless peer instance ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4603 b'is available' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4604 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4605 ) |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4606 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4607 command = action.split(b' ', 1)[1] |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4608 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4609 args = {} |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4610 for line in lines: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4611 # We need to allow empty values. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4612 fields = line.lstrip().split(b' ', 1) |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4613 if len(fields) == 1: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4614 key = fields[0] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4615 value = b'' |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4616 else: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4617 key, value = fields |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4618 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4619 if value.startswith(b'eval:'): |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4620 value = stringutil.evalpythonliteral(value[5:]) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4621 else: |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4622 value = stringutil.unescapestr(value) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4623 |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
4624 args[key] = value |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4625 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4626 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4627 batchedcommands.append((command, args)) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4628 continue |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4629 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4630 ui.status(_(b'sending %s command\n') % command) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4631 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4632 if b'PUSHFILE' in args: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4633 with open(args[b'PUSHFILE'], 'rb') as fh: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4634 del args[b'PUSHFILE'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4635 res, output = peer._callpush( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4636 command, fh, **pycompat.strkwargs(args) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4637 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4638 ui.status(_(b'result: %s\n') % stringutil.escapestr(res)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4639 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4640 _(b'remote output: %s\n') % stringutil.escapestr(output) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4641 ) |
36534
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36531
diff
changeset
|
4642 else: |
37652
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
4643 with peer.commandexecutor() as e: |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
4644 res = e.callcommand(command, args).result() |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
4645 |
48526 | 4646 ui.status( |
4647 _(b'response: %s\n') | |
4648 % stringutil.pprint(res, bprefix=True, indent=2) | |
4649 ) | |
36530
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36528
diff
changeset
|
4650 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4651 elif action == b'batchbegin': |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4652 if batchedcommands is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4653 raise error.Abort(_(b'nested batchbegin not allowed')) |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4654 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4655 batchedcommands = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4656 elif action == b'batchsubmit': |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4657 # 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
|
4658 # 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
|
4659 # to bypass this layer and normalize to commands + args. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4660 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4661 _(b'sending batch with %d sub-commands\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4662 % len(batchedcommands) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4663 ) |
43704
23ad4f0c1578
debugcommands: add assertions to convince pytype peer is not None
Augie Fackler <augie@google.com>
parents:
43703
diff
changeset
|
4664 assert peer is not None |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4665 for i, chunk in enumerate(peer._submitbatch(batchedcommands)): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4666 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4667 _(b'response #%d: %s\n') % (i, stringutil.escapestr(chunk)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4668 ) |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4669 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4670 batchedcommands = None |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4671 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4672 elif action.startswith(b'httprequest '): |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4673 if not opener: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4674 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43116
diff
changeset
|
4675 _(b'cannot use httprequest without an HTTP peer') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4676 ) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4677 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4678 request = action.split(b' ', 2) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4679 if len(request) != 3: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4680 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4681 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4682 b'invalid httprequest: expected format is ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4683 b'"httprequest <method> <path>' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4684 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4685 ) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4686 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4687 method, httppath = request[1:] |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4688 headers = {} |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4689 body = None |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4690 frames = [] |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4691 for line in lines: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4692 line = line.lstrip() |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4693 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
|
4694 if m: |
39955
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
4695 # Headers need to use native strings. |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
4696 key = pycompat.strurl(m.group(1)) |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
4697 value = pycompat.strurl(m.group(2)) |
c421c22d3ad2
py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39884
diff
changeset
|
4698 headers[key] = value |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4699 continue |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4700 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4701 if line.startswith(b'BODYFILE '): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4702 with open(line.split(b' ', 1), b'rb') as fh: |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4703 body = fh.read() |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4704 elif line.startswith(b'frame '): |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4705 frame = wireprotoframing.makeframefromhumanstring( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4706 line[len(b'frame ') :] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4707 ) |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4708 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4709 frames.append(frame) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4710 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4711 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4712 _(b'unknown argument to httprequest: %s') % line |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4713 ) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4714 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4715 url = path + httppath |
37051
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4716 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4717 if frames: |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
4718 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
|
4719 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4720 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
|
4721 |
37047
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37045
diff
changeset
|
4722 # 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
|
4723 # 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
|
4724 # explicitly requested method. |
39064
a2fa7247ca70
debugcommands: get_method should always return a sysstr
Augie Fackler <augie@google.com>
parents:
39062
diff
changeset
|
4725 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
|
4726 |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4727 try: |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
4728 res = opener.open(req) |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
4729 body = res.read() |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4730 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
|
4731 # 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
|
4732 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
|
4733 continue |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
4734 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4735 ct = res.headers.get('Content-Type') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
4736 if ct == 'application/mercurial-cbor': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4737 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4738 _(b'cbor> %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4739 % stringutil.pprint( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4740 cborutil.decodeall(body), bprefix=True, indent=2 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4741 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43067
diff
changeset
|
4742 ) |
37013
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37012
diff
changeset
|
4743 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4744 elif action == b'close': |
43704
23ad4f0c1578
debugcommands: add assertions to convince pytype peer is not None
Augie Fackler <augie@google.com>
parents:
43703
diff
changeset
|
4745 assert peer is not None |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4746 peer.close() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4747 elif action == b'readavailable': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4748 if not stdout or not stderr: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4749 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4750 _(b'readavailable not available on this peer') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4751 ) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4752 |
36843
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
4753 stdin.close() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
4754 stdout.read() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36835
diff
changeset
|
4755 stderr.read() |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4756 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4757 elif action == b'readline': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4758 if not stdout: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4759 raise error.Abort(_(b'readline not available on this peer')) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4760 stdout.readline() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4761 elif action == b'ereadline': |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4762 if not stderr: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4763 raise error.Abort(_(b'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
|
4764 stderr.readline() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4765 elif action.startswith(b'read '): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4766 count = int(action.split(b' ', 1)[1]) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4767 if not stdout: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4768 raise error.Abort(_(b'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
|
4769 stdout.read(count) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4770 elif action.startswith(b'eread '): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4771 count = int(action.split(b' ', 1)[1]) |
37012
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37007
diff
changeset
|
4772 if not stderr: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4773 raise error.Abort(_(b'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
|
4774 stderr.read(count) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4775 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4776 raise error.Abort(_(b'unknown action: %s') % action) |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4777 |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4778 if batchedcommands is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
4779 raise error.Abort(_(b'unclosed "batchbegin" request')) |
36531
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36530
diff
changeset
|
4780 |
36528
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4781 if peer: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4782 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4783 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4784 if proc: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36527
diff
changeset
|
4785 proc.kill() |