annotate mercurial/debugcommands.py @ 48850:308e45f7b455 stable

debugcommands: remove `debugdirstateignorepatternhash` This is replaced by the more complete `--docket` option to `debugstate`. Differential Revision: https://phab.mercurial-scm.org/D12591
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 28 Apr 2022 15:22:08 +0200
parents eaaf4f98c9f1
children a932cad26d37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30411
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: 46806
diff changeset
3 # Copyright 2005-2016 Olivia Mackall <olivia@selenic.com>
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 #
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 from __future__ import absolute_import
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9
47674
ff97e793ed36 dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents: 47568
diff changeset
10 import binascii
34144
902219a99901 debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents: 34135
diff changeset
11 import codecs
34043
626a28f30dbd debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents: 33553
diff changeset
12 import collections
46782
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
13 import contextlib
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
14 import difflib
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
15 import errno
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
16 import glob
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
17 import operator
30534
86ebd2f61c31 debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30533
diff changeset
18 import os
44230
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
19 import platform
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
20 import random
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
21 import re
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
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
36789
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 36786
diff changeset
24 import stat
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
25 import string
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
26 import subprocess
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
27 import sys
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
28 import time
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 from .i18n import _
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
31 from .node import (
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
32 bin,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
33 hex,
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
34 nullrev,
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
35 short,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
36 )
43089
c59eb1560c44 py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43085
diff changeset
37 from .pycompat import (
c59eb1560c44 py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43085
diff changeset
38 getattr,
c59eb1560c44 py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43085
diff changeset
39 open,
c59eb1560c44 py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43085
diff changeset
40 )
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41 from . import (
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
42 bundle2,
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
43 bundlerepo,
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
44 changegroup,
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 cmdutil,
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
46 color,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
47 context,
41529
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
48 copies,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
49 dagparser,
48849
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
50 dirstateutils,
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
51 encoding,
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 error,
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
53 exchange,
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
54 extensions,
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
55 filemerge,
38845
b9162ea1b815 fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 38842
diff changeset
56 filesetlang,
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
57 formatter,
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
58 hg,
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
59 httppeer,
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
60 localrepo,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
61 lock as lockmod,
35928
c8e2d6ed1f9e cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents: 35730
diff changeset
62 logcmdutil,
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
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: 45457
diff changeset
64 metadata,
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
65 obsolete,
33148
4f49810a1011 obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33119
diff changeset
66 obsutil,
43677
0b7733719d21 utils: move finddirs() to pathutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 43554
diff changeset
67 pathutil,
32765
23734c0e361f debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32714
diff changeset
68 phases,
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
69 policy,
30967
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
70 pvec,
30528
20a42325fdef py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30527
diff changeset
71 pycompat,
32376
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32355
diff changeset
72 registrar,
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30774
diff changeset
73 repair,
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
74 repoview,
47810
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,
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 revlog,
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
77 revset,
31044
0b8356705de6 revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 31008
diff changeset
78 revsetlang,
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 scmutil,
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
80 setdiscovery,
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
81 simplemerge,
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
82 sshpeer,
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
83 sslutil,
30511
6da030496667 debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30510
diff changeset
84 streamclone,
45880
d7a508a75d72 strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 45838
diff changeset
85 strip,
44336
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
86 tags as tagsmod,
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
87 templater,
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
88 treediscovery,
31864
70d163b86316 upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31694
diff changeset
89 upgrade,
35562
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
90 url as urlmod,
30525
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
91 util,
31249
9cdba6072b97 vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31226
diff changeset
92 vfs as vfsmod,
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
93 wireprotoframing,
36556
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
94 wireprotoserver,
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 )
47309
e96f75857361 updatecaches: use the caches argument in `hg debugupdatecaches`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47153
diff changeset
96 from .interfaces import repository
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
97 from .utils import (
39468
e5eb67dea6e8 debugcommands: use our CBOR decoder
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39405
diff changeset
98 cborutil,
42041
3e47d1ec9da5 util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42035
diff changeset
99 compression,
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
100 dateutil,
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37087
diff changeset
101 procutil,
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
102 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
103 urlutil,
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
104 )
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
106 from .revlogutils import (
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
107 deltas as deltautil,
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
108 nodemap,
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
109 rewrite,
45665
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
110 sidedata,
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
111 )
39357
655b5b465953 revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents: 39309
diff changeset
112
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
113 release = lockmod.release
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
114
45880
d7a508a75d72 strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 45838
diff changeset
115 table = {}
d7a508a75d72 strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 45838
diff changeset
116 table.update(strip.command._table)
d7a508a75d72 strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 45838
diff changeset
117 command = registrar.command(table)
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
119
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
120 @command(b'debugancestor', [], _(b'[INDEX] REV1 REV2'), optionalrepo=True)
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121 def debugancestor(ui, repo, *args):
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 """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
123 if len(args) == 3:
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 index, rev1, rev2 = args
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39776
diff changeset
125 r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index)
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 lookup = r.lookup
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 elif len(args) == 2:
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 if not repo:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
129 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
130 _(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
131 )
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 rev1, rev2 = args
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133 r = repo.changelog
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134 lookup = repo.lookup
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
136 raise error.Abort(_(b'either two or three arguments required'))
30411
869d660b8669 debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 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
138 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
139
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
140
45149
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
141 @command(b'debugantivirusrunning', [])
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
142 def debugantivirusrunning(ui, repo):
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
143 """attempt to trigger an antivirus scanner to see if one is active"""
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
144 with repo.cachevfs.open('eicar-test-file.com', b'wb') as f:
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
145 f.write(
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
146 util.b85decode(
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
147 # 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
148 # 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
149 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
150 b'E<)&Nm5l)EmTEQR4qnHOhq9iNGnJx'
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
151 )
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
152 )
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
153 # Give an AV engine time to scan the file.
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
154 time.sleep(2)
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
155 util.unlink(repo.cachevfs.join('eicar-test-file.com'))
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
156
87047efbc6a6 debugcommands: create new debugantivirusrunning command
Augie Fackler <augie@google.com>
parents: 45107
diff changeset
157
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
158 @command(b'debugapplystreamclonebundle', [], b'FILE')
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
159 def debugapplystreamclonebundle(ui, repo, fname):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
160 """apply a stream clone bundle file"""
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
161 f = hg.openpath(ui, fname)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
162 gen = exchange.readbundle(ui, f, fname)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
163 gen.apply(repo)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
164
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
165
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
166 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
167 b'debugbuilddag',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
168 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
169 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
170 b'm',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
171 b'mergeable-file',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
172 None,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
173 _(b'add single file mergeable changes'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
174 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
175 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
176 b'o',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
177 b'overwritten-file',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
178 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
179 _(b'add single file all revs overwrite'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
180 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
181 (b'n', b'new-file', None, _(b'add new file at each rev')),
48705
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
182 (
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
183 b'',
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
184 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: 48590
diff changeset
185 None,
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
186 _(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: 48590
diff changeset
187 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
188 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
189 _(b'[OPTION]... [TEXT]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
190 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
191 def debugbuilddag(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
192 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
193 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
194 text=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
195 mergeable_file=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
196 overwritten_file=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
197 new_file=False,
48705
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
198 from_existing=False,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
199 ):
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
200 """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: 30411
diff changeset
201
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
202 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: 30411
diff changeset
203 command line.
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
204
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
205 Elements:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
206
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
207 - "+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: 30411
diff changeset
208 - "." is a single node based on the current default parent
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
209 - "$" resets the default parent to null (implied at the start);
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
210 otherwise the default parent is always the last node created
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
211 - "<p" sets the default parent to the backref p
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
212 - "*p" is a fork at parent p, which is a backref
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
213 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
214 - "/p2" is a merge of the preceding node and p2
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
215 - ":tag" defines a local tag for the preceding node
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
216 - "@branch" sets the named branch for subsequent nodes
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
217 - "#...\\n" is a comment up to the end of the line
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
218
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
219 Whitespace between the above elements is ignored.
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
220
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
221 A backref is either
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
222
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
223 - 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: 30411
diff changeset
224 node, or
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
225 - the name of a local tag you placed earlier using ":tag", or
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
226 - empty to denote the default parent.
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
227
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
228 All string valued-elements are either strictly alphanumeric, or must
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
229 be enclosed in double quotes ("..."), with "\\" as escape character.
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
230 """
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
231
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
232 if text is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
233 ui.status(_(b"reading DAG from stdin\n"))
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
234 text = ui.fin.read()
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
235
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
236 cl = repo.changelog
48705
b4bc9c4f925d debugbuilddag: add a flag to allow running it from a non-empty repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48590
diff changeset
237 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
238 raise error.Abort(_(b'repository is not empty'))
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
239
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
240 # determine number of revs in DAG
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
241 total = 0
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
242 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
243 if type == b'n':
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
244 total += 1
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
245
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
246 if mergeable_file:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
247 linesperrev = 2
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
248 # make a file with k lines per rev
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
249 initialmergedlines = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
250 b'%d' % i for i in pycompat.xrange(0, total * linesperrev)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
251 ]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
252 initialmergedlines.append(b"")
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
253
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
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 )
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
258 with progress, repo.wlock(), repo.lock(), repo.transaction(b"builddag"):
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
259 at = -1
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
260 atbranch = b'default'
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
261 nodeids = []
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
262 id = 0
38381
fce1c17493db debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38361
diff changeset
263 progress.update(id)
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
264 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
265 if type == b'n':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
266 ui.note((b'node %s\n' % pycompat.bytestr(data)))
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
267 id, ps = data
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
268
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
269 files = []
35406
dffc35a5be9f debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents: 35402
diff changeset
270 filecontent = {}
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
271
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
272 p2 = None
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
273 if mergeable_file:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
274 fn = b"mf"
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
275 p1 = repo[ps[0]]
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
276 if len(ps) > 1:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
277 p2 = repo[ps[1]]
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
278 pa = p1.ancestor(p2)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
279 base, local, other = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
280 x[fn].data() for x in (pa, p1, p2)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
281 ]
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
282 m3 = simplemerge.Merge3Text(base, local, other)
48586
2dbee604a4f0 simplemerge: clarify names of functions that render conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents: 48585
diff changeset
283 ml = [
48590
12ac4401ff7d simplemerge: simplify and rename `render_markers()`
Martin von Zweigbergk <martinvonz@google.com>
parents: 48586
diff changeset
284 l.strip()
12ac4401ff7d simplemerge: simplify and rename `render_markers()`
Martin von Zweigbergk <martinvonz@google.com>
parents: 48586
diff changeset
285 for l in simplemerge.render_minimized(m3)[0]
48586
2dbee604a4f0 simplemerge: clarify names of functions that render conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents: 48585
diff changeset
286 ]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
287 ml.append(b"")
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
288 elif at > 0:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
289 ml = p1[fn].data().split(b"\n")
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
290 else:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
291 ml = initialmergedlines
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
292 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
293 mergedtext = b"\n".join(ml)
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
294 files.append(fn)
35406
dffc35a5be9f debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents: 35402
diff changeset
295 filecontent[fn] = mergedtext
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
296
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
297 if overwritten_file:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
298 fn = b"of"
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
299 files.append(fn)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
300 filecontent[fn] = b"r%i\n" % id
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
301
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
302 if new_file:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
303 fn = b"nf%i" % id
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
304 files.append(fn)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
305 filecontent[fn] = b"r%i\n" % id
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
306 if len(ps) > 1:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
307 if not p2:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
308 p2 = repo[ps[1]]
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
309 for fn in p2:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
310 if fn.startswith(b"nf"):
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
311 files.append(fn)
35406
dffc35a5be9f debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents: 35402
diff changeset
312 filecontent[fn] = p2[fn].data()
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
313
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
314 def fctxfn(repo, cx, path):
35406
dffc35a5be9f debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents: 35402
diff changeset
315 if path in filecontent:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
316 return context.memfilectx(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
317 repo, cx, path, filecontent[path]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
318 )
35406
dffc35a5be9f debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents: 35402
diff changeset
319 return None
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
320
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
321 if len(ps) == 0 or ps[0] < 0:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
322 pars = [None, None]
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
323 elif len(ps) == 1:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
324 pars = [nodeids[ps[0]], None]
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
325 else:
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
326 pars = [nodeids[p] for p in ps]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
327 cx = context.memctx(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
328 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
329 pars,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
330 b"r%i" % id,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
331 files,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
332 fctxfn,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
333 date=(id, 0),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
334 user=b"debugbuilddag",
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
335 extra={b'branch': atbranch},
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
336 )
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
337 nodeid = repo.commitctx(cx)
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
338 nodeids.append(nodeid)
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
339 at = id
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
340 elif type == b'l':
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
341 id, name = data
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
342 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
343 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
344 elif type == b'a':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
345 ui.note((b'branch %s\n' % data))
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
346 atbranch = data
38381
fce1c17493db debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38361
diff changeset
347 progress.update(id)
30412
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
348
945f8229b30d debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30411
diff changeset
349 if tags:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
350 repo.vfs.write(b"localtags", b"".join(tags))
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
351
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
352
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
353 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
354 indent_string = b' ' * indent
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
355 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
356 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
357 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
358 % indent_string
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
359 )
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
360
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
361 def showchunks(named):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
362 ui.write(b"\n%s%s\n" % (indent_string, named))
34299
311f6ccf8f23 debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents: 34145
diff changeset
363 for deltadata in gen.deltaiter():
46724
a41565bef69f changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents: 46702
diff changeset
364 node, p1, p2, cs, deltabase, delta, flags, sidedata = deltadata
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
365 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
366 b"%s%s %s %s %s %s %d\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
367 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
368 indent_string,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
369 hex(node),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
370 hex(p1),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
371 hex(p2),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
372 hex(cs),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
373 hex(deltabase),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
374 len(delta),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
375 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
376 )
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
377
43977
7a2c49a3cbae debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents: 43884
diff changeset
378 gen.changelogheader()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
379 showchunks(b"changelog")
43977
7a2c49a3cbae debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents: 43884
diff changeset
380 gen.manifestheader()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
381 showchunks(b"manifest")
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
382 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
383 fname = chunkdata[b'filename']
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
384 showchunks(fname)
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
385 else:
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
386 if isinstance(gen, bundle2.unbundle20):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
387 raise error.Abort(_(b'use debugbundle2 for this file'))
43977
7a2c49a3cbae debug: drop unused variable assignments
Matt Harbison <matt_harbison@yahoo.com>
parents: 43884
diff changeset
388 gen.changelogheader()
34299
311f6ccf8f23 debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents: 34145
diff changeset
389 for deltadata in gen.deltaiter():
46724
a41565bef69f changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents: 46702
diff changeset
390 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
391 ui.write(b"%s%s\n" % (indent_string, hex(node)))
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
392
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
393
33041
b482d80e041b debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents: 33040
diff changeset
394 def _debugobsmarkers(ui, part, indent=0, **opts):
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
395 """display version and markers contained in 'data'"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
396 opts = pycompat.byteskwargs(opts)
33041
b482d80e041b debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents: 33040
diff changeset
397 data = part.read()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
398 indent_string = b' ' * indent
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
399 try:
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
400 version, markers = obsolete._readmarkers(data)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
401 except error.UnknownVersion as exc:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
402 msg = b"%sunsupported version: %s (%d bytes)\n"
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
403 msg %= indent_string, exc.version, len(data)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
404 ui.write(msg)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
405 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
406 msg = b"%sversion: %d (%d bytes)\n"
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
407 msg %= indent_string, version, len(data)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
408 ui.write(msg)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
409 fm = ui.formatter(b'debugobsolete', opts)
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
410 for rawmarker in sorted(markers):
33154
4e30168d7939 obsutil: move the 'marker' class to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33148
diff changeset
411 m = obsutil.marker(None, rawmarker)
32550
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
412 fm.startitem()
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
413 fm.plain(indent_string)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
414 cmdutil.showmarker(fm, m)
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
415 fm.end()
b62b2b373bce debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32491
diff changeset
416
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
417
33043
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
418 def _debugphaseheads(ui, data, indent=0):
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
419 """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
420 indent_string = b' ' * indent
34327
12c42bcd4133 phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents: 34299
diff changeset
421 headsbyphase = phases.binarydecode(data)
33043
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
422 for phase in phases.allphases:
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
423 for head in headsbyphase[phase]:
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
424 ui.write(indent_string)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
425 ui.write(b'%s %s\n' % (hex(head), phases.phasenames[phase]))
33043
e8c8d81eb864 bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents: 33041
diff changeset
426
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
427
34043
626a28f30dbd debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents: 33553
diff changeset
428 def _quasirepr(thing):
626a28f30dbd debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents: 33553
diff changeset
429 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
430 return b'{%s}' % (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
431 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
432 )
34043
626a28f30dbd debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents: 33553
diff changeset
433 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
434
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
435
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
436 def _debugbundle2(ui, gen, all=None, **opts):
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
437 """lists the contents of a bundle2"""
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
438 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
439 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
440 ui.write((b'Stream params: %s\n' % _quasirepr(gen.params)))
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
441 parttypes = opts.get('part_type', [])
30510
a87e469201f9 debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30412
diff changeset
442 for part in gen.iterparts():
32714
3ef319e9505f debugbundle: add --part-type flag to emit only named part types
Danek Duvall <danek.duvall@oracle.com>
parents: 32649
diff changeset
443 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: 32649
diff changeset
444 continue
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
445 msg = b'%s -- %s (mandatory: %r)\n'
37836
d618558e4e8b debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents: 37823
diff changeset
446 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
447 if part.type == b'changegroup':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
448 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
449 cg = changegroup.getunbundler(version, part, b'UN')
36957
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
450 if not ui.quiet:
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
451 _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
452 if part.type == b'obsmarkers':
36957
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
453 if not ui.quiet:
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
454 _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
455 if part.type == b'phase-heads':
36957
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
456 if not ui.quiet:
c92d1d3c58ee debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents: 36851
diff changeset
457 _debugphaseheads(ui, part, indent=4)
30511
6da030496667 debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30510
diff changeset
458
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
459
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
460 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
461 b'debugbundle',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
462 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
463 (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
464 (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
465 (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
466 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
467 _(b'FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
468 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
469 )
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
470 def debugbundle(ui, bundlepath, all=None, spec=None, **opts):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
471 """lists the contents of a bundle"""
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
472 with hg.openpath(ui, bundlepath) as f:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
473 if spec:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
474 spec = exchange.getbundlespec(ui, f)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
475 ui.write(b'%s\n' % spec)
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
476 return
30511
6da030496667 debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30510
diff changeset
477
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
478 gen = exchange.readbundle(ui, f, bundlepath)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
479 if isinstance(gen, bundle2.unbundle20):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
480 return _debugbundle2(ui, gen, all=all, **opts)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
481 _debugchangegroup(ui, gen, all=all, **opts)
30512
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
482
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
483
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
484 @command(b'debugcapabilities', [], _(b'PATH'), norepo=True)
35015
7ee2d859f720 debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents: 34645
diff changeset
485 def debugcapabilities(ui, path, **opts):
7ee2d859f720 debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents: 34645
diff changeset
486 """lists the capabilities of a remote peer"""
35408
cd3392cb5818 py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35407
diff changeset
487 opts = pycompat.byteskwargs(opts)
35015
7ee2d859f720 debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents: 34645
diff changeset
488 peer = hg.peer(ui, opts, path)
46702
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
489 try:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
490 caps = peer.capabilities()
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
491 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: 46694
diff changeset
492 for c in sorted(caps):
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
493 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: 46694
diff changeset
494 b2caps = bundle2.bundle2caps(peer)
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
495 if b2caps:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
496 ui.writenoi18n(b'Bundle2 capabilities:\n')
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
497 for key, values in sorted(pycompat.iteritems(b2caps)):
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
498 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: 46694
diff changeset
499 for v in values:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
500 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: 46694
diff changeset
501 finally:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
502 peer.close()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
503
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
504
46538
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
505 @command(
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
506 b'debugchangedfiles',
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
507 [
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
508 (
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
509 b'',
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
510 b'compute',
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
511 False,
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
512 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: 46535
diff changeset
513 ),
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
514 ],
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
515 b'REV',
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
516 )
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
517 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: 45457
diff changeset
518 """list the stored files changes for a revision"""
48130
5105a9975407 errors: raise InputError from revsingle() iff revset provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48128
diff changeset
519 ctx = logcmdutil.revsingle(repo, rev, None)
46538
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
520 files = None
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
521
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
522 if opts['compute']:
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
523 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: 46535
diff changeset
524 else:
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
525 sd = repo.changelog.sidedata(ctx.rev())
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
526 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: 46535
diff changeset
527 if files_block is not None:
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
528 files = metadata.decode_files_sidedata(sd)
c2435280ca63 copy-tracing: add a --compute flag to debugchangedfiles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46535
diff changeset
529 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: 45457
diff changeset
530 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: 45457
diff changeset
531 if f in files.added:
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
532 action = b"added"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
533 elif f in files.removed:
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
534 action = b"removed"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
535 elif f in files.merged:
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
536 action = b"merged"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
537 elif f in files.salvaged:
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
538 action = b"salvaged"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
539 else:
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
540 action = b"touched"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
541
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
542 copy_parent = b""
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
543 copy_source = b""
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
544 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: 45457
diff changeset
545 copy_parent = b"p1"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
546 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: 45457
diff changeset
547 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: 45457
diff changeset
548 copy_parent = b"p2"
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
549 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: 45457
diff changeset
550
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
551 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: 45457
diff changeset
552 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: 45457
diff changeset
553 ui.write(template % data)
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
554
308ca5528ee6 changing-files: add a debug command display changed files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45457
diff changeset
555
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
556 @command(b'debugcheckstate', [], b'')
30512
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
557 def debugcheckstate(ui, repo):
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
558 """validate the correctness of the current dirstate"""
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
559 parent1, parent2 = repo.dirstate.parents()
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
560 m1 = repo[parent1].manifest()
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
561 m2 = repo[parent2].manifest()
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
562 errors = 0
48101
c87844960a35 dirstate: move verification code within the dirstate itself
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48046
diff changeset
563 for err in repo.dirstate.verify(m1, m2):
c87844960a35 dirstate: move verification code within the dirstate itself
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48046
diff changeset
564 ui.warn(err[0] % err[1:])
c87844960a35 dirstate: move verification code within the dirstate itself
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48046
diff changeset
565 errors += 1
30512
6bfb333a6f2f debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30511
diff changeset
566 if errors:
43679
72b454fae92e debugcommands: don't shadow the error module
Augie Fackler <augie@google.com>
parents: 43677
diff changeset
567 errstr = _(b".hg/dirstate inconsistent with current parent's manifest")
72b454fae92e debugcommands: don't shadow the error module
Augie Fackler <augie@google.com>
parents: 43677
diff changeset
568 raise error.Abort(errstr)
30513
c3bdc27121d1 debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30512
diff changeset
569
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
570
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
571 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
572 b'debugcolor',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
573 [(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
574 b'hg debugcolor',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
575 )
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
576 def debugcolor(ui, repo, **opts):
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
577 """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
578 ui.writenoi18n(b'color mode: %s\n' % stringutil.pprint(ui._colormode))
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
579 if opts.get('style'):
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
580 return _debugdisplaystyle(ui)
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
581 else:
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
582 return _debugdisplaycolor(ui)
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
583
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
584
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
585 def _debugdisplaycolor(ui):
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
586 ui = ui.copy()
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
587 ui._styles.clear()
31694
57a22f699179 color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents: 31639
diff changeset
588 for effect in color._activeeffects(ui).keys():
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
589 ui._styles[effect] = effect
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
590 if ui._terminfoparams:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
591 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
592 if k.startswith(b'color.'):
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
593 ui._styles[k] = k[6:]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
594 elif k.startswith(b'terminfo.'):
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
595 ui._styles[k] = k[9:]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
596 ui.write(_(b'available colors:\n'))
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
597 # 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
598 items = sorted(ui._styles.items(), key=lambda i: (b'_' in i[0], i[0], i[1]))
31136
8fc55bbd2235 color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
599 for colorname, label in items:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
600 ui.write(b'%s\n' % colorname, label=label)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
601
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
602
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
603 def _debugdisplaystyle(ui):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
604 ui.write(_(b'available style:\n'))
37823
0e9ddab2bac2 debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents: 37722
diff changeset
605 if not ui._styles:
0e9ddab2bac2 debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents: 37722
diff changeset
606 return
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
607 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: 31091
diff changeset
608 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
609 ui.write(b'%s' % label, label=label)
31135
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
610 if effects:
c4e8fa2b1c40 color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31091
diff changeset
611 # 50
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
612 ui.write(b': ')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
613 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
614 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
615 ui.write(b'\n')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
616
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 @command(b'debugcreatestreamclonebundle', [], b'FILE')
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
619 def debugcreatestreamclonebundle(ui, repo, fname):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
620 """create a stream clone bundle file
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
621
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
622 Stream bundles are special bundles that are essentially archives of
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
623 revlog files. They are commonly used for cloning very quickly.
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
624 """
32765
23734c0e361f debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32714
diff changeset
625 # 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: 32714
diff changeset
626 # is moved into `hg bundle`.
23734c0e361f debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32714
diff changeset
627 if phases.hassecret(repo):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
628 ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
629 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
630 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
631 b'revisions)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
632 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
633 )
32765
23734c0e361f debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32714
diff changeset
634
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
635 requirements, gen = streamclone.generatebundlev1(repo)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
636 changegroup.writechunks(ui, gen, fname)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
637
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
638 ui.write(_(b'bundle requirements: %s\n') % b', '.join(sorted(requirements)))
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
639
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
640
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
641 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
642 b'debugdag',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
643 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
644 (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
645 (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
646 (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
647 (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
648 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
649 _(b'[OPTION]... [FILE [REV]...]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
650 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
651 )
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
652 def debugdag(ui, repo, file_=None, *revs, **opts):
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
653 """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: 30514
diff changeset
654
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
655 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: 30514
diff changeset
656 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: 30514
diff changeset
657
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
658 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: 30514
diff changeset
659 """
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
660 spaces = opts.get('spaces')
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
661 dots = opts.get('dots')
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
662 if file_:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
663 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), file_)
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44453
diff changeset
664 revs = {int(r) for r in revs}
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
665
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
666 def events():
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
667 for r in rlog:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
668 yield b'n', (r, list(p for p in rlog.parentrevs(r) if p != -1))
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
669 if r in revs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
670 yield b'l', (r, b"r%i" % r)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
671
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
672 elif repo:
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
673 cl = repo.changelog
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
674 tags = opts.get('tags')
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
675 branches = opts.get('branches')
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
676 if tags:
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
677 labels = {}
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
678 for l, n in repo.tags().items():
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
679 labels.setdefault(cl.rev(n), []).append(l)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
680
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
681 def events():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
682 b = b"default"
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
683 for r in cl:
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
684 if branches:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
685 newb = cl.read(cl.node(r))[5][b'branch']
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
686 if newb != b:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
687 yield b'a', newb
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
688 b = newb
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
689 yield b'n', (r, list(p for p in cl.parentrevs(r) if p != -1))
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
690 if tags:
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
691 ls = labels.get(r)
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
692 if ls:
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
693 for l in ls:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
694 yield b'l', (r, l)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
695
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
696 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
697 raise error.Abort(_(b'need repo for changelog dag'))
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
698
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
699 for line in dagparser.dagtextlines(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
700 events(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
701 addspaces=spaces,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
702 wraplabels=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
703 wrapannotations=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
704 wrapnonlinear=dots,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
705 usedots=dots,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
706 maxlinewidth=70,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
707 ):
30523
625ccc95fa96 debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30514
diff changeset
708 ui.write(line)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
709 ui.write(b"\n")
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
710
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
711
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
712 @command(b'debugdata', cmdutil.debugrevlogopts, _(b'-c|-m|FILE REV'))
30524
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
713 def debugdata(ui, repo, file_, rev=None, **opts):
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
714 """dump the contents of a data file revision"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
715 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
716 if opts.get(b'changelog') or opts.get(b'manifest') or opts.get(b'dir'):
30524
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
717 if rev is not None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
718 raise error.CommandError(b'debugdata', _(b'invalid arguments'))
30524
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
719 file_, rev = None, file_
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
720 elif rev is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
721 raise error.CommandError(b'debugdata', _(b'invalid arguments'))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
722 r = cmdutil.openstorage(repo, b'debugdata', file_, opts)
30524
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
723 try:
42789
127d57e950e0 rawdata: update callers in debugcommands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42683
diff changeset
724 ui.write(r.rawdata(r.lookup(rev)))
30524
cdd1885d0f2f debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30523
diff changeset
725 except KeyError:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
726 raise error.Abort(_(b'invalid revision identifier %s') % rev)
30525
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
727
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
728
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
729 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
730 b'debugdate',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
731 [(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
732 _(b'[-e] DATE [RANGE]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
733 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
734 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
735 )
30525
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
736 def debugdate(ui, date, range=None, **opts):
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
737 """parse and display a date"""
43551
313e3a279828 cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents: 43238
diff changeset
738 if opts["extended"]:
43884
38d6aa768310 debugcommands: finish moving `extendeddateformats` from util to dateutil
Matt Harbison <matt_harbison@yahoo.com>
parents: 43744
diff changeset
739 d = dateutil.parsedate(date, dateutil.extendeddateformats)
30525
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
740 else:
36636
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36616
diff changeset
741 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
742 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
743 ui.writenoi18n(b"standard: %s\n" % dateutil.datestr(d))
30525
ef1353c283e3 debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30524
diff changeset
744 if range:
36636
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36616
diff changeset
745 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
746 ui.writenoi18n(b"match: %s\n" % m(d[0]))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
747
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
748
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
749 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
750 b'debugdeltachain',
32414
04baab18d60a commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents: 32410
diff changeset
751 cmdutil.debugrevlogopts + cmdutil.formatteropts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
752 _(b'-c|-m|FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
753 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
754 )
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
755 def debugdeltachain(ui, repo, file_=None, **opts):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
756 """dump information about delta chains in a revlog
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
757
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
758 Output can be templatized. Available template keywords are:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
759
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
760 :``rev``: revision number
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
761 :``chainid``: delta chain identifier (numbered by unique base)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
762 :``chainlen``: delta chain length to this revision
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
763 :``prevrev``: previous revision in delta chain
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
764 :``deltatype``: role of delta / how it was computed
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
765 :``compsize``: compressed size of revision
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
766 :``uncompsize``: uncompressed size of revision
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
767 :``chainsize``: total size of compressed revisions in chain
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
768 :``chainratio``: total chain size divided by uncompressed revision size
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
769 (new delta chains typically start at ratio 2.00)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
770 :``lindist``: linear distance from base revision in delta chain to end
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
771 of this revision
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
772 :``extradist``: total size of revisions not part of this delta chain from
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
773 base of delta chain to end of this revision; a measurement
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
774 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: 30538
diff changeset
775 the delta chain for this revision
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
776 :``extraratio``: extradist divided by chainsize; another representation of
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
777 how much unrelated data is needed to load this delta chain
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
778
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
779 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: 35016
diff changeset
780 are available:
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
781
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
782 :``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: 35016
diff changeset
783 (sum of the sizes of all the blocks)
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
784 :``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: 35016
diff changeset
785 :``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
786 :``srchunks``: in how many data hunks the whole revision would be read
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
787
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
788 The sparse read can be enabled with experimental.sparse-read = True
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
789 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
790 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
791 r = cmdutil.openrevlog(repo, b'debugdeltachain', file_, opts)
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
792 index = r.index
38148
b17fa9041695 debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents: 38021
diff changeset
793 start = r.start
b17fa9041695 debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents: 38021
diff changeset
794 length = r.length
47151
c261899fb282 revlog: replace flag check related to generaldelta with attribute check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47142
diff changeset
795 generaldelta = r._generaldelta
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
796 withsparseread = getattr(r, '_withsparseread', False)
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
797
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
798 def revinfo(rev):
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
799 e = index[rev]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
800 compsize = e[1]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
801 uncompsize = e[2]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
802 chainsize = 0
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
803
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
804 if generaldelta:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
805 if e[3] == e[5]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
806 deltatype = b'p1'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
807 elif e[3] == e[6]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
808 deltatype = b'p2'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
809 elif e[3] == rev - 1:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
810 deltatype = b'prev'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
811 elif e[3] == rev:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
812 deltatype = b'base'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
813 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
814 deltatype = b'other'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
815 else:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
816 if e[3] == rev:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
817 deltatype = b'base'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
818 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
819 deltatype = b'prev'
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
820
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
821 chain = r._deltachain(rev)[0]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
822 for iterrev in chain:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
823 e = index[iterrev]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
824 chainsize += e[1]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
825
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
826 return compsize, uncompsize, deltatype, chain, chainsize
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
827
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
828 fm = ui.formatter(b'debugdeltachain', opts)
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
829
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
830 fm.plain(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
831 b' rev chain# chainlen prev delta '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
832 b'size rawsize chainsize ratio lindist extradist '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
833 b'extraratio'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
834 )
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
835 if withsparseread:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
836 fm.plain(b' readsize largestblk rddensity srchunks')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
837 fm.plain(b'\n')
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
838
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
839 chainbases = {}
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
840 for rev in r:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
841 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
842 chainbase = chain[0]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
843 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
844 basestart = start(chainbase)
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
845 revstart = start(rev)
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
846 lineardist = revstart + comp - basestart
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
847 extradist = lineardist - chainsize
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
848 try:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
849 prevrev = chain[-2]
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
850 except IndexError:
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
851 prevrev = -1
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
852
38646
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
853 if uncomp != 0:
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
854 chainratio = float(chainsize) / float(uncomp)
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
855 else:
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
856 chainratio = chainsize
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
857
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
858 if chainsize != 0:
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
859 extraratio = float(extradist) / float(chainsize)
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
860 else:
93313f66b69b debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents: 38613
diff changeset
861 extraratio = extradist
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
862
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
863 fm.startitem()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
864 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
865 b'rev chainid chainlen prevrev deltatype compsize '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
866 b'uncompsize chainsize chainratio lindist extradist '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
867 b'extraratio',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
868 b'%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
869 rev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
870 chainid,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
871 len(chain),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
872 prevrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
873 deltatype,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
874 comp,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
875 uncomp,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
876 chainsize,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
877 chainratio,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
878 lineardist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
879 extradist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
880 extraratio,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
881 rev=rev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
882 chainid=chainid,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
883 chainlen=len(chain),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
884 prevrev=prevrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
885 deltatype=deltatype,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
886 compsize=comp,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
887 uncompsize=uncomp,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
888 chainsize=chainsize,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
889 chainratio=chainratio,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
890 lindist=lineardist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
891 extradist=extradist,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
892 extraratio=extraratio,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
893 )
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
894 if withsparseread:
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
895 readsize = 0
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
896 largestblock = 0
35728
22a877215ea1 debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents: 35678
diff changeset
897 srchunks = 0
22a877215ea1 debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents: 35678
diff changeset
898
39357
655b5b465953 revlog: split functionality related to deltas computation in a new module
Boris Feld <boris.feld@octobus.net>
parents: 39309
diff changeset
899 for revschunk in deltautil.slicechunk(r, chain):
35728
22a877215ea1 debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents: 35678
diff changeset
900 srchunks += 1
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
901 blkend = start(revschunk[-1]) + length(revschunk[-1])
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
902 blksize = blkend - start(revschunk[0])
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
903
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
904 readsize += blksize
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
905 if largestblock < blksize:
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
906 largestblock = blksize
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
907
38647
0f4c2c70e26e debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents: 38646
diff changeset
908 if readsize:
0f4c2c70e26e debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents: 38646
diff changeset
909 readdensity = float(chainsize) / float(readsize)
0f4c2c70e26e debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents: 38646
diff changeset
910 else:
0f4c2c70e26e debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents: 38646
diff changeset
911 readdensity = 1
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
912
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
913 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
914 b'readsize largestblock readdensity srchunks',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
915 b' %10d %10d %9.5f %8d',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
916 readsize,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
917 largestblock,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
918 readdensity,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
919 srchunks,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
920 readsize=readsize,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
921 largestblock=largestblock,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
922 readdensity=readdensity,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
923 srchunks=srchunks,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
924 )
35082
5cbbef8d2a57 debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents: 35016
diff changeset
925
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
926 fm.plain(b'\n')
30550
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
927
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
928 fm.end()
342d0cb4f446 debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30538
diff changeset
929
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
930
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
931 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
932 b'debugdirstate|debugstate',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
933 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
934 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
935 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
936 b'nodates',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
937 None,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
938 _(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
939 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
940 (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
941 (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
942 (
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47682
diff changeset
943 b'',
48849
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
944 b'docket',
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
945 False,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
946 _(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: 48835
diff changeset
947 ),
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
948 (
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
949 b'',
47683
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47682
diff changeset
950 b'all',
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47682
diff changeset
951 False,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47682
diff changeset
952 _(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
953 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
954 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
955 _(b'[OPTION]...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
956 )
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
957 def debugstate(ui, repo, **opts):
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
958 """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: 30973
diff changeset
959
48849
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
960 if opts.get("docket"):
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
961 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: 48835
diff changeset
962 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: 48835
diff changeset
963
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
964 docket = repo.dirstate._map.docket
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
965 (
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
966 start_offset,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
967 root_nodes,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
968 nodes_with_entry,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
969 nodes_with_copy,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
970 unused_bytes,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
971 _unused,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
972 ignore_pattern,
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
973 ) = 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: 48835
diff changeset
974
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
975 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: 48835
diff changeset
976 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: 48835
diff changeset
977 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: 48835
diff changeset
978 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: 48835
diff changeset
979 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: 48835
diff changeset
980 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: 48835
diff changeset
981 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: 48835
diff changeset
982 ui.write(
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
983 _(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: 48835
diff changeset
984 )
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
985 return
eaaf4f98c9f1 dirstate-v2: add flag to `debugstate` to print docket information
Raphaël Gomès <rgomes@octobus.net>
parents: 48835
diff changeset
986
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
987 nodates = not opts['dates']
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
988 if opts.get('nodates') is not None:
39776
7e99b02768ef debugdirstate: deprecate --nodates in favor of --no-dates
Martin von Zweigbergk <martinvonz@google.com>
parents: 39577
diff changeset
989 nodates = True
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
990 datesort = opts.get('datesort')
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
991
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
992 if datesort:
48046
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
993
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
994 def keyfunc(entry):
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
995 filename, _state, _mode, _size, mtime = entry
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
996 return (mtime, filename)
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
997
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
998 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
999 keyfunc = None # sort by filename
48045
357307feaf61 debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents: 47916
diff changeset
1000 entries = list(repo.dirstate._map.debug_iter(all=opts['all']))
47357
3b9914b28133 dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents: 47309
diff changeset
1001 entries.sort(key=keyfunc)
48046
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1002 for entry in entries:
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1003 filename, state, mode, size, mtime = entry
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1004 if mtime == -1:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1005 timestr = b'unset '
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
1006 elif nodates:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1007 timestr = b'set '
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
1008 else:
48046
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1009 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(mtime))
35214
d4b108fdf423 py3: use encoding.strtolocal() to convert string to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35172
diff changeset
1010 timestr = encoding.strtolocal(timestr)
48046
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1011 if mode & 0o20000:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1012 mode = b'lnk'
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
1013 else:
48046
cedfe2606adf debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents: 48045
diff changeset
1014 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: 48045
diff changeset
1015 ui.write(b"%c %s %10d %s%s\n" % (state, mode, size, timestr, filename))
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
1016 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
1017 ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
30974
dad968920130 debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30973
diff changeset
1018
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1019
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1020 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1021 b'debugdiscovery',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1022 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1023 (b'', b'old', None, _(b'use old-style discovery')),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1024 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1025 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1026 b'nonheads',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1027 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1028 _(b'use old-style discovery with non-heads included'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1029 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1030 (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
1031 (b'', b'seed', b'12323', b'specify the random seed use for discovery'),
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1032 (
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1033 b'',
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1034 b'local-as-revs',
46783
b6ac612445e0 debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46782
diff changeset
1035 b"",
b6ac612445e0 debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46782
diff changeset
1036 b'treat local has having these revisions only',
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1037 ),
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1038 (
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1039 b'',
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1040 b'remote-as-revs',
46783
b6ac612445e0 debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46782
diff changeset
1041 b"",
b6ac612445e0 debugdiscovery: add missing byte string marker to some help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46782
diff changeset
1042 b'use local as remote, with only these these revisions',
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1043 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1044 ]
46781
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1045 + cmdutil.remoteopts
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1046 + cmdutil.formatteropts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1047 _(b'[--rev REV] [OTHER]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1048 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1049 def debugdiscovery(ui, repo, remoteurl=b"default", **opts):
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1050 """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: 46527
diff changeset
1051
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1052 The local peer can be "replaced" by a subset of the local repository by
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1053 using the `--local-as-revs` flag. Int he same way, usual `remote` peer can
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1054 be "replaced" by a subset of the local repository using the
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1055 `--local-as-revs` flag. This is useful to efficiently debug pathological
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1056 discovery situation.
46804
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1057
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1058 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: 46796
diff changeset
1059
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1060 * devel.discovery.exchange-heads=True
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1061
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1062 If False, the discovery will not start with
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1063 remote head fetching and local head querying.
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1064
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1065 * devel.discovery.grow-sample=True
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1066
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1067 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: 46796
diff changeset
1068 through the process
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1069
46806
2b1b8f3e6510 setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46804
diff changeset
1070 * devel.discovery.grow-sample.dynamic=True
2b1b8f3e6510 setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46804
diff changeset
1071
2b1b8f3e6510 setdiscovery: add a discovery.grow-sample.dynamic option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46804
diff changeset
1072 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: 46804
diff changeset
1073 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: 46804
diff changeset
1074 <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: 46804
diff changeset
1075
46804
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1076 * devel.discovery.grow-sample.rate=1.05
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1077
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1078 the rate at which the sample grow
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1079
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1080 * devel.discovery.randomize=True
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1081
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1082 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: 46796
diff changeset
1083 integration tests.
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1084
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1085 * devel.discovery.sample-size=200
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1086
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1087 Control the initial size of the discovery sample
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1088
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1089 * devel.discovery.sample-size.initial=100
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1090
13d973690ecd debugdiscovery: document relevant config option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46796
diff changeset
1091 Control the initial size of the discovery for initial change
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1092 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1093 opts = pycompat.byteskwargs(opts)
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1094 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: 46527
diff changeset
1095
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1096 # setup potential extra filtering
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1097 local_revs = opts[b"local_as_revs"]
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1098 remote_revs = opts[b"remote_as_revs"]
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1099
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1100 # make sure tests are repeatable
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1101 random.seed(int(opts[b'seed']))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1102
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1103 if not remote_revs:
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1104
46959
9e021cffb356 debugdiscovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46908
diff changeset
1105 remoteurl, branches = urlutil.get_unique_pull_path(
9e021cffb356 debugdiscovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46908
diff changeset
1106 b'debugdiscovery', repo, ui, remoteurl
9e021cffb356 debugdiscovery: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46908
diff changeset
1107 )
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1108 remote = hg.peer(repo, opts, remoteurl)
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
1109 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(remoteurl))
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1110 else:
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1111 branches = (None, [])
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
1112 remote_filtered_revs = logcmdutil.revrange(
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1113 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: 46527
diff changeset
1114 )
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1115 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: 46527
diff changeset
1116
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1117 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: 46527
diff changeset
1118 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: 46527
diff changeset
1119
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1120 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: 46527
diff changeset
1121
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1122 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: 46527
diff changeset
1123 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: 46527
diff changeset
1124
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1125 if local_revs:
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
1126 local_filtered_revs = logcmdutil.revrange(
46535
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1127 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: 46527
diff changeset
1128 )
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1129 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: 46527
diff changeset
1130
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1131 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: 46527
diff changeset
1132 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: 46527
diff changeset
1133
4f5e9a77ff7a debugdiscovery: add flags to run discovery on subsets of the local repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46527
diff changeset
1134 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: 46527
diff changeset
1135 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: 46527
diff changeset
1136
46111
d90f439ff19f debugdiscovery: display the number of roundtrip used
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46080
diff changeset
1137 data = {}
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1138 if opts.get(b'old'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1139
42031
d31d8c5279c6 debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42030
diff changeset
1140 def doit(pushedrevs, remoteheads, remote=remote):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1141 if not util.safehasattr(remote, b'branches'):
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1142 # enable in-client legacy support
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1143 remote = localrepo.locallegacypeer(remote.local())
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1144 common, _in, hds = treediscovery.findcommonincoming(
46111
d90f439ff19f debugdiscovery: display the number of roundtrip used
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46080
diff changeset
1145 repo, remote, force=True, audit=data
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1146 )
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1147 common = set(common)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1148 if not opts.get(b'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
1149 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1150 b"unpruned common: %s\n"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1151 % b" ".join(sorted(short(n) for n in common))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1152 )
39196
26f3d075f36e debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39194
diff changeset
1153
26f3d075f36e debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39194
diff changeset
1154 clnode = repo.changelog.node
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1155 common = repo.revs(b'heads(::%ln)', common)
39196
26f3d075f36e debugcommands: use a revset instead of dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39194
diff changeset
1156 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
1157 return common, hds
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1158
42031
d31d8c5279c6 debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42030
diff changeset
1159 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1160
42031
d31d8c5279c6 debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42030
diff changeset
1161 def doit(pushedrevs, remoteheads, remote=remote):
35313
f77121b6bf1b setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents: 35214
diff changeset
1162 nodes = None
f77121b6bf1b setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents: 35214
diff changeset
1163 if pushedrevs:
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
1164 revs = logcmdutil.revrange(repo, pushedrevs)
35313
f77121b6bf1b setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents: 35214
diff changeset
1165 nodes = [repo[r].node() for r in revs]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1166 common, any, hds = setdiscovery.findcommonheads(
46111
d90f439ff19f debugdiscovery: display the number of roundtrip used
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46080
diff changeset
1167 ui, repo, remote, ancestorsof=nodes, audit=data
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1168 )
42031
d31d8c5279c6 debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42030
diff changeset
1169 return common, hds
30526
a3ec6db36315 debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30525
diff changeset
1170
35426
fed2c040764e debugdiscovery: drop reference to non-existent --remote-head option
Martin von Zweigbergk <martinvonz@google.com>
parents: 35425
diff changeset
1171 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1172 localrevs = opts[b'rev']
46782
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1173
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1174 fm = ui.formatter(b'debugdiscovery', opts)
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1175 if fm.strict_format:
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1176
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1177 @contextlib.contextmanager
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1178 def may_capture_output():
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1179 ui.pushbuffer()
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1180 yield
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1181 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: 46781
diff changeset
1182
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1183 else:
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1184 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: 46781
diff changeset
1185 with may_capture_output():
67a2ecea8bd9 debugdiscovery: also integrate the discovery output in the json one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46781
diff changeset
1186 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: 46781
diff changeset
1187 common, hds = doit(localrevs, remoterevs)
42031
d31d8c5279c6 debugdiscovery: small internal refactoring
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42030
diff changeset
1188
42032
63165e4a76da debugdiscovery: display more statistic about the common set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42031
diff changeset
1189 # compute all statistics
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1190 heads_common = set(common)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1191 heads_remote = set(hds)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1192 heads_local = set(repo.heads())
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1193 # 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: 46064
diff changeset
1194 # itself a head of common.
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1195 heads_common_local = heads_common & heads_local
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1196 heads_common_remote = heads_common & heads_remote
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1197 heads_common_both = heads_common & heads_remote & heads_local
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1198
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1199 all = repo.revs(b'all()')
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1200 common = repo.revs(b'::%ln', common)
46079
3ca9d26c5984 debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46065
diff changeset
1201 roots_common = repo.revs(b'roots(::%ld)', common)
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1202 missing = repo.revs(b'not ::%ld', common)
46079
3ca9d26c5984 debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46065
diff changeset
1203 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: 46065
diff changeset
1204 roots_missing = repo.revs(b'roots(%ld)', missing)
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1205 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
1206
46080
0e5065b6baa0 debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46079
diff changeset
1207 initial_undecided = repo.revs(
0e5065b6baa0 debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46079
diff changeset
1208 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: 46079
diff changeset
1209 )
0e5065b6baa0 debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46079
diff changeset
1210 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: 46079
diff changeset
1211 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: 46079
diff changeset
1212 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: 46079
diff changeset
1213 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: 46079
diff changeset
1214
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1215 data[b'elapsed'] = t.elapsed
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1216 data[b'nb-common-heads'] = len(heads_common)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1217 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: 46064
diff changeset
1218 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: 46064
diff changeset
1219 data[b'nb-common-heads-both'] = len(heads_common_both)
46079
3ca9d26c5984 debugdiscovery: add some data about the shapes of the sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46065
diff changeset
1220 data[b'nb-common-roots'] = len(roots_common)
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1221 data[b'nb-head-local'] = len(heads_local)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1222 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: 46064
diff changeset
1223 data[b'nb-head-remote'] = len(heads_remote)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1224 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: 46064
diff changeset
1225 heads_common_remote
46064
24751551fe64 debugdiscovery: clarify internal key name in debugobsolete
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46034
diff changeset
1226 )
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1227 data[b'nb-revs'] = len(all)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1228 data[b'nb-revs-common'] = len(common)
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1229 data[b'nb-revs-missing'] = len(missing)
46112
9e24b3d8e896 debugdiscovery: fix swapped heads and roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46111
diff changeset
1230 data[b'nb-missing-heads'] = len(heads_missing)
9e24b3d8e896 debugdiscovery: fix swapped heads and roots
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46111
diff changeset
1231 data[b'nb-missing-roots'] = len(roots_missing)
46080
0e5065b6baa0 debugdiscovery: display some information about the initial "undecided" set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46079
diff changeset
1232 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: 46079
diff changeset
1233 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: 46079
diff changeset
1234 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: 46079
diff changeset
1235 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: 46079
diff changeset
1236 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
1237
46781
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1238 fm.startitem()
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1239 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
1240 # display discovery summary
46781
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1241 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: 46724
diff changeset
1242 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data)
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1243 fm.plain(b"heads summary:\n")
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1244 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: 46724
diff changeset
1245 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: 46724
diff changeset
1246 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: 46724
diff changeset
1247 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: 46724
diff changeset
1248 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: 46724
diff changeset
1249 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: 46724
diff changeset
1250 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: 46724
diff changeset
1251 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: 46724
diff changeset
1252 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: 46724
diff changeset
1253 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: 46724
diff changeset
1254 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: 46724
diff changeset
1255 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: 46724
diff changeset
1256 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: 46724
diff changeset
1257 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: 46724
diff changeset
1258 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: 46724
diff changeset
1259 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: 46724
diff changeset
1260 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: 46724
diff changeset
1261 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: 46724
diff changeset
1262 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: 46724
diff changeset
1263 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: 46724
diff changeset
1264 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: 46724
diff changeset
1265 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
1266
42034
fd8d13ea1bcc debugdiscovery: only list common heads on verbose
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42033
diff changeset
1267 if ui.verbose:
46781
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1268 fm.plain(
46065
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1269 b"common heads: %s\n"
44a52048c6d6 debugdiscovery: move various computation earlier
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46064
diff changeset
1270 % 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
1271 )
46781
3a8cf5b9c820 debugdiscovery: add support for Json output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46724
diff changeset
1272 fm.end()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1273
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1274
35562
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1275 _chunksize = 4 << 10
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1277
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1278 @command(
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1279 b'debugdownload',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1280 [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1281 (b'o', b'output', b'', _(b'path')),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1282 ],
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1283 optionalrepo=True,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1284 )
35730
05d415790761 debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents: 35728
diff changeset
1285 def debugdownload(ui, repo, url, output=None, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1286 """download a resource using Mercurial logic and config"""
35562
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1287 fh = urlmod.open(ui, url, output)
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1288
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1289 dest = ui
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1290 if output:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1291 dest = open(output, b"wb", _chunksize)
35562
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1292 try:
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1293 data = fh.read(_chunksize)
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1294 while data:
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1295 dest.write(data)
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1296 data = fh.read(_chunksize)
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1297 finally:
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1298 if output:
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1299 dest.close()
6580cf751418 debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents: 35518
diff changeset
1300
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1301
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1302 @command(b'debugextensions', cmdutil.formatteropts, [], optionalrepo=True)
38021
8ba0344f9fb1 debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents: 37986
diff changeset
1303 def debugextensions(ui, repo, **opts):
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1304 '''show information about active extensions'''
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1305 opts = pycompat.byteskwargs(opts)
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1306 exts = extensions.extensions(ui)
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1307 hgver = util.version()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1308 fm = ui.formatter(b'debugextensions', opts)
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1309 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: 30526
diff changeset
1310 isinternal = extensions.ismoduleinternal(extmod)
43727
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1311 extsource = None
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1312
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1313 if util.safehasattr(extmod, '__file__'):
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1314 extsource = pycompat.fsencode(extmod.__file__)
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1315 elif getattr(sys, 'oxidized', False):
f1dabf99db17 debugextensions: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43726
diff changeset
1316 extsource = pycompat.sysexecutable
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1317 if isinternal:
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1318 exttestedwith = [] # never expose magic string to users
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1319 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1320 exttestedwith = getattr(extmod, 'testedwith', b'').split()
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1321 extbuglink = getattr(extmod, 'buglink', None)
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1322
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1323 fm.startitem()
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1324
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1325 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
1326 fm.write(b'name', b'%s\n', extname)
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1327 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1328 fm.write(b'name', b'%s', extname)
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1329 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
1330 fm.plain(b'\n')
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1331 elif not exttestedwith:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1332 fm.plain(_(b' (untested!)\n'))
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1333 else:
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1334 lasttestedversion = exttestedwith[-1]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1335 fm.plain(b' (%s!)\n' % lasttestedversion)
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1336
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1337 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1338 ui.verbose and extsource,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1339 b'source',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1340 _(b' location: %s\n'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1341 extsource or b"",
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1342 )
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1343
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1344 if ui.verbose:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1345 fm.plain(_(b' bundled: %s\n') % [b'no', b'yes'][isinternal])
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1346 fm.data(bundled=isinternal)
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1347
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1348 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1349 ui.verbose and exttestedwith,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1350 b'testedwith',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1351 _(b' tested with: %s\n'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1352 fm.formatlist(exttestedwith, name=b'ver'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1353 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1354
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1355 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1356 ui.verbose and extbuglink,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1357 b'buglink',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1358 _(b' bug reporting: %s\n'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1359 extbuglink or b"",
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1360 )
30527
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1361
a8b17859684a debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30526
diff changeset
1362 fm.end()
30533
1ee358c3ed26 debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30528
diff changeset
1363
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1364
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1365 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1366 b'debugfileset',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1367 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1368 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1369 b'r',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1370 b'rev',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1371 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1372 _(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
1373 _(b'REV'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1374 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1375 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1376 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1377 b'all-files',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1378 False,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1379 _(b'test files from all revisions and working directory'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1380 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1381 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1382 b's',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1383 b'show-matcher',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1384 None,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1385 _(b'print internal representation of matcher'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1386 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1387 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1388 b'p',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1389 b'show-stage',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1390 [],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1391 _(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
1392 _(b'NAME'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1393 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1394 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1395 _(b'[-r REV] [--all-files] [OPTION]... FILESPEC'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1396 )
30533
1ee358c3ed26 debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30528
diff changeset
1397 def debugfileset(ui, repo, expr, **opts):
1ee358c3ed26 debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30528
diff changeset
1398 '''parse and apply a fileset specification'''
39010
4d992e3f10ba debugcommands: force import of fileset in debugfileset
Augie Fackler <augie@google.com>
parents: 38869
diff changeset
1399 from . import fileset
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1400
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1401 fileset.symbols # force import of fileset so we have predicates to optimize
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1402 opts = pycompat.byteskwargs(opts)
48130
5105a9975407 errors: raise InputError from revsingle() iff revset provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48128
diff changeset
1403 ctx = logcmdutil.revsingle(repo, opts.get(b'rev'), None)
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1404
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1405 stages = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1406 (b'parsed', pycompat.identity),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1407 (b'analyzed', filesetlang.analyze),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1408 (b'optimized', filesetlang.optimize),
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1409 ]
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44453
diff changeset
1410 stagenames = {n for n, f in stages}
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1411
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1412 showalways = set()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1413 if ui.verbose and not opts[b'show_stage']:
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1414 # 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
1415 showalways.add(b'parsed')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1416 if opts[b'show_stage'] == [b'all']:
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1417 showalways.update(stagenames)
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1418 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1419 for n in opts[b'show_stage']:
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1420 if n not in stagenames:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1421 raise error.Abort(_(b'invalid stage name: %s') % n)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1422 showalways.update(opts[b'show_stage'])
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1423
38845
b9162ea1b815 fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 38842
diff changeset
1424 tree = filesetlang.parse(expr)
38841
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1425 for n, f in stages:
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1426 tree = f(tree)
1d1c1645d7b9 debugfileset: backport --show-stage option from debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents: 38823
diff changeset
1427 if n in showalways:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1428 if opts[b'show_stage'] or n != b'parsed':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1429 ui.write(b"* %s:\n" % n)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1430 ui.write(filesetlang.prettyformat(tree), b"\n")
30533
1ee358c3ed26 debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30528
diff changeset
1431
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1432 files = set()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1433 if opts[b'all_files']:
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1434 for r in repo:
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1435 c = repo[r]
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1436 files.update(c.files())
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1437 files.update(c.substate)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1438 if opts[b'all_files'] or ctx.rev() is None:
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1439 wctx = repo[None]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1440 files.update(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1441 repo.dirstate.walk(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1442 scmutil.matchall(repo),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1443 subrepos=list(wctx.substate),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1444 unknown=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1445 ignored=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1446 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1447 )
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1448 files.update(wctx.substate)
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1449 else:
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1450 files.update(ctx.files())
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1451 files.update(ctx.substate)
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1452
44012
e685fac56693 match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents: 43977
diff changeset
1453 m = ctx.matchfileset(repo.getcwd(), expr)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1454 if opts[b'show_matcher'] or (opts[b'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
1455 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n')
38611
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1456 for f in sorted(files):
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1457 if not m(f):
3d8ef60569d8 fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents: 38600
diff changeset
1458 continue
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1459 ui.write(b"%s\n" % f)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1460
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1461
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1462 @command(
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1463 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
1464 [
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1465 (
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1466 b'',
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1467 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
1468 b'',
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1469 _(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
1470 _(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
1471 ),
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1472 (
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1473 b'',
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1474 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
1475 b'',
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1476 _(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
1477 _(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
1478 ),
47812
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1479 (
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1480 b'',
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1481 b'paranoid',
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1482 False,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1483 _(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: 47810
diff changeset
1484 ),
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1485 ]
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1486 + 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
1487 )
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1488 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
1489 """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
1490
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1491 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
1492 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
1493 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
1494
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1495 ```
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1496 <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
1497 ```
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1498
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1499 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
1500 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
1501 filename.
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1502
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1503 Note that this does *not* mean that this repairs future affected revisions,
48199
b669e40fbbd6 help: update help text for debug-repair-issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 48130
diff changeset
1504 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: 48130
diff changeset
1505 Mercurial 5.9.1.
47812
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1506
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1507 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: 47810
diff changeset
1508 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: 47810
diff changeset
1509 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: 47810
diff changeset
1510 method to test on large repositories as a fuzzing method of sorts.
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1511 """
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1512 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
1513 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
1514 )
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1515 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
1516 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
1517 from_report = opts.get('from_report')
47812
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1518 paranoid = opts.get('paranoid')
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1519 # 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
1520 # 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
1521
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1522 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
1523 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
1524 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
1525
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1526 rewrite.repair_issue6528(
47812
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1527 ui,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1528 repo,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1529 dry_run=dry_run,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1530 to_report=to_report,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1531 from_report=from_report,
855463b5fe49 debugcommands: add a `--paranoid` option to `debug-repair-issue-6528`
Raphaël Gomès <rgomes@octobus.net>
parents: 47810
diff changeset
1532 paranoid=paranoid,
47810
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1533 )
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1534
b30a53ffbf9b debugcommands: introduce a debug command to repair repos affected by issue6528
Raphaël Gomès <rgomes@octobus.net>
parents: 47683
diff changeset
1535
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1536 @command(b'debugformat', [] + cmdutil.formatteropts)
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1537 def debugformat(ui, repo, **opts):
35346
cfb403b92f43 debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents: 35345
diff changeset
1538 """display format information about the current repository
cfb403b92f43 debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents: 35345
diff changeset
1539
cfb403b92f43 debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents: 35345
diff changeset
1540 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: 35345
diff changeset
1541 Mercurial default."""
35408
cd3392cb5818 py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35407
diff changeset
1542 opts = pycompat.byteskwargs(opts)
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1543 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
1544 maxvariantlength = max(len(b'format-variant'), maxvariantlength)
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1545
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1546 def makeformatname(name):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1547 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
1548
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1549 fm = ui.formatter(b'debugformat', opts)
35387
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1550 if fm.isplain():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1551
35387
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1552 def formatvalue(value):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1553 if util.safehasattr(value, b'startswith'):
35387
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1554 return value
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1555 if value:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1556 return b'yes'
35387
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1557 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1558 return b'no'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1559
35387
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1560 else:
9144e898cad5 debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents: 35386
diff changeset
1561 formatvalue = pycompat.identity
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1562
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1563 fm.plain(b'format-variant')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1564 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
1565 fm.plain(b' repo')
35346
cfb403b92f43 debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents: 35345
diff changeset
1566 if ui.verbose:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1567 fm.plain(b' config default')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1568 fm.plain(b'\n')
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1569 for fv in upgrade.allformatvariant:
35386
c0b6fa74e007 debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents: 35348
diff changeset
1570 fm.startitem()
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1571 repovalue = fv.fromrepo(repo)
35346
cfb403b92f43 debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents: 35345
diff changeset
1572 configvalue = fv.fromconfig(repo)
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1573
35347
bd326f3e0e14 debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents: 35346
diff changeset
1574 if repovalue != configvalue:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1575 namelabel = b'formatvariant.name.mismatchconfig'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1576 repolabel = b'formatvariant.repo.mismatchconfig'
35347
bd326f3e0e14 debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents: 35346
diff changeset
1577 elif repovalue != fv.default:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1578 namelabel = b'formatvariant.name.mismatchdefault'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1579 repolabel = b'formatvariant.repo.mismatchdefault'
35347
bd326f3e0e14 debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents: 35346
diff changeset
1580 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1581 namelabel = b'formatvariant.name.uptodate'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1582 repolabel = b'formatvariant.repo.uptodate'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1583
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1584 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
1585 fm.write(b'repo', b' %3s', formatvalue(repovalue), label=repolabel)
35347
bd326f3e0e14 debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents: 35346
diff changeset
1586 if fv.default != configvalue:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1587 configlabel = b'formatvariant.config.special'
35347
bd326f3e0e14 debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents: 35346
diff changeset
1588 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1589 configlabel = b'formatvariant.config.default'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1590 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1591 ui.verbose,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1592 b'config',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1593 b' %6s',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1594 formatvalue(configvalue),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1595 label=configlabel,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1596 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1597 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1598 ui.verbose,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1599 b'default',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1600 b' %7s',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1601 formatvalue(fv.default),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1602 label=b'formatvariant.default',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1603 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1604 fm.plain(b'\n')
35386
c0b6fa74e007 debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents: 35348
diff changeset
1605 fm.end()
35345
c3e4f196b6e0 debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents: 35313
diff changeset
1606
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1607
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1608 @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
1609 def debugfsinfo(ui, path=b"."):
30534
86ebd2f61c31 debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30533
diff changeset
1610 """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
1611 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
1612 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
1613 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
1614 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
1615 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
1616 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
1617 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
1618 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
1619 )
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
1620 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
1621 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
1622 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1623 casesensitive = b'(unknown)'
31639
35738db2037a debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents: 31638
diff changeset
1624 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1625 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
1626 casesensitive = util.fscasesensitive(f.name) and b'yes' or b'no'
31639
35738db2037a debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents: 31638
diff changeset
1627 except OSError:
35738db2037a debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents: 31638
diff changeset
1628 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
1629 ui.writenoi18n(b'case-sensitive: %s\n' % casesensitive)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1630
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1631
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1632 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1633 b'debuggetbundle',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1634 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1635 (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
1636 (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
1637 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1638 b't',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1639 b'type',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1640 b'bzip2',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1641 _(b'bundle compression type to use'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1642 _(b'TYPE'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1643 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1644 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1645 _(b'REPO FILE [-H|-C ID]...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1646 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1647 )
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1648 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: 30534
diff changeset
1649 """retrieves a bundle from a repo
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1650
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1651 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: 30534
diff changeset
1652 given file.
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1653 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1654 opts = pycompat.byteskwargs(opts)
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1655 repo = hg.peer(ui, opts, repopath)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1656 if not repo.capable(b'getbundle'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1657 raise error.Abort(b"getbundle() not supported by target repository")
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1658 args = {}
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1659 if common:
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
1660 args['common'] = [bin(s) for s in common]
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1661 if head:
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
1662 args['heads'] = [bin(s) for s in head]
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1663 # TODO: get desired bundlecaps from command line.
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
1664 args['bundlecaps'] = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1665 bundle = repo.getbundle(b'debug', **args)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1666
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1667 bundletype = opts.get(b'type', b'bzip2').lower()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1668 btypes = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1669 b'none': b'HG10UN',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1670 b'bzip2': b'HG10BZ',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1671 b'gzip': b'HG10GZ',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1672 b'bundle2': b'HG20',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1673 }
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1674 bundletype = btypes.get(bundletype)
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1675 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
1676 raise error.Abort(_(b'unknown bundle type specified with --type'))
30535
9c10905f4b48 debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30534
diff changeset
1677 bundle2.writebundle(ui, bundle, bundlepath, bundletype)
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1678
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1679
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1680 @command(b'debugignore', [], b'[FILE]')
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1681 def debugignore(ui, repo, *files, **opts):
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1682 """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: 30535
diff changeset
1683
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1684 With no argument display the combined ignore pattern.
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1685
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1686 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: 30535
diff changeset
1687 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: 30535
diff changeset
1688 """
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1689 ignore = repo.dirstate._ignore
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1690 if not files:
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1691 # Show all the patterns
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1692 ui.write(b"%s\n" % pycompat.byterepr(ignore))
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1693 else:
33507
e9672de52a23 debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents: 33493
diff changeset
1694 m = scmutil.match(repo[None], pats=files)
41647
be8741d42836 debugignore: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents: 41529
diff changeset
1695 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
1696 for f in m.files():
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1697 nf = util.normpath(f)
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1698 ignored = None
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1699 ignoredata = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1700 if nf != b'.':
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1701 if ignore(nf):
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1702 ignored = nf
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1703 ignoredata = repo.dirstate._ignorefileandline(nf)
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1704 else:
43677
0b7733719d21 utils: move finddirs() to pathutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 43554
diff changeset
1705 for p in pathutil.finddirs(nf):
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1706 if ignore(p):
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1707 ignored = p
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1708 ignoredata = repo.dirstate._ignorefileandline(p)
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1709 break
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1710 if ignored:
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1711 if ignored == nf:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1712 ui.write(_(b"%s is ignored\n") % uipathfn(f))
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1713 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1714 ui.write(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1715 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1716 b"%s is ignored because of "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1717 b"containing directory %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1718 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1719 % (uipathfn(f), ignored)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1720 )
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1721 ignorefile, lineno, line = ignoredata
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1722 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1723 _(b"(ignore rule in %s, line %d: '%s')\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1724 % (ignorefile, lineno, line)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1725 )
30536
243ecbd4f5c9 debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30535
diff changeset
1726 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1727 ui.write(_(b"%s is not ignored\n") % uipathfn(f))
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1728
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1729
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1730 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1731 b'debugindex',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1732 cmdutil.debugrevlogopts + cmdutil.formatteropts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1733 _(b'-c|-m|FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1734 )
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1735 def debugindex(ui, repo, file_=None, **opts):
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1736 """dump index data for a storage primitive"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1737 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1738 store = cmdutil.openstorage(repo, b'debugindex', file_, opts)
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1739
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1740 if ui.debugflag:
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1741 shortfn = hex
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1742 else:
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1743 shortfn = short
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1744
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1745 idlen = 12
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1746 for i in store:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1747 idlen = len(shortfn(store.node(i)))
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1748 break
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1749
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1750 fm = ui.formatter(b'debugindex', opts)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1751 fm.plain(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1752 b' rev linkrev %s %s p2\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1753 % (b'nodeid'.ljust(idlen), b'p1'.ljust(idlen))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1754 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1755
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1756 for rev in store:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1757 node = store.node(rev)
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1758 parents = store.parents(node)
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1759
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1760 fm.startitem()
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1761 fm.write(b'rev', b'%6d ', rev)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1762 fm.write(b'linkrev', b'%7d ', store.linkrev(rev))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1763 fm.write(b'node', b'%s ', shortfn(node))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1764 fm.write(b'p1', b'%s ', shortfn(parents[0]))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1765 fm.write(b'p2', b'%s', shortfn(parents[1]))
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1766 fm.plain(b'\n')
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1767
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
1768 fm.end()
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1769
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1770
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1771 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1772 b'debugindexdot',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1773 cmdutil.debugrevlogopts,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1774 _(b'-c|-m|FILE'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1775 optionalrepo=True,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1776 )
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1777 def debugindexdot(ui, repo, file_=None, **opts):
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1778 """dump an index DAG as a graphviz dot file"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1779 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1780 r = cmdutil.openstorage(repo, b'debugindexdot', file_, opts)
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
1781 ui.writenoi18n(b"digraph G {\n")
30537
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1782 for i in r:
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1783 node = r.node(i)
22683f2f8100 debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30536
diff changeset
1784 pp = r.parents(node)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1785 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i))
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
1786 if pp[1] != repo.nullid:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1787 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
1788 ui.write(b"}\n")
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1789
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1790
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1791 @command(b'debugindexstats', [])
39981
d71e0ba34d9b debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents: 39957
diff changeset
1792 def debugindexstats(ui, repo):
d71e0ba34d9b debugcommands: add a debugindexstats command
Martin von Zweigbergk <martinvonz@google.com>
parents: 39957
diff changeset
1793 """show stats related to the changelog index"""
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
1794 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
1795 index = repo.changelog.index
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1796 if not util.safehasattr(index, b'stats'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1797 raise error.Abort(_(b'debugindexstats only works with native code'))
40365
4f37af86d5d5 debugcommands: avoid stack trace from debugindexstats in pure mode
Martin von Zweigbergk <martinvonz@google.com>
parents: 40174
diff changeset
1798 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
1799 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
1800
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1801
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1802 @command(b'debuginstall', [] + cmdutil.formatteropts, b'', norepo=True)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1803 def debuginstall(ui, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1804 """test Mercurial installation
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1805
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1806 Returns 0 on success.
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
1807 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
1808 opts = pycompat.byteskwargs(opts)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1809
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1810 problems = 0
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1811
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1812 fm = ui.formatter(b'debuginstall', opts)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1813 fm.startitem()
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1814
45100
d50d922ca02b debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents: 44929
diff changeset
1815 # encoding might be unknown or wrong. don't translate these messages.
d50d922ca02b debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents: 44929
diff changeset
1816 fm.write(b'encoding', b"checking encoding (%s)...\n", encoding.encoding)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1817 err = None
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1818 try:
34144
902219a99901 debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents: 34135
diff changeset
1819 codecs.lookup(pycompat.sysstr(encoding.encoding))
902219a99901 debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents: 34135
diff changeset
1820 except LookupError as inst:
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
1821 err = stringutil.forcebytestr(inst)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1822 problems += 1
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1823 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1824 err,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1825 b'encodingerror',
45100
d50d922ca02b debuginstall: don't translate encoding messages
Yuya Nishihara <yuya@tcha.org>
parents: 44929
diff changeset
1826 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
1827 err,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1828 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1829
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1830 # Python
43726
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1831 pythonlib = None
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1832 if util.safehasattr(os, '__file__'):
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1833 pythonlib = os.path.dirname(pycompat.fsencode(os.__file__))
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1834 elif getattr(sys, 'oxidized', False):
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1835 pythonlib = pycompat.sysexecutable
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1836
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1837 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1838 b'pythonexe',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1839 _(b"checking Python executable (%s)\n"),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1840 pycompat.sysexecutable or _(b"unknown"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1841 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1842 fm.write(
44230
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
1843 b'pythonimplementation',
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
1844 _(b"checking Python implementation (%s)\n"),
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
1845 pycompat.sysbytes(platform.python_implementation()),
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
1846 )
0b475b0b0344 debugcommands: add Python implementation to debuginstall
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44123
diff changeset
1847 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1848 b'pythonver',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1849 _(b"checking Python version (%s)\n"),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1850 (b"%d.%d.%d" % sys.version_info[:3]),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1851 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1852 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1853 b'pythonlib',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1854 _(b"checking Python lib (%s)...\n"),
43726
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1855 pythonlib or _(b"unknown"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1856 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1857
44481
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1858 try:
46413
521ac0d7047f typing: disable import error warnings that are already handled
Matt Harbison <matt_harbison@yahoo.com>
parents: 46396
diff changeset
1859 from . import rustext # pytype: disable=import-error
44481
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1860
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1861 rustext.__doc__ # trigger lazy import
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1862 except ImportError:
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1863 rustext = None
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1864
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1865 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
1866 if sslutil.hassni:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1867 security.add(b'sni')
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1868
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1869 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1870 b'pythonsecurity',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1871 _(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
1872 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
1873 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1874
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1875 # 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
1876 # may change in the future.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1877 if b'tls1.2' not in security:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1878 fm.plain(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1879 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1880 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
1881 b'network connections lack modern security\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1882 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1883 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1884 if b'sni' not in security:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1885 fm.plain(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1886 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1887 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
1888 b'connectivity issues with some servers\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1889 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1890 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1891
44481
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1892 fm.plain(
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1893 _(
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1894 b"checking Rust extensions (%s)\n"
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1895 % (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: 44470
diff changeset
1896 ),
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1897 )
295417387769 debuginstall: print if Rust extensions are installed
Raphaël Gomès <rgomes@octobus.net>
parents: 44470
diff changeset
1898
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1899 # 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
1900
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1901 # hg version
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1902 hgver = util.version()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1903 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1904 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
1905 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1906 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1907 b'hgverextra',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1908 _(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
1909 b'+'.join(hgver.split(b'+')[1:]),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1910 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1911
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1912 # compiled modules
43726
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1913 hgmodules = None
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1914 if util.safehasattr(sys.modules[__name__], '__file__'):
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1915 hgmodules = os.path.dirname(pycompat.fsencode(__file__))
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1916 elif getattr(sys, 'oxidized', False):
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1917 hgmodules = pycompat.sysexecutable
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1918
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1919 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1920 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
1921 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1922 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1923 b'hgmodules',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1924 _(b"checking installed modules (%s)...\n"),
43726
1fb19665c166 debuginstall: gracefully handle missing __file__ attributes
Matt Harbison <matt_harbison@yahoo.com>
parents: 43679
diff changeset
1925 hgmodules or _(b"unknown"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1926 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1927
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1928 rustandc = policy.policy in (b'rust+c', b'rust+c-allow')
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1929 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
1930 cext = policy.policy in (b'c', b'allow') or rustandc
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1931 nopure = cext or rustext
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1932 if nopure:
32249
85dc5a25f1fc debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents: 31864
diff changeset
1933 err = None
85dc5a25f1fc debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents: 31864
diff changeset
1934 try:
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1935 if cext:
43743
a9b14ef701d1 debugcommands: suppress import errors for pytype
Augie Fackler <augie@google.com>
parents: 43727
diff changeset
1936 from .cext import ( # pytype: disable=import-error
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1937 base85,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1938 bdiff,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1939 mpatch,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1940 osutil,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1941 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1942
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1943 # quiet pyflakes
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1944 dir(bdiff), dir(mpatch), dir(base85), dir(osutil)
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1945 if rustext:
43743
a9b14ef701d1 debugcommands: suppress import errors for pytype
Augie Fackler <augie@google.com>
parents: 43727
diff changeset
1946 from .rustext import ( # pytype: disable=import-error
42467
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1947 ancestor,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1948 dirstate,
810f66b468cd rust: module policy with importrust
Georges Racinet <georges.racinet@octobus.net>
parents: 42148
diff changeset
1949 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1950
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1951 dir(ancestor), dir(dirstate) # quiet pyflakes
32249
85dc5a25f1fc debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents: 31864
diff changeset
1952 except Exception as inst:
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
1953 err = stringutil.forcebytestr(inst)
32249
85dc5a25f1fc debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents: 31864
diff changeset
1954 problems += 1
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1955 fm.condwrite(err, b'extensionserror', b" %s\n", err)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1956
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1957 compengines = util.compengines._engines.values()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1958 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1959 b'compengines',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1960 _(b'checking registered compression engines (%s)\n'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1961 fm.formatlist(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1962 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
1963 name=b'compengine',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1964 fmt=b'%s',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1965 sep=b', ',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1966 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1967 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1968 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1969 b'compenginesavail',
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43116
diff changeset
1970 _(b'checking available compression engines (%s)\n'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1971 fm.formatlist(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1972 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
1973 name=b'compengine',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1974 fmt=b'%s',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1975 sep=b', ',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1976 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1977 )
42041
3e47d1ec9da5 util: extract compression code in `mercurial.utils.compression`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42035
diff changeset
1978 wirecompengines = compression.compengines.supportedwireengines(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1979 compression.SERVERROLE
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1980 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1981 fm.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1982 b'compenginesserver',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1983 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1984 b'checking available compression engines '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1985 b'for wire protocol (%s)\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1986 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1987 fm.formatlist(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1988 [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
1989 name=b'compengine',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1990 fmt=b'%s',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1991 sep=b', ',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1992 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
1993 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1994 re2 = b'missing'
35452
8251c4c4abdc debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents: 35431
diff changeset
1995 if util._re2:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1996 re2 = b'available'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1997 fm.plain(_(b'checking "re2" regexp engine (%s)\n') % re2)
35452
8251c4c4abdc debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents: 35431
diff changeset
1998 fm.data(re2=bool(util._re2))
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
1999
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2000 # templates
45235
91aa9bba3dc9 templater: make templatepaths() return a single path, or None
Martin von Zweigbergk <martinvonz@google.com>
parents: 45149
diff changeset
2001 p = templater.templatedir()
45247
d5ccc059fbcd templater: handle None returned from templatedir()
Martin von Zweigbergk <martinvonz@google.com>
parents: 45235
diff changeset
2002 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
2003 fm.condwrite(not p, b'', _(b" no template directories found\n"))
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2004 if p:
45341
4aa484efc926 templater: add exception-raising version of open_template()
Martin von Zweigbergk <martinvonz@google.com>
parents: 45330
diff changeset
2005 (m, fp) = templater.try_open_template(b"map-cmdline.default")
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2006 if m:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2007 # 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
2008 err = None
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2009 try:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2010 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
2011 except Exception as inst:
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
2012 err = stringutil.forcebytestr(inst)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2013 p = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2014 fm.condwrite(err, b'defaulttemplateerror', b" %s\n", err)
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2015 else:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2016 p = None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2017 fm.condwrite(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2018 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
2019 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2020 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2021 not m,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2022 b'defaulttemplatenotfound',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2023 _(b" template '%s' not found\n"),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2024 b"default",
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2025 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2026 if not p:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2027 problems += 1
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2028 fm.condwrite(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2029 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
2030 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2031
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2032 # editor
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2033 editor = ui.geteditor()
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2034 editor = util.expandpath(editor)
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37087
diff changeset
2035 editorbin = procutil.shellsplit(editor)[0]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2036 fm.write(b'editor', _(b"checking commit editor... (%s)\n"), editorbin)
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37087
diff changeset
2037 cmdpath = procutil.findexe(editorbin)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2038 fm.condwrite(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2039 not cmdpath and editor == b'vi',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2040 b'vinotfound',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2041 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2042 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
2043 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
2044 b" file)\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2045 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2046 not cmdpath and editor == b'vi' and editorbin,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2047 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2048 fm.condwrite(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2049 not cmdpath and editor != b'vi',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2050 b'editornotfound',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2051 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2052 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
2053 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
2054 b" file)\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2055 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2056 not cmdpath and editorbin,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2057 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2058 if not cmdpath and editor != b'vi':
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2059 problems += 1
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2060
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2061 # check username
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2062 username = None
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2063 err = None
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2064 try:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2065 username = ui.username()
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2066 except error.Abort as e:
45682
d2e1dcd4490d errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents: 45665
diff changeset
2067 err = e.message
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2068 problems += 1
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2069
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2070 fm.condwrite(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2071 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
2072 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2073 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2074 err,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2075 b'usernameerror',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2076 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2077 b"checking username...\n %s\n"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2078 b" (specify a username in your configuration file)\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2079 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2080 err,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2081 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2082
42683
7f1df7019497 debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents: 42580
diff changeset
2083 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
2084 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
2085 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
2086 problems += handler(ui, fm)
7f1df7019497 debugcommands: add support for extensions adding their own debug info
Augie Fackler <augie@google.com>
parents: 42580
diff changeset
2087
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2088 fm.condwrite(not problems, b'', _(b"no problems detected\n"))
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2089 if not problems:
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2090 fm.data(problems=problems)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2091 fm.condwrite(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2092 problems,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2093 b'problems',
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43116
diff changeset
2094 _(b"%d problems detected, please check your install!\n"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2095 problems,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2096 )
30938
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2097 fm.end()
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2098
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2099 return problems
fec3dbaa7f83 debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30775
diff changeset
2100
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2101
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2102 @command(b'debugknown', [], _(b'REPO ID...'), norepo=True)
30939
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2103 def debugknown(ui, repopath, *ids, **opts):
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2104 """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: 30938
diff changeset
2105
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2106 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: 30938
diff changeset
2107 and 1s indicating unknown/known.
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2108 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
2109 opts = pycompat.byteskwargs(opts)
30939
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2110 repo = hg.peer(ui, opts, repopath)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2111 if not repo.capable(b'known'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2112 raise error.Abort(b"known() not supported by target repository")
30939
e1fa5fe9f9d4 debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30938
diff changeset
2113 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
2114 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
2115
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2116
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2117 @command(b'debuglabelcomplete', [], _(b'LABEL...'))
30955
e46533c3201e debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30939
diff changeset
2118 def debuglabelcomplete(ui, repo, *args):
e46533c3201e debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30939
diff changeset
2119 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
31411
ea0395eec67b debuglabelcomplete: fix to call debugnamecomplete in new location
Kyle Lippincott <spectral@google.com>
parents: 31249
diff changeset
2120 debugnamecomplete(ui, repo, *args)
30955
e46533c3201e debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30939
diff changeset
2121
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2122
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2123 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2124 b'debuglocks',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2125 [
46237
bc884e31b8c8 debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46211
diff changeset
2126 (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
2127 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2128 b'W',
46237
bc884e31b8c8 debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46211
diff changeset
2129 b'force-free-wlock',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2130 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2131 _(b'free the working state lock (DANGEROUS)'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2132 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2133 (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
2134 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2135 b'S',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2136 b'set-wlock',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2137 None,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2138 _(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
2139 ),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2140 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2141 _(b'[OPTION]...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2142 )
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2143 def debuglocks(ui, repo, **opts):
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2144 """show or modify state of locks
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2145
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2146 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: 30957
diff changeset
2147 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: 30957
diff changeset
2148 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: 30957
diff changeset
2149 running if it's not local.
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2150
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2151 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: 30957
diff changeset
2152 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: 30957
diff changeset
2153 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: 30957
diff changeset
2154 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: 30957
diff changeset
2155
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2156 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: 30957
diff changeset
2157 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: 30957
diff changeset
2158 blocked by filesystem permissions.
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2159
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2160 Setting a lock will prevent other commands from changing the data.
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2161 The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2162 The set locks are removed when the command exits.
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2163
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2164 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: 30957
diff changeset
2165
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2166 """
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2167
46237
bc884e31b8c8 debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46211
diff changeset
2168 if opts.get('force_free_lock'):
48835
020378f32d57 debuglock: ignore ENOENT error when unlocking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48705
diff changeset
2169 repo.svfs.tryunlink(b'lock')
46237
bc884e31b8c8 debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46211
diff changeset
2170 if opts.get('force_free_wlock'):
48835
020378f32d57 debuglock: ignore ENOENT error when unlocking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48705
diff changeset
2171 repo.vfs.tryunlink(b'wlock')
46237
bc884e31b8c8 debuglock: rename flag names to better clarity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46211
diff changeset
2172 if opts.get('force_free_lock') or opts.get('force_free_wlock'):
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2173 return 0
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2174
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2175 locks = []
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2176 try:
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2177 if opts.get('set_wlock'):
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2178 try:
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2179 locks.append(repo.wlock(False))
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2180 except error.LockHeld:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2181 raise error.Abort(_(b'wlock is already held'))
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2182 if opts.get('set_lock'):
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2183 try:
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2184 locks.append(repo.lock(False))
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2185 except error.LockHeld:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2186 raise error.Abort(_(b'lock is already held'))
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2187 if len(locks):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2188 ui.promptchoice(_(b"ready to release the lock (y)? $$ &Yes"))
35402
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2189 return 0
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2190 finally:
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2191 release(*locks)
12055fb3ba30 debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents: 35401
diff changeset
2192
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2193 now = time.time()
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2194 held = 0
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2195
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2196 def report(vfs, name, method):
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2197 # 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: 30957
diff changeset
2198 try:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2199 l = method(False)
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2200 except error.LockHeld:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2201 l = None
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2202
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2203 if l:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2204 l.release()
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2205 else:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2206 try:
36789
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 36786
diff changeset
2207 st = vfs.lstat(name)
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 36786
diff changeset
2208 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: 36786
diff changeset
2209 user = util.username(st.st_uid)
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2210 locker = vfs.readlock(name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2211 if b":" in locker:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2212 host, pid = locker.split(b':')
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2213 if host == socket.gethostname():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2214 locker = b'user %s, process %s' % (user or b'None', pid)
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2215 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2216 locker = b'user %s, process %s, host %s' % (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2217 user or b'None',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2218 pid,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2219 host,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2220 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
2221 ui.writenoi18n(b"%-6s %s (%ds)\n" % (name + b":", locker, age))
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2222 return 1
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2223 except OSError as e:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2224 if e.errno != errno.ENOENT:
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2225 raise
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2226
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
2227 ui.writenoi18n(b"%-6s free\n" % (name + b":"))
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2228 return 0
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2229
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2230 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
2231 held += report(repo.vfs, b"wlock", repo.wlock)
30958
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2232
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2233 return held
23c801570449 debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30957
diff changeset
2234
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2235
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2236 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2237 b'debugmanifestfulltextcache',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2238 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2239 (b'', b'clear', False, _(b'clear the cache')),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2240 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2241 b'a',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2242 b'add',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2243 [],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2244 _(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
2245 _(b'NODE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2246 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2247 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2248 b'',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2249 )
41963
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2250 def debugmanifestfulltextcache(ui, repo, add=(), **opts):
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2251 """show, clear or amend the contents of the manifest fulltext cache"""
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2252
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2253 def getcache():
39272
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39196
diff changeset
2254 r = repo.manifestlog.getstorage(b'')
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2255 try:
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2256 return r._fulltextcache
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2257 except AttributeError:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2258 msg = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2259 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
2260 b"manifest fulltext cache\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2261 )
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2262 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: 41946
diff changeset
2263
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2264 if opts.get('clear'):
41969
d121823072b8 manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41964
diff changeset
2265 with repo.wlock():
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2266 cache = getcache()
41952
b74ef67573e5 manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41948
diff changeset
2267 cache.clear(clear_persisted_data=True)
b74ef67573e5 manifestcache: actually honor --clear
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41948
diff changeset
2268 return
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2269
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2270 if add:
41969
d121823072b8 manifestcache: protect write with `wlock` instead of `lock`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41964
diff changeset
2271 with repo.wlock():
41963
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2272 m = repo.manifestlog
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2273 store = m.getstorage(b'')
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2274 for n in add:
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2275 try:
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2276 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: 41952
diff changeset
2277 except error.LookupError as e:
46396
8408c3198ec1 debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents: 46237
diff changeset
2278 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
2279 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
2280 )
41963
1fe278aa4ad5 manifestcache: support multiple cache addition in one debug command run
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41952
diff changeset
2281 manifest.read() # stores revisision in cache too
41948
1e75311d78f7 manifestcache: do not display data when using --add
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41947
diff changeset
2282 return
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2283
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2284 cache = getcache()
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2285 if not len(cache):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2286 ui.write(_(b'cache empty\n'))
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2287 else:
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2288 ui.write(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2289 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2290 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
2291 b'least recent:\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2292 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2293 % (len(cache),)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2294 )
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2295 totalsize = 0
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2296 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: 41946
diff changeset
2297 # Use cache.get to not update the LRU order
41964
e3307243d188 manifestcache: stop altering the lru cache order while displaying it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41963
diff changeset
2298 data = cache.peek(nodeid)
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2299 size = len(data)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2300 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2301 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2302 _(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
2303 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2304 ondisk = cache._opener.stat(b'manifestfulltextcache').st_size
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2305 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2306 _(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
2307 % (util.bytecount(totalsize), util.bytecount(ondisk))
41947
fbee66c90cef manifestcache: only lock the repository if the debug command touch the cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41946
diff changeset
2308 )
38821
0a57945aaf7f manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents: 38707
diff changeset
2309
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2310
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2311 @command(b'debugmergestate', [] + cmdutil.templateopts, b'')
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2312 def debugmergestate(ui, repo, *args, **opts):
30956
8de38479d60b debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30955
diff changeset
2313 """print merge state
8de38479d60b debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30955
diff changeset
2314
8de38479d60b debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30955
diff changeset
2315 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: 30955
diff changeset
2316 was chosen."""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2317
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2318 if ui.verbose:
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2319 ms = mergestatemod.mergestate(repo)
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2320
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2321 # sort so that reasonable information is on top
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2322 v1records = ms._readrecordsv1()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2323 v2records = ms._readrecordsv2()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2324
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2325 if not v1records and not v2records:
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2326 pass
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2327 elif not v2records:
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2328 ui.writenoi18n(b'no version 2 merge state\n')
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2329 elif ms._v1v2match(v1records, v2records):
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2330 ui.writenoi18n(b'v1 and v2 states match: using v2\n')
30956
8de38479d60b debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30955
diff changeset
2331 else:
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2332 ui.writenoi18n(b'v1 and v2 states mismatch: using v1\n')
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2333
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2334 opts = pycompat.byteskwargs(opts)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2335 if not opts[b'template']:
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2336 opts[b'template'] = (
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2337 b'{if(commits, "", "no merge state found\n")}'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2338 b'{commits % "{name}{if(label, " ({label})")}: {node}\n"}'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2339 b'{files % "file: {path} (state \\"{state}\\")\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2340 b'{if(local_path, "'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2341 b' local path: {local_path} (hash {local_key}, flags \\"{local_flags}\\")\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2342 b' ancestor path: {ancestor_path} (node {ancestor_node})\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2343 b' other path: {other_path} (node {other_node})\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2344 b'")}'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2345 b'{if(rename_side, "'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2346 b' rename side: {rename_side}\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2347 b' renamed path: {renamed_path}\n'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2348 b'")}'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2349 b'{extras % " extra: {key} = {value}\n"}'
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2350 b'"}'
45456
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2351 b'{extras % "extra: {file} ({key} = {value})\n"}'
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2352 )
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2353
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2354 ms = mergestatemod.mergestate.read(repo)
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2355
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2356 fm = ui.formatter(b'debugmergestate', opts)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2357 fm.startitem()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2358
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2359 fm_commits = fm.nested(b'commits')
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2360 if ms.active():
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2361 for name, node, label_index in (
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2362 (b'local', ms.local, 0),
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2363 (b'other', ms.other, 1),
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2364 ):
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2365 fm_commits.startitem()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2366 fm_commits.data(name=name)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2367 fm_commits.data(node=hex(node))
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2368 if ms._labels and len(ms._labels) > label_index:
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2369 fm_commits.data(label=ms._labels[label_index])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2370 fm_commits.end()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2371
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2372 fm_files = fm.nested(b'files')
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2373 if ms.active():
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2374 for f in ms:
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2375 fm_files.startitem()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2376 fm_files.data(path=f)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2377 state = ms._state[f]
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2378 fm_files.data(state=state[0])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2379 if state[0] in (
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2380 mergestatemod.MERGE_RECORD_UNRESOLVED,
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2381 mergestatemod.MERGE_RECORD_RESOLVED,
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2382 ):
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2383 fm_files.data(local_key=state[1])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2384 fm_files.data(local_path=state[2])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2385 fm_files.data(ancestor_path=state[3])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2386 fm_files.data(ancestor_node=state[4])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2387 fm_files.data(other_path=state[5])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2388 fm_files.data(other_node=state[6])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2389 fm_files.data(local_flags=state[7])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2390 elif state[0] in (
44915
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2391 mergestatemod.MERGE_RECORD_UNRESOLVED_PATH,
b7808443ed6a mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents: 44662
diff changeset
2392 mergestatemod.MERGE_RECORD_RESOLVED_PATH,
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2393 ):
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2394 fm_files.data(renamed_path=state[1])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2395 fm_files.data(rename_side=state[2])
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2396 fm_extras = fm_files.nested(b'extras')
45457
00e4e97c6bc8 debugmergestate: sort extras before printing
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45456
diff changeset
2397 for k, v in sorted(ms.extras(f).items()):
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2398 fm_extras.startitem()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2399 fm_extras.data(key=k)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2400 fm_extras.data(value=v)
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2401 fm_extras.end()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2402
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2403 fm_files.end()
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2404
45456
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2405 fm_extras = fm.nested(b'extras')
45715
0428978bca22 mergestate: add `allextras()` to get all extras
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45682
diff changeset
2406 for f, d in sorted(pycompat.iteritems(ms.allextras())):
45456
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2407 if f in ms:
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2408 # 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: 45341
diff changeset
2409 continue
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2410 for k, v in pycompat.iteritems(d):
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2411 fm_extras.startitem()
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2412 fm_extras.data(file=f)
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2413 fm_extras.data(key=k)
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2414 fm_extras.data(value=v)
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2415 fm_extras.end()
766797f23f77 debugmergestate: show extras for files which are not in mergestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45341
diff changeset
2416
44427
acbfa31cfaf2 debugmergestate: make templated
Martin von Zweigbergk <martinvonz@google.com>
parents: 44397
diff changeset
2417 fm.end()
30956
8de38479d60b debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30955
diff changeset
2418
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2419
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2420 @command(b'debugnamecomplete', [], _(b'NAME...'))
30957
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2421 def debugnamecomplete(ui, repo, *args):
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2422 '''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: 30956
diff changeset
2423
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2424 names = set()
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2425 # 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: 30956
diff changeset
2426 # specially (after this for loop)
43106
d783f945a701 py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43094
diff changeset
2427 for name, ns in pycompat.iteritems(repo.names):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2428 if name != b'branches':
30957
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2429 names.update(ns.listnames(repo))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2430 names.update(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2431 tag
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2432 for (tag, heads, tip, closed) in repo.branchmap().iterbranches()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2433 if not closed
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2434 )
30957
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2435 completions = set()
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2436 if not args:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2437 args = [b'']
30957
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2438 for a in args:
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2439 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
2440 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
2441 ui.write(b'\n')
30957
a9aa67ba3f96 debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30956
diff changeset
2442
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2443
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2444 @command(
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2445 b'debugnodemap',
44352
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2446 [
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2447 (
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2448 b'',
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2449 b'dump-new',
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2450 False,
46527
3e3b81b6e7da debugcommands: s/stdin/stdout in debugnodemap help
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46464
diff changeset
2451 _(b'write a (new) persistent binary nodemap on stdout'),
44352
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2452 ),
46527
3e3b81b6e7da debugcommands: s/stdin/stdout in debugnodemap help
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46464
diff changeset
2453 (b'', b'dump-disk', False, _(b'dump on-disk data on stdout')),
44361
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2454 (
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2455 b'',
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2456 b'check',
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2457 False,
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2458 _(b'check that the data on disk data are correct.'),
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2459 ),
44368
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2460 (
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2461 b'',
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2462 b'metadata',
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2463 False,
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2464 _(b'display the on disk meta data for the nodemap'),
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2465 ),
44352
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2466 ],
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2467 )
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2468 def debugnodemap(ui, repo, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
2469 """write and inspect on disk nodemap"""
44352
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2470 if opts['dump_new']:
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2471 unfi = repo.unfiltered()
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2472 cl = unfi.changelog
44522
febe88a6f7f7 nodemap: use data from the index in debugnodemap --dump-new
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44481
diff changeset
2473 if util.safehasattr(cl.index, "nodemap_data_all"):
febe88a6f7f7 nodemap: use data from the index in debugnodemap --dump-new
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44481
diff changeset
2474 data = cl.index.nodemap_data_all()
febe88a6f7f7 nodemap: use data from the index in debugnodemap --dump-new
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44481
diff changeset
2475 else:
febe88a6f7f7 nodemap: use data from the index in debugnodemap --dump-new
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44481
diff changeset
2476 data = nodemap.persistent_data(cl.index)
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2477 ui.write(data)
44352
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2478 elif opts['dump_disk']:
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2479 unfi = repo.unfiltered()
6c07480d6659 nodemap: add a function to read the data from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44350
diff changeset
2480 cl = unfi.changelog
44366
76a96e3a2bbb nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44361
diff changeset
2481 nm_data = nodemap.persisted_data(cl)
76a96e3a2bbb nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44361
diff changeset
2482 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: 44361
diff changeset
2483 docket, data = nm_data
44397
f7459da77f23 nodemap: introduce an option to use mmap to read the nodemap mapping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44384
diff changeset
2484 ui.write(data[:])
44361
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2485 elif opts['check']:
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2486 unfi = repo.unfiltered()
20e125cdd719 nodemap: add basic checking of the on disk nodemap content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44352
diff changeset
2487 cl = unfi.changelog
44366
76a96e3a2bbb nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44361
diff changeset
2488 nm_data = nodemap.persisted_data(cl)
76a96e3a2bbb nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44361
diff changeset
2489 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: 44361
diff changeset
2490 docket, data = nm_data
76a96e3a2bbb nodemap: keep track of the docket for loaded data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44361
diff changeset
2491 return nodemap.check_data(ui, cl.index, data)
44368
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2492 elif opts['metadata']:
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2493 unfi = repo.unfiltered()
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2494 cl = unfi.changelog
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2495 nm_data = nodemap.persisted_data(cl)
6614b301ea58 nodemap: add a flag to dump the details of the docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44366
diff changeset
2496 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: 44366
diff changeset
2497 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: 44366
diff changeset
2498 ui.write((b"uid: %s\n") % docket.uid)
44369
e41a164db7a9 nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44368
diff changeset
2499 ui.write((b"tip-rev: %d\n") % docket.tip_rev)
44525
6c906eaedd0d nodemap: track the tip_node for validation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44522
diff changeset
2500 ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
44370
8374b69aef75 nodemap: track the total and unused amount of data in the rawdata file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44369
diff changeset
2501 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: 44369
diff changeset
2502 ui.write((b"data-unused: %d\n") % docket.data_unused)
44639
99ea74cbed74 nodemap: display percentage of unused in `hg debugnodemap`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44542
diff changeset
2503 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: 44542
diff changeset
2504 ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
44350
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2505
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2506
c577bb4a04d4 nodemap: have some python code writing a nodemap in persistent binary form
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44349
diff changeset
2507 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2508 b'debugobsolete',
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 (b'', b'flags', 0, _(b'markers flag')),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2511 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2512 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2513 b'record-parents',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2514 False,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2515 _(b'record parent information for the precursor'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2516 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2517 (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
2518 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2519 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2520 b'exclusive',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2521 False,
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43116
diff changeset
2522 _(b'restrict display to markers only relevant to REV'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2523 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2524 (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
2525 (b'', b'delete', [], _(b'delete markers specified by indices')),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2526 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2527 + cmdutil.commitopts2
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2528 + cmdutil.formatteropts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2529 _(b'[OBSOLETED [REPLACEMENT ...]]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2530 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2531 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: 30958
diff changeset
2532 """create arbitrary obsolete marker
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2533
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2534 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: 30958
diff changeset
2535
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
2536 opts = pycompat.byteskwargs(opts)
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
2537
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2538 def parsenodeid(s):
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2539 try:
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2540 # 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: 30958
diff changeset
2541 # 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: 30958
diff changeset
2542 # local repository.
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2543 n = bin(s)
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
2544 if len(n) != repo.nodeconstants.nodelen:
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2545 raise TypeError()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2546 return n
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2547 except TypeError:
45889
1a72e4839795 errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents: 45880
diff changeset
2548 raise error.InputError(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2549 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
2550 b'node identifiers'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2551 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2552
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2553 if opts.get(b'delete'):
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2554 indices = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2555 for v in opts.get(b'delete'):
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2556 try:
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2557 indices.append(int(v))
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2558 except ValueError:
45889
1a72e4839795 errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents: 45880
diff changeset
2559 raise error.InputError(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2560 _(b'invalid index value: %r') % v,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2561 hint=_(b'use integers for indices'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2562 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2563
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2564 if repo.currenttransaction():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2565 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
2566 _(b'cannot delete obsmarkers in the middle of transaction.')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2567 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2568
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2569 with repo.lock():
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2570 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
2571 ui.write(_(b'deleted %i obsolescence markers\n') % n)
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2572
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2573 return
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2574
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2575 if precursor is not None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2576 if opts[b'rev']:
45889
1a72e4839795 errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents: 45880
diff changeset
2577 raise error.InputError(
1a72e4839795 errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents: 45880
diff changeset
2578 b'cannot select revision when creating marker'
1a72e4839795 errors: raise InputError in `hg debugobsolete`
Martin von Zweigbergk <martinvonz@google.com>
parents: 45880
diff changeset
2579 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2580 metadata = {}
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2581 metadata[b'user'] = encoding.fromlocal(opts[b'user'] or ui.username())
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2582 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: 30958
diff changeset
2583 l = repo.lock()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2584 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2585 tr = repo.transaction(b'debugobsolete')
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2586 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2587 date = opts.get(b'date')
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2588 if date:
36636
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36616
diff changeset
2589 date = dateutil.parsedate(date)
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2590 else:
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2591 date = None
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2592 prec = parsenodeid(precursor)
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2593 parents = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2594 if opts[b'record_parents']:
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2595 if prec not in repo.unfiltered():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2596 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2597 b'cannot used --record-parents on '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2598 b'unknown changesets'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2599 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2600 parents = repo.unfiltered()[prec].parents()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2601 parents = tuple(p.node() for p in parents)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2602 repo.obsstore.create(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2603 tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2604 prec,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2605 succs,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2606 opts[b'flags'],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2607 parents=parents,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2608 date=date,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2609 metadata=metadata,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2610 ui=ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2611 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2612 tr.close()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2613 except ValueError as exc:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2614 raise error.Abort(
46396
8408c3198ec1 debug: convert a few exceptions to bytes before wrapping in another error
Matt Harbison <matt_harbison@yahoo.com>
parents: 46237
diff changeset
2615 _(b'bad obsmarker input: %s') % stringutil.forcebytestr(exc)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2616 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2617 finally:
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2618 tr.release()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2619 finally:
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2620 l.release()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2621 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2622 if opts[b'rev']:
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
2623 revs = logcmdutil.revrange(repo, opts[b'rev'])
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2624 nodes = [repo[r].node() for r in revs]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2625 markers = list(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2626 obsutil.getmarkers(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2627 repo, nodes=nodes, exclusive=opts[b'exclusive']
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2628 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2629 )
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2630 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: 30958
diff changeset
2631 else:
33155
a14e2e7f7d1f obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33154
diff changeset
2632 markers = obsutil.getmarkers(repo)
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2633
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2634 markerstoiter = markers
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2635 isrelevant = lambda m: True
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2636 if opts.get(b'rev') and opts.get(b'index'):
33155
a14e2e7f7d1f obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33154
diff changeset
2637 markerstoiter = obsutil.getmarkers(repo)
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2638 markerset = set(markers)
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2639 isrelevant = lambda m: m in markerset
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2640
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2641 fm = ui.formatter(b'debugobsolete', opts)
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2642 for i, m in enumerate(markerstoiter):
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2643 if not isrelevant(m):
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2644 # 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: 30958
diff changeset
2645 # 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: 30958
diff changeset
2646 # 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: 30958
diff changeset
2647 # 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: 30958
diff changeset
2648 # 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: 30958
diff changeset
2649 # 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: 30958
diff changeset
2650 # are relevant to --rev value
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2651 continue
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2652 fm.startitem()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2653 ind = i if opts.get(b'index') else None
30959
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2654 cmdutil.showmarker(fm, m, index=ind)
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2655 fm.end()
9e39d196cdf5 debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30958
diff changeset
2656
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2657
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2658 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2659 b'debugp1copies',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2660 [(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
2661 _(b'[-r REV]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2662 )
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2663 def debugp1copies(ui, repo, **opts):
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2664 """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: 41758
diff changeset
2665
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2666 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2667 ctx = scmutil.revsingle(repo, opts.get(b'rev'), default=None)
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2668 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
2669 ui.write(b'%s -> %s\n' % (src, dst))
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2670
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2671
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2672 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2673 b'debugp2copies',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2674 [(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
2675 _(b'[-r REV]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2676 )
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2677 def debugp1copies(ui, repo, **opts):
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2678 """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: 41758
diff changeset
2679
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2680 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2681 ctx = scmutil.revsingle(repo, opts.get(b'rev'), default=None)
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2682 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
2683 ui.write(b'%s -> %s\n' % (src, dst))
41764
a4358f7345b4 context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents: 41758
diff changeset
2684
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2685
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2686 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2687 b'debugpathcomplete',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2688 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2689 (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
2690 (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
2691 (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
2692 (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
2693 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2694 _(b'FILESPEC...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2695 )
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2696 def debugpathcomplete(ui, repo, *specs, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
2697 """complete part or all of a tracked path
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2698
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2699 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: 30959
diff changeset
2700 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: 30959
diff changeset
2701
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2702 Completion extends only to the next path segment unless
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
2703 --full is specified, in which case entire paths are used."""
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2704
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2705 def complete(path, acceptable):
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2706 dirstate = repo.dirstate
39823
24e493ec2229 py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents: 39776
diff changeset
2707 spec = os.path.normpath(os.path.join(encoding.getcwd(), path))
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2708 rootdir = repo.root + pycompat.ossep
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2709 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: 30959
diff changeset
2710 return [], []
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2711 if os.path.isdir(spec):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2712 spec += b'/'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2713 spec = spec[len(rootdir) :]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2714 fixpaths = pycompat.ossep != b'/'
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2715 if fixpaths:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2716 spec = spec.replace(pycompat.ossep, b'/')
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2717 speclen = len(spec)
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2718 fullpaths = opts['full']
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2719 files, dirs = set(), set()
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2720 adddir, addfile = dirs.add, files.add
43106
d783f945a701 py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43094
diff changeset
2721 for f, st in pycompat.iteritems(dirstate):
47544
5363610f61ef dirstate-item: use the `state` property in debugpathcomplete
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47444
diff changeset
2722 if f.startswith(spec) and st.state in acceptable:
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2723 if fixpaths:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2724 f = f.replace(b'/', pycompat.ossep)
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2725 if fullpaths:
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2726 addfile(f)
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2727 continue
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2728 s = f.find(pycompat.ossep, speclen)
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2729 if s >= 0:
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2730 adddir(f[:s])
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2731 else:
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2732 addfile(f)
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2733 return files, dirs
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2734
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2735 acceptable = b''
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2736 if opts['normal']:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2737 acceptable += b'nm'
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2738 if opts['added']:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2739 acceptable += b'a'
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2740 if opts['removed']:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2741 acceptable += b'r'
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2742 cwd = repo.getcwd()
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2743 if not specs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2744 specs = [b'.']
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2745
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2746 files, dirs = set(), set()
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2747 for spec in specs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2748 f, d = complete(spec, acceptable or b'nmar')
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2749 files.update(f)
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2750 dirs.update(d)
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2751 files.update(dirs)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2752 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
2753 ui.write(b'\n')
30960
c8081ea63591 debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30959
diff changeset
2754
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2755
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2756 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2757 b'debugpathcopies',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2758 cmdutil.walkopts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2759 b'hg debugpathcopies REV1 REV2 [FILE]',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2760 inferrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2761 )
41529
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
2762 def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts):
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
2763 """show copies between two revisions"""
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
2764 ctx1 = scmutil.revsingle(repo, rev1)
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
2765 ctx2 = scmutil.revsingle(repo, rev2)
7dc160a57025 debugcommands: add a debugpathcopies command
Martin von Zweigbergk <martinvonz@google.com>
parents: 41387
diff changeset
2766 m = scmutil.match(ctx1, pats, opts)
41758
f96988680afe debugpathcopies: sort output so it's deterministic
Martin von Zweigbergk <martinvonz@google.com>
parents: 41702
diff changeset
2767 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
2768 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
2769
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2770
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2771 @command(b'debugpeer', [], _(b'PATH'), norepo=True)
35969
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2772 def debugpeer(ui, path):
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2773 """establish a connection to a peer repository"""
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2774 # Always enable peer request logging. Requires --debug to display
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2775 # though.
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2776 overrides = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2777 (b'devel', b'debug.peer-request'): True,
35969
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2778 }
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2779
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2780 with ui.configoverride(overrides):
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2781 peer = hg.peer(ui, {}, path)
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2782
46702
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2783 try:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2784 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: 46694
diff changeset
2785 canpush = peer.canpush()
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2786
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2787 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: 46694
diff changeset
2788 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: 46694
diff changeset
2789 ui.write(
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2790 _(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: 46694
diff changeset
2791 )
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2792 finally:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2793 peer.close()
35969
5f029d03cf71 debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35942
diff changeset
2794
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2795
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2796 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2797 b'debugpickmergetool',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2798 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2799 (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
2800 (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
2801 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2802 + cmdutil.walkopts
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2803 + cmdutil.mergetoolopts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2804 _(b'[PATTERN]...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2805 inferrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2806 )
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2807 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: 32269
diff changeset
2808 """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: 32269
diff changeset
2809
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2810 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: 32269
diff changeset
2811 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: 32269
diff changeset
2812 chosen for specified file.
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2813
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2814 1. ``--tool`` option
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2815 2. ``HGMERGE`` environment variable
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2816 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: 32269
diff changeset
2817 4. configuration of ``ui.merge``
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2818 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: 32269
diff changeset
2819 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: 32269
diff changeset
2820 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: 32269
diff changeset
2821
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2822 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: 32269
diff changeset
2823
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2824 FILE = MERGETOOL
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2825
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2826 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: 32269
diff changeset
2827 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: 32269
diff changeset
2828 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: 32269
diff changeset
2829 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: 32269
diff changeset
2830
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2831 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: 32269
diff changeset
2832 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: 32269
diff changeset
2833 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: 32269
diff changeset
2834 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: 32269
diff changeset
2835 to configurations in hgrc.
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2836
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2837 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: 32269
diff changeset
2838 first (only if specified).
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2839
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2840 - ``--tool`` option
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2841 - ``HGMERGE`` environment variable
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2842 - configuration of ``ui.merge``
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2843
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2844 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: 32269
diff changeset
2845 ``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: 32269
diff changeset
2846 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: 32269
diff changeset
2847 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: 32269
diff changeset
2848 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
2849 opts = pycompat.byteskwargs(opts)
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2850 overrides = {}
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2851 if opts[b'tool']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2852 overrides[(b'ui', b'forcemerge')] = opts[b'tool']
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
2853 ui.notenoi18n(b'with --tool %r\n' % (pycompat.bytestr(opts[b'tool'])))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2854
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2855 with ui.configoverride(overrides, b'debugmergepatterns'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2856 hgmerge = encoding.environ.get(b"HGMERGE")
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2857 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
2858 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
2859 uimerge = ui.config(b"ui", b"merge")
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2860 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
2861 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
2862
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2863 ctx = scmutil.revsingle(repo, opts.get(b'rev'))
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2864 m = scmutil.match(ctx, pats, opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2865 changedelete = opts[b'changedelete']
32296
9bc36198338e debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32269
diff changeset
2866 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: 32269
diff changeset
2867 fctx = ctx[path]
47443
7a430116f639 ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents: 47357
diff changeset
2868 with ui.silent(
7a430116f639 ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents: 47357
diff changeset
2869 error=True
7a430116f639 ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents: 47357
diff changeset
2870 ) if not ui.debugflag else util.nullcontextmanager():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2871 tool, toolpath = filemerge._picktool(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2872 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2873 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2874 path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2875 fctx.isbinary(),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2876 b'l' in fctx.flags(),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2877 changedelete,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2878 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2879 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
2880
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2881
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2882 @command(b'debugpushkey', [], _(b'REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
30966
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2883 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
2884 """access the pushkey key/value protocol
30966
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2885
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2886 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: 30960
diff changeset
2887
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2888 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: 30960
diff changeset
2889 Reports success or failure.
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
2890 """
30966
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2891
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2892 target = hg.peer(ui, {}, repopath)
46702
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2893 try:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2894 if keyinfo:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2895 key, old, new = keyinfo
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2896 with target.commandexecutor() as e:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2897 r = e.callcommand(
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2898 b'pushkey',
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2899 {
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2900 b'namespace': namespace,
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2901 b'key': key,
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2902 b'old': old,
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2903 b'new': new,
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2904 },
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2905 ).result()
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2906
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2907 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: 46694
diff changeset
2908 return not r
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2909 else:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2910 for k, v in sorted(pycompat.iteritems(target.listkeys(namespace))):
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2911 ui.write(
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2912 b"%s\t%s\n"
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2913 % (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: 46694
diff changeset
2914 )
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2915 finally:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
2916 target.close()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2917
30966
7103122495e2 debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30960
diff changeset
2918
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2919 @command(b'debugpvec', [], _(b'A B'))
30967
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2920 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: 30966
diff changeset
2921 ca = scmutil.revsingle(repo, a)
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2922 cb = scmutil.revsingle(repo, b)
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2923 pa = pvec.ctxpvec(ca)
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2924 pb = pvec.ctxpvec(cb)
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2925 if pa == pb:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2926 rel = b"="
30967
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2927 elif pa > pb:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2928 rel = b">"
30967
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2929 elif pa < pb:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2930 rel = b"<"
30967
3c766ca89377 debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30966
diff changeset
2931 elif pa | pb:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2932 rel = b"|"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2933 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
2934 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
2935 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
2936 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2937 _(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
2938 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2939 abs(pa._depth - pb._depth),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2940 pvec._hamming(pa._vec, pb._vec),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2941 pa.distance(pb),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2942 rel,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2943 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2944 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2945
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2946
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2947 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2948 b'debugrebuilddirstate|debugrebuildstate',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2949 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2950 (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
2951 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2952 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2953 b'minimal',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2954 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2955 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2956 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
2957 b'the working copy parent'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2958 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2959 ),
30968
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2960 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2961 _(b'[-r REV]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2962 )
30968
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2963 def debugrebuilddirstate(ui, repo, rev, **opts):
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2964 """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: 30967
diff changeset
2965
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2966 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: 30967
diff changeset
2967
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2968 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: 30967
diff changeset
2969 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: 30967
diff changeset
2970 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: 30967
diff changeset
2971
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2972 ``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: 30967
diff changeset
2973 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: 30967
diff changeset
2974 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: 30967
diff changeset
2975 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: 30967
diff changeset
2976
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2977 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: 30967
diff changeset
2978 check the actual file content.
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2979 """
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2980 ctx = scmutil.revsingle(repo, rev)
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2981 with repo.wlock():
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2982 dirstate = repo.dirstate
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2983 changedfiles = None
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2984 # See command doc for what minimal does.
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
2985 if opts.get('minimal'):
30968
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2986 manifestfiles = set(ctx.manifest().keys())
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2987 dirstatefiles = set(dirstate)
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2988 manifestonly = manifestfiles - dirstatefiles
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2989 dsonly = dirstatefiles - manifestfiles
48113
78e66649cdb3 dirstate-item: use `added` in debugrebuilddirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48101
diff changeset
2990 dsnotadded = {f for f in dsonly if not dirstate.get_entry(f).added}
30968
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2991 changedfiles = manifestonly | dsnotadded
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2992
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2993 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
cc2b537b1966 debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30967
diff changeset
2994
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
2995
47916
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
2996 @command(
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
2997 b'debugrebuildfncache',
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
2998 [
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
2999 (
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3000 b'',
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3001 b'only-data',
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3002 False,
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3003 _(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: 47812
diff changeset
3004 )
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3005 ],
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3006 b'',
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3007 )
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3008 def debugrebuildfncache(ui, repo, **opts):
30969
e7d7335819f4 debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30968
diff changeset
3009 """rebuild the fncache file"""
47916
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3010 opts = pycompat.byteskwargs(opts)
0fb328bb2459 debugrebuildfncache: add a cheaper option to rebuild the fncache
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 47812
diff changeset
3011 repair.rebuildfncache(ui, repo, opts.get(b"only_data"))
30969
e7d7335819f4 debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30968
diff changeset
3012
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3013
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3014 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3015 b'debugrename',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3016 [(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
3017 _(b'[-r REV] [FILE]...'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3018 )
41701
ea72da71ad69 debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents: 41682
diff changeset
3019 def debugrename(ui, repo, *pats, **opts):
30970
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3020 """dump rename information"""
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3021
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
3022 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3023 ctx = scmutil.revsingle(repo, opts.get(b'rev'))
41701
ea72da71ad69 debugrename: don't require at least one path
Martin von Zweigbergk <martinvonz@google.com>
parents: 41682
diff changeset
3024 m = scmutil.match(ctx, pats, opts)
30970
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3025 for abs in ctx.walk(m):
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3026 fctx = ctx[abs]
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3027 o = fctx.filelog().renamed(fctx.filenode())
41670
ecf7f4ef52fb debugwalk: avoid match.rel() and use repo.pathto() instead
Martin von Zweigbergk <martinvonz@google.com>
parents: 41647
diff changeset
3028 rel = repo.pathto(abs)
30970
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3029 if o:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3030 ui.write(_(b"%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
30970
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3031 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3032 ui.write(_(b"%s not renamed\n") % rel)
30970
7236f949ce3f debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30969
diff changeset
3033
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3034
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3035 @command(b'debugrequires|debugrequirements', [], b'')
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3036 def debugrequirements(ui, repo):
47031
f38bf44e077f black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents: 47030
diff changeset
3037 """print the current repo requirements"""
45107
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3038 for r in sorted(repo.requirements):
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3039 ui.write(b"%s\n" % r)
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3040
4a28f5e8408e debugcommands: introduce new debugrequirements command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45100
diff changeset
3041
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3042 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3043 b'debugrevlog',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3044 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
3045 _(b'-c|-m|FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3046 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3047 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3048 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: 30970
diff changeset
3049 """show data and statistics about a revlog"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
3050 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3051 r = cmdutil.openrevlog(repo, b'debugrevlog', file_, opts)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3052
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3053 if opts.get(b"dump"):
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3054 numrevs = len(r)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3055 ui.write(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3056 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3057 b"# rev p1rev p2rev start end deltastart base p1 p2"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3058 b" rawsize totalsize compression heads chainlen\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3059 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3060 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3061 ts = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3062 heads = set()
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3063
38823
e7aa113b14f7 global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38821
diff changeset
3064 for rev in pycompat.xrange(numrevs):
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3065 dbase = r.deltaparent(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3066 if dbase == -1:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3067 dbase = rev
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3068 cbase = r.chainbase(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3069 clen = r.chainlen(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3070 p1, p2 = r.parentrevs(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3071 rs = r.rawsize(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3072 ts = ts + rs
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3073 heads -= set(r.parentrevs(rev))
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3074 heads.add(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3075 try:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3076 compression = ts / r.end(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3077 except ZeroDivisionError:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3078 compression = 0
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3079 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3080 b"%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3081 b"%11d %5d %8d\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3082 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3083 rev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3084 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3085 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3086 r.start(rev),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3087 r.end(rev),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3088 r.start(dbase),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3089 r.start(cbase),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3090 r.start(p1),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3091 r.start(p2),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3092 rs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3093 ts,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3094 compression,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3095 len(heads),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3096 clen,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3097 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3098 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3099 return 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3100
47153
f58a13c52726 revlog: split the `version` attribute into its two components
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47151
diff changeset
3101 format = r._format_version
f58a13c52726 revlog: split the `version` attribute into its two components
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47151
diff changeset
3102 v = r._format_flags
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3103 flags = []
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3104 gdelta = False
32355
67026d65a4fc revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32305
diff changeset
3105 if v & revlog.FLAG_INLINE_DATA:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3106 flags.append(b'inline')
32355
67026d65a4fc revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32305
diff changeset
3107 if v & revlog.FLAG_GENERALDELTA:
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3108 gdelta = True
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3109 flags.append(b'generaldelta')
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3110 if not flags:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3111 flags = [b'(none)']
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3112
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3113 ### tracks merge vs single parent
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3114 nummerges = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3115
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3116 ### tracks ways the "delta" are build
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3117 # nodelta
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3118 numempty = 0
39119
a456c603a83d debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents: 39118
diff changeset
3119 numemptytext = 0
a456c603a83d debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents: 39118
diff changeset
3120 numemptydelta = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3121 # full file content
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3122 numfull = 0
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3123 # intermediate snapshot against a prior snapshot
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3124 numsemi = 0
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3125 # snapshot count per depth
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3126 numsnapdepth = collections.defaultdict(lambda: 0)
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3127 # delta against previous revision
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3128 numprev = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3129 # delta against first or second parent (not prev)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3130 nump1 = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3131 nump2 = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3132 # delta against neither prev nor parents
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3133 numother = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3134 # delta against prev that are also first or second parent
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3135 # (details of `numprev`)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3136 nump1prev = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3137 nump2prev = 0
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3138
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3139 # data about delta chain of each revs
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3140 chainlengths = []
33069
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3141 chainbases = []
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3142 chainspans = []
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3143
39117
5c99486fcfe1 debugrevlog: document some of the variable used
Boris Feld <boris.feld@octobus.net>
parents: 39102
diff changeset
3144 # data about each revision
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3145 datasize = [None, 0, 0]
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3146 fullsize = [None, 0, 0]
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3147 semisize = [None, 0, 0]
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3148 # snapshot count per depth
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3149 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3150 deltasize = [None, 0, 0]
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3151 chunktypecounts = {}
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3152 chunktypesizes = {}
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3153
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3154 def addsize(size, l):
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3155 if l[0] is None or size < l[0]:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3156 l[0] = size
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3157 if size > l[1]:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3158 l[1] = size
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3159 l[2] += size
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3160
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3161 numrevs = len(r)
38823
e7aa113b14f7 global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38821
diff changeset
3162 for rev in pycompat.xrange(numrevs):
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3163 p1, p2 = r.parentrevs(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3164 delta = r.deltaparent(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3165 if format > 0:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3166 addsize(r.rawsize(rev), datasize)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3167 if p2 != nullrev:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3168 nummerges += 1
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3169 size = r.length(rev)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3170 if delta == nullrev:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3171 chainlengths.append(0)
33069
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3172 chainbases.append(r.start(rev))
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3173 chainspans.append(size)
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3174 if size == 0:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3175 numempty += 1
39119
a456c603a83d debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents: 39118
diff changeset
3176 numemptytext += 1
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3177 else:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3178 numfull += 1
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3179 numsnapdepth[0] += 1
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3180 addsize(size, fullsize)
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3181 addsize(size, snapsizedepth[0])
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3182 else:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3183 chainlengths.append(chainlengths[delta] + 1)
33069
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3184 baseaddr = chainbases[delta]
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3185 revaddr = r.start(rev)
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3186 chainbases.append(baseaddr)
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3187 chainspans.append((revaddr - baseaddr) + size)
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3188 if size == 0:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3189 numempty += 1
39119
a456c603a83d debugrevlog: display details about empty revision
Boris Feld <boris.feld@octobus.net>
parents: 39118
diff changeset
3190 numemptydelta += 1
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3191 elif r.issnapshot(rev):
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3192 addsize(size, semisize)
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3193 numsemi += 1
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3194 depth = r.snapshotdepth(rev)
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3195 numsnapdepth[depth] += 1
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3196 addsize(size, snapsizedepth[depth])
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3197 else:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3198 addsize(size, deltasize)
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3199 if delta == rev - 1:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3200 numprev += 1
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3201 if delta == p1:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3202 nump1prev += 1
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3203 elif delta == p2:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3204 nump2prev += 1
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3205 elif delta == p1:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3206 nump1 += 1
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3207 elif delta == p2:
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3208 nump2 += 1
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3209 elif delta != nullrev:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3210 numother += 1
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3211
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3212 # Obtain data on the raw chunks in the revlog.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3213 if util.safehasattr(r, b'_getsegmentforrevs'):
39181
1464183343b3 debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents: 39119
diff changeset
3214 segment = r._getsegmentforrevs(rev, rev)[1]
1464183343b3 debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents: 39119
diff changeset
3215 else:
1464183343b3 debugrevlog: fix for non-manifest object
Boris Feld <boris.feld@octobus.net>
parents: 39119
diff changeset
3216 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
32269
75e93d95aae6 revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 32249
diff changeset
3217 if segment:
33118
2f812b0d1936 py3: pass the memoryview object into bytes() to get the value
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33114
diff changeset
3218 chunktype = bytes(segment[0:1])
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3219 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3220 chunktype = b'empty'
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3221
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3222 if chunktype not in chunktypecounts:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3223 chunktypecounts[chunktype] = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3224 chunktypesizes[chunktype] = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3225
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3226 chunktypecounts[chunktype] += 1
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3227 chunktypesizes[chunktype] += size
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3228
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3229 # Adjust size min value for empty cases
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3230 for size in (datasize, fullsize, semisize, deltasize):
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3231 if size[0] is None:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3232 size[0] = 0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3233
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3234 numdeltas = numrevs - numfull - numempty - numsemi
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3235 numoprev = numprev - nump1prev - nump2prev
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3236 totalrawsize = datasize[2]
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3237 datasize[2] /= numrevs
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3238 fulltotal = fullsize[2]
42186
30033d56758f debugrevlog: fix average size computation for empty data (issue6167)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42148
diff changeset
3239 if numfull == 0:
30033d56758f debugrevlog: fix average size computation for empty data (issue6167)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42148
diff changeset
3240 fullsize[2] = 0
30033d56758f debugrevlog: fix average size computation for empty data (issue6167)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42148
diff changeset
3241 else:
30033d56758f debugrevlog: fix average size computation for empty data (issue6167)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42148
diff changeset
3242 fullsize[2] /= numfull
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3243 semitotal = semisize[2]
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3244 snaptotal = {}
40030
e2697acd9381 cleanup: some Yoda conditions, this patch removes
Martin von Zweigbergk <martinvonz@google.com>
parents: 40018
diff changeset
3245 if numsemi > 0:
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3246 semisize[2] /= numsemi
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3247 for depth in snapsizedepth:
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3248 snaptotal[depth] = snapsizedepth[depth][2]
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3249 snapsizedepth[depth][2] /= numsnapdepth[depth]
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3250
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3251 deltatotal = deltasize[2]
39118
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3252 if numdeltas > 0:
195ed920653e debugrevlog: track empty revlog entries
Boris Feld <boris.feld@octobus.net>
parents: 39117
diff changeset
3253 deltasize[2] /= numdeltas
39184
07b82f55f351 debugrevlog: include information about intermediate snapshots
Boris Feld <boris.feld@octobus.net>
parents: 39181
diff changeset
3254 totalsize = fulltotal + semitotal + deltatotal
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3255 avgchainlen = sum(chainlengths) / numrevs
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3256 maxchainlen = max(chainlengths)
33069
03eefca3ed33 debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 33043
diff changeset
3257 maxchainspan = max(chainspans)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3258 compratio = 1
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3259 if totalsize:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3260 compratio = totalrawsize / totalsize
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3261
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3262 basedfmtstr = b'%%%dd\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3263 basepcfmtstr = b'%%%dd %s(%%5.2f%%%%)\n'
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3264
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3265 def dfmtstr(max):
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3266 return basedfmtstr % len(str(max))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3267
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3268 def pcfmtstr(max, padding=0):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3269 return basepcfmtstr % (len(str(max)), b' ' * padding)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3270
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3271 def pcfmt(value, total):
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3272 if total:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3273 return (value, 100 * float(value) / total)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3274 else:
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3275 return value, 100.0
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3276
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3277 ui.writenoi18n(b'format : %d\n' % format)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3278 ui.writenoi18n(b'flags : %s\n' % b', '.join(flags))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3279
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3280 ui.write(b'\n')
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3281 fmt = pcfmtstr(totalsize)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3282 fmt2 = dfmtstr(totalsize)
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3283 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3284 ui.writenoi18n(b' merges : ' + fmt % pcfmt(nummerges, numrevs))
43094
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3285 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3286 b' normal : ' + fmt % pcfmt(numrevs - nummerges, numrevs)
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3287 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3288 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3289 ui.writenoi18n(b' empty : ' + fmt % pcfmt(numempty, numrevs))
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3290 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3291 b' text : '
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3292 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3293 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3294 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3295 b' delta : '
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3296 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3297 )
43094
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3298 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3299 b' snapshot : ' + fmt % pcfmt(numfull + numsemi, numrevs)
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3300 )
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3301 for depth in sorted(numsnapdepth):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3302 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3303 (b' lvl-%-3d : ' % depth)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3304 + fmt % pcfmt(numsnapdepth[depth], numrevs)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3305 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3306 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(numdeltas, numrevs))
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3307 ui.writenoi18n(b'revision size : ' + fmt2 % totalsize)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3308 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3309 b' snapshot : ' + fmt % pcfmt(fulltotal + semitotal, totalsize)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3310 )
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3311 for depth in sorted(numsnapdepth):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3312 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3313 (b' lvl-%-3d : ' % depth)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3314 + fmt % pcfmt(snaptotal[depth], totalsize)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3315 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3316 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(deltatotal, totalsize))
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3317
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3318 def fmtchunktype(chunktype):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3319 if chunktype == b'empty':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3320 return b' %s : ' % chunktype
33119
e88fdec9cb9e py3: use pycompat.bytestr() to convert str to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33118
diff changeset
3321 elif chunktype in pycompat.bytestr(string.ascii_letters):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3322 return b' 0x%s (%s) : ' % (hex(chunktype), chunktype)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3323 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3324 return b' 0x%s : ' % hex(chunktype)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3325
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3326 ui.write(b'\n')
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3327 ui.writenoi18n(b'chunks : ' + fmt2 % numrevs)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3328 for chunktype in sorted(chunktypecounts):
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3329 ui.write(fmtchunktype(chunktype))
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3330 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs))
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3331 ui.writenoi18n(b'chunks size : ' + fmt2 % totalsize)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3332 for chunktype in sorted(chunktypecounts):
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3333 ui.write(fmtchunktype(chunktype))
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3334 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3335
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3336 ui.write(b'\n')
33074
e21b750c9b9e debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents: 33069
diff changeset
3337 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3338 ui.writenoi18n(b'avg chain length : ' + fmt % avgchainlen)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3339 ui.writenoi18n(b'max chain length : ' + fmt % maxchainlen)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3340 ui.writenoi18n(b'max chain reach : ' + fmt % maxchainspan)
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3341 ui.writenoi18n(b'compression ratio : ' + fmt % compratio)
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3342
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3343 if format > 0:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3344 ui.write(b'\n')
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3345 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3346 b'uncompressed data size (min/max/avg) : %d / %d / %d\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3347 % tuple(datasize)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3348 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3349 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3350 b'full revision size (min/max/avg) : %d / %d / %d\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3351 % tuple(fullsize)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3352 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3353 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3354 b'inter-snapshot size (min/max/avg) : %d / %d / %d\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3355 % tuple(semisize)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3356 )
39186
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3357 for depth in sorted(snapsizedepth):
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3358 if depth == 0:
9d6fab487c13 debugrevlog: display snapshot details per depth
Boris Feld <boris.feld@octobus.net>
parents: 39184
diff changeset
3359 continue
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3360 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3361 b' level-%-3d (min/max/avg) : %d / %d / %d\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3362 % ((depth,) + tuple(snapsizedepth[depth]))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3363 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3364 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3365 b'delta size (min/max/avg) : %d / %d / %d\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3366 % tuple(deltasize)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3367 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3368
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3369 if numdeltas > 0:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3370 ui.write(b'\n')
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3371 fmt = pcfmtstr(numdeltas)
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3372 fmt2 = pcfmtstr(numdeltas, 4)
43094
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3373 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3374 b'deltas against prev : ' + fmt % pcfmt(numprev, numdeltas)
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3375 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3376 if numprev > 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
3377 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3378 b' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3379 )
43080
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(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3381 b' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3382 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3383 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3384 b' other : ' + fmt2 % pcfmt(numoprev, numprev)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3385 )
30971
f44b96aef81b debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30970
diff changeset
3386 if gdelta:
43094
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3387 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3388 b'deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas)
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3389 )
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3390 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3391 b'deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas)
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3392 )
43080
86e4daa2d54c cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents: 43077
diff changeset
3393 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3394 b'deltas against other : ' + fmt % pcfmt(numother, numdeltas)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3395 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3396
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3397
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3398 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3399 b'debugrevlogindex',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3400 cmdutil.debugrevlogopts
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3401 + [(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
3402 _(b'[-f FORMAT] -c|-m|FILE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3403 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3404 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3405 def debugrevlogindex(ui, repo, file_=None, **opts):
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3406 """dump the contents of a revlog index"""
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3407 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3408 r = cmdutil.openrevlog(repo, b'debugrevlogindex', file_, opts)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3409 format = opts.get(b'format', 0)
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3410 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
3411 raise error.Abort(_(b"unknown format %d") % format)
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3412
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3413 if ui.debugflag:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3414 shortfn = hex
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3415 else:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3416 shortfn = short
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3417
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3418 # There might not be anything in r, so have a sane default
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3419 idlen = 12
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3420 for i in r:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3421 idlen = len(shortfn(r.node(i)))
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3422 break
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3423
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3424 if format == 0:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3425 if ui.verbose:
43116
defabf63e969 debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
3426 ui.writenoi18n(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43116
diff changeset
3427 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
3428 % (b"nodeid".ljust(idlen), b"p1".ljust(idlen))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3429 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3430 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
3431 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3432 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
3433 % (b"nodeid".ljust(idlen), b"p1".ljust(idlen))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3434 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3435 elif format == 1:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3436 if ui.verbose:
43116
defabf63e969 debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
3437 ui.writenoi18n(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3438 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3439 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
3440 b" p2 %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3441 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3442 % b"nodeid".rjust(idlen)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3443 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3444 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
3445 ui.writenoi18n(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3446 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
3447 % b"nodeid".rjust(idlen)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3448 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3449
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3450 for i in r:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3451 node = r.node(i)
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3452 if format == 0:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3453 try:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3454 pp = r.parents(node)
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3455 except Exception:
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
3456 pp = [repo.nullid, repo.nullid]
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3457 if ui.verbose:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3458 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3459 b"% 6d % 9d % 7d % 7d %s %s %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3460 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3461 i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3462 r.start(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3463 r.length(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3464 r.linkrev(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3465 shortfn(node),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3466 shortfn(pp[0]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3467 shortfn(pp[1]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3468 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3469 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3470 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3471 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3472 b"% 6d % 7d %s %s %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3473 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3474 i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3475 r.linkrev(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3476 shortfn(node),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3477 shortfn(pp[0]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3478 shortfn(pp[1]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3479 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3480 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3481 elif format == 1:
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3482 pr = r.parentrevs(i)
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3483 if ui.verbose:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3484 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3485 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
3486 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3487 i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3488 r.flags(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3489 r.start(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3490 r.length(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3491 r.rawsize(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3492 r.linkrev(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3493 pr[0],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3494 pr[1],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3495 shortfn(node),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3496 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3497 )
39309
828a45233036 debugcommands: introduce debugrevlogindex (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39308
diff changeset
3498 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3499 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3500 b"% 6d %04x % 8d % 6d % 6d % 6d %s\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3501 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3502 i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3503 r.flags(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3504 r.rawsize(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3505 r.linkrev(i),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3506 pr[0],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3507 pr[1],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3508 shortfn(node),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3509 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3510 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3511
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3512
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3513 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3514 b'debugrevspec',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3515 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3516 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3517 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3518 b'optimize',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3519 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3520 _(b'print parsed tree after optimizing (DEPRECATED)'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3521 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3522 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3523 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3524 b'show-revs',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3525 True,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3526 _(b'print list of result revisions (default)'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3527 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3528 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3529 b's',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3530 b'show-set',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3531 None,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3532 _(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
3533 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3534 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3535 b'p',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3536 b'show-stage',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3537 [],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3538 _(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
3539 _(b'NAME'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3540 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3541 (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
3542 (b'', b'verify-optimized', False, _(b'verify optimized result')),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3543 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3544 b'REVSPEC',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3545 )
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3546 def debugrevspec(ui, repo, expr, **opts):
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3547 """parse and apply a revision specification
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3548
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3549 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: 30971
diff changeset
3550 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: 30971
diff changeset
3551
32816
bcca357bb792 debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents: 32815
diff changeset
3552 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: 32815
diff changeset
3553 representation or the parsed tree respectively.
bcca357bb792 debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents: 32815
diff changeset
3554
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3555 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: 30971
diff changeset
3556 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: 30971
diff changeset
3557 """
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
3558 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3559 aliases = ui.configitems(b'revsetalias')
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3560 stages = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3561 (b'parsed', lambda tree: tree),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3562 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3563 b'expanded',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3564 lambda tree: revsetlang.expandaliases(tree, aliases, ui.warn),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3565 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3566 (b'concatenated', revsetlang.foldconcat),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3567 (b'analyzed', revsetlang.analyze),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3568 (b'optimized', revsetlang.optimize),
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3569 ]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3570 if opts[b'no_optimized']:
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3571 stages = stages[:-1]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3572 if opts[b'verify_optimized'] and opts[b'no_optimized']:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3573 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
3574 _(b'cannot use --verify-optimized with --no-optimized')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3575 )
44470
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44453
diff changeset
3576 stagenames = {n for n, f in stages}
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3577
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3578 showalways = set()
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3579 showchanged = set()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3580 if ui.verbose and not opts[b'show_stage']:
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3581 # 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
3582 showalways.add(b'parsed')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3583 showchanged.update([b'expanded', b'concatenated'])
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3584 if opts[b'optimize']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3585 showalways.add(b'optimized')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3586 if opts[b'show_stage'] and opts[b'optimize']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3587 raise error.Abort(_(b'cannot use --optimize with --show-stage'))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3588 if opts[b'show_stage'] == [b'all']:
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3589 showalways.update(stagenames)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3590 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3591 for n in opts[b'show_stage']:
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3592 if n not in stagenames:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3593 raise error.Abort(_(b'invalid stage name: %s') % n)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3594 showalways.update(opts[b'show_stage'])
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3595
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3596 treebystage = {}
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3597 printedtree = None
37350
e32dfff71529 revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents: 37322
diff changeset
3598 tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3599 for n, f in stages:
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3600 treebystage[n] = tree = f(tree)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3601 if n in showalways or (n in showchanged and tree != printedtree):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3602 if opts[b'show_stage'] or n != b'parsed':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3603 ui.write(b"* %s:\n" % n)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3604 ui.write(revsetlang.prettyformat(tree), b"\n")
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3605 printedtree = tree
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3606
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3607 if opts[b'verify_optimized']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3608 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
3609 brevs = revset.makematcher(treebystage[b'optimized'])(repo)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3610 if opts[b'show_set'] or (opts[b'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
3611 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3612 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
3613 )
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3614 ui.writenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
3615 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
3616 )
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3617 arevs = list(arevs)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3618 brevs = list(brevs)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3619 if arevs == brevs:
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3620 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
3621 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
3622 ui.writenoi18n(b'+++ optimized\n', label=b'diff.file_b')
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3623 sm = difflib.SequenceMatcher(None, arevs, brevs)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3624 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
3625 if tag in ('delete', 'replace'):
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3626 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
3627 ui.write(b'-%d\n' % c, label=b'diff.deleted')
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
3628 if tag in ('insert', 'replace'):
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3629 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
3630 ui.write(b'+%d\n' % c, label=b'diff.inserted')
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
3631 if tag == 'equal':
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3632 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
3633 ui.write(b' %d\n' % c)
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3634 return 1
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3635
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3636 func = revset.makematcher(tree)
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3637 revs = func(repo)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3638 if opts[b'show_set'] or (opts[b'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
3639 ui.writenoi18n(b"* set:\n", stringutil.prettyrepr(revs), b"\n")
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3640 if not opts[b'show_revs']:
32816
bcca357bb792 debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents: 32815
diff changeset
3641 return
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3642 for c in revs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3643 ui.write(b"%d\n" % c)
30972
85c3c879c43a debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30971
diff changeset
3644
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3645
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3646 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3647 b'debugserve',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3648 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3649 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3650 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3651 b'sshstdio',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3652 False,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3653 _(b'run an SSH server bound to process handles'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3654 ),
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3655 (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
3656 (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
3657 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3658 b'',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3659 )
36556
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3660 def debugserve(ui, repo, **opts):
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3661 """run a server with advanced settings
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3662
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3663 This command is similar to :hg:`serve`. It exists partially as a
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3664 workaround to the fact that ``hg serve --stdio`` must have specific
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3665 arguments for security reasons.
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3666 """
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3667 opts = pycompat.byteskwargs(opts)
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3668
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3669 if not opts[b'sshstdio']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3670 raise error.Abort(_(b'only --sshstdio is currently supported'))
36556
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3671
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3672 logfh = None
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3673
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3674 if opts[b'logiofd'] and opts[b'logiofile']:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3675 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
3676
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3677 if opts[b'logiofd']:
44123
52f8b07ad2f9 debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44012
diff changeset
3678 # 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: 44012
diff changeset
3679 # 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: 44012
diff changeset
3680 # 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: 44012
diff changeset
3681 # performance critical code, it should be fine.
38322
275cc461b854 debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents: 38275
diff changeset
3682 try:
44123
52f8b07ad2f9 debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44012
diff changeset
3683 logfh = os.fdopen(int(opts[b'logiofd']), 'ab', 0)
38322
275cc461b854 debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents: 38275
diff changeset
3684 except OSError as e:
275cc461b854 debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents: 38275
diff changeset
3685 if e.errno != errno.ESPIPE:
275cc461b854 debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents: 38275
diff changeset
3686 raise
275cc461b854 debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents: 38275
diff changeset
3687 # can't seek a pipe, so `ab` mode fails on py3
44123
52f8b07ad2f9 debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44012
diff changeset
3688 logfh = os.fdopen(int(opts[b'logiofd']), 'wb', 0)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3689 elif opts[b'logiofile']:
44123
52f8b07ad2f9 debugcommands: move away from line buffered output on binary stream
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44012
diff changeset
3690 logfh = open(opts[b'logiofile'], b'ab', 0)
36556
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3691
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3692 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3693 s.serve_forever()
44dc34b8d17b debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36522
diff changeset
3694
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3695
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3696 @command(b'debugsetparents', [], _(b'REV1 [REV2]'))
30973
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3697 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: 46113
diff changeset
3698 """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: 46113
diff changeset
3699
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3700 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: 46113
diff changeset
3701 this command will most certainly results in slight corruption of the file
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3702 level histories withing your repository. DO NOT USE THIS COMMAND.
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3703
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3704 The command update the p1 and p2 field in the dirstate, and not touching
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3705 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: 46113
diff changeset
3706 should be used with extreme care. For example, neither the working
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3707 directory nor the dirstate is updated, so file status may be incorrect
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3708 after running this command. Only used if you are one of the few people that
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3709 deeply unstand both conversion tools and file level histories. If you are
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3710 reading this help, you are not one of this people (most of them sailed west
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3711 from Mithlond anyway.
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3712
b986e3342827 debugsetparents: add various warning in the help message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46113
diff changeset
3713 So one last time DO NOT USE THIS COMMAND.
30973
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3714
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3715 Returns 0 on success.
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3716 """
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3717
37146
8bac14ce5778 debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents: 37123
diff changeset
3718 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
3719 node2 = scmutil.revsingle(repo, rev2, b'null').node()
30973
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3720
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3721 with repo.wlock():
37146
8bac14ce5778 debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents: 37123
diff changeset
3722 repo.setparents(node1, node2)
30973
5b09e9bc0902 debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30972
diff changeset
3723
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3724
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3725 @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: 42930
diff changeset
3726 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
3727 """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
3728
ba5b062a1388 debugsidedata: small doc improvement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
3729 Use --verbose to dump the sidedata content."""
43041
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3730 opts = pycompat.byteskwargs(opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3731 if opts.get(b'changelog') or opts.get(b'manifest') or opts.get(b'dir'):
43041
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3732 if rev is not None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3733 raise error.CommandError(b'debugdata', _(b'invalid arguments'))
43041
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3734 file_, rev = None, file_
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3735 elif rev is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3736 raise error.CommandError(b'debugdata', _(b'invalid arguments'))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3737 r = cmdutil.openstorage(repo, b'debugdata', file_, opts)
43041
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3738 r = getattr(r, '_revlog', r)
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3739 try:
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3740 sidedata = r.sidedata(r.lookup(rev))
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3741 except KeyError:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3742 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: 42930
diff changeset
3743 if sidedata:
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3744 sidedata = list(sidedata.items())
559ac8411f12 sidedata: add a debugsidedata command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42930
diff changeset
3745 sidedata.sort()
43116
defabf63e969 debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
3746 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: 42930
diff changeset
3747 for key, value in sidedata:
43116
defabf63e969 debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
3748 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: 42930
diff changeset
3749 if ui.verbose:
43116
defabf63e969 debugcommands: add a few more writenoi18n()
Martin von Zweigbergk <martinvonz@google.com>
parents: 43106
diff changeset
3750 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
3751
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3752
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3753 @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
3754 def debugssl(ui, repo, source=None, **opts):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
3755 """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
3756
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
3757 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
3758 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
3759 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
3760
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
3761 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
3762 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
3763
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
3764 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
3765 of the SSL error is likely another issue.
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
3766 """
34645
75979c8d4572 codemod: use pycompat.iswindows
Jun Wu <quark@fb.com>
parents: 34327
diff changeset
3767 if not pycompat.iswindows:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3768 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
3769 _(b'certificate chain building is only possible on Windows')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3770 )
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
3771
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
3772 if not source:
33672
3c3066367d72 debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents: 33553
diff changeset
3773 if not repo:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3774 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3775 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3776 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
3777 b"server specified"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3778 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3779 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3780 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
3781
46960
69359c91dc43 debugssl: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46959
diff changeset
3782 source, branches = urlutil.get_unique_pull_path(
69359c91dc43 debugssl: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46959
diff changeset
3783 b'debugssl', repo, ui, source
69359c91dc43 debugssl: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46959
diff changeset
3784 )
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
3785 url = urlutil.url(source)
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
3786
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3787 defaultport = {b'https': 443, b'ssh': 22}
35005
88572b7e50fd debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents: 34645
diff changeset
3788 if url.scheme in defaultport:
88572b7e50fd debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents: 34645
diff changeset
3789 try:
88572b7e50fd debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents: 34645
diff changeset
3790 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
3791 except ValueError:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3792 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
3793 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3794 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
3795
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
3796 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
3797
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3798 s = ssl.wrap_socket(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3799 socket.socket(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3800 ssl_version=ssl.PROTOCOL_TLS,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3801 cert_reqs=ssl.CERT_NONE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3802 ca_certs=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3803 )
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
3804
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
3805 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
3806 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
3807 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
3808
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3809 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
3810
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
3811 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
3812
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
3813 if not complete:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3814 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
3815
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
3816 if not win32.checkcertificatechain(cert):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3817 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
3818 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3819 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
3820 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3821 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
3822 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
3823 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
3824
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3825
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3826 @command(
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3827 b"debugbackupbundle",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3828 [
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3829 (
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3830 b"",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3831 b"recover",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3832 b"",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3833 b"brings the specified changeset back into the repository",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3834 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3835 ]
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3836 + cmdutil.logopts,
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3837 _(b"hg debugbackupbundle [--recover HASH]"),
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3838 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3839 def debugbackupbundle(ui, repo, *pats, **opts):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3840 """lists the changesets available in backup bundles
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3841
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3842 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: 44427
diff changeset
3843 backup bundle.
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3844
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3845 --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: 44427
diff changeset
3846 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: 44427
diff changeset
3847
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3848 --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: 44427
diff changeset
3849 backup.
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3850 """
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3851 backups = list(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3852 filter(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3853 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: 44427
diff changeset
3854 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3855 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3856 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: 44427
diff changeset
3857
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3858 opts = pycompat.byteskwargs(opts)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3859 opts[b"bundle"] = b""
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3860 opts[b"force"] = None
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3861 limit = logcmdutil.getlimit(opts)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3862
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3863 def display(other, chlist, displayer):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3864 if opts.get(b"newest_first"):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3865 chlist.reverse()
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3866 count = 0
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3867 for n in chlist:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3868 if limit is not None and count >= limit:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3869 break
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
3870 parents = [
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46961
diff changeset
3871 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
3872 ]
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3873 if opts.get(b"no_merges") and len(parents) == 2:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3874 continue
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3875 count += 1
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3876 displayer.show(other[n])
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3877
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3878 recovernode = opts.get(b"recover")
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3879 if recovernode:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3880 if scmutil.isrevsymbol(repo, recovernode):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3881 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: 44427
diff changeset
3882 return
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3883 elif backups:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3884 msg = _(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3885 b"Recover changesets using: hg debugbackupbundle --recover "
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3886 b"<changeset hash>\n\nAvailable backup changesets:"
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3887 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3888 ui.status(msg, label=b"status.removed")
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3889 else:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3890 ui.status(_(b"no backup changesets found\n"))
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3891 return
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3892
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3893 for backup in backups:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3894 # 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
3895 source = os.path.relpath(backup, encoding.getcwd())
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3896 source, branches = urlutil.get_unique_pull_path(
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3897 b'debugbackupbundle',
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3898 repo,
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3899 ui,
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3900 source,
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3901 default_branches=opts.get(b'branch'),
d7b36a4e03de debugbackupbundle: use `get_unique_pull_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46960
diff changeset
3902 )
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3903 try:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3904 other = hg.peer(repo, opts, source)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3905 except error.LookupError as ex:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3906 msg = _(b"\nwarning: unable to open bundle %s") % source
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3907 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: 44427
diff changeset
3908 ui.warn(msg, hint=hint)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3909 continue
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3910 revs, checkout = hg.addbranchrevs(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3911 repo, other, branches, opts.get(b"rev")
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3912 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3913
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3914 if revs:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3915 revs = [other.lookup(rev) for rev in revs]
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3916
47444
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3917 with ui.silent():
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3918 try:
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3919 other, chlist, cleanupfn = bundlerepo.getremotechanges(
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3920 ui, repo, other, revs, opts[b"bundle"], opts[b"force"]
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3921 )
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3922 except error.LookupError:
1be9bf3669cb debugbackupbundle: use new context manager for silencing the ui
Martin von Zweigbergk <martinvonz@google.com>
parents: 47443
diff changeset
3923 continue
44453
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3924
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3925 try:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3926 if not chlist:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3927 continue
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3928 if recovernode:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3929 with repo.lock(), repo.transaction(b"unbundle") as tr:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3930 if scmutil.isrevsymbol(other, recovernode):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3931 ui.status(_(b"Unbundling %s\n") % (recovernode))
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3932 f = hg.openpath(ui, source)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3933 gen = exchange.readbundle(ui, f, source)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3934 if isinstance(gen, bundle2.unbundle20):
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3935 bundle2.applybundle(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3936 repo,
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3937 gen,
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3938 tr,
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3939 source=b"unbundle",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3940 url=b"bundle:" + source,
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3941 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3942 else:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3943 gen.apply(repo, b"unbundle", b"bundle:" + source)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3944 break
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3945 else:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3946 backupdate = encoding.strtolocal(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3947 time.strftime(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3948 "%a %H:%M, %Y-%m-%d",
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3949 time.localtime(os.path.getmtime(source)),
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3950 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3951 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3952 ui.status(b"\n%s\n" % (backupdate.ljust(50)))
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3953 if ui.verbose:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3954 ui.status(b"%s%s\n" % (b"bundle:".ljust(13), source))
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3955 else:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3956 opts[
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3957 b"template"
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3958 ] = b"{label('status.modified', node|short)} {desc|firstline}\n"
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3959 displayer = logcmdutil.changesetdisplayer(
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3960 ui, other, opts, False
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3961 )
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3962 display(other, chlist, displayer)
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3963 displayer.close()
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3964 finally:
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3965 cleanupfn()
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3966
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3967
f82d2d4e71db debugbackupbundle: introduce command to interact with strip backups
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44427
diff changeset
3968 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3969 b'debugsub',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3970 [(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
3971 _(b'[-r REV] [REV]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3972 )
30975
8e38fa360a12 debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30974
diff changeset
3973 def debugsub(ui, repo, rev=None):
8e38fa360a12 debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30974
diff changeset
3974 ctx = scmutil.revsingle(repo, rev, None)
8e38fa360a12 debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30974
diff changeset
3975 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
3976 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
3977 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
3978 ui.writenoi18n(b' revision %s\n' % v[1])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3979
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3980
46464
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3981 @command(b'debugshell', optionalrepo=True)
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3982 def debugshell(ui, repo):
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3983 """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
3984
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3985 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
3986 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
3987 """
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3988 import code
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3989
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3990 imported_objects = {
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3991 'ui': ui,
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3992 'repo': repo,
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3993 }
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3994
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3995 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
3996
f25c770c217b debugshell: add a simple command for starting an interactive shell
Joerg Sonnenberger <joerg@bec.de>
parents: 46237
diff changeset
3997
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
3998 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
3999 b'debugsuccessorssets',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4000 [(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
4001 _(b'[REV]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4002 )
33274
68f3e819d41d obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents: 33273
diff changeset
4003 def debugsuccessorssets(ui, repo, *revs, **opts):
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4004 """show set of successors for revision
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4005
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4006 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
4007 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
4008 successors set is set.
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4009
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4010 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: 30975
diff changeset
4011 successor (changeset A replaced by A').
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4012
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4013 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: 30975
diff changeset
4014 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: 30975
diff changeset
4015
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4016 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: 30975
diff changeset
4017 more than one successor.
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4018
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4019 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: 30975
diff changeset
4020 "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: 30975
diff changeset
4021 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: 30975
diff changeset
4022
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4023 Results are displayed as follows::
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4024
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4025 <rev1>
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4026 <successors-1A>
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4027 <rev2>
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4028 <successors-2A>
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4029 <successors-2B1> <successors-2B2> <successors-2B3>
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4030
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4031 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: 30975
diff changeset
4032 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: 30975
diff changeset
4033 been split).
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4034 """
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4035 # 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: 30975
diff changeset
4036 cache = {}
36161
8eb13f5d5d3f py3: convert context to bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35969
diff changeset
4037 ctx2str = bytes
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4038 node2str = short
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
4039 for rev in logcmdutil.revrange(repo, revs):
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4040 ctx = repo[rev]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4041 ui.write(b'%s\n' % ctx2str(ctx))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4042 for succsset in obsutil.successorssets(
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4043 repo, ctx.node(), closest=opts['closest'], cache=cache
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4044 ):
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4045 if succsset:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4046 ui.write(b' ')
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4047 ui.write(node2str(succsset[0]))
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4048 for node in succsset[1:]:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4049 ui.write(b' ')
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4050 ui.write(node2str(node))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4051 ui.write(b'\n')
30976
db30c6bfeb70 debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
4052
44349
a0ec05d93c8e cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents: 44336
diff changeset
4053
44336
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4054 @command(b'debugtagscache', [])
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4055 def debugtagscache(ui, repo):
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4056 """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: 44230
diff changeset
4057 cache = tagsmod.hgtagsfnodescache(repo.unfiltered())
46694
e4e971abb6a3 debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46692
diff changeset
4058 flog = repo.file(b'.hgtags')
44336
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4059 for r in repo:
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4060 node = repo[r].node()
d8b53385b1bc tags: add a debug command to display .hg/cache/hgtagsfnodes1
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents: 44230
diff changeset
4061 tagsnode = cache.getfnode(node, computemissing=False)
46547
5aac1a1a5beb tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents: 46538
diff changeset
4062 if tagsnode:
5aac1a1a5beb tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents: 46538
diff changeset
4063 tagsnodedisplay = hex(tagsnode)
46694
e4e971abb6a3 debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46692
diff changeset
4064 if not flog.hasnode(tagsnode):
e4e971abb6a3 debugtagscache: verify that filenode is correct
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46692
diff changeset
4065 tagsnodedisplay += b' (unknown node)'
46692
9306a16ca964 debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46547
diff changeset
4066 elif tagsnode is None:
9306a16ca964 debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46547
diff changeset
4067 tagsnodedisplay = b'missing'
9306a16ca964 debugcommands: prevent using `is False`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46547
diff changeset
4068 else:
46547
5aac1a1a5beb tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents: 46538
diff changeset
4069 tagsnodedisplay = b'invalid'
5aac1a1a5beb tagcache: distinguish between invalid and missing entries
Matt Harbison <matt_harbison@yahoo.com>
parents: 46538
diff changeset
4070
44384
e80da7a63264 tags: fix some type confusion exposed in python 3
Augie Fackler <augie@google.com>
parents: 44370
diff changeset
4071 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
4072
44349
a0ec05d93c8e cleanup: re-run black on the codebase
Augie Fackler <augie@google.com>
parents: 44336
diff changeset
4073
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4074 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4075 b'debugtemplate',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4076 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4077 (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
4078 (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
4079 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4080 _(b'[-r REV]... [-D KEY=VALUE]... TEMPLATE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4081 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4082 )
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4083 def debugtemplate(ui, repo, tmpl, **opts):
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4084 """parse and apply a template
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4085
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4086 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: 30976
diff changeset
4087 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: 30976
diff changeset
4088 template.
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4089
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4090 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: 30976
diff changeset
4091 """
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4092 revs = None
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4093 if opts['rev']:
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4094 if repo is None:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4095 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
4096 _(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
4097 )
48128
5ced12cfa41b errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents: 48113
diff changeset
4098 revs = logcmdutil.revrange(repo, opts['rev'])
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4099
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4100 props = {}
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4101 for d in opts['define']:
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4102 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4103 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
4104 if not k or k == b'ui':
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4105 raise ValueError
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4106 props[k] = v
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4107 except ValueError:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4108 raise error.Abort(_(b'malformed keyword definition: %s') % d)
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4109
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4110 if ui.verbose:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4111 aliases = ui.configitems(b'templatealias')
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4112 tree = templater.parse(tmpl)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4113 ui.note(templater.prettyformat(tree), b'\n')
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4114 newtree = templater.expandaliases(tree, aliases)
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4115 if newtree != tree:
43094
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
4116 ui.notenoi18n(
e8cf9ad52a78 formatting: run black on all file again
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43089
diff changeset
4117 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
4118 )
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4119
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4120 if revs is None:
35473
f1c54d003327 templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
4121 tres = formatter.templateresources(ui, repo)
f1c54d003327 templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents: 35469
diff changeset
4122 t = formatter.maketemplater(ui, tmpl, resources=tres)
38361
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38322
diff changeset
4123 if ui.verbose:
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38322
diff changeset
4124 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
4125 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
4126 ui.writenoi18n(b"* functions: %s\n" % b', '.join(sorted(funcs)))
36991
317382151ac3 templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents: 36960
diff changeset
4127 ui.write(t.renderdefault(props))
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4128 else:
35928
c8e2d6ed1f9e cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents: 35730
diff changeset
4129 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
38361
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38322
diff changeset
4130 if ui.verbose:
d4fae9a0ab1f templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents: 38322
diff changeset
4131 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
4132 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
4133 ui.writenoi18n(b"* functions: %s\n" % b', '.join(sorted(funcs)))
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4134 for r in revs:
33114
1b6946f87c50 py3: use pycompat.strkwargs() to convert kwargs keys to str
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33113
diff changeset
4135 displayer.show(repo[r], **pycompat.strkwargs(props))
30977
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4136 displayer.close()
14794735faa8 debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30976
diff changeset
4137
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4138
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4139 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4140 b'debuguigetpass',
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4141 [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4142 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4143 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4144 _(b'[-p TEXT]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4145 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4146 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4147 def debuguigetpass(ui, prompt=b''):
36800
15c050b5d599 ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents: 36789
diff changeset
4148 """show prompt to type password"""
15c050b5d599 ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents: 36789
diff changeset
4149 r = ui.getpass(prompt)
45783
e614eeb794f9 ui: remove excessive strtolocal() from debuguigetpass
Yuya Nishihara <yuya@tcha.org>
parents: 45777
diff changeset
4150 if r is None:
45777
07b0a687c01a ui: ensure `getpass()` returns bytes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45715
diff changeset
4151 r = b"<default response>"
44662
649fd6c3ed33 debugcommands: fix typo in debuguigetpass
Yuya Nishihara <yuya@tcha.org>
parents: 44639
diff changeset
4152 ui.writenoi18n(b'response: %s\n' % r)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4153
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 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4156 b'debuguiprompt',
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4157 [
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4158 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4159 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4160 _(b'[-p TEXT]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4161 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4162 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4163 def debuguiprompt(ui, prompt=b''):
36800
15c050b5d599 ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents: 36789
diff changeset
4164 """show plain prompt"""
15c050b5d599 ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents: 36789
diff changeset
4165 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
4166 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
4167
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4168
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4169 @command(b'debugupdatecaches', [])
32305
ccef71de7d41 caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32296
diff changeset
4170 def debugupdatecaches(ui, repo, *pats, **opts):
ccef71de7d41 caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32296
diff changeset
4171 """warm all known caches in the repository"""
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 33336
diff changeset
4172 with repo.wlock(), repo.lock():
47309
e96f75857361 updatecaches: use the caches argument in `hg debugupdatecaches`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47153
diff changeset
4173 repo.updatecaches(caches=repository.CACHES_ALL)
32305
ccef71de7d41 caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32296
diff changeset
4174
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4175
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4176 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4177 b'debugupgraderepo',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4178 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4179 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4180 b'o',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4181 b'optimize',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4182 [],
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4183 _(b'extra optimization to perform'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4184 _(b'NAME'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4185 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4186 (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
4187 (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
4188 (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
4189 (b'', b'manifest', None, _(b'select the manifest for upgrade')),
46012
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45957
diff changeset
4190 (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
4191 ],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4192 )
42840
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4193 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
4194 """upgrade a repository to use different features
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4195
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4196 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
4197 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
4198
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4199 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
4200 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
4201 by the command output when run without ``--run``.
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4202
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4203 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
4204 allowed.
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4205
eaa5607132a2 debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30743
diff changeset
4206 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
4207 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
4208 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
4209 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
4210 unable to access the repository should be low.
42840
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4211
47030
bd2ed1032b4e debugcommands: fix some plural-agreements I noticed
Augie Fackler <augie@google.com>
parents: 46961
diff changeset
4212 By default, all revlogs will be upgraded. You can restrict this using flags
42840
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4213 such as `--manifest`:
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4214
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4215 * `--manifest`: only optimize the manifest
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42789
diff changeset
4216 * `--no-manifest`: optimize all revlog but the manifest
42841
908ff446590e upgrade: add an argument to control changelog upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42840
diff changeset
4217 * `--changelog`: optimize the changelog only
908ff446590e upgrade: add an argument to control changelog upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42840
diff changeset
4218 * `--no-changelog --no-manifest`: optimize filelogs only
46012
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45957
diff changeset
4219 * `--filelogs`: optimize the filelogs only
46211
2dbe6053d49a debugupgraderepo: minor documentation fix
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46208
diff changeset
4220 * `--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
4221 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4222 return upgrade.upgraderepo(
46208
083438d6f403 upgrade: drop support for old style optimization names
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46201
diff changeset
4223 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
4224 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4225
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4226
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4227 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4228 b'debugwalk', cmdutil.walkopts, _(b'[OPTION]... [FILE]...'), inferrepo=True
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4229 )
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4230 def debugwalk(ui, repo, *pats, **opts):
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4231 """show how files match on given patterns"""
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
4232 opts = pycompat.byteskwargs(opts)
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4233 m = scmutil.match(repo[None], pats, opts)
38274
7c3a59e2971b debugwalk: show matcher output only if -v/--verbose
Yuya Nishihara <yuya@tcha.org>
parents: 38273
diff changeset
4234 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
4235 ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n')
32402
a275186b989a debugcommands: use repo[None].walk instead of repo.walk
Augie Fackler <augie@google.com>
parents: 32376
diff changeset
4236 items = list(repo[None].walk(m))
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4237 if not items:
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4238 return
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4239 f = lambda fn: fn
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4240 if ui.configbool(b'ui', b'slash') and pycompat.ossep != b'/':
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4241 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
4242 fmt = b'f %%-%ds %%-%ds %%s' % (
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4243 max([len(abs) for abs in items]),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4244 max([len(repo.pathto(abs)) for abs in items]),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4245 )
30978
df73368c87c3 debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30977
diff changeset
4246 for abs in items:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4247 line = fmt % (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4248 abs,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4249 f(repo.pathto(abs)),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4250 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
4251 )
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4252 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
4253
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4254
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4255 @command(b'debugwhyunstable', [], _(b'REV'))
36960
efc4fb344c05 debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents: 36958
diff changeset
4256 def debugwhyunstable(ui, repo, rev):
efc4fb344c05 debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents: 36958
diff changeset
4257 """explain instabilities of a changeset"""
37396
9966f44ecab4 debugwhyunstable: add support for revsets
Martin von Zweigbergk <martinvonz@google.com>
parents: 37350
diff changeset
4258 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
4259 dnodes = b''
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4260 if entry.get(b'divergentnodes'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4261 dnodes = (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4262 b' '.join(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4263 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
4264 for ctx in entry[b'divergentnodes']
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4265 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4266 + b' '
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4267 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4268 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4269 b'%s: %s%s %s\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4270 % (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
4271 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4272
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4273
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4274 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4275 b'debugwireargs',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4276 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4277 (b'', b'three', b'', b'three'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4278 (b'', b'four', b'', b'four'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4279 (b'', b'five', b'', b'five'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4280 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4281 + cmdutil.remoteopts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4282 _(b'REPO [OPTIONS]... [ONE [TWO]]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4283 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4284 )
30979
bd5694ce8beb debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30978
diff changeset
4285 def debugwireargs(ui, repopath, *vals, **opts):
33112
05906b8e1d23 py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33074
diff changeset
4286 opts = pycompat.byteskwargs(opts)
30979
bd5694ce8beb debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30978
diff changeset
4287 repo = hg.peer(ui, opts, repopath)
46702
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4288 try:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4289 for opt in cmdutil.remoteopts:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4290 del opts[opt[1]]
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4291 args = {}
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4292 for k, v in pycompat.iteritems(opts):
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4293 if v:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4294 args[k] = v
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4295 args = pycompat.strkwargs(args)
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4296 # 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: 46694
diff changeset
4297 res1 = repo.debugwireargs(*vals, **args)
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4298 res2 = repo.debugwireargs(*vals, **args)
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4299 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: 46694
diff changeset
4300 if res1 != res2:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4301 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: 46694
diff changeset
4302 finally:
a4c19a162615 sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 46694
diff changeset
4303 repo.close()
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4304
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4305
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4306 def _parsewirelangblocks(fh):
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4307 activeaction = None
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4308 blocklines = []
40174
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4309 lastindent = 0
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4310
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4311 for line in fh:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4312 line = line.rstrip()
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4313 if not line:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4314 continue
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4315
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4316 if line.startswith(b'#'):
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4317 continue
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4318
39099
efeeb73f54c3 debugcommands: fix a missing b prefix
Augie Fackler <augie@google.com>
parents: 39010
diff changeset
4319 if not line.startswith(b' '):
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4320 # New block. Flush previous one.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4321 if activeaction:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4322 yield activeaction, blocklines
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4323
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4324 activeaction = line
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4325 blocklines = []
40174
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4326 lastindent = 0
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4327 continue
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4328
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4329 # Else we start with an indent.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4330
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4331 if not activeaction:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4332 raise error.Abort(_(b'indented line outside of block'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4333
40174
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4334 indent = len(line) - len(line.lstrip())
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4335
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4336 # 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: 40030
diff changeset
4337 if indent > lastindent and blocklines:
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4338 blocklines[-1] += line.lstrip()
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4339 else:
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4340 blocklines.append(line)
64360202d5b2 debugcommands: support wrapping long lines
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40030
diff changeset
4341 lastindent = indent
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4342
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4343 # Flush last block.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4344 if activeaction:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4345 yield activeaction, blocklines
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4346
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4347
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4348 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4349 b'debugwireproto',
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4350 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4351 (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
4352 (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
4353 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4354 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4355 b'noreadstderr',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4356 False,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4357 _(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
4358 ),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4359 (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4360 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4361 b'nologhandshake',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4362 False,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4363 _(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
4364 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4365 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4366 + cmdutil.remoteopts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4367 _(b'[PATH]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4368 optionalrepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4369 )
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4370 def debugwireproto(ui, repo, path=None, **opts):
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4371 """send wire protocol commands to a server
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4372
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4373 This command can be used to issue wire protocol commands to remote
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4374 peers and to debug the raw data being exchanged.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4375
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4376 ``--localssh`` will start an SSH server against the current repository
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4377 and connect to that. By default, the connection will perform a handshake
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4378 and establish an appropriate peer instance.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4379
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4380 ``--peer`` can be used to bypass the handshake protocol and construct a
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4381 peer instance using the specified class type. Valid values are ``raw``,
48561
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4382 ``ssh1``. ``raw`` instances only allow sending raw data payloads and
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4383 don't support higher-level command actions.
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4384
36563
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4385 ``--noreadstderr`` can be used to disable automatic reading from stderr
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4386 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: 36560
diff changeset
4387 stderr is useful for making output more deterministic.
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4388
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4389 Commands are issued via a mini language which is specified via stdin.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4390 The language consists of individual actions to perform. An action is
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4391 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: 36556
diff changeset
4392 space followed by 0 or more lines with leading space. Blocks are
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4393 effectively a high-level command with additional metadata.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4394
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4395 Lines beginning with ``#`` are ignored.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4396
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4397 The following sections denote available actions.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4398
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4399 raw
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4400 ---
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4401
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4402 Send raw data to the server.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4403
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4404 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: 36556
diff changeset
4405 operation. The data may not actually be delivered in a single system
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4406 call: it depends on the abilities of the transport being used.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4407
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4408 Each line in the block is de-indented and concatenated. Then, that
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4409 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: 36556
diff changeset
4410 backslash escaping, etc.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4411
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4412 raw+
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4413 ----
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4414
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4415 Behaves like ``raw`` except flushes output afterwards.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4416
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4417 command <X>
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4418 -----------
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4419
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4420 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: 36557
diff changeset
4421 string.
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4422
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4423 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: 36557
diff changeset
4424 each line is ``<key> <value>``. e.g.::
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4425
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4426 command listkeys
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4427 namespace bookmarks
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4428
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4429 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
4430 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
4431 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
4432 backslash escaping.
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4433
36563
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4434 The following arguments have special meaning:
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4435
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4436 ``PUSHFILE``
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4437 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: 36560
diff changeset
4438 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: 36560
diff changeset
4439 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: 36560
diff changeset
4440 command payload.
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4441
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4442 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: 36560
diff changeset
4443
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4444 batchbegin
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4445 ----------
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4446
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4447 Instruct the peer to begin a batched send.
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4448
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4449 All ``command`` blocks are queued for execution until the next
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4450 ``batchsubmit`` block.
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4451
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4452 batchsubmit
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4453 -----------
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4454
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4455 Submit previously queued ``command`` blocks as a batch request.
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4456
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4457 This action MUST be paired with a ``batchbegin`` action.
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4458
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4459 httprequest <method> <path>
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4460 ---------------------------
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4461
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4462 (HTTP peer only)
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4463
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4464 Send an HTTP request to the peer.
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4465
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4466 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: 37015
diff changeset
4467
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4468 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: 37015
diff changeset
4469 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: 37015
diff changeset
4470
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4471 The following arguments are special:
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4472
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4473 ``BODYFILE``
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4474 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: 37015
diff changeset
4475 transferred verbatim as the HTTP request body.
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4476
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4477 ``frame <type> <flags> <payload>``
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4478 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: 37050
diff changeset
4479
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4480 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: 37050
diff changeset
4481 request.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4482
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4483 close
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4484 -----
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4485
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4486 Close the connection to the server.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4487
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4488 flush
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4489 -----
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4490
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4491 Flush data written to the server.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4492
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4493 readavailable
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4494 -------------
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4495
36851
31581528f242 debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents: 36843
diff changeset
4496 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: 36843
diff changeset
4497 the server.
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4498
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4499 If the connection to the server encompasses multiple pipes, we poll both
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4500 pipes and read available data.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4501
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4502 readline
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4503 --------
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4504
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4505 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: 36556
diff changeset
4506 pipes, reads only the main pipe.
37010
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4507
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4508 ereadline
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4509 ---------
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4510
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4511 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: 36991
diff changeset
4512
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4513 read <X>
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4514 --------
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4515
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4516 ``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: 36991
diff changeset
4517
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4518 eread <X>
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4519 ---------
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4520
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4521 ``read()`` N bytes from the server's stderr pipe, if available.
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4522
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4523 Specifying Unified Frame-Based Protocol Frames
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4524 ----------------------------------------------
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4525
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4526 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: 37050
diff changeset
4527 syntax.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4528
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4529 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: 37285
diff changeset
4530 from a string of the form:
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4531
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4532 <request-id> <stream-id> <stream-flags> <type> <flags> <payload>
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4533
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4534 ``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: 37285
diff changeset
4535 stream identifiers.
37060
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37054
diff changeset
4536
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4537 ``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: 37050
diff changeset
4538 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: 37050
diff changeset
4539 ``command-name``.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4540
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4541 ``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: 37285
diff changeset
4542 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: 37285
diff changeset
4543 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: 37285
diff changeset
4544 resolved to integers and then bitwise OR'd together.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37285
diff changeset
4545
37290
cc5a040fe150 wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
4546 ``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
4547 ``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
4548 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
4549 as a Python byte string literal.
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4550 """
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4551 opts = pycompat.byteskwargs(opts)
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4552
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4553 if opts[b'localssh'] and not repo:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4554 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
4555
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4556 if opts[b'peer'] and opts[b'peer'] not in (
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4557 b'raw',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4558 b'ssh1',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4559 ):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4560 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4561 _(b'invalid value for --peer'),
48561
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4562 hint=_(b'valid values are "raw" and "ssh1"'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4563 )
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4564
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4565 if path and opts[b'localssh']:
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43116
diff changeset
4566 raise error.Abort(_(b'cannot specify --localssh with an explicit path'))
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4567
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4568 if ui.interactive():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4569 ui.write(_(b'(waiting for commands on stdin)\n'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4570
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4571 blocks = list(_parsewirelangblocks(ui.fin))
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4572
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4573 proc = None
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4574 stdin = None
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4575 stdout = None
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4576 stderr = None
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4577 opener = None
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4578
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4579 if opts[b'localssh']:
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4580 # 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: 36556
diff changeset
4581 # separation. This prevents a whole class of potential bugs around
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4582 # shared state from interfering with server operation.
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37087
diff changeset
4583 args = procutil.hgcmd() + [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4584 b'-R',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4585 repo.root,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4586 b'debugserve',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4587 b'--sshstdio',
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4588 ]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4589 proc = subprocess.Popen(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4590 pycompat.rapply(procutil.tonativestr, args),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4591 stdin=subprocess.PIPE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4592 stdout=subprocess.PIPE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4593 stderr=subprocess.PIPE,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4594 bufsize=0,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4595 )
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4596
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4597 stdin = proc.stdin
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4598 stdout = proc.stdout
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4599 stderr = proc.stderr
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4600
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4601 # We turn the pipes into observers so we can log I/O.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4602 if ui.verbose or opts[b'peer'] == b'raw':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4603 stdin = util.makeloggingfileobject(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4604 ui, proc.stdin, b'i', logdata=True
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4605 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4606 stdout = util.makeloggingfileobject(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4607 ui, proc.stdout, b'o', logdata=True
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4608 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4609 stderr = util.makeloggingfileobject(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4610 ui, proc.stderr, b'e', logdata=True
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4611 )
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4612
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4613 # --localssh also implies the peer connection settings.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4614
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4615 url = b'ssh://localserver'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4616 autoreadstderr = not opts[b'noreadstderr']
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4617
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4618 if opts[b'peer'] == b'ssh1':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4619 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
4620 peer = sshpeer.sshv1peer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4621 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4622 url,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4623 proc,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4624 stdin,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4625 stdout,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4626 stderr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4627 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4628 autoreadstderr=autoreadstderr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4629 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4630 elif opts[b'peer'] == b'raw':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4631 ui.write(_(b'using raw connection to peer\n'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4632 peer = None
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4633 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4634 ui.write(_(b'creating ssh peer from handshake results\n'))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4635 peer = sshpeer.makepeer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4636 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4637 url,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4638 proc,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4639 stdin,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4640 stdout,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4641 stderr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4642 autoreadstderr=autoreadstderr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4643 )
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4644
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4645 elif path:
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4646 # We bypass hg.peer() so we can proxy the sockets.
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4647 # TODO consider not doing this because we skip
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4648 # ``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
4649 u = urlutil.url(path)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4650 if u.scheme != b'http':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4651 raise error.Abort(_(b'only http:// paths are currently supported'))
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4652
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4653 url, authinfo = u.authinfo()
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4654 openerargs = {
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4655 'useragent': b'Mercurial debugwireproto',
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4656 }
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4657
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4658 # 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: 37010
diff changeset
4659 if ui.verbose:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4660 openerargs.update(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4661 {
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4662 'loggingfh': ui,
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4663 'loggingname': b's',
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4664 'loggingopts': {
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4665 'logdata': True,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4666 'logdataapis': False,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45944
diff changeset
4667 },
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4668 }
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4669 )
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4670
37047
d3a9036d9ae9 util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37016
diff changeset
4671 if ui.debugflag:
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4672 openerargs['loggingopts']['logdataapis'] = True
37047
d3a9036d9ae9 util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37016
diff changeset
4673
37048
a708e1e4d7a8 url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37047
diff changeset
4674 # 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: 37047
diff changeset
4675 # 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: 37047
diff changeset
4676 # have near complete control over what's sent on the wire.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4677 if opts[b'peer'] == b'raw':
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4678 openerargs['sendaccept'] = False
37048
a708e1e4d7a8 url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37047
diff changeset
4679
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4680 opener = urlmod.opener(ui, authinfo, **openerargs)
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4681
48561
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4682 if opts[b'peer'] == b'raw':
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4683 ui.write(_(b'using raw connection to peer\n'))
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4684 peer = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4685 elif opts[b'peer']:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4686 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4687 _(b'--peer %s not supported with HTTP peers') % opts[b'peer']
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4688 )
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4689 else:
37553
6b08cf6b900f httppeer: allow opener to be passed to makepeer()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37552
diff changeset
4690 peer = httppeer.makepeer(ui, path, opener=opener)
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4691
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4692 # We /could/ populate stdin/stdout with sock.makefile()...
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4693 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4694 raise error.Abort(_(b'unsupported connection configuration'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4695
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4696 batchedcommands = None
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4697
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4698 # Now perform actions based on the parsed wire language instructions.
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4699 for action, lines in blocks:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4700 if action in (b'raw', b'raw+'):
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4701 if not stdin:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4702 raise error.Abort(_(b'cannot call raw/raw+ on this peer'))
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4703
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4704 # Concatenate the data together.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4705 data = b''.join(l.lstrip() for l in lines)
37087
f0b6fbea00cf stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 37060
diff changeset
4706 data = stringutil.unescapestr(data)
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4707 stdin.write(data)
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4708
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4709 if action == b'raw+':
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4710 stdin.flush()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4711 elif action == b'flush':
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4712 if not stdin:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4713 raise error.Abort(_(b'cannot call flush on this peer'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4714 stdin.flush()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4715 elif action.startswith(b'command'):
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4716 if not peer:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4717 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4718 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4719 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
4720 b'is available'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4721 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4722 )
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4723
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4724 command = action.split(b' ', 1)[1]
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4725
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4726 args = {}
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4727 for line in lines:
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4728 # 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
4729 fields = line.lstrip().split(b' ', 1)
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4730 if len(fields) == 1:
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4731 key = fields[0]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4732 value = b''
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4733 else:
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4734 key, value = fields
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4735
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4736 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
4737 value = stringutil.evalpythonliteral(value[5:])
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4738 else:
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4739 value = stringutil.unescapestr(value)
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4740
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37396
diff changeset
4741 args[key] = value
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4742
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4743 if batchedcommands is not None:
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4744 batchedcommands.append((command, args))
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4745 continue
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4746
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4747 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
4748
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4749 if b'PUSHFILE' in args:
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4750 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
4751 del args[b'PUSHFILE']
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4752 res, output = peer._callpush(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4753 command, fh, **pycompat.strkwargs(args)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4754 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4755 ui.status(_(b'result: %s\n') % stringutil.escapestr(res))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4756 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4757 _(b'remote output: %s\n') % stringutil.escapestr(output)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4758 )
36563
5faeabb07cf5 debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36560
diff changeset
4759 else:
37652
fe8c6f9f2914 debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37647
diff changeset
4760 with peer.commandexecutor() as e:
fe8c6f9f2914 debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37647
diff changeset
4761 res = e.callcommand(command, args).result()
fe8c6f9f2914 debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37647
diff changeset
4762
48561
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4763 ui.status(
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4764 _(b'response: %s\n')
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4765 % stringutil.pprint(res, bprefix=True, indent=2)
04688c51f81f exchangev2: remove it
Raphaël Gomès <rgomes@octobus.net>
parents: 48199
diff changeset
4766 )
36559
bde0bd50f368 debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36557
diff changeset
4767
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4768 elif action == b'batchbegin':
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4769 if batchedcommands is not None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4770 raise error.Abort(_(b'nested batchbegin not allowed'))
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4771
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4772 batchedcommands = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4773 elif action == b'batchsubmit':
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4774 # 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: 36559
diff changeset
4775 # difficult to normalize requests into function calls. It is easier
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4776 # to bypass this layer and normalize to commands + args.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4777 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4778 _(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
4779 % len(batchedcommands)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4780 )
43744
23ad4f0c1578 debugcommands: add assertions to convince pytype peer is not None
Augie Fackler <augie@google.com>
parents: 43743
diff changeset
4781 assert peer is not None
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4782 for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4783 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4784 _(b'response #%d: %s\n') % (i, stringutil.escapestr(chunk))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4785 )
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4786
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4787 batchedcommands = None
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4788
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4789 elif action.startswith(b'httprequest '):
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4790 if not opener:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4791 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
4792 _(b'cannot use httprequest without an HTTP peer')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4793 )
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4794
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4795 request = action.split(b' ', 2)
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4796 if len(request) != 3:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4797 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4798 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4799 b'invalid httprequest: expected format is '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4800 b'"httprequest <method> <path>'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4801 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4802 )
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4803
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4804 method, httppath = request[1:]
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4805 headers = {}
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4806 body = None
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4807 frames = []
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4808 for line in lines:
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4809 line = line.lstrip()
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4810 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line)
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4811 if m:
39956
c421c22d3ad2 py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39889
diff changeset
4812 # Headers need to use native strings.
c421c22d3ad2 py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39889
diff changeset
4813 key = pycompat.strurl(m.group(1))
c421c22d3ad2 py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39889
diff changeset
4814 value = pycompat.strurl(m.group(2))
c421c22d3ad2 py3: convert HTTP request headers to str
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39889
diff changeset
4815 headers[key] = value
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4816 continue
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4817
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4818 if line.startswith(b'BODYFILE '):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4819 with open(line.split(b' ', 1), b'rb') as fh:
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4820 body = fh.read()
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4821 elif line.startswith(b'frame '):
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4822 frame = wireprotoframing.makeframefromhumanstring(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4823 line[len(b'frame ') :]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4824 )
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4825
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4826 frames.append(frame)
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4827 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4828 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4829 _(b'unknown argument to httprequest: %s') % line
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4830 )
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4831
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4832 url = path + httppath
37054
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4833
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4834 if frames:
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
4835 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: 37050
diff changeset
4836
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4837 req = urlmod.urlreq.request(pycompat.strurl(url), body, headers)
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4838
37050
fddcb51b5084 wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37048
diff changeset
4839 # 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: 37048
diff changeset
4840 # 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: 37048
diff changeset
4841 # explicitly requested method.
39101
a2fa7247ca70 debugcommands: get_method should always return a sysstr
Augie Fackler <augie@google.com>
parents: 39099
diff changeset
4842 req.get_method = lambda: pycompat.sysstr(method)
37050
fddcb51b5084 wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37048
diff changeset
4843
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4844 try:
37557
734515aca84d wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37553
diff changeset
4845 res = opener.open(req)
734515aca84d wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37553
diff changeset
4846 body = res.read()
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4847 except util.urlerr.urlerror as e:
39102
730e7d92a023 debugcommands: urlerror only has a read() method in Python 2
Augie Fackler <augie@google.com>
parents: 39101
diff changeset
4848 # 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: 39101
diff changeset
4849 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
4850 continue
734515aca84d wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37553
diff changeset
4851
43554
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4852 ct = res.headers.get('Content-Type')
9f70512ae2cf cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents: 43551
diff changeset
4853 if ct == 'application/mercurial-cbor':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4854 ui.write(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4855 _(b'cbor> %s\n')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4856 % stringutil.pprint(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4857 cborutil.decodeall(body), bprefix=True, indent=2
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4858 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43067
diff changeset
4859 )
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
4860
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4861 elif action == b'close':
43744
23ad4f0c1578 debugcommands: add assertions to convince pytype peer is not None
Augie Fackler <augie@google.com>
parents: 43743
diff changeset
4862 assert peer is not None
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4863 peer.close()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4864 elif action == b'readavailable':
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4865 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
4866 raise error.Abort(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4867 _(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
4868 )
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4869
36851
31581528f242 debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents: 36843
diff changeset
4870 stdin.close()
31581528f242 debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents: 36843
diff changeset
4871 stdout.read()
31581528f242 debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents: 36843
diff changeset
4872 stderr.read()
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4873
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4874 elif action == b'readline':
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4875 if not stdout:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4876 raise error.Abort(_(b'readline not available on this peer'))
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4877 stdout.readline()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4878 elif action == b'ereadline':
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4879 if not stderr:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4880 raise error.Abort(_(b'ereadline not available on this peer'))
37010
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4881 stderr.readline()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4882 elif action.startswith(b'read '):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4883 count = int(action.split(b' ', 1)[1])
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4884 if not stdout:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4885 raise error.Abort(_(b'read not available on this peer'))
37010
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4886 stdout.read(count)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4887 elif action.startswith(b'eread '):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4888 count = int(action.split(b' ', 1)[1])
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37010
diff changeset
4889 if not stderr:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4890 raise error.Abort(_(b'eread not available on this peer'))
37010
143219fc2620 debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36991
diff changeset
4891 stderr.read(count)
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4892 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4893 raise error.Abort(_(b'unknown action: %s') % action)
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4894
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4895 if batchedcommands is not None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
4896 raise error.Abort(_(b'unclosed "batchbegin" request'))
36560
097ad1079192 debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36559
diff changeset
4897
36557
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4898 if peer:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4899 peer.close()
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4900
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4901 if proc:
72e487851a53 debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36556
diff changeset
4902 proc.kill()